User:Jyril/hotkeys.js

Hello, you have come here looking for the meaning of the word User:Jyril/hotkeys.js. In DICTIOUS you will not only get to know all the dictionary meanings for the word User:Jyril/hotkeys.js, but we will also tell you about its etymology, its characteristics and you will know how to say User:Jyril/hotkeys.js in singular and plural. Everything you need to know about the word User:Jyril/hotkeys.js you have here. The definition of the word User:Jyril/hotkeys.js will help you to be more precise and correct when speaking or writing your texts. Knowing the definition ofUser:Jyril/hotkeys.js, as well as those of other words, enriches your vocabulary and provides you with more and better linguistic resources.
// 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.

var hotkeys = {
    'a' : '===Adjective===\n{{fi-adj||empi|in}}\n',
    'b' : '===Adverb===\n{{fi-adv|}}\n',
    'd' : '====Declension====\n{{fi-decl-|}}\n',
    'e' : '===Etymology===\n',
    'g' : '',
    'h' : '',
    'i' : '',
    'j' : '',
    'k' : '',
    'm' : '{{compound|lang=fi|}}',
    'n' : '===Noun===\n{{fi-noun}}\n',
    'o' : '====Conjugation====\n{{fi-conj-|}}\n',
    'p' : '{{prefix|lang=fi|}}',
    'q' : '',
    's' : '{{suffix|lang=fi|}}',
    't' : '====Translations====\n{{trans-top|}}\n{{trans-mid}}\n{{trans-bottom}}\n',
    'u' : '',
    'w' : '===Verb===\n{{fi-verb|cat=}}\n',
    'y' : ''
};

function hotkey(e) {
    if (e && e.altKey && 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;
}

$( function()
{
    var defaultAlt = {
        "," : "←",                   // 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 (wgAction != "view" || wgCanonicalSpecialPageName)
    {
        if (typeof(hotkeys) == 'undefined')  hotkeys = {};
        for (var key in defaultAlt) {
            if (hotkeys == null)
                hotkeys = defaultAlt;
        }
        for (var field in fields) {
            var f = document.getElementById(field);
            if (f)  f.onkeypress = hotkey;
        }
    }
});