Difference between revisions of "User:Andreas Plank/vector.js"

From CETAF Identifiers Wiki
Jump to: navigation, search
(Created page with "//<pre> //<source lang="javascript"> /* o ptions: { * pre:'{|'+classStr+"\n", peri:table, post:'|}', ownline:true type: "booklet" label string: non-localizable label s...")
 
m ({pre: "<tt>", post: "</tt>"})
 
Line 203: Line 203:
 
                 type: 'encapsulate',
 
                 type: 'encapsulate',
 
               options: {pre: "<tvar|name>", peri: "contents", post: "</>"}
 
               options: {pre: "<tvar|name>", peri: "contents", post: "</>"}
 +
            }
 +
          },{
 +
            label: "tt",
 +
            action: {
 +
              type: 'encapsulate', options: {pre: "<tt>", post: "</tt>"}
 
             }
 
             }
 
           },{
 
           },{

Latest revision as of 13:56, 16 July 2020

//<pre>
//<source lang="javascript">
/*
 o ptions: { *
 pre:'{|'+classStr+"\n",
 peri:table,
 post:'|}',
 ownline:true

 type: "booklet"
 label string: non-localizable label string
 labelMsg string: key for localizable message string
 deferLoad boolean
 pages object: map of name keys to further objects:
 layout string required: 'table' or 'characters'
 label string: non-localizable label string
 labelMsg string: key for localizable message string
 headings string[]: array of objects? {textMsg: key} ??
 rows object[] optional?: array of objects? {'row key name': {message object?}}
 characters string[] optional?: array of strings of little character bits for insertion (???!)

 */
var customizeUserToolbarAndreasPlank = function () {
  $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
    'section': 'advanced',
    'group': 'format',
    'tools': {
      'strikethrough': {
        label: 'Durchgestrichen',
        type: 'button',
        icon: 'https://species-id.net/o/media/thumb/4/45/Gnome-format-text-strikethrough.svg/22px-Gnome-format-text-strikethrough.svg.png',
        action: {
          type: 'encapsulate',
          options: {
            pre: "<s>",
            post: "</s>"
          }
        }
      },
      'underline': {
        label: 'Unterstrichen',
        type: 'button',
        icon: 'https://species-id.net/o/media/thumb/9/99/Gnome-format-text-underline.svg/22px-Gnome-format-text-underline.svg.png',
        action: {
          type: 'encapsulate',
          options: {
            pre: "<u>",
            post: "</u>"
          }
        }
      },
      'syntaxhighlight': {
        label: 'Syntax Hervorhebung',
        type: 'button',
        icon: 'https://upload.wikimedia.org/wikipedia/commons/d/d2/Button_source.png',
        action: {
          type: 'encapsulate',
          options: {
            pre: "<syntaxhighlight lang=\"html4strict\">\n",
            post: "\n</syntaxhighlight>"
          }
        }
      },
      'blockquote': {
        label: 'Eingerückten Blockquote einfügen',
        type: 'button',
        icon: 'https://upload.wikimedia.org/wikipedia/en/f/fd/Button_blockquote.png',
        action: {
          type: 'encapsulate',
          options: {
            pre: "<blockquote>\n",
            post: "\n</blockquote>"
          }
        }
      }
    }
  });
  $('#wpTextbox1').wikiEditor('addToToolbar', {
    'sections': {
      'programming': {
        type: 'booklet',
        label: 'Programmierung'
      }
    }
  });
  $('#wpTextbox1').wikiEditor('addToToolbar', {
    'section': 'programming',
    'pages': {
      'tags': {
        'layout': 'characters',
        label: 'Wiki/HTML Tags',
        'characters': [{
          label: "nbsp;",
          action: {
            type: 'encapsulate', options: {pre: "&nbsp;", post: ""}
            }
          },{          
            label: "shy;",
            action: {
              type: 'encapsulate', options: {pre: "&shy;", post: ""}
            }
          },{
            label: "()",
            action: {
              type: 'encapsulate', options: {pre: "(", post: ")"
            }
          }
        },{
          label: "[]",
          action: {
            type: 'encapsulate', options: {pre: "[", post: "]"}
            }
          },{
            label: "[[]]",
            action: {
              type: 'encapsulate', options: {pre: "[[", post: "]]"}
            }
          },{
            label: "{{}}",
            action: {
              type: 'encapsulate', options: {pre: '{{', post: '}}'}
            }
          },{
            label: "{{{}}}",
            action: {
              type: 'encapsulate', options: {pre: "{{{", 'peri': '1', post: "}}}"}
            }
          },{
            label: "{{{|}}}",
            action: {
              type: 'encapsulate', options: {pre: "{{{|", 'peri': '1', post: "}}}"}
            }
          },{
            label: "[[Kategorie:]]",
            action: {
              type: 'encapsulate', options: {pre: '[[Kategorie: ', post: ']]'}
            }
          }, {
              label: "[[Attribut:]]",
              action: {
                type: 'encapsulate',
                options: {
                  /* no selection */
                  pre: "[[Attribut: ",
                  post: "]]",
                  /* a selection */
                  regex:/\s*(.+)\s*/,
                  regexReplace:"[[Attribut: \$1 |\$1]]"
                }
              }
            }, {
              label: "[[property:]]",
              action: {
                type: 'encapsulate',
                options: {
                  /* no selection */
                  pre: "[[property: ",
                  post: "]]",
                  /* a selection */
                  regex:/\s*(.+)\s*/,
                  regexReplace:"[[property: \$1 |\$1]]"
                }
              }
            },{
            label: "#WEITERLEITUNG [[]]",
            action: {
              type: 'encapsulate', options: {pre: "#WEITERLEITUNG [[", post: "]]"}
            }
          },{
            label: "ref",
            action: {
              type: 'encapsulate', options: {pre: '<ref name="">', peri: 'Referenz/Zitat', post: '</ref>'}
            }
          },{
            label: "references",
            action: {
              type: 'encapsulate', options: {pre: '<references/>', post: ''}
            }
          },{
            label: "noinclude",
            action: {
              type: 'encapsulate', options: {pre: "<noinclude>", post: "</noinclude>"}
            }
          },{
            label: "includeonly",
            action: {
              type: 'encapsulate', options: {pre: "<includeonly>", post: "</includeonly>"}
            }
          },{
            label: "onlyinclude",
            action: {
              type: 'encapsulate', options: {pre: "<onlyinclude>", post: "</onlyinclude>"}
            }
          },{
            label: "translate",
            action: {
                type: 'encapsulate',
                options: {pre: "\u003Ctranslate\u003E", post: "\u003C/translate\u003E"}
            }
          }, {
            label: "tvar",
            action: {
                type: 'encapsulate',
              options: {pre: "<tvar|name>", peri: "contents", post: "</>"}
            }
          },{
            label: "tt",
            action: {
              type: 'encapsulate', options: {pre: "<tt>", post: "</tt>"}
            }
          },{
            label: "code",
            action: {
              type: 'encapsulate', options: {pre: "<code>", post: "</code>"}
            }
          },{
            label: "nowiki",
            action: {
              type: 'encapsulate', options: {pre: "<nowiki>", post: "</nowiki>"}
            }
          },{
            label: "code nowiki code",
            action: {
              type: 'encapsulate', options: {pre: "<code><nowiki>", post: "</nowiki></code>"}
            }
          },{
            label: "comment",
            action: {
              type: 'encapsulate', options: {pre: "<!-- ", 'peri': 'comment:', post: " -->"}
            }
          },{
            label: "comment lt--gt",
            action: {
              type: 'encapsulate', options: {pre: "&lt;!-- ", 'peri': 'comment:', post: " -->"}
            }
          },{
            label: "span",
            action: {
              type: 'encapsulate', options: {pre: '<span style="">', post: '</span>'}
            }
          },{
            label: "span.plainlinks",
            action: {
              type: 'encapsulate', options: {pre: '<span class="plainlinks">', post: '</span>'}
            }
          },{
            label: "div",
            action: {
              type: 'encapsulate', options: {pre: '<div style="">', post: '</div>'}
            }
          },{
            label: "{{DEFAULTSORT:}}",
            action: {
              type: 'encapsulate', options: {pre: "{{DEFAULTSORT: ", post: "}}"}
            }
          },{
            label: "{{SORTIERUNG:}}",
            action: {
              type: 'encapsulate', options: {pre: "{{SORTIERUNG: ", post: "}}"}
            }
          },{
            'label': "div.definition-inline",
            'action': {
              'type': 'encapsulate','options': {'pre': '<div class="definition-inline">\n; ','post': ' : Erläuterung\n</div>'}
            }
          },{
            label: "{{#arraymap:}}",
            action: {
              type: 'encapsulate', options: {pre: "{{#arraymap: ", peri:  '{{{field|}}}', post: '|;|§|[[My property::§]] |&#32;•&#32;}}'}
            }
          },{
            label: "{{#arraymap:long}}",
            action: {
              type: 'encapsulate', options: {pre: "{{#arraymap: ", peri:  '{{{field|}}}', post: '<!-- values\n-->|;<!-- split on ;\n-->|§<!-- assign temporary variable\n-->|[[My property::§]] <!-- output\n-->|&#32;•&#32;<!-- new output separator\n-->}}'}
            }
          },{
            label: "if",
            action: {
              type: 'encapsulate', options: {pre: "{{#if: ", post: "| | }}"}
            }
          },{
            label: "if long",
            action: {
              type: 'encapsulate', options: {pre: "<!--\n-->{{#if: ", post: "<!--\nthen-->|<!--\nelse-->|<!--\n-->}}<!-- if end\n-->"}
            }
          },{
            label: "switch CONTENTLANGUAGE",
            action: {
              type: 'encapsulate', options: {pre: "{{#switch: {{CONTENTLANGUAGE}}", post: "<!--\n-->|de|de-formal= deutsch <!--\n-->| #default = english<!--\n-->}}<!-- switch end\n-->"}
            }
          },{
            label: "switch",
            action: {
              type: 'encapsulate', options: {pre: "{{#switch: ", post: "<!--\n-->| one | two = <!--\n-->| #default = <!--\n-->}}<!-- switch end\n-->"}
            }
          }, {
            label: "table",
            action: {
              type: 'encapsulate',
              options: {pre: '<table>',peri: '<!--\n--><tr><!--\n  --><td></td><!--\n--></tr><!--\n-->', post: '</table>'}
            }
          }, {
            label: "tr",
            action: {
              type: 'encapsulate',
              options: {pre: '<tr>',peri: '<!--\n  --><td></td><!--\n-->', post: '</tr>'}
            }
          }, {
            label: "th",
            action: {
              type: 'encapsulate',
              options: {pre: '<th>', post: '</th>'}
            }
          }, {
            label: "td",
            action: {
              type: 'encapsulate',
              options: {pre: '<td>', post: '</td>'}
            }
          },
          '┌',
          '┬',
          '┐',
          '└',
          '┴',
          '┘',
          '│',
          '─',
          '├',
          '┼',
          '┤'
          /*  <s></s>   <sup></sup>   <sub></sub>  */
          ]
        },
        'templates': {
          'layout': 'characters',
          label: 'Vorlagen',
          'characters': [{
            label: "Keyboard",
            action: {
              type: 'encapsulate', options: {pre: "{{Keyboard |", post: "}}"}
            }
          },{
            label: "Zitat",
            action: {
              type: 'encapsulate', options: {pre: '{{Zitat |', post: '}}'}
            }
          },{
            label: "Zitat versteckt",
            action: {
              type: 'encapsulate', options: {pre: '{{Zitat versteckt|', post: '}}'}
            }
          },{
            label: "{{gesperrt}}",
            action: {
              type: 'encapsulate', options: {pre: '{{gesperrt|', post: '}}'}
            }
          },{
            label: "{{SC}}",
            action: {
              type: 'encapsulate', options: {pre: '{{SC|', post: '}}'}
            }
          },{
            label: "nbsp;",
            action: {
              type: 'encapsulate',
              options: {pre: "&nbsp;", post: ""}
            }
          }, {
            label: "()",
            action: {
              type: 'encapsulate',
             options: {pre: "(", post: ")"}
            }
          }, {
            label: "[]",
            action: {
              type: 'encapsulate',
              options: {pre: "[", post: "]"}
              }
          }, {
            label: "[[]]",
            action: {
              type: 'encapsulate',
              options: {pre: "[[", post: "]]"}
            }
          }, {
            label: "{{}}",
            action: {
              type: 'encapsulate',
              options: {pre: "{{", post: "}}"}
            }
          }, {
            label: "{{{}}}",
            action: {
              type: 'encapsulate',
              options: {pre: "{{{", post: "}}}"}
            }
          }, {
            label: "{{{|}}}",
            action: {
              type: 'encapsulate',
              options: {pre: "{{{", post: "|}}}"}
            }
          }, {
            label: "noinclude",
            action: {
              type: 'encapsulate',
              options: {pre: "<noinclude>", post: "</noinclude>"}
            }
          }, {
            label: "includeonly",
            action: {
              type: 'encapsulate',
              options: {pre: "<includeonly>", post: "</includeonly>"}
            }
          }, {
            label: "onlyinclude",
            action: {
              type: 'encapsulate',
              options: {pre: "<onlyinclude>", post: "</onlyinclude>"}
            }
          }, {
            label: "nowiki",
            action: {
              type: 'encapsulate',
              options: {pre: "<nowiki>", post: "</nowiki>"}
            }
          }, {
            label: "comment",
            action: {
              type: 'encapsulate',
              options: {pre: "<!-- ", post: " -->"}
            }
          }, {
            label: "{{#arraymap:}} long",
            action: {
              type: 'encapsulate',
              options: {pre: "{{#arraymap: ", peri : '{{{field|}}}', post: "<!--\n-->|;<!-- sep\n-->|§<!-- assign temporary var\n-->|[[My property::§]] <!--output\n-->|&#32;•&#32;<!--output sep\n-->}}<!-- end arraymap \n-->"}
            }
          }, {
            label: "{{#arraymap:}}",
            action: {
              type: 'encapsulate',
              options: {pre: "{{#arraymap: ", peri : '{{{field|}}}', post: "|;|§|[[My property::§]] |&#32;•&#32;}}"}
            }
          }, {
            label: "{{#ask:table}}",
            action: {
              type: 'encapsulate',
              options: {pre: "{{#ask: ", peri : '[[PAGE]] [[property::+]]', post: " | ?displayprop |? | mainlabel=- | link=none | format = table | limit = 500}}"}
            }
          }, {
            label: "{{#ask:list}}",
            action: {
              type: 'encapsulate',
              options: {pre: "{{#ask: ", peri : '[[PAGE]] [[property::+]]', post: " | ?displayprop | mainlabel=- | link=none | format = list | sep=&#32;•&#32; | limit = 500}}"}
            }
          }, {
            label: "{{#vardefine:}}",
            action: {
              type: 'encapsulate',
              options: {pre: "{{#vardefine: ", peri : 'myVar', post: "| }}"}
            }
          }, {
            label: "{{#varexist:}}",
            action: {
              type: 'encapsulate',
              options: {pre: "{{#varexist: ", peri : 'myVar', post: "}}"}
            }
          }, {
            label: "{{#var:}}",
            action: {
              type: 'encapsulate',
              options: {pre: "{{#var: ", peri : 'myVar', post: "}}"}
            }
          }, {
            label: "if",
            action: {
              type: 'encapsulate',
              options: {pre: "{{#if: ", post: "| | }}"}
            }
          }, {
            label: "if long",
            action: {
              type: 'encapsulate',
              options: {pre: "<!--\n-->{{#if: ", post: "<!--\nthen-->|<!--\nelse-->|<!--\n-->}}<!-- end if\n-->"}
            }
          }, {
            label: "ifexist",
            action: {
              type: 'encapsulate',
              options: {pre: "{{#ifexist: ", post: "| | }}"}
            }
          }, {
            label: "ifexist long",
            action: {
              type: 'encapsulate',
              options: {pre: "<!--\n-->{{#ifexist: ", post: "<!--\nthen-->|<!--\nelse-->|<!--\n-->}}<!-- end ifexist\n-->"}
            }
          }, {
            label: "{{#expr:}}",
            action: {
              type: 'encapsulate',
              options: {pre: "{{#expr: ", peri : '1 + 6', post: "}}"}
            }
          }, {
            label: "switch",
            action: {
              type: 'encapsulate',
              options: {pre: "{{#switch: ", post: "<!--\n-->| one | two = <!--\n-->| #default = <!--\n-->}}<!-- end switch\n-->"}
            }
          }, {
            label: "{{DEFAULTSORT:}}",
            action: {
              type: 'encapsulate',
              options: {pre: "{{DEFAULTSORT:", post: "}}"}
            }
          }, {
            label: "{{DISPLAYTITLE:}}",
            action: {
              type: 'encapsulate',
              options: {pre: "{{DISPLAYTITLE:", post: "}}"}
            }
          },
          '{{PAGENAME}}',
          '{{PAGENAMEE}}',
          '{{FULLPAGENAME}}',
          '{{FULLPAGENAMEE}}'
          ]
        },
        'key_start': {
          'layout': 'characters',
          label: 'Key Start',
          'characters': [{
            label: "im_a",
            action: {
              type: 'encapsulate', options: {pre: "| image a =", post: "\n| caption a ="}
            }
          },{
            label: "im_b",
            action: {
              type: 'encapsulate', options: {pre: "| image b =", post: "\n| caption b ="}
            }
          },{
            label: "im_c",
            action: {
              type: 'encapsulate', options: {pre: "| image c =", post: "\n| caption c ="}
            }
          },{
            label: "im_d",
            action: {
              type: 'encapsulate', options: {pre: "| image d =", post: "\n| caption d ="}
            }
          },{
            label: "im_e",
            action: {
              type: 'encapsulate', options: {pre: "| image e =", post: "\n| caption e ="}
            }
          },{
            label: "im_j",
            action: {
              type: 'encapsulate', options: {pre: "| image j =", post: "\n| caption j ="}
            }
          },{
            label: "im_k",
            action: {
              type: 'encapsulate', options: {pre: "| image k =", post: "\n| caption k ="}
            }
          },{
            label: "im_m",
            action: {
              type: 'encapsulate', options: {pre: "| image m =", post: "\n| caption m ="}
            }
          },{
            label: "im_n",
            action: {
              type: 'encapsulate', options: {pre: "| image n =", post: "\n| caption n ="}
            }
          },{
            label: "im_o",
            action: {
              type: 'encapsulate', options: {pre: "| image o =", post: "\n| caption o ="}
            }
          },{
            label: "im_p",
            action: {
              type: 'encapsulate', options: {pre: "| image p =", post: "\n| caption p ="}
            }
          },{
            label: "im_q",
            action: {
              type: 'encapsulate', options: {pre: "| image q =", post: "\n| caption q ="}
            }
          },{
            label: "im_r",
            action: {
              type: 'encapsulate', options: {pre: "| image r =", post: "\n| caption r ="}
            }
          }
          ]
        }
      }
  });
}

/* Check if view is in edit mode and that the required modules are available. Then, customize the toolbar … */
if ( $.inArray( mw.config.get( 'wgAction' ), ['edit', 'submit'] ) !== -1 ) {
  mw.loader.using( 'user.options', function () {
    if ( mw.user.options.get('usebetatoolbar') ) {
      mw.loader.using( 'ext.wikiEditor.toolbar', function () {
        $(document).ready( customizeUserToolbarAndreasPlank );
      });
    }
  });
}

// </source>
// </pre>