mirror of
https://github.com/Eggbertx/gochan.git
synced 2025-08-03 11:46:22 -07:00
Use stylesheet cookie if set
This commit is contained in:
parent
77b109770a
commit
8021743c82
8 changed files with 48 additions and 26 deletions
|
@ -371,6 +371,7 @@ input.config-text {
|
|||
}
|
||||
|
||||
.lightbox-footer {
|
||||
background-color: #CDCDCD;
|
||||
bottom: 5%;
|
||||
clear: both;
|
||||
left: 16px;
|
||||
|
|
|
@ -181,7 +181,6 @@ function showMessage(msg) {
|
|||
lightbox_css_added = true;
|
||||
}
|
||||
$jq(document.body).prepend("<div class=\"lightbox-bg\"></div><div class=\"lightbox-msg\">"+msg+"<br /><button class=\"lightbox-msg-ok\" style=\"float: right; margin-top:8px;\">OK</button></div>");
|
||||
console.log($jq(".lightbox-msg").width());
|
||||
var centeroffset = parseInt($jq(".lightbox-msg").css("transform-origin").replace("px",""),10)+$jq(".lightbox-msg").width()/2
|
||||
|
||||
$jq(".lightbox-msg").css({
|
||||
|
@ -342,7 +341,7 @@ function isFrontPage() {
|
|||
}
|
||||
|
||||
function setCookie(name,value) {
|
||||
document.cookie = name + "=" + escape(value)
|
||||
document.cookie = name + "=" + escape(value) + ";path=" + webroot;
|
||||
}
|
||||
|
||||
function getCookie(name) {
|
||||
|
@ -406,15 +405,15 @@ var Setting = function(id, text, type, defaultVal, callback, options) {
|
|||
this.text = text;
|
||||
this.type = type; // text, textarea, checkbox, select
|
||||
this.defaultVal = defaultVal;
|
||||
if(this.getCookie() === undefined) this.setCookie(this.defaultVal);
|
||||
if(!this.getCookie()) this.setCookie(this.defaultVal);
|
||||
if(this.type == "select") this.options = options;
|
||||
if(!callback) this.callback = function() {};
|
||||
else this.callback = callback;
|
||||
}
|
||||
|
||||
Setting.prototype.onSave == function(newVal) {
|
||||
this.callback();
|
||||
Setting.prototype.save = function(newVal) {
|
||||
setCookie(this.id, newVal);
|
||||
this.callback();
|
||||
}
|
||||
|
||||
Setting.prototype.getCookie = function() {
|
||||
|
@ -449,6 +448,7 @@ Setting.prototype.renderHTML = function() {
|
|||
if(this.getCookie() == this.options[o].val) html += "selected=\"" + this.getCookie() + "\"";
|
||||
html += ">" + this.options[o].text + "</option>";
|
||||
}
|
||||
html += "</select>";
|
||||
break;
|
||||
case "textarea":
|
||||
html = "<textarea id=\"" + this.id + "\" name=\"" + this.id + "\">" + this.getCookie() + "</textarea>";
|
||||
|
@ -461,11 +461,12 @@ Setting.prototype.renderHTML = function() {
|
|||
}
|
||||
|
||||
function initSettings() {
|
||||
var settings_html = "<table width=\"100%\"><colgroup><col span=\"1\" width=\"50%\"><col span=\"1\" width=\"50%\"></colgroup>";
|
||||
var settings_html = "<div id=\"settings-container\" style=\"overflow:auto\"><table width=\"100%\"><colgroup><col span=\"1\" width=\"50%\"><col span=\"1\" width=\"50%\"></colgroup>";
|
||||
|
||||
settings.push(
|
||||
new Setting("style", "Style", "select", "pipes.css", function() {
|
||||
|
||||
new Setting("style", "Style", "select", defaultStyle, function() {
|
||||
console.log(this.getCookie());
|
||||
document.getElementById("theme").setAttribute("href", webroot + "css/" + this.getCookie());
|
||||
}, []),
|
||||
new Setting("pintopbar", "Pin top bar", "checkbox", true),
|
||||
new Setting("enableposthover", "Preview post on hover", "checkbox", true),
|
||||
|
@ -481,26 +482,37 @@ function initSettings() {
|
|||
settings_html += "<tr><td><b>" + setting.text + ":</b></td><td>" + setting.renderHTML() + "</td></tr>";
|
||||
}
|
||||
|
||||
settings_html += "</table><div class=\"lightbox-footer\"><hr /><button id=\"save-settings-button\">Save Settings</button></div>";
|
||||
settings_html += "</table></div><div class=\"lightbox-footer\"><hr /><button id=\"save-settings-button\">Save Settings</button></div>";
|
||||
|
||||
settings_menu = new TopBarButton("Settings",function(){
|
||||
showLightBox("Settings",settings_html,null)
|
||||
$jq("button#save-settings-button").click(function() {
|
||||
for(var s = 0; s < settings.length; s++) {
|
||||
var val = settings[s].getVal();
|
||||
if(val !== undefined) settings[s].setCookie(val);
|
||||
settings[s].save(val);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
$jq(document).ready(function() {
|
||||
var style = getCookie("style");
|
||||
if(style === undefined) style = defaultStyle;
|
||||
var themeElem = document.getElementById("theme");
|
||||
if(themeElem) themeElem.setAttribute("href", webroot + "css/" + style);
|
||||
board = location.pathname.substring(1,location.pathname.indexOf("/",1))
|
||||
current_staff = getStaff()
|
||||
initCookies();
|
||||
|
||||
topbar = $jq("div#topbar");
|
||||
|
||||
if(getCookie("pintopbar") == "false") {
|
||||
topbar.css({
|
||||
"position": "absolute",
|
||||
"top": "0px",
|
||||
"padding-left": "0px",
|
||||
"padding-right": "0px",
|
||||
});
|
||||
}
|
||||
initSettings();
|
||||
|
||||
watched_threads_btn = new TopBarButton("WT",function() {});
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
}
|
||||
|
||||
.lightbox-footer {
|
||||
background-color:#CDCDCD;
|
||||
bottom:5%;
|
||||
clear:both;
|
||||
left:16px;
|
||||
|
|
|
@ -2,11 +2,12 @@
|
|||
<html>
|
||||
<head>
|
||||
<title>Banned</title>
|
||||
<link rel="shortcut icon" href="/favicon.png">
|
||||
<link rel="stylesheet" href="{{$.config.SiteWebfolder}}css/global.css" />
|
||||
<link rel="stylesheet" href="{{$.config.SiteWebfolder}}css/{{$.config.DefaultStyle}}" />
|
||||
<link rel="shortcut icon" href="{{.config.SiteWebfolder}}favicon.png">
|
||||
<link rel="stylesheet" href="{{.config.SiteWebfolder}}css/global.css" />
|
||||
<link id="theme" rel="stylesheet" href="{{.config.SiteWebfolder}}css/{{.config.DefaultStyle}}" />
|
||||
<script type="text/javascript">
|
||||
var styles = [{{range $ii, $style := .config.Styles}}{{if gt $ii 0}}, {{end}}{Name: "{{$style.Name}}", Filename: "{{$style.Filename}}"}{{end}}];
|
||||
var defaultStyle = "{{.config.DefaultStyle}}";
|
||||
var webroot = "{{.config.SiteWebfolder}}"
|
||||
</script>
|
||||
<script type="text/javascript" src="/javascript/jquery-3.3.1.min.js"></script>
|
||||
|
|
|
@ -7,14 +7,15 @@
|
|||
<script type="text/javascript" src="{{.config.SiteWebfolder}}javascript/jquery-3.3.1.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
var styles = [{{range $ii, $style := .config.Styles}}{{if gt $ii 0}}, {{end}}{Name: "{{$style.Name}}", Filename: "{{$style.Filename}}"}{{end}}];
|
||||
var defaultStyle = "{{.config.DefaultStyle}}";
|
||||
var webroot = "{{.config.SiteWebfolder}}"
|
||||
</script>
|
||||
<script type="text/javascript" src="{{.config.SiteWebfolder}}javascript/gochan.js"></script>
|
||||
<script type="text/javascript" src="{{.config.SiteWebfolder}}javascript/manage.js"></script>
|
||||
|
||||
<link rel="stylesheet" href="/css/global.css" />
|
||||
<link rel="stylesheet" href="/css/{{.config.DefaultStyle}}" />
|
||||
<link rel="shortcut icon" href="/favicon.png">
|
||||
<link rel="stylesheet" href="{{.config.SiteWebfolder}}css/global.css" />
|
||||
<link id="theme" rel="stylesheet" href="{{.config.SiteWebfolder}}css/{{.config.DefaultStyle}}" />
|
||||
<link rel="shortcut icon" href="{{.config.SiteWebfolder}}favicon.png">
|
||||
</head>
|
||||
<body>
|
||||
<div id="topbar">{{range $i, $board := .boards}}
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
<script type="text/javascript" src="{{$.config.SiteWebfolder}}javascript/jquery-3.3.1.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
var styles = [{{range $ii, $style := .config.Styles}}{{if gt $ii 0}}, {{end}}{Name: "{{$style.Name}}", Filename: "{{$style.Filename}}"}{{end}}];
|
||||
var defaultStyle = "{{$.config.DefaultStyle}}";
|
||||
var webroot = "{{$.config.SiteWebfolder}}";
|
||||
var thread_type = "thread";
|
||||
|
||||
|
@ -22,9 +23,9 @@
|
|||
</script>
|
||||
<script type="text/javascript" src="{{$.config.SiteWebfolder}}javascript/gochan.js"></script>
|
||||
<script type="text/javascript" src="{{$.config.SiteWebfolder}}javascript/manage.js"></script>
|
||||
<link rel="stylesheet" href="{{$.config.SiteWebfolder}}css/global.css" />
|
||||
<link rel="stylesheet" href="{{$.config.SiteWebfolder}}css/{{$.config.DefaultStyle}}" />
|
||||
<link rel="shortcut icon" href="{{$.config.SiteWebfolder}}favicon.png" />
|
||||
<link rel="stylesheet" href="{{.config.SiteWebfolder}}css/global.css" />
|
||||
<link id="theme" rel="stylesheet" href="{{.config.SiteWebfolder}}css/{{.config.DefaultStyle}}" />
|
||||
<link rel="shortcut icon" href="{{.config.SiteWebfolder}}favicon.png">
|
||||
</head>
|
||||
<body>
|
||||
<div id="topbar">
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
<title>Gochan Manage page</title>
|
||||
<link rel="stylesheet" href="{{.SiteWebfolder}}css/global.css" />
|
||||
<link rel="stylesheet" href="{{$.SiteWebfolder}}css/{{.DefaultStyle}}" />
|
||||
<link id="theme" rel="stylesheet" href="{{.SiteWebfolder}}css/{{.DefaultStyle}}" />
|
||||
<link rel="shortcut icon" href="{{.SiteWebfolder}}favicon.png" />
|
||||
<script type="text/javascript">
|
||||
var styles = [{{range $ii, $style := .Styles}}{{if gt $ii 0}}, {{end}}{Name: "{{$style.Name}}", Filename: "{{$style.Filename}}"}{{end}}];
|
||||
var defaultStyle = "{{.DefaultStyle}}";
|
||||
var webroot = "{{.SiteWebfolder}}"
|
||||
</script>
|
||||
<script type="text/javascript" src="{{.SiteWebfolder}}javascript/jquery-3.3.1.min.js"></script>
|
||||
|
|
|
@ -7,14 +7,18 @@
|
|||
<script type="text/javascript" src="/javascript/jquery-3.3.1.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
var styles = [{{range $ii, $style := .config.Styles}}{{if gt $ii 0}}, {{end}}{Name: "{{$style.Name}}", Filename: "{{$style.Filename}}"}{{end}}];
|
||||
var defaultStyle = "{{.config.DefaultStyle}}";
|
||||
var webroot = "{{$.config.SiteWebfolder}}";
|
||||
</script>
|
||||
<script type="text/javascript" src="/javascript/gochan.js"></script>
|
||||
<script type="text/javascript" src="/javascript/manage.js"></script>
|
||||
<link rel="stylesheet" href="/css/global/img.css" />
|
||||
<script type="text/javascript" src="{{.config.SiteWebfolder}}javascript/gochan.js"></script>
|
||||
<script type="text/javascript" src="{{.config.SiteWebfolder}}javascript/manage.js"></script>
|
||||
<link rel="stylesheet" href="{{.config.SiteWebfolder}}css/global/img.css" />
|
||||
{{range $_, $style := .config.Styles}}
|
||||
<link rel="stylesheet" href="/css/{{$style.Filename}}" />{{end}}
|
||||
<link rel="shortcut icon" href="/favicon.png" />
|
||||
<link rel="stylesheet" href="{{.config.SiteWebfolder}}css/{{$style.Filename}}" />{{end}}
|
||||
<link rel="shortcut icon" href="{{.config.SiteWebfolder}}favicon.png" />
|
||||
<link rel="stylesheet" href="{{.config.SiteWebfolder}}css/global.css" />
|
||||
<link id="theme" rel="stylesheet" href="{{.config.SiteWebfolder}}css/{{.config.DefaultStyle}}" />
|
||||
<link rel="shortcut icon" href="{{.config.SiteWebfolder}}favicon.png">
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue