diff --git a/public/analytics.js b/public/analytics.js index 9424a81e..4c21eb03 100644 --- a/public/analytics.js +++ b/public/analytics.js @@ -1,6 +1,5 @@ function memStuff(window, document, Chartist) { 'use strict'; - Chartist.plugins = Chartist.plugins || {}; Chartist.plugins.byteUnits = function(options) { options = Chartist.extend({}, {}, options); @@ -17,7 +16,7 @@ function memStuff(window, document, Chartist) { for(let i = 0; i < vbits.length; i++) { tbits[i] = vbits[i].innerHTML; } - console.log("tbits:",tbits); + console.log("tbits",tbits); const calc = (places) => { if(places==3) return; @@ -40,7 +39,6 @@ function memStuff(window, document, Chartist) { function perfStuff(window, document, Chartist) { 'use strict'; - Chartist.plugins = Chartist.plugins || {}; Chartist.plugins.perfUnits = function(options) { options = Chartist.extend({}, {}, options); @@ -85,18 +83,18 @@ const Terabyte = Gigabyte * 1024; const Petabyte = Terabyte * 1024; function convertByteUnit(bytes, places = 0) { - let out; - if(bytes >= Petabyte) out = [bytes / Petabyte, "PB"]; - else if(bytes >= Terabyte) out = [bytes / Terabyte, "TB"]; - else if(bytes >= Gigabyte) out = [bytes / Gigabyte, "GB"]; - else if(bytes >= Megabyte) out = [bytes / Megabyte, "MB"]; - else if(bytes >= Kilobyte) out = [bytes / Kilobyte, "KB"]; - else out = [bytes,"b"]; + let o; + if(bytes >= Petabyte) o = [bytes / Petabyte, "PB"]; + else if(bytes >= Terabyte) o = [bytes / Terabyte, "TB"]; + else if(bytes >= Gigabyte) o = [bytes / Gigabyte, "GB"]; + else if(bytes >= Megabyte) o = [bytes / Megabyte, "MB"]; + else if(bytes >= Kilobyte) o = [bytes / Kilobyte, "KB"]; + else o = [bytes,"b"]; - if(places==0) return Math.ceil(out[0]) + out[1]; + if(places==0) return Math.ceil(o[0]) + o[1]; else { let ex = Math.pow(10, places); - return (Math.round(out[0], ex) / ex) + out[1]; + return (Math.round(o[0], ex) / ex) + o[1]; } } @@ -106,18 +104,18 @@ let min = sec * 60; let hour = min * 60; let day = hour * 24; function convertPerfUnit(quan, places = 0) { - let out; - if(quan >= day) out = [quan / day, "d"]; - else if(quan >= hour) out = [quan / hour, "h"]; - else if(quan >= min) out = [quan / min, "m"]; - else if(quan >= sec) out = [quan / sec, "s"]; - else if(quan >= ms) out = [quan / ms, "ms"]; - else out = [quan,"Ξs"]; + let o; + if(quan >= day) o = [quan / day, "d"]; + else if(quan >= hour) o = [quan / hour, "h"]; + else if(quan >= min) o = [quan / min, "m"]; + else if(quan >= sec) o = [quan / sec, "s"]; + else if(quan >= ms) o = [quan / ms, "ms"]; + else o = [quan,"Ξs"]; - if(places==0) return Math.ceil(out[0]) + out[1]; + if(places==0) return Math.ceil(o[0]) + o[1]; else { let ex = Math.pow(10, places); - return (Math.round(out[0], ex) / ex) + out[1]; + return (Math.round(o[0], ex) / ex) + o[1]; } } @@ -125,7 +123,7 @@ function convertPerfUnit(quan, places = 0) { // TODO: Load rawLabels and seriesData dynamically rather than potentially fiddling with nonces for the CSP? function buildStatsChart(rawLabels, seriesData, timeRange, legendNames, typ=0) { console.log("buildStatsChart"); - console.log("seriesData:",seriesData); + console.log("seriesData",seriesData); let labels = []; let aphrases = phraseBox["analytics"]; if(timeRange=="one-year") { @@ -158,19 +156,19 @@ function buildStatsChart(rawLabels, seriesData, timeRange, legendNames, typ=0) { continue; } let date = new Date(rawLabels[i]*1000); - console.log("date:", date); + console.log("date", date); let minutes = "0" + date.getMinutes(); let label = date.getHours() + ":" + minutes.substr(-2); - console.log("label:", label); + console.log("label", label); labels.push(label); } } else { for(const i in rawLabels) { let date = new Date(rawLabels[i]*1000); - console.log("date:", date); + console.log("date", date); let minutes = "0" + date.getMinutes(); let label = date.getHours() + ":" + minutes.substr(-2); - console.log("label:", label); + console.log("label", label); labels.push(label); } } diff --git a/public/global.js b/public/global.js index f5e209cc..8a0a5ff3 100644 --- a/public/global.js +++ b/public/global.js @@ -119,7 +119,7 @@ function updateAlertList(menuAlerts) { } bindToAlerts(); - console.log("alertCount:",alertCount) + console.log("alertCount",alertCount) runInitHook("after_update_alert_list", alertCount); } @@ -192,7 +192,7 @@ function SplitN(data,ch,n) { } function wsAlertEvent(data) { - console.log("wsAlertEvent:",data) + console.log("wsAlertEvent",data) addAlert(data, true); alertCount++; @@ -409,7 +409,7 @@ function Paginate(currentPage, lastPage, maxPages) { function mainInit(){ runInitHook("start_init"); - $(".more_topics").click((ev) => { + $(".more_topics").click(ev => { ev.preventDefault(); let moreTopicBlocks = document.getElementsByClassName("more_topic_block_active"); for(let i = 0; i < moreTopicBlocks.length; i++) { @@ -456,7 +456,7 @@ function mainInit(){ dataType: "json", data: { js: 1 }, error: ajaxError, - success: function (data, status, xhr) { + success: function (data,status,xhr) { if("success" in data && data["success"] == "1") return; // addNotice("Failed to add a like: {err}") //likeCountNode.innerHTML = parseInt(likeCountNode.innerHTML)-1; @@ -505,10 +505,10 @@ function mainInit(){ // TODO: Try to de-duplicate some of these fetch calls fetch(url+q+"&js=1", {credentials: "same-origin"}) - .then((resp) => { + .then(resp => { if(!resp.ok) throw(url+q+"&js=1 failed to load"); return resp.json(); - }).then((data) => { + }).then(data => { if(!"Topics" in data) throw("no Topics in data"); let topics = data["Topics"]; console.log("ajax navigated to different page"); @@ -522,29 +522,29 @@ function mainInit(){ history.pushState(obj, obj.Title, obj.Url); rebuildPaginator(data.LastPage); rebindPaginator(); - }).catch((ex) => { + }).catch(ex => { console.log("Unable to get script '"+url+q+"&js=1"+"'"); - console.log("ex: ", ex); + console.log("ex", ex); console.trace(); }); }); } // TODO: Render a headless topics.html instead of the individual topic rows and a bit of JS glue - $(".filter_item").click(function(event) { + $(".filter_item").click(function(ev) { if(!window.location.pathname.startsWith("/topics/")) return - event.preventDefault(); + ev.preventDefault(); let that = this; let fid = this.getAttribute("data-fid"); // TODO: Take mostviewed into account let url = "//"+window.location.host+"/topics/?fids="+fid; fetch(url+"&js=1", {credentials: "same-origin"}) - .then((resp) => { + .then(resp => { if(!resp.ok) throw(url+"&js=1 failed to load"); return resp.json(); - }).then((data) => { - console.log("data:",data); + }).then(data => { + console.log("data",data); if(!"Topics" in data) throw("no Topics in data"); let topics = data["Topics"]; console.log("ajax navigated to "+that.innerText); @@ -568,9 +568,9 @@ function mainInit(){ }); that.classList.add("filter_selected"); $(".topic_list_title h1").text(that.innerText); - }).catch((ex) => { + }).catch(ex => { console.log("Unable to get script '"+url+"&js=1"+"'"); - console.log("ex: ", ex); + console.log("ex", ex); console.trace(); }); }); @@ -592,10 +592,10 @@ function mainInit(){ // TODO: Try to de-duplicate some of these fetch calls fetch(url+q+"&js=1", {credentials: "same-origin"}) - .then((resp) => { + .then(resp => { if(!resp.ok) throw(url+q+"&js=1 failed to load"); return resp.json(); - }).then((data) => { + }).then(data => { if(!"Topics" in data) throw("no Topics in data"); let topics = data["Topics"]; console.log("ajax navigated to search page"); @@ -613,22 +613,22 @@ function mainInit(){ history.pushState(obj, obj.Title, obj.Url); rebuildPaginator(data.LastPage); rebindPaginator(); - }).catch((ex) => { + }).catch(ex => { console.log("Unable to get script '"+url+q+"&js=1"+"'"); - console.log("ex: ", ex); + console.log("ex", ex); console.trace(); }); }); - $(".open_edit").click((event) => { - event.preventDefault(); + $(".open_edit").click(ev => { + ev.preventDefault(); $('.hide_on_edit').addClass("edit_opened"); $('.show_on_edit').addClass("edit_opened"); runHook("open_edit"); }); - $(".topic_item .submit_edit").click(function(event){ - event.preventDefault(); + $(".topic_item .submit_edit").click(function(ev){ + ev.preventDefault(); let topicNameInput = $(".topic_name_input").val(); $(".topic_name").html(topicNameInput); $(".topic_name").attr(topicNameInput); @@ -658,53 +658,53 @@ function mainInit(){ }); }); - $(".delete_item").click(function(event) { - postLink(event); + $(".delete_item").click(function(ev) { + postLink(ev); $(this).closest('.deletable_block').remove(); }); // Miniature implementation of the parser to avoid sending as much data back and forth - function quickParse(msg) { - msg = msg.replace(":)", "😀") - msg = msg.replace(":(", "😞") - msg = msg.replace(":D", "😃") - msg = msg.replace(":P", "😛") - msg = msg.replace(":O", "ðŸ˜ē") - msg = msg.replace(":p", "😛") - msg = msg.replace(":o", "ðŸ˜ē") - msg = msg.replace(";)", "😉") - msg = msg.replace("\n","
") - return msg + function quickParse(m) { + m = m.replace(":)", "😀") + m = m.replace(":(", "😞") + m = m.replace(":D", "😃") + m = m.replace(":P", "😛") + m = m.replace(":O", "ðŸ˜ē") + m = m.replace(":p", "😛") + m = m.replace(":o", "ðŸ˜ē") + m = m.replace(";)", "😉") + m = m.replace("\n","
") + return m } - $(".edit_item").click(function(event){ - event.preventDefault(); + $(".edit_item").click(function(ev){ + ev.preventDefault(); - let blockParent = this.closest('.editable_parent'); - $(blockParent).find('.hide_on_edit').addClass("edit_opened"); - $(blockParent).find('.show_on_edit').addClass("edit_opened"); - $(blockParent).find('.hide_on_block_edit').addClass("edit_opened"); - $(blockParent).find('.show_on_block_edit').addClass("edit_opened"); - let srcNode = blockParent.querySelector(".edit_source"); - let block = blockParent.querySelector('.editable_block'); + let bp = this.closest('.editable_parent'); + $(bp).find('.hide_on_edit').addClass("edit_opened"); + $(bp).find('.show_on_edit').addClass("edit_opened"); + $(bp).find('.hide_on_block_edit').addClass("edit_opened"); + $(bp).find('.show_on_block_edit').addClass("edit_opened"); + let srcNode = bp.querySelector(".edit_source"); + let block = bp.querySelector('.editable_block'); block.classList.add("in_edit"); let source = ""; if(srcNode!=null) source = srcNode.innerText; else source = block.innerHTML; block.innerHTML = Template_topic_c_edit_post({ - ID: blockParent.getAttribute("id").slice("post-".length), + ID: bp.getAttribute("id").slice("post-".length), Source: source, Ref: this.closest('a').getAttribute("href") }) runHook("edit_item_pre_bind"); - $(".submit_edit").click(function(event){ - event.preventDefault(); - $(blockParent).find('.hide_on_edit').removeClass("edit_opened"); - $(blockParent).find('.show_on_edit').removeClass("edit_opened"); - $(blockParent).find('.hide_on_block_edit').removeClass("edit_opened"); - $(blockParent).find('.show_on_block_edit').removeClass("edit_opened"); + $(".submit_edit").click(function(ev){ + ev.preventDefault(); + $(bp).find('.hide_on_edit').removeClass("edit_opened"); + $(bp).find('.show_on_edit').removeClass("edit_opened"); + $(bp).find('.hide_on_block_edit').removeClass("edit_opened"); + $(bp).find('.show_on_block_edit').removeClass("edit_opened"); block.classList.remove("in_edit"); let content = block.querySelector('textarea').value; block.innerHTML = quickParse(content); @@ -725,16 +725,16 @@ function mainInit(){ }); }); - $(".edit_field").click(function(event) { - event.preventDefault(); - let blockParent = $(this).closest('.editable_parent'); - let block = blockParent.find('.editable_block').eq(0); + $(".edit_field").click(function(ev) { + ev.preventDefault(); + let bp = $(this).closest('.editable_parent'); + let block = bp.find('.editable_block').eq(0); block.html(""); - $(".submit_edit").click(function(event) { - event.preventDefault(); - let blockParent = $(this).closest('.editable_parent'); - let block = blockParent.find('.editable_block').eq(0); + $(".submit_edit").click(function(ev) { + ev.preventDefault(); + let bp = $(this).closest('.editable_parent'); + let block = bp.find('.editable_block').eq(0); let content = block.find('input').eq(0).val(); block.html(content); @@ -749,8 +749,8 @@ function mainInit(){ }); }); - $(".edit_fields").click(function(event) { - event.preventDefault(); + $(".edit_fields").click(function(ev) { + ev.preventDefault(); if($(this).find("input").length !== 0) return; //console.log("clicked .edit_fields"); var blockParent = $(this).closest('.editable_parent'); @@ -784,11 +784,11 @@ function mainInit(){ // Remove any handlers already attached to the submitter $(".submit_edit").unbind("click"); - $(".submit_edit").click(function(event) { - event.preventDefault(); + $(".submit_edit").click(function(ev) { + ev.preventDefault(); var outData = {js: 1} - var blockParent = $(this).closest('.editable_parent'); - blockParent.find('.editable_block').each(function() { + var bp = $(this).closest('.editable_parent'); + bp.find('.editable_block').each(function() { var fieldName = this.getAttribute("data-field"); var fieldType = this.getAttribute("data-type"); if(fieldType=="list") { @@ -806,11 +806,11 @@ function mainInit(){ }); var formAction = $(this).closest('a').attr("href"); - //console.log("Form Action:", formAction); + //console.log("Form Action", formAction); //console.log(outData); $.ajax({ url: formAction + "?s=" + me.User.S, type:"POST", dataType:"json", data: outData, error: ajaxError }); - blockParent.find('.hide_on_edit').removeClass("edit_opened"); - blockParent.find('.show_on_edit').removeClass("edit_opened"); + bp.find('.hide_on_edit').removeClass("edit_opened"); + bp.find('.show_on_edit').removeClass("edit_opened"); }); }); @@ -939,7 +939,7 @@ function mainInit(){ $("#poll_results_" + pollID).removeClass("auto_hide"); fetch("/poll/results/" + pollID, { credentials: 'same-origin' - }).then(resp => resp.text()).catch(err => console.error("err:",err)).then((rawData) => { + }).then(resp => resp.text()).catch(err => console.error("err",err)).then(rawData => { // TODO: Make sure the received data is actually a list of integers let data = JSON.parse(rawData); let allZero = true; @@ -953,8 +953,8 @@ function mainInit(){ } $("#poll_results_"+pollID+" .user_content").html("
"); - console.log("rawData: ", rawData); - console.log("series: ", data); + console.log("rawData", rawData); + console.log("series", data); Chartist.Pie('#poll_results_chart_'+pollID, { series: data, }, { @@ -965,4 +965,4 @@ function mainInit(){ runInitHook("almost_end_init"); runInitHook("end_init"); -}; +} \ No newline at end of file diff --git a/public/panel_forums.js b/public/panel_forums.js index 80d16ec4..5966df48 100644 --- a/public/panel_forums.js +++ b/public/panel_forums.js @@ -8,19 +8,19 @@ formVars = { var forums = {}; let items = document.getElementsByClassName("panel_forum_item"); for(let i = 0; item = items[i]; i++) forums[i] = item.getAttribute("data-fid"); -console.log("forums:",forums); +console.log("forums",forums); Sortable.create(document.getElementById("panel_forums"), { sort: true, onEnd: (evt) => { - console.log("pre forums:", forums) - console.log("evt:", evt) + console.log("pre forums", forums) + console.log("evt", evt) let oldFid = forums[evt.newIndex]; forums[evt.oldIndex] = oldFid; let newFid = evt.item.getAttribute("data-fid"); - console.log("newFid:", newFid); + console.log("newFid", newFid); forums[evt.newIndex] = newFid; - console.log("post forums:", forums); + console.log("post forums", forums); } }); @@ -37,12 +37,12 @@ document.getElementById("panel_forums_order_button").addEventListener("click", ( if(req.status!==200) return; let resp = JSON.parse(req.responseText); - console.log("resp:", resp); + console.log("resp", resp); // TODO: Should we move other notices into TmplPhrases like this one? pushNotice(phraseBox["panel"]["panel.forums_order_updated"]); if(resp.success==1) return; } catch(ex) { - console.error("exception: ", ex) + console.error("ex", ex) } console.trace(); } @@ -56,4 +56,4 @@ document.getElementById("panel_forums_order_button").addEventListener("click", ( }); }); -})(); \ No newline at end of file +})() \ No newline at end of file diff --git a/public/panel_menu_items.js b/public/panel_menu_items.js index e671a749..e2bbd944 100644 --- a/public/panel_menu_items.js +++ b/public/panel_menu_items.js @@ -9,14 +9,14 @@ for(let i = 0; item = items[i]; i++) menuItems[i] = item.getAttribute("data-miid Sortable.create(document.getElementById("panel_menu_item_holder"), { sort: true, onEnd: (evt) => { - console.log("pre menuItems:", menuItems) - console.log("evt:", evt) + console.log("pre menuItems", menuItems) + console.log("evt", evt) let oldMiid = menuItems[evt.newIndex]; menuItems[evt.oldIndex] = oldMiid; let newMiid = evt.item.getAttribute("data-miid"); - console.log("newMiid:", newMiid); + console.log("newMiid", newMiid); menuItems[evt.newIndex] = newMiid; - console.log("post menuItems:", menuItems); + console.log("post menuItems", menuItems); } }); @@ -32,13 +32,13 @@ document.getElementById("panel_menu_items_order_button").addEventListener("click // TODO: Signal the error with a notice if(req.status===200) { let resp = JSON.parse(req.responseText); - console.log("resp:", resp); + console.log("resp", resp); // TODO: Should we move other notices into TmplPhrases like this one? pushNotice(phraseBox["panel"]["panel.themes_menus_items_order_updated"]); if(resp.success==1) return; } } catch(ex) { - console.error("exception:", ex) + console.error("ex", ex) } console.trace(); } @@ -53,4 +53,4 @@ document.getElementById("panel_menu_items_order_button").addEventListener("click }); }); -})(); \ No newline at end of file +})() \ No newline at end of file diff --git a/public/register.js b/public/register.js index adbe070b..c1a96ee3 100644 --- a/public/register.js +++ b/public/register.js @@ -4,11 +4,11 @@ .then(resp => { if(resp.status!==200) { console.log("error"); - console.log("response:", resp); + console.log("resp:", resp); return; } resp.text().then(data => eval(data)); }) - .catch(err => console.log("err:", err)); + .catch(err => console.log("err", err)); }); -})(); \ No newline at end of file +})() \ No newline at end of file diff --git a/templates/header.html b/templates/header.html index f99092b2..a921413d 100644 --- a/templates/header.html +++ b/templates/header.html @@ -57,7 +57,7 @@
-
+
{{range .Header.NoticeList}} {{template "notice.html" . }}{{end}}
\ No newline at end of file diff --git a/templates/topic_c_attach_item.html b/templates/topic_c_attach_item.html index 5fd73ac4..22230712 100644 --- a/templates/topic_c_attach_item.html +++ b/templates/topic_c_attach_item.html @@ -1,4 +1,4 @@ -{{if .ImgSrc}}{{end}} +{{if .ImgSrc}}{{end}} {{.Path}} \ No newline at end of file diff --git a/templates/topics.html b/templates/topics.html index 0ad02b68..a67f04a0 100644 --- a/templates/topics.html +++ b/templates/topics.html @@ -1,5 +1,5 @@ {{template "header.html" . }} - +
@@ -9,7 +9,7 @@ {{if .ForumList}}
- - {{if eq .Sort.SortBy "mostviewed" }}{{lang "topic_list.most_viewed_filter"}}{{else}}{{lang "topic_list.most_recent_filter"}}{{end}} â–ū + {{if eq .Sort.SortBy "mostviewed"}}{{lang "topic_list.most_viewed_filter"}}{{else}}{{lang "topic_list.most_recent_filter"}}{{end}} â–ū