diff --git a/README.md b/README.md index 90e31d8..29a00f1 100755 --- a/README.md +++ b/README.md @@ -62,6 +62,13 @@ Read-Write access for working directory #### Changelog +* v1.6.0: + * Forced a good amount of JS from index.php to core.js + * User list is live, and working along with web client + * CSS modifications to dark/light.css for user list + * Autofill /msg [username] for input box on nickname click in userlist + * Ignore some IRC server client flags that are not needed in the chat logs. (NAMES, and MOTD EOF lines) + * v1.5.1: * Add /archive, allows to keep IRC logs while clearing chat history. * Minor fixes / tweaks diff --git a/core.js b/core.js new file mode 100644 index 0000000..e3a421e --- /dev/null +++ b/core.js @@ -0,0 +1,237 @@ + var httpObject = null; + var link = ""; + var link2 = ""; + var link3 = ""; + var pinglink = ""; + var ScrollDown = 0; + var msgBox = document.getElementById('msgs'); + var timerID = 0; + + // Get the HTTP Object + function getHTTPObject() { + if (window.ActiveXObject) return new ActiveXObject("Microsoft.XMLHTTP"); + else if (window.XMLHttpRequest) return new XMLHttpRequest(); + else { + alert("Your browser does not support AJAX."); + return null; + } + } + + + // MSGBOX input + function UserPM(tag) { + var msgInput = document.getElementById('msg'); + var content = msgInput.value; + msgInput.value = '/msg ' + tag + ' ' + content; + } + + // Change the value of the outputText field + function setHtml() { + if(ajaxVar.readyState == 4){ + var response = ajaxVar.responseText; + var msgBox = document.getElementById("msgs"); + msgBox.innerHTML += response; + ScrollDown = 0; + MsgScrollDown(); + } + } + + // Change the value of the outputText field + function setAll() { + if(ajaxVar.readyState == 4){ + var response = ajaxVar.responseText; + var msgBox = document.getElementById("msgs"); + msgBox.innerHTML = response; + ScrollDown = 0; + MsgScrollDown(); + } + } + + // Getting and generating user list. + function genUserlist() { + if(ajaxUserlist.readyState == 4){ + var response = ajaxUserlist.responseText; + var userlist = document.getElementById('userlist'); + userlist.innerHTML = response; + } + } + + function getUserlist() { + ajaxUserlist = getHTTPObject(); + //var randomnumber=Math.floor(Math.random()*10000); + if (ajaxUserlist != null) { + link = "server.php?userlist&nick="+nickName; + ajaxUserlist.open("GET", link , true); + ajaxUserlist.onreadystatechange = genUserlist; + ajaxUserlist.send(null); + } + } + + + + function doNotificationPm() { + if(ajaxVar4.readyState == 4){ + var mentionUser = ajaxVar4.responseText; + if(Notification.permission==="granted") { + var notify = new Notification("Private message from " + mentionUser, { body: ""}); + } + } + } + + function getPmUser() { + ajaxVar4 = getHTTPObject(); + //var randomnumber=Math.floor(Math.random()*10000); + if (ajaxVar4 != null) { + link4 = "server.php?get=notificationpmed&nick="+nickName; + ajaxVar4.open("GET", link4 , true); + ajaxVar4.onreadystatechange = doNotificationPm; + ajaxVar4.send(null); + } + } + + function checkNotificationPm() { + if(ajaxVar5.readyState == 4){ + var returnMsg = ajaxVar5.responseText; + var compareString = "true"; + //console.log(returnMsg); + if(returnMsg.trim() === compareString.trim()) { + getPmUser(); + } + } + } + + function checkPmUrl() { + ajaxVar5 = getHTTPObject(); + //var randomnumber=Math.floor(Math.random()*10000); + if (ajaxVar5 != null) { + link5 = "server.php?get=notificationpmedexists&nick="+nickName; + ajaxVar5.open("GET", link5 , true); + ajaxVar5.onreadystatechange = checkNotificationPm; + ajaxVar5.send(null); + } + } + + + function doNotificationMention() { + if(ajaxVar2.readyState == 4){ + var mentionUser = ajaxVar2.responseText; + if(Notification.permission==="granted") { + var notify = new Notification("You were mentioned by " + mentionUser, { body: ""}); + } + } + } + + function getMentionUser() { + ajaxVar2 = getHTTPObject(); + //var randomnumber=Math.floor(Math.random()*10000); + if (ajaxVar2 != null) { + link2 = "server.php?get=notificationmention&nick="+nickName; + ajaxVar2.open("GET", link2 , true); + ajaxVar2.onreadystatechange = doNotificationMention; + ajaxVar2.send(null); + } + } + + function checkNotificationMention() { + if(ajaxVar3.readyState == 4){ + var returnMsg = ajaxVar3.responseText; + var compareString = "true"; + //console.log(returnMsg); + if(returnMsg.trim() === compareString.trim()) { + getMentionUser(); + } + } + } + + function checkMentionUrl() { + ajaxVar3 = getHTTPObject(); + //var randomnumber=Math.floor(Math.random()*10000); + if (ajaxVar3 != null) { + link3 = "server.php?get=notificationmentionexists&nick="+nickName; + ajaxVar3.open("GET", link3 , true); + ajaxVar3.onreadystatechange = checkNotificationMention; + ajaxVar3.send(null); + } + } + + + // Implement business logic + function serverWrite() { + ajaxVar = getHTTPObject(); + if (ajaxVar != null) { + link = "server.php?nick="+nickName+"&msg="+encodeURIComponent(document.getElementById('msg').value); + ajaxVar.open("GET", link , true); + ajaxVar.send(null); + } + } + + // Implement business logic + function serverReload() { + ajaxVar = getHTTPObject(); + //var randomnumber=Math.floor(Math.random()*10000); + if (ajaxVar != null) { + link = "server.php?get&nick="+nickName; + ajaxVar.open("GET", link , true); + ajaxVar.onreadystatechange = setAll; + ajaxVar.send(null); + } + } + + function MsgScrollDown() { + if(ScrollDown != 1) { + var msgBox = document.getElementById("msgs"); + msgBox.scrollTop = msgBox.scrollHeight; + ScrollDown = 1; + } + } + + function UpdateTimer() { + serverReload(); + MsgScrollDown(); + getUserlist(); + checkPmUrl(); + checkMentionUrl(); + setTimeout(UpdateTimer, 1000); + } + + function doLogin() { + ajaxVar = getHTTPObject(); + if(ajaxVar != null) { + link = "server.php?do=login&nick="+nickName; + ajaxVar.open("GET", link, true); + ajaxVar.onreadystatechange = setHtml; + ajaxVar.send(null); + setTimeout(function() { window.location.reload(); },1000); + } + } + + function doClearLog() { + ajaxVar = getHTTPObject(); + if(ajaxVar != null) { + link = "server.php?do=clearlog&nick="+nickName; + ajaxVar.open("GET", link, true); + ajaxVar.onreadystatechange = setHtml; + ajaxVar.send(null); + setTimeout(function() { window.location.reload(); },1000); + } + } + + function doLogout() { + ajaxVar = getHTTPObject(); + if(ajaxVar != null) { + link = "server.php?do=logout&nick="+nickName; + ajaxVar.open("GET", link, true); + ajaxVar.onreadystatechange = setHtml; + ajaxVar.send(null); + setTimeout(function() { window.location.reload(); },1000); + } + } + + function wrapBBCode(tag) { + var msgInput = document.getElementById('msg'); + var content = msgInput.value; + var selectedContent = content.substring(msgInput.selectionStart, msgInput.selectionEnd); + var beforeContent = content.substring(0, msgInput.selectionStart); + var afterContent = content.substring(msgInput.selectionEnd, content.length); + msgInput.value = beforeContent + '[' + tag + ']' + selectedContent + '[/' + tag + ']' + afterContent; + } diff --git a/dark.css b/dark.css index 671e2f0..738e059 100755 --- a/dark.css +++ b/dark.css @@ -1,19 +1,19 @@ @import url('https://fonts.googleapis.com/css2?family=DM+Mono:ital,wght@0,400;0,500;1,400&display=swap'); -@media only screen and (min-width: 2201px) { body { max-width: 1290px; } #msg { width: 1100px; } } -@media only screen and (max-width: 2200px) { body { max-width: 1290px; } #msg { width: 1100px; } } -@media only screen and (max-width: 1900px) { body { max-width: 1290px; } #msg { width: 1100px; } } -@media only screen and (max-width: 1700px) { body { max-width: 1290px; } #msg { width: 1100px; } } -@media only screen and (max-width: 1500px) { body { max-width: 1290px; } #msg { width: 1100px; } } -@media only screen and (max-width: 1300px) { body { max-width: 1090px; } #msg { width: 920px; } } -@media only screen and (max-width: 1100px) { body { max-width: 890px; } #msg { width: 740px; } } -@media only screen and (max-width: 900px) { body { max-width: 800px; } #msg { width: 660px; } } -@media only screen and (max-width: 800px) { body { max-width: 700px; } #msg { width: 570px; } } -@media only screen and (max-width: 700px) { body { max-width: 600px; } #msg { width: 480px; } } -@media only screen and (max-width: 600px) { body { max-width: 500px; } #msg { width: 380px; } } +@media only screen and (min-width: 2201px) { body { max-width: 1290px; } #msg { width: 960px; } } +@media only screen and (max-width: 2200px) { body { max-width: 1290px; } #msg { width: 960px; } } +@media only screen and (max-width: 1900px) { body { max-width: 1290px; } #msg { width: 960px; } } +@media only screen and (max-width: 1700px) { body { max-width: 1290px; } #msg { width: 960px; } } +@media only screen and (max-width: 1500px) { body { max-width: 1290px; } #msg { width: 960px; } } +@media only screen and (max-width: 1300px) { body { max-width: 1090px; } #msg { width: 780px; } } +@media only screen and (max-width: 1100px) { body { max-width: 890px; } #msg { width: 600px; } } +@media only screen and (max-width: 900px) { body { max-width: 800px; } #msg { width: 520px; } } +@media only screen and (max-width: 800px) { body { max-width: 700px; } #msg { width: 430px; } } +@media only screen and (max-width: 700px) { body { max-width: 600px; } #msg { width: 340px; } } +@media only screen and (max-width: 600px) { body { max-width: 500px; } #msg { width: 240px; } } /* small windows and phones */ -@media only screen and (max-width: 500px) { body { max-width: 450px; } #msg { width: 330px; } } -@media only screen and (max-width: 400px) { body { max-width: 350px; } #msg { width: 230px; } } +@media only screen and (max-width: 500px) { body { max-width: 450px; } #msg { width: 230px; } } +@media only screen and (max-width: 400px) { body { max-width: 350px; } #msg { width: 170px; } } html { font-family: "DM Mono", Arial, sans-serif; @@ -141,6 +141,28 @@ input, button, select, textarea{ overflow-x: auto; } +.clientcontain { + padding: 0px 0px 0px 22px; + margin: 0 auto; +} + +#userlist { + min-width: 110px; + width: 110px; + font-size: 14px; + background-color: #292929; + padding: 2px 5px 2px 5px; + border-radius: 3px; + border: solid 1px #333333; + margin: 0; + vertical-align: top; +} + +#client { + width: 100%; + margin: 0; +} + #msgs tr:nth-child(even) { background-color: #333333; } #msgs tr:nth-child(odd) { background-color: #262626; } #msgs td:nth-child(even) { width: 80%; max-width: 950px; min-width: 320px; } diff --git a/index.php b/index.php index aabecf1..406a53d 100755 --- a/index.php +++ b/index.php @@ -173,7 +173,15 @@ if (isset($_GET['do']) && $_GET['do']=="login" && isset($_POST['submitBtn']) && + + +
> + Settings+ + |
";
@@ -558,6 +573,9 @@ if (!isset($_SESSION['idleirc-user'])) {
}
?>
+ |
+