summaryrefslogtreecommitdiff
path: root/data/js
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2015-08-17 01:10:55 +0200
committerYorhel <git@yorhel.nl>2015-08-17 01:14:29 +0200
commit0fcc3797a7cef3f063ebcbc59aecfab5eb89eecb (patch)
treed54365074eec34607c685a42fc1e77c41d43aec3 /data/js
parentfcaa479640044cc7430702e5d9c79199d58481d7 (diff)
js: Add L10N strings to all relevant vars
This simplifies the JS code in some places and removes a whole number of L10N strings from the "l10n_str" var, thus shrinking the JS size a bit (uncompressed about 1500 bytes, in fact. 500 bytes after gzip).
Diffstat (limited to 'data/js')
-rw-r--r--data/js/filter.js53
-rw-r--r--data/js/relmedia.js17
-rw-r--r--data/js/vnstaff.js6
3 files changed, 24 insertions, 52 deletions
diff --git a/data/js/filter.js b/data/js/filter.js
index 36a32e50..a9766f55 100644
--- a/data/js/filter.js
+++ b/data/js/filter.js
@@ -436,20 +436,13 @@ function filFTagInput(name, label, type) {
}
function filChars() {
- var gend = VARS.genders;
- for(var i=0; i<gend.length; i++) // l10n /_gender_.+/
- gend[i] = [ gend[i], mt('_gender_'+gend[i]) ];
- var bloodt = VARS.blood_types;
- for(var i=0; i<bloodt.length; i++) // l10n /_bloodt_.+/
- bloodt[i] = [ bloodt[i], bloodt[i] == 'unknown' ? mt('_unknown') : mt('_bloodt_'+bloodt[i]) ];
-
var ontraitpage = location.pathname.indexOf('/c/') < 0;
return [
mt('_charb_fil_title'),
[ mt('_charb_general'),
- filFSelect('gender', mt('_charb_gender'), 4, gend),
- filFSelect('bloodt', mt('_charb_bloodt'), 5, bloodt),
+ filFSelect('gender', mt('_charb_gender'), 4, VARS.genders),
+ filFSelect('bloodt', mt('_charb_bloodt'), 5, VARS.blood_types),
'',
filFSlider('bust_min', mt('_charb_bust_min'), 20, 120, 40, 'cm'),
filFSlider('bust_max', mt('_charb_bust_max'), 20, 120, 100, 'cm'),
@@ -476,25 +469,14 @@ function filChars() {
}
function filReleases() {
- var types = VARS.release_types;
- for(var i=0; i<types.length; i++) // l10n /_rtype_.+/
- types[i] = [ types[i], mt('_rtype_'+types[i]) ];
var plat = VARS.platforms;
plat.splice(0, 0, [ 'unk', mt('_unknown') ]);
var med = VARS.media;
- for(var i=0; i<med.length; i++) // l10n /_med_.+/
- med[i] = [ med[i], mt('_med_'+med[i]) ];
med.splice(0, 0, [ 'unk', mt('_unknown') ]);
- var voi = VARS.voiced;
- for(var i=0; i<voi.length; i++) // l10n /_voiced_.+/
- voi[i] = [ voi[i], voi[i] == 0 ? mt('_unknown') : mt('_voiced_'+voi[i]) ];
- var ani = VARS.animated;
- for(var i=0; i<ani.length; i++) // l10n /_animated_.+/
- ani[i] = [ ani[i], ani[i] == 0 ? mt('_unknown') : mt('_animated_'+ani[i]) ];
return [
mt('_rbrowse_fil_title'),
[ mt('_rbrowse_general'),
- filFOptions('type', mt('_rbrowse_type'), types),
+ filFOptions('type', mt('_rbrowse_type'), VARS.release_types),
filFOptions('patch', mt('_rbrowse_patch'), [ [1, mt('_rbrowse_patch_yes')], [0, mt('_rbrowse_patch_no')] ]),
filFOptions('freeware', mt('_rbrowse_freeware'),[ [1, mt('_rbrowse_freeware_yes')], [0, mt('_rbrowse_freeware_no')] ]),
filFOptions('doujin', mt('_rbrowse_doujin'), [ [1, mt('_rbrowse_doujin_yes')], [0, mt('_rbrowse_doujin_no')] ]),
@@ -508,25 +490,21 @@ function filReleases() {
[ mt('_rbrowse_resolution'), filFSelect('resolution', mt('_rbrowse_resolution'), 15, VARS.resolutions) ],
[ mt('_rbrowse_platform'), filFSelect('plat', mt('_rbrowse_platform'), 20, plat) ],
[ mt('_rbrowse_medium'), filFSelect('med', mt('_rbrowse_medium'), 10, med) ],
- [ mt('_rbrowse_voiced'), filFSelect('voiced', mt('_rbrowse_voiced'), 5, voi) ],
+ [ mt('_rbrowse_voiced'), filFSelect('voiced', mt('_rbrowse_voiced'), 5, VARS.voiced) ],
[ mt('_rbrowse_animation'),
- filFSelect('ani_story', mt('_rbrowse_ani_story'), 5, ani),
- filFSelect('ani_ero', mt('_rbrowse_ani_ero'), 5, ani)
+ filFSelect('ani_story', mt('_rbrowse_ani_story'), 5, VARS.animated),
+ filFSelect('ani_ero', mt('_rbrowse_ani_ero'), 5, VARS.animated)
]
];
}
function filVN() {
- var len = VARS.vn_lengths;
- for(var i=0; i<len.length; i++) // l10n /_vnlength_.+/
- len[i] = [ len[i], len[i] == 0 ? mt('_unknown') : mt('_vnlength_'+len[i]) ];
-
var ontagpage = location.pathname.indexOf('/v/') < 0;
return [
mt('_vnbrowse_fil_title'),
[ mt('_vnbrowse_general'),
- filFSelect( 'length', mt('_vnbrowse_length'), 6, len),
+ filFSelect( 'length', mt('_vnbrowse_length'), 6, VARS.vn_lengths),
filFOptions('hasani', mt('_vnbrowse_anime'), [[1, mt('_vnbrowse_anime_yes')],[0, mt('_vnbrowse_anime_no')]])
],
ontagpage ? [ mt('_vnbrowse_tags'),
@@ -557,14 +535,15 @@ function filStaff() {
['m', mt('_gender_m')],
['f', mt('_gender_f')],
];
- var roles = [];
- for(var i=0; i<VARS.staff_roles.length; i++) { // l10n /_credit_.+/
- if(VARS.staff_roles[i] == 'staff') {
- roles.push(['seiyuu', mt('_credit_seiyuu')]);
- roles.push(['staff', mt('_credit_other')]);
- } else
- roles.push([ VARS.staff_roles[i], mt('_credit_'+VARS.staff_roles[i]) ]);
- }
+
+ // Insert seiyuu into the list of roles, before the "staff" role.
+ var roles = VARS.staff_roles;
+ for(var i=0; i<roles.length; i++)
+ if(roles[i][0] == 'staff') {
+ roles.splice(i, 0, ['seiyuu', mt('_credit_seiyuu')]);
+ break;
+ }
+
return [
mt('_sbrowse_fil_title'),
[ mt('_sbrowse_general'),
diff --git a/data/js/relmedia.js b/data/js/relmedia.js
index 195d5c96..3b1a4f4a 100644
--- a/data/js/relmedia.js
+++ b/data/js/relmedia.js
@@ -1,11 +1,4 @@
-var medTypes = [ ];
function medLoad() {
- // load the medTypes and clear the div
- var sel = byName(byId('media_div'), 'select')[0].options;
- for(var i=0; i<sel.length; i++)
- medTypes[medTypes.length] = [ sel[i].value, getText(sel[i]), !hasClass(sel[i], 'noqty') ];
- setText(byId('media_div'), '');
-
// load the selected media
var med = byId('media').value.split(',');
for(var i=0; i<med.length && med[i].length > 1; i++)
@@ -22,8 +15,8 @@ function medAdd(med, qty) {
var msel = tag('select', {'class':'medium', onchange: med == '' ? medFormAdd : medSerialize});
if(med == '')
msel.appendChild(tag('option', {value:''}, mt('_redit_form_med_medium')));
- for(var i=0; i<medTypes.length; i++)
- msel.appendChild(tag('option', {value:medTypes[i][0], selected: med==medTypes[i][0]}, medTypes[i][1]));
+ for(var i=0; i<VARS.media.length; i++)
+ msel.appendChild(tag('option', {value:VARS.media[i][0], selected: med==VARS.media[i][0]}, VARS.media[i][1]));
byId('media_div').appendChild(tag('span', qsel, msel,
med != '' ? tag('input', {type: 'button', 'class':'submit', onclick:medDel, value:mt('_js_remove')}) : null
@@ -61,12 +54,12 @@ function medSerialize() {
var qty = byClass(meds[i], 'select', 'qty')[0];
/* correct quantity if necessary */
- if(medTypes[med.selectedIndex][2] && !qty.selectedIndex)
+ if(VARS.media[med.selectedIndex][2] && !qty.selectedIndex)
qty.selectedIndex = 1;
- if(!medTypes[med.selectedIndex][2] && qty.selectedIndex)
+ if(!VARS.media[med.selectedIndex][2] && qty.selectedIndex)
qty.selectedIndex = 0;
- r[r.length] = medTypes[med.selectedIndex][0] + ' ' + qty.selectedIndex;
+ r[r.length] = VARS.media[med.selectedIndex][0] + ' ' + qty.selectedIndex;
}
byId('media').value = r.join(',');
}
diff --git a/data/js/vnstaff.js b/data/js/vnstaff.js
index 11542a81..a4fa012f 100644
--- a/data/js/vnstaff.js
+++ b/data/js/vnstaff.js
@@ -25,9 +25,9 @@ function vnsAdd(staff, role, note) {
var tbl = byId('credits_tbl');
var rlist = tag('select', {onchange:vnsSerialize});
- for (var i = 0; i < VARS.staff_roles.length; i++) // l10n /^_credit_/
- rlist.appendChild(tag('option', {value:VARS.staff_roles[i], selected:VARS.staff_roles[i]==role},
- mt('_credit_'+VARS.staff_roles[i])));
+ var r = VARS.staff_roles;
+ for (var i = 0; i<r.length; i++)
+ rlist.appendChild(tag('option', {value:r[i][0], selected:r[i][0]==role}, r[i][1]));
tbl.appendChild(tag('tr', {id:'vns_a'+staff.aid},
tag('td', {'class':'tc_name'},