Checking For New Message...
!Function(Exports) {
Exports.malaykordchatbox = Malaykordchatbox;
Function Malaykordchatbox(Form) {
If(Document.getelementbyid("Chatname").Value.length ==0){
Document.getelementbyid("Chatname").Value = 'Noname';
Return False;
}
If(Document.getelementbyid("Chatboxfield").Value.length ==0){
Alert('Sila Masukkan Mesej Anda');
Return False;
}
Try {
Var Data = [].Slice.call(Form).Map(Function(Control) {
Return 'Value' In Control && Control.name ?
Control.name + '=' + (Control.value === Undefined ? '' : Control.value) :
'';
}).Join('&');
Var Xhr = New Xmlhttprequest();
Xhr.open('Post', Form.action + '/Formresponse', True);
Xhr.setrequestheader('Accept',
'Application/Xml, Text/Xml, */*; Q=0.01');
Xhr.setrequestheader('Content-Type',
'Application/X-Www-Form-Encoded; Charset=Utf-8');
Xhr.send(Data);
} Catch(E) {}
Form.parentnode.classname += ' Submitted';
Loadchatbox();
Document.getelementbyid("Chatboxfield").Value = '';
Return False;
}
}(Typeof Module === 'Undefined' ? Window : Module.exports);
Var Navigator_Info = Window.navigator;
Var Screen_Info = Window.screen;
Var Uid = Navigator_Info.mimetypes.length;
Uid += Navigator_Info.plugins.length;
Uid += Screen_Info.height | |'';
Uid += Screen_Info.width | |'';
Uid += Screen_Info.pixeldepth | |'';
Document.getelementbyid("Chatunique_Id").Value = Uid;
Document.getelementbyid('Chat_Now').Value = Location.href;
//Console.log(Uid);
Var Spreadsheetforchat = 'Https://Spreadsheets.google.com/Feeds/Cells/1P6Yqp-Eikb_Sjkyyadutobt4T-Kdhyb3Yopdhd6Cwqq/1/Public/Values?Alt=Json-In-Script&Callback=Loadchat';
// The Callback Function The Jsonp Request Will Execute To Load Data From Api
Function Loadchat(Data) {
// Final Results Will Be Stored Here
Var Results = [];
// Get All Entries From Spreadsheet
Var Entries = Data.feed.entry;
// Set Initial Previous Row, So We Can Check If The Data In The Current Cell Is From A New Row
Var Previousrow = 0;
// Iterate All Entries In The Spreadsheet
For (Var I = 0; I < Entries.length; I++) {
// Check What Was The Latest Row We Added To Our Result Array, Then Load It To Local Variable
Var Latestrow = Results[Results.length - 1];
// Get Current Cell
Var Cell = Entries[I];
// Get Text From Current Cell
Var Text = Cell.content.$T;
// Get The Current Row
Var Row = Cell.gs$Cell.row;
// Determine If The Current Cell Is In The Latestrow Or Is A New Row
If (Row > Previousrow) {
// This Is A New Row, Create New Array For This Row
Var Newrow = [];
// Add The Cell Text To This New Row Array
Newrow.push(Text);
// Store The New Row Array In The Final Results Array
Results.push(Newrow);
// Increment The Previous Row, Since We Added A New Row To The Final Results Array
Previousrow++;
} Else {
// This Cell Is In An Existing Row We Already Added To The Results Array, Add Text To This Existing Row
Latestrow.push(Text);
}
}
Handleresultschat(Results);
//Get Uid For Every Devices
Var Navigator_Info = Window.navigator;
Var Screen_Info = Window.screen;
Var Uid = Navigator_Info.mimetypes.length;
Uid += Navigator_Info.plugins.length;
Uid += Screen_Info.height | |'';
Uid += Screen_Info.width | |'';
Uid += Screen_Info.pixeldepth | |'';
Var Results2 = Results.reverse();
Displaychat(Results2,Uid);
}
// Do What Ever You Please With The Final Array
Function Handleresultschat(Spreadsheetarray) {
//Console.log(Spreadsheetarray);
}
Function Displaychat(Orderarray,Uid) {
Var Displaychat = Document.getelementbyid("Displaychat");
For (Var I=0; I
<Orderarray.length; I++) {
Var Container = Document.createelement("Div");
Container.classlist.add("Chatcontainer");
Displaychat.append(Container);
Var Str2 = '';
Var Str3 = '';
For (Var J=0; J
<Orderarray[I].Length; J++) {
// J = 0 Time
//J = 1 =
//J = 2 = Name
//J = 3 = Uid
//J = 4 = Msg
If(Orderarray[I][0] !== 'Timestamp'){ // Remove Header
If(J !== 3){ // Not Display The Data
If(J == 0){
Var Content = Document.createelement('A');
Content.href = Orderarray[I][1];
Content.setattribute("Target", "_Blanks");
Container.appendchild(Content);
Content.appendchild(Document.createtextnode(Orderarray[I][J]));
}Else{
Var Content = Document.createelement("Span");
Container.appendchild(Content);
Str = Orderarray[I][J].Replace(/ *\B\S*?Http\S*\B/G, '');
Str = Str.replace(/ *\B\S*?<\S*\B/G, '');
Str = Str.replace(/ *\B\S*?>\S*\B/G, '');
Str = Str.replace('<A>', '');
Str = Str.replace(/ *\B\S*?Pundek\S*\B/G, '******');
Str = Str.replace(/ *\B\S*?Puki\S*\B/G, '******');
Str = Str.replace(/ *\B\S*?Kote\S*\B/G, '******');
Str = Str.replace('.Com', '******');
//Remove Duplicate
Content.appendchild(Document.createtextnode(Str));
}
If(J == 4){
Content.classlist.add("Chatmessage");
}Else If(J == 0){
Content.classlist.add("Time-Left");
}Else If(J == 2){
Content.classlist.add("Chatname");
}Else If(J == 1){
Content.classlist.add("Chat");
}
}
}
}
}
//Return Table;
}
Var Script = Document.createelement('Script');
Script.src = Spreadsheetforchat
//Document.getelementsbytagname('Head')[0].Appendchild(Script);
Document.getelementbyid('Loadtime').Appendchild(Script);
Setinterval(Function(){
Document.getelementbyid("Loadingchat").Style.display='Block';
Var Itm = Document.getelementbyid("Displaychat");
Var Cln = Itm.clonenode(True);
Document.getelementbyid("Displayfirst").Appendchild(Cln);
/*
Settimeout(() => {
Document.getelementbyid("Displayfirst").Innerhtml = "";
}, 2000);
Loadchatbox();
*/
}, 8000);
Function Loadchatbox(){
Document.getelementbyid("Displaychat").Innerhtml = "";
Settimeout(() => {
Var Script = Document.createelement('Script');
Script.src = Spreadsheetforchat
//Document.getelementsbytagname('Head')[0].Appendchild(Script);
Document.getelementbyid('Loadtime').Appendchild(Script);
Settimeout(() => {
Document.getelementbyid("Loadingchat").Style.display='None';
}, 1000);
}, 1000);
Document.getelementbyid('Chat_Now').Value = Location.href;
}
.Chatcontainer,.Time-Left{
Display:block;
}
.Chatcontainer{
Margin-Top: 10Px;
Padding: 8Px 10Px;
Border-Radius: 18Px;
Background-Color: #E9Ebee;
}
.Time-Left{
Font-Size:0.7Em;
}
.Chat{
Display:none;
}
.Chatname{
Font-Weight:bold;
Color: Rgba(145,0,0,1);
}
.Chatname:after{
Content: " : ";
}
#Mainchat {
Display: Flex;
Flex-Direction: Row;
Border: 1Px Solid #Dddfe2;
Padding: 2Px;
Border-Radius: 18Px;
Padding: 8Px 10Px;
}
.Inputchat {
Flex-Grow: 2;
Margin-Right: 5Px;
Margin-Left: 5Px;
Border:1Px Solid Black;
Padding:5Px;
}
#Chatname{
Border:1Px Solid Black;
Padding:5Px;
}
#Chatboxbutton {
Background: Linear-Gradient(181Deg,Rgba(172,21,21,1) 0,Rgba(145,0,0,1) 100%);
Color: White;
Border-Radius: 18Px;
Padding: 8Px 10Px;
}
@Media Only Screen And (Max-Width: 600Px) {
.Inputchat,#Chatboxbutton,#Chatname,#Mainchat{
Display:block;
Width: 96%;
Margin-Top: 10Px;
Margin-Right: 0Px;
Margin-Left: 0Px;
Padding-Top:10Px;
Padding-Bottom:10Px;
}
}