From 785452873f0ee0a27fc157b482b7551560f0282d Mon Sep 17 00:00:00 2001 From: lolcat Date: Tue, 7 Nov 2023 08:04:56 -0500 Subject: fix typo --- static/client.js | 32 +++- static/serverping.js | 495 ++++++++++++++++++++++++++++++++++++++++++++++++ static/style.css | 140 +++++++++++--- static/themes/Cream.css | 31 +++ 4 files changed, 665 insertions(+), 33 deletions(-) create mode 100644 static/serverping.js create mode 100644 static/themes/Cream.css (limited to 'static') diff --git a/static/client.js b/static/client.js index 2e691f8..5935f92 100644 --- a/static/client.js +++ b/static/client.js @@ -318,11 +318,23 @@ if(image_class !== null){ image_url = htmlspecialchars_decode(image_url); } + var w = Math.round(click.target.naturalWidth); + var h = Math.round(click.target.naturalHeight); + + if( + w === 0 || + h === 0 + ){ + + w = 100; + h = 100; + } + collection = [ { "url": image_url, - "width": Math.round(click.target.naturalWidth), - "height": Math.round(click.target.naturalHeight) + "width": w, + "height": h } ]; @@ -362,10 +374,22 @@ if(image_class !== null){ var imagesize = elem.getElementsByTagName("img")[0]; + var imagesize_w = 0; + var imagesize_h = 0; + if(imagesize.complete){ - var imagesize_w = imagesize.naturalWidth; - var imagesize_h = imagesize.naturalHeight; + imagesize_w = imagesize.naturalWidth; + imagesize_h = imagesize.naturalHeight; + } + + if( + imagesize_w === 0 || + imagesize_h === 0 + ){ + + imagesize_w = 100; + imagesize_h = 100; } for(var i=0; i<Empty>"; + } + + var map = { + '&': '&', + '<': '<', + '>': '>', + '"': '"', + "'": ''' + } + + return str.replace(/[&<>"']/g, function(m){return map[m];}); +} + +// initialize garbage +var list = []; +var pinged_list = []; +var reqs = 0; +var errors = 0; +var sort = 0; // lower ping first + +// check for instance redirect stuff +var redir = ""; +var target = "/web?"; +new URL(window.location.href) + .searchParams + .forEach( + function(value, key){ + + if(key == "target"){ + + target = "/" + encodeURIComponent(value) + "?"; + return; + } + + if(key == "npt"){ return; } + redir += encodeURIComponent(key) + "=" + encodeURIComponent(value) + } + ); + +if(redir != ""){ + redir = target + redir; +} + +var quote = document.createElement("div"); +quote.className = "quote"; +quote.innerHTML = 'Pinged 0 servers (0 failed requests)'; +var [div_servercount, div_failedreqs] = + quote.getElementsByTagName("b"); + +var noscript = document.getElementsByTagName("noscript")[0]; +document.body.insertBefore(quote, noscript.nextSibling); + +// create table +var table = document.createElement("table"); +table.innerHTML = + '' + + '' + + '
Ping' + + 'Server' + + 'Address' + + 'Bot protection' + + 'Real reqs (?)' + + 'Bot reqs (?)' + + 'API' + + 'Version' + + '' + + '' + + ''; + +document.body.insertBefore(table, quote.nextSibling); + +// handle sorting clicks +var tbody = table.getElementsByTagName("tbody")[0]; +var th = table.getElementsByTagName("th"); + +for(var i=0; i'; + + for(var i=0; i<8; i++){ + + html += ''; + break; + } + + if(sorted_list[k].server.ping <= 200){ + + html += '>' + sorted_list[k].server.ping + ''; + break; + } + + html += '>' + number_format(sorted_list[k].server.ping) + ''; + break; + + // server name + case 1: html += ' class="extend">' + htmlspecialchars(sorted_list[k].server.name); break; + case 2: html += '>' + htmlspecialchars(new URL(sorted_list[k].server.ip).host); break; + case 3: // bot protection + switch(sorted_list[k].server.bot_protection){ + + case 0: + html += '>Disabled'; + break; + + case 1: + html += '>Image captcha'; + break; + + case 2: + html += '>Invite only'; + break; + + default: + html += '>Unknown'; + } + break; + + case 4: // real reqs + html += '>' + number_format(sorted_list[k].server.real_requests); + break; + + case 5: // bot reqs + html += '>' + number_format(sorted_list[k].server.bot_requests); + break; + + case 6: // api enabled + + if(sorted_list[k].server.api_enabled){ + + html += '>Yes'; + }else{ + + html += '>No'; + } + break; + + // version + case 7: html += ">v" + sorted_list[k].server.version; break; + } + + html += ''; + } + + html += ''; + } + + tbody.innerHTML = html; +} + +var popup_bg = document.getElementById("popup-bg"); +var popup_wrapper = document.getElementsByClassName("popup-wrapper")[0]; +var popup = popup_wrapper.getElementsByClassName("popup")[0]; +var popup_shown = false; + +popup_bg.addEventListener("click", function(){ + + popup_wrapper.style.display = "none"; + popup_bg.style.display = "none"; +}); + +function show_server(serverid){ + + var html = + '

' + htmlspecialchars(pinged_list[serverid].server.name) + '

' + + 'Description' + + '
' + htmlspecialchars(pinged_list[serverid].server.description) + '
'; + + var url_obj = new URL(pinged_list[serverid].server.ip); + var url = htmlspecialchars(url_obj.origin); + var domain = url_obj.hostname; + + html += + 'URL: ' + url + ' (IP lookup)' + + '

Alt addresses:'; + + var len = pinged_list[serverid].server.alt_addresses.length; + + if(len === 0){ + + html += ' <Empty>'; + }else{ + + html += '
    '; + + for(var i=0; i' + url + ' (IP lookup)'; + }else{ + + console.warn(pinged_list[serverid].server.ip + ": Invalid peer URL => " + pinged_list[serverid].server.alt_addresses[i]); + } + } + + html += '
'; + } + popup.innerHTML = html; + + popup_wrapper.style.display = "block"; + popup_bg.style.display = "block"; +} + +function hide_server(){ + + popup_wrapper.style.display = "none"; + popup_bg.style.display = "none"; +} diff --git a/static/style.css b/static/style.css index fdb4951..bb76c2e 100644 --- a/static/style.css +++ b/static/style.css @@ -1,7 +1,3 @@ - -/* - Global styles -*/ :root{ /* background */ --1d2021: #1d2021; @@ -21,31 +17,11 @@ --default: #d4be98; --keyword: #d8a657; --string: #7daea7; -} - -.theme-white{ - /* background */ - --1d2021: #bdae93; - --282828: #a89984; - --3c3836: #a89984; - --504945: #504945; - /* font */ - --928374: #1d2021; - --a89984: #282828; - --bdae93: #3c3836; - --8ec07c: #52520e; - --ebdbb2: #1d2021; - - /* code highlighter */ - --comment: #6a4400; - --default: #d4be98; - --keyword: #4a4706; - --string: #076678; -} - -.theme-white .autocomplete .entry:hover{ - background:#928374; + /* color codes for instance list */ + --green: #b8bb26; + --yellow: #d8a657; + --red: #fb4934; } audio{ @@ -516,6 +492,7 @@ h3,h4,h5,h6{ .web .favicon img, .favicon-dropdown img{ margin:3px 7px 0 0; + width:16px; height:16px; font-size:12px; line-height:16px; @@ -1020,6 +997,7 @@ table tr a:last-child{ cursor:grab; user-select:none; pointer-events:none; + z-index:5; } #popup:active{ @@ -1046,6 +1024,7 @@ table tr a:last-child{ height:35px; background:var(--1d2021); border-bottom:1px solid var(--928374); + z-index:4; } #popup-bg{ @@ -1057,6 +1036,7 @@ table tr a:last-child{ width:100%; height:100%; display:none; + z-index:3; } #popup-status select{ @@ -1166,6 +1146,108 @@ table tr a:last-child{ color:var(--string); } +/* + Instances page +*/ +.instances table{ + white-space:nowrap; + margin-top:17px; +} + +.instances a{ + color:var(--bdae93); +} + +.instances tbody tr:nth-child(even){ + background:var(--282828); +} + +.instances thead{ + outline:1px solid var(--928374); + outline-offset:-1px; + background:var(--3c3836); + user-select:none; + z-index:2; + position:sticky; + top:0; +} + +.instances th{ + cursor:row-resize; +} + +.instances th:hover{ + background:var(--504945); +} + +.instances tbody{ + outline:1px solid var(--504945); + outline-offset:-1px; + position:relative; + top:-1px; +} + +.instances tbody tr:hover{ + background:var(--3c3836); + cursor:pointer; +} + +.instances .arrow{ + display:inline-block; + position:relative; + top:6px; + margin-right:7px; + width:0; + height:0; + border:6px solid transparent; + border-top:10px solid var(--bdae93); +} + +.instances .arrow.up{ + top:0; + border:6px solid transparent; + border-bottom:10px solid var(--bdae93); +} + +.instances th, .instances td{ + padding:4px 7px; + width:0; +} + +.instances .extend{ + width:unset; + overflow:hidden; + max-width:200px; +} + +.instances .popup-wrapper{ + display:none; + position:fixed; + left:50%; + top:50%; + transform:translate(-50%, -50%); + width:800px; + max-width:100%; + max-height:100%; + overflow-x:auto; + padding:17px; + box-sizing:border-box; + pointer-events:none; + z-index:3; +} + +.instances .popup{ + border:1px solid var(--928374); + background:var(--282828); + padding:7px 10px; + pointer-events:initial; +} + +.instances ul{ + padding-left:20px; +} + + /* Responsive image */ @@ -1221,7 +1303,7 @@ table tr a:last-child{ width:100%; } - table td{ + body:not(.instances) table td{ display:block; width:100%; } diff --git a/static/themes/Cream.css b/static/themes/Cream.css new file mode 100644 index 0000000..3d6b615 --- /dev/null +++ b/static/themes/Cream.css @@ -0,0 +1,31 @@ +:root{ + /* background */ + --1d2021: #bdae93; + --282828: #a89984; + --3c3836: #a89984; + --504945: #504945; + + /* font */ + --928374: #1d2021; + --a89984: #282828; + --bdae93: #3c3836; + --8ec07c: #52520e; + --ebdbb2: #1d2021; + + /* code highlighter */ + --comment: #6a4400; + --default: #d4be98; + --keyword: #4a4706; + --string: #076678; + + /* color codes for instance list */ + --green: #636311; + --yellow: #8a6214; + --red: #711410; +} + +.autocomplete .entry:hover, +.instances th:hover +{ + background:#928374; +} -- cgit v1.2.3