mirror of
https://github.com/vichan-devel/vichan.git
synced 2024-11-12 01:50:48 +01:00
Slightly less crappy stylesheet chooser
This commit is contained in:
parent
0183506993
commit
881fb0d315
@ -525,7 +525,7 @@
|
||||
// $config['banner_height'] = 100;
|
||||
|
||||
// Custom stylesheets available. The prefix for each stylesheet URI is defined below.
|
||||
$config['stylesheets']['Yotsuba B'] = 'default.css';
|
||||
$config['stylesheets']['Yotsuba B'] = ''; // default
|
||||
$config['stylesheets']['Yotsuba'] = 'yotsuba.css';
|
||||
// $config['stylesheets']['Futaba'] = 'futaba.css';
|
||||
|
||||
|
@ -21,7 +21,8 @@ class Twig_Extensions_Extension_Tinyboard extends Twig_Extension
|
||||
'poster_id' => new Twig_Filter_Function('poster_id', array('needs_environment' => false)),
|
||||
'remove_whitespace' => new Twig_Filter_Function('twig_remove_whitespace_filter', array('needs_environment' => false)),
|
||||
'count' => new Twig_Filter_Function('count', array('needs_environment' => false)),
|
||||
'until' => new Twig_Filter_Function('until', array('needs_environment' => false))
|
||||
'until' => new Twig_Filter_Function('until', array('needs_environment' => false)),
|
||||
'addslashes' => new Twig_Filter_Function('addslashes', array('needs_environment' => false)),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1,13 +1,13 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" media="screen" href="{{ config.url_stylesheet }}" />
|
||||
{% if config.url_favicon %}<link rel="shortcut icon" href="{{ config.url_favicon }}" />{% endif %}
|
||||
<link rel="stylesheet" media="screen" href="{{ config.url_stylesheet }}">
|
||||
{% if config.url_favicon %}<link rel="shortcut icon" href="{{ config.url_favicon }}">{% endif %}
|
||||
<title>{{ board.url }} - {{ board.name }}</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
|
||||
{% if config.meta_keywords %}<meta name="keywords" content="{{ config.meta_keywords }}" />{% endif %}
|
||||
<link rel="stylesheet" type="text/css" id="stylesheet" href="{{ config.uri_stylesheets }}{{ config.default_stylesheet.1 }}" />
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
|
||||
{% if config.meta_keywords %}<meta name="keywords" content="{{ config.meta_keywords }}">{% endif %}
|
||||
{% if config.default_stylesheet.1 != '' %}<link rel="stylesheet" type="text/css" id="stylesheet" href="{{ config.uri_stylesheets }}{{ config.default_stylesheet.1 }}">{% endif %}
|
||||
{% if not nojavascript %}
|
||||
<script type="text/javascript" src="{{ config.url_javascript }}"></script>
|
||||
{% if not config.additional_javascript_compile %}
|
||||
|
@ -1,12 +1,71 @@
|
||||
{% raw %}
|
||||
|
||||
var selectedstyle = '{% endraw %}{{ config.default_stylesheet.0 }}{% raw %}';
|
||||
var styles = [
|
||||
{% endraw %}{% for stylesheet in stylesheets %}{% raw %}['{% endraw %}{{ stylesheet.name }}{% raw %}', '{% endraw %}{{ stylesheet.uri }}{% raw %}']{% endraw %}{% if not loop.last %}{% raw %},
|
||||
{% endraw %}{% endif %}{% endfor %}{% raw %}
|
||||
];
|
||||
var saved = {};
|
||||
|
||||
|
||||
var selectedstyle = '{% endraw %}{{ config.default_stylesheet.0|addslashes }}{% raw %}';
|
||||
var styles = {
|
||||
{% endraw %}
|
||||
{% for stylesheet in stylesheets %}{% raw %}'{% endraw %}{{ stylesheet.name|addslashes }}{% raw %}' : '{% endraw %}{{ stylesheet.uri|addslashes }}{% raw %}',
|
||||
{% endraw %}{% endfor %}{% raw %}
|
||||
};
|
||||
|
||||
function changeStyle(styleName, link) {
|
||||
localStorage.stylesheet = styleName;
|
||||
|
||||
if (!document.getElementById('stylesheet')) {
|
||||
var s = document.createElement('link');
|
||||
s.rel = 'stylesheet';
|
||||
s.type = 'text/css';
|
||||
s.id = 'stylesheet';
|
||||
var x = document.getElementsByTagName('head')[0];
|
||||
x.appendChild(s);
|
||||
}
|
||||
|
||||
document.getElementById('stylesheet').href = styles[styleName];
|
||||
selectedstyle = styleName;
|
||||
|
||||
if (document.getElementsByClassName('styles').length != 0) {
|
||||
var styleLinks = document.getElementsByClassName('styles')[0].childNodes;
|
||||
for (i = 0; i < styleLinks.length; i++) {
|
||||
styleLinks[i].className = '';
|
||||
}
|
||||
}
|
||||
|
||||
if (link) {
|
||||
link.className = 'selected';
|
||||
}
|
||||
}
|
||||
|
||||
if (localStorage.stylesheet) {
|
||||
for (styleName in styles) {
|
||||
if (styleName == localStorage.stylesheet) {
|
||||
changeStyle(styleName);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function init_stylechooser() {
|
||||
var newElement = document.createElement('div');
|
||||
newElement.className = 'styles';
|
||||
|
||||
for (styleName in styles) {
|
||||
var style = document.createElement('a');
|
||||
style.innerHTML = '[' + styleName + ']';
|
||||
style.onclick = function() {
|
||||
changeStyle(this.innerHTML.substring(1, this.innerHTML.length - 1), this);
|
||||
};
|
||||
if (styleName == selectedstyle) {
|
||||
style.className = 'selected';
|
||||
}
|
||||
style.href = 'javascript:void(0);';
|
||||
newElement.appendChild(style);
|
||||
}
|
||||
|
||||
document.getElementsByTagName('body')[0].insertBefore(newElement, document.getElementsByTagName('body')[0].lastChild.nextSibling);
|
||||
}
|
||||
|
||||
function get_cookie(cookie_name) {
|
||||
var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)');
|
||||
if (results)
|
||||
@ -57,6 +116,7 @@ function dopost(form) {
|
||||
|
||||
return form.elements['body'].value != "" || form.elements['file'].value != "";
|
||||
}
|
||||
|
||||
function citeReply(id) {
|
||||
var body = document.getElementById('body');
|
||||
|
||||
@ -76,21 +136,6 @@ function citeReply(id) {
|
||||
}
|
||||
}
|
||||
|
||||
function changeStyle(x) {
|
||||
localStorage.stylesheet = styles[x][1];
|
||||
document.getElementById('stylesheet').href = styles[x][1];
|
||||
selectedstyle = styles[x][0];
|
||||
}
|
||||
|
||||
if(localStorage.stylesheet) {
|
||||
for(var x = 0; x < styles.length ; x++) {
|
||||
if(styles[x][1] == localStorage.stylesheet) {
|
||||
changeStyle(x);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function rememberStuff() {
|
||||
if (document.forms.post) {
|
||||
if (document.forms.post.password) {
|
||||
@ -132,19 +177,7 @@ function rememberStuff() {
|
||||
}
|
||||
|
||||
function init() {
|
||||
var newElement = document.createElement('div');
|
||||
newElement.className = 'styles';
|
||||
|
||||
for(x = 0; x < styles.length; x++) {
|
||||
var style = document.createElement('a');
|
||||
style.innerHTML = '[' + styles[x][0] + ']';
|
||||
style.href = 'javascript:changeStyle(' + x + ');';
|
||||
if(selectedstyle == styles[x][0])
|
||||
style.className = 'selected';
|
||||
newElement.appendChild(style);
|
||||
}
|
||||
|
||||
document.getElementsByTagName('body')[0].insertBefore(newElement, document.getElementsByTagName('body')[0].lastChild.nextSibling)
|
||||
init_stylechooser();
|
||||
|
||||
if (document.forms.postcontrols) {
|
||||
document.forms.postcontrols.password.value = localStorage.password;
|
||||
@ -174,3 +207,4 @@ onready(init);
|
||||
{% endraw %}{% if config.google_analytics %}{% raw %}
|
||||
|
||||
var _gaq = _gaq || [];_gaq.push(['_setAccount', '{% endraw %}{{ config.google_analytics }}{% raw %}']);{% endraw %}{% if config.google_analytics_domain %}{% raw %}_gaq.push(['_setDomainName', '{% endraw %}{{ config.google_analytics_domain }}{% raw %}']){% endraw %}{% endif %}{% if not config.google_analytics_domain %}{% raw %}_gaq.push(['_setDomainName', 'none']){% endraw %}{% endif %}{% raw %};_gaq.push(['_trackPageview']);(function() {var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);})();{% endraw %}{% endif %}
|
||||
|
||||
|
@ -1,16 +1,16 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" media="screen" href="{{ config.url_stylesheet }}" />
|
||||
{% if config.url_favicon %}<link rel="shortcut icon" href="{{ config.url_favicon }}" />{% endif %}
|
||||
<link rel="stylesheet" media="screen" href="{{ config.url_stylesheet }}">
|
||||
{% if config.url_favicon %}<link rel="shortcut icon" href="{{ config.url_favicon }}">{% endif %}
|
||||
<title>{{ title }}</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
|
||||
<link rel="stylesheet" type="text/css" id="stylesheet" href="{{ config.uri_stylesheets }}{{ config.default_stylesheet.1 }}" />
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
|
||||
{% if config.default_stylesheet.1 != '' %}<link rel="stylesheet" type="text/css" id="stylesheet" href="{{ config.uri_stylesheets }}{{ config.default_stylesheet.1 }}">{% endif %}
|
||||
{% if not nojavascript %}<script type="text/javascript" src="{{ config.url_javascript }}"></script>{% endif %}
|
||||
</head>
|
||||
<body>
|
||||
{% if pm %}<div class="top_notice">You have <a href="?/PM/{{ pm.id }}">an unread PM</a>{% if pm.waiting > 0 %}, plus {{ pm.waiting }} more waiting{% endif %}.</div><hr />{% endif %}
|
||||
{% if pm %}<div class="top_notice">You have <a href="?/PM/{{ pm.id }}">an unread PM</a>{% if pm.waiting > 0 %}, plus {{ pm.waiting }} more waiting{% endif %}.</div><hr>{% endif %}
|
||||
<header>
|
||||
<h1>{{ title }}</h1>
|
||||
<div class="subtitle">
|
||||
@ -21,7 +21,7 @@
|
||||
</div>
|
||||
</header>
|
||||
{{ body }}
|
||||
<hr />
|
||||
<hr>
|
||||
<footer>
|
||||
<p class="unimportant" style="margin-top:20px;text-align:center;">Powered by <a href="http://tinyboard.org/">Tinyboard</a> {{ config.version }} | <a href="http://tinyboard.org/">Tinyboard</a> Copyright © 2010-2012 Tinyboard Development Group</p>
|
||||
</footer>
|
||||
|
@ -1,13 +1,13 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" media="screen" href="{{ config.url_stylesheet }}" />
|
||||
{% if config.url_favicon %}<link rel="shortcut icon" href="{{ config.url_favicon }}" />{% endif %}
|
||||
<link rel="stylesheet" media="screen" href="{{ config.url_stylesheet }}">
|
||||
{% if config.url_favicon %}<link rel="shortcut icon" href="{{ config.url_favicon }}">{% endif %}
|
||||
<title>{{ board.url }} - {{ board.name }}</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
|
||||
{% if config.meta_keywords %}<meta name="keywords" content="{{ config.meta_keywords }}" />{% endif %}
|
||||
<link rel="stylesheet" type="text/css" id="stylesheet" href="{{ config.uri_stylesheets }}{{ config.default_stylesheet.1 }}" />
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
|
||||
{% if config.meta_keywords %}<meta name="keywords" content="{{ config.meta_keywords }}">{% endif %}
|
||||
{% if config.default_stylesheet.1 != '' %}<link rel="stylesheet" type="text/css" id="stylesheet" href="{{ config.uri_stylesheets }}{{ config.default_stylesheet.1 }}">{% endif %}
|
||||
{% if not nojavascript %}
|
||||
<script type="text/javascript" src="{{ config.url_javascript }}"></script>
|
||||
{% if not config.additional_javascript_compile %}
|
||||
|
Loading…
Reference in New Issue
Block a user