commento.js: double newline between functions

This commit is contained in:
Adhityaa 2018-06-16 18:58:17 +05:30
parent ef21599109
commit 53016b93ce

View File

@ -190,6 +190,7 @@
document.cookie = name + "=" + value + expires + "; path=/"; document.cookie = name + "=" + value + expires + "; path=/";
} }
function sessionGet() { function sessionGet() {
var session = cookieGet("session"); var session = cookieGet("session");
if (session === undefined) if (session === undefined)
@ -198,11 +199,13 @@
return session; return session;
} }
global.logout = function() { global.logout = function() {
cookieSet("session", "anonymous"); cookieSet("session", "anonymous");
refreshAll(); refreshAll();
} }
function selfGet(callback) { function selfGet(callback) {
var session = sessionGet(); var session = sessionGet();
if (session == "anonymous") { if (session == "anonymous") {
@ -270,6 +273,7 @@
}); });
} }
function cssLoad(file, onload) { function cssLoad(file, onload) {
var link = create("link"); var link = create("link");
var head = document.getElementsByTagName('head')[0]; var head = document.getElementsByTagName('head')[0];
@ -282,6 +286,7 @@
append(head, link); append(head, link);
} }
function jsLoad(file, ready) { function jsLoad(file, ready) {
var script = document.createElement("script"); var script = document.createElement("script");
var loaded = false; var loaded = false;
@ -305,6 +310,7 @@
append(document.body, script); append(document.body, script);
} }
function footerLoad() { function footerLoad() {
var footer = create("div"); var footer = create("div");
var aContainer = create("div"); var aContainer = create("div");
@ -334,6 +340,7 @@
append(root, footer); append(root, footer);
} }
function commentsGet(callback) { function commentsGet(callback) {
var json = { var json = {
session: sessionGet(), session: sessionGet(),
@ -364,6 +371,7 @@
}); });
} }
function errorShow(text) { function errorShow(text) {
var el = $(ID_ERROR); var el = $(ID_ERROR);
@ -372,6 +380,7 @@
attrSet(el, "style", "display: block;"); attrSet(el, "style", "display: block;");
} }
function errorElementCreate() { function errorElementCreate() {
var el = create("div"); var el = create("div");
@ -383,6 +392,7 @@
append(root, el); append(root, el);
} }
function autoExpander(el) { function autoExpander(el) {
return function() { return function() {
el.style.height = ""; el.style.height = "";
@ -390,6 +400,7 @@
} }
}; };
function isMobile() { function isMobile() {
var mobile = false; var mobile = false;
if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|ipad|iris|kindle|Android|Silk|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(navigator.userAgent) if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|ipad|iris|kindle|Android|Silk|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(navigator.userAgent)
@ -399,6 +410,7 @@
return mobile; return mobile;
} }
function textareaCreate(id) { function textareaCreate(id) {
var textareaSuperContainer = create("div"); var textareaSuperContainer = create("div");
var textareaContainer = create("div"); var textareaContainer = create("div");
@ -440,6 +452,7 @@
return textareaSuperContainer; return textareaSuperContainer;
} }
function rootCreate(callback) { function rootCreate(callback) {
var mainArea = $(ID_MAIN_AREA); var mainArea = $(ID_MAIN_AREA);
var commentsArea = create("div"); var commentsArea = create("div");
@ -457,6 +470,7 @@
call(callback); call(callback);
} }
function messageCreate(text) { function messageCreate(text) {
var msg = create("div"); var msg = create("div");
@ -467,6 +481,7 @@
return msg; return msg;
} }
global.postComment = function(id) { global.postComment = function(id) {
var textarea = $(ID_TEXTAREA + id); var textarea = $(ID_TEXTAREA + id);
@ -513,6 +528,7 @@
}); });
} }
function colorGet(name) { function colorGet(name) {
var colors = [ var colors = [
// some visually distincy // some visually distincy
@ -532,6 +548,7 @@
return color; return color;
} }
function timeDifference(current, previous) { // thanks stackoverflow function timeDifference(current, previous) { // thanks stackoverflow
var msJustNow = 5000; var msJustNow = 5000;
var msPerMinute = 60000; var msPerMinute = 60000;
@ -565,6 +582,7 @@
} }
} }
function scorify(score) { function scorify(score) {
if (score != 1) if (score != 1)
return score + " points"; return score + " points";
@ -572,6 +590,7 @@
return score + " point"; return score + " point";
} }
function commentsRecurse(parentMap, parentHex) { function commentsRecurse(parentMap, parentHex) {
var cur = parentMap[parentHex]; var cur = parentMap[parentHex];
if (!cur || !cur.length) { if (!cur || !cur.length) {
@ -846,6 +865,7 @@
post(origin + "/api/comment/vote", json, function(resp) {}); post(origin + "/api/comment/vote", json, function(resp) {});
} }
global.replyShow = function(id) { global.replyShow = function(id) {
if (id in shownReply && shownReply[id]) if (id in shownReply && shownReply[id])
return; return;
@ -864,6 +884,7 @@
attrSet(replyButton, "onclick", "replyCollapse('" + id + "')") attrSet(replyButton, "onclick", "replyCollapse('" + id + "')")
}; };
global.replyCollapse = function(id) { global.replyCollapse = function(id) {
var replyButton = $(ID_REPLY + id); var replyButton = $(ID_REPLY + id);
var el = $(ID_SUPER_CONTAINER + id); var el = $(ID_SUPER_CONTAINER + id);
@ -880,6 +901,7 @@
attrSet(replyButton, "onclick", "replyShow('" + id + "')") attrSet(replyButton, "onclick", "replyShow('" + id + "')")
} }
global.commentCollapse = function(id) { global.commentCollapse = function(id) {
var contents = $(ID_CONTENTS + id); var contents = $(ID_CONTENTS + id);
var button = $(ID_COLLAPSE + id); var button = $(ID_COLLAPSE + id);
@ -894,6 +916,7 @@
attrSet(button, "onclick", "commentUncollapse('" + id + "')"); attrSet(button, "onclick", "commentUncollapse('" + id + "')");
} }
global.commentUncollapse = function(id) { global.commentUncollapse = function(id) {
var contents = $(ID_CONTENTS + id); var contents = $(ID_CONTENTS + id);
var button = $(ID_COLLAPSE + id); var button = $(ID_COLLAPSE + id);
@ -908,6 +931,7 @@
attrSet(button, "onclick", "commentCollapse('" + id + "')"); attrSet(button, "onclick", "commentCollapse('" + id + "')");
} }
function commentsRender() { function commentsRender() {
var parentMap = {}; var parentMap = {};
var parentHex; var parentHex;
@ -928,6 +952,7 @@
} }
} }
global.showSubmitButton = function(id) { global.showSubmitButton = function(id) {
if (id in shownSubmitButton && shownSubmitButton[id]) if (id in shownSubmitButton && shownSubmitButton[id])
return; return;
@ -951,6 +976,7 @@
append(el, submit); append(el, submit);
} }
global.commentoAuth = function(provider) { global.commentoAuth = function(provider) {
if (provider == "anonymous") { if (provider == "anonymous") {
cookieSet("session", "anonymous"); cookieSet("session", "anonymous");
@ -980,6 +1006,7 @@
}); });
} }
function refreshAll(callback) { function refreshAll(callback) {
$(ID_ROOT).innerHTML = ""; $(ID_ROOT).innerHTML = "";
shownSubmitButton = {"root": false}; shownSubmitButton = {"root": false};
@ -987,6 +1014,7 @@
main(callback); main(callback);
} }
function loginBoxCreate() { function loginBoxCreate() {
var loginBoxContainer = create("div"); var loginBoxContainer = create("div");
@ -995,6 +1023,7 @@
append(root, loginBoxContainer); append(root, loginBoxContainer);
} }
global.signupRender = function() { global.signupRender = function() {
var loginBoxContainer = $(ID_LOGIN_BOX_CONTAINER); var loginBoxContainer = $(ID_LOGIN_BOX_CONTAINER);
var loginBox = create("div"); var loginBox = create("div");
@ -1091,6 +1120,7 @@
append(loginBoxContainer, loginBox); append(loginBoxContainer, loginBox);
} }
global.loginSwitch = function() { global.loginSwitch = function() {
var header = $(ID_LOGIN_BOX_HEADER); var header = $(ID_LOGIN_BOX_HEADER);
var subtitle = $(ID_LOGIN_BOX_SUBTITLE); var subtitle = $(ID_LOGIN_BOX_SUBTITLE);
@ -1114,11 +1144,13 @@
} }
} }
global.signupSwitch = function() { global.signupSwitch = function() {
loginBoxClose(); loginBoxClose();
loginBoxShow(); loginBoxShow();
} }
function loginUP(username, password) { function loginUP(username, password) {
var json = { var json = {
email: username, email: username,
@ -1137,6 +1169,7 @@
}); });
} }
global.login = function() { global.login = function() {
var email = $(ID_LOGIN_BOX_EMAIL_INPUT); var email = $(ID_LOGIN_BOX_EMAIL_INPUT);
var password = $(ID_LOGIN_BOX_PASSWORD_INPUT); var password = $(ID_LOGIN_BOX_PASSWORD_INPUT);
@ -1144,6 +1177,7 @@
loginUP(email.value, password.value); loginUP(email.value, password.value);
} }
global.signup = function() { global.signup = function() {
var email = $(ID_LOGIN_BOX_EMAIL_INPUT); var email = $(ID_LOGIN_BOX_EMAIL_INPUT);
var name = $(ID_LOGIN_BOX_NAME_INPUT); var name = $(ID_LOGIN_BOX_NAME_INPUT);
@ -1168,6 +1202,7 @@
}); });
} }
global.passwordAsk = function() { global.passwordAsk = function() {
var loginBox = $(ID_LOGIN_BOX); var loginBox = $(ID_LOGIN_BOX);
var subtitle = $(ID_LOGIN_BOX_SUBTITLE); var subtitle = $(ID_LOGIN_BOX_SUBTITLE);
@ -1240,6 +1275,7 @@
} }
} }
function mainAreaCreate() { function mainAreaCreate() {
var mainArea = create("div"); var mainArea = create("div");
@ -1252,6 +1288,7 @@
append(root, mainArea); append(root, mainArea);
} }
global.loadCssOverride = function() { global.loadCssOverride = function() {
if (cssOverride === undefined) if (cssOverride === undefined)
global.allShow(); global.allShow();
@ -1259,6 +1296,7 @@
cssLoad(cssOverride, "window.allShow()"); cssLoad(cssOverride, "window.allShow()");
} }
global.allShow = function() { global.allShow = function() {
var mainArea = $(ID_MAIN_AREA); var mainArea = $(ID_MAIN_AREA);
var loggedContainer = $(ID_LOGGED_CONTAINER); var loggedContainer = $(ID_LOGGED_CONTAINER);
@ -1272,6 +1310,7 @@
nameWidthFix(); nameWidthFix();
} }
global.loginBoxClose = function() { global.loginBoxClose = function() {
var mainArea = $(ID_MAIN_AREA); var mainArea = $(ID_MAIN_AREA);
var loginBoxContainer = $(ID_LOGIN_BOX_CONTAINER); var loginBoxContainer = $(ID_LOGIN_BOX_CONTAINER);
@ -1281,6 +1320,7 @@
attrSet(loginBoxContainer, "style", "display: none"); attrSet(loginBoxContainer, "style", "display: none");
} }
global.loginBoxShow = function() { global.loginBoxShow = function() {
var mainArea = $(ID_MAIN_AREA); var mainArea = $(ID_MAIN_AREA);
var loginBoxContainer = $(ID_LOGIN_BOX_CONTAINER); var loginBoxContainer = $(ID_LOGIN_BOX_CONTAINER);
@ -1296,6 +1336,7 @@
$(ID_LOGIN_BOX_EMAIL_INPUT).focus(); $(ID_LOGIN_BOX_EMAIL_INPUT).focus();
} }
function dataTagsLoad() { function dataTagsLoad() {
var scripts = tags("script") var scripts = tags("script")
for (var i = 0; i < scripts.length; i++) { for (var i = 0; i < scripts.length; i++) {
@ -1311,6 +1352,7 @@
} }
} }
global.main = function(callback) { global.main = function(callback) {
root = $(ID_ROOT); root = $(ID_ROOT);
classAdd(root, "root"); classAdd(root, "root");
@ -1333,6 +1375,7 @@
}); });
} }
var autoInitted = false; var autoInitted = false;
function autoInit() { function autoInit() {
if (autoInitted) if (autoInitted)
@ -1347,6 +1390,7 @@
console.log("[commento] error: invalid value for data-auto-init; allowed values: true, false"); console.log("[commento] error: invalid value for data-auto-init; allowed values: true, false");
} }
if (document.readyState != "complete" && document.readyState != "interactive") if (document.readyState != "complete" && document.readyState != "interactive")
document.addEventListener("load", autoInit); document.addEventListener("load", autoInit);
else else