save bytes

This commit is contained in:
Azareal 2020-03-09 20:37:41 +10:00
parent aa303dc14d
commit 42b38ae3d8
10 changed files with 128 additions and 130 deletions

View File

@ -1,6 +1,5 @@
function memStuff(window, document, Chartist) { function memStuff(window, document, Chartist) {
'use strict'; 'use strict';
Chartist.plugins = Chartist.plugins || {}; Chartist.plugins = Chartist.plugins || {};
Chartist.plugins.byteUnits = function(options) { Chartist.plugins.byteUnits = function(options) {
options = Chartist.extend({}, {}, options); options = Chartist.extend({}, {}, options);
@ -17,7 +16,7 @@ function memStuff(window, document, Chartist) {
for(let i = 0; i < vbits.length; i++) { for(let i = 0; i < vbits.length; i++) {
tbits[i] = vbits[i].innerHTML; tbits[i] = vbits[i].innerHTML;
} }
console.log("tbits:",tbits); console.log("tbits",tbits);
const calc = (places) => { const calc = (places) => {
if(places==3) return; if(places==3) return;
@ -40,7 +39,6 @@ function memStuff(window, document, Chartist) {
function perfStuff(window, document, Chartist) { function perfStuff(window, document, Chartist) {
'use strict'; 'use strict';
Chartist.plugins = Chartist.plugins || {}; Chartist.plugins = Chartist.plugins || {};
Chartist.plugins.perfUnits = function(options) { Chartist.plugins.perfUnits = function(options) {
options = Chartist.extend({}, {}, options); options = Chartist.extend({}, {}, options);
@ -85,18 +83,18 @@ const Terabyte = Gigabyte * 1024;
const Petabyte = Terabyte * 1024; const Petabyte = Terabyte * 1024;
function convertByteUnit(bytes, places = 0) { function convertByteUnit(bytes, places = 0) {
let out; let o;
if(bytes >= Petabyte) out = [bytes / Petabyte, "PB"]; if(bytes >= Petabyte) o = [bytes / Petabyte, "PB"];
else if(bytes >= Terabyte) out = [bytes / Terabyte, "TB"]; else if(bytes >= Terabyte) o = [bytes / Terabyte, "TB"];
else if(bytes >= Gigabyte) out = [bytes / Gigabyte, "GB"]; else if(bytes >= Gigabyte) o = [bytes / Gigabyte, "GB"];
else if(bytes >= Megabyte) out = [bytes / Megabyte, "MB"]; else if(bytes >= Megabyte) o = [bytes / Megabyte, "MB"];
else if(bytes >= Kilobyte) out = [bytes / Kilobyte, "KB"]; else if(bytes >= Kilobyte) o = [bytes / Kilobyte, "KB"];
else out = [bytes,"b"]; 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 { else {
let ex = Math.pow(10, places); 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 hour = min * 60;
let day = hour * 24; let day = hour * 24;
function convertPerfUnit(quan, places = 0) { function convertPerfUnit(quan, places = 0) {
let out; let o;
if(quan >= day) out = [quan / day, "d"]; if(quan >= day) o = [quan / day, "d"];
else if(quan >= hour) out = [quan / hour, "h"]; else if(quan >= hour) o = [quan / hour, "h"];
else if(quan >= min) out = [quan / min, "m"]; else if(quan >= min) o = [quan / min, "m"];
else if(quan >= sec) out = [quan / sec, "s"]; else if(quan >= sec) o = [quan / sec, "s"];
else if(quan >= ms) out = [quan / ms, "ms"]; else if(quan >= ms) o = [quan / ms, "ms"];
else out = [quan,"μs"]; 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 { else {
let ex = Math.pow(10, places); 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? // TODO: Load rawLabels and seriesData dynamically rather than potentially fiddling with nonces for the CSP?
function buildStatsChart(rawLabels, seriesData, timeRange, legendNames, typ=0) { function buildStatsChart(rawLabels, seriesData, timeRange, legendNames, typ=0) {
console.log("buildStatsChart"); console.log("buildStatsChart");
console.log("seriesData:",seriesData); console.log("seriesData",seriesData);
let labels = []; let labels = [];
let aphrases = phraseBox["analytics"]; let aphrases = phraseBox["analytics"];
if(timeRange=="one-year") { if(timeRange=="one-year") {
@ -158,19 +156,19 @@ function buildStatsChart(rawLabels, seriesData, timeRange, legendNames, typ=0) {
continue; continue;
} }
let date = new Date(rawLabels[i]*1000); let date = new Date(rawLabels[i]*1000);
console.log("date:", date); console.log("date", date);
let minutes = "0" + date.getMinutes(); let minutes = "0" + date.getMinutes();
let label = date.getHours() + ":" + minutes.substr(-2); let label = date.getHours() + ":" + minutes.substr(-2);
console.log("label:", label); console.log("label", label);
labels.push(label); labels.push(label);
} }
} else { } else {
for(const i in rawLabels) { for(const i in rawLabels) {
let date = new Date(rawLabels[i]*1000); let date = new Date(rawLabels[i]*1000);
console.log("date:", date); console.log("date", date);
let minutes = "0" + date.getMinutes(); let minutes = "0" + date.getMinutes();
let label = date.getHours() + ":" + minutes.substr(-2); let label = date.getHours() + ":" + minutes.substr(-2);
console.log("label:", label); console.log("label", label);
labels.push(label); labels.push(label);
} }
} }

View File

@ -119,7 +119,7 @@ function updateAlertList(menuAlerts) {
} }
bindToAlerts(); bindToAlerts();
console.log("alertCount:",alertCount) console.log("alertCount",alertCount)
runInitHook("after_update_alert_list", alertCount); runInitHook("after_update_alert_list", alertCount);
} }
@ -192,7 +192,7 @@ function SplitN(data,ch,n) {
} }
function wsAlertEvent(data) { function wsAlertEvent(data) {
console.log("wsAlertEvent:",data) console.log("wsAlertEvent",data)
addAlert(data, true); addAlert(data, true);
alertCount++; alertCount++;
@ -409,7 +409,7 @@ function Paginate(currentPage, lastPage, maxPages) {
function mainInit(){ function mainInit(){
runInitHook("start_init"); runInitHook("start_init");
$(".more_topics").click((ev) => { $(".more_topics").click(ev => {
ev.preventDefault(); ev.preventDefault();
let moreTopicBlocks = document.getElementsByClassName("more_topic_block_active"); let moreTopicBlocks = document.getElementsByClassName("more_topic_block_active");
for(let i = 0; i < moreTopicBlocks.length; i++) { for(let i = 0; i < moreTopicBlocks.length; i++) {
@ -456,7 +456,7 @@ function mainInit(){
dataType: "json", dataType: "json",
data: { js: 1 }, data: { js: 1 },
error: ajaxError, error: ajaxError,
success: function (data, status, xhr) { success: function (data,status,xhr) {
if("success" in data && data["success"] == "1") return; if("success" in data && data["success"] == "1") return;
// addNotice("Failed to add a like: {err}") // addNotice("Failed to add a like: {err}")
//likeCountNode.innerHTML = parseInt(likeCountNode.innerHTML)-1; //likeCountNode.innerHTML = parseInt(likeCountNode.innerHTML)-1;
@ -505,10 +505,10 @@ function mainInit(){
// TODO: Try to de-duplicate some of these fetch calls // TODO: Try to de-duplicate some of these fetch calls
fetch(url+q+"&js=1", {credentials: "same-origin"}) fetch(url+q+"&js=1", {credentials: "same-origin"})
.then((resp) => { .then(resp => {
if(!resp.ok) throw(url+q+"&js=1 failed to load"); if(!resp.ok) throw(url+q+"&js=1 failed to load");
return resp.json(); return resp.json();
}).then((data) => { }).then(data => {
if(!"Topics" in data) throw("no Topics in data"); if(!"Topics" in data) throw("no Topics in data");
let topics = data["Topics"]; let topics = data["Topics"];
console.log("ajax navigated to different page"); console.log("ajax navigated to different page");
@ -522,29 +522,29 @@ function mainInit(){
history.pushState(obj, obj.Title, obj.Url); history.pushState(obj, obj.Title, obj.Url);
rebuildPaginator(data.LastPage); rebuildPaginator(data.LastPage);
rebindPaginator(); rebindPaginator();
}).catch((ex) => { }).catch(ex => {
console.log("Unable to get script '"+url+q+"&js=1"+"'"); console.log("Unable to get script '"+url+q+"&js=1"+"'");
console.log("ex: ", ex); console.log("ex", ex);
console.trace(); console.trace();
}); });
}); });
} }
// TODO: Render a headless topics.html instead of the individual topic rows and a bit of JS glue // 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 if(!window.location.pathname.startsWith("/topics/")) return
event.preventDefault(); ev.preventDefault();
let that = this; let that = this;
let fid = this.getAttribute("data-fid"); let fid = this.getAttribute("data-fid");
// TODO: Take mostviewed into account // TODO: Take mostviewed into account
let url = "//"+window.location.host+"/topics/?fids="+fid; let url = "//"+window.location.host+"/topics/?fids="+fid;
fetch(url+"&js=1", {credentials: "same-origin"}) fetch(url+"&js=1", {credentials: "same-origin"})
.then((resp) => { .then(resp => {
if(!resp.ok) throw(url+"&js=1 failed to load"); if(!resp.ok) throw(url+"&js=1 failed to load");
return resp.json(); return resp.json();
}).then((data) => { }).then(data => {
console.log("data:",data); console.log("data",data);
if(!"Topics" in data) throw("no Topics in data"); if(!"Topics" in data) throw("no Topics in data");
let topics = data["Topics"]; let topics = data["Topics"];
console.log("ajax navigated to "+that.innerText); console.log("ajax navigated to "+that.innerText);
@ -568,9 +568,9 @@ function mainInit(){
}); });
that.classList.add("filter_selected"); that.classList.add("filter_selected");
$(".topic_list_title h1").text(that.innerText); $(".topic_list_title h1").text(that.innerText);
}).catch((ex) => { }).catch(ex => {
console.log("Unable to get script '"+url+"&js=1"+"'"); console.log("Unable to get script '"+url+"&js=1"+"'");
console.log("ex: ", ex); console.log("ex", ex);
console.trace(); console.trace();
}); });
}); });
@ -592,10 +592,10 @@ function mainInit(){
// TODO: Try to de-duplicate some of these fetch calls // TODO: Try to de-duplicate some of these fetch calls
fetch(url+q+"&js=1", {credentials: "same-origin"}) fetch(url+q+"&js=1", {credentials: "same-origin"})
.then((resp) => { .then(resp => {
if(!resp.ok) throw(url+q+"&js=1 failed to load"); if(!resp.ok) throw(url+q+"&js=1 failed to load");
return resp.json(); return resp.json();
}).then((data) => { }).then(data => {
if(!"Topics" in data) throw("no Topics in data"); if(!"Topics" in data) throw("no Topics in data");
let topics = data["Topics"]; let topics = data["Topics"];
console.log("ajax navigated to search page"); console.log("ajax navigated to search page");
@ -613,22 +613,22 @@ function mainInit(){
history.pushState(obj, obj.Title, obj.Url); history.pushState(obj, obj.Title, obj.Url);
rebuildPaginator(data.LastPage); rebuildPaginator(data.LastPage);
rebindPaginator(); rebindPaginator();
}).catch((ex) => { }).catch(ex => {
console.log("Unable to get script '"+url+q+"&js=1"+"'"); console.log("Unable to get script '"+url+q+"&js=1"+"'");
console.log("ex: ", ex); console.log("ex", ex);
console.trace(); console.trace();
}); });
}); });
$(".open_edit").click((event) => { $(".open_edit").click(ev => {
event.preventDefault(); ev.preventDefault();
$('.hide_on_edit').addClass("edit_opened"); $('.hide_on_edit').addClass("edit_opened");
$('.show_on_edit').addClass("edit_opened"); $('.show_on_edit').addClass("edit_opened");
runHook("open_edit"); runHook("open_edit");
}); });
$(".topic_item .submit_edit").click(function(event){ $(".topic_item .submit_edit").click(function(ev){
event.preventDefault(); ev.preventDefault();
let topicNameInput = $(".topic_name_input").val(); let topicNameInput = $(".topic_name_input").val();
$(".topic_name").html(topicNameInput); $(".topic_name").html(topicNameInput);
$(".topic_name").attr(topicNameInput); $(".topic_name").attr(topicNameInput);
@ -658,53 +658,53 @@ function mainInit(){
}); });
}); });
$(".delete_item").click(function(event) { $(".delete_item").click(function(ev) {
postLink(event); postLink(ev);
$(this).closest('.deletable_block').remove(); $(this).closest('.deletable_block').remove();
}); });
// Miniature implementation of the parser to avoid sending as much data back and forth // Miniature implementation of the parser to avoid sending as much data back and forth
function quickParse(msg) { function quickParse(m) {
msg = msg.replace(":)", "😀") m = m.replace(":)", "😀")
msg = msg.replace(":(", "😞") m = m.replace(":(", "😞")
msg = msg.replace(":D", "😃") m = m.replace(":D", "😃")
msg = msg.replace(":P", "😛") m = m.replace(":P", "😛")
msg = msg.replace(":O", "😲") m = m.replace(":O", "😲")
msg = msg.replace(":p", "😛") m = m.replace(":p", "😛")
msg = msg.replace(":o", "😲") m = m.replace(":o", "😲")
msg = msg.replace(";)", "😉") m = m.replace(";)", "😉")
msg = msg.replace("\n","<br>") m = m.replace("\n","<br>")
return msg return m
} }
$(".edit_item").click(function(event){ $(".edit_item").click(function(ev){
event.preventDefault(); ev.preventDefault();
let blockParent = this.closest('.editable_parent'); let bp = this.closest('.editable_parent');
$(blockParent).find('.hide_on_edit').addClass("edit_opened"); $(bp).find('.hide_on_edit').addClass("edit_opened");
$(blockParent).find('.show_on_edit').addClass("edit_opened"); $(bp).find('.show_on_edit').addClass("edit_opened");
$(blockParent).find('.hide_on_block_edit').addClass("edit_opened"); $(bp).find('.hide_on_block_edit').addClass("edit_opened");
$(blockParent).find('.show_on_block_edit').addClass("edit_opened"); $(bp).find('.show_on_block_edit').addClass("edit_opened");
let srcNode = blockParent.querySelector(".edit_source"); let srcNode = bp.querySelector(".edit_source");
let block = blockParent.querySelector('.editable_block'); let block = bp.querySelector('.editable_block');
block.classList.add("in_edit"); block.classList.add("in_edit");
let source = ""; let source = "";
if(srcNode!=null) source = srcNode.innerText; if(srcNode!=null) source = srcNode.innerText;
else source = block.innerHTML; else source = block.innerHTML;
block.innerHTML = Template_topic_c_edit_post({ block.innerHTML = Template_topic_c_edit_post({
ID: blockParent.getAttribute("id").slice("post-".length), ID: bp.getAttribute("id").slice("post-".length),
Source: source, Source: source,
Ref: this.closest('a').getAttribute("href") Ref: this.closest('a').getAttribute("href")
}) })
runHook("edit_item_pre_bind"); runHook("edit_item_pre_bind");
$(".submit_edit").click(function(event){ $(".submit_edit").click(function(ev){
event.preventDefault(); ev.preventDefault();
$(blockParent).find('.hide_on_edit').removeClass("edit_opened"); $(bp).find('.hide_on_edit').removeClass("edit_opened");
$(blockParent).find('.show_on_edit').removeClass("edit_opened"); $(bp).find('.show_on_edit').removeClass("edit_opened");
$(blockParent).find('.hide_on_block_edit').removeClass("edit_opened"); $(bp).find('.hide_on_block_edit').removeClass("edit_opened");
$(blockParent).find('.show_on_block_edit').removeClass("edit_opened"); $(bp).find('.show_on_block_edit').removeClass("edit_opened");
block.classList.remove("in_edit"); block.classList.remove("in_edit");
let content = block.querySelector('textarea').value; let content = block.querySelector('textarea').value;
block.innerHTML = quickParse(content); block.innerHTML = quickParse(content);
@ -725,16 +725,16 @@ function mainInit(){
}); });
}); });
$(".edit_field").click(function(event) { $(".edit_field").click(function(ev) {
event.preventDefault(); ev.preventDefault();
let blockParent = $(this).closest('.editable_parent'); let bp = $(this).closest('.editable_parent');
let block = blockParent.find('.editable_block').eq(0); let block = bp.find('.editable_block').eq(0);
block.html("<input name='edit_field' value='" + block.text() + "' type='text'/><a href='" + $(this).closest('a').attr("href") + "'><button class='submit_edit' type='submit'>Update</button></a>"); block.html("<input name='edit_field' value='" + block.text() + "' type='text'/><a href='" + $(this).closest('a').attr("href") + "'><button class='submit_edit' type='submit'>Update</button></a>");
$(".submit_edit").click(function(event) { $(".submit_edit").click(function(ev) {
event.preventDefault(); ev.preventDefault();
let blockParent = $(this).closest('.editable_parent'); let bp = $(this).closest('.editable_parent');
let block = blockParent.find('.editable_block').eq(0); let block = bp.find('.editable_block').eq(0);
let content = block.find('input').eq(0).val(); let content = block.find('input').eq(0).val();
block.html(content); block.html(content);
@ -749,8 +749,8 @@ function mainInit(){
}); });
}); });
$(".edit_fields").click(function(event) { $(".edit_fields").click(function(ev) {
event.preventDefault(); ev.preventDefault();
if($(this).find("input").length !== 0) return; if($(this).find("input").length !== 0) return;
//console.log("clicked .edit_fields"); //console.log("clicked .edit_fields");
var blockParent = $(this).closest('.editable_parent'); var blockParent = $(this).closest('.editable_parent');
@ -784,11 +784,11 @@ function mainInit(){
// Remove any handlers already attached to the submitter // Remove any handlers already attached to the submitter
$(".submit_edit").unbind("click"); $(".submit_edit").unbind("click");
$(".submit_edit").click(function(event) { $(".submit_edit").click(function(ev) {
event.preventDefault(); ev.preventDefault();
var outData = {js: 1} var outData = {js: 1}
var blockParent = $(this).closest('.editable_parent'); var bp = $(this).closest('.editable_parent');
blockParent.find('.editable_block').each(function() { bp.find('.editable_block').each(function() {
var fieldName = this.getAttribute("data-field"); var fieldName = this.getAttribute("data-field");
var fieldType = this.getAttribute("data-type"); var fieldType = this.getAttribute("data-type");
if(fieldType=="list") { if(fieldType=="list") {
@ -806,11 +806,11 @@ function mainInit(){
}); });
var formAction = $(this).closest('a').attr("href"); var formAction = $(this).closest('a').attr("href");
//console.log("Form Action:", formAction); //console.log("Form Action", formAction);
//console.log(outData); //console.log(outData);
$.ajax({ url: formAction + "?s=" + me.User.S, type:"POST", dataType:"json", data: outData, error: ajaxError }); $.ajax({ url: formAction + "?s=" + me.User.S, type:"POST", dataType:"json", data: outData, error: ajaxError });
blockParent.find('.hide_on_edit').removeClass("edit_opened"); bp.find('.hide_on_edit').removeClass("edit_opened");
blockParent.find('.show_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"); $("#poll_results_" + pollID).removeClass("auto_hide");
fetch("/poll/results/" + pollID, { fetch("/poll/results/" + pollID, {
credentials: 'same-origin' 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 // TODO: Make sure the received data is actually a list of integers
let data = JSON.parse(rawData); let data = JSON.parse(rawData);
let allZero = true; let allZero = true;
@ -953,8 +953,8 @@ function mainInit(){
} }
$("#poll_results_"+pollID+" .user_content").html("<div id='poll_results_chart_"+pollID+"'></div>"); $("#poll_results_"+pollID+" .user_content").html("<div id='poll_results_chart_"+pollID+"'></div>");
console.log("rawData: ", rawData); console.log("rawData", rawData);
console.log("series: ", data); console.log("series", data);
Chartist.Pie('#poll_results_chart_'+pollID, { Chartist.Pie('#poll_results_chart_'+pollID, {
series: data, series: data,
}, { }, {
@ -965,4 +965,4 @@ function mainInit(){
runInitHook("almost_end_init"); runInitHook("almost_end_init");
runInitHook("end_init"); runInitHook("end_init");
}; }

View File

@ -8,19 +8,19 @@ formVars = {
var forums = {}; var forums = {};
let items = document.getElementsByClassName("panel_forum_item"); let items = document.getElementsByClassName("panel_forum_item");
for(let i = 0; item = items[i]; i++) forums[i] = item.getAttribute("data-fid"); 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"), { Sortable.create(document.getElementById("panel_forums"), {
sort: true, sort: true,
onEnd: (evt) => { onEnd: (evt) => {
console.log("pre forums:", forums) console.log("pre forums", forums)
console.log("evt:", evt) console.log("evt", evt)
let oldFid = forums[evt.newIndex]; let oldFid = forums[evt.newIndex];
forums[evt.oldIndex] = oldFid; forums[evt.oldIndex] = oldFid;
let newFid = evt.item.getAttribute("data-fid"); let newFid = evt.item.getAttribute("data-fid");
console.log("newFid:", newFid); console.log("newFid", newFid);
forums[evt.newIndex] = 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; if(req.status!==200) return;
let resp = JSON.parse(req.responseText); 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? // TODO: Should we move other notices into TmplPhrases like this one?
pushNotice(phraseBox["panel"]["panel.forums_order_updated"]); pushNotice(phraseBox["panel"]["panel.forums_order_updated"]);
if(resp.success==1) return; if(resp.success==1) return;
} catch(ex) { } catch(ex) {
console.error("exception: ", ex) console.error("ex", ex)
} }
console.trace(); console.trace();
} }
@ -56,4 +56,4 @@ document.getElementById("panel_forums_order_button").addEventListener("click", (
}); });
}); });
})(); })()

View File

@ -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"), { Sortable.create(document.getElementById("panel_menu_item_holder"), {
sort: true, sort: true,
onEnd: (evt) => { onEnd: (evt) => {
console.log("pre menuItems:", menuItems) console.log("pre menuItems", menuItems)
console.log("evt:", evt) console.log("evt", evt)
let oldMiid = menuItems[evt.newIndex]; let oldMiid = menuItems[evt.newIndex];
menuItems[evt.oldIndex] = oldMiid; menuItems[evt.oldIndex] = oldMiid;
let newMiid = evt.item.getAttribute("data-miid"); let newMiid = evt.item.getAttribute("data-miid");
console.log("newMiid:", newMiid); console.log("newMiid", newMiid);
menuItems[evt.newIndex] = 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 // TODO: Signal the error with a notice
if(req.status===200) { if(req.status===200) {
let resp = JSON.parse(req.responseText); 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? // TODO: Should we move other notices into TmplPhrases like this one?
pushNotice(phraseBox["panel"]["panel.themes_menus_items_order_updated"]); pushNotice(phraseBox["panel"]["panel.themes_menus_items_order_updated"]);
if(resp.success==1) return; if(resp.success==1) return;
} }
} catch(ex) { } catch(ex) {
console.error("exception:", ex) console.error("ex", ex)
} }
console.trace(); console.trace();
} }
@ -53,4 +53,4 @@ document.getElementById("panel_menu_items_order_button").addEventListener("click
}); });
}); });
})(); })()

View File

@ -4,11 +4,11 @@
.then(resp => { .then(resp => {
if(resp.status!==200) { if(resp.status!==200) {
console.log("error"); console.log("error");
console.log("response:", resp); console.log("resp:", resp);
return; return;
} }
resp.text().then(data => eval(data)); resp.text().then(data => eval(data));
}) })
.catch(err => console.log("err:", err)); .catch(err => console.log("err", err));
}); });
})(); })()

View File

@ -57,7 +57,7 @@
<div class="midRow"> <div class="midRow">
<div class="midLeft"></div> <div class="midLeft"></div>
<div id="back" class="zone_{{.Header.Zone}}{{if hasWidgets "rightSidebar" .Header }} shrink_main{{end}}"> <div id="back" class="zone_{{.Header.Zone}}{{if hasWidgets "rightSidebar" .Header }} shrink_main{{end}}">
<div id="main" > <div id="main">
<div class="alertbox initial_alertbox">{{range .Header.NoticeList}} <div class="alertbox initial_alertbox">{{range .Header.NoticeList}}
{{template "notice.html" . }}{{end}} {{template "notice.html" . }}{{end}}
</div> </div>

View File

@ -1,4 +1,4 @@
{{if .ImgSrc}}<img src='{{.ImgSrc}}' height=24 width=24 />{{end}} {{if .ImgSrc}}<img src='{{.ImgSrc}}' height=24 width=24/>{{end}}
<span class='attach_item_path' aid='{{.ID}}' fullpath='{{.FullPath}}'>{{.Path}}</span> <span class='attach_item_path' aid='{{.ID}}' fullpath='{{.FullPath}}'>{{.Path}}</span>
<button class='attach_item_select'>{{lang "topic.select_button_text"}}</button> <button class='attach_item_select'>{{lang "topic.select_button_text"}}</button>
<button class='attach_item_copy'>{{lang "topic.copy_button_text"}}</button> <button class='attach_item_copy'>{{lang "topic.copy_button_text"}}</button>

View File

@ -1,5 +1,5 @@
{{template "header.html" . }} {{template "header.html" . }}
<link rel="canonical" href="//{{.Site.URL}}/topics/{{if eq .Sort.SortBy "mostviewed"}}most-viewed/{{end}}{{if gt .Page 1}}?page={{.Page}}{{end}}" /> <link rel="canonical" href="//{{.Site.URL}}/topics/{{if eq .Sort.SortBy "mostviewed"}}most-viewed/{{end}}{{if gt .Page 1}}?page={{.Page}}{{end}}"/>
<main id="topicsItemList" itemscope itemtype="http://schema.org/ItemList"> <main id="topicsItemList" itemscope itemtype="http://schema.org/ItemList">
<div class="rowblock rowhead topic_list_title_block{{if .CurrentUser.Loggedin}} has_opt{{end}}"> <div class="rowblock rowhead topic_list_title_block{{if .CurrentUser.Loggedin}} has_opt{{end}}">
@ -9,7 +9,7 @@
{{if .ForumList}} {{if .ForumList}}
<div class="opt filter_opt"> <div class="opt filter_opt">
<a class="filter_opt_sep"> - </a> <a class="filter_opt_sep"> - </a>
<a href="#" class="filter_opt_label link_label" data-for="topic_list_filter_select">{{if eq .Sort.SortBy "mostviewed" }}{{lang "topic_list.most_viewed_filter"}}{{else}}{{lang "topic_list.most_recent_filter"}}{{end}} <span class="filter_opt_pointy"></span></a> <a href="#" class="filter_opt_label link_label" data-for="topic_list_filter_select">{{if eq .Sort.SortBy "mostviewed"}}{{lang "topic_list.most_viewed_filter"}}{{else}}{{lang "topic_list.most_recent_filter"}}{{end}} <span class="filter_opt_pointy"></span></a>
<div id="topic_list_filter_select" class="link_select"> <div id="topic_list_filter_select" class="link_select">
<div class="link_option link_selected"> <div class="link_option link_selected">
<a href="/topics/">{{lang "topic_list.most_recent_filter"}}</a> <a href="/topics/">{{lang "topic_list.most_recent_filter"}}</a>
@ -39,7 +39,7 @@
{{/** TODO: Add ARIA attributes for this **/}} {{/** TODO: Add ARIA attributes for this **/}}
<div id="mod_topic_mover" class="modal_pane auto_hide"> <div id="mod_topic_mover" class="modal_pane auto_hide">
<form action="/topic/move/submit/?s={{.CurrentUser.Session}}" method="post"> <form action="/topic/move/submit/?s={{.CurrentUser.Session}}" method="post">
<input id="mover_fid" name="fid" value=0 type="hidden" /> <input id="mover_fid" name="fid" value=0 type="hidden"/>
<div class="pane_header"> <div class="pane_header">
<h3>{{lang "topic_list.move_head"}}</h3> <h3>{{lang "topic_list.move_head"}}</h3>
</div> </div>
@ -55,7 +55,7 @@
</div> </div>
<div class="rowblock topic_create_form quick_create_form auto_hide" aria-label="{{lang "quick_topic.aria"}}"> <div class="rowblock topic_create_form quick_create_form auto_hide" aria-label="{{lang "quick_topic.aria"}}">
<form name="topic_create_form_form" id="quick_post_form" enctype="multipart/form-data" action="/topic/create/submit/?s={{.CurrentUser.Session}}" method="post"></form> <form name="topic_create_form_form" id="quick_post_form" enctype="multipart/form-data" action="/topic/create/submit/?s={{.CurrentUser.Session}}" method="post"></form>
<img class="little_row_avatar" src="{{.CurrentUser.MicroAvatar}}" height=64 alt="{{lang "quick_topic.avatar_alt"}}" title="{{lang "quick_topic.avatar_tooltip"}}" /> <img class="little_row_avatar" src="{{.CurrentUser.MicroAvatar}}" height=64 alt="{{lang "quick_topic.avatar_alt"}}" title="{{lang "quick_topic.avatar_tooltip"}}"/>
<div class="main_form"> <div class="main_form">
<div class="topic_meta"> <div class="topic_meta">
<div class="formrow topic_board_row real_first_child"> <div class="formrow topic_board_row real_first_child">

View File

@ -1,17 +1,17 @@
<div class="topic_row{{if .Sticky}} topic_sticky{{else if .IsClosed}} topic_closed{{end}}" data-tid="{{.ID}}"> <div class="topic_row{{if .Sticky}} topic_sticky{{else if .IsClosed}} topic_closed{{end}}" data-tid="{{.ID}}">
<div class="rowitem topic_left passive datarow"> <div class="rowitem topic_left passive datarow">
<span class="selector"></span> <span class="selector"></span>
<a href="{{.Creator.Link}}"><img src="{{.Creator.MicroAvatar}}" height=64 alt="Avatar" title="{{.Creator.Name}}'s Avatar" aria-hidden="true" /></a> <a href="{{.Creator.Link}}"><img src="{{.Creator.MicroAvatar}}" height=64 alt="Avatar" title="{{.Creator.Name}}'s Avatar" aria-hidden="true"/></a>
<span class="topic_inner_left"> <span class="topic_inner_left">
<a class="rowtopic" href="{{.Link}}" itemprop="itemListElement" title="{{.Title}}"><span>{{.Title}}</span></a> {{if .ForumName}}<a class="rowsmall parent_forum" href="{{.ForumLink}}" title="{{.ForumName}}">{{.ForumName}}</a>{{end}} <a class="rowtopic" href="{{.Link}}" itemprop="itemListElement" title="{{.Title}}"><span>{{.Title}}</span></a> {{if .ForumName}}<a class="rowsmall parent_forum" href="{{.ForumLink}}" title="{{.ForumName}}">{{.ForumName}}</a>{{end}}
<br /><a class="rowsmall starter" href="{{.Creator.Link}}" title="{{.Creator.Name}}">{{.Creator.Name}}</a> <br><a class="rowsmall starter" href="{{.Creator.Link}}" title="{{.Creator.Name}}">{{.Creator.Name}}</a>
{{/** TODO: Avoid the double '|' when both .IsClosed and .Sticky are set to true. We could probably do this with CSS **/}} {{/** TODO: Avoid the double '|' when both .IsClosed and .Sticky are set to true. We could probably do this with CSS **/}}
{{if .IsClosed}}<span class="rowsmall topic_status_e topic_status_closed" title="{{lang "status.closed_tooltip"}}"> | &#x1F512;&#xFE0E</span>{{end}} {{if .IsClosed}}<span class="rowsmall topic_status_e topic_status_closed" title="{{lang "status.closed_tooltip"}}"> | &#x1F512;&#xFE0E</span>{{end}}
{{if .Sticky}}<span class="rowsmall topic_status_e topic_status_sticky" title="{{lang "status.pinned_tooltip"}}"> | &#x1F4CD;&#xFE0E</span>{{end}} {{if .Sticky}}<span class="rowsmall topic_status_e topic_status_sticky" title="{{lang "status.pinned_tooltip"}}"> | &#x1F4CD;&#xFE0E</span>{{end}}
</span> </span>
{{/** TODO: Phase this out of Cosora and remove it **/}} {{/** TODO: Phase this out of Cosora and remove it **/}}
<div class="topic_inner_right rowsmall"> <div class="topic_inner_right rowsmall">
<span class="replyCount">{{.PostCount}}</span><br /> <span class="replyCount">{{.PostCount}}</span><br>
<span class="likeCount">{{.LikeCount}}</span> <span class="likeCount">{{.LikeCount}}</span>
</div> </div>
</div> </div>
@ -24,7 +24,7 @@
</div> </div>
<div class="rowitem topic_right passive datarow"> <div class="rowitem topic_right passive datarow">
<div class="topic_right_inside"> <div class="topic_right_inside">
<a href="{{.LastUser.Link}}"><img src="{{.LastUser.MicroAvatar}}" height=64 alt="Avatar" title="{{.LastUser.Name}}'s Avatar" aria-hidden="true" /></a> <a href="{{.LastUser.Link}}"><img src="{{.LastUser.MicroAvatar}}" height=64 alt="Avatar" title="{{.LastUser.Name}}'s Avatar" aria-hidden="true"/></a>
<span> <span>
<a href="{{.LastUser.Link}}" class="lastName" title="{{.LastUser.Name}}">{{.LastUser.Name}}</a><br> <a href="{{.LastUser.Link}}" class="lastName" title="{{.LastUser.Name}}">{{.LastUser.Name}}</a><br>
<a href="{{.Link}}?page={{.LastPage}}{{if .LastReplyID}}#post-{{.LastReplyID}}{{end}}" class="rowsmall lastReplyAt" title="{{abstime .LastReplyAt}}">{{reltime .LastReplyAt}}</a> <a href="{{.Link}}?page={{.LastPage}}{{if .LastReplyID}}#post-{{.LastReplyID}}{{end}}" class="rowsmall lastReplyAt" title="{{abstime .LastReplyAt}}">{{reltime .LastReplyAt}}</a>

View File

@ -1,9 +1,9 @@
<div class="topic_row{{if .Sticky}} topic_sticky{{else if .IsClosed}} topic_closed{{end}}" data-tid="{{.ID}}"> <div class="topic_row{{if .Sticky}} topic_sticky{{else if .IsClosed}} topic_closed{{end}}" data-tid="{{.ID}}">
<div class="rowitem topic_left passive datarow"> <div class="rowitem topic_left passive datarow">
<a href="{{.Creator.Link}}"><img src="{{.Creator.MicroAvatar}}" height=64 alt="Avatar" title="{{.Creator.Name}}'s Avatar" aria-hidden="true" /></a> <a href="{{.Creator.Link}}"><img src="{{.Creator.MicroAvatar}}" height=64 alt="Avatar" title="{{.Creator.Name}}'s Avatar" aria-hidden="true"/></a>
<span class="topic_inner_left"> <span class="topic_inner_left">
<span class="rowtopic" itemprop="itemListElement" title="{{.Title}}"><a href="{{.Link}}">{{.Title}}</a>{{if .ForumName}}<a class="parent_forum_sep">-</a><a href="{{.ForumLink}}" title="{{.ForumName}}" class="rowsmall parent_forum">{{.ForumName}}</a>{{end}}</span> <span class="rowtopic" itemprop="itemListElement" title="{{.Title}}"><a href="{{.Link}}">{{.Title}}</a>{{if .ForumName}}<a class="parent_forum_sep">-</a><a href="{{.ForumLink}}" title="{{.ForumName}}" class="rowsmall parent_forum">{{.ForumName}}</a>{{end}}</span>
<br /><a class="rowsmall starter" href="{{.Creator.Link}}" title="{{.Creator.Name}}">{{.Creator.Name}}</a> <br><a class="rowsmall starter" href="{{.Creator.Link}}" title="{{.Creator.Name}}">{{.Creator.Name}}</a>
</span> </span>
</div> </div>
<div class="topic_middle"> <div class="topic_middle">
@ -15,7 +15,7 @@
</div> </div>
<div class="rowitem topic_right passive datarow"> <div class="rowitem topic_right passive datarow">
<div class="topic_right_inside"> <div class="topic_right_inside">
<a href="{{.LastUser.Link}}"><img src="{{.LastUser.MicroAvatar}}" height=64 alt="Avatar" title="{{.LastUser.Name}}'s Avatar" aria-hidden="true" /></a> <a href="{{.LastUser.Link}}"><img src="{{.LastUser.MicroAvatar}}" height=64 alt="Avatar" title="{{.LastUser.Name}}'s Avatar" aria-hidden="true"/></a>
<span> <span>
<a href="{{.LastUser.Link}}" class="lastName" title="{{.LastUser.Name}}">{{.LastUser.Name}}</a><br> <a href="{{.LastUser.Link}}" class="lastName" title="{{.LastUser.Name}}">{{.LastUser.Name}}</a><br>
<a href="{{.Link}}?page={{.LastPage}}{{if .LastReplyID}}#post-{{.LastReplyID}}{{end}}" class="rowsmall lastReplyAt" title="{{abstime .LastReplyAt}}">{{reltime .LastReplyAt}}</a> <a href="{{.Link}}?page={{.LastPage}}{{if .LastReplyID}}#post-{{.LastReplyID}}{{end}}" class="rowsmall lastReplyAt" title="{{abstime .LastReplyAt}}">{{reltime .LastReplyAt}}</a>