mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/CodeMirror
synced 2024-11-27 15:40:00 +00:00
fix js code for passing jshint (v 1.1.1)
Bug: 69869 Change-Id: I1b058ea1dc6c5c3e10ff2de39f03ddd72207e57e
This commit is contained in:
parent
1a05b6c9d2
commit
bdb653d94e
2
.jshintignore
Normal file
2
.jshintignore
Normal file
|
@ -0,0 +1,2 @@
|
|||
# upstream libs
|
||||
resources/lib/
|
|
@ -15,7 +15,7 @@ if ( !defined( 'MEDIAWIKI' ) ) {
|
|||
die( 'This file is an extension to MediaWiki and thus not a valid entry point.' );
|
||||
}
|
||||
|
||||
const CODEMIRROR_VERSION = '1.1.0';
|
||||
const CODEMIRROR_VERSION = '1.1.1';
|
||||
|
||||
// Register this extension on Special:Version
|
||||
$wgExtensionCredits['parserhook'][] = array(
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
$( document ).ready( function () {
|
||||
var myCodeMirror = CodeMirror.fromTextArea(document.getElementById("wpTextbox1"), {
|
||||
/*global CodeMirror*/
|
||||
jQuery( document ).ready( function ( $ ) {
|
||||
CodeMirror.fromTextArea( $( '#wpTextbox1' )[0], {
|
||||
styleActiveLine: true,
|
||||
//lineNumbers: true,
|
||||
lineWrapping: true,
|
||||
|
@ -7,6 +8,6 @@ $( document ).ready( function () {
|
|||
//indentWithTabs: true
|
||||
//matchBrackets: true,
|
||||
//autoCloseBrackets: true,
|
||||
mode: "text/mediawiki"
|
||||
mode: 'text/mediawiki'
|
||||
} );
|
||||
} );
|
||||
|
|
|
@ -1,88 +1,87 @@
|
|||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
/*global CodeMirror, define, require */
|
||||
(function( mod ) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"), require("../htmlmixed/htmlmixed"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror", "../htmlmixed/htmlmixed"], mod);
|
||||
else // Plain browser env
|
||||
if ( typeof exports === 'object' && typeof module === 'object' ) { // CommonJS
|
||||
mod( require( '../../lib/codemirror' ), require( '../htmlmixed/htmlmixed' ) );
|
||||
} else if ( typeof define === 'function' && define.amd ) { // AMD
|
||||
define( ['../../lib/codemirror', '../htmlmixed/htmlmixed'], mod );
|
||||
} else { // Plain browser env
|
||||
mod( CodeMirror );
|
||||
}
|
||||
})(function( CodeMirror ) {
|
||||
"use strict";
|
||||
'use strict';
|
||||
|
||||
CodeMirror.defineMode("mediawiki", function(config, parserConfig) {
|
||||
CodeMirror.defineMode('mediawiki', function( /*config, parserConfig*/ ) {
|
||||
function inTemplatePageName( stream, state ) { // {{
|
||||
if (stream.eat("#")) {
|
||||
if ( stream.eat( '#' ) ) {
|
||||
state.tokenize = inParserFunctionName;
|
||||
return "strong";
|
||||
return 'strong';
|
||||
}
|
||||
stream.eatWhile( /[^\|\}\s]/ );
|
||||
state.tokenize = inTemplateArgumentSeparator;
|
||||
return "link";
|
||||
return 'link';
|
||||
}
|
||||
|
||||
function inTemplateArgumentSeparator( stream, state ) { // {{ Page name |
|
||||
if ( stream.eatSpace() && !stream.eol() ) {
|
||||
var peek = stream.peek();
|
||||
if ( peek !== "|" && peek != "}" ) {
|
||||
if ( peek !== '|' && peek !== '}' ) {
|
||||
state.tokenize = inTemplatePageName;
|
||||
return "link";
|
||||
return 'link';
|
||||
}
|
||||
}
|
||||
if (stream.eat("|")) {
|
||||
if ( stream.eat( '|' ) ) {
|
||||
state.tokenize = inTemplateArgument;
|
||||
return "tag strong";
|
||||
return 'tag strong';
|
||||
}
|
||||
if (stream.eat("}")) {
|
||||
if (stream.eat("}")) {
|
||||
if ( stream.eat( '}' ) ) {
|
||||
if ( stream.eat( '}' ) ) {
|
||||
state.tokenize = inWikitext;
|
||||
return "tag bracket";
|
||||
return 'tag bracket';
|
||||
}
|
||||
}
|
||||
if ( stream.eol() ) {
|
||||
return null;
|
||||
}
|
||||
stream.next();
|
||||
return "error";
|
||||
return 'error';
|
||||
}
|
||||
|
||||
function inTemplateArgument( stream, state ) { // {{ Page name |
|
||||
stream.eatWhile( /[^\|}]/ );
|
||||
state.tokenize = inTemplateArgumentSeparator;
|
||||
return "string";
|
||||
return 'string';
|
||||
}
|
||||
|
||||
function inParserFunctionName( stream, state ) { // {{#
|
||||
if ( stream.eatWhile( /\w/ ) ) {
|
||||
if (stream.peek() === ":") {
|
||||
if ( stream.peek() === ':' ) {
|
||||
state.tokenize = inParserFunctionArgumentSeparator;
|
||||
return "keyword strong";
|
||||
return 'keyword strong';
|
||||
}
|
||||
}
|
||||
state.tokenize = inWikitext;
|
||||
return "error";
|
||||
return 'error';
|
||||
}
|
||||
|
||||
function inParserFunctionArgumentSeparator( stream, state ) { // {{ Page name |
|
||||
if ( stream.eat( /[|:]/ ) ) {
|
||||
state.tokenize = inParserFunctionArgument;
|
||||
return "tag strong";
|
||||
return 'tag strong';
|
||||
}
|
||||
if (stream.eat("}")) {
|
||||
if (stream.eat("}")) {
|
||||
if ( stream.eat( '}' ) ) {
|
||||
if ( stream.eat( '}' ) ) {
|
||||
state.tokenize = inWikitext;
|
||||
return "tag bracket";
|
||||
return 'tag bracket';
|
||||
}
|
||||
}
|
||||
stream.next();
|
||||
return "string";
|
||||
return 'string';
|
||||
}
|
||||
|
||||
function inParserFunctionArgument( stream, state ) { // {{#
|
||||
stream.eatWhile( /[^|}]/ );
|
||||
state.tokenize = inParserFunctionArgumentSeparator;
|
||||
return "string";
|
||||
return 'string';
|
||||
}
|
||||
|
||||
function inWikitext( stream, state ) {
|
||||
|
@ -96,29 +95,29 @@ CodeMirror.defineMode("mediawiki", function(config, parserConfig) {
|
|||
}
|
||||
|
||||
switch ( ch ) {
|
||||
case "{":
|
||||
if (stream.eat("{")) { // Templates
|
||||
case '{':
|
||||
if ( stream.eat( '{' ) ) { // Templates
|
||||
state.tokenize = inTemplatePageName;
|
||||
stream.eatSpace();
|
||||
return "tag bracket";
|
||||
return 'tag bracket';
|
||||
}
|
||||
break;
|
||||
case "'":
|
||||
if (stream.match("''")) {
|
||||
case '\'':
|
||||
if ( stream.match( '\'\'' ) ) {
|
||||
state.isBold = ( state.isBold ? false : true );
|
||||
} else if (stream.match("'")) {
|
||||
} else if ( stream.match( '\'' ) ) {
|
||||
state.isItalic = ( state.isItalic ? false : true );
|
||||
}
|
||||
break;
|
||||
}
|
||||
if ( state.isBold ) {
|
||||
style.push("strong");
|
||||
style.push( 'strong' );
|
||||
}
|
||||
if ( state.isItalic ) {
|
||||
style.push("em");
|
||||
style.push( 'em' );
|
||||
}
|
||||
if ( style.length > 0 ) {
|
||||
return style.join(" ");
|
||||
return style.join(' ');
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -133,6 +132,6 @@ CodeMirror.defineMode("mediawiki", function(config, parserConfig) {
|
|||
};
|
||||
});
|
||||
|
||||
CodeMirror.defineMIME("text/mediawiki", "mediawiki");
|
||||
CodeMirror.defineMIME( 'text/mediawiki', 'mediawiki' );
|
||||
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue