summaryrefslogtreecommitdiff
path: root/data/js
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2019-10-16 10:31:24 +0200
committerYorhel <git@yorhel.nl>2019-10-16 15:29:38 +0200
commit678f511619708ba893cb2414eead90cdae685708 (patch)
tree2c79c111805f38454e07d96645f3fdc31fe75860 /data/js
parent1fb8a234cf5a455af6d78c893320b21de8347bc4 (diff)
v2rw: Convert staff adding/editing form
This is the first major editing form to be converted, so I'm expecting a little breakage. A good chunk of this code has been copied from v3. In terms of the UI there has been a small change: aliases that are still referenced do not have the 'remove' link and instead have a flag that shows that they are still referenced. This ought to be a bit friendlier than throwing an error message after the user has submitted the form. Some other things I'd like to improve in this form: - BBCode preview - Pasting in external links and letting the form figure out the Pixiv ID, etc. - Or perhaps even: Integrate AniDB/Wikidata search/autocompletion.
Diffstat (limited to 'data/js')
-rw-r--r--data/js/main.js3
-rw-r--r--data/js/staffalias.js80
2 files changed, 0 insertions, 83 deletions
diff --git a/data/js/main.js b/data/js/main.js
index 09d62d12..3d4248b9 100644
--- a/data/js/main.js
+++ b/data/js/main.js
@@ -48,6 +48,3 @@ VARS = /*VARS*/;
// Character editing (/c+/edit)
//include chartraits.js
//include charvns.js
-
-// Staff editing (/s+/edit)
-//include staffalias.js
diff --git a/data/js/staffalias.js b/data/js/staffalias.js
deleted file mode 100644
index 7e6abe0c..00000000
--- a/data/js/staffalias.js
+++ /dev/null
@@ -1,80 +0,0 @@
-function salLoad () {
- byId('alias_tbl').appendChild(tag('tr', {id:'alias_new'},
- tag('td', null),
- tag('td', {colspan:3}, tag('a', {href:'#', onclick:salFormAdd}, 'Add alias'))));
-
- salAdd(byId('primary').value||0, byId('name').value, byId('original').value);
- var aliases = jsonParse(byId('aliases').value) || [];
- for(var i = 0; i < aliases.length; i++) {
- salAdd(aliases[i].aid, aliases[i].name, aliases[i].orig);
- }
-
- byName(byId('maincontent'), 'form')[0].onsubmit = salSerialize;
-}
-
-function salAdd(aid, name, original) {
- var tbl = byId('alias_tbl');
- var first = tbl.rows.length <= 1;
- tbl.insertBefore(tag('tr', first ? {id:'primary_name'} : null,
- tag('td', {'class':'tc_id' },
- tag('input', {type:'radio', name:'primary_id', value:aid, checked:first, onchange:salPrimary})),
- tag('td', {'class':'tc_name' }, tag('input', {type:'text', 'class':'text', value:name})),
- tag('td', {'class':'tc_original' }, tag('input', {type:'text', 'class':'text', value:original})),
- tag('td', {'class':'tc_add' }, !first ?
- tag('a', {href:'#', onclick:salDel}, 'remove') : null)
- ), byId('alias_new'));
-}
-
-function salPrimary() {
- var prev = byId('primary_name')
- prev.removeAttribute('id');
- byClass(prev, 'td', 'tc_add')[0].appendChild(tag('a', {href:'#', onclick:salDel}, 'remove'));
- var tr = this;
- while (tr && tr.nodeName.toLowerCase() != 'tr')
- tr = tr.parentNode;
- tr.setAttribute('id', 'primary_name');
- var td = byClass(tr, 'td', 'tc_add')[0];
- while (td.firstChild)
- td.removeChild(td.firstChild);
-
- return salSerialize();
-}
-
-function salSerialize() {
- var tbl = byName(byId('alias_tbl'), 'tr');
- var a = [];
- for (var i = 0; i < tbl.length; ++i) {
- if(tbl[i].id == 'alias_new')
- continue;
- var id = byName(byClass(tbl[i], 'td', 'tc_id')[0], 'input')[0].value;
- var name = byName(byClass(tbl[i], 'td', 'tc_name')[0], 'input')[0].value;
- var orig = byName(byClass(tbl[i], 'td', 'tc_original')[0], 'input')[0].value;
- if(tbl[i].id == 'primary_name') {
- byId('name').value = name;
- byId('original').value = orig;
- byId('primary').value = id;
- } else
- a.push({ aid:Number(id), name:name, orig:orig });
- }
- byId('aliases').value = JSON.stringify(a);
- return true;
-}
-
-function salDel() {
- var tr = this;
- while (tr && tr.nodeName.toLowerCase() != 'tr')
- tr = tr.parentNode;
- var tbl = byId('alias_tbl');
- tbl.removeChild(tr);
- salSerialize();
- return false;
-}
-
-function salFormAdd() {
- salAdd(0, '', '');
- byName(byClass(byId('alias_new').previousSibling, 'td', 'tc_name')[0], 'input')[0].focus();
- return false;
-}
-
-if(byId('jt_box_staffe_geninfo'))
- salLoad();