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("