No edit summary |
No edit summary |
||
| (One intermediate revision by the same user not shown) | |||
| Line 1: | Line 1: | ||
/* Sitewide options for | /* Sitewide options for the Cite toolbar button. Runs after Gadget-refToolbarBase.js. */ | ||
$('head').one('reftoolbarbase', function () { | |||
var citeTemplate = window.citeTemplate; | |||
var citeErrorCheck = window.citeErrorCheck; | |||
* | |||
CiteTB.Options = { | CiteTB.Options = { | ||
"date format": "<date> <monthname> <year>", | |||
"autodate fields": ['access-date'], | |||
"months": ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'], | |||
"modal": true, | |||
"autoparse": true, | |||
"expandtemplates": false | |||
}; | }; | ||
new citeTemplate('cite web', 'web', | |||
new citeTemplate('cite web', 'web', | [ | ||
{"field": "last<N>", "autofillprop": "last-incr", 'increment_group': 'author'}, | |||
{"field": "first<N>", "autofillprop": "first-incr", 'increment_group': 'author', 'increment_button': true}, | |||
{"field": "title", "autofillprop": "title"}, | |||
{"field": "url", "autofillid": "url"}, | |||
{"field": "website", "autofillprop": "journal"}, | |||
{"field": "publisher", "autofillprop": "publisher"}, | |||
{"field": "access-date"}, | |||
{"field": "ref", "tooltip": "cite-ref-tooltip"} | |||
], | |||
[ | |||
{"field": "author<N>", 'increment_group': 'author_alt', 'increment_button': true}, | |||
{"field": "author<N>-link", "tooltip": "cite-authorlink-tooltip", 'increment_group': 'authorlink', 'increment_button': true}, | |||
{"field": "archive-url"}, | |||
{"field": "archive-date"}, | |||
{"field": "location"}, | |||
{"field": "page", "tooltip": "cite-page-tooltip"}, | |||
{"field": "pages", "autofillprop": "pages", "tooltip": "cite-pages-tooltip"}, | |||
{"field": "language", "autofillprop": "language"}, | |||
{"field": "format"}, | |||
{"field": "doi", "autofillid": "doi", "autofillprop": "doi"}, | |||
{"field": "date", "autofillprop": "date"}, | |||
{"field": "quote"}, | |||
{"field": "url-status", "tooltip": "cite-urlstatus-tooltip"}, | |||
{"field": "trans-title"} | |||
] | |||
); | |||
new citeTemplate('cite news', 'news', | new citeTemplate('cite news', 'news', | ||
[ | |||
{"field": "last<N>", "autofillprop": "last-incr", 'increment_group': 'author'}, | |||
{"field": "first<N>", "autofillprop": "first-incr", 'increment_group': 'author', 'increment_button': true}, | |||
{"field": "title", "autofillprop": "title"}, | |||
{"field": "url", "autofillid": "url"}, | |||
{"field": "access-date"}, | |||
{"field": "work", "tooltip": "cite-work-tooltip", "autofillprop": "journal"}, | |||
{"field": "agency", "tooltip": "cite-agency-tooltip"}, | |||
{"field": "volume"}, | |||
{"field": "issue"}, | |||
{"field": "publisher", "tooltip": "cite-publisher-tooltip", "autofillprop": "publisher"}, | |||
{"field": "date", "autofillprop": "date"}, | |||
{"field": "ref", "tooltip": "cite-ref-tooltip"} | |||
], | |||
[ | |||
{"field": "author<N>", 'increment_group': 'author_alt', 'increment_button': true}, | |||
{"field": "author<N>-link", "tooltip": "cite-authorlink-tooltip", 'increment_group': 'authorlink', 'increment_button': true}, | |||
{"field": "archive-url"}, | |||
{"field": "archive-date"}, | |||
{"field": "location"}, | |||
{"field": "page", "tooltip": "cite-page-tooltip"}, | |||
{"field": "pages", "autofillprop": "pages", "tooltip": "cite-pages-tooltip"}, | |||
{"field": "language", "autofillprop": "language"}, | |||
{"field": "format"}, | |||
{"field": "doi", "autofillid": "doi", "autofillprop": "doi"}, | |||
{"field": "quote"}, | |||
{"field": "url-status", "tooltip": "cite-urlstatus-tooltip"}, | |||
{"field": "trans-title"} | |||
] | |||
); | |||
new citeTemplate('cite book', 'book', | new citeTemplate('cite book', 'book', | ||
[ | |||
{"field": "last<N>", "autofillprop": "last-incr", 'increment_group': 'author'}, | |||
{"field": "first<N>", "autofillprop": "first-incr", 'increment_group': 'author', 'increment_button': true}, | |||
{"field": "title", "autofillprop": "title"}, | |||
{"field": "date", "autofillprop": "date"}, | |||
{"field": "publisher", "autofillprop": "publisher"}, | |||
{"field": "location", "autofillprop": "location"}, | |||
{"field": "isbn", "autofillid": "isbn", "autofillprop": "isbn"}, | |||
{"field": "page", "tooltip": "cite-page-tooltip"}, | |||
{"field": "pages", "autofillprop": "pages", "tooltip": "cite-pages-tooltip"}, | |||
{"field": "edition", "autofillprop": "edition"}, | |||
{"field": "url", "autofillid": "url"}, | |||
{"field": "access-date"}, | |||
{"field": "ref", "tooltip": "cite-ref-tooltip"} | |||
], | |||
[ | |||
{"field": "author<N>", 'increment_group': 'author_alt', 'increment_button': true}, | |||
{"field": "author<N>-link", "tooltip": "cite-authorlink-tooltip", 'increment_group': 'authorlink', 'increment_button': true}, | |||
{"field": "editor<N>-last", "increment_group": "editor"}, | |||
{"field": "editor<N>-first", "increment_group": "editor", "increment_button": true}, | |||
{"field": "editor<N>-link", 'increment_group': 'editorlink', 'increment_button': true}, | |||
{"field": "archive-url"}, | |||
{"field": "archive-date"}, | |||
{"field": "language", "autofillprop": "language"}, | |||
{"field": "format"}, | |||
{"field": "chapter", "autofillprop": "chapter"}, | |||
{"field": "quote"}, | |||
{"field": "url-status", "tooltip": "cite-urlstatus-tooltip"}, | |||
{"field": "trans-title"} | |||
] | |||
); | |||
new citeTemplate('cite journal', 'journal', | new citeTemplate('cite journal', 'journal', | ||
[ | |||
{"field": "last<N>", "autofillprop": "last-incr", 'increment_group': 'author'}, | |||
{"field": "first<N>", "autofillprop": "first-incr", 'increment_group': 'author', 'increment_button': true}, | |||
{"field": "title", "autofillprop": "title"}, | |||
{"field": "journal", "autofillprop": "journal"}, | |||
{"field": "date", "autofillprop": "date"}, | |||
{"field": "volume", "autofillprop": "volume"}, | |||
{"field": "issue", "autofillprop": "issue"}, | |||
{"field": "page", "tooltip": "cite-page-tooltip"}, | |||
{"field": "pages", "autofillprop": "pages", "tooltip": "cite-pages-tooltip"}, | |||
{"field": "doi", "autofillid": "doi", "autofillprop": "doi"}, | |||
{"field": "pmid", "autofillid": "pmid"}, | |||
{"field": "url", "autofillid": "url"}, | |||
{"field": "access-date"}, | |||
{"field": "ref", "tooltip": "cite-ref-tooltip"} | |||
], | |||
[ | |||
{"field": "author<N>", 'increment_group': 'author_alt', 'increment_button': true}, | |||
{"field": "author<N>-link", "tooltip": "cite-authorlink-tooltip", 'increment_group': 'authorlink', 'increment_button': true}, | |||
{"field": "editor<N>-last", "increment_group": "editor"}, | |||
{"field": "editor<N>-first", "increment_group": "editor", "increment_button": true}, | |||
{"field": "editor<N>-link", 'increment_group': 'editorlink', 'increment_button': true}, | |||
{"field": "series"}, | |||
{"field": "at", "tooltip": "cite-at-tooltip"}, | |||
{"field": "trans-title"}, | |||
{"field": "publisher", "autofillprop": "publisher"}, | |||
{"field": "location"}, | |||
{"field": "language", "autofillprop": "language"}, | |||
{"field": "format"}, | |||
{"field": "issn", "autofillprop": "issn"}, | |||
{"field": "pmc"}, | |||
{"field": "oclc"}, | |||
{"field": "bibcode"}, | |||
{"field": "id"}, | |||
{"field": "quote"}, | |||
{"field": "postscript", "tooltip": "cite-postscript-tooltip"}, | |||
{"field": "url-status", "tooltip": "cite-urlstatus-tooltip"} | |||
] | |||
); | |||
new citeErrorCheck({ | new citeErrorCheck({ | ||
'type': 'reflist', 'testname': 'samecontent', 'desc': 'cite-samecontent-desc', | 'type': 'reflist', 'testname': 'samecontent', 'desc': 'cite-samecontent-desc', | ||
'func': function (reflist) { | 'func': function (reflist) { | ||
| Line 206: | Line 164: | ||
} | } | ||
} | } | ||
ret = []; | var ret = []; | ||
for (var j = 0; j < errors.length; j++) { | for (var j = 0; j < errors.length; j++) { | ||
ret.push({'msg': 'cite-samecontent-error', 'err': errors[j]}); | ret.push({'msg': 'cite-samecontent-error', 'err': errors[j]}); | ||
| Line 212: | Line 170: | ||
return ret; | return ret; | ||
} | } | ||
} | }); | ||
); | |||
new citeErrorCheck({ | new citeErrorCheck({ | ||
'type': 'reflist', 'testname': 'repeated', 'desc': 'cite-repeated-desc', | 'type': 'reflist', 'testname': 'repeated', 'desc': 'cite-repeated-desc', | ||
'func': function (reflist) { | 'func': function (reflist) { | ||
| Line 231: | Line 188: | ||
} | } | ||
} | } | ||
ret = []; | var ret = []; | ||
for (var j = 0; j < errors.length; j++) { | for (var j = 0; j < errors.length; j++) { | ||
ret.push({'msg': 'cite-repeated-error', 'err': errors[j]}); | ret.push({'msg': 'cite-repeated-error', 'err': errors[j]}); | ||
| Line 237: | Line 194: | ||
return ret; | return ret; | ||
} | } | ||
} | }); | ||
); | |||
new citeErrorCheck({ | new citeErrorCheck({ | ||
'type': 'reflist', 'testname': 'undefined', 'desc': 'cite-undefined-desc', | 'type': 'reflist', 'testname': 'undefined', 'desc': 'cite-undefined-desc', | ||
'func': function (reflist) { | 'func': function (reflist) { | ||
| Line 251: | Line 207: | ||
} | } | ||
for (var j = 0; j < reflist.length; j++) { | for (var j = 0; j < reflist.length; j++) { | ||
if (reflist[j].shorttag && $.inArray(reflist[j].refname, errors) == -1 && $.inArray(reflist[j].refname, longrefs) == -1) { | |||
errors.push(reflist[j].refname); | |||
} | |||
} | } | ||
ret = []; | var ret = []; | ||
for (var | for (var k = 0; k < errors.length; k++) { | ||
ret.push({'msg': 'cite-undefined-error', 'err': errors[ | ret.push({'msg': 'cite-undefined-error', 'err': errors[k]}); | ||
} | } | ||
return ret; | return ret; | ||
} | } | ||
} | }); | ||
); | |||
CiteTB.init(); | CiteTB.init(); | ||
}); | |||
if (window.citeTemplate) { | |||
$('head').trigger('reftoolbarbase'); | |||
} | |||
Latest revision as of 20:17, 24 September 2026
/* Sitewide options for the Cite toolbar button. Runs after Gadget-refToolbarBase.js. */
$('head').one('reftoolbarbase', function () {
var citeTemplate = window.citeTemplate;
var citeErrorCheck = window.citeErrorCheck;
CiteTB.Options = {
"date format": "<date> <monthname> <year>",
"autodate fields": ['access-date'],
"months": ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
"modal": true,
"autoparse": true,
"expandtemplates": false
};
new citeTemplate('cite web', 'web',
[
{"field": "last<N>", "autofillprop": "last-incr", 'increment_group': 'author'},
{"field": "first<N>", "autofillprop": "first-incr", 'increment_group': 'author', 'increment_button': true},
{"field": "title", "autofillprop": "title"},
{"field": "url", "autofillid": "url"},
{"field": "website", "autofillprop": "journal"},
{"field": "publisher", "autofillprop": "publisher"},
{"field": "access-date"},
{"field": "ref", "tooltip": "cite-ref-tooltip"}
],
[
{"field": "author<N>", 'increment_group': 'author_alt', 'increment_button': true},
{"field": "author<N>-link", "tooltip": "cite-authorlink-tooltip", 'increment_group': 'authorlink', 'increment_button': true},
{"field": "archive-url"},
{"field": "archive-date"},
{"field": "location"},
{"field": "page", "tooltip": "cite-page-tooltip"},
{"field": "pages", "autofillprop": "pages", "tooltip": "cite-pages-tooltip"},
{"field": "language", "autofillprop": "language"},
{"field": "format"},
{"field": "doi", "autofillid": "doi", "autofillprop": "doi"},
{"field": "date", "autofillprop": "date"},
{"field": "quote"},
{"field": "url-status", "tooltip": "cite-urlstatus-tooltip"},
{"field": "trans-title"}
]
);
new citeTemplate('cite news', 'news',
[
{"field": "last<N>", "autofillprop": "last-incr", 'increment_group': 'author'},
{"field": "first<N>", "autofillprop": "first-incr", 'increment_group': 'author', 'increment_button': true},
{"field": "title", "autofillprop": "title"},
{"field": "url", "autofillid": "url"},
{"field": "access-date"},
{"field": "work", "tooltip": "cite-work-tooltip", "autofillprop": "journal"},
{"field": "agency", "tooltip": "cite-agency-tooltip"},
{"field": "volume"},
{"field": "issue"},
{"field": "publisher", "tooltip": "cite-publisher-tooltip", "autofillprop": "publisher"},
{"field": "date", "autofillprop": "date"},
{"field": "ref", "tooltip": "cite-ref-tooltip"}
],
[
{"field": "author<N>", 'increment_group': 'author_alt', 'increment_button': true},
{"field": "author<N>-link", "tooltip": "cite-authorlink-tooltip", 'increment_group': 'authorlink', 'increment_button': true},
{"field": "archive-url"},
{"field": "archive-date"},
{"field": "location"},
{"field": "page", "tooltip": "cite-page-tooltip"},
{"field": "pages", "autofillprop": "pages", "tooltip": "cite-pages-tooltip"},
{"field": "language", "autofillprop": "language"},
{"field": "format"},
{"field": "doi", "autofillid": "doi", "autofillprop": "doi"},
{"field": "quote"},
{"field": "url-status", "tooltip": "cite-urlstatus-tooltip"},
{"field": "trans-title"}
]
);
new citeTemplate('cite book', 'book',
[
{"field": "last<N>", "autofillprop": "last-incr", 'increment_group': 'author'},
{"field": "first<N>", "autofillprop": "first-incr", 'increment_group': 'author', 'increment_button': true},
{"field": "title", "autofillprop": "title"},
{"field": "date", "autofillprop": "date"},
{"field": "publisher", "autofillprop": "publisher"},
{"field": "location", "autofillprop": "location"},
{"field": "isbn", "autofillid": "isbn", "autofillprop": "isbn"},
{"field": "page", "tooltip": "cite-page-tooltip"},
{"field": "pages", "autofillprop": "pages", "tooltip": "cite-pages-tooltip"},
{"field": "edition", "autofillprop": "edition"},
{"field": "url", "autofillid": "url"},
{"field": "access-date"},
{"field": "ref", "tooltip": "cite-ref-tooltip"}
],
[
{"field": "author<N>", 'increment_group': 'author_alt', 'increment_button': true},
{"field": "author<N>-link", "tooltip": "cite-authorlink-tooltip", 'increment_group': 'authorlink', 'increment_button': true},
{"field": "editor<N>-last", "increment_group": "editor"},
{"field": "editor<N>-first", "increment_group": "editor", "increment_button": true},
{"field": "editor<N>-link", 'increment_group': 'editorlink', 'increment_button': true},
{"field": "archive-url"},
{"field": "archive-date"},
{"field": "language", "autofillprop": "language"},
{"field": "format"},
{"field": "chapter", "autofillprop": "chapter"},
{"field": "quote"},
{"field": "url-status", "tooltip": "cite-urlstatus-tooltip"},
{"field": "trans-title"}
]
);
new citeTemplate('cite journal', 'journal',
[
{"field": "last<N>", "autofillprop": "last-incr", 'increment_group': 'author'},
{"field": "first<N>", "autofillprop": "first-incr", 'increment_group': 'author', 'increment_button': true},
{"field": "title", "autofillprop": "title"},
{"field": "journal", "autofillprop": "journal"},
{"field": "date", "autofillprop": "date"},
{"field": "volume", "autofillprop": "volume"},
{"field": "issue", "autofillprop": "issue"},
{"field": "page", "tooltip": "cite-page-tooltip"},
{"field": "pages", "autofillprop": "pages", "tooltip": "cite-pages-tooltip"},
{"field": "doi", "autofillid": "doi", "autofillprop": "doi"},
{"field": "pmid", "autofillid": "pmid"},
{"field": "url", "autofillid": "url"},
{"field": "access-date"},
{"field": "ref", "tooltip": "cite-ref-tooltip"}
],
[
{"field": "author<N>", 'increment_group': 'author_alt', 'increment_button': true},
{"field": "author<N>-link", "tooltip": "cite-authorlink-tooltip", 'increment_group': 'authorlink', 'increment_button': true},
{"field": "editor<N>-last", "increment_group": "editor"},
{"field": "editor<N>-first", "increment_group": "editor", "increment_button": true},
{"field": "editor<N>-link", 'increment_group': 'editorlink', 'increment_button': true},
{"field": "series"},
{"field": "at", "tooltip": "cite-at-tooltip"},
{"field": "trans-title"},
{"field": "publisher", "autofillprop": "publisher"},
{"field": "location"},
{"field": "language", "autofillprop": "language"},
{"field": "format"},
{"field": "issn", "autofillprop": "issn"},
{"field": "pmc"},
{"field": "oclc"},
{"field": "bibcode"},
{"field": "id"},
{"field": "quote"},
{"field": "postscript", "tooltip": "cite-postscript-tooltip"},
{"field": "url-status", "tooltip": "cite-urlstatus-tooltip"}
]
);
new citeErrorCheck({
'type': 'reflist', 'testname': 'samecontent', 'desc': 'cite-samecontent-desc',
'func': function (reflist) {
var errors = [];
var refs2 = [];
for (var i = 0; i < reflist.length; i++) {
if (!reflist[i].shorttag) {
if ($.inArray(reflist[i].content, refs2) != -1) {
if ($.inArray(reflist[i].content, errors) == -1) {
errors.push(reflist[i].content);
}
} else {
refs2.push(reflist[i].content);
}
}
}
var ret = [];
for (var j = 0; j < errors.length; j++) {
ret.push({'msg': 'cite-samecontent-error', 'err': errors[j]});
}
return ret;
}
});
new citeErrorCheck({
'type': 'reflist', 'testname': 'repeated', 'desc': 'cite-repeated-desc',
'func': function (reflist) {
var errors = [];
var refs2 = [];
for (var i = 0; i < reflist.length; i++) {
if (!reflist[i].shorttag && reflist[i].refname) {
if ($.inArray(reflist[i].refname, refs2) != -1) {
if ($.inArray(reflist[i].refname, errors) == -1) {
errors.push(reflist[i].refname);
}
} else {
refs2.push(reflist[i].refname);
}
}
}
var ret = [];
for (var j = 0; j < errors.length; j++) {
ret.push({'msg': 'cite-repeated-error', 'err': errors[j]});
}
return ret;
}
});
new citeErrorCheck({
'type': 'reflist', 'testname': 'undefined', 'desc': 'cite-undefined-desc',
'func': function (reflist) {
var errors = [];
var longrefs = [];
for (var i = 0; i < reflist.length; i++) {
if (!reflist[i].shorttag && reflist[i].refname) {
longrefs.push(reflist[i].refname);
}
}
for (var j = 0; j < reflist.length; j++) {
if (reflist[j].shorttag && $.inArray(reflist[j].refname, errors) == -1 && $.inArray(reflist[j].refname, longrefs) == -1) {
errors.push(reflist[j].refname);
}
}
var ret = [];
for (var k = 0; k < errors.length; k++) {
ret.push({'msg': 'cite-undefined-error', 'err': errors[k]});
}
return ret;
}
});
CiteTB.init();
});
if (window.citeTemplate) {
$('head').trigger('reftoolbarbase');
}