User:PerfektesChaos/js/editToolStrIns/debug.js

/// editToolStrIns /// Edit tool to insert characters and strings -- especially for WMF /// 2011-11-27 PerfektesChaos@de.wikipedia

// Uses: //   MediaWiki  1.18 (mw.libs, jQuery.textSelection) //              jQuery.trimLeft, jQuery.trimRight //   jQuery     core; $.focus, .cookie, .isArray //   JavaScript 1.3 //   DOM        Level 3

/* Based upon previous work of: mw:User:Alex Smotrov             2008 w:de:User:Revolus                2008/2009 w:de:User:WIKImaniac             2009 w:de:MediaWiki:Onlyifediting.js  2011-08-11 /// @license GPL [//www.mediawiki.org/w/COPYING] (+ CC-BY-SA) /// About: mw:User:PerfektesChaos/js/editToolStrIns

if ( typeof( mw.libs.editToolStrIns ) !== "object" ) { mw.libs.editToolStrIns =  { }; } with ( mw.libs ) { editToolStrIns.vsn = 0.3; if ( typeof editToolStrIns.debug !== "object" ) { editToolStrIns.debug = false; }  if ( typeof editToolStrIns.l10n !== "object" ) { editToolStrIns.l10n = { }; }  editToolStrIns.attr = { names: { "class":       false, "lang":       false, "dir":        false, "font-family": true, "font-size":  true } }; editToolStrIns.defs = { "global": null }; editToolStrIns.gui = { "container": ".mw-editTools", "self":     "editToolStrIns" }; editToolStrIns.menu = { }; }  // with mw.libs

// No customization recommended above this point. // Start adption and localization here:

with ( mw.libs.editToolStrIns ) { gui.old =  "#specialchars," + "#editpage-specialchars"; menu.separator = "\xA0\xA0•\xA0 "; menu.divide   = { "font-weight": "bold" }; menu.stick    = "…"; l10n[ "dewiki" ] = {  // example for introduction period "list": [ "0",     "Standard", "",  "WikiSyntax", ":6",    "Datei:", ":10",   "Vorlage:", "IPA",   "IPA-Lautschrift", "Latin", "Lateinisch", "AHD",   "AHD-Lautschrift", "grc",   "Altgriechisch", "ar",    "Arabisch", "DMG",   "DMG-Umschrift", "eo",    "Esperanto", "et",    "Estnisch", "fr",    "Französisch", "gl",    "Galicisch", "el",    "Griechisch", "haw",   "Hawaiisch", "is",    "Isländisch", "it",    "Italienisch", "iw",    "Hebräisch", "hbs",   "Kroatisch/Serbisch/Bosnisch", "Cyril", "Kyrillisch", "Latin", "Lateinisch", "lv",    "Lettisch", "lt",    "Litauisch", "mt",    "Maltesisch", "pl",    "Polnisch", "pt",    "Portugiesisch", "Pinyin", "Pinyin", "roa",   "Romanisch", "ro",    "Rumänisch", "Scand", "Skandinavisch", "wen",   "Sorbisch", "es",    "Spanisch", "cz",    "Tschechisch", "tr",    "Türkisch", "hu",    "Ungarisch", "vi",    "Vietnamesisch" ], "defs": { "AHD": { "class": "Unicode" }, "ar": { "class": "spanAr", "font-size": "1.25em" }, "grc": { "class": "polytonic" }, "haw": { "font-family": "Arial Unicode MS, Lucida Sans Unicode, MS Mincho, " + "Arial, sans-serif;" } } };  // l10n.dewiki.list 2011-11-01 l10n[ "enwiki" ] = { "defs": {  // example for introduction period "0":        [ [ "–",                       "—",                       [ "‘", "’" ],                       [ "“", "”" ] ],                     false, [ 1, "°″′≈≠≤≥±−×÷√←→·§" ],                    [ 0, "Sign your posts on talk pages:" ], [ "~" ],                    [ 0, "Cite your sources:" ], [ [ " " ] ] ],     "":      [ [ 0, "Insert:" ], [ "–",                      "—",                       [ "‘", "’" ],                       [ "“", "”" ] ],                     false, [ 1, "°″′≈≠≤≥±−×÷√←→·§" ],                    false, [ "~",                      [ " " ] ],                     [ 0, "Wiki markup:" ], [ [ "" ],                      [ "" ],                       "|",                       [ "[", "]" ],                       [ "", "" ],                       [ "" ],                       [ "#REDIRECT ", "" ], " ",                      [ " ", " " ],                       [ "", "" ],                       [ "", "" ],                       [ " " ],                       [ " ", " " ],                       [ ""', '"" ],                       [ " " ],                       [ "" ],                       "",                       " " ],                  [ " " ],                  [ " ", " " ],                  [ " ", " " ],                  [ "", "" ],                  [ "", "" ],                  [ "" ] ],                [ "", [ "", "" ] ], [ [ "$$", "$$" ],                 [ " " ]                  ],                [ [ " " ],                  [ " " ],                  [ " " ],                  " " ],                [ [ " ", " " ],                  [ " ", " " ],                  [ " ", " " ] ] ],      ":10":  [ { "font-family": "monospace"  }, [ [ "" ],                 [ "" ],                  "|",                  [ "",           "", "", "if" ], [ "",       "", "", "ifeq" ], [ "",     "", "", "ifexist" ], [ "",          "", "", "expr" ], [ "",      "", "", "ifexpr" ], [ "",     "", "", "iferror" ], [ "", "", "", "switch" ], [ "",          "", "", "tag" ], [ "NaN",      "", "", "formatnum" ], [ "",     "", "", "formatdate" ], [ "", "",             "", "", "lc" ], [ "", "",             "", "", "uc" ], [ "",          "", "", "subst" ] ] ], // ISO 639 "ang": [ { "lang": "ang" }, [ 1, "ĀāÆæǢǣǼǽĊċÐðĒēĠġĪīŌōŪūǷƿȲȳÞþȜȝ" ] ], "ar": [ { "lang": "ar", "dir": "rtl" }, [ 1, "؛؟ءآأؤإئابةتثجحخدذرزسشصضطظعغفقكلمنهوىي،", "پچژگڭ"] ], "bn": [ { "lang": "bn" }, [ 2, 0x0981, 0x0983, 0x0985, 0x098C, 0x098F, 0x0990, 0x0993, 0x09A8, 0x09AA, 0x09B0, 0x09B2, 0x09B2, 0x09B6, 0x09B9, 0x09BC, 0x09C4, 0x09C7, 0x09C8, 0x09CB, 0x09CE, 0x09D7, 0x09D7, 0x09DC, 0x09DD, 0x09DF, 0x09E3, 0x09E6, 0x09FB ] ], "cz": [ { "lang": "cz" }, [ 1, "ÁáČčĎďÉéĚěÍíŇňÓóŘřŠšŤťÚúŮůÝýŽž" ] ], "de": [ { "lang": "de" }, [ 1, "ÄäÖößÜü" ], [ [ "„", "“" ],                [ "‚", "‘" ],                 [ "»", "«" ],                 [ "›", "‹" ] ] ],      "el":  [ { "lang": "el" }, [ 1, "ΑΆΒΓΔΕΈΖΗΉΘΙΊΚΛΜΝΞΟΌΠΡΣΤΥΎΦΧΨΩΏ", "αάβγδεέζηήθιίκλμνξοόπρσςτυύφχψωώ" ] ], "eo": [ { "lang": "eo" }, [ 1, "ĈĉĜĝĤĥĴĵŜŝŬŭ" ] ], "es": [ { "lang": "es" }, [ 1, "ÁáÉéÍíÑñÓóÚúÜü¡¿" ] ], "et": [ { "lang": "et" }, [ 1, "ČčŠšŽžÕõÄäÖöÜü" ] ], "fr": [ { "lang": "fr" }, [ 1, "ÀàÂâÇçÉéÈèÊêËëÎîÏïÔôŒœÙùÛûÜüŸÿ" ], [ [ "«", "»" ],                [ "‹", "›" ] ] ],      "gl":  [ { "lang": "gl" }, [ 1, "ÁáÀàÂâÄäÉéÈèÊêËëÌìÎîÏïÓóÒòÔôÖöÙùÛû" + "ẀẁŴŵẄẅÝýỲỳŶŷŸÿ" ] ], "grc": [ { "lang": "grc" }, [ 1, "ΑαΆάΒβΓγΔδΕεΈέΖζΗηΉήΘθΙιΊίΪϊΐΚκΛλΜμΝνΞξΟοΌόΠπΡρΣσς" + "ΤτΥυΫϋΎύΰΦφΧχΨψΩωΏώ;·ἀἁὰᾶἂἃἄἅἆἇᾳᾀᾁᾴᾲᾷᾄᾅᾂᾃᾆᾇἐἑὲἔἕἒ" + "ἓἠἡὴῆἤἢἣἥἦἧῃῄῂῇᾐᾑᾔᾒᾕᾓᾖᾗἰἱὶῖἴἲἵἳἶἷὸὀὁὄὅὂὃῤῥὐὑὺῦὔὕὒ" + "ὓὖὗὠὡὼῶὤὢὥὣὦὧῳῴῲῷᾠᾡᾤᾢᾥᾣᾦᾧ`᾿῾῍῎῏῟῞῝῍῎ϜϝϘϙϠϡ" ] ], "gu": [ { "lang": "gu" }, [ 2, 0x0A81, 0x0A83, 0x0A85, 0x0A8D, 0x0A8F, 0x0A91, 0x0A93, 0x0AA8, 0x0AAA, 0x0AB0, 0x0AB2, 0x0AB3, 0x0AB5, 0x0AB9, 0x0ABC, 0x0AC5, 0x0AC7, 0x0AC9, 0x0ACB, 0x0ACD, 0x0AD0, 0x0AD0, 0x0AE0, 0x0AE3 ], [ 2, 0x0AE6, 0x0AEF, 0x0AF1, 0x0AF1 ] ], "haw": [ { "lang": "haw" }, [ 1, "ĀāĒēĪīŌōŪūʻ" ] ], "hbs": [ { "lang": "hbs" }, [ -32, "Č č Ć ć Dž dž Đ đ Š š Ž ž" ] ], "hu": [ { "lang": "hu" }, [ 1, "áéíŐöóőŰúüű" ] ], "is": [ { "lang": "is" }, [ 1, "ÁáÐðÉéÍíÓóÚúÝýÞþÆæÖöǫ" ] ], "it": [ { "lang": "it" }, [ 1, "ÁáÀàÉéÈèÍíÌìÓóÒòÚúÙù" ] ], "iw": [ { "lang": "yi", "dir": "rtl" }, [ -32, "א אַ אָ ב בֿ ג ד ה ו וּ" + "װ ױ ז זש ח ט י יִ ײ ײַ כ ך כּל מ ם נ ן ס ע " + "פ פּ פֿ ף צ ץ ק ר ש שׂ תּ ת ׳ ״ ־ " ] ], "lo": [ { "lang": "lo" }, [ 2, 0x0E81, 0x0E82, 0x0E84, 0x0E84, 0x0E87, 0x0E88, 0x0E8A, 0x0E8A, 0x0E8D, 0x0E8D, 0x0E94, 0x0E97, 0x0E99, 0x0E9F, 0x0EA1, 0x0EA3, 0x0EA5, 0x0EA5, 0x0EA7, 0x0EA7, 0x0EAA, 0x0EAB, 0x0EAD, 0x0EB9, 0x0EC0, 0x0EC4, 0x0EC6, 0x0EC6, 0x0EC8, 0x0ECD, 0x0ED0, 0x0ED9, 0x0EDC, 0x0EDD ] ], "lv": [ { "lang": "lv" }, [ 1, "ĀČĒĢĪĶĻŅŠŪŽ", "āčēģīķļņšūž" ] ], "lt": [ { "lang": "lt" }, [ 1, "ĄČĘĖĮŠŲŪŽ", "ąčęėįšųūž" ] ], "mt": [ { "lang": "mt" }, [ 1, "ĊċĠġĦħŻż" ] ], "pl": [ { "lang": "pl" }, [ 1, "ąĄćĆęĘłŁńŃóÓśŚźŹżŻ" ] ], "pt": [ { "lang": "pt" }, [ 1, "ÁáÀàÂâÃãÇçÉéÊêÍíÓóÔôÕõÚúÜü" ] ], "ro": [ { "lang": "ro" }, [ 1, "ĂăÂâÎîȘșȚț" ] ], "roa": [ { "lang": "roa" }, [ 1, "ĀāĒēĪīŌōŪū" ] ], "si": [ { "lang": "si" }, [ 2, 0x0D82, 0x0D83, 0x0D85, 0x0D96, 0x0D9A, 0x0DB1, 0x0DB3, 0x0DBB, 0x0DBD, 0x0DBD, 0x0DC0, 0x0DC6, 0x0DCA, 0x0DCA, 0x0DCF, 0x0DD4, 0x0DD6, 0x0DD6, 0x0DD8, 0x0DDF, 0x0DF2, 0x0DF4 ] ], "sk": [ { "lang": "sk" }, [ 1, "ÁáČčĎďÉéÍíĽľŇňÓóÔôŔŕŠšŤťÚúÝýŽž" ] ], "te": [ { "lang": "te" }, [ 2, 0x0C01, 0x0C03, 0x0C05, 0x0C0C, 0x0C0E, 0x0C10, 0x0C12, 0x0C28, 0x0C2A, 0x0C33, 0x0C35, 0x0C39, 0x0C3D, 0x0C44, 0x0C46, 0x0C48, 0x0C4A, 0x0C4D, 0x0C55, 0x0C56, 0x0C58, 0x0C59, 0x0C60, 0x0C63, 0x0C66, 0x0C6F, 0x0C78, 0x0C7F ] ], "th": [ { "lang": "th" }, [ 2, 0x0E01, 0x0E3A ], [ 2, 0x0E3F, 0x0E5B ] ], "tr": [ { "lang": "tr" }, [ -32, "Â Ə Ç Ğ Gʻ Î İ Ñ Ň Oʻ Ş Û Ý Ž", "â ə ç ğ gʻ î ı ñ ň oʻ ş û ý ž" ] ], "vi": [ { "lang": "vi" }, [ 1, "ÀàẢảÁáẠạÃãĂăẰằẲẳẴẵẮắẶặÂâẦầẨẩẪẫẤấẬậ", "Đđ", "ÈèẺẻẼẽÉéẸẹÊêỀềỂểỄễẾếỆệ", "ỈỉĨĩÍíỊịÌì", "ỎỏÓóỌọÒòÕõÔôỒồỔổỖỗỐốỘộƠơỜờỞởỠỡỚớỢợ", "ÙùỦủŨũÚúỤụƯưỪừỬửỮữỨứỰự", "ỲỳỶỷỸỹỴỵÝý" ] ], "wen": [ { "lang": "wen" }, [ 1, "ČčĆćěŁłńóřŕŠšŚśŽžŹź" ] ], // ISO 15924 "Khmr": [ null,  // Khmer [ 2, 0x1780, 0x17DD ], [ 2, 0x17E0, 0x17E9 ], [ 2, 0x17F0, 0x17F9 ] ], "Phli": [ { "dir": "rtl",  // Pahlavi "font-family": "ZH Mono" }, [ 2, 0x10B60, 0x10B72 ], [ 2, 0x10B78, 0x10B7F ] ], "Prti": [ { "dir": "rtl",  // Parthian "font-family": "ZH Mono" }, [ 2, 0x10B40, 0x10B55 ], [ 2, 0x10B58, 0x10B5F ] ], "Xsux": [ { "font-family":  // Cuneiform "Akkadian, CuneiformComposite, Free Idg Serif" }, [ 2, 0x12000, 0x1236F ], [ 2, 0x12400, 0x12462 ], [ 2, 0x12470, 0x12473 ] ], // Others "AHD":   [ null, [ 1, "āăäâēĕīĭîōŏôŭ" ], false, [ [ "o͞o", "", "", "food" ], [ "o͝o", "", "", "foot" ] ] ], "Cyril": [ null, [ 1,                   "АӘБВГҐЃҒДЂЕЄЁЖЗЅИІЇİЙӢЈКЌҚЛЉМНЊҢОӨПРСТЋУЎӮ" + "ҰҮФХҲҺЦЧҶЏШЩЪЫЬЭЮЯ", "аәбвгґѓғдђеєёжзѕиіїйӣјкќқлљмнњңоөпрстћуўӯ" + "ұүфхҳһцчҷџшщъыьэюя" ] ], "DMG":   [ null, [ 1, "ʾʿĀāČčḌḍḎḏǦǧĠġḤḥḪḫĪīḷŋṢṣŠšṬṭṮṯŪūẒẓẔẕŽž" ] ], "Finance":[ null, [ 1, "‰", "₳฿₵¢₡₢$₫₯€₠₣ƒ₴₭₤ℳ₥₦№₧₰£៛₨₪৳₮₩¥" ], [ [ "¤", "", "", "unspecified currency" ] ], [ 1, "©®™", "§" ] ],     "IPA":    [ { "class": "IPA" }, [ -32, "p t̪ t ʈ c k q ʡ ʔ", "b d̪ d ɖ ɟ ɡ ɢ", "ɓ ɗ ʄ ɠ ʛ", "t͡s t͡ʃ t͡ɕ d͡z d͡ʒ d͡ʑ", "ɸ f θ s ʃ ʅ ʆ ʂ ɕ ç ɧ x χ ħ ʜ h", "β v ʍ ð z ʒ ʓ ʐ ʑ ʝ ɣ ʁ ʕ ʖ ʢ ɦ", "ɬ ɮ", "m m̩ ɱ ɱ̩ ɱ̍ n̪ n̪̍ n n̩ ɳ ɳ̩ ɲ ɲ̩ ŋ ŋ̍ ŋ̩ ɴ ", "ɴ̩ ʙ ʙ̩ r r̩ ʀ ʀ̩", "ɾ ɽ ɿ ɺ", "l̪ l̪̩ l l̩ ɫ ɫ̩ ɭ ɭ̩ ʎ ʎ̩ ʟ ʟ̩", "w ɥ ʋ ɹ ɻ j ɰ", "ʘ ǂ ǀ ǃ ǁ", "ʰ ʱ ʷ ʸ ʲ ʳ ⁿ ˡ ʴ ʵ ˢ ˣ ˠ ʶ ˤ ˁ ˀ ʼ", "i i̯ ĩ y y̯ ỹ ɪ ɪ̯ ɪ̃ ʏ ʏ̯ ʏ̃ ɨ ɨ̯ ɨ̃ ʉ ʉ̯ ʉ̃ " + "ɯ ɯ̯ ɯ̃ u u̯ ũ ʊ ʊ̯ ʊ̃", "e e̯ ẽ ø ø̯ ø̃ ɘ ɘ̯ ɘ̃ ɵ ɵ̯ ɵ̃ ɤ ɤ̯ ɤ̃ o o̯ õ", "ɛ ɛ̯ ɛ̃ œ œ̯ œ̃ ɜ ɜ̯ ɜ̃ ə ə̯ ə̃ ɞ ɞ̯ ɞ̃ ʌ ʌ̯ " + "ʌ̃ ɔ ɔ̯ ɔ̃", "æ æ̯ æ̃ ɶ ɶ̯ ɶ̃ a a̯ ã " + "ɐ ɐ̯ ɐ̃ ɑ ɑ̯ ɑ̃ ɒ ɒ̯ ɒ̃", "ˈ ˌ ː ˑ ˘ . ‿ | ‖" ] ], "KhmrSy": [ null,  // Khmer lunatics [ 2, 0x19E0, 0x19FF ] ], "Latin": [ null, [ -32, "Á á Ć ć É é Í í Ó ó Ś ś Ú ú Ý ý Ǿ ǿ", "À à È è Ì ì Ò ò Ù ù", "Â â Ĉ ĉ Ê ê Ĝ ĝ Ĥ ĥ Î î Ĵ ĵ Ô ô ŝ Ŝ Û û", "Ä ä Ë ë Ï ï Ö ö Ü ü ÿ", "Ã ã Ñ ñ Õ õ", "Å å", "Ç ç", "Č č Š š ŭ", "Ł ł", "Ő ő Ű ű", "Ø ø", "Ā ā Ē ē Ī ī Ō ō Ū ū Ȳ ȳ", "Ă ă Ĕ ĕ Ğ ğ Ĭ ĭ Ŏ ŏ Ŭ ŭ Y̆ y̆" , "ß", "Æ æ Œ œ", "Ð ð Þ þ |" ] ], "Pinyin": [ null, [ 1, "ÁáÀàǍǎĀāÉéÈèĚěĒēÍíÌìǏǐĪī" + "ÓóÒòǑǒŌōÚúÙùÜüǓǔŪūǗǘǛǜǙǚǕǖ" ] ], "Scand": [ null, [ 1, "ÀàÉéÅåÆæÄäØøÖö", "ÐðÍíÓóÚúÝýÞþǫ" ] ], "TeX":   [ null, [ [ "$$", "$$" ],                   [ "{,}",        "",      "", "comma",    "," ], "\\",                   [ "{", "}" ],                    "^",                    [ "\\cdot",     "",      "", "cdot",     "·" ], [ "\\times",   "",      "", "times",    "×" ], [ "\\pm",      "",      "", "pm",       "±" ], [ "\\sum{",    "}",     "", "sum{}",    "Σ" ], [ "\\frac{",   "}{}",   "", "frac{}{}", "—" ], [ "\\sqrt{",   "}",     "", "sqrt{}",   "√" ], [ "\\sqrt[n]{", "}",    "", "sqrt[n]{}","ⁿ√" ], [ "\\leq",     "",      "", "leq",      "≤" ], [ "\\geq",     "",      "", "geq",      "≥" ], [ "\\approx",  "",      "", "approx",   "≈" ], [ "\\ne",      "",      "", "ne",       "≠" ], [ "\\circ",    "",      "", "circ",     "°" ], [ "\\infty",   "",      "", "infty",    "∞" ], [ "\\cup",     "",      "", "cup",      "∪" ], [ "\\cap",     "",      "", "cap",      "∩" ], [ "\\begin",   "\\end", "", "",       "begin…end" ], [ "\!\,",      "",      "", "spacing",  "SPC" ], [ "\\{",       "",      "", "",         "{" ],                    [ "\\}",        "",      "", "",         "}" ] ] ],      "TeX_ar": [ null, [ [ "\\leftarrow",     "", "", "", "←" ], [ "\\leftrightarrow", "", "", "", "↔" ], [ "\\rightarrow",    "", "", "", "→" ], [ "\\Leftarrow",     "", "", "", "⇐" ], [ "\\Leftrightarrow", "", "", "", "⇔" ], [ "\\Rightarrow",    "", "", "", "⇒" ] ] ], "TeX_gr": [ null, [ [ "\\alpha",  "", "", "", "α" ], [ "\\beta",   "", "", "", "β" ], [ "\\gamma",  "", "", "", "γ" ], [ "\\delta",  "", "", "", "δ" ], [ "\\epsilon", "", "", "", "ε" ], [ "\\zeta",   "", "", "", "ζ" ], [ "\\eta",    "", "", "", "η" ], [ "\\theta",  "", "", "", "θ" ], [ "\\iota",   "", "", "", "ι" ], [ "\\kappa",  "", "", "", "κ" ], [ "\\lambda", "", "", "", "λ" ], [ "\\mu",     "", "", "", "μ" ], [ "\\nu",     "", "", "", "ν" ], [ "\\xi",     "", "", "", "ξ" ], [ "\\omicron", "", "", "", "ο" ], [ "\\pi",     "", "", "", "π" ], [ "\\rho",    "", "", "", "ρ" ], [ "\\sigma",  "", "", "", "σ" ], [ "\\tau",    "", "", "", "ς" ], [ "\\upsilon", "", "", "", "τ" ], [ "\\phi",    "", "", "", "υ" ], [ "\\chi",    "", "", "", "φ" ], [ "\\psi",    "", "", "", "χ" ], [ "\\omega",  "", "", "", "ψ" ] ], [ [ "\\Alpha",  "", "", "", "Α" ], [ "\\Beta",   "", "", "", "Β" ], [ "\\Gamma",  "", "", "", "Γ" ], [ "\\Delta",  "", "", "", "Δ" ], [ "\\Epsilon", "", "", "", "Ε" ], [ "\\Zeta",   "", "", "", "Ζ" ], [ "\\Eta",    "", "", "", "Η" ], [ "\\Theta",  "", "", "", "Θ" ], [ "\\Iota",   "", "", "", "Ι" ], [ "\\Kappa",  "", "", "", "Κ" ], [ "\\Lambda", "", "", "", "Λ" ], [ "\\Mu",     "", "", "", "Μ" ], [ "\\Nu",     "", "", "", "Ν" ], [ "\\Xi",     "", "", "", "Ξ" ], [ "\\Omicron", "", "", "", "Ο" ], [ "\\Pi",     "", "", "", "Π" ], [ "\\Rho",    "", "", "", "Ρ" ], [ "\\Sigma",  "", "", "", "Σ" ], [ "\\Tau",    "", "", "", "Τ" ], [ "\\Upsilon", "", "", "", "Υ" ], [ "\\Phi",    "", "", "", "Φ" ], [ "\\Chi",    "", "", "", "Χ" ], [ "\\Psi",    "", "", "", "Ψ" ], [ "\\Omega",  "", "", "", "Ω" ] ], [ 0, " var: " ], [ [ "\\varepsilon", "", "", "", "ε" ], [ "\\vartheta",  "", "", "", "θ" ], [ "\\varkappa",  "", "", "", "κ" ], [ "\\varpi",     "", "", "", "π" ], [ "\\varrho",    "", "", "", "ρ" ], [ "\\varsigma",  "", "", "", "σ" ], [ "\\varphi",    "", "", "", "υ" ] ] ], "TeX_tx": [ null, [ [ "\\mbox",        "",  "", "", "mbox" ], [ "\\text",        "",  "", "", "text" ], [ "\\displaystyle", "", "", "", "displaystyle" ], [ "\\textstyle",   "",  "", "", "textstyle" ], [ "\\boldsymbol{", "}", "", "","boldsymbol" ], [ "\\mathit{",     "}", "", "italic", "mathit" ], [ "\\mathrm{",     "}", "", "roman", "mathrm" ], [ "\\mathsf{",     "}", "", "sans serif","mathsf" ], [ "\\color{",      "}", "", "", "color" ] ] ] };  // defs.global defs.global[ "IPA_T" ] = defs.global.IPA.concat( [ [ [ "" ] ] ] ); }  // with editToolStrIns

// No customization recommended beyond this point.

mw.libs.editToolStrIns.attr.fetch = function ( access ) { // Retrieve attribute setting from definition and user customization // Precondition: //   access  -- definition item // Uses: //   >< .attr.current // 2011-10-27 PerfektesChaos@de.wikipedia with ( mw.libs.editToolStrIns ) { var d = access[ 0 ], s;     if ( d ) { for ( var v in attr.current ) { if ( ! attr.current[ v ] ) { s = d[ v ]; if ( typeof s === "string" ) { attr.current[ v ] = s;              } }        }   // for v in .current }  }   // with editToolStrIns }  // .attr.fetch

mw.libs.editToolStrIns.attr.fit = function ( attempt ) { // Does definition element match requirements for a valid attr? // Precondition: //   attempt  -- item // Postcondition: //   Returns true if is valid attr // Uses: //   >  .attr.names // 2011-10-27 PerfektesChaos@de.wikipedia var r = false; with ( mw.libs.editToolStrIns ) { if ( attempt ) { for ( var v in attr.names ) { if ( typeof attempt[ v ] === "string" ) { r = true; break;  // for v in .names }        }   // for v in .names } else { r = true; }  }   // with editToolStrIns return r; }  // .attr.fit

mw.libs.editToolStrIns.attr.furnish = function ( assign, acquire, applied ) { // Equip menu with attributes // Precondition: //   assign   -- jQuery menu to be extended //   acquire  -- ID of requested content definition //   applied  -- definition element which provided menu content // Postcondition: //   Menu attributed by cascading properties, if any. // Uses: //   >  .attr.names //   >  .defs.current //    < .attr.current //   .attr.fetch // 2011-11-26 PerfektesChaos@de.wikipedia with ( mw.libs.editToolStrIns ) { var d,         n = defs.current.length, q,         v;      attr.current = { }; for ( v in attr.names ) { attr.current[ v ] = false; }  // for v in attr.names attr.current[ "dir" ] = "ltr"; for ( var i = 0; i < n;  i++ ) { q = defs.current[ i ]; d = q[ 1 ][ "defs" ]; if ( typeof d === "object" ) { d = d[ acquire ]; if ( typeof d === "object" ) { attr.fetch( d ); }        }         if ( q[ 0 ]  ===  applied ) { break;  // for i         } }  // for i      for ( v in attr.current ) { d = attr.current[ v ]; if ( d ) { if ( attr.names[ v ] ) { assign.css( v, d ); } else { assign.attr( v, d ); }        }      }   // for v in attr.current }  // with editToolStrIns }  // .attr.furnish

mw.libs.editToolStrIns.defs.factory = function { // Build data model from project and user spec // Postcondition: //   .defs.current has been built in current environment // Uses: //   >  .user //   >  .user.lang //   >  .project //   >  .l10n //   >  .lang //    < .defs.current //    < .defs.lead //   .defs.found //   .defs.fluent //   .defs.features // 2011-11-26 PerfektesChaos@de.wikipedia with ( mw.libs.editToolStrIns ) { var o,         p,          scope = false, shift = false, slang = false; defs.current = [ ]; if ( typeof user === "object" ) { o = defs.found( "user", user ); if ( o ) { p = o[ "lang" ]; if ( typeof p === "string" ) { if ( p.length ) { shift = p;              } }           if ( typeof o[ "custom" ] === "object" ) { defs.lead = true; }        }      }      if ( typeof project === "string" ) { if ( project.length ) { scope = project; }     }      if ( ! scope ) { scope = mw.config.get( "wgDBname" ); }     defs.found( "db", scope ); p = scope.search( /wik[it].+$/ ); if ( p > 0 ) { defs.found( "project", scope.substr( p ) ); }     if ( typeof lang === "string" ) { if ( lang.length ) { slang = lang; }     }      if ( typeof slang !== "string" ) { slang = mw.config.get( "wgContentLanguage" ); }     p = defs.fluent( slang, "projlang", "projsub", false ); if ( typeof shift !== "string" ) { shift = mw.config.get( "wgUserLanguage" ).toLowerCase; }     p = defs.fluent( shift, "language", "dialect", p ); defs.features; defs.current.push( [ "global", { "defs": defs.global } ] ); defs.fluent( "en", "fallback", false, p ); }  // with editToolStrIns }  // .defs.factory

mw.libs.editToolStrIns.defs.fade = function ( access ) { // Remove an an option definition from standard options // Precondition: //   access  -- ID of definition // Postcondition: //   defs.opts is updated // Uses: //   >< .defs.opts // 2011-11-23 PerfektesChaos@de.wikipedia with ( mw.libs.editToolStrIns ) { if ( access ) { var d,            n = defs.opts.length; for ( var i = 0; i < n;  i++ ) { d = defs.opts[ i ]; if ( d[ 0 ] ===  access ) { defs.opts.splice( i, 1 ); break;  // for i            } }  // for i      } }  // with editToolStrIns }  // .defs.fade

mw.libs.editToolStrIns.defs.fair = function { // Check standard list, reduce to valid items and build options // Uses: //   >< .defs.tmp //   >< .defs.opts //   .defs.finder // 2011-11-23 PerfektesChaos@de.wikipedia with ( mw.libs.editToolStrIns ) { var d,         j,          n    = defs.tmp.length / 2, say, seek; for ( var i = 0; i < n;  i++ ) { j   = i + i;         seek = defs.tmp[ j ]; say = defs.tmp[ j + 1 ]; if ( typeof say === "string" &&  typeof seek === "string" ) { if ( say.length ) { d = defs.finder( seek ); if ( d ) { d = d.concat( [ say, false ] ); if ( defs.opts ) { defs.opts.push( d ); } else { defs.opts = [ d ]; }              }            }         }      }   // for i      delete defs.tmp; }  // with editToolStrIns }  // .defs.fair

mw.libs.editToolStrIns.defs.features = function { // Assign project and user settings // Precondition: //   defs.current is filled with user and l10n objects // Postcondition: //   Cascading settings performed // Uses: //   >  .defs.current //   .set // 2011-11-26 PerfektesChaos@de.wikipedia with ( mw.libs.editToolStrIns ) { var c,         n = defs.current.length - 1, p;     for ( var i = n;  i >= 0;  i-- ) { c = defs.current[ i ][ 1 ][ "config" ]; if ( typeof c === "object" ) { for ( p in c ) { set( p, c[ p ] ); }  // for p in c         } }  // for i-- }  // with editToolStrIns }  // .defs.features

mw.libs.editToolStrIns.defs.filter = function { // Remove situation dependent list items // Postcondition: //   Standard list has been reduced if appropriate // Uses: //   >< .defs.opts //   >< .defs.reNS // 2011-11-23 PerfektesChaos@de.wikipedia with ( mw.libs.editToolStrIns ) { var n = defs.opts.length, s;     for ( var i = n - 1;  i >= 0;  i-- ) { s = defs.opts[ i ][ 0 ]; if ( typeof s === "string" ) { switch ( s.charCodeAt( 0 ) ) { case 47 :  // '/' project type // TODO break; case 58 :  // ':' namespace if ( ! defs.reNS ) { defs.reNS = "^:" + mw.config.get( "wgNamespaceNumber" ) + "(_.*)?$" ;                    defs.reNS = new RegExp( defs.reNS, "" ); }                 if ( ! defs.reNS.test( s ) ) { defs.opts.splice( i, 1 ); n--; }                 break; }  // switch charCodeAt }     }   // for i-- if ( ! n ) { defs.opts = false; }  }   // with editToolStrIns }  // .defs.filter

mw.libs.editToolStrIns.defs.find = function ( access, alike ) { // Find property within objects in current environment // Precondition: //   access  -- name of property //   alike   -- type of property // Postcondition: //   Returns not-empty value,  or false if not found // Uses: //   >  .defs.current // 2011-11-23 PerfektesChaos@de.wikipedia var r = false; with ( mw.libs.editToolStrIns ) { var n = defs.current.length, p;     for ( var i = 0;  i < n;  i++ ) { p = defs.current[ i ][ 1 ][ access ]; if ( typeof p === alike ) { if ( p ) { r = p;              break;   // for i            } }     }   // for i   }   // with editToolStrIns return r; }  // .defs.find

mw.libs.editToolStrIns.defs.finder = function ( acquire ) { // Find content definition within current environment // Precondition: //   acquire  -- ID of requested content definition // Postcondition: //   Returns false if not found, or   //            Array(3):  [0] ID,  [1] definition,  [2] origin // Uses: //   >  .defs.current // 2011-11-23 PerfektesChaos@de.wikipedia var r = false; with ( mw.libs.editToolStrIns ) { var d,         g,          n = defs.current.length, p;     for ( var i = 0;  i < n;  i++ ) { g = defs.current[ i ]; p = g[ 1 ][ "defs" ]; if ( typeof p === "object" ) { d = p[ acquire ]; if ( typeof d === "object" ) { if ( d.length > 1 ) { r = [ acquire, d,  g[ 0 ] ]; break;  // for i               } }        }      }   // for i   }   // with editToolStrIns return r; }  // .defs.finder

mw.libs.editToolStrIns.defs.fluent = function ( assign, appoint, another, already ) { // Build data model with respect to language // Precondition: //   assign   -- string: code of language (ISO 639) //   appoint  -- string: id of language in current data model //   another  -- string: id of dialect in data model //   already  -- Array(2) of known items, or false if not yet set // Postcondition: //   Returns Array(2) of items, or false if not set // Uses: //   .defs.found // 2011-10-27 PerfektesChaos@de.wikipedia var r = ( already ?  already  :  [ false, false ] ); with ( mw.libs.editToolStrIns ) { var k    = assign.indexOf( "-" ), slang = assign.toLowerCase; if ( k > 1 ) { var s  = slang.substr( 0,  k - 1 ), sub = s + "_"  +   slang.substr( 0,  k + 1 ); if ( already ) { if ( already[0] === s ) { s = false; }           if ( already[1] === sub ) { sub = false; }        }         if ( s ) { defs.found( appoint, s ); }        if ( sub ) { defs.found( another, sub ); }        r = [ s, sub ]; } else { if ( already ) { if ( already[ 0 ] ===  slang ) { slang = false; }        }         if ( slang ) { defs.found( appoint, slang ); r = [ slang, false ]; }     }   }   // with editToolStrIns return r; }  // .defs.fluent

mw.libs.editToolStrIns.defs.format = function { // Adjust all definitions in focus as canonical form definition // Postcondition: //   All definitions available in canonical form // Uses: //   >  .defs.current //   .attr.fit // 2011-11-23 PerfektesChaos@de.wikipedia with ( mw.libs.editToolStrIns ) { var c,         d,          e,          g,          n = defs.current.length, o,         p;      for ( var i = 0;  i < n;  i++ ) { o = defs.current[ i ][ 1 ]; c = o[ "defs" ]; if ( typeof c === "object" ) { if ( c ) { for ( e in c ) { d = c[ e ]; if ( typeof d === "object" ) { if ( attr.fit( d ) ) { c[ e ] = [ d ]; } else { if ( jQuery.isArray( d ) ) { if ( ! attr.fit( d[0] ) ) { d.unshift( [ null ] ); }                       } else { p = d[ "atributes" ]; g = d[ "groups" ]; if ( p || g ) { if ( ! p ) { p = null; }                             if ( g ) { c[ e ] = [ p, { "groups": g } ]; } else { c[ e ] = [ p ]; }                          } else { d = false; }                       }                     }                  } else { d = false; }                 if ( ! d ) { delete c[ e ]; }              }   // for e in c            } } else { c = false; }        if ( ! c ) { delete o[ "defs" ]; }     }   // for i   }   // with editToolStrIns }  // .defs.format

mw.libs.editToolStrIns.defs.found = function ( appoint, assign ) { // Append data model item to current model, if valid // Precondition: //   appoint  -- string: id in current data model //   assign   -- string: id in .l10n. object (direct access) // Postcondition: //   Returns object reference in data model // Uses: //   >  .l10n //    < .defs.current // 2011-11-23 PerfektesChaos@de.wikipedia var r = false; with ( mw.libs.editToolStrIns ) { var o = false; switch ( typeof assign ) { case "object" : o = assign; break; case "string" : o = l10n[ assign ]; break; }  // switch typeof if ( typeof o === "object" ) { if ( o ) { defs.current.push( [ appoint, o ] ); r = o;        } }  }   // with editToolStrIns return r; }  // .defs.found

mw.libs.editToolStrIns.defs.friend = function ( access ) { // Find option title within standard list // Precondition: //   access  -- ID of option // Postcondition: //   Returns false if not found, or title string // Uses: //   >  .defs.opts // 2011-11-23 PerfektesChaos@de.wikipedia var r = false; with ( mw.libs.editToolStrIns ) { var n = defs.opts.length, o;     for ( var i = 0;  i < n;  i++ ) { o = defs.opts[ i ]; if ( o[ 0 ] ===  access ) { r = o[ 3 ]; break; }     }   // for i   }   // with editToolStrIns return r; }  // .defs.friend

mw.libs.editToolStrIns.defs.furnish = function { // Customize standard list by heading elements and removing items // Precondition: //   Customization entry available //   Standard list in preprocessed form // Postcondition: //   Standard list has been updated // Uses: //   >  .user.custom //   >< .defs.opts //   .defs.finder //   .defs.friend //   .defs.fade //   jQuery.isArray //   jQuery.trimRight // 2011-11-23 PerfektesChaos@de.wikipedia with ( mw.libs.editToolStrIns ) { if ( typeof user.custom === "object" ) { if ( jQuery.isArray( user.custom ) ) { var n = user.custom.length / 2; if ( n ) { var j,                  opt, say, seek, temp = [ ]; for ( var i = 0; i < n;  i++ ) { j   = i + i;                  seek = user.custom[ j ]; if ( typeof seek === "string" ) { if ( seek.length ) { opt = false; j++; say = user.custom[ j ]; if ( say ) { if ( typeof say === "string" ) { say = jQuery.trimRight( say ); if ( ! say.length ) { say = false; }                          } else { say = defs.friend( seek ); }                          if ( say ) { opt = defs.finder( seek ); if ( opt ) { opt = opt.concat( [ say, false ] ); temp.push( opt ); }                          }                        }                        if ( seek !== "" ) { defs.fade( seek ); }                    }                  }               }   // for i               if ( temp.length ) { defs.opts = temp.concat( defs.opts ); }           }   // user.custom not empty }  // user.custom isArray }  // user.custom }  // with editToolStrIns }  // .defs.furnish

mw.libs.editToolStrIns.gui.facet = function ( action ) { // Display menu: initial selection or handle GUI event // Precondition: //   action  -- false:  initialization after setup //              object: GUI event // Uses: //   >  .gui.$gadget //   >  .gui.selection //   >  .gui.cookie //   >  .gui.$menu //   >  .defs.opts //   .gui.find //   .menu.factory //   jQuery.cookie // 2011-11-23 PerfektesChaos@de.wikipedia with ( mw.libs.editToolStrIns ) { var k,         learn = ( typeof gui.cookie === "string" ); if ( action ) { k = gui.$gadget.attr( "value" ); } else { if ( typeof gui.selection === "string" ) { k = gui.find( gui.selection ); } else { k = -1; }        if ( k < 0 ) { if ( learn ) { var s = jQuery.cookie( gui.cookie ); k = gui.find( s ); }        }         gui.$gadget.attr( "value", k ); }     k = ( k < 0  ?  0  :  k ); if ( ! defs.opts[ k ][ 4 ] ) { defs.opts[ k ][ 4 ] = menu.factory( defs.opts[ k ] ); }     gui.$menu.children.detach; gui.$menu.append( defs.opts[ k ][ 4 ] ); if ( learn ) { jQuery.cookie( gui.cookie,                       defs.opts[ k ][ 0 ],                        { expires: null,                          path:    "/" } ); }  }   // with editToolStrIns }  // .gui.facet

mw.libs.editToolStrIns.gui.favour = function { // Kick out competitors // Uses: //   >  .gui.old // 2011-11-27 PerfektesChaos@de.wikipedia with ( mw.libs.editToolStrIns ) { if ( typeof gui.old === "string" ) { mw.util.addCSS( gui.old + "{display:none}" ); }  }   // with editToolStrIns }  // .gui.favour

mw.libs.editToolStrIns.gui.fill = function ( arglist ) { // Perform insertion // Precondition: //   arglist  -- parameters for jQuery.textSelection // Uses: //   >  .gui.$textarea //   >< .gui.wikEd:: //       >  .wikEd.focus //       >< .wikEd.active //   >< .gui.$current //   .gui.flip //   >  wikEd:: //         >  .disabled //   jQuery.textSelection // 2011-11-21 PerfektesChaos@de.wikipedia with ( mw.libs.editToolStrIns ) { if ( gui.$current.length ) { if ( gui.wikEd ) { if ( window.wikEd.disabled ) { gui.wikEd.active = false; }           if ( gui.wikEd.active ) { if ( gui.wikEd.focus ) { if ( arglist[ "post" ] ||                       arglist[ "peri" ]  ||                       arglist[ "replace" ] ) { // jQuery.textSelection (2011-11) does not support // DOM composition wihin iframe gui.flip; }                 wikEd.UpdateTextarea( null ); gui.$current = gui.$textarea; }           } else { gui.wikEd.focus = false; }        }         gui.$current.textSelection( "encapsulateSelection", arglist ); }  }   // with editToolStrIns }  // .gui.fill

mw.libs.editToolStrIns.gui.find = function ( adjust ) { // Retrieve number of item in gadget for a certain identifier // Precondition: //   adjust  -- identifier // Postcondition: //   Returns number,  < 0 if not found // Uses: //   >  .defs.opts // 2011-11-23 PerfektesChaos@de.wikipedia var r = -1; with ( mw.libs.editToolStrIns ) { var n = defs.opts.length; for ( var i = 0; i < n;  i++ ) { if ( defs.opts[ i ][ 0 ] ===  adjust ) { r = i;           break;   // for i         } }  // for i   }   // with editToolStrIns return r; }  // .gui.find

mw.libs.editToolStrIns.gui.fit = function ( arglist ) { // Perform RegExp replacement // Precondition: //   arglist   -- Array(6) //                [0] to be inserted before caret / selection //                    string or empty //                [1] to be inserted after caret / selection //                    string or empty //                [2] string with replacement expression //                [5] string with RegExp to process selection // Uses: //   >  .gui.$current //   jQuery.textSelection //   gui.fill // 2011-11-21 PerfektesChaos@de.wikipedia with ( mw.libs.editToolStrIns ) { if ( gui.$current.length ) { var pars = { }, range = gui.$current.textSelection( "getCaretPosition",                                                { "startAndEnd":                                                   true } ); if ( arglist[0] ) { pars[ "pre" ] = arglist[0]; }        if ( arglist[1] ) { pars[ "post" ] = arglist[1]; }        if ( range[0] < range[1] ) { if ( typeof arglist[2] === "string" &&                 typeof arglist[5] === "string" ) { var re = new RegExp( arglist[5], "" ), sel = gui.$current.textSelection( "getSelection" ); pars[ "peri" ]   = sel.replace( re, arglist[2] ); pars[ "replace" ] = true; }        }         gui.fill( pars ); }  }   // with editToolStrIns }  // .gui.fit

mw.libs.editToolStrIns.gui.flip = function { // Strip whitespace from current selection, mainly for wikEd // Precondition: //   ahead  -- selection begin is of interest //   after  -- selection end is of interest //   Browser supports wikEd, wikEd active // Uses: //   .gui.flipEnd //   .gui.flipBegin //   >  wikEd:: //         .GetSelection //   jQuery.trimLeft //   jQuery.trimRight //   DOM: .rangeCount // 2011-11-27 PerfektesChaos@de.wikipedia with ( mw.libs.editToolStrIns ) { var range = wikEd.GetSelection, sel   = range.toString, n     = sel.length, lead  = ( n  !==  jQuery.trimLeft( sel ).length ), later = ( n  !==  jQuery.trimRight( sel ).length ); if ( lead || later ) { var numRange = range.rangeCount; if ( numRange ) { if ( later ) { gui.flipEnd( range, numRange ); }           if ( lead ) { //            gui.flipBegin( range ); }        }   // numRange }  // lead || later }  // with editToolStrIns }  // .gui.flip

/* mw.libs.editToolStrIns.gui.flipBegin = function ( assembly ) { // Strip heading whitespace from current selection, mainly for wikEd // Precondition: //   assembly  -- Range object // Uses: //   .gui.flipper //   DOM // 2011-11-27 PerfektesChaos@de.wikipedia with ( mw.libs.editToolStrIns ) { var located, rangeLast = rangeSel.getRangeAt( numRange - 1 ), container = rangeLast.endContainer, m        = rangeLast.endOffset, c,            n,             s;         while ( container ) { mw.log(debug,".gui.flipBegin   nodeType="+container.nodeType,0); switch ( container.nodeType ) { case Node.ELEMENT_NODE : mw.log(debug,".gui.flipBegin   ELEMENT_NODE "+container.nodeName,0); container = gui.flipper( container ); break; case Node.TEXT_NODE : if ( m ) { s = container.textContent; m--; located = false; for ( n = m; n >= 0;  n-- ) { c = s.charCodeAt( n ); if ( c > 32 &&  c !== 160 ) { break;  // for n-- }                       located = true; }  // for n-- if ( located ) { if ( n >= 0 ) { rangeLast.setEnd( container, n + 1 ); }                    }                     container = false; } else { mw.log(debug,".gui.flipBegin   TEXT_NODE m=0",0); container = gui.flipper( container ); }                 break; }  // switch nodeType if ( container ) { if ( container.nodeType === Node.TEXT_NODE ) { m = container.textContent.length; mw.log(debug,".gui.flipBegin textContent",0,container.textContent+"<"); }           }         }   // while container }  // with editToolStrIns }  // .gui.flipBegin

mw.libs.editToolStrIns.gui.flipEnd = function ( assembly, amount ) { // Strip trailing whitespace from current selection, mainly for wikEd // Precondition: //   assembly  -- Range object //   amount    -- number of elements in assembly, >= 1 // Uses: //   .gui.flipper //   DOM   .getRangeAt, .endContainer, .endOffset, .textContent // 2011-11-27 PerfektesChaos@de.wikipedia with ( mw.libs.editToolStrIns ) { var located, rangeLast = assembly.getRangeAt( amount - 1 ), container = rangeLast.endContainer, m        = rangeLast.endOffset, c,         n,          s; //mw.log(debug,".gui.flipEnd",0); while ( container ) { switch ( container.nodeType ) { case Node.ELEMENT_NODE : //mw.log(debug,".gui.flipEnd   ELEMENT_NODE "+container.nodeName,0); container = gui.flipper( container, Node.ELEMENT_NODE ); break; case Node.TEXT_NODE : if ( m ) { s = container.textContent; m--; located = false; for ( n = m; n >= 0;  n-- ) { c = s.charCodeAt( n ); if ( c > 32 &&  c !== 160 ) { break;  // for n-- }                    located = true; }  // for n-- if ( located ) { if ( n >= 0 ) { rangeLast.setEnd( container, n + 1 ); }                 }                  container = false; } else { container = gui.flipper( container, Node.TEXT_NODE ); }              break; }  // switch nodeType if ( container ) { if ( container.nodeType === Node.TEXT_NODE ) { m = container.textContent.length; }        }      }   // while container }  // with editToolStrIns }  // .gui.flipEnd

mw.libs.editToolStrIns.gui.flipper = function ( after, about ) { // Traverse upwards/forward in DOM tree // Precondition: //   after  -- DOM Node at end //   about  -- nodeType // Postcondition: //   Returns DOM Node sibling // Uses: //   DOM // 2011-11-27 PerfektesChaos@de.wikipedia var container = after, mode     = about, parent   = null, previous, r        = null; with ( mw.libs.editToolStrIns ) {///////////////// while ( true ) { previous = container.previousSibling; if ( previous ) { //mw.log(debug,".gui.flipper  previousSibling "+previous.nodeName,0); r   = previous; mode = 0; break;  // while }     if ( mode === Node.ELEMENT_NODE ) { parent = container.parentNode; //mw.log(debug,".gui.flipper  parentNode="+parent.nodeName,0); if ( parent.nodeName.toLowerCase === "html" ) { break;  // while } else { container = parent; mode     = container.nodeType; }     }   }   // while loop }  // with editToolStrIns return r; }  // .gui.flipper

mw.libs.editToolStrIns.gui.focus = function { // Initialize focussing // Precondition: //   document ready // Postcondition: //   Binding is established // Uses: //    < .gui.$textarea //    < .gui.$current //    < .gui.wikEd //   >  wikEd:: //         >  .frameBody //         >  .disabled //         >  .frameDocument //         .Setup //   jQuery.focus //   (.gui.frames) // 2011-11-21 PerfektesChaos@de.wikipedia with ( mw.libs.editToolStrIns ) { gui.$textarea = jQuery( "#wpTextbox1" ); gui.$current = gui.$textarea; gui.wikEd    = false; jQuery( "textarea, input:text" ).focus( function { 	                                       gui.$current = jQuery( this );                                           if ( gui.wikEd ) {                                              gui.wikEd.focus = false;                                           }                                                          } ); if ( typeof window.wikEd === "object" ) { if ( window.wikEd ) { if ( typeof window.wikEd.disabled !==  "boolean" ) { // asynchronous overrun window.wikEd.Setup; }           if ( gui.$textarea.length  &&  ! window.wikEd.disabled ) { gui.wikEd = { active: true, focus: true }; window.wikEd.frameDocument.addEventListener( "click",                                                           gui.frames,                                                            false ); window.wikEd.frameDocument.addEventListener( "dblclick",                                                           gui.frames,                                                            false ); window.wikEd.frameDocument.addEventListener( "keypress",                                                           gui.frames,                                                            false ); /* wikEd uses an iframe which cannot receive focus under < .gui.wikEd:: //        < .wikEd.focus // 2011-11-21 PerfektesChaos@de.wikipedia with ( mw.libs.editToolStrIns ) { if ( gui.wikEd ) { gui.wikEd.focus = true; }  }   // with editToolStrIns }  // .gui.frames

mw.libs.editToolStrIns.menu.factory = function ( apply ) { // Build menu area // Precondition: //   apply  -- Array(5) //             [0] identifier //             [1] definition //             [2] origin //             [3] option title //             [4] $menu (false) // Postcondition: //   Returns jQuery object for $menu (apply[4]) // Uses: //   >  .menu.separator //   >  .gui.self //   >  .menu.divide //   >< .menu.$sep //   .attr.furnish //   .menu.field // 2011-11-23 PerfektesChaos@de.wikipedia var $r; with ( mw.libs.editToolStrIns ) { var d   = apply[ 1 ], lead = false, n   = d.length, sel; $r = jQuery( " " ); $r.css( "display", "inline" ); if ( typeof menu.$sep !== "object" ) { menu.$sep = false; if ( typeof menu.separator === "string" ) { if ( menu.separator.length ) { menu.$sep = jQuery( " " ); menu.$sep.text( menu.separator ); menu.$sep.attr( "class", gui.self + "-sep" ); if ( typeof menu.divide === "object" ) { for ( var p in menu.divide ) { menu.$sep.css( p, menu.divide[ p ] ); }  // for p in menu.divide }           }         }      }      attr.furnish( $r,  apply[ 0 ],  apply[ 2 ] ); sel = $r.attr( "class" ); if ( typeof sel === "string" ) { sel = sel + ","; } else { sel = ""; }     sel = sel + gui.self + "-menu-"  + apply[ 0 ]; $r.attr( "class", sel ); for ( var i = 1; i < n;  i++ ) { lead = menu.field( $r, d[ i ],  lead ); }  // for i   }   // with editToolStrIns return $r; }  // .menu.factory

mw.libs.editToolStrIns.menu.feed = function ( assign, apply, align ) { // Process a definition element of type "separated compressed" // Precondition: //   assign  -- jQuery element to be extended //   apply   -- definition item; Array with at least 2 elements //              [0] number < 0, -[0]: code of separator //              [1] and further: string, separated by -[0] //   align   -- true: insert group separator ahead // Postcondition: //   assign is extended // Uses: //   .menu.fence //   .menu.fill // 2011-10-27 PerfektesChaos@de.wikipedia with ( mw.libs.editToolStrIns ) { var lead  = align, m,         more   = apply.length, n,         sep    = String.fromCharCode( -apply[ 0 ] ), subs, stream; for ( var i = 1; i < more;  i++ ) { stream = apply[ i ]; if ( typeof stream === "string" ) { subs = stream.split( sep ); n   = subs.length; menu.fence( assign, n && lead ); for ( m = 0; m < n;  m++ ) { menu.fill( assign, subs[ m ] ); }  // for m         } lead = true; }  // for i   }   // with editToolStrIns }  // .menu.feed

mw.libs.editToolStrIns.menu.fence = function ( assign, align ) { // Insert group separator conditionally // Precondition: //   assign  -- jQuery element to be extended //   align   -- true: insert group separator ahead, else do nothing // Postcondition: //   group separator has been appended to assign, if align // Uses: //   >  .menu.$sep // 2011-11-23 PerfektesChaos@de.wikipedia if ( align ) { with ( mw.libs.editToolStrIns ) { if ( menu.$sep ) { assign.append( menu.$sep.clone ); }     }   // with editToolStrIns } }  // .menu.fence

mw.libs.editToolStrIns.menu.field = function ( assign, apply, align ) { // Process a group (one item in definition array) // Precondition: //   assign  -- jQuery element to be extended //   apply   -- definition element //              Array:   with specifications //              boolean: false  -- no group separator //              number:  0      -- no group separator //   align   -- true: insert group separator ahead // Postcondition: //   Returns necessity for separator before next group // Uses: //   .menu.flush //   .menu.figures //   .menu.feed //   .menu.fixed //   .menu.fence //   .menu.fill // 2011-11-23 PerfektesChaos@de.wikipedia var r = true; with ( mw.libs.editToolStrIns ) { var light = true; if ( apply ) { var begin = apply[0]; light = ( typeof begin === "number" ); if ( light ) { if ( begin === 1 ) { menu.flush( assign, apply, align ); } else if ( begin === 2 ) { menu.figures( assign, apply, align ); } else if ( begin < -31 ) { menu.feed( assign, apply, align ); } else if ( ! begin ) { if ( apply[1] ) { menu.fixed( assign, apply[1], align ); }              r = false; } else if ( begin > 126 ) { light = false; }        }      } else { r = false; }  // apply if ( ! light ) { var n = apply.length; menu.fence( assign, align ); for ( var i = 0; i < n;  i++ ) { menu.fill( assign, apply[i] ); }  // for i      } }  // with editToolStrIns return r; }  // .menu.field

mw.libs.editToolStrIns.menu.figures = function ( assign, apply, align ) { // Process a definition element of type "numeric range of single UCS" // Precondition: //   assign  -- jQuery element to be extended //   apply   -- definition item; Array with at least 3 elements //              [0] code for "numeric range" //              [1] UCS of first character in first pair //              [2] UCS of last character in first pair //              [4] optional: UCS of first character in second pair //              [5] optional: UCS of last character in second pair //              ... etc.   //    align   -- true: insert group separator ahead // Ranges are supposed to cover less than 1024 codepoints // Postcondition: //   assign is extended // Uses: //   .menu.fence //   .menu.fill //   .menu.fixed // 2011-11-23 PerfektesChaos@de.wikipedia with ( mw.libs.editToolStrIns ) { var i,         j,          m,          n = apply.length; menu.fence( assign, align ); for ( var k = 1; k < n;  k += 2 ) { i = apply[ k ]; j = apply[ k + 1 ]; m = j - i;        if ( i < j ) { if ( m < 1024 ) { for ( i <= j; i++ ) { menu.fill( assign, i ); }  // for i               m = false; }        } else {   // rtl if ( m > -1024 ) { for ( i >= j; i-- ) { menu.fill( assign, i ); }  // for i-- m = false; }        }         if ( m ) { menu.fixed( assign,                       "ERROR: too many UCS chars: " + i + "..." + j,                        true ); }     }   // for k   }   // with editToolStrIns }  // .menu.figures

mw.libs.editToolStrIns.menu.fill = function ( assign, apply ) { // Create a single token // Precondition: //   assign  -- jQuery element to be extended //   apply   -- specification //              string: insert ahead //              number: insert UCS ahead //              Array(1...)    [0]...[4]: string or empty //              [0] to be inserted before cursor position / selection //              [1] to be inserted after cursor position / selection //              [2] to be inserted if there is no selection range //              [3] tooltip //              [4] explicit label for token //              [5] advanced //                  true:     Replace current selection, if any. //                  function: to be executed with apply //                  string:   RegExp for selection, apply to [2] //              [...] any further value that has currently no meaning // Uses: //   >  .menu.stick //   >  .gui.self //   .menu.fromCharCode //   (.gui.fill) //   (.menu.fun) //   (.gui.fit) // 2011-11-23 PerfektesChaos@de.wikipedia with ( mw.libs.editToolStrIns ) { var exec = false, light = false, pars = false, say  = "", story = false; switch ( typeof apply ) { case "number" : if ( apply > 0 ) { say  = menu.fromCharCode( apply ); light = true; }           break; case "string" : say  = apply; light = true; break; case "object" : var loose = false, n     = apply.length, sample = "", start = ( apply[0] ? apply[0] : "" ), suffix = ""; if ( typeof start === "number" ) { start = menu.fromCharCode( start ); }           say = start; if ( n > 1 ) { if ( apply[1] ) { suffix = apply[1]; if ( typeof suffix === "number" ) { suffix = menu.fromCharCode( suffix ); }                 say   = start + suffix; story = start + menu.stick + suffix; }              if ( n > 2 ) { if ( apply[2] ) { sample = apply[2]; story = say + sample + suffix; }                 if ( n > 3 ) { if ( apply[3] ) { story = apply[3]; }                    if ( n > 4 ) { if ( apply[4] ) { say = apply[4]; }                       if ( n > 5 ) { switch ( typeof apply[5] ) { case "boolean" : loose = apply[5]; break; case "function" : exec = function {  menu.fun( apply ); return false; };                                break; case "string" : exec = function {  gui.fit( apply ); return false; };                                break; }  // switch typeof apply[5] }                    }                  }               }            }            if ( ! exec ) { pars = { }; if ( start ) { pars[ "pre" ] = start; }              if ( suffix ) { pars[ "post" ] = suffix; }              if ( sample ) { pars[ "peri" ] = sample; }              if ( loose ) { pars[ "replace" ] = true; }              if ( pars === { } ) { pars = false; }           }            break; }  // switch typeof apply if ( say.length ) { if ( light ) { pars = { "pre": say }; }        if ( pars ) { exec = function {  gui.fill( pars ); return false; };        }         if ( exec ) { var $space = jQuery( " " ), $token = jQuery( "" ); $token.attr( "href", "#" ); $token.attr( "class", gui.self + "-token" ); $token.text( say.replace( / /g, "\xA0" ) );  // escapes self if ( story ) { $token.attr( "title", story ); }           $token.click( exec ); assign.append( $space ); assign.append( $token ); }     }   }   // with editToolStrIns }  // .menu.fill

mw.libs.editToolStrIns.menu.fixed = function ( assign, apply, align ) { // Process a definition element of type "fixed text" // Precondition: //   assign  -- jQuery element to be extended //   apply   -- (HTML) string to be inserted //   align   -- true: insert separating spaces ahead // Postcondition: //   apply has been appended to assign // 2011-10-27 PerfektesChaos@de.wikipedia var s = " " + ( align ? " " : "" ) + apply + " "; assign.append( s ); }  // .menu.fixed

mw.libs.editToolStrIns.menu.flush = function ( assign, apply, align ) { // Process a definition element of type "packed characters" // Precondition: //   assign  -- jQuery element to be extended //   apply   -- definition item; Array with at least 2 elements //              [0] === 1   //               [1] and further: string, character sequence group //   align   -- true: insert group separator ahead // Postcondition: //   assign is extended // Uses: //   .menu.fence //   .menu.fill // 2011-10-27 PerfektesChaos@de.wikipedia with ( mw.libs.editToolStrIns ) { var lead  = align, m,         more   = apply.length, n,         stream; for ( var i = 1; i < more;  i++ ) { stream = apply[i]; if ( typeof stream === "string" ) { n = stream.length; menu.fence( assign, n && lead ); for ( m = 0; m < n;  m++ ) { menu.fill( assign, stream.substr( m, 1 ) ); }  // for m         } lead = true; }  // for i   }   // with editToolStrIns }  // .menu.flush

mw.libs.editToolStrIns.menu.fromCharCode = function ( address ) { // Extended fromCharCode for UCS > 0xFFFF (4 bytes/char) // Precondition: //   address  -- number, UCS // Postcondition: //   Returns a single character, //      which might have a string length of 2 instead of 1 // Requires: JavaScript 1.3  String.fromCharCode  2 byte chars only // 2011-10-27 PerfektesChaos@de.wikipedia var r;  if ( address > 0xFFFF ) { var c = address - 0x10000; r = String.fromCharCode( 0xD800 +  ( c >> 10 ),                               0xDC00  +  ( c & 0x3FF ) ); } else { r = String.fromCharCode( address ); }  return r; }   // .menu.fromCharCode

mw.libs.editToolStrIns.menu.fun = function ( apply ) { // Evaluate user defined function // Precondition: //   apply  -- specification array; apply[5] is the UDF //             If apply[5] returns an encapsulateSelection object, //             insertion will be performed. // Uses: //   >  .gui.$current //   .gui.fill // 2011-11-23 PerfektesChaos@de.wikipedia with ( mw.libs.editToolStrIns ) { var got = apply[5]( apply,                         gui.$current.textSelection( "getSelection" ) ); if ( typeof got === "object" ) { gui.fill( got ); }  }   // with editToolStrIns }  // .menu.fun

mw.libs.editToolStrIns.factory = function { // (Re-)build entire data model from project and user spec // Postcondition: //   .current defs are defined // Uses: //   >< .defs.lead //   >< .defs.opts //    < .defs.tmp //    < .defs.reNS //    < .gui.hintList //    < .gui.hintMenu //   .defs.factory //   .defs.format //   .defs.fair //   .defs.furnish //   .defs.filter // 2011-11-23 PerfektesChaos@de.wikipedia with ( mw.libs.editToolStrIns ) { var i = 0; defs.lead = false; defs.opts = false; defs.reNS = false defs.factory; defs.tmp    = defs.find( "list", "object" ); gui.hintList = defs.find( "hintList", "string" ); gui.hintMenu = defs.find( "hintMenu", "string" ); defs.format; defs.fair; if ( defs.lead ) { defs.furnish; }     if ( defs.opts ) { defs.filter }  }   // with editToolStrIns }  // .factory

mw.libs.editToolStrIns.about_defs = function ( alerting ) { // Show message box with all available definition identifiers (API) // Precondition: //   alerting  -- false: don't try to pop up message box // Postcondition: //   Message box is presented, if possible. //   Returns void(0) if message box shown, //           else string with definition identifiers. // Uses: //   > .defs.current // 2011-11-23 PerfektesChaos@de.wikipedia var r = false; with ( mw.libs.editToolStrIns ) { var collect = [ ], d,         n,          p,          q,          v;      n = defs.current.length; for ( var i = 0; i < n;  i++ ) { d = defs.current[ i ][ 1 ][ "defs" ]; for ( q in d ) { v = d[ q ]; if ( typeof v === "object" ) { if ( v.length > 1 ) { collect = collect.concat( [ q ] ); }           }         }   // for q in d      }   // for i      n = collect.length; if ( n ) { collect.sort; r = ""; p = ""; for ( q = 0; q < n;  q++ ) { v = collect[ q ]; if ( v !== p ) { r += " " + v;              p  = v;            } }  // for q         r = r.substr( 1 ); } else { r = "*-*-*-*"; }  }   // with editToolStrIns if ( alerting !== false ) { if ( typeof window ===  "object" ) { window.alert( r ); r = void( 0 ); }  // online }  return r; }   // .about_defs

mw.libs.editToolStrIns.set = function ( action, apply ) { // Set project or user property (API) // Precondition: //   action  -- string: which property to be set //              "cookieName":        for selection ID   //               "ellipsis":          tooltip generation //                                   show between start and end tag //              "groupSeparator":    non-empty string //                                   or false //              "groupSeparatorCSS": object with CSS assignments //              "old":               selector for other edittools //                                   or false //              "selection":         gadget shift //   apply   -- string or boolean // Uses: //   >  .defs.opts //    < .gui.cookie //    < .menu.divide //    < .menu.separator //    < .menu.stick //    < .gui.old //    < .gui.selection //   .gui.favour //   .gui.facet //   jQuery.trimLeft //   jQuery.trimRight // 2011-11-27 PerfektesChaos@de.wikipedia with ( mw.libs.editToolStrIns ) { switch ( action ) { case "cookieName" : if ( typeof apply === "string" ) { gui.cookie = jQuery.trimLeft( apply ); gui.cookie = jQuery.trimRight( gui.cookie ); if ( ! gui.cookie.length ) { gui.cookie = false; }           } else { gui.cookie = false; }           break; case "ellipsis" : if ( typeof apply === "string" ) { menu.stick = apply; }           break; case "groupSeparator" : menu.separator = apply; break; case "groupSeparatorCSS" : if ( typeof apply === "object" ) { menu.divide = apply; }           break; case "old" : gui.old = apply; gui.favour; break; case "selection" : gui.selection = apply; if ( typeof defs.opts === "object" ) { gui.facet; }           break; }  // switch action }  // with editToolStrIns }  // .set

mw.libs.editToolStrIns.update = function { // Furnish entire list and model once again (may be used as API) // Precondition: //   GUI environment available // Postcondition: //   Gadget equipped // Uses: //   >  .gui.$container //   >  .defs.opts //   >  .gui.self //   >  .gui.hintList //   >  .gui.hintMenu //   >< .gui.$wrapper //    < .gui.$gadget //    < .gui.$menu //   .factory //   .gui.facet // 2011-11-23 PerfektesChaos@de.wikipedia with ( mw.libs.editToolStrIns ) { if ( gui.$wrapper ) {  // reset gui.$container.remove( "." + gui.self ); }     factory; if ( defs.opts ) { var n = defs.opts.length; var x = "";  // DEVELOPMENT if ( vsn < 1 ) { x = " ***** TEST " + gui.self + " " + vsn; }        var $opt, $sep = jQuery( " " ); gui.$wrapper = jQuery( " " ); gui.$wrapper.attr( "class", gui.self ); gui.$gadget = jQuery( " " ); gui.$gadget.attr( "class", gui.self + "-gadget" ); if ( gui.hintList ) { gui.$gadget.attr( "title", gui.hintList /************/ + x ); } else { gui.$gadget.attr( "title", x ); }        for ( var i = 0;  i < n;  i++ ) { $opt = jQuery( " " ); $opt.attr( "value", i ); $opt.text( defs.opts[ i ][ 3 ] ); gui.$gadget.append( $opt ); }  // for i         gui.$wrapper.append( gui.$gadget ); gui.$wrapper.append( $sep ); gui.$menu = jQuery( " " ); gui.$menu.attr( "class", gui.self + "-menu" ); gui.$menu.css( "display", "inline" ); if ( gui.hintMenu ) { gui.$menu.attr( "title", gui.hintMenu ); }        gui.$wrapper.append( gui.$menu ); gui.facet( false ); gui.$container.prepend( gui.$wrapper ); gui.$gadget.change( gui.facet ); gui.$gadget.keyup( gui.facet ); }  }   // with editToolStrIns }  // .update

mw.libs.editToolStrIns.fire = function { // Start once on loading when document ready // Precondition: //   document ready // Postcondition: //   GUI environment established, initial equipment // Uses: //   >  .gui.container //   >  .gui.old //   >< .off //    < .gui.$wrapper //    < .gui.$container //   .gui.favour //   .gui.focus //   .update // 2011-11-27 PerfektesChaos@de.wikipedia with ( mw.libs.editToolStrIns ) { if ( typeof off === "undefined" ) { gui.$wrapper  = false; gui.$container = jQuery( gui.container ); if ( gui.$container.length ) { gui.favour; gui.focus; update; }     }   }   // with editToolStrIns mw.libs.editToolStrIns.off = true;  // avoid multiple setup }  // .fire

if ( mw.libs.editToolStrIns.off === undefined ) { jQuery( document ).ready( mw.libs.editToolStrIns.fire ); } mw.loader.state( "ext.gadget.editToolStrIns", "ready" ); /// end of editToolStrIns.js