Today, User:Þjarkur/GregU's hotkeys.js is a topic of great relevance and interest to many people around the world. Since ancient times, User:Þjarkur/GregU's hotkeys.js has been the object of study, debate and reflection, and its impact covers various aspects of daily life. Currently, the importance of User:Þjarkur/GregU's hotkeys.js has been enhanced by the rise of new technologies, which have opened new perspectives of analysis and understanding on this topic. In this article, we will explore different aspects of User:Þjarkur/GregU's hotkeys.js, from its origin to its relevance today, through its implications in different areas of social, cultural, economic and political life.
// This defines some control-key shortcuts you can use in text fields.
// IE not supported. See talk page for documentation.
// by Greg Ubben
// Add some control hotkeys for easily entering right-arrows (→) and other
// characters and phrases in the edit summary, edit box, or other text fields.
// hotkeys can be defined to augment the defaults. Type Ctrl-? to list all.
$.ready.then(function () {
function hotkey(e) {
if (e && e.ctrlKey && hotkeys) {
var newtxt = hotkeys;
var before = this.value.slice(0, this.selectionStart);
var after = this.value.slice(this.selectionEnd);
var scroll = this.scrollTop;
if (newtxt == "MENU") { // type Ctrl-? for a list
var menu = "";
for (var key in hotkeys) {
var name = key.toUpperCase().replace(",", "<").replace(".", ">");
var value = hotkeys.replace(/\n/g, "•").slice(0, 40);
if (value && value != newtxt)
menu += "\u200E" + name + " \t" + value + "\n";
}
alert(menu);
return false;
}
// hack to not override Ctrl-F, Ctrl-T, etc. in main text area
//
if (newtxt.search(/\[\[WP:|\bfix/i) >= 0 && this.id == "wpTextbox1") {
return true;
}
if (newtxt.search(/^\[*\w./) >= 0 && this.id != "wpTextbox1") {
if (before.search(/$/) >= 0) before += "; ";
if (after.search(/^/) >= 0) newtxt += "; ";
}
this.value = before + newtxt + after;
this.selectionStart = this.selectionEnd = before.length + newtxt.length;
this.scrollTop = scroll; // don't lose our position
return false;
}
return true;
}
var defaultCtrl = {
",": "←", // Ctrl < left arrow
".": "→", // Ctrl > right arrow
"-": "–", // Ctrl - en dash
"=": "—", // Ctrl = em dash
"7": "&" + "nbsp;", // Ctrl & non-breaking space
"l": "link rename",
"r": "reverted ]",
"s": "]",
"/": "MENU" // special function
};
var fields = { wpSummary: 0, wpTextbox1: 0, wpReason: 0, wpUploadDescription: 0 };
if (mw.config.get('wgAction') != "view") {
if (typeof (hotkeys) == 'undefined') hotkeys = {};
for (var key in defaultCtrl) {
if (hotkeys == null)
hotkeys = defaultCtrl;
}
for (var field in fields) {
var f = document.getElementById(field);
if (f) f.onkeypress = hotkey;
}
}
})