|
|
Line 1: |
Line 1: |
| /* Any JavaScript here will be loaded for all users on every page load. */
| | window.onload=function(){ |
| | const toggleSwitch = document.querySelector('.theme-switch input[type="checkbox"]'); |
| | const currentTheme = localStorage.getItem('theme'); |
|
| |
|
| /* Any JavaScript here will be loaded for all users on every page load. */
| | if (currentTheme) { |
| | document.documentElement.setAttribute('data-theme', currentTheme); |
| | |
| | if (currentTheme === 'dark') { |
| | toggleSwitch.checked = true; |
| | } |
| | } |
|
| |
|
| var customizeToolbar = function() {
| | function switchTheme(e) { |
| | | if (e.target.checked) { |
| /* TEMPLATE SECTION */
| | document.documentElement.setAttribute('data-theme', 'dark'); |
| $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
| | localStorage.setItem('theme', 'dark'); |
| 'sections': {
| | } |
| 'templates': {
| | else { document.documentElement.setAttribute('data-theme', 'light'); |
| 'type': 'booklet', // Can also be 'booklet'
| | localStorage.setItem('theme', 'light'); |
| 'label': 'Templates'
| | } |
| // or 'labelMsg': 'section-emoticons-label' for a localized label
| | } |
| }
| |
| }
| |
| } );
| |
| /* TEMPLATE SECTION END */
| |
| | |
| /* TEMPLATE SECTION ENTRIES */
| |
| // Template:Category
| |
| $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
| |
| 'section': 'templates',
| |
| 'pages': {
| |
| 'category': {
| |
| 'layout': 'table',
| |
| 'label': 'Category',
| |
| 'headings': [
| |
| { text: 'Template' },
| |
| { text: 'Documentation' }
| |
| ],
| |
| 'rows': [
| |
| {
| |
| 'name': { html: '{{category|<b>nameofcategory</b>}}' },
| |
| 'doc': { html: 'In almost all situations the template will be used instead of [[Category:Name]] to avoid the main article along with its translations to be included under the same category.<br /><br />Attributes:<br /><b>langcat</b> - Value <b>yes</b> to create a separate category for each translation of an article (optional).<br /><b>dir</b> - Value <b>3</b> if an article translation resides in the third part of the directory e.g trans/smilies/<b>et</b> (optional).' }
| |
| }
| |
| ]
| |
| }
| |
| }
| |
| } );
| |
| | |
| // Template:Gallery
| |
| $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
| |
| 'section': 'templates',
| |
| 'pages': {
| |
| 'gallery': {
| |
| 'layout': 'table',
| |
| 'label': 'Gallery',
| |
| 'headings': [
| |
| { text: 'Template' },
| |
| { text: 'Documentation' }
| |
| ],
| |
| 'rows': [
| |
| {
| |
| 'name': { html: '{{Gallery<br />|<b>https://</b>|1d=<br />|<b>https://</b>|2d=<br />}}' },
| |
| 'doc': { html: 'Display a gallery of up to 10 images.<br /><br />Attributes:<br /><b>1d-10d</b> - Image descriptions (optional).<br /><b>width</b> - Width of each thumbnail in pixels (optional, defaults to 275).<br /><b>scalable</b> - Value <b>no</b> to prevent images from scaling.' }
| |
| }
| |
| ]
| |
| }
| |
| }
| |
| } );
| |
| | |
| // Template:Img
| |
| $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
| |
| 'section': 'templates',
| |
| 'pages': {
| |
| 'img': {
| |
| 'layout': 'table',
| |
| 'label': 'Img',
| |
| 'headings': [
| |
| { text: 'Template' },
| |
| { text: 'Documentation' }
| |
| ],
| |
| 'rows': [
| |
| {
| |
| 'name': { text: '{{img|image=|description=}}' },
| |
| 'doc': { html: 'Image thumbnails for external images.<br /><br />Attributes:<br /><b>image</b> - Direct link to an image you're going to use.<br /><b>width</b> - Sets the width of an image thumb in pixels, defaults to 275px and should be kept that way, unless the image is smaller than that.<br /><b>float</b> - Value <b>right</b> or <b>left</b>, defaults to right (optional).<br /><b>description</b> - Short description of the image.<br /><b>link</b> - Where the thumbnail links to, should not be set for regular thumbnails (optional).<br /><b>scalable</b> - Value no to prevent image from scaling.' }
| |
| }
| |
| ]
| |
| }
| |
| }
| |
| } );
| |
| | |
| // Template:Trans
| |
| $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
| |
| 'section': 'templates',
| |
| 'pages': {
| |
| 'trans': {
| |
| 'layout': 'table',
| |
| 'label': 'Translatable templates',
| |
| 'headings': [
| |
| { text: '' },
| |
| { text: '' }
| |
| ],
| |
| 'rows': [
| |
| {
| |
| 'name': { html: '<b>Various</b>' },
| |
| 'doc': { html: '' }
| |
| },
| |
| {
| |
| 'name': { text: '{{ {{tt|Trans/examples}} }}' },
| |
| 'doc': { html: ''== Examples =='' }
| |
| },
| |
| {
| |
| 'name': { text: '{{ {{tt|Trans/newin}} }}' },
| |
| 'doc': { html: ''New in'' }
| |
| },
| |
| {
| |
| 'name': { text: '{{ {{tt|Trans/pawns}} }}' },
| |
| 'doc': { html: ''Limited Pawns'' }
| |
| },
| |
| {
| |
| 'name': { text: '{{ {{tt|Trans/smilies}} }}' },
| |
| 'doc': { html: ''Smilies'' }
| |
| },
| |
| {
| |
| 'name': { text: '{{ {{tt|Trans/ts}} }}' },
| |
| 'doc': { html: ''themed smilies'' }
| |
| },
| |
| {
| |
| 'name': { text: '{{ {{tt|Trans/usage}} }}' },
| |
| 'doc': { html: ''== Usage =='' }
| |
| },
| |
| {
| |
| 'name': { html: '<b>Hug</b>' },
| |
| 'doc': { html: '' }
| |
| },
| |
| {
| |
| 'name': { text: '{{ {{tt|Trans/hug}} }}' },
| |
| 'doc': { html: '<i>Hug description.</i>' }
| |
| },
| |
| {
| |
| 'name': { text: '{{ {{tt|Trans/hugm}} }}' },
| |
| 'doc': { html: ''Your message here#optional color code'' }
| |
| },
| |
| {
| |
| 'name': { html: '<b>Jinx</b>' },
| |
| 'doc': { html: '' }
| |
| },
| |
| {
| |
| 'name': { text: '{{ {{tt|Trans/jinxallnote}} }}' },
| |
| 'doc': { html: '<i>How much it costs and how often can you send.</i>' }
| |
| },
| |
| {
| |
| 'name': { text: '{{ {{tt|Trans/jinxexamples}} }}' },
| |
| 'doc': { html: ''Examples'' }
| |
| },
| |
| {
| |
| 'name': { text: '{{ {{tt|Trans/jinxgcontrol}} }}' },
| |
| 'doc': { html: '<i>Configuring jinx using Gcontrol</i>' }
| |
| },
| |
| {
| |
| 'name': { text: '{{ {{tt|Trans/jinxnote1}} }}' },
| |
| 'doc': { html: '<i>Cannot jinx in main chat</i>' }
| |
| },
| |
| {
| |
| 'name': { text: '{{ {{tt|Trans/jinxprobability}} }}' },
| |
| 'doc': { html: ''probability%'' }
| |
| },
| |
| {
| |
| 'name': { text: '{{ {{tt|Trans/jinxtime}} }}' },
| |
| 'doc': { html: ''time in minutes'' }
| |
| },
| |
| {
| |
| 'name': { text: '{{ {{tt|Trans/jinxusage1}} }}' },
| |
| 'doc': { html: ''To jinx_name the user in private chat only'' }
| |
| },
| |
| {
| |
| 'name': { text: '{{ {{tt|Trans/jinxusage2}} }}' },
| |
| 'doc': { html: ''To jinx_name the user in main chat'' }
| |
| },
| |
| {
| |
| 'name': { text: '{{ {{tt|Trans/jinxusagenotes}} }}' },
| |
| 'doc': { html: '<i>Jinx usage notes</i>' }
| |
| },
| |
| {
| |
| 'name': { text: '{{ {{tt|Trans/unjinx}} }}' },
| |
| 'doc': { html: '<i>Info on unjinxing.</i>' }
| |
| },
| |
| {
| |
| 'name': { text: '{{ {{tt|Trans/unjinxmain}} }}' },
| |
| 'doc': { html: '<i>Info on how to unjinx in main chat.</i>' }
| |
| },
| |
| {
| |
| 'name': { text: '{{ {{tt|Trans/unjinxpc}} }}' },
| |
| 'doc': { html: '<i>Info on how to unjinx in private chat.' }
| |
| }
| |
| ]
| |
| }
| |
| }
| |
| } );
| |
| | |
| // Template:Shortcut
| |
| $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
| |
| 'section': 'templates',
| |
| 'pages': {
| |
| 'shortcut': {
| |
| 'layout': 'table',
| |
| 'label': 'Shortcut',
| |
| 'headings': [
| |
| { text: 'Template' },
| |
| { text: 'Documentation' }
| |
| ],
| |
| 'rows': [
| |
| {
| |
| 'name': { text: '{{shortcut}}' },
| |
| 'doc': { html: 'To display a xat.wiki short link with the same name as the article, all you need to do, is add <b>{{shortcut}}</b> on the very first line of an article. In case you find the name of an article too long and complicated you can create a redirect and define the redirect on an article, e.g <b>{{shortcut|og}}</b> for Owners_Guide, which has og redirecting to it.' }
| |
| }
| |
| ]
| |
| }
| |
| }
| |
| } );
| |
| /* TEMPLATE SECTION ENTRIES END */
| |
| | |
| /* TRANSLATE GROUP */
| |
| $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', {
| |
| 'section': 'main',
| |
| 'groups': {
| |
| 'translate': {
| |
| 'label': 'Translate' // or use labelMsg for a localized label, see above
| |
| }
| |
| }
| |
| } );
| |
| /* TRANSLATE GROUP END */
| |
| | |
| /* LANGUAGES BUTTON */
| |
| $('#wpTextbox1').wikiEditor('addToToolbar', {
| |
| section: 'main',
| |
| group: 'translate',
| |
| tools: {
| |
| "languages": {
| |
| label: 'Languages',
| |
| type: 'button',
| |
| icon: '//util.xat.com/wiki/images/2/29/Button_languages.png',
| |
| action: {
| |
| type: 'encapsulate',
| |
| options: {
| |
| pre: "<languages/>",
| |
| post: ""
| |
| }
| |
| }
| |
| }
| |
| }
| |
| });
| |
| /* LANGUAGES BUTTON END */
| |
| | |
| /* TRANSLATE BUTTON */
| |
| $('#wpTextbox1').wikiEditor('addToToolbar', {
| |
| section: 'main',
| |
| group: 'translate',
| |
| tools: {
| |
| "translate": {
| |
| label: 'Translate',
| |
| type: 'button',
| |
| icon: '//util.xat.com/wiki/images/5/5c/Button_translate.png',
| |
| action: {
| |
| type: 'encapsulate',
| |
| options: {
| |
| pre: "<translate>",
| |
| post: "</translate>"
| |
| }
| |
| }
| |
| }
| |
| }
| |
| });
| |
| /* TRANSLATE BUTTON END */
| |
| | |
| /* TRANS TEMPLATE BUTTON */
| |
| $('#wpTextbox1').wikiEditor('addToToolbar', {
| |
| section: 'main',
| |
| group: 'translate',
| |
| tools: {
| |
| "tt": {
| |
| label: 'Translatable template',
| |
| type: 'button',
| |
| icon: '//util.xat.com/wiki/images/f/f6/Button_tt.png',
| |
| action: {
| |
| type: 'encapsulate',
| |
| options: {
| |
| pre: "{{ {{tt|trans/",
| |
| post: "}} }}"
| |
| }
| |
| }
| |
| }
| |
| }
| |
| });
| |
| /* TRANS TEMPLATE BUTTON END */
| |
| | |
| /* TVAR BUTTON */
| |
| $('#wpTextbox1').wikiEditor('addToToolbar', {
| |
| section: 'main',
| |
| group: 'translate',
| |
| tools: {
| |
| "tvar": {
| |
| label: 'Variable',
| |
| type: 'button',
| |
| icon: '//util.xat.com/wiki/images/e/e4/Button_tvar.png',
| |
| action: {
| |
| type: 'encapsulate',
| |
| options: {
| |
| pre: "<tvar|1>",
| |
| post: "</>"
| |
| }
| |
| }
| |
| }
| |
| }
| |
| });
| |
| /* TVAR BUTTON END */
| |
| | |
| /* MYLANGUAGE BUTTON */
| |
| $('#wpTextbox1').wikiEditor('addToToolbar', {
| |
| section: 'main',
| |
| group: 'translate',
| |
| tools: {
| |
| "tvar": {
| |
| label: 'MyLanguage',
| |
| type: 'button',
| |
| icon: '//util.xat.com/wiki/images/8/84/Button_ml.png',
| |
| action: {
| |
| type: 'encapsulate',
| |
| options: {
| |
| pre: "[[<tvar|1>Special:MyLanguage/</>|",
| |
| post: "]]"
| |
| }
| |
| }
| |
| }
| |
| }
| |
| }); | |
| /* MYLANGUAGE BUTTON END */
| |
| | |
| /* REMOVED BUTTONS */
| |
| /* Remove Search & Replace */
| |
| $( '#wpTextbox1' ).wikiEditor( 'removeFromToolbar', {
| |
| 'section': 'main',
| |
| 'group': 'insert',
| |
| 'tool': 'file'
| |
| });
| |
| | |
| $( '#wpTextbox1' ).wikiEditor( 'removeFromToolbar', {
| |
| 'section': 'main',
| |
| 'group': 'insert',
| |
| 'tool': 'reference'
| |
| });
| |
| /* REMOVED BUTTONS END */
| |
| | |
| };
| |
|
| |
|
| /* TOOLBAR CONFIG */
| | toggleSwitch.addEventListener('change', switchTheme, false); |
| /* 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 () {
| |
| // This can be the string "0" if the user disabled the preference ([[phab:T54542#555387]])
| |
| if ( mw.user.options.get( 'usebetatoolbar' ) == 1 ) {
| |
| $.when(
| |
| mw.loader.using( 'ext.wikiEditor.toolbar' ), $.ready
| |
| ).then( customizeToolbar );
| |
| }
| |
| } );
| |
| } | | } |
| // Add the customizations to LiquidThreads' edit toolbar, if available
| |
| mw.hook( 'ext.lqt.textareaCreated' ).add( customizeToolbar );
| |
| /* TOOLBAR CONFIG END */
| |