-
Notifications
You must be signed in to change notification settings - Fork 0
/
sendmsg.js
91 lines (86 loc) · 3.08 KB
/
sendmsg.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
function sendInfoMsg(clicked_id) {
localStorage.setItem("clicked_id", clicked_id);
arrBtnPushed.push(parseInt(clicked_id.substr(7 ,1)));
targetDate = arrHistory[((parseInt(clicked_id.substr(7 ,1)))*2)+1];
const arrTarget = targetDate.split("-");
window.targetY = parseInt(arrTarget[0]);
window.targetM = parseInt(arrTarget[1]);
window.targetD = parseInt(arrTarget[2]);
calculateCountdown();
tmpEvent = arrHistory[((parseInt(clicked_id.substr(7 ,1)))*2)];
senderName = window.webxdc.selfName;
//set string and language for infomessage
window.fallback = true;
changeLanguage();
if (window.expired == true) {
info = strInfoMsgO.replace('%N', senderName).replace ('%E', tmpEvent);
if (window.fallback == false) {
changeLanguage();
infoEn = strInfoMsgO.replace('%N', senderName).replace ('%E', tmpEvent);
addEnglish();
}
}
else if (window.countY>0) {
info = strInfoMsgY.replace('%N', senderName).replace ('%E', tmpEvent).replace('%Y',window.countY).replace('%M',window.countM).replace('%D',window.countD);
if (window.fallback == false) {
changeLanguage();
infoEn = strInfoMsgY.replace('%N', senderName).replace ('%E', tmpEvent).replace('%Y',window.countY).replace('%M',window.countM).replace('%D',window.countD);
addEnglish();
}
}
else if (window.countM>0) {
info = strInfoMsgM.replace('%N', senderName).replace ('%E', tmpEvent).replace('%M',window.countM).replace('%D',window.countD);
if (window.fallback == false) {
changeLanguage();
infoEn = strInfoMsgM.replace('%N', senderName).replace ('%E', tmpEvent).replace('%M',window.countM).replace('%D',window.countD);
addEnglish();
}
}
else if (window.countD>1) {
info = strInfoMsgD.replace('%N', senderName).replace ('%E', tmpEvent).replace('%D',window.countD);
if (window.fallback == false) {
changeLanguage();
infoEn = strInfoMsgD.replace('%N', senderName).replace ('%E', tmpEvent).replace('%D',window.countD);
addEnglish();
}
}
else if (window.countD == 1) {
info = strInfoMsgTM.replace('%N', senderName).replace ('%E', tmpEvent);
if (window.fallback == false) {
changeLanguage();
infoEn = strInfoMsgTM.replace('%N', senderName).replace ('%E', tmpEvent);
addEnglish();
}
}
else {
info = strInfoMsgTD.replace('%N', senderName).replace ('%E', tmpEvent).replace('%D',window.countD);
if (window.fallback == false) {
changeLanguage();
infoEn = strInfoMsgTD.replace('%N', senderName).replace ('%E', tmpEvent).replace('%D',window.countD);
addEnglish();
}
}
localStorage.setItem("info", info);
location.assign("./chatmsg.html");
};
function addEnglish() {
info = info + "\n" + "\n" + "<-- english below -->" + "\n" + "\n" + infoEn;
window.fallback = true;
};
function sendSilentMsg() {
info = localStorage.getItem("info");
localStorage.setItem("silentMsgSent", "true");
location.assign('./index.html');
}
function cancelSendMsg() {
localStorage.setItem("info", "");
location.assign("./index.html");
}
function sendChatMsg() {
info = localStorage.getItem("info");
localStorage.setItem("info", "");
window.webxdc.sendToChat({
text: info
});
location.assign('./index.html');
};