User:Bosco/Unsigned helper.js: Difference between revisions

From Test Wiki
Content deleted Content added
searchFromIndex: fix wrong reference to non-existent variable `text`. doAddUnsignedTemplate: Rename variable `txt` → `selection`
searchFromIndex: fix error message
Line 508: Line 508:
* For reference, see https://en.wikipedia.org/wiki/MediaWiki:Gadget-charinsert-core.js#L-251--L-258
* For reference, see https://en.wikipedia.org/wiki/MediaWiki:Gadget-charinsert-core.js#L-251--L-258
*/
*/
let selection = $(wikitextEditor).textSelection('getSelection');
const originalSelection = $(wikitextEditor).textSelection('getSelection');
let selection = originalSelection;
debug(`doAddUnsignedTemplate: getSelection: '${selection}'`);
debug(`doAddUnsignedTemplate: getSelection: '${selection}'`);
selection = selection.replace(new RegExp('[\\s\\S]*\\d\\d:\\d\\d, \\d+ (' + months.join('|') + ') \\d\\d\\d\\d \\(UTC\\)'), '');
selection = selection.replace(new RegExp('[\\s\\S]*\\d\\d:\\d\\d, \\d+ (' + months.join('|') + ') \\d\\d\\d\\d \\(UTC\\)'), '');
Line 614: Line 615:
if (selection == undefined || selection == '') {
if (selection == undefined || selection == '') {
mainDialog.html(formatErrorSpan("Please select an unsigned message.") +
mainDialog.html(formatErrorSpan("Please select an unsigned message.") +
" Selected: <code>" + selection + "</code>");
" Selected: <code>" + originalSelection + "</code>");
return;
return;
}
}