User:Bosco/Unsigned helper.js: Difference between revisions
From Test Wiki
Content deleted Content added
chooseTemplate & makeTemplate: add support for Template:Undated; searchFromIndex: make it easier to check found diff by showing it to the user; applySearcherResult: mention the used template in edit summary; findRevisionWhenTextAdded: add better protection against infinite recursion; createTimestampWikitext: use Unicode escapes instead of string concatenation for protection; |
stop script from loading without editor; add support for mw:Extension:CodeMirror |
||
| Line 28: | Line 28: | ||
unsignedIp: 'Unsigned IP', // [[Template:Unsigned IP]] |
unsignedIp: 'Unsigned IP', // [[Template:Unsigned IP]] |
||
}; |
}; |
||
if (mw.config.get('wgAction') !== 'edit' && mw.config.get('wgAction') !== 'submit' && document.getElementById("editform") == null) { |
|||
info('Not editing a page. Aborting.'); |
|||
return; |
|||
} |
|||
info('Loading...'); |
info('Loading...'); |
||
| Line 499: | Line 504: | ||
template |
template |
||
); |
); |
||
// https://doc.wikimedia.org/mediawiki-core/master/js/module-jquery.textSelection.html |
|||
const newWikitextTillSelection = wikitextEditor.value.substr(0, pos).replace(/\s*$/, ' ') + templateWikitext; |
|||
wikitextEditor. |
$(wikitextEditor).textSelection( |
||
'encapsulateSelection', { |
|||
$(wikitextEditor).textSelection('setSelection', { start: newWikitextTillSelection.length }); |
|||
post: " " + templateWikitext |
|||
} |
|||
); |
|||
appendToEditSummary(`mark [[Template:${template}|{{${template}}}]] [[Special:Diff/${fullRevision.revid}]]`); |
appendToEditSummary(`mark [[Template:${template}|{{${template}}}]] [[Special:Diff/${fullRevision.revid}]]`); |
||
mainDialog.dialog('close'); |
mainDialog.dialog('close'); |
||