2021-11-04 03:45:01 +01:00
|
|
|
{% verbatim %}
|
2013-07-31 10:28:26 +02:00
|
|
|
|
|
|
|
/* gettext-compatible _ function, example of usage:
|
|
|
|
*
|
|
|
|
* > // Loading pl_PL.json here (containing polish translation strings generated by tools/i18n_compile.php)
|
|
|
|
* > alert(_("Hello!"));
|
|
|
|
* Witaj!
|
|
|
|
*/
|
|
|
|
function _(s) {
|
|
|
|
return (typeof l10n != 'undefined' && typeof l10n[s] != 'undefined') ? l10n[s] : s;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* printf-like formatting function, example of usage:
|
|
|
|
*
|
|
|
|
* > alert(fmt("There are {0} birds on {1} trees", [3,4]));
|
|
|
|
* There are 3 birds on 4 trees
|
|
|
|
* > // Loading pl_PL.json here (containing polish translation strings generated by tools/locale_compile.php)
|
|
|
|
* > alert(fmt(_("{0} users"), [3]));
|
|
|
|
* 3 uzytkownikow
|
|
|
|
*/
|
2024-08-04 15:32:12 +02:00
|
|
|
function fmt(s, a) {
|
2013-07-31 10:28:26 +02:00
|
|
|
return s.replace(/\{([0-9]+)\}/g, function(x) { return a[x[1]]; });
|
|
|
|
}
|
|
|
|
|
2024-08-04 15:32:12 +02:00
|
|
|
function until(timestamp) {
|
|
|
|
let difference = timestamp - Date.now() / 1000 | 0;
|
|
|
|
switch (true) {
|
|
|
|
case (difference < 60):
|
|
|
|
return "" + difference + ' ' + _('second(s)');
|
|
|
|
case (difference < 3600): // 60 * 60 = 3600
|
|
|
|
return "" + Math.round(difference / 60) + ' ' + _('minute(s)');
|
|
|
|
case (difference < 86400): // 60 * 60 * 24 = 86400
|
|
|
|
return "" + Math.round(difference / 3600) + ' ' + _('hour(s)');
|
|
|
|
case (difference < 604800): // 60 * 60 * 24 * 7 = 604800
|
|
|
|
return "" + Math.round(difference / 86400) + ' ' + _('day(s)');
|
|
|
|
case (difference < 31536000): // 60 * 60 * 24 * 365 = 31536000
|
|
|
|
return "" + Math.round(difference / 604800) + ' ' + _('week(s)');
|
|
|
|
default:
|
|
|
|
return "" + Math.round(difference / 31536000) + ' ' + _('year(s)');
|
|
|
|
}
|
2014-10-08 23:23:59 +02:00
|
|
|
}
|
|
|
|
|
2024-08-04 15:32:12 +02:00
|
|
|
function ago(timestamp) {
|
|
|
|
let difference = (Date.now() / 1000 | 0) - timestamp;
|
|
|
|
switch (true) {
|
|
|
|
case (difference < 60):
|
|
|
|
return "" + difference + ' ' + _('second(s)');
|
|
|
|
case (difference < 3600): /// 60 * 60 = 3600
|
|
|
|
return "" + Math.round(difference/(60)) + ' ' + _('minute(s)');
|
|
|
|
case (difference < 86400): // 60 * 60 * 24 = 86400
|
|
|
|
return "" + Math.round(difference/(3600)) + ' ' + _('hour(s)');
|
|
|
|
case (difference < 604800): // 60 * 60 * 24 * 7 = 604800
|
|
|
|
return "" + Math.round(difference/(86400)) + ' ' + _('day(s)');
|
|
|
|
case (difference < 31536000): // 60 * 60 * 24 * 365 = 31536000
|
|
|
|
return "" + Math.round(difference/(604800)) + ' ' + _('week(s)');
|
|
|
|
default:
|
|
|
|
return "" + Math.round(difference/(31536000)) + ' ' + _('year(s)');
|
|
|
|
}
|
2014-10-08 23:23:59 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
var datelocale =
|
2024-08-04 15:32:12 +02:00
|
|
|
{ days: [_('Sunday'), _('Monday'), _('Tuesday'), _('Wednesday'), _('Thursday'), _('Friday'), _('Saturday')]
|
|
|
|
, shortDays: [_("Sun"), _("Mon"), _("Tue"), _("Wed"), _("Thu"), _("Fri"), _("Sat")]
|
|
|
|
, months: [_('January'), _('February'), _('March'), _('April'), _('May'), _('June'), _('July'), _('August'), _('September'), _('October'), _('November'), _('December')]
|
|
|
|
, shortMonths: [_('Jan'), _('Feb'), _('Mar'), _('Apr'), _('May'), _('Jun'), _('Jul'), _('Aug'), _('Sep'), _('Oct'), _('Nov'), _('Dec')]
|
|
|
|
, AM: _('AM')
|
|
|
|
, PM: _('PM')
|
|
|
|
, am: _('am')
|
|
|
|
, pm: _('pm')
|
|
|
|
};
|
2014-10-08 23:23:59 +02:00
|
|
|
|
2014-10-18 22:43:35 +02:00
|
|
|
|
2015-02-28 14:06:50 +01:00
|
|
|
function alert(a, do_confirm, confirm_ok_action, confirm_cancel_action) {
|
2024-08-04 15:32:12 +02:00
|
|
|
var handler, div, bg, closebtn, okbtn;
|
|
|
|
let close = function() {
|
|
|
|
handler.fadeOut(400, function() { handler.remove(); });
|
|
|
|
return false;
|
|
|
|
};
|
2014-10-18 22:43:35 +02:00
|
|
|
|
2024-08-04 15:32:12 +02:00
|
|
|
handler = $("<div id='alert_handler'></div>").hide().appendTo('body');
|
2014-10-18 22:43:35 +02:00
|
|
|
|
2024-08-04 15:32:12 +02:00
|
|
|
bg = $("<div id='alert_background'></div>").appendTo(handler);
|
2014-10-18 22:43:35 +02:00
|
|
|
|
2024-08-04 15:32:12 +02:00
|
|
|
div = $("<div id='alert_div'></div>").appendTo(handler);
|
|
|
|
closebtn = $("<a id='alert_close' href='javascript:void(0)'><i class='fa fa-times'></i></div>")
|
|
|
|
.appendTo(div);
|
2014-10-18 22:43:35 +02:00
|
|
|
|
2024-08-04 15:32:12 +02:00
|
|
|
$("<div id='alert_message'></div>").html(a).appendTo(div);
|
2014-10-18 22:43:35 +02:00
|
|
|
|
2024-08-04 15:32:12 +02:00
|
|
|
okbtn = $("<button class='button alert_button'>"+_("OK")+"</button>").appendTo(div);
|
2014-10-18 22:43:35 +02:00
|
|
|
|
2024-08-04 15:32:12 +02:00
|
|
|
if (do_confirm) {
|
|
|
|
confirm_ok_action = (typeof confirm_ok_action !== "function") ? function(){} : confirm_ok_action;
|
|
|
|
confirm_cancel_action = (typeof confirm_cancel_action !== "function") ? function(){} : confirm_cancel_action;
|
|
|
|
okbtn.click(confirm_ok_action);
|
|
|
|
$("<button class='button alert_button'>"+_("Cancel")+"</button>").click(confirm_cancel_action).click(close).appendTo(div);
|
|
|
|
bg.click(confirm_cancel_action);
|
|
|
|
okbtn.click(confirm_cancel_action);
|
|
|
|
closebtn.click(confirm_cancel_action);
|
|
|
|
}
|
2015-02-28 14:06:50 +01:00
|
|
|
|
2024-08-04 15:32:12 +02:00
|
|
|
bg.click(close);
|
|
|
|
okbtn.click(close);
|
|
|
|
closebtn.click(close);
|
2015-02-28 14:06:50 +01:00
|
|
|
|
2024-08-04 15:32:12 +02:00
|
|
|
handler.fadeIn(400);
|
2014-10-18 22:43:35 +02:00
|
|
|
}
|
|
|
|
|
2013-07-31 10:28:26 +02:00
|
|
|
var saved = {};
|
|
|
|
|
|
|
|
|
2021-11-04 03:45:01 +01:00
|
|
|
var selectedstyle = '{% endverbatim %}{{ config.default_stylesheet.0|addslashes }}{% verbatim %}';
|
2013-07-31 10:28:26 +02:00
|
|
|
var styles = {
|
2021-11-04 03:45:01 +01:00
|
|
|
{% endverbatim %}
|
|
|
|
{% for stylesheet in stylesheets %}{% verbatim %}'{% endverbatim %}{{ stylesheet.name|addslashes }}{% verbatim %}' : '{% endverbatim %}{{ stylesheet.uri|addslashes }}{% verbatim %}',
|
|
|
|
{% endverbatim %}{% endfor %}{% verbatim %}
|
2013-07-31 10:28:26 +02:00
|
|
|
};
|
2016-05-05 14:38:24 +02:00
|
|
|
|
|
|
|
if (typeof board_name === 'undefined') {
|
|
|
|
var board_name = false;
|
|
|
|
}
|
2013-07-31 10:28:26 +02:00
|
|
|
|
2013-07-23 07:35:56 +02:00
|
|
|
function changeStyle(styleName, link) {
|
2021-11-04 03:45:01 +01:00
|
|
|
{% endverbatim %}
|
|
|
|
{% if config.stylesheets_board %}{% verbatim %}
|
2013-07-23 07:35:56 +02:00
|
|
|
if (board_name) {
|
|
|
|
stylesheet_choices[board_name] = styleName;
|
|
|
|
localStorage.board_stylesheets = JSON.stringify(stylesheet_choices);
|
|
|
|
}
|
2021-11-04 03:45:01 +01:00
|
|
|
{% endverbatim %}{% else %}
|
2013-07-23 07:35:56 +02:00
|
|
|
localStorage.stylesheet = styleName;
|
|
|
|
{% endif %}
|
2021-11-04 03:45:01 +01:00
|
|
|
{% verbatim %}
|
2024-04-15 23:33:12 +02:00
|
|
|
|
2013-07-31 10:28:26 +02:00
|
|
|
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);
|
|
|
|
}
|
2024-04-15 23:33:12 +02:00
|
|
|
|
2013-07-31 10:28:26 +02:00
|
|
|
document.getElementById('stylesheet').href = styles[styleName];
|
|
|
|
selectedstyle = styleName;
|
2024-04-15 23:33:12 +02:00
|
|
|
|
2013-07-31 10:28:26 +02:00
|
|
|
if (document.getElementsByClassName('styles').length != 0) {
|
|
|
|
var styleLinks = document.getElementsByClassName('styles')[0].childNodes;
|
|
|
|
for (var i = 0; i < styleLinks.length; i++) {
|
|
|
|
styleLinks[i].className = '';
|
|
|
|
}
|
|
|
|
}
|
2024-04-15 23:33:12 +02:00
|
|
|
|
2013-07-31 10:28:26 +02:00
|
|
|
if (link) {
|
|
|
|
link.className = 'selected';
|
|
|
|
}
|
2024-04-15 23:33:12 +02:00
|
|
|
|
2024-08-04 15:32:12 +02:00
|
|
|
if (typeof $ != 'undefined') {
|
2013-09-15 02:29:35 +02:00
|
|
|
$(window).trigger('stylesheet', styleName);
|
2024-08-04 15:32:12 +02:00
|
|
|
}
|
2013-07-31 10:28:26 +02:00
|
|
|
}
|
2013-07-23 07:35:56 +02:00
|
|
|
|
|
|
|
|
2021-11-04 03:45:01 +01:00
|
|
|
{% endverbatim %}
|
2013-07-23 07:35:56 +02:00
|
|
|
{% if config.stylesheets_board %}
|
2021-11-04 03:45:01 +01:00
|
|
|
{% verbatim %}
|
2024-04-15 23:33:12 +02:00
|
|
|
|
2013-07-23 07:35:56 +02:00
|
|
|
if (!localStorage.board_stylesheets) {
|
|
|
|
localStorage.board_stylesheets = '{}';
|
|
|
|
}
|
2024-04-15 23:33:12 +02:00
|
|
|
|
2013-07-23 07:35:56 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-11-04 03:45:01 +01:00
|
|
|
{% endverbatim%}
|
2013-07-23 07:35:56 +02:00
|
|
|
{% else %}
|
2021-11-04 03:45:01 +01:00
|
|
|
{% verbatim %}
|
2013-07-31 10:28:26 +02:00
|
|
|
if (localStorage.stylesheet) {
|
|
|
|
for (var styleName in styles) {
|
|
|
|
if (styleName == localStorage.stylesheet) {
|
|
|
|
changeStyle(styleName);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2013-07-23 07:35:56 +02:00
|
|
|
}
|
2021-11-04 03:45:01 +01:00
|
|
|
{% endverbatim %}
|
2013-07-23 07:35:56 +02:00
|
|
|
{% endif %}
|
2021-11-04 03:45:01 +01:00
|
|
|
{% verbatim %}
|
2013-07-31 10:28:26 +02:00
|
|
|
|
2024-08-04 15:37:36 +02:00
|
|
|
function initStyleChooser() {
|
2013-07-31 10:28:26 +02:00
|
|
|
var newElement = document.createElement('div');
|
|
|
|
newElement.className = 'styles';
|
2024-04-15 23:33:12 +02:00
|
|
|
|
2013-07-31 10:28:26 +02:00
|
|
|
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);
|
2024-04-15 23:33:12 +02:00
|
|
|
}
|
|
|
|
|
2013-07-31 10:28:26 +02:00
|
|
|
document.getElementsByTagName('body')[0].insertBefore(newElement, document.getElementsByTagName('body')[0].lastChild.nextSibling);
|
|
|
|
}
|
|
|
|
|
2024-08-04 15:07:56 +02:00
|
|
|
function getCookie(cookie_name) {
|
|
|
|
let results = document.cookie.match('(^|;) ?' + cookie_name + '=([^;]*)(;|$)');
|
|
|
|
if (results) {
|
|
|
|
return unescape(results[2]);
|
|
|
|
} else {
|
2013-07-31 10:28:26 +02:00
|
|
|
return null;
|
2024-08-04 15:07:56 +02:00
|
|
|
}
|
2013-07-31 10:28:26 +02:00
|
|
|
}
|
|
|
|
|
2024-05-25 00:32:44 +02:00
|
|
|
{% endraw %}
|
2024-08-15 16:11:28 +02:00
|
|
|
{% if config.captcha.dynamic %}
|
2024-05-25 00:32:44 +02:00
|
|
|
function is_dynamic_captcha_enabled() {
|
|
|
|
let cookie = get_cookie('require-captcha');
|
|
|
|
return cookie === '1';
|
|
|
|
}
|
|
|
|
|
|
|
|
function get_captcha_pub_key() {
|
2024-08-15 16:11:28 +02:00
|
|
|
{% if config.captcha.provider === 'recaptcha' %}
|
|
|
|
return "{{ config.captcha.recaptcha.sitekey }}";
|
2024-05-25 00:32:44 +02:00
|
|
|
{% else %}
|
|
|
|
return null;
|
|
|
|
{% endif %}
|
|
|
|
}
|
|
|
|
|
|
|
|
function init_dynamic_captcha() {
|
|
|
|
if (!is_dynamic_captcha_enabled()) {
|
|
|
|
let pub_key = get_captcha_pub_key();
|
|
|
|
if (!pub_key) {
|
|
|
|
console.error("Missing public captcha key!");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
let captcha_hook = document.getElementById('captcha');
|
|
|
|
captcha_hook.style = "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
{% endif %}
|
|
|
|
{% raw %}
|
|
|
|
|
2013-07-31 10:28:26 +02:00
|
|
|
function highlightReply(id) {
|
|
|
|
if (typeof window.event != "undefined" && event.which == 2) {
|
|
|
|
// don't highlight on middle click
|
|
|
|
return true;
|
|
|
|
}
|
2024-04-15 23:33:12 +02:00
|
|
|
|
2024-08-04 15:32:12 +02:00
|
|
|
let divs = document.getElementsByTagName('div');
|
2013-07-31 10:28:26 +02:00
|
|
|
for (var i = 0; i < divs.length; i++)
|
|
|
|
{
|
2024-08-04 15:32:12 +02:00
|
|
|
if (divs[i].className.indexOf('post') != -1) {
|
2013-07-31 10:28:26 +02:00
|
|
|
divs[i].className = divs[i].className.replace(/highlighted/, '');
|
2024-08-04 15:32:12 +02:00
|
|
|
}
|
2013-07-31 10:28:26 +02:00
|
|
|
}
|
|
|
|
if (id) {
|
2024-08-04 15:32:12 +02:00
|
|
|
let post = document.getElementById('reply_' + id);
|
|
|
|
if (post) {
|
2013-07-31 10:28:26 +02:00
|
|
|
post.className += ' highlighted';
|
2024-08-04 15:32:12 +02:00
|
|
|
}
|
|
|
|
window.location.hash = id;
|
2013-07-31 10:28:26 +02:00
|
|
|
}
|
2014-06-12 17:36:01 +02:00
|
|
|
return true;
|
2013-07-31 10:28:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function generatePassword() {
|
2024-08-04 15:32:12 +02:00
|
|
|
let pass = '';
|
|
|
|
let chars = '{% endverbatim %}{{ config.genpassword_chars }}{% verbatim %}';
|
|
|
|
for (let i = 0; i < 8; i++) {
|
|
|
|
let rnd = Math.floor(Math.random() * chars.length);
|
2013-07-31 10:28:26 +02:00
|
|
|
pass += chars.substring(rnd, rnd + 1);
|
|
|
|
}
|
|
|
|
return pass;
|
|
|
|
}
|
|
|
|
|
2024-08-04 15:13:05 +02:00
|
|
|
function doPost(form) {
|
2013-07-31 10:28:26 +02:00
|
|
|
if (form.elements['name']) {
|
|
|
|
localStorage.name = form.elements['name'].value.replace(/( |^)## .+$/, '');
|
|
|
|
}
|
2013-08-20 15:34:41 +02:00
|
|
|
if (form.elements['password']) {
|
|
|
|
localStorage.password = form.elements['password'].value;
|
|
|
|
}
|
2013-07-31 10:28:26 +02:00
|
|
|
if (form.elements['email'] && form.elements['email'].value != 'sage') {
|
|
|
|
localStorage.email = form.elements['email'].value;
|
|
|
|
}
|
2024-04-15 23:33:12 +02:00
|
|
|
|
2013-07-31 10:28:26 +02:00
|
|
|
saved[document.location] = form.elements['body'].value;
|
|
|
|
sessionStorage.body = JSON.stringify(saved);
|
2024-04-15 23:33:12 +02:00
|
|
|
|
2015-04-01 19:37:06 +02:00
|
|
|
return form.elements['body'].value != "" || (form.elements['file'] && form.elements['file'].value != "") || (form.elements.file_url && form.elements['file_url'].value != "");
|
2013-07-31 10:28:26 +02:00
|
|
|
}
|
|
|
|
|
2013-09-14 23:31:05 +02:00
|
|
|
function citeReply(id, with_link) {
|
2024-08-04 15:32:12 +02:00
|
|
|
let textarea = document.getElementById('body');
|
|
|
|
if (!textarea) {
|
|
|
|
return false;
|
|
|
|
}
|
2024-04-15 23:33:12 +02:00
|
|
|
|
2013-07-31 10:28:26 +02:00
|
|
|
if (document.selection) {
|
|
|
|
// IE
|
2013-09-15 19:51:36 +02:00
|
|
|
textarea.focus();
|
2024-08-04 15:32:12 +02:00
|
|
|
let sel = document.selection.createRange();
|
2013-07-31 10:28:26 +02:00
|
|
|
sel.text = '>>' + id + '\n';
|
2013-09-15 19:51:36 +02:00
|
|
|
} else if (textarea.selectionStart || textarea.selectionStart == '0') {
|
2024-08-04 15:32:12 +02:00
|
|
|
let start = textarea.selectionStart;
|
|
|
|
let end = textarea.selectionEnd;
|
2013-09-15 19:51:36 +02:00
|
|
|
textarea.value = textarea.value.substring(0, start) + '>>' + id + '\n' + textarea.value.substring(end, textarea.value.length);
|
2024-04-15 23:33:12 +02:00
|
|
|
|
2013-09-15 19:51:36 +02:00
|
|
|
textarea.selectionStart += ('>>' + id).length + 1;
|
|
|
|
textarea.selectionEnd = textarea.selectionStart;
|
2013-07-31 10:28:26 +02:00
|
|
|
} else {
|
|
|
|
// ???
|
2013-09-15 19:51:36 +02:00
|
|
|
textarea.value += '>>' + id + '\n';
|
2013-07-31 10:28:26 +02:00
|
|
|
}
|
2013-09-15 02:29:35 +02:00
|
|
|
if (typeof $ != 'undefined') {
|
2024-08-04 15:32:12 +02:00
|
|
|
let select = document.getSelection().toString();
|
2014-09-30 07:45:02 +02:00
|
|
|
if (select) {
|
2024-08-04 15:32:12 +02:00
|
|
|
let body = $('#reply_' + id + ', #op_' + id).find('div.body'); // TODO: support for OPs
|
|
|
|
let index = body.text().indexOf(select.replace('\n', '')); // for some reason this only works like this
|
2014-09-30 07:45:02 +02:00
|
|
|
if (index > -1) {
|
|
|
|
textarea.value += '>' + select + '\n';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-14 23:31:05 +02:00
|
|
|
$(window).trigger('cite', [id, with_link]);
|
2013-09-15 19:51:36 +02:00
|
|
|
$(textarea).change();
|
2013-07-31 10:28:26 +02:00
|
|
|
}
|
2013-12-25 14:16:28 +01:00
|
|
|
return false;
|
2013-07-31 10:28:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function rememberStuff() {
|
|
|
|
if (document.forms.post) {
|
|
|
|
if (document.forms.post.password) {
|
2024-08-04 15:32:12 +02:00
|
|
|
if (!localStorage.password) {
|
2013-07-31 10:28:26 +02:00
|
|
|
localStorage.password = generatePassword();
|
2024-08-04 15:32:12 +02:00
|
|
|
}
|
2013-07-31 10:28:26 +02:00
|
|
|
document.forms.post.password.value = localStorage.password;
|
|
|
|
}
|
2024-04-15 23:33:12 +02:00
|
|
|
|
2024-08-04 15:32:12 +02:00
|
|
|
if (localStorage.name && document.forms.post.elements['name']) {
|
2013-07-31 10:28:26 +02:00
|
|
|
document.forms.post.elements['name'].value = localStorage.name;
|
2024-08-04 15:32:12 +02:00
|
|
|
}
|
|
|
|
if (localStorage.email && document.forms.post.elements['email']) {
|
2013-07-31 10:28:26 +02:00
|
|
|
document.forms.post.elements['email'].value = localStorage.email;
|
2024-08-04 15:32:12 +02:00
|
|
|
}
|
2024-04-15 23:33:12 +02:00
|
|
|
|
2024-08-04 15:32:12 +02:00
|
|
|
if (window.location.hash.indexOf('q') == 1) {
|
2013-09-14 23:31:05 +02:00
|
|
|
citeReply(window.location.hash.substring(2), true);
|
2024-08-04 15:32:12 +02:00
|
|
|
}
|
2024-04-15 23:33:12 +02:00
|
|
|
|
2013-07-31 10:28:26 +02:00
|
|
|
if (sessionStorage.body) {
|
2024-08-04 15:32:12 +02:00
|
|
|
let saved = JSON.parse(sessionStorage.body);
|
2024-08-04 15:07:56 +02:00
|
|
|
if (getCookie('{% endverbatim %}{{ config.cookies.js }}{% verbatim %}')) {
|
2013-07-31 10:28:26 +02:00
|
|
|
// Remove successful posts
|
2024-08-04 15:32:12 +02:00
|
|
|
let successful = JSON.parse(getCookie('{% endverbatim %}{{ config.cookies.js }}{% verbatim %}'));
|
|
|
|
for (let url in successful) {
|
2013-07-31 10:28:26 +02:00
|
|
|
saved[url] = null;
|
|
|
|
}
|
|
|
|
sessionStorage.body = JSON.stringify(saved);
|
2024-04-15 23:33:12 +02:00
|
|
|
|
2021-11-04 03:45:01 +01:00
|
|
|
document.cookie = '{% endverbatim %}{{ config.cookies.js }}{% verbatim %}={};expires=0;path=/;';
|
2013-07-31 10:28:26 +02:00
|
|
|
}
|
|
|
|
if (saved[document.location]) {
|
|
|
|
document.forms.post.body.value = saved[document.location];
|
|
|
|
}
|
|
|
|
}
|
2024-04-15 23:33:12 +02:00
|
|
|
|
2013-07-31 10:28:26 +02:00
|
|
|
if (localStorage.body) {
|
|
|
|
document.forms.post.body.value = localStorage.body;
|
|
|
|
localStorage.body = '';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-18 06:40:39 +02:00
|
|
|
var script_settings = function(script_name) {
|
|
|
|
this.script_name = script_name;
|
|
|
|
this.get = function(var_name, default_val) {
|
|
|
|
if (typeof tb_settings == 'undefined' ||
|
|
|
|
typeof tb_settings[this.script_name] == 'undefined' ||
|
2024-08-04 15:32:12 +02:00
|
|
|
typeof tb_settings[this.script_name][var_name] == 'undefined') {
|
2013-09-18 06:40:39 +02:00
|
|
|
return default_val;
|
2024-08-04 15:32:12 +02:00
|
|
|
}
|
2013-09-18 06:40:39 +02:00
|
|
|
return tb_settings[this.script_name][var_name];
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-07-31 10:28:26 +02:00
|
|
|
function init() {
|
2024-08-04 15:37:36 +02:00
|
|
|
initStyleChooser();
|
2014-05-19 20:11:24 +02:00
|
|
|
|
2024-04-15 23:33:12 +02:00
|
|
|
{% endverbatim %}
|
2014-05-19 20:11:24 +02:00
|
|
|
{% if config.allow_delete %}
|
2013-07-31 10:28:26 +02:00
|
|
|
if (document.forms.postcontrols) {
|
|
|
|
document.forms.postcontrols.password.value = localStorage.password;
|
|
|
|
}
|
2014-05-19 20:11:24 +02:00
|
|
|
{% endif %}
|
2021-11-04 03:45:01 +01:00
|
|
|
{% verbatim %}
|
2024-04-15 23:33:12 +02:00
|
|
|
|
2013-07-31 10:28:26 +02:00
|
|
|
if (window.location.hash.indexOf('q') != 1 && window.location.hash.substring(1))
|
|
|
|
highlightReply(window.location.hash.substring(1));
|
|
|
|
}
|
|
|
|
|
|
|
|
var RecaptchaOptions = {
|
|
|
|
theme : 'clean'
|
|
|
|
};
|
|
|
|
|
|
|
|
onready_callbacks = [];
|
2024-08-05 18:32:11 +02:00
|
|
|
function onReady(fnc) {
|
2013-07-31 10:28:26 +02:00
|
|
|
onready_callbacks.push(fnc);
|
|
|
|
}
|
|
|
|
|
|
|
|
function ready() {
|
2024-08-04 15:32:12 +02:00
|
|
|
for (let i = 0; i < onready_callbacks.length; i++) {
|
2013-07-31 10:28:26 +02:00
|
|
|
onready_callbacks[i]();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-11-04 03:45:01 +01:00
|
|
|
{% endverbatim %}
|
2013-08-17 20:00:26 +02:00
|
|
|
|
2014-02-23 17:58:16 +01:00
|
|
|
var post_date = "{{ config.post_date }}";
|
2014-04-27 15:48:47 +02:00
|
|
|
var max_images = {{ config.max_images }};
|
2014-02-23 17:58:16 +01:00
|
|
|
|
2024-08-05 18:32:11 +02:00
|
|
|
onReady(init);
|
2014-02-23 17:58:16 +01:00
|
|
|
|
2021-11-04 03:45:01 +01:00
|
|
|
{% if config.google_analytics %}{% verbatim %}
|
2013-07-31 10:28:26 +02:00
|
|
|
|
2021-11-04 03:45:01 +01:00
|
|
|
var _gaq = _gaq || [];_gaq.push(['_setAccount', '{% endverbatim %}{{ config.google_analytics }}{% verbatim %}']);{% endverbatim %}{% if config.google_analytics_domain %}{% verbatim %}_gaq.push(['_setDomainName', '{% endverbatim %}{{ config.google_analytics_domain }}{% verbatim %}']){% endverbatim %}{% endif %}{% if not config.google_analytics_domain %}{% verbatim %}_gaq.push(['_setDomainName', 'none']){% endverbatim %}{% endif %}{% verbatim %};_gaq.push(['_trackPageview']);(function() {var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;ga.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'stats.g.doubleclick.net/dc.js';var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);})();{% endverbatim %}{% endif %}
|
2013-07-31 10:28:26 +02:00
|
|
|
|
2014-08-24 23:33:53 +02:00
|
|
|
{% if config.statcounter_project and config.statcounter_security %}
|
|
|
|
var sc = document.createElement('script');
|
|
|
|
sc.type = 'text/javascript';
|
|
|
|
sc.innerHTML = 'var sc_project={{ config.statcounter_project }};var sc_invisible=1;var sc_security="{{ config.statcounter_security }}";var scJsHost=(("https:" == document.location.protocol) ? "https://secure." : "http://www.");document.write("<sc"+"ript type=text/javascript src="+scJsHost+"statcounter.com/counter/counter.js></"+"script>");';
|
|
|
|
var s = document.getElementsByTagName('script')[0];
|
|
|
|
s.parentNode.insertBefore(sc, s);
|
|
|
|
{% endif %}
|