User:Mach61/js/smartLinkingLoader.js
/* smartLinkingLoader.js
* v. 2014-07-07
*
* This script adds a toolbar button which, when pressed, loads smartLinking.js and calls window.smartLinking().
*
* Smart Linking home: http://en.wikipedia.org/wiki/User:V111P/js/Smart_Linking
*/
mw.libs.smartLinkingLoader = mw.libs.smartLinkingLoader || {};
mw.libs.smartLinkingLoader.version = 1000;
mw.libs.smartLinkingLoader.smartLinking = function () {
"use strict";
if (window.smartLinking) {
window.smartLinking();
}
else {
$.ajax({
url: '//en.wikipedia.org/w/index.php?title=User:V111P/js/smartLinking.js'
+ '&action=raw&ctype=text/javascript&smaxage=86400&maxage=604800',
dataType: 'script',
cache: true,
success: function () {
if (window.smartLinking)
window.smartLinking();
else
setTimeout(function () {
if (window.smartLinking)
window.smartLinking();
}, 500);
}
});
}
};
mw.libs.smartLinkingLoader.addButton = function () {
"use strict";
var buttonId = 'smartLinkingButton';
if ( $.inArray( mw.config.get( 'wgAction' ), ['edit', 'submit'] ) == -1
|| $('#' + buttonId).length > 0 )
return;
var addToolbarButtons_scriptUrl = '//en.wikipedia.org/w/index.php?title='
+ 'User:V111P/js/addToolbarButtons.js&action=raw'
+ '&ctype=text/javascript'; // [[User:V111P/js/addToolbarButtons.js]]
var c = ( window.smartLinkingConfig || {} );
var toolbarButtonProps = {
id: buttonId,
tooltip: (c.msgs && c.msgs.scriptName) || 'Smart Linking',
section: 'main',
group: 'insert',
callback: mw.libs.smartLinkingLoader.smartLinking,
iconUrl: '//upload.wikimedia.org/wikipedia/commons/9/96/Interpage_icon.png',
iconUrlClassic: '//upload.wikimedia.org/wikipedia/commons/5/5a/Interpage_button.png'
};
if (mediaWiki.libs.addToolbarButtons)
mediaWiki.libs.addToolbarButtons(toolbarButtonProps);
else {
var tbs = window.toolbarButtonsToAdd = window.toolbarButtonsToAdd || [];
tbs.push(toolbarButtonProps);
$.ajax({
url: addToolbarButtons_scriptUrl,
dataType: 'script',
cache: true
});
}
};
if ((window.smartLinkingConfig || {}).addButton !== false)
mediaWiki.libs.smartLinkingLoader.addButton();
// define a handler
function doc_keyUp(e) {
// this would test for whichever key is 40 (down arrow) and the ctrl key at the same time
if (e.altKey && e.which == 65) {
// call your function to do the thing
window.smartLinking();
}
}
// register the handler
document.addEventListener('keyup', doc_keyUp, false);
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.