many changes

This commit is contained in:
Piyush मिश्रः 2021-02-18 10:57:54 +05:30
parent 3d34871ebd
commit 18afc8bad7
17 changed files with 1010 additions and 100 deletions

View File

@ -21,12 +21,11 @@ pub struct Grih {
loog: Vec<Addr<ws_sansad::WsSansad>>
}
#[derive(Clone)]
#[derive(Debug, Clone)]
pub struct Vyakti {
name: String,
tags: Vec<String>
}
pub struct VyaktiWatchlist {
kunjika: String,
addr: Addr<ws_sansad::WsSansad>
@ -145,16 +144,33 @@ impl Handler<ms::JoinRandom> for ChatPinnd {
}
}
/// send text to exryone
/// send text to everyone
impl Handler<ms::SendText> for ChatPinnd {
type Result = ();
fn handle(&mut self, msg: ms::SendText, _: &mut Self::Context) -> Self::Result {
if let Some(grih) = self.grih.get(&msg.grih_kunjika) {
grih.loog.iter().for_each(|c| {
c.do_send(ms::WsMessage {
sender: msg.kunjika.clone(),
c.do_send(ms::WsText {
sender_kunjika: msg.kunjika.clone(),
text: msg.text.clone(),
reply: msg.reply.clone()
});
});
}
}
}
/// send status to everyone
impl Handler<ms::SendStatus> for ChatPinnd {
type Result = ();
fn handle(&mut self, msg: ms::SendStatus, _: &mut Self::Context) -> Self::Result {
if let Some(grih) = self.grih.get(&msg.grih_kunjika) {
grih.loog.iter().for_each(|c| {
c.do_send(ms::WsStatus {
sender_kunjika: msg.kunjika.clone(),
status: msg.status.clone(),
});
});
}
@ -166,13 +182,14 @@ impl Handler<ms::LeaveUser> for ChatPinnd {
type Result = ();
fn handle(&mut self, msg: ms::LeaveUser, _: &mut Self::Context) -> Self::Result {
if let Some(grih) = self.grih.get_mut(&msg.grih_kunjika) {
if let Some(grih_kunjika) = &msg.grih_kunjika {
if let Some(grih) = self.grih.get_mut(grih_kunjika) {
if let Some(i) = grih.loog.iter().position(|x| x == &msg.addr) {
grih.loog.remove(i);
}
if grih.loog.len() == 0 {
self.grih.remove(&msg.grih_kunjika);
self.grih.remove(grih_kunjika);
} else {
grih.loog.iter().for_each(|a| {
a.do_send(ms::WsDisconnected {
@ -182,6 +199,12 @@ impl Handler<ms::LeaveUser> for ChatPinnd {
}
}
}
self.vyakti.remove(&msg.kunjika).unwrap_or(());
if let Some(i) = self.vyaktigat_waitlist.iter().position(|a| a.kunjika == msg.kunjika) {
self.vyaktigat_waitlist.remove(i);
}
}
}
impl Default for ChatPinnd {

View File

@ -39,14 +39,24 @@ pub struct JoinRandom {
pub struct SendText {
pub grih_kunjika: String,
pub kunjika: String,
pub text: String
pub text: String,
pub reply: Option<String>,
}
// Request to send text t
#[derive(Clone, Message)]
#[rtype(result = "()")]
pub struct SendStatus {
pub grih_kunjika: String,
pub kunjika: String,
pub status: String
}
/// Request to leave grih
#[derive(Clone, Message)]
#[rtype(result = "()")]
pub struct LeaveUser {
pub grih_kunjika: String,
pub grih_kunjika: Option<String>,
pub kunjika: String,
pub addr: Addr<WsSansad>
}
@ -55,11 +65,21 @@ pub struct LeaveUser {
// Request to send transfer text
#[derive(Clone, Message)]
#[rtype(result = "()")]
pub struct WsMessage {
pub struct WsText {
pub text: String,
pub sender: String
pub reply: Option<String>,
pub sender_kunjika: String
}
// Request to send transfer text
#[derive(Clone, Message)]
#[rtype(result = "()")]
pub struct WsStatus {
pub status: String,
pub sender_kunjika: String
}
// Notify Someone connected
#[derive(Clone, Message)]
#[rtype(result = "()")]

View File

@ -50,13 +50,28 @@ impl StreamHandler<Result<ws::Message, ws::ProtocolError>> for WsSansad {
}
/// send text message
impl Handler<ms::WsMessage> for WsSansad {
impl Handler<ms::WsText> for WsSansad {
type Result = ();
fn handle(&mut self, msg: ms::WsMessage, ctx: &mut Self::Context) -> Self::Result {
fn handle(&mut self, msg: ms::WsText, ctx: &mut Self::Context) -> Self::Result {
let json = json!({
"cmd": "text",
"text": msg.text,
"kunjika": msg.sender // Sender's kunjuka
"reply": msg.reply,
"kunjika": msg.sender_kunjika // Sender's kunjuka
});
ctx.text(json.to_string());
}
}
/// send text status
impl Handler<ms::WsStatus> for WsSansad {
type Result = ();
fn handle(&mut self, msg: ms::WsStatus, ctx: &mut Self::Context) -> Self::Result {
let json = json!({
"cmd": "text",
"status": msg.status,
"kunjika": msg.sender_kunjika // Sender's kunjuka
});
ctx.text(json.to_string());
}
@ -130,6 +145,7 @@ impl WsSansad {
"join" => { self.join_grih(val).await },
"rand" => { self.join_random().await },
"text" => { self.send_text(val).await },
"status" => { self.send_status(val).await },
"leave" => { self.leave_grih().await },
_ => ()
}
@ -137,10 +153,10 @@ impl WsSansad {
}
/// send ok response
fn send_ok_response(&self) {
fn send_ok_response(&self, text: &str) {
self.addr.clone().unwrap().do_send(ms::WsResponse {
result: "Ok".to_owned(),
message: "".to_owned()
message: text.to_owned()
});
}
@ -178,8 +194,7 @@ impl WsSansad {
v
},
None => {
self.send_err_response("Invalid request");
return;
Vec::new()
}
};
@ -200,7 +215,7 @@ impl WsSansad {
}
self.kunjika = Some(kunjika);
self.send_ok_response();
self.send_ok_response("info changed");
}
/// Request for joining to random person
@ -213,10 +228,7 @@ impl WsSansad {
// is vayakti in watch list
if let Isthiti::VraktigatWaitlist = self.isthiti {
self.addr.clone().unwrap().do_send(ms::WsResponse {
result: "Ok".to_owned(),
message: "watchlist".to_owned()
});
self.send_ok_response("watchlist");
return;
}
@ -227,10 +239,7 @@ impl WsSansad {
}).await.unwrap();
if let None = result {
self.addr.clone().unwrap().do_send(ms::WsResponse {
result: "Ok".to_owned(),
message: "watchlist".to_owned()
});
self.send_ok_response("watchlist");
self.isthiti = Isthiti::VraktigatWaitlist;
}
}
@ -243,8 +252,15 @@ impl WsSansad {
return;
}
match self.isthiti {
Isthiti::None => (),
_ => {
return;
}
}
// parse parameter
let grih_kunjika = match val.get("kunjika") {
let grih_kunjika = match val.get("grih_kunjika") {
Some(val) => val,
None => {
self.send_err_response("Invalid request");
@ -274,7 +290,7 @@ impl WsSansad {
match result {
Ok(_) => {
self.isthiti = Isthiti::Grih(grih_kunjika);
self.send_ok_response()
self.send_ok_response("joined")
},
Err(e) => self.send_err_response(&format!("{}", e))
}
@ -305,6 +321,12 @@ impl WsSansad {
return;
}
}.as_str().unwrap().to_owned();
let reply: Option<String> = match val.get("reply") {
Some(val) => Some(val.as_str().unwrap().to_owned()),
None => None
};
let grih_kunjika = match &self.isthiti {
Isthiti::Grih(g) => {
g.clone()
@ -315,20 +337,66 @@ impl WsSansad {
Broker::<SystemBroker>::issue_async(ms::SendText {
grih_kunjika,
kunjika: self.kunjika.clone().unwrap(),
text
text,
reply
});
}
/// send status to vayakti in grih
async fn send_status(&mut self, val: Value) {
// check if vayakti exist
if let None = self.kunjika {
self.send_err_response("No vayakti kunjika set");
return;
}
// check if connected to any grih
match self.isthiti {
Isthiti::Grih(_) => (),
_ => {
self.send_err_response("Grih not connected");
return;
}
}
// sent status
let status = match val.get("status") {
Some(val) => val,
None => {
self.send_err_response("Invalid request");
return;
}
}.as_str().unwrap().to_owned();
let grih_kunjika = match &self.isthiti {
Isthiti::Grih(g) => {
g.clone()
}, _ => {
return;
}
};
Broker::<SystemBroker>::issue_async(ms::SendStatus {
grih_kunjika,
kunjika: self.kunjika.clone().unwrap(),
status
});
}
// notify leaving
async fn leave_grih(&mut self) {
if let Isthiti::Grih(val) = &mut self.isthiti {
let grih_kunjika = match &self.isthiti {
Isthiti::Grih(val) => Some(val.to_owned()),
_ => None
};
if let Some(ku) = &self.kunjika {
Broker::<SystemBroker>::issue_async(ms::LeaveUser {
grih_kunjika: val.clone(),
kunjika: self.kunjika.clone().unwrap(),
grih_kunjika,
kunjika:
ku.to_owned(),
addr: self.addr.clone().unwrap()
});
}
self.send_ok_response();
}
self.send_ok_response("left");
}
}

File diff suppressed because one or more lines are too long

8
static/css/siimple.min.css vendored Normal file

File diff suppressed because one or more lines are too long

112
static/css/style.css Normal file
View File

@ -0,0 +1,112 @@
pre {
font-family: Arial, Helvetica, sans-serif;
margin-top: 0;
margin-bottom: 0;
}
.hidden {
display: none;
}
.siimple-progress.progress-bar {
height: 10px !important;
position: fixed;
top: 0; left: 0; right: 0;
}
.cover-screen {
position: fixed;
top: 0; bottom: 0; left: 0; right: 0;
z-index: 999;
}
.chatpanel {
display: flex;
justify-content: center;
width: 100%;
height: 44px;
}
.chatpanel-left {
display: inline;
width: 34px;
}
.chatpanel-mid {
display: inline;
width: calc(100% - 54px - 34px);
}
.chatpanel-right {
display: inline;
width: 44px;
}
.message {
padding: 0px 8px 5px 8px;
margin: 2px;
word-wrap: break-word;;
}
.message-other {
border-left: 5px solid #1E86D7;
background-color: #95C1E2;
}
.message-me {
border-left: 5px solid #2F848D;
background-color: #99C5C9;
}
.message-reply {
border-left: 5px solid #383C4A;
background-color: #DEDEDE;
}
.message .message-by {
font-size: 0.9rem;
font-style: italic;
text-decoration: underline;
padding-bottom: 2px;
}
.message-me.active {
border: 2px dashed #11603F;
border-left: 5px solid #11603F;
}
.message-other.active {
border: 2px dashed #104975;
border-left: 5px solid #104975;
}
.clip-win {
position: fixed;
z-index: 9999;
padding: 8px;
margin: 5px;
bottom: 44px;
border: 1px dashed #1E86D7;
}
.clip-win.reply-clip {
width: calc(100% - 2*8px - 3*5px);
max-width: 720px;
height: 1.5em;
border-left: 5px solid #1E86D7;
border-radius: 0px 30px 30px 0px;
}
.clip-win.selected-clip {
width: fit-content;
height: 34px;
left: 50%;
transform: translateX(-50%);
border-radius: 15px;
}
.clip-win.action-clip {
border-radius: 10px;
width: calc(100% - 2*8px - 3*5px);
max-width: 720px;
}

49
static/img/clip.svg Normal file
View File

@ -0,0 +1,49 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- Generator: Adobe Illustrator 19.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 512.002 512.002" style="enable-background:new 0 0 512.002 512.002;" xml:space="preserve">
<rect x="7.098" y="151.896" style="fill:#36A9E1;" width="40.768" height="360.106"/>
<rect x="47.11" y="119.882" style="fill:#A5C6E3;" width="40.768" height="392.12"/>
<rect x="87.12" y="87.873" style="fill:#1D71B8;" width="424.124" height="424.124"/>
<g>
<polygon style="fill:#1D1D1B;" points="95.728,512 80.029,512 80.029,80.024 319.947,80.024 319.947,95.722 95.728,95.722 "/>
<rect x="351.195" y="80.029" style="fill:#1D1D1B;" width="160.802" height="15.698"/>
<polygon style="fill:#1D1D1B;" points="55.715,512 40.017,512 40.017,112.034 71.874,112.034 71.874,127.732 55.715,127.732 "/>
<polygon style="fill:#1D1D1B;" points="15.703,512 0.005,512 0.005,144.044 31.861,144.044 31.861,159.742 15.703,159.742 "/>
</g>
<polygon style="fill:#FFFFFF;" points="263.02,359.953 247.129,348.75 247.322,119.883 263.02,119.883 "/>
<path style="fill:#1D1D1B;" d="M291.938,383.807c-28.597,0-51.863-23.265-51.863-51.863V119.883h15.698v212.063
c0,19.941,16.224,36.164,36.164,36.164s36.164-16.224,36.164-36.164V67.868c0-28.765-23.403-52.169-52.169-52.169
c-28.765,0-52.169,23.403-52.169,52.169v4.001h-15.698v-4.001C208.067,30.445,238.511,0,275.934,0s67.868,30.445,67.868,67.868
v264.078C343.801,360.543,320.535,383.807,291.938,383.807z"/>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.8 KiB

55
static/img/image.svg Normal file
View File

@ -0,0 +1,55 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- Generator: Adobe Illustrator 19.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 483.2 483.2" style="enable-background:new 0 0 483.2 483.2;" xml:space="preserve">
<polygon style="fill:#FFFFFF;" points="33.6,0 33.6,352 163.2,480 449.6,480 449.6,0 "/>
<polyline style="fill:#E9F4F3;" points="449.6,480 449.6,0 33.6,0 "/>
<polyline style="fill:#D4E8E5;" points="449.6,224 449.6,0 33.6,0 "/>
<polygon style="fill:#D6E5E3;" points="289.6,480.8 161.6,352 161.6,480 289.6,480 "/>
<polygon style="fill:#8AC4BD;" points="33.6,352 161.6,483.2 161.6,352 "/>
<polygon style="fill:#67A59C;" points="82.4,402.4 161.6,483.2 161.6,352 95.2,413.6 "/>
<polygon style="fill:#1589AD;" points="384.8,336.8 303.2,343.2 222.4,336.8 303.2,176.8 "/>
<polyline style="fill:#035670;" points="303.2,176.8 384.8,336.8 303.2,343.2 "/>
<polygon style="fill:#1EA4C4;" points="303.2,314.4 349.6,268 324,216.8 303.2,196 283.2,216.8 256.8,268 "/>
<polyline style="fill:#066B93;" points="303.2,314.4 349.6,268 324,216.8 303.2,196 "/>
<polygon style="fill:#1589AD;" points="338.4,332.8 218.4,343.2 98.4,332.8 218.4,97.6 "/>
<polyline style="fill:#057091;" points="218.4,97.6 338.4,332.8 218.4,343.2 "/>
<polygon style="fill:#1EA4C4;" points="218.4,300.8 286.4,232.8 248,156.8 218.4,126.4 188.8,156.8 149.6,232.8 "/>
<polyline style="fill:#1290AD;" points="218.4,300.8 286.4,232.8 248,156.8 218.4,126.4 "/>
<polygon style="fill:#9ADFEF;" points="237.6,214.4 257.6,234.4 277.6,214.4 218.4,97.6 159.2,214.4 179.2,234.4 199.2,214.4
218.4,234.4 "/>
<polyline style="fill:#7DD4E2;" points="218.4,234.4 237.6,214.4 257.6,234.4 277.6,214.4 218.4,97.6 "/>
<rect x="97.6" y="328" style="fill:#057091;" width="288" height="16"/>
<circle style="fill:#F98D2B;" cx="349.6" cy="136" r="37.6"/>
<path style="fill:#DD6E12;" d="M376.8,108.8c14.4,14.4,14.4,38.4,0,53.6s-38.4,14.4-53.6,0"/>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
<g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.2 KiB

104
static/img/label-l.svg Normal file
View File

@ -0,0 +1,104 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="710"
height="260"
viewBox="0 0 710 260.00001"
version="1.1"
id="svg8"
inkscape:version="1.0.2 (e86c870879, 2021-01-15)"
sodipodi:docname="label-l.svg">
<defs
id="defs2" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="0.98994949"
inkscape:cx="641.86295"
inkscape:cy="202.32654"
inkscape:document-units="px"
inkscape:current-layer="layer1"
inkscape:document-rotation="0"
showgrid="false"
units="px"
inkscape:window-width="1496"
inkscape:window-height="1026"
inkscape:window-x="128"
inkscape:window-y="27"
inkscape:window-maximized="0" />
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:96px;line-height:1.25;font-family:sans-serif;fill:#d7f4ee;fill-opacity:1;stroke:none;"
x="268.32236"
y="211.30991"
id="text52"><tspan
sodipodi:role="line"
id="tspan50"
x="268.32236"
y="211.30991"
style="font-size:96px;fill:#d7f4ee;">Lupt Chat </tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:96px;line-height:1.25;font-family:sans-serif;fill:#aaccff;fill-opacity:1;stroke:none;"
x="281.27032"
y="102.09531"
id="text56"><tspan
sodipodi:role="line"
id="tspan54"
x="281.27032"
y="102.09531">लुप्त चैट</tspan></text>
<g
style="fill:#5fd3bc"
id="g49"
transform="matrix(-12.364986,0,0,12.637333,279.67091,-13.563207)">
<path
d="M 8,9.50004 C 7.30964,9.50004 6.75,10.0597 6.75,10.75 6.75,11.4404 7.30964,12 8,12 8.69036,12 9.25,11.4404 9.25,10.75 9.25,10.0597 8.69036,9.50004 8,9.50004 Z"
fill="#000000"
id="path29"
style="fill:#5fd3bc" />
<path
d="m 12,9.50004 c -0.6904,0 -1.25,0.55966 -1.25,1.24996 0,0.6904 0.5596,1.25 1.25,1.25 0.6904,0 1.25,-0.5596 1.25,-1.25 0,-0.6903 -0.5596,-1.24996 -1.25,-1.24996 z"
fill="#000000"
id="path31"
style="fill:#5fd3bc" />
<path
d="m 14.75,10.75 c 0,-0.6903 0.5596,-1.24996 1.25,-1.24996 0.6904,0 1.25,0.55966 1.25,1.24996 0,0.6904 -0.5596,1.25 -1.25,1.25 -0.6904,0 -1.25,-0.5596 -1.25,-1.25 z"
fill="#000000"
id="path33"
style="fill:#5fd3bc" />
<path
fill-rule="evenodd"
clip-rule="evenodd"
d="M 16.1007,4.59283 C 13.4065,4.36307 10.6983,4.34974 8.00194,4.55296 L 7.80871,4.56752 C 5.23741,4.76132 3.25,6.90415 3.25,9.48275 V 18 c 0,0.2639 0.13867,0.5084 0.36515,0.6438 0.22648,0.1354 0.50746,0.1418 0.73989,0.0169 L 8.26583,16.559 C 8.44774,16.4612 8.65104,16.41 8.85756,16.41 H 17.834 c 1.1321,0 2.1022,-0.8094 2.3052,-1.9231 0.4113,-2.2572 0.4437,-4.5672 0.0961,-6.83511 L 20.1329,6.98346 C 19.9464,5.76671 18.951,4.8359 17.7245,4.7313 Z M 8.11468,6.04871 C 10.731,5.85152 13.359,5.86446 15.9733,6.0874 l 1.6237,0.13848 c 0.5364,0.04574 0.9716,0.45277 1.0532,0.98485 l 0.1024,0.66833 C 19.075,9.98234 19.0449,12.1246 18.6635,14.218 18.5904,14.6188 18.2413,14.91 17.834,14.91 H 8.85756 c -0.45434,0 -0.9016,0.1126 -1.30181,0.3277 L 4.75,16.7455 V 9.48275 C 4.75,7.68884 6.13262,6.1981 7.92144,6.06328 Z"
fill="#000000"
id="path35"
style="fill:#5fd3bc" />
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 4.2 KiB

104
static/img/label.svg Normal file
View File

@ -0,0 +1,104 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="710"
height="260"
viewBox="0 0 710 260.00001"
version="1.1"
id="svg8"
inkscape:version="1.0.2 (e86c870879, 2021-01-15)"
sodipodi:docname="label.svg">
<defs
id="defs2" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="0.7"
inkscape:cx="411.10748"
inkscape:cy="261.91995"
inkscape:document-units="px"
inkscape:current-layer="layer1"
inkscape:document-rotation="0"
showgrid="false"
units="px"
inkscape:window-width="1496"
inkscape:window-height="1026"
inkscape:window-x="128"
inkscape:window-y="27"
inkscape:window-maximized="0" />
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:96px;line-height:1.25;font-family:sans-serif;fill:#217867;fill-opacity:1;stroke:none"
x="268.32236"
y="211.30991"
id="text52"><tspan
sodipodi:role="line"
id="tspan50"
x="268.32236"
y="211.30991"
style="font-size:96px;fill:#217867">Lupt Chat </tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:96px;line-height:1.25;font-family:sans-serif;fill:#535d6c;fill-opacity:1;stroke:none;"
x="281.27032"
y="102.09531"
id="text56"><tspan
sodipodi:role="line"
id="tspan54"
x="281.27032"
y="102.09531">लुप्त चैट</tspan></text>
<g
style="fill:#d45500"
id="g49"
transform="matrix(-12.364986,0,0,12.637333,279.67091,-13.563207)">
<path
d="M 8,9.50004 C 7.30964,9.50004 6.75,10.0597 6.75,10.75 6.75,11.4404 7.30964,12 8,12 8.69036,12 9.25,11.4404 9.25,10.75 9.25,10.0597 8.69036,9.50004 8,9.50004 Z"
fill="#000000"
id="path29"
style="fill:#d45500" />
<path
d="m 12,9.50004 c -0.6904,0 -1.25,0.55966 -1.25,1.24996 0,0.6904 0.5596,1.25 1.25,1.25 0.6904,0 1.25,-0.5596 1.25,-1.25 0,-0.6903 -0.5596,-1.24996 -1.25,-1.24996 z"
fill="#000000"
id="path31"
style="fill:#d45500" />
<path
d="m 14.75,10.75 c 0,-0.6903 0.5596,-1.24996 1.25,-1.24996 0.6904,0 1.25,0.55966 1.25,1.24996 0,0.6904 -0.5596,1.25 -1.25,1.25 -0.6904,0 -1.25,-0.5596 -1.25,-1.25 z"
fill="#000000"
id="path33"
style="fill:#d45500" />
<path
fill-rule="evenodd"
clip-rule="evenodd"
d="M 16.1007,4.59283 C 13.4065,4.36307 10.6983,4.34974 8.00194,4.55296 L 7.80871,4.56752 C 5.23741,4.76132 3.25,6.90415 3.25,9.48275 V 18 c 0,0.2639 0.13867,0.5084 0.36515,0.6438 0.22648,0.1354 0.50746,0.1418 0.73989,0.0169 L 8.26583,16.559 C 8.44774,16.4612 8.65104,16.41 8.85756,16.41 H 17.834 c 1.1321,0 2.1022,-0.8094 2.3052,-1.9231 0.4113,-2.2572 0.4437,-4.5672 0.0961,-6.83511 L 20.1329,6.98346 C 19.9464,5.76671 18.951,4.8359 17.7245,4.7313 Z M 8.11468,6.04871 C 10.731,5.85152 13.359,5.86446 15.9733,6.0874 l 1.6237,0.13848 c 0.5364,0.04574 0.9716,0.45277 1.0532,0.98485 l 0.1024,0.66833 C 19.075,9.98234 19.0449,12.1246 18.6635,14.218 18.5904,14.6188 18.2413,14.91 17.834,14.91 H 8.85756 c -0.45434,0 -0.9016,0.1126 -1.30181,0.3277 L 4.75,16.7455 V 9.48275 C 4.75,7.68884 6.13262,6.1981 7.92144,6.06328 Z"
fill="#000000"
id="path35"
style="fill:#d45500" />
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 4.2 KiB

56
static/img/send.svg Normal file
View File

@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="24px"
height="24px"
viewBox="0 0 24 24"
fill="none"
version="1.1"
id="svg4"
sodipodi:docname="send2.svg"
inkscape:version="1.0.2 (e86c870879, 2021-01-15)">
<metadata
id="metadata10">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs8" />
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1135"
inkscape:window-height="810"
id="namedview6"
showgrid="false"
inkscape:zoom="17.479167"
inkscape:cx="10.309773"
inkscape:cy="11.868146"
inkscape:window-x="0"
inkscape:window-y="27"
inkscape:window-maximized="0"
inkscape:current-layer="svg4" />
<path
d="M 7.7577801,6.14799 C 6.84443,5.77187 6.0833001,5.45843 5.49196,5.30702 4.91915,5.16036 4.18085,5.07761 3.63766,5.62862 3.09447,6.17962 3.18776,6.91666 3.34259,7.48732 3.50242,8.0764399 3.8267,8.83302 4.21583,9.7409 L 4.86259,11.25 H 10 c 0.4142,0 0.75,0.3358 0.75,0.75 0,0.4142 -0.3358,0.75 -0.75,0.75 H 4.8626 l -0.64677,1.5091 c -0.38913,0.9079 -0.71341,1.6645 -0.87324,2.2536 -0.15483,0.5706 -0.24812,1.3077 0.29507,1.8587 0.54319,0.551 1.28149,0.4682 1.8543,0.3216 0.5913401,-0.1514 1.35247,-0.4649 2.2658102,-0.841 L 19.1997,13.1406 c 0.2056,-0.0845 0.4282,-0.1761 0.5944,-0.2736 0.1499,-0.088 0.5493,-0.3478 0.5493,-0.867 0,-0.5192 -0.3994,-0.779 -0.5493,-0.867 -0.1662,-0.0975 -0.3888,-0.1891 -0.5944,-0.2736 z"
fill="black"
id="path2"
style="fill:#f9f9f9;stroke-width:1" />
</svg>

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

@ -4,63 +4,140 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="shortcut icon" href="#">
<title>Document</title>
<link rel="stylesheet" href="css/siimple.min.css">
<link rel="stylesheet" href="css/style.css">
<title>Lupt Chat</title>
</head>
<body>
<script>
// Create WebSocket connection.
const socket = new WebSocket('ws://localhost:8080/ws/');
<div id="progressbar" class="siimple-progress siimple-progress--primary siimple-progress--striped progress-bar">
<span style="width:100%;"></span>
</div>
// Connection opened
socket.addEventListener('open', function (event) {
socket.send('Hello Server!');
});
<!-- Connect Screen -->
<div class="siimple-content siimple-content--extra-small">
<div class="siimple--px-5 siimple--py-5">
<tabs>
<div class="siimple-jumbotron siimple--text-center siimple--py-4">
<div class="siimple-jumbotron-title"><img src="img/label.svg" alt="Lupt Chat" style="width: 100%; height: auto;"></div>
<div class="siimple-jumbotron-detail">Chat in group or to strangers</div>
</div>
<div class="siimple-tabs">
<div for="grih_sec" class="siimple-tabs-item siimple-tabs-tab--selected">Grih</div>
<div for="stranger_sec" class="siimple-tabs-item">Stranger</div>
</div>
// Listen for messages
socket.addEventListener('message', function (event) {
console.log('Message from server ', event.data);
});
<form name="grih_sec" cmd="join" class="siimple-form">
<div class="siimple-form-detail">Connect Grih(group) with kunjika.</div>
<div class="siimple-form-field">
<div class="siimple-form-field-label">Grih kunjika</div>
<input name="grih_kunjika" type="text" class="siimple-input siimple-input--fluid" placeholder="Grih kunjika">
</div>
<div class="siimple-form-field">
<div class="siimple-form-field-label">Your kunjika</div>
<input name="kunjika" type="text" class="siimple-input siimple-input--fluid" placeholder="Your kunjika">
</div>
<div class="siimple-form-field">
<div class="siimple-form-field-label">Your name</div>
<input name="name" type="text" class="siimple-input siimple-input--fluid" placeholder="Your name">
</div>
<div class="siimple-form-field siimple--float-right">
<div id="grih_connect" class="siimple-btn siimple-btn--success" onclick="connect($(this).parents('form').first())">Connect</div>
</div>
</form>
function wsend(p) {
socket.send(p);
}
<form name="stranger_sec" cmd="rand" class="siimple-form hidden">
<div class="siimple-form-detail">Connect random stranger</div>
<div class="siimple-form-field">
<div class="siimple-form-field-label">Your kunjika</div>
<input name="kunjika" type="text" class="siimple-input siimple-input--fluid" placeholder="Your kunjika">
</div>
<div class="siimple-form-field">
<div class="siimple-form-field-label">Your name</div>
<input name="name" type="text" class="siimple-input siimple-input--fluid" placeholder="Your name">
</div>
<div class="siimple-form-field">
<div class="siimple-form-field-label">Tags</div>
<input name="tags" type="text" class="siimple-input siimple-input--fluid" placeholder="Tags">
<div class="siimple-form-field-helper">Seperated by space</div>
</div>
<div class="siimple-form-field siimple--float-right">
<div id="str_connect" class="siimple-btn siimple-btn--success" onclick="connect($(this).parents('form').first())">Connect</div>
</div>
</form>
</tabs>
</div>
</div>
function join(r, l) {
socket.send(JSON.stringify({
cmd: "join",
kunjika: r,
length: l
}));
}
<!-- Chat Screen -->
<div id="chat_panel" class="cover-screen siimple--bg-white hidden">
<div class="siimple-navbar siimple--py-1 siimple-navbar--dark">
<div class="siimple--float-left">
<a onclick="leave()" class="siimple-navbar-item">&leftarrow; Back</a>
</div>
<a class="siimple-navbar-title"><img src="img/label-l.svg" alt="Lupt Chat" height="34px"></a>
<div class="siimple--float-right">
<a class="siimple-navbar-item">Next &rightarrow;</a>
</div>
</div>
<div style="height: calc(100% - 2*44px - 2*5px); padding: 5px; overflow-y: scroll;" class="siimple--bg-light">
<div id="message_area" class="siimple--my-1">
<div class="message message-other">
<div class="message-by">Ram_1_5</div>
<pre>huh</pre>
</div>
<div class="message message-other">
<div class="message-by">Ram_1_5</div>
<pre>haha</pre>
</div>
<div class="message message-me">
<div class="message-by">you</div>
<pre>ya</pre>
</div>
</div>
</div>
<div class="siimple--bg-light chatpanel">
<div class="chatpanel-left siimple--mx-1 siimple--my-1">
<div onclick="$('#action_clip').toggleClass('hidden')" class="siimple-btn siimple-btn--grey siimple--px-1"><img src="img/clip.svg" alt="send" width="24"></div>
</div>
<div class="chatpanel-mid siimple--mx-1 siimple--my-1">
<textarea id="send_box" class="siimple-textarea siimple-textarea--fluid" style="height: calc(2em + 10px); overflow-y: hidden;"></textarea>
</div>
<div class="chatpanel-right siimple--mx-1 siimple--my-1">
<div onclick="send()" class="siimple-btn siimple-btn--blue siimple--px-2" style="height: 24px;"><img src="img/send.svg" alt="Send" width="24"></div>
</div>
</div>
</div>
function leave() {
socket.send(JSON.stringify({
cmd: "leave"
}));
}
<!-- Reply Clip -->
<div id="reply_clip" class="clip-win reply-clip siimple--bg-white hidden">
<span></span>
<div onclick="$('#reply_clip > span').text(''); $('#reply_clip').addClass('hidden');" class="siimple-close siimple--float-right"></div>
</div>
function send(t) {
socket.send(JSON.stringify({
cmd: "text",
text: t
}));
}
<!-- Selected Clip -->
<div id="selected_clip" class="clip-win selected-clip siimple--bg-white hidden">
<div class="siimple-btn-group">
<div onclick="copyMessagesToClipboard()" class="siimple-btn siimple-btn--blue siimple--px-2" style="height: 24px;">Copy</div>
<div onclick="prepareReply()" class="siimple-btn siimple-btn--blue siimple--px-2" style="height: 24px;">Reply</div>
</div>
<div class="siimple-close siimple--float-right siimple--my-1 siimple--ml-2"></div>
</div>
function info(k, n, t) {
socket.send(JSON.stringify({
cmd: "seinfo",
kunjika: k,
name: n,
tags: t
}));
}
<!-- Action Clip -->
<div id="action_clip" class="clip-win action-clip siimple--bg-white hidden">
<div class="siimple--my-1">
<div class="siimple-btn siimple-btn--light">
<img src="img/image.svg" alt="Image" width="50" class="siimple--py-2 siimple--px-2">
<div>send image</div>
</div>
</div>
<div>
<a class="siimple-btn siimple-btn--blue">Clear</a>
<a class="siimple-btn siimple-btn--blue">List Users</a>
</div>
</div>
function joinrand() {
socket.send(JSON.stringify({
cmd: "rand"
}));
}
</script>
<script src="js/jquery-3.5.1.min.js"></script>
<script src="js/app.js"></script>
</body>
</html>

209
static/js/app.js Normal file
View File

@ -0,0 +1,209 @@
$(document).ready(() => {
$(".siimple-tabs-item").click(function() {
var t = $(this);
var tab = $(t.parents('tabs').first());
tab.find('form').each((i,elm) => {
var elm = $(elm);
if(elm.attr('name') == t.attr('for'))
elm.removeClass('hidden');
else
elm.addClass('hidden');
});
t.parent().find('.siimple-tabs-item').each((i, elm) => {
var elm = $(elm);
if(elm.attr('for') === t.attr('for'))
elm.addClass('siimple-tabs-tab--selected');
else
elm.removeClass('siimple-tabs-tab--selected');
});
});
$('.message-me, .message-other').click(function() {
activateMessage(this);
});
$('#selected_clip > .siimple-close').click(function() {
deactivateMessages();
});
});
// Create WebSocket connection.
const socket = new WebSocket('ws://localhost:8080/ws/');
var callbacks = [];
var myinfo = {
kunjika: "",
name: ""
};
// Connection opened
socket.addEventListener('open', function (event) {
$('#progressbar').toggleClass('hidden');
});
// Listen for messages
socket.addEventListener('message', function (event) {
var j = JSON.parse(event.data);
console.log(j);
switch(j.cmd) {
case 'resp':
if(j.result == 'Err') {
console.log('Error', j.message);
} else {
if(callbacks.length > 0) {
callbacks[0]();
callbacks.splice(0);
}
}
break;
case 'text':
pushMessage(j.kunjika, j.text, j.reply);
break;
}
});
function connect(frm) {
var frm = $(frm);
$('#progressbar').addClass('hidden');
var data = {};
frm.serializeArray().forEach(el => {
data[el.name] = el.value;
});
callbacks.push(() => {
socket.send(JSON.stringify(Object.assign({cmd: frm.attr('cmd')}, data)));
$('#progressbar').addClass('hidden');
$('#chat_panel').removeClass('hidden');
myinfo.kunjika = data.kunjika;
myinfo.name = data.name;
});
socket.send(JSON.stringify(Object.assign({cmd: 'seinfo'}, data)));
}
function leave() {
callbacks.push(() => {
$('#chat_panel').addClass('hidden');
$('#reply_clip').addClass('hidden');
$('#selected_clip').addClass('hidden');
$('#action_clip').addClass('hidden');
});
socket.send(JSON.stringify({
cmd: "leave"
}));
}
function pushMessage(sender, text, reply = null) {
var isMe = myinfo.kunjika == sender;
var area = $('#message_area');
var elm = $('<div>', {class: 'message '+(isMe?'message-me':'message-other')});
elm.append($('<div>', {class: 'message-by'}).append(sender));
if(reply != null && reply.length > 0) {
elm.append(
$('<div>', {class: 'message message-reply'})
.append($('<pre>', {class: 'siimple--my-0 siimple--pt-1'}).append(reply))
);
}
elm.append($('<pre>').append(text));
elm.click(function() {
activateMessage(this);
});
area.append(elm)
}
function deactivateMessages() {
$('.active').each(function() {
$(this).removeClass('active');
});
$('#selected_clip').addClass('hidden');
}
function activateMessage(t) {
var t = $(t);
t.toggleClass('active');
if($('.active').length == 0)
$('#selected_clip').addClass('hidden');
else
$('#selected_clip').removeClass('hidden');
}
function selectedMessageToText() {
var text = "";
$('.active').each(function() {
$(this).find('pre').each(function() {
text += $(this).text() + '\n'
});
});
return text.trim();
}
function prepareReply() {
var text = selectedMessageToText();
var el = $('#reply_clip');
el.removeClass('hidden');
el.attr('msg', text);
$('#reply_clip > span').text(text.substr(0, 15)+ '...');
deactivateMessages();
}
function send() {
socket.send(JSON.stringify({
cmd: "text",
text: $('#send_box').val(),
reply: $('#reply_clip').attr('msg')
}));
$('#send_box').val('');
$('#reply_clip').attr('msg', '');
$('#reply_clip').addClass('hidden');
$('#reply_clip > span').text('');
}
function copyMessagesToClipboard() {
var $temp = $("<textarea>");
$("body").append($temp);
$temp.val(selectedMessageToText()).select();
document.execCommand("copy");
$temp.remove();
deactivateMessages();
}
// function wsend(p) {
// socket.send(p);
// }
// function join(r, l) {
// socket.send(JSON.stringify({
// cmd: "join",
// grih_kunjika: r,
// length: l
// }));
// }
// function leave() {
// socket.send(JSON.stringify({
// cmd: "leave"
// }));
// }
// function send(t) {
// socket.send(JSON.stringify({
// cmd: "text",
// text: t
// }));
// }
// function info(k, n, t) {
// socket.send(JSON.stringify({
// cmd: "seinfo",
// kunjika: k,
// name: n,
// tags: t
// }));
// }
// function joinrand() {
// socket.send(JSON.stringify({
// cmd: "rand"
// }));
// }

2
static/js/jquery-3.5.1.min.js vendored Normal file

File diff suppressed because one or more lines are too long

19
static/test.html Normal file
View File

@ -0,0 +1,19 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/siimple@3.3.1/dist/siimple.min.css">
<title>Document</title>
</head>
<body>
<div class="siimple-navbar">
<a class="siimple-navbar-title">Title</a>
<div class="siimple--float-right">
<a class="siimple-navbar-item">Link 1</a>
<a class="siimple-navbar-item">Link 2</a>
</div>
</div>
</body>
</html>

2
vecmap/Cargo.lock generated
View File

@ -1,5 +1,5 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
[[package]]
name = "hashmap_mod"
name = "vecmap"
version = "0.1.0"

View File

@ -90,6 +90,10 @@ impl<K: Clone + PartialEq,V: Clone> VecMap<K,V> {
None => false
}
}
pub fn len(&self) -> usize {
self.0.len()
}
}
#[cfg(test)]
@ -103,8 +107,7 @@ mod tests {
a.insert(1, 5);
a.insert(2, 10);
a.change_key(1, 2).unwrap();
a.insert(2, 15);
a.remove(&1);
a.into_iter().enumerate().for_each(|(i,e)| {
println!("{}\t-> {:?}", i,e);