Option to make stylesheet selections board-specific
This commit is contained in:
parent
f0aee74523
commit
ab0c5ee481
@ -560,6 +560,9 @@
|
|||||||
// The default stylesheet to use
|
// The default stylesheet to use
|
||||||
$config['default_stylesheet'] = array('Yotsuba B', $config['stylesheets']['Yotsuba B']);
|
$config['default_stylesheet'] = array('Yotsuba B', $config['stylesheets']['Yotsuba B']);
|
||||||
|
|
||||||
|
// Make stylesheet selections board-specific
|
||||||
|
$config['stylesheets_board'] = false;
|
||||||
|
|
||||||
// Boardlinks
|
// Boardlinks
|
||||||
// You can group, order and place the boardlist at the top of every page, using the following template.
|
// You can group, order and place the boardlist at the top of every page, using the following template.
|
||||||
//$config['boards'] = array(
|
//$config['boards'] = array(
|
||||||
|
@ -9,9 +9,19 @@ var styles = {
|
|||||||
{% for stylesheet in stylesheets %}{% raw %}'{% endraw %}{{ stylesheet.name|addslashes }}{% raw %}' : '{% endraw %}{{ stylesheet.uri|addslashes }}{% raw %}',
|
{% for stylesheet in stylesheets %}{% raw %}'{% endraw %}{{ stylesheet.name|addslashes }}{% raw %}' : '{% endraw %}{{ stylesheet.uri|addslashes }}{% raw %}',
|
||||||
{% endraw %}{% endfor %}{% raw %}
|
{% endraw %}{% endfor %}{% raw %}
|
||||||
};
|
};
|
||||||
|
var board_name = false;
|
||||||
|
|
||||||
function changeStyle(styleName, link) {
|
function changeStyle(styleName, link) {
|
||||||
localStorage.stylesheet = styleName;
|
{% endraw %}
|
||||||
|
{% if config.stylesheets_board %}{% raw %}
|
||||||
|
if (board_name) {
|
||||||
|
stylesheet_choices[board_name] = styleName;
|
||||||
|
localStorage.board_stylesheets = JSON.stringify(stylesheet_choices);
|
||||||
|
}
|
||||||
|
{% endraw %}{% else %}
|
||||||
|
localStorage.stylesheet = styleName;
|
||||||
|
{% endif %}
|
||||||
|
{% raw %}
|
||||||
|
|
||||||
if (!document.getElementById('stylesheet')) {
|
if (!document.getElementById('stylesheet')) {
|
||||||
var s = document.createElement('link');
|
var s = document.createElement('link');
|
||||||
@ -27,7 +37,7 @@ function changeStyle(styleName, link) {
|
|||||||
|
|
||||||
if (document.getElementsByClassName('styles').length != 0) {
|
if (document.getElementsByClassName('styles').length != 0) {
|
||||||
var styleLinks = document.getElementsByClassName('styles')[0].childNodes;
|
var styleLinks = document.getElementsByClassName('styles')[0].childNodes;
|
||||||
for (i = 0; i < styleLinks.length; i++) {
|
for (var i = 0; i < styleLinks.length; i++) {
|
||||||
styleLinks[i].className = '';
|
styleLinks[i].className = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -36,15 +46,44 @@ function changeStyle(styleName, link) {
|
|||||||
link.className = 'selected';
|
link.className = 'selected';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (localStorage.stylesheet) {
|
|
||||||
for (styleName in styles) {
|
{% endraw %}
|
||||||
if (styleName == localStorage.stylesheet) {
|
{% if config.stylesheets_board %}
|
||||||
changeStyle(styleName);
|
{# This is such an unacceptable mess. There needs to be an easier way. #}
|
||||||
break;
|
var matches = document.URL.match(/\/(\w+)\/($|{{ config.dir.res|replace({'/': '\\/'}) }}{{ config.file_page|replace({'%d': '\\d+', '.': '\\.'}) }}|{{ config.file_index|replace({'.': '\\.'}) }}|{{ config.file_page|replace({'%d': '\\d+', '.': '\\.'}) }})/);
|
||||||
|
{% raw %}
|
||||||
|
if (matches) {
|
||||||
|
board_name = matches[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!localStorage.board_stylesheets) {
|
||||||
|
localStorage.board_stylesheets = '{}';
|
||||||
|
}
|
||||||
|
|
||||||
|
var stylesheet_choices = JSON.parse(localStorage.board_stylesheets);
|
||||||
|
if (board_name && stylesheet_choices[board_name]) {
|
||||||
|
for (var styleName in styles) {
|
||||||
|
if (styleName == stylesheet_choices[board_name]) {
|
||||||
|
changeStyle(styleName);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
{% endraw%}
|
||||||
|
{% else %}
|
||||||
|
{% raw %}
|
||||||
|
if (localStorage.stylesheet) {
|
||||||
|
for (var styleName in styles) {
|
||||||
|
if (styleName == localStorage.stylesheet) {
|
||||||
|
changeStyle(styleName);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
{% endraw %}
|
||||||
|
{% endif %}
|
||||||
|
{% raw %}
|
||||||
|
|
||||||
function init_stylechooser() {
|
function init_stylechooser() {
|
||||||
var newElement = document.createElement('div');
|
var newElement = document.createElement('div');
|
||||||
|
Loading…
Reference in New Issue
Block a user