Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/wp-conte.../plugins/wp-file-.../lib/codemirr.../mode/django
File: django.js
// CodeMirror, copyright (c) by Marijn Haverbeke and others
[0] Fix | Delete
// Distributed under an MIT license: http://codemirror.net/LICENSE
[1] Fix | Delete
[2] Fix | Delete
(function(mod) {
[3] Fix | Delete
if (typeof exports == "object" && typeof module == "object") // CommonJS
[4] Fix | Delete
mod(require("../../lib/codemirror"), require("../htmlmixed/htmlmixed"),
[5] Fix | Delete
require("../../addon/mode/overlay"));
[6] Fix | Delete
else if (typeof define == "function" && define.amd) // AMD
[7] Fix | Delete
define(["../../lib/codemirror", "../htmlmixed/htmlmixed",
[8] Fix | Delete
"../../addon/mode/overlay"], mod);
[9] Fix | Delete
else // Plain browser env
[10] Fix | Delete
mod(CodeMirror);
[11] Fix | Delete
})(function(CodeMirror) {
[12] Fix | Delete
"use strict";
[13] Fix | Delete
[14] Fix | Delete
CodeMirror.defineMode("django:inner", function() {
[15] Fix | Delete
var keywords = ["block", "endblock", "for", "endfor", "true", "false", "filter", "endfilter",
[16] Fix | Delete
"loop", "none", "self", "super", "if", "elif", "endif", "as", "else", "import",
[17] Fix | Delete
"with", "endwith", "without", "context", "ifequal", "endifequal", "ifnotequal",
[18] Fix | Delete
"endifnotequal", "extends", "include", "load", "comment", "endcomment",
[19] Fix | Delete
"empty", "url", "static", "trans", "blocktrans", "endblocktrans", "now",
[20] Fix | Delete
"regroup", "lorem", "ifchanged", "endifchanged", "firstof", "debug", "cycle",
[21] Fix | Delete
"csrf_token", "autoescape", "endautoescape", "spaceless", "endspaceless",
[22] Fix | Delete
"ssi", "templatetag", "verbatim", "endverbatim", "widthratio"],
[23] Fix | Delete
filters = ["add", "addslashes", "capfirst", "center", "cut", "date",
[24] Fix | Delete
"default", "default_if_none", "dictsort",
[25] Fix | Delete
"dictsortreversed", "divisibleby", "escape", "escapejs",
[26] Fix | Delete
"filesizeformat", "first", "floatformat", "force_escape",
[27] Fix | Delete
"get_digit", "iriencode", "join", "last", "length",
[28] Fix | Delete
"length_is", "linebreaks", "linebreaksbr", "linenumbers",
[29] Fix | Delete
"ljust", "lower", "make_list", "phone2numeric", "pluralize",
[30] Fix | Delete
"pprint", "random", "removetags", "rjust", "safe",
[31] Fix | Delete
"safeseq", "slice", "slugify", "stringformat", "striptags",
[32] Fix | Delete
"time", "timesince", "timeuntil", "title", "truncatechars",
[33] Fix | Delete
"truncatechars_html", "truncatewords", "truncatewords_html",
[34] Fix | Delete
"unordered_list", "upper", "urlencode", "urlize",
[35] Fix | Delete
"urlizetrunc", "wordcount", "wordwrap", "yesno"],
[36] Fix | Delete
operators = ["==", "!=", "<", ">", "<=", ">="],
[37] Fix | Delete
wordOperators = ["in", "not", "or", "and"];
[38] Fix | Delete
[39] Fix | Delete
keywords = new RegExp("^\\b(" + keywords.join("|") + ")\\b");
[40] Fix | Delete
filters = new RegExp("^\\b(" + filters.join("|") + ")\\b");
[41] Fix | Delete
operators = new RegExp("^\\b(" + operators.join("|") + ")\\b");
[42] Fix | Delete
wordOperators = new RegExp("^\\b(" + wordOperators.join("|") + ")\\b");
[43] Fix | Delete
[44] Fix | Delete
// We have to return "null" instead of null, in order to avoid string
[45] Fix | Delete
// styling as the default, when using Django templates inside HTML
[46] Fix | Delete
// element attributes
[47] Fix | Delete
function tokenBase (stream, state) {
[48] Fix | Delete
// Attempt to identify a variable, template or comment tag respectively
[49] Fix | Delete
if (stream.match("{{")) {
[50] Fix | Delete
state.tokenize = inVariable;
[51] Fix | Delete
return "tag";
[52] Fix | Delete
} else if (stream.match("{%")) {
[53] Fix | Delete
state.tokenize = inTag;
[54] Fix | Delete
return "tag";
[55] Fix | Delete
} else if (stream.match("{#")) {
[56] Fix | Delete
state.tokenize = inComment;
[57] Fix | Delete
return "comment";
[58] Fix | Delete
}
[59] Fix | Delete
[60] Fix | Delete
// Ignore completely any stream series that do not match the
[61] Fix | Delete
// Django template opening tags.
[62] Fix | Delete
while (stream.next() != null && !stream.match(/\{[{%#]/, false)) {}
[63] Fix | Delete
return null;
[64] Fix | Delete
}
[65] Fix | Delete
[66] Fix | Delete
// A string can be included in either single or double quotes (this is
[67] Fix | Delete
// the delimiter). Mark everything as a string until the start delimiter
[68] Fix | Delete
// occurs again.
[69] Fix | Delete
function inString (delimiter, previousTokenizer) {
[70] Fix | Delete
return function (stream, state) {
[71] Fix | Delete
if (!state.escapeNext && stream.eat(delimiter)) {
[72] Fix | Delete
state.tokenize = previousTokenizer;
[73] Fix | Delete
} else {
[74] Fix | Delete
if (state.escapeNext) {
[75] Fix | Delete
state.escapeNext = false;
[76] Fix | Delete
}
[77] Fix | Delete
[78] Fix | Delete
var ch = stream.next();
[79] Fix | Delete
[80] Fix | Delete
// Take into account the backslash for escaping characters, such as
[81] Fix | Delete
// the string delimiter.
[82] Fix | Delete
if (ch == "\\") {
[83] Fix | Delete
state.escapeNext = true;
[84] Fix | Delete
}
[85] Fix | Delete
}
[86] Fix | Delete
[87] Fix | Delete
return "string";
[88] Fix | Delete
};
[89] Fix | Delete
}
[90] Fix | Delete
[91] Fix | Delete
// Apply Django template variable syntax highlighting
[92] Fix | Delete
function inVariable (stream, state) {
[93] Fix | Delete
// Attempt to match a dot that precedes a property
[94] Fix | Delete
if (state.waitDot) {
[95] Fix | Delete
state.waitDot = false;
[96] Fix | Delete
[97] Fix | Delete
if (stream.peek() != ".") {
[98] Fix | Delete
return "null";
[99] Fix | Delete
}
[100] Fix | Delete
[101] Fix | Delete
// Dot followed by a non-word character should be considered an error.
[102] Fix | Delete
if (stream.match(/\.\W+/)) {
[103] Fix | Delete
return "error";
[104] Fix | Delete
} else if (stream.eat(".")) {
[105] Fix | Delete
state.waitProperty = true;
[106] Fix | Delete
return "null";
[107] Fix | Delete
} else {
[108] Fix | Delete
throw Error ("Unexpected error while waiting for property.");
[109] Fix | Delete
}
[110] Fix | Delete
}
[111] Fix | Delete
[112] Fix | Delete
// Attempt to match a pipe that precedes a filter
[113] Fix | Delete
if (state.waitPipe) {
[114] Fix | Delete
state.waitPipe = false;
[115] Fix | Delete
[116] Fix | Delete
if (stream.peek() != "|") {
[117] Fix | Delete
return "null";
[118] Fix | Delete
}
[119] Fix | Delete
[120] Fix | Delete
// Pipe followed by a non-word character should be considered an error.
[121] Fix | Delete
if (stream.match(/\.\W+/)) {
[122] Fix | Delete
return "error";
[123] Fix | Delete
} else if (stream.eat("|")) {
[124] Fix | Delete
state.waitFilter = true;
[125] Fix | Delete
return "null";
[126] Fix | Delete
} else {
[127] Fix | Delete
throw Error ("Unexpected error while waiting for filter.");
[128] Fix | Delete
}
[129] Fix | Delete
}
[130] Fix | Delete
[131] Fix | Delete
// Highlight properties
[132] Fix | Delete
if (state.waitProperty) {
[133] Fix | Delete
state.waitProperty = false;
[134] Fix | Delete
if (stream.match(/\b(\w+)\b/)) {
[135] Fix | Delete
state.waitDot = true; // A property can be followed by another property
[136] Fix | Delete
state.waitPipe = true; // A property can be followed by a filter
[137] Fix | Delete
return "property";
[138] Fix | Delete
}
[139] Fix | Delete
}
[140] Fix | Delete
[141] Fix | Delete
// Highlight filters
[142] Fix | Delete
if (state.waitFilter) {
[143] Fix | Delete
state.waitFilter = false;
[144] Fix | Delete
if (stream.match(filters)) {
[145] Fix | Delete
return "variable-2";
[146] Fix | Delete
}
[147] Fix | Delete
}
[148] Fix | Delete
[149] Fix | Delete
// Ignore all white spaces
[150] Fix | Delete
if (stream.eatSpace()) {
[151] Fix | Delete
state.waitProperty = false;
[152] Fix | Delete
return "null";
[153] Fix | Delete
}
[154] Fix | Delete
[155] Fix | Delete
// Identify numbers
[156] Fix | Delete
if (stream.match(/\b\d+(\.\d+)?\b/)) {
[157] Fix | Delete
return "number";
[158] Fix | Delete
}
[159] Fix | Delete
[160] Fix | Delete
// Identify strings
[161] Fix | Delete
if (stream.match("'")) {
[162] Fix | Delete
state.tokenize = inString("'", state.tokenize);
[163] Fix | Delete
return "string";
[164] Fix | Delete
} else if (stream.match('"')) {
[165] Fix | Delete
state.tokenize = inString('"', state.tokenize);
[166] Fix | Delete
return "string";
[167] Fix | Delete
}
[168] Fix | Delete
[169] Fix | Delete
// Attempt to find the variable
[170] Fix | Delete
if (stream.match(/\b(\w+)\b/) && !state.foundVariable) {
[171] Fix | Delete
state.waitDot = true;
[172] Fix | Delete
state.waitPipe = true; // A property can be followed by a filter
[173] Fix | Delete
return "variable";
[174] Fix | Delete
}
[175] Fix | Delete
[176] Fix | Delete
// If found closing tag reset
[177] Fix | Delete
if (stream.match("}}")) {
[178] Fix | Delete
state.waitProperty = null;
[179] Fix | Delete
state.waitFilter = null;
[180] Fix | Delete
state.waitDot = null;
[181] Fix | Delete
state.waitPipe = null;
[182] Fix | Delete
state.tokenize = tokenBase;
[183] Fix | Delete
return "tag";
[184] Fix | Delete
}
[185] Fix | Delete
[186] Fix | Delete
// If nothing was found, advance to the next character
[187] Fix | Delete
stream.next();
[188] Fix | Delete
return "null";
[189] Fix | Delete
}
[190] Fix | Delete
[191] Fix | Delete
function inTag (stream, state) {
[192] Fix | Delete
// Attempt to match a dot that precedes a property
[193] Fix | Delete
if (state.waitDot) {
[194] Fix | Delete
state.waitDot = false;
[195] Fix | Delete
[196] Fix | Delete
if (stream.peek() != ".") {
[197] Fix | Delete
return "null";
[198] Fix | Delete
}
[199] Fix | Delete
[200] Fix | Delete
// Dot followed by a non-word character should be considered an error.
[201] Fix | Delete
if (stream.match(/\.\W+/)) {
[202] Fix | Delete
return "error";
[203] Fix | Delete
} else if (stream.eat(".")) {
[204] Fix | Delete
state.waitProperty = true;
[205] Fix | Delete
return "null";
[206] Fix | Delete
} else {
[207] Fix | Delete
throw Error ("Unexpected error while waiting for property.");
[208] Fix | Delete
}
[209] Fix | Delete
}
[210] Fix | Delete
[211] Fix | Delete
// Attempt to match a pipe that precedes a filter
[212] Fix | Delete
if (state.waitPipe) {
[213] Fix | Delete
state.waitPipe = false;
[214] Fix | Delete
[215] Fix | Delete
if (stream.peek() != "|") {
[216] Fix | Delete
return "null";
[217] Fix | Delete
}
[218] Fix | Delete
[219] Fix | Delete
// Pipe followed by a non-word character should be considered an error.
[220] Fix | Delete
if (stream.match(/\.\W+/)) {
[221] Fix | Delete
return "error";
[222] Fix | Delete
} else if (stream.eat("|")) {
[223] Fix | Delete
state.waitFilter = true;
[224] Fix | Delete
return "null";
[225] Fix | Delete
} else {
[226] Fix | Delete
throw Error ("Unexpected error while waiting for filter.");
[227] Fix | Delete
}
[228] Fix | Delete
}
[229] Fix | Delete
[230] Fix | Delete
// Highlight properties
[231] Fix | Delete
if (state.waitProperty) {
[232] Fix | Delete
state.waitProperty = false;
[233] Fix | Delete
if (stream.match(/\b(\w+)\b/)) {
[234] Fix | Delete
state.waitDot = true; // A property can be followed by another property
[235] Fix | Delete
state.waitPipe = true; // A property can be followed by a filter
[236] Fix | Delete
return "property";
[237] Fix | Delete
}
[238] Fix | Delete
}
[239] Fix | Delete
[240] Fix | Delete
// Highlight filters
[241] Fix | Delete
if (state.waitFilter) {
[242] Fix | Delete
state.waitFilter = false;
[243] Fix | Delete
if (stream.match(filters)) {
[244] Fix | Delete
return "variable-2";
[245] Fix | Delete
}
[246] Fix | Delete
}
[247] Fix | Delete
[248] Fix | Delete
// Ignore all white spaces
[249] Fix | Delete
if (stream.eatSpace()) {
[250] Fix | Delete
state.waitProperty = false;
[251] Fix | Delete
return "null";
[252] Fix | Delete
}
[253] Fix | Delete
[254] Fix | Delete
// Identify numbers
[255] Fix | Delete
if (stream.match(/\b\d+(\.\d+)?\b/)) {
[256] Fix | Delete
return "number";
[257] Fix | Delete
}
[258] Fix | Delete
[259] Fix | Delete
// Identify strings
[260] Fix | Delete
if (stream.match("'")) {
[261] Fix | Delete
state.tokenize = inString("'", state.tokenize);
[262] Fix | Delete
return "string";
[263] Fix | Delete
} else if (stream.match('"')) {
[264] Fix | Delete
state.tokenize = inString('"', state.tokenize);
[265] Fix | Delete
return "string";
[266] Fix | Delete
}
[267] Fix | Delete
[268] Fix | Delete
// Attempt to match an operator
[269] Fix | Delete
if (stream.match(operators)) {
[270] Fix | Delete
return "operator";
[271] Fix | Delete
}
[272] Fix | Delete
[273] Fix | Delete
// Attempt to match a word operator
[274] Fix | Delete
if (stream.match(wordOperators)) {
[275] Fix | Delete
return "keyword";
[276] Fix | Delete
}
[277] Fix | Delete
[278] Fix | Delete
// Attempt to match a keyword
[279] Fix | Delete
var keywordMatch = stream.match(keywords);
[280] Fix | Delete
if (keywordMatch) {
[281] Fix | Delete
if (keywordMatch[0] == "comment") {
[282] Fix | Delete
state.blockCommentTag = true;
[283] Fix | Delete
}
[284] Fix | Delete
return "keyword";
[285] Fix | Delete
}
[286] Fix | Delete
[287] Fix | Delete
// Attempt to match a variable
[288] Fix | Delete
if (stream.match(/\b(\w+)\b/)) {
[289] Fix | Delete
state.waitDot = true;
[290] Fix | Delete
state.waitPipe = true; // A property can be followed by a filter
[291] Fix | Delete
return "variable";
[292] Fix | Delete
}
[293] Fix | Delete
[294] Fix | Delete
// If found closing tag reset
[295] Fix | Delete
if (stream.match("%}")) {
[296] Fix | Delete
state.waitProperty = null;
[297] Fix | Delete
state.waitFilter = null;
[298] Fix | Delete
state.waitDot = null;
[299] Fix | Delete
state.waitPipe = null;
[300] Fix | Delete
// If the tag that closes is a block comment tag, we want to mark the
[301] Fix | Delete
// following code as comment, until the tag closes.
[302] Fix | Delete
if (state.blockCommentTag) {
[303] Fix | Delete
state.blockCommentTag = false; // Release the "lock"
[304] Fix | Delete
state.tokenize = inBlockComment;
[305] Fix | Delete
} else {
[306] Fix | Delete
state.tokenize = tokenBase;
[307] Fix | Delete
}
[308] Fix | Delete
return "tag";
[309] Fix | Delete
}
[310] Fix | Delete
[311] Fix | Delete
// If nothing was found, advance to the next character
[312] Fix | Delete
stream.next();
[313] Fix | Delete
return "null";
[314] Fix | Delete
}
[315] Fix | Delete
[316] Fix | Delete
// Mark everything as comment inside the tag and the tag itself.
[317] Fix | Delete
function inComment (stream, state) {
[318] Fix | Delete
if (stream.match(/^.*?#\}/)) state.tokenize = tokenBase
[319] Fix | Delete
else stream.skipToEnd()
[320] Fix | Delete
return "comment";
[321] Fix | Delete
}
[322] Fix | Delete
[323] Fix | Delete
// Mark everything as a comment until the `blockcomment` tag closes.
[324] Fix | Delete
function inBlockComment (stream, state) {
[325] Fix | Delete
if (stream.match(/\{%\s*endcomment\s*%\}/, false)) {
[326] Fix | Delete
state.tokenize = inTag;
[327] Fix | Delete
stream.match("{%");
[328] Fix | Delete
return "tag";
[329] Fix | Delete
} else {
[330] Fix | Delete
stream.next();
[331] Fix | Delete
return "comment";
[332] Fix | Delete
}
[333] Fix | Delete
}
[334] Fix | Delete
[335] Fix | Delete
return {
[336] Fix | Delete
startState: function () {
[337] Fix | Delete
return {tokenize: tokenBase};
[338] Fix | Delete
},
[339] Fix | Delete
token: function (stream, state) {
[340] Fix | Delete
return state.tokenize(stream, state);
[341] Fix | Delete
},
[342] Fix | Delete
blockCommentStart: "{% comment %}",
[343] Fix | Delete
blockCommentEnd: "{% endcomment %}"
[344] Fix | Delete
};
[345] Fix | Delete
});
[346] Fix | Delete
[347] Fix | Delete
CodeMirror.defineMode("django", function(config) {
[348] Fix | Delete
var htmlBase = CodeMirror.getMode(config, "text/html");
[349] Fix | Delete
var djangoInner = CodeMirror.getMode(config, "django:inner");
[350] Fix | Delete
return CodeMirror.overlayMode(htmlBase, djangoInner);
[351] Fix | Delete
});
[352] Fix | Delete
[353] Fix | Delete
CodeMirror.defineMIME("text/x-django", "django");
[354] Fix | Delete
});
[355] Fix | Delete
[356] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function