Created
July 5, 2021 22:06
-
-
Save realrasengan/d0a9e5391a292bc8a7678f1803ae99a2 to your computer and use it in GitHub Desktop.
IRC Client for IRC.com Remotes v0.02
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const Console = require("./lib/console.js"); | |
| const $ = new (require("./lib/irc.js"))("nickname","token",true); | |
| let startup=false; | |
| let app = `var style = $(\`<style> | |
| #box { | |
| z-index:100000; | |
| position:absolute; | |
| left:0; | |
| top:40px; | |
| color:#fff; | |
| text-align:center; | |
| background-color:#555; | |
| border:1px solid #888; | |
| width:calc(100% - 2px); | |
| height:calc(90% - 2px); | |
| padding:1px; | |
| overflow:hidden; | |
| } | |
| .title { | |
| width:100%; | |
| position:relative; | |
| top:0; | |
| height:20px; | |
| z-index:100000; | |
| text-align:center; | |
| background-color:#222; | |
| color:#fff; | |
| font-weight:bold; | |
| margin-bottom:0px; | |
| overflow:hidden; | |
| font-size:0.8em; | |
| } | |
| .title span { | |
| margin-left:4px; | |
| margin-right:4px; | |
| display:inline-block; | |
| } | |
| span.appName { | |
| width:20%; | |
| text-align:center; | |
| z-index:100000; | |
| display:inline-block; | |
| float:left; | |
| } | |
| span.topic { | |
| width:calc(75% - 24px); | |
| overflow:hidden; | |
| display:inline-block; | |
| text-align:left; | |
| float:left; | |
| } | |
| #sidebar { | |
| position:absolute; | |
| width:20%; | |
| height:calc(100% - 20px); | |
| left:0; | |
| top:20px; | |
| overflow:scroll; | |
| text-align:left; | |
| background-color:#222;; | |
| } | |
| #sidebar .chatbutton { | |
| font-size:0.7em; | |
| margin-bottom:5px; | |
| margin-left:2px; | |
| position:relative; | |
| } | |
| #sidebar .chatbutton:hover { | |
| cursor:pointer; | |
| } | |
| #chat { | |
| width:80%; | |
| position:absolute; | |
| height:calc(100% - 20px); | |
| top:20px; | |
| left:20%; | |
| background-color:#000; | |
| } | |
| .nicks { | |
| width:20%; | |
| position:absolute; | |
| overflow:scroll; | |
| height:calc(100% - 26px); | |
| border-left:1px solid #333; | |
| top:0; | |
| right:0; | |
| display:none; | |
| } | |
| .nicks span { | |
| display:block; | |
| font-size:0.7em; | |
| text-align:left; | |
| } | |
| .chatbox { | |
| width:99%; | |
| height:calc(100% - 26px); | |
| margin-right:1%; | |
| font-size:0.8em; | |
| text-align:left; | |
| overflow:scroll; | |
| position:absolute; | |
| top:0; | |
| left:0; | |
| display:none; | |
| word-break: break-all; | |
| } | |
| .input_text { | |
| width:calc(80% - 26px); | |
| position:absolute; | |
| bottom:0; | |
| left:20%; | |
| height:26px; | |
| font-weight:bold; | |
| background-color:#000; | |
| color:#fff; | |
| } | |
| #input_submit { | |
| position:absolute; | |
| right:0; | |
| height:26px; | |
| font-size:0.6em; | |
| background-color:#333; | |
| bottom:0; | |
| width:26px; | |
| color:#fff; | |
| } | |
| .minimize { | |
| width:20px; | |
| height:20px; | |
| float:right; | |
| border:1px solid #777; | |
| background-color:#333; | |
| color:#fff; | |
| z-index:100000; | |
| display:inline-block; | |
| } | |
| </style>\`).prependTo(document.body); | |
| document.element = $("<div id='box' class='ui-widget-content'></div>").appendTo(document.body); | |
| document.element.draggable().resizable(); | |
| document.element_title = $("<div class='title'></div>").appendTo(document.element); | |
| document.element_title_app = $("<span class='appName'>IRC Client</span>").appendTo(document.element_title); | |
| document.element_title_topic = $("<span class='topic'></span>").appendTo(document.element_title); | |
| document.element_minimize = $("<button class='minimize'>⎯</button>").appendTo(document.element_title); | |
| document.element_minimize.click(()=>{ | |
| if(parseInt(document.element.css('height').replace("px",""))>24) { | |
| document.element.animate({height:'20px'},{duration:400,queue:false}); | |
| document.element.animate({width:'168px'},{duration:400,queue:false}); | |
| document.element_title_topic.hide(); | |
| document.element.animate({left:"5%"},{duration:400,queue:false}); | |
| document.element.animate({top:"95%"},{duration:400,queue:false}); | |
| } | |
| else { | |
| document.element.animate({height:'90%'},{duration:400,queue:false}); | |
| document.element.animate({width:'100%'},{duration:400,queue:false}); | |
| document.element.animate({left:0},{duration:400,queue:false}); | |
| document.element.animate({top:40},{duration:400,queue:false}); | |
| document.element_title_topic.show(); | |
| } | |
| }); | |
| document.element_chat = $("<div id='chat'></div>").appendTo(document.element); | |
| document.element_form = $("<form id='irc_input'></form>").appendTo(document.element); | |
| document.element_input = $("<input class='input_text' type='text' id='input_text'>").appendTo(document.element_form); | |
| document.element_submit = $("<input type='submit' id='input_submit' value='↵'>").appendTo(document.element_form); | |
| document.element_sidebar = $("<div id='sidebar'></div>").appendTo(document.element); | |
| let location=""; | |
| document.element_sidebar.swipe({ | |
| swipe: | |
| function(event, direction, distance, duration, fingerCount, fingerData) { | |
| console.log(event); | |
| if(direction=='left' && location==""){ | |
| document.element_sidebar.toggle('slide'); | |
| document.element_chat.animate({width:'100%'},{duration:400,queue:false}); | |
| var numPixels=($(window).width()*1 - 26) + "px"; | |
| document.element_input.animate({width:numPixels},{duration:400,queue:false,complete:()=>{document.element_input.css('width',"calc(100% - 26px)")}}); | |
| document.element_chat.animate({left:0},{duration:400,queue:false}); | |
| document.element_input.animate({left:0},{duration:400,queue:false}); | |
| location="left"; | |
| document.element_chat.swipe({ | |
| swipe: | |
| function(event,direction,distance,duration,fingerCount,fingerData) { | |
| var xcoord = event.pageX - document.element.offset().left; | |
| if(direction=='right' && location=="left" && (parseInt(xcoord) < parseInt($(this).width()/2))) { | |
| document.element_sidebar.toggle('slide',{direction:"left"}); | |
| document.element_chat.animate({left:'20%'},{duration:400,queue:false}); | |
| document.element_input.animate({left:'20%'},{duration:400,queue:false}); | |
| document.element_chat.animate({width:'80%'},{duration:400,queue:false}); | |
| var numPixels=($(window).width()*.8 - 26) + "px"; | |
| document.element_input.animate({width:numPixels},{duration:400,queue:false,complete:()=>{document.element_input.css('width',"calc(80% - 26px)")}}); | |
| location=""; | |
| } | |
| }, | |
| threshold:30 | |
| }); | |
| } | |
| }, | |
| threshold:30 | |
| }); | |
| $('form#irc_input').submit((e)=> { | |
| let value = $('input#input_text').val(); | |
| if(value.length==0) { | |
| e.preventDefault(); | |
| return; | |
| } | |
| if(value.substr(0,1)!="/" && document.currentFoc!="") { | |
| if(!document.button[document.currentFoc].text().includes("(") && document.currentFoc!="@status") { | |
| send("PRIVMSG "+document.currentFoc+" :"+value); | |
| document.channel[document.currentFoc].append("<"+""+document.currentNick+"> "+value.replace(/ /g,' ').replace(/</g,"<").replace(/>/g,">")+"<br>"); | |
| } | |
| } | |
| else if(value.substr(0,1)=="/") { | |
| let tokens = value.substr(1).split(" "); | |
| let _message; | |
| switch(tokens[0].toLowerCase()) { | |
| case "msg": | |
| let _chan = tokens[1]; | |
| tokens.shift(); | |
| tokens.shift(); | |
| _message = tokens.join(" ").trim(); | |
| send("PRIVMSG "+_chan+" :"+_message); | |
| document.handleMessage(document.currentNick,_chan,_message,"msg"); | |
| break; | |
| case "me": | |
| tokens.shift(); | |
| _message= tokens.join(" ").trim(); | |
| send("PRIVMSG "+document.currentFoc+ " :"+String.fromCharCode(1)+"ACTION "+_message); | |
| document.handleMessage(document.currentNick,document.currentFoc,_message,"action"); | |
| break; | |
| case "join": | |
| tokens.shift(); | |
| send("JOIN "+tokens[0].toLowerCase()+(typeof tokens[1] === "undefined"?"":tokens[1])); | |
| break; | |
| case "part": | |
| tokens.shift(); | |
| if(typeof tokens[0] === "undefined") | |
| tokens[0]=document.currentFoc; | |
| send("PART "+tokens[0]); | |
| break; | |
| case "close": | |
| if(document.currentFoc.substr(0,1)=='#') | |
| send("PART "+document.currentFoc); | |
| document.channel[document.currentFoc].remove(); | |
| document.button[document.currentFoc].remove(); | |
| delete document.channel[document.currentFoc]; | |
| delete document.button[document.currentFoc]; | |
| document.currentFoc=""; | |
| break; | |
| default: | |
| let command = tokens[0].toUpperCase(); | |
| tokens.shift(); | |
| send(command+" "+tokens.join(" ")); | |
| break; | |
| } | |
| } | |
| $('input#input_text').val(''); | |
| e.preventDefault(); | |
| }); | |
| var controlKeyStatus=0; | |
| document.element_input.on({ | |
| keydown: function(e) { | |
| if (e.ctrlKey) | |
| controlKeyStatus=1; | |
| }, | |
| keyup: function(e) { | |
| if (!e.ctrlKey) | |
| controlKeyStatus=0; | |
| }, | |
| keypress: function(e) { | |
| if(controlKeyStatus===1) { | |
| switch(e.originalEvent.key) { | |
| case 's': // strong | |
| document.element_input.val(document.element_input.val()+String.fromCharCode(2)); | |
| break; | |
| case 'K': // colour | |
| document.element_input.val(document.element_input.val()+String.fromCharCode(3)); | |
| break; | |
| default: | |
| break; | |
| } | |
| } | |
| } | |
| }) | |
| document.currentFoc = ""; | |
| document.channel=[]; | |
| document.button=[]; | |
| document.nicks=[]; | |
| document.topics=[]; | |
| document.createWindow = function(target) { | |
| target=target.toLowerCase(); | |
| if(!document.channel[target]) { | |
| document.channel[target]=$("<div class='chatbox' name='"+target+"'></div>").appendTo(document.element_chat); | |
| document.channel[target].hide(); | |
| document.channel[target].data("name",target) | |
| document.button[target]=$("<div class='chatbutton' name='"+target+"_button'>"+target+"</div>").appendTo(document.element_sidebar); | |
| document.button[target].data("channel",target); | |
| if(target.substr(0,1)=='#') { | |
| document.nicks[target]=$("<div class='nicks'></div>").appendTo(document.element_chat); | |
| document.channel[target].css('width','79%'); | |
| document.nicks[target].data("channel",target); | |
| document.nicks[target].swipe({ | |
| swipe: | |
| function(event, direction, distance, duration, fingerCount, fingerData) { | |
| let curChan=$(this); | |
| curChan.data("location","") | |
| if(direction=='right' && curChan.data("location")==""){ | |
| curChan.toggle('slide',{direction:"right"}); | |
| document.channel[curChan.data("channel")].animate({width:'99%'},{duration:400,queue:false}); | |
| curChan.data("location","right"); | |
| document.channel[curChan.data("channel")].swipe({ | |
| swipe: | |
| function(event,direction,distance,duration,fingerCount,fingerData) { | |
| var xcoord = event.pageX - document.element.offset().left; | |
| let mainCurChan=$(this); | |
| let mainCurNick=document.nicks[mainCurChan.data("name")] | |
| if(direction=='left' && mainCurNick.data('location')=="right" && (parseInt(xcoord) >= parseInt($(this).width()/2))) { | |
| mainCurNick.toggle('slide',{direction:"right"}); | |
| mainCurChan.animate({width:'79%'},{duration:400,queue:false}); | |
| mainCurNick.data('location',""); | |
| } | |
| }, | |
| threshold:30 | |
| }); | |
| } | |
| return false; | |
| }, | |
| threshold:30 | |
| }); | |
| } | |
| document.button[target].click(function() { | |
| $(this).css('color','white'); | |
| $(this).css('background-color','#555'); | |
| let chanwin = document.channel[$(this).data("channel")]; | |
| let channicks; | |
| if(target.substr(0,1)=='#') { | |
| channicks = document.nicks[$(this).data("channel")]; | |
| } | |
| if(document.currentFoc.length>0) { | |
| document.channel[document.currentFoc].hide(); | |
| if(document.currentFoc.substr(0,1)=='#') { | |
| document.nicks[document.currentFoc].hide(); | |
| document.element_title_topic.text(""); | |
| document.element_title_topic.prop("title",""); | |
| } | |
| document.button[document.currentFoc].css('background-color','#222'); | |
| } | |
| if(target.substr(0,1)=='#') { | |
| document.element_title_topic.text(document.topics[$(this).data("channel")]); | |
| document.element_title_topic.prop('title',document.element_title_topic.text()) | |
| channicks.show(); | |
| } | |
| else { | |
| document.element_title_topic.text(""); | |
| document.element_title_topic.prop('title',''); | |
| } | |
| chanwin.show(); | |
| document.currentFoc=$(this).data("channel"); | |
| }); | |
| } | |
| else{ | |
| document.button[target].text(target); | |
| } | |
| }; | |
| document.handleMessage = function(sender,target,msg,type) { | |
| if(target.substr(0,1)!='#' && sender.toLowerCase()!==document.currentNick.toLowerCase()) { | |
| target=sender; | |
| } | |
| if(target.substr(0,1)=="(") | |
| return; | |
| document.createWindow(target); | |
| if(type=="msg") | |
| document.channel[target.toLowerCase()].append("<"+sender+"> "+msg.replace(/ /g,' ')+"<br>"); | |
| else if(type=="notice") | |
| document.channel[target.toLowerCase()].append("- "+sender+" - "+msg.replace(/ /g,' ')+"<br>"); | |
| else | |
| document.channel[target.toLowerCase()].append("* "+sender+" "+msg.replace(/ /g,' ')+"<br>"); | |
| if(target!=document.currentFoc) { | |
| document.button[target.toLowerCase()].css('color','red'); | |
| } | |
| if(document.currentFoc=="") { | |
| document.currentFoc=target.toLowerCase(); | |
| document.button[target.toLowerCase()].css('color','white'); | |
| document.channel[target.toLowerCase()].show(); | |
| } | |
| document.scrollToBottom(target.toLowerCase()); | |
| }; | |
| document.scrollToBottom = function(target) { | |
| document.channel[target].animate({scrollTop: document.channel[target].get(0).scrollHeight},100); | |
| }; | |
| $(document).ready(function(){ | |
| var _originalSize = $(window).width() + $(window).height() | |
| $(window).resize(function(){ | |
| if($(window).width() + $(window).height() != _originalSize){ | |
| } | |
| else { | |
| $(document.body).css({ | |
| zoom : '', | |
| position : '', | |
| left: "", | |
| top: "", | |
| "-moz-transform" : "", | |
| width : '' | |
| }); | |
| } | |
| }); | |
| }); | |
| `; | |
| Console.on('msg',(msg)=>{ | |
| $.write(msg); | |
| }); | |
| Console.on('startup',(id)=>{ | |
| doStartup(id); | |
| }); | |
| // MAIN APP | |
| $.on('invite',(sender,chan,target)=>{ | |
| if(startup) { | |
| if($.isEqual(target,$.me())) | |
| Console.code(` | |
| document.channel["@status"].append("*** `+sender.replace(/\\/g,"\")+` has invited you to `+chan.replace(/\\/g,"\")+`"); | |
| document.scrollToBottom("@status"); | |
| `); | |
| } | |
| }); | |
| $.on('action',(sender,target,msg)=>{ | |
| if(startup) { | |
| target=target.toLowerCase(); | |
| Console.code(` | |
| document.handleMessage("`+sender.replace(/\\/g,"\")+`","`+target+`","`+msg.replace(/"/g,""").replace(/\\/g,"\").replace(/</g,"<").replace(/>/g,">")+`","action"); | |
| `); | |
| } | |
| }); | |
| $.on('privmsg',(sender,target,msg)=>{ | |
| if(startup) { | |
| target=target.toLowerCase(); | |
| Console.code(` | |
| document.handleMessage("`+sender.replace(/\\/g,"\")+`","`+target.replace(/\\/g,"\")+`","`+msg.replace(/"/g,""").replace(/\\/g,"\").replace(/</g,"<").replace(/>/g,">")+`","msg"); | |
| `); | |
| } | |
| }); | |
| $.on('notice',(sender,target,msg)=> { | |
| if(startup) { | |
| target=target.toLowerCase(); | |
| Console.code(` | |
| document.handleMessage("`+sender.replace(/\\/g,"\")+`","`+target.replace(/\\/g,"\")+`","`+msg.replace(/"/g,""").replace(/\\/g,"\").replace(/</g,"<").replace(/>/g,">")+`","notice"); | |
| `); | |
| } | |
| }); | |
| $.on('snotice',(target,msg)=> { | |
| if(startup) { | |
| target=target.toLowerCase(); | |
| Console.code(` | |
| document.handleMessage("*.freenode.net","`+target.replace(/\\/g,"\")+`","`+msg.replace(/"/g,""").replace(/\\/g,"\").replace(/</g,"<").replace(/>/g,">")+`","notice"); | |
| `); | |
| } | |
| }); | |
| $.on('part',(nick,chan)=>{ | |
| if(startup) { | |
| chan=chan.toLowerCase(); | |
| let toSend=``; | |
| if($.isEqual(nick,$.me())) { | |
| toSend+=` | |
| document.button["`+chan.replace(/\\/g,"\\\\")+`"].text("(`+chan.replace(/\\/g,"\\\\")+`)"); | |
| `; | |
| } | |
| toSend+=`document.channel["`+chan.replace(/\\/g,"\\\\")+`"].append("*** `+nick.replace(/\\/g,"\")+` parts `+chan.replace(/\\/g,"\")+`<br>") | |
| document.scrollToBottom("`+chan.replace(/\\/g,"\\\\")+`"); | |
| `; | |
| if($.isEqual(nick,$.me())){ | |
| toSend+=`document.nicks["`+chan.replace(/\\/g,"\\\\")+`"].html("");`; | |
| } | |
| else | |
| toSend+=updateNicks(chan); | |
| Console.code(toSend); | |
| } | |
| }); | |
| $.on('topic',(nick,chan,topic)=>{ | |
| if(startup) { | |
| chan=chan.toLowerCase(); | |
| toSend=updateTopic(chan); | |
| toSend+=`document.channel["`+chan.replace(/\\/g,"\\\\")+`"].append("*** `+nick.replace(/\\/g,"\")+` changed the topic to '`+topic.replace(/\\/g,"\")+`'<br>");`; | |
| toSend+=`if(document.currentFoc=="`+chan.replace(/\\/g,"\\\\")+`") document.element_title_topic.text(document.topics["`+chan+`"]);`; | |
| Console.code(toSend); | |
| } | |
| }); | |
| $.on('stopic',(chan,topic)=>{ | |
| if(startup) { | |
| chan=chan.toLowerCase(); | |
| toSend=updateTopic(chan); | |
| toSend+=`document.channel["`+chan.replace(/\\/g,"\\\\")+`"].append("*** *.freenode.net changed the topic to '`+topic.replace(/\\/g,"\")+`'<br>");`; | |
| toSend+=`if(document.currentFoc=="`+chan.replace(/\\/g,"\\\\")+`") document.element_title_topic.text(document.topics["`+chan+`"]);`; | |
| Console.code(toSend); | |
| } | |
| }); | |
| $.on('kick',(nick,chan,target,reason)=>{ | |
| if(startup) { | |
| chan=chan.toLowerCase(); | |
| let toSend=``; | |
| if($.isEqual(target,$.me())) { | |
| toSend+=` | |
| document.button["`+chan.replace(/\\/g,"\\\\")+`"].text("(`+chan.replace(/\\/g,"\\\\")+`)") | |
| `; | |
| } | |
| toSend+=`document.channel["`+chan.replace(/\\/g,"\\\\")+`"].append("*** `+target.replace(/\\/g,"\")+` kicked by `+nick.replace(/\\/g,"\")+` from `+chan.replace(/\\/g,"\")+` (`+reason.replace(/"/g,""").replace(/\\/g,"\")+`)<br>"); | |
| document.scrollToBottom("`+chan.replace(/\\/g,"\\\\")+`"); | |
| `; | |
| if($.isEqual(target,$.me())){ | |
| toSend+=`document.nicks["`+chan.replace(/\\/g,"\\\\")+`"].html("");`; | |
| } | |
| else | |
| toSend+=updateNicks(chan.replace(/\\/g,"\\\\")); | |
| Console.code(toSend); | |
| } | |
| }); | |
| $.on('mode',(nick,chan,modes,parms) =>{ | |
| if(startup) { | |
| chan=chan.toLowerCase(); | |
| let toSend=` | |
| document.channel["`+chan.replace(/\\/g,"\\\\")+`"].append("*** `+nick.replace(/\\/g,"\")+` sets mode `+modes+` `+parms.replace(/\\/g,"\")+`<br>"); | |
| document.scrollToBottom("`+chan.replace(/\\/g,"\\\\")+`"); | |
| `; | |
| toSend+=updateNicks(chan.replace(/\\/g,"\\\\")); | |
| Console.code(toSend); | |
| } | |
| }); | |
| $.on('smode',(chan,modes,parms) =>{ | |
| if(startup) { | |
| chan=chan.toLowerCase(); | |
| let toSend=` | |
| document.channel["`+chan.replace(/\\/g,"\\\\")+`"].append("*** *.freenode.net sets mode `+modes+` `+parms.replace(/\\/g,"\")+`<br>"); | |
| document.scrollToBottom("`+chan.replace(/\\/g,"\\\\")+`"); | |
| `; | |
| toSend+=updateNicks(chan.replace(/\\/g,"\\\\")); | |
| Console.code(toSend); | |
| } | |
| }); | |
| $.on('join',(nick,chan)=>{ | |
| if(startup) { | |
| chan=chan.toLowerCase(); | |
| let toSend=``; | |
| if($.isEqual(nick,$.me())) { | |
| toSend+=` | |
| document.createWindow("`+chan.replace(/\\/g,"\\\\")+`"); | |
| document.button["`+chan.replace(/\\/g,"\\\\")+`"].click(); | |
| `; | |
| } | |
| toSend+=` | |
| document.channel["`+chan.replace(/\\/g,"\\\\")+`"].append("*** `+nick.replace(/\\/g,"\")+` (`+$.getChannelNickUserHost(chan,nick)+`) joins `+chan.replace(/\\/g,"\")+`<br>") | |
| document.scrollToBottom("`+chan.replace(/\\/g,"\\\\")+`"); | |
| `; | |
| toSend+=updateNicks(chan); | |
| Console.code(toSend); | |
| } | |
| }); | |
| $.on('names',(chan)=>{ | |
| if(startup) { | |
| let toSend=updateNicks(chan); | |
| Console.code(toSend); | |
| } | |
| }) | |
| $.on('nick',(who,to)=>{ | |
| if(startup) { | |
| let toSend=``; | |
| let channels={}; | |
| if($.isEqual(who,$.me())) { | |
| toSend+=` | |
| document.currentNick = "`+to+`"; | |
| `; | |
| channels = $.getChannels(); | |
| for(x=0;x<channels.length && who != to;x++) { | |
| toSend+=` | |
| document.channel["`+channels[x].replace(/\\/g,"\\\\").toLowerCase()+`"].append("*** `+who.replace(/\\/g,"\")+` is now known as `+to.replace(/\\/g,"\")+`<br>"); | |
| document.scrollToBottom("`+channels[x].replace(/\\/g,"\\\\").toLowerCase()+`"); | |
| `; | |
| toSend+=updateNicks(channels[x].replace(/\\/g,"\\\\").toLowerCase()); | |
| } | |
| } | |
| else { | |
| channels = $.getChannels(); | |
| for(x=0;x<channels.length;x++) { | |
| if($.isIn(channels[x],to)) { | |
| toSend+=` | |
| document.channel["`+channels[x].replace(/\\/g,"\\\\").toLowerCase()+`"].append("*** `+who.replace(/\\/g,"\")+` is now known as `+to.replace(/\\/g,"\")+`<br>"); | |
| document.scrollToBottom("`+channels[x].replace(/\\/g,"\\\\").toLowerCase()+`"); | |
| `; | |
| toSend+=updateNicks(channels[x].replace(/\\/g,"\\\\").toLowerCase()); | |
| } | |
| } | |
| } | |
| Console.code(toSend); | |
| } | |
| }); | |
| $.on('quit',(nick,reason)=>{ | |
| if(startup) { | |
| let toSend=``; | |
| let channels=$.getChannels(); | |
| for(x=0;x<channels.length;x++) { | |
| if($.isIn(channels[x],nick)) { | |
| toSend+=` | |
| document.channel["`+channels[x].replace(/\\/g,"\\\\").toLowerCase()+`"].append("*** `+nick.replace(/\\/g,"\")+` quit (`+reason.replace(/\\/g,"\")+`)<br>"); | |
| document.scrollToBottom("`+channels[x].replace(/\\/g,"\\\\").toLowerCase()+`"); | |
| `; | |
| toSend+=updateNicks(channels[x].toLowerCase()); | |
| } | |
| } | |
| Console.code(toSend); | |
| } | |
| }); | |
| // END APP | |
| function doStartup(id) { | |
| if(!$.isConnected()) { | |
| setTimeout(function() { | |
| doStartup(id); | |
| },5000,id); | |
| } | |
| else { | |
| let channels = $.getChannels(); | |
| let toSend=app+`document.currentNick = "`+$.me()+`";`; | |
| toSend+=`document.createWindow("@status");`; | |
| Console.codeTargeted(id,toSend); | |
| toSend=``; | |
| for(x=0;x<channels.length;x++) { | |
| title=$.getChannelTopic(channels[x]); | |
| toSend+=` | |
| document.createWindow("`+channels[x].replace(/\\/g,"\\\\").toLowerCase()+`"); | |
| `; | |
| toSend+=updateNicks(channels[x].toLowerCase()); | |
| toSend+=updateTopic(channels[x].toLowerCase()); | |
| } | |
| toSend+=` | |
| document.button["@status"].click(); | |
| `; | |
| Console.codeTargeted(id,toSend); | |
| startup=true; | |
| } | |
| } | |
| function updateTopic(chan) { | |
| return `document.topics["`+chan.replace(/\\/g,"\\\\")+`"] = "`+$.getChannelTopic(chan)+`";`; | |
| } | |
| function updateNicks(chan) { | |
| let toSend=``; | |
| let nicks = $.getChannelNicks(chan.replace(/\\/g,"\\\\").toLowerCase()); | |
| nicks.sort(function(a,b){ | |
| if(a.substr(0,1)=='@'){ | |
| if(b.substr(0,1)=='!') | |
| return 1; | |
| else if(b.substr(0,1)=="+"||b.substr(0,1)=="%"||b.substr(0,1)!="@") | |
| return -1; | |
| else | |
| return a-b; | |
| } | |
| else if(b.substr(0,1)=='@') { | |
| if(a.substr(0,1)=='!') | |
| return -1; | |
| else if(a.substr(0,1)=="+"||a.substr(0,1)=="%"||a.substr(0,1)!="@") | |
| return 1; | |
| else | |
| return b-a; | |
| } | |
| else | |
| return a-b; | |
| }); | |
| let nicklist=""; | |
| for(y=0;y<nicks.length;y++){ | |
| nicklist+="<span id='"+nicks[y].replace(/\\/g,"\\\\").toLowerCase()+"'>"+nicks[y].replace(/\\/g,"\")+"</span>"; | |
| } | |
| toSend+=` | |
| document.nicks["`+chan.replace(/\\/g,"\\\\")+`"].html("`+nicklist+`"); | |
| `; | |
| return toSend; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment