Content deleted Content added
m Bold and italics supported by default. |
mNo edit summary |
||
Line 22:
this.insert(number - 1);
}
else if(e.ctrlKey
{
this.insert(e.key);
Line 29:
// Load user's settings.
var page
this.getWikitext(page, wikitext =>
{▼
{
▲ url : `/wiki/User:${mw.config.get("wgUserName")}/InsertShortcutsSettings.js?action=raw`, dataType : "text"
if(wikitext.startsWith("!!REDIRECT"))
{
var project = wikitext.split(" ")[1];
this.getWikitext(page, wikitext =>
{
// Remove escaped newlines. Split into tags.▼
// Remove escaped newlines. Split into tags.
this.inserts = text.replace(/\\\n/g, "").split("\n");▼
this.inserts = wikitext.replace(/\\\n/g, "").split("\n");
}, null, null, `https://${project}.org/w/api.php`);
}
else
{
▲ // Remove escaped newlines. Split into tags.
}
});
},
Line 67 ⟶ 76:
txtarea.selectionStart = end;
txtarea.selectionEnd = end;
},
getWikitext: function(sTitles, fDone, fFail=null, fThen=null, href=null)
{
var settings =
{
"action": "query",
"prop": "revisions",
"rvprop": "content",
"rvslots": "main",
"rvlimit": 1,
"titles": sTitles
};
var api = href === null ? new mw.Api() : new mw.ForeignApi(href);
api.get(settings)
.done(data =>
{
var wikitext = [];
for(var id in data.query.pages)
{
wikitext.push(data.query.pages[id].revisions[0].slots.main['*']);
}
if(wikitext.length == 1)
{
fDone(wikitext[0]);
}
else
{
fDone(wikitext);
}
}).fail(fFail).then(fThen);
}
};
|