forked from GithubBackups/vichan
main.js: trim
This commit is contained in:
parent
d78f865645
commit
8d3bfedc72
@ -45,7 +45,7 @@ function ago($timestamp) {
|
|||||||
switch(true){
|
switch(true){
|
||||||
case ($difference < 60) :
|
case ($difference < 60) :
|
||||||
return "" + $difference + ' ' + _('second(s)');
|
return "" + $difference + ' ' + _('second(s)');
|
||||||
case ($difference < 3600): //60*60 = 3600
|
case ($difference < 3600): //60*60 = 3600
|
||||||
return "" + ($num = Math.round($difference/(60))) + ' ' + _('minute(s)');
|
return "" + ($num = Math.round($difference/(60))) + ' ' + _('minute(s)');
|
||||||
case ($difference < 86400): //60*60*24 = 86400
|
case ($difference < 86400): //60*60*24 = 86400
|
||||||
return "" + ($num = Math.round($difference/(3600))) + ' ' + _('hour(s)');
|
return "" + ($num = Math.round($difference/(3600))) + ' ' + _('hour(s)');
|
||||||
@ -131,7 +131,7 @@ function changeStyle(styleName, link) {
|
|||||||
localStorage.stylesheet = styleName;
|
localStorage.stylesheet = styleName;
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% verbatim %}
|
{% verbatim %}
|
||||||
|
|
||||||
if (!document.getElementById('stylesheet')) {
|
if (!document.getElementById('stylesheet')) {
|
||||||
var s = document.createElement('link');
|
var s = document.createElement('link');
|
||||||
s.rel = 'stylesheet';
|
s.rel = 'stylesheet';
|
||||||
@ -140,21 +140,21 @@ function changeStyle(styleName, link) {
|
|||||||
var x = document.getElementsByTagName('head')[0];
|
var x = document.getElementsByTagName('head')[0];
|
||||||
x.appendChild(s);
|
x.appendChild(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
document.getElementById('stylesheet').href = styles[styleName];
|
document.getElementById('stylesheet').href = styles[styleName];
|
||||||
selectedstyle = styleName;
|
selectedstyle = styleName;
|
||||||
|
|
||||||
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 (var i = 0; i < styleLinks.length; i++) {
|
for (var i = 0; i < styleLinks.length; i++) {
|
||||||
styleLinks[i].className = '';
|
styleLinks[i].className = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (link) {
|
if (link) {
|
||||||
link.className = 'selected';
|
link.className = 'selected';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof $ != 'undefined')
|
if (typeof $ != 'undefined')
|
||||||
$(window).trigger('stylesheet', styleName);
|
$(window).trigger('stylesheet', styleName);
|
||||||
}
|
}
|
||||||
@ -163,11 +163,11 @@ function changeStyle(styleName, link) {
|
|||||||
{% endverbatim %}
|
{% endverbatim %}
|
||||||
{% if config.stylesheets_board %}
|
{% if config.stylesheets_board %}
|
||||||
{% verbatim %}
|
{% verbatim %}
|
||||||
|
|
||||||
if (!localStorage.board_stylesheets) {
|
if (!localStorage.board_stylesheets) {
|
||||||
localStorage.board_stylesheets = '{}';
|
localStorage.board_stylesheets = '{}';
|
||||||
}
|
}
|
||||||
|
|
||||||
var stylesheet_choices = JSON.parse(localStorage.board_stylesheets);
|
var stylesheet_choices = JSON.parse(localStorage.board_stylesheets);
|
||||||
if (board_name && stylesheet_choices[board_name]) {
|
if (board_name && stylesheet_choices[board_name]) {
|
||||||
for (var styleName in styles) {
|
for (var styleName in styles) {
|
||||||
@ -195,7 +195,7 @@ function changeStyle(styleName, link) {
|
|||||||
function init_stylechooser() {
|
function init_stylechooser() {
|
||||||
var newElement = document.createElement('div');
|
var newElement = document.createElement('div');
|
||||||
newElement.className = 'styles';
|
newElement.className = 'styles';
|
||||||
|
|
||||||
for (styleName in styles) {
|
for (styleName in styles) {
|
||||||
var style = document.createElement('a');
|
var style = document.createElement('a');
|
||||||
style.innerHTML = '[' + styleName + ']';
|
style.innerHTML = '[' + styleName + ']';
|
||||||
@ -207,8 +207,8 @@ function init_stylechooser() {
|
|||||||
}
|
}
|
||||||
style.href = 'javascript:void(0);';
|
style.href = 'javascript:void(0);';
|
||||||
newElement.appendChild(style);
|
newElement.appendChild(style);
|
||||||
}
|
}
|
||||||
|
|
||||||
document.getElementsByTagName('body')[0].insertBefore(newElement, document.getElementsByTagName('body')[0].lastChild.nextSibling);
|
document.getElementsByTagName('body')[0].insertBefore(newElement, document.getElementsByTagName('body')[0].lastChild.nextSibling);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -225,7 +225,7 @@ function highlightReply(id) {
|
|||||||
// don't highlight on middle click
|
// don't highlight on middle click
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
var divs = document.getElementsByTagName('div');
|
var divs = document.getElementsByTagName('div');
|
||||||
for (var i = 0; i < divs.length; i++)
|
for (var i = 0; i < divs.length; i++)
|
||||||
{
|
{
|
||||||
@ -261,10 +261,10 @@ function dopost(form) {
|
|||||||
if (form.elements['email'] && form.elements['email'].value != 'sage') {
|
if (form.elements['email'] && form.elements['email'].value != 'sage') {
|
||||||
localStorage.email = form.elements['email'].value;
|
localStorage.email = form.elements['email'].value;
|
||||||
}
|
}
|
||||||
|
|
||||||
saved[document.location] = form.elements['body'].value;
|
saved[document.location] = form.elements['body'].value;
|
||||||
sessionStorage.body = JSON.stringify(saved);
|
sessionStorage.body = JSON.stringify(saved);
|
||||||
|
|
||||||
return form.elements['body'].value != "" || (form.elements['file'] && form.elements['file'].value != "") || (form.elements.file_url && form.elements['file_url'].value != "");
|
return form.elements['body'].value != "" || (form.elements['file'] && form.elements['file'].value != "") || (form.elements.file_url && form.elements['file_url'].value != "");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -272,7 +272,7 @@ function citeReply(id, with_link) {
|
|||||||
var textarea = document.getElementById('body');
|
var textarea = document.getElementById('body');
|
||||||
|
|
||||||
if (!textarea) return false;
|
if (!textarea) return false;
|
||||||
|
|
||||||
if (document.selection) {
|
if (document.selection) {
|
||||||
// IE
|
// IE
|
||||||
textarea.focus();
|
textarea.focus();
|
||||||
@ -282,7 +282,7 @@ function citeReply(id, with_link) {
|
|||||||
var start = textarea.selectionStart;
|
var start = textarea.selectionStart;
|
||||||
var end = textarea.selectionEnd;
|
var end = textarea.selectionEnd;
|
||||||
textarea.value = textarea.value.substring(0, start) + '>>' + id + '\n' + textarea.value.substring(end, textarea.value.length);
|
textarea.value = textarea.value.substring(0, start) + '>>' + id + '\n' + textarea.value.substring(end, textarea.value.length);
|
||||||
|
|
||||||
textarea.selectionStart += ('>>' + id).length + 1;
|
textarea.selectionStart += ('>>' + id).length + 1;
|
||||||
textarea.selectionEnd = textarea.selectionStart;
|
textarea.selectionEnd = textarea.selectionStart;
|
||||||
} else {
|
} else {
|
||||||
@ -312,15 +312,15 @@ function rememberStuff() {
|
|||||||
localStorage.password = generatePassword();
|
localStorage.password = generatePassword();
|
||||||
document.forms.post.password.value = localStorage.password;
|
document.forms.post.password.value = localStorage.password;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (localStorage.name && document.forms.post.elements['name'])
|
if (localStorage.name && document.forms.post.elements['name'])
|
||||||
document.forms.post.elements['name'].value = localStorage.name;
|
document.forms.post.elements['name'].value = localStorage.name;
|
||||||
if (localStorage.email && document.forms.post.elements['email'])
|
if (localStorage.email && document.forms.post.elements['email'])
|
||||||
document.forms.post.elements['email'].value = localStorage.email;
|
document.forms.post.elements['email'].value = localStorage.email;
|
||||||
|
|
||||||
if (window.location.hash.indexOf('q') == 1)
|
if (window.location.hash.indexOf('q') == 1)
|
||||||
citeReply(window.location.hash.substring(2), true);
|
citeReply(window.location.hash.substring(2), true);
|
||||||
|
|
||||||
if (sessionStorage.body) {
|
if (sessionStorage.body) {
|
||||||
var saved = JSON.parse(sessionStorage.body);
|
var saved = JSON.parse(sessionStorage.body);
|
||||||
if (get_cookie('{% endverbatim %}{{ config.cookies.js }}{% verbatim %}')) {
|
if (get_cookie('{% endverbatim %}{{ config.cookies.js }}{% verbatim %}')) {
|
||||||
@ -330,14 +330,14 @@ function rememberStuff() {
|
|||||||
saved[url] = null;
|
saved[url] = null;
|
||||||
}
|
}
|
||||||
sessionStorage.body = JSON.stringify(saved);
|
sessionStorage.body = JSON.stringify(saved);
|
||||||
|
|
||||||
document.cookie = '{% endverbatim %}{{ config.cookies.js }}{% verbatim %}={};expires=0;path=/;';
|
document.cookie = '{% endverbatim %}{{ config.cookies.js }}{% verbatim %}={};expires=0;path=/;';
|
||||||
}
|
}
|
||||||
if (saved[document.location]) {
|
if (saved[document.location]) {
|
||||||
document.forms.post.body.value = saved[document.location];
|
document.forms.post.body.value = saved[document.location];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (localStorage.body) {
|
if (localStorage.body) {
|
||||||
document.forms.post.body.value = localStorage.body;
|
document.forms.post.body.value = localStorage.body;
|
||||||
localStorage.body = '';
|
localStorage.body = '';
|
||||||
@ -359,14 +359,14 @@ var script_settings = function(script_name) {
|
|||||||
function init() {
|
function init() {
|
||||||
init_stylechooser();
|
init_stylechooser();
|
||||||
|
|
||||||
{% endverbatim %}
|
{% endverbatim %}
|
||||||
{% if config.allow_delete %}
|
{% if config.allow_delete %}
|
||||||
if (document.forms.postcontrols) {
|
if (document.forms.postcontrols) {
|
||||||
document.forms.postcontrols.password.value = localStorage.password;
|
document.forms.postcontrols.password.value = localStorage.password;
|
||||||
}
|
}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% verbatim %}
|
{% verbatim %}
|
||||||
|
|
||||||
if (window.location.hash.indexOf('q') != 1 && window.location.hash.substring(1))
|
if (window.location.hash.indexOf('q') != 1 && window.location.hash.substring(1))
|
||||||
highlightReply(window.location.hash.substring(1));
|
highlightReply(window.location.hash.substring(1));
|
||||||
}
|
}
|
||||||
@ -404,4 +404,3 @@ sc.innerHTML = 'var sc_project={{ config.statcounter_project }};var sc_invisible
|
|||||||
var s = document.getElementsByTagName('script')[0];
|
var s = document.getElementsByTagName('script')[0];
|
||||||
s.parentNode.insertBefore(sc, s);
|
s.parentNode.insertBefore(sc, s);
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user