1
0
Fork 0
mirror of https://github.com/Eggbertx/gochan.git synced 2025-08-02 10:56:25 -07:00

Improve cookie loading with type setting

This commit is contained in:
Eggbertx 2021-08-24 13:14:11 -07:00
parent 282d0208f0
commit 45a47e54fb
12 changed files with 189 additions and 59 deletions

View file

@ -1,5 +1,5 @@
export function getCookie(name, defaultVal) { export function getCookie(name, options = {type: "string"}) {
let val = defaultVal; let val = options.default;
let cookieArr = document.cookie.split("; "); let cookieArr = document.cookie.split("; ");
for(const cookie of cookieArr) { for(const cookie of cookieArr) {
@ -8,18 +8,34 @@ export function getCookie(name, defaultVal) {
try { try {
val = decodeURIComponent(pair[1]); val = decodeURIComponent(pair[1]);
} catch(err) { } catch(err) {
return defaultVal; return options.default;
} }
} }
switch(options.type) {
case "int":
return parseInt(val);
case "float":
return parseFloat(val);
case "bool":
case "boolean":
return val == "true" || val == "1";
case "json":
// console.log(val);
try {
return JSON.parse(val);
} catch(e) {
return {};
}
}
return val; return val;
} }
// gets cookies ready to be used elsewhere // gets cookies ready to be used elsewhere
export function initCookies() { export function initCookies() {
$("input[name=postname]").val(getCookie("name", "")); $("input[name=postname]").val(getCookie("name"));
$("input[name=postemail]").val(getCookie("email", "")); $("input[name=postemail]").val(getCookie("email"));
$("input[name=postpassword]").val(getCookie("password", "")); $("input[name=postpassword]").val(getCookie("password"));
$("input[name=delete-password]").val(getCookie("password", "")); $("input[name=delete-password]").val(getCookie("password"));
} }
export function setCookie(name, value, expires) { export function setCookie(name, value, expires) {

View file

@ -5,6 +5,7 @@ import { initSettings } from "./settings";
import { initTopBar, TopBarButton, DropDownMenu } from "./topbar"; import { initTopBar, TopBarButton, DropDownMenu } from "./topbar";
import { initQR } from "./qr"; import { initQR } from "./qr";
import { opRegex } from "./vars"; import { opRegex } from "./vars";
import { initWatcher } from "./watcher";
let currentStaff = null; let currentStaff = null;
let $watchedThreadsBtn = null; let $watchedThreadsBtn = null;
@ -91,13 +92,14 @@ function handleKeydown(e) {
$(() => { $(() => {
let pageThread = getPageThread(); let pageThread = getPageThread();
let style = getCookie("style", defaultStyle); let style = getCookie("style", {default: defaultStyle});
let themeElem = document.getElementById("theme"); let themeElem = document.getElementById("theme");
if(themeElem) themeElem.setAttribute("href", `${webroot}css/${style}`); if(themeElem) themeElem.setAttribute("href", `${webroot}css/${style}`);
currentStaff = getStaff(); currentStaff = getStaff();
initCookies(); initCookies();
initTopBar(); initTopBar();
initSettings(); initSettings();
initWatcher();
$watchedThreadsBtn = new TopBarButton("WT", () => {}); $watchedThreadsBtn = new TopBarButton("WT", () => {});
@ -106,8 +108,8 @@ $(() => {
window.location = "/manage?action=dashboard" window.location = "/manage?action=dashboard"
}) })
/* $staffBtn = new DropDownMenu("Staff",getStaffMenuHTML()) /* $staffBtn = new DropDownMenu("Staff",getStaffMenuHTML())
$("a#staff.dropdown-button").click(function() { $("a#staff.dropdown-button").on("click", function() {
$("a.staffmenu-item").click(function() { $("a.staffmenu-item").on("click", function() {
let url = $(this).attr("id"); let url = $(this).attr("id");
openStaffLightBox(url); openStaffLightBox(url);
}); });
@ -117,11 +119,11 @@ $(() => {
if(pageThread.board != "") { if(pageThread.board != "") {
prepareThumbnails(); prepareThumbnails();
if(getCookie("useqr") == "true") initQR(pageThread); if(getCookie("useqr", {type: "bool"})) initQR(pageThread);
} }
preparePostPreviews(false); preparePostPreviews(false);
$(".plus").click(function() { $("plus").on("click", function() {
let block = $(this).parent().next(); let block = $(this).parent().next();
if(block.css("display") == "none") { if(block.css("display") == "none") {
block.show(); block.show();
@ -132,7 +134,7 @@ $(() => {
} }
}); });
let threadMenuOpen = false; let threadMenuOpen = false;
$(".thread-ddown a, body").click(function(e) { $(".thread-ddown a, body").on("click", function(e) {
e.stopPropagation(); e.stopPropagation();
let postID = $(this).parent().parent().parent().attr("id"); let postID = $(this).parent().parent().parent().attr("id");
let isOP = $(this).parent().parent().parent().attr("class") == "thread"; let isOP = $(this).parent().parent().parent().attr("class") == "thread";

View file

@ -2,7 +2,7 @@ export function showLightBox(title, innerHTML) {
$(document.body).prepend( $(document.body).prepend(
`<div class="lightbox-bg"></div><div class="lightbox"><div class="lightbox-title">${title}<a href="#" class="lightbox-x">X</a><hr /></div>${innerHTML}</div>` `<div class="lightbox-bg"></div><div class="lightbox"><div class="lightbox-title">${title}<a href="#" class="lightbox-x">X</a><hr /></div>${innerHTML}</div>`
); );
$("a.lightbox-x, .lightbox-bg").click(() => { $("a.lightbox-x, .lightbox-bg").on("click", () => {
$(".lightbox, .lightbox-bg").remove(); $(".lightbox, .lightbox-bg").remove();
}); });
} }
@ -17,7 +17,7 @@ export function showMessage(msg) {
"left": $(document).width()/2 - centeroffset/2-16 "left": $(document).width()/2 - centeroffset/2-16
}); });
$(".lightbox-msg-ok, .lightbox-bg").click(() => { $(".lightbox-msg-ok, .lightbox-bg").on("click", () => {
$(".lightbox-msg, .lightbox-bg").remove(); $(".lightbox-msg, .lightbox-bg").remove();
}); });
} }

View file

@ -87,7 +87,7 @@ export function preparePostPreviews(isInline) {
if(expandablePostrefs) { if(expandablePostrefs) {
let clkStr = "a.postref"; let clkStr = "a.postref";
if(isInline) clkStr = "div.inlinepostprev " + clkStr; if(isInline) clkStr = "div.inlinepostprev " + clkStr;
$(clkStr).click(() => { $(clkStr).on("click", () => {
let $this = $(this); let $this = $(this);
if($this.next().attr("class") != "inlinepostprev") { if($this.next().attr("class") != "inlinepostprev") {
$(".postprev").remove(); $(".postprev").remove();
@ -108,7 +108,7 @@ export function preparePostPreviews(isInline) {
export function prepareThumbnails() { export function prepareThumbnails() {
// set thumbnails to expand when clicked // set thumbnails to expand when clicked
$("a.upload-container").click(function(e) { $("a.upload-container").on("click", function(e) {
e.preventDefault(); e.preventDefault();
let a = $(this); let a = $(this);
let thumb = a.find("img.upload"); let thumb = a.find("img.upload");
@ -132,7 +132,7 @@ export function prepareThumbnails() {
fileInfoElement.append($("<a />") fileInfoElement.append($("<a />")
.prop("href", "javascript:;") .prop("href", "javascript:;")
.click(e =>{ .on("click", e =>{
video.remove(); video.remove();
thumb.show(); thumb.show();
this.remove(); this.remove();

View file

@ -16,8 +16,8 @@ const qrTitleBar =
`<a href="javascript:toTop();">${upArrow}</a><a href="javascript:closeQR();">X</a></span></div>`; `<a href="javascript:toTop();">${upArrow}</a><a href="javascript:closeQR();">X</a></span></div>`;
export function initQR(pageThread) { export function initQR(pageThread) {
const nameCookie = getCookie("name",""); const nameCookie = getCookie("name");
const emailCookie = getCookie("email",""); const emailCookie = getCookie("email");
const qrFormHTML = const qrFormHTML =
`<input type="hidden" name="threadid" value="${pageThread.op}" />` + `<input type="hidden" name="threadid" value="${pageThread.op}" />` +
`<input type="hidden" name="boardid" value="1" />` + `<input type="hidden" name="boardid" value="1" />` +
@ -37,9 +37,13 @@ export function initQR(pageThread) {
enctype:"multipart/form-data" enctype:"multipart/form-data"
}).append(qrFormHTML,$qrbuttons); }).append(qrFormHTML,$qrbuttons);
let qrTop = 32; let qrTop = 32;
if(!getCookie("pintopbar",true)) qrTop = $topbar.outerHeight() + 16; if(!getCookie("pintopbar",{default: true, type: "bool"}))
qrTop = $topbar.outerHeight() + 16;
let qrPos = JSON.parse(getCookie("qrpos", JSON.stringify({top: qrTop, left: 16}))); let qrPos = getCookie("qrpos", {
type: "json",
default: JSON.stringify({top: qrTop, left: 16})
});
$qr = $("<div />").prop({ $qr = $("<div />").prop({
id: "qr-box", id: "qr-box",
style: `top: ${qrPos.top}px;left: ${qrPos.left}px; position:fixed;`, style: `top: ${qrPos.top}px;left: ${qrPos.left}px; position:fixed;`,

View file

@ -32,8 +32,8 @@ class Setting {
this.cb(); this.cb();
} }
getCookie(defaultVal) { getCookie(type = "string", defaultVal) {
let val = getCookie(this.id, defaultVal); let val = getCookie(this.id, {type: type, default: defaultVal});
if(this.type == "checkbox") val = (val == "true"); if(this.type == "checkbox") val = (val == "true");
return val; return val;
@ -106,7 +106,7 @@ export function initSettings() {
$settingsMenu = new TopBarButton("Settings", () => { $settingsMenu = new TopBarButton("Settings", () => {
showLightBox("Settings", settingsHTML); showLightBox("Settings", settingsHTML);
$("button#save-settings-button").click(() => { $("button#save-settings-button").on("click", () => {
for(const setting of settings) { for(const setting of settings) {
setting.save(setting.getVal()); setting.save(setting.getVal());
} }

View file

@ -12,7 +12,7 @@ export class TopBarButton {
$topbar.append(`<a href="javascript:;" class="dropdown-button" id="${title.toLowerCase()}">${title}${downArrow}</a>`); $topbar.append(`<a href="javascript:;" class="dropdown-button" id="${title.toLowerCase()}">${title}${downArrow}</a>`);
let buttonOpen = false; let buttonOpen = false;
let self = this; let self = this;
$topbar.find("a#" + title.toLowerCase()).click(event => { $topbar.find("a#" + title.toLowerCase()).on("click", event => {
if(!buttonOpen) { if(!buttonOpen) {
self.onOpen(); self.onOpen();
$(document).bind("click", () => { $(document).bind("click", () => {
@ -30,7 +30,7 @@ export class TopBarButton {
export function initTopBar() { export function initTopBar() {
$topbar = $("div#topbar"); $topbar = $("div#topbar");
if(!getCookie("pintopbar", true)) { if(!getCookie("pintopbar", {default: true, type: "bool"})) {
$topbar.css({ $topbar.css({
"position": "absolute", "position": "absolute",
"top": "0px", "top": "0px",

29
frontend/src/watcher.js Normal file
View file

@ -0,0 +1,29 @@
let watching = false;
export function getWatchedThreads() {
if(!watching) {
clearInterval(getWatchedThreads);
return;
}
fetch("/test/res/1.json")
.then(response => {
if(!response.ok)
throw new Error(response.statusText);
return response.json();
})
.then(data => {
console.log(data);
})
.catch(err => {
console.log(`Error getting watched threads: ${err}`);
clearInterval(getWatchedThreads);
watching = false;
})
}
export function initWatcher() {
watching = true;
getWatchedThreads();
// setInterval(getWatchedThreads, 1000);
}

View file

@ -27273,8 +27273,11 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
function getCookie(name, defaultVal) { function getCookie(name) {
var val = defaultVal; var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
type: "string"
};
var val = options["default"];
var cookieArr = document.cookie.split("; "); var cookieArr = document.cookie.split("; ");
var _iterator = _createForOfIteratorHelper(cookieArr), var _iterator = _createForOfIteratorHelper(cookieArr),
@ -27289,7 +27292,7 @@ function getCookie(name, defaultVal) {
try { try {
val = decodeURIComponent(pair[1]); val = decodeURIComponent(pair[1]);
} catch (err) { } catch (err) {
return defaultVal; return options["default"];
} }
} }
} catch (err) { } catch (err) {
@ -27298,14 +27301,34 @@ function getCookie(name, defaultVal) {
_iterator.f(); _iterator.f();
} }
switch (options.type) {
case "int":
return parseInt(val);
case "float":
return parseFloat(val);
case "bool":
case "boolean":
return val == "true" || val == "1";
case "json":
try {
return JSON.parse(val);
} catch (e) {
return {};
}
}
return val; return val;
} }
function initCookies() { function initCookies() {
$("input[name=postname]").val(getCookie("name", "")); $("input[name=postname]").val(getCookie("name"));
$("input[name=postemail]").val(getCookie("email", "")); $("input[name=postemail]").val(getCookie("email"));
$("input[name=postpassword]").val(getCookie("password", "")); $("input[name=postpassword]").val(getCookie("password"));
$("input[name=delete-password]").val(getCookie("password", "")); $("input[name=delete-password]").val(getCookie("password"));
} }
function setCookie(name, value, expires) { function setCookie(name, value, expires) {
@ -27346,6 +27369,8 @@ var _qr = require("./qr");
var _vars = require("./vars"); var _vars = require("./vars");
var _watcher = require("./watcher");
var currentStaff = null; var currentStaff = null;
var $watchedThreadsBtn = null; var $watchedThreadsBtn = null;
var $staffBtn = null; var $staffBtn = null;
@ -27441,13 +27466,16 @@ function handleKeydown(e) {
$(function () { $(function () {
var pageThread = getPageThread(); var pageThread = getPageThread();
var style = (0, _cookies.getCookie)("style", defaultStyle); var style = (0, _cookies.getCookie)("style", {
"default": defaultStyle
});
var themeElem = document.getElementById("theme"); var themeElem = document.getElementById("theme");
if (themeElem) themeElem.setAttribute("href", "".concat(webroot, "css/").concat(style)); if (themeElem) themeElem.setAttribute("href", "".concat(webroot, "css/").concat(style));
currentStaff = (0, _manage.getStaff)(); currentStaff = (0, _manage.getStaff)();
(0, _cookies.initCookies)(); (0, _cookies.initCookies)();
(0, _topbar.initTopBar)(); (0, _topbar.initTopBar)();
(0, _settings.initSettings)(); (0, _settings.initSettings)();
(0, _watcher.initWatcher)();
$watchedThreadsBtn = new _topbar.TopBarButton("WT", function () {}); $watchedThreadsBtn = new _topbar.TopBarButton("WT", function () {});
if (currentStaff.rank > 0) { if (currentStaff.rank > 0) {
@ -27458,11 +27486,13 @@ $(function () {
if (pageThread.board != "") { if (pageThread.board != "") {
(0, _postutil.prepareThumbnails)(); (0, _postutil.prepareThumbnails)();
if ((0, _cookies.getCookie)("useqr") == "true") (0, _qr.initQR)(pageThread); if ((0, _cookies.getCookie)("useqr", {
type: "bool"
})) (0, _qr.initQR)(pageThread);
} }
(0, _postutil.preparePostPreviews)(false); (0, _postutil.preparePostPreviews)(false);
$(".plus").click(function () { $("plus").on("click", function () {
var block = $(this).parent().next(); var block = $(this).parent().next();
if (block.css("display") == "none") { if (block.css("display") == "none") {
@ -27474,7 +27504,7 @@ $(function () {
} }
}); });
var threadMenuOpen = false; var threadMenuOpen = false;
$(".thread-ddown a, body").click(function (e) { $(".thread-ddown a, body").on("click", function (e) {
e.stopPropagation(); e.stopPropagation();
var postID = $(this).parent().parent().parent().attr("id"); var postID = $(this).parent().parent().parent().attr("id");
var isOP = $(this).parent().parent().parent().attr("class") == "thread"; var isOP = $(this).parent().parent().parent().attr("class") == "thread";
@ -27495,7 +27525,7 @@ $(function () {
$(document).keydown(handleKeydown); $(document).keydown(handleKeydown);
}); });
},{"./cookies":3,"./manage":6,"./postutil":7,"./qr":8,"./settings":9,"./topbar":10,"./vars":11}],5:[function(require,module,exports){ },{"./cookies":3,"./manage":6,"./postutil":7,"./qr":8,"./settings":9,"./topbar":10,"./vars":11,"./watcher":12}],5:[function(require,module,exports){
"use strict"; "use strict";
Object.defineProperty(exports, "__esModule", { Object.defineProperty(exports, "__esModule", {
@ -27506,7 +27536,7 @@ exports.showMessage = showMessage;
function showLightBox(title, innerHTML) { function showLightBox(title, innerHTML) {
$(document.body).prepend("<div class=\"lightbox-bg\"></div><div class=\"lightbox\"><div class=\"lightbox-title\">".concat(title, "<a href=\"#\" class=\"lightbox-x\">X</a><hr /></div>").concat(innerHTML, "</div>")); $(document.body).prepend("<div class=\"lightbox-bg\"></div><div class=\"lightbox\"><div class=\"lightbox-title\">".concat(title, "<a href=\"#\" class=\"lightbox-x\">X</a><hr /></div>").concat(innerHTML, "</div>"));
$("a.lightbox-x, .lightbox-bg").click(function () { $("a.lightbox-x, .lightbox-bg").on("click", function () {
$(".lightbox, .lightbox-bg").remove(); $(".lightbox, .lightbox-bg").remove();
}); });
} }
@ -27518,7 +27548,7 @@ function showMessage(msg) {
"position": "fixed", "position": "fixed",
"left": $(document).width() / 2 - centeroffset / 2 - 16 "left": $(document).width() / 2 - centeroffset / 2 - 16
}); });
$(".lightbox-msg-ok, .lightbox-bg").click(function () { $(".lightbox-msg-ok, .lightbox-bg").on("click", function () {
$(".lightbox-msg, .lightbox-bg").remove(); $(".lightbox-msg, .lightbox-bg").remove();
}); });
} }
@ -27808,7 +27838,7 @@ function preparePostPreviews(isInline) {
if (expandablePostrefs) { if (expandablePostrefs) {
var clkStr = "a.postref"; var clkStr = "a.postref";
if (isInline) clkStr = "div.inlinepostprev " + clkStr; if (isInline) clkStr = "div.inlinepostprev " + clkStr;
$(clkStr).click(function () { $(clkStr).on("click", function () {
var $this = $(_this); var $this = $(_this);
if ($this.next().attr("class") != "inlinepostprev") { if ($this.next().attr("class") != "inlinepostprev") {
@ -27830,7 +27860,7 @@ function preparePostPreviews(isInline) {
} }
function prepareThumbnails() { function prepareThumbnails() {
$("a.upload-container").click(function (e) { $("a.upload-container").on("click", function (e) {
var _this2 = this; var _this2 = this;
e.preventDefault(); e.preventDefault();
@ -27850,7 +27880,7 @@ function prepareThumbnails() {
"class": "upload", "class": "upload",
loop: true loop: true
}).insertAfter(fileInfoElement); }).insertAfter(fileInfoElement);
fileInfoElement.append($("<a />").prop("href", "javascript:;").click(function (e) { fileInfoElement.append($("<a />").prop("href", "javascript:;").on("click", function (e) {
video.remove(); video.remove();
thumb.show(); thumb.show();
@ -27919,8 +27949,8 @@ var qrButtonHTML = "<input type=\"file\" id=\"imagefile\" name=\"imagefile\" sty
var qrTitleBar = "<div id=\"qr-title\">" + "<span id=\"qr-message\"></span>" + "<span id=\"qr-buttons\"><a href=\"javascript:toBottom();\">".concat(_vars.downArrow, "</a>") + "<a href=\"javascript:toTop();\">".concat(_vars.upArrow, "</a><a href=\"javascript:closeQR();\">X</a></span></div>"); var qrTitleBar = "<div id=\"qr-title\">" + "<span id=\"qr-message\"></span>" + "<span id=\"qr-buttons\"><a href=\"javascript:toBottom();\">".concat(_vars.downArrow, "</a>") + "<a href=\"javascript:toTop();\">".concat(_vars.upArrow, "</a><a href=\"javascript:closeQR();\">X</a></span></div>");
function initQR(pageThread) { function initQR(pageThread) {
var nameCookie = (0, _cookies.getCookie)("name", ""); var nameCookie = (0, _cookies.getCookie)("name");
var emailCookie = (0, _cookies.getCookie)("email", ""); var emailCookie = (0, _cookies.getCookie)("email");
var qrFormHTML = "<input type=\"hidden\" name=\"threadid\" value=\"".concat(pageThread.op, "\" />") + "<input type=\"hidden\" name=\"boardid\" value=\"1\" />" + "<div id=\"qrpostname\"><input id=\"qrpostname\" type=\"text\" name=\"postname\" value=\"".concat(nameCookie, "\" placeholder=\"Name\"/></div>") + "<div id=\"qrpostemail\"><input id=\"qrpostemail\" type=\"text\" name=\"postemail\" value=\"".concat(emailCookie, "\" placeholder=\"Email\"/></div>") + "<div id=\"qrpostsubject\"><input id=\"qrpostsubject\" type=\"text\" name=\"postsubject\" placeholder=\"Subject\"/></div>" + "<div id=\"qrpostmsg\"><textarea id=\"qrpostmsg\" name=\"postmsg\" id=\"postmsg\" placeholder=\"Message\"></textarea></div>"; var qrFormHTML = "<input type=\"hidden\" name=\"threadid\" value=\"".concat(pageThread.op, "\" />") + "<input type=\"hidden\" name=\"boardid\" value=\"1\" />" + "<div id=\"qrpostname\"><input id=\"qrpostname\" type=\"text\" name=\"postname\" value=\"".concat(nameCookie, "\" placeholder=\"Name\"/></div>") + "<div id=\"qrpostemail\"><input id=\"qrpostemail\" type=\"text\" name=\"postemail\" value=\"".concat(emailCookie, "\" placeholder=\"Email\"/></div>") + "<div id=\"qrpostsubject\"><input id=\"qrpostsubject\" type=\"text\" name=\"postsubject\" placeholder=\"Subject\"/></div>" + "<div id=\"qrpostmsg\"><textarea id=\"qrpostmsg\" name=\"postmsg\" id=\"postmsg\" placeholder=\"Message\"></textarea></div>";
var $qrbuttons = $("<div />").prop("id", "qrbuttons").append(qrButtonHTML); var $qrbuttons = $("<div />").prop("id", "qrbuttons").append(qrButtonHTML);
var $postform = $("<form />").prop({ var $postform = $("<form />").prop({
@ -27931,11 +27961,17 @@ function initQR(pageThread) {
enctype: "multipart/form-data" enctype: "multipart/form-data"
}).append(qrFormHTML, $qrbuttons); }).append(qrFormHTML, $qrbuttons);
var qrTop = 32; var qrTop = 32;
if (!(0, _cookies.getCookie)("pintopbar", true)) qrTop = _topbar.$topbar.outerHeight() + 16; if (!(0, _cookies.getCookie)("pintopbar", {
var qrPos = JSON.parse((0, _cookies.getCookie)("qrpos", JSON.stringify({ "default": true,
top: qrTop, type: "bool"
left: 16 })) qrTop = _topbar.$topbar.outerHeight() + 16;
}))); var qrPos = (0, _cookies.getCookie)("qrpos", {
type: "json",
"default": JSON.stringify({
top: qrTop,
left: 16
})
});
exports.$qr = $qr = $("<div />").prop({ exports.$qr = $qr = $("<div />").prop({
id: "qr-box", id: "qr-box",
style: "top: ".concat(qrPos.top, "px;left: ").concat(qrPos.left, "px; position:fixed;") style: "top: ".concat(qrPos.top, "px;left: ").concat(qrPos.left, "px; position:fixed;")
@ -28027,8 +28063,13 @@ var Setting = function () {
} }
}, { }, {
key: "getCookie", key: "getCookie",
value: function getCookie(defaultVal) { value: function getCookie() {
var val = (0, _cookies.getCookie)(this.id, defaultVal); var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "string";
var defaultVal = arguments.length > 1 ? arguments[1] : undefined;
var val = (0, _cookies.getCookie)(this.id, {
type: type,
"default": defaultVal
});
if (this.type == "checkbox") val = val == "true"; if (this.type == "checkbox") val = val == "true";
return val; return val;
} }
@ -28135,7 +28176,7 @@ function initSettings() {
settingsHTML += "</table></div><div class=\"lightbox-footer\"><hr /><button id=\"save-settings-button\">Save Settings</button></div>"; settingsHTML += "</table></div><div class=\"lightbox-footer\"><hr /><button id=\"save-settings-button\">Save Settings</button></div>";
exports.$settingsMenu = $settingsMenu = new _topbar.TopBarButton("Settings", function () { exports.$settingsMenu = $settingsMenu = new _topbar.TopBarButton("Settings", function () {
(0, _lightbox.showLightBox)("Settings", settingsHTML); (0, _lightbox.showLightBox)("Settings", settingsHTML);
$("button#save-settings-button").click(function () { $("button#save-settings-button").on("click", function () {
var _iterator4 = _createForOfIteratorHelper(settings), var _iterator4 = _createForOfIteratorHelper(settings),
_step4; _step4;
@ -28185,7 +28226,7 @@ var TopBarButton = function TopBarButton(title) {
$topbar.append("<a href=\"javascript:;\" class=\"dropdown-button\" id=\"".concat(title.toLowerCase(), "\">").concat(title).concat(_vars.downArrow, "</a>")); $topbar.append("<a href=\"javascript:;\" class=\"dropdown-button\" id=\"".concat(title.toLowerCase(), "\">").concat(title).concat(_vars.downArrow, "</a>"));
var buttonOpen = false; var buttonOpen = false;
var self = this; var self = this;
$topbar.find("a#" + title.toLowerCase()).click(function (event) { $topbar.find("a#" + title.toLowerCase()).on("click", function (event) {
if (!buttonOpen) { if (!buttonOpen) {
self.onOpen(); self.onOpen();
$(document).bind("click", function () { $(document).bind("click", function () {
@ -28206,7 +28247,10 @@ exports.TopBarButton = TopBarButton;
function initTopBar() { function initTopBar() {
exports.$topbar = $topbar = $("div#topbar"); exports.$topbar = $topbar = $("div#topbar");
if (!(0, _cookies.getCookie)("pintopbar", true)) { if (!(0, _cookies.getCookie)("pintopbar", {
"default": true,
type: "bool"
})) {
$topbar.css({ $topbar.css({
"position": "absolute", "position": "absolute",
"top": "0px", "top": "0px",
@ -28258,6 +28302,39 @@ exports.opRegex = opRegex;
var dropdownDivCreated = false; var dropdownDivCreated = false;
exports.dropdownDivCreated = dropdownDivCreated; exports.dropdownDivCreated = dropdownDivCreated;
},{"jquery":1,"jqueryui":2}]},{},[3,4,5,6,7,8,9,10,11]); },{"jquery":1,"jqueryui":2}],12:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getWatchedThreads = getWatchedThreads;
exports.initWatcher = initWatcher;
var watching = false;
function getWatchedThreads() {
if (!watching) {
clearInterval(getWatchedThreads);
return;
}
fetch("/test/res/1.json").then(function (response) {
if (!response.ok) throw new Error(response.statusText);
return response.json();
}).then(function (data) {
console.log(data);
})["catch"](function (err) {
console.log("Error getting watched threads: ".concat(err));
clearInterval(getWatchedThreads);
watching = false;
});
}
function initWatcher() {
watching = true;
getWatchedThreads();
}
},{}]},{},[3,4,5,6,7,8,9,10,11,12]);
//# sourceMappingURL=maps/gochan.js.map //# sourceMappingURL=maps/gochan.js.map

File diff suppressed because one or more lines are too long

View file

@ -11,7 +11,7 @@
{{- else}}<title>/{{$.board.Dir}}/ - {{$.board.Title}}</title>{{end}} {{- else}}<title>/{{$.board.Dir}}/ - {{$.board.Title}}</title>{{end}}
{{- else}}<title>{{.site_config.SiteName}}</title>{{end}} {{- else}}<title>{{.site_config.SiteName}}</title>{{end}}
<link rel="stylesheet" href="{{$.webroot}}css/global.css" /> <link rel="stylesheet" href="{{$.webroot}}css/global.css" />
<link id="theme" rel="stylesheet" href="{{.webroot}}css/{{.board_config.DefaultStyle}}" /> <link id="theme" rel="stylesheet" href="{{.webroot}}css/{{.board.DefaultStyle}}" />
<link rel="shortcut icon" href="{{.webroot}}favicon.png"> <link rel="shortcut icon" href="{{.webroot}}favicon.png">
<script type="text/javascript" src="{{$.webroot}}js/consts.js"></script> <script type="text/javascript" src="{{$.webroot}}js/consts.js"></script>
<script type="text/javascript" src="{{$.webroot}}js/gochan.js"></script> <script type="text/javascript" src="{{$.webroot}}js/gochan.js"></script>

View file

@ -151,4 +151,6 @@ Server set up. To access the virtual machine, run 'vagrant ssh'. Then, to start
run 'sudo systemctl start gochan.service'. The virtual machine is set to run gochan on startup, so you run 'sudo systemctl start gochan.service'. The virtual machine is set to run gochan on startup, so you
will not need to do this every time you start it. You can access it from a browser at http://172.27.0.3/ will not need to do this every time you start it. You can access it from a browser at http://172.27.0.3/
The first time gochan is run, it will create a simple /test/ board. The first time gochan is run, it will create a simple /test/ board.
If you want to do frontend development, you'll need to run 'apt install npm'
EOF EOF