From a5e5cd03e6936e17b91acfb485c7e8a19b4c0b2a Mon Sep 17 00:00:00 2001 From: Macil Tech Date: Tue, 18 Jun 2013 11:58:32 -0500 Subject: Don't forget secure tripcode that's preceded by a space. Mod capcodes are not remembered in the posting form. --- templates/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'templates/main.js') diff --git a/templates/main.js b/templates/main.js index b0a96393..9ec0025f 100644 --- a/templates/main.js +++ b/templates/main.js @@ -105,7 +105,7 @@ function generatePassword() { function dopost(form) { if (form.elements['name']) { - localStorage.name = form.elements['name'].value.replace(/ ##.+$/, ''); + localStorage.name = form.elements['name'].value.replace(/( |^)## .+$/, ''); } if (form.elements['email'] && form.elements['email'].value != 'sage') { localStorage.email = form.elements['email'].value; -- cgit v1.3 From 74f4c7da18aa96aecfbe92d234b09d697f7a268a Mon Sep 17 00:00:00 2001 From: czaks Date: Tue, 2 Jul 2013 23:10:00 -0400 Subject: main.js: added preliminary translation functions for javascript --- templates/main.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'templates/main.js') diff --git a/templates/main.js b/templates/main.js index 9ec0025f..b3e773a3 100644 --- a/templates/main.js +++ b/templates/main.js @@ -1,5 +1,27 @@ {% raw %} +/* gettext-compatible _ function, example of usage: + * + * > // Loading pl_PL.json here (containing polish translation strings generated by tools/locale_compile.php) + * > alert(_("Hello!")); + * Witaj! + */ +function _(s) { + return (typeof tb_l10n != 'undefined' && typeof tb_l10n[s] != 'undefined') ? tb_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 + */ +function fmt(s,a) { + return s.replace(/\{([0-9]+)\}/g, function(x) { return a[x[1]]; }); +} + var saved = {}; -- cgit v1.3 From da9f367f2f9cf24d47b8d6a04cf2e54cb14a03bc Mon Sep 17 00:00:00 2001 From: czaks Date: Wed, 3 Jul 2013 01:04:08 -0400 Subject: js i18n: misc fixes; quick-reply.js i18n --- js/quick-reply.js | 6 +++--- templates/main.js | 4 ++-- tools/i18n_compile.php | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) (limited to 'templates/main.js') diff --git a/js/quick-reply.js b/js/quick-reply.js index bc36ca48..ea504b48 100644 --- a/js/quick-reply.js +++ b/js/quick-reply.js @@ -17,7 +17,7 @@ $(document).ready(function(){ return; // not index txt_new_topic = $('form[name=post] input[type=submit]').val(); - txt_new_reply = txt_new_topic == 'Submit' ? txt_new_topic : new_reply_string; + txt_new_reply = txt_new_topic == _('Submit') ? txt_new_topic : new_reply_string; undo_quick_reply = function() { $('div.banner').remove(); @@ -27,9 +27,9 @@ $(document).ready(function(){ $('div.post.op').each(function() { var id = $(this).children('p.intro').children('a.post_no:eq(1)').text(); - $('[Quick reply]').insertAfter($(this).children('p.intro').children('a:last')).click(function() { + $('['+_("Quick reply")+']').insertAfter($(this).children('p.intro').children('a:last')).click(function() { $('div.banner').remove(); - $('') + $('') .insertBefore('form[name=post]'); $('form[name=post] input[type=submit]').val(txt_new_reply); diff --git a/templates/main.js b/templates/main.js index b3e773a3..31c0254a 100644 --- a/templates/main.js +++ b/templates/main.js @@ -2,12 +2,12 @@ /* gettext-compatible _ function, example of usage: * - * > // Loading pl_PL.json here (containing polish translation strings generated by tools/locale_compile.php) + * > // Loading pl_PL.json here (containing polish translation strings generated by tools/i18n_compile.php) * > alert(_("Hello!")); * Witaj! */ function _(s) { - return (typeof tb_l10n != 'undefined' && typeof tb_l10n[s] != 'undefined') ? tb_l10n[s] : s; + return (typeof l10n != 'undefined' && typeof l10n[s] != 'undefined') ? l10n[s] : s; } /* printf-like formatting function, example of usage: diff --git a/tools/i18n_compile.php b/tools/i18n_compile.php index c85ccb83..ce00051c 100755 --- a/tools/i18n_compile.php +++ b/tools/i18n_compile.php @@ -35,10 +35,10 @@ foreach ($locales as $loc) { if (file_exists($locdir."/LC_MESSAGES/tinyboard.po")) $join = "-j"; else $join = ""; `cd $locdir/LC_MESSAGES; - msgfmt tinyboard.po`; + msgfmt tinyboard.po -o tinyboard.mo`; // Generate javascript.po `cd tools/inc/lib/jsgettext/; php po2json.php -i ../../../../$locdir/LC_MESSAGES/javascript.po \ - -o ../../../../$locdir/LC_MESSAGES/javascript.js -k tb_i18n`; + -o ../../../../$locdir/LC_MESSAGES/javascript.js`; } -- cgit v1.3