User:So9q/AddNewLexemeMenu.js
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
/* Adds a section to the sidebar with links for creating new lexemes
* Inspired by [[User:Nikki/InOtherFormats.js]]
* To use, add the following to your common.js:
*
*/
(function () {
"use strict";
const languages = {
"Q9035": {
name: "Danish",
code: "da"
},
"Q9027": {
name: "Swedish",
code: "sv"
},
"Q1860": {
name: "English",
code: "en"
},
"Q143": {
name: "Esperanto",
code: "eo"
}
};
//const language-qids = ['', 'Q9027'];
const lexical_categories = {
'noun': 'Q1084'
};
//const lexicalCategoryId = ['Q1084', 'Q24905', 'Q34698', 'Q184511', 'Q187931', 'Q62155', 'Q83034', 'Q111029'];
//const lexicalCategoryName = ['noun', 'verb', 'adjective', 'idiom', 'phrase', 'affix', 'interjection', 'root'];
var qid = mw.config.get('wbEntityId');
if (qid) {
console.log("Generating the html");
var div = $('div');
for (let category_name in lexical_categories) {
var li = $('<li>').text(category_name ": ")
.css('padding-left', '5px');
$.each(languages, function(qid) {
// Add the links
$('<a>').text(languages[qid]["code"] " ").href('/wiki/Special:NewLexeme?lexeme-language=' qid
'&lemma-language=' languages[qid]["code"]
'&lexicalcategory=' lexical_categories[category_name]);
})
.appendTo(li);
};
li.appendTo(div);
}
$("#mw-panel").append(div);
}
})();