update
This commit is contained in:
+7
File diff suppressed because one or more lines are too long
@@ -0,0 +1,119 @@
|
||||
$(function () {
|
||||
$('select').change(beautify);
|
||||
});
|
||||
var the = {
|
||||
use_codemirror: (!window.location.href.match(/without-codemirror/)),
|
||||
beautify_in_progress: false,
|
||||
editor: null // codemirror editor
|
||||
};
|
||||
|
||||
function run_tests() {
|
||||
var st = new SanityTest();
|
||||
run_beautifier_tests(st, Urlencoded, js_beautify, html_beautify, css_beautify);
|
||||
JavascriptObfuscator.run_tests(st);
|
||||
P_A_C_K_E_R.run_tests(st);
|
||||
Urlencoded.run_tests(st);
|
||||
MyObfuscate.run_tests(st);
|
||||
var results = st.results_raw()
|
||||
.replace(/&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/ /g, ' ')
|
||||
.replace(/\r/g, '·')
|
||||
.replace(/\n/g, '<br>');
|
||||
$('#testresults').html(results).show();
|
||||
}
|
||||
|
||||
|
||||
function any(a, b) {
|
||||
return a || b;
|
||||
}
|
||||
function unpacker_filter(source) {
|
||||
var trailing_comments = '',
|
||||
comment = '',
|
||||
unpacked = '',
|
||||
found = false;
|
||||
|
||||
// cut trailing comments
|
||||
do {
|
||||
found = false;
|
||||
if (/^\s*\/\*/.test(source)) {
|
||||
found = true;
|
||||
comment = source.substr(0, source.indexOf('*/') + 2);
|
||||
source = source.substr(comment.length).replace(/^\s+/, '');
|
||||
trailing_comments += comment + "\n";
|
||||
} else if (/^\s*\/\//.test(source)) {
|
||||
found = true;
|
||||
comment = source.match(/^\s*\/\/.*/)[0];
|
||||
source = source.substr(comment.length).replace(/^\s+/, '');
|
||||
trailing_comments += comment + "\n";
|
||||
}
|
||||
} while (found);
|
||||
|
||||
var unpackers = [P_A_C_K_E_R, Urlencoded, /*JavascriptObfuscator,*/MyObfuscate];
|
||||
for (var i = 0; i < unpackers.length; i++) {
|
||||
if (unpackers[i].detect(source)) {
|
||||
unpacked = unpackers[i].unpack(source);
|
||||
if (unpacked != source) {
|
||||
source = unpacker_filter(unpacked);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return trailing_comments + source;
|
||||
}
|
||||
|
||||
|
||||
function beautify() {
|
||||
if (the.beautify_in_progress) return;
|
||||
|
||||
the.beautify_in_progress = true;
|
||||
|
||||
var source = the.editor ? the.editor.getValue() : $('#code').val(),
|
||||
output,
|
||||
opts = {};
|
||||
|
||||
opts.indent_size = $('#tabsize').val();
|
||||
opts.indent_char = opts.indent_size == 1 ? '\t' : ' ';
|
||||
opts.max_preserve_newlines = $('#max-preserve-newlines').val();
|
||||
opts.preserve_newlines = opts.max_preserve_newlines !== "-1";
|
||||
opts.keep_array_indentation = false;
|
||||
opts.break_chained_methods = false;
|
||||
opts.indent_scripts = "keep";
|
||||
opts.brace_style = $('#brace-style').val();
|
||||
opts.space_before_conditional = false;
|
||||
opts.unescape_strings = false;
|
||||
opts.jslint_happy = false;
|
||||
opts.end_with_newline = false;
|
||||
opts.wrap_line_length = $('#wrap-line-length').val();
|
||||
|
||||
if (looks_like_html(source)) {
|
||||
output = html_beautify(source, opts);
|
||||
} else if (the.editor.options.mode == 'css') {
|
||||
output = css_beautify(source);
|
||||
} else {
|
||||
if ($('#detect-packers').prop('checked')) {
|
||||
source = unpacker_filter(source);
|
||||
}
|
||||
output = js_beautify(source, opts);
|
||||
}
|
||||
if (the.editor) {
|
||||
the.editor.setValue(output);
|
||||
} else {
|
||||
$('#code').val(output);
|
||||
}
|
||||
|
||||
the.beautify_in_progress = false;
|
||||
}
|
||||
|
||||
function looks_like_html(source) {
|
||||
|
||||
var trimmed = source.replace(/^[ \t\n\r]+/, '');
|
||||
var comment_mark = '<' + '!-' + '-';
|
||||
return (trimmed && (trimmed.substring(0, 1) === '<' && trimmed.substring(0, 4) !== comment_mark));
|
||||
}
|
||||
|
||||
function Clean() {
|
||||
$('#code').val("");
|
||||
the.editor.setValue("");
|
||||
}
|
||||
@@ -0,0 +1,439 @@
|
||||
/*jshint curly:true, eqeqeq:true, laxbreak:true, noempty:false */
|
||||
/*
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2007-2013 Einar Lielmanis and contributors.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person
|
||||
obtaining a copy of this software and associated documentation files
|
||||
(the "Software"), to deal in the Software without restriction,
|
||||
including without limitation the rights to use, copy, modify, merge,
|
||||
publish, distribute, sublicense, and/or sell copies of the Software,
|
||||
and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
|
||||
CSS Beautifier
|
||||
---------------
|
||||
|
||||
Written by Harutyun Amirjanyan, (amirjanyan@gmail.com)
|
||||
|
||||
Based on code initially developed by: Einar Lielmanis, <einar@jsbeautifier.org>
|
||||
http://jsbeautifier.org/
|
||||
|
||||
Usage:
|
||||
css_beautify(source_text);
|
||||
css_beautify(source_text, options);
|
||||
|
||||
The options are (default in brackets):
|
||||
indent_size (4) — indentation size,
|
||||
indent_char (space) — character to indent with,
|
||||
selector_separator_newline (true) - separate selectors with newline or
|
||||
not (e.g. "a,\nbr" or "a, br")
|
||||
end_with_newline (false) - end with a newline
|
||||
|
||||
e.g
|
||||
|
||||
css_beautify(css_source_text, {
|
||||
'indent_size': 1,
|
||||
'indent_char': '\t',
|
||||
'selector_separator': ' ',
|
||||
'end_with_newline': false,
|
||||
});
|
||||
*/
|
||||
|
||||
// http://www.w3.org/TR/CSS21/syndata.html#tokenization
|
||||
// http://www.w3.org/TR/css3-syntax/
|
||||
|
||||
(function() {
|
||||
function css_beautify(source_text, options) {
|
||||
options = options || {};
|
||||
var indentSize = options.indent_size || 4;
|
||||
var indentCharacter = options.indent_char || ' ';
|
||||
var selectorSeparatorNewline = (options.selector_separator_newline === undefined) ? true : options.selector_separator_newline;
|
||||
var end_with_newline = (options.end_with_newline === undefined) ? false : options.end_with_newline;
|
||||
|
||||
// compatibility
|
||||
if (typeof indentSize === "string") {
|
||||
indentSize = parseInt(indentSize, 10);
|
||||
}
|
||||
|
||||
|
||||
// tokenizer
|
||||
var whiteRe = /^\s+$/;
|
||||
var wordRe = /[\w$\-_]/;
|
||||
|
||||
var pos = -1,
|
||||
ch;
|
||||
|
||||
function next() {
|
||||
ch = source_text.charAt(++pos);
|
||||
return ch || '';
|
||||
}
|
||||
|
||||
function peek(skipWhitespace) {
|
||||
var prev_pos = pos;
|
||||
if (skipWhitespace) {
|
||||
eatWhitespace();
|
||||
}
|
||||
result = source_text.charAt(pos + 1) || '';
|
||||
pos = prev_pos - 1;
|
||||
next();
|
||||
return result;
|
||||
}
|
||||
|
||||
function eatString(endChars) {
|
||||
var start = pos;
|
||||
while (next()) {
|
||||
if (ch === "\\") {
|
||||
next();
|
||||
} else if (endChars.indexOf(ch) !== -1) {
|
||||
break;
|
||||
} else if (ch === "\n") {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return source_text.substring(start, pos + 1);
|
||||
}
|
||||
|
||||
function peekString(endChar) {
|
||||
var prev_pos = pos;
|
||||
var str = eatString(endChar);
|
||||
pos = prev_pos - 1;
|
||||
next();
|
||||
return str;
|
||||
}
|
||||
|
||||
function eatWhitespace() {
|
||||
var result = '';
|
||||
while (whiteRe.test(peek())) {
|
||||
next()
|
||||
result += ch;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function skipWhitespace() {
|
||||
var result = '';
|
||||
if (ch && whiteRe.test(ch)) {
|
||||
result = ch;
|
||||
}
|
||||
while (whiteRe.test(next())) {
|
||||
result += ch
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function eatComment(singleLine) {
|
||||
var start = pos;
|
||||
var singleLine = peek() === "/";
|
||||
next();
|
||||
while (next()) {
|
||||
if (!singleLine && ch === "*" && peek() === "/") {
|
||||
next();
|
||||
break;
|
||||
} else if (singleLine && ch === "\n") {
|
||||
return source_text.substring(start, pos);
|
||||
}
|
||||
}
|
||||
|
||||
return source_text.substring(start, pos) + ch;
|
||||
}
|
||||
|
||||
|
||||
function lookBack(str) {
|
||||
return source_text.substring(pos - str.length, pos).toLowerCase() ===
|
||||
str;
|
||||
}
|
||||
|
||||
// Nested pseudo-class if we are insideRule
|
||||
// and the next special character found opens
|
||||
// a new block
|
||||
function foundNestedPseudoClass() {
|
||||
for (var i = pos + 1; i < source_text.length; i++){
|
||||
var ch = source_text.charAt(i);
|
||||
if (ch === "{"){
|
||||
return true;
|
||||
} else if (ch === ";" || ch === "}" || ch === ")") {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// printer
|
||||
var basebaseIndentString = source_text.match(/^[\t ]*/)[0];
|
||||
var singleIndent = new Array(indentSize + 1).join(indentCharacter);
|
||||
var indentLevel = 0;
|
||||
var nestedLevel = 0;
|
||||
|
||||
function indent() {
|
||||
indentLevel++;
|
||||
basebaseIndentString += singleIndent;
|
||||
}
|
||||
|
||||
function outdent() {
|
||||
indentLevel--;
|
||||
basebaseIndentString = basebaseIndentString.slice(0, -indentSize);
|
||||
}
|
||||
|
||||
var print = {};
|
||||
print["{"] = function(ch) {
|
||||
print.singleSpace();
|
||||
output.push(ch);
|
||||
print.newLine();
|
||||
};
|
||||
print["}"] = function(ch) {
|
||||
print.newLine();
|
||||
output.push(ch);
|
||||
print.newLine();
|
||||
};
|
||||
|
||||
print._lastCharWhitespace = function() {
|
||||
return whiteRe.test(output[output.length - 1]);
|
||||
};
|
||||
|
||||
print.newLine = function(keepWhitespace) {
|
||||
if (!keepWhitespace) {
|
||||
print.trim();
|
||||
}
|
||||
|
||||
if (output.length) {
|
||||
output.push('\n');
|
||||
}
|
||||
if (basebaseIndentString) {
|
||||
output.push(basebaseIndentString);
|
||||
}
|
||||
};
|
||||
print.singleSpace = function() {
|
||||
if (output.length && !print._lastCharWhitespace()) {
|
||||
output.push(' ');
|
||||
}
|
||||
};
|
||||
|
||||
print.trim = function() {
|
||||
while (print._lastCharWhitespace()) {
|
||||
output.pop();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
var output = [];
|
||||
if (basebaseIndentString) {
|
||||
output.push(basebaseIndentString);
|
||||
}
|
||||
/*_____________________--------------------_____________________*/
|
||||
|
||||
var insideRule = false;
|
||||
var enteringConditionalGroup = false;
|
||||
var top_ch = '';
|
||||
var last_top_ch = '';
|
||||
|
||||
while (true) {
|
||||
var whitespace = skipWhitespace();
|
||||
var isAfterSpace = whitespace !== '';
|
||||
var isAfterNewline = whitespace.indexOf('\n') !== -1;
|
||||
var last_top_ch = top_ch;
|
||||
var top_ch = ch;
|
||||
|
||||
if (!ch) {
|
||||
break;
|
||||
} else if (ch === '/' && peek() === '*') { /* css comment */
|
||||
var header = lookBack("");
|
||||
print.newLine();
|
||||
output.push(eatComment());
|
||||
print.newLine();
|
||||
if (header) {
|
||||
print.newLine(true);
|
||||
}
|
||||
} else if (ch === '/' && peek() === '/') { // single line comment
|
||||
if (!isAfterNewline && last_top_ch !== '{') {
|
||||
print.trim();
|
||||
}
|
||||
print.singleSpace();
|
||||
output.push(eatComment());
|
||||
print.newLine();
|
||||
} else if (ch === '@') {
|
||||
// pass along the space we found as a separate item
|
||||
if (isAfterSpace) {
|
||||
print.singleSpace();
|
||||
}
|
||||
output.push(ch);
|
||||
|
||||
// strip trailing space, if present, for hash property checks
|
||||
var variableOrRule = peekString(": ,;{}()[]/='\"").replace(/\s$/, '');
|
||||
|
||||
// might be a nesting at-rule
|
||||
if (variableOrRule in css_beautify.NESTED_AT_RULE) {
|
||||
nestedLevel += 1;
|
||||
if (variableOrRule in css_beautify.CONDITIONAL_GROUP_RULE) {
|
||||
enteringConditionalGroup = true;
|
||||
}
|
||||
} else if (': '.indexOf(variableOrRule[variableOrRule.length -1]) >= 0) {
|
||||
//we have a variable, add it and insert one space before continuing
|
||||
next();
|
||||
variableOrRule = eatString(": ").replace(/\s$/, '');
|
||||
output.push(variableOrRule);
|
||||
print.singleSpace();
|
||||
}
|
||||
} else if (ch === '{') {
|
||||
if (peek(true) === '}') {
|
||||
eatWhitespace();
|
||||
next();
|
||||
print.singleSpace();
|
||||
output.push("{}");
|
||||
} else {
|
||||
indent();
|
||||
print["{"](ch);
|
||||
// when entering conditional groups, only rulesets are allowed
|
||||
if (enteringConditionalGroup) {
|
||||
enteringConditionalGroup = false;
|
||||
insideRule = (indentLevel > nestedLevel);
|
||||
} else {
|
||||
// otherwise, declarations are also allowed
|
||||
insideRule = (indentLevel >= nestedLevel);
|
||||
}
|
||||
}
|
||||
} else if (ch === '}') {
|
||||
outdent();
|
||||
print["}"](ch);
|
||||
insideRule = false;
|
||||
if (nestedLevel) {
|
||||
nestedLevel--;
|
||||
}
|
||||
} else if (ch === ":") {
|
||||
eatWhitespace();
|
||||
if ((insideRule || enteringConditionalGroup) &&
|
||||
!(lookBack("&") || foundNestedPseudoClass())) {
|
||||
// 'property: value' delimiter
|
||||
// which could be in a conditional group query
|
||||
output.push(':');
|
||||
print.singleSpace();
|
||||
} else {
|
||||
// sass/less parent reference don't use a space
|
||||
// sass nested pseudo-class don't use a space
|
||||
if (peek() === ":") {
|
||||
// pseudo-element
|
||||
next();
|
||||
output.push("::");
|
||||
} else {
|
||||
// pseudo-class
|
||||
output.push(':');
|
||||
}
|
||||
}
|
||||
} else if (ch === '"' || ch === '\'') {
|
||||
if (isAfterSpace) {
|
||||
print.singleSpace();
|
||||
}
|
||||
output.push(eatString(ch));
|
||||
} else if (ch === ';') {
|
||||
output.push(ch);
|
||||
print.newLine();
|
||||
} else if (ch === '(') { // may be a url
|
||||
if (lookBack("url")) {
|
||||
output.push(ch);
|
||||
eatWhitespace();
|
||||
if (next()) {
|
||||
if (ch !== ')' && ch !== '"' && ch !== '\'') {
|
||||
output.push(eatString(')'));
|
||||
} else {
|
||||
pos--;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (isAfterSpace) {
|
||||
print.singleSpace();
|
||||
}
|
||||
output.push(ch);
|
||||
eatWhitespace();
|
||||
}
|
||||
} else if (ch === ')') {
|
||||
output.push(ch);
|
||||
} else if (ch === ',') {
|
||||
output.push(ch);
|
||||
eatWhitespace();
|
||||
if (!insideRule && selectorSeparatorNewline) {
|
||||
print.newLine();
|
||||
} else {
|
||||
print.singleSpace();
|
||||
}
|
||||
} else if (ch === ']') {
|
||||
output.push(ch);
|
||||
} else if (ch === '[') {
|
||||
if (isAfterSpace) {
|
||||
print.singleSpace();
|
||||
}
|
||||
output.push(ch);
|
||||
} else if (ch === '=') { // no whitespace before or after
|
||||
eatWhitespace();
|
||||
output.push(ch);
|
||||
} else {
|
||||
if (isAfterSpace) {
|
||||
print.singleSpace();
|
||||
}
|
||||
|
||||
output.push(ch);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var sweetCode = output.join('').replace(/[\r\n\t ]+$/, '');
|
||||
|
||||
// establish end_with_newline
|
||||
if (end_with_newline) {
|
||||
sweetCode += "\n";
|
||||
}
|
||||
|
||||
return sweetCode;
|
||||
}
|
||||
|
||||
// https://developer.mozilla.org/en-US/docs/Web/CSS/At-rule
|
||||
css_beautify.NESTED_AT_RULE = {
|
||||
"@page": true,
|
||||
"@font-face": true,
|
||||
"@keyframes": true,
|
||||
// also in CONDITIONAL_GROUP_RULE below
|
||||
"@media": true,
|
||||
"@supports": true,
|
||||
"@document": true
|
||||
};
|
||||
css_beautify.CONDITIONAL_GROUP_RULE = {
|
||||
"@media": true,
|
||||
"@supports": true,
|
||||
"@document": true
|
||||
};
|
||||
|
||||
/*global define */
|
||||
if (typeof define === "function" && define.amd) {
|
||||
// Add support for AMD ( https://github.com/amdjs/amdjs-api/wiki/AMD#defineamd-property- )
|
||||
define([], function() {
|
||||
return {
|
||||
css_beautify: css_beautify
|
||||
};
|
||||
});
|
||||
} else if (typeof exports !== "undefined") {
|
||||
// Add support for CommonJS. Just put this file somewhere on your require.paths
|
||||
// and you will be able to `var html_beautify = require("beautify").html_beautify`.
|
||||
exports.css_beautify = css_beautify;
|
||||
} else if (typeof window !== "undefined") {
|
||||
// If we're running a web page and don't have either of the above, add our one global
|
||||
window.css_beautify = css_beautify;
|
||||
} else if (typeof global !== "undefined") {
|
||||
// If we don't even have window, try global.
|
||||
global.css_beautify = css_beautify;
|
||||
}
|
||||
|
||||
}());
|
||||
@@ -0,0 +1,880 @@
|
||||
/*jshint curly:true, eqeqeq:true, laxbreak:true, noempty:false */
|
||||
/*
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2007-2013 Einar Lielmanis and contributors.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person
|
||||
obtaining a copy of this software and associated documentation files
|
||||
(the "Software"), to deal in the Software without restriction,
|
||||
including without limitation the rights to use, copy, modify, merge,
|
||||
publish, distribute, sublicense, and/or sell copies of the Software,
|
||||
and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
||||
BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
||||
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
|
||||
Style HTML
|
||||
---------------
|
||||
|
||||
Written by Nochum Sossonko, (nsossonko@hotmail.com)
|
||||
|
||||
Based on code initially developed by: Einar Lielmanis, <einar@jsbeautifier.org>
|
||||
http://jsbeautifier.org/
|
||||
|
||||
Usage:
|
||||
style_html(html_source);
|
||||
|
||||
style_html(html_source, options);
|
||||
|
||||
The options are:
|
||||
indent_inner_html (default false) — indent <head> and <body> sections,
|
||||
indent_size (default 4) — indentation size,
|
||||
indent_char (default space) — character to indent with,
|
||||
wrap_line_length (default 250) - maximum amount of characters per line (0 = disable)
|
||||
brace_style (default "collapse") - "collapse" | "expand" | "end-expand" | "none"
|
||||
put braces on the same line as control statements (default), or put braces on own line (Allman / ANSI style), or just put end braces on own line, or attempt to keep them where they are.
|
||||
unformatted (defaults to inline tags) - list of tags, that shouldn't be reformatted
|
||||
indent_scripts (default normal) - "keep"|"separate"|"normal"
|
||||
preserve_newlines (default true) - whether existing line breaks before elements should be preserved
|
||||
Only works before elements, not inside tags or for text.
|
||||
max_preserve_newlines (default unlimited) - maximum number of line breaks to be preserved in one chunk
|
||||
indent_handlebars (default false) - format and indent {{#foo}} and {{/foo}}
|
||||
end_with_newline (false) - end with a newline
|
||||
|
||||
|
||||
e.g.
|
||||
|
||||
style_html(html_source, {
|
||||
'indent_inner_html': false,
|
||||
'indent_size': 2,
|
||||
'indent_char': ' ',
|
||||
'wrap_line_length': 78,
|
||||
'brace_style': 'expand',
|
||||
'unformatted': ['a', 'sub', 'sup', 'b', 'i', 'u'],
|
||||
'preserve_newlines': true,
|
||||
'max_preserve_newlines': 5,
|
||||
'indent_handlebars': false
|
||||
});
|
||||
*/
|
||||
|
||||
(function() {
|
||||
|
||||
function trim(s) {
|
||||
return s.replace(/^\s+|\s+$/g, '');
|
||||
}
|
||||
|
||||
function ltrim(s) {
|
||||
return s.replace(/^\s+/g, '');
|
||||
}
|
||||
|
||||
function rtrim(s) {
|
||||
return s.replace(/\s+$/g,'');
|
||||
}
|
||||
|
||||
function style_html(html_source, options, js_beautify, css_beautify) {
|
||||
//Wrapper function to invoke all the necessary constructors and deal with the output.
|
||||
|
||||
var multi_parser,
|
||||
indent_inner_html,
|
||||
indent_size,
|
||||
indent_character,
|
||||
wrap_line_length,
|
||||
brace_style,
|
||||
unformatted,
|
||||
preserve_newlines,
|
||||
max_preserve_newlines,
|
||||
indent_handlebars,
|
||||
end_with_newline;
|
||||
|
||||
options = options || {};
|
||||
|
||||
// backwards compatibility to 1.3.4
|
||||
if ((options.wrap_line_length === undefined || parseInt(options.wrap_line_length, 10) === 0) &&
|
||||
(options.max_char !== undefined && parseInt(options.max_char, 10) !== 0)) {
|
||||
options.wrap_line_length = options.max_char;
|
||||
}
|
||||
|
||||
indent_inner_html = (options.indent_inner_html === undefined) ? false : options.indent_inner_html;
|
||||
indent_size = (options.indent_size === undefined) ? 4 : parseInt(options.indent_size, 10);
|
||||
indent_character = (options.indent_char === undefined) ? ' ' : options.indent_char;
|
||||
brace_style = (options.brace_style === undefined) ? 'collapse' : options.brace_style;
|
||||
wrap_line_length = parseInt(options.wrap_line_length, 10) === 0 ? 32786 : parseInt(options.wrap_line_length || 250, 10);
|
||||
unformatted = options.unformatted || ['a', 'span', 'img', 'bdo', 'em', 'strong', 'dfn', 'code', 'samp', 'kbd', 'var', 'cite', 'abbr', 'acronym', 'q', 'sub', 'sup', 'tt', 'i', 'b', 'big', 'small', 'u', 's', 'strike', 'font', 'ins', 'del', 'pre', 'address', 'dt', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'];
|
||||
preserve_newlines = (options.preserve_newlines === undefined) ? true : options.preserve_newlines;
|
||||
max_preserve_newlines = preserve_newlines ?
|
||||
(isNaN(parseInt(options.max_preserve_newlines, 10)) ? 32786 : parseInt(options.max_preserve_newlines, 10))
|
||||
: 0;
|
||||
indent_handlebars = (options.indent_handlebars === undefined) ? false : options.indent_handlebars;
|
||||
end_with_newline = (options.end_with_newline === undefined) ? false : options.end_with_newline;
|
||||
|
||||
function Parser() {
|
||||
|
||||
this.pos = 0; //Parser position
|
||||
this.token = '';
|
||||
this.current_mode = 'CONTENT'; //reflects the current Parser mode: TAG/CONTENT
|
||||
this.tags = { //An object to hold tags, their position, and their parent-tags, initiated with default values
|
||||
parent: 'parent1',
|
||||
parentcount: 1,
|
||||
parent1: ''
|
||||
};
|
||||
this.tag_type = '';
|
||||
this.token_text = this.last_token = this.last_text = this.token_type = '';
|
||||
this.newlines = 0;
|
||||
this.indent_content = indent_inner_html;
|
||||
|
||||
this.Utils = { //Uilities made available to the various functions
|
||||
whitespace: "\n\r\t ".split(''),
|
||||
single_token: 'br,input,link,meta,!doctype,basefont,base,area,hr,wbr,param,img,isindex,?xml,embed,?php,?,?='.split(','), //all the single tags for HTML
|
||||
extra_liners: 'head,body,/html'.split(','), //for tags that need a line of whitespace before them
|
||||
in_array: function(what, arr) {
|
||||
for (var i = 0; i < arr.length; i++) {
|
||||
if (what === arr[i]) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
// Return true iff the given text is composed entirely of
|
||||
// whitespace.
|
||||
this.is_whitespace = function(text) {
|
||||
for (var n = 0; n < text.length; text++) {
|
||||
if (!this.Utils.in_array(text.charAt(n), this.Utils.whitespace)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
this.traverse_whitespace = function() {
|
||||
var input_char = '';
|
||||
|
||||
input_char = this.input.charAt(this.pos);
|
||||
if (this.Utils.in_array(input_char, this.Utils.whitespace)) {
|
||||
this.newlines = 0;
|
||||
while (this.Utils.in_array(input_char, this.Utils.whitespace)) {
|
||||
if (preserve_newlines && input_char === '\n' && this.newlines <= max_preserve_newlines) {
|
||||
this.newlines += 1;
|
||||
}
|
||||
|
||||
this.pos++;
|
||||
input_char = this.input.charAt(this.pos);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
// Append a space to the given content (string array) or, if we are
|
||||
// at the wrap_line_length, append a newline/indentation.
|
||||
this.space_or_wrap = function(content) {
|
||||
if (this.line_char_count >= this.wrap_line_length) { //insert a line when the wrap_line_length is reached
|
||||
this.print_newline(false, content);
|
||||
this.print_indentation(content);
|
||||
} else {
|
||||
this.line_char_count++;
|
||||
content.push(' ');
|
||||
}
|
||||
};
|
||||
|
||||
this.get_content = function() { //function to capture regular content between tags
|
||||
var input_char = '',
|
||||
content = [],
|
||||
space = false; //if a space is needed
|
||||
|
||||
while (this.input.charAt(this.pos) !== '<') {
|
||||
if (this.pos >= this.input.length) {
|
||||
return content.length ? content.join('') : ['', 'TK_EOF'];
|
||||
}
|
||||
|
||||
if (this.traverse_whitespace()) {
|
||||
this.space_or_wrap(content);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (indent_handlebars) {
|
||||
// Handlebars parsing is complicated.
|
||||
// {{#foo}} and {{/foo}} are formatted tags.
|
||||
// {{something}} should get treated as content, except:
|
||||
// {{else}} specifically behaves like {{#if}} and {{/if}}
|
||||
var peek3 = this.input.substr(this.pos, 3);
|
||||
if (peek3 === '{{#' || peek3 === '{{/') {
|
||||
// These are tags and not content.
|
||||
break;
|
||||
} else if (this.input.substr(this.pos, 2) === '{{') {
|
||||
if (this.get_tag(true) === '{{else}}') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
input_char = this.input.charAt(this.pos);
|
||||
this.pos++;
|
||||
this.line_char_count++;
|
||||
content.push(input_char); //letter at-a-time (or string) inserted to an array
|
||||
}
|
||||
return content.length ? content.join('') : '';
|
||||
};
|
||||
|
||||
this.get_contents_to = function(name) { //get the full content of a script or style to pass to js_beautify
|
||||
if (this.pos === this.input.length) {
|
||||
return ['', 'TK_EOF'];
|
||||
}
|
||||
var input_char = '';
|
||||
var content = '';
|
||||
var reg_match = new RegExp('</' + name + '\\s*>', 'igm');
|
||||
reg_match.lastIndex = this.pos;
|
||||
var reg_array = reg_match.exec(this.input);
|
||||
var end_script = reg_array ? reg_array.index : this.input.length; //absolute end of script
|
||||
if (this.pos < end_script) { //get everything in between the script tags
|
||||
content = this.input.substring(this.pos, end_script);
|
||||
this.pos = end_script;
|
||||
}
|
||||
return content;
|
||||
};
|
||||
|
||||
this.record_tag = function(tag) { //function to record a tag and its parent in this.tags Object
|
||||
if (this.tags[tag + 'count']) { //check for the existence of this tag type
|
||||
this.tags[tag + 'count']++;
|
||||
this.tags[tag + this.tags[tag + 'count']] = this.indent_level; //and record the present indent level
|
||||
} else { //otherwise initialize this tag type
|
||||
this.tags[tag + 'count'] = 1;
|
||||
this.tags[tag + this.tags[tag + 'count']] = this.indent_level; //and record the present indent level
|
||||
}
|
||||
this.tags[tag + this.tags[tag + 'count'] + 'parent'] = this.tags.parent; //set the parent (i.e. in the case of a div this.tags.div1parent)
|
||||
this.tags.parent = tag + this.tags[tag + 'count']; //and make this the current parent (i.e. in the case of a div 'div1')
|
||||
};
|
||||
|
||||
this.retrieve_tag = function(tag) { //function to retrieve the opening tag to the corresponding closer
|
||||
if (this.tags[tag + 'count']) { //if the openener is not in the Object we ignore it
|
||||
var temp_parent = this.tags.parent; //check to see if it's a closable tag.
|
||||
while (temp_parent) { //till we reach '' (the initial value);
|
||||
if (tag + this.tags[tag + 'count'] === temp_parent) { //if this is it use it
|
||||
break;
|
||||
}
|
||||
temp_parent = this.tags[temp_parent + 'parent']; //otherwise keep on climbing up the DOM Tree
|
||||
}
|
||||
if (temp_parent) { //if we caught something
|
||||
this.indent_level = this.tags[tag + this.tags[tag + 'count']]; //set the indent_level accordingly
|
||||
this.tags.parent = this.tags[temp_parent + 'parent']; //and set the current parent
|
||||
}
|
||||
delete this.tags[tag + this.tags[tag + 'count'] + 'parent']; //delete the closed tags parent reference...
|
||||
delete this.tags[tag + this.tags[tag + 'count']]; //...and the tag itself
|
||||
if (this.tags[tag + 'count'] === 1) {
|
||||
delete this.tags[tag + 'count'];
|
||||
} else {
|
||||
this.tags[tag + 'count']--;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
this.indent_to_tag = function(tag) {
|
||||
// Match the indentation level to the last use of this tag, but don't remove it.
|
||||
if (!this.tags[tag + 'count']) {
|
||||
return;
|
||||
}
|
||||
var temp_parent = this.tags.parent;
|
||||
while (temp_parent) {
|
||||
if (tag + this.tags[tag + 'count'] === temp_parent) {
|
||||
break;
|
||||
}
|
||||
temp_parent = this.tags[temp_parent + 'parent'];
|
||||
}
|
||||
if (temp_parent) {
|
||||
this.indent_level = this.tags[tag + this.tags[tag + 'count']];
|
||||
}
|
||||
};
|
||||
|
||||
this.get_tag = function(peek) { //function to get a full tag and parse its type
|
||||
var input_char = '',
|
||||
content = [],
|
||||
comment = '',
|
||||
space = false,
|
||||
tag_start, tag_end,
|
||||
tag_start_char,
|
||||
orig_pos = this.pos,
|
||||
orig_line_char_count = this.line_char_count;
|
||||
|
||||
peek = peek !== undefined ? peek : false;
|
||||
|
||||
do {
|
||||
if (this.pos >= this.input.length) {
|
||||
if (peek) {
|
||||
this.pos = orig_pos;
|
||||
this.line_char_count = orig_line_char_count;
|
||||
}
|
||||
return content.length ? content.join('') : ['', 'TK_EOF'];
|
||||
}
|
||||
|
||||
input_char = this.input.charAt(this.pos);
|
||||
this.pos++;
|
||||
|
||||
if (this.Utils.in_array(input_char, this.Utils.whitespace)) { //don't want to insert unnecessary space
|
||||
space = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (input_char === "'" || input_char === '"') {
|
||||
input_char += this.get_unformatted(input_char);
|
||||
space = true;
|
||||
|
||||
}
|
||||
|
||||
if (input_char === '=') { //no space before =
|
||||
space = false;
|
||||
}
|
||||
|
||||
if (content.length && content[content.length - 1] !== '=' && input_char !== '>' && space) {
|
||||
//no space after = or before >
|
||||
this.space_or_wrap(content);
|
||||
space = false;
|
||||
}
|
||||
|
||||
if (indent_handlebars && tag_start_char === '<') {
|
||||
// When inside an angle-bracket tag, put spaces around
|
||||
// handlebars not inside of strings.
|
||||
if ((input_char + this.input.charAt(this.pos)) === '{{') {
|
||||
input_char += this.get_unformatted('}}');
|
||||
if (content.length && content[content.length - 1] !== ' ' && content[content.length - 1] !== '<') {
|
||||
input_char = ' ' + input_char;
|
||||
}
|
||||
space = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (input_char === '<' && !tag_start_char) {
|
||||
tag_start = this.pos - 1;
|
||||
tag_start_char = '<';
|
||||
}
|
||||
|
||||
if (indent_handlebars && !tag_start_char) {
|
||||
if (content.length >= 2 && content[content.length - 1] === '{' && content[content.length - 2] == '{') {
|
||||
if (input_char === '#' || input_char === '/') {
|
||||
tag_start = this.pos - 3;
|
||||
} else {
|
||||
tag_start = this.pos - 2;
|
||||
}
|
||||
tag_start_char = '{';
|
||||
}
|
||||
}
|
||||
|
||||
this.line_char_count++;
|
||||
content.push(input_char); //inserts character at-a-time (or string)
|
||||
|
||||
if (content[1] && content[1] === '!') { //if we're in a comment, do something special
|
||||
// We treat all comments as literals, even more than preformatted tags
|
||||
// we just look for the appropriate close tag
|
||||
content = [this.get_comment(tag_start)];
|
||||
break;
|
||||
}
|
||||
|
||||
if (indent_handlebars && tag_start_char === '{' && content.length > 2 && content[content.length - 2] === '}' && content[content.length - 1] === '}') {
|
||||
break;
|
||||
}
|
||||
} while (input_char !== '>');
|
||||
|
||||
var tag_complete = content.join('');
|
||||
var tag_index;
|
||||
var tag_offset;
|
||||
|
||||
if (tag_complete.indexOf(' ') !== -1) { //if there's whitespace, thats where the tag name ends
|
||||
tag_index = tag_complete.indexOf(' ');
|
||||
} else if (tag_complete[0] === '{') {
|
||||
tag_index = tag_complete.indexOf('}');
|
||||
} else { //otherwise go with the tag ending
|
||||
tag_index = tag_complete.indexOf('>');
|
||||
}
|
||||
if (tag_complete[0] === '<' || !indent_handlebars) {
|
||||
tag_offset = 1;
|
||||
} else {
|
||||
tag_offset = tag_complete[2] === '#' ? 3 : 2;
|
||||
}
|
||||
var tag_check = tag_complete.substring(tag_offset, tag_index).toLowerCase();
|
||||
if (tag_complete.charAt(tag_complete.length - 2) === '/' ||
|
||||
this.Utils.in_array(tag_check, this.Utils.single_token)) { //if this tag name is a single tag type (either in the list or has a closing /)
|
||||
if (!peek) {
|
||||
this.tag_type = 'SINGLE';
|
||||
}
|
||||
} else if (indent_handlebars && tag_complete[0] === '{' && tag_check === 'else') {
|
||||
if (!peek) {
|
||||
this.indent_to_tag('if');
|
||||
this.tag_type = 'HANDLEBARS_ELSE';
|
||||
this.indent_content = true;
|
||||
this.traverse_whitespace();
|
||||
}
|
||||
} else if (this.is_unformatted(tag_check, unformatted)) { // do not reformat the "unformatted" tags
|
||||
comment = this.get_unformatted('</' + tag_check + '>', tag_complete); //...delegate to get_unformatted function
|
||||
content.push(comment);
|
||||
tag_end = this.pos - 1;
|
||||
this.tag_type = 'SINGLE';
|
||||
} else if (tag_check === 'script' &&
|
||||
(tag_complete.search('type') === -1 ||
|
||||
(tag_complete.search('type') > -1 &&
|
||||
tag_complete.search(/\b(text|application)\/(x-)?(javascript|ecmascript|jscript|livescript)/) > -1))) {
|
||||
if (!peek) {
|
||||
this.record_tag(tag_check);
|
||||
this.tag_type = 'SCRIPT';
|
||||
}
|
||||
} else if (tag_check === 'style' &&
|
||||
(tag_complete.search('type') === -1 ||
|
||||
(tag_complete.search('type') > -1 && tag_complete.search('text/css') > -1))) {
|
||||
if (!peek) {
|
||||
this.record_tag(tag_check);
|
||||
this.tag_type = 'STYLE';
|
||||
}
|
||||
} else if (tag_check.charAt(0) === '!') { //peek for <! comment
|
||||
// for comments content is already correct.
|
||||
if (!peek) {
|
||||
this.tag_type = 'SINGLE';
|
||||
this.traverse_whitespace();
|
||||
}
|
||||
} else if (!peek) {
|
||||
if (tag_check.charAt(0) === '/') { //this tag is a double tag so check for tag-ending
|
||||
this.retrieve_tag(tag_check.substring(1)); //remove it and all ancestors
|
||||
this.tag_type = 'END';
|
||||
} else { //otherwise it's a start-tag
|
||||
this.record_tag(tag_check); //push it on the tag stack
|
||||
if (tag_check.toLowerCase() !== 'html') {
|
||||
this.indent_content = true;
|
||||
}
|
||||
this.tag_type = 'START';
|
||||
}
|
||||
|
||||
// Allow preserving of newlines after a start or end tag
|
||||
if (this.traverse_whitespace()) {
|
||||
this.space_or_wrap(content);
|
||||
}
|
||||
|
||||
if (this.Utils.in_array(tag_check, this.Utils.extra_liners)) { //check if this double needs an extra line
|
||||
this.print_newline(false, this.output);
|
||||
if (this.output.length && this.output[this.output.length - 2] !== '\n') {
|
||||
this.print_newline(true, this.output);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (peek) {
|
||||
this.pos = orig_pos;
|
||||
this.line_char_count = orig_line_char_count;
|
||||
}
|
||||
|
||||
return content.join(''); //returns fully formatted tag
|
||||
};
|
||||
|
||||
this.get_comment = function(start_pos) { //function to return comment content in its entirety
|
||||
// this is will have very poor perf, but will work for now.
|
||||
var comment = '',
|
||||
delimiter = '>',
|
||||
matched = false;
|
||||
|
||||
this.pos = start_pos;
|
||||
input_char = this.input.charAt(this.pos);
|
||||
this.pos++;
|
||||
|
||||
while (this.pos <= this.input.length) {
|
||||
comment += input_char;
|
||||
|
||||
// only need to check for the delimiter if the last chars match
|
||||
if (comment[comment.length - 1] === delimiter[delimiter.length - 1] &&
|
||||
comment.indexOf(delimiter) !== -1) {
|
||||
break;
|
||||
}
|
||||
|
||||
// only need to search for custom delimiter for the first few characters
|
||||
if (!matched && comment.length < 10) {
|
||||
if (comment.indexOf('<![if') === 0) { //peek for <![if conditional comment
|
||||
delimiter = '<![endif]>';
|
||||
matched = true;
|
||||
} else if (comment.indexOf('<![cdata[') === 0) { //if it's a <[cdata[ comment...
|
||||
delimiter = ']]>';
|
||||
matched = true;
|
||||
} else if (comment.indexOf('<![') === 0) { // some other ![ comment? ...
|
||||
delimiter = ']>';
|
||||
matched = true;
|
||||
} else if (comment.indexOf('<!--') === 0) { // <!-- comment ...
|
||||
delimiter = '-->';
|
||||
matched = true;
|
||||
}
|
||||
}
|
||||
|
||||
input_char = this.input.charAt(this.pos);
|
||||
this.pos++;
|
||||
}
|
||||
|
||||
return comment;
|
||||
};
|
||||
|
||||
this.get_unformatted = function(delimiter, orig_tag) { //function to return unformatted content in its entirety
|
||||
|
||||
if (orig_tag && orig_tag.toLowerCase().indexOf(delimiter) !== -1) {
|
||||
return '';
|
||||
}
|
||||
var input_char = '';
|
||||
var content = '';
|
||||
var min_index = 0;
|
||||
var space = true;
|
||||
do {
|
||||
|
||||
if (this.pos >= this.input.length) {
|
||||
return content;
|
||||
}
|
||||
|
||||
input_char = this.input.charAt(this.pos);
|
||||
this.pos++;
|
||||
|
||||
if (this.Utils.in_array(input_char, this.Utils.whitespace)) {
|
||||
if (!space) {
|
||||
this.line_char_count--;
|
||||
continue;
|
||||
}
|
||||
if (input_char === '\n' || input_char === '\r') {
|
||||
content += '\n';
|
||||
/* Don't change tab indention for unformatted blocks. If using code for html editing, this will greatly affect <pre> tags if they are specified in the 'unformatted array'
|
||||
for (var i=0; i<this.indent_level; i++) {
|
||||
content += this.indent_string;
|
||||
}
|
||||
space = false; //...and make sure other indentation is erased
|
||||
*/
|
||||
this.line_char_count = 0;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
content += input_char;
|
||||
this.line_char_count++;
|
||||
space = true;
|
||||
|
||||
if (indent_handlebars && input_char === '{' && content.length && content[content.length - 2] === '{') {
|
||||
// Handlebars expressions in strings should also be unformatted.
|
||||
content += this.get_unformatted('}}');
|
||||
// These expressions are opaque. Ignore delimiters found in them.
|
||||
min_index = content.length;
|
||||
}
|
||||
} while (content.toLowerCase().indexOf(delimiter, min_index) === -1);
|
||||
return content;
|
||||
};
|
||||
|
||||
this.get_token = function() { //initial handler for token-retrieval
|
||||
var token;
|
||||
|
||||
if (this.last_token === 'TK_TAG_SCRIPT' || this.last_token === 'TK_TAG_STYLE') { //check if we need to format javascript
|
||||
var type = this.last_token.substr(7);
|
||||
token = this.get_contents_to(type);
|
||||
if (typeof token !== 'string') {
|
||||
return token;
|
||||
}
|
||||
return [token, 'TK_' + type];
|
||||
}
|
||||
if (this.current_mode === 'CONTENT') {
|
||||
token = this.get_content();
|
||||
if (typeof token !== 'string') {
|
||||
return token;
|
||||
} else {
|
||||
return [token, 'TK_CONTENT'];
|
||||
}
|
||||
}
|
||||
|
||||
if (this.current_mode === 'TAG') {
|
||||
token = this.get_tag();
|
||||
if (typeof token !== 'string') {
|
||||
return token;
|
||||
} else {
|
||||
var tag_name_type = 'TK_TAG_' + this.tag_type;
|
||||
return [token, tag_name_type];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
this.get_full_indent = function(level) {
|
||||
level = this.indent_level + level || 0;
|
||||
if (level < 1) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return Array(level + 1).join(this.indent_string);
|
||||
};
|
||||
|
||||
this.is_unformatted = function(tag_check, unformatted) {
|
||||
//is this an HTML5 block-level link?
|
||||
if (!this.Utils.in_array(tag_check, unformatted)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (tag_check.toLowerCase() !== 'a' || !this.Utils.in_array('a', unformatted)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
//at this point we have an tag; is its first child something we want to remain
|
||||
//unformatted?
|
||||
var next_tag = this.get_tag(true /* peek. */ );
|
||||
|
||||
// test next_tag to see if it is just html tag (no external content)
|
||||
var tag = (next_tag || "").match(/^\s*<\s*\/?([a-z]*)\s*[^>]*>\s*$/);
|
||||
|
||||
// if next_tag comes back but is not an isolated tag, then
|
||||
// let's treat the 'a' tag as having content
|
||||
// and respect the unformatted option
|
||||
if (!tag || this.Utils.in_array(tag, unformatted)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
this.printer = function(js_source, indent_character, indent_size, wrap_line_length, brace_style) { //handles input/output and some other printing functions
|
||||
|
||||
this.input = js_source || ''; //gets the input for the Parser
|
||||
this.output = [];
|
||||
this.indent_character = indent_character;
|
||||
this.indent_string = '';
|
||||
this.indent_size = indent_size;
|
||||
this.brace_style = brace_style;
|
||||
this.indent_level = 0;
|
||||
this.wrap_line_length = wrap_line_length;
|
||||
this.line_char_count = 0; //count to see if wrap_line_length was exceeded
|
||||
|
||||
for (var i = 0; i < this.indent_size; i++) {
|
||||
this.indent_string += this.indent_character;
|
||||
}
|
||||
|
||||
this.print_newline = function(force, arr) {
|
||||
this.line_char_count = 0;
|
||||
if (!arr || !arr.length) {
|
||||
return;
|
||||
}
|
||||
if (force || (arr[arr.length - 1] !== '\n')) { //we might want the extra line
|
||||
if ((arr[arr.length - 1] !== '\n')) {
|
||||
arr[arr.length - 1] = rtrim(arr[arr.length - 1]);
|
||||
}
|
||||
arr.push('\n');
|
||||
}
|
||||
};
|
||||
|
||||
this.print_indentation = function(arr) {
|
||||
for (var i = 0; i < this.indent_level; i++) {
|
||||
arr.push(this.indent_string);
|
||||
this.line_char_count += this.indent_string.length;
|
||||
}
|
||||
};
|
||||
|
||||
this.print_token = function(text) {
|
||||
// Avoid printing initial whitespace.
|
||||
if (this.is_whitespace(text) && !this.output.length) {
|
||||
return;
|
||||
}
|
||||
if (text || text !== '') {
|
||||
if (this.output.length && this.output[this.output.length - 1] === '\n') {
|
||||
this.print_indentation(this.output);
|
||||
text = ltrim(text);
|
||||
}
|
||||
}
|
||||
this.print_token_raw(text);
|
||||
};
|
||||
|
||||
this.print_token_raw = function(text) {
|
||||
// If we are going to print newlines, truncate trailing
|
||||
// whitespace, as the newlines will represent the space.
|
||||
if (this.newlines > 0) {
|
||||
text = rtrim(text);
|
||||
}
|
||||
|
||||
if (text && text !== '') {
|
||||
if (text.length > 1 && text[text.length - 1] === '\n') {
|
||||
// unformatted tags can grab newlines as their last character
|
||||
this.output.push(text.slice(0, -1));
|
||||
this.print_newline(false, this.output);
|
||||
} else {
|
||||
this.output.push(text);
|
||||
}
|
||||
}
|
||||
|
||||
for (var n = 0; n < this.newlines; n++) {
|
||||
this.print_newline(n > 0, this.output);
|
||||
}
|
||||
this.newlines = 0;
|
||||
};
|
||||
|
||||
this.indent = function() {
|
||||
this.indent_level++;
|
||||
};
|
||||
|
||||
this.unindent = function() {
|
||||
if (this.indent_level > 0) {
|
||||
this.indent_level--;
|
||||
}
|
||||
};
|
||||
};
|
||||
return this;
|
||||
}
|
||||
|
||||
/*_____________________--------------------_____________________*/
|
||||
|
||||
multi_parser = new Parser(); //wrapping functions Parser
|
||||
multi_parser.printer(html_source, indent_character, indent_size, wrap_line_length, brace_style); //initialize starting values
|
||||
|
||||
while (true) {
|
||||
var t = multi_parser.get_token();
|
||||
multi_parser.token_text = t[0];
|
||||
multi_parser.token_type = t[1];
|
||||
|
||||
if (multi_parser.token_type === 'TK_EOF') {
|
||||
break;
|
||||
}
|
||||
|
||||
switch (multi_parser.token_type) {
|
||||
case 'TK_TAG_START':
|
||||
multi_parser.print_newline(false, multi_parser.output);
|
||||
multi_parser.print_token(multi_parser.token_text);
|
||||
if (multi_parser.indent_content) {
|
||||
multi_parser.indent();
|
||||
multi_parser.indent_content = false;
|
||||
}
|
||||
multi_parser.current_mode = 'CONTENT';
|
||||
break;
|
||||
case 'TK_TAG_STYLE':
|
||||
case 'TK_TAG_SCRIPT':
|
||||
multi_parser.print_newline(false, multi_parser.output);
|
||||
multi_parser.print_token(multi_parser.token_text);
|
||||
multi_parser.current_mode = 'CONTENT';
|
||||
break;
|
||||
case 'TK_TAG_END':
|
||||
//Print new line only if the tag has no content and has child
|
||||
if (multi_parser.last_token === 'TK_CONTENT' && multi_parser.last_text === '') {
|
||||
var tag_name = multi_parser.token_text.match(/\w+/)[0];
|
||||
var tag_extracted_from_last_output = null;
|
||||
if (multi_parser.output.length) {
|
||||
tag_extracted_from_last_output = multi_parser.output[multi_parser.output.length - 1].match(/(?:<|{{#)\s*(\w+)/);
|
||||
}
|
||||
if (tag_extracted_from_last_output === null ||
|
||||
tag_extracted_from_last_output[1] !== tag_name) {
|
||||
multi_parser.print_newline(false, multi_parser.output);
|
||||
}
|
||||
}
|
||||
multi_parser.print_token(multi_parser.token_text);
|
||||
multi_parser.current_mode = 'CONTENT';
|
||||
break;
|
||||
case 'TK_TAG_SINGLE':
|
||||
// Don't add a newline before elements that should remain unformatted.
|
||||
var tag_check = multi_parser.token_text.match(/^\s*<([a-z-]+)/i);
|
||||
if (!tag_check || !multi_parser.Utils.in_array(tag_check[1], unformatted)) {
|
||||
multi_parser.print_newline(false, multi_parser.output);
|
||||
}
|
||||
multi_parser.print_token(multi_parser.token_text);
|
||||
multi_parser.current_mode = 'CONTENT';
|
||||
break;
|
||||
case 'TK_TAG_HANDLEBARS_ELSE':
|
||||
multi_parser.print_token(multi_parser.token_text);
|
||||
if (multi_parser.indent_content) {
|
||||
multi_parser.indent();
|
||||
multi_parser.indent_content = false;
|
||||
}
|
||||
multi_parser.current_mode = 'CONTENT';
|
||||
break;
|
||||
case 'TK_CONTENT':
|
||||
multi_parser.print_token(multi_parser.token_text);
|
||||
multi_parser.current_mode = 'TAG';
|
||||
break;
|
||||
case 'TK_STYLE':
|
||||
case 'TK_SCRIPT':
|
||||
if (multi_parser.token_text !== '') {
|
||||
multi_parser.print_newline(false, multi_parser.output);
|
||||
var text = multi_parser.token_text,
|
||||
_beautifier,
|
||||
script_indent_level = 1;
|
||||
if (multi_parser.token_type === 'TK_SCRIPT') {
|
||||
_beautifier = typeof js_beautify === 'function' && js_beautify;
|
||||
} else if (multi_parser.token_type === 'TK_STYLE') {
|
||||
_beautifier = typeof css_beautify === 'function' && css_beautify;
|
||||
}
|
||||
|
||||
if (options.indent_scripts === "keep") {
|
||||
script_indent_level = 0;
|
||||
} else if (options.indent_scripts === "separate") {
|
||||
script_indent_level = -multi_parser.indent_level;
|
||||
}
|
||||
|
||||
var indentation = multi_parser.get_full_indent(script_indent_level);
|
||||
if (_beautifier) {
|
||||
// call the Beautifier if avaliable
|
||||
text = _beautifier(text.replace(/^\s*/, indentation), options);
|
||||
} else {
|
||||
// simply indent the string otherwise
|
||||
var white = text.match(/^\s*/)[0];
|
||||
var _level = white.match(/[^\n\r]*$/)[0].split(multi_parser.indent_string).length - 1;
|
||||
var reindent = multi_parser.get_full_indent(script_indent_level - _level);
|
||||
text = text.replace(/^\s*/, indentation)
|
||||
.replace(/\r\n|\r|\n/g, '\n' + reindent)
|
||||
.replace(/\s+$/, '');
|
||||
}
|
||||
if (text) {
|
||||
multi_parser.print_token_raw(text);
|
||||
multi_parser.print_newline(true, multi_parser.output);
|
||||
}
|
||||
}
|
||||
multi_parser.current_mode = 'TAG';
|
||||
break;
|
||||
default:
|
||||
// We should not be getting here but we don't want to drop input on the floor
|
||||
// Just output the text and move on
|
||||
if (multi_parser.token_text !== '') {
|
||||
multi_parser.print_token(multi_parser.token_text);
|
||||
}
|
||||
break;
|
||||
}
|
||||
multi_parser.last_token = multi_parser.token_type;
|
||||
multi_parser.last_text = multi_parser.token_text;
|
||||
}
|
||||
var sweet_code = multi_parser.output.join('').replace(/[\r\n\t ]+$/, '');
|
||||
if (end_with_newline) {
|
||||
sweet_code += '\n';
|
||||
}
|
||||
return sweet_code;
|
||||
}
|
||||
|
||||
if (typeof define === "function" && define.amd) {
|
||||
// Add support for AMD ( https://github.com/amdjs/amdjs-api/wiki/AMD#defineamd-property- )
|
||||
define(["require", "./beautify", "./beautify-css"], function(requireamd) {
|
||||
var js_beautify = requireamd("./beautify");
|
||||
var css_beautify = requireamd("./beautify-css");
|
||||
|
||||
return {
|
||||
html_beautify: function(html_source, options) {
|
||||
return style_html(html_source, options, js_beautify.js_beautify, css_beautify.css_beautify);
|
||||
}
|
||||
};
|
||||
});
|
||||
} else if (typeof exports !== "undefined") {
|
||||
// Add support for CommonJS. Just put this file somewhere on your require.paths
|
||||
// and you will be able to `var html_beautify = require("beautify").html_beautify`.
|
||||
var js_beautify = require('./beautify.js');
|
||||
var css_beautify = require('./beautify-css.js');
|
||||
|
||||
exports.html_beautify = function(html_source, options) {
|
||||
return style_html(html_source, options, js_beautify.js_beautify, css_beautify.css_beautify);
|
||||
};
|
||||
} else if (typeof window !== "undefined") {
|
||||
// If we're running a web page and don't have either of the above, add our one global
|
||||
window.html_beautify = function(html_source, options) {
|
||||
return style_html(html_source, options, window.js_beautify, window.css_beautify);
|
||||
};
|
||||
} else if (typeof global !== "undefined") {
|
||||
// If we don't even have window, try global.
|
||||
global.html_beautify = function(html_source, options) {
|
||||
return style_html(html_source, options, global.js_beautify, global.css_beautify);
|
||||
};
|
||||
}
|
||||
|
||||
}());
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,451 @@
|
||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
CodeMirror.defineMode("clike", function(config, parserConfig) {
|
||||
var indentUnit = config.indentUnit,
|
||||
statementIndentUnit = parserConfig.statementIndentUnit || indentUnit,
|
||||
dontAlignCalls = parserConfig.dontAlignCalls,
|
||||
keywords = parserConfig.keywords || {},
|
||||
builtin = parserConfig.builtin || {},
|
||||
blockKeywords = parserConfig.blockKeywords || {},
|
||||
atoms = parserConfig.atoms || {},
|
||||
hooks = parserConfig.hooks || {},
|
||||
multiLineStrings = parserConfig.multiLineStrings;
|
||||
var isOperatorChar = /[+\-*&%=<>!?|\/]/;
|
||||
|
||||
var curPunc;
|
||||
|
||||
function tokenBase(stream, state) {
|
||||
var ch = stream.next();
|
||||
if (hooks[ch]) {
|
||||
var result = hooks[ch](stream, state);
|
||||
if (result !== false) return result;
|
||||
}
|
||||
if (ch == '"' || ch == "'") {
|
||||
state.tokenize = tokenString(ch);
|
||||
return state.tokenize(stream, state);
|
||||
}
|
||||
if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
|
||||
curPunc = ch;
|
||||
return null;
|
||||
}
|
||||
if (/\d/.test(ch)) {
|
||||
stream.eatWhile(/[\w\.]/);
|
||||
return "number";
|
||||
}
|
||||
if (ch == "/") {
|
||||
if (stream.eat("*")) {
|
||||
state.tokenize = tokenComment;
|
||||
return tokenComment(stream, state);
|
||||
}
|
||||
if (stream.eat("/")) {
|
||||
stream.skipToEnd();
|
||||
return "comment";
|
||||
}
|
||||
}
|
||||
if (isOperatorChar.test(ch)) {
|
||||
stream.eatWhile(isOperatorChar);
|
||||
return "operator";
|
||||
}
|
||||
stream.eatWhile(/[\w\$_]/);
|
||||
var cur = stream.current();
|
||||
if (keywords.propertyIsEnumerable(cur)) {
|
||||
if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
|
||||
return "keyword";
|
||||
}
|
||||
if (builtin.propertyIsEnumerable(cur)) {
|
||||
if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
|
||||
return "builtin";
|
||||
}
|
||||
if (atoms.propertyIsEnumerable(cur)) return "atom";
|
||||
return "variable";
|
||||
}
|
||||
|
||||
function tokenString(quote) {
|
||||
return function(stream, state) {
|
||||
var escaped = false, next, end = false;
|
||||
while ((next = stream.next()) != null) {
|
||||
if (next == quote && !escaped) {end = true; break;}
|
||||
escaped = !escaped && next == "\\";
|
||||
}
|
||||
if (end || !(escaped || multiLineStrings))
|
||||
state.tokenize = null;
|
||||
return "string";
|
||||
};
|
||||
}
|
||||
|
||||
function tokenComment(stream, state) {
|
||||
var maybeEnd = false, ch;
|
||||
while (ch = stream.next()) {
|
||||
if (ch == "/" && maybeEnd) {
|
||||
state.tokenize = null;
|
||||
break;
|
||||
}
|
||||
maybeEnd = (ch == "*");
|
||||
}
|
||||
return "comment";
|
||||
}
|
||||
|
||||
function Context(indented, column, type, align, prev) {
|
||||
this.indented = indented;
|
||||
this.column = column;
|
||||
this.type = type;
|
||||
this.align = align;
|
||||
this.prev = prev;
|
||||
}
|
||||
function pushContext(state, col, type) {
|
||||
var indent = state.indented;
|
||||
if (state.context && state.context.type == "statement")
|
||||
indent = state.context.indented;
|
||||
return state.context = new Context(indent, col, type, null, state.context);
|
||||
}
|
||||
function popContext(state) {
|
||||
var t = state.context.type;
|
||||
if (t == ")" || t == "]" || t == "}")
|
||||
state.indented = state.context.indented;
|
||||
return state.context = state.context.prev;
|
||||
}
|
||||
|
||||
// Interface
|
||||
|
||||
return {
|
||||
startState: function(basecolumn) {
|
||||
return {
|
||||
tokenize: null,
|
||||
context: new Context((basecolumn || 0) - indentUnit, 0, "top", false),
|
||||
indented: 0,
|
||||
startOfLine: true
|
||||
};
|
||||
},
|
||||
|
||||
token: function(stream, state) {
|
||||
var ctx = state.context;
|
||||
if (stream.sol()) {
|
||||
if (ctx.align == null) ctx.align = false;
|
||||
state.indented = stream.indentation();
|
||||
state.startOfLine = true;
|
||||
}
|
||||
if (stream.eatSpace()) return null;
|
||||
curPunc = null;
|
||||
var style = (state.tokenize || tokenBase)(stream, state);
|
||||
if (style == "comment" || style == "meta") return style;
|
||||
if (ctx.align == null) ctx.align = true;
|
||||
|
||||
if ((curPunc == ";" || curPunc == ":" || curPunc == ",") && ctx.type == "statement") popContext(state);
|
||||
else if (curPunc == "{") pushContext(state, stream.column(), "}");
|
||||
else if (curPunc == "[") pushContext(state, stream.column(), "]");
|
||||
else if (curPunc == "(") pushContext(state, stream.column(), ")");
|
||||
else if (curPunc == "}") {
|
||||
while (ctx.type == "statement") ctx = popContext(state);
|
||||
if (ctx.type == "}") ctx = popContext(state);
|
||||
while (ctx.type == "statement") ctx = popContext(state);
|
||||
}
|
||||
else if (curPunc == ctx.type) popContext(state);
|
||||
else if (((ctx.type == "}" || ctx.type == "top") && curPunc != ';') || (ctx.type == "statement" && curPunc == "newstatement"))
|
||||
pushContext(state, stream.column(), "statement");
|
||||
state.startOfLine = false;
|
||||
return style;
|
||||
},
|
||||
|
||||
indent: function(state, textAfter) {
|
||||
if (state.tokenize != tokenBase && state.tokenize != null) return CodeMirror.Pass;
|
||||
var ctx = state.context, firstChar = textAfter && textAfter.charAt(0);
|
||||
if (ctx.type == "statement" && firstChar == "}") ctx = ctx.prev;
|
||||
var closing = firstChar == ctx.type;
|
||||
if (ctx.type == "statement") return ctx.indented + (firstChar == "{" ? 0 : statementIndentUnit);
|
||||
else if (ctx.align && (!dontAlignCalls || ctx.type != ")")) return ctx.column + (closing ? 0 : 1);
|
||||
else if (ctx.type == ")" && !closing) return ctx.indented + statementIndentUnit;
|
||||
else return ctx.indented + (closing ? 0 : indentUnit);
|
||||
},
|
||||
|
||||
electricChars: "{}",
|
||||
blockCommentStart: "/*",
|
||||
blockCommentEnd: "*/",
|
||||
lineComment: "//",
|
||||
fold: "brace"
|
||||
};
|
||||
});
|
||||
|
||||
function words(str) {
|
||||
var obj = {}, words = str.split(" ");
|
||||
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
|
||||
return obj;
|
||||
}
|
||||
var cKeywords = "auto if break int case long char register continue return default short do sizeof " +
|
||||
"double static else struct entry switch extern typedef float union for unsigned " +
|
||||
"goto while enum void const signed volatile";
|
||||
|
||||
function cppHook(stream, state) {
|
||||
if (!state.startOfLine) return false;
|
||||
for (;;) {
|
||||
if (stream.skipTo("\\")) {
|
||||
stream.next();
|
||||
if (stream.eol()) {
|
||||
state.tokenize = cppHook;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
stream.skipToEnd();
|
||||
state.tokenize = null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return "meta";
|
||||
}
|
||||
|
||||
function cpp11StringHook(stream, state) {
|
||||
stream.backUp(1);
|
||||
// Raw strings.
|
||||
if (stream.match(/(R|u8R|uR|UR|LR)/)) {
|
||||
var match = stream.match(/"([^\s\\()]{0,16})\(/);
|
||||
if (!match) {
|
||||
return false;
|
||||
}
|
||||
state.cpp11RawStringDelim = match[1];
|
||||
state.tokenize = tokenRawString;
|
||||
return tokenRawString(stream, state);
|
||||
}
|
||||
// Unicode strings/chars.
|
||||
if (stream.match(/(u8|u|U|L)/)) {
|
||||
if (stream.match(/["']/, /* eat */ false)) {
|
||||
return "string";
|
||||
}
|
||||
return false;
|
||||
}
|
||||
// Ignore this hook.
|
||||
stream.next();
|
||||
return false;
|
||||
}
|
||||
|
||||
// C#-style strings where "" escapes a quote.
|
||||
function tokenAtString(stream, state) {
|
||||
var next;
|
||||
while ((next = stream.next()) != null) {
|
||||
if (next == '"' && !stream.eat('"')) {
|
||||
state.tokenize = null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return "string";
|
||||
}
|
||||
|
||||
// C++11 raw string literal is <prefix>"<delim>( anything )<delim>", where
|
||||
// <delim> can be a string up to 16 characters long.
|
||||
function tokenRawString(stream, state) {
|
||||
// Escape characters that have special regex meanings.
|
||||
var delim = state.cpp11RawStringDelim.replace(/[^\w\s]/g, '\\$&');
|
||||
var match = stream.match(new RegExp(".*?\\)" + delim + '"'));
|
||||
if (match)
|
||||
state.tokenize = null;
|
||||
else
|
||||
stream.skipToEnd();
|
||||
return "string";
|
||||
}
|
||||
|
||||
function def(mimes, mode) {
|
||||
if (typeof mimes == "string") mimes = [mimes];
|
||||
var words = [];
|
||||
function add(obj) {
|
||||
if (obj) for (var prop in obj) if (obj.hasOwnProperty(prop))
|
||||
words.push(prop);
|
||||
}
|
||||
add(mode.keywords);
|
||||
add(mode.builtin);
|
||||
add(mode.atoms);
|
||||
if (words.length) {
|
||||
mode.helperType = mimes[0];
|
||||
CodeMirror.registerHelper("hintWords", mimes[0], words);
|
||||
}
|
||||
|
||||
for (var i = 0; i < mimes.length; ++i)
|
||||
CodeMirror.defineMIME(mimes[i], mode);
|
||||
}
|
||||
|
||||
def(["text/x-csrc", "text/x-c", "text/x-chdr"], {
|
||||
name: "clike",
|
||||
keywords: words(cKeywords),
|
||||
blockKeywords: words("case do else for if switch while struct"),
|
||||
atoms: words("null"),
|
||||
hooks: {"#": cppHook},
|
||||
modeProps: {fold: ["brace", "include"]}
|
||||
});
|
||||
|
||||
def(["text/x-c++src", "text/x-c++hdr"], {
|
||||
name: "clike",
|
||||
keywords: words(cKeywords + " asm dynamic_cast namespace reinterpret_cast try bool explicit new " +
|
||||
"static_cast typeid catch operator template typename class friend private " +
|
||||
"this using const_cast inline public throw virtual delete mutable protected " +
|
||||
"wchar_t alignas alignof constexpr decltype nullptr noexcept thread_local final " +
|
||||
"static_assert override"),
|
||||
blockKeywords: words("catch class do else finally for if struct switch try while"),
|
||||
atoms: words("true false null"),
|
||||
hooks: {
|
||||
"#": cppHook,
|
||||
"u": cpp11StringHook,
|
||||
"U": cpp11StringHook,
|
||||
"L": cpp11StringHook,
|
||||
"R": cpp11StringHook
|
||||
},
|
||||
modeProps: {fold: ["brace", "include"]}
|
||||
});
|
||||
def("text/x-java", {
|
||||
name: "clike",
|
||||
keywords: words("abstract assert boolean break byte case catch char class const continue default " +
|
||||
"do double else enum extends final finally float for goto if implements import " +
|
||||
"instanceof int interface long native new package private protected public " +
|
||||
"return short static strictfp super switch synchronized this throw throws transient " +
|
||||
"try void volatile while"),
|
||||
blockKeywords: words("catch class do else finally for if switch try while"),
|
||||
atoms: words("true false null"),
|
||||
hooks: {
|
||||
"@": function(stream) {
|
||||
stream.eatWhile(/[\w\$_]/);
|
||||
return "meta";
|
||||
}
|
||||
},
|
||||
modeProps: {fold: ["brace", "import"]}
|
||||
});
|
||||
def("text/x-csharp", {
|
||||
name: "clike",
|
||||
keywords: words("abstract as base break case catch checked class const continue" +
|
||||
" default delegate do else enum event explicit extern finally fixed for" +
|
||||
" foreach goto if implicit in interface internal is lock namespace new" +
|
||||
" operator out override params private protected public readonly ref return sealed" +
|
||||
" sizeof stackalloc static struct switch this throw try typeof unchecked" +
|
||||
" unsafe using virtual void volatile while add alias ascending descending dynamic from get" +
|
||||
" global group into join let orderby partial remove select set value var yield"),
|
||||
blockKeywords: words("catch class do else finally for foreach if struct switch try while"),
|
||||
builtin: words("Boolean Byte Char DateTime DateTimeOffset Decimal Double" +
|
||||
" Guid Int16 Int32 Int64 Object SByte Single String TimeSpan UInt16 UInt32" +
|
||||
" UInt64 bool byte char decimal double short int long object" +
|
||||
" sbyte float string ushort uint ulong"),
|
||||
atoms: words("true false null"),
|
||||
hooks: {
|
||||
"@": function(stream, state) {
|
||||
if (stream.eat('"')) {
|
||||
state.tokenize = tokenAtString;
|
||||
return tokenAtString(stream, state);
|
||||
}
|
||||
stream.eatWhile(/[\w\$_]/);
|
||||
return "meta";
|
||||
}
|
||||
}
|
||||
});
|
||||
def("text/x-scala", {
|
||||
name: "clike",
|
||||
keywords: words(
|
||||
|
||||
/* scala */
|
||||
"abstract case catch class def do else extends false final finally for forSome if " +
|
||||
"implicit import lazy match new null object override package private protected return " +
|
||||
"sealed super this throw trait try trye type val var while with yield _ : = => <- <: " +
|
||||
"<% >: # @ " +
|
||||
|
||||
/* package scala */
|
||||
"assert assume require print println printf readLine readBoolean readByte readShort " +
|
||||
"readChar readInt readLong readFloat readDouble " +
|
||||
|
||||
"AnyVal App Application Array BufferedIterator BigDecimal BigInt Char Console Either " +
|
||||
"Enumeration Equiv Error Exception Fractional Function IndexedSeq Integral Iterable " +
|
||||
"Iterator List Map Numeric Nil NotNull Option Ordered Ordering PartialFunction PartialOrdering " +
|
||||
"Product Proxy Range Responder Seq Serializable Set Specializable Stream StringBuilder " +
|
||||
"StringContext Symbol Throwable Traversable TraversableOnce Tuple Unit Vector :: #:: " +
|
||||
|
||||
/* package java.lang */
|
||||
"Boolean Byte Character CharSequence Class ClassLoader Cloneable Comparable " +
|
||||
"Compiler Double Exception Float Integer Long Math Number Object Package Pair Process " +
|
||||
"Runtime Runnable SecurityManager Short StackTraceElement StrictMath String " +
|
||||
"StringBuffer System Thread ThreadGroup ThreadLocal Throwable Triple Void"
|
||||
|
||||
|
||||
),
|
||||
multiLineStrings: true,
|
||||
blockKeywords: words("catch class do else finally for forSome if match switch try while"),
|
||||
atoms: words("true false null"),
|
||||
hooks: {
|
||||
"@": function(stream) {
|
||||
stream.eatWhile(/[\w\$_]/);
|
||||
return "meta";
|
||||
}
|
||||
}
|
||||
});
|
||||
def(["x-shader/x-vertex", "x-shader/x-fragment"], {
|
||||
name: "clike",
|
||||
keywords: words("float int bool void " +
|
||||
"vec2 vec3 vec4 ivec2 ivec3 ivec4 bvec2 bvec3 bvec4 " +
|
||||
"mat2 mat3 mat4 " +
|
||||
"sampler1D sampler2D sampler3D samplerCube " +
|
||||
"sampler1DShadow sampler2DShadow" +
|
||||
"const attribute uniform varying " +
|
||||
"break continue discard return " +
|
||||
"for while do if else struct " +
|
||||
"in out inout"),
|
||||
blockKeywords: words("for while do if else struct"),
|
||||
builtin: words("radians degrees sin cos tan asin acos atan " +
|
||||
"pow exp log exp2 sqrt inversesqrt " +
|
||||
"abs sign floor ceil fract mod min max clamp mix step smootstep " +
|
||||
"length distance dot cross normalize ftransform faceforward " +
|
||||
"reflect refract matrixCompMult " +
|
||||
"lessThan lessThanEqual greaterThan greaterThanEqual " +
|
||||
"equal notEqual any all not " +
|
||||
"texture1D texture1DProj texture1DLod texture1DProjLod " +
|
||||
"texture2D texture2DProj texture2DLod texture2DProjLod " +
|
||||
"texture3D texture3DProj texture3DLod texture3DProjLod " +
|
||||
"textureCube textureCubeLod " +
|
||||
"shadow1D shadow2D shadow1DProj shadow2DProj " +
|
||||
"shadow1DLod shadow2DLod shadow1DProjLod shadow2DProjLod " +
|
||||
"dFdx dFdy fwidth " +
|
||||
"noise1 noise2 noise3 noise4"),
|
||||
atoms: words("true false " +
|
||||
"gl_FragColor gl_SecondaryColor gl_Normal gl_Vertex " +
|
||||
"gl_MultiTexCoord0 gl_MultiTexCoord1 gl_MultiTexCoord2 gl_MultiTexCoord3 " +
|
||||
"gl_MultiTexCoord4 gl_MultiTexCoord5 gl_MultiTexCoord6 gl_MultiTexCoord7 " +
|
||||
"gl_FogCoord " +
|
||||
"gl_Position gl_PointSize gl_ClipVertex " +
|
||||
"gl_FrontColor gl_BackColor gl_FrontSecondaryColor gl_BackSecondaryColor " +
|
||||
"gl_TexCoord gl_FogFragCoord " +
|
||||
"gl_FragCoord gl_FrontFacing " +
|
||||
"gl_FragColor gl_FragData gl_FragDepth " +
|
||||
"gl_ModelViewMatrix gl_ProjectionMatrix gl_ModelViewProjectionMatrix " +
|
||||
"gl_TextureMatrix gl_NormalMatrix gl_ModelViewMatrixInverse " +
|
||||
"gl_ProjectionMatrixInverse gl_ModelViewProjectionMatrixInverse " +
|
||||
"gl_TexureMatrixTranspose gl_ModelViewMatrixInverseTranspose " +
|
||||
"gl_ProjectionMatrixInverseTranspose " +
|
||||
"gl_ModelViewProjectionMatrixInverseTranspose " +
|
||||
"gl_TextureMatrixInverseTranspose " +
|
||||
"gl_NormalScale gl_DepthRange gl_ClipPlane " +
|
||||
"gl_Point gl_FrontMaterial gl_BackMaterial gl_LightSource gl_LightModel " +
|
||||
"gl_FrontLightModelProduct gl_BackLightModelProduct " +
|
||||
"gl_TextureColor gl_EyePlaneS gl_EyePlaneT gl_EyePlaneR gl_EyePlaneQ " +
|
||||
"gl_FogParameters " +
|
||||
"gl_MaxLights gl_MaxClipPlanes gl_MaxTextureUnits gl_MaxTextureCoords " +
|
||||
"gl_MaxVertexAttribs gl_MaxVertexUniformComponents gl_MaxVaryingFloats " +
|
||||
"gl_MaxVertexTextureImageUnits gl_MaxTextureImageUnits " +
|
||||
"gl_MaxFragmentUniformComponents gl_MaxCombineTextureImageUnits " +
|
||||
"gl_MaxDrawBuffers"),
|
||||
hooks: {"#": cppHook},
|
||||
modeProps: {fold: ["brace", "include"]}
|
||||
});
|
||||
|
||||
def("text/x-nesc", {
|
||||
name: "clike",
|
||||
keywords: words(cKeywords + "as atomic async call command component components configuration event generic " +
|
||||
"implementation includes interface module new norace nx_struct nx_union post provides " +
|
||||
"signal task uses abstract extends"),
|
||||
blockKeywords: words("case do else for if switch while struct"),
|
||||
atoms: words("null"),
|
||||
hooks: {"#": cppHook},
|
||||
modeProps: {fold: ["brace", "include"]}
|
||||
});
|
||||
|
||||
});
|
||||
@@ -0,0 +1,309 @@
|
||||
/* BASICS */
|
||||
|
||||
.CodeMirror {
|
||||
/* Set height, width, borders, and global font properties here */
|
||||
font-family: monospace;
|
||||
height: 300px;
|
||||
border:1px solid #ddd;
|
||||
}
|
||||
.CodeMirror-scroll {
|
||||
/* Set scrolling behaviour here */
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
/* PADDING */
|
||||
|
||||
.CodeMirror-lines {
|
||||
padding: 4px 0; /* Vertical padding around content */
|
||||
}
|
||||
.CodeMirror pre {
|
||||
padding: 0 4px; /* Horizontal padding of content */
|
||||
}
|
||||
|
||||
.CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
|
||||
background-color: white; /* The little square between H and V scrollbars */
|
||||
}
|
||||
|
||||
/* GUTTER */
|
||||
|
||||
.CodeMirror-gutters {
|
||||
border-right: 1px solid #ddd;
|
||||
background-color: #f7f7f7;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.CodeMirror-linenumbers {}
|
||||
.CodeMirror-linenumber {
|
||||
padding: 0 3px 0 5px;
|
||||
min-width: 20px;
|
||||
text-align: right;
|
||||
color: #999;
|
||||
-moz-box-sizing: content-box;
|
||||
box-sizing: content-box;
|
||||
}
|
||||
|
||||
.CodeMirror-guttermarker { color: black; }
|
||||
.CodeMirror-guttermarker-subtle { color: #999; }
|
||||
|
||||
/* CURSOR */
|
||||
|
||||
.CodeMirror div.CodeMirror-cursor {
|
||||
border-left: 1px solid black;
|
||||
}
|
||||
/* Shown when moving in bi-directional text */
|
||||
.CodeMirror div.CodeMirror-secondarycursor {
|
||||
border-left: 1px solid silver;
|
||||
}
|
||||
.CodeMirror.cm-keymap-fat-cursor div.CodeMirror-cursor {
|
||||
width: auto;
|
||||
border: 0;
|
||||
background: #7e7;
|
||||
}
|
||||
.CodeMirror.cm-keymap-fat-cursor div.CodeMirror-cursors {
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.cm-animate-fat-cursor {
|
||||
width: auto;
|
||||
border: 0;
|
||||
-webkit-animation: blink 1.06s steps(1) infinite;
|
||||
-moz-animation: blink 1.06s steps(1) infinite;
|
||||
animation: blink 1.06s steps(1) infinite;
|
||||
}
|
||||
@-moz-keyframes blink {
|
||||
0% { background: #7e7; }
|
||||
50% { background: none; }
|
||||
100% { background: #7e7; }
|
||||
}
|
||||
@-webkit-keyframes blink {
|
||||
0% { background: #7e7; }
|
||||
50% { background: none; }
|
||||
100% { background: #7e7; }
|
||||
}
|
||||
@keyframes blink {
|
||||
0% { background: #7e7; }
|
||||
50% { background: none; }
|
||||
100% { background: #7e7; }
|
||||
}
|
||||
|
||||
/* Can style cursor different in overwrite (non-insert) mode */
|
||||
div.CodeMirror-overwrite div.CodeMirror-cursor {}
|
||||
|
||||
.cm-tab { display: inline-block; }
|
||||
|
||||
.CodeMirror-ruler {
|
||||
border-left: 1px solid #ccc;
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
/* DEFAULT THEME */
|
||||
|
||||
.cm-s-default .cm-keyword {color: #708;}
|
||||
.cm-s-default .cm-atom {color: #219;}
|
||||
.cm-s-default .cm-number {color: #164;}
|
||||
.cm-s-default .cm-def {color: #00f;}
|
||||
.cm-s-default .cm-variable,
|
||||
.cm-s-default .cm-punctuation,
|
||||
.cm-s-default .cm-property,
|
||||
.cm-s-default .cm-operator {}
|
||||
.cm-s-default .cm-variable-2 {color: #05a;}
|
||||
.cm-s-default .cm-variable-3 {color: #085;}
|
||||
.cm-s-default .cm-comment {color: #a50;}
|
||||
.cm-s-default .cm-string {color: #a11;}
|
||||
.cm-s-default .cm-string-2 {color: #f50;}
|
||||
.cm-s-default .cm-meta {color: #555;}
|
||||
.cm-s-default .cm-qualifier {color: #555;}
|
||||
.cm-s-default .cm-builtin {color: #30a;}
|
||||
.cm-s-default .cm-bracket {color: #997;}
|
||||
.cm-s-default .cm-tag {color: #170;}
|
||||
.cm-s-default .cm-attribute {color: #00c;}
|
||||
.cm-s-default .cm-header {color: blue;}
|
||||
.cm-s-default .cm-quote {color: #090;}
|
||||
.cm-s-default .cm-hr {color: #999;}
|
||||
.cm-s-default .cm-link {color: #00c;}
|
||||
|
||||
.cm-negative {color: #d44;}
|
||||
.cm-positive {color: #292;}
|
||||
.cm-header, .cm-strong {font-weight: bold;}
|
||||
.cm-em {font-style: italic;}
|
||||
.cm-link {text-decoration: underline;}
|
||||
|
||||
.cm-s-default .cm-error {color: #f00;}
|
||||
.cm-invalidchar {color: #f00;}
|
||||
|
||||
/* Default styles for common addons */
|
||||
|
||||
div.CodeMirror span.CodeMirror-matchingbracket {color: #0f0;}
|
||||
div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
|
||||
.CodeMirror-matchingtag { background: rgba(255, 150, 0, .3); }
|
||||
.CodeMirror-activeline-background {background: #e8f2ff;}
|
||||
|
||||
/* STOP */
|
||||
|
||||
/* The rest of this file contains styles related to the mechanics of
|
||||
the editor. You probably shouldn't touch them. */
|
||||
|
||||
.CodeMirror {
|
||||
line-height: 1;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
background: white;
|
||||
}
|
||||
|
||||
.CodeMirror-scroll {
|
||||
/* 30px is the magic margin used to hide the element's real scrollbars */
|
||||
/* See overflow: hidden in .CodeMirror */
|
||||
margin-bottom: -30px; margin-right: -30px;
|
||||
padding-bottom: 30px;
|
||||
height: 100%;
|
||||
outline: none; /* Prevent dragging from highlighting the element */
|
||||
position: relative;
|
||||
-moz-box-sizing: content-box;
|
||||
box-sizing: content-box;
|
||||
}
|
||||
.CodeMirror-sizer {
|
||||
position: relative;
|
||||
border-right: 30px solid transparent;
|
||||
-moz-box-sizing: content-box;
|
||||
box-sizing: content-box;
|
||||
}
|
||||
|
||||
/* The fake, visible scrollbars. Used to force redraw during scrolling
|
||||
before actuall scrolling happens, thus preventing shaking and
|
||||
flickering artifacts. */
|
||||
.CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
|
||||
position: absolute;
|
||||
z-index: 6;
|
||||
display: none;
|
||||
}
|
||||
.CodeMirror-vscrollbar {
|
||||
right: 0; top: 0;
|
||||
overflow-x: hidden;
|
||||
overflow-y: scroll;
|
||||
}
|
||||
.CodeMirror-hscrollbar {
|
||||
bottom: 0; left: 0;
|
||||
overflow-y: hidden;
|
||||
overflow-x: scroll;
|
||||
}
|
||||
.CodeMirror-scrollbar-filler {
|
||||
right: 0; bottom: 0;
|
||||
}
|
||||
.CodeMirror-gutter-filler {
|
||||
left: 0; bottom: 0;
|
||||
}
|
||||
|
||||
.CodeMirror-gutters {
|
||||
position: absolute; left: 0; top: 0;
|
||||
padding-bottom: 30px;
|
||||
z-index: 3;
|
||||
}
|
||||
.CodeMirror-gutter {
|
||||
white-space: normal;
|
||||
height: 100%;
|
||||
-moz-box-sizing: content-box;
|
||||
box-sizing: content-box;
|
||||
padding-bottom: 30px;
|
||||
margin-bottom: -32px;
|
||||
display: inline-block;
|
||||
/* Hack to make IE7 behave */
|
||||
*zoom:1;
|
||||
*display:inline;
|
||||
}
|
||||
.CodeMirror-gutter-elt {
|
||||
position: absolute;
|
||||
cursor: default;
|
||||
z-index: 4;
|
||||
}
|
||||
|
||||
.CodeMirror-lines {
|
||||
cursor: text;
|
||||
min-height: 1px; /* prevents collapsing before first draw */
|
||||
}
|
||||
.CodeMirror pre {
|
||||
/* Reset some styles that the rest of the page might have set */
|
||||
-moz-border-radius: 0; -webkit-border-radius: 0; border-radius: 0;
|
||||
border-width: 0;
|
||||
background: transparent;
|
||||
font-family: inherit;
|
||||
font-size: inherit;
|
||||
margin: 0;
|
||||
white-space: pre;
|
||||
word-wrap: normal;
|
||||
line-height: inherit;
|
||||
color: inherit;
|
||||
z-index: 2;
|
||||
position: relative;
|
||||
overflow: visible;
|
||||
}
|
||||
.CodeMirror-wrap pre {
|
||||
word-wrap: break-word;
|
||||
white-space: pre-wrap;
|
||||
word-break: normal;
|
||||
}
|
||||
|
||||
.CodeMirror-linebackground {
|
||||
position: absolute;
|
||||
left: 0; right: 0; top: 0; bottom: 0;
|
||||
z-index: 0;
|
||||
}
|
||||
|
||||
.CodeMirror-linewidget {
|
||||
position: relative;
|
||||
z-index: 2;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.CodeMirror-widget {}
|
||||
|
||||
.CodeMirror-wrap .CodeMirror-scroll {
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
.CodeMirror-measure {
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
height: 0;
|
||||
overflow: hidden;
|
||||
visibility: hidden;
|
||||
}
|
||||
.CodeMirror-measure pre { position: static; }
|
||||
|
||||
.CodeMirror div.CodeMirror-cursor {
|
||||
position: absolute;
|
||||
border-right: none;
|
||||
width: 0;
|
||||
}
|
||||
|
||||
div.CodeMirror-cursors {
|
||||
visibility: hidden;
|
||||
position: relative;
|
||||
z-index: 3;
|
||||
}
|
||||
.CodeMirror-focused div.CodeMirror-cursors {
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
.CodeMirror-selected { background: #d9d9d9; }
|
||||
.CodeMirror-focused .CodeMirror-selected { background: #d7d4f0; }
|
||||
.CodeMirror-crosshair { cursor: crosshair; }
|
||||
|
||||
.cm-searching {
|
||||
background: #ffa;
|
||||
background: rgba(255, 255, 0, .4);
|
||||
}
|
||||
|
||||
/* IE7 hack to prevent it from returning funny offsetTops on the spans */
|
||||
.CodeMirror span { *vertical-align: text-bottom; }
|
||||
|
||||
/* Used to force a border model for a node */
|
||||
.cm-force-border { padding-right: .1px; }
|
||||
|
||||
@media print {
|
||||
/* Hide the cursor when printing */
|
||||
.CodeMirror div.CodeMirror-cursors {
|
||||
visibility: hidden;
|
||||
}
|
||||
}
|
||||
|
||||
/* Help users use markselection to safely style text background */
|
||||
span.CodeMirror-selectedtext { background: none; }
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,717 @@
|
||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
CodeMirror.defineMode("css", function(config, parserConfig) {
|
||||
if (!parserConfig.propertyKeywords) parserConfig = CodeMirror.resolveMode("text/css");
|
||||
|
||||
var indentUnit = config.indentUnit,
|
||||
tokenHooks = parserConfig.tokenHooks,
|
||||
mediaTypes = parserConfig.mediaTypes || {},
|
||||
mediaFeatures = parserConfig.mediaFeatures || {},
|
||||
propertyKeywords = parserConfig.propertyKeywords || {},
|
||||
nonStandardPropertyKeywords = parserConfig.nonStandardPropertyKeywords || {},
|
||||
colorKeywords = parserConfig.colorKeywords || {},
|
||||
valueKeywords = parserConfig.valueKeywords || {},
|
||||
fontProperties = parserConfig.fontProperties || {},
|
||||
allowNested = parserConfig.allowNested;
|
||||
|
||||
var type, override;
|
||||
function ret(style, tp) { type = tp; return style; }
|
||||
|
||||
// Tokenizers
|
||||
|
||||
function tokenBase(stream, state) {
|
||||
var ch = stream.next();
|
||||
if (tokenHooks[ch]) {
|
||||
var result = tokenHooks[ch](stream, state);
|
||||
if (result !== false) return result;
|
||||
}
|
||||
if (ch == "@") {
|
||||
stream.eatWhile(/[\w\\\-]/);
|
||||
return ret("def", stream.current());
|
||||
} else if (ch == "=" || (ch == "~" || ch == "|") && stream.eat("=")) {
|
||||
return ret(null, "compare");
|
||||
} else if (ch == "\"" || ch == "'") {
|
||||
state.tokenize = tokenString(ch);
|
||||
return state.tokenize(stream, state);
|
||||
} else if (ch == "#") {
|
||||
stream.eatWhile(/[\w\\\-]/);
|
||||
return ret("atom", "hash");
|
||||
} else if (ch == "!") {
|
||||
stream.match(/^\s*\w*/);
|
||||
return ret("keyword", "important");
|
||||
} else if (/\d/.test(ch) || ch == "." && stream.eat(/\d/)) {
|
||||
stream.eatWhile(/[\w.%]/);
|
||||
return ret("number", "unit");
|
||||
} else if (ch === "-") {
|
||||
if (/[\d.]/.test(stream.peek())) {
|
||||
stream.eatWhile(/[\w.%]/);
|
||||
return ret("number", "unit");
|
||||
} else if (stream.match(/^\w+-/)) {
|
||||
return ret("meta", "meta");
|
||||
}
|
||||
} else if (/[,+>*\/]/.test(ch)) {
|
||||
return ret(null, "select-op");
|
||||
} else if (ch == "." && stream.match(/^-?[_a-z][_a-z0-9-]*/i)) {
|
||||
return ret("qualifier", "qualifier");
|
||||
} else if (/[:;{}\[\]\(\)]/.test(ch)) {
|
||||
return ret(null, ch);
|
||||
} else if (ch == "u" && stream.match("rl(")) {
|
||||
stream.backUp(1);
|
||||
state.tokenize = tokenParenthesized;
|
||||
return ret("property", "word");
|
||||
} else if (/[\w\\\-]/.test(ch)) {
|
||||
stream.eatWhile(/[\w\\\-]/);
|
||||
return ret("property", "word");
|
||||
} else {
|
||||
return ret(null, null);
|
||||
}
|
||||
}
|
||||
|
||||
function tokenString(quote) {
|
||||
return function(stream, state) {
|
||||
var escaped = false, ch;
|
||||
while ((ch = stream.next()) != null) {
|
||||
if (ch == quote && !escaped) {
|
||||
if (quote == ")") stream.backUp(1);
|
||||
break;
|
||||
}
|
||||
escaped = !escaped && ch == "\\";
|
||||
}
|
||||
if (ch == quote || !escaped && quote != ")") state.tokenize = null;
|
||||
return ret("string", "string");
|
||||
};
|
||||
}
|
||||
|
||||
function tokenParenthesized(stream, state) {
|
||||
stream.next(); // Must be '('
|
||||
if (!stream.match(/\s*[\"\')]/, false))
|
||||
state.tokenize = tokenString(")");
|
||||
else
|
||||
state.tokenize = null;
|
||||
return ret(null, "(");
|
||||
}
|
||||
|
||||
// Context management
|
||||
|
||||
function Context(type, indent, prev) {
|
||||
this.type = type;
|
||||
this.indent = indent;
|
||||
this.prev = prev;
|
||||
}
|
||||
|
||||
function pushContext(state, stream, type) {
|
||||
state.context = new Context(type, stream.indentation() + indentUnit, state.context);
|
||||
return type;
|
||||
}
|
||||
|
||||
function popContext(state) {
|
||||
state.context = state.context.prev;
|
||||
return state.context.type;
|
||||
}
|
||||
|
||||
function pass(type, stream, state) {
|
||||
return states[state.context.type](type, stream, state);
|
||||
}
|
||||
function popAndPass(type, stream, state, n) {
|
||||
for (var i = n || 1; i > 0; i--)
|
||||
state.context = state.context.prev;
|
||||
return pass(type, stream, state);
|
||||
}
|
||||
|
||||
// Parser
|
||||
|
||||
function wordAsValue(stream) {
|
||||
var word = stream.current().toLowerCase();
|
||||
if (valueKeywords.hasOwnProperty(word))
|
||||
override = "atom";
|
||||
else if (colorKeywords.hasOwnProperty(word))
|
||||
override = "keyword";
|
||||
else
|
||||
override = "variable";
|
||||
}
|
||||
|
||||
var states = {};
|
||||
|
||||
states.top = function(type, stream, state) {
|
||||
if (type == "{") {
|
||||
return pushContext(state, stream, "block");
|
||||
} else if (type == "}" && state.context.prev) {
|
||||
return popContext(state);
|
||||
} else if (type == "@media") {
|
||||
return pushContext(state, stream, "media");
|
||||
} else if (type == "@font-face") {
|
||||
return "font_face_before";
|
||||
} else if (/^@(-(moz|ms|o|webkit)-)?keyframes$/.test(type)) {
|
||||
return "keyframes";
|
||||
} else if (type && type.charAt(0) == "@") {
|
||||
return pushContext(state, stream, "at");
|
||||
} else if (type == "hash") {
|
||||
override = "builtin";
|
||||
} else if (type == "word") {
|
||||
override = "tag";
|
||||
} else if (type == "variable-definition") {
|
||||
return "maybeprop";
|
||||
} else if (type == "interpolation") {
|
||||
return pushContext(state, stream, "interpolation");
|
||||
} else if (type == ":") {
|
||||
return "pseudo";
|
||||
} else if (allowNested && type == "(") {
|
||||
return pushContext(state, stream, "parens");
|
||||
}
|
||||
return state.context.type;
|
||||
};
|
||||
|
||||
states.block = function(type, stream, state) {
|
||||
if (type == "word") {
|
||||
var word = stream.current().toLowerCase();
|
||||
if (propertyKeywords.hasOwnProperty(word)) {
|
||||
override = "property";
|
||||
return "maybeprop";
|
||||
} else if (nonStandardPropertyKeywords.hasOwnProperty(word)) {
|
||||
override = "string-2";
|
||||
return "maybeprop";
|
||||
} else if (allowNested) {
|
||||
override = stream.match(/^\s*:/, false) ? "property" : "tag";
|
||||
return "block";
|
||||
} else {
|
||||
override += " error";
|
||||
return "maybeprop";
|
||||
}
|
||||
} else if (type == "meta") {
|
||||
return "block";
|
||||
} else if (!allowNested && (type == "hash" || type == "qualifier")) {
|
||||
override = "error";
|
||||
return "block";
|
||||
} else {
|
||||
return states.top(type, stream, state);
|
||||
}
|
||||
};
|
||||
|
||||
states.maybeprop = function(type, stream, state) {
|
||||
if (type == ":") return pushContext(state, stream, "prop");
|
||||
return pass(type, stream, state);
|
||||
};
|
||||
|
||||
states.prop = function(type, stream, state) {
|
||||
if (type == ";") return popContext(state);
|
||||
if (type == "{" && allowNested) return pushContext(state, stream, "propBlock");
|
||||
if (type == "}" || type == "{") return popAndPass(type, stream, state);
|
||||
if (type == "(") return pushContext(state, stream, "parens");
|
||||
|
||||
if (type == "hash" && !/^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/.test(stream.current())) {
|
||||
override += " error";
|
||||
} else if (type == "word") {
|
||||
wordAsValue(stream);
|
||||
} else if (type == "interpolation") {
|
||||
return pushContext(state, stream, "interpolation");
|
||||
}
|
||||
return "prop";
|
||||
};
|
||||
|
||||
states.propBlock = function(type, _stream, state) {
|
||||
if (type == "}") return popContext(state);
|
||||
if (type == "word") { override = "property"; return "maybeprop"; }
|
||||
return state.context.type;
|
||||
};
|
||||
|
||||
states.parens = function(type, stream, state) {
|
||||
if (type == "{" || type == "}") return popAndPass(type, stream, state);
|
||||
if (type == ")") return popContext(state);
|
||||
if (type == "(") return pushContext(state, stream, "parens");
|
||||
if (type == "word") wordAsValue(stream);
|
||||
return "parens";
|
||||
};
|
||||
|
||||
states.pseudo = function(type, stream, state) {
|
||||
if (type == "word") {
|
||||
override = "variable-3";
|
||||
return state.context.type;
|
||||
}
|
||||
return pass(type, stream, state);
|
||||
};
|
||||
|
||||
states.media = function(type, stream, state) {
|
||||
if (type == "(") return pushContext(state, stream, "media_parens");
|
||||
if (type == "}") return popAndPass(type, stream, state);
|
||||
if (type == "{") return popContext(state) && pushContext(state, stream, allowNested ? "block" : "top");
|
||||
|
||||
if (type == "word") {
|
||||
var word = stream.current().toLowerCase();
|
||||
if (word == "only" || word == "not" || word == "and")
|
||||
override = "keyword";
|
||||
else if (mediaTypes.hasOwnProperty(word))
|
||||
override = "attribute";
|
||||
else if (mediaFeatures.hasOwnProperty(word))
|
||||
override = "property";
|
||||
else
|
||||
override = "error";
|
||||
}
|
||||
return state.context.type;
|
||||
};
|
||||
|
||||
states.media_parens = function(type, stream, state) {
|
||||
if (type == ")") return popContext(state);
|
||||
if (type == "{" || type == "}") return popAndPass(type, stream, state, 2);
|
||||
return states.media(type, stream, state);
|
||||
};
|
||||
|
||||
states.font_face_before = function(type, stream, state) {
|
||||
if (type == "{")
|
||||
return pushContext(state, stream, "font_face");
|
||||
return pass(type, stream, state);
|
||||
};
|
||||
|
||||
states.font_face = function(type, stream, state) {
|
||||
if (type == "}") return popContext(state);
|
||||
if (type == "word") {
|
||||
if (!fontProperties.hasOwnProperty(stream.current().toLowerCase()))
|
||||
override = "error";
|
||||
else
|
||||
override = "property";
|
||||
return "maybeprop";
|
||||
}
|
||||
return "font_face";
|
||||
};
|
||||
|
||||
states.keyframes = function(type, stream, state) {
|
||||
if (type == "word") { override = "variable"; return "keyframes"; }
|
||||
if (type == "{") return pushContext(state, stream, "top");
|
||||
return pass(type, stream, state);
|
||||
};
|
||||
|
||||
states.at = function(type, stream, state) {
|
||||
if (type == ";") return popContext(state);
|
||||
if (type == "{" || type == "}") return popAndPass(type, stream, state);
|
||||
if (type == "word") override = "tag";
|
||||
else if (type == "hash") override = "builtin";
|
||||
return "at";
|
||||
};
|
||||
|
||||
states.interpolation = function(type, stream, state) {
|
||||
if (type == "}") return popContext(state);
|
||||
if (type == "{" || type == ";") return popAndPass(type, stream, state);
|
||||
if (type != "variable") override = "error";
|
||||
return "interpolation";
|
||||
};
|
||||
|
||||
return {
|
||||
startState: function(base) {
|
||||
return {tokenize: null,
|
||||
state: "top",
|
||||
context: new Context("top", base || 0, null)};
|
||||
},
|
||||
|
||||
token: function(stream, state) {
|
||||
if (!state.tokenize && stream.eatSpace()) return null;
|
||||
var style = (state.tokenize || tokenBase)(stream, state);
|
||||
if (style && typeof style == "object") {
|
||||
type = style[1];
|
||||
style = style[0];
|
||||
}
|
||||
override = style;
|
||||
state.state = states[state.state](type, stream, state);
|
||||
return override;
|
||||
},
|
||||
|
||||
indent: function(state, textAfter) {
|
||||
var cx = state.context, ch = textAfter && textAfter.charAt(0);
|
||||
var indent = cx.indent;
|
||||
if (cx.type == "prop" && (ch == "}" || ch == ")")) cx = cx.prev;
|
||||
if (cx.prev &&
|
||||
(ch == "}" && (cx.type == "block" || cx.type == "top" || cx.type == "interpolation" || cx.type == "font_face") ||
|
||||
ch == ")" && (cx.type == "parens" || cx.type == "media_parens") ||
|
||||
ch == "{" && (cx.type == "at" || cx.type == "media"))) {
|
||||
indent = cx.indent - indentUnit;
|
||||
cx = cx.prev;
|
||||
}
|
||||
return indent;
|
||||
},
|
||||
|
||||
electricChars: "}",
|
||||
blockCommentStart: "/*",
|
||||
blockCommentEnd: "*/",
|
||||
fold: "brace"
|
||||
};
|
||||
});
|
||||
|
||||
function keySet(array) {
|
||||
var keys = {};
|
||||
for (var i = 0; i < array.length; ++i) {
|
||||
keys[array[i]] = true;
|
||||
}
|
||||
return keys;
|
||||
}
|
||||
|
||||
var mediaTypes_ = [
|
||||
"all", "aural", "braille", "handheld", "print", "projection", "screen",
|
||||
"tty", "tv", "embossed"
|
||||
], mediaTypes = keySet(mediaTypes_);
|
||||
|
||||
var mediaFeatures_ = [
|
||||
"width", "min-width", "max-width", "height", "min-height", "max-height",
|
||||
"device-width", "min-device-width", "max-device-width", "device-height",
|
||||
"min-device-height", "max-device-height", "aspect-ratio",
|
||||
"min-aspect-ratio", "max-aspect-ratio", "device-aspect-ratio",
|
||||
"min-device-aspect-ratio", "max-device-aspect-ratio", "color", "min-color",
|
||||
"max-color", "color-index", "min-color-index", "max-color-index",
|
||||
"monochrome", "min-monochrome", "max-monochrome", "resolution",
|
||||
"min-resolution", "max-resolution", "scan", "grid"
|
||||
], mediaFeatures = keySet(mediaFeatures_);
|
||||
|
||||
var propertyKeywords_ = [
|
||||
"align-content", "align-items", "align-self", "alignment-adjust",
|
||||
"alignment-baseline", "anchor-point", "animation", "animation-delay",
|
||||
"animation-direction", "animation-duration", "animation-fill-mode",
|
||||
"animation-iteration-count", "animation-name", "animation-play-state",
|
||||
"animation-timing-function", "appearance", "azimuth", "backface-visibility",
|
||||
"background", "background-attachment", "background-clip", "background-color",
|
||||
"background-image", "background-origin", "background-position",
|
||||
"background-repeat", "background-size", "baseline-shift", "binding",
|
||||
"bleed", "bookmark-label", "bookmark-level", "bookmark-state",
|
||||
"bookmark-target", "border", "border-bottom", "border-bottom-color",
|
||||
"border-bottom-left-radius", "border-bottom-right-radius",
|
||||
"border-bottom-style", "border-bottom-width", "border-collapse",
|
||||
"border-color", "border-image", "border-image-outset",
|
||||
"border-image-repeat", "border-image-slice", "border-image-source",
|
||||
"border-image-width", "border-left", "border-left-color",
|
||||
"border-left-style", "border-left-width", "border-radius", "border-right",
|
||||
"border-right-color", "border-right-style", "border-right-width",
|
||||
"border-spacing", "border-style", "border-top", "border-top-color",
|
||||
"border-top-left-radius", "border-top-right-radius", "border-top-style",
|
||||
"border-top-width", "border-width", "bottom", "box-decoration-break",
|
||||
"box-shadow", "box-sizing", "break-after", "break-before", "break-inside",
|
||||
"caption-side", "clear", "clip", "color", "color-profile", "column-count",
|
||||
"column-fill", "column-gap", "column-rule", "column-rule-color",
|
||||
"column-rule-style", "column-rule-width", "column-span", "column-width",
|
||||
"columns", "content", "counter-increment", "counter-reset", "crop", "cue",
|
||||
"cue-after", "cue-before", "cursor", "direction", "display",
|
||||
"dominant-baseline", "drop-initial-after-adjust",
|
||||
"drop-initial-after-align", "drop-initial-before-adjust",
|
||||
"drop-initial-before-align", "drop-initial-size", "drop-initial-value",
|
||||
"elevation", "empty-cells", "fit", "fit-position", "flex", "flex-basis",
|
||||
"flex-direction", "flex-flow", "flex-grow", "flex-shrink", "flex-wrap",
|
||||
"float", "float-offset", "flow-from", "flow-into", "font", "font-feature-settings",
|
||||
"font-family", "font-kerning", "font-language-override", "font-size", "font-size-adjust",
|
||||
"font-stretch", "font-style", "font-synthesis", "font-variant",
|
||||
"font-variant-alternates", "font-variant-caps", "font-variant-east-asian",
|
||||
"font-variant-ligatures", "font-variant-numeric", "font-variant-position",
|
||||
"font-weight", "grid", "grid-area", "grid-auto-columns", "grid-auto-flow",
|
||||
"grid-auto-position", "grid-auto-rows", "grid-column", "grid-column-end",
|
||||
"grid-column-start", "grid-row", "grid-row-end", "grid-row-start",
|
||||
"grid-template", "grid-template-areas", "grid-template-columns",
|
||||
"grid-template-rows", "hanging-punctuation", "height", "hyphens",
|
||||
"icon", "image-orientation", "image-rendering", "image-resolution",
|
||||
"inline-box-align", "justify-content", "left", "letter-spacing",
|
||||
"line-break", "line-height", "line-stacking", "line-stacking-ruby",
|
||||
"line-stacking-shift", "line-stacking-strategy", "list-style",
|
||||
"list-style-image", "list-style-position", "list-style-type", "margin",
|
||||
"margin-bottom", "margin-left", "margin-right", "margin-top",
|
||||
"marker-offset", "marks", "marquee-direction", "marquee-loop",
|
||||
"marquee-play-count", "marquee-speed", "marquee-style", "max-height",
|
||||
"max-width", "min-height", "min-width", "move-to", "nav-down", "nav-index",
|
||||
"nav-left", "nav-right", "nav-up", "object-fit", "object-position",
|
||||
"opacity", "order", "orphans", "outline",
|
||||
"outline-color", "outline-offset", "outline-style", "outline-width",
|
||||
"overflow", "overflow-style", "overflow-wrap", "overflow-x", "overflow-y",
|
||||
"padding", "padding-bottom", "padding-left", "padding-right", "padding-top",
|
||||
"page", "page-break-after", "page-break-before", "page-break-inside",
|
||||
"page-policy", "pause", "pause-after", "pause-before", "perspective",
|
||||
"perspective-origin", "pitch", "pitch-range", "play-during", "position",
|
||||
"presentation-level", "punctuation-trim", "quotes", "region-break-after",
|
||||
"region-break-before", "region-break-inside", "region-fragment",
|
||||
"rendering-intent", "resize", "rest", "rest-after", "rest-before", "richness",
|
||||
"right", "rotation", "rotation-point", "ruby-align", "ruby-overhang",
|
||||
"ruby-position", "ruby-span", "shape-image-threshold", "shape-inside", "shape-margin",
|
||||
"shape-outside", "size", "speak", "speak-as", "speak-header",
|
||||
"speak-numeral", "speak-punctuation", "speech-rate", "stress", "string-set",
|
||||
"tab-size", "table-layout", "target", "target-name", "target-new",
|
||||
"target-position", "text-align", "text-align-last", "text-decoration",
|
||||
"text-decoration-color", "text-decoration-line", "text-decoration-skip",
|
||||
"text-decoration-style", "text-emphasis", "text-emphasis-color",
|
||||
"text-emphasis-position", "text-emphasis-style", "text-height",
|
||||
"text-indent", "text-justify", "text-outline", "text-overflow", "text-shadow",
|
||||
"text-size-adjust", "text-space-collapse", "text-transform", "text-underline-position",
|
||||
"text-wrap", "top", "transform", "transform-origin", "transform-style",
|
||||
"transition", "transition-delay", "transition-duration",
|
||||
"transition-property", "transition-timing-function", "unicode-bidi",
|
||||
"vertical-align", "visibility", "voice-balance", "voice-duration",
|
||||
"voice-family", "voice-pitch", "voice-range", "voice-rate", "voice-stress",
|
||||
"voice-volume", "volume", "white-space", "widows", "width", "word-break",
|
||||
"word-spacing", "word-wrap", "z-index",
|
||||
// SVG-specific
|
||||
"clip-path", "clip-rule", "mask", "enable-background", "filter", "flood-color",
|
||||
"flood-opacity", "lighting-color", "stop-color", "stop-opacity", "pointer-events",
|
||||
"color-interpolation", "color-interpolation-filters",
|
||||
"color-rendering", "fill", "fill-opacity", "fill-rule", "image-rendering",
|
||||
"marker", "marker-end", "marker-mid", "marker-start", "shape-rendering", "stroke",
|
||||
"stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin",
|
||||
"stroke-miterlimit", "stroke-opacity", "stroke-width", "text-rendering",
|
||||
"baseline-shift", "dominant-baseline", "glyph-orientation-horizontal",
|
||||
"glyph-orientation-vertical", "text-anchor", "writing-mode"
|
||||
], propertyKeywords = keySet(propertyKeywords_);
|
||||
|
||||
var nonStandardPropertyKeywords_ = [
|
||||
"scrollbar-arrow-color", "scrollbar-base-color", "scrollbar-dark-shadow-color",
|
||||
"scrollbar-face-color", "scrollbar-highlight-color", "scrollbar-shadow-color",
|
||||
"scrollbar-3d-light-color", "scrollbar-track-color", "shape-inside",
|
||||
"searchfield-cancel-button", "searchfield-decoration", "searchfield-results-button",
|
||||
"searchfield-results-decoration", "zoom"
|
||||
], nonStandardPropertyKeywords = keySet(nonStandardPropertyKeywords_);
|
||||
|
||||
var colorKeywords_ = [
|
||||
"aliceblue", "antiquewhite", "aqua", "aquamarine", "azure", "beige",
|
||||
"bisque", "black", "blanchedalmond", "blue", "blueviolet", "brown",
|
||||
"burlywood", "cadetblue", "chartreuse", "chocolate", "coral", "cornflowerblue",
|
||||
"cornsilk", "crimson", "cyan", "darkblue", "darkcyan", "darkgoldenrod",
|
||||
"darkgray", "darkgreen", "darkkhaki", "darkmagenta", "darkolivegreen",
|
||||
"darkorange", "darkorchid", "darkred", "darksalmon", "darkseagreen",
|
||||
"darkslateblue", "darkslategray", "darkturquoise", "darkviolet",
|
||||
"deeppink", "deepskyblue", "dimgray", "dodgerblue", "firebrick",
|
||||
"floralwhite", "forestgreen", "fuchsia", "gainsboro", "ghostwhite",
|
||||
"gold", "goldenrod", "gray", "grey", "green", "greenyellow", "honeydew",
|
||||
"hotpink", "indianred", "indigo", "ivory", "khaki", "lavender",
|
||||
"lavenderblush", "lawngreen", "lemonchiffon", "lightblue", "lightcoral",
|
||||
"lightcyan", "lightgoldenrodyellow", "lightgray", "lightgreen", "lightpink",
|
||||
"lightsalmon", "lightseagreen", "lightskyblue", "lightslategray",
|
||||
"lightsteelblue", "lightyellow", "lime", "limegreen", "linen", "magenta",
|
||||
"maroon", "mediumaquamarine", "mediumblue", "mediumorchid", "mediumpurple",
|
||||
"mediumseagreen", "mediumslateblue", "mediumspringgreen", "mediumturquoise",
|
||||
"mediumvioletred", "midnightblue", "mintcream", "mistyrose", "moccasin",
|
||||
"navajowhite", "navy", "oldlace", "olive", "olivedrab", "orange", "orangered",
|
||||
"orchid", "palegoldenrod", "palegreen", "paleturquoise", "palevioletred",
|
||||
"papayawhip", "peachpuff", "peru", "pink", "plum", "powderblue",
|
||||
"purple", "rebeccapurple", "red", "rosybrown", "royalblue", "saddlebrown",
|
||||
"salmon", "sandybrown", "seagreen", "seashell", "sienna", "silver", "skyblue",
|
||||
"slateblue", "slategray", "snow", "springgreen", "steelblue", "tan",
|
||||
"teal", "thistle", "tomato", "turquoise", "violet", "wheat", "white",
|
||||
"whitesmoke", "yellow", "yellowgreen"
|
||||
], colorKeywords = keySet(colorKeywords_);
|
||||
|
||||
var valueKeywords_ = [
|
||||
"above", "absolute", "activeborder", "activecaption", "afar",
|
||||
"after-white-space", "ahead", "alias", "all", "all-scroll", "alternate",
|
||||
"always", "amharic", "amharic-abegede", "antialiased", "appworkspace",
|
||||
"arabic-indic", "armenian", "asterisks", "auto", "avoid", "avoid-column", "avoid-page",
|
||||
"avoid-region", "background", "backwards", "baseline", "below", "bidi-override", "binary",
|
||||
"bengali", "blink", "block", "block-axis", "bold", "bolder", "border", "border-box",
|
||||
"both", "bottom", "break", "break-all", "break-word", "button", "button-bevel",
|
||||
"buttonface", "buttonhighlight", "buttonshadow", "buttontext", "cambodian",
|
||||
"capitalize", "caps-lock-indicator", "caption", "captiontext", "caret",
|
||||
"cell", "center", "checkbox", "circle", "cjk-earthly-branch",
|
||||
"cjk-heavenly-stem", "cjk-ideographic", "clear", "clip", "close-quote",
|
||||
"col-resize", "collapse", "column", "compact", "condensed", "contain", "content",
|
||||
"content-box", "context-menu", "continuous", "copy", "cover", "crop",
|
||||
"cross", "crosshair", "currentcolor", "cursive", "dashed", "decimal",
|
||||
"decimal-leading-zero", "default", "default-button", "destination-atop",
|
||||
"destination-in", "destination-out", "destination-over", "devanagari",
|
||||
"disc", "discard", "document", "dot-dash", "dot-dot-dash", "dotted",
|
||||
"double", "down", "e-resize", "ease", "ease-in", "ease-in-out", "ease-out",
|
||||
"element", "ellipse", "ellipsis", "embed", "end", "ethiopic", "ethiopic-abegede",
|
||||
"ethiopic-abegede-am-et", "ethiopic-abegede-gez", "ethiopic-abegede-ti-er",
|
||||
"ethiopic-abegede-ti-et", "ethiopic-halehame-aa-er",
|
||||
"ethiopic-halehame-aa-et", "ethiopic-halehame-am-et",
|
||||
"ethiopic-halehame-gez", "ethiopic-halehame-om-et",
|
||||
"ethiopic-halehame-sid-et", "ethiopic-halehame-so-et",
|
||||
"ethiopic-halehame-ti-er", "ethiopic-halehame-ti-et",
|
||||
"ethiopic-halehame-tig", "ew-resize", "expanded", "extra-condensed",
|
||||
"extra-expanded", "fantasy", "fast", "fill", "fixed", "flat", "footnotes",
|
||||
"forwards", "from", "geometricPrecision", "georgian", "graytext", "groove",
|
||||
"gujarati", "gurmukhi", "hand", "hangul", "hangul-consonant", "hebrew",
|
||||
"help", "hidden", "hide", "higher", "highlight", "highlighttext",
|
||||
"hiragana", "hiragana-iroha", "horizontal", "hsl", "hsla", "icon", "ignore",
|
||||
"inactiveborder", "inactivecaption", "inactivecaptiontext", "infinite",
|
||||
"infobackground", "infotext", "inherit", "initial", "inline", "inline-axis",
|
||||
"inline-block", "inline-table", "inset", "inside", "intrinsic", "invert",
|
||||
"italic", "justify", "kannada", "katakana", "katakana-iroha", "keep-all", "khmer",
|
||||
"landscape", "lao", "large", "larger", "left", "level", "lighter",
|
||||
"line-through", "linear", "lines", "list-item", "listbox", "listitem",
|
||||
"local", "logical", "loud", "lower", "lower-alpha", "lower-armenian",
|
||||
"lower-greek", "lower-hexadecimal", "lower-latin", "lower-norwegian",
|
||||
"lower-roman", "lowercase", "ltr", "malayalam", "match",
|
||||
"media-controls-background", "media-current-time-display",
|
||||
"media-fullscreen-button", "media-mute-button", "media-play-button",
|
||||
"media-return-to-realtime-button", "media-rewind-button",
|
||||
"media-seek-back-button", "media-seek-forward-button", "media-slider",
|
||||
"media-sliderthumb", "media-time-remaining-display", "media-volume-slider",
|
||||
"media-volume-slider-container", "media-volume-sliderthumb", "medium",
|
||||
"menu", "menulist", "menulist-button", "menulist-text",
|
||||
"menulist-textfield", "menutext", "message-box", "middle", "min-intrinsic",
|
||||
"mix", "mongolian", "monospace", "move", "multiple", "myanmar", "n-resize",
|
||||
"narrower", "ne-resize", "nesw-resize", "no-close-quote", "no-drop",
|
||||
"no-open-quote", "no-repeat", "none", "normal", "not-allowed", "nowrap",
|
||||
"ns-resize", "nw-resize", "nwse-resize", "oblique", "octal", "open-quote",
|
||||
"optimizeLegibility", "optimizeSpeed", "oriya", "oromo", "outset",
|
||||
"outside", "outside-shape", "overlay", "overline", "padding", "padding-box",
|
||||
"painted", "page", "paused", "persian", "plus-darker", "plus-lighter", "pointer",
|
||||
"polygon", "portrait", "pre", "pre-line", "pre-wrap", "preserve-3d", "progress", "push-button",
|
||||
"radio", "read-only", "read-write", "read-write-plaintext-only", "rectangle", "region",
|
||||
"relative", "repeat", "repeat-x", "repeat-y", "reset", "reverse", "rgb", "rgba",
|
||||
"ridge", "right", "round", "row-resize", "rtl", "run-in", "running",
|
||||
"s-resize", "sans-serif", "scroll", "scrollbar", "se-resize", "searchfield",
|
||||
"searchfield-cancel-button", "searchfield-decoration",
|
||||
"searchfield-results-button", "searchfield-results-decoration",
|
||||
"semi-condensed", "semi-expanded", "separate", "serif", "show", "sidama",
|
||||
"single", "skip-white-space", "slide", "slider-horizontal",
|
||||
"slider-vertical", "sliderthumb-horizontal", "sliderthumb-vertical", "slow",
|
||||
"small", "small-caps", "small-caption", "smaller", "solid", "somali",
|
||||
"source-atop", "source-in", "source-out", "source-over", "space", "square",
|
||||
"square-button", "start", "static", "status-bar", "stretch", "stroke",
|
||||
"sub", "subpixel-antialiased", "super", "sw-resize", "table",
|
||||
"table-caption", "table-cell", "table-column", "table-column-group",
|
||||
"table-footer-group", "table-header-group", "table-row", "table-row-group",
|
||||
"telugu", "text", "text-bottom", "text-top", "textarea", "textfield", "thai",
|
||||
"thick", "thin", "threeddarkshadow", "threedface", "threedhighlight",
|
||||
"threedlightshadow", "threedshadow", "tibetan", "tigre", "tigrinya-er",
|
||||
"tigrinya-er-abegede", "tigrinya-et", "tigrinya-et-abegede", "to", "top",
|
||||
"transparent", "ultra-condensed", "ultra-expanded", "underline", "up",
|
||||
"upper-alpha", "upper-armenian", "upper-greek", "upper-hexadecimal",
|
||||
"upper-latin", "upper-norwegian", "upper-roman", "uppercase", "urdu", "url",
|
||||
"vertical", "vertical-text", "visible", "visibleFill", "visiblePainted",
|
||||
"visibleStroke", "visual", "w-resize", "wait", "wave", "wider",
|
||||
"window", "windowframe", "windowtext", "x-large", "x-small", "xor",
|
||||
"xx-large", "xx-small"
|
||||
], valueKeywords = keySet(valueKeywords_);
|
||||
|
||||
var fontProperties_ = [
|
||||
"font-family", "src", "unicode-range", "font-variant", "font-feature-settings",
|
||||
"font-stretch", "font-weight", "font-style"
|
||||
], fontProperties = keySet(fontProperties_);
|
||||
|
||||
var allWords = mediaTypes_.concat(mediaFeatures_).concat(propertyKeywords_)
|
||||
.concat(nonStandardPropertyKeywords_).concat(colorKeywords_).concat(valueKeywords_);
|
||||
CodeMirror.registerHelper("hintWords", "css", allWords);
|
||||
|
||||
function tokenCComment(stream, state) {
|
||||
var maybeEnd = false, ch;
|
||||
while ((ch = stream.next()) != null) {
|
||||
if (maybeEnd && ch == "/") {
|
||||
state.tokenize = null;
|
||||
break;
|
||||
}
|
||||
maybeEnd = (ch == "*");
|
||||
}
|
||||
return ["comment", "comment"];
|
||||
}
|
||||
|
||||
function tokenSGMLComment(stream, state) {
|
||||
if (stream.skipTo("-->")) {
|
||||
stream.match("-->");
|
||||
state.tokenize = null;
|
||||
} else {
|
||||
stream.skipToEnd();
|
||||
}
|
||||
return ["comment", "comment"];
|
||||
}
|
||||
|
||||
CodeMirror.defineMIME("text/css", {
|
||||
mediaTypes: mediaTypes,
|
||||
mediaFeatures: mediaFeatures,
|
||||
propertyKeywords: propertyKeywords,
|
||||
nonStandardPropertyKeywords: nonStandardPropertyKeywords,
|
||||
colorKeywords: colorKeywords,
|
||||
valueKeywords: valueKeywords,
|
||||
fontProperties: fontProperties,
|
||||
tokenHooks: {
|
||||
"<": function(stream, state) {
|
||||
if (!stream.match("!--")) return false;
|
||||
state.tokenize = tokenSGMLComment;
|
||||
return tokenSGMLComment(stream, state);
|
||||
},
|
||||
"/": function(stream, state) {
|
||||
if (!stream.eat("*")) return false;
|
||||
state.tokenize = tokenCComment;
|
||||
return tokenCComment(stream, state);
|
||||
}
|
||||
},
|
||||
name: "css"
|
||||
});
|
||||
|
||||
CodeMirror.defineMIME("text/x-scss", {
|
||||
mediaTypes: mediaTypes,
|
||||
mediaFeatures: mediaFeatures,
|
||||
propertyKeywords: propertyKeywords,
|
||||
nonStandardPropertyKeywords: nonStandardPropertyKeywords,
|
||||
colorKeywords: colorKeywords,
|
||||
valueKeywords: valueKeywords,
|
||||
fontProperties: fontProperties,
|
||||
allowNested: true,
|
||||
tokenHooks: {
|
||||
"/": function(stream, state) {
|
||||
if (stream.eat("/")) {
|
||||
stream.skipToEnd();
|
||||
return ["comment", "comment"];
|
||||
} else if (stream.eat("*")) {
|
||||
state.tokenize = tokenCComment;
|
||||
return tokenCComment(stream, state);
|
||||
} else {
|
||||
return ["operator", "operator"];
|
||||
}
|
||||
},
|
||||
":": function(stream) {
|
||||
if (stream.match(/\s*\{/))
|
||||
return [null, "{"];
|
||||
return false;
|
||||
},
|
||||
"$": function(stream) {
|
||||
stream.match(/^[\w-]+/);
|
||||
if (stream.match(/^\s*:/, false))
|
||||
return ["variable-2", "variable-definition"];
|
||||
return ["variable-2", "variable"];
|
||||
},
|
||||
"#": function(stream) {
|
||||
if (!stream.eat("{")) return false;
|
||||
return [null, "interpolation"];
|
||||
}
|
||||
},
|
||||
name: "css",
|
||||
helperType: "scss"
|
||||
});
|
||||
|
||||
CodeMirror.defineMIME("text/x-less", {
|
||||
mediaTypes: mediaTypes,
|
||||
mediaFeatures: mediaFeatures,
|
||||
propertyKeywords: propertyKeywords,
|
||||
nonStandardPropertyKeywords: nonStandardPropertyKeywords,
|
||||
colorKeywords: colorKeywords,
|
||||
valueKeywords: valueKeywords,
|
||||
fontProperties: fontProperties,
|
||||
allowNested: true,
|
||||
tokenHooks: {
|
||||
"/": function(stream, state) {
|
||||
if (stream.eat("/")) {
|
||||
stream.skipToEnd();
|
||||
return ["comment", "comment"];
|
||||
} else if (stream.eat("*")) {
|
||||
state.tokenize = tokenCComment;
|
||||
return tokenCComment(stream, state);
|
||||
} else {
|
||||
return ["operator", "operator"];
|
||||
}
|
||||
},
|
||||
"@": function(stream) {
|
||||
if (stream.match(/^(charset|document|font-face|import|(-(moz|ms|o|webkit)-)?keyframes|media|namespace|page|supports)\b/, false)) return false;
|
||||
stream.eatWhile(/[\w\\\-]/);
|
||||
if (stream.match(/^\s*:/, false))
|
||||
return ["variable-2", "variable-definition"];
|
||||
return ["variable-2", "variable"];
|
||||
},
|
||||
"&": function() {
|
||||
return ["atom", "atom"];
|
||||
}
|
||||
},
|
||||
name: "css",
|
||||
helperType: "less"
|
||||
});
|
||||
|
||||
});
|
||||
@@ -0,0 +1,297 @@
|
||||
// ============== Formatting extensions ============================
|
||||
// A common storage for all mode-specific formatting features
|
||||
if (!CodeMirror.modeExtensions) CodeMirror.modeExtensions = {};
|
||||
|
||||
// Returns the extension of the editor's current mode
|
||||
CodeMirror.defineExtension("getModeExt", function () {
|
||||
var mname = CodeMirror.resolveMode(this.getOption("mode")).name;
|
||||
var ext = CodeMirror.modeExtensions[mname];
|
||||
if (!ext) throw new Error("No extensions found for mode " + mname);
|
||||
return ext;
|
||||
});
|
||||
|
||||
// If the current mode is 'htmlmixed', returns the extension of a mode located at
|
||||
// the specified position (can be htmlmixed, css or javascript). Otherwise, simply
|
||||
// returns the extension of the editor's current mode.
|
||||
CodeMirror.defineExtension("getModeExtAtPos", function (pos) {
|
||||
var token = this.getTokenAt(pos);
|
||||
if (token && token.state && token.state.mode)
|
||||
return CodeMirror.modeExtensions[token.state.mode == "html" ? "htmlmixed" : token.state.mode];
|
||||
else
|
||||
return this.getModeExt();
|
||||
});
|
||||
|
||||
// Comment/uncomment the specified range
|
||||
CodeMirror.defineExtension("commentRange", function (isComment, from, to) {
|
||||
var curMode = this.getModeExtAtPos(this.getCursor());
|
||||
if (isComment) { // Comment range
|
||||
var commentedText = this.getRange(from, to);
|
||||
this.replaceRange(curMode.commentStart + this.getRange(from, to) + curMode.commentEnd
|
||||
, from, to);
|
||||
if (from.line == to.line && from.ch == to.ch) { // An empty comment inserted - put cursor inside
|
||||
this.setCursor(from.line, from.ch + curMode.commentStart.length);
|
||||
}
|
||||
}
|
||||
else { // Uncomment range
|
||||
var selText = this.getRange(from, to);
|
||||
var startIndex = selText.indexOf(curMode.commentStart);
|
||||
var endIndex = selText.lastIndexOf(curMode.commentEnd);
|
||||
if (startIndex > -1 && endIndex > -1 && endIndex > startIndex) {
|
||||
// Take string till comment start
|
||||
selText = selText.substr(0, startIndex)
|
||||
// From comment start till comment end
|
||||
+ selText.substring(startIndex + curMode.commentStart.length, endIndex)
|
||||
// From comment end till string end
|
||||
+ selText.substr(endIndex + curMode.commentEnd.length);
|
||||
}
|
||||
this.replaceRange(selText, from, to);
|
||||
}
|
||||
});
|
||||
|
||||
// Applies automatic mode-aware indentation to the specified range
|
||||
CodeMirror.defineExtension("autoIndentRange", function (from, to) {
|
||||
var cmInstance = this;
|
||||
this.operation(function () {
|
||||
for (var i = from.line; i <= to.line; i++) {
|
||||
cmInstance.indentLine(i, "smart");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Applies automatic formatting to the specified range
|
||||
CodeMirror.defineExtension("autoFormatRange", function (from, to) {
|
||||
var absStart = this.indexFromPos(from);
|
||||
var absEnd = this.indexFromPos(to);
|
||||
// Insert additional line breaks where necessary according to the
|
||||
// mode's syntax
|
||||
var res = this.getModeExt().autoFormatLineBreaks(this.getValue(), absStart, absEnd);
|
||||
var cmInstance = this;
|
||||
|
||||
// Replace and auto-indent the range
|
||||
this.operation(function () {
|
||||
cmInstance.replaceRange(res, from, to);
|
||||
var startLine = cmInstance.posFromIndex(absStart).line;
|
||||
var endLine = cmInstance.posFromIndex(absStart + res.length).line;
|
||||
for (var i = startLine; i <= endLine; i++) {
|
||||
cmInstance.indentLine(i, "smart");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Define extensions for a few modes
|
||||
|
||||
CodeMirror.modeExtensions["css"] = {
|
||||
commentStart: "/*",
|
||||
commentEnd: "*/",
|
||||
wordWrapChars: [";", "\\{", "\\}"],
|
||||
autoFormatLineBreaks: function (text, startPos, endPos) {
|
||||
text = text.substring(startPos, endPos);
|
||||
return text.replace(new RegExp("(;|\\{|\\})([^\r\n])", "g"), "$1\n$2");
|
||||
}
|
||||
};
|
||||
|
||||
CodeMirror.modeExtensions["javascript"] = {
|
||||
commentStart: "/*",
|
||||
commentEnd: "*/",
|
||||
wordWrapChars: [";", "\\{", "\\}"],
|
||||
|
||||
getNonBreakableBlocks: function (text) {
|
||||
var nonBreakableRegexes = [
|
||||
new RegExp("for\\s*?\\(([\\s\\S]*?)\\)"),
|
||||
new RegExp("'([\\s\\S]*?)('|$)"),
|
||||
new RegExp("\"([\\s\\S]*?)(\"|$)"),
|
||||
new RegExp("//.*([\r\n]|$)")
|
||||
];
|
||||
var nonBreakableBlocks = new Array();
|
||||
for (var i = 0; i < nonBreakableRegexes.length; i++) {
|
||||
var curPos = 0;
|
||||
while (curPos < text.length) {
|
||||
var m = text.substr(curPos).match(nonBreakableRegexes[i]);
|
||||
if (m != null) {
|
||||
nonBreakableBlocks.push({
|
||||
start: curPos + m.index,
|
||||
end: curPos + m.index + m[0].length
|
||||
});
|
||||
curPos += m.index + Math.max(1, m[0].length);
|
||||
}
|
||||
else { // No more matches
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
nonBreakableBlocks.sort(function (a, b) {
|
||||
return a.start - b.start;
|
||||
});
|
||||
|
||||
return nonBreakableBlocks;
|
||||
},
|
||||
|
||||
autoFormatLineBreaks: function (text, startPos, endPos) {
|
||||
text = text.substring(startPos, endPos);
|
||||
var curPos = 0;
|
||||
var reLinesSplitter = new RegExp("(;|\\{|\\})([^\r\n])", "g");
|
||||
var nonBreakableBlocks = this.getNonBreakableBlocks(text);
|
||||
if (nonBreakableBlocks != null) {
|
||||
var res = "";
|
||||
for (var i = 0; i < nonBreakableBlocks.length; i++) {
|
||||
if (nonBreakableBlocks[i].start > curPos) { // Break lines till the block
|
||||
res += text.substring(curPos, nonBreakableBlocks[i].start).replace(reLinesSplitter, "$1\n$2");
|
||||
curPos = nonBreakableBlocks[i].start;
|
||||
}
|
||||
if (nonBreakableBlocks[i].start <= curPos
|
||||
&& nonBreakableBlocks[i].end >= curPos) { // Skip non-breakable block
|
||||
res += text.substring(curPos, nonBreakableBlocks[i].end);
|
||||
curPos = nonBreakableBlocks[i].end;
|
||||
}
|
||||
}
|
||||
if (curPos < text.length - 1) {
|
||||
res += text.substr(curPos).replace(reLinesSplitter, "$1\n$2");
|
||||
}
|
||||
return res;
|
||||
}
|
||||
else {
|
||||
return text.replace(reLinesSplitter, "$1\n$2");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
CodeMirror.modeExtensions["xml"] = {
|
||||
commentStart: "<!--",
|
||||
commentEnd: "-->",
|
||||
wordWrapChars: [">"],
|
||||
|
||||
autoFormatLineBreaks: function (text, startPos, endPos) {
|
||||
text = text.substring(startPos, endPos);
|
||||
var lines = text.split("\n");
|
||||
var reProcessedPortion = new RegExp("(^\\s*?<|^[^<]*?)(.+)(>\\s*?$|[^>]*?$)");
|
||||
var reOpenBrackets = new RegExp("<", "g");
|
||||
var reCloseBrackets = new RegExp("(>)([^\r\n])", "g");
|
||||
for (var i = 0; i < lines.length; i++) {
|
||||
var mToProcess = lines[i].match(reProcessedPortion);
|
||||
if (mToProcess != null && mToProcess.length > 3) { // The line starts with whitespaces and ends with whitespaces
|
||||
lines[i] = mToProcess[1]
|
||||
+ mToProcess[2].replace(reOpenBrackets, "\n$&").replace(reCloseBrackets, "$1\n$2")
|
||||
+ mToProcess[3];
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
return lines.join("\n");
|
||||
}
|
||||
};
|
||||
|
||||
CodeMirror.modeExtensions["htmlmixed"] = {
|
||||
commentStart: "<!--",
|
||||
commentEnd: "-->",
|
||||
wordWrapChars: [">", ";", "\\{", "\\}"],
|
||||
|
||||
getModeInfos: function (text, absPos) {
|
||||
var modeInfos = new Array();
|
||||
modeInfos[0] =
|
||||
{
|
||||
pos: 0,
|
||||
modeExt: CodeMirror.modeExtensions["xml"],
|
||||
modeName: "xml"
|
||||
};
|
||||
|
||||
var modeMatchers = new Array();
|
||||
modeMatchers[0] =
|
||||
{
|
||||
regex: new RegExp("<style[^>]*>([\\s\\S]*?)(</style[^>]*>|$)", "i"),
|
||||
modeExt: CodeMirror.modeExtensions["css"],
|
||||
modeName: "css"
|
||||
};
|
||||
modeMatchers[1] =
|
||||
{
|
||||
regex: new RegExp("<script[^>]*>([\\s\\S]*?)(</script[^>]*>|$)", "i"),
|
||||
modeExt: CodeMirror.modeExtensions["javascript"],
|
||||
modeName: "javascript"
|
||||
};
|
||||
|
||||
var lastCharPos = (typeof (absPos) !== "undefined" ? absPos : text.length - 1);
|
||||
// Detect modes for the entire text
|
||||
for (var i = 0; i < modeMatchers.length; i++) {
|
||||
var curPos = 0;
|
||||
while (curPos <= lastCharPos) {
|
||||
var m = text.substr(curPos).match(modeMatchers[i].regex);
|
||||
if (m != null) {
|
||||
if (m.length > 1 && m[1].length > 0) {
|
||||
// Push block begin pos
|
||||
var blockBegin = curPos + m.index + m[0].indexOf(m[1]);
|
||||
modeInfos.push(
|
||||
{
|
||||
pos: blockBegin,
|
||||
modeExt: modeMatchers[i].modeExt,
|
||||
modeName: modeMatchers[i].modeName
|
||||
});
|
||||
// Push block end pos
|
||||
modeInfos.push(
|
||||
{
|
||||
pos: blockBegin + m[1].length,
|
||||
modeExt: modeInfos[0].modeExt,
|
||||
modeName: modeInfos[0].modeName
|
||||
});
|
||||
curPos += m.index + m[0].length;
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
curPos += m.index + Math.max(m[0].length, 1);
|
||||
}
|
||||
}
|
||||
else { // No more matches
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Sort mode infos
|
||||
modeInfos.sort(function sortModeInfo(a, b) {
|
||||
return a.pos - b.pos;
|
||||
});
|
||||
|
||||
return modeInfos;
|
||||
},
|
||||
|
||||
autoFormatLineBreaks: function (text, startPos, endPos) {
|
||||
var modeInfos = this.getModeInfos(text);
|
||||
var reBlockStartsWithNewline = new RegExp("^\\s*?\n");
|
||||
var reBlockEndsWithNewline = new RegExp("\n\\s*?$");
|
||||
var res = "";
|
||||
// Use modes info to break lines correspondingly
|
||||
if (modeInfos.length > 1) { // Deal with multi-mode text
|
||||
for (var i = 1; i <= modeInfos.length; i++) {
|
||||
var selStart = modeInfos[i - 1].pos;
|
||||
var selEnd = (i < modeInfos.length ? modeInfos[i].pos : endPos);
|
||||
|
||||
if (selStart >= endPos) { // The block starts later than the needed fragment
|
||||
break;
|
||||
}
|
||||
if (selStart < startPos) {
|
||||
if (selEnd <= startPos) { // The block starts earlier than the needed fragment
|
||||
continue;
|
||||
}
|
||||
selStart = startPos;
|
||||
}
|
||||
if (selEnd > endPos) {
|
||||
selEnd = endPos;
|
||||
}
|
||||
var textPortion = text.substring(selStart, selEnd);
|
||||
if (modeInfos[i - 1].modeName != "xml") { // Starting a CSS or JavaScript block
|
||||
if (!reBlockStartsWithNewline.test(textPortion)
|
||||
&& selStart > 0) { // The block does not start with a line break
|
||||
textPortion = "\n" + textPortion;
|
||||
}
|
||||
if (!reBlockEndsWithNewline.test(textPortion)
|
||||
&& selEnd < text.length - 1) { // The block does not end with a line break
|
||||
textPortion += "\n";
|
||||
}
|
||||
}
|
||||
res += modeInfos[i - 1].modeExt.autoFormatLineBreaks(textPortion);
|
||||
}
|
||||
}
|
||||
else { // Single-mode text
|
||||
res = modeInfos[0].modeExt.autoFormatLineBreaks(text.substring(startPos, endPos));
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,41 @@
|
||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
CodeMirror.defineOption("fullScreen", false, function(cm, val, old) {
|
||||
if (old == CodeMirror.Init) old = false;
|
||||
if (!old == !val) return;
|
||||
if (val) setFullscreen(cm);
|
||||
else setNormal(cm);
|
||||
});
|
||||
|
||||
function setFullscreen(cm) {
|
||||
var wrap = cm.getWrapperElement();
|
||||
cm.state.fullScreenRestore = {scrollTop: window.pageYOffset, scrollLeft: window.pageXOffset,
|
||||
width: wrap.style.width, height: wrap.style.height};
|
||||
wrap.style.width = "";
|
||||
wrap.style.height = "auto";
|
||||
wrap.className += " CodeMirror-fullscreen";
|
||||
document.documentElement.style.overflow = "hidden";
|
||||
cm.refresh();
|
||||
}
|
||||
|
||||
function setNormal(cm) {
|
||||
var wrap = cm.getWrapperElement();
|
||||
wrap.className = wrap.className.replace(/\s*CodeMirror-fullscreen\b/, "");
|
||||
document.documentElement.style.overflow = "";
|
||||
var info = cm.state.fullScreenRestore;
|
||||
wrap.style.width = info.width; wrap.style.height = info.height;
|
||||
window.scrollTo(info.scrollLeft, info.scrollTop);
|
||||
cm.refresh();
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,121 @@
|
||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"), require("../xml/xml"), require("../javascript/javascript"), require("../css/css"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror", "../xml/xml", "../javascript/javascript", "../css/css"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
CodeMirror.defineMode("htmlmixed", function(config, parserConfig) {
|
||||
var htmlMode = CodeMirror.getMode(config, {name: "xml",
|
||||
htmlMode: true,
|
||||
multilineTagIndentFactor: parserConfig.multilineTagIndentFactor,
|
||||
multilineTagIndentPastTag: parserConfig.multilineTagIndentPastTag});
|
||||
var cssMode = CodeMirror.getMode(config, "css");
|
||||
|
||||
var scriptTypes = [], scriptTypesConf = parserConfig && parserConfig.scriptTypes;
|
||||
scriptTypes.push({matches: /^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^$/i,
|
||||
mode: CodeMirror.getMode(config, "javascript")});
|
||||
if (scriptTypesConf) for (var i = 0; i < scriptTypesConf.length; ++i) {
|
||||
var conf = scriptTypesConf[i];
|
||||
scriptTypes.push({matches: conf.matches, mode: conf.mode && CodeMirror.getMode(config, conf.mode)});
|
||||
}
|
||||
scriptTypes.push({matches: /./,
|
||||
mode: CodeMirror.getMode(config, "text/plain")});
|
||||
|
||||
function html(stream, state) {
|
||||
var tagName = state.htmlState.tagName;
|
||||
if (tagName) tagName = tagName.toLowerCase();
|
||||
var style = htmlMode.token(stream, state.htmlState);
|
||||
if (tagName == "script" && /\btag\b/.test(style) && stream.current() == ">") {
|
||||
// Script block: mode to change to depends on type attribute
|
||||
var scriptType = stream.string.slice(Math.max(0, stream.pos - 100), stream.pos).match(/\btype\s*=\s*("[^"]+"|'[^']+'|\S+)[^<]*$/i);
|
||||
scriptType = scriptType ? scriptType[1] : "";
|
||||
if (scriptType && /[\"\']/.test(scriptType.charAt(0))) scriptType = scriptType.slice(1, scriptType.length - 1);
|
||||
for (var i = 0; i < scriptTypes.length; ++i) {
|
||||
var tp = scriptTypes[i];
|
||||
if (typeof tp.matches == "string" ? scriptType == tp.matches : tp.matches.test(scriptType)) {
|
||||
if (tp.mode) {
|
||||
state.token = script;
|
||||
state.localMode = tp.mode;
|
||||
state.localState = tp.mode.startState && tp.mode.startState(htmlMode.indent(state.htmlState, ""));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (tagName == "style" && /\btag\b/.test(style) && stream.current() == ">") {
|
||||
state.token = css;
|
||||
state.localMode = cssMode;
|
||||
state.localState = cssMode.startState(htmlMode.indent(state.htmlState, ""));
|
||||
}
|
||||
return style;
|
||||
}
|
||||
function maybeBackup(stream, pat, style) {
|
||||
var cur = stream.current();
|
||||
var close = cur.search(pat), m;
|
||||
if (close > -1) stream.backUp(cur.length - close);
|
||||
else if (m = cur.match(/<\/?$/)) {
|
||||
stream.backUp(cur.length);
|
||||
if (!stream.match(pat, false)) stream.match(cur);
|
||||
}
|
||||
return style;
|
||||
}
|
||||
function script(stream, state) {
|
||||
if (stream.match(/^<\/\s*script\s*>/i, false)) {
|
||||
state.token = html;
|
||||
state.localState = state.localMode = null;
|
||||
return html(stream, state);
|
||||
}
|
||||
return maybeBackup(stream, /<\/\s*script\s*>/,
|
||||
state.localMode.token(stream, state.localState));
|
||||
}
|
||||
function css(stream, state) {
|
||||
if (stream.match(/^<\/\s*style\s*>/i, false)) {
|
||||
state.token = html;
|
||||
state.localState = state.localMode = null;
|
||||
return html(stream, state);
|
||||
}
|
||||
return maybeBackup(stream, /<\/\s*style\s*>/,
|
||||
cssMode.token(stream, state.localState));
|
||||
}
|
||||
|
||||
return {
|
||||
startState: function() {
|
||||
var state = htmlMode.startState();
|
||||
return {token: html, localMode: null, localState: null, htmlState: state};
|
||||
},
|
||||
|
||||
copyState: function(state) {
|
||||
if (state.localState)
|
||||
var local = CodeMirror.copyState(state.localMode, state.localState);
|
||||
return {token: state.token, localMode: state.localMode, localState: local,
|
||||
htmlState: CodeMirror.copyState(htmlMode, state.htmlState)};
|
||||
},
|
||||
|
||||
token: function(stream, state) {
|
||||
return state.token(stream, state);
|
||||
},
|
||||
|
||||
indent: function(state, textAfter) {
|
||||
if (!state.localMode || /^\s*<\//.test(textAfter))
|
||||
return htmlMode.indent(state.htmlState, textAfter);
|
||||
else if (state.localMode.indent)
|
||||
return state.localMode.indent(state.localState, textAfter);
|
||||
else
|
||||
return CodeMirror.Pass;
|
||||
},
|
||||
|
||||
innerMode: function(state) {
|
||||
return {state: state.localState || state.htmlState, mode: state.localMode || htmlMode};
|
||||
}
|
||||
};
|
||||
}, "xml", "javascript", "css");
|
||||
|
||||
CodeMirror.defineMIME("text/html", "htmlmixed");
|
||||
|
||||
});
|
||||
@@ -0,0 +1,684 @@
|
||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
// TODO actually recognize syntax of TypeScript constructs
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
CodeMirror.defineMode("javascript", function(config, parserConfig) {
|
||||
var indentUnit = config.indentUnit;
|
||||
var statementIndent = parserConfig.statementIndent;
|
||||
var jsonldMode = parserConfig.jsonld;
|
||||
var jsonMode = parserConfig.json || jsonldMode;
|
||||
var isTS = parserConfig.typescript;
|
||||
var wordRE = parserConfig.wordCharacters || /[\w$]/;
|
||||
|
||||
// Tokenizer
|
||||
|
||||
var keywords = function(){
|
||||
function kw(type) {return {type: type, style: "keyword"};}
|
||||
var A = kw("keyword a"), B = kw("keyword b"), C = kw("keyword c");
|
||||
var operator = kw("operator"), atom = {type: "atom", style: "atom"};
|
||||
|
||||
var jsKeywords = {
|
||||
"if": kw("if"), "while": A, "with": A, "else": B, "do": B, "try": B, "finally": B,
|
||||
"return": C, "break": C, "continue": C, "new": C, "delete": C, "throw": C, "debugger": C,
|
||||
"var": kw("var"), "const": kw("var"), "let": kw("var"),
|
||||
"function": kw("function"), "catch": kw("catch"),
|
||||
"for": kw("for"), "switch": kw("switch"), "case": kw("case"), "default": kw("default"),
|
||||
"in": operator, "typeof": operator, "instanceof": operator,
|
||||
"true": atom, "false": atom, "null": atom, "undefined": atom, "NaN": atom, "Infinity": atom,
|
||||
"this": kw("this"), "module": kw("module"), "class": kw("class"), "super": kw("atom"),
|
||||
"yield": C, "export": kw("export"), "import": kw("import"), "extends": C
|
||||
};
|
||||
|
||||
// Extend the 'normal' keywords with the TypeScript language extensions
|
||||
if (isTS) {
|
||||
var type = {type: "variable", style: "variable-3"};
|
||||
var tsKeywords = {
|
||||
// object-like things
|
||||
"interface": kw("interface"),
|
||||
"extends": kw("extends"),
|
||||
"constructor": kw("constructor"),
|
||||
|
||||
// scope modifiers
|
||||
"public": kw("public"),
|
||||
"private": kw("private"),
|
||||
"protected": kw("protected"),
|
||||
"static": kw("static"),
|
||||
|
||||
// types
|
||||
"string": type, "number": type, "bool": type, "any": type
|
||||
};
|
||||
|
||||
for (var attr in tsKeywords) {
|
||||
jsKeywords[attr] = tsKeywords[attr];
|
||||
}
|
||||
}
|
||||
|
||||
return jsKeywords;
|
||||
}();
|
||||
|
||||
var isOperatorChar = /[+\-*&%=<>!?|~^]/;
|
||||
var isJsonldKeyword = /^@(context|id|value|language|type|container|list|set|reverse|index|base|vocab|graph)"/;
|
||||
|
||||
function readRegexp(stream) {
|
||||
var escaped = false, next, inSet = false;
|
||||
while ((next = stream.next()) != null) {
|
||||
if (!escaped) {
|
||||
if (next == "/" && !inSet) return;
|
||||
if (next == "[") inSet = true;
|
||||
else if (inSet && next == "]") inSet = false;
|
||||
}
|
||||
escaped = !escaped && next == "\\";
|
||||
}
|
||||
}
|
||||
|
||||
// Used as scratch variables to communicate multiple values without
|
||||
// consing up tons of objects.
|
||||
var type, content;
|
||||
function ret(tp, style, cont) {
|
||||
type = tp; content = cont;
|
||||
return style;
|
||||
}
|
||||
function tokenBase(stream, state) {
|
||||
var ch = stream.next();
|
||||
if (ch == '"' || ch == "'") {
|
||||
state.tokenize = tokenString(ch);
|
||||
return state.tokenize(stream, state);
|
||||
} else if (ch == "." && stream.match(/^\d+(?:[eE][+\-]?\d+)?/)) {
|
||||
return ret("number", "number");
|
||||
} else if (ch == "." && stream.match("..")) {
|
||||
return ret("spread", "meta");
|
||||
} else if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
|
||||
return ret(ch);
|
||||
} else if (ch == "=" && stream.eat(">")) {
|
||||
return ret("=>", "operator");
|
||||
} else if (ch == "0" && stream.eat(/x/i)) {
|
||||
stream.eatWhile(/[\da-f]/i);
|
||||
return ret("number", "number");
|
||||
} else if (/\d/.test(ch)) {
|
||||
stream.match(/^\d*(?:\.\d*)?(?:[eE][+\-]?\d+)?/);
|
||||
return ret("number", "number");
|
||||
} else if (ch == "/") {
|
||||
if (stream.eat("*")) {
|
||||
state.tokenize = tokenComment;
|
||||
return tokenComment(stream, state);
|
||||
} else if (stream.eat("/")) {
|
||||
stream.skipToEnd();
|
||||
return ret("comment", "comment");
|
||||
} else if (state.lastType == "operator" || state.lastType == "keyword c" ||
|
||||
state.lastType == "sof" || /^[\[{}\(,;:]$/.test(state.lastType)) {
|
||||
readRegexp(stream);
|
||||
stream.eatWhile(/[gimy]/); // 'y' is "sticky" option in Mozilla
|
||||
return ret("regexp", "string-2");
|
||||
} else {
|
||||
stream.eatWhile(isOperatorChar);
|
||||
return ret("operator", "operator", stream.current());
|
||||
}
|
||||
} else if (ch == "`") {
|
||||
state.tokenize = tokenQuasi;
|
||||
return tokenQuasi(stream, state);
|
||||
} else if (ch == "#") {
|
||||
stream.skipToEnd();
|
||||
return ret("error", "error");
|
||||
} else if (isOperatorChar.test(ch)) {
|
||||
stream.eatWhile(isOperatorChar);
|
||||
return ret("operator", "operator", stream.current());
|
||||
} else if (wordRE.test(ch)) {
|
||||
stream.eatWhile(wordRE);
|
||||
var word = stream.current(), known = keywords.propertyIsEnumerable(word) && keywords[word];
|
||||
return (known && state.lastType != ".") ? ret(known.type, known.style, word) :
|
||||
ret("variable", "variable", word);
|
||||
}
|
||||
}
|
||||
|
||||
function tokenString(quote) {
|
||||
return function(stream, state) {
|
||||
var escaped = false, next;
|
||||
if (jsonldMode && stream.peek() == "@" && stream.match(isJsonldKeyword)){
|
||||
state.tokenize = tokenBase;
|
||||
return ret("jsonld-keyword", "meta");
|
||||
}
|
||||
while ((next = stream.next()) != null) {
|
||||
if (next == quote && !escaped) break;
|
||||
escaped = !escaped && next == "\\";
|
||||
}
|
||||
if (!escaped) state.tokenize = tokenBase;
|
||||
return ret("string", "string");
|
||||
};
|
||||
}
|
||||
|
||||
function tokenComment(stream, state) {
|
||||
var maybeEnd = false, ch;
|
||||
while (ch = stream.next()) {
|
||||
if (ch == "/" && maybeEnd) {
|
||||
state.tokenize = tokenBase;
|
||||
break;
|
||||
}
|
||||
maybeEnd = (ch == "*");
|
||||
}
|
||||
return ret("comment", "comment");
|
||||
}
|
||||
|
||||
function tokenQuasi(stream, state) {
|
||||
var escaped = false, next;
|
||||
while ((next = stream.next()) != null) {
|
||||
if (!escaped && (next == "`" || next == "$" && stream.eat("{"))) {
|
||||
state.tokenize = tokenBase;
|
||||
break;
|
||||
}
|
||||
escaped = !escaped && next == "\\";
|
||||
}
|
||||
return ret("quasi", "string-2", stream.current());
|
||||
}
|
||||
|
||||
var brackets = "([{}])";
|
||||
// This is a crude lookahead trick to try and notice that we're
|
||||
// parsing the argument patterns for a fat-arrow function before we
|
||||
// actually hit the arrow token. It only works if the arrow is on
|
||||
// the same line as the arguments and there's no strange noise
|
||||
// (comments) in between. Fallback is to only notice when we hit the
|
||||
// arrow, and not declare the arguments as locals for the arrow
|
||||
// body.
|
||||
function findFatArrow(stream, state) {
|
||||
if (state.fatArrowAt) state.fatArrowAt = null;
|
||||
var arrow = stream.string.indexOf("=>", stream.start);
|
||||
if (arrow < 0) return;
|
||||
|
||||
var depth = 0, sawSomething = false;
|
||||
for (var pos = arrow - 1; pos >= 0; --pos) {
|
||||
var ch = stream.string.charAt(pos);
|
||||
var bracket = brackets.indexOf(ch);
|
||||
if (bracket >= 0 && bracket < 3) {
|
||||
if (!depth) { ++pos; break; }
|
||||
if (--depth == 0) break;
|
||||
} else if (bracket >= 3 && bracket < 6) {
|
||||
++depth;
|
||||
} else if (wordRE.test(ch)) {
|
||||
sawSomething = true;
|
||||
} else if (sawSomething && !depth) {
|
||||
++pos;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (sawSomething && !depth) state.fatArrowAt = pos;
|
||||
}
|
||||
|
||||
// Parser
|
||||
|
||||
var atomicTypes = {"atom": true, "number": true, "variable": true, "string": true, "regexp": true, "this": true, "jsonld-keyword": true};
|
||||
|
||||
function JSLexical(indented, column, type, align, prev, info) {
|
||||
this.indented = indented;
|
||||
this.column = column;
|
||||
this.type = type;
|
||||
this.prev = prev;
|
||||
this.info = info;
|
||||
if (align != null) this.align = align;
|
||||
}
|
||||
|
||||
function inScope(state, varname) {
|
||||
for (var v = state.localVars; v; v = v.next)
|
||||
if (v.name == varname) return true;
|
||||
for (var cx = state.context; cx; cx = cx.prev) {
|
||||
for (var v = cx.vars; v; v = v.next)
|
||||
if (v.name == varname) return true;
|
||||
}
|
||||
}
|
||||
|
||||
function parseJS(state, style, type, content, stream) {
|
||||
var cc = state.cc;
|
||||
// Communicate our context to the combinators.
|
||||
// (Less wasteful than consing up a hundred closures on every call.)
|
||||
cx.state = state; cx.stream = stream; cx.marked = null, cx.cc = cc; cx.style = style;
|
||||
|
||||
if (!state.lexical.hasOwnProperty("align"))
|
||||
state.lexical.align = true;
|
||||
|
||||
while(true) {
|
||||
var combinator = cc.length ? cc.pop() : jsonMode ? expression : statement;
|
||||
if (combinator(type, content)) {
|
||||
while(cc.length && cc[cc.length - 1].lex)
|
||||
cc.pop()();
|
||||
if (cx.marked) return cx.marked;
|
||||
if (type == "variable" && inScope(state, content)) return "variable-2";
|
||||
return style;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Combinator utils
|
||||
|
||||
var cx = {state: null, column: null, marked: null, cc: null};
|
||||
function pass() {
|
||||
for (var i = arguments.length - 1; i >= 0; i--) cx.cc.push(arguments[i]);
|
||||
}
|
||||
function cont() {
|
||||
pass.apply(null, arguments);
|
||||
return true;
|
||||
}
|
||||
function register(varname) {
|
||||
function inList(list) {
|
||||
for (var v = list; v; v = v.next)
|
||||
if (v.name == varname) return true;
|
||||
return false;
|
||||
}
|
||||
var state = cx.state;
|
||||
if (state.context) {
|
||||
cx.marked = "def";
|
||||
if (inList(state.localVars)) return;
|
||||
state.localVars = {name: varname, next: state.localVars};
|
||||
} else {
|
||||
if (inList(state.globalVars)) return;
|
||||
if (parserConfig.globalVars)
|
||||
state.globalVars = {name: varname, next: state.globalVars};
|
||||
}
|
||||
}
|
||||
|
||||
// Combinators
|
||||
|
||||
var defaultVars = {name: "this", next: {name: "arguments"}};
|
||||
function pushcontext() {
|
||||
cx.state.context = {prev: cx.state.context, vars: cx.state.localVars};
|
||||
cx.state.localVars = defaultVars;
|
||||
}
|
||||
function popcontext() {
|
||||
cx.state.localVars = cx.state.context.vars;
|
||||
cx.state.context = cx.state.context.prev;
|
||||
}
|
||||
function pushlex(type, info) {
|
||||
var result = function() {
|
||||
var state = cx.state, indent = state.indented;
|
||||
if (state.lexical.type == "stat") indent = state.lexical.indented;
|
||||
else for (var outer = state.lexical; outer && outer.type == ")" && outer.align; outer = outer.prev)
|
||||
indent = outer.indented;
|
||||
state.lexical = new JSLexical(indent, cx.stream.column(), type, null, state.lexical, info);
|
||||
};
|
||||
result.lex = true;
|
||||
return result;
|
||||
}
|
||||
function poplex() {
|
||||
var state = cx.state;
|
||||
if (state.lexical.prev) {
|
||||
if (state.lexical.type == ")")
|
||||
state.indented = state.lexical.indented;
|
||||
state.lexical = state.lexical.prev;
|
||||
}
|
||||
}
|
||||
poplex.lex = true;
|
||||
|
||||
function expect(wanted) {
|
||||
function exp(type) {
|
||||
if (type == wanted) return cont();
|
||||
else if (wanted == ";") return pass();
|
||||
else return cont(exp);
|
||||
};
|
||||
return exp;
|
||||
}
|
||||
|
||||
function statement(type, value) {
|
||||
if (type == "var") return cont(pushlex("vardef", value.length), vardef, expect(";"), poplex);
|
||||
if (type == "keyword a") return cont(pushlex("form"), expression, statement, poplex);
|
||||
if (type == "keyword b") return cont(pushlex("form"), statement, poplex);
|
||||
if (type == "{") return cont(pushlex("}"), block, poplex);
|
||||
if (type == ";") return cont();
|
||||
if (type == "if") {
|
||||
if (cx.state.lexical.info == "else" && cx.state.cc[cx.state.cc.length - 1] == poplex)
|
||||
cx.state.cc.pop()();
|
||||
return cont(pushlex("form"), expression, statement, poplex, maybeelse);
|
||||
}
|
||||
if (type == "function") return cont(functiondef);
|
||||
if (type == "for") return cont(pushlex("form"), forspec, statement, poplex);
|
||||
if (type == "variable") return cont(pushlex("stat"), maybelabel);
|
||||
if (type == "switch") return cont(pushlex("form"), expression, pushlex("}", "switch"), expect("{"),
|
||||
block, poplex, poplex);
|
||||
if (type == "case") return cont(expression, expect(":"));
|
||||
if (type == "default") return cont(expect(":"));
|
||||
if (type == "catch") return cont(pushlex("form"), pushcontext, expect("("), funarg, expect(")"),
|
||||
statement, poplex, popcontext);
|
||||
if (type == "module") return cont(pushlex("form"), pushcontext, afterModule, popcontext, poplex);
|
||||
if (type == "class") return cont(pushlex("form"), className, poplex);
|
||||
if (type == "export") return cont(pushlex("form"), afterExport, poplex);
|
||||
if (type == "import") return cont(pushlex("form"), afterImport, poplex);
|
||||
return pass(pushlex("stat"), expression, expect(";"), poplex);
|
||||
}
|
||||
function expression(type) {
|
||||
return expressionInner(type, false);
|
||||
}
|
||||
function expressionNoComma(type) {
|
||||
return expressionInner(type, true);
|
||||
}
|
||||
function expressionInner(type, noComma) {
|
||||
if (cx.state.fatArrowAt == cx.stream.start) {
|
||||
var body = noComma ? arrowBodyNoComma : arrowBody;
|
||||
if (type == "(") return cont(pushcontext, pushlex(")"), commasep(pattern, ")"), poplex, expect("=>"), body, popcontext);
|
||||
else if (type == "variable") return pass(pushcontext, pattern, expect("=>"), body, popcontext);
|
||||
}
|
||||
|
||||
var maybeop = noComma ? maybeoperatorNoComma : maybeoperatorComma;
|
||||
if (atomicTypes.hasOwnProperty(type)) return cont(maybeop);
|
||||
if (type == "function") return cont(functiondef, maybeop);
|
||||
if (type == "keyword c") return cont(noComma ? maybeexpressionNoComma : maybeexpression);
|
||||
if (type == "(") return cont(pushlex(")"), maybeexpression, comprehension, expect(")"), poplex, maybeop);
|
||||
if (type == "operator" || type == "spread") return cont(noComma ? expressionNoComma : expression);
|
||||
if (type == "[") return cont(pushlex("]"), arrayLiteral, poplex, maybeop);
|
||||
if (type == "{") return contCommasep(objprop, "}", null, maybeop);
|
||||
if (type == "quasi") { return pass(quasi, maybeop); }
|
||||
return cont();
|
||||
}
|
||||
function maybeexpression(type) {
|
||||
if (type.match(/[;\}\)\],]/)) return pass();
|
||||
return pass(expression);
|
||||
}
|
||||
function maybeexpressionNoComma(type) {
|
||||
if (type.match(/[;\}\)\],]/)) return pass();
|
||||
return pass(expressionNoComma);
|
||||
}
|
||||
|
||||
function maybeoperatorComma(type, value) {
|
||||
if (type == ",") return cont(expression);
|
||||
return maybeoperatorNoComma(type, value, false);
|
||||
}
|
||||
function maybeoperatorNoComma(type, value, noComma) {
|
||||
var me = noComma == false ? maybeoperatorComma : maybeoperatorNoComma;
|
||||
var expr = noComma == false ? expression : expressionNoComma;
|
||||
if (type == "=>") return cont(pushcontext, noComma ? arrowBodyNoComma : arrowBody, popcontext);
|
||||
if (type == "operator") {
|
||||
if (/\+\+|--/.test(value)) return cont(me);
|
||||
if (value == "?") return cont(expression, expect(":"), expr);
|
||||
return cont(expr);
|
||||
}
|
||||
if (type == "quasi") { return pass(quasi, me); }
|
||||
if (type == ";") return;
|
||||
if (type == "(") return contCommasep(expressionNoComma, ")", "call", me);
|
||||
if (type == ".") return cont(property, me);
|
||||
if (type == "[") return cont(pushlex("]"), maybeexpression, expect("]"), poplex, me);
|
||||
}
|
||||
function quasi(type, value) {
|
||||
if (type != "quasi") return pass();
|
||||
if (value.slice(value.length - 2) != "${") return cont(quasi);
|
||||
return cont(expression, continueQuasi);
|
||||
}
|
||||
function continueQuasi(type) {
|
||||
if (type == "}") {
|
||||
cx.marked = "string-2";
|
||||
cx.state.tokenize = tokenQuasi;
|
||||
return cont(quasi);
|
||||
}
|
||||
}
|
||||
function arrowBody(type) {
|
||||
findFatArrow(cx.stream, cx.state);
|
||||
return pass(type == "{" ? statement : expression);
|
||||
}
|
||||
function arrowBodyNoComma(type) {
|
||||
findFatArrow(cx.stream, cx.state);
|
||||
return pass(type == "{" ? statement : expressionNoComma);
|
||||
}
|
||||
function maybelabel(type) {
|
||||
if (type == ":") return cont(poplex, statement);
|
||||
return pass(maybeoperatorComma, expect(";"), poplex);
|
||||
}
|
||||
function property(type) {
|
||||
if (type == "variable") {cx.marked = "property"; return cont();}
|
||||
}
|
||||
function objprop(type, value) {
|
||||
if (type == "variable" || cx.style == "keyword") {
|
||||
cx.marked = "property";
|
||||
if (value == "get" || value == "set") return cont(getterSetter);
|
||||
return cont(afterprop);
|
||||
} else if (type == "number" || type == "string") {
|
||||
cx.marked = jsonldMode ? "property" : (cx.style + " property");
|
||||
return cont(afterprop);
|
||||
} else if (type == "jsonld-keyword") {
|
||||
return cont(afterprop);
|
||||
} else if (type == "[") {
|
||||
return cont(expression, expect("]"), afterprop);
|
||||
}
|
||||
}
|
||||
function getterSetter(type) {
|
||||
if (type != "variable") return pass(afterprop);
|
||||
cx.marked = "property";
|
||||
return cont(functiondef);
|
||||
}
|
||||
function afterprop(type) {
|
||||
if (type == ":") return cont(expressionNoComma);
|
||||
if (type == "(") return pass(functiondef);
|
||||
}
|
||||
function commasep(what, end) {
|
||||
function proceed(type) {
|
||||
if (type == ",") {
|
||||
var lex = cx.state.lexical;
|
||||
if (lex.info == "call") lex.pos = (lex.pos || 0) + 1;
|
||||
return cont(what, proceed);
|
||||
}
|
||||
if (type == end) return cont();
|
||||
return cont(expect(end));
|
||||
}
|
||||
return function(type) {
|
||||
if (type == end) return cont();
|
||||
return pass(what, proceed);
|
||||
};
|
||||
}
|
||||
function contCommasep(what, end, info) {
|
||||
for (var i = 3; i < arguments.length; i++)
|
||||
cx.cc.push(arguments[i]);
|
||||
return cont(pushlex(end, info), commasep(what, end), poplex);
|
||||
}
|
||||
function block(type) {
|
||||
if (type == "}") return cont();
|
||||
return pass(statement, block);
|
||||
}
|
||||
function maybetype(type) {
|
||||
if (isTS && type == ":") return cont(typedef);
|
||||
}
|
||||
function typedef(type) {
|
||||
if (type == "variable"){cx.marked = "variable-3"; return cont();}
|
||||
}
|
||||
function vardef() {
|
||||
return pass(pattern, maybetype, maybeAssign, vardefCont);
|
||||
}
|
||||
function pattern(type, value) {
|
||||
if (type == "variable") { register(value); return cont(); }
|
||||
if (type == "[") return contCommasep(pattern, "]");
|
||||
if (type == "{") return contCommasep(proppattern, "}");
|
||||
}
|
||||
function proppattern(type, value) {
|
||||
if (type == "variable" && !cx.stream.match(/^\s*:/, false)) {
|
||||
register(value);
|
||||
return cont(maybeAssign);
|
||||
}
|
||||
if (type == "variable") cx.marked = "property";
|
||||
return cont(expect(":"), pattern, maybeAssign);
|
||||
}
|
||||
function maybeAssign(_type, value) {
|
||||
if (value == "=") return cont(expressionNoComma);
|
||||
}
|
||||
function vardefCont(type) {
|
||||
if (type == ",") return cont(vardef);
|
||||
}
|
||||
function maybeelse(type, value) {
|
||||
if (type == "keyword b" && value == "else") return cont(pushlex("form", "else"), statement, poplex);
|
||||
}
|
||||
function forspec(type) {
|
||||
if (type == "(") return cont(pushlex(")"), forspec1, expect(")"), poplex);
|
||||
}
|
||||
function forspec1(type) {
|
||||
if (type == "var") return cont(vardef, expect(";"), forspec2);
|
||||
if (type == ";") return cont(forspec2);
|
||||
if (type == "variable") return cont(formaybeinof);
|
||||
return pass(expression, expect(";"), forspec2);
|
||||
}
|
||||
function formaybeinof(_type, value) {
|
||||
if (value == "in" || value == "of") { cx.marked = "keyword"; return cont(expression); }
|
||||
return cont(maybeoperatorComma, forspec2);
|
||||
}
|
||||
function forspec2(type, value) {
|
||||
if (type == ";") return cont(forspec3);
|
||||
if (value == "in" || value == "of") { cx.marked = "keyword"; return cont(expression); }
|
||||
return pass(expression, expect(";"), forspec3);
|
||||
}
|
||||
function forspec3(type) {
|
||||
if (type != ")") cont(expression);
|
||||
}
|
||||
function functiondef(type, value) {
|
||||
if (value == "*") {cx.marked = "keyword"; return cont(functiondef);}
|
||||
if (type == "variable") {register(value); return cont(functiondef);}
|
||||
if (type == "(") return cont(pushcontext, pushlex(")"), commasep(funarg, ")"), poplex, statement, popcontext);
|
||||
}
|
||||
function funarg(type) {
|
||||
if (type == "spread") return cont(funarg);
|
||||
return pass(pattern, maybetype);
|
||||
}
|
||||
function className(type, value) {
|
||||
if (type == "variable") {register(value); return cont(classNameAfter);}
|
||||
}
|
||||
function classNameAfter(type, value) {
|
||||
if (value == "extends") return cont(expression, classNameAfter);
|
||||
if (type == "{") return cont(pushlex("}"), classBody, poplex);
|
||||
}
|
||||
function classBody(type, value) {
|
||||
if (type == "variable" || cx.style == "keyword") {
|
||||
cx.marked = "property";
|
||||
if (value == "get" || value == "set") return cont(classGetterSetter, functiondef, classBody);
|
||||
return cont(functiondef, classBody);
|
||||
}
|
||||
if (value == "*") {
|
||||
cx.marked = "keyword";
|
||||
return cont(classBody);
|
||||
}
|
||||
if (type == ";") return cont(classBody);
|
||||
if (type == "}") return cont();
|
||||
}
|
||||
function classGetterSetter(type) {
|
||||
if (type != "variable") return pass();
|
||||
cx.marked = "property";
|
||||
return cont();
|
||||
}
|
||||
function afterModule(type, value) {
|
||||
if (type == "string") return cont(statement);
|
||||
if (type == "variable") { register(value); return cont(maybeFrom); }
|
||||
}
|
||||
function afterExport(_type, value) {
|
||||
if (value == "*") { cx.marked = "keyword"; return cont(maybeFrom, expect(";")); }
|
||||
if (value == "default") { cx.marked = "keyword"; return cont(expression, expect(";")); }
|
||||
return pass(statement);
|
||||
}
|
||||
function afterImport(type) {
|
||||
if (type == "string") return cont();
|
||||
return pass(importSpec, maybeFrom);
|
||||
}
|
||||
function importSpec(type, value) {
|
||||
if (type == "{") return contCommasep(importSpec, "}");
|
||||
if (type == "variable") register(value);
|
||||
return cont();
|
||||
}
|
||||
function maybeFrom(_type, value) {
|
||||
if (value == "from") { cx.marked = "keyword"; return cont(expression); }
|
||||
}
|
||||
function arrayLiteral(type) {
|
||||
if (type == "]") return cont();
|
||||
return pass(expressionNoComma, maybeArrayComprehension);
|
||||
}
|
||||
function maybeArrayComprehension(type) {
|
||||
if (type == "for") return pass(comprehension, expect("]"));
|
||||
if (type == ",") return cont(commasep(expressionNoComma, "]"));
|
||||
return pass(commasep(expressionNoComma, "]"));
|
||||
}
|
||||
function comprehension(type) {
|
||||
if (type == "for") return cont(forspec, comprehension);
|
||||
if (type == "if") return cont(expression, comprehension);
|
||||
}
|
||||
|
||||
// Interface
|
||||
|
||||
return {
|
||||
startState: function(basecolumn) {
|
||||
var state = {
|
||||
tokenize: tokenBase,
|
||||
lastType: "sof",
|
||||
cc: [],
|
||||
lexical: new JSLexical((basecolumn || 0) - indentUnit, 0, "block", false),
|
||||
localVars: parserConfig.localVars,
|
||||
context: parserConfig.localVars && {vars: parserConfig.localVars},
|
||||
indented: 0
|
||||
};
|
||||
if (parserConfig.globalVars && typeof parserConfig.globalVars == "object")
|
||||
state.globalVars = parserConfig.globalVars;
|
||||
return state;
|
||||
},
|
||||
|
||||
token: function(stream, state) {
|
||||
if (stream.sol()) {
|
||||
if (!state.lexical.hasOwnProperty("align"))
|
||||
state.lexical.align = false;
|
||||
state.indented = stream.indentation();
|
||||
findFatArrow(stream, state);
|
||||
}
|
||||
if (state.tokenize != tokenComment && stream.eatSpace()) return null;
|
||||
var style = state.tokenize(stream, state);
|
||||
if (type == "comment") return style;
|
||||
state.lastType = type == "operator" && (content == "++" || content == "--") ? "incdec" : type;
|
||||
return parseJS(state, style, type, content, stream);
|
||||
},
|
||||
|
||||
indent: function(state, textAfter) {
|
||||
if (state.tokenize == tokenComment) return CodeMirror.Pass;
|
||||
if (state.tokenize != tokenBase) return 0;
|
||||
var firstChar = textAfter && textAfter.charAt(0), lexical = state.lexical;
|
||||
// Kludge to prevent 'maybelse' from blocking lexical scope pops
|
||||
if (!/^\s*else\b/.test(textAfter)) for (var i = state.cc.length - 1; i >= 0; --i) {
|
||||
var c = state.cc[i];
|
||||
if (c == poplex) lexical = lexical.prev;
|
||||
else if (c != maybeelse) break;
|
||||
}
|
||||
if (lexical.type == "stat" && firstChar == "}") lexical = lexical.prev;
|
||||
if (statementIndent && lexical.type == ")" && lexical.prev.type == "stat")
|
||||
lexical = lexical.prev;
|
||||
var type = lexical.type, closing = firstChar == type;
|
||||
|
||||
if (type == "vardef") return lexical.indented + (state.lastType == "operator" || state.lastType == "," ? lexical.info + 1 : 0);
|
||||
else if (type == "form" && firstChar == "{") return lexical.indented;
|
||||
else if (type == "form") return lexical.indented + indentUnit;
|
||||
else if (type == "stat")
|
||||
return lexical.indented + (state.lastType == "operator" || state.lastType == "," ? statementIndent || indentUnit : 0);
|
||||
else if (lexical.info == "switch" && !closing && parserConfig.doubleIndentSwitch != false)
|
||||
return lexical.indented + (/^(?:case|default)\b/.test(textAfter) ? indentUnit : 2 * indentUnit);
|
||||
else if (lexical.align) return lexical.column + (closing ? 0 : 1);
|
||||
else return lexical.indented + (closing ? 0 : indentUnit);
|
||||
},
|
||||
|
||||
electricChars: ":{}",
|
||||
blockCommentStart: jsonMode ? null : "/*",
|
||||
blockCommentEnd: jsonMode ? null : "*/",
|
||||
lineComment: jsonMode ? null : "//",
|
||||
fold: "brace",
|
||||
|
||||
helperType: jsonMode ? "json" : "javascript",
|
||||
jsonldMode: jsonldMode,
|
||||
jsonMode: jsonMode
|
||||
};
|
||||
});
|
||||
|
||||
CodeMirror.registerHelper("wordChars", "javascript", /[\w$]/);
|
||||
|
||||
CodeMirror.defineMIME("text/javascript", "javascript");
|
||||
CodeMirror.defineMIME("text/ecmascript", "javascript");
|
||||
CodeMirror.defineMIME("application/javascript", "javascript");
|
||||
CodeMirror.defineMIME("application/x-javascript", "javascript");
|
||||
CodeMirror.defineMIME("application/ecmascript", "javascript");
|
||||
CodeMirror.defineMIME("application/json", {name: "javascript", json: true});
|
||||
CodeMirror.defineMIME("application/x-json", {name: "javascript", json: true});
|
||||
CodeMirror.defineMIME("application/ld+json", {name: "javascript", jsonld: true});
|
||||
CodeMirror.defineMIME("text/typescript", { name: "javascript", typescript: true });
|
||||
CodeMirror.defineMIME("application/typescript", { name: "javascript", typescript: true });
|
||||
|
||||
});
|
||||
@@ -0,0 +1,103 @@
|
||||
//
|
||||
// simple unpacker/deobfuscator for scripts messed up with javascriptobfuscator.com
|
||||
// written by Einar Lielmanis <einar@jsbeautifier.org>
|
||||
//
|
||||
// usage:
|
||||
//
|
||||
// if (JavascriptObfuscator.detect(some_string)) {
|
||||
// var unpacked = JavascriptObfuscator.unpack(some_string);
|
||||
// }
|
||||
//
|
||||
//
|
||||
|
||||
var JavascriptObfuscator = {
|
||||
detect: function (str) {
|
||||
return /^var _0x[a-f0-9]+ ?\= ?\[/.test(str);
|
||||
},
|
||||
|
||||
unpack: function (str) {
|
||||
if (JavascriptObfuscator.detect(str)) {
|
||||
var matches = /var (_0x[a-f\d]+) ?\= ?\[(.*?)\];/.exec(str);
|
||||
if (matches) {
|
||||
var var_name = matches[1];
|
||||
var strings = JavascriptObfuscator._smart_split(matches[2]);
|
||||
str = str.substring(matches[0].length);
|
||||
for (var k in strings) {
|
||||
str = str.replace(new RegExp(var_name + '\\[' + k + '\\]', 'g'),
|
||||
JavascriptObfuscator._fix_quotes(JavascriptObfuscator._unescape(strings[k])));
|
||||
}
|
||||
}
|
||||
}
|
||||
return str;
|
||||
},
|
||||
|
||||
_fix_quotes: function(str) {
|
||||
var matches = /^"(.*)"$/.exec(str);
|
||||
if (matches) {
|
||||
str = matches[1];
|
||||
str = "'" + str.replace(/'/g, "\\'") + "'";
|
||||
}
|
||||
return str;
|
||||
},
|
||||
|
||||
_smart_split: function(str) {
|
||||
var strings = [];
|
||||
var pos = 0;
|
||||
while (pos < str.length) {
|
||||
if (str.charAt(pos) == '"') {
|
||||
// new word
|
||||
var word = '';
|
||||
pos += 1;
|
||||
while (pos < str.length) {
|
||||
if (str.charAt(pos) == '"') {
|
||||
break;
|
||||
}
|
||||
if (str.charAt(pos) == '\\') {
|
||||
word += '\\';
|
||||
pos++;
|
||||
}
|
||||
word += str.charAt(pos);
|
||||
pos++;
|
||||
}
|
||||
strings.push('"' + word + '"');
|
||||
}
|
||||
pos += 1;
|
||||
}
|
||||
return strings;
|
||||
},
|
||||
|
||||
|
||||
_unescape: function (str) {
|
||||
// inefficient if used repeatedly or on small strings, but wonderful on single large chunk of text
|
||||
for (var i = 32; i < 128; i++) {
|
||||
str = str.replace(new RegExp('\\\\x' + i.toString(16), 'ig'), String.fromCharCode(i));
|
||||
}
|
||||
str = str.replace(/\\x09/g, "\t");
|
||||
return str;
|
||||
},
|
||||
|
||||
run_tests: function (sanity_test) {
|
||||
var t = sanity_test || new SanityTest();
|
||||
|
||||
t.test_function(JavascriptObfuscator._smart_split, "JavascriptObfuscator._smart_split");
|
||||
t.expect('', []);
|
||||
t.expect('"a", "b"', ['"a"', '"b"']);
|
||||
t.expect('"aaa","bbbb"', ['"aaa"', '"bbbb"']);
|
||||
t.expect('"a", "b\\\""', ['"a"', '"b\\\""']);
|
||||
t.test_function(JavascriptObfuscator._unescape, 'JavascriptObfuscator._unescape');
|
||||
t.expect('\\x40', '@');
|
||||
t.expect('\\x10', '\\x10');
|
||||
t.expect('\\x1', '\\x1');
|
||||
t.expect("\\x61\\x62\\x22\\x63\\x64", 'ab"cd');
|
||||
t.test_function(JavascriptObfuscator.detect, 'JavascriptObfuscator.detect');
|
||||
t.expect('', false);
|
||||
t.expect('abcd', false);
|
||||
t.expect('var _0xaaaa', false);
|
||||
t.expect('var _0xaaaa = ["a", "b"]', true);
|
||||
t.expect('var _0xaaaa=["a", "b"]', true);
|
||||
t.expect('var _0x1234=["a","b"]', true);
|
||||
return t;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
@@ -0,0 +1,90 @@
|
||||
//
|
||||
// simple unpacker/deobfuscator for scripts messed up with myobfuscate.com
|
||||
// You really don't want to obfuscate your scripts there: they're tracking
|
||||
// your unpackings, your script gets turned into something like this,
|
||||
// as of 2011-04-25:
|
||||
/*
|
||||
|
||||
var _escape = 'your_script_escaped';
|
||||
var _111 = document.createElement('script');
|
||||
_111.src = 'http://api.www.myobfuscate.com/?getsrc=ok' +
|
||||
'&ref=' + encodeURIComponent(document.referrer) +
|
||||
'&url=' + encodeURIComponent(document.URL);
|
||||
var 000 = document.getElementsByTagName('head')[0];
|
||||
000.appendChild(_111);
|
||||
document.write(unescape(_escape));
|
||||
|
||||
*/
|
||||
//
|
||||
// written by Einar Lielmanis <einar@jsbeautifier.org>
|
||||
//
|
||||
// usage:
|
||||
//
|
||||
// if (MyObfuscate.detect(some_string)) {
|
||||
// var unpacked = MyObfuscate.unpack(some_string);
|
||||
// }
|
||||
//
|
||||
//
|
||||
|
||||
var MyObfuscate = {
|
||||
detect: function (str) {
|
||||
if (/^var _?[0O1lI]{3}\=('|\[).*\)\)\);/.test(str)) {
|
||||
return true;
|
||||
}
|
||||
if (/^function _?[0O1lI]{3}\(_/.test(str) && /eval\(/.test(str)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
unpack: function (str) {
|
||||
if (MyObfuscate.detect(str)) {
|
||||
var __eval = eval;
|
||||
try {
|
||||
eval = function (unpacked) {
|
||||
if (MyObfuscate.starts_with(unpacked, 'var _escape')) {
|
||||
// fetch the urlencoded stuff from the script,
|
||||
var matches = /'([^']*)'/.exec(unpacked);
|
||||
var unescaped = unescape(matches[1]);
|
||||
if (MyObfuscate.starts_with(unescaped, '<script>')) {
|
||||
unescaped = unescaped.substr(8, unescaped.length - 8);
|
||||
}
|
||||
if (MyObfuscate.ends_with(unescaped, '</script>')) {
|
||||
unescaped = unescaped.substr(0, unescaped.length - 9);
|
||||
}
|
||||
unpacked = unescaped;
|
||||
}
|
||||
// throw to terminate the script
|
||||
unpacked = "// Unpacker warning: be careful when using myobfuscate.com for your projects:\n" +
|
||||
"// scripts obfuscated by the free online version may call back home.\n" +
|
||||
"\n//\n" + unpacked;
|
||||
throw unpacked;
|
||||
};
|
||||
__eval(str); // should throw
|
||||
} catch (e) {
|
||||
// well, it failed. we'll just return the original, instead of crashing on user.
|
||||
if (typeof e === "string") {
|
||||
str = e;
|
||||
}
|
||||
}
|
||||
eval = __eval;
|
||||
}
|
||||
return str;
|
||||
},
|
||||
|
||||
starts_with: function (str, what) {
|
||||
return str.substr(0, what.length) === what;
|
||||
},
|
||||
|
||||
ends_with: function (str, what) {
|
||||
return str.substr(str.length - what.length, what.length) === what;
|
||||
},
|
||||
|
||||
run_tests: function (sanity_test) {
|
||||
var t = sanity_test || new SanityTest();
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
@@ -0,0 +1,80 @@
|
||||
//
|
||||
// Unpacker for Dean Edward's p.a.c.k.e.r, a part of javascript beautifier
|
||||
// written by Einar Lielmanis <einar@jsbeautifier.org>
|
||||
//
|
||||
// Coincidentally, it can defeat a couple of other eval-based compressors.
|
||||
//
|
||||
// usage:
|
||||
//
|
||||
// if (P_A_C_K_E_R.detect(some_string)) {
|
||||
// var unpacked = P_A_C_K_E_R.unpack(some_string);
|
||||
// }
|
||||
//
|
||||
//
|
||||
|
||||
var P_A_C_K_E_R = {
|
||||
detect: function (str) {
|
||||
return (P_A_C_K_E_R.get_chunks(str).length > 0);
|
||||
},
|
||||
|
||||
get_chunks: function(str) {
|
||||
var chunks = str.match(/eval\(\(?function\(.*?(,0,\{\}\)\)|split\('\|'\)\)\))($|\n)/g);
|
||||
return chunks ? chunks : [];
|
||||
},
|
||||
|
||||
unpack: function (str) {
|
||||
var chunks = P_A_C_K_E_R.get_chunks(str),
|
||||
chunk;
|
||||
for(var i = 0; i < chunks.length; i++) {
|
||||
chunk = chunks[i].replace(/\n$/, '');
|
||||
str = str.split(chunk).join( P_A_C_K_E_R.unpack_chunk(chunk) );
|
||||
}
|
||||
return str;
|
||||
},
|
||||
|
||||
unpack_chunk: function (str) {
|
||||
var unpacked_source = '';
|
||||
var __eval = eval;
|
||||
if (P_A_C_K_E_R.detect(str)) {
|
||||
try {
|
||||
eval = function (s) { unpacked_source += s; return unpacked_source; };
|
||||
__eval(str);
|
||||
if (typeof unpacked_source == 'string' && unpacked_source) {
|
||||
str = unpacked_source;
|
||||
}
|
||||
} catch (e) {
|
||||
// well, it failed. we'll just return the original, instead of crashing on user.
|
||||
}
|
||||
}
|
||||
eval = __eval;
|
||||
return str;
|
||||
},
|
||||
|
||||
run_tests: function (sanity_test) {
|
||||
var t = sanity_test || new SanityTest(),
|
||||
|
||||
pk1 = "eval(function(p,a,c,k,e,r){e=String;if(!''.replace(/^/,String)){while(c--)r[c]=k[c]||c;k=[function(e){return r[e]}];e=function(){return'\\\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\\\b'+e(c)+'\\\\b','g'),k[c]);return p}('0 2=1',3,3,'var||a'.split('|'),0,{}))",
|
||||
unpk1 = 'var a=1',
|
||||
pk2 = "eval(function(p,a,c,k,e,r){e=String;if(!''.replace(/^/,String)){while(c--)r[c]=k[c]||c;k=[function(e){return r[e]}];e=function(){return'\\\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\\\b'+e(c)+'\\\\b','g'),k[c]);return p}('0 2=1',3,3,'foo||b'.split('|'),0,{}))",
|
||||
unpk2 = 'foo b=1',
|
||||
pk_broken = "eval(function(p,a,c,k,e,r){BORKBORK;if(!''.replace(/^/,String)){while(c--)r[c]=k[c]||c;k=[function(e){return r[e]}];e=function(){return'\\\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\\\b'+e(c)+'\\\\b','g'),k[c]);return p}('0 2=1',3,3,'var||a'.split('|'),0,{}))";
|
||||
pk3 = "eval(function(p,a,c,k,e,r){e=String;if(!''.replace(/^/,String)){while(c--)r[c]=k[c]||c;k=[function(e){return r[e]}];e=function(){return'\\\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\\\b'+e(c)+'\\\\b','g'),k[c]);return p}('0 2=1{}))',3,3,'var||a'.split('|'),0,{}))",
|
||||
unpk3 = 'var a=1{}))',
|
||||
|
||||
t.test_function(P_A_C_K_E_R.detect, "P_A_C_K_E_R.detect");
|
||||
t.expect('', false);
|
||||
t.expect('var a = b', false);
|
||||
t.test_function(P_A_C_K_E_R.unpack, "P_A_C_K_E_R.unpack");
|
||||
t.expect(pk_broken, pk_broken);
|
||||
t.expect(pk1, unpk1);
|
||||
t.expect(pk2, unpk2);
|
||||
t.expect(pk3, unpk3);
|
||||
|
||||
var filler = '\nfiller\n';
|
||||
t.expect(filler + pk1 + "\n" + pk_broken + filler + pk2 + filler, filler + unpk1 + "\n" + pk_broken + filler + unpk2 + filler);
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
@@ -0,0 +1,923 @@
|
||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
// CodeMirror2 mode/perl/perl.js (text/x-perl) beta 0.10 (2011-11-08)
|
||||
// This is a part of CodeMirror from https://github.com/sabaca/CodeMirror_mode_perl (mail@sabaca.com)
|
||||
|
||||
(function (mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function (CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
CodeMirror.defineMode("perl", function () {
|
||||
// http://perldoc.perl.org
|
||||
var PERL = { // null - magic touch
|
||||
// 1 - keyword
|
||||
// 2 - def
|
||||
// 3 - atom
|
||||
// 4 - operator
|
||||
// 5 - variable-2 (predefined)
|
||||
// [x,y] - x=1,2,3; y=must be defined if x{...}
|
||||
// PERL operators
|
||||
'->': 4,
|
||||
'++': 4,
|
||||
'--': 4,
|
||||
'**': 4,
|
||||
// ! ~ \ and unary + and -
|
||||
'=~': 4,
|
||||
'!~': 4,
|
||||
'*': 4,
|
||||
'/': 4,
|
||||
'%': 4,
|
||||
'x': 4,
|
||||
'+': 4,
|
||||
'-': 4,
|
||||
'.': 4,
|
||||
'<<': 4,
|
||||
'>>': 4,
|
||||
// named unary operators
|
||||
'<': 4,
|
||||
'>': 4,
|
||||
'<=': 4,
|
||||
'>=': 4,
|
||||
'lt': 4,
|
||||
'gt': 4,
|
||||
'le': 4,
|
||||
'ge': 4,
|
||||
'==': 4,
|
||||
'!=': 4,
|
||||
'<=>': 4,
|
||||
'eq': 4,
|
||||
'ne': 4,
|
||||
'cmp': 4,
|
||||
'~~': 4,
|
||||
'&': 4,
|
||||
'|': 4,
|
||||
'^': 4,
|
||||
'&&': 4,
|
||||
'||': 4,
|
||||
'//': 4,
|
||||
'..': 4,
|
||||
'...': 4,
|
||||
'?': 4,
|
||||
':': 4,
|
||||
'=': 4,
|
||||
'+=': 4,
|
||||
'-=': 4,
|
||||
'*=': 4, // etc. ???
|
||||
',': 4,
|
||||
'=>': 4,
|
||||
'::': 4,
|
||||
// list operators (rightward)
|
||||
'not': 4,
|
||||
'and': 4,
|
||||
'or': 4,
|
||||
'xor': 4,
|
||||
// PERL predefined variables (I know, what this is a paranoid idea, but may be needed for people, who learn PERL, and for me as well, ...and may be for you?;)
|
||||
'BEGIN': [5, 1],
|
||||
'END': [5, 1],
|
||||
'PRINT': [5, 1],
|
||||
'PRINTF': [5, 1],
|
||||
'GETC': [5, 1],
|
||||
'READ': [5, 1],
|
||||
'READLINE': [5, 1],
|
||||
'DESTROY': [5, 1],
|
||||
'TIE': [5, 1],
|
||||
'TIEHANDLE': [5, 1],
|
||||
'UNTIE': [5, 1],
|
||||
'STDIN': 5,
|
||||
'STDIN_TOP': 5,
|
||||
'STDOUT': 5,
|
||||
'STDOUT_TOP': 5,
|
||||
'STDERR': 5,
|
||||
'STDERR_TOP': 5,
|
||||
'$ARG': 5,
|
||||
'$_': 5,
|
||||
'@ARG': 5,
|
||||
'@_': 5,
|
||||
'$LIST_SEPARATOR': 5,
|
||||
'$"': 5,
|
||||
'$PROCESS_ID': 5,
|
||||
'$PID': 5,
|
||||
'$$': 5,
|
||||
'$REAL_GROUP_ID': 5,
|
||||
'$GID': 5,
|
||||
'$(': 5,
|
||||
'$EFFECTIVE_GROUP_ID': 5,
|
||||
'$EGID': 5,
|
||||
'$)': 5,
|
||||
'$PROGRAM_NAME': 5,
|
||||
'$0': 5,
|
||||
'$SUBSCRIPT_SEPARATOR': 5,
|
||||
'$SUBSEP': 5,
|
||||
'$;': 5,
|
||||
'$REAL_USER_ID': 5,
|
||||
'$UID': 5,
|
||||
'$<': 5,
|
||||
'$EFFECTIVE_USER_ID': 5,
|
||||
'$EUID': 5,
|
||||
'$>': 5,
|
||||
'$a': 5,
|
||||
'$b': 5,
|
||||
'$COMPILING': 5,
|
||||
'$^C': 5,
|
||||
'$DEBUGGING': 5,
|
||||
'$^D': 5,
|
||||
'${^ENCODING}': 5,
|
||||
'$ENV': 5,
|
||||
'%ENV': 5,
|
||||
'$SYSTEM_FD_MAX': 5,
|
||||
'$^F': 5,
|
||||
'@F': 5,
|
||||
'${^GLOBAL_PHASE}': 5,
|
||||
'$^H': 5,
|
||||
'%^H': 5,
|
||||
'@INC': 5,
|
||||
'%INC': 5,
|
||||
'$INPLACE_EDIT': 5,
|
||||
'$^I': 5,
|
||||
'$^M': 5,
|
||||
'$OSNAME': 5,
|
||||
'$^O': 5,
|
||||
'${^OPEN}': 5,
|
||||
'$PERLDB': 5,
|
||||
'$^P': 5,
|
||||
'$SIG': 5,
|
||||
'%SIG': 5,
|
||||
'$BASETIME': 5,
|
||||
'$^T': 5,
|
||||
'${^TAINT}': 5,
|
||||
'${^UNICODE}': 5,
|
||||
'${^UTF8CACHE}': 5,
|
||||
'${^UTF8LOCALE}': 5,
|
||||
'$PERL_VERSION': 5,
|
||||
'$^V': 5,
|
||||
'${^WIN32_SLOPPY_STAT}': 5,
|
||||
'$EXECUTABLE_NAME': 5,
|
||||
'$^X': 5,
|
||||
'$1': 5, // - regexp $1, $2...
|
||||
'$MATCH': 5,
|
||||
'$&': 5,
|
||||
'${^MATCH}': 5,
|
||||
'$PREMATCH': 5,
|
||||
'$`': 5,
|
||||
'${^PREMATCH}': 5,
|
||||
'$POSTMATCH': 5,
|
||||
"$'": 5,
|
||||
'${^POSTMATCH}': 5,
|
||||
'$LAST_PAREN_MATCH': 5,
|
||||
'$+': 5,
|
||||
'$LAST_SUBMATCH_RESULT': 5,
|
||||
'$^N': 5,
|
||||
'@LAST_MATCH_END': 5,
|
||||
'@+': 5,
|
||||
'%LAST_PAREN_MATCH': 5,
|
||||
'%+': 5,
|
||||
'@LAST_MATCH_START': 5,
|
||||
'@-': 5,
|
||||
'%LAST_MATCH_START': 5,
|
||||
'%-': 5,
|
||||
'$LAST_REGEXP_CODE_RESULT': 5,
|
||||
'$^R': 5,
|
||||
'${^RE_DEBUG_FLAGS}': 5,
|
||||
'${^RE_TRIE_MAXBUF}': 5,
|
||||
'$ARGV': 5,
|
||||
'@ARGV': 5,
|
||||
'ARGV': 5,
|
||||
'ARGVOUT': 5,
|
||||
'$OUTPUT_FIELD_SEPARATOR': 5,
|
||||
'$OFS': 5,
|
||||
'$,': 5,
|
||||
'$INPUT_LINE_NUMBER': 5,
|
||||
'$NR': 5,
|
||||
'$.': 5,
|
||||
'$INPUT_RECORD_SEPARATOR': 5,
|
||||
'$RS': 5,
|
||||
'$/': 5,
|
||||
'$OUTPUT_RECORD_SEPARATOR': 5,
|
||||
'$ORS': 5,
|
||||
'$\\': 5,
|
||||
'$OUTPUT_AUTOFLUSH': 5,
|
||||
'$|': 5,
|
||||
'$ACCUMULATOR': 5,
|
||||
'$^A': 5,
|
||||
'$FORMAT_FORMFEED': 5,
|
||||
'$^L': 5,
|
||||
'$FORMAT_PAGE_NUMBER': 5,
|
||||
'$%': 5,
|
||||
'$FORMAT_LINES_LEFT': 5,
|
||||
'$-': 5,
|
||||
'$FORMAT_LINE_BREAK_CHARACTERS': 5,
|
||||
'$:': 5,
|
||||
'$FORMAT_LINES_PER_PAGE': 5,
|
||||
'$=': 5,
|
||||
'$FORMAT_TOP_NAME': 5,
|
||||
'$^': 5,
|
||||
'$FORMAT_NAME': 5,
|
||||
'$~': 5,
|
||||
'${^CHILD_ERROR_NATIVE}': 5,
|
||||
'$EXTENDED_OS_ERROR': 5,
|
||||
'$^E': 5,
|
||||
'$EXCEPTIONS_BEING_CAUGHT': 5,
|
||||
'$^S': 5,
|
||||
'$WARNING': 5,
|
||||
'$^W': 5,
|
||||
'${^WARNING_BITS}': 5,
|
||||
'$OS_ERROR': 5,
|
||||
'$ERRNO': 5,
|
||||
'$!': 5,
|
||||
'%OS_ERROR': 5,
|
||||
'%ERRNO': 5,
|
||||
'%!': 5,
|
||||
'$CHILD_ERROR': 5,
|
||||
'$?': 5,
|
||||
'$EVAL_ERROR': 5,
|
||||
'$@': 5,
|
||||
'$OFMT': 5,
|
||||
'$#': 5,
|
||||
'$*': 5,
|
||||
'$ARRAY_BASE': 5,
|
||||
'$[': 5,
|
||||
'$OLD_PERL_VERSION': 5,
|
||||
'$]': 5,
|
||||
// PERL blocks
|
||||
'if': [1, 1],
|
||||
elsif: [1, 1],
|
||||
'else': [1, 1],
|
||||
'while': [1, 1],
|
||||
unless: [1, 1],
|
||||
'for': [1, 1],
|
||||
foreach: [1, 1],
|
||||
// PERL functions
|
||||
'abs': 1, // - absolute value function
|
||||
accept: 1, // - accept an incoming socket connect
|
||||
alarm: 1, // - schedule a SIGALRM
|
||||
'atan2': 1, // - arctangent of Y/X in the range -PI to PI
|
||||
bind: 1, // - binds an address to a socket
|
||||
binmode: 1, // - prepare binary files for I/O
|
||||
bless: 1, // - create an object
|
||||
bootstrap: 1, //
|
||||
'break': 1, // - break out of a "given" block
|
||||
caller: 1, // - get context of the current subroutine call
|
||||
chdir: 1, // - change your current working directory
|
||||
chmod: 1, // - changes the permissions on a list of files
|
||||
chomp: 1, // - remove a trailing record separator from a string
|
||||
chop: 1, // - remove the last character from a string
|
||||
chown: 1, // - change the owership on a list of files
|
||||
chr: 1, // - get character this number represents
|
||||
chroot: 1, // - make directory new root for path lookups
|
||||
close: 1, // - close file (or pipe or socket) handle
|
||||
closedir: 1, // - close directory handle
|
||||
connect: 1, // - connect to a remote socket
|
||||
'continue': [1, 1], // - optional trailing block in a while or foreach
|
||||
'cos': 1, // - cosine function
|
||||
crypt: 1, // - one-way passwd-style encryption
|
||||
dbmclose: 1, // - breaks binding on a tied dbm file
|
||||
dbmopen: 1, // - create binding on a tied dbm file
|
||||
'default': 1, //
|
||||
defined: 1, // - test whether a value, variable, or function is defined
|
||||
'delete': 1, // - deletes a value from a hash
|
||||
die: 1, // - raise an exception or bail out
|
||||
'do': 1, // - turn a BLOCK into a TERM
|
||||
dump: 1, // - create an immediate core dump
|
||||
each: 1, // - retrieve the next key/value pair from a hash
|
||||
endgrent: 1, // - be done using group file
|
||||
endhostent: 1, // - be done using hosts file
|
||||
endnetent: 1, // - be done using networks file
|
||||
endprotoent: 1, // - be done using protocols file
|
||||
endpwent: 1, // - be done using passwd file
|
||||
endservent: 1, // - be done using services file
|
||||
eof: 1, // - test a filehandle for its end
|
||||
'eval': 1, // - catch exceptions or compile and run code
|
||||
'exec': 1, // - abandon this program to run another
|
||||
exists: 1, // - test whether a hash key is present
|
||||
exit: 1, // - terminate this program
|
||||
'exp': 1, // - raise I to a power
|
||||
fcntl: 1, // - file control system call
|
||||
fileno: 1, // - return file descriptor from filehandle
|
||||
flock: 1, // - lock an entire file with an advisory lock
|
||||
fork: 1, // - create a new process just like this one
|
||||
format: 1, // - declare a picture format with use by the write() function
|
||||
formline: 1, // - internal function used for formats
|
||||
getc: 1, // - get the next character from the filehandle
|
||||
getgrent: 1, // - get next group record
|
||||
getgrgid: 1, // - get group record given group user ID
|
||||
getgrnam: 1, // - get group record given group name
|
||||
gethostbyaddr: 1, // - get host record given its address
|
||||
gethostbyname: 1, // - get host record given name
|
||||
gethostent: 1, // - get next hosts record
|
||||
getlogin: 1, // - return who logged in at this tty
|
||||
getnetbyaddr: 1, // - get network record given its address
|
||||
getnetbyname: 1, // - get networks record given name
|
||||
getnetent: 1, // - get next networks record
|
||||
getpeername: 1, // - find the other end of a socket connection
|
||||
getpgrp: 1, // - get process group
|
||||
getppid: 1, // - get parent process ID
|
||||
getpriority: 1, // - get current nice value
|
||||
getprotobyname: 1, // - get protocol record given name
|
||||
getprotobynumber: 1, // - get protocol record numeric protocol
|
||||
getprotoent: 1, // - get next protocols record
|
||||
getpwent: 1, // - get next passwd record
|
||||
getpwnam: 1, // - get passwd record given user login name
|
||||
getpwuid: 1, // - get passwd record given user ID
|
||||
getservbyname: 1, // - get services record given its name
|
||||
getservbyport: 1, // - get services record given numeric port
|
||||
getservent: 1, // - get next services record
|
||||
getsockname: 1, // - retrieve the sockaddr for a given socket
|
||||
getsockopt: 1, // - get socket options on a given socket
|
||||
given: 1, //
|
||||
glob: 1, // - expand filenames using wildcards
|
||||
gmtime: 1, // - convert UNIX time into record or string using Greenwich time
|
||||
'goto': 1, // - create spaghetti code
|
||||
grep: 1, // - locate elements in a list test true against a given criterion
|
||||
hex: 1, // - convert a string to a hexadecimal number
|
||||
'import': 1, // - patch a module's namespace into your own
|
||||
index: 1, // - find a substring within a string
|
||||
'int': 1, // - get the integer portion of a number
|
||||
ioctl: 1, // - system-dependent device control system call
|
||||
'join': 1, // - join a list into a string using a separator
|
||||
keys: 1, // - retrieve list of indices from a hash
|
||||
kill: 1, // - send a signal to a process or process group
|
||||
last: 1, // - exit a block prematurely
|
||||
lc: 1, // - return lower-case version of a string
|
||||
lcfirst: 1, // - return a string with just the next letter in lower case
|
||||
length: 1, // - return the number of bytes in a string
|
||||
'link': 1, // - create a hard link in the filesytem
|
||||
listen: 1, // - register your socket as a server
|
||||
local: 2, // - create a temporary value for a global variable (dynamic scoping)
|
||||
localtime: 1, // - convert UNIX time into record or string using local time
|
||||
lock: 1, // - get a thread lock on a variable, subroutine, or method
|
||||
'log': 1, // - retrieve the natural logarithm for a number
|
||||
lstat: 1, // - stat a symbolic link
|
||||
m: null, // - match a string with a regular expression pattern
|
||||
map: 1, // - apply a change to a list to get back a new list with the changes
|
||||
mkdir: 1, // - create a directory
|
||||
msgctl: 1, // - SysV IPC message control operations
|
||||
msgget: 1, // - get SysV IPC message queue
|
||||
msgrcv: 1, // - receive a SysV IPC message from a message queue
|
||||
msgsnd: 1, // - send a SysV IPC message to a message queue
|
||||
my: 2, // - declare and assign a local variable (lexical scoping)
|
||||
'new': 1, //
|
||||
next: 1, // - iterate a block prematurely
|
||||
no: 1, // - unimport some module symbols or semantics at compile time
|
||||
oct: 1, // - convert a string to an octal number
|
||||
open: 1, // - open a file, pipe, or descriptor
|
||||
opendir: 1, // - open a directory
|
||||
ord: 1, // - find a character's numeric representation
|
||||
our: 2, // - declare and assign a package variable (lexical scoping)
|
||||
pack: 1, // - convert a list into a binary representation
|
||||
'package': 1, // - declare a separate global namespace
|
||||
pipe: 1, // - open a pair of connected filehandles
|
||||
pop: 1, // - remove the last element from an array and return it
|
||||
pos: 1, // - find or set the offset for the last/next m//g search
|
||||
print: 1, // - output a list to a filehandle
|
||||
printf: 1, // - output a formatted list to a filehandle
|
||||
prototype: 1, // - get the prototype (if any) of a subroutine
|
||||
push: 1, // - append one or more elements to an array
|
||||
q: null, // - singly quote a string
|
||||
qq: null, // - doubly quote a string
|
||||
qr: null, // - Compile pattern
|
||||
quotemeta: null, // - quote regular expression magic characters
|
||||
qw: null, // - quote a list of words
|
||||
qx: null, // - backquote quote a string
|
||||
rand: 1, // - retrieve the next pseudorandom number
|
||||
read: 1, // - fixed-length buffered input from a filehandle
|
||||
readdir: 1, // - get a directory from a directory handle
|
||||
readline: 1, // - fetch a record from a file
|
||||
readlink: 1, // - determine where a symbolic link is pointing
|
||||
readpipe: 1, // - execute a system command and collect standard output
|
||||
recv: 1, // - receive a message over a Socket
|
||||
redo: 1, // - start this loop iteration over again
|
||||
ref: 1, // - find out the type of thing being referenced
|
||||
rename: 1, // - change a filename
|
||||
require: 1, // - load in external functions from a library at runtime
|
||||
reset: 1, // - clear all variables of a given name
|
||||
'return': 1, // - get out of a function early
|
||||
reverse: 1, // - flip a string or a list
|
||||
rewinddir: 1, // - reset directory handle
|
||||
rindex: 1, // - right-to-left substring search
|
||||
rmdir: 1, // - remove a directory
|
||||
s: null, // - replace a pattern with a string
|
||||
say: 1, // - print with newline
|
||||
scalar: 1, // - force a scalar context
|
||||
seek: 1, // - reposition file pointer for random-access I/O
|
||||
seekdir: 1, // - reposition directory pointer
|
||||
select: 1, // - reset default output or do I/O multiplexing
|
||||
semctl: 1, // - SysV semaphore control operations
|
||||
semget: 1, // - get set of SysV semaphores
|
||||
semop: 1, // - SysV semaphore operations
|
||||
send: 1, // - send a message over a socket
|
||||
setgrent: 1, // - prepare group file for use
|
||||
sethostent: 1, // - prepare hosts file for use
|
||||
setnetent: 1, // - prepare networks file for use
|
||||
setpgrp: 1, // - set the process group of a process
|
||||
setpriority: 1, // - set a process's nice value
|
||||
setprotoent: 1, // - prepare protocols file for use
|
||||
setpwent: 1, // - prepare passwd file for use
|
||||
setservent: 1, // - prepare services file for use
|
||||
setsockopt: 1, // - set some socket options
|
||||
shift: 1, // - remove the first element of an array, and return it
|
||||
shmctl: 1, // - SysV shared memory operations
|
||||
shmget: 1, // - get SysV shared memory segment identifier
|
||||
shmread: 1, // - read SysV shared memory
|
||||
shmwrite: 1, // - write SysV shared memory
|
||||
shutdown: 1, // - close down just half of a socket connection
|
||||
'sin': 1, // - return the sine of a number
|
||||
sleep: 1, // - block for some number of seconds
|
||||
socket: 1, // - create a socket
|
||||
socketpair: 1, // - create a pair of sockets
|
||||
'sort': 1, // - sort a list of values
|
||||
splice: 1, // - add or remove elements anywhere in an array
|
||||
'split': 1, // - split up a string using a regexp delimiter
|
||||
sprintf: 1, // - formatted print into a string
|
||||
'sqrt': 1, // - square root function
|
||||
srand: 1, // - seed the random number generator
|
||||
stat: 1, // - get a file's status information
|
||||
state: 1, // - declare and assign a state variable (persistent lexical scoping)
|
||||
study: 1, // - optimize input data for repeated searches
|
||||
'sub': 1, // - declare a subroutine, possibly anonymously
|
||||
'substr': 1, // - get or alter a portion of a stirng
|
||||
symlink: 1, // - create a symbolic link to a file
|
||||
syscall: 1, // - execute an arbitrary system call
|
||||
sysopen: 1, // - open a file, pipe, or descriptor
|
||||
sysread: 1, // - fixed-length unbuffered input from a filehandle
|
||||
sysseek: 1, // - position I/O pointer on handle used with sysread and syswrite
|
||||
system: 1, // - run a separate program
|
||||
syswrite: 1, // - fixed-length unbuffered output to a filehandle
|
||||
tell: 1, // - get current seekpointer on a filehandle
|
||||
telldir: 1, // - get current seekpointer on a directory handle
|
||||
tie: 1, // - bind a variable to an object class
|
||||
tied: 1, // - get a reference to the object underlying a tied variable
|
||||
time: 1, // - return number of seconds since 1970
|
||||
times: 1, // - return elapsed time for self and child processes
|
||||
tr: null, // - transliterate a string
|
||||
truncate: 1, // - shorten a file
|
||||
uc: 1, // - return upper-case version of a string
|
||||
ucfirst: 1, // - return a string with just the next letter in upper case
|
||||
umask: 1, // - set file creation mode mask
|
||||
undef: 1, // - remove a variable or function definition
|
||||
unlink: 1, // - remove one link to a file
|
||||
unpack: 1, // - convert binary structure into normal perl variables
|
||||
unshift: 1, // - prepend more elements to the beginning of a list
|
||||
untie: 1, // - break a tie binding to a variable
|
||||
use: 1, // - load in a module at compile time
|
||||
utime: 1, // - set a file's last access and modify times
|
||||
values: 1, // - return a list of the values in a hash
|
||||
vec: 1, // - test or set particular bits in a string
|
||||
wait: 1, // - wait for any child process to die
|
||||
waitpid: 1, // - wait for a particular child process to die
|
||||
wantarray: 1, // - get void vs scalar vs list context of current subroutine call
|
||||
warn: 1, // - print debugging info
|
||||
when: 1, //
|
||||
write: 1, // - print a picture record
|
||||
y: null
|
||||
}; // - transliterate a string
|
||||
|
||||
var RXstyle = "string-2";
|
||||
var RXmodifiers = /[goseximacplud]/; // NOTE: "m", "s", "y" and "tr" need to correct real modifiers for each regexp type
|
||||
|
||||
function tokenChain(stream, state, chain, style, tail) { // NOTE: chain.length > 2 is not working now (it's for s[...][...]geos;)
|
||||
state.chain = null; // 12 3tail
|
||||
state.style = null;
|
||||
state.tail = null;
|
||||
state.tokenize = function (stream, state) {
|
||||
var e = false, c, i = 0;
|
||||
while (c = stream.next()) {
|
||||
if (c === chain[i] && !e) {
|
||||
if (chain[++i] !== undefined) {
|
||||
state.chain = chain[i];
|
||||
state.style = style;
|
||||
state.tail = tail;
|
||||
}
|
||||
else if (tail)
|
||||
stream.eatWhile(tail);
|
||||
state.tokenize = tokenPerl;
|
||||
return style;
|
||||
}
|
||||
e = !e && c == "\\";
|
||||
}
|
||||
return style;
|
||||
};
|
||||
return state.tokenize(stream, state);
|
||||
}
|
||||
|
||||
function tokenSOMETHING(stream, state, string) {
|
||||
state.tokenize = function (stream, state) {
|
||||
if (stream.string == string)
|
||||
state.tokenize = tokenPerl;
|
||||
stream.skipToEnd();
|
||||
return "string";
|
||||
};
|
||||
return state.tokenize(stream, state);
|
||||
}
|
||||
|
||||
function tokenPerl(stream, state) {
|
||||
if (stream.eatSpace())
|
||||
return null;
|
||||
if (state.chain)
|
||||
return tokenChain(stream, state, state.chain, state.style, state.tail);
|
||||
if (stream.match(/^\-?[\d\.]/, false))
|
||||
if (stream.match(/^(\-?(\d*\.\d+(e[+-]?\d+)?|\d+\.\d*)|0x[\da-fA-F]+|0b[01]+|\d+(e[+-]?\d+)?)/))
|
||||
return 'number';
|
||||
if (stream.match(/^<<(?=\w)/)) { // NOTE: <<SOMETHING\n...\nSOMETHING\n
|
||||
stream.eatWhile(/\w/);
|
||||
return tokenSOMETHING(stream, state, stream.current().substr(2));
|
||||
}
|
||||
if (stream.sol() && stream.match(/^\=item(?!\w)/)) {// NOTE: \n=item...\n=cut\n
|
||||
return tokenSOMETHING(stream, state, '=cut');
|
||||
}
|
||||
var ch = stream.next();
|
||||
if (ch == '"' || ch == "'") { // NOTE: ' or " or <<'SOMETHING'\n...\nSOMETHING\n or <<"SOMETHING"\n...\nSOMETHING\n
|
||||
if (prefix(stream, 3) == "<<" + ch) {
|
||||
var p = stream.pos;
|
||||
stream.eatWhile(/\w/);
|
||||
var n = stream.current().substr(1);
|
||||
if (n && stream.eat(ch))
|
||||
return tokenSOMETHING(stream, state, n);
|
||||
stream.pos = p;
|
||||
}
|
||||
return tokenChain(stream, state, [ch], "string");
|
||||
}
|
||||
if (ch == "q") {
|
||||
var c = look(stream, -2);
|
||||
if (!(c && /\w/.test(c))) {
|
||||
c = look(stream, 0);
|
||||
if (c == "x") {
|
||||
c = look(stream, 1);
|
||||
if (c == "(") {
|
||||
eatSuffix(stream, 2);
|
||||
return tokenChain(stream, state, [")"], RXstyle, RXmodifiers);
|
||||
}
|
||||
if (c == "[") {
|
||||
eatSuffix(stream, 2);
|
||||
return tokenChain(stream, state, ["]"], RXstyle, RXmodifiers);
|
||||
}
|
||||
if (c == "{") {
|
||||
eatSuffix(stream, 2);
|
||||
return tokenChain(stream, state, ["}"], RXstyle, RXmodifiers);
|
||||
}
|
||||
if (c == "<") {
|
||||
eatSuffix(stream, 2);
|
||||
return tokenChain(stream, state, [">"], RXstyle, RXmodifiers);
|
||||
}
|
||||
if (/[\^'"!~\/]/.test(c)) {
|
||||
eatSuffix(stream, 1);
|
||||
return tokenChain(stream, state, [stream.eat(c)], RXstyle, RXmodifiers);
|
||||
}
|
||||
}
|
||||
else if (c == "q") {
|
||||
c = look(stream, 1);
|
||||
if (c == "(") {
|
||||
eatSuffix(stream, 2);
|
||||
return tokenChain(stream, state, [")"], "string");
|
||||
}
|
||||
if (c == "[") {
|
||||
eatSuffix(stream, 2);
|
||||
return tokenChain(stream, state, ["]"], "string");
|
||||
}
|
||||
if (c == "{") {
|
||||
eatSuffix(stream, 2);
|
||||
return tokenChain(stream, state, ["}"], "string");
|
||||
}
|
||||
if (c == "<") {
|
||||
eatSuffix(stream, 2);
|
||||
return tokenChain(stream, state, [">"], "string");
|
||||
}
|
||||
if (/[\^'"!~\/]/.test(c)) {
|
||||
eatSuffix(stream, 1);
|
||||
return tokenChain(stream, state, [stream.eat(c)], "string");
|
||||
}
|
||||
}
|
||||
else if (c == "w") {
|
||||
c = look(stream, 1);
|
||||
if (c == "(") {
|
||||
eatSuffix(stream, 2);
|
||||
return tokenChain(stream, state, [")"], "bracket");
|
||||
}
|
||||
if (c == "[") {
|
||||
eatSuffix(stream, 2);
|
||||
return tokenChain(stream, state, ["]"], "bracket");
|
||||
}
|
||||
if (c == "{") {
|
||||
eatSuffix(stream, 2);
|
||||
return tokenChain(stream, state, ["}"], "bracket");
|
||||
}
|
||||
if (c == "<") {
|
||||
eatSuffix(stream, 2);
|
||||
return tokenChain(stream, state, [">"], "bracket");
|
||||
}
|
||||
if (/[\^'"!~\/]/.test(c)) {
|
||||
eatSuffix(stream, 1);
|
||||
return tokenChain(stream, state, [stream.eat(c)], "bracket");
|
||||
}
|
||||
}
|
||||
else if (c == "r") {
|
||||
c = look(stream, 1);
|
||||
if (c == "(") {
|
||||
eatSuffix(stream, 2);
|
||||
return tokenChain(stream, state, [")"], RXstyle, RXmodifiers);
|
||||
}
|
||||
if (c == "[") {
|
||||
eatSuffix(stream, 2);
|
||||
return tokenChain(stream, state, ["]"], RXstyle, RXmodifiers);
|
||||
}
|
||||
if (c == "{") {
|
||||
eatSuffix(stream, 2);
|
||||
return tokenChain(stream, state, ["}"], RXstyle, RXmodifiers);
|
||||
}
|
||||
if (c == "<") {
|
||||
eatSuffix(stream, 2);
|
||||
return tokenChain(stream, state, [">"], RXstyle, RXmodifiers);
|
||||
}
|
||||
if (/[\^'"!~\/]/.test(c)) {
|
||||
eatSuffix(stream, 1);
|
||||
return tokenChain(stream, state, [stream.eat(c)], RXstyle, RXmodifiers);
|
||||
}
|
||||
}
|
||||
else if (/[\^'"!~\/(\[{<]/.test(c)) {
|
||||
if (c == "(") {
|
||||
eatSuffix(stream, 1);
|
||||
return tokenChain(stream, state, [")"], "string");
|
||||
}
|
||||
if (c == "[") {
|
||||
eatSuffix(stream, 1);
|
||||
return tokenChain(stream, state, ["]"], "string");
|
||||
}
|
||||
if (c == "{") {
|
||||
eatSuffix(stream, 1);
|
||||
return tokenChain(stream, state, ["}"], "string");
|
||||
}
|
||||
if (c == "<") {
|
||||
eatSuffix(stream, 1);
|
||||
return tokenChain(stream, state, [">"], "string");
|
||||
}
|
||||
if (/[\^'"!~\/]/.test(c)) {
|
||||
return tokenChain(stream, state, [stream.eat(c)], "string");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ch == "m") {
|
||||
var c = look(stream, -2);
|
||||
if (!(c && /\w/.test(c))) {
|
||||
c = stream.eat(/[(\[{<\^'"!~\/]/);
|
||||
if (c) {
|
||||
if (/[\^'"!~\/]/.test(c)) {
|
||||
return tokenChain(stream, state, [c], RXstyle, RXmodifiers);
|
||||
}
|
||||
if (c == "(") {
|
||||
return tokenChain(stream, state, [")"], RXstyle, RXmodifiers);
|
||||
}
|
||||
if (c == "[") {
|
||||
return tokenChain(stream, state, ["]"], RXstyle, RXmodifiers);
|
||||
}
|
||||
if (c == "{") {
|
||||
return tokenChain(stream, state, ["}"], RXstyle, RXmodifiers);
|
||||
}
|
||||
if (c == "<") {
|
||||
return tokenChain(stream, state, [">"], RXstyle, RXmodifiers);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ch == "s") {
|
||||
var c = /[\/>\]})\w]/.test(look(stream, -2));
|
||||
if (!c) {
|
||||
c = stream.eat(/[(\[{<\^'"!~\/]/);
|
||||
if (c) {
|
||||
if (c == "[")
|
||||
return tokenChain(stream, state, ["]", "]"], RXstyle, RXmodifiers);
|
||||
if (c == "{")
|
||||
return tokenChain(stream, state, ["}", "}"], RXstyle, RXmodifiers);
|
||||
if (c == "<")
|
||||
return tokenChain(stream, state, [">", ">"], RXstyle, RXmodifiers);
|
||||
if (c == "(")
|
||||
return tokenChain(stream, state, [")", ")"], RXstyle, RXmodifiers);
|
||||
return tokenChain(stream, state, [c, c], RXstyle, RXmodifiers);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ch == "y") {
|
||||
var c = /[\/>\]})\w]/.test(look(stream, -2));
|
||||
if (!c) {
|
||||
c = stream.eat(/[(\[{<\^'"!~\/]/);
|
||||
if (c) {
|
||||
if (c == "[")
|
||||
return tokenChain(stream, state, ["]", "]"], RXstyle, RXmodifiers);
|
||||
if (c == "{")
|
||||
return tokenChain(stream, state, ["}", "}"], RXstyle, RXmodifiers);
|
||||
if (c == "<")
|
||||
return tokenChain(stream, state, [">", ">"], RXstyle, RXmodifiers);
|
||||
if (c == "(")
|
||||
return tokenChain(stream, state, [")", ")"], RXstyle, RXmodifiers);
|
||||
return tokenChain(stream, state, [c, c], RXstyle, RXmodifiers);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ch == "t") {
|
||||
var c = /[\/>\]})\w]/.test(look(stream, -2));
|
||||
if (!c) {
|
||||
c = stream.eat("r"); if (c) {
|
||||
c = stream.eat(/[(\[{<\^'"!~\/]/);
|
||||
if (c) {
|
||||
if (c == "[")
|
||||
return tokenChain(stream, state, ["]", "]"], RXstyle, RXmodifiers);
|
||||
if (c == "{")
|
||||
return tokenChain(stream, state, ["}", "}"], RXstyle, RXmodifiers);
|
||||
if (c == "<")
|
||||
return tokenChain(stream, state, [">", ">"], RXstyle, RXmodifiers);
|
||||
if (c == "(")
|
||||
return tokenChain(stream, state, [")", ")"], RXstyle, RXmodifiers);
|
||||
return tokenChain(stream, state, [c, c], RXstyle, RXmodifiers);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ch == "`") {
|
||||
return tokenChain(stream, state, [ch], "variable-2");
|
||||
}
|
||||
if (ch == "/") {
|
||||
if (!/~\s*$/.test(prefix(stream)))
|
||||
return "operator";
|
||||
else
|
||||
return tokenChain(stream, state, [ch], RXstyle, RXmodifiers);
|
||||
}
|
||||
if (ch == "$") {
|
||||
var p = stream.pos;
|
||||
if (stream.eatWhile(/\d/) || stream.eat("{") && stream.eatWhile(/\d/) && stream.eat("}"))
|
||||
return "variable-2";
|
||||
else
|
||||
stream.pos = p;
|
||||
}
|
||||
if (/[$@%]/.test(ch)) {
|
||||
var p = stream.pos;
|
||||
if (stream.eat("^") && stream.eat(/[A-Z]/) || !/[@$%&]/.test(look(stream, -2)) && stream.eat(/[=|\\\-#?@;:&`~\^!\[\]*'"$+.,\/<>()]/)) {
|
||||
var c = stream.current();
|
||||
if (PERL[c])
|
||||
return "variable-2";
|
||||
}
|
||||
stream.pos = p;
|
||||
}
|
||||
if (/[$@%&]/.test(ch)) {
|
||||
if (stream.eatWhile(/[\w$\[\]]/) || stream.eat("{") && stream.eatWhile(/[\w$\[\]]/) && stream.eat("}")) {
|
||||
var c = stream.current();
|
||||
if (PERL[c])
|
||||
return "variable-2";
|
||||
else
|
||||
return "variable";
|
||||
}
|
||||
}
|
||||
if (ch == "#") {
|
||||
if (look(stream, -2) != "$") {
|
||||
stream.skipToEnd();
|
||||
return "comment";
|
||||
}
|
||||
}
|
||||
if (/[:+\-\^*$&%@=<>!?|\/~\.]/.test(ch)) {
|
||||
var p = stream.pos;
|
||||
stream.eatWhile(/[:+\-\^*$&%@=<>!?|\/~\.]/);
|
||||
if (PERL[stream.current()])
|
||||
return "operator";
|
||||
else
|
||||
stream.pos = p;
|
||||
}
|
||||
if (ch == "_") {
|
||||
if (stream.pos == 1) {
|
||||
if (suffix(stream, 6) == "_END__") {
|
||||
return tokenChain(stream, state, ['\0'], "comment");
|
||||
}
|
||||
else if (suffix(stream, 7) == "_DATA__") {
|
||||
return tokenChain(stream, state, ['\0'], "variable-2");
|
||||
}
|
||||
else if (suffix(stream, 7) == "_C__") {
|
||||
return tokenChain(stream, state, ['\0'], "string");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (/\w/.test(ch)) {
|
||||
var p = stream.pos;
|
||||
if (look(stream, -2) == "{" && (look(stream, 0) == "}" || stream.eatWhile(/\w/) && look(stream, 0) == "}"))
|
||||
return "string";
|
||||
else
|
||||
stream.pos = p;
|
||||
}
|
||||
if (/[A-Z]/.test(ch)) {
|
||||
var l = look(stream, -2);
|
||||
var p = stream.pos;
|
||||
stream.eatWhile(/[A-Z_]/);
|
||||
if (/[\da-z]/.test(look(stream, 0))) {
|
||||
stream.pos = p;
|
||||
}
|
||||
else {
|
||||
var c = PERL[stream.current()];
|
||||
if (!c)
|
||||
return "meta";
|
||||
if (c[1])
|
||||
c = c[0];
|
||||
if (l != ":") {
|
||||
if (c == 1)
|
||||
return "keyword";
|
||||
else if (c == 2)
|
||||
return "def";
|
||||
else if (c == 3)
|
||||
return "atom";
|
||||
else if (c == 4)
|
||||
return "operator";
|
||||
else if (c == 5)
|
||||
return "variable-2";
|
||||
else
|
||||
return "meta";
|
||||
}
|
||||
else
|
||||
return "meta";
|
||||
}
|
||||
}
|
||||
if (/[a-zA-Z_]/.test(ch)) {
|
||||
var l = look(stream, -2);
|
||||
stream.eatWhile(/\w/);
|
||||
var c = PERL[stream.current()];
|
||||
if (!c)
|
||||
return "meta";
|
||||
if (c[1])
|
||||
c = c[0];
|
||||
if (l != ":") {
|
||||
if (c == 1)
|
||||
return "keyword";
|
||||
else if (c == 2)
|
||||
return "def";
|
||||
else if (c == 3)
|
||||
return "atom";
|
||||
else if (c == 4)
|
||||
return "operator";
|
||||
else if (c == 5)
|
||||
return "variable-2";
|
||||
else
|
||||
return "meta";
|
||||
}
|
||||
else
|
||||
return "meta";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
return {
|
||||
startState: function () {
|
||||
return {
|
||||
tokenize: tokenPerl,
|
||||
chain: null,
|
||||
style: null,
|
||||
tail: null
|
||||
};
|
||||
},
|
||||
token: function (stream, state) {
|
||||
return (state.tokenize || tokenPerl)(stream, state);
|
||||
},
|
||||
electricChars: "{}"
|
||||
};
|
||||
});
|
||||
|
||||
CodeMirror.registerHelper("wordChars", "perl", /[\w$]/);
|
||||
|
||||
CodeMirror.defineMIME("text/x-perl", "perl");
|
||||
|
||||
// it's like "peek", but need for look-ahead or look-behind if index < 0
|
||||
function look(stream, c) {
|
||||
return stream.string.charAt(stream.pos + (c || 0));
|
||||
}
|
||||
|
||||
// return a part of prefix of current stream from current position
|
||||
function prefix(stream, c) {
|
||||
if (c) {
|
||||
var x = stream.pos - c;
|
||||
return stream.string.substr((x >= 0 ? x : 0), c);
|
||||
}
|
||||
else {
|
||||
return stream.string.substr(0, stream.pos - 1);
|
||||
}
|
||||
}
|
||||
|
||||
// return a part of suffix of current stream from current position
|
||||
function suffix(stream, c) {
|
||||
var y = stream.string.length;
|
||||
var x = y - stream.pos + 1;
|
||||
return stream.string.substr(stream.pos, (c && c < y ? c : x));
|
||||
}
|
||||
|
||||
// eating and vomiting a part of stream from current position
|
||||
function eatSuffix(stream, c) {
|
||||
var x = stream.pos + c;
|
||||
var y;
|
||||
if (x <= 0)
|
||||
stream.pos = 0;
|
||||
else if (x >= (y = stream.string.length - 1))
|
||||
stream.pos = y;
|
||||
else
|
||||
stream.pos = x;
|
||||
}
|
||||
|
||||
});
|
||||
@@ -0,0 +1,58 @@
|
||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
CodeMirror.defineOption("placeholder", "", function(cm, val, old) {
|
||||
var prev = old && old != CodeMirror.Init;
|
||||
if (val && !prev) {
|
||||
cm.on("blur", onBlur);
|
||||
cm.on("change", onChange);
|
||||
onChange(cm);
|
||||
} else if (!val && prev) {
|
||||
cm.off("blur", onBlur);
|
||||
cm.off("change", onChange);
|
||||
clearPlaceholder(cm);
|
||||
var wrapper = cm.getWrapperElement();
|
||||
wrapper.className = wrapper.className.replace(" CodeMirror-empty", "");
|
||||
}
|
||||
|
||||
if (val && !cm.hasFocus()) onBlur(cm);
|
||||
});
|
||||
|
||||
function clearPlaceholder(cm) {
|
||||
if (cm.state.placeholder) {
|
||||
cm.state.placeholder.parentNode.removeChild(cm.state.placeholder);
|
||||
cm.state.placeholder = null;
|
||||
}
|
||||
}
|
||||
function setPlaceholder(cm) {
|
||||
clearPlaceholder(cm);
|
||||
var elt = cm.state.placeholder = document.createElement("pre");
|
||||
elt.style.cssText = "height: 0; overflow: visible";
|
||||
elt.className = "CodeMirror-placeholder";
|
||||
elt.appendChild(document.createTextNode(cm.getOption("placeholder")));
|
||||
cm.display.lineSpace.insertBefore(elt, cm.display.lineSpace.firstChild);
|
||||
}
|
||||
|
||||
function onBlur(cm) {
|
||||
if (isEmpty(cm)) setPlaceholder(cm);
|
||||
}
|
||||
function onChange(cm) {
|
||||
var wrapper = cm.getWrapperElement(), empty = isEmpty(cm);
|
||||
wrapper.className = wrapper.className.replace(" CodeMirror-empty", "") + (empty ? " CodeMirror-empty" : "");
|
||||
|
||||
if (empty) setPlaceholder(cm);
|
||||
else clearPlaceholder(cm);
|
||||
}
|
||||
|
||||
function isEmpty(cm) {
|
||||
return (cm.lineCount() === 1) && (cm.getLine(0) === "");
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,346 @@
|
||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
function wordRegexp(words) {
|
||||
return new RegExp("^((" + words.join(")|(") + "))\\b");
|
||||
}
|
||||
|
||||
var wordOperators = wordRegexp(["and", "or", "not", "is"]);
|
||||
var commonKeywords = ["as", "assert", "break", "class", "continue",
|
||||
"def", "del", "elif", "else", "except", "finally",
|
||||
"for", "from", "global", "if", "import",
|
||||
"lambda", "pass", "raise", "return",
|
||||
"try", "while", "with", "yield", "in"];
|
||||
var commonBuiltins = ["abs", "all", "any", "bin", "bool", "bytearray", "callable", "chr",
|
||||
"classmethod", "compile", "complex", "delattr", "dict", "dir", "divmod",
|
||||
"enumerate", "eval", "filter", "float", "format", "frozenset",
|
||||
"getattr", "globals", "hasattr", "hash", "help", "hex", "id",
|
||||
"input", "int", "isinstance", "issubclass", "iter", "len",
|
||||
"list", "locals", "map", "max", "memoryview", "min", "next",
|
||||
"object", "oct", "open", "ord", "pow", "property", "range",
|
||||
"repr", "reversed", "round", "set", "setattr", "slice",
|
||||
"sorted", "staticmethod", "str", "sum", "super", "tuple",
|
||||
"type", "vars", "zip", "__import__", "NotImplemented",
|
||||
"Ellipsis", "__debug__"];
|
||||
var py2 = {builtins: ["apply", "basestring", "buffer", "cmp", "coerce", "execfile",
|
||||
"file", "intern", "long", "raw_input", "reduce", "reload",
|
||||
"unichr", "unicode", "xrange", "False", "True", "None"],
|
||||
keywords: ["exec", "print"]};
|
||||
var py3 = {builtins: ["ascii", "bytes", "exec", "print"],
|
||||
keywords: ["nonlocal", "False", "True", "None"]};
|
||||
|
||||
CodeMirror.registerHelper("hintWords", "python", commonKeywords.concat(commonBuiltins));
|
||||
|
||||
function top(state) {
|
||||
return state.scopes[state.scopes.length - 1];
|
||||
}
|
||||
|
||||
CodeMirror.defineMode("python", function(conf, parserConf) {
|
||||
var ERRORCLASS = "error";
|
||||
|
||||
var singleOperators = parserConf.singleOperators || new RegExp("^[\\+\\-\\*/%&|\\^~<>!]");
|
||||
var singleDelimiters = parserConf.singleDelimiters || new RegExp("^[\\(\\)\\[\\]\\{\\}@,:`=;\\.]");
|
||||
var doubleOperators = parserConf.doubleOperators || new RegExp("^((==)|(!=)|(<=)|(>=)|(<>)|(<<)|(>>)|(//)|(\\*\\*))");
|
||||
var doubleDelimiters = parserConf.doubleDelimiters || new RegExp("^((\\+=)|(\\-=)|(\\*=)|(%=)|(/=)|(&=)|(\\|=)|(\\^=))");
|
||||
var tripleDelimiters = parserConf.tripleDelimiters || new RegExp("^((//=)|(>>=)|(<<=)|(\\*\\*=))");
|
||||
var identifiers = parserConf.identifiers|| new RegExp("^[_A-Za-z][_A-Za-z0-9]*");
|
||||
var hangingIndent = parserConf.hangingIndent || conf.indentUnit;
|
||||
|
||||
var myKeywords = commonKeywords, myBuiltins = commonBuiltins;
|
||||
if(parserConf.extra_keywords != undefined){
|
||||
myKeywords = myKeywords.concat(parserConf.extra_keywords);
|
||||
}
|
||||
if(parserConf.extra_builtins != undefined){
|
||||
myBuiltins = myBuiltins.concat(parserConf.extra_builtins);
|
||||
}
|
||||
if (parserConf.version && parseInt(parserConf.version, 10) == 3) {
|
||||
myKeywords = myKeywords.concat(py3.keywords);
|
||||
myBuiltins = myBuiltins.concat(py3.builtins);
|
||||
var stringPrefixes = new RegExp("^(([rb]|(br))?('{3}|\"{3}|['\"]))", "i");
|
||||
} else {
|
||||
myKeywords = myKeywords.concat(py2.keywords);
|
||||
myBuiltins = myBuiltins.concat(py2.builtins);
|
||||
var stringPrefixes = new RegExp("^(([rub]|(ur)|(br))?('{3}|\"{3}|['\"]))", "i");
|
||||
}
|
||||
var keywords = wordRegexp(myKeywords);
|
||||
var builtins = wordRegexp(myBuiltins);
|
||||
|
||||
// tokenizers
|
||||
function tokenBase(stream, state) {
|
||||
// Handle scope changes
|
||||
if (stream.sol() && top(state).type == "py") {
|
||||
var scopeOffset = top(state).offset;
|
||||
if (stream.eatSpace()) {
|
||||
var lineOffset = stream.indentation();
|
||||
if (lineOffset > scopeOffset)
|
||||
pushScope(stream, state, "py");
|
||||
else if (lineOffset < scopeOffset && dedent(stream, state))
|
||||
state.errorToken = true;
|
||||
return null;
|
||||
} else {
|
||||
var style = tokenBaseInner(stream, state);
|
||||
if (scopeOffset > 0 && dedent(stream, state))
|
||||
style += " " + ERRORCLASS;
|
||||
return style;
|
||||
}
|
||||
}
|
||||
return tokenBaseInner(stream, state);
|
||||
}
|
||||
|
||||
function tokenBaseInner(stream, state) {
|
||||
if (stream.eatSpace()) return null;
|
||||
|
||||
var ch = stream.peek();
|
||||
|
||||
// Handle Comments
|
||||
if (ch == "#") {
|
||||
stream.skipToEnd();
|
||||
return "comment";
|
||||
}
|
||||
|
||||
// Handle Number Literals
|
||||
if (stream.match(/^[0-9\.]/, false)) {
|
||||
var floatLiteral = false;
|
||||
// Floats
|
||||
if (stream.match(/^\d*\.\d+(e[\+\-]?\d+)?/i)) { floatLiteral = true; }
|
||||
if (stream.match(/^\d+\.\d*/)) { floatLiteral = true; }
|
||||
if (stream.match(/^\.\d+/)) { floatLiteral = true; }
|
||||
if (floatLiteral) {
|
||||
// Float literals may be "imaginary"
|
||||
stream.eat(/J/i);
|
||||
return "number";
|
||||
}
|
||||
// Integers
|
||||
var intLiteral = false;
|
||||
// Hex
|
||||
if (stream.match(/^0x[0-9a-f]+/i)) intLiteral = true;
|
||||
// Binary
|
||||
if (stream.match(/^0b[01]+/i)) intLiteral = true;
|
||||
// Octal
|
||||
if (stream.match(/^0o[0-7]+/i)) intLiteral = true;
|
||||
// Decimal
|
||||
if (stream.match(/^[1-9]\d*(e[\+\-]?\d+)?/)) {
|
||||
// Decimal literals may be "imaginary"
|
||||
stream.eat(/J/i);
|
||||
// TODO - Can you have imaginary longs?
|
||||
intLiteral = true;
|
||||
}
|
||||
// Zero by itself with no other piece of number.
|
||||
if (stream.match(/^0(?![\dx])/i)) intLiteral = true;
|
||||
if (intLiteral) {
|
||||
// Integer literals may be "long"
|
||||
stream.eat(/L/i);
|
||||
return "number";
|
||||
}
|
||||
}
|
||||
|
||||
// Handle Strings
|
||||
if (stream.match(stringPrefixes)) {
|
||||
state.tokenize = tokenStringFactory(stream.current());
|
||||
return state.tokenize(stream, state);
|
||||
}
|
||||
|
||||
// Handle operators and Delimiters
|
||||
if (stream.match(tripleDelimiters) || stream.match(doubleDelimiters))
|
||||
return null;
|
||||
|
||||
if (stream.match(doubleOperators)
|
||||
|| stream.match(singleOperators)
|
||||
|| stream.match(wordOperators))
|
||||
return "operator";
|
||||
|
||||
if (stream.match(singleDelimiters))
|
||||
return null;
|
||||
|
||||
if (stream.match(keywords))
|
||||
return "keyword";
|
||||
|
||||
if (stream.match(builtins))
|
||||
return "builtin";
|
||||
|
||||
if (stream.match(/^(self|cls)\b/))
|
||||
return "variable-2";
|
||||
|
||||
if (stream.match(identifiers)) {
|
||||
if (state.lastToken == "def" || state.lastToken == "class")
|
||||
return "def";
|
||||
return "variable";
|
||||
}
|
||||
|
||||
// Handle non-detected items
|
||||
stream.next();
|
||||
return ERRORCLASS;
|
||||
}
|
||||
|
||||
function tokenStringFactory(delimiter) {
|
||||
while ("rub".indexOf(delimiter.charAt(0).toLowerCase()) >= 0)
|
||||
delimiter = delimiter.substr(1);
|
||||
|
||||
var singleline = delimiter.length == 1;
|
||||
var OUTCLASS = "string";
|
||||
|
||||
function tokenString(stream, state) {
|
||||
while (!stream.eol()) {
|
||||
stream.eatWhile(/[^'"\\]/);
|
||||
if (stream.eat("\\")) {
|
||||
stream.next();
|
||||
if (singleline && stream.eol())
|
||||
return OUTCLASS;
|
||||
} else if (stream.match(delimiter)) {
|
||||
state.tokenize = tokenBase;
|
||||
return OUTCLASS;
|
||||
} else {
|
||||
stream.eat(/['"]/);
|
||||
}
|
||||
}
|
||||
if (singleline) {
|
||||
if (parserConf.singleLineStringErrors)
|
||||
return ERRORCLASS;
|
||||
else
|
||||
state.tokenize = tokenBase;
|
||||
}
|
||||
return OUTCLASS;
|
||||
}
|
||||
tokenString.isString = true;
|
||||
return tokenString;
|
||||
}
|
||||
|
||||
function pushScope(stream, state, type) {
|
||||
var offset = 0, align = null;
|
||||
if (type == "py") {
|
||||
while (top(state).type != "py")
|
||||
state.scopes.pop();
|
||||
}
|
||||
offset = top(state).offset + (type == "py" ? conf.indentUnit : hangingIndent);
|
||||
if (type != "py" && !stream.match(/^(\s|#.*)*$/, false))
|
||||
align = stream.column() + 1;
|
||||
state.scopes.push({offset: offset, type: type, align: align});
|
||||
}
|
||||
|
||||
function dedent(stream, state) {
|
||||
var indented = stream.indentation();
|
||||
while (top(state).offset > indented) {
|
||||
if (top(state).type != "py") return true;
|
||||
state.scopes.pop();
|
||||
}
|
||||
return top(state).offset != indented;
|
||||
}
|
||||
|
||||
function tokenLexer(stream, state) {
|
||||
var style = state.tokenize(stream, state);
|
||||
var current = stream.current();
|
||||
|
||||
// Handle '.' connected identifiers
|
||||
if (current == ".") {
|
||||
style = stream.match(identifiers, false) ? null : ERRORCLASS;
|
||||
if (style == null && state.lastStyle == "meta") {
|
||||
// Apply 'meta' style to '.' connected identifiers when
|
||||
// appropriate.
|
||||
style = "meta";
|
||||
}
|
||||
return style;
|
||||
}
|
||||
|
||||
// Handle decorators
|
||||
if (current == "@")
|
||||
return stream.match(identifiers, false) ? "meta" : ERRORCLASS;
|
||||
|
||||
if ((style == "variable" || style == "builtin")
|
||||
&& state.lastStyle == "meta")
|
||||
style = "meta";
|
||||
|
||||
// Handle scope changes.
|
||||
if (current == "pass" || current == "return")
|
||||
state.dedent += 1;
|
||||
|
||||
if (current == "lambda") state.lambda = true;
|
||||
if (current == ":" && !state.lambda && top(state).type == "py")
|
||||
pushScope(stream, state, "py");
|
||||
|
||||
var delimiter_index = current.length == 1 ? "[({".indexOf(current) : -1;
|
||||
if (delimiter_index != -1)
|
||||
pushScope(stream, state, "])}".slice(delimiter_index, delimiter_index+1));
|
||||
|
||||
delimiter_index = "])}".indexOf(current);
|
||||
if (delimiter_index != -1) {
|
||||
if (top(state).type == current) state.scopes.pop();
|
||||
else return ERRORCLASS;
|
||||
}
|
||||
if (state.dedent > 0 && stream.eol() && top(state).type == "py") {
|
||||
if (state.scopes.length > 1) state.scopes.pop();
|
||||
state.dedent -= 1;
|
||||
}
|
||||
|
||||
return style;
|
||||
}
|
||||
|
||||
var external = {
|
||||
startState: function(basecolumn) {
|
||||
return {
|
||||
tokenize: tokenBase,
|
||||
scopes: [{offset: basecolumn || 0, type: "py", align: null}],
|
||||
lastStyle: null,
|
||||
lastToken: null,
|
||||
lambda: false,
|
||||
dedent: 0
|
||||
};
|
||||
},
|
||||
|
||||
token: function(stream, state) {
|
||||
var addErr = state.errorToken;
|
||||
if (addErr) state.errorToken = false;
|
||||
var style = tokenLexer(stream, state);
|
||||
|
||||
state.lastStyle = style;
|
||||
|
||||
var current = stream.current();
|
||||
if (current && style)
|
||||
state.lastToken = current;
|
||||
|
||||
if (stream.eol() && state.lambda)
|
||||
state.lambda = false;
|
||||
return addErr ? style + " " + ERRORCLASS : style;
|
||||
},
|
||||
|
||||
indent: function(state, textAfter) {
|
||||
if (state.tokenize != tokenBase)
|
||||
return state.tokenize.isString ? CodeMirror.Pass : 0;
|
||||
|
||||
var scope = top(state);
|
||||
var closing = textAfter && textAfter.charAt(0) == scope.type;
|
||||
if (scope.align != null)
|
||||
return scope.align - (closing ? 1 : 0);
|
||||
else if (closing && state.scopes.length > 1)
|
||||
return state.scopes[state.scopes.length - 2].offset;
|
||||
else
|
||||
return scope.offset;
|
||||
},
|
||||
|
||||
lineComment: "#",
|
||||
fold: "indent"
|
||||
};
|
||||
return external;
|
||||
});
|
||||
|
||||
CodeMirror.defineMIME("text/x-python", "python");
|
||||
|
||||
var words = function(str) { return str.split(" "); };
|
||||
|
||||
CodeMirror.defineMIME("text/x-cython", {
|
||||
name: "python",
|
||||
extra_keywords: words("by cdef cimport cpdef ctypedef enum except"+
|
||||
"extern gil include nogil property public"+
|
||||
"readonly struct union DEF IF ELIF ELSE")
|
||||
});
|
||||
|
||||
});
|
||||
@@ -0,0 +1,285 @@
|
||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function (mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function (CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
CodeMirror.defineMode("ruby", function (config) {
|
||||
function wordObj(words) {
|
||||
var o = {};
|
||||
for (var i = 0, e = words.length; i < e; ++i) o[words[i]] = true;
|
||||
return o;
|
||||
}
|
||||
var keywords = wordObj([
|
||||
"alias", "and", "BEGIN", "begin", "break", "case", "class", "def", "defined?", "do", "else",
|
||||
"elsif", "END", "end", "ensure", "false", "for", "if", "in", "module", "next", "not", "or",
|
||||
"redo", "rescue", "retry", "return", "self", "super", "then", "true", "undef", "unless",
|
||||
"until", "when", "while", "yield", "nil", "raise", "throw", "catch", "fail", "loop", "callcc",
|
||||
"caller", "lambda", "proc", "public", "protected", "private", "require", "load",
|
||||
"require_relative", "extend", "autoload", "__END__", "__FILE__", "__LINE__", "__dir__"
|
||||
]);
|
||||
var indentWords = wordObj(["def", "class", "case", "for", "while", "module", "then",
|
||||
"catch", "loop", "proc", "begin"]);
|
||||
var dedentWords = wordObj(["end", "until"]);
|
||||
var matching = { "[": "]", "{": "}", "(": ")" };
|
||||
var curPunc;
|
||||
|
||||
function chain(newtok, stream, state) {
|
||||
state.tokenize.push(newtok);
|
||||
return newtok(stream, state);
|
||||
}
|
||||
|
||||
function tokenBase(stream, state) {
|
||||
curPunc = null;
|
||||
if (stream.sol() && stream.match("=begin") && stream.eol()) {
|
||||
state.tokenize.push(readBlockComment);
|
||||
return "comment";
|
||||
}
|
||||
if (stream.eatSpace()) return null;
|
||||
var ch = stream.next(), m;
|
||||
if (ch == "`" || ch == "'" || ch == '"') {
|
||||
return chain(readQuoted(ch, "string", ch == '"' || ch == "`"), stream, state);
|
||||
} else if (ch == "/") {
|
||||
var currentIndex = stream.current().length;
|
||||
if (stream.skipTo("/")) {
|
||||
var search_till = stream.current().length;
|
||||
stream.backUp(stream.current().length - currentIndex);
|
||||
var balance = 0; // balance brackets
|
||||
while (stream.current().length < search_till) {
|
||||
var chchr = stream.next();
|
||||
if (chchr == "(") balance += 1;
|
||||
else if (chchr == ")") balance -= 1;
|
||||
if (balance < 0) break;
|
||||
}
|
||||
stream.backUp(stream.current().length - currentIndex);
|
||||
if (balance == 0)
|
||||
return chain(readQuoted(ch, "string-2", true), stream, state);
|
||||
}
|
||||
return "operator";
|
||||
} else if (ch == "%") {
|
||||
var style = "string", embed = true;
|
||||
if (stream.eat("s")) style = "atom";
|
||||
else if (stream.eat(/[WQ]/)) style = "string";
|
||||
else if (stream.eat(/[r]/)) style = "string-2";
|
||||
else if (stream.eat(/[wxq]/)) { style = "string"; embed = false; }
|
||||
var delim = stream.eat(/[^\w\s=]/);
|
||||
if (!delim) return "operator";
|
||||
if (matching.propertyIsEnumerable(delim)) delim = matching[delim];
|
||||
return chain(readQuoted(delim, style, embed, true), stream, state);
|
||||
} else if (ch == "#") {
|
||||
stream.skipToEnd();
|
||||
return "comment";
|
||||
} else if (ch == "<" && (m = stream.match(/^<-?[\`\"\']?([a-zA-Z_?]\w*)[\`\"\']?(?:;|$)/))) {
|
||||
return chain(readHereDoc(m[1]), stream, state);
|
||||
} else if (ch == "0") {
|
||||
if (stream.eat("x")) stream.eatWhile(/[\da-fA-F]/);
|
||||
else if (stream.eat("b")) stream.eatWhile(/[01]/);
|
||||
else stream.eatWhile(/[0-7]/);
|
||||
return "number";
|
||||
} else if (/\d/.test(ch)) {
|
||||
stream.match(/^[\d_]*(?:\.[\d_]+)?(?:[eE][+\-]?[\d_]+)?/);
|
||||
return "number";
|
||||
} else if (ch == "?") {
|
||||
while (stream.match(/^\\[CM]-/)) { }
|
||||
if (stream.eat("\\")) stream.eatWhile(/\w/);
|
||||
else stream.next();
|
||||
return "string";
|
||||
} else if (ch == ":") {
|
||||
if (stream.eat("'")) return chain(readQuoted("'", "atom", false), stream, state);
|
||||
if (stream.eat('"')) return chain(readQuoted('"', "atom", true), stream, state);
|
||||
|
||||
// :> :>> :< :<< are valid symbols
|
||||
if (stream.eat(/[\<\>]/)) {
|
||||
stream.eat(/[\<\>]/);
|
||||
return "atom";
|
||||
}
|
||||
|
||||
// :+ :- :/ :* :| :& :! are valid symbols
|
||||
if (stream.eat(/[\+\-\*\/\&\|\:\!]/)) {
|
||||
return "atom";
|
||||
}
|
||||
|
||||
// Symbols can't start by a digit
|
||||
if (stream.eat(/[a-zA-Z$@_]/)) {
|
||||
stream.eatWhile(/[\w]/);
|
||||
// Only one ? ! = is allowed and only as the last character
|
||||
stream.eat(/[\?\!\=]/);
|
||||
return "atom";
|
||||
}
|
||||
return "operator";
|
||||
} else if (ch == "@" && stream.match(/^@?[a-zA-Z_]/)) {
|
||||
stream.eat("@");
|
||||
stream.eatWhile(/[\w]/);
|
||||
return "variable-2";
|
||||
} else if (ch == "$") {
|
||||
if (stream.eat(/[a-zA-Z_]/)) {
|
||||
stream.eatWhile(/[\w]/);
|
||||
} else if (stream.eat(/\d/)) {
|
||||
stream.eat(/\d/);
|
||||
} else {
|
||||
stream.next(); // Must be a special global like $: or $!
|
||||
}
|
||||
return "variable-3";
|
||||
} else if (/[a-zA-Z_]/.test(ch)) {
|
||||
stream.eatWhile(/[\w]/);
|
||||
stream.eat(/[\?\!]/);
|
||||
if (stream.eat(":")) return "atom";
|
||||
return "ident";
|
||||
} else if (ch == "|" && (state.varList || state.lastTok == "{" || state.lastTok == "do")) {
|
||||
curPunc = "|";
|
||||
return null;
|
||||
} else if (/[\(\)\[\]{}\\;]/.test(ch)) {
|
||||
curPunc = ch;
|
||||
return null;
|
||||
} else if (ch == "-" && stream.eat(">")) {
|
||||
return "arrow";
|
||||
} else if (/[=+\-\/*:\.^%<>~|]/.test(ch)) {
|
||||
var more = stream.eatWhile(/[=+\-\/*:\.^%<>~|]/);
|
||||
if (ch == "." && !more) curPunc = ".";
|
||||
return "operator";
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function tokenBaseUntilBrace() {
|
||||
var depth = 1;
|
||||
return function (stream, state) {
|
||||
if (stream.peek() == "}") {
|
||||
depth--;
|
||||
if (depth == 0) {
|
||||
state.tokenize.pop();
|
||||
return state.tokenize[state.tokenize.length - 1](stream, state);
|
||||
}
|
||||
} else if (stream.peek() == "{") {
|
||||
depth++;
|
||||
}
|
||||
return tokenBase(stream, state);
|
||||
};
|
||||
}
|
||||
function tokenBaseOnce() {
|
||||
var alreadyCalled = false;
|
||||
return function (stream, state) {
|
||||
if (alreadyCalled) {
|
||||
state.tokenize.pop();
|
||||
return state.tokenize[state.tokenize.length - 1](stream, state);
|
||||
}
|
||||
alreadyCalled = true;
|
||||
return tokenBase(stream, state);
|
||||
};
|
||||
}
|
||||
function readQuoted(quote, style, embed, unescaped) {
|
||||
return function (stream, state) {
|
||||
var escaped = false, ch;
|
||||
|
||||
if (state.context.type === 'read-quoted-paused') {
|
||||
state.context = state.context.prev;
|
||||
stream.eat("}");
|
||||
}
|
||||
|
||||
while ((ch = stream.next()) != null) {
|
||||
if (ch == quote && (unescaped || !escaped)) {
|
||||
state.tokenize.pop();
|
||||
break;
|
||||
}
|
||||
if (embed && ch == "#" && !escaped) {
|
||||
if (stream.eat("{")) {
|
||||
if (quote == "}") {
|
||||
state.context = { prev: state.context, type: 'read-quoted-paused' };
|
||||
}
|
||||
state.tokenize.push(tokenBaseUntilBrace());
|
||||
break;
|
||||
} else if (/[@\$]/.test(stream.peek())) {
|
||||
state.tokenize.push(tokenBaseOnce());
|
||||
break;
|
||||
}
|
||||
}
|
||||
escaped = !escaped && ch == "\\";
|
||||
}
|
||||
return style;
|
||||
};
|
||||
}
|
||||
function readHereDoc(phrase) {
|
||||
return function (stream, state) {
|
||||
if (stream.match(phrase)) state.tokenize.pop();
|
||||
else stream.skipToEnd();
|
||||
return "string";
|
||||
};
|
||||
}
|
||||
function readBlockComment(stream, state) {
|
||||
if (stream.sol() && stream.match("=end") && stream.eol())
|
||||
state.tokenize.pop();
|
||||
stream.skipToEnd();
|
||||
return "comment";
|
||||
}
|
||||
|
||||
return {
|
||||
startState: function () {
|
||||
return { tokenize: [tokenBase],
|
||||
indented: 0,
|
||||
context: { type: "top", indented: -config.indentUnit },
|
||||
continuedLine: false,
|
||||
lastTok: null,
|
||||
varList: false
|
||||
};
|
||||
},
|
||||
|
||||
token: function (stream, state) {
|
||||
if (stream.sol()) state.indented = stream.indentation();
|
||||
var style = state.tokenize[state.tokenize.length - 1](stream, state), kwtype;
|
||||
var thisTok = curPunc;
|
||||
if (style == "ident") {
|
||||
var word = stream.current();
|
||||
style = state.lastTok == "." ? "property"
|
||||
: keywords.propertyIsEnumerable(stream.current()) ? "keyword"
|
||||
: /^[A-Z]/.test(word) ? "tag"
|
||||
: (state.lastTok == "def" || state.lastTok == "class" || state.varList) ? "def"
|
||||
: "variable";
|
||||
if (style == "keyword") {
|
||||
thisTok = word;
|
||||
if (indentWords.propertyIsEnumerable(word)) kwtype = "indent";
|
||||
else if (dedentWords.propertyIsEnumerable(word)) kwtype = "dedent";
|
||||
else if ((word == "if" || word == "unless") && stream.column() == stream.indentation())
|
||||
kwtype = "indent";
|
||||
else if (word == "do" && state.context.indented < state.indented)
|
||||
kwtype = "indent";
|
||||
}
|
||||
}
|
||||
if (curPunc || (style && style != "comment")) state.lastTok = thisTok;
|
||||
if (curPunc == "|") state.varList = !state.varList;
|
||||
|
||||
if (kwtype == "indent" || /[\(\[\{]/.test(curPunc))
|
||||
state.context = { prev: state.context, type: curPunc || style, indented: state.indented };
|
||||
else if ((kwtype == "dedent" || /[\)\]\}]/.test(curPunc)) && state.context.prev)
|
||||
state.context = state.context.prev;
|
||||
|
||||
if (stream.eol())
|
||||
state.continuedLine = (curPunc == "\\" || style == "operator");
|
||||
return style;
|
||||
},
|
||||
|
||||
indent: function (state, textAfter) {
|
||||
if (state.tokenize[state.tokenize.length - 1] != tokenBase) return 0;
|
||||
var firstChar = textAfter && textAfter.charAt(0);
|
||||
var ct = state.context;
|
||||
var closing = ct.type == matching[firstChar] ||
|
||||
ct.type == "keyword" && /^(?:end|until|else|elsif|when|rescue)\b/.test(textAfter);
|
||||
return ct.indented + (closing ? 0 : config.indentUnit) +
|
||||
(state.continuedLine ? config.indentUnit : 0);
|
||||
},
|
||||
|
||||
electricChars: "}de", // enD and rescuE
|
||||
lineComment: "#"
|
||||
};
|
||||
});
|
||||
|
||||
CodeMirror.defineMIME("text/x-ruby", "ruby");
|
||||
|
||||
});
|
||||
@@ -0,0 +1,135 @@
|
||||
//
|
||||
// simple testing interface
|
||||
// written by Einar Lielmanis, einar@jsbeautifier.org
|
||||
//
|
||||
// usage:
|
||||
//
|
||||
// var t = new SanityTest(function (x) { return x; }, 'my function');
|
||||
// t.expect('input', 'output');
|
||||
// t.expect('a', 'a');
|
||||
// output_somewhere(t.results()); // good for <pre>, html safe-ish
|
||||
// alert(t.results_raw()); // html unescaped
|
||||
|
||||
|
||||
function SanityTest (func, name_of_test) {
|
||||
|
||||
var test_func = func || function (x) {
|
||||
return x;
|
||||
};
|
||||
|
||||
var test_name = name_of_test || '';
|
||||
|
||||
var n_failed = 0;
|
||||
var n_succeeded = 0;
|
||||
|
||||
var failures = [];
|
||||
|
||||
this.test_function = function(func, name) {
|
||||
test_func = func;
|
||||
test_name = name || '';
|
||||
};
|
||||
|
||||
this.get_exitcode = function() {
|
||||
return n_succeeded === 0 || n_failed !== 0 ? 1 : 0;
|
||||
};
|
||||
|
||||
this.expect = function(parameters, expected_value) {
|
||||
// multi-parameter calls not supported (I don't need them now).
|
||||
var result = test_func(parameters);
|
||||
// proper array checking is a pain. i'll maybe do it later, compare strings representations instead
|
||||
if ((result === expected_value) || (expected_value instanceof Array && result.join(', ') == expected_value.join(', '))) {
|
||||
n_succeeded += 1;
|
||||
} else {
|
||||
n_failed += 1;
|
||||
failures.push([test_name, parameters, expected_value, result]);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
this.results_raw = function() {
|
||||
var results = '';
|
||||
if (n_failed === 0) {
|
||||
if (n_succeeded === 0) {
|
||||
results = 'No tests run.';
|
||||
} else {
|
||||
results = 'All ' + n_succeeded + ' tests passed.';
|
||||
}
|
||||
} else {
|
||||
for (var i = 0 ; i < failures.length; i++) {
|
||||
var f = failures[i];
|
||||
if (f[0]) {
|
||||
f[0] = f[0] + ' ';
|
||||
}
|
||||
results += '---- ' + f[0] + 'input -------\n' + this.prettyprint(f[1]) + '\n';
|
||||
results += '---- ' + f[0] + 'expected ----\n' + this.prettyprint(f[2]) + '\n';
|
||||
results += '---- ' + f[0] + 'output ------\n' + this.prettyprint(f[3]) + '\n\n';
|
||||
|
||||
}
|
||||
results += n_failed + ' tests failed.\n';
|
||||
}
|
||||
return results;
|
||||
};
|
||||
|
||||
|
||||
this.results = function() {
|
||||
return this.lazy_escape(this.results_raw());
|
||||
};
|
||||
|
||||
|
||||
this.prettyprint = function(something, quote_strings) {
|
||||
var type = typeof something;
|
||||
switch(type.toLowerCase()) {
|
||||
case 'string':
|
||||
if (quote_strings) {
|
||||
return "'" + something.replace("'", "\\'") + "'";
|
||||
} else {
|
||||
return something;
|
||||
}
|
||||
case 'number':
|
||||
return '' + something;
|
||||
case 'boolean':
|
||||
return something ? 'true' : 'false';
|
||||
case 'undefined':
|
||||
return 'undefined';
|
||||
case 'object':
|
||||
if (something instanceof Array) {
|
||||
var x = [];
|
||||
var expected_index = 0;
|
||||
for (var k in something) {
|
||||
if (k == expected_index) {
|
||||
x.push(this.prettyprint(something[k], true));
|
||||
expected_index += 1;
|
||||
} else {
|
||||
x.push('\n' + k + ': ' + this.prettyprint(something[k], true));
|
||||
}
|
||||
}
|
||||
return '[' + x.join(', ') + ']';
|
||||
} else {
|
||||
return 'object: ' + something;
|
||||
}
|
||||
default:
|
||||
return type + ': ' + something;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
this.lazy_escape = function (str) {
|
||||
return str.replace(/</g, '<').replace(/\>/g, '>').replace(/\n/g, '<br />');
|
||||
};
|
||||
|
||||
|
||||
this.log = function () {
|
||||
if (window.console) {
|
||||
if (console.firebug) {
|
||||
console.log.apply(console, Array.prototype.slice.call(arguments));
|
||||
} else {
|
||||
console.log.call(console, Array.prototype.slice.call(arguments));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
if (typeof module !== 'undefined' && module.exports) {
|
||||
module.exports = SanityTest;
|
||||
}
|
||||
@@ -0,0 +1,392 @@
|
||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function (mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function (CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
CodeMirror.defineMode("sql", function (config, parserConfig) {
|
||||
"use strict";
|
||||
|
||||
var client = parserConfig.client || {},
|
||||
atoms = parserConfig.atoms || { "false": true, "true": true, "null": true },
|
||||
builtin = parserConfig.builtin || {},
|
||||
keywords = parserConfig.keywords || {},
|
||||
operatorChars = parserConfig.operatorChars || /^[*+\-%<>!=&|~^]/,
|
||||
support = parserConfig.support || {},
|
||||
hooks = parserConfig.hooks || {},
|
||||
dateSQL = parserConfig.dateSQL || { "date": true, "time": true, "timestamp": true };
|
||||
|
||||
function tokenBase(stream, state) {
|
||||
var ch = stream.next();
|
||||
|
||||
// call hooks from the mime type
|
||||
if (hooks[ch]) {
|
||||
var result = hooks[ch](stream, state);
|
||||
if (result !== false) return result;
|
||||
}
|
||||
|
||||
if (support.hexNumber == true &&
|
||||
((ch == "0" && stream.match(/^[xX][0-9a-fA-F]+/))
|
||||
|| (ch == "x" || ch == "X") && stream.match(/^'[0-9a-fA-F]+'/))) {
|
||||
// hex
|
||||
// ref: http://dev.mysql.com/doc/refman/5.5/en/hexadecimal-literals.html
|
||||
return "number";
|
||||
} else if (support.binaryNumber == true &&
|
||||
(((ch == "b" || ch == "B") && stream.match(/^'[01]+'/))
|
||||
|| (ch == "0" && stream.match(/^b[01]+/)))) {
|
||||
// bitstring
|
||||
// ref: http://dev.mysql.com/doc/refman/5.5/en/bit-field-literals.html
|
||||
return "number";
|
||||
} else if (ch.charCodeAt(0) > 47 && ch.charCodeAt(0) < 58) {
|
||||
// numbers
|
||||
// ref: http://dev.mysql.com/doc/refman/5.5/en/number-literals.html
|
||||
stream.match(/^[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?/);
|
||||
support.decimallessFloat == true && stream.eat('.');
|
||||
return "number";
|
||||
} else if (ch == "?" && (stream.eatSpace() || stream.eol() || stream.eat(";"))) {
|
||||
// placeholders
|
||||
return "variable-3";
|
||||
} else if (ch == "'" || (ch == '"' && support.doubleQuote)) {
|
||||
// strings
|
||||
// ref: http://dev.mysql.com/doc/refman/5.5/en/string-literals.html
|
||||
state.tokenize = tokenLiteral(ch);
|
||||
return state.tokenize(stream, state);
|
||||
} else if ((((support.nCharCast == true && (ch == "n" || ch == "N"))
|
||||
|| (support.charsetCast == true && ch == "_" && stream.match(/[a-z][a-z0-9]*/i)))
|
||||
&& (stream.peek() == "'" || stream.peek() == '"'))) {
|
||||
// charset casting: _utf8'str', N'str', n'str'
|
||||
// ref: http://dev.mysql.com/doc/refman/5.5/en/string-literals.html
|
||||
return "keyword";
|
||||
} else if (/^[\(\),\;\[\]]/.test(ch)) {
|
||||
// no highlightning
|
||||
return null;
|
||||
} else if (support.commentSlashSlash && ch == "/" && stream.eat("/")) {
|
||||
// 1-line comment
|
||||
stream.skipToEnd();
|
||||
return "comment";
|
||||
} else if ((support.commentHash && ch == "#")
|
||||
|| (ch == "-" && stream.eat("-") && (!support.commentSpaceRequired || stream.eat(" ")))) {
|
||||
// 1-line comments
|
||||
// ref: https://kb.askmonty.org/en/comment-syntax/
|
||||
stream.skipToEnd();
|
||||
return "comment";
|
||||
} else if (ch == "/" && stream.eat("*")) {
|
||||
// multi-line comments
|
||||
// ref: https://kb.askmonty.org/en/comment-syntax/
|
||||
state.tokenize = tokenComment;
|
||||
return state.tokenize(stream, state);
|
||||
} else if (ch == ".") {
|
||||
// .1 for 0.1
|
||||
if (support.zerolessFloat == true && stream.match(/^(?:\d+(?:e[+-]?\d+)?)/i)) {
|
||||
return "number";
|
||||
}
|
||||
// .table_name (ODBC)
|
||||
// // ref: http://dev.mysql.com/doc/refman/5.6/en/identifier-qualifiers.html
|
||||
if (support.ODBCdotTable == true && stream.match(/^[a-zA-Z_]+/)) {
|
||||
return "variable-2";
|
||||
}
|
||||
} else if (operatorChars.test(ch)) {
|
||||
// operators
|
||||
stream.eatWhile(operatorChars);
|
||||
return null;
|
||||
} else if (ch == '{' &&
|
||||
(stream.match(/^( )*(d|D|t|T|ts|TS)( )*'[^']*'( )*}/) || stream.match(/^( )*(d|D|t|T|ts|TS)( )*"[^"]*"( )*}/))) {
|
||||
// dates (weird ODBC syntax)
|
||||
// ref: http://dev.mysql.com/doc/refman/5.5/en/date-and-time-literals.html
|
||||
return "number";
|
||||
} else {
|
||||
stream.eatWhile(/^[_\w\d]/);
|
||||
var word = stream.current().toLowerCase();
|
||||
// dates (standard SQL syntax)
|
||||
// ref: http://dev.mysql.com/doc/refman/5.5/en/date-and-time-literals.html
|
||||
if (dateSQL.hasOwnProperty(word) && (stream.match(/^( )+'[^']*'/) || stream.match(/^( )+"[^"]*"/)))
|
||||
return "number";
|
||||
if (atoms.hasOwnProperty(word)) return "atom";
|
||||
if (builtin.hasOwnProperty(word)) return "builtin";
|
||||
if (keywords.hasOwnProperty(word)) return "keyword";
|
||||
if (client.hasOwnProperty(word)) return "string-2";
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// 'string', with char specified in quote escaped by '\'
|
||||
function tokenLiteral(quote) {
|
||||
return function (stream, state) {
|
||||
var escaped = false, ch;
|
||||
while ((ch = stream.next()) != null) {
|
||||
if (ch == quote && !escaped) {
|
||||
state.tokenize = tokenBase;
|
||||
break;
|
||||
}
|
||||
escaped = !escaped && ch == "\\";
|
||||
}
|
||||
return "string";
|
||||
};
|
||||
}
|
||||
function tokenComment(stream, state) {
|
||||
while (true) {
|
||||
if (stream.skipTo("*")) {
|
||||
stream.next();
|
||||
if (stream.eat("/")) {
|
||||
state.tokenize = tokenBase;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
stream.skipToEnd();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return "comment";
|
||||
}
|
||||
|
||||
function pushContext(stream, state, type) {
|
||||
state.context = {
|
||||
prev: state.context,
|
||||
indent: stream.indentation(),
|
||||
col: stream.column(),
|
||||
type: type
|
||||
};
|
||||
}
|
||||
|
||||
function popContext(state) {
|
||||
state.indent = state.context.indent;
|
||||
state.context = state.context.prev;
|
||||
}
|
||||
|
||||
return {
|
||||
startState: function () {
|
||||
return { tokenize: tokenBase, context: null };
|
||||
},
|
||||
|
||||
token: function (stream, state) {
|
||||
if (stream.sol()) {
|
||||
if (state.context && state.context.align == null)
|
||||
state.context.align = false;
|
||||
}
|
||||
if (stream.eatSpace()) return null;
|
||||
|
||||
var style = state.tokenize(stream, state);
|
||||
if (style == "comment") return style;
|
||||
|
||||
if (state.context && state.context.align == null)
|
||||
state.context.align = true;
|
||||
|
||||
var tok = stream.current();
|
||||
if (tok == "(")
|
||||
pushContext(stream, state, ")");
|
||||
else if (tok == "[")
|
||||
pushContext(stream, state, "]");
|
||||
else if (state.context && state.context.type == tok)
|
||||
popContext(state);
|
||||
return style;
|
||||
},
|
||||
|
||||
indent: function (state, textAfter) {
|
||||
var cx = state.context;
|
||||
if (!cx) return 0;
|
||||
var closing = textAfter.charAt(0) == cx.type;
|
||||
if (cx.align) return cx.col + (closing ? 0 : 1);
|
||||
else return cx.indent + (closing ? 0 : config.indentUnit);
|
||||
},
|
||||
|
||||
blockCommentStart: "/*",
|
||||
blockCommentEnd: "*/",
|
||||
lineComment: support.commentSlashSlash ? "//" : support.commentHash ? "#" : null
|
||||
};
|
||||
});
|
||||
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
// `identifier`
|
||||
function hookIdentifier(stream) {
|
||||
// MySQL/MariaDB identifiers
|
||||
// ref: http://dev.mysql.com/doc/refman/5.6/en/identifier-qualifiers.html
|
||||
var ch;
|
||||
while ((ch = stream.next()) != null) {
|
||||
if (ch == "`" && !stream.eat("`")) return "variable-2";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// variable token
|
||||
function hookVar(stream) {
|
||||
// variables
|
||||
// @@prefix.varName @varName
|
||||
// varName can be quoted with ` or ' or "
|
||||
// ref: http://dev.mysql.com/doc/refman/5.5/en/user-variables.html
|
||||
if (stream.eat("@")) {
|
||||
stream.match(/^session\./);
|
||||
stream.match(/^local\./);
|
||||
stream.match(/^global\./);
|
||||
}
|
||||
|
||||
if (stream.eat("'")) {
|
||||
stream.match(/^.*'/);
|
||||
return "variable-2";
|
||||
} else if (stream.eat('"')) {
|
||||
stream.match(/^.*"/);
|
||||
return "variable-2";
|
||||
} else if (stream.eat("`")) {
|
||||
stream.match(/^.*`/);
|
||||
return "variable-2";
|
||||
} else if (stream.match(/^[0-9a-zA-Z$\.\_]+/)) {
|
||||
return "variable-2";
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
// short client keyword token
|
||||
function hookClient(stream) {
|
||||
// \N means NULL
|
||||
// ref: http://dev.mysql.com/doc/refman/5.5/en/null-values.html
|
||||
if (stream.eat("N")) {
|
||||
return "atom";
|
||||
}
|
||||
// \g, etc
|
||||
// ref: http://dev.mysql.com/doc/refman/5.5/en/mysql-commands.html
|
||||
return stream.match(/^[a-zA-Z.#!?]/) ? "variable-2" : null;
|
||||
}
|
||||
|
||||
// these keywords are used by all SQL dialects (however, a mode can still overwrite it)
|
||||
var sqlKeywords = "alter and as asc between by count create delete desc distinct drop from having in insert into is join like not on or order select set table union update values where ";
|
||||
|
||||
// turn a space-separated list into an array
|
||||
function set(str) {
|
||||
var obj = {}, words = str.split(" ");
|
||||
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
|
||||
return obj;
|
||||
}
|
||||
|
||||
// A generic SQL Mode. It's not a standard, it just try to support what is generally supported
|
||||
CodeMirror.defineMIME("text/x-sql", {
|
||||
name: "sql",
|
||||
keywords: set(sqlKeywords + "begin"),
|
||||
builtin: set("bool boolean bit blob enum long longblob longtext medium mediumblob mediumint mediumtext time timestamp tinyblob tinyint tinytext text bigint int int1 int2 int3 int4 int8 integer float float4 float8 double char varbinary varchar varcharacter precision real date datetime year unsigned signed decimal numeric"),
|
||||
atoms: set("false true null unknown"),
|
||||
operatorChars: /^[*+\-%<>!=]/,
|
||||
dateSQL: set("date time timestamp"),
|
||||
support: set("ODBCdotTable doubleQuote binaryNumber hexNumber")
|
||||
});
|
||||
|
||||
CodeMirror.defineMIME("text/x-mssql", {
|
||||
name: "sql",
|
||||
client: set("charset clear connect edit ego exit go help nopager notee nowarning pager print prompt quit rehash source status system tee"),
|
||||
keywords: set(sqlKeywords + "begin trigger proc view index for add constraint key primary foreign collate clustered nonclustered"),
|
||||
builtin: set("bigint numeric bit smallint decimal smallmoney int tinyint money float real char varchar text nchar nvarchar ntext binary varbinary image cursor timestamp hierarchyid uniqueidentifier sql_variant xml table "),
|
||||
atoms: set("false true null unknown"),
|
||||
operatorChars: /^[*+\-%<>!=]/,
|
||||
dateSQL: set("date datetimeoffset datetime2 smalldatetime datetime time"),
|
||||
hooks: {
|
||||
"@": hookVar
|
||||
}
|
||||
});
|
||||
|
||||
CodeMirror.defineMIME("text/x-mysql", {
|
||||
name: "sql",
|
||||
client: set("charset clear connect edit ego exit go help nopager notee nowarning pager print prompt quit rehash source status system tee"),
|
||||
keywords: set(sqlKeywords + "accessible action add after algorithm all analyze asensitive at authors auto_increment autocommit avg avg_row_length before binary binlog both btree cache call cascade cascaded case catalog_name chain change changed character check checkpoint checksum class_origin client_statistics close coalesce code collate collation collations column columns comment commit committed completion concurrent condition connection consistent constraint contains continue contributors convert cross current current_date current_time current_timestamp current_user cursor data database databases day_hour day_microsecond day_minute day_second deallocate dec declare default delay_key_write delayed delimiter des_key_file describe deterministic dev_pop dev_samp deviance diagnostics directory disable discard distinctrow div dual dumpfile each elseif enable enclosed end ends engine engines enum errors escape escaped even event events every execute exists exit explain extended fast fetch field fields first flush for force foreign found_rows full fulltext function general get global grant grants group groupby_concat handler hash help high_priority hosts hour_microsecond hour_minute hour_second if ignore ignore_server_ids import index index_statistics infile inner innodb inout insensitive insert_method install interval invoker isolation iterate key keys kill language last leading leave left level limit linear lines list load local localtime localtimestamp lock logs low_priority master master_heartbeat_period master_ssl_verify_server_cert masters match max max_rows maxvalue message_text middleint migrate min min_rows minute_microsecond minute_second mod mode modifies modify mutex mysql_errno natural next no no_write_to_binlog offline offset one online open optimize option optionally out outer outfile pack_keys parser partition partitions password phase plugin plugins prepare preserve prev primary privileges procedure processlist profile profiles purge query quick range read read_write reads real rebuild recover references regexp relaylog release remove rename reorganize repair repeatable replace require resignal restrict resume return returns revoke right rlike rollback rollup row row_format rtree savepoint schedule schema schema_name schemas second_microsecond security sensitive separator serializable server session share show signal slave slow smallint snapshot soname spatial specific sql sql_big_result sql_buffer_result sql_cache sql_calc_found_rows sql_no_cache sql_small_result sqlexception sqlstate sqlwarning ssl start starting starts status std stddev stddev_pop stddev_samp storage straight_join subclass_origin sum suspend table_name table_statistics tables tablespace temporary terminated to trailing transaction trigger triggers truncate uncommitted undo uninstall unique unlock upgrade usage use use_frm user user_resources user_statistics using utc_date utc_time utc_timestamp value variables varying view views warnings when while with work write xa xor year_month zerofill begin do then else loop repeat"),
|
||||
builtin: set("bool boolean bit blob decimal double float long longblob longtext medium mediumblob mediumint mediumtext time timestamp tinyblob tinyint tinytext text bigint int int1 int2 int3 int4 int8 integer float float4 float8 double char varbinary varchar varcharacter precision date datetime year unsigned signed numeric"),
|
||||
atoms: set("false true null unknown"),
|
||||
operatorChars: /^[*+\-%<>!=&|^]/,
|
||||
dateSQL: set("date time timestamp"),
|
||||
support: set("ODBCdotTable decimallessFloat zerolessFloat binaryNumber hexNumber doubleQuote nCharCast charsetCast commentHash commentSpaceRequired"),
|
||||
hooks: {
|
||||
"@": hookVar,
|
||||
"`": hookIdentifier,
|
||||
"\\": hookClient
|
||||
}
|
||||
});
|
||||
|
||||
CodeMirror.defineMIME("text/x-mariadb", {
|
||||
name: "sql",
|
||||
client: set("charset clear connect edit ego exit go help nopager notee nowarning pager print prompt quit rehash source status system tee"),
|
||||
keywords: set(sqlKeywords + "accessible action add after algorithm all always analyze asensitive at authors auto_increment autocommit avg avg_row_length before binary binlog both btree cache call cascade cascaded case catalog_name chain change changed character check checkpoint checksum class_origin client_statistics close coalesce code collate collation collations column columns comment commit committed completion concurrent condition connection consistent constraint contains continue contributors convert cross current current_date current_time current_timestamp current_user cursor data database databases day_hour day_microsecond day_minute day_second deallocate dec declare default delay_key_write delayed delimiter des_key_file describe deterministic dev_pop dev_samp deviance diagnostics directory disable discard distinctrow div dual dumpfile each elseif enable enclosed end ends engine engines enum errors escape escaped even event events every execute exists exit explain extended fast fetch field fields first flush for force foreign found_rows full fulltext function general generated get global grant grants group groupby_concat handler hard hash help high_priority hosts hour_microsecond hour_minute hour_second if ignore ignore_server_ids import index index_statistics infile inner innodb inout insensitive insert_method install interval invoker isolation iterate key keys kill language last leading leave left level limit linear lines list load local localtime localtimestamp lock logs low_priority master master_heartbeat_period master_ssl_verify_server_cert masters match max max_rows maxvalue message_text middleint migrate min min_rows minute_microsecond minute_second mod mode modifies modify mutex mysql_errno natural next no no_write_to_binlog offline offset one online open optimize option optionally out outer outfile pack_keys parser partition partitions password persistent phase plugin plugins prepare preserve prev primary privileges procedure processlist profile profiles purge query quick range read read_write reads real rebuild recover references regexp relaylog release remove rename reorganize repair repeatable replace require resignal restrict resume return returns revoke right rlike rollback rollup row row_format rtree savepoint schedule schema schema_name schemas second_microsecond security sensitive separator serializable server session share show shutdown signal slave slow smallint snapshot soft soname spatial specific sql sql_big_result sql_buffer_result sql_cache sql_calc_found_rows sql_no_cache sql_small_result sqlexception sqlstate sqlwarning ssl start starting starts status std stddev stddev_pop stddev_samp storage straight_join subclass_origin sum suspend table_name table_statistics tables tablespace temporary terminated to trailing transaction trigger triggers truncate uncommitted undo uninstall unique unlock upgrade usage use use_frm user user_resources user_statistics using utc_date utc_time utc_timestamp value variables varying view views virtual warnings when while with work write xa xor year_month zerofill begin do then else loop repeat"),
|
||||
builtin: set("bool boolean bit blob decimal double float long longblob longtext medium mediumblob mediumint mediumtext time timestamp tinyblob tinyint tinytext text bigint int int1 int2 int3 int4 int8 integer float float4 float8 double char varbinary varchar varcharacter precision date datetime year unsigned signed numeric"),
|
||||
atoms: set("false true null unknown"),
|
||||
operatorChars: /^[*+\-%<>!=&|^]/,
|
||||
dateSQL: set("date time timestamp"),
|
||||
support: set("ODBCdotTable decimallessFloat zerolessFloat binaryNumber hexNumber doubleQuote nCharCast charsetCast commentHash commentSpaceRequired"),
|
||||
hooks: {
|
||||
"@": hookVar,
|
||||
"`": hookIdentifier,
|
||||
"\\": hookClient
|
||||
}
|
||||
});
|
||||
|
||||
// the query language used by Apache Cassandra is called CQL, but this mime type
|
||||
// is called Cassandra to avoid confusion with Contextual Query Language
|
||||
CodeMirror.defineMIME("text/x-cassandra", {
|
||||
name: "sql",
|
||||
client: {},
|
||||
keywords: set("use select from using consistency where limit first reversed first and in insert into values using consistency ttl update set delete truncate begin batch apply create keyspace with columnfamily primary key index on drop alter type add any one quorum all local_quorum each_quorum"),
|
||||
builtin: set("ascii bigint blob boolean counter decimal double float int text timestamp uuid varchar varint"),
|
||||
atoms: set("false true"),
|
||||
operatorChars: /^[<>=]/,
|
||||
dateSQL: {},
|
||||
support: set("commentSlashSlash decimallessFloat"),
|
||||
hooks: {}
|
||||
});
|
||||
|
||||
// this is based on Peter Raganitsch's 'plsql' mode
|
||||
CodeMirror.defineMIME("text/x-plsql", {
|
||||
name: "sql",
|
||||
client: set("appinfo arraysize autocommit autoprint autorecovery autotrace blockterminator break btitle cmdsep colsep compatibility compute concat copycommit copytypecheck define describe echo editfile embedded escape exec execute feedback flagger flush heading headsep instance linesize lno loboffset logsource long longchunksize markup native newpage numformat numwidth pagesize pause pno recsep recsepchar release repfooter repheader serveroutput shiftinout show showmode size spool sqlblanklines sqlcase sqlcode sqlcontinue sqlnumber sqlpluscompatibility sqlprefix sqlprompt sqlterminator suffix tab term termout time timing trimout trimspool ttitle underline verify version wrap"),
|
||||
keywords: set("abort accept access add all alter and any array arraylen as asc assert assign at attributes audit authorization avg base_table begin between binary_integer body boolean by case cast char char_base check close cluster clusters colauth column comment commit compress connect connected constant constraint crash create current currval cursor data_base database date dba deallocate debugoff debugon decimal declare default definition delay delete desc digits dispose distinct do drop else elseif elsif enable end entry escape exception exception_init exchange exclusive exists exit external fast fetch file for force form from function generic goto grant group having identified if immediate in increment index indexes indicator initial initrans insert interface intersect into is key level library like limited local lock log logging long loop master maxextents maxtrans member minextents minus mislabel mode modify multiset new next no noaudit nocompress nologging noparallel not nowait number_base object of off offline on online only open option or order out package parallel partition pctfree pctincrease pctused pls_integer positive positiven pragma primary prior private privileges procedure public raise range raw read rebuild record ref references refresh release rename replace resource restrict return returning returns reverse revoke rollback row rowid rowlabel rownum rows run savepoint schema segment select separate session set share snapshot some space split sql start statement storage subtype successful synonym tabauth table tables tablespace task terminate then to trigger truncate type union unique unlimited unrecoverable unusable update use using validate value values variable view views when whenever where while with work"),
|
||||
builtin: set("abs acos add_months ascii asin atan atan2 average bfile bfilename bigserial bit blob ceil character chartorowid chr clob concat convert cos cosh count dec decode deref dual dump dup_val_on_index empty error exp false float floor found glb greatest hextoraw initcap instr instrb int integer isopen last_day least lenght lenghtb ln lower lpad ltrim lub make_ref max min mlslabel mod months_between natural naturaln nchar nclob new_time next_day nextval nls_charset_decl_len nls_charset_id nls_charset_name nls_initcap nls_lower nls_sort nls_upper nlssort no_data_found notfound null number numeric nvarchar2 nvl others power rawtohex real reftohex round rowcount rowidtochar rowtype rpad rtrim serial sign signtype sin sinh smallint soundex sqlcode sqlerrm sqrt stddev string substr substrb sum sysdate tan tanh to_char text to_date to_label to_multi_byte to_number to_single_byte translate true trunc uid unlogged upper user userenv varchar varchar2 variance varying vsize xml"),
|
||||
operatorChars: /^[*+\-%<>!=~]/,
|
||||
dateSQL: set("date time timestamp"),
|
||||
support: set("doubleQuote nCharCast zerolessFloat binaryNumber hexNumber")
|
||||
});
|
||||
|
||||
// Created to support specific hive keywords
|
||||
CodeMirror.defineMIME("text/x-hive", {
|
||||
name: "sql",
|
||||
keywords: set("select alter $elem$ $key$ $value$ add after all analyze and archive as asc before between binary both bucket buckets by cascade case cast change cluster clustered clusterstatus collection column columns comment compute concatenate continue create cross cursor data database databases dbproperties deferred delete delimited desc describe directory disable distinct distribute drop else enable end escaped exclusive exists explain export extended external false fetch fields fileformat first format formatted from full function functions grant group having hold_ddltime idxproperties if import in index indexes inpath inputdriver inputformat insert intersect into is items join keys lateral left like limit lines load local location lock locks mapjoin materialized minus msck no_drop nocompress not of offline on option or order out outer outputdriver outputformat overwrite partition partitioned partitions percent plus preserve procedure purge range rcfile read readonly reads rebuild recordreader recordwriter recover reduce regexp rename repair replace restrict revoke right rlike row schema schemas semi sequencefile serde serdeproperties set shared show show_database sort sorted ssl statistics stored streamtable table tables tablesample tblproperties temporary terminated textfile then tmp to touch transform trigger true unarchive undo union uniquejoin unlock update use using utc utc_tmestamp view when where while with"),
|
||||
builtin: set("bool boolean long timestamp tinyint smallint bigint int float double date datetime unsigned string array struct map uniontype"),
|
||||
atoms: set("false true null unknown"),
|
||||
operatorChars: /^[*+\-%<>!=]/,
|
||||
dateSQL: set("date timestamp"),
|
||||
support: set("ODBCdotTable doubleQuote binaryNumber hexNumber")
|
||||
});
|
||||
} ());
|
||||
|
||||
});
|
||||
|
||||
/*
|
||||
How Properties of Mime Types are used by SQL Mode
|
||||
=================================================
|
||||
|
||||
keywords:
|
||||
A list of keywords you want to be highlighted.
|
||||
functions:
|
||||
A list of function names you want to be highlighted.
|
||||
builtin:
|
||||
A list of builtin types you want to be highlighted (if you want types to be of class "builtin" instead of "keyword").
|
||||
operatorChars:
|
||||
All characters that must be handled as operators.
|
||||
client:
|
||||
Commands parsed and executed by the client (not the server).
|
||||
support:
|
||||
A list of supported syntaxes which are not common, but are supported by more than 1 DBMS.
|
||||
* ODBCdotTable: .tableName
|
||||
* zerolessFloat: .1
|
||||
* doubleQuote
|
||||
* nCharCast: N'string'
|
||||
* charsetCast: _utf8'string'
|
||||
* commentHash: use # char for comments
|
||||
* commentSlashSlash: use // for comments
|
||||
* commentSpaceRequired: require a space after -- for comments
|
||||
atoms:
|
||||
Keywords that must be highlighted as atoms,. Some DBMS's support more atoms than others:
|
||||
UNKNOWN, INFINITY, UNDERFLOW, NaN...
|
||||
dateSQL:
|
||||
Used for date/time SQL standard syntax, because not all DBMS's support same temporal types.
|
||||
*/
|
||||
@@ -0,0 +1,73 @@
|
||||
/*global unescape */
|
||||
/*jshint curly: false, scripturl: true */
|
||||
//
|
||||
// trivial bookmarklet/escaped script detector for the javascript beautifier
|
||||
// written by Einar Lielmanis <einar@jsbeautifier.org>
|
||||
//
|
||||
// usage:
|
||||
//
|
||||
// if (Urlencoded.detect(some_string)) {
|
||||
// var unpacked = Urlencoded.unpack(some_string);
|
||||
// }
|
||||
//
|
||||
//
|
||||
|
||||
var isNode = (typeof module !== 'undefined' && module.exports);
|
||||
if (isNode) {
|
||||
var SanityTest = require(__dirname + '/../../test/sanitytest');
|
||||
}
|
||||
|
||||
var Urlencoded = {
|
||||
detect: function (str) {
|
||||
// the fact that script doesn't contain any space, but has %20 instead
|
||||
// should be sufficient check for now.
|
||||
if (str.indexOf(' ') == -1) {
|
||||
if (str.indexOf('%2') != -1) return true;
|
||||
if (str.replace(/[^%]+/g, '').length > 3) return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
unpack: function (str) {
|
||||
if (Urlencoded.detect(str)) {
|
||||
if (str.indexOf('%2B') != -1 || str.indexOf('%2b') != -1) {
|
||||
// "+" escaped as "%2B"
|
||||
return unescape(str.replace(/\+/g, '%20'));
|
||||
} else {
|
||||
return unescape(str);
|
||||
}
|
||||
}
|
||||
return str;
|
||||
},
|
||||
|
||||
|
||||
|
||||
run_tests: function (sanity_test) {
|
||||
var t = sanity_test || new SanityTest();
|
||||
t.test_function(Urlencoded.detect, "Urlencoded.detect");
|
||||
t.expect('', false);
|
||||
t.expect('var a = b', false);
|
||||
t.expect('var%20a+=+b', true);
|
||||
t.expect('var%20a=b', true);
|
||||
t.expect('var%20%21%22', true);
|
||||
t.expect('javascript:(function(){var%20whatever={init:function(){alert(%22a%22+%22b%22)}};whatever.init()})();', true);
|
||||
t.test_function(Urlencoded.unpack, 'Urlencoded.unpack');
|
||||
|
||||
t.expect('javascript:(function(){var%20whatever={init:function(){alert(%22a%22+%22b%22)}};whatever.init()})();',
|
||||
'javascript:(function(){var whatever={init:function(){alert("a"+"b")}};whatever.init()})();'
|
||||
);
|
||||
t.expect('', '');
|
||||
t.expect('abcd', 'abcd');
|
||||
t.expect('var a = b', 'var a = b');
|
||||
t.expect('var%20a=b', 'var a=b');
|
||||
t.expect('var%20a=b+1', 'var a=b+1');
|
||||
t.expect('var%20a=b%2b1', 'var a=b+1');
|
||||
return t;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
if (isNode) {
|
||||
module.exports = Urlencoded;
|
||||
}
|
||||
@@ -0,0 +1,384 @@
|
||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
CodeMirror.defineMode("xml", function(config, parserConfig) {
|
||||
var indentUnit = config.indentUnit;
|
||||
var multilineTagIndentFactor = parserConfig.multilineTagIndentFactor || 1;
|
||||
var multilineTagIndentPastTag = parserConfig.multilineTagIndentPastTag;
|
||||
if (multilineTagIndentPastTag == null) multilineTagIndentPastTag = true;
|
||||
|
||||
var Kludges = parserConfig.htmlMode ? {
|
||||
autoSelfClosers: {'area': true, 'base': true, 'br': true, 'col': true, 'command': true,
|
||||
'embed': true, 'frame': true, 'hr': true, 'img': true, 'input': true,
|
||||
'keygen': true, 'link': true, 'meta': true, 'param': true, 'source': true,
|
||||
'track': true, 'wbr': true, 'menuitem': true},
|
||||
implicitlyClosed: {'dd': true, 'li': true, 'optgroup': true, 'option': true, 'p': true,
|
||||
'rp': true, 'rt': true, 'tbody': true, 'td': true, 'tfoot': true,
|
||||
'th': true, 'tr': true},
|
||||
contextGrabbers: {
|
||||
'dd': {'dd': true, 'dt': true},
|
||||
'dt': {'dd': true, 'dt': true},
|
||||
'li': {'li': true},
|
||||
'option': {'option': true, 'optgroup': true},
|
||||
'optgroup': {'optgroup': true},
|
||||
'p': {'address': true, 'article': true, 'aside': true, 'blockquote': true, 'dir': true,
|
||||
'div': true, 'dl': true, 'fieldset': true, 'footer': true, 'form': true,
|
||||
'h1': true, 'h2': true, 'h3': true, 'h4': true, 'h5': true, 'h6': true,
|
||||
'header': true, 'hgroup': true, 'hr': true, 'menu': true, 'nav': true, 'ol': true,
|
||||
'p': true, 'pre': true, 'section': true, 'table': true, 'ul': true},
|
||||
'rp': {'rp': true, 'rt': true},
|
||||
'rt': {'rp': true, 'rt': true},
|
||||
'tbody': {'tbody': true, 'tfoot': true},
|
||||
'td': {'td': true, 'th': true},
|
||||
'tfoot': {'tbody': true},
|
||||
'th': {'td': true, 'th': true},
|
||||
'thead': {'tbody': true, 'tfoot': true},
|
||||
'tr': {'tr': true}
|
||||
},
|
||||
doNotIndent: {"pre": true},
|
||||
allowUnquoted: true,
|
||||
allowMissing: true,
|
||||
caseFold: true
|
||||
} : {
|
||||
autoSelfClosers: {},
|
||||
implicitlyClosed: {},
|
||||
contextGrabbers: {},
|
||||
doNotIndent: {},
|
||||
allowUnquoted: false,
|
||||
allowMissing: false,
|
||||
caseFold: false
|
||||
};
|
||||
var alignCDATA = parserConfig.alignCDATA;
|
||||
|
||||
// Return variables for tokenizers
|
||||
var type, setStyle;
|
||||
|
||||
function inText(stream, state) {
|
||||
function chain(parser) {
|
||||
state.tokenize = parser;
|
||||
return parser(stream, state);
|
||||
}
|
||||
|
||||
var ch = stream.next();
|
||||
if (ch == "<") {
|
||||
if (stream.eat("!")) {
|
||||
if (stream.eat("[")) {
|
||||
if (stream.match("CDATA[")) return chain(inBlock("atom", "]]>"));
|
||||
else return null;
|
||||
} else if (stream.match("--")) {
|
||||
return chain(inBlock("comment", "-->"));
|
||||
} else if (stream.match("DOCTYPE", true, true)) {
|
||||
stream.eatWhile(/[\w\._\-]/);
|
||||
return chain(doctype(1));
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} else if (stream.eat("?")) {
|
||||
stream.eatWhile(/[\w\._\-]/);
|
||||
state.tokenize = inBlock("meta", "?>");
|
||||
return "meta";
|
||||
} else {
|
||||
type = stream.eat("/") ? "closeTag" : "openTag";
|
||||
state.tokenize = inTag;
|
||||
return "tag bracket";
|
||||
}
|
||||
} else if (ch == "&") {
|
||||
var ok;
|
||||
if (stream.eat("#")) {
|
||||
if (stream.eat("x")) {
|
||||
ok = stream.eatWhile(/[a-fA-F\d]/) && stream.eat(";");
|
||||
} else {
|
||||
ok = stream.eatWhile(/[\d]/) && stream.eat(";");
|
||||
}
|
||||
} else {
|
||||
ok = stream.eatWhile(/[\w\.\-:]/) && stream.eat(";");
|
||||
}
|
||||
return ok ? "atom" : "error";
|
||||
} else {
|
||||
stream.eatWhile(/[^&<]/);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function inTag(stream, state) {
|
||||
var ch = stream.next();
|
||||
if (ch == ">" || (ch == "/" && stream.eat(">"))) {
|
||||
state.tokenize = inText;
|
||||
type = ch == ">" ? "endTag" : "selfcloseTag";
|
||||
return "tag bracket";
|
||||
} else if (ch == "=") {
|
||||
type = "equals";
|
||||
return null;
|
||||
} else if (ch == "<") {
|
||||
state.tokenize = inText;
|
||||
state.state = baseState;
|
||||
state.tagName = state.tagStart = null;
|
||||
var next = state.tokenize(stream, state);
|
||||
return next ? next + " tag error" : "tag error";
|
||||
} else if (/[\'\"]/.test(ch)) {
|
||||
state.tokenize = inAttribute(ch);
|
||||
state.stringStartCol = stream.column();
|
||||
return state.tokenize(stream, state);
|
||||
} else {
|
||||
stream.match(/^[^\s\u00a0=<>\"\']*[^\s\u00a0=<>\"\'\/]/);
|
||||
return "word";
|
||||
}
|
||||
}
|
||||
|
||||
function inAttribute(quote) {
|
||||
var closure = function(stream, state) {
|
||||
while (!stream.eol()) {
|
||||
if (stream.next() == quote) {
|
||||
state.tokenize = inTag;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return "string";
|
||||
};
|
||||
closure.isInAttribute = true;
|
||||
return closure;
|
||||
}
|
||||
|
||||
function inBlock(style, terminator) {
|
||||
return function(stream, state) {
|
||||
while (!stream.eol()) {
|
||||
if (stream.match(terminator)) {
|
||||
state.tokenize = inText;
|
||||
break;
|
||||
}
|
||||
stream.next();
|
||||
}
|
||||
return style;
|
||||
};
|
||||
}
|
||||
function doctype(depth) {
|
||||
return function(stream, state) {
|
||||
var ch;
|
||||
while ((ch = stream.next()) != null) {
|
||||
if (ch == "<") {
|
||||
state.tokenize = doctype(depth + 1);
|
||||
return state.tokenize(stream, state);
|
||||
} else if (ch == ">") {
|
||||
if (depth == 1) {
|
||||
state.tokenize = inText;
|
||||
break;
|
||||
} else {
|
||||
state.tokenize = doctype(depth - 1);
|
||||
return state.tokenize(stream, state);
|
||||
}
|
||||
}
|
||||
}
|
||||
return "meta";
|
||||
};
|
||||
}
|
||||
|
||||
function Context(state, tagName, startOfLine) {
|
||||
this.prev = state.context;
|
||||
this.tagName = tagName;
|
||||
this.indent = state.indented;
|
||||
this.startOfLine = startOfLine;
|
||||
if (Kludges.doNotIndent.hasOwnProperty(tagName) || (state.context && state.context.noIndent))
|
||||
this.noIndent = true;
|
||||
}
|
||||
function popContext(state) {
|
||||
if (state.context) state.context = state.context.prev;
|
||||
}
|
||||
function maybePopContext(state, nextTagName) {
|
||||
var parentTagName;
|
||||
while (true) {
|
||||
if (!state.context) {
|
||||
return;
|
||||
}
|
||||
parentTagName = state.context.tagName;
|
||||
if (!Kludges.contextGrabbers.hasOwnProperty(parentTagName) ||
|
||||
!Kludges.contextGrabbers[parentTagName].hasOwnProperty(nextTagName)) {
|
||||
return;
|
||||
}
|
||||
popContext(state);
|
||||
}
|
||||
}
|
||||
|
||||
function baseState(type, stream, state) {
|
||||
if (type == "openTag") {
|
||||
state.tagStart = stream.column();
|
||||
return tagNameState;
|
||||
} else if (type == "closeTag") {
|
||||
return closeTagNameState;
|
||||
} else {
|
||||
return baseState;
|
||||
}
|
||||
}
|
||||
function tagNameState(type, stream, state) {
|
||||
if (type == "word") {
|
||||
state.tagName = stream.current();
|
||||
setStyle = "tag";
|
||||
return attrState;
|
||||
} else {
|
||||
setStyle = "error";
|
||||
return tagNameState;
|
||||
}
|
||||
}
|
||||
function closeTagNameState(type, stream, state) {
|
||||
if (type == "word") {
|
||||
var tagName = stream.current();
|
||||
if (state.context && state.context.tagName != tagName &&
|
||||
Kludges.implicitlyClosed.hasOwnProperty(state.context.tagName))
|
||||
popContext(state);
|
||||
if (state.context && state.context.tagName == tagName) {
|
||||
setStyle = "tag";
|
||||
return closeState;
|
||||
} else {
|
||||
setStyle = "tag error";
|
||||
return closeStateErr;
|
||||
}
|
||||
} else {
|
||||
setStyle = "error";
|
||||
return closeStateErr;
|
||||
}
|
||||
}
|
||||
|
||||
function closeState(type, _stream, state) {
|
||||
if (type != "endTag") {
|
||||
setStyle = "error";
|
||||
return closeState;
|
||||
}
|
||||
popContext(state);
|
||||
return baseState;
|
||||
}
|
||||
function closeStateErr(type, stream, state) {
|
||||
setStyle = "error";
|
||||
return closeState(type, stream, state);
|
||||
}
|
||||
|
||||
function attrState(type, _stream, state) {
|
||||
if (type == "word") {
|
||||
setStyle = "attribute";
|
||||
return attrEqState;
|
||||
} else if (type == "endTag" || type == "selfcloseTag") {
|
||||
var tagName = state.tagName, tagStart = state.tagStart;
|
||||
state.tagName = state.tagStart = null;
|
||||
if (type == "selfcloseTag" ||
|
||||
Kludges.autoSelfClosers.hasOwnProperty(tagName)) {
|
||||
maybePopContext(state, tagName);
|
||||
} else {
|
||||
maybePopContext(state, tagName);
|
||||
state.context = new Context(state, tagName, tagStart == state.indented);
|
||||
}
|
||||
return baseState;
|
||||
}
|
||||
setStyle = "error";
|
||||
return attrState;
|
||||
}
|
||||
function attrEqState(type, stream, state) {
|
||||
if (type == "equals") return attrValueState;
|
||||
if (!Kludges.allowMissing) setStyle = "error";
|
||||
return attrState(type, stream, state);
|
||||
}
|
||||
function attrValueState(type, stream, state) {
|
||||
if (type == "string") return attrContinuedState;
|
||||
if (type == "word" && Kludges.allowUnquoted) {setStyle = "string"; return attrState;}
|
||||
setStyle = "error";
|
||||
return attrState(type, stream, state);
|
||||
}
|
||||
function attrContinuedState(type, stream, state) {
|
||||
if (type == "string") return attrContinuedState;
|
||||
return attrState(type, stream, state);
|
||||
}
|
||||
|
||||
return {
|
||||
startState: function() {
|
||||
return {tokenize: inText,
|
||||
state: baseState,
|
||||
indented: 0,
|
||||
tagName: null, tagStart: null,
|
||||
context: null};
|
||||
},
|
||||
|
||||
token: function(stream, state) {
|
||||
if (!state.tagName && stream.sol())
|
||||
state.indented = stream.indentation();
|
||||
|
||||
if (stream.eatSpace()) return null;
|
||||
type = null;
|
||||
var style = state.tokenize(stream, state);
|
||||
if ((style || type) && style != "comment") {
|
||||
setStyle = null;
|
||||
state.state = state.state(type || style, stream, state);
|
||||
if (setStyle)
|
||||
style = setStyle == "error" ? style + " error" : setStyle;
|
||||
}
|
||||
return style;
|
||||
},
|
||||
|
||||
indent: function(state, textAfter, fullLine) {
|
||||
var context = state.context;
|
||||
// Indent multi-line strings (e.g. css).
|
||||
if (state.tokenize.isInAttribute) {
|
||||
if (state.tagStart == state.indented)
|
||||
return state.stringStartCol + 1;
|
||||
else
|
||||
return state.indented + indentUnit;
|
||||
}
|
||||
if (context && context.noIndent) return CodeMirror.Pass;
|
||||
if (state.tokenize != inTag && state.tokenize != inText)
|
||||
return fullLine ? fullLine.match(/^(\s*)/)[0].length : 0;
|
||||
// Indent the starts of attribute names.
|
||||
if (state.tagName) {
|
||||
if (multilineTagIndentPastTag)
|
||||
return state.tagStart + state.tagName.length + 2;
|
||||
else
|
||||
return state.tagStart + indentUnit * multilineTagIndentFactor;
|
||||
}
|
||||
if (alignCDATA && /<!\[CDATA\[/.test(textAfter)) return 0;
|
||||
var tagAfter = textAfter && /^<(\/)?([\w_:\.-]*)/.exec(textAfter);
|
||||
if (tagAfter && tagAfter[1]) { // Closing tag spotted
|
||||
while (context) {
|
||||
if (context.tagName == tagAfter[2]) {
|
||||
context = context.prev;
|
||||
break;
|
||||
} else if (Kludges.implicitlyClosed.hasOwnProperty(context.tagName)) {
|
||||
context = context.prev;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (tagAfter) { // Opening tag spotted
|
||||
while (context) {
|
||||
var grabbers = Kludges.contextGrabbers[context.tagName];
|
||||
if (grabbers && grabbers.hasOwnProperty(tagAfter[2]))
|
||||
context = context.prev;
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (context && !context.startOfLine)
|
||||
context = context.prev;
|
||||
if (context) return context.indent + indentUnit;
|
||||
else return 0;
|
||||
},
|
||||
|
||||
electricInput: /<\/[\s\w:]+>$/,
|
||||
blockCommentStart: "<!--",
|
||||
blockCommentEnd: "-->",
|
||||
|
||||
configuration: parserConfig.htmlMode ? "html" : "xml",
|
||||
helperType: parserConfig.htmlMode ? "html" : "xml"
|
||||
};
|
||||
});
|
||||
|
||||
CodeMirror.defineMIME("text/xml", "xml");
|
||||
CodeMirror.defineMIME("application/xml", "xml");
|
||||
if (!CodeMirror.mimeModes.hasOwnProperty("text/html"))
|
||||
CodeMirror.defineMIME("text/html", {name: "xml", htmlMode: true});
|
||||
|
||||
});
|
||||
@@ -0,0 +1,424 @@
|
||||
|
||||
function updateBorders(color) {
|
||||
var hexColor = "transparent";
|
||||
if(color) {
|
||||
hexColor = color.toHexString();
|
||||
}
|
||||
$("#docs-content").css("border-color", hexColor);
|
||||
}
|
||||
|
||||
$(function() {
|
||||
|
||||
$("#full").spectrum({
|
||||
flat:true,
|
||||
allowEmpty:true,
|
||||
color: "#ECC",
|
||||
showInput: true,
|
||||
containerClassName: "full-spectrum",
|
||||
showInitial: true,
|
||||
showPalette: true,
|
||||
showSelectionPalette: true,
|
||||
showAlpha: true,
|
||||
maxPaletteSize: 10,
|
||||
preferredFormat: "hex",
|
||||
localStorageKey: "spectrum.demo",
|
||||
move: function (color) {
|
||||
updateBorders(color);
|
||||
},
|
||||
show: function () {
|
||||
|
||||
},
|
||||
beforeShow: function () {
|
||||
|
||||
},
|
||||
hide: function (color) {
|
||||
updateBorders(color);
|
||||
},
|
||||
|
||||
palette: [
|
||||
["rgb(0, 0, 0)", "rgb(67, 67, 67)", "rgb(102, 102, 102)", /*"rgb(153, 153, 153)","rgb(183, 183, 183)",*/
|
||||
"rgb(204, 204, 204)", "rgb(217, 217, 217)", /*"rgb(239, 239, 239)", "rgb(243, 243, 243)",*/ "rgb(255, 255, 255)"],
|
||||
["rgb(152, 0, 0)", "rgb(255, 0, 0)", "rgb(255, 153, 0)", "rgb(255, 255, 0)", "rgb(0, 255, 0)",
|
||||
"rgb(0, 255, 255)", "rgb(74, 134, 232)", "rgb(0, 0, 255)", "rgb(153, 0, 255)", "rgb(255, 0, 255)"],
|
||||
["rgb(230, 184, 175)", "rgb(244, 204, 204)", "rgb(252, 229, 205)", "rgb(255, 242, 204)", "rgb(217, 234, 211)",
|
||||
"rgb(208, 224, 227)", "rgb(201, 218, 248)", "rgb(207, 226, 243)", "rgb(217, 210, 233)", "rgb(234, 209, 220)",
|
||||
"rgb(221, 126, 107)", "rgb(234, 153, 153)", "rgb(249, 203, 156)", "rgb(255, 229, 153)", "rgb(182, 215, 168)",
|
||||
"rgb(162, 196, 201)", "rgb(164, 194, 244)", "rgb(159, 197, 232)", "rgb(180, 167, 214)", "rgb(213, 166, 189)",
|
||||
"rgb(204, 65, 37)", "rgb(224, 102, 102)", "rgb(246, 178, 107)", "rgb(255, 217, 102)", "rgb(147, 196, 125)",
|
||||
"rgb(118, 165, 175)", "rgb(109, 158, 235)", "rgb(111, 168, 220)", "rgb(142, 124, 195)", "rgb(194, 123, 160)",
|
||||
"rgb(166, 28, 0)", "rgb(204, 0, 0)", "rgb(230, 145, 56)", "rgb(241, 194, 50)", "rgb(106, 168, 79)",
|
||||
"rgb(69, 129, 142)", "rgb(60, 120, 216)", "rgb(61, 133, 198)", "rgb(103, 78, 167)", "rgb(166, 77, 121)",
|
||||
/*"rgb(133, 32, 12)", "rgb(153, 0, 0)", "rgb(180, 95, 6)", "rgb(191, 144, 0)", "rgb(56, 118, 29)",
|
||||
"rgb(19, 79, 92)", "rgb(17, 85, 204)", "rgb(11, 83, 148)", "rgb(53, 28, 117)", "rgb(116, 27, 71)",*/
|
||||
"rgb(91, 15, 0)", "rgb(102, 0, 0)", "rgb(120, 63, 4)", "rgb(127, 96, 0)", "rgb(39, 78, 19)",
|
||||
"rgb(12, 52, 61)", "rgb(28, 69, 135)", "rgb(7, 55, 99)", "rgb(32, 18, 77)", "rgb(76, 17, 48)"]
|
||||
]
|
||||
});
|
||||
|
||||
$("#hideButtons").spectrum({
|
||||
showButtons: false,
|
||||
change: updateBorders
|
||||
});
|
||||
|
||||
|
||||
var isDisabled = true;
|
||||
$("#toggle-disabled").click(function() {
|
||||
if (isDisabled) {
|
||||
$("#disabled").spectrum("enable");
|
||||
}
|
||||
else {
|
||||
$("#disabled").spectrum("disable");
|
||||
}
|
||||
isDisabled = !isDisabled;
|
||||
return false;
|
||||
});
|
||||
|
||||
$("input:disabled").spectrum({
|
||||
|
||||
});
|
||||
$("#disabled").spectrum({
|
||||
disabled: true
|
||||
});
|
||||
|
||||
$("#pick1").spectrum({
|
||||
flat: true,
|
||||
change: function(color) {
|
||||
var hsv = color.toHsv();
|
||||
var rgb = color.toRgbString();
|
||||
var hex = color.toHexString();
|
||||
//console.log("callback",color.toHslString(), color.toHsl().h, color.toHsl().s, color.toHsl().l)
|
||||
$("#docs-content").css({
|
||||
'background-color': color.toRgbString()
|
||||
}).toggleClass("dark", hsv.v < .5);
|
||||
$("#switch-current-rgb").text(rgb);
|
||||
$("#switch-current-hex").text(hex);
|
||||
},
|
||||
show: function() {
|
||||
|
||||
},
|
||||
hide: function() {
|
||||
|
||||
},
|
||||
showInput: true,
|
||||
showPalette: true,
|
||||
palette: ['white', '#306', '#c5c88d', '#ac5c5c', '#344660']
|
||||
});
|
||||
|
||||
$("#collapsed").spectrum({
|
||||
color: "#dd3333",
|
||||
change: updateBorders,
|
||||
show: function() {
|
||||
|
||||
},
|
||||
hide: function() {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
$("#flat").spectrum({
|
||||
flat: true,
|
||||
showInput: true,
|
||||
move: updateBorders
|
||||
});
|
||||
|
||||
$("#flatClearable").spectrum({
|
||||
flat: true,
|
||||
move: updateBorders,
|
||||
change: updateBorders,
|
||||
allowEmpty:true,
|
||||
showInput: true
|
||||
});
|
||||
|
||||
$("#showInput").spectrum({
|
||||
color: "#dd33dd",
|
||||
showInput: true,
|
||||
change: updateBorders,
|
||||
show: function() {
|
||||
|
||||
},
|
||||
hide: function() {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
$("#showAlpha").spectrum({
|
||||
color: "rgba(255, 128, 0, .5)",
|
||||
showAlpha: true,
|
||||
change: updateBorders
|
||||
});
|
||||
|
||||
$("#showAlphaWithInput").spectrum({
|
||||
color: "rgba(255, 128, 0, .5)",
|
||||
showAlpha: true,
|
||||
showInput: true,
|
||||
showPalette: true,
|
||||
palette: [
|
||||
["rgba(255, 128, 0, .9)", "rgba(255, 128, 0, .5)"],
|
||||
["red", "green", "blue"],
|
||||
["hsla(25, 50, 75, .5)", "rgba(100, .5, .5, .8)"]
|
||||
],
|
||||
change: updateBorders
|
||||
});
|
||||
|
||||
$("#showAlphaWithInputAndEmpty").spectrum({
|
||||
color: "rgba(255, 128, 0, .5)",
|
||||
allowEmpty:true,
|
||||
showAlpha: true,
|
||||
showInput: true,
|
||||
showPalette: true,
|
||||
palette: [
|
||||
["rgba(255, 128, 0, .9)", "rgba(255, 128, 0, .5)"],
|
||||
["red", "green", "blue"],
|
||||
["hsla(25, 50, 75, .5)", "rgba(100, .5, .5, .8)"]
|
||||
],
|
||||
change: updateBorders
|
||||
});
|
||||
|
||||
$("#showInputWithClear").spectrum({
|
||||
allowEmpty:true,
|
||||
color: "",
|
||||
showInput: true,
|
||||
change: updateBorders,
|
||||
show: function() {
|
||||
|
||||
},
|
||||
hide: function() {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
$("#openWithLink").spectrum({
|
||||
color: "#dd3333",
|
||||
change: updateBorders,
|
||||
show: function() {
|
||||
|
||||
},
|
||||
hide: function() {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
$("#className").spectrum({
|
||||
className: 'awesome'
|
||||
});
|
||||
|
||||
$("#replacerClassName").spectrum({
|
||||
replacerClassName: 'awesome'
|
||||
});
|
||||
|
||||
$("#containerClassName").spectrum({
|
||||
containerClassName: 'awesome'
|
||||
});
|
||||
|
||||
$("#showPalette").spectrum({
|
||||
showPalette: true,
|
||||
palette: [
|
||||
['black', 'white', 'blanchedalmond'],
|
||||
['rgb(255, 128, 0);', 'hsv 100 70 50', 'lightyellow']
|
||||
],
|
||||
change: updateBorders
|
||||
});
|
||||
|
||||
var textPalette = ["rgb(255, 255, 255)", "rgb(204, 204, 204)", "rgb(192, 192, 192)", "rgb(153, 153, 153)", "rgb(102, 102, 102)", "rgb(51, 51, 51)", "rgb(0, 0, 0)", "rgb(255, 204, 204)", "rgb(255, 102, 102)", "rgb(255, 0, 0)", "rgb(204, 0, 0)", "rgb(153, 0, 0)", "rgb(102, 0, 0)", "rgb(51, 0, 0)", "rgb(255, 204, 153)", "rgb(255, 153, 102)", "rgb(255, 153, 0)", "rgb(255, 102, 0)", "rgb(204, 102, 0)", "rgb(153, 51, 0)", "rgb(102, 51, 0)", "rgb(255, 255, 153)", "rgb(255, 255, 102)", "rgb(255, 204, 102)", "rgb(255, 204, 51)", "rgb(204, 153, 51)", "rgb(153, 102, 51)", "rgb(102, 51, 51)", "rgb(255, 255, 204)", "rgb(255, 255, 51)", "rgb(255, 255, 0)", "rgb(255, 204, 0)", "rgb(153, 153, 0)", "rgb(102, 102, 0)", "rgb(51, 51, 0)", "rgb(153, 255, 153)", "rgb(102, 255, 153)", "rgb(51, 255, 51)", "rgb(51, 204, 0)", "rgb(0, 153, 0)", "rgb(0, 102, 0)", "rgb(0, 51, 0)", "rgb(153, 255, 255)", "rgb(51, 255, 255)", "rgb(102, 204, 204)", "rgb(0, 204, 204)", "rgb(51, 153, 153)", "rgb(51, 102, 102)", "rgb(0, 51, 51)", "rgb(204, 255, 255)", "rgb(102, 255, 255)", "rgb(51, 204, 255)", "rgb(51, 102, 255)", "rgb(51, 51, 255)", "rgb(0, 0, 153)", "rgb(0, 0, 102)", "rgb(204, 204, 255)", "rgb(153, 153, 255)", "rgb(102, 102, 204)", "rgb(102, 51, 255)", "rgb(102, 0, 204)", "rgb(51, 51, 153)", "rgb(51, 0, 153)", "rgb(255, 204, 255)", "rgb(255, 153, 255)", "rgb(204, 102, 204)", "rgb(204, 51, 204)", "rgb(153, 51, 153)", "rgb(102, 51, 102)", "rgb(51, 0, 51)"];
|
||||
|
||||
$("#showPaletteOnly").spectrum({
|
||||
color: 'blanchedalmond',
|
||||
showPaletteOnly: true,
|
||||
showPalette:true,
|
||||
palette: [
|
||||
['black', 'white', 'blanchedalmond',
|
||||
'rgb(255, 128, 0);', 'hsv 100 70 50'],
|
||||
['red', 'yellow', 'green', 'blue', 'violet']
|
||||
]
|
||||
});
|
||||
|
||||
$("#clickoutFiresChange").spectrum({
|
||||
clickoutFiresChange: true,
|
||||
change: updateBorders
|
||||
});
|
||||
|
||||
$("#clickoutDoesntFireChange").spectrum({
|
||||
change: updateBorders
|
||||
});
|
||||
|
||||
$("#showInitial").spectrum({
|
||||
showInitial: true
|
||||
});
|
||||
|
||||
$("#showInputAndInitial").spectrum({
|
||||
showInitial: true,
|
||||
showInput: true
|
||||
});
|
||||
|
||||
$("#showInputInitialClear").spectrum({
|
||||
allowEmpty:true,
|
||||
showInitial: true,
|
||||
showInput: true
|
||||
});
|
||||
|
||||
$("#changeOnMove").spectrum({
|
||||
move: function(c) {
|
||||
var label = $("#changeOnMoveLabel");
|
||||
label.text("Move called: " + c.toHexString());
|
||||
}
|
||||
});
|
||||
$("#changeOnMoveNo").spectrum({
|
||||
showInput: true,
|
||||
change: function(c) {
|
||||
var label = $("#changeOnMoveNoLabel");
|
||||
label.text("Change called: " + c.toHexString());
|
||||
}
|
||||
});
|
||||
|
||||
function prettyTime() {
|
||||
var date = new Date();
|
||||
|
||||
return date.toLocaleTimeString();
|
||||
}
|
||||
|
||||
$("#eventshow").spectrum({
|
||||
show: function(c) {
|
||||
var label = $("#eventshowLabel");
|
||||
label.text("show called at " + prettyTime() + " (color is " + c.toHexString() + ")");
|
||||
}
|
||||
});
|
||||
|
||||
$("#eventhide").spectrum({
|
||||
hide: function(c) {
|
||||
var label = $("#eventhideLabel");
|
||||
label.text("hide called at " + prettyTime() + " (color is " + c.toHexString() + ")");
|
||||
}
|
||||
});
|
||||
|
||||
$("#eventdragstart").spectrum({
|
||||
showAlpha: true
|
||||
}).on("dragstart.spectrum", function(e, c) {
|
||||
var label = $("#eventdragstartLabel");
|
||||
label.text("dragstart called at " + prettyTime() + " (color is " + c.toHexString() + ")");
|
||||
});
|
||||
|
||||
$("#eventdragstop").spectrum({
|
||||
showAlpha: true
|
||||
}).on("dragstop.spectrum", function(e, c) {
|
||||
var label = $("#eventdragstopLabel");
|
||||
label.text("dragstop called at " + prettyTime() + " (color is " + c.toHexString() + ")");
|
||||
});
|
||||
|
||||
|
||||
$(".basic").spectrum({ change: updateBorders });
|
||||
$(".override").spectrum({
|
||||
color: "yellow",
|
||||
change: updateBorders
|
||||
});
|
||||
|
||||
$(".startEmpty").spectrum({
|
||||
allowEmpty:true,
|
||||
change: updateBorders});
|
||||
|
||||
$("#beforeShow").spectrum({
|
||||
beforeShow: function() {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
$("#custom").spectrum({
|
||||
color: "#f00"
|
||||
});
|
||||
|
||||
$("#buttonText").spectrum({
|
||||
allowEmpty:true,
|
||||
chooseText: "Alright",
|
||||
cancelText: "No way"
|
||||
});
|
||||
|
||||
|
||||
$("#showSelectionPalette").spectrum({
|
||||
showPalette: true,
|
||||
showSelectionPalette: true, // true by default
|
||||
palette: [ ]
|
||||
});
|
||||
$("#showSelectionPaletteStorage").spectrum({
|
||||
showPalette: true,
|
||||
localStorageKey: "spectrum.homepage", // Any picker with the same string will share selection
|
||||
showSelectionPalette: true,
|
||||
palette: [ ]
|
||||
});
|
||||
$("#showSelectionPaletteStorage2").spectrum({
|
||||
showPalette: true,
|
||||
localStorageKey: "spectrum.homepage", // Any picker with the same string will share selection
|
||||
showSelectionPalette: true,
|
||||
palette: [ ]
|
||||
});
|
||||
|
||||
|
||||
$("#preferredHex").spectrum({
|
||||
preferredFormat: "hex",
|
||||
showInput: true,
|
||||
showPalette: true,
|
||||
palette: [["red", "rgba(0, 255, 0, .5)", "rgb(0, 0, 255)"]]
|
||||
});
|
||||
$("#preferredHex3").spectrum({
|
||||
preferredFormat: "hex3",
|
||||
showInput: true,
|
||||
showPalette: true,
|
||||
palette: [["red", "rgba(0, 255, 0, .5)", "rgb(0, 0, 255)"]]
|
||||
});
|
||||
$("#preferredHsl").spectrum({
|
||||
preferredFormat: "hsl",
|
||||
showInput: true,
|
||||
showPalette: true,
|
||||
palette: [["red", "rgba(0, 255, 0, .5)", "rgb(0, 0, 255)"]]
|
||||
});
|
||||
$("#preferredRgb").spectrum({
|
||||
preferredFormat: "rgb",
|
||||
showInput: true,
|
||||
showPalette: true,
|
||||
palette: [["red", "rgba(0, 255, 0, .5)", "rgb(0, 0, 255)"]]
|
||||
});
|
||||
$("#preferredName").spectrum({
|
||||
preferredFormat: "name",
|
||||
showInput: true,
|
||||
showPalette: true,
|
||||
palette: [["red", "rgba(0, 255, 0, .5)", "rgb(0, 0, 255)"]]
|
||||
});
|
||||
$("#preferredNone").spectrum({
|
||||
showInput: true,
|
||||
showPalette: true,
|
||||
palette: [["red", "rgba(0, 255, 0, .5)", "rgb(0, 0, 255)"]]
|
||||
});
|
||||
|
||||
$("#triggerSet").spectrum({
|
||||
change: updateBorders
|
||||
});
|
||||
|
||||
// Show the original input to demonstrate the value changing when calling `set`
|
||||
$("#triggerSet").show();
|
||||
|
||||
$("#btnEnterAColor").click(function() {
|
||||
$("#triggerSet").spectrum("set", $("#enterAColor").val());
|
||||
});
|
||||
|
||||
$("#toggle").spectrum();
|
||||
$("#btn-toggle").click(function() {
|
||||
$("#toggle").spectrum("toggle");
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
//$('#toc').toc({
|
||||
// 'selectors': 'h2,h3', //elements to use as headings
|
||||
// 'container': '#docs', //element to find all selectors in
|
||||
// 'smoothScrolling': true, //enable or disable smooth scrolling on click
|
||||
// 'prefix': 'toc', //prefix for anchor tags and class names
|
||||
// 'highlightOnScroll': true, //add class to heading that is currently in focus
|
||||
// 'highlightOffset': 100, //offset to trigger the next headline
|
||||
// 'anchorName': function(i, heading, prefix) { //custom function for anchor name
|
||||
// return heading.id || prefix+i;
|
||||
// }
|
||||
//});
|
||||
|
||||
//prettyPrint();
|
||||
|
||||
|
||||
});
|
||||
@@ -0,0 +1,522 @@
|
||||
/***
|
||||
Spectrum Colorpicker v1.3.4
|
||||
https://github.com/bgrins/spectrum
|
||||
Author: Brian Grinstead
|
||||
License: MIT
|
||||
***/
|
||||
|
||||
.sp-container {
|
||||
position:absolute;
|
||||
top:0;
|
||||
left:0;
|
||||
display:inline-block;
|
||||
*display: inline;
|
||||
*zoom: 1;
|
||||
/* https://github.com/bgrins/spectrum/issues/40 */
|
||||
z-index: 100;
|
||||
overflow: hidden;
|
||||
}
|
||||
.sp-container.sp-flat {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
/* Fix for * { box-sizing: border-box; } */
|
||||
.sp-container,
|
||||
.sp-container * {
|
||||
-webkit-box-sizing: content-box;
|
||||
-moz-box-sizing: content-box;
|
||||
box-sizing: content-box;
|
||||
}
|
||||
|
||||
/* http://ansciath.tumblr.com/post/7347495869/css-aspect-ratio */
|
||||
.sp-top {
|
||||
position:relative;
|
||||
width: 100%;
|
||||
display:inline-block;
|
||||
}
|
||||
.sp-top-inner {
|
||||
position:absolute;
|
||||
top:0;
|
||||
left:0;
|
||||
bottom:0;
|
||||
right:0;
|
||||
}
|
||||
.sp-color {
|
||||
position: absolute;
|
||||
top:0;
|
||||
left:0;
|
||||
bottom:0;
|
||||
right:20%;
|
||||
}
|
||||
.sp-hue {
|
||||
position: absolute;
|
||||
top:0;
|
||||
right:0;
|
||||
bottom:0;
|
||||
left:84%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.sp-clear-enabled .sp-hue {
|
||||
top:33px;
|
||||
height: 77.5%;
|
||||
}
|
||||
|
||||
.sp-fill {
|
||||
padding-top: 80%;
|
||||
}
|
||||
.sp-sat, .sp-val {
|
||||
position: absolute;
|
||||
top:0;
|
||||
left:0;
|
||||
right:0;
|
||||
bottom:0;
|
||||
}
|
||||
|
||||
.sp-alpha-enabled .sp-top {
|
||||
margin-bottom: 18px;
|
||||
}
|
||||
.sp-alpha-enabled .sp-alpha {
|
||||
display: block;
|
||||
}
|
||||
.sp-alpha-handle {
|
||||
position:absolute;
|
||||
top:-4px;
|
||||
bottom: -4px;
|
||||
width: 6px;
|
||||
left: 50%;
|
||||
cursor: pointer;
|
||||
border: 1px solid black;
|
||||
background: white;
|
||||
opacity: .8;
|
||||
}
|
||||
.sp-alpha {
|
||||
display: none;
|
||||
position: absolute;
|
||||
bottom: -14px;
|
||||
right: 0;
|
||||
left: 0;
|
||||
height: 8px;
|
||||
}
|
||||
.sp-alpha-inner {
|
||||
border: solid 1px #333;
|
||||
}
|
||||
|
||||
.sp-clear {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.sp-clear.sp-clear-display {
|
||||
background-position: center;
|
||||
}
|
||||
|
||||
.sp-clear-enabled .sp-clear {
|
||||
display: block;
|
||||
position:absolute;
|
||||
top:0px;
|
||||
right:0;
|
||||
bottom:0;
|
||||
left:84%;
|
||||
height: 28px;
|
||||
}
|
||||
|
||||
/* Don't allow text selection */
|
||||
.sp-container, .sp-replacer, .sp-preview, .sp-dragger, .sp-slider, .sp-alpha, .sp-clear, .sp-alpha-handle, .sp-container.sp-dragging .sp-input, .sp-container button {
|
||||
-webkit-user-select:none;
|
||||
-moz-user-select: -moz-none;
|
||||
-o-user-select:none;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.sp-container.sp-input-disabled .sp-input-container {
|
||||
display: none;
|
||||
}
|
||||
.sp-container.sp-buttons-disabled .sp-button-container {
|
||||
display: none;
|
||||
}
|
||||
.sp-palette-only .sp-picker-container {
|
||||
display: none;
|
||||
}
|
||||
.sp-palette-disabled .sp-palette-container {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.sp-initial-disabled .sp-initial {
|
||||
display: none;
|
||||
}
|
||||
|
||||
|
||||
/* Gradients for hue, saturation and value instead of images. Not pretty... but it works */
|
||||
.sp-sat {
|
||||
background-image: -webkit-gradient(linear, 0 0, 100% 0, from(#FFF), to(rgba(204, 154, 129, 0)));
|
||||
background-image: -webkit-linear-gradient(left, #FFF, rgba(204, 154, 129, 0));
|
||||
background-image: -moz-linear-gradient(left, #fff, rgba(204, 154, 129, 0));
|
||||
background-image: -o-linear-gradient(left, #fff, rgba(204, 154, 129, 0));
|
||||
background-image: -ms-linear-gradient(left, #fff, rgba(204, 154, 129, 0));
|
||||
background-image: linear-gradient(to right, #fff, rgba(204, 154, 129, 0));
|
||||
-ms-filter: "progid:DXImageTransform.Microsoft.gradient(GradientType = 1, startColorstr=#FFFFFFFF, endColorstr=#00CC9A81)";
|
||||
filter : progid:DXImageTransform.Microsoft.gradient(GradientType = 1, startColorstr='#FFFFFFFF', endColorstr='#00CC9A81');
|
||||
}
|
||||
.sp-val {
|
||||
background-image: -webkit-gradient(linear, 0 100%, 0 0, from(#000000), to(rgba(204, 154, 129, 0)));
|
||||
background-image: -webkit-linear-gradient(bottom, #000000, rgba(204, 154, 129, 0));
|
||||
background-image: -moz-linear-gradient(bottom, #000, rgba(204, 154, 129, 0));
|
||||
background-image: -o-linear-gradient(bottom, #000, rgba(204, 154, 129, 0));
|
||||
background-image: -ms-linear-gradient(bottom, #000, rgba(204, 154, 129, 0));
|
||||
background-image: linear-gradient(to top, #000, rgba(204, 154, 129, 0));
|
||||
-ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#00CC9A81, endColorstr=#FF000000)";
|
||||
filter : progid:DXImageTransform.Microsoft.gradient(startColorstr='#00CC9A81', endColorstr='#FF000000');
|
||||
}
|
||||
|
||||
.sp-hue {
|
||||
background: -moz-linear-gradient(top, #ff0000 0%, #ffff00 17%, #00ff00 33%, #00ffff 50%, #0000ff 67%, #ff00ff 83%, #ff0000 100%);
|
||||
background: -ms-linear-gradient(top, #ff0000 0%, #ffff00 17%, #00ff00 33%, #00ffff 50%, #0000ff 67%, #ff00ff 83%, #ff0000 100%);
|
||||
background: -o-linear-gradient(top, #ff0000 0%, #ffff00 17%, #00ff00 33%, #00ffff 50%, #0000ff 67%, #ff00ff 83%, #ff0000 100%);
|
||||
background: -webkit-gradient(linear, left top, left bottom, from(#ff0000), color-stop(0.17, #ffff00), color-stop(0.33, #00ff00), color-stop(0.5, #00ffff), color-stop(0.67, #0000ff), color-stop(0.83, #ff00ff), to(#ff0000));
|
||||
background: -webkit-linear-gradient(top, #ff0000 0%, #ffff00 17%, #00ff00 33%, #00ffff 50%, #0000ff 67%, #ff00ff 83%, #ff0000 100%);
|
||||
}
|
||||
|
||||
/* IE filters do not support multiple color stops.
|
||||
Generate 6 divs, line them up, and do two color gradients for each.
|
||||
Yes, really.
|
||||
*/
|
||||
.sp-1 {
|
||||
height:17%;
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff0000', endColorstr='#ffff00');
|
||||
}
|
||||
.sp-2 {
|
||||
height:16%;
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffff00', endColorstr='#00ff00');
|
||||
}
|
||||
.sp-3 {
|
||||
height:17%;
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#00ff00', endColorstr='#00ffff');
|
||||
}
|
||||
.sp-4 {
|
||||
height:17%;
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#00ffff', endColorstr='#0000ff');
|
||||
}
|
||||
.sp-5 {
|
||||
height:16%;
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#0000ff', endColorstr='#ff00ff');
|
||||
}
|
||||
.sp-6 {
|
||||
height:17%;
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff00ff', endColorstr='#ff0000');
|
||||
}
|
||||
|
||||
.sp-hidden {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
/* Clearfix hack */
|
||||
.sp-cf:before, .sp-cf:after { content: ""; display: table; }
|
||||
.sp-cf:after { clear: both; }
|
||||
.sp-cf { *zoom: 1; }
|
||||
|
||||
/* Mobile devices, make hue slider bigger so it is easier to slide */
|
||||
@media (max-device-width: 480px) {
|
||||
.sp-color { right: 40%; }
|
||||
.sp-hue { left: 63%; }
|
||||
.sp-fill { padding-top: 60%; }
|
||||
}
|
||||
.sp-dragger {
|
||||
border-radius: 5px;
|
||||
height: 5px;
|
||||
width: 5px;
|
||||
border: 1px solid #fff;
|
||||
background: #000;
|
||||
cursor: pointer;
|
||||
position:absolute;
|
||||
top:0;
|
||||
left: 0;
|
||||
}
|
||||
.sp-slider {
|
||||
position: absolute;
|
||||
top:0;
|
||||
cursor:pointer;
|
||||
height: 3px;
|
||||
left: -1px;
|
||||
right: -1px;
|
||||
border: 1px solid #000;
|
||||
background: white;
|
||||
opacity: .8;
|
||||
}
|
||||
|
||||
/*
|
||||
Theme authors:
|
||||
Here are the basic themeable display options (colors, fonts, global widths).
|
||||
See http://bgrins.github.io/spectrum/themes/ for instructions.
|
||||
*/
|
||||
.sp-choose,.sp-cancel{
|
||||
display:none !important;
|
||||
}
|
||||
|
||||
.sp-container {
|
||||
border-radius: 0;
|
||||
background-color: #ECECEC;
|
||||
border: solid 1px #ddd;
|
||||
padding: 0;
|
||||
}
|
||||
.sp-container, .sp-container button, .sp-container input, .sp-color, .sp-hue, .sp-clear
|
||||
{
|
||||
font: normal 12px "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", Geneva, Verdana, sans-serif;
|
||||
-webkit-box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
-ms-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.sp-top
|
||||
{
|
||||
margin-bottom: 3px;
|
||||
}
|
||||
.sp-color, .sp-hue, .sp-clear
|
||||
{
|
||||
border: solid 1px #666;
|
||||
}
|
||||
|
||||
/* Input */
|
||||
.sp-input-container {
|
||||
float:right;
|
||||
width: 100px;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
.sp-initial-disabled .sp-input-container {
|
||||
width: 100%;
|
||||
}
|
||||
.sp-input {
|
||||
font-size: 12px !important;
|
||||
border: 1px inset;
|
||||
padding: 4px 5px;
|
||||
margin: 0;
|
||||
width: 100%;
|
||||
/*background:transparent;*/
|
||||
border-radius: 3px;
|
||||
color: #222;
|
||||
}
|
||||
.sp-input:focus {
|
||||
border: 1px solid orange;
|
||||
}
|
||||
.sp-input.sp-validation-error
|
||||
{
|
||||
border: 1px solid red;
|
||||
background: #fdd;
|
||||
}
|
||||
.sp-picker-container , .sp-palette-container
|
||||
{
|
||||
float:left;
|
||||
position: relative;
|
||||
padding: 10px;
|
||||
padding-bottom: 300px;
|
||||
margin-bottom: -290px;
|
||||
}
|
||||
.sp-picker-container
|
||||
{
|
||||
width: 172px;
|
||||
border-left: solid 1px #fff;
|
||||
}
|
||||
|
||||
/* Palettes */
|
||||
.sp-palette-container
|
||||
{
|
||||
border-right: solid 1px #ccc;
|
||||
}
|
||||
|
||||
.sp-palette .sp-thumb-el {
|
||||
display: block;
|
||||
position:relative;
|
||||
float:left;
|
||||
width: 24px;
|
||||
height: 15px;
|
||||
margin: 3px;
|
||||
cursor: pointer;
|
||||
border:solid 2px transparent;
|
||||
}
|
||||
.sp-palette .sp-thumb-el:hover, .sp-palette .sp-thumb-el.sp-thumb-active {
|
||||
border-color: orange;
|
||||
}
|
||||
.sp-thumb-el
|
||||
{
|
||||
position:relative;
|
||||
}
|
||||
|
||||
/* Initial */
|
||||
.sp-initial
|
||||
{
|
||||
float: left;
|
||||
border: solid 1px #333;
|
||||
}
|
||||
.sp-initial span {
|
||||
width: 30px;
|
||||
height: 25px;
|
||||
border:none;
|
||||
display:block;
|
||||
float:left;
|
||||
margin:0;
|
||||
}
|
||||
|
||||
.sp-initial .sp-clear-display {
|
||||
background-position: center;
|
||||
}
|
||||
|
||||
/* Buttons */
|
||||
.sp-button-container {
|
||||
float: right;
|
||||
}
|
||||
|
||||
/* Replacer (the little preview div that shows up instead of the <input>) */
|
||||
.sp-replacer {
|
||||
margin:0;
|
||||
overflow:hidden;
|
||||
cursor:pointer;
|
||||
padding: 4px;
|
||||
display:inline-block;
|
||||
*zoom: 1;
|
||||
*display: inline;
|
||||
border: solid 1px #91765d;
|
||||
background: #eee;
|
||||
color: #333;
|
||||
vertical-align: middle;
|
||||
}
|
||||
.sp-replacer:hover, .sp-replacer.sp-active {
|
||||
border-color: #F0C49B;
|
||||
color: #111;
|
||||
}
|
||||
.sp-replacer.sp-disabled {
|
||||
cursor:default;
|
||||
border-color: silver;
|
||||
color: silver;
|
||||
}
|
||||
.sp-dd {
|
||||
padding: 2px 0;
|
||||
height: 16px;
|
||||
line-height: 16px;
|
||||
float:left;
|
||||
font-size:10px;
|
||||
}
|
||||
.sp-preview
|
||||
{
|
||||
position:relative;
|
||||
width:25px;
|
||||
height: 20px;
|
||||
border: solid 1px #222;
|
||||
margin-right: 5px;
|
||||
float:left;
|
||||
z-index: 0;
|
||||
}
|
||||
|
||||
.sp-palette
|
||||
{
|
||||
*width: 220px;
|
||||
max-width: 220px;
|
||||
}
|
||||
.sp-palette .sp-thumb-el
|
||||
{
|
||||
width:16px;
|
||||
height: 16px;
|
||||
margin:2px 1px;
|
||||
border: solid 1px #d0d0d0;
|
||||
}
|
||||
|
||||
.sp-container
|
||||
{
|
||||
padding-bottom:0;
|
||||
}
|
||||
|
||||
|
||||
/* Buttons: http://hellohappy.org/css3-buttons/ */
|
||||
.sp-container button {
|
||||
background-color: #eeeeee;
|
||||
background-image: -webkit-linear-gradient(top, #eeeeee, #cccccc);
|
||||
background-image: -moz-linear-gradient(top, #eeeeee, #cccccc);
|
||||
background-image: -ms-linear-gradient(top, #eeeeee, #cccccc);
|
||||
background-image: -o-linear-gradient(top, #eeeeee, #cccccc);
|
||||
background-image: linear-gradient(to bottom, #eeeeee, #cccccc);
|
||||
border: 1px solid #ccc;
|
||||
border-bottom: 1px solid #bbb;
|
||||
border-radius: 3px;
|
||||
color: #333;
|
||||
font-size: 14px;
|
||||
line-height: 1;
|
||||
padding: 5px 4px;
|
||||
text-align: center;
|
||||
text-shadow: 0 1px 0 #eee;
|
||||
vertical-align: middle;
|
||||
}
|
||||
.sp-container button:hover {
|
||||
background-color: #dddddd;
|
||||
background-image: -webkit-linear-gradient(top, #dddddd, #bbbbbb);
|
||||
background-image: -moz-linear-gradient(top, #dddddd, #bbbbbb);
|
||||
background-image: -ms-linear-gradient(top, #dddddd, #bbbbbb);
|
||||
background-image: -o-linear-gradient(top, #dddddd, #bbbbbb);
|
||||
background-image: linear-gradient(to bottom, #dddddd, #bbbbbb);
|
||||
border: 1px solid #bbb;
|
||||
border-bottom: 1px solid #999;
|
||||
cursor: pointer;
|
||||
text-shadow: 0 1px 0 #ddd;
|
||||
}
|
||||
.sp-container button:active {
|
||||
border: 1px solid #aaa;
|
||||
border-bottom: 1px solid #888;
|
||||
-webkit-box-shadow: inset 0 0 5px 2px #aaaaaa, 0 1px 0 0 #eeeeee;
|
||||
-moz-box-shadow: inset 0 0 5px 2px #aaaaaa, 0 1px 0 0 #eeeeee;
|
||||
-ms-box-shadow: inset 0 0 5px 2px #aaaaaa, 0 1px 0 0 #eeeeee;
|
||||
-o-box-shadow: inset 0 0 5px 2px #aaaaaa, 0 1px 0 0 #eeeeee;
|
||||
box-shadow: inset 0 0 5px 2px #aaaaaa, 0 1px 0 0 #eeeeee;
|
||||
}
|
||||
.sp-cancel
|
||||
{
|
||||
font-size: 11px;
|
||||
color: #d93f3f !important;
|
||||
margin:0;
|
||||
padding:2px;
|
||||
margin-right: 5px;
|
||||
vertical-align: middle;
|
||||
text-decoration:none;
|
||||
|
||||
}
|
||||
.sp-cancel:hover
|
||||
{
|
||||
color: #d93f3f !important;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
|
||||
.sp-palette span:hover, .sp-palette span.sp-thumb-active
|
||||
{
|
||||
border-color: #000;
|
||||
}
|
||||
|
||||
.sp-preview, .sp-alpha, .sp-thumb-el
|
||||
{
|
||||
position:relative;
|
||||
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAIAAADZF8uwAAAAGUlEQVQYV2M4gwH+YwCGIasIUwhT25BVBADtzYNYrHvv4gAAAABJRU5ErkJggg==);
|
||||
}
|
||||
.sp-preview-inner, .sp-alpha-inner, .sp-thumb-inner
|
||||
{
|
||||
display:block;
|
||||
position:absolute;
|
||||
top:0;left:0;bottom:0;right:0;
|
||||
}
|
||||
|
||||
.sp-palette .sp-thumb-inner
|
||||
{
|
||||
background-position: 50% 50%;
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
|
||||
.sp-palette .sp-thumb-light.sp-thumb-active .sp-thumb-inner
|
||||
{
|
||||
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAYAAABWzo5XAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAIVJREFUeNpiYBhsgJFMffxAXABlN5JruT4Q3wfi/0DsT64h8UD8HmpIPCWG/KemIfOJCUB+Aoacx6EGBZyHBqI+WsDCwuQ9mhxeg2A210Ntfo8klk9sOMijaURm7yc1UP2RNCMbKE9ODK1HM6iegYLkfx8pligC9lCD7KmRof0ZhjQACDAAceovrtpVBRkAAAAASUVORK5CYII=);
|
||||
}
|
||||
|
||||
.sp-palette .sp-thumb-dark.sp-thumb-active .sp-thumb-inner
|
||||
{
|
||||
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAYAAABWzo5XAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAadEVYdFNvZnR3YXJlAFBhaW50Lk5FVCB2My41LjEwMPRyoQAAAMdJREFUOE+tkgsNwzAMRMugEAahEAahEAZhEAqlEAZhEAohEAYh81X2dIm8fKpEspLGvudPOsUYpxE2BIJCroJmEW9qJ+MKaBFhEMNabSy9oIcIPwrB+afvAUFoK4H0tMaQ3XtlrggDhOVVMuT4E5MMG0FBbCEYzjYT7OxLEvIHQLY2zWwQ3D+9luyOQTfKDiFD3iUIfPk8VqrKjgAiSfGFPecrg6HN6m/iBcwiDAo7WiBeawa+Kwh7tZoSCGLMqwlSAzVDhoK+6vH4G0P5wdkAAAAASUVORK5CYII=);
|
||||
}
|
||||
|
||||
.sp-clear-display {
|
||||
background-repeat:no-repeat;
|
||||
background-position: center;
|
||||
background-image: url(data:image/gif;base64,R0lGODlhFAAUAPcAAAAAAJmZmZ2dnZ6enqKioqOjo6SkpKWlpaampqenp6ioqKmpqaqqqqurq/Hx8fLy8vT09PX19ff39/j4+Pn5+fr6+vv7+wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAP8ALAAAAAAUABQAAAihAP9FoPCvoMGDBy08+EdhQAIJCCMybCDAAYUEARBAlFiQQoMABQhKUJBxY0SPICEYHBnggEmDKAuoPMjS5cGYMxHW3IiT478JJA8M/CjTZ0GgLRekNGpwAsYABHIypcAgQMsITDtWJYBR6NSqMico9cqR6tKfY7GeBCuVwlipDNmefAtTrkSzB1RaIAoXodsABiZAEFB06gIBWC1mLVgBa0AAOw==);
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,55 @@
|
||||
var reg = /([\s|\{|;])([a-z\-]+)(\s*):/ig;
|
||||
var cssChanger = {
|
||||
format: function(s) {
|
||||
s = s.toString();
|
||||
s = s.replace(/\s*([\{\}\:\;\,])\s*/g, "$1");
|
||||
s = s.replace(/(\s*)\}/g, "$1;}");
|
||||
s = s.replace(/;\s*;/g, ";");
|
||||
s = s.replace(/\,[\s\.\#\d]*{/g, "{");
|
||||
s = s.replace(/([^\s])\{([^\s])/g, "$1 {\n\t$2");
|
||||
s = s.replace(/([^\s])\}([^\n]*)/g, "$1\n}\n$2");
|
||||
s = s.replace(/([^\s]);([^\s\}])/g, "$1;\n\t$2");
|
||||
if ($("#delnotes").prop("checked")) {
|
||||
s = s.replace(/\/\*(.|\n)*?\*\//g, "\n\t")
|
||||
}
|
||||
s = s.replace(/\n(\n)*( *)*(\n)*\n/g, "");
|
||||
if ($("#chk").prop("checked")) {
|
||||
s = s.replace(/(\r|\n|\t)/g, "");
|
||||
s = s.replace(/(})/g, "$1\r\n")
|
||||
}
|
||||
if ($("#tolower").prop("checked")) {
|
||||
s = s.replace(reg,
|
||||
function(word) {
|
||||
return word.toLowerCase()
|
||||
});
|
||||
}
|
||||
s = s.replace(/\s+\*\//g, "*/");
|
||||
return s
|
||||
},
|
||||
pack: function (s) {
|
||||
s = s.replace(/\s*([\{\}\:\;\,])\s*/g, "$1");
|
||||
s = s.replace(/\,[\s\.\#\d]*\{/g, "{");
|
||||
s = s.replace(/;\s*;/g, ";");
|
||||
if ($("#tolower").prop("checked")) {
|
||||
s = s.replace(reg,
|
||||
function(word) {
|
||||
return word.toLowerCase()
|
||||
});
|
||||
}
|
||||
if ($("#delnotes").prop("checked")) {
|
||||
s = s.replace(/\/\*(.|\n)*?\*\//g, "");
|
||||
}
|
||||
s = s.match(/^\s*(\S+(\s+\S+)*)\s*$/);
|
||||
return (s == null) ? "" : s[1];
|
||||
}
|
||||
};
|
||||
function format_css(s) {
|
||||
var content = cssChanger[s]($("#content").val());
|
||||
if (content.length == '') {
|
||||
pcjson_com_msg($("#content"),'CSS代码不能为空!');
|
||||
return false
|
||||
}
|
||||
$("pre").show();
|
||||
$('#result').html(hljs.highlightAuto(content).value);
|
||||
}
|
||||
function Empty() { $("#content").val(""); $("#result").html(''); $("#content").select();$("pre").hide(); }
|
||||
@@ -0,0 +1,143 @@
|
||||
function hide_pwd() { $("#p_div").hide(); }
|
||||
function show_pwd() { $("#p_div").show(); }
|
||||
|
||||
function hashjsonscn(type) {
|
||||
try {
|
||||
switch (type) {
|
||||
case "SHA1":
|
||||
hide_pwd();
|
||||
hightout(CryptoJS.SHA1($("#content").val()).toString());
|
||||
break;
|
||||
case "SHA224":
|
||||
hide_pwd();
|
||||
hightout(CryptoJS.SHA224($("#content").val()).toString());
|
||||
break;
|
||||
case "SHA256":
|
||||
hide_pwd();
|
||||
hightout(CryptoJS.SHA256($("#content").val()).toString());
|
||||
break;
|
||||
case "SHA384":
|
||||
hide_pwd();
|
||||
hightout(CryptoJS.SHA384($("#content").val()).toString());
|
||||
break;
|
||||
case "SHA512":
|
||||
hide_pwd();
|
||||
hightout(CryptoJS.SHA512($("#content").val()).toString());
|
||||
break;
|
||||
case "MD5":
|
||||
hide_pwd();
|
||||
hightout(CryptoJS.MD5($("#content").val()).toString());
|
||||
break;
|
||||
case "HmacSHA1":
|
||||
show_pwd();
|
||||
hightout(CryptoJS.HmacSHA1($("#content").val(), $("#pwd").val()).toString());
|
||||
break;
|
||||
case "HmacSHA224":
|
||||
show_pwd();
|
||||
hightout(CryptoJS.HmacSHA224($("#content").val(), $("#pwd").val()).toString());
|
||||
break;
|
||||
case "HmacSHA256":
|
||||
show_pwd();
|
||||
hightout(CryptoJS.HmacSHA256($("#content").val(), $("#pwd").val()).toString());
|
||||
break;
|
||||
case "HmacSHA384":
|
||||
show_pwd();
|
||||
hightout(CryptoJS.HmacSHA384($("#content").val(), $("#pwd").val()).toString());
|
||||
break;
|
||||
case "HmacSHA512":
|
||||
show_pwd();
|
||||
hightout(CryptoJS.HmacSHA512($("#content").val(), $("#pwd").val()).toString());
|
||||
break;
|
||||
case "HmacMD5":
|
||||
show_pwd();
|
||||
hightout(CryptoJS.HmacMD5($("#content").val(), $("#pwd").val()).toString());
|
||||
break;
|
||||
case "base64加密":
|
||||
hide_pwd();
|
||||
var str = CryptoJS.enc.Utf8.parse($("#content").val().toString());
|
||||
hightout(CryptoJS.enc.Base64.stringify(str));
|
||||
break;
|
||||
case "base64解密":
|
||||
hide_pwd();
|
||||
hightout(CryptoJS.enc.Base64.parse($("#content").val()).toString(CryptoJS.enc.Utf8));
|
||||
break;
|
||||
case "AES加密":
|
||||
show_pwd();
|
||||
hightout(CryptoJS.AES.encrypt($("#content").val(), $("#pwd").val()).toString());
|
||||
break;
|
||||
case "AES解密":
|
||||
show_pwd();
|
||||
hightout(CryptoJS.AES.decrypt($("#content").val(), $("#pwd").val()).toString(CryptoJS.enc.Utf8));
|
||||
break;
|
||||
case "DES加密":
|
||||
show_pwd();
|
||||
hightout(CryptoJS.DES.encrypt($("#content").val(), $("#pwd").val()).toString());
|
||||
break;
|
||||
case "DES解密":
|
||||
show_pwd();
|
||||
hightout(CryptoJS.DES.decrypt($("#content").val(), $("#pwd").val()).toString(CryptoJS.enc.Utf8));
|
||||
break;
|
||||
case "Rabbit加密":
|
||||
show_pwd();
|
||||
hightout(CryptoJS.Rabbit.encrypt($("#content").val(), $("#pwd").val()).toString());
|
||||
break;
|
||||
case "Rabbit解密":
|
||||
show_pwd();
|
||||
hightout(CryptoJS.Rabbit.decrypt($("#content").val(), $("#pwd").val()).toString(CryptoJS.enc.Utf8));
|
||||
break;
|
||||
case "RC4加密":
|
||||
show_pwd();
|
||||
hightout(CryptoJS.RC4.encrypt($("#content").val(), $("#pwd").val()).toString());
|
||||
break;
|
||||
case "RC4解密":
|
||||
show_pwd();
|
||||
hightout(CryptoJS.RC4.decrypt($("#content").val(), $("#pwd").val()).toString(CryptoJS.enc.Utf8));
|
||||
break;
|
||||
case "TripleDES加密":
|
||||
show_pwd();
|
||||
hightout(CryptoJS.TripleDES.encrypt($("#content").val(), $("#pwd").val()).toString());
|
||||
break;
|
||||
case "TripleDES解密":
|
||||
show_pwd();
|
||||
hightout(CryptoJS.TripleDES.decrypt($("#content").val(), $("#pwd").val()).toString(CryptoJS.enc.Utf8));
|
||||
break;
|
||||
case "UrlEncode":
|
||||
hide_pwd();
|
||||
UrlEncode($("#content").val().toString());
|
||||
break;
|
||||
case "UrlDecode":
|
||||
hide_pwd();
|
||||
UrlDecode($("#content").val().toString());
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (err) {
|
||||
hightout(err);
|
||||
}
|
||||
}
|
||||
function UrlEncode(str) {
|
||||
$.ajax({
|
||||
url: "/tool/urlencode",
|
||||
dataType: "json",
|
||||
async: true,
|
||||
data: { "str": str },
|
||||
type: "GET",
|
||||
success: function (result) {
|
||||
hightout(result.msg);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
function UrlDecode(str) {
|
||||
$.ajax({
|
||||
url: "/tool/urldecode",
|
||||
dataType: "json",
|
||||
async: true,
|
||||
data: { "str": str },
|
||||
type: "GET",
|
||||
success: function (result) {
|
||||
hightout(result.msg);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
CryptoJS v3.1.2
|
||||
code.google.com/p/crypto-js
|
||||
(c) 2009-2013 by Jeff Mott. All rights reserved.
|
||||
code.google.com/p/crypto-js/wiki/License
|
||||
*/
|
||||
var CryptoJS=CryptoJS||function(s,p){var m={},l=m.lib={},n=function(){},r=l.Base={extend:function(b){n.prototype=this;var h=new n;b&&h.mixIn(b);h.hasOwnProperty("init")||(h.init=function(){h.$super.init.apply(this,arguments)});h.init.prototype=h;h.$super=this;return h},create:function(){var b=this.extend();b.init.apply(b,arguments);return b},init:function(){},mixIn:function(b){for(var h in b)b.hasOwnProperty(h)&&(this[h]=b[h]);b.hasOwnProperty("toString")&&(this.toString=b.toString)},clone:function(){return this.init.prototype.extend(this)}},
|
||||
q=l.WordArray=r.extend({init:function(b,h){b=this.words=b||[];this.sigBytes=h!=p?h:4*b.length},toString:function(b){return(b||t).stringify(this)},concat:function(b){var h=this.words,a=b.words,j=this.sigBytes;b=b.sigBytes;this.clamp();if(j%4)for(var g=0;g<b;g++)h[j+g>>>2]|=(a[g>>>2]>>>24-8*(g%4)&255)<<24-8*((j+g)%4);else if(65535<a.length)for(g=0;g<b;g+=4)h[j+g>>>2]=a[g>>>2];else h.push.apply(h,a);this.sigBytes+=b;return this},clamp:function(){var b=this.words,h=this.sigBytes;b[h>>>2]&=4294967295<<
|
||||
32-8*(h%4);b.length=s.ceil(h/4)},clone:function(){var b=r.clone.call(this);b.words=this.words.slice(0);return b},random:function(b){for(var h=[],a=0;a<b;a+=4)h.push(4294967296*s.random()|0);return new q.init(h,b)}}),v=m.enc={},t=v.Hex={stringify:function(b){var a=b.words;b=b.sigBytes;for(var g=[],j=0;j<b;j++){var k=a[j>>>2]>>>24-8*(j%4)&255;g.push((k>>>4).toString(16));g.push((k&15).toString(16))}return g.join("")},parse:function(b){for(var a=b.length,g=[],j=0;j<a;j+=2)g[j>>>3]|=parseInt(b.substr(j,
|
||||
2),16)<<24-4*(j%8);return new q.init(g,a/2)}},a=v.Latin1={stringify:function(b){var a=b.words;b=b.sigBytes;for(var g=[],j=0;j<b;j++)g.push(String.fromCharCode(a[j>>>2]>>>24-8*(j%4)&255));return g.join("")},parse:function(b){for(var a=b.length,g=[],j=0;j<a;j++)g[j>>>2]|=(b.charCodeAt(j)&255)<<24-8*(j%4);return new q.init(g,a)}},u=v.Utf8={stringify:function(b){try{return decodeURIComponent(escape(a.stringify(b)))}catch(g){throw Error("Malformed UTF-8 data");}},parse:function(b){return a.parse(unescape(encodeURIComponent(b)))}},
|
||||
g=l.BufferedBlockAlgorithm=r.extend({reset:function(){this._data=new q.init;this._nDataBytes=0},_append:function(b){"string"==typeof b&&(b=u.parse(b));this._data.concat(b);this._nDataBytes+=b.sigBytes},_process:function(b){var a=this._data,g=a.words,j=a.sigBytes,k=this.blockSize,m=j/(4*k),m=b?s.ceil(m):s.max((m|0)-this._minBufferSize,0);b=m*k;j=s.min(4*b,j);if(b){for(var l=0;l<b;l+=k)this._doProcessBlock(g,l);l=g.splice(0,b);a.sigBytes-=j}return new q.init(l,j)},clone:function(){var b=r.clone.call(this);
|
||||
b._data=this._data.clone();return b},_minBufferSize:0});l.Hasher=g.extend({cfg:r.extend(),init:function(b){this.cfg=this.cfg.extend(b);this.reset()},reset:function(){g.reset.call(this);this._doReset()},update:function(b){this._append(b);this._process();return this},finalize:function(b){b&&this._append(b);return this._doFinalize()},blockSize:16,_createHelper:function(b){return function(a,g){return(new b.init(g)).finalize(a)}},_createHmacHelper:function(b){return function(a,g){return(new k.HMAC.init(b,
|
||||
g)).finalize(a)}}});var k=m.algo={};return m}(Math);
|
||||
(function(s){function p(a,k,b,h,l,j,m){a=a+(k&b|~k&h)+l+m;return(a<<j|a>>>32-j)+k}function m(a,k,b,h,l,j,m){a=a+(k&h|b&~h)+l+m;return(a<<j|a>>>32-j)+k}function l(a,k,b,h,l,j,m){a=a+(k^b^h)+l+m;return(a<<j|a>>>32-j)+k}function n(a,k,b,h,l,j,m){a=a+(b^(k|~h))+l+m;return(a<<j|a>>>32-j)+k}for(var r=CryptoJS,q=r.lib,v=q.WordArray,t=q.Hasher,q=r.algo,a=[],u=0;64>u;u++)a[u]=4294967296*s.abs(s.sin(u+1))|0;q=q.MD5=t.extend({_doReset:function(){this._hash=new v.init([1732584193,4023233417,2562383102,271733878])},
|
||||
_doProcessBlock:function(g,k){for(var b=0;16>b;b++){var h=k+b,w=g[h];g[h]=(w<<8|w>>>24)&16711935|(w<<24|w>>>8)&4278255360}var b=this._hash.words,h=g[k+0],w=g[k+1],j=g[k+2],q=g[k+3],r=g[k+4],s=g[k+5],t=g[k+6],u=g[k+7],v=g[k+8],x=g[k+9],y=g[k+10],z=g[k+11],A=g[k+12],B=g[k+13],C=g[k+14],D=g[k+15],c=b[0],d=b[1],e=b[2],f=b[3],c=p(c,d,e,f,h,7,a[0]),f=p(f,c,d,e,w,12,a[1]),e=p(e,f,c,d,j,17,a[2]),d=p(d,e,f,c,q,22,a[3]),c=p(c,d,e,f,r,7,a[4]),f=p(f,c,d,e,s,12,a[5]),e=p(e,f,c,d,t,17,a[6]),d=p(d,e,f,c,u,22,a[7]),
|
||||
c=p(c,d,e,f,v,7,a[8]),f=p(f,c,d,e,x,12,a[9]),e=p(e,f,c,d,y,17,a[10]),d=p(d,e,f,c,z,22,a[11]),c=p(c,d,e,f,A,7,a[12]),f=p(f,c,d,e,B,12,a[13]),e=p(e,f,c,d,C,17,a[14]),d=p(d,e,f,c,D,22,a[15]),c=m(c,d,e,f,w,5,a[16]),f=m(f,c,d,e,t,9,a[17]),e=m(e,f,c,d,z,14,a[18]),d=m(d,e,f,c,h,20,a[19]),c=m(c,d,e,f,s,5,a[20]),f=m(f,c,d,e,y,9,a[21]),e=m(e,f,c,d,D,14,a[22]),d=m(d,e,f,c,r,20,a[23]),c=m(c,d,e,f,x,5,a[24]),f=m(f,c,d,e,C,9,a[25]),e=m(e,f,c,d,q,14,a[26]),d=m(d,e,f,c,v,20,a[27]),c=m(c,d,e,f,B,5,a[28]),f=m(f,c,
|
||||
d,e,j,9,a[29]),e=m(e,f,c,d,u,14,a[30]),d=m(d,e,f,c,A,20,a[31]),c=l(c,d,e,f,s,4,a[32]),f=l(f,c,d,e,v,11,a[33]),e=l(e,f,c,d,z,16,a[34]),d=l(d,e,f,c,C,23,a[35]),c=l(c,d,e,f,w,4,a[36]),f=l(f,c,d,e,r,11,a[37]),e=l(e,f,c,d,u,16,a[38]),d=l(d,e,f,c,y,23,a[39]),c=l(c,d,e,f,B,4,a[40]),f=l(f,c,d,e,h,11,a[41]),e=l(e,f,c,d,q,16,a[42]),d=l(d,e,f,c,t,23,a[43]),c=l(c,d,e,f,x,4,a[44]),f=l(f,c,d,e,A,11,a[45]),e=l(e,f,c,d,D,16,a[46]),d=l(d,e,f,c,j,23,a[47]),c=n(c,d,e,f,h,6,a[48]),f=n(f,c,d,e,u,10,a[49]),e=n(e,f,c,d,
|
||||
C,15,a[50]),d=n(d,e,f,c,s,21,a[51]),c=n(c,d,e,f,A,6,a[52]),f=n(f,c,d,e,q,10,a[53]),e=n(e,f,c,d,y,15,a[54]),d=n(d,e,f,c,w,21,a[55]),c=n(c,d,e,f,v,6,a[56]),f=n(f,c,d,e,D,10,a[57]),e=n(e,f,c,d,t,15,a[58]),d=n(d,e,f,c,B,21,a[59]),c=n(c,d,e,f,r,6,a[60]),f=n(f,c,d,e,z,10,a[61]),e=n(e,f,c,d,j,15,a[62]),d=n(d,e,f,c,x,21,a[63]);b[0]=b[0]+c|0;b[1]=b[1]+d|0;b[2]=b[2]+e|0;b[3]=b[3]+f|0},_doFinalize:function(){var a=this._data,k=a.words,b=8*this._nDataBytes,h=8*a.sigBytes;k[h>>>5]|=128<<24-h%32;var l=s.floor(b/
|
||||
4294967296);k[(h+64>>>9<<4)+15]=(l<<8|l>>>24)&16711935|(l<<24|l>>>8)&4278255360;k[(h+64>>>9<<4)+14]=(b<<8|b>>>24)&16711935|(b<<24|b>>>8)&4278255360;a.sigBytes=4*(k.length+1);this._process();a=this._hash;k=a.words;for(b=0;4>b;b++)h=k[b],k[b]=(h<<8|h>>>24)&16711935|(h<<24|h>>>8)&4278255360;return a},clone:function(){var a=t.clone.call(this);a._hash=this._hash.clone();return a}});r.MD5=t._createHelper(q);r.HmacMD5=t._createHmacHelper(q)})(Math);
|
||||
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
CryptoJS v3.1.2
|
||||
code.google.com/p/crypto-js
|
||||
(c) 2009-2013 by Jeff Mott. All rights reserved.
|
||||
code.google.com/p/crypto-js/wiki/License
|
||||
*/
|
||||
var CryptoJS=CryptoJS||function(g,j){var e={},d=e.lib={},m=function(){},n=d.Base={extend:function(a){m.prototype=this;var c=new m;a&&c.mixIn(a);c.hasOwnProperty("init")||(c.init=function(){c.$super.init.apply(this,arguments)});c.init.prototype=c;c.$super=this;return c},create:function(){var a=this.extend();a.init.apply(a,arguments);return a},init:function(){},mixIn:function(a){for(var c in a)a.hasOwnProperty(c)&&(this[c]=a[c]);a.hasOwnProperty("toString")&&(this.toString=a.toString)},clone:function(){return this.init.prototype.extend(this)}},
|
||||
q=d.WordArray=n.extend({init:function(a,c){a=this.words=a||[];this.sigBytes=c!=j?c:4*a.length},toString:function(a){return(a||l).stringify(this)},concat:function(a){var c=this.words,p=a.words,f=this.sigBytes;a=a.sigBytes;this.clamp();if(f%4)for(var b=0;b<a;b++)c[f+b>>>2]|=(p[b>>>2]>>>24-8*(b%4)&255)<<24-8*((f+b)%4);else if(65535<p.length)for(b=0;b<a;b+=4)c[f+b>>>2]=p[b>>>2];else c.push.apply(c,p);this.sigBytes+=a;return this},clamp:function(){var a=this.words,c=this.sigBytes;a[c>>>2]&=4294967295<<
|
||||
32-8*(c%4);a.length=g.ceil(c/4)},clone:function(){var a=n.clone.call(this);a.words=this.words.slice(0);return a},random:function(a){for(var c=[],b=0;b<a;b+=4)c.push(4294967296*g.random()|0);return new q.init(c,a)}}),b=e.enc={},l=b.Hex={stringify:function(a){var c=a.words;a=a.sigBytes;for(var b=[],f=0;f<a;f++){var d=c[f>>>2]>>>24-8*(f%4)&255;b.push((d>>>4).toString(16));b.push((d&15).toString(16))}return b.join("")},parse:function(a){for(var c=a.length,b=[],f=0;f<c;f+=2)b[f>>>3]|=parseInt(a.substr(f,
|
||||
2),16)<<24-4*(f%8);return new q.init(b,c/2)}},k=b.Latin1={stringify:function(a){var c=a.words;a=a.sigBytes;for(var b=[],f=0;f<a;f++)b.push(String.fromCharCode(c[f>>>2]>>>24-8*(f%4)&255));return b.join("")},parse:function(a){for(var c=a.length,b=[],f=0;f<c;f++)b[f>>>2]|=(a.charCodeAt(f)&255)<<24-8*(f%4);return new q.init(b,c)}},h=b.Utf8={stringify:function(a){try{return decodeURIComponent(escape(k.stringify(a)))}catch(b){throw Error("Malformed UTF-8 data");}},parse:function(a){return k.parse(unescape(encodeURIComponent(a)))}},
|
||||
u=d.BufferedBlockAlgorithm=n.extend({reset:function(){this._data=new q.init;this._nDataBytes=0},_append:function(a){"string"==typeof a&&(a=h.parse(a));this._data.concat(a);this._nDataBytes+=a.sigBytes},_process:function(a){var b=this._data,d=b.words,f=b.sigBytes,l=this.blockSize,e=f/(4*l),e=a?g.ceil(e):g.max((e|0)-this._minBufferSize,0);a=e*l;f=g.min(4*a,f);if(a){for(var h=0;h<a;h+=l)this._doProcessBlock(d,h);h=d.splice(0,a);b.sigBytes-=f}return new q.init(h,f)},clone:function(){var a=n.clone.call(this);
|
||||
a._data=this._data.clone();return a},_minBufferSize:0});d.Hasher=u.extend({cfg:n.extend(),init:function(a){this.cfg=this.cfg.extend(a);this.reset()},reset:function(){u.reset.call(this);this._doReset()},update:function(a){this._append(a);this._process();return this},finalize:function(a){a&&this._append(a);return this._doFinalize()},blockSize:16,_createHelper:function(a){return function(b,d){return(new a.init(d)).finalize(b)}},_createHmacHelper:function(a){return function(b,d){return(new w.HMAC.init(a,
|
||||
d)).finalize(b)}}});var w=e.algo={};return e}(Math);
|
||||
(function(){var g=CryptoJS,j=g.lib,e=j.WordArray,d=j.Hasher,m=[],j=g.algo.SHA1=d.extend({_doReset:function(){this._hash=new e.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(d,e){for(var b=this._hash.words,l=b[0],k=b[1],h=b[2],g=b[3],j=b[4],a=0;80>a;a++){if(16>a)m[a]=d[e+a]|0;else{var c=m[a-3]^m[a-8]^m[a-14]^m[a-16];m[a]=c<<1|c>>>31}c=(l<<5|l>>>27)+j+m[a];c=20>a?c+((k&h|~k&g)+1518500249):40>a?c+((k^h^g)+1859775393):60>a?c+((k&h|k&g|h&g)-1894007588):c+((k^h^
|
||||
g)-899497514);j=g;g=h;h=k<<30|k>>>2;k=l;l=c}b[0]=b[0]+l|0;b[1]=b[1]+k|0;b[2]=b[2]+h|0;b[3]=b[3]+g|0;b[4]=b[4]+j|0},_doFinalize:function(){var d=this._data,e=d.words,b=8*this._nDataBytes,l=8*d.sigBytes;e[l>>>5]|=128<<24-l%32;e[(l+64>>>9<<4)+14]=Math.floor(b/4294967296);e[(l+64>>>9<<4)+15]=b;d.sigBytes=4*e.length;this._process();return this._hash},clone:function(){var e=d.clone.call(this);e._hash=this._hash.clone();return e}});g.SHA1=d._createHelper(j);g.HmacSHA1=d._createHmacHelper(j)})();
|
||||
(function(){var g=CryptoJS,j=g.enc.Utf8;g.algo.HMAC=g.lib.Base.extend({init:function(e,d){e=this._hasher=new e.init;"string"==typeof d&&(d=j.parse(d));var g=e.blockSize,n=4*g;d.sigBytes>n&&(d=e.finalize(d));d.clamp();for(var q=this._oKey=d.clone(),b=this._iKey=d.clone(),l=q.words,k=b.words,h=0;h<g;h++)l[h]^=1549556828,k[h]^=909522486;q.sigBytes=b.sigBytes=n;this.reset()},reset:function(){var e=this._hasher;e.reset();e.update(this._iKey)},update:function(e){this._hasher.update(e);return this},finalize:function(e){var d=
|
||||
this._hasher;e=d.finalize(e);d.reset();return d.finalize(this._oKey.clone().concat(e))}})})();
|
||||
(function(){var g=CryptoJS,j=g.lib,e=j.Base,d=j.WordArray,j=g.algo,m=j.HMAC,n=j.PBKDF2=e.extend({cfg:e.extend({keySize:4,hasher:j.SHA1,iterations:1}),init:function(d){this.cfg=this.cfg.extend(d)},compute:function(e,b){for(var g=this.cfg,k=m.create(g.hasher,e),h=d.create(),j=d.create([1]),n=h.words,a=j.words,c=g.keySize,g=g.iterations;n.length<c;){var p=k.update(b).finalize(j);k.reset();for(var f=p.words,v=f.length,s=p,t=1;t<g;t++){s=k.finalize(s);k.reset();for(var x=s.words,r=0;r<v;r++)f[r]^=x[r]}h.concat(p);
|
||||
a[0]++}h.sigBytes=4*c;return h}});g.PBKDF2=function(d,b,e){return n.create(e).compute(d,b)}})();
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
CryptoJS v3.1.2
|
||||
code.google.com/p/crypto-js
|
||||
(c) 2009-2013 by Jeff Mott. All rights reserved.
|
||||
code.google.com/p/crypto-js/wiki/License
|
||||
*/
|
||||
var CryptoJS=CryptoJS||function(u,p){var d={},l=d.lib={},s=function(){},t=l.Base={extend:function(a){s.prototype=this;var c=new s;a&&c.mixIn(a);c.hasOwnProperty("init")||(c.init=function(){c.$super.init.apply(this,arguments)});c.init.prototype=c;c.$super=this;return c},create:function(){var a=this.extend();a.init.apply(a,arguments);return a},init:function(){},mixIn:function(a){for(var c in a)a.hasOwnProperty(c)&&(this[c]=a[c]);a.hasOwnProperty("toString")&&(this.toString=a.toString)},clone:function(){return this.init.prototype.extend(this)}},
|
||||
r=l.WordArray=t.extend({init:function(a,c){a=this.words=a||[];this.sigBytes=c!=p?c:4*a.length},toString:function(a){return(a||v).stringify(this)},concat:function(a){var c=this.words,e=a.words,j=this.sigBytes;a=a.sigBytes;this.clamp();if(j%4)for(var k=0;k<a;k++)c[j+k>>>2]|=(e[k>>>2]>>>24-8*(k%4)&255)<<24-8*((j+k)%4);else if(65535<e.length)for(k=0;k<a;k+=4)c[j+k>>>2]=e[k>>>2];else c.push.apply(c,e);this.sigBytes+=a;return this},clamp:function(){var a=this.words,c=this.sigBytes;a[c>>>2]&=4294967295<<
|
||||
32-8*(c%4);a.length=u.ceil(c/4)},clone:function(){var a=t.clone.call(this);a.words=this.words.slice(0);return a},random:function(a){for(var c=[],e=0;e<a;e+=4)c.push(4294967296*u.random()|0);return new r.init(c,a)}}),w=d.enc={},v=w.Hex={stringify:function(a){var c=a.words;a=a.sigBytes;for(var e=[],j=0;j<a;j++){var k=c[j>>>2]>>>24-8*(j%4)&255;e.push((k>>>4).toString(16));e.push((k&15).toString(16))}return e.join("")},parse:function(a){for(var c=a.length,e=[],j=0;j<c;j+=2)e[j>>>3]|=parseInt(a.substr(j,
|
||||
2),16)<<24-4*(j%8);return new r.init(e,c/2)}},b=w.Latin1={stringify:function(a){var c=a.words;a=a.sigBytes;for(var e=[],j=0;j<a;j++)e.push(String.fromCharCode(c[j>>>2]>>>24-8*(j%4)&255));return e.join("")},parse:function(a){for(var c=a.length,e=[],j=0;j<c;j++)e[j>>>2]|=(a.charCodeAt(j)&255)<<24-8*(j%4);return new r.init(e,c)}},x=w.Utf8={stringify:function(a){try{return decodeURIComponent(escape(b.stringify(a)))}catch(c){throw Error("Malformed UTF-8 data");}},parse:function(a){return b.parse(unescape(encodeURIComponent(a)))}},
|
||||
q=l.BufferedBlockAlgorithm=t.extend({reset:function(){this._data=new r.init;this._nDataBytes=0},_append:function(a){"string"==typeof a&&(a=x.parse(a));this._data.concat(a);this._nDataBytes+=a.sigBytes},_process:function(a){var c=this._data,e=c.words,j=c.sigBytes,k=this.blockSize,b=j/(4*k),b=a?u.ceil(b):u.max((b|0)-this._minBufferSize,0);a=b*k;j=u.min(4*a,j);if(a){for(var q=0;q<a;q+=k)this._doProcessBlock(e,q);q=e.splice(0,a);c.sigBytes-=j}return new r.init(q,j)},clone:function(){var a=t.clone.call(this);
|
||||
a._data=this._data.clone();return a},_minBufferSize:0});l.Hasher=q.extend({cfg:t.extend(),init:function(a){this.cfg=this.cfg.extend(a);this.reset()},reset:function(){q.reset.call(this);this._doReset()},update:function(a){this._append(a);this._process();return this},finalize:function(a){a&&this._append(a);return this._doFinalize()},blockSize:16,_createHelper:function(a){return function(b,e){return(new a.init(e)).finalize(b)}},_createHmacHelper:function(a){return function(b,e){return(new n.HMAC.init(a,
|
||||
e)).finalize(b)}}});var n=d.algo={};return d}(Math);
|
||||
(function(){var u=CryptoJS,p=u.lib.WordArray;u.enc.Base64={stringify:function(d){var l=d.words,p=d.sigBytes,t=this._map;d.clamp();d=[];for(var r=0;r<p;r+=3)for(var w=(l[r>>>2]>>>24-8*(r%4)&255)<<16|(l[r+1>>>2]>>>24-8*((r+1)%4)&255)<<8|l[r+2>>>2]>>>24-8*((r+2)%4)&255,v=0;4>v&&r+0.75*v<p;v++)d.push(t.charAt(w>>>6*(3-v)&63));if(l=t.charAt(64))for(;d.length%4;)d.push(l);return d.join("")},parse:function(d){var l=d.length,s=this._map,t=s.charAt(64);t&&(t=d.indexOf(t),-1!=t&&(l=t));for(var t=[],r=0,w=0;w<
|
||||
l;w++)if(w%4){var v=s.indexOf(d.charAt(w-1))<<2*(w%4),b=s.indexOf(d.charAt(w))>>>6-2*(w%4);t[r>>>2]|=(v|b)<<24-8*(r%4);r++}return p.create(t,r)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}})();
|
||||
(function(u){function p(b,n,a,c,e,j,k){b=b+(n&a|~n&c)+e+k;return(b<<j|b>>>32-j)+n}function d(b,n,a,c,e,j,k){b=b+(n&c|a&~c)+e+k;return(b<<j|b>>>32-j)+n}function l(b,n,a,c,e,j,k){b=b+(n^a^c)+e+k;return(b<<j|b>>>32-j)+n}function s(b,n,a,c,e,j,k){b=b+(a^(n|~c))+e+k;return(b<<j|b>>>32-j)+n}for(var t=CryptoJS,r=t.lib,w=r.WordArray,v=r.Hasher,r=t.algo,b=[],x=0;64>x;x++)b[x]=4294967296*u.abs(u.sin(x+1))|0;r=r.MD5=v.extend({_doReset:function(){this._hash=new w.init([1732584193,4023233417,2562383102,271733878])},
|
||||
_doProcessBlock:function(q,n){for(var a=0;16>a;a++){var c=n+a,e=q[c];q[c]=(e<<8|e>>>24)&16711935|(e<<24|e>>>8)&4278255360}var a=this._hash.words,c=q[n+0],e=q[n+1],j=q[n+2],k=q[n+3],z=q[n+4],r=q[n+5],t=q[n+6],w=q[n+7],v=q[n+8],A=q[n+9],B=q[n+10],C=q[n+11],u=q[n+12],D=q[n+13],E=q[n+14],x=q[n+15],f=a[0],m=a[1],g=a[2],h=a[3],f=p(f,m,g,h,c,7,b[0]),h=p(h,f,m,g,e,12,b[1]),g=p(g,h,f,m,j,17,b[2]),m=p(m,g,h,f,k,22,b[3]),f=p(f,m,g,h,z,7,b[4]),h=p(h,f,m,g,r,12,b[5]),g=p(g,h,f,m,t,17,b[6]),m=p(m,g,h,f,w,22,b[7]),
|
||||
f=p(f,m,g,h,v,7,b[8]),h=p(h,f,m,g,A,12,b[9]),g=p(g,h,f,m,B,17,b[10]),m=p(m,g,h,f,C,22,b[11]),f=p(f,m,g,h,u,7,b[12]),h=p(h,f,m,g,D,12,b[13]),g=p(g,h,f,m,E,17,b[14]),m=p(m,g,h,f,x,22,b[15]),f=d(f,m,g,h,e,5,b[16]),h=d(h,f,m,g,t,9,b[17]),g=d(g,h,f,m,C,14,b[18]),m=d(m,g,h,f,c,20,b[19]),f=d(f,m,g,h,r,5,b[20]),h=d(h,f,m,g,B,9,b[21]),g=d(g,h,f,m,x,14,b[22]),m=d(m,g,h,f,z,20,b[23]),f=d(f,m,g,h,A,5,b[24]),h=d(h,f,m,g,E,9,b[25]),g=d(g,h,f,m,k,14,b[26]),m=d(m,g,h,f,v,20,b[27]),f=d(f,m,g,h,D,5,b[28]),h=d(h,f,
|
||||
m,g,j,9,b[29]),g=d(g,h,f,m,w,14,b[30]),m=d(m,g,h,f,u,20,b[31]),f=l(f,m,g,h,r,4,b[32]),h=l(h,f,m,g,v,11,b[33]),g=l(g,h,f,m,C,16,b[34]),m=l(m,g,h,f,E,23,b[35]),f=l(f,m,g,h,e,4,b[36]),h=l(h,f,m,g,z,11,b[37]),g=l(g,h,f,m,w,16,b[38]),m=l(m,g,h,f,B,23,b[39]),f=l(f,m,g,h,D,4,b[40]),h=l(h,f,m,g,c,11,b[41]),g=l(g,h,f,m,k,16,b[42]),m=l(m,g,h,f,t,23,b[43]),f=l(f,m,g,h,A,4,b[44]),h=l(h,f,m,g,u,11,b[45]),g=l(g,h,f,m,x,16,b[46]),m=l(m,g,h,f,j,23,b[47]),f=s(f,m,g,h,c,6,b[48]),h=s(h,f,m,g,w,10,b[49]),g=s(g,h,f,m,
|
||||
E,15,b[50]),m=s(m,g,h,f,r,21,b[51]),f=s(f,m,g,h,u,6,b[52]),h=s(h,f,m,g,k,10,b[53]),g=s(g,h,f,m,B,15,b[54]),m=s(m,g,h,f,e,21,b[55]),f=s(f,m,g,h,v,6,b[56]),h=s(h,f,m,g,x,10,b[57]),g=s(g,h,f,m,t,15,b[58]),m=s(m,g,h,f,D,21,b[59]),f=s(f,m,g,h,z,6,b[60]),h=s(h,f,m,g,C,10,b[61]),g=s(g,h,f,m,j,15,b[62]),m=s(m,g,h,f,A,21,b[63]);a[0]=a[0]+f|0;a[1]=a[1]+m|0;a[2]=a[2]+g|0;a[3]=a[3]+h|0},_doFinalize:function(){var b=this._data,n=b.words,a=8*this._nDataBytes,c=8*b.sigBytes;n[c>>>5]|=128<<24-c%32;var e=u.floor(a/
|
||||
4294967296);n[(c+64>>>9<<4)+15]=(e<<8|e>>>24)&16711935|(e<<24|e>>>8)&4278255360;n[(c+64>>>9<<4)+14]=(a<<8|a>>>24)&16711935|(a<<24|a>>>8)&4278255360;b.sigBytes=4*(n.length+1);this._process();b=this._hash;n=b.words;for(a=0;4>a;a++)c=n[a],n[a]=(c<<8|c>>>24)&16711935|(c<<24|c>>>8)&4278255360;return b},clone:function(){var b=v.clone.call(this);b._hash=this._hash.clone();return b}});t.MD5=v._createHelper(r);t.HmacMD5=v._createHmacHelper(r)})(Math);
|
||||
(function(){var u=CryptoJS,p=u.lib,d=p.Base,l=p.WordArray,p=u.algo,s=p.EvpKDF=d.extend({cfg:d.extend({keySize:4,hasher:p.MD5,iterations:1}),init:function(d){this.cfg=this.cfg.extend(d)},compute:function(d,r){for(var p=this.cfg,s=p.hasher.create(),b=l.create(),u=b.words,q=p.keySize,p=p.iterations;u.length<q;){n&&s.update(n);var n=s.update(d).finalize(r);s.reset();for(var a=1;a<p;a++)n=s.finalize(n),s.reset();b.concat(n)}b.sigBytes=4*q;return b}});u.EvpKDF=function(d,l,p){return s.create(p).compute(d,
|
||||
l)}})();
|
||||
CryptoJS.lib.Cipher||function(u){var p=CryptoJS,d=p.lib,l=d.Base,s=d.WordArray,t=d.BufferedBlockAlgorithm,r=p.enc.Base64,w=p.algo.EvpKDF,v=d.Cipher=t.extend({cfg:l.extend(),createEncryptor:function(e,a){return this.create(this._ENC_XFORM_MODE,e,a)},createDecryptor:function(e,a){return this.create(this._DEC_XFORM_MODE,e,a)},init:function(e,a,b){this.cfg=this.cfg.extend(b);this._xformMode=e;this._key=a;this.reset()},reset:function(){t.reset.call(this);this._doReset()},process:function(e){this._append(e);return this._process()},
|
||||
finalize:function(e){e&&this._append(e);return this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(e){return{encrypt:function(b,k,d){return("string"==typeof k?c:a).encrypt(e,b,k,d)},decrypt:function(b,k,d){return("string"==typeof k?c:a).decrypt(e,b,k,d)}}}});d.StreamCipher=v.extend({_doFinalize:function(){return this._process(!0)},blockSize:1});var b=p.mode={},x=function(e,a,b){var c=this._iv;c?this._iv=u:c=this._prevBlock;for(var d=0;d<b;d++)e[a+d]^=
|
||||
c[d]},q=(d.BlockCipherMode=l.extend({createEncryptor:function(e,a){return this.Encryptor.create(e,a)},createDecryptor:function(e,a){return this.Decryptor.create(e,a)},init:function(e,a){this._cipher=e;this._iv=a}})).extend();q.Encryptor=q.extend({processBlock:function(e,a){var b=this._cipher,c=b.blockSize;x.call(this,e,a,c);b.encryptBlock(e,a);this._prevBlock=e.slice(a,a+c)}});q.Decryptor=q.extend({processBlock:function(e,a){var b=this._cipher,c=b.blockSize,d=e.slice(a,a+c);b.decryptBlock(e,a);x.call(this,
|
||||
e,a,c);this._prevBlock=d}});b=b.CBC=q;q=(p.pad={}).Pkcs7={pad:function(a,b){for(var c=4*b,c=c-a.sigBytes%c,d=c<<24|c<<16|c<<8|c,l=[],n=0;n<c;n+=4)l.push(d);c=s.create(l,c);a.concat(c)},unpad:function(a){a.sigBytes-=a.words[a.sigBytes-1>>>2]&255}};d.BlockCipher=v.extend({cfg:v.cfg.extend({mode:b,padding:q}),reset:function(){v.reset.call(this);var a=this.cfg,b=a.iv,a=a.mode;if(this._xformMode==this._ENC_XFORM_MODE)var c=a.createEncryptor;else c=a.createDecryptor,this._minBufferSize=1;this._mode=c.call(a,
|
||||
this,b&&b.words)},_doProcessBlock:function(a,b){this._mode.processBlock(a,b)},_doFinalize:function(){var a=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){a.pad(this._data,this.blockSize);var b=this._process(!0)}else b=this._process(!0),a.unpad(b);return b},blockSize:4});var n=d.CipherParams=l.extend({init:function(a){this.mixIn(a)},toString:function(a){return(a||this.formatter).stringify(this)}}),b=(p.format={}).OpenSSL={stringify:function(a){var b=a.ciphertext;a=a.salt;return(a?s.create([1398893684,
|
||||
1701076831]).concat(a).concat(b):b).toString(r)},parse:function(a){a=r.parse(a);var b=a.words;if(1398893684==b[0]&&1701076831==b[1]){var c=s.create(b.slice(2,4));b.splice(0,4);a.sigBytes-=16}return n.create({ciphertext:a,salt:c})}},a=d.SerializableCipher=l.extend({cfg:l.extend({format:b}),encrypt:function(a,b,c,d){d=this.cfg.extend(d);var l=a.createEncryptor(c,d);b=l.finalize(b);l=l.cfg;return n.create({ciphertext:b,key:c,iv:l.iv,algorithm:a,mode:l.mode,padding:l.padding,blockSize:a.blockSize,formatter:d.format})},
|
||||
decrypt:function(a,b,c,d){d=this.cfg.extend(d);b=this._parse(b,d.format);return a.createDecryptor(c,d).finalize(b.ciphertext)},_parse:function(a,b){return"string"==typeof a?b.parse(a,this):a}}),p=(p.kdf={}).OpenSSL={execute:function(a,b,c,d){d||(d=s.random(8));a=w.create({keySize:b+c}).compute(a,d);c=s.create(a.words.slice(b),4*c);a.sigBytes=4*b;return n.create({key:a,iv:c,salt:d})}},c=d.PasswordBasedCipher=a.extend({cfg:a.cfg.extend({kdf:p}),encrypt:function(b,c,d,l){l=this.cfg.extend(l);d=l.kdf.execute(d,
|
||||
b.keySize,b.ivSize);l.iv=d.iv;b=a.encrypt.call(this,b,c,d.key,l);b.mixIn(d);return b},decrypt:function(b,c,d,l){l=this.cfg.extend(l);c=this._parse(c,l.format);d=l.kdf.execute(d,b.keySize,b.ivSize,c.salt);l.iv=d.iv;return a.decrypt.call(this,b,c,d.key,l)}})}();
|
||||
(function(){for(var u=CryptoJS,p=u.lib.BlockCipher,d=u.algo,l=[],s=[],t=[],r=[],w=[],v=[],b=[],x=[],q=[],n=[],a=[],c=0;256>c;c++)a[c]=128>c?c<<1:c<<1^283;for(var e=0,j=0,c=0;256>c;c++){var k=j^j<<1^j<<2^j<<3^j<<4,k=k>>>8^k&255^99;l[e]=k;s[k]=e;var z=a[e],F=a[z],G=a[F],y=257*a[k]^16843008*k;t[e]=y<<24|y>>>8;r[e]=y<<16|y>>>16;w[e]=y<<8|y>>>24;v[e]=y;y=16843009*G^65537*F^257*z^16843008*e;b[k]=y<<24|y>>>8;x[k]=y<<16|y>>>16;q[k]=y<<8|y>>>24;n[k]=y;e?(e=z^a[a[a[G^z]]],j^=a[a[j]]):e=j=1}var H=[0,1,2,4,8,
|
||||
16,32,64,128,27,54],d=d.AES=p.extend({_doReset:function(){for(var a=this._key,c=a.words,d=a.sigBytes/4,a=4*((this._nRounds=d+6)+1),e=this._keySchedule=[],j=0;j<a;j++)if(j<d)e[j]=c[j];else{var k=e[j-1];j%d?6<d&&4==j%d&&(k=l[k>>>24]<<24|l[k>>>16&255]<<16|l[k>>>8&255]<<8|l[k&255]):(k=k<<8|k>>>24,k=l[k>>>24]<<24|l[k>>>16&255]<<16|l[k>>>8&255]<<8|l[k&255],k^=H[j/d|0]<<24);e[j]=e[j-d]^k}c=this._invKeySchedule=[];for(d=0;d<a;d++)j=a-d,k=d%4?e[j]:e[j-4],c[d]=4>d||4>=j?k:b[l[k>>>24]]^x[l[k>>>16&255]]^q[l[k>>>
|
||||
8&255]]^n[l[k&255]]},encryptBlock:function(a,b){this._doCryptBlock(a,b,this._keySchedule,t,r,w,v,l)},decryptBlock:function(a,c){var d=a[c+1];a[c+1]=a[c+3];a[c+3]=d;this._doCryptBlock(a,c,this._invKeySchedule,b,x,q,n,s);d=a[c+1];a[c+1]=a[c+3];a[c+3]=d},_doCryptBlock:function(a,b,c,d,e,j,l,f){for(var m=this._nRounds,g=a[b]^c[0],h=a[b+1]^c[1],k=a[b+2]^c[2],n=a[b+3]^c[3],p=4,r=1;r<m;r++)var q=d[g>>>24]^e[h>>>16&255]^j[k>>>8&255]^l[n&255]^c[p++],s=d[h>>>24]^e[k>>>16&255]^j[n>>>8&255]^l[g&255]^c[p++],t=
|
||||
d[k>>>24]^e[n>>>16&255]^j[g>>>8&255]^l[h&255]^c[p++],n=d[n>>>24]^e[g>>>16&255]^j[h>>>8&255]^l[k&255]^c[p++],g=q,h=s,k=t;q=(f[g>>>24]<<24|f[h>>>16&255]<<16|f[k>>>8&255]<<8|f[n&255])^c[p++];s=(f[h>>>24]<<24|f[k>>>16&255]<<16|f[n>>>8&255]<<8|f[g&255])^c[p++];t=(f[k>>>24]<<24|f[n>>>16&255]<<16|f[g>>>8&255]<<8|f[h&255])^c[p++];n=(f[n>>>24]<<24|f[g>>>16&255]<<16|f[h>>>8&255]<<8|f[k&255])^c[p++];a[b]=q;a[b+1]=s;a[b+2]=t;a[b+3]=n},keySize:8});u.AES=p._createHelper(d)})();
|
||||
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
CryptoJS v3.1.2
|
||||
code.google.com/p/crypto-js
|
||||
(c) 2009-2013 by Jeff Mott. All rights reserved.
|
||||
code.google.com/p/crypto-js/wiki/License
|
||||
*/
|
||||
(function(){var h=CryptoJS,j=h.lib.WordArray;h.enc.Base64={stringify:function(b){var e=b.words,f=b.sigBytes,c=this._map;b.clamp();b=[];for(var a=0;a<f;a+=3)for(var d=(e[a>>>2]>>>24-8*(a%4)&255)<<16|(e[a+1>>>2]>>>24-8*((a+1)%4)&255)<<8|e[a+2>>>2]>>>24-8*((a+2)%4)&255,g=0;4>g&&a+0.75*g<f;g++)b.push(c.charAt(d>>>6*(3-g)&63));if(e=c.charAt(64))for(;b.length%4;)b.push(e);return b.join("")},parse:function(b){var e=b.length,f=this._map,c=f.charAt(64);c&&(c=b.indexOf(c),-1!=c&&(e=c));for(var c=[],a=0,d=0;d<
|
||||
e;d++)if(d%4){var g=f.indexOf(b.charAt(d-1))<<2*(d%4),h=f.indexOf(b.charAt(d))>>>6-2*(d%4);c[a>>>2]|=(g|h)<<24-8*(a%4);a++}return j.create(c,a)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}})();
|
||||
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
CryptoJS v3.1.2
|
||||
code.google.com/p/crypto-js
|
||||
(c) 2009-2013 by Jeff Mott. All rights reserved.
|
||||
code.google.com/p/crypto-js/wiki/License
|
||||
*/
|
||||
var CryptoJS=CryptoJS||function(q,r){var k={},g=k.lib={},p=function(){},t=g.Base={extend:function(b){p.prototype=this;var j=new p;b&&j.mixIn(b);j.hasOwnProperty("init")||(j.init=function(){j.$super.init.apply(this,arguments)});j.init.prototype=j;j.$super=this;return j},create:function(){var b=this.extend();b.init.apply(b,arguments);return b},init:function(){},mixIn:function(b){for(var j in b)b.hasOwnProperty(j)&&(this[j]=b[j]);b.hasOwnProperty("toString")&&(this.toString=b.toString)},clone:function(){return this.init.prototype.extend(this)}},
|
||||
n=g.WordArray=t.extend({init:function(b,j){b=this.words=b||[];this.sigBytes=j!=r?j:4*b.length},toString:function(b){return(b||u).stringify(this)},concat:function(b){var j=this.words,a=b.words,l=this.sigBytes;b=b.sigBytes;this.clamp();if(l%4)for(var h=0;h<b;h++)j[l+h>>>2]|=(a[h>>>2]>>>24-8*(h%4)&255)<<24-8*((l+h)%4);else if(65535<a.length)for(h=0;h<b;h+=4)j[l+h>>>2]=a[h>>>2];else j.push.apply(j,a);this.sigBytes+=b;return this},clamp:function(){var b=this.words,j=this.sigBytes;b[j>>>2]&=4294967295<<
|
||||
32-8*(j%4);b.length=q.ceil(j/4)},clone:function(){var b=t.clone.call(this);b.words=this.words.slice(0);return b},random:function(b){for(var j=[],a=0;a<b;a+=4)j.push(4294967296*q.random()|0);return new n.init(j,b)}}),v=k.enc={},u=v.Hex={stringify:function(b){var a=b.words;b=b.sigBytes;for(var h=[],l=0;l<b;l++){var m=a[l>>>2]>>>24-8*(l%4)&255;h.push((m>>>4).toString(16));h.push((m&15).toString(16))}return h.join("")},parse:function(b){for(var a=b.length,h=[],l=0;l<a;l+=2)h[l>>>3]|=parseInt(b.substr(l,
|
||||
2),16)<<24-4*(l%8);return new n.init(h,a/2)}},a=v.Latin1={stringify:function(b){var a=b.words;b=b.sigBytes;for(var h=[],l=0;l<b;l++)h.push(String.fromCharCode(a[l>>>2]>>>24-8*(l%4)&255));return h.join("")},parse:function(b){for(var a=b.length,h=[],l=0;l<a;l++)h[l>>>2]|=(b.charCodeAt(l)&255)<<24-8*(l%4);return new n.init(h,a)}},s=v.Utf8={stringify:function(b){try{return decodeURIComponent(escape(a.stringify(b)))}catch(h){throw Error("Malformed UTF-8 data");}},parse:function(b){return a.parse(unescape(encodeURIComponent(b)))}},
|
||||
h=g.BufferedBlockAlgorithm=t.extend({reset:function(){this._data=new n.init;this._nDataBytes=0},_append:function(b){"string"==typeof b&&(b=s.parse(b));this._data.concat(b);this._nDataBytes+=b.sigBytes},_process:function(b){var a=this._data,h=a.words,l=a.sigBytes,m=this.blockSize,k=l/(4*m),k=b?q.ceil(k):q.max((k|0)-this._minBufferSize,0);b=k*m;l=q.min(4*b,l);if(b){for(var g=0;g<b;g+=m)this._doProcessBlock(h,g);g=h.splice(0,b);a.sigBytes-=l}return new n.init(g,l)},clone:function(){var b=t.clone.call(this);
|
||||
b._data=this._data.clone();return b},_minBufferSize:0});g.Hasher=h.extend({cfg:t.extend(),init:function(b){this.cfg=this.cfg.extend(b);this.reset()},reset:function(){h.reset.call(this);this._doReset()},update:function(b){this._append(b);this._process();return this},finalize:function(b){b&&this._append(b);return this._doFinalize()},blockSize:16,_createHelper:function(b){return function(a,h){return(new b.init(h)).finalize(a)}},_createHmacHelper:function(b){return function(a,h){return(new m.HMAC.init(b,
|
||||
h)).finalize(a)}}});var m=k.algo={};return k}(Math);
|
||||
(function(q){function r(a,m,b,j,g,l,k){a=a+(m&b|~m&j)+g+k;return(a<<l|a>>>32-l)+m}function k(a,m,b,j,g,l,k){a=a+(m&j|b&~j)+g+k;return(a<<l|a>>>32-l)+m}function g(a,m,b,j,g,l,k){a=a+(m^b^j)+g+k;return(a<<l|a>>>32-l)+m}function p(a,g,b,j,k,l,p){a=a+(b^(g|~j))+k+p;return(a<<l|a>>>32-l)+g}for(var t=CryptoJS,n=t.lib,v=n.WordArray,u=n.Hasher,n=t.algo,a=[],s=0;64>s;s++)a[s]=4294967296*q.abs(q.sin(s+1))|0;n=n.MD5=u.extend({_doReset:function(){this._hash=new v.init([1732584193,4023233417,2562383102,271733878])},
|
||||
_doProcessBlock:function(h,m){for(var b=0;16>b;b++){var j=m+b,n=h[j];h[j]=(n<<8|n>>>24)&16711935|(n<<24|n>>>8)&4278255360}var b=this._hash.words,j=h[m+0],n=h[m+1],l=h[m+2],q=h[m+3],t=h[m+4],s=h[m+5],u=h[m+6],v=h[m+7],w=h[m+8],x=h[m+9],y=h[m+10],z=h[m+11],A=h[m+12],B=h[m+13],C=h[m+14],D=h[m+15],c=b[0],d=b[1],e=b[2],f=b[3],c=r(c,d,e,f,j,7,a[0]),f=r(f,c,d,e,n,12,a[1]),e=r(e,f,c,d,l,17,a[2]),d=r(d,e,f,c,q,22,a[3]),c=r(c,d,e,f,t,7,a[4]),f=r(f,c,d,e,s,12,a[5]),e=r(e,f,c,d,u,17,a[6]),d=r(d,e,f,c,v,22,a[7]),
|
||||
c=r(c,d,e,f,w,7,a[8]),f=r(f,c,d,e,x,12,a[9]),e=r(e,f,c,d,y,17,a[10]),d=r(d,e,f,c,z,22,a[11]),c=r(c,d,e,f,A,7,a[12]),f=r(f,c,d,e,B,12,a[13]),e=r(e,f,c,d,C,17,a[14]),d=r(d,e,f,c,D,22,a[15]),c=k(c,d,e,f,n,5,a[16]),f=k(f,c,d,e,u,9,a[17]),e=k(e,f,c,d,z,14,a[18]),d=k(d,e,f,c,j,20,a[19]),c=k(c,d,e,f,s,5,a[20]),f=k(f,c,d,e,y,9,a[21]),e=k(e,f,c,d,D,14,a[22]),d=k(d,e,f,c,t,20,a[23]),c=k(c,d,e,f,x,5,a[24]),f=k(f,c,d,e,C,9,a[25]),e=k(e,f,c,d,q,14,a[26]),d=k(d,e,f,c,w,20,a[27]),c=k(c,d,e,f,B,5,a[28]),f=k(f,c,
|
||||
d,e,l,9,a[29]),e=k(e,f,c,d,v,14,a[30]),d=k(d,e,f,c,A,20,a[31]),c=g(c,d,e,f,s,4,a[32]),f=g(f,c,d,e,w,11,a[33]),e=g(e,f,c,d,z,16,a[34]),d=g(d,e,f,c,C,23,a[35]),c=g(c,d,e,f,n,4,a[36]),f=g(f,c,d,e,t,11,a[37]),e=g(e,f,c,d,v,16,a[38]),d=g(d,e,f,c,y,23,a[39]),c=g(c,d,e,f,B,4,a[40]),f=g(f,c,d,e,j,11,a[41]),e=g(e,f,c,d,q,16,a[42]),d=g(d,e,f,c,u,23,a[43]),c=g(c,d,e,f,x,4,a[44]),f=g(f,c,d,e,A,11,a[45]),e=g(e,f,c,d,D,16,a[46]),d=g(d,e,f,c,l,23,a[47]),c=p(c,d,e,f,j,6,a[48]),f=p(f,c,d,e,v,10,a[49]),e=p(e,f,c,d,
|
||||
C,15,a[50]),d=p(d,e,f,c,s,21,a[51]),c=p(c,d,e,f,A,6,a[52]),f=p(f,c,d,e,q,10,a[53]),e=p(e,f,c,d,y,15,a[54]),d=p(d,e,f,c,n,21,a[55]),c=p(c,d,e,f,w,6,a[56]),f=p(f,c,d,e,D,10,a[57]),e=p(e,f,c,d,u,15,a[58]),d=p(d,e,f,c,B,21,a[59]),c=p(c,d,e,f,t,6,a[60]),f=p(f,c,d,e,z,10,a[61]),e=p(e,f,c,d,l,15,a[62]),d=p(d,e,f,c,x,21,a[63]);b[0]=b[0]+c|0;b[1]=b[1]+d|0;b[2]=b[2]+e|0;b[3]=b[3]+f|0},_doFinalize:function(){var a=this._data,g=a.words,b=8*this._nDataBytes,j=8*a.sigBytes;g[j>>>5]|=128<<24-j%32;var k=q.floor(b/
|
||||
4294967296);g[(j+64>>>9<<4)+15]=(k<<8|k>>>24)&16711935|(k<<24|k>>>8)&4278255360;g[(j+64>>>9<<4)+14]=(b<<8|b>>>24)&16711935|(b<<24|b>>>8)&4278255360;a.sigBytes=4*(g.length+1);this._process();a=this._hash;g=a.words;for(b=0;4>b;b++)j=g[b],g[b]=(j<<8|j>>>24)&16711935|(j<<24|j>>>8)&4278255360;return a},clone:function(){var a=u.clone.call(this);a._hash=this._hash.clone();return a}});t.MD5=u._createHelper(n);t.HmacMD5=u._createHmacHelper(n)})(Math);
|
||||
(function(){var q=CryptoJS,r=q.enc.Utf8;q.algo.HMAC=q.lib.Base.extend({init:function(k,g){k=this._hasher=new k.init;"string"==typeof g&&(g=r.parse(g));var p=k.blockSize,q=4*p;g.sigBytes>q&&(g=k.finalize(g));g.clamp();for(var n=this._oKey=g.clone(),v=this._iKey=g.clone(),u=n.words,a=v.words,s=0;s<p;s++)u[s]^=1549556828,a[s]^=909522486;n.sigBytes=v.sigBytes=q;this.reset()},reset:function(){var k=this._hasher;k.reset();k.update(this._iKey)},update:function(k){this._hasher.update(k);return this},finalize:function(k){var g=
|
||||
this._hasher;k=g.finalize(k);g.reset();return g.finalize(this._oKey.clone().concat(k))}})})();
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
CryptoJS v3.1.2
|
||||
code.google.com/p/crypto-js
|
||||
(c) 2009-2013 by Jeff Mott. All rights reserved.
|
||||
code.google.com/p/crypto-js/wiki/License
|
||||
*/
|
||||
/*
|
||||
|
||||
(c) 2012 by C?dric Mesnil. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
var CryptoJS=CryptoJS||function(h,j){var c={},e=c.lib={},A=function(){},l=e.Base={extend:function(a){A.prototype=this;var d=new A;a&&d.mixIn(a);d.hasOwnProperty("init")||(d.init=function(){d.$super.init.apply(this,arguments)});d.init.prototype=d;d.$super=this;return d},create:function(){var a=this.extend();a.init.apply(a,arguments);return a},init:function(){},mixIn:function(a){for(var d in a)a.hasOwnProperty(d)&&(this[d]=a[d]);a.hasOwnProperty("toString")&&(this.toString=a.toString)},clone:function(){return this.init.prototype.extend(this)}},
|
||||
m=e.WordArray=l.extend({init:function(a,d){a=this.words=a||[];this.sigBytes=d!=j?d:4*a.length},toString:function(a){return(a||x).stringify(this)},concat:function(a){var d=this.words,B=a.words,f=this.sigBytes;a=a.sigBytes;this.clamp();if(f%4)for(var b=0;b<a;b++)d[f+b>>>2]|=(B[b>>>2]>>>24-8*(b%4)&255)<<24-8*((f+b)%4);else if(65535<B.length)for(b=0;b<a;b+=4)d[f+b>>>2]=B[b>>>2];else d.push.apply(d,B);this.sigBytes+=a;return this},clamp:function(){var a=this.words,d=this.sigBytes;a[d>>>2]&=4294967295<<
|
||||
32-8*(d%4);a.length=h.ceil(d/4)},clone:function(){var a=l.clone.call(this);a.words=this.words.slice(0);return a},random:function(a){for(var d=[],b=0;b<a;b+=4)d.push(4294967296*h.random()|0);return new m.init(d,a)}}),v=c.enc={},x=v.Hex={stringify:function(a){var d=a.words;a=a.sigBytes;for(var b=[],f=0;f<a;f++){var c=d[f>>>2]>>>24-8*(f%4)&255;b.push((c>>>4).toString(16));b.push((c&15).toString(16))}return b.join("")},parse:function(a){for(var d=a.length,b=[],f=0;f<d;f+=2)b[f>>>3]|=parseInt(a.substr(f,
|
||||
2),16)<<24-4*(f%8);return new m.init(b,d/2)}},w=v.Latin1={stringify:function(a){var d=a.words;a=a.sigBytes;for(var b=[],f=0;f<a;f++)b.push(String.fromCharCode(d[f>>>2]>>>24-8*(f%4)&255));return b.join("")},parse:function(a){for(var b=a.length,c=[],f=0;f<b;f++)c[f>>>2]|=(a.charCodeAt(f)&255)<<24-8*(f%4);return new m.init(c,b)}},k=v.Utf8={stringify:function(a){try{return decodeURIComponent(escape(w.stringify(a)))}catch(b){throw Error("Malformed UTF-8 data");}},parse:function(a){return w.parse(unescape(encodeURIComponent(a)))}},
|
||||
u=e.BufferedBlockAlgorithm=l.extend({reset:function(){this._data=new m.init;this._nDataBytes=0},_append:function(a){"string"==typeof a&&(a=k.parse(a));this._data.concat(a);this._nDataBytes+=a.sigBytes},_process:function(a){var b=this._data,c=b.words,f=b.sigBytes,e=this.blockSize,k=f/(4*e),k=a?h.ceil(k):h.max((k|0)-this._minBufferSize,0);a=k*e;f=h.min(4*a,f);if(a){for(var u=0;u<a;u+=e)this._doProcessBlock(c,u);u=c.splice(0,a);b.sigBytes-=f}return new m.init(u,f)},clone:function(){var a=l.clone.call(this);
|
||||
a._data=this._data.clone();return a},_minBufferSize:0});e.Hasher=u.extend({cfg:l.extend(),init:function(a){this.cfg=this.cfg.extend(a);this.reset()},reset:function(){u.reset.call(this);this._doReset()},update:function(a){this._append(a);this._process();return this},finalize:function(a){a&&this._append(a);return this._doFinalize()},blockSize:16,_createHelper:function(a){return function(b,c){return(new a.init(c)).finalize(b)}},_createHmacHelper:function(a){return function(d,c){return(new b.HMAC.init(a,
|
||||
c)).finalize(d)}}});var b=c.algo={};return c}(Math);
|
||||
(function(){var h=CryptoJS,j=h.lib,c=j.WordArray,e=j.Hasher,j=h.algo,A=c.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),l=c.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),m=c.create([11,14,15,12,
|
||||
5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),v=c.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),x=c.create([0,1518500249,1859775393,2400959708,2840853838]),w=c.create([1352829926,1548603684,1836072691,
|
||||
2053994217,0]),j=j.RIPEMD160=e.extend({_doReset:function(){this._hash=c.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(c,e){for(var b=0;16>b;b++){var a=e+b,d=c[a];c[a]=(d<<8|d>>>24)&16711935|(d<<24|d>>>8)&4278255360}var a=this._hash.words,d=x.words,h=w.words,f=A.words,j=l.words,E=m.words,F=v.words,C,n,p,q,y,D,r,s,t,z;D=C=a[0];r=n=a[1];s=p=a[2];t=q=a[3];z=y=a[4];for(var g,b=0;80>b;b+=1)g=C+c[e+f[b]]|0,g=16>b?g+((n^p^q)+d[0]):32>b?g+((n&p|~n&q)+d[1]):48>b?
|
||||
g+(((n|~p)^q)+d[2]):64>b?g+((n&q|p&~q)+d[3]):g+((n^(p|~q))+d[4]),g|=0,g=g<<E[b]|g>>>32-E[b],g=g+y|0,C=y,y=q,q=p<<10|p>>>22,p=n,n=g,g=D+c[e+j[b]]|0,g=16>b?g+((r^(s|~t))+h[0]):32>b?g+((r&t|s&~t)+h[1]):48>b?g+(((r|~s)^t)+h[2]):64>b?g+((r&s|~r&t)+h[3]):g+((r^s^t)+h[4]),g|=0,g=g<<F[b]|g>>>32-F[b],g=g+z|0,D=z,z=t,t=s<<10|s>>>22,s=r,r=g;g=a[1]+p+t|0;a[1]=a[2]+q+z|0;a[2]=a[3]+y+D|0;a[3]=a[4]+C+r|0;a[4]=a[0]+n+s|0;a[0]=g},_doFinalize:function(){var c=this._data,e=c.words,b=8*this._nDataBytes,a=8*c.sigBytes;
|
||||
e[a>>>5]|=128<<24-a%32;e[(a+64>>>9<<4)+14]=(b<<8|b>>>24)&16711935|(b<<24|b>>>8)&4278255360;c.sigBytes=4*(e.length+1);this._process();c=this._hash;e=c.words;for(b=0;5>b;b++)a=e[b],e[b]=(a<<8|a>>>24)&16711935|(a<<24|a>>>8)&4278255360;return c},clone:function(){var c=e.clone.call(this);c._hash=this._hash.clone();return c}});h.RIPEMD160=e._createHelper(j);h.HmacRIPEMD160=e._createHmacHelper(j)})(Math);
|
||||
(function(){var h=CryptoJS,j=h.enc.Utf8;h.algo.HMAC=h.lib.Base.extend({init:function(c,e){c=this._hasher=new c.init;"string"==typeof e&&(e=j.parse(e));var h=c.blockSize,l=4*h;e.sigBytes>l&&(e=c.finalize(e));e.clamp();for(var m=this._oKey=e.clone(),v=this._iKey=e.clone(),x=m.words,w=v.words,k=0;k<h;k++)x[k]^=1549556828,w[k]^=909522486;m.sigBytes=v.sigBytes=l;this.reset()},reset:function(){var c=this._hasher;c.reset();c.update(this._iKey)},update:function(c){this._hasher.update(c);return this},finalize:function(c){var e=
|
||||
this._hasher;c=e.finalize(c);e.reset();return e.finalize(this._oKey.clone().concat(c))}})})();
|
||||
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
CryptoJS v3.1.2
|
||||
code.google.com/p/crypto-js
|
||||
(c) 2009-2013 by Jeff Mott. All rights reserved.
|
||||
code.google.com/p/crypto-js/wiki/License
|
||||
*/
|
||||
var CryptoJS=CryptoJS||function(g,l){var e={},d=e.lib={},m=function(){},k=d.Base={extend:function(a){m.prototype=this;var c=new m;a&&c.mixIn(a);c.hasOwnProperty("init")||(c.init=function(){c.$super.init.apply(this,arguments)});c.init.prototype=c;c.$super=this;return c},create:function(){var a=this.extend();a.init.apply(a,arguments);return a},init:function(){},mixIn:function(a){for(var c in a)a.hasOwnProperty(c)&&(this[c]=a[c]);a.hasOwnProperty("toString")&&(this.toString=a.toString)},clone:function(){return this.init.prototype.extend(this)}},
|
||||
p=d.WordArray=k.extend({init:function(a,c){a=this.words=a||[];this.sigBytes=c!=l?c:4*a.length},toString:function(a){return(a||n).stringify(this)},concat:function(a){var c=this.words,q=a.words,f=this.sigBytes;a=a.sigBytes;this.clamp();if(f%4)for(var b=0;b<a;b++)c[f+b>>>2]|=(q[b>>>2]>>>24-8*(b%4)&255)<<24-8*((f+b)%4);else if(65535<q.length)for(b=0;b<a;b+=4)c[f+b>>>2]=q[b>>>2];else c.push.apply(c,q);this.sigBytes+=a;return this},clamp:function(){var a=this.words,c=this.sigBytes;a[c>>>2]&=4294967295<<
|
||||
32-8*(c%4);a.length=g.ceil(c/4)},clone:function(){var a=k.clone.call(this);a.words=this.words.slice(0);return a},random:function(a){for(var c=[],b=0;b<a;b+=4)c.push(4294967296*g.random()|0);return new p.init(c,a)}}),b=e.enc={},n=b.Hex={stringify:function(a){var c=a.words;a=a.sigBytes;for(var b=[],f=0;f<a;f++){var d=c[f>>>2]>>>24-8*(f%4)&255;b.push((d>>>4).toString(16));b.push((d&15).toString(16))}return b.join("")},parse:function(a){for(var c=a.length,b=[],f=0;f<c;f+=2)b[f>>>3]|=parseInt(a.substr(f,
|
||||
2),16)<<24-4*(f%8);return new p.init(b,c/2)}},j=b.Latin1={stringify:function(a){var c=a.words;a=a.sigBytes;for(var b=[],f=0;f<a;f++)b.push(String.fromCharCode(c[f>>>2]>>>24-8*(f%4)&255));return b.join("")},parse:function(a){for(var c=a.length,b=[],f=0;f<c;f++)b[f>>>2]|=(a.charCodeAt(f)&255)<<24-8*(f%4);return new p.init(b,c)}},h=b.Utf8={stringify:function(a){try{return decodeURIComponent(escape(j.stringify(a)))}catch(c){throw Error("Malformed UTF-8 data");}},parse:function(a){return j.parse(unescape(encodeURIComponent(a)))}},
|
||||
r=d.BufferedBlockAlgorithm=k.extend({reset:function(){this._data=new p.init;this._nDataBytes=0},_append:function(a){"string"==typeof a&&(a=h.parse(a));this._data.concat(a);this._nDataBytes+=a.sigBytes},_process:function(a){var c=this._data,b=c.words,f=c.sigBytes,d=this.blockSize,e=f/(4*d),e=a?g.ceil(e):g.max((e|0)-this._minBufferSize,0);a=e*d;f=g.min(4*a,f);if(a){for(var k=0;k<a;k+=d)this._doProcessBlock(b,k);k=b.splice(0,a);c.sigBytes-=f}return new p.init(k,f)},clone:function(){var a=k.clone.call(this);
|
||||
a._data=this._data.clone();return a},_minBufferSize:0});d.Hasher=r.extend({cfg:k.extend(),init:function(a){this.cfg=this.cfg.extend(a);this.reset()},reset:function(){r.reset.call(this);this._doReset()},update:function(a){this._append(a);this._process();return this},finalize:function(a){a&&this._append(a);return this._doFinalize()},blockSize:16,_createHelper:function(a){return function(b,d){return(new a.init(d)).finalize(b)}},_createHmacHelper:function(a){return function(b,d){return(new s.HMAC.init(a,
|
||||
d)).finalize(b)}}});var s=e.algo={};return e}(Math);
|
||||
(function(){var g=CryptoJS,l=g.lib,e=l.WordArray,d=l.Hasher,m=[],l=g.algo.SHA1=d.extend({_doReset:function(){this._hash=new e.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(d,e){for(var b=this._hash.words,n=b[0],j=b[1],h=b[2],g=b[3],l=b[4],a=0;80>a;a++){if(16>a)m[a]=d[e+a]|0;else{var c=m[a-3]^m[a-8]^m[a-14]^m[a-16];m[a]=c<<1|c>>>31}c=(n<<5|n>>>27)+l+m[a];c=20>a?c+((j&h|~j&g)+1518500249):40>a?c+((j^h^g)+1859775393):60>a?c+((j&h|j&g|h&g)-1894007588):c+((j^h^
|
||||
g)-899497514);l=g;g=h;h=j<<30|j>>>2;j=n;n=c}b[0]=b[0]+n|0;b[1]=b[1]+j|0;b[2]=b[2]+h|0;b[3]=b[3]+g|0;b[4]=b[4]+l|0},_doFinalize:function(){var d=this._data,e=d.words,b=8*this._nDataBytes,g=8*d.sigBytes;e[g>>>5]|=128<<24-g%32;e[(g+64>>>9<<4)+14]=Math.floor(b/4294967296);e[(g+64>>>9<<4)+15]=b;d.sigBytes=4*e.length;this._process();return this._hash},clone:function(){var e=d.clone.call(this);e._hash=this._hash.clone();return e}});g.SHA1=d._createHelper(l);g.HmacSHA1=d._createHmacHelper(l)})();
|
||||
(function(){var g=CryptoJS,l=g.enc.Utf8;g.algo.HMAC=g.lib.Base.extend({init:function(e,d){e=this._hasher=new e.init;"string"==typeof d&&(d=l.parse(d));var g=e.blockSize,k=4*g;d.sigBytes>k&&(d=e.finalize(d));d.clamp();for(var p=this._oKey=d.clone(),b=this._iKey=d.clone(),n=p.words,j=b.words,h=0;h<g;h++)n[h]^=1549556828,j[h]^=909522486;p.sigBytes=b.sigBytes=k;this.reset()},reset:function(){var e=this._hasher;e.reset();e.update(this._iKey)},update:function(e){this._hasher.update(e);return this},finalize:function(e){var d=
|
||||
this._hasher;e=d.finalize(e);d.reset();return d.finalize(this._oKey.clone().concat(e))}})})();
|
||||
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
CryptoJS v3.1.2
|
||||
code.google.com/p/crypto-js
|
||||
(c) 2009-2013 by Jeff Mott. All rights reserved.
|
||||
code.google.com/p/crypto-js/wiki/License
|
||||
*/
|
||||
var CryptoJS=CryptoJS||function(j,k){var c={},e=c.lib={},p=function(){},m=e.Base={extend:function(a){p.prototype=this;var d=new p;a&&d.mixIn(a);d.hasOwnProperty("init")||(d.init=function(){d.$super.init.apply(this,arguments)});d.init.prototype=d;d.$super=this;return d},create:function(){var a=this.extend();a.init.apply(a,arguments);return a},init:function(){},mixIn:function(a){for(var d in a)a.hasOwnProperty(d)&&(this[d]=a[d]);a.hasOwnProperty("toString")&&(this.toString=a.toString)},clone:function(){return this.init.prototype.extend(this)}},
|
||||
r=e.WordArray=m.extend({init:function(a,d){a=this.words=a||[];this.sigBytes=d!=k?d:4*a.length},toString:function(a){return(a||l).stringify(this)},concat:function(a){var d=this.words,f=a.words,b=this.sigBytes;a=a.sigBytes;this.clamp();if(b%4)for(var g=0;g<a;g++)d[b+g>>>2]|=(f[g>>>2]>>>24-8*(g%4)&255)<<24-8*((b+g)%4);else if(65535<f.length)for(g=0;g<a;g+=4)d[b+g>>>2]=f[g>>>2];else d.push.apply(d,f);this.sigBytes+=a;return this},clamp:function(){var a=this.words,d=this.sigBytes;a[d>>>2]&=4294967295<<
|
||||
32-8*(d%4);a.length=j.ceil(d/4)},clone:function(){var a=m.clone.call(this);a.words=this.words.slice(0);return a},random:function(a){for(var d=[],f=0;f<a;f+=4)d.push(4294967296*j.random()|0);return new r.init(d,a)}}),s=c.enc={},l=s.Hex={stringify:function(a){var d=a.words;a=a.sigBytes;for(var f=[],b=0;b<a;b++){var g=d[b>>>2]>>>24-8*(b%4)&255;f.push((g>>>4).toString(16));f.push((g&15).toString(16))}return f.join("")},parse:function(a){for(var d=a.length,f=[],b=0;b<d;b+=2)f[b>>>3]|=parseInt(a.substr(b,
|
||||
2),16)<<24-4*(b%8);return new r.init(f,d/2)}},n=s.Latin1={stringify:function(a){var d=a.words;a=a.sigBytes;for(var f=[],b=0;b<a;b++)f.push(String.fromCharCode(d[b>>>2]>>>24-8*(b%4)&255));return f.join("")},parse:function(a){for(var d=a.length,f=[],b=0;b<d;b++)f[b>>>2]|=(a.charCodeAt(b)&255)<<24-8*(b%4);return new r.init(f,d)}},h=s.Utf8={stringify:function(a){try{return decodeURIComponent(escape(n.stringify(a)))}catch(d){throw Error("Malformed UTF-8 data");}},parse:function(a){return n.parse(unescape(encodeURIComponent(a)))}},
|
||||
u=e.BufferedBlockAlgorithm=m.extend({reset:function(){this._data=new r.init;this._nDataBytes=0},_append:function(a){"string"==typeof a&&(a=h.parse(a));this._data.concat(a);this._nDataBytes+=a.sigBytes},_process:function(a){var d=this._data,f=d.words,b=d.sigBytes,g=this.blockSize,c=b/(4*g),c=a?j.ceil(c):j.max((c|0)-this._minBufferSize,0);a=c*g;b=j.min(4*a,b);if(a){for(var e=0;e<a;e+=g)this._doProcessBlock(f,e);e=f.splice(0,a);d.sigBytes-=b}return new r.init(e,b)},clone:function(){var a=m.clone.call(this);
|
||||
a._data=this._data.clone();return a},_minBufferSize:0});e.Hasher=u.extend({cfg:m.extend(),init:function(a){this.cfg=this.cfg.extend(a);this.reset()},reset:function(){u.reset.call(this);this._doReset()},update:function(a){this._append(a);this._process();return this},finalize:function(a){a&&this._append(a);return this._doFinalize()},blockSize:16,_createHelper:function(a){return function(d,f){return(new a.init(f)).finalize(d)}},_createHmacHelper:function(a){return function(d,f){return(new t.HMAC.init(a,
|
||||
f)).finalize(d)}}});var t=c.algo={};return c}(Math);
|
||||
(function(j){for(var k=CryptoJS,c=k.lib,e=c.WordArray,p=c.Hasher,c=k.algo,m=[],r=[],s=function(a){return 4294967296*(a-(a|0))|0},l=2,n=0;64>n;){var h;a:{h=l;for(var u=j.sqrt(h),t=2;t<=u;t++)if(!(h%t)){h=!1;break a}h=!0}h&&(8>n&&(m[n]=s(j.pow(l,0.5))),r[n]=s(j.pow(l,1/3)),n++);l++}var a=[],c=c.SHA256=p.extend({_doReset:function(){this._hash=new e.init(m.slice(0))},_doProcessBlock:function(d,f){for(var b=this._hash.words,g=b[0],c=b[1],e=b[2],j=b[3],h=b[4],p=b[5],m=b[6],n=b[7],q=0;64>q;q++){if(16>q)a[q]=
|
||||
d[f+q]|0;else{var k=a[q-15],l=a[q-2];a[q]=((k<<25|k>>>7)^(k<<14|k>>>18)^k>>>3)+a[q-7]+((l<<15|l>>>17)^(l<<13|l>>>19)^l>>>10)+a[q-16]}k=n+((h<<26|h>>>6)^(h<<21|h>>>11)^(h<<7|h>>>25))+(h&p^~h&m)+r[q]+a[q];l=((g<<30|g>>>2)^(g<<19|g>>>13)^(g<<10|g>>>22))+(g&c^g&e^c&e);n=m;m=p;p=h;h=j+k|0;j=e;e=c;c=g;g=k+l|0}b[0]=b[0]+g|0;b[1]=b[1]+c|0;b[2]=b[2]+e|0;b[3]=b[3]+j|0;b[4]=b[4]+h|0;b[5]=b[5]+p|0;b[6]=b[6]+m|0;b[7]=b[7]+n|0},_doFinalize:function(){var a=this._data,c=a.words,b=8*this._nDataBytes,e=8*a.sigBytes;
|
||||
c[e>>>5]|=128<<24-e%32;c[(e+64>>>9<<4)+14]=j.floor(b/4294967296);c[(e+64>>>9<<4)+15]=b;a.sigBytes=4*c.length;this._process();return this._hash},clone:function(){var a=p.clone.call(this);a._hash=this._hash.clone();return a}});k.SHA256=p._createHelper(c);k.HmacSHA256=p._createHmacHelper(c)})(Math);
|
||||
(function(){var j=CryptoJS,k=j.lib.WordArray,c=j.algo,e=c.SHA256,c=c.SHA224=e.extend({_doReset:function(){this._hash=new k.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var c=e._doFinalize.call(this);c.sigBytes-=4;return c}});j.SHA224=e._createHelper(c);j.HmacSHA224=e._createHmacHelper(c)})();
|
||||
(function(){var j=CryptoJS,k=j.enc.Utf8;j.algo.HMAC=j.lib.Base.extend({init:function(c,e){c=this._hasher=new c.init;"string"==typeof e&&(e=k.parse(e));var j=c.blockSize,m=4*j;e.sigBytes>m&&(e=c.finalize(e));e.clamp();for(var r=this._oKey=e.clone(),s=this._iKey=e.clone(),l=r.words,n=s.words,h=0;h<j;h++)l[h]^=1549556828,n[h]^=909522486;r.sigBytes=s.sigBytes=m;this.reset()},reset:function(){var c=this._hasher;c.reset();c.update(this._iKey)},update:function(c){this._hasher.update(c);return this},finalize:function(c){var e=
|
||||
this._hasher;c=e.finalize(c);e.reset();return e.finalize(this._oKey.clone().concat(c))}})})();
|
||||
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
CryptoJS v3.1.2
|
||||
code.google.com/p/crypto-js
|
||||
(c) 2009-2013 by Jeff Mott. All rights reserved.
|
||||
code.google.com/p/crypto-js/wiki/License
|
||||
*/
|
||||
var CryptoJS=CryptoJS||function(h,s){var f={},g=f.lib={},q=function(){},m=g.Base={extend:function(a){q.prototype=this;var c=new q;a&&c.mixIn(a);c.hasOwnProperty("init")||(c.init=function(){c.$super.init.apply(this,arguments)});c.init.prototype=c;c.$super=this;return c},create:function(){var a=this.extend();a.init.apply(a,arguments);return a},init:function(){},mixIn:function(a){for(var c in a)a.hasOwnProperty(c)&&(this[c]=a[c]);a.hasOwnProperty("toString")&&(this.toString=a.toString)},clone:function(){return this.init.prototype.extend(this)}},
|
||||
r=g.WordArray=m.extend({init:function(a,c){a=this.words=a||[];this.sigBytes=c!=s?c:4*a.length},toString:function(a){return(a||k).stringify(this)},concat:function(a){var c=this.words,d=a.words,b=this.sigBytes;a=a.sigBytes;this.clamp();if(b%4)for(var e=0;e<a;e++)c[b+e>>>2]|=(d[e>>>2]>>>24-8*(e%4)&255)<<24-8*((b+e)%4);else if(65535<d.length)for(e=0;e<a;e+=4)c[b+e>>>2]=d[e>>>2];else c.push.apply(c,d);this.sigBytes+=a;return this},clamp:function(){var a=this.words,c=this.sigBytes;a[c>>>2]&=4294967295<<
|
||||
32-8*(c%4);a.length=h.ceil(c/4)},clone:function(){var a=m.clone.call(this);a.words=this.words.slice(0);return a},random:function(a){for(var c=[],d=0;d<a;d+=4)c.push(4294967296*h.random()|0);return new r.init(c,a)}}),l=f.enc={},k=l.Hex={stringify:function(a){var c=a.words;a=a.sigBytes;for(var d=[],b=0;b<a;b++){var e=c[b>>>2]>>>24-8*(b%4)&255;d.push((e>>>4).toString(16));d.push((e&15).toString(16))}return d.join("")},parse:function(a){for(var c=a.length,d=[],b=0;b<c;b+=2)d[b>>>3]|=parseInt(a.substr(b,
|
||||
2),16)<<24-4*(b%8);return new r.init(d,c/2)}},n=l.Latin1={stringify:function(a){var c=a.words;a=a.sigBytes;for(var d=[],b=0;b<a;b++)d.push(String.fromCharCode(c[b>>>2]>>>24-8*(b%4)&255));return d.join("")},parse:function(a){for(var c=a.length,d=[],b=0;b<c;b++)d[b>>>2]|=(a.charCodeAt(b)&255)<<24-8*(b%4);return new r.init(d,c)}},j=l.Utf8={stringify:function(a){try{return decodeURIComponent(escape(n.stringify(a)))}catch(c){throw Error("Malformed UTF-8 data");}},parse:function(a){return n.parse(unescape(encodeURIComponent(a)))}},
|
||||
u=g.BufferedBlockAlgorithm=m.extend({reset:function(){this._data=new r.init;this._nDataBytes=0},_append:function(a){"string"==typeof a&&(a=j.parse(a));this._data.concat(a);this._nDataBytes+=a.sigBytes},_process:function(a){var c=this._data,d=c.words,b=c.sigBytes,e=this.blockSize,f=b/(4*e),f=a?h.ceil(f):h.max((f|0)-this._minBufferSize,0);a=f*e;b=h.min(4*a,b);if(a){for(var g=0;g<a;g+=e)this._doProcessBlock(d,g);g=d.splice(0,a);c.sigBytes-=b}return new r.init(g,b)},clone:function(){var a=m.clone.call(this);
|
||||
a._data=this._data.clone();return a},_minBufferSize:0});g.Hasher=u.extend({cfg:m.extend(),init:function(a){this.cfg=this.cfg.extend(a);this.reset()},reset:function(){u.reset.call(this);this._doReset()},update:function(a){this._append(a);this._process();return this},finalize:function(a){a&&this._append(a);return this._doFinalize()},blockSize:16,_createHelper:function(a){return function(c,d){return(new a.init(d)).finalize(c)}},_createHmacHelper:function(a){return function(c,d){return(new t.HMAC.init(a,
|
||||
d)).finalize(c)}}});var t=f.algo={};return f}(Math);
|
||||
(function(h){for(var s=CryptoJS,f=s.lib,g=f.WordArray,q=f.Hasher,f=s.algo,m=[],r=[],l=function(a){return 4294967296*(a-(a|0))|0},k=2,n=0;64>n;){var j;a:{j=k;for(var u=h.sqrt(j),t=2;t<=u;t++)if(!(j%t)){j=!1;break a}j=!0}j&&(8>n&&(m[n]=l(h.pow(k,0.5))),r[n]=l(h.pow(k,1/3)),n++);k++}var a=[],f=f.SHA256=q.extend({_doReset:function(){this._hash=new g.init(m.slice(0))},_doProcessBlock:function(c,d){for(var b=this._hash.words,e=b[0],f=b[1],g=b[2],j=b[3],h=b[4],m=b[5],n=b[6],q=b[7],p=0;64>p;p++){if(16>p)a[p]=
|
||||
c[d+p]|0;else{var k=a[p-15],l=a[p-2];a[p]=((k<<25|k>>>7)^(k<<14|k>>>18)^k>>>3)+a[p-7]+((l<<15|l>>>17)^(l<<13|l>>>19)^l>>>10)+a[p-16]}k=q+((h<<26|h>>>6)^(h<<21|h>>>11)^(h<<7|h>>>25))+(h&m^~h&n)+r[p]+a[p];l=((e<<30|e>>>2)^(e<<19|e>>>13)^(e<<10|e>>>22))+(e&f^e&g^f&g);q=n;n=m;m=h;h=j+k|0;j=g;g=f;f=e;e=k+l|0}b[0]=b[0]+e|0;b[1]=b[1]+f|0;b[2]=b[2]+g|0;b[3]=b[3]+j|0;b[4]=b[4]+h|0;b[5]=b[5]+m|0;b[6]=b[6]+n|0;b[7]=b[7]+q|0},_doFinalize:function(){var a=this._data,d=a.words,b=8*this._nDataBytes,e=8*a.sigBytes;
|
||||
d[e>>>5]|=128<<24-e%32;d[(e+64>>>9<<4)+14]=h.floor(b/4294967296);d[(e+64>>>9<<4)+15]=b;a.sigBytes=4*d.length;this._process();return this._hash},clone:function(){var a=q.clone.call(this);a._hash=this._hash.clone();return a}});s.SHA256=q._createHelper(f);s.HmacSHA256=q._createHmacHelper(f)})(Math);
|
||||
(function(){var h=CryptoJS,s=h.enc.Utf8;h.algo.HMAC=h.lib.Base.extend({init:function(f,g){f=this._hasher=new f.init;"string"==typeof g&&(g=s.parse(g));var h=f.blockSize,m=4*h;g.sigBytes>m&&(g=f.finalize(g));g.clamp();for(var r=this._oKey=g.clone(),l=this._iKey=g.clone(),k=r.words,n=l.words,j=0;j<h;j++)k[j]^=1549556828,n[j]^=909522486;r.sigBytes=l.sigBytes=m;this.reset()},reset:function(){var f=this._hasher;f.reset();f.update(this._iKey)},update:function(f){this._hasher.update(f);return this},finalize:function(f){var g=
|
||||
this._hasher;f=g.finalize(f);g.reset();return g.finalize(this._oKey.clone().concat(f))}})})();
|
||||
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
CryptoJS v3.1.2
|
||||
code.google.com/p/crypto-js
|
||||
(c) 2009-2013 by Jeff Mott. All rights reserved.
|
||||
code.google.com/p/crypto-js/wiki/License
|
||||
*/
|
||||
var CryptoJS=CryptoJS||function(q,f){var c={},d=c.lib={},v=function(){},s=d.Base={extend:function(a){v.prototype=this;var b=new v;a&&b.mixIn(a);b.hasOwnProperty("init")||(b.init=function(){b.$super.init.apply(this,arguments)});b.init.prototype=b;b.$super=this;return b},create:function(){var a=this.extend();a.init.apply(a,arguments);return a},init:function(){},mixIn:function(a){for(var b in a)a.hasOwnProperty(b)&&(this[b]=a[b]);a.hasOwnProperty("toString")&&(this.toString=a.toString)},clone:function(){return this.init.prototype.extend(this)}},
|
||||
t=d.WordArray=s.extend({init:function(a,b){a=this.words=a||[];this.sigBytes=b!=f?b:4*a.length},toString:function(a){return(a||r).stringify(this)},concat:function(a){var b=this.words,e=a.words,j=this.sigBytes;a=a.sigBytes;this.clamp();if(j%4)for(var p=0;p<a;p++)b[j+p>>>2]|=(e[p>>>2]>>>24-8*(p%4)&255)<<24-8*((j+p)%4);else if(65535<e.length)for(p=0;p<a;p+=4)b[j+p>>>2]=e[p>>>2];else b.push.apply(b,e);this.sigBytes+=a;return this},clamp:function(){var a=this.words,b=this.sigBytes;a[b>>>2]&=4294967295<<
|
||||
32-8*(b%4);a.length=q.ceil(b/4)},clone:function(){var a=s.clone.call(this);a.words=this.words.slice(0);return a},random:function(a){for(var b=[],e=0;e<a;e+=4)b.push(4294967296*q.random()|0);return new t.init(b,a)}}),w=c.enc={},r=w.Hex={stringify:function(a){var b=a.words;a=a.sigBytes;for(var e=[],j=0;j<a;j++){var p=b[j>>>2]>>>24-8*(j%4)&255;e.push((p>>>4).toString(16));e.push((p&15).toString(16))}return e.join("")},parse:function(a){for(var b=a.length,e=[],j=0;j<b;j+=2)e[j>>>3]|=parseInt(a.substr(j,
|
||||
2),16)<<24-4*(j%8);return new t.init(e,b/2)}},g=w.Latin1={stringify:function(a){var b=a.words;a=a.sigBytes;for(var e=[],j=0;j<a;j++)e.push(String.fromCharCode(b[j>>>2]>>>24-8*(j%4)&255));return e.join("")},parse:function(a){for(var b=a.length,e=[],j=0;j<b;j++)e[j>>>2]|=(a.charCodeAt(j)&255)<<24-8*(j%4);return new t.init(e,b)}},n=w.Utf8={stringify:function(a){try{return decodeURIComponent(escape(g.stringify(a)))}catch(b){throw Error("Malformed UTF-8 data");}},parse:function(a){return g.parse(unescape(encodeURIComponent(a)))}},
|
||||
u=d.BufferedBlockAlgorithm=s.extend({reset:function(){this._data=new t.init;this._nDataBytes=0},_append:function(a){"string"==typeof a&&(a=n.parse(a));this._data.concat(a);this._nDataBytes+=a.sigBytes},_process:function(a){var b=this._data,e=b.words,j=b.sigBytes,p=this.blockSize,c=j/(4*p),c=a?q.ceil(c):q.max((c|0)-this._minBufferSize,0);a=c*p;j=q.min(4*a,j);if(a){for(var g=0;g<a;g+=p)this._doProcessBlock(e,g);g=e.splice(0,a);b.sigBytes-=j}return new t.init(g,j)},clone:function(){var a=s.clone.call(this);
|
||||
a._data=this._data.clone();return a},_minBufferSize:0});d.Hasher=u.extend({cfg:s.extend(),init:function(a){this.cfg=this.cfg.extend(a);this.reset()},reset:function(){u.reset.call(this);this._doReset()},update:function(a){this._append(a);this._process();return this},finalize:function(a){a&&this._append(a);return this._doFinalize()},blockSize:16,_createHelper:function(a){return function(b,e){return(new a.init(e)).finalize(b)}},_createHmacHelper:function(a){return function(b,e){return(new x.HMAC.init(a,
|
||||
e)).finalize(b)}}});var x=c.algo={};return c}(Math);
|
||||
(function(q){var f=CryptoJS,c=f.lib,d=c.Base,v=c.WordArray,f=f.x64={};f.Word=d.extend({init:function(c,d){this.high=c;this.low=d}});f.WordArray=d.extend({init:function(c,d){c=this.words=c||[];this.sigBytes=d!=q?d:8*c.length},toX32:function(){for(var c=this.words,d=c.length,f=[],r=0;r<d;r++){var g=c[r];f.push(g.high);f.push(g.low)}return v.create(f,this.sigBytes)},clone:function(){for(var c=d.clone.call(this),f=c.words=this.words.slice(0),q=f.length,r=0;r<q;r++)f[r]=f[r].clone();return c}})})();
|
||||
(function(q){for(var f=CryptoJS,c=f.lib,d=c.WordArray,v=c.Hasher,s=f.x64.Word,c=f.algo,t=[],w=[],r=[],g=1,n=0,u=0;24>u;u++){t[g+5*n]=(u+1)*(u+2)/2%64;var x=(2*g+3*n)%5,g=n%5,n=x}for(g=0;5>g;g++)for(n=0;5>n;n++)w[g+5*n]=n+5*((2*g+3*n)%5);g=1;for(n=0;24>n;n++){for(var a=x=u=0;7>a;a++){if(g&1){var b=(1<<a)-1;32>b?x^=1<<b:u^=1<<b-32}g=g&128?g<<1^113:g<<1}r[n]=s.create(u,x)}for(var e=[],g=0;25>g;g++)e[g]=s.create();c=c.SHA3=v.extend({cfg:v.cfg.extend({outputLength:512}),_doReset:function(){for(var a=this._state=
|
||||
[],b=0;25>b;b++)a[b]=new s.init;this.blockSize=(1600-2*this.cfg.outputLength)/32},_doProcessBlock:function(a,b){for(var c=this._state,g=this.blockSize/2,k=0;k<g;k++){var d=a[b+2*k],l=a[b+2*k+1],d=(d<<8|d>>>24)&16711935|(d<<24|d>>>8)&4278255360,l=(l<<8|l>>>24)&16711935|(l<<24|l>>>8)&4278255360,h=c[k];h.high^=l;h.low^=d}for(g=0;24>g;g++){for(k=0;5>k;k++){for(var f=d=0,m=0;5>m;m++)h=c[k+5*m],d^=h.high,f^=h.low;h=e[k];h.high=d;h.low=f}for(k=0;5>k;k++){h=e[(k+4)%5];d=e[(k+1)%5];l=d.high;m=d.low;d=h.high^
|
||||
(l<<1|m>>>31);f=h.low^(m<<1|l>>>31);for(m=0;5>m;m++)h=c[k+5*m],h.high^=d,h.low^=f}for(l=1;25>l;l++)h=c[l],k=h.high,h=h.low,m=t[l],32>m?(d=k<<m|h>>>32-m,f=h<<m|k>>>32-m):(d=h<<m-32|k>>>64-m,f=k<<m-32|h>>>64-m),h=e[w[l]],h.high=d,h.low=f;h=e[0];k=c[0];h.high=k.high;h.low=k.low;for(k=0;5>k;k++)for(m=0;5>m;m++)l=k+5*m,h=c[l],d=e[l],l=e[(k+1)%5+5*m],f=e[(k+2)%5+5*m],h.high=d.high^~l.high&f.high,h.low=d.low^~l.low&f.low;h=c[0];k=r[g];h.high^=k.high;h.low^=k.low}},_doFinalize:function(){var a=this._data,
|
||||
b=a.words,c=8*a.sigBytes,e=32*this.blockSize;b[c>>>5]|=1<<24-c%32;b[(q.ceil((c+1)/e)*e>>>5)-1]|=128;a.sigBytes=4*b.length;this._process();for(var a=this._state,b=this.cfg.outputLength/8,c=b/8,e=[],g=0;g<c;g++){var f=a[g],l=f.high,f=f.low,l=(l<<8|l>>>24)&16711935|(l<<24|l>>>8)&4278255360,f=(f<<8|f>>>24)&16711935|(f<<24|f>>>8)&4278255360;e.push(f);e.push(l)}return new d.init(e,b)},clone:function(){for(var a=v.clone.call(this),b=a._state=this._state.slice(0),c=0;25>c;c++)b[c]=b[c].clone();return a}});
|
||||
f.SHA3=v._createHelper(c);f.HmacSHA3=v._createHmacHelper(c)})(Math);
|
||||
(function(){var q=CryptoJS,f=q.enc.Utf8;q.algo.HMAC=q.lib.Base.extend({init:function(c,d){c=this._hasher=new c.init;"string"==typeof d&&(d=f.parse(d));var q=c.blockSize,s=4*q;d.sigBytes>s&&(d=c.finalize(d));d.clamp();for(var t=this._oKey=d.clone(),w=this._iKey=d.clone(),r=t.words,g=w.words,n=0;n<q;n++)r[n]^=1549556828,g[n]^=909522486;t.sigBytes=w.sigBytes=s;this.reset()},reset:function(){var c=this._hasher;c.reset();c.update(this._iKey)},update:function(c){this._hasher.update(c);return this},finalize:function(c){var d=
|
||||
this._hasher;c=d.finalize(c);d.reset();return d.finalize(this._oKey.clone().concat(c))}})})();
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
CryptoJS v3.1.2
|
||||
code.google.com/p/crypto-js
|
||||
(c) 2009-2013 by Jeff Mott. All rights reserved.
|
||||
code.google.com/p/crypto-js/wiki/License
|
||||
*/
|
||||
var CryptoJS=CryptoJS||function(a,d){var c={},b=c.lib={},f=function(){},l=b.Base={extend:function(a){f.prototype=this;var g=new f;a&&g.mixIn(a);g.hasOwnProperty("init")||(g.init=function(){g.$super.init.apply(this,arguments)});g.init.prototype=g;g.$super=this;return g},create:function(){var a=this.extend();a.init.apply(a,arguments);return a},init:function(){},mixIn:function(a){for(var g in a)a.hasOwnProperty(g)&&(this[g]=a[g]);a.hasOwnProperty("toString")&&(this.toString=a.toString)},clone:function(){return this.init.prototype.extend(this)}},
|
||||
u=b.WordArray=l.extend({init:function(a,g){a=this.words=a||[];this.sigBytes=g!=d?g:4*a.length},toString:function(a){return(a||m).stringify(this)},concat:function(a){var g=this.words,c=a.words,e=this.sigBytes;a=a.sigBytes;this.clamp();if(e%4)for(var b=0;b<a;b++)g[e+b>>>2]|=(c[b>>>2]>>>24-8*(b%4)&255)<<24-8*((e+b)%4);else if(65535<c.length)for(b=0;b<a;b+=4)g[e+b>>>2]=c[b>>>2];else g.push.apply(g,c);this.sigBytes+=a;return this},clamp:function(){var C=this.words,g=this.sigBytes;C[g>>>2]&=4294967295<<
|
||||
32-8*(g%4);C.length=a.ceil(g/4)},clone:function(){var a=l.clone.call(this);a.words=this.words.slice(0);return a},random:function(C){for(var g=[],b=0;b<C;b+=4)g.push(4294967296*a.random()|0);return new u.init(g,C)}}),k=c.enc={},m=k.Hex={stringify:function(a){var g=a.words;a=a.sigBytes;for(var b=[],e=0;e<a;e++){var c=g[e>>>2]>>>24-8*(e%4)&255;b.push((c>>>4).toString(16));b.push((c&15).toString(16))}return b.join("")},parse:function(a){for(var b=a.length,c=[],e=0;e<b;e+=2)c[e>>>3]|=parseInt(a.substr(e,
|
||||
2),16)<<24-4*(e%8);return new u.init(c,b/2)}},x=k.Latin1={stringify:function(a){var b=a.words;a=a.sigBytes;for(var c=[],e=0;e<a;e++)c.push(String.fromCharCode(b[e>>>2]>>>24-8*(e%4)&255));return c.join("")},parse:function(a){for(var b=a.length,c=[],e=0;e<b;e++)c[e>>>2]|=(a.charCodeAt(e)&255)<<24-8*(e%4);return new u.init(c,b)}},y=k.Utf8={stringify:function(a){try{return decodeURIComponent(escape(x.stringify(a)))}catch(b){throw Error("Malformed UTF-8 data");}},parse:function(a){return x.parse(unescape(encodeURIComponent(a)))}},
|
||||
$=b.BufferedBlockAlgorithm=l.extend({reset:function(){this._data=new u.init;this._nDataBytes=0},_append:function(a){"string"==typeof a&&(a=y.parse(a));this._data.concat(a);this._nDataBytes+=a.sigBytes},_process:function(b){var c=this._data,l=c.words,e=c.sigBytes,d=this.blockSize,f=e/(4*d),f=b?a.ceil(f):a.max((f|0)-this._minBufferSize,0);b=f*d;e=a.min(4*b,e);if(b){for(var k=0;k<b;k+=d)this._doProcessBlock(l,k);k=l.splice(0,b);c.sigBytes-=e}return new u.init(k,e)},clone:function(){var a=l.clone.call(this);
|
||||
a._data=this._data.clone();return a},_minBufferSize:0});b.Hasher=$.extend({cfg:l.extend(),init:function(a){this.cfg=this.cfg.extend(a);this.reset()},reset:function(){$.reset.call(this);this._doReset()},update:function(a){this._append(a);this._process();return this},finalize:function(a){a&&this._append(a);return this._doFinalize()},blockSize:16,_createHelper:function(a){return function(b,c){return(new a.init(c)).finalize(b)}},_createHmacHelper:function(a){return function(b,c){return(new ia.HMAC.init(a,
|
||||
c)).finalize(b)}}});var ia=c.algo={};return c}(Math);
|
||||
(function(a){var d=CryptoJS,c=d.lib,b=c.Base,f=c.WordArray,d=d.x64={};d.Word=b.extend({init:function(a,b){this.high=a;this.low=b}});d.WordArray=b.extend({init:function(b,c){b=this.words=b||[];this.sigBytes=c!=a?c:8*b.length},toX32:function(){for(var a=this.words,b=a.length,c=[],d=0;d<b;d++){var x=a[d];c.push(x.high);c.push(x.low)}return f.create(c,this.sigBytes)},clone:function(){for(var a=b.clone.call(this),c=a.words=this.words.slice(0),d=c.length,f=0;f<d;f++)c[f]=c[f].clone();return a}})})();
|
||||
(function(){function a(){return f.create.apply(f,arguments)}for(var d=CryptoJS,c=d.lib.Hasher,b=d.x64,f=b.Word,l=b.WordArray,b=d.algo,u=[a(1116352408,3609767458),a(1899447441,602891725),a(3049323471,3964484399),a(3921009573,2173295548),a(961987163,4081628472),a(1508970993,3053834265),a(2453635748,2937671579),a(2870763221,3664609560),a(3624381080,2734883394),a(310598401,1164996542),a(607225278,1323610764),a(1426881987,3590304994),a(1925078388,4068182383),a(2162078206,991336113),a(2614888103,633803317),
|
||||
a(3248222580,3479774868),a(3835390401,2666613458),a(4022224774,944711139),a(264347078,2341262773),a(604807628,2007800933),a(770255983,1495990901),a(1249150122,1856431235),a(1555081692,3175218132),a(1996064986,2198950837),a(2554220882,3999719339),a(2821834349,766784016),a(2952996808,2566594879),a(3210313671,3203337956),a(3336571891,1034457026),a(3584528711,2466948901),a(113926993,3758326383),a(338241895,168717936),a(666307205,1188179964),a(773529912,1546045734),a(1294757372,1522805485),a(1396182291,
|
||||
2643833823),a(1695183700,2343527390),a(1986661051,1014477480),a(2177026350,1206759142),a(2456956037,344077627),a(2730485921,1290863460),a(2820302411,3158454273),a(3259730800,3505952657),a(3345764771,106217008),a(3516065817,3606008344),a(3600352804,1432725776),a(4094571909,1467031594),a(275423344,851169720),a(430227734,3100823752),a(506948616,1363258195),a(659060556,3750685593),a(883997877,3785050280),a(958139571,3318307427),a(1322822218,3812723403),a(1537002063,2003034995),a(1747873779,3602036899),
|
||||
a(1955562222,1575990012),a(2024104815,1125592928),a(2227730452,2716904306),a(2361852424,442776044),a(2428436474,593698344),a(2756734187,3733110249),a(3204031479,2999351573),a(3329325298,3815920427),a(3391569614,3928383900),a(3515267271,566280711),a(3940187606,3454069534),a(4118630271,4000239992),a(116418474,1914138554),a(174292421,2731055270),a(289380356,3203993006),a(460393269,320620315),a(685471733,587496836),a(852142971,1086792851),a(1017036298,365543100),a(1126000580,2618297676),a(1288033470,
|
||||
3409855158),a(1501505948,4234509866),a(1607167915,987167468),a(1816402316,1246189591)],k=[],m=0;80>m;m++)k[m]=a();b=b.SHA512=c.extend({_doReset:function(){this._hash=new l.init([new f.init(1779033703,4089235720),new f.init(3144134277,2227873595),new f.init(1013904242,4271175723),new f.init(2773480762,1595750129),new f.init(1359893119,2917565137),new f.init(2600822924,725511199),new f.init(528734635,4215389547),new f.init(1541459225,327033209)])},_doProcessBlock:function(a,b){for(var c=this._hash.words,
|
||||
d=c[0],f=c[1],g=c[2],l=c[3],e=c[4],m=c[5],L=c[6],c=c[7],Z=d.high,M=d.low,aa=f.high,N=f.low,ba=g.high,O=g.low,ca=l.high,P=l.low,da=e.high,Q=e.low,ea=m.high,R=m.low,fa=L.high,S=L.low,ga=c.high,T=c.low,r=Z,n=M,F=aa,D=N,G=ba,E=O,W=ca,H=P,s=da,p=Q,U=ea,I=R,V=fa,J=S,X=ga,K=T,t=0;80>t;t++){var z=k[t];if(16>t)var q=z.high=a[b+2*t]|0,h=z.low=a[b+2*t+1]|0;else{var q=k[t-15],h=q.high,v=q.low,q=(h>>>1|v<<31)^(h>>>8|v<<24)^h>>>7,v=(v>>>1|h<<31)^(v>>>8|h<<24)^(v>>>7|h<<25),B=k[t-2],h=B.high,j=B.low,B=(h>>>19|j<<
|
||||
13)^(h<<3|j>>>29)^h>>>6,j=(j>>>19|h<<13)^(j<<3|h>>>29)^(j>>>6|h<<26),h=k[t-7],Y=h.high,A=k[t-16],w=A.high,A=A.low,h=v+h.low,q=q+Y+(h>>>0<v>>>0?1:0),h=h+j,q=q+B+(h>>>0<j>>>0?1:0),h=h+A,q=q+w+(h>>>0<A>>>0?1:0);z.high=q;z.low=h}var Y=s&U^~s&V,A=p&I^~p&J,z=r&F^r&G^F&G,ja=n&D^n&E^D&E,v=(r>>>28|n<<4)^(r<<30|n>>>2)^(r<<25|n>>>7),B=(n>>>28|r<<4)^(n<<30|r>>>2)^(n<<25|r>>>7),j=u[t],ka=j.high,ha=j.low,j=K+((p>>>14|s<<18)^(p>>>18|s<<14)^(p<<23|s>>>9)),w=X+((s>>>14|p<<18)^(s>>>18|p<<14)^(s<<23|p>>>9))+(j>>>0<
|
||||
K>>>0?1:0),j=j+A,w=w+Y+(j>>>0<A>>>0?1:0),j=j+ha,w=w+ka+(j>>>0<ha>>>0?1:0),j=j+h,w=w+q+(j>>>0<h>>>0?1:0),h=B+ja,z=v+z+(h>>>0<B>>>0?1:0),X=V,K=J,V=U,J=I,U=s,I=p,p=H+j|0,s=W+w+(p>>>0<H>>>0?1:0)|0,W=G,H=E,G=F,E=D,F=r,D=n,n=j+h|0,r=w+z+(n>>>0<j>>>0?1:0)|0}M=d.low=M+n;d.high=Z+r+(M>>>0<n>>>0?1:0);N=f.low=N+D;f.high=aa+F+(N>>>0<D>>>0?1:0);O=g.low=O+E;g.high=ba+G+(O>>>0<E>>>0?1:0);P=l.low=P+H;l.high=ca+W+(P>>>0<H>>>0?1:0);Q=e.low=Q+p;e.high=da+s+(Q>>>0<p>>>0?1:0);R=m.low=R+I;m.high=ea+U+(R>>>0<I>>>0?1:0);
|
||||
S=L.low=S+J;L.high=fa+V+(S>>>0<J>>>0?1:0);T=c.low=T+K;c.high=ga+X+(T>>>0<K>>>0?1:0)},_doFinalize:function(){var a=this._data,c=a.words,b=8*this._nDataBytes,d=8*a.sigBytes;c[d>>>5]|=128<<24-d%32;c[(d+128>>>10<<5)+30]=Math.floor(b/4294967296);c[(d+128>>>10<<5)+31]=b;a.sigBytes=4*c.length;this._process();return this._hash.toX32()},clone:function(){var a=c.clone.call(this);a._hash=this._hash.clone();return a},blockSize:32});d.SHA512=c._createHelper(b);d.HmacSHA512=c._createHmacHelper(b)})();
|
||||
(function(){var a=CryptoJS,d=a.x64,c=d.Word,b=d.WordArray,d=a.algo,f=d.SHA512,d=d.SHA384=f.extend({_doReset:function(){this._hash=new b.init([new c.init(3418070365,3238371032),new c.init(1654270250,914150663),new c.init(2438529370,812702999),new c.init(355462360,4144912697),new c.init(1731405415,4290775857),new c.init(2394180231,1750603025),new c.init(3675008525,1694076839),new c.init(1203062813,3204075428)])},_doFinalize:function(){var a=f._doFinalize.call(this);a.sigBytes-=16;return a}});a.SHA384=
|
||||
f._createHelper(d);a.HmacSHA384=f._createHmacHelper(d)})();
|
||||
(function(){var a=CryptoJS,d=a.enc.Utf8;a.algo.HMAC=a.lib.Base.extend({init:function(a,b){a=this._hasher=new a.init;"string"==typeof b&&(b=d.parse(b));var f=a.blockSize,l=4*f;b.sigBytes>l&&(b=a.finalize(b));b.clamp();for(var u=this._oKey=b.clone(),k=this._iKey=b.clone(),m=u.words,x=k.words,y=0;y<f;y++)m[y]^=1549556828,x[y]^=909522486;u.sigBytes=k.sigBytes=l;this.reset()},reset:function(){var a=this._hasher;a.reset();a.update(this._iKey)},update:function(a){this._hasher.update(a);return this},finalize:function(a){var b=
|
||||
this._hasher;a=b.finalize(a);b.reset();return b.finalize(this._oKey.clone().concat(a))}})})();
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
CryptoJS v3.1.2
|
||||
code.google.com/p/crypto-js
|
||||
(c) 2009-2013 by Jeff Mott. All rights reserved.
|
||||
code.google.com/p/crypto-js/wiki/License
|
||||
*/
|
||||
var CryptoJS=CryptoJS||function(a,j){var c={},b=c.lib={},f=function(){},l=b.Base={extend:function(a){f.prototype=this;var d=new f;a&&d.mixIn(a);d.hasOwnProperty("init")||(d.init=function(){d.$super.init.apply(this,arguments)});d.init.prototype=d;d.$super=this;return d},create:function(){var a=this.extend();a.init.apply(a,arguments);return a},init:function(){},mixIn:function(a){for(var d in a)a.hasOwnProperty(d)&&(this[d]=a[d]);a.hasOwnProperty("toString")&&(this.toString=a.toString)},clone:function(){return this.init.prototype.extend(this)}},
|
||||
u=b.WordArray=l.extend({init:function(a,d){a=this.words=a||[];this.sigBytes=d!=j?d:4*a.length},toString:function(a){return(a||m).stringify(this)},concat:function(a){var d=this.words,M=a.words,e=this.sigBytes;a=a.sigBytes;this.clamp();if(e%4)for(var b=0;b<a;b++)d[e+b>>>2]|=(M[b>>>2]>>>24-8*(b%4)&255)<<24-8*((e+b)%4);else if(65535<M.length)for(b=0;b<a;b+=4)d[e+b>>>2]=M[b>>>2];else d.push.apply(d,M);this.sigBytes+=a;return this},clamp:function(){var D=this.words,d=this.sigBytes;D[d>>>2]&=4294967295<<
|
||||
32-8*(d%4);D.length=a.ceil(d/4)},clone:function(){var a=l.clone.call(this);a.words=this.words.slice(0);return a},random:function(D){for(var d=[],b=0;b<D;b+=4)d.push(4294967296*a.random()|0);return new u.init(d,D)}}),k=c.enc={},m=k.Hex={stringify:function(a){var d=a.words;a=a.sigBytes;for(var b=[],e=0;e<a;e++){var c=d[e>>>2]>>>24-8*(e%4)&255;b.push((c>>>4).toString(16));b.push((c&15).toString(16))}return b.join("")},parse:function(a){for(var d=a.length,b=[],e=0;e<d;e+=2)b[e>>>3]|=parseInt(a.substr(e,
|
||||
2),16)<<24-4*(e%8);return new u.init(b,d/2)}},y=k.Latin1={stringify:function(a){var b=a.words;a=a.sigBytes;for(var c=[],e=0;e<a;e++)c.push(String.fromCharCode(b[e>>>2]>>>24-8*(e%4)&255));return c.join("")},parse:function(a){for(var b=a.length,c=[],e=0;e<b;e++)c[e>>>2]|=(a.charCodeAt(e)&255)<<24-8*(e%4);return new u.init(c,b)}},z=k.Utf8={stringify:function(a){try{return decodeURIComponent(escape(y.stringify(a)))}catch(b){throw Error("Malformed UTF-8 data");}},parse:function(a){return y.parse(unescape(encodeURIComponent(a)))}},
|
||||
x=b.BufferedBlockAlgorithm=l.extend({reset:function(){this._data=new u.init;this._nDataBytes=0},_append:function(a){"string"==typeof a&&(a=z.parse(a));this._data.concat(a);this._nDataBytes+=a.sigBytes},_process:function(b){var d=this._data,c=d.words,e=d.sigBytes,l=this.blockSize,k=e/(4*l),k=b?a.ceil(k):a.max((k|0)-this._minBufferSize,0);b=k*l;e=a.min(4*b,e);if(b){for(var x=0;x<b;x+=l)this._doProcessBlock(c,x);x=c.splice(0,b);d.sigBytes-=e}return new u.init(x,e)},clone:function(){var a=l.clone.call(this);
|
||||
a._data=this._data.clone();return a},_minBufferSize:0});b.Hasher=x.extend({cfg:l.extend(),init:function(a){this.cfg=this.cfg.extend(a);this.reset()},reset:function(){x.reset.call(this);this._doReset()},update:function(a){this._append(a);this._process();return this},finalize:function(a){a&&this._append(a);return this._doFinalize()},blockSize:16,_createHelper:function(a){return function(b,c){return(new a.init(c)).finalize(b)}},_createHmacHelper:function(a){return function(b,c){return(new ja.HMAC.init(a,
|
||||
c)).finalize(b)}}});var ja=c.algo={};return c}(Math);
|
||||
(function(a){var j=CryptoJS,c=j.lib,b=c.Base,f=c.WordArray,j=j.x64={};j.Word=b.extend({init:function(a,b){this.high=a;this.low=b}});j.WordArray=b.extend({init:function(b,c){b=this.words=b||[];this.sigBytes=c!=a?c:8*b.length},toX32:function(){for(var a=this.words,b=a.length,c=[],m=0;m<b;m++){var y=a[m];c.push(y.high);c.push(y.low)}return f.create(c,this.sigBytes)},clone:function(){for(var a=b.clone.call(this),c=a.words=this.words.slice(0),k=c.length,f=0;f<k;f++)c[f]=c[f].clone();return a}})})();
|
||||
(function(){function a(){return f.create.apply(f,arguments)}for(var j=CryptoJS,c=j.lib.Hasher,b=j.x64,f=b.Word,l=b.WordArray,b=j.algo,u=[a(1116352408,3609767458),a(1899447441,602891725),a(3049323471,3964484399),a(3921009573,2173295548),a(961987163,4081628472),a(1508970993,3053834265),a(2453635748,2937671579),a(2870763221,3664609560),a(3624381080,2734883394),a(310598401,1164996542),a(607225278,1323610764),a(1426881987,3590304994),a(1925078388,4068182383),a(2162078206,991336113),a(2614888103,633803317),
|
||||
a(3248222580,3479774868),a(3835390401,2666613458),a(4022224774,944711139),a(264347078,2341262773),a(604807628,2007800933),a(770255983,1495990901),a(1249150122,1856431235),a(1555081692,3175218132),a(1996064986,2198950837),a(2554220882,3999719339),a(2821834349,766784016),a(2952996808,2566594879),a(3210313671,3203337956),a(3336571891,1034457026),a(3584528711,2466948901),a(113926993,3758326383),a(338241895,168717936),a(666307205,1188179964),a(773529912,1546045734),a(1294757372,1522805485),a(1396182291,
|
||||
2643833823),a(1695183700,2343527390),a(1986661051,1014477480),a(2177026350,1206759142),a(2456956037,344077627),a(2730485921,1290863460),a(2820302411,3158454273),a(3259730800,3505952657),a(3345764771,106217008),a(3516065817,3606008344),a(3600352804,1432725776),a(4094571909,1467031594),a(275423344,851169720),a(430227734,3100823752),a(506948616,1363258195),a(659060556,3750685593),a(883997877,3785050280),a(958139571,3318307427),a(1322822218,3812723403),a(1537002063,2003034995),a(1747873779,3602036899),
|
||||
a(1955562222,1575990012),a(2024104815,1125592928),a(2227730452,2716904306),a(2361852424,442776044),a(2428436474,593698344),a(2756734187,3733110249),a(3204031479,2999351573),a(3329325298,3815920427),a(3391569614,3928383900),a(3515267271,566280711),a(3940187606,3454069534),a(4118630271,4000239992),a(116418474,1914138554),a(174292421,2731055270),a(289380356,3203993006),a(460393269,320620315),a(685471733,587496836),a(852142971,1086792851),a(1017036298,365543100),a(1126000580,2618297676),a(1288033470,
|
||||
3409855158),a(1501505948,4234509866),a(1607167915,987167468),a(1816402316,1246189591)],k=[],m=0;80>m;m++)k[m]=a();b=b.SHA512=c.extend({_doReset:function(){this._hash=new l.init([new f.init(1779033703,4089235720),new f.init(3144134277,2227873595),new f.init(1013904242,4271175723),new f.init(2773480762,1595750129),new f.init(1359893119,2917565137),new f.init(2600822924,725511199),new f.init(528734635,4215389547),new f.init(1541459225,327033209)])},_doProcessBlock:function(a,b){for(var c=this._hash.words,
|
||||
f=c[0],j=c[1],d=c[2],l=c[3],e=c[4],m=c[5],N=c[6],c=c[7],aa=f.high,O=f.low,ba=j.high,P=j.low,ca=d.high,Q=d.low,da=l.high,R=l.low,ea=e.high,S=e.low,fa=m.high,T=m.low,ga=N.high,U=N.low,ha=c.high,V=c.low,r=aa,n=O,G=ba,E=P,H=ca,F=Q,Y=da,I=R,s=ea,p=S,W=fa,J=T,X=ga,K=U,Z=ha,L=V,t=0;80>t;t++){var A=k[t];if(16>t)var q=A.high=a[b+2*t]|0,g=A.low=a[b+2*t+1]|0;else{var q=k[t-15],g=q.high,v=q.low,q=(g>>>1|v<<31)^(g>>>8|v<<24)^g>>>7,v=(v>>>1|g<<31)^(v>>>8|g<<24)^(v>>>7|g<<25),C=k[t-2],g=C.high,h=C.low,C=(g>>>19|
|
||||
h<<13)^(g<<3|h>>>29)^g>>>6,h=(h>>>19|g<<13)^(h<<3|g>>>29)^(h>>>6|g<<26),g=k[t-7],$=g.high,B=k[t-16],w=B.high,B=B.low,g=v+g.low,q=q+$+(g>>>0<v>>>0?1:0),g=g+h,q=q+C+(g>>>0<h>>>0?1:0),g=g+B,q=q+w+(g>>>0<B>>>0?1:0);A.high=q;A.low=g}var $=s&W^~s&X,B=p&J^~p&K,A=r&G^r&H^G&H,ka=n&E^n&F^E&F,v=(r>>>28|n<<4)^(r<<30|n>>>2)^(r<<25|n>>>7),C=(n>>>28|r<<4)^(n<<30|r>>>2)^(n<<25|r>>>7),h=u[t],la=h.high,ia=h.low,h=L+((p>>>14|s<<18)^(p>>>18|s<<14)^(p<<23|s>>>9)),w=Z+((s>>>14|p<<18)^(s>>>18|p<<14)^(s<<23|p>>>9))+(h>>>
|
||||
0<L>>>0?1:0),h=h+B,w=w+$+(h>>>0<B>>>0?1:0),h=h+ia,w=w+la+(h>>>0<ia>>>0?1:0),h=h+g,w=w+q+(h>>>0<g>>>0?1:0),g=C+ka,A=v+A+(g>>>0<C>>>0?1:0),Z=X,L=K,X=W,K=J,W=s,J=p,p=I+h|0,s=Y+w+(p>>>0<I>>>0?1:0)|0,Y=H,I=F,H=G,F=E,G=r,E=n,n=h+g|0,r=w+A+(n>>>0<h>>>0?1:0)|0}O=f.low=O+n;f.high=aa+r+(O>>>0<n>>>0?1:0);P=j.low=P+E;j.high=ba+G+(P>>>0<E>>>0?1:0);Q=d.low=Q+F;d.high=ca+H+(Q>>>0<F>>>0?1:0);R=l.low=R+I;l.high=da+Y+(R>>>0<I>>>0?1:0);S=e.low=S+p;e.high=ea+s+(S>>>0<p>>>0?1:0);T=m.low=T+J;m.high=fa+W+(T>>>0<J>>>0?1:
|
||||
0);U=N.low=U+K;N.high=ga+X+(U>>>0<K>>>0?1:0);V=c.low=V+L;c.high=ha+Z+(V>>>0<L>>>0?1:0)},_doFinalize:function(){var a=this._data,b=a.words,c=8*this._nDataBytes,f=8*a.sigBytes;b[f>>>5]|=128<<24-f%32;b[(f+128>>>10<<5)+30]=Math.floor(c/4294967296);b[(f+128>>>10<<5)+31]=c;a.sigBytes=4*b.length;this._process();return this._hash.toX32()},clone:function(){var a=c.clone.call(this);a._hash=this._hash.clone();return a},blockSize:32});j.SHA512=c._createHelper(b);j.HmacSHA512=c._createHmacHelper(b)})();
|
||||
(function(){var a=CryptoJS,j=a.enc.Utf8;a.algo.HMAC=a.lib.Base.extend({init:function(a,b){a=this._hasher=new a.init;"string"==typeof b&&(b=j.parse(b));var f=a.blockSize,l=4*f;b.sigBytes>l&&(b=a.finalize(b));b.clamp();for(var u=this._oKey=b.clone(),k=this._iKey=b.clone(),m=u.words,y=k.words,z=0;z<f;z++)m[z]^=1549556828,y[z]^=909522486;u.sigBytes=k.sigBytes=l;this.reset()},reset:function(){var a=this._hasher;a.reset();a.update(this._iKey)},update:function(a){this._hasher.update(a);return this},finalize:function(a){var b=
|
||||
this._hasher;a=b.finalize(a);b.reset();return b.finalize(this._oKey.clone().concat(a))}})})();
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
CryptoJS v3.1.2
|
||||
code.google.com/p/crypto-js
|
||||
(c) 2009-2013 by Jeff Mott. All rights reserved.
|
||||
code.google.com/p/crypto-js/wiki/License
|
||||
*/
|
||||
var CryptoJS=CryptoJS||function(q,k){var e={},l=e.lib={},p=function(){},c=l.Base={extend:function(a){p.prototype=this;var b=new p;a&&b.mixIn(a);b.hasOwnProperty("init")||(b.init=function(){b.$super.init.apply(this,arguments)});b.init.prototype=b;b.$super=this;return b},create:function(){var a=this.extend();a.init.apply(a,arguments);return a},init:function(){},mixIn:function(a){for(var b in a)a.hasOwnProperty(b)&&(this[b]=a[b]);a.hasOwnProperty("toString")&&(this.toString=a.toString)},clone:function(){return this.init.prototype.extend(this)}},
|
||||
s=l.WordArray=c.extend({init:function(a,b){a=this.words=a||[];this.sigBytes=b!=k?b:4*a.length},toString:function(a){return(a||d).stringify(this)},concat:function(a){var b=this.words,m=a.words,n=this.sigBytes;a=a.sigBytes;this.clamp();if(n%4)for(var r=0;r<a;r++)b[n+r>>>2]|=(m[r>>>2]>>>24-8*(r%4)&255)<<24-8*((n+r)%4);else if(65535<m.length)for(r=0;r<a;r+=4)b[n+r>>>2]=m[r>>>2];else b.push.apply(b,m);this.sigBytes+=a;return this},clamp:function(){var a=this.words,b=this.sigBytes;a[b>>>2]&=4294967295<<
|
||||
32-8*(b%4);a.length=q.ceil(b/4)},clone:function(){var a=c.clone.call(this);a.words=this.words.slice(0);return a},random:function(a){for(var b=[],m=0;m<a;m+=4)b.push(4294967296*q.random()|0);return new s.init(b,a)}}),b=e.enc={},d=b.Hex={stringify:function(a){var b=a.words;a=a.sigBytes;for(var m=[],n=0;n<a;n++){var r=b[n>>>2]>>>24-8*(n%4)&255;m.push((r>>>4).toString(16));m.push((r&15).toString(16))}return m.join("")},parse:function(a){for(var b=a.length,m=[],n=0;n<b;n+=2)m[n>>>3]|=parseInt(a.substr(n,
|
||||
2),16)<<24-4*(n%8);return new s.init(m,b/2)}},a=b.Latin1={stringify:function(a){var b=a.words;a=a.sigBytes;for(var m=[],n=0;n<a;n++)m.push(String.fromCharCode(b[n>>>2]>>>24-8*(n%4)&255));return m.join("")},parse:function(a){for(var b=a.length,m=[],n=0;n<b;n++)m[n>>>2]|=(a.charCodeAt(n)&255)<<24-8*(n%4);return new s.init(m,b)}},t=b.Utf8={stringify:function(b){try{return decodeURIComponent(escape(a.stringify(b)))}catch(c){throw Error("Malformed UTF-8 data");}},parse:function(b){return a.parse(unescape(encodeURIComponent(b)))}},
|
||||
u=l.BufferedBlockAlgorithm=c.extend({reset:function(){this._data=new s.init;this._nDataBytes=0},_append:function(a){"string"==typeof a&&(a=t.parse(a));this._data.concat(a);this._nDataBytes+=a.sigBytes},_process:function(a){var b=this._data,m=b.words,n=b.sigBytes,r=this.blockSize,c=n/(4*r),c=a?q.ceil(c):q.max((c|0)-this._minBufferSize,0);a=c*r;n=q.min(4*a,n);if(a){for(var u=0;u<a;u+=r)this._doProcessBlock(m,u);u=m.splice(0,a);b.sigBytes-=n}return new s.init(u,n)},clone:function(){var a=c.clone.call(this);
|
||||
a._data=this._data.clone();return a},_minBufferSize:0});l.Hasher=u.extend({cfg:c.extend(),init:function(a){this.cfg=this.cfg.extend(a);this.reset()},reset:function(){u.reset.call(this);this._doReset()},update:function(a){this._append(a);this._process();return this},finalize:function(a){a&&this._append(a);return this._doFinalize()},blockSize:16,_createHelper:function(a){return function(b,m){return(new a.init(m)).finalize(b)}},_createHmacHelper:function(a){return function(b,m){return(new w.HMAC.init(a,
|
||||
m)).finalize(b)}}});var w=e.algo={};return e}(Math);
|
||||
(function(){var q=CryptoJS,k=q.lib.WordArray;q.enc.Base64={stringify:function(e){var l=e.words,p=e.sigBytes,c=this._map;e.clamp();e=[];for(var k=0;k<p;k+=3)for(var b=(l[k>>>2]>>>24-8*(k%4)&255)<<16|(l[k+1>>>2]>>>24-8*((k+1)%4)&255)<<8|l[k+2>>>2]>>>24-8*((k+2)%4)&255,d=0;4>d&&k+0.75*d<p;d++)e.push(c.charAt(b>>>6*(3-d)&63));if(l=c.charAt(64))for(;e.length%4;)e.push(l);return e.join("")},parse:function(e){var l=e.length,p=this._map,c=p.charAt(64);c&&(c=e.indexOf(c),-1!=c&&(l=c));for(var c=[],s=0,b=0;b<
|
||||
l;b++)if(b%4){var d=p.indexOf(e.charAt(b-1))<<2*(b%4),a=p.indexOf(e.charAt(b))>>>6-2*(b%4);c[s>>>2]|=(d|a)<<24-8*(s%4);s++}return k.create(c,s)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}})();
|
||||
(function(q){function k(a,b,c,d,m,n,r){a=a+(b&c|~b&d)+m+r;return(a<<n|a>>>32-n)+b}function e(a,b,c,d,m,n,r){a=a+(b&d|c&~d)+m+r;return(a<<n|a>>>32-n)+b}function l(a,b,c,d,m,n,r){a=a+(b^c^d)+m+r;return(a<<n|a>>>32-n)+b}function p(a,b,c,d,m,n,r){a=a+(c^(b|~d))+m+r;return(a<<n|a>>>32-n)+b}for(var c=CryptoJS,s=c.lib,b=s.WordArray,d=s.Hasher,s=c.algo,a=[],t=0;64>t;t++)a[t]=4294967296*q.abs(q.sin(t+1))|0;s=s.MD5=d.extend({_doReset:function(){this._hash=new b.init([1732584193,4023233417,2562383102,271733878])},
|
||||
_doProcessBlock:function(b,c){for(var d=0;16>d;d++){var t=c+d,m=b[t];b[t]=(m<<8|m>>>24)&16711935|(m<<24|m>>>8)&4278255360}var d=this._hash.words,t=b[c+0],m=b[c+1],n=b[c+2],r=b[c+3],x=b[c+4],s=b[c+5],q=b[c+6],y=b[c+7],z=b[c+8],A=b[c+9],B=b[c+10],C=b[c+11],D=b[c+12],E=b[c+13],F=b[c+14],G=b[c+15],f=d[0],g=d[1],h=d[2],j=d[3],f=k(f,g,h,j,t,7,a[0]),j=k(j,f,g,h,m,12,a[1]),h=k(h,j,f,g,n,17,a[2]),g=k(g,h,j,f,r,22,a[3]),f=k(f,g,h,j,x,7,a[4]),j=k(j,f,g,h,s,12,a[5]),h=k(h,j,f,g,q,17,a[6]),g=k(g,h,j,f,y,22,a[7]),
|
||||
f=k(f,g,h,j,z,7,a[8]),j=k(j,f,g,h,A,12,a[9]),h=k(h,j,f,g,B,17,a[10]),g=k(g,h,j,f,C,22,a[11]),f=k(f,g,h,j,D,7,a[12]),j=k(j,f,g,h,E,12,a[13]),h=k(h,j,f,g,F,17,a[14]),g=k(g,h,j,f,G,22,a[15]),f=e(f,g,h,j,m,5,a[16]),j=e(j,f,g,h,q,9,a[17]),h=e(h,j,f,g,C,14,a[18]),g=e(g,h,j,f,t,20,a[19]),f=e(f,g,h,j,s,5,a[20]),j=e(j,f,g,h,B,9,a[21]),h=e(h,j,f,g,G,14,a[22]),g=e(g,h,j,f,x,20,a[23]),f=e(f,g,h,j,A,5,a[24]),j=e(j,f,g,h,F,9,a[25]),h=e(h,j,f,g,r,14,a[26]),g=e(g,h,j,f,z,20,a[27]),f=e(f,g,h,j,E,5,a[28]),j=e(j,f,
|
||||
g,h,n,9,a[29]),h=e(h,j,f,g,y,14,a[30]),g=e(g,h,j,f,D,20,a[31]),f=l(f,g,h,j,s,4,a[32]),j=l(j,f,g,h,z,11,a[33]),h=l(h,j,f,g,C,16,a[34]),g=l(g,h,j,f,F,23,a[35]),f=l(f,g,h,j,m,4,a[36]),j=l(j,f,g,h,x,11,a[37]),h=l(h,j,f,g,y,16,a[38]),g=l(g,h,j,f,B,23,a[39]),f=l(f,g,h,j,E,4,a[40]),j=l(j,f,g,h,t,11,a[41]),h=l(h,j,f,g,r,16,a[42]),g=l(g,h,j,f,q,23,a[43]),f=l(f,g,h,j,A,4,a[44]),j=l(j,f,g,h,D,11,a[45]),h=l(h,j,f,g,G,16,a[46]),g=l(g,h,j,f,n,23,a[47]),f=p(f,g,h,j,t,6,a[48]),j=p(j,f,g,h,y,10,a[49]),h=p(h,j,f,g,
|
||||
F,15,a[50]),g=p(g,h,j,f,s,21,a[51]),f=p(f,g,h,j,D,6,a[52]),j=p(j,f,g,h,r,10,a[53]),h=p(h,j,f,g,B,15,a[54]),g=p(g,h,j,f,m,21,a[55]),f=p(f,g,h,j,z,6,a[56]),j=p(j,f,g,h,G,10,a[57]),h=p(h,j,f,g,q,15,a[58]),g=p(g,h,j,f,E,21,a[59]),f=p(f,g,h,j,x,6,a[60]),j=p(j,f,g,h,C,10,a[61]),h=p(h,j,f,g,n,15,a[62]),g=p(g,h,j,f,A,21,a[63]);d[0]=d[0]+f|0;d[1]=d[1]+g|0;d[2]=d[2]+h|0;d[3]=d[3]+j|0},_doFinalize:function(){var a=this._data,b=a.words,c=8*this._nDataBytes,d=8*a.sigBytes;b[d>>>5]|=128<<24-d%32;var m=q.floor(c/
|
||||
4294967296);b[(d+64>>>9<<4)+15]=(m<<8|m>>>24)&16711935|(m<<24|m>>>8)&4278255360;b[(d+64>>>9<<4)+14]=(c<<8|c>>>24)&16711935|(c<<24|c>>>8)&4278255360;a.sigBytes=4*(b.length+1);this._process();a=this._hash;b=a.words;for(c=0;4>c;c++)d=b[c],b[c]=(d<<8|d>>>24)&16711935|(d<<24|d>>>8)&4278255360;return a},clone:function(){var a=d.clone.call(this);a._hash=this._hash.clone();return a}});c.MD5=d._createHelper(s);c.HmacMD5=d._createHmacHelper(s)})(Math);
|
||||
(function(){var q=CryptoJS,k=q.lib,e=k.Base,l=k.WordArray,k=q.algo,p=k.EvpKDF=e.extend({cfg:e.extend({keySize:4,hasher:k.MD5,iterations:1}),init:function(c){this.cfg=this.cfg.extend(c)},compute:function(c,e){for(var b=this.cfg,d=b.hasher.create(),a=l.create(),k=a.words,p=b.keySize,b=b.iterations;k.length<p;){q&&d.update(q);var q=d.update(c).finalize(e);d.reset();for(var v=1;v<b;v++)q=d.finalize(q),d.reset();a.concat(q)}a.sigBytes=4*p;return a}});q.EvpKDF=function(c,e,b){return p.create(b).compute(c,
|
||||
e)}})();
|
||||
CryptoJS.lib.Cipher||function(q){var k=CryptoJS,e=k.lib,l=e.Base,p=e.WordArray,c=e.BufferedBlockAlgorithm,s=k.enc.Base64,b=k.algo.EvpKDF,d=e.Cipher=c.extend({cfg:l.extend(),createEncryptor:function(a,b){return this.create(this._ENC_XFORM_MODE,a,b)},createDecryptor:function(a,b){return this.create(this._DEC_XFORM_MODE,a,b)},init:function(a,b,c){this.cfg=this.cfg.extend(c);this._xformMode=a;this._key=b;this.reset()},reset:function(){c.reset.call(this);this._doReset()},process:function(a){this._append(a);return this._process()},
|
||||
finalize:function(a){a&&this._append(a);return this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(a){return{encrypt:function(b,c,d){return("string"==typeof c?H:v).encrypt(a,b,c,d)},decrypt:function(b,c,d){return("string"==typeof c?H:v).decrypt(a,b,c,d)}}}});e.StreamCipher=d.extend({_doFinalize:function(){return this._process(!0)},blockSize:1});var a=k.mode={},t=function(a,b,c){var d=this._iv;d?this._iv=q:d=this._prevBlock;for(var e=0;e<c;e++)a[b+e]^=
|
||||
d[e]},u=(e.BlockCipherMode=l.extend({createEncryptor:function(a,b){return this.Encryptor.create(a,b)},createDecryptor:function(a,b){return this.Decryptor.create(a,b)},init:function(a,b){this._cipher=a;this._iv=b}})).extend();u.Encryptor=u.extend({processBlock:function(a,b){var c=this._cipher,d=c.blockSize;t.call(this,a,b,d);c.encryptBlock(a,b);this._prevBlock=a.slice(b,b+d)}});u.Decryptor=u.extend({processBlock:function(a,b){var c=this._cipher,d=c.blockSize,e=a.slice(b,b+d);c.decryptBlock(a,b);t.call(this,
|
||||
a,b,d);this._prevBlock=e}});a=a.CBC=u;u=(k.pad={}).Pkcs7={pad:function(a,b){for(var c=4*b,c=c-a.sigBytes%c,d=c<<24|c<<16|c<<8|c,e=[],k=0;k<c;k+=4)e.push(d);c=p.create(e,c);a.concat(c)},unpad:function(a){a.sigBytes-=a.words[a.sigBytes-1>>>2]&255}};e.BlockCipher=d.extend({cfg:d.cfg.extend({mode:a,padding:u}),reset:function(){d.reset.call(this);var a=this.cfg,b=a.iv,a=a.mode;if(this._xformMode==this._ENC_XFORM_MODE)var c=a.createEncryptor;else c=a.createDecryptor,this._minBufferSize=1;this._mode=c.call(a,
|
||||
this,b&&b.words)},_doProcessBlock:function(a,b){this._mode.processBlock(a,b)},_doFinalize:function(){var a=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){a.pad(this._data,this.blockSize);var b=this._process(!0)}else b=this._process(!0),a.unpad(b);return b},blockSize:4});var w=e.CipherParams=l.extend({init:function(a){this.mixIn(a)},toString:function(a){return(a||this.formatter).stringify(this)}}),a=(k.format={}).OpenSSL={stringify:function(a){var b=a.ciphertext;a=a.salt;return(a?p.create([1398893684,
|
||||
1701076831]).concat(a).concat(b):b).toString(s)},parse:function(a){a=s.parse(a);var b=a.words;if(1398893684==b[0]&&1701076831==b[1]){var c=p.create(b.slice(2,4));b.splice(0,4);a.sigBytes-=16}return w.create({ciphertext:a,salt:c})}},v=e.SerializableCipher=l.extend({cfg:l.extend({format:a}),encrypt:function(a,b,c,d){d=this.cfg.extend(d);var e=a.createEncryptor(c,d);b=e.finalize(b);e=e.cfg;return w.create({ciphertext:b,key:c,iv:e.iv,algorithm:a,mode:e.mode,padding:e.padding,blockSize:a.blockSize,formatter:d.format})},
|
||||
decrypt:function(a,b,c,d){d=this.cfg.extend(d);b=this._parse(b,d.format);return a.createDecryptor(c,d).finalize(b.ciphertext)},_parse:function(a,b){return"string"==typeof a?b.parse(a,this):a}}),k=(k.kdf={}).OpenSSL={execute:function(a,c,d,e){e||(e=p.random(8));a=b.create({keySize:c+d}).compute(a,e);d=p.create(a.words.slice(c),4*d);a.sigBytes=4*c;return w.create({key:a,iv:d,salt:e})}},H=e.PasswordBasedCipher=v.extend({cfg:v.cfg.extend({kdf:k}),encrypt:function(a,b,c,d){d=this.cfg.extend(d);c=d.kdf.execute(c,
|
||||
a.keySize,a.ivSize);d.iv=c.iv;a=v.encrypt.call(this,a,b,c.key,d);a.mixIn(c);return a},decrypt:function(a,b,c,d){d=this.cfg.extend(d);b=this._parse(b,d.format);c=d.kdf.execute(c,a.keySize,a.ivSize,b.salt);d.iv=c.iv;return v.decrypt.call(this,a,b,c.key,d)}})}();
|
||||
(function(){function q(){for(var b=this._X,d=this._C,a=0;8>a;a++)p[a]=d[a];d[0]=d[0]+1295307597+this._b|0;d[1]=d[1]+3545052371+(d[0]>>>0<p[0]>>>0?1:0)|0;d[2]=d[2]+886263092+(d[1]>>>0<p[1]>>>0?1:0)|0;d[3]=d[3]+1295307597+(d[2]>>>0<p[2]>>>0?1:0)|0;d[4]=d[4]+3545052371+(d[3]>>>0<p[3]>>>0?1:0)|0;d[5]=d[5]+886263092+(d[4]>>>0<p[4]>>>0?1:0)|0;d[6]=d[6]+1295307597+(d[5]>>>0<p[5]>>>0?1:0)|0;d[7]=d[7]+3545052371+(d[6]>>>0<p[6]>>>0?1:0)|0;this._b=d[7]>>>0<p[7]>>>0?1:0;for(a=0;8>a;a++){var e=b[a]+d[a],k=e&65535,
|
||||
l=e>>>16;c[a]=((k*k>>>17)+k*l>>>15)+l*l^((e&4294901760)*e|0)+((e&65535)*e|0)}b[0]=c[0]+(c[7]<<16|c[7]>>>16)+(c[6]<<16|c[6]>>>16)|0;b[1]=c[1]+(c[0]<<8|c[0]>>>24)+c[7]|0;b[2]=c[2]+(c[1]<<16|c[1]>>>16)+(c[0]<<16|c[0]>>>16)|0;b[3]=c[3]+(c[2]<<8|c[2]>>>24)+c[1]|0;b[4]=c[4]+(c[3]<<16|c[3]>>>16)+(c[2]<<16|c[2]>>>16)|0;b[5]=c[5]+(c[4]<<8|c[4]>>>24)+c[3]|0;b[6]=c[6]+(c[5]<<16|c[5]>>>16)+(c[4]<<16|c[4]>>>16)|0;b[7]=c[7]+(c[6]<<8|c[6]>>>24)+c[5]|0}var k=CryptoJS,e=k.lib.StreamCipher,l=[],p=[],c=[],s=k.algo.RabbitLegacy=
|
||||
e.extend({_doReset:function(){for(var b=this._key.words,c=this.cfg.iv,a=this._X=[b[0],b[3]<<16|b[2]>>>16,b[1],b[0]<<16|b[3]>>>16,b[2],b[1]<<16|b[0]>>>16,b[3],b[2]<<16|b[1]>>>16],b=this._C=[b[2]<<16|b[2]>>>16,b[0]&4294901760|b[1]&65535,b[3]<<16|b[3]>>>16,b[1]&4294901760|b[2]&65535,b[0]<<16|b[0]>>>16,b[2]&4294901760|b[3]&65535,b[1]<<16|b[1]>>>16,b[3]&4294901760|b[0]&65535],e=this._b=0;4>e;e++)q.call(this);for(e=0;8>e;e++)b[e]^=a[e+4&7];if(c){var a=c.words,c=a[0],a=a[1],c=(c<<8|c>>>24)&16711935|(c<<
|
||||
24|c>>>8)&4278255360,a=(a<<8|a>>>24)&16711935|(a<<24|a>>>8)&4278255360,e=c>>>16|a&4294901760,k=a<<16|c&65535;b[0]^=c;b[1]^=e;b[2]^=a;b[3]^=k;b[4]^=c;b[5]^=e;b[6]^=a;b[7]^=k;for(e=0;4>e;e++)q.call(this)}},_doProcessBlock:function(b,c){var a=this._X;q.call(this);l[0]=a[0]^a[5]>>>16^a[3]<<16;l[1]=a[2]^a[7]>>>16^a[5]<<16;l[2]=a[4]^a[1]>>>16^a[7]<<16;l[3]=a[6]^a[3]>>>16^a[1]<<16;for(a=0;4>a;a++)l[a]=(l[a]<<8|l[a]>>>24)&16711935|(l[a]<<24|l[a]>>>8)&4278255360,b[c+a]^=l[a]},blockSize:4,ivSize:2});k.RabbitLegacy=
|
||||
e._createHelper(s)})();
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
CryptoJS v3.1.2
|
||||
code.google.com/p/crypto-js
|
||||
(c) 2009-2013 by Jeff Mott. All rights reserved.
|
||||
code.google.com/p/crypto-js/wiki/License
|
||||
*/
|
||||
var CryptoJS=CryptoJS||function(q,k){var e={},l=e.lib={},p=function(){},c=l.Base={extend:function(a){p.prototype=this;var b=new p;a&&b.mixIn(a);b.hasOwnProperty("init")||(b.init=function(){b.$super.init.apply(this,arguments)});b.init.prototype=b;b.$super=this;return b},create:function(){var a=this.extend();a.init.apply(a,arguments);return a},init:function(){},mixIn:function(a){for(var b in a)a.hasOwnProperty(b)&&(this[b]=a[b]);a.hasOwnProperty("toString")&&(this.toString=a.toString)},clone:function(){return this.init.prototype.extend(this)}},
|
||||
s=l.WordArray=c.extend({init:function(a,b){a=this.words=a||[];this.sigBytes=b!=k?b:4*a.length},toString:function(a){return(a||d).stringify(this)},concat:function(a){var b=this.words,m=a.words,n=this.sigBytes;a=a.sigBytes;this.clamp();if(n%4)for(var r=0;r<a;r++)b[n+r>>>2]|=(m[r>>>2]>>>24-8*(r%4)&255)<<24-8*((n+r)%4);else if(65535<m.length)for(r=0;r<a;r+=4)b[n+r>>>2]=m[r>>>2];else b.push.apply(b,m);this.sigBytes+=a;return this},clamp:function(){var a=this.words,b=this.sigBytes;a[b>>>2]&=4294967295<<
|
||||
32-8*(b%4);a.length=q.ceil(b/4)},clone:function(){var a=c.clone.call(this);a.words=this.words.slice(0);return a},random:function(a){for(var b=[],m=0;m<a;m+=4)b.push(4294967296*q.random()|0);return new s.init(b,a)}}),b=e.enc={},d=b.Hex={stringify:function(a){var b=a.words;a=a.sigBytes;for(var m=[],n=0;n<a;n++){var r=b[n>>>2]>>>24-8*(n%4)&255;m.push((r>>>4).toString(16));m.push((r&15).toString(16))}return m.join("")},parse:function(a){for(var b=a.length,m=[],n=0;n<b;n+=2)m[n>>>3]|=parseInt(a.substr(n,
|
||||
2),16)<<24-4*(n%8);return new s.init(m,b/2)}},a=b.Latin1={stringify:function(a){var b=a.words;a=a.sigBytes;for(var m=[],n=0;n<a;n++)m.push(String.fromCharCode(b[n>>>2]>>>24-8*(n%4)&255));return m.join("")},parse:function(a){for(var b=a.length,m=[],n=0;n<b;n++)m[n>>>2]|=(a.charCodeAt(n)&255)<<24-8*(n%4);return new s.init(m,b)}},u=b.Utf8={stringify:function(b){try{return decodeURIComponent(escape(a.stringify(b)))}catch(c){throw Error("Malformed UTF-8 data");}},parse:function(b){return a.parse(unescape(encodeURIComponent(b)))}},
|
||||
t=l.BufferedBlockAlgorithm=c.extend({reset:function(){this._data=new s.init;this._nDataBytes=0},_append:function(a){"string"==typeof a&&(a=u.parse(a));this._data.concat(a);this._nDataBytes+=a.sigBytes},_process:function(a){var b=this._data,m=b.words,n=b.sigBytes,r=this.blockSize,c=n/(4*r),c=a?q.ceil(c):q.max((c|0)-this._minBufferSize,0);a=c*r;n=q.min(4*a,n);if(a){for(var t=0;t<a;t+=r)this._doProcessBlock(m,t);t=m.splice(0,a);b.sigBytes-=n}return new s.init(t,n)},clone:function(){var a=c.clone.call(this);
|
||||
a._data=this._data.clone();return a},_minBufferSize:0});l.Hasher=t.extend({cfg:c.extend(),init:function(a){this.cfg=this.cfg.extend(a);this.reset()},reset:function(){t.reset.call(this);this._doReset()},update:function(a){this._append(a);this._process();return this},finalize:function(a){a&&this._append(a);return this._doFinalize()},blockSize:16,_createHelper:function(a){return function(b,m){return(new a.init(m)).finalize(b)}},_createHmacHelper:function(a){return function(b,m){return(new w.HMAC.init(a,
|
||||
m)).finalize(b)}}});var w=e.algo={};return e}(Math);
|
||||
(function(){var q=CryptoJS,k=q.lib.WordArray;q.enc.Base64={stringify:function(e){var l=e.words,p=e.sigBytes,c=this._map;e.clamp();e=[];for(var k=0;k<p;k+=3)for(var b=(l[k>>>2]>>>24-8*(k%4)&255)<<16|(l[k+1>>>2]>>>24-8*((k+1)%4)&255)<<8|l[k+2>>>2]>>>24-8*((k+2)%4)&255,d=0;4>d&&k+0.75*d<p;d++)e.push(c.charAt(b>>>6*(3-d)&63));if(l=c.charAt(64))for(;e.length%4;)e.push(l);return e.join("")},parse:function(e){var l=e.length,p=this._map,c=p.charAt(64);c&&(c=e.indexOf(c),-1!=c&&(l=c));for(var c=[],s=0,b=0;b<
|
||||
l;b++)if(b%4){var d=p.indexOf(e.charAt(b-1))<<2*(b%4),a=p.indexOf(e.charAt(b))>>>6-2*(b%4);c[s>>>2]|=(d|a)<<24-8*(s%4);s++}return k.create(c,s)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}})();
|
||||
(function(q){function k(a,b,c,d,m,n,r){a=a+(b&c|~b&d)+m+r;return(a<<n|a>>>32-n)+b}function e(a,b,c,d,m,n,r){a=a+(b&d|c&~d)+m+r;return(a<<n|a>>>32-n)+b}function l(a,b,c,d,m,n,r){a=a+(b^c^d)+m+r;return(a<<n|a>>>32-n)+b}function p(a,b,c,d,m,n,r){a=a+(c^(b|~d))+m+r;return(a<<n|a>>>32-n)+b}for(var c=CryptoJS,s=c.lib,b=s.WordArray,d=s.Hasher,s=c.algo,a=[],u=0;64>u;u++)a[u]=4294967296*q.abs(q.sin(u+1))|0;s=s.MD5=d.extend({_doReset:function(){this._hash=new b.init([1732584193,4023233417,2562383102,271733878])},
|
||||
_doProcessBlock:function(b,c){for(var d=0;16>d;d++){var s=c+d,m=b[s];b[s]=(m<<8|m>>>24)&16711935|(m<<24|m>>>8)&4278255360}var d=this._hash.words,s=b[c+0],m=b[c+1],n=b[c+2],r=b[c+3],x=b[c+4],u=b[c+5],q=b[c+6],y=b[c+7],z=b[c+8],A=b[c+9],B=b[c+10],C=b[c+11],D=b[c+12],E=b[c+13],F=b[c+14],G=b[c+15],f=d[0],g=d[1],h=d[2],j=d[3],f=k(f,g,h,j,s,7,a[0]),j=k(j,f,g,h,m,12,a[1]),h=k(h,j,f,g,n,17,a[2]),g=k(g,h,j,f,r,22,a[3]),f=k(f,g,h,j,x,7,a[4]),j=k(j,f,g,h,u,12,a[5]),h=k(h,j,f,g,q,17,a[6]),g=k(g,h,j,f,y,22,a[7]),
|
||||
f=k(f,g,h,j,z,7,a[8]),j=k(j,f,g,h,A,12,a[9]),h=k(h,j,f,g,B,17,a[10]),g=k(g,h,j,f,C,22,a[11]),f=k(f,g,h,j,D,7,a[12]),j=k(j,f,g,h,E,12,a[13]),h=k(h,j,f,g,F,17,a[14]),g=k(g,h,j,f,G,22,a[15]),f=e(f,g,h,j,m,5,a[16]),j=e(j,f,g,h,q,9,a[17]),h=e(h,j,f,g,C,14,a[18]),g=e(g,h,j,f,s,20,a[19]),f=e(f,g,h,j,u,5,a[20]),j=e(j,f,g,h,B,9,a[21]),h=e(h,j,f,g,G,14,a[22]),g=e(g,h,j,f,x,20,a[23]),f=e(f,g,h,j,A,5,a[24]),j=e(j,f,g,h,F,9,a[25]),h=e(h,j,f,g,r,14,a[26]),g=e(g,h,j,f,z,20,a[27]),f=e(f,g,h,j,E,5,a[28]),j=e(j,f,
|
||||
g,h,n,9,a[29]),h=e(h,j,f,g,y,14,a[30]),g=e(g,h,j,f,D,20,a[31]),f=l(f,g,h,j,u,4,a[32]),j=l(j,f,g,h,z,11,a[33]),h=l(h,j,f,g,C,16,a[34]),g=l(g,h,j,f,F,23,a[35]),f=l(f,g,h,j,m,4,a[36]),j=l(j,f,g,h,x,11,a[37]),h=l(h,j,f,g,y,16,a[38]),g=l(g,h,j,f,B,23,a[39]),f=l(f,g,h,j,E,4,a[40]),j=l(j,f,g,h,s,11,a[41]),h=l(h,j,f,g,r,16,a[42]),g=l(g,h,j,f,q,23,a[43]),f=l(f,g,h,j,A,4,a[44]),j=l(j,f,g,h,D,11,a[45]),h=l(h,j,f,g,G,16,a[46]),g=l(g,h,j,f,n,23,a[47]),f=p(f,g,h,j,s,6,a[48]),j=p(j,f,g,h,y,10,a[49]),h=p(h,j,f,g,
|
||||
F,15,a[50]),g=p(g,h,j,f,u,21,a[51]),f=p(f,g,h,j,D,6,a[52]),j=p(j,f,g,h,r,10,a[53]),h=p(h,j,f,g,B,15,a[54]),g=p(g,h,j,f,m,21,a[55]),f=p(f,g,h,j,z,6,a[56]),j=p(j,f,g,h,G,10,a[57]),h=p(h,j,f,g,q,15,a[58]),g=p(g,h,j,f,E,21,a[59]),f=p(f,g,h,j,x,6,a[60]),j=p(j,f,g,h,C,10,a[61]),h=p(h,j,f,g,n,15,a[62]),g=p(g,h,j,f,A,21,a[63]);d[0]=d[0]+f|0;d[1]=d[1]+g|0;d[2]=d[2]+h|0;d[3]=d[3]+j|0},_doFinalize:function(){var a=this._data,b=a.words,c=8*this._nDataBytes,d=8*a.sigBytes;b[d>>>5]|=128<<24-d%32;var m=q.floor(c/
|
||||
4294967296);b[(d+64>>>9<<4)+15]=(m<<8|m>>>24)&16711935|(m<<24|m>>>8)&4278255360;b[(d+64>>>9<<4)+14]=(c<<8|c>>>24)&16711935|(c<<24|c>>>8)&4278255360;a.sigBytes=4*(b.length+1);this._process();a=this._hash;b=a.words;for(c=0;4>c;c++)d=b[c],b[c]=(d<<8|d>>>24)&16711935|(d<<24|d>>>8)&4278255360;return a},clone:function(){var a=d.clone.call(this);a._hash=this._hash.clone();return a}});c.MD5=d._createHelper(s);c.HmacMD5=d._createHmacHelper(s)})(Math);
|
||||
(function(){var q=CryptoJS,k=q.lib,e=k.Base,l=k.WordArray,k=q.algo,p=k.EvpKDF=e.extend({cfg:e.extend({keySize:4,hasher:k.MD5,iterations:1}),init:function(c){this.cfg=this.cfg.extend(c)},compute:function(c,e){for(var b=this.cfg,d=b.hasher.create(),a=l.create(),k=a.words,p=b.keySize,b=b.iterations;k.length<p;){q&&d.update(q);var q=d.update(c).finalize(e);d.reset();for(var v=1;v<b;v++)q=d.finalize(q),d.reset();a.concat(q)}a.sigBytes=4*p;return a}});q.EvpKDF=function(c,e,b){return p.create(b).compute(c,
|
||||
e)}})();
|
||||
CryptoJS.lib.Cipher||function(q){var k=CryptoJS,e=k.lib,l=e.Base,p=e.WordArray,c=e.BufferedBlockAlgorithm,s=k.enc.Base64,b=k.algo.EvpKDF,d=e.Cipher=c.extend({cfg:l.extend(),createEncryptor:function(a,b){return this.create(this._ENC_XFORM_MODE,a,b)},createDecryptor:function(a,b){return this.create(this._DEC_XFORM_MODE,a,b)},init:function(a,b,c){this.cfg=this.cfg.extend(c);this._xformMode=a;this._key=b;this.reset()},reset:function(){c.reset.call(this);this._doReset()},process:function(a){this._append(a);return this._process()},
|
||||
finalize:function(a){a&&this._append(a);return this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(a){return{encrypt:function(b,c,d){return("string"==typeof c?H:v).encrypt(a,b,c,d)},decrypt:function(b,c,d){return("string"==typeof c?H:v).decrypt(a,b,c,d)}}}});e.StreamCipher=d.extend({_doFinalize:function(){return this._process(!0)},blockSize:1});var a=k.mode={},u=function(a,b,c){var d=this._iv;d?this._iv=q:d=this._prevBlock;for(var e=0;e<c;e++)a[b+e]^=
|
||||
d[e]},t=(e.BlockCipherMode=l.extend({createEncryptor:function(a,b){return this.Encryptor.create(a,b)},createDecryptor:function(a,b){return this.Decryptor.create(a,b)},init:function(a,b){this._cipher=a;this._iv=b}})).extend();t.Encryptor=t.extend({processBlock:function(a,b){var c=this._cipher,d=c.blockSize;u.call(this,a,b,d);c.encryptBlock(a,b);this._prevBlock=a.slice(b,b+d)}});t.Decryptor=t.extend({processBlock:function(a,b){var c=this._cipher,d=c.blockSize,e=a.slice(b,b+d);c.decryptBlock(a,b);u.call(this,
|
||||
a,b,d);this._prevBlock=e}});a=a.CBC=t;t=(k.pad={}).Pkcs7={pad:function(a,b){for(var c=4*b,c=c-a.sigBytes%c,d=c<<24|c<<16|c<<8|c,e=[],k=0;k<c;k+=4)e.push(d);c=p.create(e,c);a.concat(c)},unpad:function(a){a.sigBytes-=a.words[a.sigBytes-1>>>2]&255}};e.BlockCipher=d.extend({cfg:d.cfg.extend({mode:a,padding:t}),reset:function(){d.reset.call(this);var a=this.cfg,b=a.iv,a=a.mode;if(this._xformMode==this._ENC_XFORM_MODE)var c=a.createEncryptor;else c=a.createDecryptor,this._minBufferSize=1;this._mode=c.call(a,
|
||||
this,b&&b.words)},_doProcessBlock:function(a,b){this._mode.processBlock(a,b)},_doFinalize:function(){var a=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){a.pad(this._data,this.blockSize);var b=this._process(!0)}else b=this._process(!0),a.unpad(b);return b},blockSize:4});var w=e.CipherParams=l.extend({init:function(a){this.mixIn(a)},toString:function(a){return(a||this.formatter).stringify(this)}}),a=(k.format={}).OpenSSL={stringify:function(a){var b=a.ciphertext;a=a.salt;return(a?p.create([1398893684,
|
||||
1701076831]).concat(a).concat(b):b).toString(s)},parse:function(a){a=s.parse(a);var b=a.words;if(1398893684==b[0]&&1701076831==b[1]){var c=p.create(b.slice(2,4));b.splice(0,4);a.sigBytes-=16}return w.create({ciphertext:a,salt:c})}},v=e.SerializableCipher=l.extend({cfg:l.extend({format:a}),encrypt:function(a,b,c,d){d=this.cfg.extend(d);var e=a.createEncryptor(c,d);b=e.finalize(b);e=e.cfg;return w.create({ciphertext:b,key:c,iv:e.iv,algorithm:a,mode:e.mode,padding:e.padding,blockSize:a.blockSize,formatter:d.format})},
|
||||
decrypt:function(a,b,c,d){d=this.cfg.extend(d);b=this._parse(b,d.format);return a.createDecryptor(c,d).finalize(b.ciphertext)},_parse:function(a,b){return"string"==typeof a?b.parse(a,this):a}}),k=(k.kdf={}).OpenSSL={execute:function(a,c,d,e){e||(e=p.random(8));a=b.create({keySize:c+d}).compute(a,e);d=p.create(a.words.slice(c),4*d);a.sigBytes=4*c;return w.create({key:a,iv:d,salt:e})}},H=e.PasswordBasedCipher=v.extend({cfg:v.cfg.extend({kdf:k}),encrypt:function(a,b,c,d){d=this.cfg.extend(d);c=d.kdf.execute(c,
|
||||
a.keySize,a.ivSize);d.iv=c.iv;a=v.encrypt.call(this,a,b,c.key,d);a.mixIn(c);return a},decrypt:function(a,b,c,d){d=this.cfg.extend(d);b=this._parse(b,d.format);c=d.kdf.execute(c,a.keySize,a.ivSize,b.salt);d.iv=c.iv;return v.decrypt.call(this,a,b,c.key,d)}})}();
|
||||
(function(){function q(){for(var b=this._X,d=this._C,a=0;8>a;a++)p[a]=d[a];d[0]=d[0]+1295307597+this._b|0;d[1]=d[1]+3545052371+(d[0]>>>0<p[0]>>>0?1:0)|0;d[2]=d[2]+886263092+(d[1]>>>0<p[1]>>>0?1:0)|0;d[3]=d[3]+1295307597+(d[2]>>>0<p[2]>>>0?1:0)|0;d[4]=d[4]+3545052371+(d[3]>>>0<p[3]>>>0?1:0)|0;d[5]=d[5]+886263092+(d[4]>>>0<p[4]>>>0?1:0)|0;d[6]=d[6]+1295307597+(d[5]>>>0<p[5]>>>0?1:0)|0;d[7]=d[7]+3545052371+(d[6]>>>0<p[6]>>>0?1:0)|0;this._b=d[7]>>>0<p[7]>>>0?1:0;for(a=0;8>a;a++){var e=b[a]+d[a],k=e&65535,
|
||||
l=e>>>16;c[a]=((k*k>>>17)+k*l>>>15)+l*l^((e&4294901760)*e|0)+((e&65535)*e|0)}b[0]=c[0]+(c[7]<<16|c[7]>>>16)+(c[6]<<16|c[6]>>>16)|0;b[1]=c[1]+(c[0]<<8|c[0]>>>24)+c[7]|0;b[2]=c[2]+(c[1]<<16|c[1]>>>16)+(c[0]<<16|c[0]>>>16)|0;b[3]=c[3]+(c[2]<<8|c[2]>>>24)+c[1]|0;b[4]=c[4]+(c[3]<<16|c[3]>>>16)+(c[2]<<16|c[2]>>>16)|0;b[5]=c[5]+(c[4]<<8|c[4]>>>24)+c[3]|0;b[6]=c[6]+(c[5]<<16|c[5]>>>16)+(c[4]<<16|c[4]>>>16)|0;b[7]=c[7]+(c[6]<<8|c[6]>>>24)+c[5]|0}var k=CryptoJS,e=k.lib.StreamCipher,l=[],p=[],c=[],s=k.algo.Rabbit=
|
||||
e.extend({_doReset:function(){for(var b=this._key.words,c=this.cfg.iv,a=0;4>a;a++)b[a]=(b[a]<<8|b[a]>>>24)&16711935|(b[a]<<24|b[a]>>>8)&4278255360;for(var e=this._X=[b[0],b[3]<<16|b[2]>>>16,b[1],b[0]<<16|b[3]>>>16,b[2],b[1]<<16|b[0]>>>16,b[3],b[2]<<16|b[1]>>>16],b=this._C=[b[2]<<16|b[2]>>>16,b[0]&4294901760|b[1]&65535,b[3]<<16|b[3]>>>16,b[1]&4294901760|b[2]&65535,b[0]<<16|b[0]>>>16,b[2]&4294901760|b[3]&65535,b[1]<<16|b[1]>>>16,b[3]&4294901760|b[0]&65535],a=this._b=0;4>a;a++)q.call(this);for(a=0;8>
|
||||
a;a++)b[a]^=e[a+4&7];if(c){var a=c.words,c=a[0],a=a[1],c=(c<<8|c>>>24)&16711935|(c<<24|c>>>8)&4278255360,a=(a<<8|a>>>24)&16711935|(a<<24|a>>>8)&4278255360,e=c>>>16|a&4294901760,k=a<<16|c&65535;b[0]^=c;b[1]^=e;b[2]^=a;b[3]^=k;b[4]^=c;b[5]^=e;b[6]^=a;b[7]^=k;for(a=0;4>a;a++)q.call(this)}},_doProcessBlock:function(b,c){var a=this._X;q.call(this);l[0]=a[0]^a[5]>>>16^a[3]<<16;l[1]=a[2]^a[7]>>>16^a[5]<<16;l[2]=a[4]^a[1]>>>16^a[7]<<16;l[3]=a[6]^a[3]>>>16^a[1]<<16;for(a=0;4>a;a++)l[a]=(l[a]<<8|l[a]>>>24)&
|
||||
16711935|(l[a]<<24|l[a]>>>8)&4278255360,b[c+a]^=l[a]},blockSize:4,ivSize:2});k.Rabbit=e._createHelper(s)})();
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
CryptoJS v3.1.2
|
||||
code.google.com/p/crypto-js
|
||||
(c) 2009-2013 by Jeff Mott. All rights reserved.
|
||||
code.google.com/p/crypto-js/wiki/License
|
||||
*/
|
||||
var CryptoJS=CryptoJS||function(s,l){var e={},n=e.lib={},p=function(){},b=n.Base={extend:function(c){p.prototype=this;var a=new p;c&&a.mixIn(c);a.hasOwnProperty("init")||(a.init=function(){a.$super.init.apply(this,arguments)});a.init.prototype=a;a.$super=this;return a},create:function(){var c=this.extend();c.init.apply(c,arguments);return c},init:function(){},mixIn:function(c){for(var a in c)c.hasOwnProperty(a)&&(this[a]=c[a]);c.hasOwnProperty("toString")&&(this.toString=c.toString)},clone:function(){return this.init.prototype.extend(this)}},
|
||||
d=n.WordArray=b.extend({init:function(c,a){c=this.words=c||[];this.sigBytes=a!=l?a:4*c.length},toString:function(c){return(c||q).stringify(this)},concat:function(c){var a=this.words,m=c.words,f=this.sigBytes;c=c.sigBytes;this.clamp();if(f%4)for(var r=0;r<c;r++)a[f+r>>>2]|=(m[r>>>2]>>>24-8*(r%4)&255)<<24-8*((f+r)%4);else if(65535<m.length)for(r=0;r<c;r+=4)a[f+r>>>2]=m[r>>>2];else a.push.apply(a,m);this.sigBytes+=c;return this},clamp:function(){var c=this.words,a=this.sigBytes;c[a>>>2]&=4294967295<<
|
||||
32-8*(a%4);c.length=s.ceil(a/4)},clone:function(){var c=b.clone.call(this);c.words=this.words.slice(0);return c},random:function(c){for(var a=[],m=0;m<c;m+=4)a.push(4294967296*s.random()|0);return new d.init(a,c)}}),t=e.enc={},q=t.Hex={stringify:function(c){var a=c.words;c=c.sigBytes;for(var m=[],f=0;f<c;f++){var r=a[f>>>2]>>>24-8*(f%4)&255;m.push((r>>>4).toString(16));m.push((r&15).toString(16))}return m.join("")},parse:function(c){for(var a=c.length,m=[],f=0;f<a;f+=2)m[f>>>3]|=parseInt(c.substr(f,
|
||||
2),16)<<24-4*(f%8);return new d.init(m,a/2)}},a=t.Latin1={stringify:function(c){var a=c.words;c=c.sigBytes;for(var m=[],f=0;f<c;f++)m.push(String.fromCharCode(a[f>>>2]>>>24-8*(f%4)&255));return m.join("")},parse:function(c){for(var a=c.length,m=[],f=0;f<a;f++)m[f>>>2]|=(c.charCodeAt(f)&255)<<24-8*(f%4);return new d.init(m,a)}},v=t.Utf8={stringify:function(c){try{return decodeURIComponent(escape(a.stringify(c)))}catch(u){throw Error("Malformed UTF-8 data");}},parse:function(c){return a.parse(unescape(encodeURIComponent(c)))}},
|
||||
u=n.BufferedBlockAlgorithm=b.extend({reset:function(){this._data=new d.init;this._nDataBytes=0},_append:function(a){"string"==typeof a&&(a=v.parse(a));this._data.concat(a);this._nDataBytes+=a.sigBytes},_process:function(a){var u=this._data,m=u.words,f=u.sigBytes,r=this.blockSize,e=f/(4*r),e=a?s.ceil(e):s.max((e|0)-this._minBufferSize,0);a=e*r;f=s.min(4*a,f);if(a){for(var b=0;b<a;b+=r)this._doProcessBlock(m,b);b=m.splice(0,a);u.sigBytes-=f}return new d.init(b,f)},clone:function(){var a=b.clone.call(this);
|
||||
a._data=this._data.clone();return a},_minBufferSize:0});n.Hasher=u.extend({cfg:b.extend(),init:function(a){this.cfg=this.cfg.extend(a);this.reset()},reset:function(){u.reset.call(this);this._doReset()},update:function(a){this._append(a);this._process();return this},finalize:function(a){a&&this._append(a);return this._doFinalize()},blockSize:16,_createHelper:function(a){return function(u,m){return(new a.init(m)).finalize(u)}},_createHmacHelper:function(a){return function(u,m){return(new w.HMAC.init(a,
|
||||
m)).finalize(u)}}});var w=e.algo={};return e}(Math);
|
||||
(function(){var s=CryptoJS,l=s.lib.WordArray;s.enc.Base64={stringify:function(e){var n=e.words,l=e.sigBytes,b=this._map;e.clamp();e=[];for(var d=0;d<l;d+=3)for(var t=(n[d>>>2]>>>24-8*(d%4)&255)<<16|(n[d+1>>>2]>>>24-8*((d+1)%4)&255)<<8|n[d+2>>>2]>>>24-8*((d+2)%4)&255,q=0;4>q&&d+0.75*q<l;q++)e.push(b.charAt(t>>>6*(3-q)&63));if(n=b.charAt(64))for(;e.length%4;)e.push(n);return e.join("")},parse:function(e){var n=e.length,p=this._map,b=p.charAt(64);b&&(b=e.indexOf(b),-1!=b&&(n=b));for(var b=[],d=0,t=0;t<
|
||||
n;t++)if(t%4){var q=p.indexOf(e.charAt(t-1))<<2*(t%4),a=p.indexOf(e.charAt(t))>>>6-2*(t%4);b[d>>>2]|=(q|a)<<24-8*(d%4);d++}return l.create(b,d)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}})();
|
||||
(function(s){function l(a,b,c,e,m,f,r){a=a+(b&c|~b&e)+m+r;return(a<<f|a>>>32-f)+b}function e(a,b,c,e,m,f,r){a=a+(b&e|c&~e)+m+r;return(a<<f|a>>>32-f)+b}function n(a,b,c,e,m,f,r){a=a+(b^c^e)+m+r;return(a<<f|a>>>32-f)+b}function p(a,b,c,e,m,f,r){a=a+(c^(b|~e))+m+r;return(a<<f|a>>>32-f)+b}for(var b=CryptoJS,d=b.lib,t=d.WordArray,q=d.Hasher,d=b.algo,a=[],v=0;64>v;v++)a[v]=4294967296*s.abs(s.sin(v+1))|0;d=d.MD5=q.extend({_doReset:function(){this._hash=new t.init([1732584193,4023233417,2562383102,271733878])},
|
||||
_doProcessBlock:function(b,d){for(var c=0;16>c;c++){var q=d+c,m=b[q];b[q]=(m<<8|m>>>24)&16711935|(m<<24|m>>>8)&4278255360}var c=this._hash.words,q=b[d+0],m=b[d+1],f=b[d+2],r=b[d+3],x=b[d+4],t=b[d+5],s=b[d+6],v=b[d+7],y=b[d+8],z=b[d+9],A=b[d+10],B=b[d+11],C=b[d+12],D=b[d+13],E=b[d+14],F=b[d+15],g=c[0],h=c[1],j=c[2],k=c[3],g=l(g,h,j,k,q,7,a[0]),k=l(k,g,h,j,m,12,a[1]),j=l(j,k,g,h,f,17,a[2]),h=l(h,j,k,g,r,22,a[3]),g=l(g,h,j,k,x,7,a[4]),k=l(k,g,h,j,t,12,a[5]),j=l(j,k,g,h,s,17,a[6]),h=l(h,j,k,g,v,22,a[7]),
|
||||
g=l(g,h,j,k,y,7,a[8]),k=l(k,g,h,j,z,12,a[9]),j=l(j,k,g,h,A,17,a[10]),h=l(h,j,k,g,B,22,a[11]),g=l(g,h,j,k,C,7,a[12]),k=l(k,g,h,j,D,12,a[13]),j=l(j,k,g,h,E,17,a[14]),h=l(h,j,k,g,F,22,a[15]),g=e(g,h,j,k,m,5,a[16]),k=e(k,g,h,j,s,9,a[17]),j=e(j,k,g,h,B,14,a[18]),h=e(h,j,k,g,q,20,a[19]),g=e(g,h,j,k,t,5,a[20]),k=e(k,g,h,j,A,9,a[21]),j=e(j,k,g,h,F,14,a[22]),h=e(h,j,k,g,x,20,a[23]),g=e(g,h,j,k,z,5,a[24]),k=e(k,g,h,j,E,9,a[25]),j=e(j,k,g,h,r,14,a[26]),h=e(h,j,k,g,y,20,a[27]),g=e(g,h,j,k,D,5,a[28]),k=e(k,g,
|
||||
h,j,f,9,a[29]),j=e(j,k,g,h,v,14,a[30]),h=e(h,j,k,g,C,20,a[31]),g=n(g,h,j,k,t,4,a[32]),k=n(k,g,h,j,y,11,a[33]),j=n(j,k,g,h,B,16,a[34]),h=n(h,j,k,g,E,23,a[35]),g=n(g,h,j,k,m,4,a[36]),k=n(k,g,h,j,x,11,a[37]),j=n(j,k,g,h,v,16,a[38]),h=n(h,j,k,g,A,23,a[39]),g=n(g,h,j,k,D,4,a[40]),k=n(k,g,h,j,q,11,a[41]),j=n(j,k,g,h,r,16,a[42]),h=n(h,j,k,g,s,23,a[43]),g=n(g,h,j,k,z,4,a[44]),k=n(k,g,h,j,C,11,a[45]),j=n(j,k,g,h,F,16,a[46]),h=n(h,j,k,g,f,23,a[47]),g=p(g,h,j,k,q,6,a[48]),k=p(k,g,h,j,v,10,a[49]),j=p(j,k,g,h,
|
||||
E,15,a[50]),h=p(h,j,k,g,t,21,a[51]),g=p(g,h,j,k,C,6,a[52]),k=p(k,g,h,j,r,10,a[53]),j=p(j,k,g,h,A,15,a[54]),h=p(h,j,k,g,m,21,a[55]),g=p(g,h,j,k,y,6,a[56]),k=p(k,g,h,j,F,10,a[57]),j=p(j,k,g,h,s,15,a[58]),h=p(h,j,k,g,D,21,a[59]),g=p(g,h,j,k,x,6,a[60]),k=p(k,g,h,j,B,10,a[61]),j=p(j,k,g,h,f,15,a[62]),h=p(h,j,k,g,z,21,a[63]);c[0]=c[0]+g|0;c[1]=c[1]+h|0;c[2]=c[2]+j|0;c[3]=c[3]+k|0},_doFinalize:function(){var a=this._data,b=a.words,c=8*this._nDataBytes,d=8*a.sigBytes;b[d>>>5]|=128<<24-d%32;var m=s.floor(c/
|
||||
4294967296);b[(d+64>>>9<<4)+15]=(m<<8|m>>>24)&16711935|(m<<24|m>>>8)&4278255360;b[(d+64>>>9<<4)+14]=(c<<8|c>>>24)&16711935|(c<<24|c>>>8)&4278255360;a.sigBytes=4*(b.length+1);this._process();a=this._hash;b=a.words;for(c=0;4>c;c++)d=b[c],b[c]=(d<<8|d>>>24)&16711935|(d<<24|d>>>8)&4278255360;return a},clone:function(){var a=q.clone.call(this);a._hash=this._hash.clone();return a}});b.MD5=q._createHelper(d);b.HmacMD5=q._createHmacHelper(d)})(Math);
|
||||
(function(){var s=CryptoJS,l=s.lib,e=l.Base,n=l.WordArray,l=s.algo,p=l.EvpKDF=e.extend({cfg:e.extend({keySize:4,hasher:l.MD5,iterations:1}),init:function(b){this.cfg=this.cfg.extend(b)},compute:function(b,d){for(var e=this.cfg,q=e.hasher.create(),a=n.create(),l=a.words,p=e.keySize,e=e.iterations;l.length<p;){s&&q.update(s);var s=q.update(b).finalize(d);q.reset();for(var c=1;c<e;c++)s=q.finalize(s),q.reset();a.concat(s)}a.sigBytes=4*p;return a}});s.EvpKDF=function(b,d,e){return p.create(e).compute(b,
|
||||
d)}})();
|
||||
CryptoJS.lib.Cipher||function(s){var l=CryptoJS,e=l.lib,n=e.Base,p=e.WordArray,b=e.BufferedBlockAlgorithm,d=l.enc.Base64,t=l.algo.EvpKDF,q=e.Cipher=b.extend({cfg:n.extend(),createEncryptor:function(a,f){return this.create(this._ENC_XFORM_MODE,a,f)},createDecryptor:function(a,f){return this.create(this._DEC_XFORM_MODE,a,f)},init:function(a,f,c){this.cfg=this.cfg.extend(c);this._xformMode=a;this._key=f;this.reset()},reset:function(){b.reset.call(this);this._doReset()},process:function(a){this._append(a);return this._process()},
|
||||
finalize:function(a){a&&this._append(a);return this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(a){return{encrypt:function(f,b,d){return("string"==typeof b?G:c).encrypt(a,f,b,d)},decrypt:function(f,b,d){return("string"==typeof b?G:c).decrypt(a,f,b,d)}}}});e.StreamCipher=q.extend({_doFinalize:function(){return this._process(!0)},blockSize:1});var a=l.mode={},v=function(a,f,b){var c=this._iv;c?this._iv=s:c=this._prevBlock;for(var d=0;d<b;d++)a[f+d]^=
|
||||
c[d]},u=(e.BlockCipherMode=n.extend({createEncryptor:function(a,f){return this.Encryptor.create(a,f)},createDecryptor:function(a,f){return this.Decryptor.create(a,f)},init:function(a,f){this._cipher=a;this._iv=f}})).extend();u.Encryptor=u.extend({processBlock:function(a,f){var b=this._cipher,c=b.blockSize;v.call(this,a,f,c);b.encryptBlock(a,f);this._prevBlock=a.slice(f,f+c)}});u.Decryptor=u.extend({processBlock:function(a,f){var b=this._cipher,c=b.blockSize,d=a.slice(f,f+c);b.decryptBlock(a,f);v.call(this,
|
||||
a,f,c);this._prevBlock=d}});a=a.CBC=u;u=(l.pad={}).Pkcs7={pad:function(a,f){for(var b=4*f,b=b-a.sigBytes%b,c=b<<24|b<<16|b<<8|b,d=[],e=0;e<b;e+=4)d.push(c);b=p.create(d,b);a.concat(b)},unpad:function(a){a.sigBytes-=a.words[a.sigBytes-1>>>2]&255}};e.BlockCipher=q.extend({cfg:q.cfg.extend({mode:a,padding:u}),reset:function(){q.reset.call(this);var a=this.cfg,b=a.iv,a=a.mode;if(this._xformMode==this._ENC_XFORM_MODE)var c=a.createEncryptor;else c=a.createDecryptor,this._minBufferSize=1;this._mode=c.call(a,
|
||||
this,b&&b.words)},_doProcessBlock:function(a,b){this._mode.processBlock(a,b)},_doFinalize:function(){var a=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){a.pad(this._data,this.blockSize);var b=this._process(!0)}else b=this._process(!0),a.unpad(b);return b},blockSize:4});var w=e.CipherParams=n.extend({init:function(a){this.mixIn(a)},toString:function(a){return(a||this.formatter).stringify(this)}}),a=(l.format={}).OpenSSL={stringify:function(a){var b=a.ciphertext;a=a.salt;return(a?p.create([1398893684,
|
||||
1701076831]).concat(a).concat(b):b).toString(d)},parse:function(a){a=d.parse(a);var b=a.words;if(1398893684==b[0]&&1701076831==b[1]){var c=p.create(b.slice(2,4));b.splice(0,4);a.sigBytes-=16}return w.create({ciphertext:a,salt:c})}},c=e.SerializableCipher=n.extend({cfg:n.extend({format:a}),encrypt:function(a,b,c,d){d=this.cfg.extend(d);var e=a.createEncryptor(c,d);b=e.finalize(b);e=e.cfg;return w.create({ciphertext:b,key:c,iv:e.iv,algorithm:a,mode:e.mode,padding:e.padding,blockSize:a.blockSize,formatter:d.format})},
|
||||
decrypt:function(a,b,c,d){d=this.cfg.extend(d);b=this._parse(b,d.format);return a.createDecryptor(c,d).finalize(b.ciphertext)},_parse:function(a,b){return"string"==typeof a?b.parse(a,this):a}}),l=(l.kdf={}).OpenSSL={execute:function(a,b,c,d){d||(d=p.random(8));a=t.create({keySize:b+c}).compute(a,d);c=p.create(a.words.slice(b),4*c);a.sigBytes=4*b;return w.create({key:a,iv:c,salt:d})}},G=e.PasswordBasedCipher=c.extend({cfg:c.cfg.extend({kdf:l}),encrypt:function(a,b,d,e){e=this.cfg.extend(e);d=e.kdf.execute(d,
|
||||
a.keySize,a.ivSize);e.iv=d.iv;a=c.encrypt.call(this,a,b,d.key,e);a.mixIn(d);return a},decrypt:function(a,b,d,e){e=this.cfg.extend(e);b=this._parse(b,e.format);d=e.kdf.execute(d,a.keySize,a.ivSize,b.salt);e.iv=d.iv;return c.decrypt.call(this,a,b,d.key,e)}})}();
|
||||
(function(){function s(){for(var b=this._S,d=this._i,e=this._j,q=0,a=0;4>a;a++){var d=(d+1)%256,e=(e+b[d])%256,l=b[d];b[d]=b[e];b[e]=l;q|=b[(b[d]+b[e])%256]<<24-8*a}this._i=d;this._j=e;return q}var l=CryptoJS,e=l.lib.StreamCipher,n=l.algo,p=n.RC4=e.extend({_doReset:function(){for(var b=this._key,d=b.words,b=b.sigBytes,e=this._S=[],l=0;256>l;l++)e[l]=l;for(var a=l=0;256>l;l++){var n=l%b,a=(a+e[l]+(d[n>>>2]>>>24-8*(n%4)&255))%256,n=e[l];e[l]=e[a];e[a]=n}this._i=this._j=0},_doProcessBlock:function(b,
|
||||
d){b[d]^=s.call(this)},keySize:8,ivSize:0});l.RC4=e._createHelper(p);n=n.RC4Drop=p.extend({cfg:p.cfg.extend({drop:192}),_doReset:function(){p._doReset.call(this);for(var b=this.cfg.drop;0<b;b--)s.call(this)}});l.RC4Drop=e._createHelper(n)})();
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
CryptoJS v3.1.2
|
||||
code.google.com/p/crypto-js
|
||||
(c) 2009-2013 by Jeff Mott. All rights reserved.
|
||||
code.google.com/p/crypto-js/wiki/License
|
||||
*/
|
||||
/*
|
||||
|
||||
(c) 2012 by C?dric Mesnil. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
var CryptoJS=CryptoJS||function(j,k){var e={},l=e.lib={},z=function(){},t=l.Base={extend:function(a){z.prototype=this;var c=new z;a&&c.mixIn(a);c.hasOwnProperty("init")||(c.init=function(){c.$super.init.apply(this,arguments)});c.init.prototype=c;c.$super=this;return c},create:function(){var a=this.extend();a.init.apply(a,arguments);return a},init:function(){},mixIn:function(a){for(var c in a)a.hasOwnProperty(c)&&(this[c]=a[c]);a.hasOwnProperty("toString")&&(this.toString=a.toString)},clone:function(){return this.init.prototype.extend(this)}},
|
||||
u=l.WordArray=t.extend({init:function(a,c){a=this.words=a||[];this.sigBytes=c!=k?c:4*a.length},toString:function(a){return(a||D).stringify(this)},concat:function(a){var c=this.words,h=a.words,d=this.sigBytes;a=a.sigBytes;this.clamp();if(d%4)for(var b=0;b<a;b++)c[d+b>>>2]|=(h[b>>>2]>>>24-8*(b%4)&255)<<24-8*((d+b)%4);else if(65535<h.length)for(b=0;b<a;b+=4)c[d+b>>>2]=h[b>>>2];else c.push.apply(c,h);this.sigBytes+=a;return this},clamp:function(){var a=this.words,c=this.sigBytes;a[c>>>2]&=4294967295<<
|
||||
32-8*(c%4);a.length=j.ceil(c/4)},clone:function(){var a=t.clone.call(this);a.words=this.words.slice(0);return a},random:function(a){for(var c=[],b=0;b<a;b+=4)c.push(4294967296*j.random()|0);return new u.init(c,a)}}),w=e.enc={},D=w.Hex={stringify:function(a){var c=a.words;a=a.sigBytes;for(var b=[],d=0;d<a;d++){var g=c[d>>>2]>>>24-8*(d%4)&255;b.push((g>>>4).toString(16));b.push((g&15).toString(16))}return b.join("")},parse:function(a){for(var c=a.length,b=[],d=0;d<c;d+=2)b[d>>>3]|=parseInt(a.substr(d,
|
||||
2),16)<<24-4*(d%8);return new u.init(b,c/2)}},A=w.Latin1={stringify:function(a){var c=a.words;a=a.sigBytes;for(var b=[],d=0;d<a;d++)b.push(String.fromCharCode(c[d>>>2]>>>24-8*(d%4)&255));return b.join("")},parse:function(a){for(var b=a.length,h=[],d=0;d<b;d++)h[d>>>2]|=(a.charCodeAt(d)&255)<<24-8*(d%4);return new u.init(h,b)}},g=w.Utf8={stringify:function(a){try{return decodeURIComponent(escape(A.stringify(a)))}catch(b){throw Error("Malformed UTF-8 data");}},parse:function(a){return A.parse(unescape(encodeURIComponent(a)))}},
|
||||
v=l.BufferedBlockAlgorithm=t.extend({reset:function(){this._data=new u.init;this._nDataBytes=0},_append:function(a){"string"==typeof a&&(a=g.parse(a));this._data.concat(a);this._nDataBytes+=a.sigBytes},_process:function(a){var b=this._data,h=b.words,d=b.sigBytes,g=this.blockSize,v=d/(4*g),v=a?j.ceil(v):j.max((v|0)-this._minBufferSize,0);a=v*g;d=j.min(4*a,d);if(a){for(var e=0;e<a;e+=g)this._doProcessBlock(h,e);e=h.splice(0,a);b.sigBytes-=d}return new u.init(e,d)},clone:function(){var a=t.clone.call(this);
|
||||
a._data=this._data.clone();return a},_minBufferSize:0});l.Hasher=v.extend({cfg:t.extend(),init:function(a){this.cfg=this.cfg.extend(a);this.reset()},reset:function(){v.reset.call(this);this._doReset()},update:function(a){this._append(a);this._process();return this},finalize:function(a){a&&this._append(a);return this._doFinalize()},blockSize:16,_createHelper:function(a){return function(b,g){return(new a.init(g)).finalize(b)}},_createHmacHelper:function(a){return function(c,g){return(new b.HMAC.init(a,
|
||||
g)).finalize(c)}}});var b=e.algo={};return e}(Math);
|
||||
(function(){var j=CryptoJS,k=j.lib,e=k.WordArray,l=k.Hasher,k=j.algo,z=e.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),t=e.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),u=e.create([11,14,15,12,
|
||||
5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),w=e.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),D=e.create([0,1518500249,1859775393,2400959708,2840853838]),A=e.create([1352829926,1548603684,1836072691,
|
||||
2053994217,0]),k=k.RIPEMD160=l.extend({_doReset:function(){this._hash=e.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(g,e){for(var b=0;16>b;b++){var a=e+b,c=g[a];g[a]=(c<<8|c>>>24)&16711935|(c<<24|c>>>8)&4278255360}var a=this._hash.words,c=D.words,h=A.words,d=z.words,j=t.words,k=u.words,l=w.words,B,m,n,p,x,C,q,r,s,y;C=B=a[0];q=m=a[1];r=n=a[2];s=p=a[3];y=x=a[4];for(var f,b=0;80>b;b+=1)f=B+g[e+d[b]]|0,f=16>b?f+((m^n^p)+c[0]):32>b?f+((m&n|~m&p)+c[1]):48>b?
|
||||
f+(((m|~n)^p)+c[2]):64>b?f+((m&p|n&~p)+c[3]):f+((m^(n|~p))+c[4]),f|=0,f=f<<k[b]|f>>>32-k[b],f=f+x|0,B=x,x=p,p=n<<10|n>>>22,n=m,m=f,f=C+g[e+j[b]]|0,f=16>b?f+((q^(r|~s))+h[0]):32>b?f+((q&s|r&~s)+h[1]):48>b?f+(((q|~r)^s)+h[2]):64>b?f+((q&r|~q&s)+h[3]):f+((q^r^s)+h[4]),f|=0,f=f<<l[b]|f>>>32-l[b],f=f+y|0,C=y,y=s,s=r<<10|r>>>22,r=q,q=f;f=a[1]+n+s|0;a[1]=a[2]+p+y|0;a[2]=a[3]+x+C|0;a[3]=a[4]+B+q|0;a[4]=a[0]+m+r|0;a[0]=f},_doFinalize:function(){var g=this._data,e=g.words,b=8*this._nDataBytes,a=8*g.sigBytes;
|
||||
e[a>>>5]|=128<<24-a%32;e[(a+64>>>9<<4)+14]=(b<<8|b>>>24)&16711935|(b<<24|b>>>8)&4278255360;g.sigBytes=4*(e.length+1);this._process();g=this._hash;e=g.words;for(b=0;5>b;b++)a=e[b],e[b]=(a<<8|a>>>24)&16711935|(a<<24|a>>>8)&4278255360;return g},clone:function(){var e=l.clone.call(this);e._hash=this._hash.clone();return e}});j.RIPEMD160=l._createHelper(k);j.HmacRIPEMD160=l._createHmacHelper(k)})(Math);
|
||||
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
CryptoJS v3.1.2
|
||||
code.google.com/p/crypto-js
|
||||
(c) 2009-2013 by Jeff Mott. All rights reserved.
|
||||
code.google.com/p/crypto-js/wiki/License
|
||||
*/
|
||||
var CryptoJS=CryptoJS||function(e,m){var p={},j=p.lib={},l=function(){},f=j.Base={extend:function(a){l.prototype=this;var c=new l;a&&c.mixIn(a);c.hasOwnProperty("init")||(c.init=function(){c.$super.init.apply(this,arguments)});c.init.prototype=c;c.$super=this;return c},create:function(){var a=this.extend();a.init.apply(a,arguments);return a},init:function(){},mixIn:function(a){for(var c in a)a.hasOwnProperty(c)&&(this[c]=a[c]);a.hasOwnProperty("toString")&&(this.toString=a.toString)},clone:function(){return this.init.prototype.extend(this)}},
|
||||
n=j.WordArray=f.extend({init:function(a,c){a=this.words=a||[];this.sigBytes=c!=m?c:4*a.length},toString:function(a){return(a||h).stringify(this)},concat:function(a){var c=this.words,q=a.words,d=this.sigBytes;a=a.sigBytes;this.clamp();if(d%4)for(var b=0;b<a;b++)c[d+b>>>2]|=(q[b>>>2]>>>24-8*(b%4)&255)<<24-8*((d+b)%4);else if(65535<q.length)for(b=0;b<a;b+=4)c[d+b>>>2]=q[b>>>2];else c.push.apply(c,q);this.sigBytes+=a;return this},clamp:function(){var a=this.words,c=this.sigBytes;a[c>>>2]&=4294967295<<
|
||||
32-8*(c%4);a.length=e.ceil(c/4)},clone:function(){var a=f.clone.call(this);a.words=this.words.slice(0);return a},random:function(a){for(var c=[],b=0;b<a;b+=4)c.push(4294967296*e.random()|0);return new n.init(c,a)}}),b=p.enc={},h=b.Hex={stringify:function(a){var c=a.words;a=a.sigBytes;for(var b=[],d=0;d<a;d++){var f=c[d>>>2]>>>24-8*(d%4)&255;b.push((f>>>4).toString(16));b.push((f&15).toString(16))}return b.join("")},parse:function(a){for(var c=a.length,b=[],d=0;d<c;d+=2)b[d>>>3]|=parseInt(a.substr(d,
|
||||
2),16)<<24-4*(d%8);return new n.init(b,c/2)}},g=b.Latin1={stringify:function(a){var c=a.words;a=a.sigBytes;for(var b=[],d=0;d<a;d++)b.push(String.fromCharCode(c[d>>>2]>>>24-8*(d%4)&255));return b.join("")},parse:function(a){for(var c=a.length,b=[],d=0;d<c;d++)b[d>>>2]|=(a.charCodeAt(d)&255)<<24-8*(d%4);return new n.init(b,c)}},r=b.Utf8={stringify:function(a){try{return decodeURIComponent(escape(g.stringify(a)))}catch(c){throw Error("Malformed UTF-8 data");}},parse:function(a){return g.parse(unescape(encodeURIComponent(a)))}},
|
||||
k=j.BufferedBlockAlgorithm=f.extend({reset:function(){this._data=new n.init;this._nDataBytes=0},_append:function(a){"string"==typeof a&&(a=r.parse(a));this._data.concat(a);this._nDataBytes+=a.sigBytes},_process:function(a){var c=this._data,b=c.words,d=c.sigBytes,f=this.blockSize,h=d/(4*f),h=a?e.ceil(h):e.max((h|0)-this._minBufferSize,0);a=h*f;d=e.min(4*a,d);if(a){for(var g=0;g<a;g+=f)this._doProcessBlock(b,g);g=b.splice(0,a);c.sigBytes-=d}return new n.init(g,d)},clone:function(){var a=f.clone.call(this);
|
||||
a._data=this._data.clone();return a},_minBufferSize:0});j.Hasher=k.extend({cfg:f.extend(),init:function(a){this.cfg=this.cfg.extend(a);this.reset()},reset:function(){k.reset.call(this);this._doReset()},update:function(a){this._append(a);this._process();return this},finalize:function(a){a&&this._append(a);return this._doFinalize()},blockSize:16,_createHelper:function(a){return function(c,b){return(new a.init(b)).finalize(c)}},_createHmacHelper:function(a){return function(b,f){return(new s.HMAC.init(a,
|
||||
f)).finalize(b)}}});var s=p.algo={};return p}(Math);
|
||||
(function(){var e=CryptoJS,m=e.lib,p=m.WordArray,j=m.Hasher,l=[],m=e.algo.SHA1=j.extend({_doReset:function(){this._hash=new p.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(f,n){for(var b=this._hash.words,h=b[0],g=b[1],e=b[2],k=b[3],j=b[4],a=0;80>a;a++){if(16>a)l[a]=f[n+a]|0;else{var c=l[a-3]^l[a-8]^l[a-14]^l[a-16];l[a]=c<<1|c>>>31}c=(h<<5|h>>>27)+j+l[a];c=20>a?c+((g&e|~g&k)+1518500249):40>a?c+((g^e^k)+1859775393):60>a?c+((g&e|g&k|e&k)-1894007588):c+((g^e^
|
||||
k)-899497514);j=k;k=e;e=g<<30|g>>>2;g=h;h=c}b[0]=b[0]+h|0;b[1]=b[1]+g|0;b[2]=b[2]+e|0;b[3]=b[3]+k|0;b[4]=b[4]+j|0},_doFinalize:function(){var f=this._data,e=f.words,b=8*this._nDataBytes,h=8*f.sigBytes;e[h>>>5]|=128<<24-h%32;e[(h+64>>>9<<4)+14]=Math.floor(b/4294967296);e[(h+64>>>9<<4)+15]=b;f.sigBytes=4*e.length;this._process();return this._hash},clone:function(){var e=j.clone.call(this);e._hash=this._hash.clone();return e}});e.SHA1=j._createHelper(m);e.HmacSHA1=j._createHmacHelper(m)})();
|
||||
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
CryptoJS v3.1.2
|
||||
code.google.com/p/crypto-js
|
||||
(c) 2009-2013 by Jeff Mott. All rights reserved.
|
||||
code.google.com/p/crypto-js/wiki/License
|
||||
*/
|
||||
var CryptoJS=CryptoJS||function(g,l){var f={},k=f.lib={},h=function(){},m=k.Base={extend:function(a){h.prototype=this;var c=new h;a&&c.mixIn(a);c.hasOwnProperty("init")||(c.init=function(){c.$super.init.apply(this,arguments)});c.init.prototype=c;c.$super=this;return c},create:function(){var a=this.extend();a.init.apply(a,arguments);return a},init:function(){},mixIn:function(a){for(var c in a)a.hasOwnProperty(c)&&(this[c]=a[c]);a.hasOwnProperty("toString")&&(this.toString=a.toString)},clone:function(){return this.init.prototype.extend(this)}},
|
||||
q=k.WordArray=m.extend({init:function(a,c){a=this.words=a||[];this.sigBytes=c!=l?c:4*a.length},toString:function(a){return(a||s).stringify(this)},concat:function(a){var c=this.words,d=a.words,b=this.sigBytes;a=a.sigBytes;this.clamp();if(b%4)for(var e=0;e<a;e++)c[b+e>>>2]|=(d[e>>>2]>>>24-8*(e%4)&255)<<24-8*((b+e)%4);else if(65535<d.length)for(e=0;e<a;e+=4)c[b+e>>>2]=d[e>>>2];else c.push.apply(c,d);this.sigBytes+=a;return this},clamp:function(){var a=this.words,c=this.sigBytes;a[c>>>2]&=4294967295<<
|
||||
32-8*(c%4);a.length=g.ceil(c/4)},clone:function(){var a=m.clone.call(this);a.words=this.words.slice(0);return a},random:function(a){for(var c=[],d=0;d<a;d+=4)c.push(4294967296*g.random()|0);return new q.init(c,a)}}),t=f.enc={},s=t.Hex={stringify:function(a){var c=a.words;a=a.sigBytes;for(var d=[],b=0;b<a;b++){var e=c[b>>>2]>>>24-8*(b%4)&255;d.push((e>>>4).toString(16));d.push((e&15).toString(16))}return d.join("")},parse:function(a){for(var c=a.length,d=[],b=0;b<c;b+=2)d[b>>>3]|=parseInt(a.substr(b,
|
||||
2),16)<<24-4*(b%8);return new q.init(d,c/2)}},n=t.Latin1={stringify:function(a){var c=a.words;a=a.sigBytes;for(var d=[],b=0;b<a;b++)d.push(String.fromCharCode(c[b>>>2]>>>24-8*(b%4)&255));return d.join("")},parse:function(a){for(var c=a.length,d=[],b=0;b<c;b++)d[b>>>2]|=(a.charCodeAt(b)&255)<<24-8*(b%4);return new q.init(d,c)}},j=t.Utf8={stringify:function(a){try{return decodeURIComponent(escape(n.stringify(a)))}catch(c){throw Error("Malformed UTF-8 data");}},parse:function(a){return n.parse(unescape(encodeURIComponent(a)))}},
|
||||
w=k.BufferedBlockAlgorithm=m.extend({reset:function(){this._data=new q.init;this._nDataBytes=0},_append:function(a){"string"==typeof a&&(a=j.parse(a));this._data.concat(a);this._nDataBytes+=a.sigBytes},_process:function(a){var c=this._data,d=c.words,b=c.sigBytes,e=this.blockSize,f=b/(4*e),f=a?g.ceil(f):g.max((f|0)-this._minBufferSize,0);a=f*e;b=g.min(4*a,b);if(a){for(var u=0;u<a;u+=e)this._doProcessBlock(d,u);u=d.splice(0,a);c.sigBytes-=b}return new q.init(u,b)},clone:function(){var a=m.clone.call(this);
|
||||
a._data=this._data.clone();return a},_minBufferSize:0});k.Hasher=w.extend({cfg:m.extend(),init:function(a){this.cfg=this.cfg.extend(a);this.reset()},reset:function(){w.reset.call(this);this._doReset()},update:function(a){this._append(a);this._process();return this},finalize:function(a){a&&this._append(a);return this._doFinalize()},blockSize:16,_createHelper:function(a){return function(c,d){return(new a.init(d)).finalize(c)}},_createHmacHelper:function(a){return function(c,d){return(new v.HMAC.init(a,
|
||||
d)).finalize(c)}}});var v=f.algo={};return f}(Math);
|
||||
(function(g){for(var l=CryptoJS,f=l.lib,k=f.WordArray,h=f.Hasher,f=l.algo,m=[],q=[],t=function(a){return 4294967296*(a-(a|0))|0},s=2,n=0;64>n;){var j;a:{j=s;for(var w=g.sqrt(j),v=2;v<=w;v++)if(!(j%v)){j=!1;break a}j=!0}j&&(8>n&&(m[n]=t(g.pow(s,0.5))),q[n]=t(g.pow(s,1/3)),n++);s++}var a=[],f=f.SHA256=h.extend({_doReset:function(){this._hash=new k.init(m.slice(0))},_doProcessBlock:function(c,d){for(var b=this._hash.words,e=b[0],f=b[1],g=b[2],k=b[3],h=b[4],l=b[5],m=b[6],n=b[7],p=0;64>p;p++){if(16>p)a[p]=
|
||||
c[d+p]|0;else{var j=a[p-15],r=a[p-2];a[p]=((j<<25|j>>>7)^(j<<14|j>>>18)^j>>>3)+a[p-7]+((r<<15|r>>>17)^(r<<13|r>>>19)^r>>>10)+a[p-16]}j=n+((h<<26|h>>>6)^(h<<21|h>>>11)^(h<<7|h>>>25))+(h&l^~h&m)+q[p]+a[p];r=((e<<30|e>>>2)^(e<<19|e>>>13)^(e<<10|e>>>22))+(e&f^e&g^f&g);n=m;m=l;l=h;h=k+j|0;k=g;g=f;f=e;e=j+r|0}b[0]=b[0]+e|0;b[1]=b[1]+f|0;b[2]=b[2]+g|0;b[3]=b[3]+k|0;b[4]=b[4]+h|0;b[5]=b[5]+l|0;b[6]=b[6]+m|0;b[7]=b[7]+n|0},_doFinalize:function(){var a=this._data,d=a.words,b=8*this._nDataBytes,e=8*a.sigBytes;
|
||||
d[e>>>5]|=128<<24-e%32;d[(e+64>>>9<<4)+14]=g.floor(b/4294967296);d[(e+64>>>9<<4)+15]=b;a.sigBytes=4*d.length;this._process();return this._hash},clone:function(){var a=h.clone.call(this);a._hash=this._hash.clone();return a}});l.SHA256=h._createHelper(f);l.HmacSHA256=h._createHmacHelper(f)})(Math);
|
||||
(function(){var g=CryptoJS,l=g.lib.WordArray,f=g.algo,k=f.SHA256,f=f.SHA224=k.extend({_doReset:function(){this._hash=new l.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var f=k._doFinalize.call(this);f.sigBytes-=4;return f}});g.SHA224=k._createHelper(f);g.HmacSHA224=k._createHmacHelper(f)})();
|
||||
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
CryptoJS v3.1.2
|
||||
code.google.com/p/crypto-js
|
||||
(c) 2009-2013 by Jeff Mott. All rights reserved.
|
||||
code.google.com/p/crypto-js/wiki/License
|
||||
*/
|
||||
var CryptoJS=CryptoJS||function(h,s){var f={},t=f.lib={},g=function(){},j=t.Base={extend:function(a){g.prototype=this;var c=new g;a&&c.mixIn(a);c.hasOwnProperty("init")||(c.init=function(){c.$super.init.apply(this,arguments)});c.init.prototype=c;c.$super=this;return c},create:function(){var a=this.extend();a.init.apply(a,arguments);return a},init:function(){},mixIn:function(a){for(var c in a)a.hasOwnProperty(c)&&(this[c]=a[c]);a.hasOwnProperty("toString")&&(this.toString=a.toString)},clone:function(){return this.init.prototype.extend(this)}},
|
||||
q=t.WordArray=j.extend({init:function(a,c){a=this.words=a||[];this.sigBytes=c!=s?c:4*a.length},toString:function(a){return(a||u).stringify(this)},concat:function(a){var c=this.words,d=a.words,b=this.sigBytes;a=a.sigBytes;this.clamp();if(b%4)for(var e=0;e<a;e++)c[b+e>>>2]|=(d[e>>>2]>>>24-8*(e%4)&255)<<24-8*((b+e)%4);else if(65535<d.length)for(e=0;e<a;e+=4)c[b+e>>>2]=d[e>>>2];else c.push.apply(c,d);this.sigBytes+=a;return this},clamp:function(){var a=this.words,c=this.sigBytes;a[c>>>2]&=4294967295<<
|
||||
32-8*(c%4);a.length=h.ceil(c/4)},clone:function(){var a=j.clone.call(this);a.words=this.words.slice(0);return a},random:function(a){for(var c=[],d=0;d<a;d+=4)c.push(4294967296*h.random()|0);return new q.init(c,a)}}),v=f.enc={},u=v.Hex={stringify:function(a){var c=a.words;a=a.sigBytes;for(var d=[],b=0;b<a;b++){var e=c[b>>>2]>>>24-8*(b%4)&255;d.push((e>>>4).toString(16));d.push((e&15).toString(16))}return d.join("")},parse:function(a){for(var c=a.length,d=[],b=0;b<c;b+=2)d[b>>>3]|=parseInt(a.substr(b,
|
||||
2),16)<<24-4*(b%8);return new q.init(d,c/2)}},k=v.Latin1={stringify:function(a){var c=a.words;a=a.sigBytes;for(var d=[],b=0;b<a;b++)d.push(String.fromCharCode(c[b>>>2]>>>24-8*(b%4)&255));return d.join("")},parse:function(a){for(var c=a.length,d=[],b=0;b<c;b++)d[b>>>2]|=(a.charCodeAt(b)&255)<<24-8*(b%4);return new q.init(d,c)}},l=v.Utf8={stringify:function(a){try{return decodeURIComponent(escape(k.stringify(a)))}catch(c){throw Error("Malformed UTF-8 data");}},parse:function(a){return k.parse(unescape(encodeURIComponent(a)))}},
|
||||
x=t.BufferedBlockAlgorithm=j.extend({reset:function(){this._data=new q.init;this._nDataBytes=0},_append:function(a){"string"==typeof a&&(a=l.parse(a));this._data.concat(a);this._nDataBytes+=a.sigBytes},_process:function(a){var c=this._data,d=c.words,b=c.sigBytes,e=this.blockSize,f=b/(4*e),f=a?h.ceil(f):h.max((f|0)-this._minBufferSize,0);a=f*e;b=h.min(4*a,b);if(a){for(var m=0;m<a;m+=e)this._doProcessBlock(d,m);m=d.splice(0,a);c.sigBytes-=b}return new q.init(m,b)},clone:function(){var a=j.clone.call(this);
|
||||
a._data=this._data.clone();return a},_minBufferSize:0});t.Hasher=x.extend({cfg:j.extend(),init:function(a){this.cfg=this.cfg.extend(a);this.reset()},reset:function(){x.reset.call(this);this._doReset()},update:function(a){this._append(a);this._process();return this},finalize:function(a){a&&this._append(a);return this._doFinalize()},blockSize:16,_createHelper:function(a){return function(c,d){return(new a.init(d)).finalize(c)}},_createHmacHelper:function(a){return function(c,d){return(new w.HMAC.init(a,
|
||||
d)).finalize(c)}}});var w=f.algo={};return f}(Math);
|
||||
(function(h){for(var s=CryptoJS,f=s.lib,t=f.WordArray,g=f.Hasher,f=s.algo,j=[],q=[],v=function(a){return 4294967296*(a-(a|0))|0},u=2,k=0;64>k;){var l;a:{l=u;for(var x=h.sqrt(l),w=2;w<=x;w++)if(!(l%w)){l=!1;break a}l=!0}l&&(8>k&&(j[k]=v(h.pow(u,0.5))),q[k]=v(h.pow(u,1/3)),k++);u++}var a=[],f=f.SHA256=g.extend({_doReset:function(){this._hash=new t.init(j.slice(0))},_doProcessBlock:function(c,d){for(var b=this._hash.words,e=b[0],f=b[1],m=b[2],h=b[3],p=b[4],j=b[5],k=b[6],l=b[7],n=0;64>n;n++){if(16>n)a[n]=
|
||||
c[d+n]|0;else{var r=a[n-15],g=a[n-2];a[n]=((r<<25|r>>>7)^(r<<14|r>>>18)^r>>>3)+a[n-7]+((g<<15|g>>>17)^(g<<13|g>>>19)^g>>>10)+a[n-16]}r=l+((p<<26|p>>>6)^(p<<21|p>>>11)^(p<<7|p>>>25))+(p&j^~p&k)+q[n]+a[n];g=((e<<30|e>>>2)^(e<<19|e>>>13)^(e<<10|e>>>22))+(e&f^e&m^f&m);l=k;k=j;j=p;p=h+r|0;h=m;m=f;f=e;e=r+g|0}b[0]=b[0]+e|0;b[1]=b[1]+f|0;b[2]=b[2]+m|0;b[3]=b[3]+h|0;b[4]=b[4]+p|0;b[5]=b[5]+j|0;b[6]=b[6]+k|0;b[7]=b[7]+l|0},_doFinalize:function(){var a=this._data,d=a.words,b=8*this._nDataBytes,e=8*a.sigBytes;
|
||||
d[e>>>5]|=128<<24-e%32;d[(e+64>>>9<<4)+14]=h.floor(b/4294967296);d[(e+64>>>9<<4)+15]=b;a.sigBytes=4*d.length;this._process();return this._hash},clone:function(){var a=g.clone.call(this);a._hash=this._hash.clone();return a}});s.SHA256=g._createHelper(f);s.HmacSHA256=g._createHmacHelper(f)})(Math);
|
||||
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
CryptoJS v3.1.2
|
||||
code.google.com/p/crypto-js
|
||||
(c) 2009-2013 by Jeff Mott. All rights reserved.
|
||||
code.google.com/p/crypto-js/wiki/License
|
||||
*/
|
||||
var CryptoJS=CryptoJS||function(v,p){var d={},u=d.lib={},r=function(){},f=u.Base={extend:function(a){r.prototype=this;var b=new r;a&&b.mixIn(a);b.hasOwnProperty("init")||(b.init=function(){b.$super.init.apply(this,arguments)});b.init.prototype=b;b.$super=this;return b},create:function(){var a=this.extend();a.init.apply(a,arguments);return a},init:function(){},mixIn:function(a){for(var b in a)a.hasOwnProperty(b)&&(this[b]=a[b]);a.hasOwnProperty("toString")&&(this.toString=a.toString)},clone:function(){return this.init.prototype.extend(this)}},
|
||||
s=u.WordArray=f.extend({init:function(a,b){a=this.words=a||[];this.sigBytes=b!=p?b:4*a.length},toString:function(a){return(a||y).stringify(this)},concat:function(a){var b=this.words,c=a.words,j=this.sigBytes;a=a.sigBytes;this.clamp();if(j%4)for(var n=0;n<a;n++)b[j+n>>>2]|=(c[n>>>2]>>>24-8*(n%4)&255)<<24-8*((j+n)%4);else if(65535<c.length)for(n=0;n<a;n+=4)b[j+n>>>2]=c[n>>>2];else b.push.apply(b,c);this.sigBytes+=a;return this},clamp:function(){var a=this.words,b=this.sigBytes;a[b>>>2]&=4294967295<<
|
||||
32-8*(b%4);a.length=v.ceil(b/4)},clone:function(){var a=f.clone.call(this);a.words=this.words.slice(0);return a},random:function(a){for(var b=[],c=0;c<a;c+=4)b.push(4294967296*v.random()|0);return new s.init(b,a)}}),x=d.enc={},y=x.Hex={stringify:function(a){var b=a.words;a=a.sigBytes;for(var c=[],j=0;j<a;j++){var n=b[j>>>2]>>>24-8*(j%4)&255;c.push((n>>>4).toString(16));c.push((n&15).toString(16))}return c.join("")},parse:function(a){for(var b=a.length,c=[],j=0;j<b;j+=2)c[j>>>3]|=parseInt(a.substr(j,
|
||||
2),16)<<24-4*(j%8);return new s.init(c,b/2)}},e=x.Latin1={stringify:function(a){var b=a.words;a=a.sigBytes;for(var c=[],j=0;j<a;j++)c.push(String.fromCharCode(b[j>>>2]>>>24-8*(j%4)&255));return c.join("")},parse:function(a){for(var b=a.length,c=[],j=0;j<b;j++)c[j>>>2]|=(a.charCodeAt(j)&255)<<24-8*(j%4);return new s.init(c,b)}},q=x.Utf8={stringify:function(a){try{return decodeURIComponent(escape(e.stringify(a)))}catch(b){throw Error("Malformed UTF-8 data");}},parse:function(a){return e.parse(unescape(encodeURIComponent(a)))}},
|
||||
t=u.BufferedBlockAlgorithm=f.extend({reset:function(){this._data=new s.init;this._nDataBytes=0},_append:function(a){"string"==typeof a&&(a=q.parse(a));this._data.concat(a);this._nDataBytes+=a.sigBytes},_process:function(a){var b=this._data,c=b.words,j=b.sigBytes,n=this.blockSize,e=j/(4*n),e=a?v.ceil(e):v.max((e|0)-this._minBufferSize,0);a=e*n;j=v.min(4*a,j);if(a){for(var f=0;f<a;f+=n)this._doProcessBlock(c,f);f=c.splice(0,a);b.sigBytes-=j}return new s.init(f,j)},clone:function(){var a=f.clone.call(this);
|
||||
a._data=this._data.clone();return a},_minBufferSize:0});u.Hasher=t.extend({cfg:f.extend(),init:function(a){this.cfg=this.cfg.extend(a);this.reset()},reset:function(){t.reset.call(this);this._doReset()},update:function(a){this._append(a);this._process();return this},finalize:function(a){a&&this._append(a);return this._doFinalize()},blockSize:16,_createHelper:function(a){return function(b,c){return(new a.init(c)).finalize(b)}},_createHmacHelper:function(a){return function(b,c){return(new w.HMAC.init(a,
|
||||
c)).finalize(b)}}});var w=d.algo={};return d}(Math);
|
||||
(function(v){var p=CryptoJS,d=p.lib,u=d.Base,r=d.WordArray,p=p.x64={};p.Word=u.extend({init:function(f,s){this.high=f;this.low=s}});p.WordArray=u.extend({init:function(f,s){f=this.words=f||[];this.sigBytes=s!=v?s:8*f.length},toX32:function(){for(var f=this.words,s=f.length,d=[],p=0;p<s;p++){var e=f[p];d.push(e.high);d.push(e.low)}return r.create(d,this.sigBytes)},clone:function(){for(var f=u.clone.call(this),d=f.words=this.words.slice(0),p=d.length,r=0;r<p;r++)d[r]=d[r].clone();return f}})})();
|
||||
(function(v){for(var p=CryptoJS,d=p.lib,u=d.WordArray,r=d.Hasher,f=p.x64.Word,d=p.algo,s=[],x=[],y=[],e=1,q=0,t=0;24>t;t++){s[e+5*q]=(t+1)*(t+2)/2%64;var w=(2*e+3*q)%5,e=q%5,q=w}for(e=0;5>e;e++)for(q=0;5>q;q++)x[e+5*q]=q+5*((2*e+3*q)%5);e=1;for(q=0;24>q;q++){for(var a=w=t=0;7>a;a++){if(e&1){var b=(1<<a)-1;32>b?w^=1<<b:t^=1<<b-32}e=e&128?e<<1^113:e<<1}y[q]=f.create(t,w)}for(var c=[],e=0;25>e;e++)c[e]=f.create();d=d.SHA3=r.extend({cfg:r.cfg.extend({outputLength:512}),_doReset:function(){for(var a=this._state=
|
||||
[],b=0;25>b;b++)a[b]=new f.init;this.blockSize=(1600-2*this.cfg.outputLength)/32},_doProcessBlock:function(a,b){for(var e=this._state,f=this.blockSize/2,h=0;h<f;h++){var l=a[b+2*h],m=a[b+2*h+1],l=(l<<8|l>>>24)&16711935|(l<<24|l>>>8)&4278255360,m=(m<<8|m>>>24)&16711935|(m<<24|m>>>8)&4278255360,g=e[h];g.high^=m;g.low^=l}for(f=0;24>f;f++){for(h=0;5>h;h++){for(var d=l=0,k=0;5>k;k++)g=e[h+5*k],l^=g.high,d^=g.low;g=c[h];g.high=l;g.low=d}for(h=0;5>h;h++){g=c[(h+4)%5];l=c[(h+1)%5];m=l.high;k=l.low;l=g.high^
|
||||
(m<<1|k>>>31);d=g.low^(k<<1|m>>>31);for(k=0;5>k;k++)g=e[h+5*k],g.high^=l,g.low^=d}for(m=1;25>m;m++)g=e[m],h=g.high,g=g.low,k=s[m],32>k?(l=h<<k|g>>>32-k,d=g<<k|h>>>32-k):(l=g<<k-32|h>>>64-k,d=h<<k-32|g>>>64-k),g=c[x[m]],g.high=l,g.low=d;g=c[0];h=e[0];g.high=h.high;g.low=h.low;for(h=0;5>h;h++)for(k=0;5>k;k++)m=h+5*k,g=e[m],l=c[m],m=c[(h+1)%5+5*k],d=c[(h+2)%5+5*k],g.high=l.high^~m.high&d.high,g.low=l.low^~m.low&d.low;g=e[0];h=y[f];g.high^=h.high;g.low^=h.low}},_doFinalize:function(){var a=this._data,
|
||||
b=a.words,c=8*a.sigBytes,e=32*this.blockSize;b[c>>>5]|=1<<24-c%32;b[(v.ceil((c+1)/e)*e>>>5)-1]|=128;a.sigBytes=4*b.length;this._process();for(var a=this._state,b=this.cfg.outputLength/8,c=b/8,e=[],h=0;h<c;h++){var d=a[h],f=d.high,d=d.low,f=(f<<8|f>>>24)&16711935|(f<<24|f>>>8)&4278255360,d=(d<<8|d>>>24)&16711935|(d<<24|d>>>8)&4278255360;e.push(d);e.push(f)}return new u.init(e,b)},clone:function(){for(var a=r.clone.call(this),b=a._state=this._state.slice(0),c=0;25>c;c++)b[c]=b[c].clone();return a}});
|
||||
p.SHA3=r._createHelper(d);p.HmacSHA3=r._createHmacHelper(d)})(Math);
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
CryptoJS v3.1.2
|
||||
code.google.com/p/crypto-js
|
||||
(c) 2009-2013 by Jeff Mott. All rights reserved.
|
||||
code.google.com/p/crypto-js/wiki/License
|
||||
*/
|
||||
var CryptoJS=CryptoJS||function(a,c){var d={},j=d.lib={},f=function(){},m=j.Base={extend:function(a){f.prototype=this;var b=new f;a&&b.mixIn(a);b.hasOwnProperty("init")||(b.init=function(){b.$super.init.apply(this,arguments)});b.init.prototype=b;b.$super=this;return b},create:function(){var a=this.extend();a.init.apply(a,arguments);return a},init:function(){},mixIn:function(a){for(var b in a)a.hasOwnProperty(b)&&(this[b]=a[b]);a.hasOwnProperty("toString")&&(this.toString=a.toString)},clone:function(){return this.init.prototype.extend(this)}},
|
||||
B=j.WordArray=m.extend({init:function(a,b){a=this.words=a||[];this.sigBytes=b!=c?b:4*a.length},toString:function(a){return(a||y).stringify(this)},concat:function(a){var b=this.words,g=a.words,e=this.sigBytes;a=a.sigBytes;this.clamp();if(e%4)for(var k=0;k<a;k++)b[e+k>>>2]|=(g[k>>>2]>>>24-8*(k%4)&255)<<24-8*((e+k)%4);else if(65535<g.length)for(k=0;k<a;k+=4)b[e+k>>>2]=g[k>>>2];else b.push.apply(b,g);this.sigBytes+=a;return this},clamp:function(){var n=this.words,b=this.sigBytes;n[b>>>2]&=4294967295<<
|
||||
32-8*(b%4);n.length=a.ceil(b/4)},clone:function(){var a=m.clone.call(this);a.words=this.words.slice(0);return a},random:function(n){for(var b=[],g=0;g<n;g+=4)b.push(4294967296*a.random()|0);return new B.init(b,n)}}),v=d.enc={},y=v.Hex={stringify:function(a){var b=a.words;a=a.sigBytes;for(var g=[],e=0;e<a;e++){var k=b[e>>>2]>>>24-8*(e%4)&255;g.push((k>>>4).toString(16));g.push((k&15).toString(16))}return g.join("")},parse:function(a){for(var b=a.length,g=[],e=0;e<b;e+=2)g[e>>>3]|=parseInt(a.substr(e,
|
||||
2),16)<<24-4*(e%8);return new B.init(g,b/2)}},F=v.Latin1={stringify:function(a){var b=a.words;a=a.sigBytes;for(var g=[],e=0;e<a;e++)g.push(String.fromCharCode(b[e>>>2]>>>24-8*(e%4)&255));return g.join("")},parse:function(a){for(var b=a.length,g=[],e=0;e<b;e++)g[e>>>2]|=(a.charCodeAt(e)&255)<<24-8*(e%4);return new B.init(g,b)}},ha=v.Utf8={stringify:function(a){try{return decodeURIComponent(escape(F.stringify(a)))}catch(b){throw Error("Malformed UTF-8 data");}},parse:function(a){return F.parse(unescape(encodeURIComponent(a)))}},
|
||||
Z=j.BufferedBlockAlgorithm=m.extend({reset:function(){this._data=new B.init;this._nDataBytes=0},_append:function(a){"string"==typeof a&&(a=ha.parse(a));this._data.concat(a);this._nDataBytes+=a.sigBytes},_process:function(n){var b=this._data,g=b.words,e=b.sigBytes,k=this.blockSize,m=e/(4*k),m=n?a.ceil(m):a.max((m|0)-this._minBufferSize,0);n=m*k;e=a.min(4*n,e);if(n){for(var c=0;c<n;c+=k)this._doProcessBlock(g,c);c=g.splice(0,n);b.sigBytes-=e}return new B.init(c,e)},clone:function(){var a=m.clone.call(this);
|
||||
a._data=this._data.clone();return a},_minBufferSize:0});j.Hasher=Z.extend({cfg:m.extend(),init:function(a){this.cfg=this.cfg.extend(a);this.reset()},reset:function(){Z.reset.call(this);this._doReset()},update:function(a){this._append(a);this._process();return this},finalize:function(a){a&&this._append(a);return this._doFinalize()},blockSize:16,_createHelper:function(a){return function(b,g){return(new a.init(g)).finalize(b)}},_createHmacHelper:function(a){return function(b,g){return(new ia.HMAC.init(a,
|
||||
g)).finalize(b)}}});var ia=d.algo={};return d}(Math);
|
||||
(function(a){var c=CryptoJS,d=c.lib,j=d.Base,f=d.WordArray,c=c.x64={};c.Word=j.extend({init:function(a,c){this.high=a;this.low=c}});c.WordArray=j.extend({init:function(c,d){c=this.words=c||[];this.sigBytes=d!=a?d:8*c.length},toX32:function(){for(var a=this.words,c=a.length,d=[],j=0;j<c;j++){var F=a[j];d.push(F.high);d.push(F.low)}return f.create(d,this.sigBytes)},clone:function(){for(var a=j.clone.call(this),c=a.words=this.words.slice(0),d=c.length,f=0;f<d;f++)c[f]=c[f].clone();return a}})})();
|
||||
(function(){function a(){return f.create.apply(f,arguments)}for(var c=CryptoJS,d=c.lib.Hasher,j=c.x64,f=j.Word,m=j.WordArray,j=c.algo,B=[a(1116352408,3609767458),a(1899447441,602891725),a(3049323471,3964484399),a(3921009573,2173295548),a(961987163,4081628472),a(1508970993,3053834265),a(2453635748,2937671579),a(2870763221,3664609560),a(3624381080,2734883394),a(310598401,1164996542),a(607225278,1323610764),a(1426881987,3590304994),a(1925078388,4068182383),a(2162078206,991336113),a(2614888103,633803317),
|
||||
a(3248222580,3479774868),a(3835390401,2666613458),a(4022224774,944711139),a(264347078,2341262773),a(604807628,2007800933),a(770255983,1495990901),a(1249150122,1856431235),a(1555081692,3175218132),a(1996064986,2198950837),a(2554220882,3999719339),a(2821834349,766784016),a(2952996808,2566594879),a(3210313671,3203337956),a(3336571891,1034457026),a(3584528711,2466948901),a(113926993,3758326383),a(338241895,168717936),a(666307205,1188179964),a(773529912,1546045734),a(1294757372,1522805485),a(1396182291,
|
||||
2643833823),a(1695183700,2343527390),a(1986661051,1014477480),a(2177026350,1206759142),a(2456956037,344077627),a(2730485921,1290863460),a(2820302411,3158454273),a(3259730800,3505952657),a(3345764771,106217008),a(3516065817,3606008344),a(3600352804,1432725776),a(4094571909,1467031594),a(275423344,851169720),a(430227734,3100823752),a(506948616,1363258195),a(659060556,3750685593),a(883997877,3785050280),a(958139571,3318307427),a(1322822218,3812723403),a(1537002063,2003034995),a(1747873779,3602036899),
|
||||
a(1955562222,1575990012),a(2024104815,1125592928),a(2227730452,2716904306),a(2361852424,442776044),a(2428436474,593698344),a(2756734187,3733110249),a(3204031479,2999351573),a(3329325298,3815920427),a(3391569614,3928383900),a(3515267271,566280711),a(3940187606,3454069534),a(4118630271,4000239992),a(116418474,1914138554),a(174292421,2731055270),a(289380356,3203993006),a(460393269,320620315),a(685471733,587496836),a(852142971,1086792851),a(1017036298,365543100),a(1126000580,2618297676),a(1288033470,
|
||||
3409855158),a(1501505948,4234509866),a(1607167915,987167468),a(1816402316,1246189591)],v=[],y=0;80>y;y++)v[y]=a();j=j.SHA512=d.extend({_doReset:function(){this._hash=new m.init([new f.init(1779033703,4089235720),new f.init(3144134277,2227873595),new f.init(1013904242,4271175723),new f.init(2773480762,1595750129),new f.init(1359893119,2917565137),new f.init(2600822924,725511199),new f.init(528734635,4215389547),new f.init(1541459225,327033209)])},_doProcessBlock:function(a,c){for(var d=this._hash.words,
|
||||
f=d[0],j=d[1],b=d[2],g=d[3],e=d[4],k=d[5],m=d[6],d=d[7],y=f.high,M=f.low,$=j.high,N=j.low,aa=b.high,O=b.low,ba=g.high,P=g.low,ca=e.high,Q=e.low,da=k.high,R=k.low,ea=m.high,S=m.low,fa=d.high,T=d.low,s=y,p=M,G=$,D=N,H=aa,E=O,W=ba,I=P,t=ca,q=Q,U=da,J=R,V=ea,K=S,X=fa,L=T,u=0;80>u;u++){var z=v[u];if(16>u)var r=z.high=a[c+2*u]|0,h=z.low=a[c+2*u+1]|0;else{var r=v[u-15],h=r.high,w=r.low,r=(h>>>1|w<<31)^(h>>>8|w<<24)^h>>>7,w=(w>>>1|h<<31)^(w>>>8|h<<24)^(w>>>7|h<<25),C=v[u-2],h=C.high,l=C.low,C=(h>>>19|l<<
|
||||
13)^(h<<3|l>>>29)^h>>>6,l=(l>>>19|h<<13)^(l<<3|h>>>29)^(l>>>6|h<<26),h=v[u-7],Y=h.high,A=v[u-16],x=A.high,A=A.low,h=w+h.low,r=r+Y+(h>>>0<w>>>0?1:0),h=h+l,r=r+C+(h>>>0<l>>>0?1:0),h=h+A,r=r+x+(h>>>0<A>>>0?1:0);z.high=r;z.low=h}var Y=t&U^~t&V,A=q&J^~q&K,z=s&G^s&H^G&H,ja=p&D^p&E^D&E,w=(s>>>28|p<<4)^(s<<30|p>>>2)^(s<<25|p>>>7),C=(p>>>28|s<<4)^(p<<30|s>>>2)^(p<<25|s>>>7),l=B[u],ka=l.high,ga=l.low,l=L+((q>>>14|t<<18)^(q>>>18|t<<14)^(q<<23|t>>>9)),x=X+((t>>>14|q<<18)^(t>>>18|q<<14)^(t<<23|q>>>9))+(l>>>0<
|
||||
L>>>0?1:0),l=l+A,x=x+Y+(l>>>0<A>>>0?1:0),l=l+ga,x=x+ka+(l>>>0<ga>>>0?1:0),l=l+h,x=x+r+(l>>>0<h>>>0?1:0),h=C+ja,z=w+z+(h>>>0<C>>>0?1:0),X=V,L=K,V=U,K=J,U=t,J=q,q=I+l|0,t=W+x+(q>>>0<I>>>0?1:0)|0,W=H,I=E,H=G,E=D,G=s,D=p,p=l+h|0,s=x+z+(p>>>0<l>>>0?1:0)|0}M=f.low=M+p;f.high=y+s+(M>>>0<p>>>0?1:0);N=j.low=N+D;j.high=$+G+(N>>>0<D>>>0?1:0);O=b.low=O+E;b.high=aa+H+(O>>>0<E>>>0?1:0);P=g.low=P+I;g.high=ba+W+(P>>>0<I>>>0?1:0);Q=e.low=Q+q;e.high=ca+t+(Q>>>0<q>>>0?1:0);R=k.low=R+J;k.high=da+U+(R>>>0<J>>>0?1:0);
|
||||
S=m.low=S+K;m.high=ea+V+(S>>>0<K>>>0?1:0);T=d.low=T+L;d.high=fa+X+(T>>>0<L>>>0?1:0)},_doFinalize:function(){var a=this._data,c=a.words,d=8*this._nDataBytes,f=8*a.sigBytes;c[f>>>5]|=128<<24-f%32;c[(f+128>>>10<<5)+30]=Math.floor(d/4294967296);c[(f+128>>>10<<5)+31]=d;a.sigBytes=4*c.length;this._process();return this._hash.toX32()},clone:function(){var a=d.clone.call(this);a._hash=this._hash.clone();return a},blockSize:32});c.SHA512=d._createHelper(j);c.HmacSHA512=d._createHmacHelper(j)})();
|
||||
(function(){var a=CryptoJS,c=a.x64,d=c.Word,j=c.WordArray,c=a.algo,f=c.SHA512,c=c.SHA384=f.extend({_doReset:function(){this._hash=new j.init([new d.init(3418070365,3238371032),new d.init(1654270250,914150663),new d.init(2438529370,812702999),new d.init(355462360,4144912697),new d.init(1731405415,4290775857),new d.init(2394180231,1750603025),new d.init(3675008525,1694076839),new d.init(1203062813,3204075428)])},_doFinalize:function(){var a=f._doFinalize.call(this);a.sigBytes-=16;return a}});a.SHA384=
|
||||
f._createHelper(c);a.HmacSHA384=f._createHmacHelper(c)})();
|
||||
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
CryptoJS v3.1.2
|
||||
code.google.com/p/crypto-js
|
||||
(c) 2009-2013 by Jeff Mott. All rights reserved.
|
||||
code.google.com/p/crypto-js/wiki/License
|
||||
*/
|
||||
var CryptoJS=CryptoJS||function(a,m){var r={},f=r.lib={},g=function(){},l=f.Base={extend:function(a){g.prototype=this;var b=new g;a&&b.mixIn(a);b.hasOwnProperty("init")||(b.init=function(){b.$super.init.apply(this,arguments)});b.init.prototype=b;b.$super=this;return b},create:function(){var a=this.extend();a.init.apply(a,arguments);return a},init:function(){},mixIn:function(a){for(var b in a)a.hasOwnProperty(b)&&(this[b]=a[b]);a.hasOwnProperty("toString")&&(this.toString=a.toString)},clone:function(){return this.init.prototype.extend(this)}},
|
||||
p=f.WordArray=l.extend({init:function(a,b){a=this.words=a||[];this.sigBytes=b!=m?b:4*a.length},toString:function(a){return(a||q).stringify(this)},concat:function(a){var b=this.words,d=a.words,c=this.sigBytes;a=a.sigBytes;this.clamp();if(c%4)for(var j=0;j<a;j++)b[c+j>>>2]|=(d[j>>>2]>>>24-8*(j%4)&255)<<24-8*((c+j)%4);else if(65535<d.length)for(j=0;j<a;j+=4)b[c+j>>>2]=d[j>>>2];else b.push.apply(b,d);this.sigBytes+=a;return this},clamp:function(){var n=this.words,b=this.sigBytes;n[b>>>2]&=4294967295<<
|
||||
32-8*(b%4);n.length=a.ceil(b/4)},clone:function(){var a=l.clone.call(this);a.words=this.words.slice(0);return a},random:function(n){for(var b=[],d=0;d<n;d+=4)b.push(4294967296*a.random()|0);return new p.init(b,n)}}),y=r.enc={},q=y.Hex={stringify:function(a){var b=a.words;a=a.sigBytes;for(var d=[],c=0;c<a;c++){var j=b[c>>>2]>>>24-8*(c%4)&255;d.push((j>>>4).toString(16));d.push((j&15).toString(16))}return d.join("")},parse:function(a){for(var b=a.length,d=[],c=0;c<b;c+=2)d[c>>>3]|=parseInt(a.substr(c,
|
||||
2),16)<<24-4*(c%8);return new p.init(d,b/2)}},G=y.Latin1={stringify:function(a){var b=a.words;a=a.sigBytes;for(var d=[],c=0;c<a;c++)d.push(String.fromCharCode(b[c>>>2]>>>24-8*(c%4)&255));return d.join("")},parse:function(a){for(var b=a.length,d=[],c=0;c<b;c++)d[c>>>2]|=(a.charCodeAt(c)&255)<<24-8*(c%4);return new p.init(d,b)}},fa=y.Utf8={stringify:function(a){try{return decodeURIComponent(escape(G.stringify(a)))}catch(b){throw Error("Malformed UTF-8 data");}},parse:function(a){return G.parse(unescape(encodeURIComponent(a)))}},
|
||||
h=f.BufferedBlockAlgorithm=l.extend({reset:function(){this._data=new p.init;this._nDataBytes=0},_append:function(a){"string"==typeof a&&(a=fa.parse(a));this._data.concat(a);this._nDataBytes+=a.sigBytes},_process:function(n){var b=this._data,d=b.words,c=b.sigBytes,j=this.blockSize,l=c/(4*j),l=n?a.ceil(l):a.max((l|0)-this._minBufferSize,0);n=l*j;c=a.min(4*n,c);if(n){for(var h=0;h<n;h+=j)this._doProcessBlock(d,h);h=d.splice(0,n);b.sigBytes-=c}return new p.init(h,c)},clone:function(){var a=l.clone.call(this);
|
||||
a._data=this._data.clone();return a},_minBufferSize:0});f.Hasher=h.extend({cfg:l.extend(),init:function(a){this.cfg=this.cfg.extend(a);this.reset()},reset:function(){h.reset.call(this);this._doReset()},update:function(a){this._append(a);this._process();return this},finalize:function(a){a&&this._append(a);return this._doFinalize()},blockSize:16,_createHelper:function(a){return function(b,d){return(new a.init(d)).finalize(b)}},_createHmacHelper:function(a){return function(b,d){return(new ga.HMAC.init(a,
|
||||
d)).finalize(b)}}});var ga=r.algo={};return r}(Math);
|
||||
(function(a){var m=CryptoJS,r=m.lib,f=r.Base,g=r.WordArray,m=m.x64={};m.Word=f.extend({init:function(a,p){this.high=a;this.low=p}});m.WordArray=f.extend({init:function(l,p){l=this.words=l||[];this.sigBytes=p!=a?p:8*l.length},toX32:function(){for(var a=this.words,p=a.length,f=[],q=0;q<p;q++){var G=a[q];f.push(G.high);f.push(G.low)}return g.create(f,this.sigBytes)},clone:function(){for(var a=f.clone.call(this),p=a.words=this.words.slice(0),g=p.length,q=0;q<g;q++)p[q]=p[q].clone();return a}})})();
|
||||
(function(){function a(){return g.create.apply(g,arguments)}for(var m=CryptoJS,r=m.lib.Hasher,f=m.x64,g=f.Word,l=f.WordArray,f=m.algo,p=[a(1116352408,3609767458),a(1899447441,602891725),a(3049323471,3964484399),a(3921009573,2173295548),a(961987163,4081628472),a(1508970993,3053834265),a(2453635748,2937671579),a(2870763221,3664609560),a(3624381080,2734883394),a(310598401,1164996542),a(607225278,1323610764),a(1426881987,3590304994),a(1925078388,4068182383),a(2162078206,991336113),a(2614888103,633803317),
|
||||
a(3248222580,3479774868),a(3835390401,2666613458),a(4022224774,944711139),a(264347078,2341262773),a(604807628,2007800933),a(770255983,1495990901),a(1249150122,1856431235),a(1555081692,3175218132),a(1996064986,2198950837),a(2554220882,3999719339),a(2821834349,766784016),a(2952996808,2566594879),a(3210313671,3203337956),a(3336571891,1034457026),a(3584528711,2466948901),a(113926993,3758326383),a(338241895,168717936),a(666307205,1188179964),a(773529912,1546045734),a(1294757372,1522805485),a(1396182291,
|
||||
2643833823),a(1695183700,2343527390),a(1986661051,1014477480),a(2177026350,1206759142),a(2456956037,344077627),a(2730485921,1290863460),a(2820302411,3158454273),a(3259730800,3505952657),a(3345764771,106217008),a(3516065817,3606008344),a(3600352804,1432725776),a(4094571909,1467031594),a(275423344,851169720),a(430227734,3100823752),a(506948616,1363258195),a(659060556,3750685593),a(883997877,3785050280),a(958139571,3318307427),a(1322822218,3812723403),a(1537002063,2003034995),a(1747873779,3602036899),
|
||||
a(1955562222,1575990012),a(2024104815,1125592928),a(2227730452,2716904306),a(2361852424,442776044),a(2428436474,593698344),a(2756734187,3733110249),a(3204031479,2999351573),a(3329325298,3815920427),a(3391569614,3928383900),a(3515267271,566280711),a(3940187606,3454069534),a(4118630271,4000239992),a(116418474,1914138554),a(174292421,2731055270),a(289380356,3203993006),a(460393269,320620315),a(685471733,587496836),a(852142971,1086792851),a(1017036298,365543100),a(1126000580,2618297676),a(1288033470,
|
||||
3409855158),a(1501505948,4234509866),a(1607167915,987167468),a(1816402316,1246189591)],y=[],q=0;80>q;q++)y[q]=a();f=f.SHA512=r.extend({_doReset:function(){this._hash=new l.init([new g.init(1779033703,4089235720),new g.init(3144134277,2227873595),new g.init(1013904242,4271175723),new g.init(2773480762,1595750129),new g.init(1359893119,2917565137),new g.init(2600822924,725511199),new g.init(528734635,4215389547),new g.init(1541459225,327033209)])},_doProcessBlock:function(a,f){for(var h=this._hash.words,
|
||||
g=h[0],n=h[1],b=h[2],d=h[3],c=h[4],j=h[5],l=h[6],h=h[7],q=g.high,m=g.low,r=n.high,N=n.low,Z=b.high,O=b.low,$=d.high,P=d.low,aa=c.high,Q=c.low,ba=j.high,R=j.low,ca=l.high,S=l.low,da=h.high,T=h.low,v=q,s=m,H=r,E=N,I=Z,F=O,W=$,J=P,w=aa,t=Q,U=ba,K=R,V=ca,L=S,X=da,M=T,x=0;80>x;x++){var B=y[x];if(16>x)var u=B.high=a[f+2*x]|0,e=B.low=a[f+2*x+1]|0;else{var u=y[x-15],e=u.high,z=u.low,u=(e>>>1|z<<31)^(e>>>8|z<<24)^e>>>7,z=(z>>>1|e<<31)^(z>>>8|e<<24)^(z>>>7|e<<25),D=y[x-2],e=D.high,k=D.low,D=(e>>>19|k<<13)^
|
||||
(e<<3|k>>>29)^e>>>6,k=(k>>>19|e<<13)^(k<<3|e>>>29)^(k>>>6|e<<26),e=y[x-7],Y=e.high,C=y[x-16],A=C.high,C=C.low,e=z+e.low,u=u+Y+(e>>>0<z>>>0?1:0),e=e+k,u=u+D+(e>>>0<k>>>0?1:0),e=e+C,u=u+A+(e>>>0<C>>>0?1:0);B.high=u;B.low=e}var Y=w&U^~w&V,C=t&K^~t&L,B=v&H^v&I^H&I,ha=s&E^s&F^E&F,z=(v>>>28|s<<4)^(v<<30|s>>>2)^(v<<25|s>>>7),D=(s>>>28|v<<4)^(s<<30|v>>>2)^(s<<25|v>>>7),k=p[x],ia=k.high,ea=k.low,k=M+((t>>>14|w<<18)^(t>>>18|w<<14)^(t<<23|w>>>9)),A=X+((w>>>14|t<<18)^(w>>>18|t<<14)^(w<<23|t>>>9))+(k>>>0<M>>>
|
||||
0?1:0),k=k+C,A=A+Y+(k>>>0<C>>>0?1:0),k=k+ea,A=A+ia+(k>>>0<ea>>>0?1:0),k=k+e,A=A+u+(k>>>0<e>>>0?1:0),e=D+ha,B=z+B+(e>>>0<D>>>0?1:0),X=V,M=L,V=U,L=K,U=w,K=t,t=J+k|0,w=W+A+(t>>>0<J>>>0?1:0)|0,W=I,J=F,I=H,F=E,H=v,E=s,s=k+e|0,v=A+B+(s>>>0<k>>>0?1:0)|0}m=g.low=m+s;g.high=q+v+(m>>>0<s>>>0?1:0);N=n.low=N+E;n.high=r+H+(N>>>0<E>>>0?1:0);O=b.low=O+F;b.high=Z+I+(O>>>0<F>>>0?1:0);P=d.low=P+J;d.high=$+W+(P>>>0<J>>>0?1:0);Q=c.low=Q+t;c.high=aa+w+(Q>>>0<t>>>0?1:0);R=j.low=R+K;j.high=ba+U+(R>>>0<K>>>0?1:0);S=l.low=
|
||||
S+L;l.high=ca+V+(S>>>0<L>>>0?1:0);T=h.low=T+M;h.high=da+X+(T>>>0<M>>>0?1:0)},_doFinalize:function(){var a=this._data,f=a.words,h=8*this._nDataBytes,g=8*a.sigBytes;f[g>>>5]|=128<<24-g%32;f[(g+128>>>10<<5)+30]=Math.floor(h/4294967296);f[(g+128>>>10<<5)+31]=h;a.sigBytes=4*f.length;this._process();return this._hash.toX32()},clone:function(){var a=r.clone.call(this);a._hash=this._hash.clone();return a},blockSize:32});m.SHA512=r._createHelper(f);m.HmacSHA512=r._createHmacHelper(f)})();
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
CryptoJS v3.1.2
|
||||
code.google.com/p/crypto-js
|
||||
(c) 2009-2013 by Jeff Mott. All rights reserved.
|
||||
code.google.com/p/crypto-js/wiki/License
|
||||
*/
|
||||
var CryptoJS=CryptoJS||function(u,l){var d={},n=d.lib={},p=function(){},s=n.Base={extend:function(a){p.prototype=this;var c=new p;a&&c.mixIn(a);c.hasOwnProperty("init")||(c.init=function(){c.$super.init.apply(this,arguments)});c.init.prototype=c;c.$super=this;return c},create:function(){var a=this.extend();a.init.apply(a,arguments);return a},init:function(){},mixIn:function(a){for(var c in a)a.hasOwnProperty(c)&&(this[c]=a[c]);a.hasOwnProperty("toString")&&(this.toString=a.toString)},clone:function(){return this.init.prototype.extend(this)}},
|
||||
q=n.WordArray=s.extend({init:function(a,c){a=this.words=a||[];this.sigBytes=c!=l?c:4*a.length},toString:function(a){return(a||v).stringify(this)},concat:function(a){var c=this.words,m=a.words,f=this.sigBytes;a=a.sigBytes;this.clamp();if(f%4)for(var t=0;t<a;t++)c[f+t>>>2]|=(m[t>>>2]>>>24-8*(t%4)&255)<<24-8*((f+t)%4);else if(65535<m.length)for(t=0;t<a;t+=4)c[f+t>>>2]=m[t>>>2];else c.push.apply(c,m);this.sigBytes+=a;return this},clamp:function(){var a=this.words,c=this.sigBytes;a[c>>>2]&=4294967295<<
|
||||
32-8*(c%4);a.length=u.ceil(c/4)},clone:function(){var a=s.clone.call(this);a.words=this.words.slice(0);return a},random:function(a){for(var c=[],m=0;m<a;m+=4)c.push(4294967296*u.random()|0);return new q.init(c,a)}}),w=d.enc={},v=w.Hex={stringify:function(a){var c=a.words;a=a.sigBytes;for(var m=[],f=0;f<a;f++){var t=c[f>>>2]>>>24-8*(f%4)&255;m.push((t>>>4).toString(16));m.push((t&15).toString(16))}return m.join("")},parse:function(a){for(var c=a.length,m=[],f=0;f<c;f+=2)m[f>>>3]|=parseInt(a.substr(f,
|
||||
2),16)<<24-4*(f%8);return new q.init(m,c/2)}},b=w.Latin1={stringify:function(a){var c=a.words;a=a.sigBytes;for(var m=[],f=0;f<a;f++)m.push(String.fromCharCode(c[f>>>2]>>>24-8*(f%4)&255));return m.join("")},parse:function(a){for(var c=a.length,m=[],f=0;f<c;f++)m[f>>>2]|=(a.charCodeAt(f)&255)<<24-8*(f%4);return new q.init(m,c)}},x=w.Utf8={stringify:function(a){try{return decodeURIComponent(escape(b.stringify(a)))}catch(c){throw Error("Malformed UTF-8 data");}},parse:function(a){return b.parse(unescape(encodeURIComponent(a)))}},
|
||||
r=n.BufferedBlockAlgorithm=s.extend({reset:function(){this._data=new q.init;this._nDataBytes=0},_append:function(a){"string"==typeof a&&(a=x.parse(a));this._data.concat(a);this._nDataBytes+=a.sigBytes},_process:function(a){var c=this._data,m=c.words,f=c.sigBytes,t=this.blockSize,b=f/(4*t),b=a?u.ceil(b):u.max((b|0)-this._minBufferSize,0);a=b*t;f=u.min(4*a,f);if(a){for(var e=0;e<a;e+=t)this._doProcessBlock(m,e);e=m.splice(0,a);c.sigBytes-=f}return new q.init(e,f)},clone:function(){var a=s.clone.call(this);
|
||||
a._data=this._data.clone();return a},_minBufferSize:0});n.Hasher=r.extend({cfg:s.extend(),init:function(a){this.cfg=this.cfg.extend(a);this.reset()},reset:function(){r.reset.call(this);this._doReset()},update:function(a){this._append(a);this._process();return this},finalize:function(a){a&&this._append(a);return this._doFinalize()},blockSize:16,_createHelper:function(a){return function(c,m){return(new a.init(m)).finalize(c)}},_createHmacHelper:function(a){return function(c,m){return(new e.HMAC.init(a,
|
||||
m)).finalize(c)}}});var e=d.algo={};return d}(Math);
|
||||
(function(){var u=CryptoJS,l=u.lib.WordArray;u.enc.Base64={stringify:function(d){var n=d.words,l=d.sigBytes,s=this._map;d.clamp();d=[];for(var q=0;q<l;q+=3)for(var w=(n[q>>>2]>>>24-8*(q%4)&255)<<16|(n[q+1>>>2]>>>24-8*((q+1)%4)&255)<<8|n[q+2>>>2]>>>24-8*((q+2)%4)&255,v=0;4>v&&q+0.75*v<l;v++)d.push(s.charAt(w>>>6*(3-v)&63));if(n=s.charAt(64))for(;d.length%4;)d.push(n);return d.join("")},parse:function(d){var n=d.length,p=this._map,s=p.charAt(64);s&&(s=d.indexOf(s),-1!=s&&(n=s));for(var s=[],q=0,w=0;w<
|
||||
n;w++)if(w%4){var v=p.indexOf(d.charAt(w-1))<<2*(w%4),b=p.indexOf(d.charAt(w))>>>6-2*(w%4);s[q>>>2]|=(v|b)<<24-8*(q%4);q++}return l.create(s,q)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}})();
|
||||
(function(u){function l(b,e,a,c,m,f,t){b=b+(e&a|~e&c)+m+t;return(b<<f|b>>>32-f)+e}function d(b,e,a,c,m,f,t){b=b+(e&c|a&~c)+m+t;return(b<<f|b>>>32-f)+e}function n(b,e,a,c,m,f,t){b=b+(e^a^c)+m+t;return(b<<f|b>>>32-f)+e}function p(b,e,a,c,m,f,t){b=b+(a^(e|~c))+m+t;return(b<<f|b>>>32-f)+e}for(var s=CryptoJS,q=s.lib,w=q.WordArray,v=q.Hasher,q=s.algo,b=[],x=0;64>x;x++)b[x]=4294967296*u.abs(u.sin(x+1))|0;q=q.MD5=v.extend({_doReset:function(){this._hash=new w.init([1732584193,4023233417,2562383102,271733878])},
|
||||
_doProcessBlock:function(r,e){for(var a=0;16>a;a++){var c=e+a,m=r[c];r[c]=(m<<8|m>>>24)&16711935|(m<<24|m>>>8)&4278255360}var a=this._hash.words,c=r[e+0],m=r[e+1],f=r[e+2],t=r[e+3],y=r[e+4],q=r[e+5],s=r[e+6],w=r[e+7],v=r[e+8],u=r[e+9],x=r[e+10],z=r[e+11],A=r[e+12],B=r[e+13],C=r[e+14],D=r[e+15],g=a[0],h=a[1],j=a[2],k=a[3],g=l(g,h,j,k,c,7,b[0]),k=l(k,g,h,j,m,12,b[1]),j=l(j,k,g,h,f,17,b[2]),h=l(h,j,k,g,t,22,b[3]),g=l(g,h,j,k,y,7,b[4]),k=l(k,g,h,j,q,12,b[5]),j=l(j,k,g,h,s,17,b[6]),h=l(h,j,k,g,w,22,b[7]),
|
||||
g=l(g,h,j,k,v,7,b[8]),k=l(k,g,h,j,u,12,b[9]),j=l(j,k,g,h,x,17,b[10]),h=l(h,j,k,g,z,22,b[11]),g=l(g,h,j,k,A,7,b[12]),k=l(k,g,h,j,B,12,b[13]),j=l(j,k,g,h,C,17,b[14]),h=l(h,j,k,g,D,22,b[15]),g=d(g,h,j,k,m,5,b[16]),k=d(k,g,h,j,s,9,b[17]),j=d(j,k,g,h,z,14,b[18]),h=d(h,j,k,g,c,20,b[19]),g=d(g,h,j,k,q,5,b[20]),k=d(k,g,h,j,x,9,b[21]),j=d(j,k,g,h,D,14,b[22]),h=d(h,j,k,g,y,20,b[23]),g=d(g,h,j,k,u,5,b[24]),k=d(k,g,h,j,C,9,b[25]),j=d(j,k,g,h,t,14,b[26]),h=d(h,j,k,g,v,20,b[27]),g=d(g,h,j,k,B,5,b[28]),k=d(k,g,
|
||||
h,j,f,9,b[29]),j=d(j,k,g,h,w,14,b[30]),h=d(h,j,k,g,A,20,b[31]),g=n(g,h,j,k,q,4,b[32]),k=n(k,g,h,j,v,11,b[33]),j=n(j,k,g,h,z,16,b[34]),h=n(h,j,k,g,C,23,b[35]),g=n(g,h,j,k,m,4,b[36]),k=n(k,g,h,j,y,11,b[37]),j=n(j,k,g,h,w,16,b[38]),h=n(h,j,k,g,x,23,b[39]),g=n(g,h,j,k,B,4,b[40]),k=n(k,g,h,j,c,11,b[41]),j=n(j,k,g,h,t,16,b[42]),h=n(h,j,k,g,s,23,b[43]),g=n(g,h,j,k,u,4,b[44]),k=n(k,g,h,j,A,11,b[45]),j=n(j,k,g,h,D,16,b[46]),h=n(h,j,k,g,f,23,b[47]),g=p(g,h,j,k,c,6,b[48]),k=p(k,g,h,j,w,10,b[49]),j=p(j,k,g,h,
|
||||
C,15,b[50]),h=p(h,j,k,g,q,21,b[51]),g=p(g,h,j,k,A,6,b[52]),k=p(k,g,h,j,t,10,b[53]),j=p(j,k,g,h,x,15,b[54]),h=p(h,j,k,g,m,21,b[55]),g=p(g,h,j,k,v,6,b[56]),k=p(k,g,h,j,D,10,b[57]),j=p(j,k,g,h,s,15,b[58]),h=p(h,j,k,g,B,21,b[59]),g=p(g,h,j,k,y,6,b[60]),k=p(k,g,h,j,z,10,b[61]),j=p(j,k,g,h,f,15,b[62]),h=p(h,j,k,g,u,21,b[63]);a[0]=a[0]+g|0;a[1]=a[1]+h|0;a[2]=a[2]+j|0;a[3]=a[3]+k|0},_doFinalize:function(){var b=this._data,e=b.words,a=8*this._nDataBytes,c=8*b.sigBytes;e[c>>>5]|=128<<24-c%32;var m=u.floor(a/
|
||||
4294967296);e[(c+64>>>9<<4)+15]=(m<<8|m>>>24)&16711935|(m<<24|m>>>8)&4278255360;e[(c+64>>>9<<4)+14]=(a<<8|a>>>24)&16711935|(a<<24|a>>>8)&4278255360;b.sigBytes=4*(e.length+1);this._process();b=this._hash;e=b.words;for(a=0;4>a;a++)c=e[a],e[a]=(c<<8|c>>>24)&16711935|(c<<24|c>>>8)&4278255360;return b},clone:function(){var b=v.clone.call(this);b._hash=this._hash.clone();return b}});s.MD5=v._createHelper(q);s.HmacMD5=v._createHmacHelper(q)})(Math);
|
||||
(function(){var u=CryptoJS,l=u.lib,d=l.Base,n=l.WordArray,l=u.algo,p=l.EvpKDF=d.extend({cfg:d.extend({keySize:4,hasher:l.MD5,iterations:1}),init:function(d){this.cfg=this.cfg.extend(d)},compute:function(d,l){for(var p=this.cfg,v=p.hasher.create(),b=n.create(),u=b.words,r=p.keySize,p=p.iterations;u.length<r;){e&&v.update(e);var e=v.update(d).finalize(l);v.reset();for(var a=1;a<p;a++)e=v.finalize(e),v.reset();b.concat(e)}b.sigBytes=4*r;return b}});u.EvpKDF=function(d,l,n){return p.create(n).compute(d,
|
||||
l)}})();
|
||||
CryptoJS.lib.Cipher||function(u){var l=CryptoJS,d=l.lib,n=d.Base,p=d.WordArray,s=d.BufferedBlockAlgorithm,q=l.enc.Base64,w=l.algo.EvpKDF,v=d.Cipher=s.extend({cfg:n.extend(),createEncryptor:function(m,a){return this.create(this._ENC_XFORM_MODE,m,a)},createDecryptor:function(m,a){return this.create(this._DEC_XFORM_MODE,m,a)},init:function(m,a,b){this.cfg=this.cfg.extend(b);this._xformMode=m;this._key=a;this.reset()},reset:function(){s.reset.call(this);this._doReset()},process:function(a){this._append(a);return this._process()},
|
||||
finalize:function(a){a&&this._append(a);return this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(m){return{encrypt:function(f,b,e){return("string"==typeof b?c:a).encrypt(m,f,b,e)},decrypt:function(f,b,e){return("string"==typeof b?c:a).decrypt(m,f,b,e)}}}});d.StreamCipher=v.extend({_doFinalize:function(){return this._process(!0)},blockSize:1});var b=l.mode={},x=function(a,f,b){var c=this._iv;c?this._iv=u:c=this._prevBlock;for(var e=0;e<b;e++)a[f+e]^=
|
||||
c[e]},r=(d.BlockCipherMode=n.extend({createEncryptor:function(a,f){return this.Encryptor.create(a,f)},createDecryptor:function(a,f){return this.Decryptor.create(a,f)},init:function(a,f){this._cipher=a;this._iv=f}})).extend();r.Encryptor=r.extend({processBlock:function(a,f){var b=this._cipher,c=b.blockSize;x.call(this,a,f,c);b.encryptBlock(a,f);this._prevBlock=a.slice(f,f+c)}});r.Decryptor=r.extend({processBlock:function(a,b){var c=this._cipher,e=c.blockSize,d=a.slice(b,b+e);c.decryptBlock(a,b);x.call(this,
|
||||
a,b,e);this._prevBlock=d}});b=b.CBC=r;r=(l.pad={}).Pkcs7={pad:function(a,b){for(var c=4*b,c=c-a.sigBytes%c,e=c<<24|c<<16|c<<8|c,d=[],l=0;l<c;l+=4)d.push(e);c=p.create(d,c);a.concat(c)},unpad:function(a){a.sigBytes-=a.words[a.sigBytes-1>>>2]&255}};d.BlockCipher=v.extend({cfg:v.cfg.extend({mode:b,padding:r}),reset:function(){v.reset.call(this);var a=this.cfg,c=a.iv,a=a.mode;if(this._xformMode==this._ENC_XFORM_MODE)var b=a.createEncryptor;else b=a.createDecryptor,this._minBufferSize=1;this._mode=b.call(a,
|
||||
this,c&&c.words)},_doProcessBlock:function(a,c){this._mode.processBlock(a,c)},_doFinalize:function(){var a=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){a.pad(this._data,this.blockSize);var c=this._process(!0)}else c=this._process(!0),a.unpad(c);return c},blockSize:4});var e=d.CipherParams=n.extend({init:function(a){this.mixIn(a)},toString:function(a){return(a||this.formatter).stringify(this)}}),b=(l.format={}).OpenSSL={stringify:function(a){var c=a.ciphertext;a=a.salt;return(a?p.create([1398893684,
|
||||
1701076831]).concat(a).concat(c):c).toString(q)},parse:function(a){a=q.parse(a);var c=a.words;if(1398893684==c[0]&&1701076831==c[1]){var b=p.create(c.slice(2,4));c.splice(0,4);a.sigBytes-=16}return e.create({ciphertext:a,salt:b})}},a=d.SerializableCipher=n.extend({cfg:n.extend({format:b}),encrypt:function(a,c,b,d){d=this.cfg.extend(d);var l=a.createEncryptor(b,d);c=l.finalize(c);l=l.cfg;return e.create({ciphertext:c,key:b,iv:l.iv,algorithm:a,mode:l.mode,padding:l.padding,blockSize:a.blockSize,formatter:d.format})},
|
||||
decrypt:function(a,c,b,e){e=this.cfg.extend(e);c=this._parse(c,e.format);return a.createDecryptor(b,e).finalize(c.ciphertext)},_parse:function(a,c){return"string"==typeof a?c.parse(a,this):a}}),l=(l.kdf={}).OpenSSL={execute:function(a,c,b,d){d||(d=p.random(8));a=w.create({keySize:c+b}).compute(a,d);b=p.create(a.words.slice(c),4*b);a.sigBytes=4*c;return e.create({key:a,iv:b,salt:d})}},c=d.PasswordBasedCipher=a.extend({cfg:a.cfg.extend({kdf:l}),encrypt:function(c,b,e,d){d=this.cfg.extend(d);e=d.kdf.execute(e,
|
||||
c.keySize,c.ivSize);d.iv=e.iv;c=a.encrypt.call(this,c,b,e.key,d);c.mixIn(e);return c},decrypt:function(c,b,e,d){d=this.cfg.extend(d);b=this._parse(b,d.format);e=d.kdf.execute(e,c.keySize,c.ivSize,b.salt);d.iv=e.iv;return a.decrypt.call(this,c,b,e.key,d)}})}();
|
||||
(function(){function u(b,a){var c=(this._lBlock>>>b^this._rBlock)&a;this._rBlock^=c;this._lBlock^=c<<b}function l(b,a){var c=(this._rBlock>>>b^this._lBlock)&a;this._lBlock^=c;this._rBlock^=c<<b}var d=CryptoJS,n=d.lib,p=n.WordArray,n=n.BlockCipher,s=d.algo,q=[57,49,41,33,25,17,9,1,58,50,42,34,26,18,10,2,59,51,43,35,27,19,11,3,60,52,44,36,63,55,47,39,31,23,15,7,62,54,46,38,30,22,14,6,61,53,45,37,29,21,13,5,28,20,12,4],w=[14,17,11,24,1,5,3,28,15,6,21,10,23,19,12,4,26,8,16,7,27,20,13,2,41,52,31,37,47,
|
||||
55,30,40,51,45,33,48,44,49,39,56,34,53,46,42,50,36,29,32],v=[1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28],b=[{"0":8421888,268435456:32768,536870912:8421378,805306368:2,1073741824:512,1342177280:8421890,1610612736:8389122,1879048192:8388608,2147483648:514,2415919104:8389120,2684354560:33280,2952790016:8421376,3221225472:32770,3489660928:8388610,3758096384:0,4026531840:33282,134217728:0,402653184:8421890,671088640:33282,939524096:32768,1207959552:8421888,1476395008:512,1744830464:8421378,2013265920:2,
|
||||
2281701376:8389120,2550136832:33280,2818572288:8421376,3087007744:8389122,3355443200:8388610,3623878656:32770,3892314112:514,4160749568:8388608,1:32768,268435457:2,536870913:8421888,805306369:8388608,1073741825:8421378,1342177281:33280,1610612737:512,1879048193:8389122,2147483649:8421890,2415919105:8421376,2684354561:8388610,2952790017:33282,3221225473:514,3489660929:8389120,3758096385:32770,4026531841:0,134217729:8421890,402653185:8421376,671088641:8388608,939524097:512,1207959553:32768,1476395009:8388610,
|
||||
1744830465:2,2013265921:33282,2281701377:32770,2550136833:8389122,2818572289:514,3087007745:8421888,3355443201:8389120,3623878657:0,3892314113:33280,4160749569:8421378},{"0":1074282512,16777216:16384,33554432:524288,50331648:1074266128,67108864:1073741840,83886080:1074282496,100663296:1073758208,117440512:16,134217728:540672,150994944:1073758224,167772160:1073741824,184549376:540688,201326592:524304,218103808:0,234881024:16400,251658240:1074266112,8388608:1073758208,25165824:540688,41943040:16,58720256:1073758224,
|
||||
75497472:1074282512,92274688:1073741824,109051904:524288,125829120:1074266128,142606336:524304,159383552:0,176160768:16384,192937984:1074266112,209715200:1073741840,226492416:540672,243269632:1074282496,260046848:16400,268435456:0,285212672:1074266128,301989888:1073758224,318767104:1074282496,335544320:1074266112,352321536:16,369098752:540688,385875968:16384,402653184:16400,419430400:524288,436207616:524304,452984832:1073741840,469762048:540672,486539264:1073758208,503316480:1073741824,520093696:1074282512,
|
||||
276824064:540688,293601280:524288,310378496:1074266112,327155712:16384,343932928:1073758208,360710144:1074282512,377487360:16,394264576:1073741824,411041792:1074282496,427819008:1073741840,444596224:1073758224,461373440:524304,478150656:0,494927872:16400,511705088:1074266128,528482304:540672},{"0":260,1048576:0,2097152:67109120,3145728:65796,4194304:65540,5242880:67108868,6291456:67174660,7340032:67174400,8388608:67108864,9437184:67174656,10485760:65792,11534336:67174404,12582912:67109124,13631488:65536,
|
||||
14680064:4,15728640:256,524288:67174656,1572864:67174404,2621440:0,3670016:67109120,4718592:67108868,5767168:65536,6815744:65540,7864320:260,8912896:4,9961472:256,11010048:67174400,12058624:65796,13107200:65792,14155776:67109124,15204352:67174660,16252928:67108864,16777216:67174656,17825792:65540,18874368:65536,19922944:67109120,20971520:256,22020096:67174660,23068672:67108868,24117248:0,25165824:67109124,26214400:67108864,27262976:4,28311552:65792,29360128:67174400,30408704:260,31457280:65796,32505856:67174404,
|
||||
17301504:67108864,18350080:260,19398656:67174656,20447232:0,21495808:65540,22544384:67109120,23592960:256,24641536:67174404,25690112:65536,26738688:67174660,27787264:65796,28835840:67108868,29884416:67109124,30932992:67174400,31981568:4,33030144:65792},{"0":2151682048,65536:2147487808,131072:4198464,196608:2151677952,262144:0,327680:4198400,393216:2147483712,458752:4194368,524288:2147483648,589824:4194304,655360:64,720896:2147487744,786432:2151678016,851968:4160,917504:4096,983040:2151682112,32768:2147487808,
|
||||
98304:64,163840:2151678016,229376:2147487744,294912:4198400,360448:2151682112,425984:0,491520:2151677952,557056:4096,622592:2151682048,688128:4194304,753664:4160,819200:2147483648,884736:4194368,950272:4198464,1015808:2147483712,1048576:4194368,1114112:4198400,1179648:2147483712,1245184:0,1310720:4160,1376256:2151678016,1441792:2151682048,1507328:2147487808,1572864:2151682112,1638400:2147483648,1703936:2151677952,1769472:4198464,1835008:2147487744,1900544:4194304,1966080:64,2031616:4096,1081344:2151677952,
|
||||
1146880:2151682112,1212416:0,1277952:4198400,1343488:4194368,1409024:2147483648,1474560:2147487808,1540096:64,1605632:2147483712,1671168:4096,1736704:2147487744,1802240:2151678016,1867776:4160,1933312:2151682048,1998848:4194304,2064384:4198464},{"0":128,4096:17039360,8192:262144,12288:536870912,16384:537133184,20480:16777344,24576:553648256,28672:262272,32768:16777216,36864:537133056,40960:536871040,45056:553910400,49152:553910272,53248:0,57344:17039488,61440:553648128,2048:17039488,6144:553648256,
|
||||
10240:128,14336:17039360,18432:262144,22528:537133184,26624:553910272,30720:536870912,34816:537133056,38912:0,43008:553910400,47104:16777344,51200:536871040,55296:553648128,59392:16777216,63488:262272,65536:262144,69632:128,73728:536870912,77824:553648256,81920:16777344,86016:553910272,90112:537133184,94208:16777216,98304:553910400,102400:553648128,106496:17039360,110592:537133056,114688:262272,118784:536871040,122880:0,126976:17039488,67584:553648256,71680:16777216,75776:17039360,79872:537133184,
|
||||
83968:536870912,88064:17039488,92160:128,96256:553910272,100352:262272,104448:553910400,108544:0,112640:553648128,116736:16777344,120832:262144,124928:537133056,129024:536871040},{"0":268435464,256:8192,512:270532608,768:270540808,1024:268443648,1280:2097152,1536:2097160,1792:268435456,2048:0,2304:268443656,2560:2105344,2816:8,3072:270532616,3328:2105352,3584:8200,3840:270540800,128:270532608,384:270540808,640:8,896:2097152,1152:2105352,1408:268435464,1664:268443648,1920:8200,2176:2097160,2432:8192,
|
||||
2688:268443656,2944:270532616,3200:0,3456:270540800,3712:2105344,3968:268435456,4096:268443648,4352:270532616,4608:270540808,4864:8200,5120:2097152,5376:268435456,5632:268435464,5888:2105344,6144:2105352,6400:0,6656:8,6912:270532608,7168:8192,7424:268443656,7680:270540800,7936:2097160,4224:8,4480:2105344,4736:2097152,4992:268435464,5248:268443648,5504:8200,5760:270540808,6016:270532608,6272:270540800,6528:270532616,6784:8192,7040:2105352,7296:2097160,7552:0,7808:268435456,8064:268443656},{"0":1048576,
|
||||
16:33555457,32:1024,48:1049601,64:34604033,80:0,96:1,112:34603009,128:33555456,144:1048577,160:33554433,176:34604032,192:34603008,208:1025,224:1049600,240:33554432,8:34603009,24:0,40:33555457,56:34604032,72:1048576,88:33554433,104:33554432,120:1025,136:1049601,152:33555456,168:34603008,184:1048577,200:1024,216:34604033,232:1,248:1049600,256:33554432,272:1048576,288:33555457,304:34603009,320:1048577,336:33555456,352:34604032,368:1049601,384:1025,400:34604033,416:1049600,432:1,448:0,464:34603008,480:33554433,
|
||||
496:1024,264:1049600,280:33555457,296:34603009,312:1,328:33554432,344:1048576,360:1025,376:34604032,392:33554433,408:34603008,424:0,440:34604033,456:1049601,472:1024,488:33555456,504:1048577},{"0":134219808,1:131072,2:134217728,3:32,4:131104,5:134350880,6:134350848,7:2048,8:134348800,9:134219776,10:133120,11:134348832,12:2080,13:0,14:134217760,15:133152,2147483648:2048,2147483649:134350880,2147483650:134219808,2147483651:134217728,2147483652:134348800,2147483653:133120,2147483654:133152,2147483655:32,
|
||||
2147483656:134217760,2147483657:2080,2147483658:131104,2147483659:134350848,2147483660:0,2147483661:134348832,2147483662:134219776,2147483663:131072,16:133152,17:134350848,18:32,19:2048,20:134219776,21:134217760,22:134348832,23:131072,24:0,25:131104,26:134348800,27:134219808,28:134350880,29:133120,30:2080,31:134217728,2147483664:131072,2147483665:2048,2147483666:134348832,2147483667:133152,2147483668:32,2147483669:134348800,2147483670:134217728,2147483671:134219808,2147483672:134350880,2147483673:134217760,
|
||||
2147483674:134219776,2147483675:0,2147483676:133120,2147483677:2080,2147483678:131104,2147483679:134350848}],x=[4160749569,528482304,33030144,2064384,129024,8064,504,2147483679],r=s.DES=n.extend({_doReset:function(){for(var b=this._key.words,a=[],c=0;56>c;c++){var d=q[c]-1;a[c]=b[d>>>5]>>>31-d%32&1}b=this._subKeys=[];for(d=0;16>d;d++){for(var f=b[d]=[],l=v[d],c=0;24>c;c++)f[c/6|0]|=a[(w[c]-1+l)%28]<<31-c%6,f[4+(c/6|0)]|=a[28+(w[c+24]-1+l)%28]<<31-c%6;f[0]=f[0]<<1|f[0]>>>31;for(c=1;7>c;c++)f[c]>>>=
|
||||
4*(c-1)+3;f[7]=f[7]<<5|f[7]>>>27}a=this._invSubKeys=[];for(c=0;16>c;c++)a[c]=b[15-c]},encryptBlock:function(b,a){this._doCryptBlock(b,a,this._subKeys)},decryptBlock:function(b,a){this._doCryptBlock(b,a,this._invSubKeys)},_doCryptBlock:function(e,a,c){this._lBlock=e[a];this._rBlock=e[a+1];u.call(this,4,252645135);u.call(this,16,65535);l.call(this,2,858993459);l.call(this,8,16711935);u.call(this,1,1431655765);for(var d=0;16>d;d++){for(var f=c[d],n=this._lBlock,p=this._rBlock,q=0,r=0;8>r;r++)q|=b[r][((p^
|
||||
f[r])&x[r])>>>0];this._lBlock=p;this._rBlock=n^q}c=this._lBlock;this._lBlock=this._rBlock;this._rBlock=c;u.call(this,1,1431655765);l.call(this,8,16711935);l.call(this,2,858993459);u.call(this,16,65535);u.call(this,4,252645135);e[a]=this._lBlock;e[a+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});d.DES=n._createHelper(r);s=s.TripleDES=n.extend({_doReset:function(){var b=this._key.words;this._des1=r.createEncryptor(p.create(b.slice(0,2)));this._des2=r.createEncryptor(p.create(b.slice(2,4)));this._des3=
|
||||
r.createEncryptor(p.create(b.slice(4,6)))},encryptBlock:function(b,a){this._des1.encryptBlock(b,a);this._des2.decryptBlock(b,a);this._des3.encryptBlock(b,a)},decryptBlock:function(b,a){this._des3.decryptBlock(b,a);this._des2.encryptBlock(b,a);this._des1.decryptBlock(b,a)},keySize:6,ivSize:2,blockSize:2});d.TripleDES=n._createHelper(s)})();
|
||||
@@ -0,0 +1,2 @@
|
||||
/*! @source http://purl.eligrey.com/github/FileSaver.js/blob/master/FileSaver.js */
|
||||
var saveAs = saveAs || function (e) { "use strict"; if (typeof navigator !== "undefined" && /MSIE [1-9]\./.test(navigator.userAgent)) { return } var t = e.document, n = function () { return e.URL || e.webkitURL || e }, r = t.createElementNS("http://www.w3.org/1999/xhtml", "a"), i = "download" in r, o = function (e) { var t = new MouseEvent("click"); e.dispatchEvent(t) }, a = /Version\/[\d\.]+.*Safari/.test(navigator.userAgent), f = e.webkitRequestFileSystem, u = e.requestFileSystem || f || e.mozRequestFileSystem, s = function (t) { (e.setImmediate || e.setTimeout)(function () { throw t }, 0) }, c = "application/octet-stream", d = 0, l = 500, w = function (t) { var r = function () { if (typeof t === "string") { n().revokeObjectURL(t) } else { t.remove() } }; if (e.chrome) { r() } else { setTimeout(r, l) } }, p = function (e, t, n) { t = [].concat(t); var r = t.length; while (r--) { var i = e["on" + t[r]]; if (typeof i === "function") { try { i.call(e, n || e) } catch (o) { s(o) } } } }, v = function (e) { if (/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)) { return new Blob(["\ufeff", e], { type: e.type }) } return e }, y = function (t, s, l) { if (!l) { t = v(t) } var y = this, m = t.type, S = false, h, R, O = function () { p(y, "writestart progress write writeend".split(" ")) }, g = function () { if (R && a && typeof FileReader !== "undefined") { var r = new FileReader; r.onloadend = function () { var e = r.result; R.location.href = "data:attachment/file" + e.slice(e.search(/[,;]/)); y.readyState = y.DONE; O() }; r.readAsDataURL(t); y.readyState = y.INIT; return } if (S || !h) { h = n().createObjectURL(t) } if (R) { R.location.href = h } else { var i = e.open(h, "_blank"); if (i == undefined && a) { e.location.href = h } } y.readyState = y.DONE; O(); w(h) }, b = function (e) { return function () { if (y.readyState !== y.DONE) { return e.apply(this, arguments) } } }, E = { create: true, exclusive: false }, N; y.readyState = y.INIT; if (!s) { s = "download" } if (i) { h = n().createObjectURL(t); r.href = h; r.download = s; setTimeout(function () { o(r); O(); w(h); y.readyState = y.DONE }); return } if (e.chrome && m && m !== c) { N = t.slice || t.webkitSlice; t = N.call(t, 0, t.size, c); S = true } if (f && s !== "download") { s += ".download" } if (m === c || f) { R = e } if (!u) { g(); return } d += t.size; u(e.TEMPORARY, d, b(function (e) { e.root.getDirectory("saved", E, b(function (e) { var n = function () { e.getFile(s, E, b(function (e) { e.createWriter(b(function (n) { n.onwriteend = function (t) { R.location.href = e.toURL(); y.readyState = y.DONE; p(y, "writeend", t); w(e) }; n.onerror = function () { var e = n.error; if (e.code !== e.ABORT_ERR) { g() } }; "writestart progress write abort".split(" ").forEach(function (e) { n["on" + e] = y["on" + e] }); n.write(t); y.abort = function () { n.abort(); y.readyState = y.DONE }; y.readyState = y.WRITING }), g) }), g) }; e.getFile(s, { create: false }, b(function (e) { e.remove(); n() }), b(function (e) { if (e.code === e.NOT_FOUND_ERR) { n() } else { g() } })) }), g) }), g) }, m = y.prototype, S = function (e, t, n) { return new y(e, t, n) }; if (typeof navigator !== "undefined" && navigator.msSaveOrOpenBlob) { return function (e, t, n) { if (!n) { e = v(e) } return navigator.msSaveOrOpenBlob(e, t || "download") } } m.abort = function () { var e = this; e.readyState = e.DONE; p(e, "abort") }; m.readyState = m.INIT = 0; m.WRITING = 1; m.DONE = 2; m.error = m.onwritestart = m.onprogress = m.onwrite = m.onabort = m.onerror = m.onwriteend = null; return S } (typeof self !== "undefined" && self || typeof window !== "undefined" && window || this.content); if (typeof module !== "undefined" && module.exports) { module.exports.saveAs = saveAs } else if (typeof define !== "undefined" && define !== null && define.amd != null) { define([], function () { return saveAs }) }
|
||||
@@ -0,0 +1,20 @@
|
||||
function check_is_ip(ip) {
|
||||
var reg = /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/
|
||||
return reg.test(ip);
|
||||
}
|
||||
function check_is_url(url) {
|
||||
const strRegex = '^((https|Net)://)?'//(https或http或ftp):// 可有可无
|
||||
+ '(([0-9]{1,3}\\.){3}[0-9]{1,3}' // IP形式的URL- 3位数字.3位数字.3位数字.3位数字
|
||||
+ '|' // 允许IP和DOMAIN(域名)
|
||||
+ '([\\w_!~*\'()-]+\\.)*' // 域名- 至少一个[英文或数字_!~*\'()-]加上.
|
||||
+ '\\w+\\.' // 一级域名 -英文或数字 加上.
|
||||
+ '[a-zA-Z]{1,6})' // 顶级域名- 1-6位英文
|
||||
+ '(:[0-9]{1,5})?' // 端口- :80 ,1-5位数字
|
||||
+ '((/?)|' // url无参数结尾 - 斜杆或这没有
|
||||
+ '(/[\\w_!~*\'()\\.;?:@&=+$,%#-]+)+/?)$';//请求参数结尾- 英文或数字和[]内的各种字符
|
||||
const re = new RegExp(strRegex, 'i'); // 大小写不敏感
|
||||
if (re.test(encodeURI(url))) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
document.write(unescape("%3Clink rel='stylesheet' href='/static/script/hljs/styles/monokai.css'%3E"));
|
||||
document.write(unescape("%3Cscript src='/static/script/hljs/highlight.pack.js' type='text/javascript'%3E%3C/script%3E"));
|
||||
$(function(){
|
||||
hljs.initHighlightingOnLoad();
|
||||
|
||||
});
|
||||
function is_hide(attr){
|
||||
attr = (typeof(attr) == "undefined" || title == '') ? "pre" : attr;
|
||||
$(attr).hide();
|
||||
}
|
||||
$("pre").hide();
|
||||
__=["\x70\x72\x65","\x73\x68\x6f\x77","\x68\x69\x67\x68\x6c\x69\x67\x68\x74\x41\x75\x74\x6f","\x76\x61\x6c\x75\x65",'\x23\x72\x65\x73\x75\x6c\x74',"\x65\x6d\x70\x74\x79","\x68\x74\x6d\x6c"];function hightout(Bd1){$(__[0])[__[1]]();var YLUMqiA2= hljs[__[2]](Bd1)[__[3]];$(__[4])[__[5]]();$(__[4])[__[6]](YLUMqiA2);}
|
||||
function is_show(attr){
|
||||
attr = (typeof(attr) == "undefined" || title == '') ? "pre" : attr;
|
||||
$(attr).show();
|
||||
}
|
||||
function ClearAll() {
|
||||
$("#content").val("");
|
||||
$("#content").select();
|
||||
$("#result").html('');
|
||||
$("pre").hide();
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
Monokai style - ported by Luigi Maselli - http://grigio.org
|
||||
*/
|
||||
|
||||
.hljs {
|
||||
display: block;
|
||||
overflow-x: auto;
|
||||
padding: 0.5em;
|
||||
background: #272822; color: #ddd;
|
||||
}
|
||||
|
||||
.hljs-tag,
|
||||
.hljs-keyword,
|
||||
.hljs-selector-tag,
|
||||
.hljs-literal,
|
||||
.hljs-strong,
|
||||
.hljs-name {
|
||||
color: #f92672;
|
||||
}
|
||||
|
||||
.hljs-code {
|
||||
color: #66d9ef;
|
||||
}
|
||||
|
||||
.hljs-class .hljs-title {
|
||||
color: white;
|
||||
}
|
||||
|
||||
.hljs-attribute,
|
||||
.hljs-symbol,
|
||||
.hljs-regexp,
|
||||
.hljs-link {
|
||||
color: #bf79db;
|
||||
}
|
||||
|
||||
.hljs-string,
|
||||
.hljs-bullet,
|
||||
.hljs-subst,
|
||||
.hljs-title,
|
||||
.hljs-section,
|
||||
.hljs-emphasis,
|
||||
.hljs-type,
|
||||
.hljs-built_in,
|
||||
.hljs-builtin-name,
|
||||
.hljs-selector-attr,
|
||||
.hljs-selector-pseudo,
|
||||
.hljs-addition,
|
||||
.hljs-variable,
|
||||
.hljs-template-tag,
|
||||
.hljs-template-variable {
|
||||
color: #a6e22e;
|
||||
}
|
||||
|
||||
.hljs-comment,
|
||||
.hljs-quote,
|
||||
.hljs-deletion,
|
||||
.hljs-meta {
|
||||
color: #75715e;
|
||||
}
|
||||
|
||||
.hljs-keyword,
|
||||
.hljs-selector-tag,
|
||||
.hljs-literal,
|
||||
.hljs-doctag,
|
||||
.hljs-title,
|
||||
.hljs-section,
|
||||
.hljs-type,
|
||||
.hljs-selector-id {
|
||||
font-weight: bold;
|
||||
}
|
||||
@@ -0,0 +1,145 @@
|
||||
var line_color = '#000';
|
||||
var line_size = 3;
|
||||
$(function() {
|
||||
$('.tool .color div').click(function() {
|
||||
$('.tool .color div').removeClass('active');
|
||||
$(this).addClass('active');
|
||||
line_color = $(this).data('color');
|
||||
mouseDot.fill = line_color;
|
||||
});
|
||||
|
||||
$('.tool .size div').click(function() {
|
||||
$('.tool .size div').removeClass('active');
|
||||
$(this).addClass('active');
|
||||
line_size = $(this).data('size');
|
||||
mouseDot.radius = Math.max(line_size / 2, 3);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
var childrens = new Array();
|
||||
|
||||
var c = document.querySelector("#canvas"),
|
||||
ctx = c.getContext("2d");
|
||||
// c.width = window.innerWidth;
|
||||
// c.height = window.innerHeight;
|
||||
c.addEventListener("touchmove", function(e) {
|
||||
e.preventDefault();
|
||||
}, false);
|
||||
|
||||
|
||||
var cs = oCanvas.create({
|
||||
canvas: "#canvas",
|
||||
background: "#fff",
|
||||
fps: 30,
|
||||
disableScrolling: true
|
||||
});
|
||||
|
||||
var isDraw = false;
|
||||
var xx = 0;
|
||||
var yy = 0;
|
||||
var mouseDot;
|
||||
|
||||
clearAll();
|
||||
|
||||
cs.bind('mousedown', function() {
|
||||
drawBegin(cs.mouse.x, cs.mouse.y);
|
||||
}).bind('touchstart tap', function() {
|
||||
drawBegin(cs.touch.x, cs.touch.y);
|
||||
}).bind('mouseup touchend', function() {
|
||||
isDraw = false;
|
||||
}).bind('mousemove', function() {
|
||||
drawMove(cs.mouse.x, cs.mouse.y);
|
||||
}).bind('touchmove', function() {
|
||||
drawMove(cs.touch.x, cs.touch.y);
|
||||
});
|
||||
|
||||
/*
|
||||
cs.setLoop(function () {
|
||||
mouseDot.x = cs.mouse.x;
|
||||
mouseDot.y = cs.mouse.y;
|
||||
}).start();
|
||||
*/
|
||||
|
||||
function drawBegin(x, y) {
|
||||
isDraw = true;
|
||||
|
||||
xx = x;
|
||||
yy = y;
|
||||
|
||||
var dot = cs.display.arc({
|
||||
x: x,
|
||||
y: y,
|
||||
radius: line_size / 2,
|
||||
start: 0,
|
||||
end: 360,
|
||||
fill: line_color
|
||||
});
|
||||
|
||||
cs.addChild(dot);
|
||||
add_child(dot);
|
||||
}
|
||||
|
||||
function drawMove(x, y) {
|
||||
if (isDraw) {
|
||||
var line = cs.display.line({
|
||||
start: {
|
||||
x: xx,
|
||||
y: yy
|
||||
},
|
||||
end: {
|
||||
x: x,
|
||||
y: y
|
||||
},
|
||||
stroke: '' + line_size + 'px ' + line_color,
|
||||
cap: "round"
|
||||
});
|
||||
|
||||
cs.addChild(line);
|
||||
add_child(line);
|
||||
xx = x;
|
||||
yy = y;
|
||||
} else {
|
||||
mouseDot.moveTo(x, y);
|
||||
cs.addChild(mouseDot);
|
||||
cs.draw.redraw();
|
||||
}
|
||||
}
|
||||
|
||||
function clearAll() {
|
||||
cs.reset();
|
||||
|
||||
// 处理鼠标
|
||||
cs.mouse.hide();
|
||||
|
||||
mouseDot = cs.display.arc({
|
||||
x: -100,
|
||||
y: -100,
|
||||
radius: Math.max(line_size / 2, 3),
|
||||
start: 0,
|
||||
end: 360,
|
||||
fill: line_color,
|
||||
shadow: '0 0 5px #333'
|
||||
});
|
||||
|
||||
cs.addChild(mouseDot);
|
||||
}
|
||||
|
||||
function add_child(d) {
|
||||
childrens.push(d);
|
||||
}
|
||||
|
||||
function re_draw() {
|
||||
var child = childrens.pop();
|
||||
if (child) {
|
||||
cs.removeChild(child);
|
||||
cs.draw.redraw();
|
||||
}
|
||||
}
|
||||
|
||||
function saveImageInfo() {
|
||||
var mycanvas = document.getElementById("canvas");
|
||||
var image = mycanvas.toDataURL("image/png");
|
||||
var w = window.open('about:blank', 'image_from_atool');
|
||||
w.document.write("<img src='" + image + "' alt='image_from_atool'/>");
|
||||
}
|
||||
@@ -0,0 +1,239 @@
|
||||
//IE对indexOf方法的支持
|
||||
if(!Array.indexOf){
|
||||
Array.prototype.indexOf = function(obj){
|
||||
for(var i=0; i<this.length; i++) if(this[i]===obj) return i;
|
||||
return -1;
|
||||
};
|
||||
}
|
||||
|
||||
;(function(root, factory) {
|
||||
var hotkeys = factory(root);
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
// AMD
|
||||
define('hotkeys', function() { return hotkeys; });
|
||||
} else if (typeof exports === 'object') {
|
||||
// Node.js
|
||||
module.exports = hotkeys;
|
||||
} else {
|
||||
// Browser globals
|
||||
// previousKey存储先前定义的关键字
|
||||
var previousKey = root.hotkeys;
|
||||
hotkeys.noConflict = function() {
|
||||
var k = root.hotkeys;
|
||||
root.hotkeys = previousKey;
|
||||
return k;
|
||||
};
|
||||
root.hotkeys = hotkeys;
|
||||
}
|
||||
}(this, function(root, undefined) {
|
||||
var _api,//对外API
|
||||
_keyMap = {//特殊键
|
||||
backspace: 8, tab: 9, clear: 12,
|
||||
enter: 13, 'return': 13,
|
||||
esc: 27, escape: 27, space: 32,
|
||||
left: 37, up: 38, right: 39, down: 40,
|
||||
del: 46, 'delete': 46,
|
||||
home: 36, end: 35,
|
||||
pageup: 33, pagedown: 34,
|
||||
',': 188, '.': 190, '/': 191,
|
||||
'`': 192, '-': 189, '=': 187,
|
||||
';': 186, '\'': 222,
|
||||
'[': 219, ']': 221, '\\': 220
|
||||
},
|
||||
_scope = 'all',//默认热键范围
|
||||
_modifier = {//修饰键
|
||||
'⇧': 16, shift: 16,
|
||||
'⌥': 18, alt: 18, option: 18,
|
||||
'⌃': 17, ctrl: 17, control: 17,
|
||||
'⌘': 91, command: 91
|
||||
},
|
||||
_downKeys=[],//记录摁下的绑定键
|
||||
modifierMap = {
|
||||
16:'shiftKey',
|
||||
18:'altKey',
|
||||
17:'ctrlKey',
|
||||
91:'metaKey'
|
||||
},
|
||||
_mods = { 16: false, 18: false, 17: false, 91: false },
|
||||
//返回键码
|
||||
code = function(x){
|
||||
return _keyMap[x] || x.toUpperCase().charCodeAt(0);
|
||||
},
|
||||
_handlers={};
|
||||
// F1~F12 特殊键
|
||||
for(k=1;k<20;k++) {
|
||||
_keyMap['f'+k] = 111+k;
|
||||
}
|
||||
|
||||
//设置获取当前范围(默认为'所有')
|
||||
function setScope(scope){ _scope = scope || 'all';}
|
||||
function getScope(){ return _scope || 'all';}
|
||||
//绑定事件
|
||||
function addEvent(object, event, method) {
|
||||
if (object.addEventListener){
|
||||
object.addEventListener(event, method, false);
|
||||
}else if(object.attachEvent){
|
||||
object.attachEvent('on'+event, function(){ method(window.event); });
|
||||
}
|
||||
}
|
||||
//判断摁下的键是否为某个键,返回true或者false
|
||||
function isPressed(keyCode) {
|
||||
if(typeof(keyCode) === 'string'){
|
||||
keyCode = code(keyCode);//转换成键码
|
||||
}
|
||||
return _downKeys.indexOf(keyCode) !==-1;
|
||||
}
|
||||
//获取摁下绑定键的键值
|
||||
function getPressedKeyCodes (argument) { return _downKeys.slice(0);}
|
||||
//处理keydown事件
|
||||
function dispatch (event) {
|
||||
var key = event.keyCode,modifiersMatch,scope,handler;
|
||||
|
||||
//搜集绑定的键
|
||||
if(_downKeys.indexOf(key)===-1) _downKeys.push(key);
|
||||
|
||||
//Gecko(Friefox)的command键值224,在Webkit(Chrome)中保持一致
|
||||
//Webkit左右command键值不一样
|
||||
if(key === 93 || key === 224) key = 91;
|
||||
if(key in _mods) {
|
||||
_mods[key] = true;
|
||||
// 将特殊字符的key注册到 hotkeys 上
|
||||
for(var k in _modifier)if(_modifier[k] === key) hotkeys[k] = true;
|
||||
return;
|
||||
}
|
||||
//将modifierMap里面的修饰键绑定到event中
|
||||
for(var e in _mods) _mods[e] = event[modifierMap[e]];
|
||||
//表单控件控件过滤 默认表单控件不触发快捷键
|
||||
if(!hotkeys.filter.call(this,event)) return;
|
||||
// key 不在_handlers中返回
|
||||
if (!(key in _handlers)) return;
|
||||
//获取范围 默认为all
|
||||
scope = getScope();
|
||||
for (i = 0; i < _handlers[key].length; i++) {
|
||||
//找到处理内容
|
||||
handler = _handlers[key][i];
|
||||
//看它是否在当前范围
|
||||
if(handler.scope === scope || handler.scope === 'all'){
|
||||
modifiersMatch = handler.mods.length > 0;
|
||||
for(var y in _mods){
|
||||
if((!_mods[y] && handler.mods.indexOf(+y) > -1) ||
|
||||
(_mods[y] && handler.mods.indexOf(+y) === -1)) modifiersMatch = false;
|
||||
}
|
||||
// 调用处理程序,如果是修饰键不做处理
|
||||
if((handler.mods.length === 0 && !_mods[16] && !_mods[18] && !_mods[17] && !_mods[91]) || modifiersMatch){
|
||||
if(handler.method(event, handler)===false){
|
||||
if(event.preventDefault) event.preventDefault();
|
||||
else event.returnValue = false;
|
||||
if(event.stopPropagation) event.stopPropagation();
|
||||
if(event.cancelBubble) event.cancelBubble = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//解除绑定某个范围的快捷键
|
||||
function unbind (key,scope) {
|
||||
var multipleKeys = getKeys(key),keys,mods = [],obj;
|
||||
for (var i = 0; i < multipleKeys.length; i++) {
|
||||
|
||||
//将组合快捷键拆分为数组
|
||||
keys =multipleKeys[i].split('+');
|
||||
|
||||
//记录每个组合键中的修饰键的键码 返回数组
|
||||
if(keys.length > 1) mods=getMods(keys);
|
||||
|
||||
//获取除修饰键外的键值key
|
||||
key = keys[keys.length - 1];
|
||||
key = code(key);
|
||||
|
||||
//判断是否传入范围,没有就获取范围
|
||||
if(scope === undefined) scope = getScope();
|
||||
|
||||
//如何key不在 _handlers 中返回不做处理
|
||||
if (!_handlers[key]) return;
|
||||
|
||||
//清空 handlers 中数据,
|
||||
//让触发快捷键键之后没有事件执行到达解除快捷键绑定的目的
|
||||
for (var r = 0; r < _handlers[key].length; r++) {
|
||||
obj = _handlers[key][r];
|
||||
//判断是否在范围内并且键值相同
|
||||
if (obj.scope === scope && compareArray(obj.mods, mods)) {
|
||||
_handlers[key][r] = {};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//比较修饰键的数组
|
||||
function compareArray(a1, a2) {
|
||||
if (a1.length !== a2.length) return false;
|
||||
for (var i = 0; i < a1.length; i++) {
|
||||
if (a1[i] !== a2[i]) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
//表单控件控件判断 返回 Boolean
|
||||
function filter(event){
|
||||
var tagName = (event.target || event.srcElement).tagName;
|
||||
//忽略这些标签情况下快捷键无效
|
||||
return !(tagName === 'INPUT' || tagName === 'SELECT' || tagName === 'TEXTAREA');
|
||||
}
|
||||
//修饰键转换成对应的键码
|
||||
function getMods (key) {
|
||||
var mods = key.slice(0, key.length - 1);
|
||||
for (var i = 0; i < mods.length; i++) mods[i] = _modifier[mods[i]];
|
||||
return mods;
|
||||
}
|
||||
//处理传的key字符串转换成数组
|
||||
function getKeys(key) {
|
||||
var keys;
|
||||
key = key.replace(/\s/g, '');//匹配任何空白字符,包括空格、制表符、换页符等等
|
||||
keys = key.split(',');
|
||||
if ((keys[keys.length - 1]) === '') keys[keys.length - 2] += ',';
|
||||
return keys;
|
||||
}
|
||||
//在全局document上设置快捷键
|
||||
addEvent(document, 'keydown', function(event) {
|
||||
dispatch(event);
|
||||
});
|
||||
//清除修改
|
||||
addEvent(document, 'keyup',function(event){
|
||||
var key = event.keyCode,
|
||||
i = _downKeys.indexOf(key);
|
||||
if(i>=0) _downKeys.splice(i,1);
|
||||
});
|
||||
//主体hotkeys函数
|
||||
function hotkeys(key,scope,method){
|
||||
var keys = getKeys(key), mods=[],i=0;
|
||||
//对为设定范围的判断
|
||||
if (method === undefined) {
|
||||
method = scope;
|
||||
scope = 'all';
|
||||
}
|
||||
//对于每个快捷键处理
|
||||
for(;i < keys.length; i++){
|
||||
key = keys[i].split('+');
|
||||
mods = [];
|
||||
//如果是组合快捷键取得组合快捷键
|
||||
if (key.length > 1){
|
||||
mods = getMods(key);
|
||||
key = [key[key.length-1]];
|
||||
}
|
||||
//转换成键码
|
||||
key = key[0];
|
||||
key = code(key);
|
||||
//判断key是否在_handlers中,不在就赋一个空数组
|
||||
if (!(key in _handlers)) _handlers[key] = [];
|
||||
_handlers[key].push({shortcut: keys[i], scope: scope, method: method, key: keys[i], mods: mods});
|
||||
}
|
||||
}
|
||||
_api = {
|
||||
setScope:setScope,
|
||||
getScope:getScope,
|
||||
getPressedKeyCodes:getPressedKeyCodes,
|
||||
isPressed:isPressed,
|
||||
filter:filter,
|
||||
unbind:unbind
|
||||
};
|
||||
for (var a in _api) hotkeys[a] = _api[a];
|
||||
return hotkeys;
|
||||
}));
|
||||
+12
File diff suppressed because one or more lines are too long
+2
File diff suppressed because one or more lines are too long
+5
File diff suppressed because one or more lines are too long
+4
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1,37 @@
|
||||
function do_js_beautify() {
|
||||
|
||||
document.getElementById("beautify").disabled = true;
|
||||
js_source = document.getElementById("content").value.replace(/^\s+/, "");
|
||||
tabsize = document.getElementById("tabsize").value;
|
||||
tabchar = " ";
|
||||
if (tabsize == 1) {
|
||||
tabchar = "\t";
|
||||
}
|
||||
if (js_source && js_source.charAt(0) === "<") {
|
||||
var output = style_html(js_source, tabsize, tabchar, 80);
|
||||
hightout(output);
|
||||
} else {
|
||||
var output = js_beautify(js_source, tabsize, tabchar);
|
||||
hightout(output);
|
||||
}
|
||||
document.getElementById("beautify").disabled = false;
|
||||
return false;
|
||||
}
|
||||
function pack_js(base64) {
|
||||
var input = document.getElementById("content").value;
|
||||
var packer = new Packer;
|
||||
if (base64) {
|
||||
var output = packer.pack(input, 1, 0);
|
||||
} else {
|
||||
var output = packer.pack(input, 0, 0);
|
||||
}
|
||||
hightout(output);
|
||||
}
|
||||
function Empty() {
|
||||
document.getElementById("content").value = "";
|
||||
document.getElementById("content").select();
|
||||
$("#result").html('');
|
||||
}
|
||||
function GetFocus() {
|
||||
document.getElementById("content").focus();
|
||||
}
|
||||
@@ -0,0 +1,439 @@
|
||||
|
||||
function style_html(html_source, indent_size, indent_character, max_char) {
|
||||
//Wrapper function to invoke all the necessary constructors and deal with the output.
|
||||
|
||||
var Parser, multi_parser;
|
||||
|
||||
function Parser() {
|
||||
|
||||
this.pos = 0; //Parser position
|
||||
this.token = '';
|
||||
this.current_mode = 'CONTENT'; //reflects the current Parser mode: TAG/CONTENT
|
||||
this.tags = { //An object to hold tags, their position, and their parent-tags, initiated with default values
|
||||
parent: 'parent1',
|
||||
parentcount: 1,
|
||||
parent1: ''
|
||||
};
|
||||
this.tag_type = '';
|
||||
this.token_text = this.last_token = this.last_text = this.token_type = '';
|
||||
|
||||
|
||||
this.Utils = { //Uilities made available to the various functions
|
||||
whitespace: "\n\r\t ".split(''),
|
||||
single_token: 'br,input,link,meta,!doctype,basefont,base,area,hr,wbr,param,img,isindex,?xml,embed'.split(','), //all the single tags for HTML
|
||||
extra_liners: 'head,body,/html'.split(','), //for tags that need a line of whitespace before them
|
||||
in_array: function (what, arr) {
|
||||
for (var i=0; i<arr.length; i++) {
|
||||
if (what === arr[i]) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
this.get_content = function () { //function to capture regular content between tags
|
||||
|
||||
var char = '';
|
||||
var content = [];
|
||||
var space = false; //if a space is needed
|
||||
while (this.input.charAt(this.pos) !== '<') {
|
||||
if (this.pos >= this.input.length) {
|
||||
return content.length?content.join(''):['', 'TK_EOF'];
|
||||
}
|
||||
|
||||
char = this.input.charAt(this.pos);
|
||||
this.pos++;
|
||||
this.line_char_count++;
|
||||
|
||||
|
||||
if (this.Utils.in_array(char, this.Utils.whitespace)) {
|
||||
if (content.length) {
|
||||
space = true;
|
||||
}
|
||||
this.line_char_count--;
|
||||
continue; //don't want to insert unnecessary space
|
||||
}
|
||||
else if (space) {
|
||||
if (this.line_char_count >= this.max_char) { //insert a line when the max_char is reached
|
||||
content.push('\n');
|
||||
for (var i=0; i<this.indent_level; i++) {
|
||||
content.push(this.indent_string);
|
||||
}
|
||||
this.line_char_count = 0;
|
||||
}
|
||||
else{
|
||||
content.push(' ');
|
||||
this.line_char_count++;
|
||||
}
|
||||
space = false;
|
||||
}
|
||||
content.push(char); //letter at-a-time (or string) inserted to an array
|
||||
}
|
||||
return content.length?content.join(''):'';
|
||||
}
|
||||
|
||||
this.get_script = function () { //get the full content of a script to pass to js_beautify
|
||||
|
||||
var char = '';
|
||||
var content = [];
|
||||
var reg_match = new RegExp('\<\/script' + '\>', 'igm');
|
||||
reg_match.lastIndex = this.pos;
|
||||
var reg_array = reg_match.exec(this.input);
|
||||
var end_script = reg_array?reg_array.index:this.input.length; //absolute end of script
|
||||
while(this.pos < end_script) { //get everything in between the script tags
|
||||
if (this.pos >= this.input.length) {
|
||||
return content.length?content.join(''):['', 'TK_EOF'];
|
||||
}
|
||||
|
||||
char = this.input.charAt(this.pos);
|
||||
this.pos++;
|
||||
|
||||
|
||||
content.push(char);
|
||||
}
|
||||
return content.length?content.join(''):''; //we might not have any content at all
|
||||
}
|
||||
|
||||
this.record_tag = function (tag){ //function to record a tag and its parent in this.tags Object
|
||||
if (this.tags[tag + 'count']) { //check for the existence of this tag type
|
||||
this.tags[tag + 'count']++;
|
||||
this.tags[tag + this.tags[tag + 'count']] = this.indent_level; //and record the present indent level
|
||||
}
|
||||
else { //otherwise initialize this tag type
|
||||
this.tags[tag + 'count'] = 1;
|
||||
this.tags[tag + this.tags[tag + 'count']] = this.indent_level; //and record the present indent level
|
||||
}
|
||||
this.tags[tag + this.tags[tag + 'count'] + 'parent'] = this.tags.parent; //set the parent (i.e. in the case of a div this.tags.div1parent)
|
||||
this.tags.parent = tag + this.tags[tag + 'count']; //and make this the current parent (i.e. in the case of a div 'div1')
|
||||
}
|
||||
|
||||
this.retrieve_tag = function (tag) { //function to retrieve the opening tag to the corresponding closer
|
||||
if (this.tags[tag + 'count']) { //if the openener is not in the Object we ignore it
|
||||
var temp_parent = this.tags.parent; //check to see if it's a closable tag.
|
||||
while (temp_parent) { //till we reach '' (the initial value);
|
||||
if (tag + this.tags[tag + 'count'] === temp_parent) { //if this is it use it
|
||||
break;
|
||||
}
|
||||
temp_parent = this.tags[temp_parent + 'parent']; //otherwise keep on climbing up the DOM Tree
|
||||
}
|
||||
if (temp_parent) { //if we caught something
|
||||
this.indent_level = this.tags[tag + this.tags[tag + 'count']]; //set the indent_level accordingly
|
||||
this.tags.parent = this.tags[temp_parent + 'parent']; //and set the current parent
|
||||
}
|
||||
delete this.tags[tag + this.tags[tag + 'count'] + 'parent']; //delete the closed tags parent reference...
|
||||
delete this.tags[tag + this.tags[tag + 'count']]; //...and the tag itself
|
||||
if (this.tags[tag + 'count'] == 1) {
|
||||
delete this.tags[tag + 'count'];
|
||||
}
|
||||
else {
|
||||
this.tags[tag + 'count']--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.get_tag = function () { //function to get a full tag and parse its type
|
||||
var char = '';
|
||||
var content = [];
|
||||
var space = false;
|
||||
|
||||
do {
|
||||
if (this.pos >= this.input.length) {
|
||||
return content.length?content.join(''):['', 'TK_EOF'];
|
||||
}
|
||||
|
||||
char = this.input.charAt(this.pos);
|
||||
this.pos++;
|
||||
this.line_char_count++;
|
||||
|
||||
if (this.Utils.in_array(char, this.Utils.whitespace)) { //don't want to insert unnecessary space
|
||||
space = true;
|
||||
this.line_char_count--;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (char === "'" || char === '"') {
|
||||
if (!content[1] || content[1] !== '!') { //if we're in a comment strings don't get treated specially
|
||||
char += this.get_unformatted(char);
|
||||
space = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (char === '=') { //no space before =
|
||||
space = false;
|
||||
}
|
||||
|
||||
if (content.length && content[content.length-1] !== '=' && char !== '>'
|
||||
&& space) { //no space after = or before >
|
||||
if (this.line_char_count >= this.max_char) {
|
||||
this.print_newline(false, content);
|
||||
this.line_char_count = 0;
|
||||
}
|
||||
else {
|
||||
content.push(' ');
|
||||
this.line_char_count++;
|
||||
}
|
||||
space = false;
|
||||
}
|
||||
content.push(char); //inserts character at-a-time (or string)
|
||||
} while (char !== '>');
|
||||
|
||||
var tag_complete = content.join('');
|
||||
var tag_index;
|
||||
if (tag_complete.indexOf(' ') != -1) { //if there's whitespace, thats where the tag name ends
|
||||
tag_index = tag_complete.indexOf(' ');
|
||||
}
|
||||
else { //otherwise go with the tag ending
|
||||
tag_index = tag_complete.indexOf('>');
|
||||
}
|
||||
var tag_check = tag_complete.substring(1, tag_index).toLowerCase();
|
||||
if (tag_complete.charAt(tag_complete.length-2) === '/' ||
|
||||
this.Utils.in_array(tag_check, this.Utils.single_token)) { //if this tag name is a single tag type (either in the list or has a closing /)
|
||||
this.tag_type = 'SINGLE';
|
||||
}
|
||||
else if (tag_check === 'script') { //for later script handling
|
||||
this.record_tag(tag_check);
|
||||
this.tag_type = 'SCRIPT';
|
||||
}
|
||||
else if (tag_check === 'style') { //for future style handling (for now it justs uses get_content)
|
||||
this.record_tag(tag_check);
|
||||
this.tag_type = 'STYLE';
|
||||
}
|
||||
else if (tag_check.charAt(0) === '!') { //peek for <!-- comment
|
||||
if (tag_check.indexOf('[if') != -1) { //peek for <!--[if conditional comment
|
||||
if (tag_complete.indexOf('!IE') != -1) { //this type needs a closing --> so...
|
||||
var comment = this.get_unformatted('-->', tag_complete); //...delegate to get_unformatted
|
||||
content.push(comment);
|
||||
}
|
||||
this.tag_type = 'START';
|
||||
}
|
||||
else if (tag_check.indexOf('[endif') != -1) {//peek for <!--[endif end conditional comment
|
||||
this.tag_type = 'END';
|
||||
this.unindent();
|
||||
}
|
||||
else if (tag_check.indexOf('[cdata[') != -1) { //if it's a <[cdata[ comment...
|
||||
var comment = this.get_unformatted(']]>', tag_complete); //...delegate to get_unformatted function
|
||||
content.push(comment);
|
||||
this.tag_type = 'SINGLE'; //<![CDATA[ comments are treated like single tags
|
||||
}
|
||||
else {
|
||||
var comment = this.get_unformatted('-->', tag_complete);
|
||||
content.push(comment);
|
||||
this.tag_type = 'SINGLE';
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (tag_check.charAt(0) === '/') { //this tag is a double tag so check for tag-ending
|
||||
this.retrieve_tag(tag_check.substring(1)); //remove it and all ancestors
|
||||
this.tag_type = 'END';
|
||||
}
|
||||
else { //otherwise it's a start-tag
|
||||
this.record_tag(tag_check); //push it on the tag stack
|
||||
this.tag_type = 'START';
|
||||
}
|
||||
if (this.Utils.in_array(tag_check, this.Utils.extra_liners)) { //check if this double needs an extra line
|
||||
this.print_newline(true, this.output);
|
||||
}
|
||||
}
|
||||
return content.join(''); //returns fully formatted tag
|
||||
}
|
||||
|
||||
this.get_unformatted = function (delimiter, orig_tag) { //function to return unformatted content in its entirety
|
||||
|
||||
if (orig_tag && orig_tag.indexOf(delimiter) != -1) {
|
||||
return '';
|
||||
}
|
||||
var char = '';
|
||||
var content = '';
|
||||
var space = true;
|
||||
do {
|
||||
|
||||
|
||||
char = this.input.charAt(this.pos);
|
||||
this.pos++
|
||||
|
||||
if (this.Utils.in_array(char, this.Utils.whitespace)) {
|
||||
if (!space) {
|
||||
this.line_char_count--;
|
||||
continue;
|
||||
}
|
||||
if (char === '\n' || char === '\r') {
|
||||
content += '\n';
|
||||
for (var i=0; i<this.indent_level; i++) {
|
||||
content += this.indent_string;
|
||||
}
|
||||
space = false; //...and make sure other indentation is erased
|
||||
this.line_char_count = 0;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
content += char;
|
||||
this.line_char_count++;
|
||||
space = true;
|
||||
|
||||
|
||||
} while (content.indexOf(delimiter) == -1);
|
||||
return content;
|
||||
}
|
||||
|
||||
this.get_token = function () { //initial handler for token-retrieval
|
||||
var token;
|
||||
|
||||
if (this.last_token === 'TK_TAG_SCRIPT') { //check if we need to format javascript
|
||||
var temp_token = this.get_script();
|
||||
if (typeof temp_token !== 'string') {
|
||||
return temp_token;
|
||||
}
|
||||
token = js_beautify(temp_token, this.indent_size, this.indent_character, this.indent_level); //call the JS Beautifier
|
||||
return [token, 'TK_CONTENT'];
|
||||
}
|
||||
if (this.current_mode === 'CONTENT') {
|
||||
token = this.get_content();
|
||||
if (typeof token !== 'string') {
|
||||
return token;
|
||||
}
|
||||
else {
|
||||
return [token, 'TK_CONTENT'];
|
||||
}
|
||||
}
|
||||
|
||||
if(this.current_mode === 'TAG') {
|
||||
token = this.get_tag();
|
||||
if (typeof token !== 'string') {
|
||||
return token;
|
||||
}
|
||||
else {
|
||||
var tag_name_type = 'TK_TAG_' + this.tag_type;
|
||||
return [token, tag_name_type];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.printer = function (js_source, indent_character, indent_size, max_char) { //handles input/output and some other printing functions
|
||||
|
||||
this.input = js_source || ''; //gets the input for the Parser
|
||||
this.output = [];
|
||||
this.indent_character = indent_character || ' ';
|
||||
this.indent_string = '';
|
||||
this.indent_size = indent_size || 2;
|
||||
this.indent_level = 0;
|
||||
this.max_char = max_char || 70; //maximum amount of characters per line
|
||||
this.line_char_count = 0; //count to see if max_char was exceeded
|
||||
|
||||
for (var i=0; i<this.indent_size; i++) {
|
||||
this.indent_string += this.indent_character;
|
||||
}
|
||||
|
||||
this.print_newline = function (ignore, arr) {
|
||||
this.line_char_count = 0;
|
||||
if (!arr || !arr.length) {
|
||||
return;
|
||||
}
|
||||
if (!ignore) { //we might want the extra line
|
||||
while (this.Utils.in_array(arr[arr.length-1], this.Utils.whitespace)) {
|
||||
arr.pop();
|
||||
}
|
||||
}
|
||||
arr.push('\n');
|
||||
for (var i=0; i<this.indent_level; i++) {
|
||||
arr.push(this.indent_string);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
this.print_token = function (text) {
|
||||
this.output.push(text);
|
||||
}
|
||||
|
||||
this.indent = function () {
|
||||
this.indent_level++;
|
||||
}
|
||||
|
||||
this.unindent = function () {
|
||||
if (this.indent_level > 0) {
|
||||
this.indent_level--;
|
||||
}
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/*_____________________--------------------_____________________*/
|
||||
|
||||
|
||||
|
||||
multi_parser = new Parser(); //wrapping functions Parser
|
||||
multi_parser.printer(html_source, indent_character, indent_size); //initialize starting values
|
||||
|
||||
|
||||
|
||||
while (true) {
|
||||
var t = multi_parser.get_token();
|
||||
multi_parser.token_text = t[0];
|
||||
multi_parser.token_type = t[1];
|
||||
|
||||
if (multi_parser.token_type === 'TK_EOF') {
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
switch (multi_parser.token_type) {
|
||||
case 'TK_TAG_START': case 'TK_TAG_SCRIPT': case 'TK_TAG_STYLE':
|
||||
multi_parser.print_newline(false, multi_parser.output);
|
||||
multi_parser.print_token(multi_parser.token_text);
|
||||
multi_parser.indent();
|
||||
multi_parser.current_mode = 'CONTENT';
|
||||
break;
|
||||
case 'TK_TAG_END':
|
||||
multi_parser.print_newline(true, multi_parser.output);
|
||||
multi_parser.print_token(multi_parser.token_text);
|
||||
multi_parser.current_mode = 'CONTENT';
|
||||
break;
|
||||
case 'TK_TAG_SINGLE':
|
||||
multi_parser.print_newline(false, multi_parser.output);
|
||||
multi_parser.print_token(multi_parser.token_text);
|
||||
multi_parser.current_mode = 'CONTENT';
|
||||
break;
|
||||
case 'TK_CONTENT':
|
||||
if (multi_parser.token_text !== '') {
|
||||
multi_parser.print_newline(false, multi_parser.output);
|
||||
multi_parser.print_token(multi_parser.token_text);
|
||||
}
|
||||
multi_parser.current_mode = 'TAG';
|
||||
break;
|
||||
}
|
||||
multi_parser.last_token = multi_parser.token_type;
|
||||
multi_parser.last_text = multi_parser.token_text;
|
||||
}
|
||||
return multi_parser.output.join('');
|
||||
}
|
||||
function HTMLcompressor(){
|
||||
var allHTML = document.getElementById("content").value;
|
||||
var headHTML = "";
|
||||
var removeThis = "";
|
||||
var headstatus = false;//document.getElementById("headstatus").checked;
|
||||
if(headstatus != true){
|
||||
//Compress all the things!
|
||||
allHTML = allHTML.replace(/(\r\n|\n|\r|\t)/gm,"");
|
||||
allHTML = allHTML.replace(/\s+/g," ");
|
||||
}else{
|
||||
//Don't compress the head
|
||||
allHTML = allHTML.replace(new RegExp("</HEAD","gi"),'</head');
|
||||
allHTML = allHTML.replace(new RegExp("</head ","gi"),'</head');
|
||||
|
||||
var bodySplit = "</head>";
|
||||
var i = allHTML.indexOf(bodySplit) != -1;
|
||||
if(i == true){
|
||||
var bodySplit = "</head>";
|
||||
tempo = allHTML.split(new RegExp(bodySplit,'i'));
|
||||
headHTML = tempo[0];
|
||||
allHTML = tempo[1];
|
||||
}else{
|
||||
bodySplit = "";
|
||||
}
|
||||
allHTML = allHTML.replace(/(\r\n|\n|\r|\t)/gm,"");
|
||||
allHTML = allHTML.replace(/\s+/g," ");
|
||||
allHTML = headHTML + bodySplit + '\n' + allHTML;
|
||||
}
|
||||
hightout(allHTML);
|
||||
}
|
||||
@@ -0,0 +1,582 @@
|
||||
var a = 62;
|
||||
$("#BtnAddEval").click(function () {
|
||||
var code = $("#content").val();
|
||||
if (code != "") {
|
||||
encode();
|
||||
}
|
||||
else {
|
||||
pcjson_com_msg($("#content"), "请输入加密内容");
|
||||
}
|
||||
});
|
||||
$("#BtnClearEval").click(function () {
|
||||
var code = $("#content").val();
|
||||
if (code != "") {
|
||||
decode();
|
||||
}
|
||||
else {
|
||||
pcjson_com_msg($("#content"), "请输入解密内容");
|
||||
}
|
||||
});
|
||||
$("#BtnClear").click(function () {
|
||||
$("#content").val("");
|
||||
$("#result").html('');
|
||||
});
|
||||
function encode() {
|
||||
var code = $("#content").val();
|
||||
code = code.replace(/[\r\n]+/g, '');
|
||||
code = code.replace(/'/g, "\\'");
|
||||
var tmp = code.match(/\b(\w+)\b/g);
|
||||
tmp.sort();
|
||||
var dict = [];
|
||||
var i, t = '';
|
||||
for (var i = 0; i < tmp.length; i++) {
|
||||
if (tmp[i] != t) dict.push(t = tmp[i]);
|
||||
}
|
||||
var len = dict.length;
|
||||
var ch;
|
||||
for (i = 0; i < len; i++) {
|
||||
ch = num(i);
|
||||
code = code.replace(new RegExp('\\b' + dict[i] + '\\b', 'g'), ch);
|
||||
if (ch == dict[i]) dict[i] = '';
|
||||
}
|
||||
var rt = "eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)d[e(c)]=k[c]||e(c);k=[function(e){return d[e]}];e=function(){return'\\\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\\\b'+e(c)+'\\\\b','g'),k[c]);return p}("
|
||||
+ "'" + code + "'," + a + "," + len + ",'" + dict.join('|') + "'.split('|'),0,{}))";
|
||||
hightout(rt);
|
||||
}
|
||||
function num(c) {
|
||||
return (c < a ? '' : num(parseInt(c / a))) + ((c = c % a) > 35 ? String.fromCharCode(c + 29) : c.toString(36));
|
||||
}
|
||||
function decode() {
|
||||
var code = $("#content").val();
|
||||
if (code != "" && code.indexOf('eval') > -1) {
|
||||
code = code.replace(/^eval/, '');
|
||||
hightout(js_beautify(eval(code), 4, " "));
|
||||
|
||||
}
|
||||
else {
|
||||
pcjson_com_msg($("#content"), "找不到符合条件的加密内容,无法解密");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function CLASS_CONFUSION(code) {
|
||||
//哈希表类
|
||||
function Hashtable() {
|
||||
this._hash = new Object();
|
||||
this.add = function (key, value) {
|
||||
if (typeof (key) != "undefined") {
|
||||
if (this.contains(key) == false) {
|
||||
this._hash[key] = typeof (value) == "undefined" ? null : value;
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
this.remove = function (key) { delete this._hash[key]; }
|
||||
this.count = function () { var i = 0; for (var k in this._hash) { i++; } return i; }
|
||||
this.items = function (key) { return this._hash[key]; }
|
||||
this.contains = function (key) { return typeof (this._hash[key]) != "undefined"; }
|
||||
this.clear = function () { for (var k in this._hash) { delete this._hash[k]; } }
|
||||
|
||||
}
|
||||
|
||||
function VariableMap(parent) {
|
||||
this.table = new Hashtable();
|
||||
this.level = parent ? parent.level + 1 : 0;
|
||||
this.parent = parent;
|
||||
this.add = function (key, value) { this.table.add(key, value) };
|
||||
this.items = function (key) { return this.table.items(key) };
|
||||
this.count = function () { return this.table.count() };
|
||||
this.contains = function (key) { return this.table.contains(key); }
|
||||
this.isParameter = false;
|
||||
}
|
||||
|
||||
this._caseSensitive = true;
|
||||
|
||||
//字符串转换为哈希表
|
||||
this.str2hashtable = function (key, cs) {
|
||||
|
||||
var _key = key.split(/,/g);
|
||||
var _hash = new Hashtable();
|
||||
var _cs = true;
|
||||
|
||||
|
||||
if (typeof (cs) == "undefined" || cs == null) {
|
||||
_cs = this._caseSensitive;
|
||||
} else {
|
||||
_cs = cs;
|
||||
}
|
||||
|
||||
for (var i in _key) {
|
||||
if (_cs) {
|
||||
_hash.add(_key[i]);
|
||||
} else {
|
||||
_hash.add((_key[i] + "").toLowerCase());
|
||||
}
|
||||
|
||||
}
|
||||
return _hash;
|
||||
}
|
||||
|
||||
//获得需要转换的代码
|
||||
this._codetxt = code;
|
||||
|
||||
if (typeof (syntax) == "undefined") {
|
||||
syntax = "";
|
||||
}
|
||||
|
||||
this._deleteComment = false;
|
||||
//是否大小写敏感
|
||||
this._caseSensitive = true;
|
||||
//得到关键字哈希表
|
||||
this._keywords = this.str2hashtable("switch,case,delete,default,typeof,for,in,function,void,this,boolean,while,if,return,new,true,false,try,catch,throw,null,else,do,var");
|
||||
this._function = this.str2hashtable("function");
|
||||
this._var = "var";
|
||||
this._beginBlock = "{";
|
||||
this._endBlock = "}";
|
||||
|
||||
this._window = this.str2hashtable("alert,escape,unescape,document,parseInt,parseFloat");
|
||||
//得到内建对象哈希表
|
||||
this._commonObjects = this.str2hashtable("String,Number,Boolean,RegExp,Error,Math,Date,Object,Array,Global");
|
||||
//得到分割字符
|
||||
this._wordDelimiters = " ,.?!;:\\/<>(){}[]\"'\r\n\t=+-|*%@#$^&";
|
||||
//引用字符
|
||||
this._quotation = this.str2hashtable("\",'");
|
||||
//行注释字符
|
||||
this._lineComment = "//";
|
||||
//转义字符
|
||||
this._escape = "\\";
|
||||
//多行引用开始
|
||||
this._commentOn = "/*";
|
||||
//多行引用结束
|
||||
this._commentOff = "*/";
|
||||
this._execute = "eval";
|
||||
//引用调用字符
|
||||
this._call = ".";
|
||||
this._varPause = "=";
|
||||
this._varContinue = ",";
|
||||
//变量个数
|
||||
this._varNum = 0;
|
||||
|
||||
this.confusion = function () {
|
||||
var codeArr = new Array();
|
||||
var word_index = 0;
|
||||
var htmlTxt = new Array();
|
||||
|
||||
|
||||
//得到分割字符数组(分词)
|
||||
for (var i = 0; i < this._codetxt.length; i++) {
|
||||
|
||||
if (this._wordDelimiters.indexOf(this._codetxt.charAt(i)) == -1) { //找不到关键字
|
||||
if (codeArr[word_index] == null || typeof (codeArr[word_index]) == 'undefined') {
|
||||
codeArr[word_index] = "";
|
||||
}
|
||||
codeArr[word_index] += this._codetxt.charAt(i);
|
||||
} else {
|
||||
if (typeof (codeArr[word_index]) != 'undefined' && codeArr[word_index].length > 0)
|
||||
word_index++;
|
||||
codeArr[word_index++] = this._codetxt.charAt(i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var quote_opened = false; //引用标记
|
||||
var slash_star_comment_opened = false; //多行注释标记
|
||||
var slash_slash_comment_opened = false; //单行注释标记
|
||||
var line_num = 1; //行号
|
||||
var quote_char = ""; //引用标记类型
|
||||
var call_opened = false;
|
||||
var call_string = "";
|
||||
var var_opened = false;
|
||||
var var_pause = false;
|
||||
var function_opened = false;
|
||||
var parameter_opened = false;
|
||||
|
||||
var var_map = new VariableMap();
|
||||
var cur_var_map = var_map;
|
||||
var execute_opened = false;
|
||||
|
||||
//按分割字,分块显示
|
||||
for (var i = 0; i <= word_index; i++) {
|
||||
|
||||
//单独处理指针引用
|
||||
if (call_opened && typeof (codeArr[i]) != "undefined") {
|
||||
if (call_string.length == 0) {
|
||||
if (this.isVar(codeArr[i])) {
|
||||
call_string += codeArr[i];
|
||||
} else {
|
||||
htmlTxt[htmlTxt.length] = "[\"" + this.toHex(call_string) + "\"]";
|
||||
if (codeArr[i] != this._call) {
|
||||
htmlTxt[htmlTxt.length] = codeArr[i];
|
||||
call_opened = false;
|
||||
}
|
||||
call_string = "";
|
||||
}
|
||||
} else {
|
||||
if (!this.isVar(codeArr[i])) {
|
||||
htmlTxt[htmlTxt.length] = "[\"" + this.toHex(call_string) + "\"]";
|
||||
if (codeArr[i] != this._call) {
|
||||
htmlTxt[htmlTxt.length] = codeArr[i];
|
||||
call_opened = false;
|
||||
}
|
||||
call_string = "";
|
||||
} else {
|
||||
htmlTxt[htmlTxt.length] = "[\"" + this.toHex(call_string) + "\"]";
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
//处理空行(由于转义带来)
|
||||
if (typeof (codeArr[i]) == "undefined" || codeArr[i].length == 0) {
|
||||
continue;
|
||||
} else if (codeArr[i] == " ") {
|
||||
htmlTxt[htmlTxt.length] = " ";
|
||||
} else if (codeArr[i] == "\n") {
|
||||
//处理换行
|
||||
} else if (codeArr[i] == "\r") {
|
||||
slash_slash_comment_opened = false;
|
||||
quote_opened = false;
|
||||
var_opened = false;
|
||||
htmlTxt[htmlTxt.length] = "\r\n";
|
||||
line_num++;
|
||||
//处理function里的参数标记
|
||||
} else if (!slash_slash_comment_opened && !slash_star_comment_opened && !quote_opened && this.isFunction(codeArr[i])) {
|
||||
htmlTxt[htmlTxt.length] = codeArr[i];
|
||||
function_opened = true;
|
||||
} else if (!slash_slash_comment_opened && !slash_star_comment_opened && !quote_opened && codeArr[i] == "(") {
|
||||
htmlTxt[htmlTxt.length] = codeArr[i];
|
||||
if (function_opened == true) {
|
||||
function_opened = false;
|
||||
var_opened = true;
|
||||
cur_var_map = new VariableMap(cur_var_map);
|
||||
cur_var_map.isParameter = true;
|
||||
}
|
||||
} else if (!slash_slash_comment_opened && !slash_star_comment_opened && !quote_opened && codeArr[i] == ")") {
|
||||
htmlTxt[htmlTxt.length] = codeArr[i];
|
||||
//处理var a = new Class(),b=new Date();类似的问题
|
||||
if (cur_var_map.isParameter) {
|
||||
var_opened = false;
|
||||
var_pause = false;
|
||||
}
|
||||
} else if (!slash_slash_comment_opened && !slash_star_comment_opened && !quote_opened && codeArr[i] == ";") {
|
||||
htmlTxt[htmlTxt.length] = codeArr[i];
|
||||
var_opened = false;
|
||||
var_pause = false;
|
||||
if (execute_opened) {
|
||||
execute_opened = false;
|
||||
}
|
||||
} else if (!slash_slash_comment_opened && !slash_star_comment_opened && !quote_opened && codeArr[i] == this._var) {
|
||||
htmlTxt[htmlTxt.length] = codeArr[i];
|
||||
var_opened = true;
|
||||
var_pause = false;
|
||||
} else if (!slash_slash_comment_opened && !slash_star_comment_opened && !quote_opened && codeArr[i] == this._varPause) {
|
||||
htmlTxt[htmlTxt.length] = codeArr[i];
|
||||
var_pause = true;
|
||||
} else if (!slash_slash_comment_opened && !slash_star_comment_opened && !quote_opened && codeArr[i] == this._varContinue) {
|
||||
htmlTxt[htmlTxt.length] = codeArr[i];
|
||||
var_pause = false;
|
||||
} else if (!slash_slash_comment_opened && !slash_star_comment_opened && !quote_opened && codeArr[i] == this._beginBlock) {
|
||||
cur_var_map = new VariableMap(cur_var_map);
|
||||
var_opened = false;
|
||||
htmlTxt[htmlTxt.length] = codeArr[i];
|
||||
} else if (!slash_slash_comment_opened && !slash_star_comment_opened && !quote_opened && codeArr[i] == this._endBlock) {
|
||||
cur_var_map = cur_var_map.parent;
|
||||
if (cur_var_map.isParameter) {
|
||||
cur_var_map = cur_var_map.parent;
|
||||
}
|
||||
htmlTxt[htmlTxt.length] = codeArr[i];
|
||||
//处理引用调用
|
||||
} else if (!slash_slash_comment_opened && !slash_star_comment_opened && !quote_opened && codeArr[i] == this._call) {
|
||||
//判断引用(.)后面第一个是否为字母货_$
|
||||
if (i < word_index - 1) {
|
||||
if (this.isVar(codeArr[i + 1])) {
|
||||
if (call_opened) {
|
||||
htmlTxt[htmlTxt.length] = this.toHex(call_string);
|
||||
}
|
||||
call_opened = true;
|
||||
} else {
|
||||
htmlTxt[htmlTxt.length] = this._call;
|
||||
}
|
||||
} else {
|
||||
htmlTxt[htmlTxt.length] = this._call;
|
||||
}
|
||||
//处理关键字
|
||||
} else if (!slash_slash_comment_opened && !slash_star_comment_opened && !quote_opened && this.isKeyword(codeArr[i])) {
|
||||
htmlTxt[htmlTxt.length] = codeArr[i];
|
||||
//处理eval后的字符串
|
||||
} else if (!slash_slash_comment_opened && !slash_star_comment_opened && !quote_opened && codeArr[i] == this._execute) {
|
||||
htmlTxt[htmlTxt.length] = "window[\"" + this.toHex(codeArr[i]) + "\"]";
|
||||
execute_opened = true;
|
||||
//window内置对象
|
||||
} else if (!slash_slash_comment_opened && !slash_star_comment_opened && !quote_opened && this.isWindow(codeArr[i])) {
|
||||
htmlTxt[htmlTxt.length] = "window[\"" + this.toHex(codeArr[i]) + "\"]";
|
||||
//处理普通对象
|
||||
} else if (!slash_slash_comment_opened && !slash_star_comment_opened && !quote_opened && this.isCommonObject(codeArr[i])) {
|
||||
htmlTxt[htmlTxt.length] = "window[\"" + this.toHex(codeArr[i]) + "\"]";
|
||||
//处理双引号(引号前不能为转义字符)
|
||||
} else if (!slash_star_comment_opened && !slash_slash_comment_opened && this._quotation.contains(codeArr[i])) {
|
||||
if (quote_opened) {
|
||||
//是相应的引号
|
||||
if (quote_char == codeArr[i]) {
|
||||
htmlTxt[htmlTxt.length] = codeArr[i];
|
||||
quote_opened = false;
|
||||
quote_char = "";
|
||||
} else {
|
||||
htmlTxt[htmlTxt.length] = this.toHex(codeArr[i]);
|
||||
}
|
||||
} else {
|
||||
htmlTxt[htmlTxt.length] = codeArr[i];
|
||||
quote_opened = true;
|
||||
quote_char = codeArr[i];
|
||||
}
|
||||
//处理转义字符
|
||||
} else if (codeArr[i] == this._escape) {
|
||||
htmlTxt[htmlTxt.length] = codeArr[i];
|
||||
if (i < word_index - 1) {
|
||||
if (codeArr[i + 1].charCodeAt(0) >= 32 && codeArr[i + 1].charCodeAt(0) <= 127) {
|
||||
htmlTxt[htmlTxt.length] = codeArr[i + 1].substr(0, 1);
|
||||
htmlTxt[htmlTxt.length] = this.toHex(codeArr[i + 1].substr(1));
|
||||
i = i + 1;
|
||||
}
|
||||
}
|
||||
//处理多行注释的开始
|
||||
} else if (!slash_slash_comment_opened && !slash_star_comment_opened && !quote_opened && this.isStartWith(this._commentOn, codeArr, i)) {
|
||||
slash_star_comment_opened = true;
|
||||
htmlTxt[htmlTxt.length] = this._commentOn;
|
||||
i = i + this.getSkipLength(this._commentOn);
|
||||
//处理单行注释
|
||||
} else if (!slash_slash_comment_opened && !slash_star_comment_opened && !quote_opened && this.isStartWith(this._lineComment, codeArr, i)) {
|
||||
slash_slash_comment_opened = true;
|
||||
if (!this._deleteComment) {
|
||||
htmlTxt[htmlTxt.length] = this._lineComment;
|
||||
}
|
||||
i = i + this.getSkipLength(this._lineComment);
|
||||
//处理忽略词
|
||||
} else if (!slash_slash_comment_opened && !slash_star_comment_opened && !quote_opened && this.isStartWith(this._ignore, codeArr, i)) {
|
||||
slash_slash_comment_opened = true;
|
||||
htmlTxt[htmlTxt.length] = this._ignore;
|
||||
i = i + this.getSkipLength(this._ignore);
|
||||
//处理多行注释结束
|
||||
} else if (!quote_opened && !slash_slash_comment_opened && this.isStartWith(this._commentOff, codeArr, i)) {
|
||||
if (slash_star_comment_opened) {
|
||||
slash_star_comment_opened = false;
|
||||
if (!this._deleteComment) {
|
||||
htmlTxt[htmlTxt.length] = this._commentOff;
|
||||
}
|
||||
i = i + this.getSkipLength(this._commentOff);
|
||||
}
|
||||
} else {
|
||||
//不是在字符串中
|
||||
if (!quote_opened) {
|
||||
//如果不是在注释重
|
||||
if (!slash_slash_comment_opened && !slash_star_comment_opened) {
|
||||
//不是在定义变量时
|
||||
if (!var_opened) {
|
||||
if (this.translateVar(cur_var_map, codeArr[i]) == "") {
|
||||
htmlTxt[htmlTxt.length] = codeArr[i];
|
||||
} else {
|
||||
htmlTxt[htmlTxt.length] = this.translateVar(cur_var_map, codeArr[i]);
|
||||
}
|
||||
} else {
|
||||
//不是在暂停变量定义时
|
||||
if (var_pause) {
|
||||
if (this.translateVar(cur_var_map, codeArr[i]) == "") {
|
||||
htmlTxt[htmlTxt.length] = codeArr[i];
|
||||
} else {
|
||||
htmlTxt[htmlTxt.length] = this.translateVar(cur_var_map, codeArr[i]);
|
||||
}
|
||||
} else {
|
||||
//变量符合命名规则,并且(变量前为空格或制表符或逗号如:var a;var a;var a,b;,还有如果是函数参数,如:function(a,b,c)
|
||||
if (this.isVar(codeArr[i]) && (i > 0 && codeArr[i - 1] == " " || codeArr[i - 1] == "\t" || codeArr[i - 1] == this._varContinue || cur_var_map.isParameter)) {
|
||||
var name = this.getRandName();
|
||||
cur_var_map.add(codeArr[i], name);
|
||||
htmlTxt[htmlTxt.length] = this.translateVar(cur_var_map, codeArr[i]);
|
||||
} else {
|
||||
htmlTxt[htmlTxt.length] = codeArr[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
//注释中
|
||||
} else {
|
||||
if (!this._deleteComment) {
|
||||
htmlTxt[htmlTxt.length] = codeArr[i];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (execute_opened) {
|
||||
if (this.translateVar(cur_var_map, codeArr[i]) == "") {
|
||||
htmlTxt[htmlTxt.length] = codeArr[i];
|
||||
} else {
|
||||
htmlTxt[htmlTxt.length] = this.translateVar(cur_var_map, codeArr[i]);
|
||||
}
|
||||
} else {
|
||||
htmlTxt[htmlTxt.length] = this.toHex(codeArr[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return htmlTxt.join("");
|
||||
}
|
||||
|
||||
this.isStartWith = function (str, code, index) {
|
||||
|
||||
if (typeof (str) != "undefined" && str.length > 0) {
|
||||
var cc = new Array();
|
||||
for (var i = index; i < index + str.length; i++) {
|
||||
cc[cc.length] = code[i];
|
||||
}
|
||||
var c = cc.join("");
|
||||
if (this._caseSensitive) {
|
||||
if (str.length >= code[index].length && c.indexOf(str) == 0) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
if (str.length >= code[index].length && c.toLowerCase().indexOf(str.toLowerCase()) == 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
this.isFunction = function (val) {
|
||||
return this._function.contains(this._caseSensitive ? val : val.toLowerCase());
|
||||
}
|
||||
|
||||
this.isKeyword = function (val) {
|
||||
return this._keywords.contains(this._caseSensitive ? val : val.toLowerCase());
|
||||
}
|
||||
|
||||
this.isWindow = function (val) {
|
||||
return this._window.contains(this._caseSensitive ? val : val.toLowerCase());
|
||||
}
|
||||
|
||||
this.isCommonObject = function (val) {
|
||||
return this._commonObjects.contains(this._caseSensitive ? val : val.toLowerCase());
|
||||
}
|
||||
|
||||
this.getSkipLength = function (val) {
|
||||
var count = 0;
|
||||
for (var i = 0; i < val.length; i++) {
|
||||
if (this._wordDelimiters.indexOf(val.charAt(i)) >= 0) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
if (count > 0) {
|
||||
count = count - 1;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
//字符串转换为16进制形式
|
||||
this.toHex = function (val) {
|
||||
var str = new Array();
|
||||
for (var i = 0; i < val.length; i++) {
|
||||
var c = val.charCodeAt(i);
|
||||
if (c >= 0 && c < 256) {
|
||||
str[str.length] = "\\x" + val.charCodeAt(i).toString(16);
|
||||
} else {
|
||||
str[str.length] = "\\u" + val.charCodeAt(i).toString(16);
|
||||
}
|
||||
}
|
||||
return str.join("");
|
||||
}
|
||||
|
||||
//获得变量随机名
|
||||
this.getRandName = function () {
|
||||
var style = parseInt(Math.random() * 4);
|
||||
var len = parseInt(Math.random() * 9) + 1;
|
||||
var n = [];
|
||||
|
||||
this._varNum++;
|
||||
var c = "abcdefghijklmnopqrstuvwsyzABCDEFGHIJKLMNOPQRSTUVWXYZ_$";
|
||||
|
||||
for (var i = 0; i < len; i++) {
|
||||
n[n.length] = c.charAt(parseInt(Math.random() * 54));
|
||||
}
|
||||
|
||||
return n.join("") + this._varNum;
|
||||
|
||||
}
|
||||
|
||||
//是否符合变量命名字首规则
|
||||
this.isVar = function (val) {
|
||||
return /^[a-zA-Z_\$].*$/.test(val);
|
||||
}
|
||||
|
||||
//翻译变量,如果返回为空则不存在此变量
|
||||
this.translateVar = function (node, key) {
|
||||
if (node.contains(key)) {
|
||||
return node.items(key);
|
||||
}
|
||||
|
||||
var cn = node.parent;
|
||||
while (cn != null) {
|
||||
if (cn.contains(key)) {
|
||||
return cn.items(key);
|
||||
}
|
||||
cn = cn.parent;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
function doConfusion(o) {
|
||||
var htmltxt = "";
|
||||
|
||||
if (o == null) {
|
||||
alert("domNode is null!");
|
||||
return;
|
||||
}
|
||||
|
||||
var _codetxt = "";
|
||||
|
||||
if (typeof (o) == "object") {
|
||||
switch (o.tagName) {
|
||||
case "TEXTAREA":
|
||||
case "INPUT":
|
||||
_codetxt = o.value;
|
||||
break;
|
||||
case "DIV":
|
||||
case "SPAN":
|
||||
_codetxt = o.innerText;
|
||||
break;
|
||||
default:
|
||||
_codetxt = o.innerHTML;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
_codetxt = o;
|
||||
}
|
||||
|
||||
var _syn = new CLASS_CONFUSION(_codetxt);
|
||||
htmltxt = _syn.confusion();
|
||||
return htmltxt;
|
||||
}
|
||||
$("#BtnCon").click(function () {
|
||||
var code = $("#content").val();
|
||||
if (code != "") {
|
||||
var xx = new CLASS_CONFUSION(code);
|
||||
var a = new Date();
|
||||
hightout(xx.confusion());
|
||||
}
|
||||
else {
|
||||
pcjson_com_msg($("#content"), "请输入混淆加密内容");
|
||||
}
|
||||
});
|
||||
$("#BtnClear").click(function () {
|
||||
$("#content").val("");
|
||||
hightout("");
|
||||
});
|
||||
|
||||
@@ -0,0 +1,568 @@
|
||||
|
||||
|
||||
function js_beautify(js_source_text, indent_size, indent_character, indent_level)
|
||||
{
|
||||
|
||||
var input, output, token_text, last_type, last_text, last_word, current_mode, modes, indent_string;
|
||||
var whitespace, wordchar, punct, parser_pos, line_starters, in_case;
|
||||
var prefix, token_type, do_block_just_closed, var_line, var_line_tainted;
|
||||
|
||||
|
||||
|
||||
function trim_output()
|
||||
{
|
||||
while (output.length && (output[output.length - 1] === ' ' || output[output.length - 1] === indent_string)) {
|
||||
output.pop();
|
||||
}
|
||||
}
|
||||
|
||||
function print_newline(ignore_repeated)
|
||||
{
|
||||
ignore_repeated = typeof ignore_repeated === 'undefined' ? true: ignore_repeated;
|
||||
|
||||
trim_output();
|
||||
|
||||
if (!output.length) {
|
||||
return; // no newline on start of file
|
||||
}
|
||||
|
||||
if (output[output.length - 1] !== "\n" || !ignore_repeated) {
|
||||
output.push("\n");
|
||||
}
|
||||
for (var i = 0; i < indent_level; i++) {
|
||||
output.push(indent_string);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
function print_space()
|
||||
{
|
||||
var last_output = output.length ? output[output.length - 1] : ' ';
|
||||
if (last_output !== ' ' && last_output !== '\n' && last_output !== indent_string) { // prevent occassional duplicate space
|
||||
output.push(' ');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function print_token()
|
||||
{
|
||||
output.push(token_text);
|
||||
}
|
||||
|
||||
function indent()
|
||||
{
|
||||
indent_level++;
|
||||
}
|
||||
|
||||
|
||||
function unindent()
|
||||
{
|
||||
if (indent_level) {
|
||||
indent_level--;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function remove_indent()
|
||||
{
|
||||
if (output.length && output[output.length - 1] === indent_string) {
|
||||
output.pop();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function set_mode(mode)
|
||||
{
|
||||
modes.push(current_mode);
|
||||
current_mode = mode;
|
||||
}
|
||||
|
||||
|
||||
function restore_mode()
|
||||
{
|
||||
do_block_just_closed = current_mode === 'DO_BLOCK';
|
||||
current_mode = modes.pop();
|
||||
}
|
||||
|
||||
|
||||
function in_array(what, arr)
|
||||
{
|
||||
for (var i = 0; i < arr.length; i++)
|
||||
{
|
||||
if (arr[i] === what) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function get_next_token()
|
||||
{
|
||||
var n_newlines = 0;
|
||||
var c = '';
|
||||
|
||||
do {
|
||||
if (parser_pos >= input.length) {
|
||||
return ['', 'TK_EOF'];
|
||||
}
|
||||
c = input.charAt(parser_pos);
|
||||
|
||||
parser_pos += 1;
|
||||
if (c === "\n") {
|
||||
n_newlines += 1;
|
||||
}
|
||||
}
|
||||
while (in_array(c, whitespace));
|
||||
|
||||
if (n_newlines > 1) {
|
||||
for (var i = 0; i < 2; i++) {
|
||||
print_newline(i === 0);
|
||||
}
|
||||
}
|
||||
var wanted_newline = (n_newlines === 1);
|
||||
|
||||
|
||||
if (in_array(c, wordchar)) {
|
||||
if (parser_pos < input.length) {
|
||||
while (in_array(input.charAt(parser_pos), wordchar)) {
|
||||
c += input.charAt(parser_pos);
|
||||
parser_pos += 1;
|
||||
if (parser_pos === input.length) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// small and surprisingly unugly hack for 1E-10 representation
|
||||
if (parser_pos !== input.length && c.match(/^[0-9]+[Ee]$/) && input.charAt(parser_pos) === '-') {
|
||||
parser_pos += 1;
|
||||
|
||||
var t = get_next_token(parser_pos);
|
||||
c += '-' + t[0];
|
||||
return [c, 'TK_WORD'];
|
||||
}
|
||||
|
||||
if (c === 'in') { // hack for 'in' operator
|
||||
return [c, 'TK_OPERATOR'];
|
||||
}
|
||||
return [c, 'TK_WORD'];
|
||||
}
|
||||
|
||||
if (c === '(' || c === '[') {
|
||||
return [c, 'TK_START_EXPR'];
|
||||
}
|
||||
|
||||
if (c === ')' || c === ']') {
|
||||
return [c, 'TK_END_EXPR'];
|
||||
}
|
||||
|
||||
if (c === '{') {
|
||||
return [c, 'TK_START_BLOCK'];
|
||||
}
|
||||
|
||||
if (c === '}') {
|
||||
return [c, 'TK_END_BLOCK'];
|
||||
}
|
||||
|
||||
if (c === ';') {
|
||||
return [c, 'TK_END_COMMAND'];
|
||||
}
|
||||
|
||||
if (c === '/') {
|
||||
var comment = '';
|
||||
// peek for comment /* ... */
|
||||
if (input.charAt(parser_pos) === '*') {
|
||||
parser_pos += 1;
|
||||
if (parser_pos < input.length) {
|
||||
while (! (input.charAt(parser_pos) === '*' && input.charAt(parser_pos + 1) && input.charAt(parser_pos + 1) === '/') && parser_pos < input.length) {
|
||||
comment += input.charAt(parser_pos);
|
||||
parser_pos += 1;
|
||||
if (parser_pos >= input.length) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
parser_pos += 2;
|
||||
return ['/*' + comment + '*/', 'TK_BLOCK_COMMENT'];
|
||||
}
|
||||
// peek for comment // ...
|
||||
if (input.charAt(parser_pos) === '/') {
|
||||
comment = c;
|
||||
while (input.charAt(parser_pos) !== "\x0d" && input.charAt(parser_pos) !== "\x0a") {
|
||||
comment += input.charAt(parser_pos);
|
||||
parser_pos += 1;
|
||||
if (parser_pos >= input.length) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
parser_pos += 1;
|
||||
if (wanted_newline) {
|
||||
print_newline();
|
||||
}
|
||||
return [comment, 'TK_COMMENT'];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (c === "'" || // string
|
||||
c === '"' || // string
|
||||
(c === '/' &&
|
||||
((last_type === 'TK_WORD' && last_text === 'return') || (last_type === 'TK_START_EXPR' || last_type === 'TK_END_BLOCK' || last_type === 'TK_OPERATOR' || last_type === 'TK_EOF' || last_type === 'TK_END_COMMAND')))) { // regexp
|
||||
var sep = c;
|
||||
var esc = false;
|
||||
c = '';
|
||||
|
||||
if (parser_pos < input.length) {
|
||||
|
||||
while (esc || input.charAt(parser_pos) !== sep) {
|
||||
c += input.charAt(parser_pos);
|
||||
if (!esc) {
|
||||
esc = input.charAt(parser_pos) === '\\';
|
||||
} else {
|
||||
esc = false;
|
||||
}
|
||||
parser_pos += 1;
|
||||
if (parser_pos >= input.length) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
parser_pos += 1;
|
||||
if (last_type === 'TK_END_COMMAND') {
|
||||
print_newline();
|
||||
}
|
||||
return [sep + c + sep, 'TK_STRING'];
|
||||
}
|
||||
|
||||
if (in_array(c, punct)) {
|
||||
while (parser_pos < input.length && in_array(c + input.charAt(parser_pos), punct)) {
|
||||
c += input.charAt(parser_pos);
|
||||
parser_pos += 1;
|
||||
if (parser_pos >= input.length) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return [c, 'TK_OPERATOR'];
|
||||
}
|
||||
|
||||
return [c, 'TK_UNKNOWN'];
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------
|
||||
|
||||
indent_character = indent_character || ' ';
|
||||
indent_size = indent_size || 4;
|
||||
|
||||
indent_string = '';
|
||||
while (indent_size--) {
|
||||
indent_string += indent_character;
|
||||
}
|
||||
|
||||
input = js_source_text;
|
||||
|
||||
last_word = ''; // last 'TK_WORD' passed
|
||||
last_type = 'TK_START_EXPR'; // last token type
|
||||
last_text = ''; // last token text
|
||||
output = [];
|
||||
|
||||
do_block_just_closed = false;
|
||||
var_line = false;
|
||||
var_line_tainted = false;
|
||||
|
||||
whitespace = "\n\r\t ".split('');
|
||||
wordchar = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_$'.split('');
|
||||
punct = '+ - * / % & ++ -- = += -= *= /= %= == === != !== > < >= <= >> << >>> >>>= >>= <<= && &= | || ! !! , : ? ^ ^= |='.split(' ');
|
||||
|
||||
// words which should always start on new line.
|
||||
line_starters = 'continue,try,throw,return,var,if,switch,case,default,for,while,break,function'.split(',');
|
||||
|
||||
// states showing if we are currently in expression (i.e. "if" case) - 'EXPRESSION', or in usual block (like, procedure), 'BLOCK'.
|
||||
// some formatting depends on that.
|
||||
current_mode = 'BLOCK';
|
||||
modes = [current_mode];
|
||||
|
||||
indent_level = indent_level || 0;
|
||||
parser_pos = 0; // parser position
|
||||
in_case = false; // flag for parser that case/default has been processed, and next colon needs special attention
|
||||
while (true) {
|
||||
var t = get_next_token(parser_pos);
|
||||
token_text = t[0];
|
||||
token_type = t[1];
|
||||
if (token_type === 'TK_EOF') {
|
||||
break;
|
||||
}
|
||||
|
||||
switch (token_type) {
|
||||
|
||||
case 'TK_START_EXPR':
|
||||
var_line = false;
|
||||
set_mode('EXPRESSION');
|
||||
if (last_type === 'TK_END_EXPR' || last_type === 'TK_START_EXPR') {
|
||||
// do nothing on (( and )( and ][ and ]( ..
|
||||
} else if (last_type !== 'TK_WORD' && last_type !== 'TK_OPERATOR') {
|
||||
print_space();
|
||||
} else if (in_array(last_word, line_starters) && last_word !== 'function') {
|
||||
print_space();
|
||||
}
|
||||
print_token();
|
||||
break;
|
||||
|
||||
case 'TK_END_EXPR':
|
||||
print_token();
|
||||
restore_mode();
|
||||
break;
|
||||
|
||||
case 'TK_START_BLOCK':
|
||||
|
||||
if (last_word === 'do') {
|
||||
set_mode('DO_BLOCK');
|
||||
} else {
|
||||
set_mode('BLOCK');
|
||||
}
|
||||
if (last_type !== 'TK_OPERATOR' && last_type !== 'TK_START_EXPR') {
|
||||
if (last_type === 'TK_START_BLOCK') {
|
||||
print_newline();
|
||||
} else {
|
||||
print_space();
|
||||
}
|
||||
}
|
||||
print_token();
|
||||
indent();
|
||||
break;
|
||||
|
||||
case 'TK_END_BLOCK':
|
||||
if (last_type === 'TK_START_BLOCK') {
|
||||
// nothing
|
||||
trim_output();
|
||||
unindent();
|
||||
} else {
|
||||
unindent();
|
||||
print_newline();
|
||||
}
|
||||
print_token();
|
||||
restore_mode();
|
||||
break;
|
||||
|
||||
case 'TK_WORD':
|
||||
|
||||
if (do_block_just_closed) {
|
||||
print_space();
|
||||
print_token();
|
||||
print_space();
|
||||
break;
|
||||
}
|
||||
|
||||
if (token_text === 'case' || token_text === 'default') {
|
||||
if (last_text === ':') {
|
||||
// switch cases following one another
|
||||
remove_indent();
|
||||
} else {
|
||||
// case statement starts in the same line where switch
|
||||
unindent();
|
||||
print_newline();
|
||||
indent();
|
||||
}
|
||||
print_token();
|
||||
in_case = true;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
prefix = 'NONE';
|
||||
if (last_type === 'TK_END_BLOCK') {
|
||||
if (!in_array(token_text.toLowerCase(), ['else', 'catch', 'finally'])) {
|
||||
prefix = 'NEWLINE';
|
||||
} else {
|
||||
prefix = 'SPACE';
|
||||
print_space();
|
||||
}
|
||||
} else if (last_type === 'TK_END_COMMAND' && (current_mode === 'BLOCK' || current_mode === 'DO_BLOCK')) {
|
||||
prefix = 'NEWLINE';
|
||||
} else if (last_type === 'TK_END_COMMAND' && current_mode === 'EXPRESSION') {
|
||||
prefix = 'SPACE';
|
||||
} else if (last_type === 'TK_WORD') {
|
||||
prefix = 'SPACE';
|
||||
} else if (last_type === 'TK_START_BLOCK') {
|
||||
prefix = 'NEWLINE';
|
||||
} else if (last_type === 'TK_END_EXPR') {
|
||||
print_space();
|
||||
prefix = 'NEWLINE';
|
||||
}
|
||||
|
||||
if (last_type !== 'TK_END_BLOCK' && in_array(token_text.toLowerCase(), ['else', 'catch', 'finally'])) {
|
||||
print_newline();
|
||||
} else if (in_array(token_text, line_starters) || prefix === 'NEWLINE') {
|
||||
if (last_text === 'else') {
|
||||
// no need to force newline on else break
|
||||
print_space();
|
||||
} else if ((last_type === 'TK_START_EXPR' || last_text === '=') && token_text === 'function') {
|
||||
// no need to force newline on 'function': (function
|
||||
// DONOTHING
|
||||
} else if (last_type === 'TK_WORD' && (last_text === 'return' || last_text === 'throw')) {
|
||||
// no newline between 'return nnn'
|
||||
print_space();
|
||||
} else if (last_type !== 'TK_END_EXPR') {
|
||||
if ((last_type !== 'TK_START_EXPR' || token_text !== 'var') && last_text !== ':') {
|
||||
// no need to force newline on 'var': for (var x = 0...)
|
||||
if (token_text === 'if' && last_type === 'TK_WORD' && last_word === 'else') {
|
||||
// no newline for } else if {
|
||||
print_space();
|
||||
} else {
|
||||
print_newline();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (in_array(token_text, line_starters) && last_text !== ')') {
|
||||
print_newline();
|
||||
}
|
||||
}
|
||||
} else if (prefix === 'SPACE') {
|
||||
print_space();
|
||||
}
|
||||
print_token();
|
||||
last_word = token_text;
|
||||
|
||||
if (token_text === 'var') {
|
||||
var_line = true;
|
||||
var_line_tainted = false;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'TK_END_COMMAND':
|
||||
|
||||
print_token();
|
||||
var_line = false;
|
||||
break;
|
||||
|
||||
case 'TK_STRING':
|
||||
|
||||
if (last_type === 'TK_START_BLOCK' || last_type === 'TK_END_BLOCK') {
|
||||
print_newline();
|
||||
} else if (last_type === 'TK_WORD') {
|
||||
print_space();
|
||||
}
|
||||
print_token();
|
||||
break;
|
||||
|
||||
case 'TK_OPERATOR':
|
||||
|
||||
var start_delim = true;
|
||||
var end_delim = true;
|
||||
if (var_line && token_text !== ',') {
|
||||
var_line_tainted = true;
|
||||
if (token_text === ':') {
|
||||
var_line = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (token_text === ':' && in_case) {
|
||||
print_token(); // colon really asks for separate treatment
|
||||
print_newline();
|
||||
break;
|
||||
}
|
||||
|
||||
in_case = false;
|
||||
|
||||
if (token_text === ',') {
|
||||
if (var_line) {
|
||||
if (var_line_tainted) {
|
||||
print_token();
|
||||
print_newline();
|
||||
var_line_tainted = false;
|
||||
} else {
|
||||
print_token();
|
||||
print_space();
|
||||
}
|
||||
} else if (last_type === 'TK_END_BLOCK') {
|
||||
print_token();
|
||||
print_newline();
|
||||
} else {
|
||||
if (current_mode === 'BLOCK') {
|
||||
print_token();
|
||||
print_newline();
|
||||
} else {
|
||||
// EXPR od DO_BLOCK
|
||||
print_token();
|
||||
print_space();
|
||||
}
|
||||
}
|
||||
break;
|
||||
} else if (token_text === '--' || token_text === '++') { // unary operators special case
|
||||
if (last_text === ';') {
|
||||
// space for (;; ++i)
|
||||
start_delim = true;
|
||||
end_delim = false;
|
||||
} else {
|
||||
start_delim = false;
|
||||
end_delim = false;
|
||||
}
|
||||
} else if (token_text === '!' && last_type === 'TK_START_EXPR') {
|
||||
// special case handling: if (!a)
|
||||
start_delim = false;
|
||||
end_delim = false;
|
||||
} else if (last_type === 'TK_OPERATOR') {
|
||||
start_delim = false;
|
||||
end_delim = false;
|
||||
} else if (last_type === 'TK_END_EXPR') {
|
||||
start_delim = true;
|
||||
end_delim = true;
|
||||
} else if (token_text === '.') {
|
||||
// decimal digits or object.property
|
||||
start_delim = false;
|
||||
end_delim = false;
|
||||
|
||||
} else if (token_text === ':') {
|
||||
// zz: xx
|
||||
// can't differentiate ternary op, so for now it's a ? b: c; without space before colon
|
||||
if (last_text.match(/^\d+$/)) {
|
||||
// a little help for ternary a ? 1 : 0;
|
||||
start_delim = true;
|
||||
} else {
|
||||
start_delim = false;
|
||||
}
|
||||
}
|
||||
if (start_delim) {
|
||||
print_space();
|
||||
}
|
||||
|
||||
print_token();
|
||||
|
||||
if (end_delim) {
|
||||
print_space();
|
||||
}
|
||||
break;
|
||||
|
||||
case 'TK_BLOCK_COMMENT':
|
||||
|
||||
print_newline();
|
||||
print_token();
|
||||
print_newline();
|
||||
break;
|
||||
|
||||
case 'TK_COMMENT':
|
||||
|
||||
// print_newline();
|
||||
print_space();
|
||||
print_token();
|
||||
print_newline();
|
||||
break;
|
||||
|
||||
case 'TK_UNKNOWN':
|
||||
print_token();
|
||||
break;
|
||||
}
|
||||
|
||||
last_type = token_type;
|
||||
last_text = token_text;
|
||||
}
|
||||
|
||||
return output.join('');
|
||||
|
||||
}
|
||||
@@ -0,0 +1,151 @@
|
||||
var tests_passed = 0;
|
||||
var tests_failed = 0;
|
||||
var test_result = '';
|
||||
|
||||
|
||||
var indent_size = 4;
|
||||
var indent_char = ' ';
|
||||
|
||||
function lazy_escape(str)
|
||||
{
|
||||
return str.replace(/</g, '<').replace(/\>/g, '>').replace(/\n/g, '<br />');
|
||||
}
|
||||
|
||||
function bt(input, expected)
|
||||
{
|
||||
expected = expected || input;
|
||||
|
||||
result = js_beautify(input, indent_size, indent_char);
|
||||
|
||||
if (result != expected) {
|
||||
test_result +=
|
||||
'\n---- input --------\n' + lazy_escape(input) +
|
||||
'\n---- expected -----\n' + lazy_escape(expected) +
|
||||
'\n---- received -----\n' + lazy_escape(result) +
|
||||
'\n-------------------';
|
||||
tests_failed += 1;
|
||||
} else {
|
||||
tests_passed += 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function results()
|
||||
{
|
||||
if (tests_failed == 0) {
|
||||
test_result += 'All ' + tests_passed + ' tests passed.';
|
||||
} else {
|
||||
test_result += '\n' + tests_failed + ' tests failed.';
|
||||
}
|
||||
return test_result;
|
||||
}
|
||||
|
||||
function test_js_beautify()
|
||||
{
|
||||
|
||||
bt('');
|
||||
bt('a = 1', 'a = 1');
|
||||
bt('a=1', 'a = 1');
|
||||
bt("a();\n\nb();", "a();\n\nb();");
|
||||
bt('var a = 1 var b = 2', "var a = 1\nvar b = 2");
|
||||
bt('a = " 12345 "');
|
||||
bt("a = ' 12345 '");
|
||||
bt('if (a == 1) b = 2', "if (a == 1) b = 2");
|
||||
bt('if(1){2}else{3}', "if (1) {\n 2\n} else {\n 3\n}");
|
||||
bt('if(1||2)', 'if (1 || 2)');
|
||||
bt('(a==1)||(b==2)', '(a == 1) || (b == 2)');
|
||||
bt('var a = 1 if (2) 3', "var a = 1\nif (2) 3");
|
||||
bt('a = a + 1');
|
||||
bt('a = a == 1');
|
||||
bt('/12345[^678]*9+/.match(a)');
|
||||
bt('a /= 5');
|
||||
bt('a = 0.5 * 3');
|
||||
bt('a *= 10.55');
|
||||
bt('a < .5');
|
||||
bt('a <= .5');
|
||||
bt('a<.5', 'a < .5');
|
||||
bt('a<=.5', 'a <= .5');
|
||||
bt('a = 0xff;');
|
||||
bt('a=0xff+4', 'a = 0xff + 4');
|
||||
bt('a = [1, 2, 3, 4]');
|
||||
bt('F*(g/=f)*g+b', 'F * (g /= f) * g + b');
|
||||
bt('a.b({c:d})', "a.b({\n c: d\n})");
|
||||
bt('a=!b', 'a = !b');
|
||||
bt('a?b:c', 'a ? b: c'); // 'a ? b : c' would need too make parser more complex to differentiate between ternary op and object assignment
|
||||
bt('a?1:2', 'a ? 1 : 2'); // 'a ? b : c' would need too make parser more complex to differentiate between ternary op and object assignment
|
||||
bt('a?(b):c', 'a ? (b) : c'); // this works, though
|
||||
bt('function void(void) {}');
|
||||
bt('if(!a)', 'if (!a)');
|
||||
bt('a=~a', 'a = ~a');
|
||||
bt('a;/*comment*/b;', "a;\n/*comment*/\nb;");
|
||||
bt('if(a)break', "if (a) break");
|
||||
bt('if(a){break}', "if (a) {\n break\n}");
|
||||
bt('if((a))', 'if ((a))');
|
||||
bt('for(var i=0;;)', 'for (var i = 0;;)');
|
||||
bt('a++;', 'a++;');
|
||||
bt('for(;;i++)', 'for (;; i++)');
|
||||
bt('for(;;++i)', 'for (;; ++i)');
|
||||
bt('return(1)', 'return (1)');
|
||||
bt('try{a();}catch(b){c();}finally{d();}', "try {\n a();\n} catch(b) {\n c();\n} finally {\n d();\n}");
|
||||
bt('(xx)()'); // magic function call
|
||||
bt('a[1]()'); // another magic function call
|
||||
bt('if(a){b();}else if(', "if (a) {\n b();\n} else if (");
|
||||
bt('switch(x) {case 0: case 1: a(); break; default: break}', "switch (x) {\ncase 0:\ncase 1:\n a();\n break;\ndefault:\n break\n}");
|
||||
bt('a !== b');
|
||||
bt('if (a) b(); else c();', "if (a) b();\nelse c();");
|
||||
bt("// comment\n(function()"); // typical greasemonkey start
|
||||
bt("// comment\n(function something()"); // typical greasemonkey start
|
||||
bt("{\n\n x();\n\n}"); // was: duplicating newlines
|
||||
bt('if (a in b)');
|
||||
//bt('var a, b');
|
||||
bt('{a:1, b:2}', "{\n a: 1,\n b: 2\n}");
|
||||
bt('var l = {\'a\':\'1\', \'b\':\'2\'}', "var l = {\n 'a': '1',\n 'b': '2'\n}");
|
||||
bt('if (template.user[n] in bk)');
|
||||
bt('{{}/z/}', "{\n {}\n /z/\n}");
|
||||
bt('return 45', "return 45");
|
||||
bt('If[1]', "If[1]");
|
||||
bt('Then[1]', "Then[1]");
|
||||
bt('a = 1e10', "a = 1e10");
|
||||
bt('a = 1.3e10', "a = 1.3e10");
|
||||
bt('a = 1.3e-10', "a = 1.3e-10");
|
||||
bt('a = -1.3e-10', "a = -1.3e-10");
|
||||
bt('a = 1e-10', "a = 1e-10");
|
||||
bt('a = e - 10', "a = e - 10");
|
||||
bt('a = 11-10', "a = 11 - 10");
|
||||
bt("a = 1;// comment\n", "a = 1; // comment\n");
|
||||
bt("a = 1; // comment\n", "a = 1; // comment\n");
|
||||
bt("a = 1;\n // comment\n", "a = 1;\n// comment\n");
|
||||
|
||||
bt("if (a) {\n do();\n}"); // was: extra space appended
|
||||
bt("if\n(a)\nb()", "if (a) b()"); // test for proper newline removal
|
||||
|
||||
bt("if (a) {\n// comment\n}else{\n// comment\n}", "if (a) {\n // comment\n} else {\n // comment\n}"); // if/else statement with empty body
|
||||
bt("if (a) {\n// comment\n// comment\n}", "if (a) {\n // comment\n // comment\n}"); // multiple comments indentation
|
||||
bt("if (a) b() else c()", "if (a) b()\nelse c()");
|
||||
bt("if (a) b() else if c() d()", "if (a) b()\nelse if c() d()");
|
||||
|
||||
bt("{}");
|
||||
bt("{\n\n}");
|
||||
bt("do { a(); } while ( 1 );", "do {\n a();\n} while ( 1 );");
|
||||
bt("do {} while ( 1 );");
|
||||
bt("do {\n} while ( 1 );", "do {} while ( 1 );");
|
||||
bt("do {\n\n} while ( 1 );");
|
||||
bt("var a, b, c, d = 0, c = function() {}, d = '';", "var a, b, c, d = 0,\nc = function() {},\nd = '';");
|
||||
bt("var a = x(a, b, c)");
|
||||
bt("delete x if (a) b();", "delete x\nif (a) b();");
|
||||
bt("delete x[x] if (a) b();", "delete x[x]\nif (a) b();");
|
||||
|
||||
|
||||
indent_size = 1;
|
||||
indent_char = ' ';
|
||||
bt('{ one_char() }', "{\n one_char()\n}")
|
||||
|
||||
indent_size = 4;
|
||||
indent_char = ' ';
|
||||
bt('{ one_char() }', "{\n one_char()\n}")
|
||||
|
||||
indent_size = 1;
|
||||
indent_char = "\t";
|
||||
bt('{ one_char() }', "{\n\tone_char()\n}")
|
||||
return results();
|
||||
}
|
||||
@@ -0,0 +1,391 @@
|
||||
window.SINGLE_TAB = " ";
|
||||
window.ImgCollapsed = "/static/images/collapsed.gif";
|
||||
window.ImgExpanded = "/static/images/expanded.gif";
|
||||
window.QuoteKeys = true;
|
||||
function $id(id) { return document.getElementById(id); }
|
||||
function IsArray(obj) {
|
||||
return obj &&
|
||||
typeof obj === 'object' &&
|
||||
typeof obj.length === 'number' &&
|
||||
!(obj.propertyIsEnumerable('length'));
|
||||
}
|
||||
|
||||
function Process() {
|
||||
SetTab();
|
||||
window.IsCollapsible = $id("CollapsibleView").checked;
|
||||
var json = $id("content").value;
|
||||
var html = "";
|
||||
try {
|
||||
$("#codeall").css("display", "none");
|
||||
$("#codeall2").css("display", "none");
|
||||
if (json == "") json = "\"\"";
|
||||
var obj = eval("[" + json + "]");
|
||||
html = ProcessObject(obj[0], 0, false, false, false);
|
||||
$id("Canvas").innerHTML = "<PRE class='CodeContainer'>" + html + "</PRE>";
|
||||
} catch (e) {
|
||||
$("#codeall").css("display", "block");
|
||||
$("#codeall2").css("display", "block");
|
||||
document.getElementById('errdiv').innerHTML = "输入的JSON数据格式不正确:" + e.message;
|
||||
$id("Canvas").innerHTML = "";
|
||||
}
|
||||
}
|
||||
window._dateObj = new Date();
|
||||
window._regexpObj = new RegExp();
|
||||
function ProcessObject(obj, indent, addComma, isArray, isPropertyContent) {
|
||||
var html = "";
|
||||
var comma = (addComma) ? "<span class='Comma'>,</span> " : "";
|
||||
var type = typeof obj;
|
||||
var clpsHtml = "";
|
||||
if (IsArray(obj)) {
|
||||
if (obj.length == 0) {
|
||||
html += GetRow(indent, "<span class='ArrayBrace'>[ ]</span>" + comma, isPropertyContent);
|
||||
} else {
|
||||
clpsHtml = window.IsCollapsible ? "<span><img src=\"" + window.ImgExpanded + "\" onClick=\"ExpImgClicked(this)\" /></span><span class='collapsible'>" : "";
|
||||
html += GetRow(indent, "<span class='ArrayBrace'>[</span>" + clpsHtml, isPropertyContent);
|
||||
for (var i = 0; i < obj.length; i++) {
|
||||
html += ProcessObject(obj[i], indent + 1, i < (obj.length - 1), true, false);
|
||||
}
|
||||
clpsHtml = window.IsCollapsible ? "</span>" : "";
|
||||
html += GetRow(indent, clpsHtml + "<span class='ArrayBrace'>]</span>" + comma);
|
||||
}
|
||||
} else if (type == 'object') {
|
||||
if (obj == null) {
|
||||
html += FormatLiteral("null", "", comma, indent, isArray, "Null");
|
||||
} else if (obj.constructor == window._dateObj.constructor) {
|
||||
html += FormatLiteral("new Date(" + obj.getTime() + ") /*" + obj.toLocaleString() + "*/", "", comma, indent, isArray, "Date");
|
||||
} else if (obj.constructor == window._regexpObj.constructor) {
|
||||
html += FormatLiteral("new RegExp(" + obj + ")", "", comma, indent, isArray, "RegExp");
|
||||
} else {
|
||||
var numProps = 0;
|
||||
for (var prop in obj) numProps++;
|
||||
if (numProps == 0) {
|
||||
html += GetRow(indent, "<span class='ObjectBrace'>{ }</span>" + comma, isPropertyContent);
|
||||
} else {
|
||||
clpsHtml = window.IsCollapsible ? "<span><img src=\"" + window.ImgExpanded + "\" onClick=\"ExpImgClicked(this)\" /></span><span class='collapsible'>" : "";
|
||||
html += GetRow(indent, "<span class='ObjectBrace'>{</span>" + clpsHtml, isPropertyContent);
|
||||
|
||||
var j = 0;
|
||||
|
||||
for (var prop in obj) {
|
||||
|
||||
var quote = window.QuoteKeys ? "\"" : "";
|
||||
|
||||
html += GetRow(indent + 1, "<span class='PropertyName'>" + quote + prop + quote + "</span>: " + ProcessObject(obj[prop], indent + 1, ++j < numProps, false, true));
|
||||
|
||||
}
|
||||
|
||||
clpsHtml = window.IsCollapsible ? "</span>" : "";
|
||||
|
||||
html += GetRow(indent, clpsHtml + "<span class='ObjectBrace'>}</span>" + comma);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else if (type == 'number') {
|
||||
|
||||
html += FormatLiteral(obj, "", comma, indent, isArray, "Number");
|
||||
|
||||
} else if (type == 'boolean') {
|
||||
|
||||
html += FormatLiteral(obj, "", comma, indent, isArray, "Boolean");
|
||||
|
||||
} else if (type == 'function') {
|
||||
|
||||
if (obj.constructor == window._regexpObj.constructor) {
|
||||
|
||||
html += FormatLiteral("new RegExp(" + obj + ")", "", comma, indent, isArray, "RegExp");
|
||||
|
||||
} else {
|
||||
|
||||
obj = FormatFunction(indent, obj);
|
||||
|
||||
html += FormatLiteral(obj, "", comma, indent, isArray, "Function");
|
||||
|
||||
}
|
||||
|
||||
} else if (type == 'undefined') {
|
||||
|
||||
html += FormatLiteral("undefined", "", comma, indent, isArray, "Null");
|
||||
|
||||
} else {
|
||||
|
||||
html += FormatLiteral(obj.toString().split("\\").join("\\\\").split('"').join('\\"'), "\"", comma, indent, isArray, "String");
|
||||
|
||||
}
|
||||
|
||||
return html;
|
||||
|
||||
}
|
||||
|
||||
function FormatLiteral(literal, quote, comma, indent, isArray, style) {
|
||||
|
||||
if (typeof literal == 'string')
|
||||
|
||||
literal = literal.split("<").join("<").split(">").join(">");
|
||||
|
||||
var str = "<span class='" + style + "'>" + quote + literal + quote + comma + "</span>";
|
||||
|
||||
if (isArray) str = GetRow(indent, str);
|
||||
|
||||
return str;
|
||||
|
||||
}
|
||||
|
||||
function FormatFunction(indent, obj) {
|
||||
|
||||
var tabs = "";
|
||||
|
||||
for (var i = 0; i < indent; i++) tabs += window.TAB;
|
||||
|
||||
var funcStrArray = obj.toString().split("\n");
|
||||
|
||||
var str = "";
|
||||
|
||||
for (var i = 0; i < funcStrArray.length; i++) {
|
||||
|
||||
str += ((i == 0) ? "" : tabs) + funcStrArray[i] + "\n";
|
||||
|
||||
}
|
||||
|
||||
return str;
|
||||
|
||||
}
|
||||
|
||||
function GetRow(indent, data, isPropertyContent) {
|
||||
|
||||
var tabs = "";
|
||||
|
||||
for (var i = 0; i < indent && !isPropertyContent; i++) tabs += window.TAB;
|
||||
|
||||
if (data != null && data.length > 0 && data.charAt(data.length - 1) != "\n")
|
||||
|
||||
data = data + "\n";
|
||||
|
||||
return tabs + data;
|
||||
|
||||
}
|
||||
|
||||
function CollapsibleViewClicked() {
|
||||
|
||||
$id("CollapsibleViewDetail").style.visibility = $id("CollapsibleView").checked ? "visible" : "hidden";
|
||||
|
||||
Process();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function QuoteKeysClicked() {
|
||||
|
||||
window.QuoteKeys = $id("QuoteKeys").checked;
|
||||
|
||||
Process();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function CollapseAllClicked() {
|
||||
|
||||
EnsureIsPopulated();
|
||||
|
||||
TraverseChildren($id("Canvas"), function (element) {
|
||||
|
||||
if (element.className == 'collapsible') {
|
||||
|
||||
MakeContentVisible(element, false);
|
||||
|
||||
}
|
||||
|
||||
}, 0);
|
||||
|
||||
}
|
||||
|
||||
function ExpandAllClicked() {
|
||||
|
||||
EnsureIsPopulated();
|
||||
|
||||
TraverseChildren($id("Canvas"), function (element) {
|
||||
|
||||
if (element.className == 'collapsible') {
|
||||
|
||||
MakeContentVisible(element, true);
|
||||
|
||||
}
|
||||
|
||||
}, 0);
|
||||
|
||||
}
|
||||
|
||||
function MakeContentVisible(element, visible) {
|
||||
|
||||
var img = element.previousSibling.firstChild;
|
||||
|
||||
if (!!img.tagName && img.tagName.toLowerCase() == "img") {
|
||||
|
||||
element.style.display = visible ? 'inline' : 'none';
|
||||
|
||||
element.previousSibling.firstChild.src = visible ? window.ImgExpanded : window.ImgCollapsed;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function TraverseChildren(element, func, depth) {
|
||||
|
||||
for (var i = 0; i < element.childNodes.length; i++) {
|
||||
|
||||
TraverseChildren(element.childNodes[i], func, depth + 1);
|
||||
|
||||
}
|
||||
|
||||
func(element, depth);
|
||||
|
||||
}
|
||||
|
||||
function ExpImgClicked(img) {
|
||||
|
||||
var container = img.parentNode.nextSibling;
|
||||
|
||||
if (!container) return;
|
||||
|
||||
var disp = "none";
|
||||
|
||||
var src = window.ImgCollapsed;
|
||||
|
||||
if (container.style.display == "none") {
|
||||
|
||||
disp = "inline";
|
||||
|
||||
src = window.ImgExpanded;
|
||||
|
||||
}
|
||||
|
||||
container.style.display = disp;
|
||||
|
||||
img.src = src;
|
||||
|
||||
}
|
||||
|
||||
function CollapseLevel(level) {
|
||||
|
||||
EnsureIsPopulated();
|
||||
|
||||
TraverseChildren($id("Canvas"), function (element, depth) {
|
||||
|
||||
if (element.className == 'collapsible') {
|
||||
|
||||
if (depth >= level) {
|
||||
|
||||
MakeContentVisible(element, false);
|
||||
|
||||
} else {
|
||||
|
||||
MakeContentVisible(element, true);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}, 0);
|
||||
|
||||
}
|
||||
|
||||
function TabSizeChanged() {
|
||||
|
||||
Process();
|
||||
|
||||
}
|
||||
|
||||
function SetTab() {
|
||||
|
||||
var select = $id("TabSize");
|
||||
|
||||
window.TAB = MultiplyString(parseInt(select.options[select.selectedIndex].value), window.SINGLE_TAB);
|
||||
|
||||
}
|
||||
|
||||
function EnsureIsPopulated() {
|
||||
|
||||
if (!$id("Canvas").innerHTML && !!$id("content").value) Process();
|
||||
|
||||
}
|
||||
|
||||
function MultiplyString(num, str) {
|
||||
|
||||
var sb = [];
|
||||
|
||||
for (var i = 0; i < num; i++) {
|
||||
|
||||
sb.push(str);
|
||||
|
||||
}
|
||||
|
||||
return sb.join("");
|
||||
|
||||
}
|
||||
|
||||
function SelectAllClicked() {
|
||||
|
||||
|
||||
|
||||
if (!!document.selection && !!document.selection.empty) {
|
||||
|
||||
document.selection.empty();
|
||||
|
||||
} else if (window.getSelection) {
|
||||
|
||||
var sel = window.getSelection();
|
||||
|
||||
if (sel.removeAllRanges) {
|
||||
|
||||
window.getSelection().removeAllRanges();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
var range =
|
||||
|
||||
(!!document.body && !!document.body.createTextRange)
|
||||
|
||||
? document.body.createTextRange()
|
||||
|
||||
: document.createRange();
|
||||
|
||||
|
||||
|
||||
if (!!range.selectNode)
|
||||
|
||||
range.selectNode($id("Canvas"));
|
||||
|
||||
else if (range.moveToElementText)
|
||||
|
||||
range.moveToElementText($id("Canvas"));
|
||||
|
||||
|
||||
|
||||
if (!!range.select)
|
||||
|
||||
range.select($id("Canvas"));
|
||||
|
||||
else
|
||||
|
||||
window.getSelection().addRange(range);
|
||||
|
||||
}
|
||||
|
||||
function LinkToJson() {
|
||||
|
||||
var val = $id("content").value;
|
||||
|
||||
val = escape(val.split('/n').join(' ').split('/r').join(' '));
|
||||
|
||||
$id("InvisibleLinkUrl").value = val;
|
||||
|
||||
$id("InvisibleLink").submit();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,206 @@
|
||||
/**
|
||||
* JSON to XML jQuery plugin. Provides quick way to convert JSON object to XML
|
||||
* string. To some extent, allows control over XML output.
|
||||
* Just as jQuery itself, this plugin is released under both MIT & GPL licences.
|
||||
*
|
||||
* @version 1.02
|
||||
* @author Micha Korecki, www.michalkorecki.com
|
||||
*/
|
||||
(function($) {
|
||||
/**
|
||||
* Converts JSON object to XML string.
|
||||
*
|
||||
* @param json object to convert
|
||||
* @param options additional parameters
|
||||
* @return XML string
|
||||
*/
|
||||
$.json2xml = function(json, options) {
|
||||
settings = {};
|
||||
settings = $.extend(true, settings, defaultSettings, options || { });
|
||||
return '<?xml version="1.0" encoding="UTF-8"?>'+convertToXml(json, settings.rootTagName, '', 0);
|
||||
};
|
||||
|
||||
var defaultSettings = {
|
||||
formatOutput: true,
|
||||
formatTextNodes: false,
|
||||
indentString: ' ',
|
||||
rootTagName: 'root',
|
||||
ignore: [],
|
||||
replace: [],
|
||||
nodes: [],
|
||||
///TODO: exceptions system
|
||||
exceptions: []
|
||||
};
|
||||
|
||||
/**
|
||||
* This is actual settings object used throught plugin, default settings
|
||||
* are stored separately to prevent overriding when using multiple times.
|
||||
*/
|
||||
var settings = {};
|
||||
|
||||
/**
|
||||
* Core function parsing JSON to XML. It iterates over object properties and
|
||||
* creates XML attributes appended to main tag, if property is primitive
|
||||
* value (eg. string, number).
|
||||
* Otherwise, if it's array or object, new node is created and appened to
|
||||
* parent tag.
|
||||
* You can alter this behaviour by providing values in settings.ignore,
|
||||
* settings.replace and settings.nodes arrays.
|
||||
*
|
||||
* @param json object to parse
|
||||
* @param tagName name of tag created for parsed object
|
||||
* @param parentPath path to properly identify elements in ignore, replace
|
||||
* and nodes arrays
|
||||
* @param depth current element's depth
|
||||
* @return XML string
|
||||
*/
|
||||
var convertToXml = function(json, tagName, parentPath, depth) {
|
||||
var suffix = (settings.formatOutput) ? '\r\n' : '';
|
||||
var indent = (settings.formatOutput) ? getIndent(depth) : '';
|
||||
var xmlTag = indent + '<' + tagName;
|
||||
var children = '';
|
||||
|
||||
for (var key in json) {
|
||||
if (json.hasOwnProperty(key)) {
|
||||
var propertyPath = parentPath + key;
|
||||
var propertyName = getPropertyName(parentPath, key);
|
||||
// element not in ignore array, process
|
||||
if ($.inArray(propertyPath, settings.ignore) == -1) {
|
||||
// array, create new child element
|
||||
if ($.isArray(json[key])) {
|
||||
children += createNodeFromArray(json[key], propertyName,
|
||||
propertyPath + '.', depth + 1, suffix);
|
||||
}
|
||||
// object, new child element aswell
|
||||
else if (typeof(json[key]) === 'object') {
|
||||
children += convertToXml(json[key], propertyName,
|
||||
propertyPath + '.', depth + 1);
|
||||
}
|
||||
// primitive value property as attribute
|
||||
else {
|
||||
// unless it's explicitly defined it should be node
|
||||
if ( propertyName.indexOf('@')==-1) {
|
||||
children += createTextNode(propertyName, json[key],
|
||||
depth, suffix);
|
||||
}
|
||||
else {
|
||||
propertyName = propertyName.replace('@','');
|
||||
xmlTag += ' ' + propertyName + '="' + json[key] + '"';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// close tag properly
|
||||
if (children !== '') {
|
||||
xmlTag += '>' + suffix + children + indent + '</' + tagName + '>' + suffix;
|
||||
}
|
||||
else {
|
||||
xmlTag += '/>' + suffix;
|
||||
}
|
||||
return xmlTag;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Creates indent string for provided depth value. See settings for details.
|
||||
*
|
||||
* @param depth
|
||||
* @return indent string
|
||||
*/
|
||||
var getIndent = function(depth) {
|
||||
var output = '';
|
||||
for (var i = 0; i < depth; i++) {
|
||||
output += settings.indentString;
|
||||
}
|
||||
return output;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Checks settings.replace array for provided name, if it exists returns
|
||||
* replacement name. Else, original name is returned.
|
||||
*
|
||||
* @param parentPath path to this element's parent
|
||||
* @param name name of element to look up
|
||||
* @return element's final name
|
||||
*/
|
||||
var getPropertyName = function(parentPath, name) {
|
||||
var index = settings.replace.length;
|
||||
var searchName = parentPath + name;
|
||||
while (index--) {
|
||||
// settings.replace array consists of {original : replacement}
|
||||
// objects
|
||||
if (settings.replace[index].hasOwnProperty(searchName)) {
|
||||
return settings.replace[index][searchName];
|
||||
}
|
||||
}
|
||||
return name;
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates XML node from javascript array object.
|
||||
*
|
||||
* @param source
|
||||
* @param name XML element name
|
||||
* @param path parent element path string
|
||||
* @param depth
|
||||
* @param suffix node suffix (whether to format output or not)
|
||||
* @return XML tag string for provided array
|
||||
*/
|
||||
var createNodeFromArray = function(source, name, path, depth, suffix) {
|
||||
var xmlNode = '';
|
||||
if (source.length > 0) {
|
||||
for (var index in source) {
|
||||
// array's element isn't object - it's primitive value, which
|
||||
// means array might need to be converted to text nodes
|
||||
if (typeof(source[index]) !== 'object') {
|
||||
// empty strings will be converted to empty nodes
|
||||
if (source[index] === "") {
|
||||
xmlNode += getIndent(depth) + '<' + name + '/>' + suffix;
|
||||
}
|
||||
else {
|
||||
var textPrefix = (settings.formatTextNodes)
|
||||
? suffix + getIndent(depth + 1) : '';
|
||||
var textSuffix = (settings.formatTextNodes)
|
||||
? suffix + getIndent(depth) : '';
|
||||
xmlNode += getIndent(depth) + '<' + name + '>'
|
||||
+ textPrefix + source[index] + textSuffix
|
||||
+ '</' + name + '>' + suffix;
|
||||
}
|
||||
}
|
||||
// else regular conversion applies
|
||||
else {
|
||||
xmlNode += convertToXml(source[index], name, path, depth);
|
||||
}
|
||||
}
|
||||
}
|
||||
// array is empty, also creating empty XML node
|
||||
else {
|
||||
xmlNode += getIndent(depth) + '<' + name + '/>' + suffix;
|
||||
}
|
||||
return xmlNode;
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates node containing text only.
|
||||
*
|
||||
* @param name node's name
|
||||
* @param text node text string
|
||||
* @param parentDepth this node's parent element depth
|
||||
* @param suffix node suffix (whether to format output or not)
|
||||
* @return XML tag string
|
||||
*/
|
||||
var createTextNode = function(name, text, parentDepth, suffix) {
|
||||
// unformatted text node: <node>value</node>
|
||||
// formatting includes value indentation and new lines
|
||||
var textPrefix = (settings.formatTextNodes)
|
||||
? suffix + getIndent(parentDepth + 2) : '';
|
||||
var textSuffix = (settings.formatTextNodes)
|
||||
? suffix + getIndent(parentDepth + 1) : '';
|
||||
var xmlNode = getIndent(parentDepth + 1) + '<' + name + '>'
|
||||
+ textPrefix + text + textSuffix
|
||||
+ '</' + name + '>' + suffix;
|
||||
return xmlNode;
|
||||
};
|
||||
})(jQuery);
|
||||
@@ -0,0 +1,193 @@
|
||||
/*
|
||||
### jQuery XML to JSON Plugin v1.3 - 2013-02-18 ###
|
||||
* http://www.fyneworks.com/ - diego@fyneworks.com
|
||||
* Licensed under http://en.wikipedia.org/wiki/MIT_License
|
||||
###
|
||||
Website: http://www.fyneworks.com/jquery/xml-to-json/
|
||||
*//*
|
||||
# INSPIRED BY: http://www.terracoder.com/
|
||||
AND: http://www.thomasfrank.se/xml_to_json.html
|
||||
AND: http://www.kawa.net/works/js/xml/objtree-e.html
|
||||
*//*
|
||||
This simple script converts XML (document of code) into a JSON object. It is the combination of 2
|
||||
'xml to json' great parsers (see below) which allows for both 'simple' and 'extended' parsing modes.
|
||||
*/
|
||||
// Avoid collisions
|
||||
;if(window.jQuery) (function($){
|
||||
|
||||
// Add function to jQuery namespace
|
||||
$.extend({
|
||||
|
||||
// converts xml documents and xml text to json object
|
||||
xml2json: function(xml, extended) {
|
||||
if(!xml) return {}; // quick fail
|
||||
|
||||
//### PARSER LIBRARY
|
||||
// Core function
|
||||
function parseXML(node, simple){
|
||||
if(!node) return null;
|
||||
var txt = '', obj = null, att = null;
|
||||
var nt = node.nodeType, nn = jsVar(node.localName || node.nodeName);
|
||||
var nv = node.text || node.nodeValue || '';
|
||||
/*DBG*/ //if(window.console) console.log(['x2j',nn,nt,nv.length+' bytes']);
|
||||
if(node.childNodes){
|
||||
if(node.childNodes.length>0){
|
||||
/*DBG*/ //if(window.console) console.log(['x2j',nn,'CHILDREN',node.childNodes]);
|
||||
$.each(node.childNodes, function(n,cn){
|
||||
var cnt = cn.nodeType, cnn = jsVar(cn.localName || cn.nodeName);
|
||||
var cnv = cn.text || cn.nodeValue || '';
|
||||
/*DBG*/ //if(window.console) console.log(['x2j',nn,'node>a',cnn,cnt,cnv]);
|
||||
if(cnt == 8){
|
||||
/*DBG*/ //if(window.console) console.log(['x2j',nn,'node>b',cnn,'COMMENT (ignore)']);
|
||||
return; // ignore comment node
|
||||
}
|
||||
else if(cnt == 3 || cnt == 4 || !cnn){
|
||||
// ignore white-space in between tags
|
||||
if(cnv.match(/^\s+$/)){
|
||||
/*DBG*/ //if(window.console) console.log(['x2j',nn,'node>c',cnn,'WHITE-SPACE (ignore)']);
|
||||
return;
|
||||
};
|
||||
/*DBG*/ //if(window.console) console.log(['x2j',nn,'node>d',cnn,'TEXT']);
|
||||
txt += cnv.replace(/^\s+/,'').replace(/\s+$/,'');
|
||||
// make sure we ditch trailing spaces from markup
|
||||
}
|
||||
else{
|
||||
/*DBG*/ //if(window.console) console.log(['x2j',nn,'node>e',cnn,'OBJECT']);
|
||||
obj = obj || {};
|
||||
if(obj[cnn]){
|
||||
/*DBG*/ //if(window.console) console.log(['x2j',nn,'node>f',cnn,'ARRAY']);
|
||||
|
||||
// http://forum.jquery.com/topic/jquery-jquery-xml2json-problems-when-siblings-of-the-same-tagname-only-have-a-textnode-as-a-child
|
||||
if(!obj[cnn].length) obj[cnn] = myArr(obj[cnn]);
|
||||
obj[cnn] = myArr(obj[cnn]);
|
||||
|
||||
obj[cnn][ obj[cnn].length ] = parseXML(cn, true/* simple */);
|
||||
obj[cnn].length = obj[cnn].length;
|
||||
}
|
||||
else{
|
||||
/*DBG*/ //if(window.console) console.log(['x2j',nn,'node>g',cnn,'dig deeper...']);
|
||||
obj[cnn] = parseXML(cn);
|
||||
};
|
||||
};
|
||||
});
|
||||
};//node.childNodes.length>0
|
||||
};//node.childNodes
|
||||
if(node.attributes){
|
||||
if(node.attributes.length>0){
|
||||
/*DBG*/ //if(window.console) console.log(['x2j',nn,'ATTRIBUTES',node.attributes])
|
||||
att = {}; obj = obj || {};
|
||||
$.each(node.attributes, function(a,at){
|
||||
var atn = jsVar('@'+at.name), atv = at.value;
|
||||
att[atn] = atv;
|
||||
if(obj[atn]){
|
||||
/*DBG*/ //if(window.console) console.log(['x2j',nn,'attr>',atn,'ARRAY']);
|
||||
|
||||
// http://forum.jquery.com/topic/jquery-jquery-xml2json-problems-when-siblings-of-the-same-tagname-only-have-a-textnode-as-a-child
|
||||
//if(!obj[atn].length) obj[atn] = myArr(obj[atn]);//[ obj[ atn ] ];
|
||||
obj[cnn] = myArr(obj[cnn]);
|
||||
|
||||
obj[atn][ obj[atn].length ] = atv;
|
||||
obj[atn].length = obj[atn].length;
|
||||
}
|
||||
else{
|
||||
/*DBG*/ //if(window.console) console.log(['x2j',nn,'attr>',atn,'TEXT']);
|
||||
obj[atn] = atv;
|
||||
};
|
||||
});
|
||||
//obj['attributes'] = att;
|
||||
};//node.attributes.length>0
|
||||
};//node.attributes
|
||||
if(obj){
|
||||
obj = $.extend( (txt!='' ? new String(txt) : {}),/* {text:txt},*/ obj || {}/*, att || {}*/);
|
||||
//txt = (obj.text) ? (typeof(obj.text)=='object' ? obj.text : [obj.text || '']).concat([txt]) : txt;
|
||||
txt = (obj.text) ? ([obj.text || '']).concat([txt]) : txt;
|
||||
if(txt) obj.text = txt;
|
||||
txt = '';
|
||||
};
|
||||
var out = obj || txt;
|
||||
//console.log([extended, simple, out]);
|
||||
if(extended){
|
||||
if(txt) out = {};//new String(out);
|
||||
txt = out.text || txt || '';
|
||||
if(txt) out.text = txt;
|
||||
if(!simple) out = myArr(out);
|
||||
};
|
||||
return out;
|
||||
};// parseXML
|
||||
// Core Function End
|
||||
// Utility functions
|
||||
var jsVar = function(s){ return String(s || '').replace(/-/g,"_"); };
|
||||
|
||||
// NEW isNum function: 01/09/2010
|
||||
// Thanks to Emile Grau, GigaTecnologies S.L., www.gigatransfer.com, www.mygigamail.com
|
||||
function isNum(s){
|
||||
// based on utility function isNum from xml2json plugin (http://www.fyneworks.com/ - diego@fyneworks.com)
|
||||
// few bugs corrected from original function :
|
||||
// - syntax error : regexp.test(string) instead of string.test(reg)
|
||||
// - regexp modified to accept comma as decimal mark (latin syntax : 25,24 )
|
||||
// - regexp modified to reject if no number before decimal mark : ".7" is not accepted
|
||||
// - string is "trimmed", allowing to accept space at the beginning and end of string
|
||||
var regexp=/^((-)?([0-9]+)(([\.\,]{0,1})([0-9]+))?$)/
|
||||
return (typeof s == "number") || regexp.test(String((s && typeof s == "string") ? jQuery.trim(s) : ''));
|
||||
};
|
||||
// OLD isNum function: (for reference only)
|
||||
//var isNum = function(s){ return (typeof s == "number") || String((s && typeof s == "string") ? s : '').test(/^((-)?([0-9]*)((\.{0,1})([0-9]+))?$)/); };
|
||||
|
||||
var myArr = function(o){
|
||||
|
||||
// http://forum.jquery.com/topic/jquery-jquery-xml2json-problems-when-siblings-of-the-same-tagname-only-have-a-textnode-as-a-child
|
||||
//if(!o.length) o = [ o ]; o.length=o.length;
|
||||
if(!$.isArray(o)) o = [ o ]; o.length=o.length;
|
||||
|
||||
// here is where you can attach additional functionality, such as searching and sorting...
|
||||
return o;
|
||||
};
|
||||
// Utility functions End
|
||||
//### PARSER LIBRARY END
|
||||
|
||||
// Convert plain text to xml
|
||||
if(typeof xml=='string') xml = $.text2xml(xml);
|
||||
|
||||
// Quick fail if not xml (or if this is a node)
|
||||
if(!xml.nodeType) return;
|
||||
if(xml.nodeType == 3 || xml.nodeType == 4) return xml.nodeValue;
|
||||
|
||||
// Find xml root node
|
||||
var root = (xml.nodeType == 9) ? xml.documentElement : xml;
|
||||
|
||||
// Convert xml to json
|
||||
var out = parseXML(root, true /* simple */);
|
||||
|
||||
// Clean-up memory
|
||||
xml = null; root = null;
|
||||
|
||||
// Send output
|
||||
return out;
|
||||
},
|
||||
|
||||
// Convert text to XML DOM
|
||||
text2xml: function(str) {
|
||||
// NOTE: I'd like to use jQuery for this, but jQuery makes all tags uppercase
|
||||
//return $(xml)[0];
|
||||
|
||||
/* prior to jquery 1.9 */
|
||||
/*
|
||||
var out;
|
||||
try{
|
||||
var xml = ((!$.support.opacity && !$.support.style))?new ActiveXObject("Microsoft.XMLDOM"):new DOMParser();
|
||||
xml.async = false;
|
||||
}catch(e){ throw new Error("XML Parser could not be instantiated") };
|
||||
try{
|
||||
if((!$.support.opacity && !$.support.style)) out = (xml.loadXML(str))?xml:false;
|
||||
else out = xml.parseFromString(str, "text/xml");
|
||||
}catch(e){ throw new Error("Error parsing XML string") };
|
||||
return out;
|
||||
*/
|
||||
|
||||
/* jquery 1.9+ */
|
||||
return $.parseXML(str);
|
||||
}
|
||||
|
||||
}); // extend $
|
||||
|
||||
})(jQuery);
|
||||
@@ -0,0 +1,334 @@
|
||||
|
||||
/*jslint evil: true, strict: false */
|
||||
|
||||
/*members "", "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply,
|
||||
call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,
|
||||
getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join,
|
||||
lastIndex, length, parse, prototype, push, replace, slice, stringify,
|
||||
test, toJSON, toString, valueOf
|
||||
*/
|
||||
|
||||
|
||||
// Create a JSON object only if one does not already exist. We create the
|
||||
// methods in a closure to avoid creating global variables.
|
||||
|
||||
if (!this.JSON) {
|
||||
this.JSON = {};
|
||||
}
|
||||
|
||||
(function () {
|
||||
|
||||
function f(n) {
|
||||
// Format integers to have at least two digits.
|
||||
return n < 10 ? '0' + n : n;
|
||||
}
|
||||
|
||||
if (typeof Date.prototype.toJSON !== 'function') {
|
||||
|
||||
Date.prototype.toJSON = function (key) {
|
||||
|
||||
return isFinite(this.valueOf()) ?
|
||||
this.getUTCFullYear() + '-' +
|
||||
f(this.getUTCMonth() + 1) + '-' +
|
||||
f(this.getUTCDate()) + 'T' +
|
||||
f(this.getUTCHours()) + ':' +
|
||||
f(this.getUTCMinutes()) + ':' +
|
||||
f(this.getUTCSeconds()) + 'Z' : null;
|
||||
};
|
||||
|
||||
String.prototype.toJSON =
|
||||
Number.prototype.toJSON =
|
||||
Boolean.prototype.toJSON = function (key) {
|
||||
return this.valueOf();
|
||||
};
|
||||
}
|
||||
|
||||
var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
|
||||
escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
|
||||
gap,
|
||||
indent,
|
||||
meta = { // table of character substitutions
|
||||
'\b': '\\b',
|
||||
'\t': '\\t',
|
||||
'\n': '\\n',
|
||||
'\f': '\\f',
|
||||
'\r': '\\r',
|
||||
'"' : '\\"',
|
||||
'\\': '\\\\'
|
||||
},
|
||||
rep;
|
||||
|
||||
|
||||
function quote(string) {
|
||||
|
||||
// If the string contains no control characters, no quote characters, and no
|
||||
// backslash characters, then we can safely slap some quotes around it.
|
||||
// Otherwise we must also replace the offending characters with safe escape
|
||||
// sequences.
|
||||
|
||||
escapable.lastIndex = 0;
|
||||
return escapable.test(string) ?
|
||||
'"' + string.replace(escapable, function (a) {
|
||||
var c = meta[a];
|
||||
return typeof c === 'string' ? c :
|
||||
'\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
|
||||
}) + '"' :
|
||||
'"' + string + '"';
|
||||
}
|
||||
|
||||
|
||||
function str(key, holder) {
|
||||
|
||||
// Produce a string from holder[key].
|
||||
|
||||
var i, // The loop counter.
|
||||
k, // The member key.
|
||||
v, // The member value.
|
||||
length,
|
||||
mind = gap,
|
||||
partial,
|
||||
value = holder[key];
|
||||
|
||||
// If the value has a toJSON method, call it to obtain a replacement value.
|
||||
|
||||
if (value && typeof value === 'object' &&
|
||||
typeof value.toJSON === 'function') {
|
||||
value = value.toJSON(key);
|
||||
}
|
||||
|
||||
// If we were called with a replacer function, then call the replacer to
|
||||
// obtain a replacement value.
|
||||
|
||||
if (typeof rep === 'function') {
|
||||
value = rep.call(holder, key, value);
|
||||
}
|
||||
|
||||
// What happens next depends on the value's type.
|
||||
|
||||
switch (typeof value) {
|
||||
case 'string':
|
||||
return quote(value);
|
||||
|
||||
case 'number':
|
||||
|
||||
// JSON numbers must be finite. Encode non-finite numbers as null.
|
||||
|
||||
return isFinite(value) ? String(value) : 'null';
|
||||
|
||||
case 'boolean':
|
||||
case 'null':
|
||||
|
||||
// If the value is a boolean or null, convert it to a string. Note:
|
||||
// typeof null does not produce 'null'. The case is included here in
|
||||
// the remote chance that this gets fixed someday.
|
||||
|
||||
return String(value);
|
||||
|
||||
// If the type is 'object', we might be dealing with an object or an array or
|
||||
// null.
|
||||
|
||||
case 'object':
|
||||
|
||||
// Due to a specification blunder in ECMAScript, typeof null is 'object',
|
||||
// so watch out for that case.
|
||||
|
||||
if (!value) {
|
||||
return 'null';
|
||||
}
|
||||
|
||||
// Make an array to hold the partial results of stringifying this object value.
|
||||
|
||||
gap += indent;
|
||||
partial = [];
|
||||
|
||||
// Is the value an array?
|
||||
|
||||
if (Object.prototype.toString.apply(value) === '[object Array]') {
|
||||
|
||||
// The value is an array. Stringify every element. Use null as a placeholder
|
||||
// for non-JSON values.
|
||||
|
||||
length = value.length;
|
||||
for (i = 0; i < length; i += 1) {
|
||||
partial[i] = str(i, value) || 'null';
|
||||
}
|
||||
|
||||
// Join all of the elements together, separated with commas, and wrap them in
|
||||
// brackets.
|
||||
|
||||
v = partial.length === 0 ? '[]' :
|
||||
gap ? '[\n' + gap +
|
||||
partial.join(',\n' + gap) + '\n' +
|
||||
mind + ']' :
|
||||
'[' + partial.join(',') + ']';
|
||||
gap = mind;
|
||||
return v;
|
||||
}
|
||||
|
||||
// If the replacer is an array, use it to select the members to be stringified.
|
||||
|
||||
if (rep && typeof rep === 'object') {
|
||||
length = rep.length;
|
||||
for (i = 0; i < length; i += 1) {
|
||||
k = rep[i];
|
||||
if (typeof k === 'string') {
|
||||
v = str(k, value);
|
||||
if (v) {
|
||||
partial.push(quote(k) + (gap ? ': ' : ':') + v);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
// Otherwise, iterate through all of the keys in the object.
|
||||
|
||||
for (k in value) {
|
||||
if (Object.hasOwnProperty.call(value, k)) {
|
||||
v = str(k, value);
|
||||
if (v) {
|
||||
partial.push(quote(k) + (gap ? ': ' : ':') + v);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Join all of the member texts together, separated with commas,
|
||||
// and wrap them in braces.
|
||||
|
||||
v = partial.length === 0 ? '{}' :
|
||||
gap ? '{\n' + gap + partial.join(',\n' + gap) + '\n' +
|
||||
mind + '}' : '{' + partial.join(',') + '}';
|
||||
gap = mind;
|
||||
return v;
|
||||
}
|
||||
}
|
||||
|
||||
// If the JSON object does not yet have a stringify method, give it one.
|
||||
|
||||
if (typeof JSON.stringify !== 'function') {
|
||||
JSON.stringify = function (value, replacer, space) {
|
||||
|
||||
// The stringify method takes a value and an optional replacer, and an optional
|
||||
// space parameter, and returns a JSON text. The replacer can be a function
|
||||
// that can replace values, or an array of strings that will select the keys.
|
||||
// A default replacer method can be provided. Use of the space parameter can
|
||||
// produce text that is more easily readable.
|
||||
|
||||
var i;
|
||||
gap = '';
|
||||
indent = '';
|
||||
|
||||
// If the space parameter is a number, make an indent string containing that
|
||||
// many spaces.
|
||||
|
||||
if (typeof space === 'number') {
|
||||
for (i = 0; i < space; i += 1) {
|
||||
indent += ' ';
|
||||
}
|
||||
|
||||
// If the space parameter is a string, it will be used as the indent string.
|
||||
|
||||
} else if (typeof space === 'string') {
|
||||
indent = space;
|
||||
}
|
||||
|
||||
// If there is a replacer, it must be a function or an array.
|
||||
// Otherwise, throw an error.
|
||||
|
||||
rep = replacer;
|
||||
if (replacer && typeof replacer !== 'function' &&
|
||||
(typeof replacer !== 'object' ||
|
||||
typeof replacer.length !== 'number')) {
|
||||
throw new Error('JSON.stringify');
|
||||
}
|
||||
|
||||
// Make a fake root object containing our value under the key of ''.
|
||||
// Return the result of stringifying the value.
|
||||
|
||||
return str('', {'': value});
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
// If the JSON object does not yet have a parse method, give it one.
|
||||
|
||||
if (typeof JSON.parse !== 'function') {
|
||||
JSON.parse = function (text, reviver) {
|
||||
|
||||
// The parse method takes a text and an optional reviver function, and returns
|
||||
// a JavaScript value if the text is a valid JSON text.
|
||||
|
||||
var j;
|
||||
|
||||
function walk(holder, key) {
|
||||
|
||||
// The walk method is used to recursively walk the resulting structure so
|
||||
// that modifications can be made.
|
||||
|
||||
var k, v, value = holder[key];
|
||||
if (value && typeof value === 'object') {
|
||||
for (k in value) {
|
||||
if (Object.hasOwnProperty.call(value, k)) {
|
||||
v = walk(value, k);
|
||||
if (v !== undefined) {
|
||||
value[k] = v;
|
||||
} else {
|
||||
delete value[k];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return reviver.call(holder, key, value);
|
||||
}
|
||||
|
||||
|
||||
// Parsing happens in four stages. In the first stage, we replace certain
|
||||
// Unicode characters with escape sequences. JavaScript handles many characters
|
||||
// incorrectly, either silently deleting them, or treating them as line endings.
|
||||
|
||||
cx.lastIndex = 0;
|
||||
if (cx.test(text)) {
|
||||
text = text.replace(cx, function (a) {
|
||||
return '\\u' +
|
||||
('0000' + a.charCodeAt(0).toString(16)).slice(-4);
|
||||
});
|
||||
}
|
||||
|
||||
// In the second stage, we run the text against regular expressions that look
|
||||
// for non-JSON patterns. We are especially concerned with '()' and 'new'
|
||||
// because they can cause invocation, and '=' because it can cause mutation.
|
||||
// But just to be safe, we want to reject all unexpected forms.
|
||||
|
||||
// We split the second stage into 4 regexp operations in order to work around
|
||||
// crippling inefficiencies in IE's and Safari's regexp engines. First we
|
||||
// replace the JSON backslash pairs with '@' (a non-JSON character). Second, we
|
||||
// replace all simple value tokens with ']' characters. Third, we delete all
|
||||
// open brackets that follow a colon or comma or that begin the text. Finally,
|
||||
// we look to see that the remaining characters are only whitespace or ']' or
|
||||
// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.
|
||||
|
||||
if (/^[\],:{}\s]*$/.
|
||||
test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@').
|
||||
replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']').
|
||||
replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
|
||||
|
||||
// In the third stage we use the eval function to compile the text into a
|
||||
// JavaScript structure. The '{' operator is subject to a syntactic ambiguity
|
||||
// in JavaScript: it can begin a block or an object literal. We wrap the text
|
||||
// in parens to eliminate the ambiguity.
|
||||
|
||||
j = eval('(' + text + ')');
|
||||
|
||||
// In the optional fourth stage, we recursively walk the new structure, passing
|
||||
// each name/value pair to a reviver function for possible transformation.
|
||||
|
||||
return typeof reviver === 'function' ?
|
||||
walk({'': j}, '') : j;
|
||||
}
|
||||
|
||||
// If the text is not JSON parseable, then a SyntaxError is thrown.
|
||||
|
||||
throw new SyntaxError('JSON.parse');
|
||||
};
|
||||
}
|
||||
}());
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,139 @@
|
||||
var Fjson = (function () {
|
||||
var _toString = Object.prototype.toString;
|
||||
|
||||
function format(object, indent_count) {
|
||||
var html_fragment = '';
|
||||
switch (_typeof(object)) {
|
||||
case 'Null': 0
|
||||
html_fragment = _format_null(object);
|
||||
break;
|
||||
case 'Boolean':
|
||||
html_fragment = _format_boolean(object);
|
||||
break;
|
||||
case 'Number':
|
||||
html_fragment = _format_number(object);
|
||||
break;
|
||||
case 'String':
|
||||
html_fragment = _format_string(object);
|
||||
break;
|
||||
case 'Array':
|
||||
html_fragment = _format_array(object, indent_count);
|
||||
break;
|
||||
case 'Object':
|
||||
html_fragment = _format_object(object, indent_count);
|
||||
break;
|
||||
}
|
||||
return html_fragment;
|
||||
};
|
||||
|
||||
function _format_null(object) {
|
||||
return '<span class="json_null">null</span>';
|
||||
}
|
||||
|
||||
function _format_boolean(object) {
|
||||
return '<span class="json_boolean">' + object + '</span>';
|
||||
}
|
||||
|
||||
function _format_number(object) {
|
||||
return '<span class="json_number">' + object + '</span>';
|
||||
}
|
||||
|
||||
function _format_string(object) {
|
||||
object = object.replace(/\</g, "<");
|
||||
object = object.replace(/\>/g, ">");
|
||||
if (0 <= object.search(/^http/)) {
|
||||
object = '<a href="' + object + '" target="_blank" class="json_link">' + object + '</a>'
|
||||
}
|
||||
return '<span class="json_string">"' + object + '"</span>';
|
||||
}
|
||||
|
||||
function _format_array(object, indent_count) {
|
||||
var tmp_array = [];
|
||||
for (var i = 0, size = object.length; i < size; ++i) {
|
||||
tmp_array.push(indent_tab(indent_count) + format(object[i], indent_count + 1));
|
||||
}
|
||||
return '<span data-type="array" data-size="' + tmp_array.length + '"><i style="cursor:pointer;" class="fa fa-minus-square-o" onclick="hide(this)"></i>[<br/>'
|
||||
+ tmp_array.join(',<br/>')
|
||||
+ '<br/>' + indent_tab(indent_count - 1) + ']</span>';
|
||||
}
|
||||
|
||||
function _format_object(object, indent_count) {
|
||||
var tmp_array = [];
|
||||
for (var key in object) {
|
||||
tmp_array.push(indent_tab(indent_count) + '<span class="json_key">"' + key + '"</span>:' + format(object[key], indent_count + 1));
|
||||
}
|
||||
return '<span data-type="object"><i style="cursor:pointer;" class="fa fa-minus-square-o" onclick="hide(this)"></i>{<br/>'
|
||||
+ tmp_array.join(',<br/>')
|
||||
+ '<br/>' + indent_tab(indent_count - 1) + '}</span>';
|
||||
}
|
||||
|
||||
function indent_tab(indent_count) {
|
||||
return (new Array(indent_count + 1)).join(' ');
|
||||
}
|
||||
|
||||
function _typeof(object) {
|
||||
var tf = typeof object,
|
||||
ts = _toString.call(object);
|
||||
return null === object ? 'Null' :
|
||||
'undefined' == tf ? 'Undefined' :
|
||||
'boolean' == tf ? 'Boolean' :
|
||||
'number' == tf ? 'Number' :
|
||||
'string' == tf ? 'String' :
|
||||
'[object Function]' == ts ? 'Function' :
|
||||
'[object Array]' == ts ? 'Array' :
|
||||
'[object Date]' == ts ? 'Date' : 'Object';
|
||||
};
|
||||
|
||||
function loadCssString() {
|
||||
var style = document.createElement('style');
|
||||
style.type = 'text/css';
|
||||
var code = Array.prototype.slice.apply(arguments).join('');
|
||||
try {
|
||||
style.appendChild(document.createTextNode(code));
|
||||
} catch (ex) {
|
||||
style.styleSheet.cssText = code;
|
||||
}
|
||||
document.getElementsByTagName('head')[0].appendChild(style);
|
||||
}
|
||||
|
||||
loadCssString(
|
||||
'.json_key{ color: #92278f;font-weight:bold;}',
|
||||
'.json_null{color: #f1592a;font-weight:bold;}',
|
||||
'.json_string{ color: #3ab54a;font-weight:bold;}',
|
||||
'.json_number{ color: #25aae2;font-weight:bold;}',
|
||||
'.json_link{ color: #717171;font-weight:bold;}',
|
||||
'.json_array_brackets{}');
|
||||
|
||||
var _Fjson = function (origin_data) {
|
||||
//this.data = origin_data ? origin_data :
|
||||
//JSON && JSON.parse ? JSON.parse(origin_data) : eval('(' + origin_data + ')');
|
||||
this.data = JSON.parse(origin_data);
|
||||
};
|
||||
|
||||
_Fjson.prototype = {
|
||||
constructor: Fjson,
|
||||
toString: function () {
|
||||
return format(this.data, 1);
|
||||
}
|
||||
}
|
||||
|
||||
return _Fjson;
|
||||
|
||||
})();
|
||||
var last_html = '';
|
||||
function hide(obj) {
|
||||
var data_type = obj.parentNode.getAttribute('data-type');
|
||||
var data_size = obj.parentNode.getAttribute('data-size');
|
||||
obj.parentNode.setAttribute('data-inner', obj.parentNode.innerHTML);
|
||||
if (data_type === 'array') {
|
||||
obj.parentNode.innerHTML = '<i style="cursor:pointer;" class="fa fa-plus-square-o" onclick="show(this)"></i>Array[<span class="json_number">' + data_size + '</span>]';
|
||||
} else {
|
||||
obj.parentNode.innerHTML = '<i style="cursor:pointer;" class="fa fa-plus-square-o" onclick="show(this)"></i>Object{...}';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function show(obj) {
|
||||
var innerHtml = obj.parentNode.getAttribute('data-inner');
|
||||
obj.parentNode.innerHTML = innerHtml;
|
||||
}
|
||||
@@ -0,0 +1,524 @@
|
||||
var jsonlint = function() {
|
||||
var a = !0,
|
||||
b = !1,
|
||||
c = {},
|
||||
d = function() {
|
||||
var a = {
|
||||
trace: function() {},
|
||||
yy: {},
|
||||
symbols_: {
|
||||
error: 2,
|
||||
JSONString: 3,
|
||||
STRING: 4,
|
||||
JSONNumber: 5,
|
||||
NUMBER: 6,
|
||||
JSONNullLiteral: 7,
|
||||
NULL: 8,
|
||||
JSONBooleanLiteral: 9,
|
||||
TRUE: 10,
|
||||
FALSE: 11,
|
||||
JSONText: 12,
|
||||
JSONValue: 13,
|
||||
EOF: 14,
|
||||
JSONObject: 15,
|
||||
JSONArray: 16,
|
||||
"{": 17,
|
||||
"}": 18,
|
||||
JSONMemberList: 19,
|
||||
JSONMember: 20,
|
||||
":": 21,
|
||||
",": 22,
|
||||
"[": 23,
|
||||
"]": 24,
|
||||
JSONElementList: 25,
|
||||
$accept: 0,
|
||||
$end: 1
|
||||
},
|
||||
terminals_: {
|
||||
2: "error",
|
||||
4: "<code>STRING</code>",
|
||||
6: "<code>NUMBER</code>",
|
||||
8: "<code>NULL</code>",
|
||||
10: "<code>TRUE</code>",
|
||||
11: "<code>FALSE</code>",
|
||||
14: "<code>EOF</code>",
|
||||
17: "<code>{</code>",
|
||||
18: "<code>}</code>",
|
||||
21: "<code>:</code>",
|
||||
22: "<code>,</code>",
|
||||
23: "<code>[</code>",
|
||||
24: "<code>]</code>"
|
||||
},
|
||||
productions_: [0, [3, 1],
|
||||
[5, 1],
|
||||
[7, 1],
|
||||
[9, 1],
|
||||
[9, 1],
|
||||
[12, 2],
|
||||
[13, 1],
|
||||
[13, 1],
|
||||
[13, 1],
|
||||
[13, 1],
|
||||
[13, 1],
|
||||
[13, 1],
|
||||
[15, 2],
|
||||
[15, 3],
|
||||
[20, 3],
|
||||
[19, 1],
|
||||
[19, 3],
|
||||
[16, 2],
|
||||
[16, 3],
|
||||
[25, 1],
|
||||
[25, 3]
|
||||
],
|
||||
performAction: function(b, c, d, e, f, g, h) {
|
||||
var i = g.length - 1;
|
||||
switch (f) {
|
||||
case 1:
|
||||
this.$ = b.replace(/\\(\\|")/g, "$1").replace(/\\n/g, "\n").replace(/\\r/g, "\r").replace(/\\t/g, " ").replace(/\\v/g, "").replace(/\\f/g, "\f").replace(/\\b/g, "\b");
|
||||
break;
|
||||
case 2:
|
||||
this.$ = Number(b);
|
||||
break;
|
||||
case 3:
|
||||
this.$ = null;
|
||||
break;
|
||||
case 4:
|
||||
this.$ = !0;
|
||||
break;
|
||||
case 5:
|
||||
this.$ = !1;
|
||||
break;
|
||||
case 6:
|
||||
return this.$ = g[i - 1];
|
||||
case 13:
|
||||
this.$ = {};
|
||||
break;
|
||||
case 14:
|
||||
this.$ = g[i - 1];
|
||||
break;
|
||||
case 15:
|
||||
this.$ = [g[i - 2], g[i]];
|
||||
break;
|
||||
case 16:
|
||||
this.$ = {}, this.$[g[i][0]] = g[i][1];
|
||||
break;
|
||||
case 17:
|
||||
this.$ = g[i - 2], g[i - 2][g[i][0]] = g[i][1];
|
||||
break;
|
||||
case 18:
|
||||
this.$ = [];
|
||||
break;
|
||||
case 19:
|
||||
this.$ = g[i - 1];
|
||||
break;
|
||||
case 20:
|
||||
this.$ = [g[i]];
|
||||
break;
|
||||
case 21:
|
||||
this.$ = g[i - 2], g[i - 2].push(g[i])
|
||||
}
|
||||
},
|
||||
table: [{
|
||||
3: 5,
|
||||
4: [1, 12],
|
||||
5: 6,
|
||||
6: [1, 13],
|
||||
7: 3,
|
||||
8: [1, 9],
|
||||
9: 4,
|
||||
10: [1, 10],
|
||||
11: [1, 11],
|
||||
12: 1,
|
||||
13: 2,
|
||||
15: 7,
|
||||
16: 8,
|
||||
17: [1, 14],
|
||||
23: [1, 15]
|
||||
}, {
|
||||
1: [3]
|
||||
}, {
|
||||
14: [1, 16]
|
||||
}, {
|
||||
14: [2, 7],
|
||||
18: [2, 7],
|
||||
22: [2, 7],
|
||||
24: [2, 7]
|
||||
}, {
|
||||
14: [2, 8],
|
||||
18: [2, 8],
|
||||
22: [2, 8],
|
||||
24: [2, 8]
|
||||
}, {
|
||||
14: [2, 9],
|
||||
18: [2, 9],
|
||||
22: [2, 9],
|
||||
24: [2, 9]
|
||||
}, {
|
||||
14: [2, 10],
|
||||
18: [2, 10],
|
||||
22: [2, 10],
|
||||
24: [2, 10]
|
||||
}, {
|
||||
14: [2, 11],
|
||||
18: [2, 11],
|
||||
22: [2, 11],
|
||||
24: [2, 11]
|
||||
}, {
|
||||
14: [2, 12],
|
||||
18: [2, 12],
|
||||
22: [2, 12],
|
||||
24: [2, 12]
|
||||
}, {
|
||||
14: [2, 3],
|
||||
18: [2, 3],
|
||||
22: [2, 3],
|
||||
24: [2, 3]
|
||||
}, {
|
||||
14: [2, 4],
|
||||
18: [2, 4],
|
||||
22: [2, 4],
|
||||
24: [2, 4]
|
||||
}, {
|
||||
14: [2, 5],
|
||||
18: [2, 5],
|
||||
22: [2, 5],
|
||||
24: [2, 5]
|
||||
}, {
|
||||
14: [2, 1],
|
||||
18: [2, 1],
|
||||
21: [2, 1],
|
||||
22: [2, 1],
|
||||
24: [2, 1]
|
||||
}, {
|
||||
14: [2, 2],
|
||||
18: [2, 2],
|
||||
22: [2, 2],
|
||||
24: [2, 2]
|
||||
}, {
|
||||
3: 20,
|
||||
4: [1, 12],
|
||||
18: [1, 17],
|
||||
19: 18,
|
||||
20: 19
|
||||
}, {
|
||||
3: 5,
|
||||
4: [1, 12],
|
||||
5: 6,
|
||||
6: [1, 13],
|
||||
7: 3,
|
||||
8: [1, 9],
|
||||
9: 4,
|
||||
10: [1, 10],
|
||||
11: [1, 11],
|
||||
13: 23,
|
||||
15: 7,
|
||||
16: 8,
|
||||
17: [1, 14],
|
||||
23: [1, 15],
|
||||
24: [1, 21],
|
||||
25: 22
|
||||
}, {
|
||||
1: [2, 6]
|
||||
}, {
|
||||
14: [2, 13],
|
||||
18: [2, 13],
|
||||
22: [2, 13],
|
||||
24: [2, 13]
|
||||
}, {
|
||||
18: [1, 24],
|
||||
22: [1, 25]
|
||||
}, {
|
||||
18: [2, 16],
|
||||
22: [2, 16]
|
||||
}, {
|
||||
21: [1, 26]
|
||||
}, {
|
||||
14: [2, 18],
|
||||
18: [2, 18],
|
||||
22: [2, 18],
|
||||
24: [2, 18]
|
||||
}, {
|
||||
22: [1, 28],
|
||||
24: [1, 27]
|
||||
}, {
|
||||
22: [2, 20],
|
||||
24: [2, 20]
|
||||
}, {
|
||||
14: [2, 14],
|
||||
18: [2, 14],
|
||||
22: [2, 14],
|
||||
24: [2, 14]
|
||||
}, {
|
||||
3: 20,
|
||||
4: [1, 12],
|
||||
20: 29
|
||||
}, {
|
||||
3: 5,
|
||||
4: [1, 12],
|
||||
5: 6,
|
||||
6: [1, 13],
|
||||
7: 3,
|
||||
8: [1, 9],
|
||||
9: 4,
|
||||
10: [1, 10],
|
||||
11: [1, 11],
|
||||
13: 30,
|
||||
15: 7,
|
||||
16: 8,
|
||||
17: [1, 14],
|
||||
23: [1, 15]
|
||||
}, {
|
||||
14: [2, 19],
|
||||
18: [2, 19],
|
||||
22: [2, 19],
|
||||
24: [2, 19]
|
||||
}, {
|
||||
3: 5,
|
||||
4: [1, 12],
|
||||
5: 6,
|
||||
6: [1, 13],
|
||||
7: 3,
|
||||
8: [1, 9],
|
||||
9: 4,
|
||||
10: [1, 10],
|
||||
11: [1, 11],
|
||||
13: 31,
|
||||
15: 7,
|
||||
16: 8,
|
||||
17: [1, 14],
|
||||
23: [1, 15]
|
||||
}, {
|
||||
18: [2, 17],
|
||||
22: [2, 17]
|
||||
}, {
|
||||
18: [2, 15],
|
||||
22: [2, 15]
|
||||
}, {
|
||||
22: [2, 21],
|
||||
24: [2, 21]
|
||||
}],
|
||||
defaultActions: {
|
||||
16: [2, 6]
|
||||
},
|
||||
parseError: function(b, c) {
|
||||
throw new Error(b)
|
||||
},
|
||||
parse: function(b) {
|
||||
function o(a) {
|
||||
d.length = d.length - 2 * a, e.length = e.length - a, f.length = f.length - a
|
||||
}
|
||||
function p() {
|
||||
var a;
|
||||
return a = c.lexer.lex() || 1, typeof a != "number" && (a = c.symbols_[a] || a), a
|
||||
}
|
||||
var c = this,
|
||||
d = [0],
|
||||
e = [null],
|
||||
f = [],
|
||||
g = this.table,
|
||||
h = "",
|
||||
i = 0,
|
||||
j = 0,
|
||||
k = 0,
|
||||
l = 2,
|
||||
m = 1;
|
||||
this.lexer.setInput(b), this.lexer.yy = this.yy, this.yy.lexer = this.lexer, typeof this.lexer.yylloc == "undefined" && (this.lexer.yylloc = {});
|
||||
var n = this.lexer.yylloc;
|
||||
f.push(n), typeof this.yy.parseError == "function" && (this.parseError = this.yy.parseError);
|
||||
var q, r, s, t, u, v, w = {},
|
||||
x, y, z, A;
|
||||
for (;;) {
|
||||
s = d[d.length - 1], this.defaultActions[s] ? t = this.defaultActions[s] : (q == null && (q = p()), t = g[s] && g[s][q]);
|
||||
if (typeof t == "undefined" || !t.length || !t[0]) {
|
||||
if (!k) {
|
||||
A = [];
|
||||
for (x in g[s]) this.terminals_[x] && x > 2 && A.push("'" + this.terminals_[x] + "'");
|
||||
var B = "";
|
||||
this.lexer.showPosition ? B = "在第"+ (i + 1)+"行发生解析错误 "+ ":<br/>" + this.lexer.showPosition() + "<br/>此处缺少" + A.join(", ") + "字符, 实际上是一个 '" + this.terminals_[q] + "'" : B = "在第"+ (i + 1)+"行发生解析错误 " + ": 本应该是 " + (q == 1 ? "结尾输入" : "'" + (this.terminals_[q] || q) + "'"), this.parseError(B, {
|
||||
text: this.lexer.match,
|
||||
token: this.terminals_[q] || q,
|
||||
line: this.lexer.yylineno,
|
||||
loc: n,
|
||||
expected: A
|
||||
})
|
||||
}
|
||||
if (k == 3) {
|
||||
if (q == m) throw new Error(B || "解析意外终止.");
|
||||
j = this.lexer.yyleng, h = this.lexer.yytext, i = this.lexer.yylineno, n = this.lexer.yylloc, q = p()
|
||||
}
|
||||
for (;;) {
|
||||
if (l.toString() in g[s]) break;
|
||||
if (s == 0) throw new Error(B || "解析意外终止.");
|
||||
o(1), s = d[d.length - 1]
|
||||
}
|
||||
r = q, q = l, s = d[d.length - 1], t = g[s] && g[s][l], k = 3
|
||||
}
|
||||
if (t[0] instanceof Array && t.length > 1) throw new Error("解析错误: multiple actions possible at state: " + s + ", token: " + q);
|
||||
switch (t[0]) {
|
||||
case 1:
|
||||
d.push(q), e.push(this.lexer.yytext), f.push(this.lexer.yylloc), d.push(t[1]), q = null, r ? (q = r, r = null) : (j = this.lexer.yyleng, h = this.lexer.yytext, i = this.lexer.yylineno, n = this.lexer.yylloc, k > 0 && k--);
|
||||
break;
|
||||
case 2:
|
||||
y = this.productions_[t[1]][1], w.$ = e[e.length - y], w._$ = {
|
||||
first_line: f[f.length - (y || 1)].first_line,
|
||||
last_line: f[f.length - 1].last_line,
|
||||
first_column: f[f.length - (y || 1)].first_column,
|
||||
last_column: f[f.length - 1].last_column
|
||||
}, v = this.performAction.call(w, h, j, i, this.yy, t[1], e, f);
|
||||
if (typeof v != "undefined") return v;
|
||||
y && (d = d.slice(0, -1 * y * 2), e = e.slice(0, -1 * y), f = f.slice(0, -1 * y)), d.push(this.productions_[t[1]][0]), e.push(w.$), f.push(w._$), z = g[d[d.length - 2]][d[d.length - 1]], d.push(z);
|
||||
break;
|
||||
case 3:
|
||||
return !0
|
||||
}
|
||||
}
|
||||
return !0
|
||||
}
|
||||
},
|
||||
b = function() {
|
||||
var a = {
|
||||
EOF: 1,
|
||||
parseError: function(b, c) {
|
||||
if (!this.yy.parseError) throw new Error(b);
|
||||
this.yy.parseError(b, c)
|
||||
},
|
||||
setInput: function(a) {
|
||||
return this._input = a, this._more = this._less = this.done = !1, this.yylineno = this.yyleng = 0, this.yytext = this.matched = this.match = "", this.conditionStack = ["INITIAL"], this.yylloc = {
|
||||
first_line: 1,
|
||||
first_column: 0,
|
||||
last_line: 1,
|
||||
last_column: 0
|
||||
}, this
|
||||
},
|
||||
input: function() {
|
||||
var a = this._input[0];
|
||||
this.yytext += a, this.yyleng++, this.match += a, this.matched += a;
|
||||
var b = a.match(/\n/);
|
||||
return b && this.yylineno++, this._input = this._input.slice(1), a
|
||||
},
|
||||
unput: function(a) {
|
||||
return this._input = a + this._input, this
|
||||
},
|
||||
more: function() {
|
||||
return this._more = !0, this
|
||||
},
|
||||
less: function(a) {
|
||||
this._input = this.match.slice(a) + this._input
|
||||
},
|
||||
pastInput: function() {
|
||||
var a = this.matched.substr(0, this.matched.length - this.match.length);
|
||||
return (a.length > 20 ? "..." : "") + a.substr(-20).replace(/\n/g, "")
|
||||
},
|
||||
upcomingInput: function() {
|
||||
var a = this.match;
|
||||
return a.length < 20 && (a += this._input.substr(0, 20 - a.length)), (a.substr(0, 20) + (a.length > 20 ? "..." : "")).replace(/\n/g, "")
|
||||
},
|
||||
showPosition: function() {
|
||||
var a = this.pastInput(),
|
||||
b = (new Array(a.length + 1 - 5)).join(" ");
|
||||
return "<code>"+ a + this.upcomingInput() + "</code><br/>" + b + '<i class="fa fa-arrow-up" style="color:green;"></i>'
|
||||
},
|
||||
next: function() {
|
||||
if (this.done) return this.EOF;
|
||||
this._input || (this.done = !0);
|
||||
var a, b, c, d, e, f;
|
||||
this._more || (this.yytext = "", this.match = "");
|
||||
var g = this._currentRules();
|
||||
for (var h = 0; h < g.length; h++) {
|
||||
c = this._input.match(this.rules[g[h]]);
|
||||
if (c && (!b || c[0].length > b[0].length)) {
|
||||
b = c, d = h;
|
||||
if (!this.options.flex) break
|
||||
}
|
||||
}
|
||||
if (b) {
|
||||
f = b[0].match(/\n.*/g), f && (this.yylineno += f.length), this.yylloc = {
|
||||
first_line: this.yylloc.last_line,
|
||||
last_line: this.yylineno + 1,
|
||||
first_column: this.yylloc.last_column,
|
||||
last_column: f ? f[f.length - 1].length - 1 : this.yylloc.last_column + b[0].length
|
||||
}, this.yytext += b[0], this.match += b[0], this.yyleng = this.yytext.length, this._more = !1, this._input = this._input.slice(b[0].length), this.matched += b[0], a = this.performAction.call(this, this.yy, this, g[d], this.conditionStack[this.conditionStack.length - 1]), this.done && this._input && (this.done = !1);
|
||||
if (a) return a;
|
||||
return
|
||||
}
|
||||
if (this._input === "") return this.EOF;
|
||||
this.parseError("词汇错误发生在第" + (this.yylineno + 1) + "行. 不能识别的字符.<br/>" + this.showPosition(), {
|
||||
text: "",
|
||||
token: null,
|
||||
line: this.yylineno
|
||||
})
|
||||
},
|
||||
lex: function() {
|
||||
var b = this.next();
|
||||
return typeof b != "undefined" ? b : this.lex()
|
||||
},
|
||||
begin: function(b) {
|
||||
this.conditionStack.push(b)
|
||||
},
|
||||
popState: function() {
|
||||
return this.conditionStack.pop()
|
||||
},
|
||||
_currentRules: function() {
|
||||
return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules
|
||||
},
|
||||
topState: function() {
|
||||
return this.conditionStack[this.conditionStack.length - 2]
|
||||
},
|
||||
pushState: function(b) {
|
||||
this.begin(b)
|
||||
}
|
||||
};
|
||||
return a.options = {}, a.performAction = function(b, c, d, e) {
|
||||
var f = e;
|
||||
switch (d) {
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
return 6;
|
||||
case 2:
|
||||
return c.yytext = c.yytext.substr(1, c.yyleng - 2), 4;
|
||||
case 3:
|
||||
return 17;
|
||||
case 4:
|
||||
return 18;
|
||||
case 5:
|
||||
return 23;
|
||||
case 6:
|
||||
return 24;
|
||||
case 7:
|
||||
return 22;
|
||||
case 8:
|
||||
return 21;
|
||||
case 9:
|
||||
return 10;
|
||||
case 10:
|
||||
return 11;
|
||||
case 11:
|
||||
return 8;
|
||||
case 12:
|
||||
return 14;
|
||||
case 13:
|
||||
return "INVALID"
|
||||
}
|
||||
}, a.rules = [/^(?:\s+)/, /^(?:(-?([0-9]|[1-9][0-9]+))(\.[0-9]+)?([eE][-+]?[0-9]+)?\b)/, /^(?:"(?:\\[\\"bfnrt/]|\\u[a-fA-F0-9]{4}|[^\\\0-\x09\x0a-\x1f"])*")/, /^(?:\{)/, /^(?:\})/, /^(?:\[)/, /^(?:\])/, /^(?:,)/, /^(?::)/, /^(?:true\b)/, /^(?:false\b)/, /^(?:null\b)/, /^(?:$)/, /^(?:.)/], a.conditions = {
|
||||
INITIAL: {
|
||||
rules: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13],
|
||||
inclusive: !0
|
||||
}
|
||||
}, a
|
||||
}();
|
||||
return a.lexer = b, a
|
||||
}();
|
||||
return typeof a != "undefined" && typeof c != "undefined" && (c.parser = d, c.parse = function() {
|
||||
return d.parse.apply(d, arguments)
|
||||
}, c.main = function(d) {
|
||||
if (!d[1]) throw new Error("Usage: " + d[0] + " FILE");
|
||||
if (typeof process != "undefined") var e = a("fs").readFileSync(a("path").join(process.cwd(), d[1]), "utf8");
|
||||
else var f = a("file").path(a("file").cwd()),
|
||||
e = f.join(d[1]).read({
|
||||
charset: "utf-8"
|
||||
});
|
||||
return c.parser.parse(e)
|
||||
}, typeof b != "undefined" && a.main === b && c.main(typeof process != "undefined" ? process.argv.slice(1) : a("system").args)), c
|
||||
}();
|
||||
@@ -0,0 +1,71 @@
|
||||
var current_json = '';
|
||||
var current_json_str = '';
|
||||
var xml_flag = false;
|
||||
var zip_flag = false;
|
||||
$('.tip').tooltip();
|
||||
function init() {
|
||||
xml_flag = false;
|
||||
zip_flag = false;
|
||||
}
|
||||
$('#json-src').keyup(function () {
|
||||
init();
|
||||
var content = $.trim($(this).val());
|
||||
var result = '';
|
||||
if (content != '') {
|
||||
//如果是xml,那么转换为json
|
||||
if (content.substr(0, 1) === '<' && content.substr(-1, 1) === '>') {
|
||||
try {
|
||||
var json_obj = $.xml2json(content);
|
||||
content = JSON.stringify(json_obj);
|
||||
} catch (e) {
|
||||
result = '解析错误:<span style="color: #f1592a;font-weight:bold;">' + e.message + '</span>';
|
||||
current_json_str = result;
|
||||
$('#json-target').html(result);
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
try {
|
||||
current_json = jsonlint.parse(content);
|
||||
current_json_str = JSON.stringify(current_json);
|
||||
result = new Fjson(content, 4).toString();
|
||||
} catch (e) {
|
||||
result = '<span style="color: #f1592a;font-weight:bold;">' + e + '</span>';
|
||||
current_json_str = result;
|
||||
}
|
||||
|
||||
$('#json-target').html(result);
|
||||
} else {
|
||||
$('#json-target').html('');
|
||||
}
|
||||
|
||||
});
|
||||
$('#xml').click(function () {
|
||||
if (xml_flag) {
|
||||
$('#json-src').keyup();
|
||||
} else {
|
||||
var result = $.json2xml(current_json);
|
||||
$('#json-target').html('<textarea style="width:100%;height:100%;border:0;resize:none;">' + result + '</textarea>');
|
||||
xml_flag = true;
|
||||
}
|
||||
});
|
||||
$('#zip').click(function () {
|
||||
if (zip_flag) {
|
||||
$('#json-src').keyup();
|
||||
} else {
|
||||
$('#json-target').html(current_json_str);
|
||||
zip_flag = true;
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
$('#clear').click(function () {
|
||||
$('#json-src').val('');
|
||||
$('#json-target').html('');
|
||||
});
|
||||
$('.save').click(function () {
|
||||
var content = JSON.stringify(current_json);
|
||||
$('#txt-content').val(content);
|
||||
$("#form-save").submit();
|
||||
});
|
||||
$('#json-src').keyup();
|
||||
@@ -0,0 +1,66 @@
|
||||
function jsonzip(ii) {
|
||||
var txtA = document.getElementById("content");
|
||||
var text = txtA.value;
|
||||
if ((ii == 1 || ii == 3)) {
|
||||
text = text.split("\n").join(" ");
|
||||
var t = [];
|
||||
var inString = false;
|
||||
for (var i = 0, len = text.length; i < len; i++) {
|
||||
var c = text.charAt(i);
|
||||
if (inString && c === inString) {
|
||||
if (text.charAt(i - 1) !== '\\') {
|
||||
inString = false;
|
||||
}
|
||||
} else if (!inString && (c === '"' || c === "'")) {
|
||||
inString = c;
|
||||
} else if (!inString && (c === ' ' || c === "\t")) {
|
||||
c = '';
|
||||
}
|
||||
t.push(c);
|
||||
}
|
||||
text = t.join('');
|
||||
}
|
||||
if ((ii == 2 || ii == 3)) {
|
||||
text = text.replace(/\\/g, "\\\\").replace(/\"/g, "\\\"");
|
||||
}
|
||||
if (ii == 4) {
|
||||
text = text.replace(/\\\\/g, "\\").replace(/\\\"/g, '\"');
|
||||
}
|
||||
txtA.value = text;
|
||||
}
|
||||
String.prototype.trim = function () {
|
||||
return this.replace(/(^\s*)|(\s*$)/g, '');
|
||||
}
|
||||
var GB2312UnicodeConverter = {
|
||||
ToUnicode: function (str) {
|
||||
var txt = escape(str).toLocaleLowerCase().replace(/%u/gi, '\\u');
|
||||
return txt.replace(/%7b/gi, '{').replace(/%7d/gi, '}').replace(/%3a/gi, ':').replace(/%2c/gi, ',').replace(/%27/gi, '\'').replace(/%22/gi, '"').replace(/%5b/gi, '[').replace(/%5d/gi, ']');
|
||||
}
|
||||
, ToGB2312: function (str) {
|
||||
return unescape(str.replace(/\\u/gi, '%u'));
|
||||
}
|
||||
};
|
||||
function u2h() {
|
||||
var txtA = document.getElementById("content");
|
||||
var text = txtA.value;
|
||||
text = text.trim();
|
||||
txtA.value = GB2312UnicodeConverter.ToGB2312(text);
|
||||
}
|
||||
function h2u() {
|
||||
var txtA = document.getElementById("content");
|
||||
var text = txtA.value;
|
||||
text = text.trim();
|
||||
txtA.value = GB2312UnicodeConverter.ToUnicode(text);
|
||||
}
|
||||
function JsonToGet(type) {
|
||||
var sstr = $("#content").val();
|
||||
if (type == 1) {
|
||||
sstr = sstr.replace(/\t/g, "");
|
||||
sstr = sstr.replace(/\"/g, "").replace("{", "").replace("}", "").replace(",", "&").replace(":", "=");
|
||||
sstr = sstr.replace(/\"/g, "").replace(/{/g, "").replace(/}/g, "").replace(/,/g, "&").replace(/:/g, "=");
|
||||
} else {
|
||||
sstr = sstr.replace(/&/g, '","').replace(/;/g, '","').replace(/=/g, '":"');
|
||||
sstr = '{"' + sstr + '"}';
|
||||
}
|
||||
$("#content").val(sstr);
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/*!
|
||||
* jQuery Message Plugin (with Transition Definitions)
|
||||
* Examples and documentation at: http://eadmarket.com/
|
||||
* Copyright (c) 2012-2013 China.Ren.
|
||||
* Version: 1.0.2 (19-OCT-2013)
|
||||
* Dual licensed under the MIT and GPL licenses.
|
||||
* http://jquery.malsup.com/license.html
|
||||
* Requires: jQuery v1.3.1 or later
|
||||
*/
|
||||
var container = $('#jquery-beauty-msg');
|
||||
if (container.length <= 0) {
|
||||
$("body").append('<div style="clear:both;"></div><div id="jquery-beauty-msg"></div>');
|
||||
container = $('#jquery-beauty-msg');
|
||||
}
|
||||
var containerStyle = 'color:#e1282b;font-family:"΢ÈíÑźÚ";font-weight:bold;font-size:20px;text-shadow:5px 5px 10px #bbb;'
|
||||
+ 'text-align:center;margin:0;padding-top:20%;width:100%;word-break:break-all;z-index:100000;';
|
||||
var closeFlag = false;
|
||||
var timer = 0;
|
||||
var msgContent = '';
|
||||
$.msg = function (txt, style, obj, delay) {
|
||||
msgContent = txt;
|
||||
|
||||
if (obj != "undefined" && obj != null) {
|
||||
containerStyle += 'position:relative;top:' + $(obj).attr('top') + ';left:' + $(obj).attr('left') + ';';
|
||||
}
|
||||
else {
|
||||
containerStyle += 'position:fixed;top:0;left:0;';
|
||||
$(container).attr('style', containerStyle + style);
|
||||
$(container).html(msgContent);
|
||||
$(container).fadeIn(300, function () {
|
||||
$(container).animate({ fontSize: '40px' }, '300');
|
||||
$(container).delay(1000).fadeOut();
|
||||
});
|
||||
}
|
||||
}
|
||||
function addDot() {
|
||||
msgContent = msgContent + ".";
|
||||
$(container).html(msgContent);
|
||||
timer = timer + 1;
|
||||
if (!closeFlag && timer >= 5) {
|
||||
$(container).html("²Ù×÷³¬Ê±£¡");
|
||||
window.clearInterval();
|
||||
}
|
||||
}
|
||||
$.loading = function (txt, action) {
|
||||
msgContent = txt;
|
||||
containerStyle += 'position:fixed;top:0;left:0;';
|
||||
$(container).attr('style', containerStyle + "color:blue;");
|
||||
$(container).html(msgContent);
|
||||
if (action != "close") {
|
||||
$(container).fadeIn(300, function () {
|
||||
$(container).animate({ fontSize: '40px' }, '300');
|
||||
});
|
||||
window.setInterval("addDot", 1000);
|
||||
|
||||
} else {
|
||||
window.clearInterval();
|
||||
closeFlag = true;
|
||||
$(container).fadeOut();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
_uacct = "UA-2223138-1";
|
||||
|
||||
function onLoad() {
|
||||
var version = getSilverlightVersion();
|
||||
|
||||
}
|
||||
function getSilverlightVersion() {
|
||||
|
||||
var version = 'No Silverlight';
|
||||
|
||||
var container = null;
|
||||
|
||||
try {
|
||||
|
||||
var control = null;
|
||||
|
||||
if (window.ActiveXObject) {
|
||||
|
||||
control = new ActiveXObject('AgControl.AgControl');
|
||||
|
||||
}
|
||||
|
||||
else {
|
||||
|
||||
if (navigator.plugins['Silverlight Plug-In']) {
|
||||
|
||||
container = document.createElement('div');
|
||||
|
||||
document.body.appendChild(container);
|
||||
|
||||
container.innerHTML = '<embed type="application/x-silverlight" src="data:," />';
|
||||
|
||||
control = container.childNodes[0];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (control) {
|
||||
|
||||
if (control.isVersionSupported('5.0')) { version = 'Silverlight/5.0'; }
|
||||
|
||||
else if (control.isVersionSupported('4.0')) { version = 'Silverlight/4.0'; }
|
||||
|
||||
else if (control.isVersionSupported('3.0')) { version = 'Silverlight/3.0'; }
|
||||
|
||||
else if (control.isVersionSupported('2.0')) { version = 'Silverlight/2.0'; }
|
||||
else if (control.isVersionSupported('1.0')) { version = 'Silverlight/1.0'; }
|
||||
}
|
||||
}
|
||||
catch (e) { }
|
||||
if (container) {
|
||||
document.body.removeChild(container);
|
||||
}
|
||||
return version;
|
||||
}
|
||||
onLoad();
|
||||
@@ -0,0 +1,369 @@
|
||||
/*
|
||||
* format - jQuery plugin to pretty-print or minify text in XML, JSON, CSS and SQL formats.
|
||||
* https://github.com/zachofalltrades/jquery.format
|
||||
*
|
||||
* Version - 0.1
|
||||
* Copyright (c) 2013 Zach Shelton
|
||||
* http://zachofalltrades.net
|
||||
*
|
||||
* Based on vkbeautify by Vadim Kiryukhin
|
||||
* http://www.eslinstructor.net/vkbeautify/
|
||||
*
|
||||
* Dual licensed under the MIT and GPL licenses:
|
||||
* http://www.opensource.org/licenses/mit-license.php
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
*
|
||||
*/
|
||||
(function( $ ) {
|
||||
|
||||
/**
|
||||
* utility function called from constructor of Formatter
|
||||
*/
|
||||
function createShiftArr(step) {
|
||||
var space = ' ';
|
||||
if ( isNaN(parseInt(step)) ) { // argument is string
|
||||
space = step;
|
||||
} else { // argument is integer
|
||||
space = new Array(step + 1).join(' '); //space is result of join (a string), not an array
|
||||
}
|
||||
var shift = ['\n']; // array of shifts
|
||||
for(var ix=0;ix<100;ix++){
|
||||
shift.push(shift[ix]+space);
|
||||
}
|
||||
return shift;
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function isSubquery(str, parenthesisLevel) {
|
||||
return parenthesisLevel - (str.replace(/\(/g,'').length - str.replace(/\)/g,'').length );
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function split_sql(str, tab) {
|
||||
return str.replace(/\s{1,}/g," ")
|
||||
.replace(/ AND /ig,"~::~"+tab+tab+"AND ")
|
||||
.replace(/ BETWEEN /ig,"~::~"+tab+"BETWEEN ")
|
||||
.replace(/ CASE /ig,"~::~"+tab+"CASE ")
|
||||
.replace(/ ELSE /ig,"~::~"+tab+"ELSE ")
|
||||
.replace(/ END /ig,"~::~"+tab+"END ")
|
||||
.replace(/ FROM /ig,"~::~FROM ")
|
||||
.replace(/ GROUP\s{1,}BY/ig,"~::~GROUP BY ")
|
||||
.replace(/ HAVING /ig,"~::~HAVING ")
|
||||
//.replace(/ SET /ig," SET~::~")
|
||||
.replace(/ IN /ig," IN ")
|
||||
.replace(/ JOIN /ig,"~::~JOIN ")
|
||||
.replace(/ CROSS~::~{1,}JOIN /ig,"~::~CROSS JOIN ")
|
||||
.replace(/ INNER~::~{1,}JOIN /ig,"~::~INNER JOIN ")
|
||||
.replace(/ LEFT~::~{1,}JOIN /ig,"~::~LEFT JOIN ")
|
||||
.replace(/ RIGHT~::~{1,}JOIN /ig,"~::~RIGHT JOIN ")
|
||||
.replace(/ ON /ig,"~::~"+tab+"ON ")
|
||||
.replace(/ OR /ig,"~::~"+tab+tab+"OR ")
|
||||
.replace(/ ORDER\s{1,}BY/ig,"~::~ORDER BY ")
|
||||
.replace(/ OVER /ig,"~::~"+tab+"OVER ")
|
||||
.replace(/\(\s{0,}SELECT /ig,"~::~(SELECT ")
|
||||
.replace(/\)\s{0,}SELECT /ig,")~::~SELECT ")
|
||||
.replace(/ THEN /ig," THEN~::~"+tab+"")
|
||||
.replace(/ UNION /ig,"~::~UNION~::~")
|
||||
.replace(/ USING /ig,"~::~USING ")
|
||||
.replace(/ WHEN /ig,"~::~"+tab+"WHEN ")
|
||||
.replace(/ WHERE /ig,"~::~WHERE ")
|
||||
.replace(/ WITH /ig,"~::~WITH ")
|
||||
//.replace(/\,\s{0,}\(/ig,",~::~( ")
|
||||
//.replace(/\,/ig,",~::~"+tab+tab+"")
|
||||
.replace(/ ALL /ig," ALL ")
|
||||
.replace(/ AS /ig," AS ")
|
||||
.replace(/ ASC /ig," ASC ")
|
||||
.replace(/ DESC /ig," DESC ")
|
||||
.replace(/ DISTINCT /ig," DISTINCT ")
|
||||
.replace(/ EXISTS /ig," EXISTS ")
|
||||
.replace(/ NOT /ig," NOT ")
|
||||
.replace(/ NULL /ig," NULL ")
|
||||
.replace(/ LIKE /ig," LIKE ")
|
||||
.replace(/\s{0,}SELECT /ig,"SELECT ")
|
||||
.replace(/\s{0,}UPDATE /ig,"UPDATE ")
|
||||
.replace(/ SET /ig," SET ")
|
||||
.replace(/~::~{1,}/g,"~::~")
|
||||
.split('~::~');
|
||||
};
|
||||
|
||||
|
||||
var Formatter = function (options) {
|
||||
this.init(options);
|
||||
//TODO - if options object maps any functions, add them as appropriately named methods
|
||||
var methodName = this.options.method;
|
||||
if (!$.isFunction(this[methodName])) {
|
||||
$.error("'" + methodName + "' is not a Formatter method.");
|
||||
};
|
||||
this.format = function(text) { //alias to currently selected method
|
||||
return this[this.options.method].call(this, text);
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* putting the methods into the prototype instead of the constructor method
|
||||
* enables more efficient on-the-fly creation of Formatter instances
|
||||
*/
|
||||
Formatter.prototype = {
|
||||
options: {},
|
||||
|
||||
init: function(options) {
|
||||
this.options = $.extend({}, $.fn.format.defaults, options);
|
||||
this.step = this.options.step;
|
||||
this.preserveComments = this.options.preserveComments;
|
||||
this.shift = createShiftArr(this.step);
|
||||
},
|
||||
|
||||
xml: function(text) {
|
||||
var ar = text.replace(/>\s{0,}</g,"><")
|
||||
.replace(/</g,"~::~<")
|
||||
.replace(/\s*xmlns\:/g,"~::~xmlns:")
|
||||
.replace(/\s*xmlns\=/g,"~::~xmlns=")
|
||||
.split('~::~'),
|
||||
len = ar.length,
|
||||
inComment = false,
|
||||
deep = 0,
|
||||
str = '',
|
||||
ix = 0;
|
||||
|
||||
for(ix=0;ix<len;ix++) {
|
||||
// start comment or <![CDATA[...]]> or <!DOCTYPE //
|
||||
if(ar[ix].search(/<!/) > -1) {
|
||||
str += this.shift[deep]+ar[ix];
|
||||
inComment = true;
|
||||
// end comment or <![CDATA[...]]> //
|
||||
if(ar[ix].search(/-->/) > -1 || ar[ix].search(/\]>/) > -1 || ar[ix].search(/!DOCTYPE/) > -1 ) {
|
||||
inComment = false;
|
||||
}
|
||||
} else
|
||||
// end comment or <![CDATA[...]]> //
|
||||
if(ar[ix].search(/-->/) > -1 || ar[ix].search(/\]>/) > -1) {
|
||||
str += ar[ix];
|
||||
inComment = false;
|
||||
} else
|
||||
// <elm></elm> //
|
||||
if( /^<\w/.exec(ar[ix-1]) && /^<\/\w/.exec(ar[ix]) &&
|
||||
/^<[\w:\-\.\,]+/.exec(ar[ix-1]) == /^<\/[\w:\-\.\,]+/.exec(ar[ix])[0].replace('/','')) {
|
||||
str += ar[ix];
|
||||
if(!inComment) deep--;
|
||||
} else
|
||||
// <elm> //
|
||||
if(ar[ix].search(/<\w/) > -1 && ar[ix].search(/<\//) == -1 && ar[ix].search(/\/>/) == -1 ) {
|
||||
str = !inComment ? str += this.shift[deep++]+ar[ix] : str += ar[ix];
|
||||
} else
|
||||
// <elm>...</elm> //
|
||||
if(ar[ix].search(/<\w/) > -1 && ar[ix].search(/<\//) > -1) {
|
||||
str = !inComment ? str += this.shift[deep]+ar[ix] : str += ar[ix];
|
||||
} else
|
||||
// </elm> //
|
||||
if(ar[ix].search(/<\//) > -1) {
|
||||
str = !inComment ? str += this.shift[--deep]+ar[ix] : str += ar[ix];
|
||||
} else
|
||||
// <elm/> //
|
||||
if(ar[ix].search(/\/>/) > -1 ) {
|
||||
str = !inComment ? str += this.shift[deep]+ar[ix] : str += ar[ix];
|
||||
} else
|
||||
// <? xml ... ?> //
|
||||
if(ar[ix].search(/<\?/) > -1) {
|
||||
str += this.shift[deep]+ar[ix];
|
||||
} else
|
||||
// xmlns //
|
||||
if( ar[ix].search(/xmlns\:/) > -1 || ar[ix].search(/xmlns\=/) > -1) {
|
||||
str += this.shift[deep]+ar[ix];
|
||||
}
|
||||
|
||||
else {
|
||||
str += ar[ix];
|
||||
}
|
||||
}
|
||||
|
||||
return (str[0] == '\n') ? str.slice(1) : str;
|
||||
},
|
||||
|
||||
xmlmin: function(text) {
|
||||
var str = this.preserveComments ? text
|
||||
: text.replace(/\<![ \r\n\t]*(--([^\-]|[\r\n]|-[^\-])*--[ \r\n\t]*)\>/g,"")
|
||||
.replace(/[ \r\n\t]{1,}xmlns/g, ' xmlns');
|
||||
return str.replace(/>\s{0,}</g,"><");
|
||||
},
|
||||
|
||||
json: function(text) {
|
||||
if ( typeof JSON === 'undefined' ) return text;
|
||||
if ( typeof text === "string" ) {
|
||||
return JSON.stringify(JSON.parse(text), null, this.step);
|
||||
}
|
||||
if ( typeof text === "object" ) {
|
||||
return JSON.stringify(text, null, this.step);
|
||||
}
|
||||
return text; // text is not string nor object
|
||||
},
|
||||
|
||||
jsonmin: function(text) {
|
||||
if (typeof JSON === 'undefined' ) {
|
||||
return text;
|
||||
}
|
||||
return JSON.stringify(JSON.parse(text), null, 0);
|
||||
},
|
||||
|
||||
css: function(text) {
|
||||
var ar = text.replace(/\s{1,}/g,' ')
|
||||
.replace(/\{/g,"{~::~")
|
||||
.replace(/\}/g,"~::~}~::~")
|
||||
.replace(/\;/g,";~::~")
|
||||
.replace(/\/\*/g,"~::~/*")
|
||||
.replace(/\*\//g,"*/~::~")
|
||||
.replace(/~::~\s{0,}~::~/g,"~::~")
|
||||
.split('~::~'),
|
||||
len = ar.length,
|
||||
deep = 0,
|
||||
str = '',
|
||||
ix = 0;
|
||||
|
||||
for(ix=0;ix<len;ix++) {
|
||||
|
||||
if( /\{/.exec(ar[ix])) {
|
||||
str += this.shift[deep++]+ar[ix];
|
||||
} else
|
||||
if( /\}/.exec(ar[ix])) {
|
||||
str += this.shift[--deep]+ar[ix];
|
||||
} else
|
||||
if( /\*\\/.exec(ar[ix])) {
|
||||
str += this.shift[deep]+ar[ix];
|
||||
}
|
||||
else {
|
||||
str += this.shift[deep]+ar[ix];
|
||||
}
|
||||
}
|
||||
return str.replace(/^\n{1,}/,'');
|
||||
},
|
||||
|
||||
cssmin: function(text) {
|
||||
var str = this.preserveComments ? text : text.replace(/\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+\//g,"") ;
|
||||
return str.replace(/\s{1,}/g,' ')
|
||||
.replace(/\{\s{1,}/g,"{")
|
||||
.replace(/\}\s{1,}/g,"}")
|
||||
.replace(/\;\s{1,}/g,";")
|
||||
.replace(/\/\*\s{1,}/g,"/*")
|
||||
.replace(/\*\/\s{1,}/g,"*/");
|
||||
},
|
||||
|
||||
sql: function(text) {
|
||||
|
||||
var ar_by_quote = text.replace(/\s{1,}/g," ")
|
||||
.replace(/\'/ig,"~::~\'")
|
||||
.split('~::~'),
|
||||
len = ar_by_quote.length,
|
||||
ar = [],
|
||||
deep = 0,
|
||||
tab = this.step,//+this.step,
|
||||
parenthesisLevel = 0,
|
||||
str = '',
|
||||
ix = 0;
|
||||
|
||||
for(ix=0;ix<len;ix++) {
|
||||
if(ix%2) {
|
||||
ar = ar.concat(ar_by_quote[ix]);
|
||||
} else {
|
||||
ar = ar.concat(split_sql(ar_by_quote[ix], tab) );
|
||||
}
|
||||
}
|
||||
|
||||
len = ar.length;
|
||||
for(ix=0;ix<len;ix++) {
|
||||
|
||||
parenthesisLevel = isSubquery(ar[ix], parenthesisLevel);
|
||||
|
||||
if( /\s{0,}\s{0,}SELECT\s{0,}/.exec(ar[ix])) {
|
||||
ar[ix] = ar[ix].replace(/\,/g,",\n"+tab+tab+"");
|
||||
}
|
||||
|
||||
if( /\s{0,}\s{0,}SET\s{0,}/.exec(ar[ix])) {
|
||||
ar[ix] = ar[ix].replace(/\,/g,",\n"+tab+tab+"");
|
||||
}
|
||||
|
||||
if( /\s{0,}\(\s{0,}SELECT\s{0,}/.exec(ar[ix])) {
|
||||
deep++;
|
||||
str += this.shift[deep]+ar[ix];
|
||||
} else
|
||||
if( /\'/.exec(ar[ix]) ) {
|
||||
if(parenthesisLevel<1 && deep) {
|
||||
deep--;
|
||||
}
|
||||
str += ar[ix];
|
||||
}
|
||||
else {
|
||||
str += this.shift[deep]+ar[ix];
|
||||
if(parenthesisLevel<1 && deep) {
|
||||
deep--;
|
||||
}
|
||||
}
|
||||
}
|
||||
str = str.replace(/^\n{1,}/,'').replace(/\n{1,}/g,"\n");
|
||||
return str;
|
||||
},
|
||||
|
||||
sqlmin: function(text) {
|
||||
return text.replace(/\s{1,}/g," ").replace(/\s{1,}\(/,"(").replace(/\s{1,}\)/,")");
|
||||
}
|
||||
|
||||
};//end Formatter.prototype
|
||||
|
||||
|
||||
/**
|
||||
* DOM chaining version
|
||||
*/
|
||||
$.fn.format = function(options) {
|
||||
var fmt = new Formatter(options);
|
||||
// var methodName = fmt.options.method;
|
||||
// if (!$.isFunction(fmt[methodName])) {
|
||||
// $.error("'" + methodName + "' is not a Formatter method.")
|
||||
// };
|
||||
// console.log("call " + methodName + " on " + $.type(this));
|
||||
// console.log(this);
|
||||
return this.each(function() {
|
||||
// console.log($.type(this));
|
||||
// console.log(this);
|
||||
var node = $(this);
|
||||
// console.log($.type(node));
|
||||
// console.log(node);
|
||||
var text = node.val();
|
||||
// console.log("text ==>\n" + text);
|
||||
text = fmt.format(text);
|
||||
hightout(text);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* utility version
|
||||
*/
|
||||
$.format = function(text, options) {
|
||||
var fmt = new Formatter(options);
|
||||
// var methodName = fmt.options.method;
|
||||
// if (!$.isFunction(fmt[methodName])) {
|
||||
// $.error("'" + methodName + "' is not a Formatter method.")
|
||||
// };
|
||||
// console.log("call " + methodName + " on " + $.type(text));
|
||||
// console.log(text);
|
||||
// return fmt[methodName].call(fmt, text);
|
||||
return fmt.format(text);
|
||||
};
|
||||
|
||||
/**
|
||||
* default configuration
|
||||
*/
|
||||
$.fn.format.defaults = {
|
||||
method: 'xml', // the method to be called
|
||||
step: ' ', // 4 spaces
|
||||
preserveComments: false //applies to cssmin and xmlmin functions
|
||||
};
|
||||
|
||||
|
||||
})(jQuery);
|
||||
function Empty() {
|
||||
document.getElementById("content").value = "";
|
||||
document.getElementById("content").select();
|
||||
}
|
||||
@@ -0,0 +1,517 @@
|
||||
// ========================================================================
|
||||
// XML.ObjTree -- XML source code from/to JavaScript object like E4X
|
||||
// ========================================================================
|
||||
|
||||
if (typeof (XML) == 'undefined') XML = function () { };
|
||||
|
||||
// constructor
|
||||
|
||||
XML.ObjTree = function () {
|
||||
return this;
|
||||
};
|
||||
|
||||
// class variables
|
||||
|
||||
XML.ObjTree.VERSION = "0.23";
|
||||
|
||||
// object prototype
|
||||
|
||||
XML.ObjTree.prototype.xmlDecl = '<?xml version="1.0" encoding="UTF-8" ?>\n';
|
||||
XML.ObjTree.prototype.attr_prefix = '-';
|
||||
|
||||
// method: parseXML( xmlsource )
|
||||
|
||||
XML.ObjTree.prototype.parseXML = function (xml) {
|
||||
var root;
|
||||
if (window.DOMParser) {
|
||||
var xmldom = new DOMParser();
|
||||
// xmldom.async = false; // DOMParser is always sync-mode
|
||||
var dom = xmldom.parseFromString(xml, "application/xml");
|
||||
if (!dom) return;
|
||||
root = dom.documentElement;
|
||||
} else if (window.ActiveXObject) {
|
||||
xmldom = new ActiveXObject('Microsoft.XMLDOM');
|
||||
xmldom.async = false;
|
||||
xmldom.loadXML(xml);
|
||||
root = xmldom.documentElement;
|
||||
}
|
||||
if (!root) return;
|
||||
return this.parseDOM(root);
|
||||
};
|
||||
|
||||
// method: parseHTTP( url, options, callback )
|
||||
|
||||
XML.ObjTree.prototype.parseHTTP = function (url, options, callback) {
|
||||
var myopt = {};
|
||||
for (var key in options) {
|
||||
myopt[key] = options[key]; // copy object
|
||||
}
|
||||
if (!myopt.method) {
|
||||
if (typeof (myopt.postBody) == "undefined" &&
|
||||
typeof (myopt.postbody) == "undefined" &&
|
||||
typeof (myopt.parameters) == "undefined") {
|
||||
myopt.method = "get";
|
||||
} else {
|
||||
myopt.method = "post";
|
||||
}
|
||||
}
|
||||
if (callback) {
|
||||
myopt.asynchronous = true; // async-mode
|
||||
var __this = this;
|
||||
var __func = callback;
|
||||
var __save = myopt.onComplete;
|
||||
myopt.onComplete = function (trans) {
|
||||
var tree;
|
||||
if (trans && trans.responseXML && trans.responseXML.documentElement) {
|
||||
tree = __this.parseDOM(trans.responseXML.documentElement);
|
||||
}
|
||||
__func(tree, trans);
|
||||
if (__save) __save(trans);
|
||||
};
|
||||
} else {
|
||||
myopt.asynchronous = false; // sync-mode
|
||||
}
|
||||
var trans;
|
||||
if (typeof (HTTP) != "undefined" && HTTP.Request) {
|
||||
myopt.uri = url;
|
||||
var req = new HTTP.Request(myopt); // JSAN
|
||||
if (req) trans = req.transport;
|
||||
} else if (typeof (Ajax) != "undefined" && Ajax.Request) {
|
||||
var req = new Ajax.Request(url, myopt); // ptorotype.js
|
||||
if (req) trans = req.transport;
|
||||
}
|
||||
if (callback) return trans;
|
||||
if (trans && trans.responseXML && trans.responseXML.documentElement) {
|
||||
return this.parseDOM(trans.responseXML.documentElement);
|
||||
}
|
||||
}
|
||||
|
||||
// method: parseDOM( documentroot )
|
||||
|
||||
XML.ObjTree.prototype.parseDOM = function (root) {
|
||||
if (!root) return;
|
||||
|
||||
this.__force_array = {};
|
||||
if (this.force_array) {
|
||||
for (var i = 0; i < this.force_array.length; i++) {
|
||||
this.__force_array[this.force_array[i]] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
var json = this.parseElement(root); // parse root node
|
||||
if (this.__force_array[root.nodeName]) {
|
||||
json = [json];
|
||||
}
|
||||
if (root.nodeType != 11) { // DOCUMENT_FRAGMENT_NODE
|
||||
var tmp = {};
|
||||
tmp[root.nodeName] = json; // root nodeName
|
||||
json = tmp;
|
||||
}
|
||||
return json;
|
||||
};
|
||||
|
||||
// method: parseElement( element )
|
||||
|
||||
XML.ObjTree.prototype.parseElement = function (elem) {
|
||||
// COMMENT_NODE
|
||||
if (elem.nodeType == 7) {
|
||||
return;
|
||||
}
|
||||
|
||||
// TEXT_NODE CDATA_SECTION_NODE
|
||||
if (elem.nodeType == 3 || elem.nodeType == 4) {
|
||||
var bool = elem.nodeValue.match(/[^\x00-\x20]/);
|
||||
if (bool == null) return; // ignore white spaces
|
||||
return elem.nodeValue;
|
||||
}
|
||||
|
||||
var retval;
|
||||
var cnt = {};
|
||||
|
||||
// parse attributes
|
||||
if (elem.attributes && elem.attributes.length) {
|
||||
retval = {};
|
||||
for (var i = 0; i < elem.attributes.length; i++) {
|
||||
var key = elem.attributes[i].nodeName;
|
||||
if (typeof (key) != "string") continue;
|
||||
var val = elem.attributes[i].nodeValue;
|
||||
if (!val) continue;
|
||||
key = this.attr_prefix + key;
|
||||
if (typeof (cnt[key]) == "undefined") cnt[key] = 0;
|
||||
cnt[key]++;
|
||||
this.addNode(retval, key, cnt[key], val);
|
||||
}
|
||||
}
|
||||
|
||||
// parse child nodes (recursive)
|
||||
if (elem.childNodes && elem.childNodes.length) {
|
||||
var textonly = true;
|
||||
if (retval) textonly = false; // some attributes exists
|
||||
for (var i = 0; i < elem.childNodes.length && textonly; i++) {
|
||||
var ntype = elem.childNodes[i].nodeType;
|
||||
if (ntype == 3 || ntype == 4) continue;
|
||||
textonly = false;
|
||||
}
|
||||
if (textonly) {
|
||||
if (!retval) retval = "";
|
||||
for (var i = 0; i < elem.childNodes.length; i++) {
|
||||
retval += elem.childNodes[i].nodeValue;
|
||||
}
|
||||
} else {
|
||||
if (!retval) retval = {};
|
||||
for (var i = 0; i < elem.childNodes.length; i++) {
|
||||
var key = elem.childNodes[i].nodeName;
|
||||
if (typeof (key) != "string") continue;
|
||||
var val = this.parseElement(elem.childNodes[i]);
|
||||
if (!val) continue;
|
||||
if (typeof (cnt[key]) == "undefined") cnt[key] = 0;
|
||||
cnt[key]++;
|
||||
this.addNode(retval, key, cnt[key], val);
|
||||
}
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
};
|
||||
|
||||
// method: addNode( hash, key, count, value )
|
||||
|
||||
XML.ObjTree.prototype.addNode = function (hash, key, cnts, val) {
|
||||
if (this.__force_array[key]) {
|
||||
if (cnts == 1) hash[key] = [];
|
||||
hash[key][hash[key].length] = val; // push
|
||||
} else if (cnts == 1) { // 1st sibling
|
||||
hash[key] = val;
|
||||
} else if (cnts == 2) { // 2nd sibling
|
||||
hash[key] = [hash[key], val];
|
||||
} else { // 3rd sibling and more
|
||||
hash[key][hash[key].length] = val;
|
||||
}
|
||||
};
|
||||
|
||||
// method: writeXML( tree )
|
||||
|
||||
XML.ObjTree.prototype.writeXML = function (tree) {
|
||||
var xml = this.hash_to_xml(null, tree);
|
||||
return this.xmlDecl + xml;
|
||||
};
|
||||
|
||||
// method: hash_to_xml( tagName, tree )
|
||||
|
||||
XML.ObjTree.prototype.hash_to_xml = function (name, tree) {
|
||||
var elem = [];
|
||||
var attr = [];
|
||||
for (var key in tree) {
|
||||
if (!tree.hasOwnProperty(key)) continue;
|
||||
var val = tree[key];
|
||||
if (key.charAt(0) != this.attr_prefix) {
|
||||
if (typeof (val) == "undefined" || val == null) {
|
||||
elem[elem.length] = "<" + key + " />";
|
||||
} else if (typeof (val) == "object" && val.constructor == Array) {
|
||||
elem[elem.length] = this.array_to_xml(key, val);
|
||||
} else if (typeof (val) == "object") {
|
||||
elem[elem.length] = this.hash_to_xml(key, val);
|
||||
} else {
|
||||
elem[elem.length] = this.scalar_to_xml(key, val);
|
||||
}
|
||||
} else {
|
||||
attr[attr.length] = " " + (key.substring(1)) + '="' + (this.xml_escape(val)) + '"';
|
||||
}
|
||||
}
|
||||
var jattr = attr.join("");
|
||||
var jelem = elem.join("");
|
||||
if (typeof (name) == "undefined" || name == null) {
|
||||
// no tag
|
||||
} else if (elem.length > 0) {
|
||||
if (jelem.match(/\n/)) {
|
||||
jelem = "<" + name + jattr + ">\n" + jelem + "</" + name + ">\n";
|
||||
} else {
|
||||
jelem = "<" + name + jattr + ">" + jelem + "</" + name + ">\n";
|
||||
}
|
||||
} else {
|
||||
jelem = "<" + name + jattr + " />\n";
|
||||
}
|
||||
return jelem;
|
||||
};
|
||||
|
||||
// method: array_to_xml( tagName, array )
|
||||
|
||||
XML.ObjTree.prototype.array_to_xml = function (name, array) {
|
||||
var out = [];
|
||||
for (var i = 0; i < array.length; i++) {
|
||||
var val = array[i];
|
||||
if (typeof (val) == "undefined" || val == null) {
|
||||
out[out.length] = "<" + name + " />";
|
||||
} else if (typeof (val) == "object" && val.constructor == Array) {
|
||||
out[out.length] = this.array_to_xml(name, val);
|
||||
} else if (typeof (val) == "object") {
|
||||
out[out.length] = this.hash_to_xml(name, val);
|
||||
} else {
|
||||
out[out.length] = this.scalar_to_xml(name, val);
|
||||
}
|
||||
}
|
||||
return out.join("");
|
||||
};
|
||||
|
||||
// method: scalar_to_xml( tagName, text )
|
||||
|
||||
XML.ObjTree.prototype.scalar_to_xml = function (name, text) {
|
||||
if (name == "#text") {
|
||||
return this.xml_escape(text);
|
||||
} else {
|
||||
return "<" + name + ">" + this.xml_escape(text) + "</" + name + ">\n";
|
||||
}
|
||||
};
|
||||
|
||||
// method: xml_escape( text )
|
||||
|
||||
XML.ObjTree.prototype.xml_escape = function (text) {
|
||||
return (text + '').replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
||||
};
|
||||
|
||||
/*
|
||||
// ========================================================================
|
||||
|
||||
=head1 NAME
|
||||
|
||||
XML.ObjTree -- XML source code from/to JavaScript object like E4X
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
var xotree = new XML.ObjTree();
|
||||
var tree1 = {
|
||||
root: {
|
||||
node: "Hello, World!"
|
||||
}
|
||||
};
|
||||
var xml1 = xotree.writeXML( tree1 ); // object tree to XML source
|
||||
alert( "xml1: "+xml1 );
|
||||
|
||||
var xml2 = '<?xml version="1.0"?><response><error>0</error></response>';
|
||||
var tree2 = xotree.parseXML( xml2 ); // XML source to object tree
|
||||
alert( "error: "+tree2.response.error );
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
XML.ObjTree class is a parser/generater between XML source code
|
||||
and JavaScript object like E4X, ECMAScript for XML.
|
||||
This is a JavaScript version of the XML::TreePP module for Perl.
|
||||
This also works as a wrapper for XMLHTTPRequest and successor to JKL.ParseXML class
|
||||
when this is used with prototype.js or JSAN's HTTP.Request class.
|
||||
|
||||
=head2 JavaScript object tree format
|
||||
|
||||
A sample XML source:
|
||||
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<family name="Kawasaki">
|
||||
<father>Yasuhisa</father>
|
||||
<mother>Chizuko</mother>
|
||||
<children>
|
||||
<girl>Shiori</girl>
|
||||
<boy>Yusuke</boy>
|
||||
<boy>Kairi</boy>
|
||||
</children>
|
||||
</family>
|
||||
|
||||
Its JavaScript object tree like JSON/E4X:
|
||||
|
||||
{
|
||||
'family': {
|
||||
'-name': 'Kawasaki',
|
||||
'father': 'Yasuhisa',
|
||||
'mother': 'Chizuko',
|
||||
'children': {
|
||||
'girl': 'Shiori'
|
||||
'boy': [
|
||||
'Yusuke',
|
||||
'Kairi'
|
||||
]
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Each elements are parsed into objects:
|
||||
|
||||
tree.family.father; # the father's given name.
|
||||
|
||||
Prefix '-' is inserted before every attributes' name.
|
||||
|
||||
tree.family["-name"]; # this family's family name
|
||||
|
||||
A array is used because this family has two boys.
|
||||
|
||||
tree.family.children.boy[0]; # first boy's name
|
||||
tree.family.children.boy[1]; # second boy's name
|
||||
tree.family.children.girl; # (girl has no other sisiters)
|
||||
|
||||
=head1 METHODS
|
||||
|
||||
=head2 xotree = new XML.ObjTree()
|
||||
|
||||
This constructor method returns a new XML.ObjTree object.
|
||||
|
||||
=head2 xotree.force_array = [ "rdf:li", "item", "-xmlns" ];
|
||||
|
||||
This property allows you to specify a list of element names
|
||||
which should always be forced into an array representation.
|
||||
The default value is null, it means that context of the elements
|
||||
will determine to make array or to keep it scalar.
|
||||
|
||||
=head2 xotree.attr_prefix = '@';
|
||||
|
||||
This property allows you to specify a prefix character which is
|
||||
inserted before each attribute names.
|
||||
Instead of default prefix '-', E4X-style prefix '@' is also available.
|
||||
The default character is '-'.
|
||||
Or set '@' to access attribute values like E4X, ECMAScript for XML.
|
||||
The length of attr_prefix must be just one character and not be empty.
|
||||
|
||||
=head2 tree = xotree.parseXML( xmlsrc );
|
||||
|
||||
This method loads an XML document using the supplied string
|
||||
and returns its JavaScript object converted.
|
||||
|
||||
=head2 tree = xotree.parseDOM( domnode );
|
||||
|
||||
This method parses a DOM tree (ex. responseXML.documentElement)
|
||||
and returns its JavaScript object converted.
|
||||
|
||||
=head2 tree = xotree.parseHTTP( url, options );
|
||||
|
||||
This method loads a XML file from remote web server
|
||||
and returns its JavaScript object converted.
|
||||
XMLHTTPRequest's synchronous mode is always used.
|
||||
This mode blocks the process until the response is completed.
|
||||
|
||||
First argument is a XML file's URL
|
||||
which must exist in the same domain as parent HTML file's.
|
||||
Cross-domain loading is not available for security reasons.
|
||||
|
||||
Second argument is options' object which can contains some parameters:
|
||||
method, postBody, parameters, onLoading, etc.
|
||||
|
||||
This method requires JSAN's L<HTTP.Request> class or prototype.js's Ajax.Request class.
|
||||
|
||||
=head2 xotree.parseHTTP( url, options, callback );
|
||||
|
||||
If a callback function is set as third argument,
|
||||
XMLHTTPRequest's asynchronous mode is used.
|
||||
|
||||
This mode calls a callback function with XML file's JavaScript object converted
|
||||
after the response is completed.
|
||||
|
||||
=head2 xmlsrc = xotree.writeXML( tree );
|
||||
|
||||
This method parses a JavaScript object tree
|
||||
and returns its XML source generated.
|
||||
|
||||
=head1 EXAMPLES
|
||||
|
||||
=head2 Text node and attributes
|
||||
|
||||
If a element has both of a text node and attributes
|
||||
or both of a text node and other child nodes,
|
||||
text node's value is moved to a special node named "#text".
|
||||
|
||||
var xotree = new XML.ObjTree();
|
||||
var xmlsrc = '<span class="author">Kawasaki Yusuke</span>';
|
||||
var tree = xotree.parseXML( xmlsrc );
|
||||
var class = tree.span["-class"]; # attribute
|
||||
var name = tree.span["#text"]; # text node
|
||||
|
||||
=head2 parseHTTP() method with HTTP-GET and sync-mode
|
||||
|
||||
HTTP/Request.js or prototype.js must be loaded before calling this method.
|
||||
|
||||
var xotree = new XML.ObjTree();
|
||||
var url = "http://example.com/index.html";
|
||||
var tree = xotree.parseHTTP( url );
|
||||
xotree.attr_prefix = '@'; // E4X-style
|
||||
alert( tree.html["@lang"] );
|
||||
|
||||
This code shows C<lang=""> attribute from a X-HTML source code.
|
||||
|
||||
=head2 parseHTTP() method with HTTP-POST and async-mode
|
||||
|
||||
Third argument is a callback function which is called on onComplete.
|
||||
|
||||
var xotree = new XML.ObjTree();
|
||||
var url = "http://example.com/mt-tb.cgi";
|
||||
var opts = {
|
||||
postBody: "title=...&excerpt=...&url=...&blog_name=..."
|
||||
};
|
||||
var func = function ( tree ) {
|
||||
alert( tree.response.error );
|
||||
};
|
||||
xotree.parseHTTP( url, opts, func );
|
||||
|
||||
This code send a trackback ping and shows its response code.
|
||||
|
||||
=head2 Simple RSS reader
|
||||
|
||||
This is a RSS reader which loads RDF file and displays all items.
|
||||
|
||||
var xotree = new XML.ObjTree();
|
||||
xotree.force_array = [ "rdf:li", "item" ];
|
||||
var url = "http://example.com/news-rdf.xml";
|
||||
var func = function( tree ) {
|
||||
var elem = document.getElementById("rss_here");
|
||||
for( var i=0; i<tree["rdf:RDF"].item.length; i++ ) {
|
||||
var divtag = document.createElement( "div" );
|
||||
var atag = document.createElement( "a" );
|
||||
atag.href = tree["rdf:RDF"].item[i].link;
|
||||
var title = tree["rdf:RDF"].item[i].title;
|
||||
var tnode = document.createTextNode( title );
|
||||
atag.appendChild( tnode );
|
||||
divtag.appendChild( atag );
|
||||
elem.appendChild( divtag );
|
||||
}
|
||||
};
|
||||
xotree.parseHTTP( url, {}, func );
|
||||
|
||||
=head2 XML-RPC using writeXML, prototype.js and parseDOM
|
||||
|
||||
If you wish to use prototype.js's Ajax.Request class by yourself:
|
||||
|
||||
var xotree = new XML.ObjTree();
|
||||
var reqtree = {
|
||||
methodCall: {
|
||||
methodName: "weblogUpdates.ping",
|
||||
params: {
|
||||
param: [
|
||||
{ value: "Kawa.Net xp top page" }, // 1st param
|
||||
{ value: "http://www.kawa.net/" } // 2nd param
|
||||
]
|
||||
}
|
||||
}
|
||||
};
|
||||
var reqxml = xotree.writeXML( reqtree ); // JS-Object to XML code
|
||||
var url = "http://example.com/xmlrpc";
|
||||
var func = function( req ) {
|
||||
var resdom = req.responseXML.documentElement;
|
||||
xotree.force_array = [ "member" ];
|
||||
var restree = xotree.parseDOM( resdom ); // XML-DOM to JS-Object
|
||||
alert( restree.methodResponse.params.param.value.struct.member[0].value.string );
|
||||
};
|
||||
var opt = {
|
||||
method: "post",
|
||||
postBody: reqxml,
|
||||
asynchronous: true,
|
||||
onComplete: func
|
||||
};
|
||||
new Ajax.Request( url, opt );
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Yusuke Kawasaki http://www.kawa.net/
|
||||
|
||||
=head1 COPYRIGHT AND LICENSE
|
||||
|
||||
Copyright (c) 2005-2006 Yusuke Kawasaki. All rights reserved.
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the Artistic license. Or whatever license I choose,
|
||||
which I will do instead of keeping this documentation like it is.
|
||||
|
||||
=cut
|
||||
// ========================================================================
|
||||
*/
|
||||
@@ -0,0 +1,53 @@
|
||||
function demo_xml() {
|
||||
var xml = "<books>\
|
||||
<book>\
|
||||
<author>Json</author>\
|
||||
<title>Json Dev</title>\
|
||||
<publisher>O'Reilly</publisher>\
|
||||
</book>\
|
||||
<book>\
|
||||
<author>Json</author>\
|
||||
<title>Podcasting Hacks</title>\
|
||||
<publisher>O'Reilly</publisher>\
|
||||
</book>\
|
||||
</books>";
|
||||
$('#input').val(xml);
|
||||
}
|
||||
function demo_json() {
|
||||
var json = '{\
|
||||
"tools": [\
|
||||
{ "name":"css format" , "site":"http://www.pcjson.com/formatcss/" },\
|
||||
{ "name":"json format" , "site":"http://www.pcjson.com/json/" },\
|
||||
{ "name":"hash MD5" , "site":"http://www.pcjson.com/md5/" }\
|
||||
]\
|
||||
}';
|
||||
$('#input').val(json);
|
||||
}
|
||||
|
||||
function xml2json() {
|
||||
var space = ($("#pretty_json").is(':checked')) ? " " : "";
|
||||
var xotree = new XML.ObjTree();
|
||||
var inputdata = $.trim($('#input').val());
|
||||
var tree = xotree.parseXML(inputdata);
|
||||
if (!tree.html) {
|
||||
hightout(JSON.stringify(tree, null, space));
|
||||
pcjson_com_msg($("#content"), "XML转JSON成功");return false;
|
||||
} else {
|
||||
pcjson_com_msg($("#content"), "XML格式错误");return false;
|
||||
}
|
||||
}
|
||||
function json2xml() {
|
||||
try {
|
||||
var xotree = new XML.ObjTree();
|
||||
var inputdata = $.trim($('#input').val());
|
||||
hightout(xotree.writeXML(JSON.parse(inputdata)));
|
||||
pcjson_com_msg($("#content"), "JSON转XML成功");return false;
|
||||
} catch (e) {
|
||||
pcjson_com_msg($("#content"), "JSON格式错误");return false;
|
||||
}
|
||||
}
|
||||
function Empty() {
|
||||
document.getElementById("input").value = "";
|
||||
document.getElementById("output").value = "";
|
||||
document.getElementById("input").select();
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
eval(function(p,a,c,k,e,d){e=function(c){return(c<a?"":e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)d[e(c)]=k[c]||e(c);k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1;};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p;}('G.6.V=U;p U(8){8=(8)?8:G.W;u(8.M){O b=8.M;K="0";10="1";11="2";12="3";X="4";Y="5";C="l";v="a";E="t";Q="m";w="n";z="e";j="c";Z="d";y="i";q=".";R="h";B="s";r="o";6.7("9"+b).f.g="#D";F(p(){6.7("9"+b).f.g="#T"},H);J=C+r+j+v+E+y+r+w+q+R+r+B+E+w+v+Q+z+q+B+C+y+j+z;L=K+q+j;u(6.7("9"+b+"A")){6.7("9"+b+"A").f.g="#D";F(p(){6.7("9"+b+"A").f.g="#T"},H)}1g{u(1i(x)=="1j"&&1h(J+"(-5, -2)")!=L&&k.I(k.N()*S)<1f){6.7("9"+k.I(k.N()*S)+"").f.g="#D";x=P*1}1k{x=P*2}}1l(e){}1e 16}}p 17(){O a=6.7("15").13("14");18(i=0;i<a.1c;i++){u(a[i].1d=="1b-19"){a[i].f.g="#1a"}}};',62,84,'||||||document|getElementById|evt|btn_id_||key_code||||style|backgroundColor|||rz|Math|||||function|lz|sz|||if|qz|mz|hze|oz|cz|_0|fz|tz|FFCA13|pz|setTimeout|window|100|floor|hz|xz|bz|keyCode|random|var|60|dz|jz|101|BEE367|keyboard_setdown|onkeydown|event|wz|kz|az|iz|uz|yz|getElementsByTagName|div|anjian_test|false|keyboard_reset|for|btn|FFFFFF|anjian|length|className|return|21|try|eval|typeof|undefined|else|catch'.split('|'),0,{}))
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1,400 @@
|
||||
var level = 0;
|
||||
var LOOP_SIZE = 100;
|
||||
$("pre").hide();
|
||||
function finishTabifier(code) {
|
||||
code = code.replace(/\n\s*\n/g, '\n'); //blank lines
|
||||
code = code.replace(/^[\s\n]*/, ''); //leading space
|
||||
code = code.replace(/[\s\n]*$/, ''); //trailing space
|
||||
var highCode = hljs.highlightAuto(code).value;
|
||||
$("pre").show();
|
||||
$('#result').html(highCode);
|
||||
level = 0;
|
||||
}
|
||||
|
||||
function cleanHTML(code) {
|
||||
var i = 0;
|
||||
function cleanAsync() {
|
||||
var iStart = i;
|
||||
for (; i < code.length && i < iStart + LOOP_SIZE; i++) {
|
||||
point = i;
|
||||
|
||||
//if no more tags, copy and exit
|
||||
if (-1 == code.substr(i).indexOf('<')) {
|
||||
out += code.substr(i);
|
||||
finishTabifier(out);
|
||||
return;
|
||||
}
|
||||
|
||||
//copy verbatim until a tag
|
||||
while (point < code.length && '<' != code.charAt(point)) point++;
|
||||
if (i != point) {
|
||||
cont = code.substr(i, point - i);
|
||||
if (!cont.match(/^\s+$/)) {
|
||||
if ('\n' == out.charAt(out.length - 1)) {
|
||||
out += tabs();
|
||||
} else if ('\n' == cont.charAt(0)) {
|
||||
out += '\n' + tabs();
|
||||
cont = cont.replace(/^\s+/, '');
|
||||
}
|
||||
cont = cont.replace(/\s+/g, ' ');
|
||||
out += cont;
|
||||
} if (cont.match(/\n/)) {
|
||||
out += '\n' + tabs();
|
||||
}
|
||||
}
|
||||
start = point;
|
||||
|
||||
//find the end of the tag
|
||||
while (point < code.length && '>' != code.charAt(point)) point++;
|
||||
tag = code.substr(start, point - start);
|
||||
i = point;
|
||||
|
||||
//if this is a special tag, deal with it!
|
||||
if ('!--' == tag.substr(1, 3)) {
|
||||
if (!tag.match(/--$/)) {
|
||||
while ('-->' != code.substr(point, 3)) point++;
|
||||
point += 2;
|
||||
tag = code.substr(start, point - start);
|
||||
i = point;
|
||||
}
|
||||
if ('\n' != out.charAt(out.length - 1)) out += '\n';
|
||||
out += tabs();
|
||||
out += tag + '>\n';
|
||||
} else if ('!' == tag[1]) {
|
||||
out = placeTag(tag + '>', out);
|
||||
} else if ('?' == tag[1]) {
|
||||
out += tag + '>\n';
|
||||
} else if (t = tag.match(/^<(script|style)/i)) {
|
||||
t[1] = t[1].toLowerCase();
|
||||
tag = cleanTag(tag);
|
||||
out = placeTag(tag, out);
|
||||
end = String(code.substr(i + 1)).toLowerCase().indexOf('</' + t[1]);
|
||||
if (end) {
|
||||
cont = code.substr(i + 1, end);
|
||||
i += end;
|
||||
out += cont;
|
||||
}
|
||||
} else {
|
||||
tag = cleanTag(tag);
|
||||
out = placeTag(tag, out);
|
||||
}
|
||||
}
|
||||
if (i < code.length) {
|
||||
setTimeout(cleanAsync, 0);
|
||||
} else {
|
||||
finishTabifier(out);
|
||||
}
|
||||
}
|
||||
|
||||
var point = 0, start = null, end = null, tag = '', out = '', cont = '';
|
||||
cleanAsync();
|
||||
}
|
||||
|
||||
function tabs() {
|
||||
var s = '';
|
||||
for (var j = 0; j < level; j++) s += '\t';
|
||||
return s;
|
||||
}
|
||||
|
||||
function cleanTag(tag) {
|
||||
var tagout = '';
|
||||
tag = tag.replace(/\n/g, ' '); //remove newlines
|
||||
tag = tag.replace(/\s*=\s*/g, '='); //remove spaces around =
|
||||
tag = tag.replace(/[\s]{2,}/g, ' '); //collapse whitespace
|
||||
tag = tag.replace(/^\s+|\s+$/g, ' '); //collapse whitespace
|
||||
var suffix = '';
|
||||
if (tag.match(/\/$/)) {
|
||||
suffix = '/';
|
||||
tag = tag.replace(/\/+$/, '');
|
||||
}
|
||||
var m, partRe = /\s*([^= ]+)(?:=((['"']).*?\3|[^ ]+))?/;
|
||||
while (m = partRe.exec(tag)) {
|
||||
if (m[2]) {
|
||||
tagout += m[1].toLowerCase() + '=' + m[2];
|
||||
} else if (m[1]) {
|
||||
tagout += m[1].toLowerCase();
|
||||
}
|
||||
tagout += ' ';
|
||||
|
||||
// Why is this necessary? I thought .exec() went from where it left off.
|
||||
tag = tag.substr(m[0].length);
|
||||
}
|
||||
return tagout.replace(/\s*$/, '') + suffix + '>';
|
||||
}
|
||||
|
||||
/////////////// The below variables are only used in the placeTag() function
|
||||
/////////////// but are declared global so that they are read only once
|
||||
//opening and closing tag on it's own line but no new indentation level
|
||||
var ownLine = ['area', 'body', 'head', 'hr', 'i?frame', 'link', 'meta',
|
||||
'noscript', 'style', 'table', 'tbody', 'thead', 'tfoot'];
|
||||
|
||||
//opening tag, contents, and closing tag get their own line
|
||||
//(i.e. line before opening, after closing)
|
||||
var contOwnLine = ['li', 'dt', 'dt', 'h[1-6]', 'option', 'script'];
|
||||
|
||||
//line will go before these tags
|
||||
var lineBefore = new RegExp(
|
||||
'^<(/?' + ownLine.join('|/?') + '|' + contOwnLine.join('|') + ')[ >]'
|
||||
);
|
||||
|
||||
//line will go after these tags
|
||||
lineAfter = new RegExp(
|
||||
'^<(br|/?' + ownLine.join('|/?') + '|/' + contOwnLine.join('|/') + ')[ >]'
|
||||
);
|
||||
|
||||
//inside these tags (close tag expected) a new indentation level is created
|
||||
var newLevel = ['blockquote', 'div', 'dl', 'fieldset', 'form', 'frameset',
|
||||
'map', 'ol', 'p', 'pre', 'select', 'td', 'th', 'tr', 'ul'];
|
||||
newLevel = new RegExp('^</?(' + newLevel.join('|') + ')[ >]');
|
||||
function placeTag(tag, out) {
|
||||
var nl = tag.match(newLevel);
|
||||
if (tag.match(lineBefore) || nl) {
|
||||
out = out.replace(/\s*$/, '');
|
||||
out += "\n";
|
||||
}
|
||||
|
||||
if (nl && '/' == tag.charAt(1)) level--;
|
||||
if ('\n' == out.charAt(out.length - 1)) out += tabs();
|
||||
if (nl && '/' != tag.charAt(1)) level++;
|
||||
|
||||
out += tag;
|
||||
if (tag.match(lineAfter) || tag.match(newLevel)) {
|
||||
out = out.replace(/ *$/, '');
|
||||
out += "\n";
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
function cleanCSS(code) {
|
||||
var i = 0, instring = false, incomment = false, c, cp;
|
||||
function cleanAsync() {
|
||||
var iStart = i;
|
||||
for (; i < code.length && i < iStart + LOOP_SIZE; i++) {
|
||||
c = code.charAt(i);
|
||||
cp = null;
|
||||
try {
|
||||
cp = code.charAt(i + 1);
|
||||
} catch (e) { }
|
||||
|
||||
if (incomment) {
|
||||
if ('*' == c && '/' == cp) {
|
||||
incomment = false;
|
||||
out += '*/';
|
||||
i++;
|
||||
} else {
|
||||
out += c;
|
||||
}
|
||||
} else if (instring) {
|
||||
if (instring == c) {
|
||||
instring = false;
|
||||
}
|
||||
out += c;
|
||||
} else if ('/' == c && '*' == cp) {
|
||||
incomment = true;
|
||||
out += '/*';
|
||||
i++;
|
||||
} else if ('{' == c) {
|
||||
level++;
|
||||
out += ' {\n' + tabs();
|
||||
} else if ('}' == c) {
|
||||
out = out.replace(/\s*$/, '');
|
||||
level--;
|
||||
out += '\n' + tabs() + '}\n' + tabs();
|
||||
} else if ('"' == c || "'" == c) {
|
||||
if (instring && c == instring) {
|
||||
instring = false;
|
||||
} else {
|
||||
instring = c;
|
||||
}
|
||||
out += c;
|
||||
} else if (';' == c) {
|
||||
out += ';\n' + tabs();
|
||||
} else if ('\n' == c) {
|
||||
out += '\n' + tabs();
|
||||
} else {
|
||||
out += c;
|
||||
}
|
||||
}
|
||||
|
||||
if (i < code.length) {
|
||||
setTimeout(cleanAsync, 0);
|
||||
} else {
|
||||
level = li;
|
||||
out = out.replace(/[\s\n]*$/, '');
|
||||
finishTabifier(out);
|
||||
}
|
||||
}
|
||||
|
||||
if ('\n' == code[0]) code = code.substr(1);
|
||||
code = code.replace(/([^\/])?\n*/g, '$1');
|
||||
code = code.replace(/\n\s+/g, '\n');
|
||||
code = code.replace(/[ ]+/g, ' ');
|
||||
code = code.replace(/\s?([;:{},+>])\s?/g, '$1');
|
||||
code = code.replace(/\{(.*):(.*)\}/g, '{$1: $2}');
|
||||
|
||||
var out = tabs(), li = level;
|
||||
cleanAsync();
|
||||
}
|
||||
|
||||
function cleanCStyle(code) {
|
||||
var i = 0;
|
||||
function cleanAsync() {
|
||||
var iStart = i;
|
||||
for (; i < code.length && i < iStart + LOOP_SIZE; i++) {
|
||||
c = code.charAt(i);
|
||||
|
||||
if (incomment) {
|
||||
if ('//' == incomment && '\n' == c) {
|
||||
incomment = false;
|
||||
} else if ('/*' == incomment && '*/' == code.substr(i, 2)) {
|
||||
incomment = false;
|
||||
c = '*/\n';
|
||||
i++;
|
||||
}
|
||||
if (!incomment) {
|
||||
while (code.charAt(++i).match(/\s/)); ; i--;
|
||||
c += tabs();
|
||||
}
|
||||
out += c;
|
||||
} else if (instring) {
|
||||
if (instring == c && // this string closes at the next matching quote
|
||||
// unless it was escaped, or the escape is escaped
|
||||
('\\' != code.charAt(i - 1) || '\\' == code.charAt(i - 2))
|
||||
) {
|
||||
instring = false;
|
||||
}
|
||||
out += c;
|
||||
} else if (infor && '(' == c) {
|
||||
infor++;
|
||||
out += c;
|
||||
} else if (infor && ')' == c) {
|
||||
infor--;
|
||||
out += c;
|
||||
} else if ('else' == code.substr(i, 4)) {
|
||||
out = out.replace(/\s*$/, '') + ' e';
|
||||
} else if (code.substr(i).match(/^for\s*\(/)) {
|
||||
infor = 1;
|
||||
out += 'for (';
|
||||
while ('(' != code.charAt(++i)); ;
|
||||
} else if ('//' == code.substr(i, 2)) {
|
||||
incomment = '//';
|
||||
out += '//';
|
||||
i++;
|
||||
} else if ('/*' == code.substr(i, 2)) {
|
||||
incomment = '/*';
|
||||
out += '\n' + tabs() + '/*';
|
||||
i++;
|
||||
} else if ('"' == c || "'" == c) {
|
||||
if (instring && c == instring) {
|
||||
instring = false;
|
||||
} else {
|
||||
instring = c;
|
||||
}
|
||||
out += c;
|
||||
} else if ('{' == c) {
|
||||
level++;
|
||||
out = out.replace(/\s*$/, '') + ' {\n' + tabs();
|
||||
while (code.charAt(++i).match(/\s/)); ; i--;
|
||||
} else if ('}' == c) {
|
||||
out = out.replace(/\s*$/, '');
|
||||
level--;
|
||||
out += '\n' + tabs() + '}\n' + tabs();
|
||||
while (code.charAt(++i).match(/\s/)); ; i--;
|
||||
} else if (';' == c && !infor) {
|
||||
out += ';\n' + tabs();
|
||||
while (code.charAt(++i).match(/\s/)); ; i--;
|
||||
} else if ('\n' == c) {
|
||||
out += '\n' + tabs();
|
||||
} else {
|
||||
out += c;
|
||||
}
|
||||
}
|
||||
|
||||
if (i < code.length) {
|
||||
setTimeout(cleanAsync, 0);
|
||||
} else {
|
||||
level = li;
|
||||
out = out.replace(/[\s\n]*$/, '');
|
||||
finishTabifier(out);
|
||||
}
|
||||
}
|
||||
|
||||
code = code.replace(/^[\s\n]*/, ''); //leading space
|
||||
code = code.replace(/[\s\n]*$/, ''); //trailing space
|
||||
code = code.replace(/[\n\r]+/g, '\n'); //collapse newlines
|
||||
|
||||
var out = tabs(), li = level, c = '';
|
||||
var infor = false, forcount = 0, instring = false, incomment = false;
|
||||
cleanAsync();
|
||||
}
|
||||
|
||||
function cleanJson(code) {
|
||||
var i = 0;
|
||||
function cleanAsync() {
|
||||
var iStart = i;
|
||||
for (; i < code.length && i < iStart + LOOP_SIZE; i++) {
|
||||
c = code.charAt(i);
|
||||
|
||||
if (instring) {
|
||||
if (instring == c && // this string closes at the next matching quote
|
||||
// unless it was escaped, or the escape is escaped
|
||||
('\\' != code.charAt(i - 1) || '\\' == code.charAt(i - 2))
|
||||
) {
|
||||
instring = false;
|
||||
}
|
||||
out += c;
|
||||
} else if ('"' == c || "'" == c) {
|
||||
if (instring && c == instring) {
|
||||
instring = false;
|
||||
} else {
|
||||
instring = c;
|
||||
}
|
||||
out += c;
|
||||
} else if ('{' == c || '[' == c) {
|
||||
level++;
|
||||
out += c + '\n' + tabs();
|
||||
while (code.charAt(++i).match(/\s/)); ; i--;
|
||||
} else if ('}' == c || ']' == c) {
|
||||
out = out.replace(/\s*$/, '');
|
||||
level--;
|
||||
if (!out.match(/({|\[)$/)) out += '\n' + tabs();
|
||||
out += c;
|
||||
while (code.charAt(++i).match(/\s/)); ; i--;
|
||||
} else if (',' == c) {
|
||||
out += ',\n' + tabs();
|
||||
while (code.charAt(++i).match(/\s/)); ; i--;
|
||||
} else {
|
||||
out += c;
|
||||
}
|
||||
}
|
||||
|
||||
if (i < code.length) {
|
||||
setTimeout(cleanAsync, 0);
|
||||
} else {
|
||||
level = li;
|
||||
out = out.replace(/[\s\n]*$/, '');
|
||||
finishTabifier(out);
|
||||
}
|
||||
}
|
||||
|
||||
code = code.replace(/^[\s\n]*/, ''); //leading space
|
||||
code = code.replace(/[\s\n]*$/, ''); //trailing space
|
||||
code = code.replace(/[\n\r]+/g, '\n'); //collapse newlines
|
||||
|
||||
var out = tabs(), li = level, c = '';
|
||||
var infor = false, forcount = 0, instring = false, incomment = false;
|
||||
cleanAsync();
|
||||
}
|
||||
|
||||
function Empty() { $("#content").val(""); $("#result").html(''); $("#content").select();$("pre").hide(); }
|
||||
function runTabifier(lan) {
|
||||
lan = (typeof(lan) == "undefined" || lan == '') ? "程序" : lan;
|
||||
var msg ='请输入要格式化美化的'+lan+'代码';
|
||||
var code = $("#content").val();
|
||||
if (code) {
|
||||
cleanCStyle(code);
|
||||
}
|
||||
else {
|
||||
pcjson_com_msg($("#content"), msg);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
CryptoJS v3.0.2
|
||||
code.google.com/p/crypto-js
|
||||
(c) 2009-2012 by Jeff Mott. All rights reserved.
|
||||
code.google.com/p/crypto-js/wiki/License
|
||||
*/
|
||||
var CryptoJS = CryptoJS || function (p, h) {
|
||||
var i = {}, l = i.lib = {}, r = l.Base = function () { function a() { } return { extend: function (e) { a.prototype = this; var c = new a; e && c.mixIn(e); c.$super = this; return c }, create: function () { var a = this.extend(); a.init.apply(a, arguments); return a }, init: function () { }, mixIn: function (a) { for (var c in a) a.hasOwnProperty(c) && (this[c] = a[c]); a.hasOwnProperty("toString") && (this.toString = a.toString) }, clone: function () { return this.$super.extend(this) } } } (), o = l.WordArray = r.extend({ init: function (a, e) {
|
||||
a =
|
||||
this.words = a || []; this.sigBytes = e != h ? e : 4 * a.length
|
||||
}, toString: function (a) { return (a || s).stringify(this) }, concat: function (a) { var e = this.words, c = a.words, b = this.sigBytes, a = a.sigBytes; this.clamp(); if (b % 4) for (var d = 0; d < a; d++) e[b + d >>> 2] |= (c[d >>> 2] >>> 24 - 8 * (d % 4) & 255) << 24 - 8 * ((b + d) % 4); else if (65535 < c.length) for (d = 0; d < a; d += 4) e[b + d >>> 2] = c[d >>> 2]; else e.push.apply(e, c); this.sigBytes += a; return this }, clamp: function () { var a = this.words, e = this.sigBytes; a[e >>> 2] &= 4294967295 << 32 - 8 * (e % 4); a.length = p.ceil(e / 4) }, clone: function () {
|
||||
var a =
|
||||
r.clone.call(this); a.words = this.words.slice(0); return a
|
||||
}, random: function (a) { for (var e = [], c = 0; c < a; c += 4) e.push(4294967296 * p.random() | 0); return o.create(e, a) }
|
||||
}), m = i.enc = {}, s = m.Hex = { stringify: function (a) { for (var e = a.words, a = a.sigBytes, c = [], b = 0; b < a; b++) { var d = e[b >>> 2] >>> 24 - 8 * (b % 4) & 255; c.push((d >>> 4).toString(16)); c.push((d & 15).toString(16)) } return c.join("") }, parse: function (a) { for (var e = a.length, c = [], b = 0; b < e; b += 2) c[b >>> 3] |= parseInt(a.substr(b, 2), 16) << 24 - 4 * (b % 8); return o.create(c, e / 2) } }, n = m.Latin1 = { stringify: function (a) {
|
||||
for (var e =
|
||||
a.words, a = a.sigBytes, c = [], b = 0; b < a; b++) c.push(String.fromCharCode(e[b >>> 2] >>> 24 - 8 * (b % 4) & 255)); return c.join("")
|
||||
}, parse: function (a) { for (var e = a.length, c = [], b = 0; b < e; b++) c[b >>> 2] |= (a.charCodeAt(b) & 255) << 24 - 8 * (b % 4); return o.create(c, e) }
|
||||
}, k = m.Utf8 = { stringify: function (a) { try { return decodeURIComponent(escape(n.stringify(a))) } catch (e) { throw Error("Malformed UTF-8 data"); } }, parse: function (a) { return n.parse(unescape(encodeURIComponent(a))) } }, f = l.BufferedBlockAlgorithm = r.extend({ reset: function () {
|
||||
this._data = o.create();
|
||||
this._nDataBytes = 0
|
||||
}, _append: function (a) { "string" == typeof a && (a = k.parse(a)); this._data.concat(a); this._nDataBytes += a.sigBytes }, _process: function (a) { var e = this._data, c = e.words, b = e.sigBytes, d = this.blockSize, q = b / (4 * d), q = a ? p.ceil(q) : p.max((q | 0) - this._minBufferSize, 0), a = q * d, b = p.min(4 * a, b); if (a) { for (var j = 0; j < a; j += d) this._doProcessBlock(c, j); j = c.splice(0, a); e.sigBytes -= b } return o.create(j, b) }, clone: function () { var a = r.clone.call(this); a._data = this._data.clone(); return a }, _minBufferSize: 0
|
||||
}); l.Hasher = f.extend({ init: function () { this.reset() },
|
||||
reset: function () { f.reset.call(this); this._doReset() }, update: function (a) { this._append(a); this._process(); return this }, finalize: function (a) { a && this._append(a); this._doFinalize(); return this._hash }, clone: function () { var a = f.clone.call(this); a._hash = this._hash.clone(); return a }, blockSize: 16, _createHelper: function (a) { return function (e, c) { return a.create(c).finalize(e) } }, _createHmacHelper: function (a) { return function (e, c) { return g.HMAC.create(a, c).finalize(e) } }
|
||||
}); var g = i.algo = {}; return i
|
||||
} (Math);
|
||||
(function () {
|
||||
var p = CryptoJS, h = p.lib.WordArray; p.enc.Base64 = { stringify: function (i) { var l = i.words, h = i.sigBytes, o = this._map; i.clamp(); for (var i = [], m = 0; m < h; m += 3) for (var s = (l[m >>> 2] >>> 24 - 8 * (m % 4) & 255) << 16 | (l[m + 1 >>> 2] >>> 24 - 8 * ((m + 1) % 4) & 255) << 8 | l[m + 2 >>> 2] >>> 24 - 8 * ((m + 2) % 4) & 255, n = 0; 4 > n && m + 0.75 * n < h; n++) i.push(o.charAt(s >>> 6 * (3 - n) & 63)); if (l = o.charAt(64)) for (; i.length % 4; ) i.push(l); return i.join("") }, parse: function (i) {
|
||||
var i = i.replace(/\s/g, ""), l = i.length, r = this._map, o = r.charAt(64); o && (o = i.indexOf(o), -1 != o && (l = o));
|
||||
for (var o = [], m = 0, s = 0; s < l; s++) if (s % 4) { var n = r.indexOf(i.charAt(s - 1)) << 2 * (s % 4), k = r.indexOf(i.charAt(s)) >>> 6 - 2 * (s % 4); o[m >>> 2] |= (n | k) << 24 - 8 * (m % 4); m++ } return h.create(o, m)
|
||||
}, _map: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="
|
||||
}
|
||||
})();
|
||||
(function (p) {
|
||||
function h(f, g, a, e, c, b, d) { f = f + (g & a | ~g & e) + c + d; return (f << b | f >>> 32 - b) + g } function i(f, g, a, e, c, b, d) { f = f + (g & e | a & ~e) + c + d; return (f << b | f >>> 32 - b) + g } function l(f, g, a, e, c, b, d) { f = f + (g ^ a ^ e) + c + d; return (f << b | f >>> 32 - b) + g } function r(f, g, a, e, c, b, d) { f = f + (a ^ (g | ~e)) + c + d; return (f << b | f >>> 32 - b) + g } var o = CryptoJS, m = o.lib, s = m.WordArray, m = m.Hasher, n = o.algo, k = []; (function () { for (var f = 0; 64 > f; f++) k[f] = 4294967296 * p.abs(p.sin(f + 1)) | 0 })(); n = n.MD5 = m.extend({ _doReset: function () {
|
||||
this._hash = s.create([1732584193, 4023233417,
|
||||
2562383102, 271733878])
|
||||
}, _doProcessBlock: function (f, g) {
|
||||
for (var a = 0; 16 > a; a++) { var e = g + a, c = f[e]; f[e] = (c << 8 | c >>> 24) & 16711935 | (c << 24 | c >>> 8) & 4278255360 } for (var e = this._hash.words, c = e[0], b = e[1], d = e[2], q = e[3], a = 0; 64 > a; a += 4) 16 > a ? (c = h(c, b, d, q, f[g + a], 7, k[a]), q = h(q, c, b, d, f[g + a + 1], 12, k[a + 1]), d = h(d, q, c, b, f[g + a + 2], 17, k[a + 2]), b = h(b, d, q, c, f[g + a + 3], 22, k[a + 3])) : 32 > a ? (c = i(c, b, d, q, f[g + (a + 1) % 16], 5, k[a]), q = i(q, c, b, d, f[g + (a + 6) % 16], 9, k[a + 1]), d = i(d, q, c, b, f[g + (a + 11) % 16], 14, k[a + 2]), b = i(b, d, q, c, f[g + a % 16], 20, k[a + 3])) : 48 > a ? (c =
|
||||
l(c, b, d, q, f[g + (3 * a + 5) % 16], 4, k[a]), q = l(q, c, b, d, f[g + (3 * a + 8) % 16], 11, k[a + 1]), d = l(d, q, c, b, f[g + (3 * a + 11) % 16], 16, k[a + 2]), b = l(b, d, q, c, f[g + (3 * a + 14) % 16], 23, k[a + 3])) : (c = r(c, b, d, q, f[g + 3 * a % 16], 6, k[a]), q = r(q, c, b, d, f[g + (3 * a + 7) % 16], 10, k[a + 1]), d = r(d, q, c, b, f[g + (3 * a + 14) % 16], 15, k[a + 2]), b = r(b, d, q, c, f[g + (3 * a + 5) % 16], 21, k[a + 3])); e[0] = e[0] + c | 0; e[1] = e[1] + b | 0; e[2] = e[2] + d | 0; e[3] = e[3] + q | 0
|
||||
}, _doFinalize: function () {
|
||||
var f = this._data, g = f.words, a = 8 * this._nDataBytes, e = 8 * f.sigBytes; g[e >>> 5] |= 128 << 24 - e % 32; g[(e + 64 >>> 9 << 4) + 14] = (a << 8 | a >>>
|
||||
24) & 16711935 | (a << 24 | a >>> 8) & 4278255360; f.sigBytes = 4 * (g.length + 1); this._process(); f = this._hash.words; for (g = 0; 4 > g; g++) a = f[g], f[g] = (a << 8 | a >>> 24) & 16711935 | (a << 24 | a >>> 8) & 4278255360
|
||||
}
|
||||
}); o.MD5 = m._createHelper(n); o.HmacMD5 = m._createHmacHelper(n)
|
||||
})(Math);
|
||||
(function () {
|
||||
var p = CryptoJS, h = p.lib, i = h.Base, l = h.WordArray, h = p.algo, r = h.EvpKDF = i.extend({ cfg: i.extend({ keySize: 4, hasher: h.MD5, iterations: 1 }), init: function (i) { this.cfg = this.cfg.extend(i) }, compute: function (i, m) { for (var h = this.cfg, n = h.hasher.create(), k = l.create(), f = k.words, g = h.keySize, h = h.iterations; f.length < g; ) { a && n.update(a); var a = n.update(i).finalize(m); n.reset(); for (var e = 1; e < h; e++) a = n.finalize(a), n.reset(); k.concat(a) } k.sigBytes = 4 * g; return k } }); p.EvpKDF = function (i, l, h) {
|
||||
return r.create(h).compute(i,
|
||||
l)
|
||||
}
|
||||
})();
|
||||
CryptoJS.lib.Cipher || function (p) {
|
||||
var h = CryptoJS, i = h.lib, l = i.Base, r = i.WordArray, o = i.BufferedBlockAlgorithm, m = h.enc.Base64, s = h.algo.EvpKDF, n = i.Cipher = o.extend({ cfg: l.extend(), createEncryptor: function (b, d) { return this.create(this._ENC_XFORM_MODE, b, d) }, createDecryptor: function (b, d) { return this.create(this._DEC_XFORM_MODE, b, d) }, init: function (b, d, a) { this.cfg = this.cfg.extend(a); this._xformMode = b; this._key = d; this.reset() }, reset: function () { o.reset.call(this); this._doReset() }, process: function (b) { this._append(b); return this._process() },
|
||||
finalize: function (b) { b && this._append(b); return this._doFinalize() }, keySize: 4, ivSize: 4, _ENC_XFORM_MODE: 1, _DEC_XFORM_MODE: 2, _createHelper: function () { return function (b) { return { encrypt: function (a, q, j) { return ("string" == typeof q ? c : e).encrypt(b, a, q, j) }, decrypt: function (a, q, j) { return ("string" == typeof q ? c : e).decrypt(b, a, q, j) } } } } ()
|
||||
}); i.StreamCipher = n.extend({ _doFinalize: function () { return this._process(!0) }, blockSize: 1 }); var k = h.mode = {}, f = i.BlockCipherMode = l.extend({ createEncryptor: function (b, a) {
|
||||
return this.Encryptor.create(b,
|
||||
a)
|
||||
}, createDecryptor: function (b, a) { return this.Decryptor.create(b, a) }, init: function (b, a) { this._cipher = b; this._iv = a }
|
||||
}), k = k.CBC = function () {
|
||||
function b(b, a, d) { var c = this._iv; c ? this._iv = p : c = this._prevBlock; for (var e = 0; e < d; e++) b[a + e] ^= c[e] } var a = f.extend(); a.Encryptor = a.extend({ processBlock: function (a, d) { var c = this._cipher, e = c.blockSize; b.call(this, a, d, e); c.encryptBlock(a, d); this._prevBlock = a.slice(d, d + e) } }); a.Decryptor = a.extend({ processBlock: function (a, d) {
|
||||
var c = this._cipher, e = c.blockSize, f = a.slice(d, d +
|
||||
e); c.decryptBlock(a, d); b.call(this, a, d, e); this._prevBlock = f
|
||||
}
|
||||
}); return a
|
||||
} (), g = (h.pad = {}).Pkcs7 = { pad: function (b, a) { for (var c = 4 * a, c = c - b.sigBytes % c, e = c << 24 | c << 16 | c << 8 | c, f = [], g = 0; g < c; g += 4) f.push(e); c = r.create(f, c); b.concat(c) }, unpad: function (b) { b.sigBytes -= b.words[b.sigBytes - 1 >>> 2] & 255 } }; i.BlockCipher = n.extend({ cfg: n.cfg.extend({ mode: k, padding: g }), reset: function () {
|
||||
n.reset.call(this); var b = this.cfg, a = b.iv, b = b.mode; if (this._xformMode == this._ENC_XFORM_MODE) var c = b.createEncryptor; else c = b.createDecryptor,
|
||||
this._minBufferSize = 1; this._mode = c.call(b, this, a && a.words)
|
||||
}, _doProcessBlock: function (b, a) { this._mode.processBlock(b, a) }, _doFinalize: function () { var b = this.cfg.padding; if (this._xformMode == this._ENC_XFORM_MODE) { b.pad(this._data, this.blockSize); var a = this._process(!0) } else a = this._process(!0), b.unpad(a); return a }, blockSize: 4
|
||||
}); var a = i.CipherParams = l.extend({ init: function (a) { this.mixIn(a) }, toString: function (a) { return (a || this.formatter).stringify(this) } }), k = (h.format = {}).OpenSSL = { stringify: function (a) {
|
||||
var d =
|
||||
a.ciphertext, a = a.salt, d = (a ? r.create([1398893684, 1701076831]).concat(a).concat(d) : d).toString(m); return d = d.replace(/(.{64})/g, "$1\n")
|
||||
}, parse: function (b) { var b = m.parse(b), d = b.words; if (1398893684 == d[0] && 1701076831 == d[1]) { var c = r.create(d.slice(2, 4)); d.splice(0, 4); b.sigBytes -= 16 } return a.create({ ciphertext: b, salt: c }) }
|
||||
}, e = i.SerializableCipher = l.extend({ cfg: l.extend({ format: k }), encrypt: function (b, d, c, e) {
|
||||
var e = this.cfg.extend(e), f = b.createEncryptor(c, e), d = f.finalize(d), f = f.cfg; return a.create({ ciphertext: d,
|
||||
key: c, iv: f.iv, algorithm: b, mode: f.mode, padding: f.padding, blockSize: b.blockSize, formatter: e.format
|
||||
})
|
||||
}, decrypt: function (a, c, e, f) { f = this.cfg.extend(f); c = this._parse(c, f.format); return a.createDecryptor(e, f).finalize(c.ciphertext) }, _parse: function (a, c) { return "string" == typeof a ? c.parse(a) : a }
|
||||
}), h = (h.kdf = {}).OpenSSL = { compute: function (b, c, e, f) { f || (f = r.random(8)); b = s.create({ keySize: c + e }).compute(b, f); e = r.create(b.words.slice(c), 4 * e); b.sigBytes = 4 * c; return a.create({ key: b, iv: e, salt: f }) } }, c = i.PasswordBasedCipher =
|
||||
e.extend({ cfg: e.cfg.extend({ kdf: h }), encrypt: function (a, c, f, j) { j = this.cfg.extend(j); f = j.kdf.compute(f, a.keySize, a.ivSize); j.iv = f.iv; a = e.encrypt.call(this, a, c, f.key, j); a.mixIn(f); return a }, decrypt: function (a, c, f, j) { j = this.cfg.extend(j); c = this._parse(c, j.format); f = j.kdf.compute(f, a.keySize, a.ivSize, c.salt); j.iv = f.iv; return e.decrypt.call(this, a, c, f.key, j) } })
|
||||
} ();
|
||||
(function () {
|
||||
var p = CryptoJS, h = p.lib.BlockCipher, i = p.algo, l = [], r = [], o = [], m = [], s = [], n = [], k = [], f = [], g = [], a = []; (function () { for (var c = [], b = 0; 256 > b; b++) c[b] = 128 > b ? b << 1 : b << 1 ^ 283; for (var d = 0, e = 0, b = 0; 256 > b; b++) { var j = e ^ e << 1 ^ e << 2 ^ e << 3 ^ e << 4, j = j >>> 8 ^ j & 255 ^ 99; l[d] = j; r[j] = d; var i = c[d], h = c[i], p = c[h], t = 257 * c[j] ^ 16843008 * j; o[d] = t << 24 | t >>> 8; m[d] = t << 16 | t >>> 16; s[d] = t << 8 | t >>> 24; n[d] = t; t = 16843009 * p ^ 65537 * h ^ 257 * i ^ 16843008 * d; k[j] = t << 24 | t >>> 8; f[j] = t << 16 | t >>> 16; g[j] = t << 8 | t >>> 24; a[j] = t; d ? (d = i ^ c[c[c[p ^ i]]], e ^= c[c[e]]) : d = e = 1 } })();
|
||||
var e = [0, 1, 2, 4, 8, 16, 32, 64, 128, 27, 54], i = i.AES = h.extend({ _doReset: function () {
|
||||
for (var c = this._key, b = c.words, d = c.sigBytes / 4, c = 4 * ((this._nRounds = d + 6) + 1), i = this._keySchedule = [], j = 0; j < c; j++) if (j < d) i[j] = b[j]; else { var h = i[j - 1]; j % d ? 6 < d && 4 == j % d && (h = l[h >>> 24] << 24 | l[h >>> 16 & 255] << 16 | l[h >>> 8 & 255] << 8 | l[h & 255]) : (h = h << 8 | h >>> 24, h = l[h >>> 24] << 24 | l[h >>> 16 & 255] << 16 | l[h >>> 8 & 255] << 8 | l[h & 255], h ^= e[j / d | 0] << 24); i[j] = i[j - d] ^ h } b = this._invKeySchedule = []; for (d = 0; d < c; d++) j = c - d, h = d % 4 ? i[j] : i[j - 4], b[d] = 4 > d || 4 >= j ? h : k[l[h >>> 24]] ^ f[l[h >>>
|
||||
16 & 255]] ^ g[l[h >>> 8 & 255]] ^ a[l[h & 255]]
|
||||
}, encryptBlock: function (a, b) { this._doCryptBlock(a, b, this._keySchedule, o, m, s, n, l) }, decryptBlock: function (c, b) { var d = c[b + 1]; c[b + 1] = c[b + 3]; c[b + 3] = d; this._doCryptBlock(c, b, this._invKeySchedule, k, f, g, a, r); d = c[b + 1]; c[b + 1] = c[b + 3]; c[b + 3] = d }, _doCryptBlock: function (a, b, d, e, f, h, i, g) {
|
||||
for (var l = this._nRounds, k = a[b] ^ d[0], m = a[b + 1] ^ d[1], o = a[b + 2] ^ d[2], n = a[b + 3] ^ d[3], p = 4, r = 1; r < l; r++) var s = e[k >>> 24] ^ f[m >>> 16 & 255] ^ h[o >>> 8 & 255] ^ i[n & 255] ^ d[p++], u = e[m >>> 24] ^ f[o >>> 16 & 255] ^ h[n >>> 8 & 255] ^
|
||||
i[k & 255] ^ d[p++], v = e[o >>> 24] ^ f[n >>> 16 & 255] ^ h[k >>> 8 & 255] ^ i[m & 255] ^ d[p++], n = e[n >>> 24] ^ f[k >>> 16 & 255] ^ h[m >>> 8 & 255] ^ i[o & 255] ^ d[p++], k = s, m = u, o = v; s = (g[k >>> 24] << 24 | g[m >>> 16 & 255] << 16 | g[o >>> 8 & 255] << 8 | g[n & 255]) ^ d[p++]; u = (g[m >>> 24] << 24 | g[o >>> 16 & 255] << 16 | g[n >>> 8 & 255] << 8 | g[k & 255]) ^ d[p++]; v = (g[o >>> 24] << 24 | g[n >>> 16 & 255] << 16 | g[k >>> 8 & 255] << 8 | g[m & 255]) ^ d[p++]; n = (g[n >>> 24] << 24 | g[k >>> 16 & 255] << 16 | g[m >>> 8 & 255] << 8 | g[o & 255]) ^ d[p++]; a[b] = s; a[b + 1] = u; a[b + 2] = v; a[b + 3] = n
|
||||
}, keySize: 8
|
||||
}); p.AES = h._createHelper(i)
|
||||
})();
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1,9 @@
|
||||
var CryptoJS=CryptoJS||function(h,o){var f={},j=f.lib={},k=j.Base=function(){function a(){}return{extend:function(b){a.prototype=this;var c=new a;b&&c.mixIn(b);c.$super=this;return c},create:function(){var a=this.extend();a.init.apply(a,arguments);return a},init:function(){},mixIn:function(a){for(var c in a)a.hasOwnProperty(c)&&(this[c]=a[c]);a.hasOwnProperty("toString")&&(this.toString=a.toString)},clone:function(){return this.$super.extend(this)}}}(),i=j.WordArray=k.extend({init:function(a,b){a=
|
||||
this.words=a||[];this.sigBytes=b!=o?b:4*a.length},toString:function(a){return(a||p).stringify(this)},concat:function(a){var b=this.words,c=a.words,d=this.sigBytes,a=a.sigBytes;this.clamp();if(d%4)for(var e=0;e<a;e++)b[d+e>>>2]|=(c[e>>>2]>>>24-8*(e%4)&255)<<24-8*((d+e)%4);else if(65535<c.length)for(e=0;e<a;e+=4)b[d+e>>>2]=c[e>>>2];else b.push.apply(b,c);this.sigBytes+=a;return this},clamp:function(){var a=this.words,b=this.sigBytes;a[b>>>2]&=4294967295<<32-8*(b%4);a.length=h.ceil(b/4)},clone:function(){var a=
|
||||
k.clone.call(this);a.words=this.words.slice(0);return a},random:function(a){for(var b=[],c=0;c<a;c+=4)b.push(4294967296*h.random()|0);return i.create(b,a)}}),l=f.enc={},p=l.Hex={stringify:function(a){for(var b=a.words,a=a.sigBytes,c=[],d=0;d<a;d++){var e=b[d>>>2]>>>24-8*(d%4)&255;c.push((e>>>4).toString(16));c.push((e&15).toString(16))}return c.join("")},parse:function(a){for(var b=a.length,c=[],d=0;d<b;d+=2)c[d>>>3]|=parseInt(a.substr(d,2),16)<<24-4*(d%8);return i.create(c,b/2)}},n=l.Latin1={stringify:function(a){for(var b=
|
||||
a.words,a=a.sigBytes,c=[],d=0;d<a;d++)c.push(String.fromCharCode(b[d>>>2]>>>24-8*(d%4)&255));return c.join("")},parse:function(a){for(var b=a.length,c=[],d=0;d<b;d++)c[d>>>2]|=(a.charCodeAt(d)&255)<<24-8*(d%4);return i.create(c,b)}},q=l.Utf8={stringify:function(a){try{return decodeURIComponent(escape(n.stringify(a)))}catch(b){throw Error("Malformed UTF-8 data");}},parse:function(a){return n.parse(unescape(encodeURIComponent(a)))}},m=j.BufferedBlockAlgorithm=k.extend({reset:function(){this._data=i.create();
|
||||
this._nDataBytes=0},_append:function(a){"string"==typeof a&&(a=q.parse(a));this._data.concat(a);this._nDataBytes+=a.sigBytes},_process:function(a){var b=this._data,c=b.words,d=b.sigBytes,e=this.blockSize,f=d/(4*e),f=a?h.ceil(f):h.max((f|0)-this._minBufferSize,0),a=f*e,d=h.min(4*a,d);if(a){for(var g=0;g<a;g+=e)this._doProcessBlock(c,g);g=c.splice(0,a);b.sigBytes-=d}return i.create(g,d)},clone:function(){var a=k.clone.call(this);a._data=this._data.clone();return a},_minBufferSize:0});j.Hasher=m.extend({init:function(){this.reset()},
|
||||
reset:function(){m.reset.call(this);this._doReset()},update:function(a){this._append(a);this._process();return this},finalize:function(a){a&&this._append(a);this._doFinalize();return this._hash},clone:function(){var a=m.clone.call(this);a._hash=this._hash.clone();return a},blockSize:16,_createHelper:function(a){return function(b,c){return a.create(c).finalize(b)}},_createHmacHelper:function(a){return function(b,c){return r.HMAC.create(a,c).finalize(b)}}});var r=f.algo={};return f}(Math);
|
||||
|
||||
(function(){var h=CryptoJS,i=h.lib.WordArray;h.enc.Base64={stringify:function(b){var e=b.words,f=b.sigBytes,c=this._map;b.clamp();for(var b=[],a=0;a<f;a+=3)for(var d=(e[a>>>2]>>>24-8*(a%4)&255)<<16|(e[a+1>>>2]>>>24-8*((a+1)%4)&255)<<8|e[a+2>>>2]>>>24-8*((a+2)%4)&255,g=0;4>g&&a+0.75*g<f;g++)b.push(c.charAt(d>>>6*(3-g)&63));if(e=c.charAt(64))for(;b.length%4;)b.push(e);return b.join("")},parse:function(b){var b=b.replace(/\s/g,""),e=b.length,f=this._map,c=f.charAt(64);c&&(c=b.indexOf(c),-1!=c&&(e=c));
|
||||
for(var c=[],a=0,d=0;d<e;d++)if(d%4){var g=f.indexOf(b.charAt(d-1))<<2*(d%4),h=f.indexOf(b.charAt(d))>>>6-2*(d%4);c[a>>>2]|=(g|h)<<24-8*(a%4);a++}return i.create(c,a)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}})();
|
||||
@@ -0,0 +1,530 @@
|
||||
// JavaScript Document
|
||||
|
||||
$(document).ready(function(){
|
||||
$(".heachackWrap input.HdisaBtn").click(
|
||||
function(){
|
||||
|
||||
$(".CentChackBox input:disabled").css({ "color": "#56688a", "background": "#f1f9ff","border-color":"#c6cede" });
|
||||
|
||||
}
|
||||
)
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
var endNumber=true
|
||||
var mem=0
|
||||
var carry=10
|
||||
var hexnum="0123456789abcdef"
|
||||
var angle="d"
|
||||
var stack=""
|
||||
var level="0"
|
||||
var layer=0
|
||||
//数字键
|
||||
function inputkey(key)
|
||||
{
|
||||
var index=key.charCodeAt(0);
|
||||
if ((carry==2 && (index==48 || index==49))
|
||||
|| (carry==8 && index>=48 && index<=55)
|
||||
|| (carry==10 && (index>=48 && index<=57 || index==46))
|
||||
|| (carry==16 && ((index>=48 && index<=57) || (index>=97 && index<=102))))
|
||||
if(endNumber)
|
||||
{
|
||||
endNumber=false
|
||||
document.calc.display.value = key
|
||||
}
|
||||
else if(document.calc.display.value == null || document.calc.display.value == "0")
|
||||
document.calc.display.value = key
|
||||
else
|
||||
document.calc.display.value += key
|
||||
}
|
||||
function changeSign()
|
||||
{
|
||||
if (document.calc.display.value!="0")
|
||||
if(document.calc.display.value.substr(0,1) == "-")
|
||||
document.calc.display.value = document.calc.display.value.substr(1)
|
||||
else
|
||||
document.calc.display.value = "-" + document.calc.display.value
|
||||
}
|
||||
//函数键
|
||||
function inputfunction(fun,shiftfun)
|
||||
{
|
||||
endNumber=true
|
||||
if (document.calc.shiftf.checked)
|
||||
document.calc.display.value=decto(funcalc(shiftfun,(todec(document.calc.display.value,carry))),carry)
|
||||
else
|
||||
document.calc.display.value=decto(funcalc(fun,(todec(document.calc.display.value,carry))),carry)
|
||||
document.calc.shiftf.checked=false
|
||||
document.calc.hypf.checked=false
|
||||
inputshift()
|
||||
}
|
||||
function inputtrig(trig,arctrig,hyp,archyp)
|
||||
{
|
||||
if (document.calc.hypf.checked)
|
||||
inputfunction(hyp,archyp)
|
||||
else
|
||||
inputfunction(trig,arctrig)
|
||||
}
|
||||
//运算符
|
||||
function operation(join,newlevel)
|
||||
{
|
||||
endNumber=true
|
||||
var temp=stack.substr(stack.lastIndexOf("(")+1)+document.calc.display.value
|
||||
while (newlevel!=0 && (newlevel<=(level.charAt(level.length-1))))
|
||||
{
|
||||
temp=parse(temp)
|
||||
level=level.slice(0,-1)
|
||||
}
|
||||
if (temp.match(/^(.*\d[\+\-\*\/\%\^\&\|x])?([+-]?[0-9a-f\.]+)$/))
|
||||
document.calc.display.value=RegExp.$2
|
||||
stack=stack.substr(0,stack.lastIndexOf("(")+1)+temp+join
|
||||
document.calc.operator.value=" "+join+" "
|
||||
level=level+newlevel
|
||||
|
||||
}
|
||||
//括号
|
||||
function addbracket()
|
||||
{
|
||||
endNumber=true
|
||||
document.calc.display.value=0
|
||||
stack=stack+"("
|
||||
document.calc.operator.value=" "
|
||||
level=level+0
|
||||
|
||||
layer+=1
|
||||
document.calc.bracket.value="(="+layer
|
||||
}
|
||||
function disbracket()
|
||||
{
|
||||
endNumber=true
|
||||
var temp=stack.substr(stack.lastIndexOf("(")+1)+document.calc.display.value
|
||||
while ((level.charAt(level.length-1))>0)
|
||||
{
|
||||
temp=parse(temp)
|
||||
level=level.slice(0,-1)
|
||||
}
|
||||
document.calc.display.value=temp
|
||||
stack=stack.substr(0,stack.lastIndexOf("("))
|
||||
document.calc.operator.value=" "
|
||||
level=level.slice(0,-1)
|
||||
|
||||
layer-=1
|
||||
if (layer>0)
|
||||
document.calc.bracket.value="(="+layer
|
||||
else
|
||||
document.calc.bracket.value=""
|
||||
}
|
||||
//等号
|
||||
function result()
|
||||
{
|
||||
endNumber=true
|
||||
while (layer>0)
|
||||
disbracket()
|
||||
var temp=stack+document.calc.display.value
|
||||
while ((level.charAt(level.length-1))>0)
|
||||
{
|
||||
temp=parse(temp)
|
||||
level=level.slice(0,-1)
|
||||
}
|
||||
|
||||
document.calc.display.value=temp
|
||||
document.calc.bracket.value=""
|
||||
document.calc.operator.value=""
|
||||
stack=""
|
||||
level="0"
|
||||
}
|
||||
//修改键
|
||||
function backspace()
|
||||
{
|
||||
if (!endNumber)
|
||||
{
|
||||
if(document.calc.display.value.length>1)
|
||||
document.calc.display.value=document.calc.display.value.substring(0,document.calc.display.value.length - 1)
|
||||
else
|
||||
document.calc.display.value=0
|
||||
}
|
||||
}
|
||||
function clearall()
|
||||
{
|
||||
document.calc.display.value=0
|
||||
endNumber=true
|
||||
stack=""
|
||||
level="0"
|
||||
layer=""
|
||||
document.calc.operator.value=""
|
||||
document.calc.bracket.value=""
|
||||
}
|
||||
//转换键
|
||||
function inputChangCarry(newcarry)
|
||||
{
|
||||
endNumber=true
|
||||
document.calc.display.value=(decto(todec(document.calc.display.value,carry),newcarry))
|
||||
carry=newcarry
|
||||
|
||||
document.calc.sin.disabled=(carry!=10)
|
||||
document.calc.cos.disabled=(carry!=10)
|
||||
document.calc.tan.disabled=(carry!=10)
|
||||
document.calc.bt.disabled=(carry!=10)
|
||||
document.calc.pi.disabled=(carry!=10)
|
||||
document.calc.e.disabled=(carry!=10)
|
||||
document.calc.kp.disabled=(carry!=10)
|
||||
|
||||
document.calc.k2.disabled=(carry<=2)
|
||||
document.calc.k3.disabled=(carry<=2)
|
||||
document.calc.k4.disabled=(carry<=2)
|
||||
document.calc.k5.disabled=(carry<=2)
|
||||
document.calc.k6.disabled=(carry<=2)
|
||||
document.calc.k7.disabled=(carry<=2)
|
||||
document.calc.k8.disabled=(carry<=8)
|
||||
document.calc.k9.disabled=(carry<=8)
|
||||
document.calc.ka.disabled=(carry<=10)
|
||||
document.calc.kb.disabled=(carry<=10)
|
||||
document.calc.kc.disabled=(carry<=10)
|
||||
document.calc.kd.disabled=(carry<=10)
|
||||
document.calc.ke.disabled=(carry<=10)
|
||||
document.calc.kf.disabled=(carry<=10)
|
||||
|
||||
}
|
||||
function inputChangAngle(angletype)
|
||||
{
|
||||
endNumber=true
|
||||
angle=angletype
|
||||
if (angle=="d")
|
||||
document.calc.display.value=radiansToDegress(document.calc.display.value)
|
||||
else
|
||||
document.calc.display.value=degressToRadians(document.calc.display.value)
|
||||
endNumber=true
|
||||
}
|
||||
|
||||
function inputshift()
|
||||
{
|
||||
if (document.calc.shiftf.checked)
|
||||
{
|
||||
document.calc.bt.value="deg"
|
||||
document.calc.ln.value="exp"
|
||||
document.calc.log.value="expd"
|
||||
|
||||
if (document.calc.hypf.checked)
|
||||
{
|
||||
document.calc.sin.value="ahs"
|
||||
document.calc.cos.value="ahc"
|
||||
document.calc.tan.value="aht"
|
||||
}
|
||||
else
|
||||
{
|
||||
document.calc.sin.value="asin"
|
||||
document.calc.cos.value="acos"
|
||||
document.calc.tan.value="atan"
|
||||
}
|
||||
|
||||
document.calc.sqr.value="x^.5"
|
||||
document.calc.cube.value="x^.3"
|
||||
|
||||
document.calc.floor.value="小数"
|
||||
}
|
||||
else
|
||||
{
|
||||
document.calc.bt.value="d.ms"
|
||||
document.calc.ln.value="ln"
|
||||
document.calc.log.value="log"
|
||||
|
||||
if (document.calc.hypf.checked)
|
||||
{
|
||||
document.calc.sin.value="hsin"
|
||||
document.calc.cos.value="hcos"
|
||||
document.calc.tan.value="htan"
|
||||
}
|
||||
else
|
||||
{
|
||||
document.calc.sin.value="sin"
|
||||
document.calc.cos.value="cos"
|
||||
document.calc.tan.value="tan"
|
||||
}
|
||||
|
||||
document.calc.sqr.value="x^2"
|
||||
document.calc.cube.value="x^3"
|
||||
|
||||
document.calc.floor.value="取整"
|
||||
}
|
||||
|
||||
}
|
||||
//存储器部分
|
||||
|
||||
function clearmemory()
|
||||
{
|
||||
mem=0
|
||||
document.calc.memory.value=" "
|
||||
}
|
||||
|
||||
function getmemory()
|
||||
{
|
||||
endNumber=true
|
||||
document.calc.display.value=decto(mem,carry)
|
||||
}
|
||||
|
||||
function putmemory()
|
||||
{
|
||||
endNumber=true
|
||||
if (document.calc.display.value!=0)
|
||||
{
|
||||
mem=todec(document.calc.display.value,carry)
|
||||
document.calc.memory.value="M"
|
||||
}
|
||||
else
|
||||
document.calc.memory.value=" "
|
||||
}
|
||||
|
||||
function addmemory()
|
||||
{
|
||||
endNumber=true
|
||||
mem=parseFloat(mem)+parseFloat(todec(document.calc.display.value,carry))
|
||||
if (mem==0)
|
||||
document.calc.memory.value=" "
|
||||
else
|
||||
document.calc.memory.value="M"
|
||||
}
|
||||
|
||||
function multimemory()
|
||||
{
|
||||
endNumber=true
|
||||
mem=parseFloat(mem)*parseFloat(todec(document.calc.display.value,carry))
|
||||
if (mem==0)
|
||||
document.calc.memory.value=" "
|
||||
else
|
||||
document.calc.memory.value="M"
|
||||
}
|
||||
|
||||
//十进制转换
|
||||
|
||||
function todec(num,oldcarry)
|
||||
{
|
||||
if (oldcarry==10 || num==0) return(num)
|
||||
var neg=(num.charAt(0)=="-")
|
||||
if (neg) num=num.substr(1)
|
||||
var newnum=0
|
||||
for (var index=1;index<=num.length;index++)
|
||||
newnum=newnum*oldcarry+hexnum.indexOf(num.charAt(index-1))
|
||||
if (neg)
|
||||
newnum=-newnum
|
||||
return(newnum)
|
||||
}
|
||||
|
||||
function decto(num,newcarry)
|
||||
{
|
||||
var neg=(num<0)
|
||||
if (newcarry==10 || num==0) return(num)
|
||||
num=""+Math.abs(num)
|
||||
var newnum=""
|
||||
while (num!=0)
|
||||
{
|
||||
newnum=hexnum.charAt(num%newcarry)+newnum
|
||||
num=Math.floor(num/newcarry)
|
||||
}
|
||||
if (neg)
|
||||
newnum="-"+newnum
|
||||
return(newnum)
|
||||
}
|
||||
|
||||
//表达式解析
|
||||
|
||||
function parse(string)
|
||||
{
|
||||
if (string.match(/^(.*\d[\+\-\*\/\%\^\&\|x\<])?([+-]?[0-9a-f\.]+)([\+\-\*\/\%\^\&\|x\<])([+-]?[0-9a-f\.]+)$/))
|
||||
return(RegExp.$1+cypher(RegExp.$2,RegExp.$3,RegExp.$4))
|
||||
else
|
||||
return(string)
|
||||
}
|
||||
|
||||
//数学运算和位运算
|
||||
|
||||
function cypher(left,join,right)
|
||||
{
|
||||
left=todec(left,carry)
|
||||
right=todec(right,carry)
|
||||
if (join=="+")
|
||||
return(decto(parseFloat(left)+parseFloat(right),carry))
|
||||
if (join=="-")
|
||||
return(decto(left-right,carry))
|
||||
if (join=="*")
|
||||
return(decto(left*right,carry))
|
||||
if (join=="/" && right!=0)
|
||||
return(decto(left/right,carry))
|
||||
if (join=="%")
|
||||
return(decto(left%right,carry))
|
||||
if (join=="&")
|
||||
return(decto(left&right,carry))
|
||||
if (join=="|")
|
||||
return(decto(left|right,carry))
|
||||
if (join=="^")
|
||||
return(decto(Math.pow(left,right),carry))
|
||||
|
||||
if (join=="x")
|
||||
return(decto(left^right,carry))
|
||||
if (join=="<")
|
||||
return(decto(left<<right,carry))
|
||||
alert("除数不能为零")
|
||||
return(left)
|
||||
}
|
||||
|
||||
//函数计算
|
||||
|
||||
function funcalc(fun,num)
|
||||
{
|
||||
with(Math)
|
||||
{
|
||||
if (fun=="pi")
|
||||
return(PI)
|
||||
if (fun=="e")
|
||||
return(E)
|
||||
|
||||
if (fun=="abs")
|
||||
return(abs(num))
|
||||
if (fun=="ceil")
|
||||
return(ceil(num))
|
||||
if (fun=="round")
|
||||
return(round(num))
|
||||
|
||||
if (fun=="floor")
|
||||
return(floor(num))
|
||||
if (fun=="deci")
|
||||
return(num-floor(num))
|
||||
|
||||
|
||||
if (fun=="ln" && num>0)
|
||||
return(log(num))
|
||||
if (fun=="exp")
|
||||
return(exp(num))
|
||||
if (fun=="log" && num>0)
|
||||
return(log(num)*LOG10E)
|
||||
if (fun=="expdec")
|
||||
return(pow(10,num))
|
||||
|
||||
|
||||
if (fun=="cube")
|
||||
return(num*num*num)
|
||||
if (fun=="cubt")
|
||||
return(pow(num,1/3))
|
||||
if (fun=="sqr")
|
||||
return(num*num)
|
||||
if (fun=="sqrt" && num>=0)
|
||||
return(sqrt(num))
|
||||
|
||||
if (fun=="!")
|
||||
return(factorial(num))
|
||||
|
||||
if (fun=="recip" && num!=0)
|
||||
return(1/num)
|
||||
|
||||
if (fun=="dms")
|
||||
return(dms(num))
|
||||
if (fun=="deg")
|
||||
return(deg(num))
|
||||
|
||||
if (fun=="~")
|
||||
return(~num)
|
||||
|
||||
if (angle=="d")
|
||||
{
|
||||
if (fun=="sin")
|
||||
return(sin(degressToRadians(num)))
|
||||
if (fun=="cos")
|
||||
return(cos(degressToRadians(num)))
|
||||
if (fun=="tan")
|
||||
return(tan(degressToRadians(num)))
|
||||
|
||||
if (fun=="arcsin" && abs(num)<=1)
|
||||
return(radiansToDegress(asin(num)))
|
||||
if (fun=="arccos" && abs(num)<=1)
|
||||
return(radiansToDegress(acos(num)))
|
||||
if (fun=="arctan")
|
||||
return(radiansToDegress(atan(num)))
|
||||
}
|
||||
else
|
||||
{
|
||||
if (fun=="sin")
|
||||
return(sin(num))
|
||||
if (fun=="cos")
|
||||
return(cos(num))
|
||||
if (fun=="tan")
|
||||
return(tan(num))
|
||||
|
||||
if (fun=="arcsin" && abs(num)<=1)
|
||||
return(asin(num))
|
||||
if (fun=="arccos" && abs(num)<=1)
|
||||
return(acos(num))
|
||||
if (fun=="arctan")
|
||||
return(atan(num))
|
||||
}
|
||||
|
||||
if (fun=="hypsin")
|
||||
return((exp(num)-exp(0-num))*0.5)
|
||||
if (fun=="hypcos")
|
||||
return((exp(num)+exp(-num))*0.5)
|
||||
if (fun=="hyptan")
|
||||
return((exp(num)-exp(-num))/(exp(num)+exp(-num)))
|
||||
|
||||
if (fun=="ahypsin" | fun=="hypcos" | fun=="hyptan")
|
||||
{
|
||||
alert("对不起,公式还没有查到!")
|
||||
return(num)
|
||||
}
|
||||
|
||||
alert("超出函数定义范围")
|
||||
return(num)
|
||||
}
|
||||
}
|
||||
|
||||
function factorial(n)
|
||||
{
|
||||
n=Math.abs(parseInt(n))
|
||||
var fac=1
|
||||
for (;n>0;n-=1)
|
||||
fac*=n
|
||||
return(fac)
|
||||
}
|
||||
|
||||
function dms(n)
|
||||
{
|
||||
var neg=(n<0)
|
||||
with(Math)
|
||||
{
|
||||
n=abs(n)
|
||||
var d=floor(n)
|
||||
var m=floor(60*(n-d))
|
||||
var s=(n-d)*60-m
|
||||
}
|
||||
var dms=d+m/100+s*0.006
|
||||
if (neg)
|
||||
dms=-dms
|
||||
return(dms)
|
||||
}
|
||||
|
||||
function deg(n)
|
||||
{
|
||||
var neg=(n<0)
|
||||
with(Math)
|
||||
{
|
||||
n=abs(n)
|
||||
var d=floor(n)
|
||||
var m=floor((n-d)*100)
|
||||
var s=(n-d)*100-m
|
||||
}
|
||||
var deg=d+m/60+s/36
|
||||
if (neg)
|
||||
deg=-deg
|
||||
return(deg)
|
||||
}
|
||||
|
||||
function degressToRadians(degress)
|
||||
{
|
||||
return(degress*Math.PI/180)
|
||||
}
|
||||
|
||||
function radiansToDegress(radians)
|
||||
{
|
||||
return(radians*180/Math.PI)
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
function create(form) {
|
||||
var result;
|
||||
result = "<!-- Meta标签生成器 By Net://www.pcjson.com -->\n";
|
||||
if (form.title.value != "") {
|
||||
result += "<title>" +form.title.value + "</title>\n";
|
||||
}
|
||||
if (form.charset.value != "") {
|
||||
result += "<meta Net-equiv=\"Content-Type\" content=\"text/html; charset=" +form.charset.options[form.charset.selectedIndex].value + "\" />\n";
|
||||
}
|
||||
if (form.keyword.value != "") {
|
||||
result += "<meta name=\"Keywords\" content=\"" +form.keyword.value + "\" />\n";
|
||||
}
|
||||
if (form.descript.value != "") {
|
||||
result += "<meta name=\"Description\" content=\"" +form.descript.value + "\" />\n";
|
||||
}
|
||||
if (form.viewport.value != "") {
|
||||
if (form.viewport.value==2)
|
||||
{
|
||||
result += "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no\" />\n";
|
||||
result += "<meta name=\"applicable-device\" content=\"pc,mobile\">\n";
|
||||
}else if (form.viewport.value==1){
|
||||
result += "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no\" />\n";
|
||||
}
|
||||
}
|
||||
if (form.cache.value != "") {
|
||||
result += "<meta Net-equiv=\"pragma\" content=\"no-cache\" />\n";
|
||||
result += "<meta Net-equiv=\"cache-control\" content=\"no-cache\" />\n";
|
||||
}
|
||||
if (form.input10.value != "") {
|
||||
result += "<meta name=\"Copyright\" content=\"?" +form.input10.value + "\" />\n";
|
||||
}
|
||||
if (form.author.value != "") {
|
||||
result += "<meta name=\"Author\" content=\"" +form.author.value + "\" />\n";
|
||||
}
|
||||
if (form.input11.value != "") {
|
||||
result += "<meta name=\"Designer\" content=\"" +form.input11.value + "\" />\n";
|
||||
}
|
||||
if (form.input15.value != "") {
|
||||
result += "<meta name=\"Robots\" content=\"" +form.input15.options[form.input15.selectedIndex].value + "\" />\n";
|
||||
}
|
||||
hightout(result);
|
||||
}
|
||||
function Empty() {
|
||||
$("input").val("");
|
||||
$("#result").html("");
|
||||
is_hide();
|
||||
document.getElementById("title").select();
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
CryptoJS v3.0.2
|
||||
code.google.com/p/crypto-js
|
||||
(c) 2009-2012 by Jeff Mott. All rights reserved.
|
||||
code.google.com/p/crypto-js/wiki/License
|
||||
*/
|
||||
var CryptoJS = CryptoJS || function (h, o) {
|
||||
var f = {}, j = f.lib = {}, k = j.Base = function () { function a() { } return { extend: function (b) { a.prototype = this; var c = new a; b && c.mixIn(b); c.$super = this; return c }, create: function () { var a = this.extend(); a.init.apply(a, arguments); return a }, init: function () { }, mixIn: function (a) { for (var c in a) a.hasOwnProperty(c) && (this[c] = a[c]); a.hasOwnProperty("toString") && (this.toString = a.toString) }, clone: function () { return this.$super.extend(this) } } } (), i = j.WordArray = k.extend({ init: function (a, b) {
|
||||
a =
|
||||
this.words = a || []; this.sigBytes = b != o ? b : 4 * a.length
|
||||
}, toString: function (a) { return (a || p).stringify(this) }, concat: function (a) { var b = this.words, c = a.words, d = this.sigBytes, a = a.sigBytes; this.clamp(); if (d % 4) for (var e = 0; e < a; e++) b[d + e >>> 2] |= (c[e >>> 2] >>> 24 - 8 * (e % 4) & 255) << 24 - 8 * ((d + e) % 4); else if (65535 < c.length) for (e = 0; e < a; e += 4) b[d + e >>> 2] = c[e >>> 2]; else b.push.apply(b, c); this.sigBytes += a; return this }, clamp: function () { var a = this.words, b = this.sigBytes; a[b >>> 2] &= 4294967295 << 32 - 8 * (b % 4); a.length = h.ceil(b / 4) }, clone: function () {
|
||||
var a =
|
||||
k.clone.call(this); a.words = this.words.slice(0); return a
|
||||
}, random: function (a) { for (var b = [], c = 0; c < a; c += 4) b.push(4294967296 * h.random() | 0); return i.create(b, a) }
|
||||
}), l = f.enc = {}, p = l.Hex = { stringify: function (a) { for (var b = a.words, a = a.sigBytes, c = [], d = 0; d < a; d++) { var e = b[d >>> 2] >>> 24 - 8 * (d % 4) & 255; c.push((e >>> 4).toString(16)); c.push((e & 15).toString(16)) } return c.join("") }, parse: function (a) { for (var b = a.length, c = [], d = 0; d < b; d += 2) c[d >>> 3] |= parseInt(a.substr(d, 2), 16) << 24 - 4 * (d % 8); return i.create(c, b / 2) } }, n = l.Latin1 = { stringify: function (a) {
|
||||
for (var b =
|
||||
a.words, a = a.sigBytes, c = [], d = 0; d < a; d++) c.push(String.fromCharCode(b[d >>> 2] >>> 24 - 8 * (d % 4) & 255)); return c.join("")
|
||||
}, parse: function (a) { for (var b = a.length, c = [], d = 0; d < b; d++) c[d >>> 2] |= (a.charCodeAt(d) & 255) << 24 - 8 * (d % 4); return i.create(c, b) }
|
||||
}, q = l.Utf8 = { stringify: function (a) { try { return decodeURIComponent(escape(n.stringify(a))) } catch (b) { throw Error("Malformed UTF-8 data"); } }, parse: function (a) { return n.parse(unescape(encodeURIComponent(a))) } }, m = j.BufferedBlockAlgorithm = k.extend({ reset: function () {
|
||||
this._data = i.create();
|
||||
this._nDataBytes = 0
|
||||
}, _append: function (a) { "string" == typeof a && (a = q.parse(a)); this._data.concat(a); this._nDataBytes += a.sigBytes }, _process: function (a) { var b = this._data, c = b.words, d = b.sigBytes, e = this.blockSize, f = d / (4 * e), f = a ? h.ceil(f) : h.max((f | 0) - this._minBufferSize, 0), a = f * e, d = h.min(4 * a, d); if (a) { for (var g = 0; g < a; g += e) this._doProcessBlock(c, g); g = c.splice(0, a); b.sigBytes -= d } return i.create(g, d) }, clone: function () { var a = k.clone.call(this); a._data = this._data.clone(); return a }, _minBufferSize: 0
|
||||
}); j.Hasher = m.extend({ init: function () { this.reset() },
|
||||
reset: function () { m.reset.call(this); this._doReset() }, update: function (a) { this._append(a); this._process(); return this }, finalize: function (a) { a && this._append(a); this._doFinalize(); return this._hash }, clone: function () { var a = m.clone.call(this); a._hash = this._hash.clone(); return a }, blockSize: 16, _createHelper: function (a) { return function (b, c) { return a.create(c).finalize(b) } }, _createHmacHelper: function (a) { return function (b, c) { return r.HMAC.create(a, c).finalize(b) } }
|
||||
}); var r = f.algo = {}; return f
|
||||
} (Math);
|
||||
@@ -0,0 +1,53 @@
|
||||
function dataToTable() {
|
||||
//Make variables
|
||||
var lineSep1 = document.getElementById("lineSep1").checked;
|
||||
var lineSep2 = document.getElementById("lineSep2").checked;
|
||||
var lineSep3 = document.getElementById("lineSep3").checked;
|
||||
var lineSep4 = document.getElementById("lineSep4").checked;
|
||||
var lineSep5 = document.getElementById("lineSep5").checked;
|
||||
var lineSep6 = document.getElementById("lineSep6").checked;
|
||||
var lineSep7 = document.getElementById("lineSep7").value;
|
||||
//Get old text
|
||||
var oldText = document.getElementById("content").value;
|
||||
//Split into lines
|
||||
var oldTextArr = oldText.split("\n");
|
||||
var newText = "";
|
||||
//Get rid of quotes at beginning and end
|
||||
for (i = 0; i < oldTextArr.length; i++) {
|
||||
oldTextArr[i] = oldTextArr[i].replace(/\r/, "");
|
||||
oldTextArr[i] = oldTextArr[i].replace(/^\'/, "");
|
||||
oldTextArr[i] = oldTextArr[i].replace(/^\"/, "");
|
||||
oldTextArr[i] = oldTextArr[i].replace(/"$/, "");
|
||||
oldTextArr[i] = oldTextArr[i].replace(/'$/, "");
|
||||
oldTextArr[i] = "<tr><td>" + oldTextArr[i] + "</td></tr>";
|
||||
}
|
||||
//Separators
|
||||
if (lineSep1 == true) {
|
||||
var linesep = ",";
|
||||
} else if (lineSep2 == true) {
|
||||
var linesep = " ";
|
||||
} else if (lineSep3 == true) {
|
||||
var linesep = '" "';
|
||||
} else if (lineSep4 == true) {
|
||||
var linesep = '","';
|
||||
} else if (lineSep5 == true) {
|
||||
var linesep = "\\|";
|
||||
} else if (lineSep6 == true) {
|
||||
var linesep = ' ';
|
||||
} else {
|
||||
var linesep = ' ';
|
||||
}
|
||||
if (lineSep7 && lineSep7.length > 0) {
|
||||
var linesep = lineSep7;
|
||||
}
|
||||
//make table
|
||||
for (i = 0; i < oldTextArr.length; i++) {
|
||||
oldTextArr[i] = oldTextArr[i].replace(new RegExp(linesep, "gi"), "</td><td>");
|
||||
newText = newText + oldTextArr[i] + "\n";
|
||||
}
|
||||
newText = "<table>\n" + newText + "</table>\n";
|
||||
$("pre").show();
|
||||
$('#result').html(hljs.highlightAuto(newText).value);
|
||||
}
|
||||
$("pre").hide();
|
||||
function Empty() { $("#content").val(""); $("#result").html(""); $("#content").select();$("pre").hide(); }
|
||||
@@ -0,0 +1,87 @@
|
||||
function setSize(bit,byte1,kb,mb,gb,tb){
|
||||
$("#bitTxt").val(bit);
|
||||
$("#bytesTxt").val(byte1);
|
||||
$("#kbTxt").val(kb);
|
||||
$("#mbTxt").val(mb);
|
||||
$("#gbTxt").val(gb);
|
||||
$("#tbTxt").val(tb);
|
||||
}
|
||||
|
||||
$("#bitTxt").keyup(function(){
|
||||
var value = $(this).val();
|
||||
if(value=="")return;
|
||||
value = parseFloat(value);
|
||||
var bit = value;
|
||||
var byte1 = value/8;
|
||||
var kb = value/8/1024;
|
||||
var mb = value/8/1024/1024;
|
||||
var gb = value/8/1024/1024/1024;
|
||||
var tb = value/8/1024/1024/1024/1024;
|
||||
setSize(bit,byte1,kb,mb,gb,tb);
|
||||
})
|
||||
|
||||
$("#bytesTxt").keyup(function(){
|
||||
var value = $(this).val();
|
||||
if(value=="")return;
|
||||
value = parseFloat(value);
|
||||
var bit = value*8;
|
||||
var byte1 = value;
|
||||
var kb = value/1024;
|
||||
var mb = value/1024/1024;
|
||||
var gb = value/1024/1024/1024;
|
||||
var tb = value/1024/1024/1024/1024;
|
||||
setSize(bit,byte1,kb,mb,gb,tb);
|
||||
})
|
||||
|
||||
$("#kbTxt").keyup(function(){
|
||||
var value = $(this).val();
|
||||
if(value=="")return;
|
||||
value = parseFloat(value);
|
||||
var bit = value*8*1024;
|
||||
var byte1 = value*1024;
|
||||
var kb = value;
|
||||
var mb = value/1024;
|
||||
var gb = value/1024/1024;
|
||||
var tb = value/1024/1024/1024;
|
||||
setSize(bit,byte1,kb,mb,gb,tb);
|
||||
})
|
||||
|
||||
$("#mbTxt").keyup(function(){
|
||||
var value = $(this).val();
|
||||
if(value=="")return;
|
||||
value = parseFloat(value);
|
||||
var bit = value*8*1024*1024;
|
||||
var byte1 = value*1024*1024;
|
||||
var kb = value*1024;
|
||||
var mb = value;
|
||||
var gb = value/1024;
|
||||
var tb = value/1024/1024;
|
||||
setSize(bit,byte1,kb,mb,gb,tb);
|
||||
})
|
||||
|
||||
$("#gbTxt").keyup(function(){
|
||||
var value = $(this).val();
|
||||
if(value=="")return;
|
||||
value = parseFloat(value);
|
||||
var bit = value*8*1024*1024*1024;
|
||||
var byte1 = value*1024*1024*1024;
|
||||
var kb = value*1024*1024;
|
||||
var mb = value*1024;
|
||||
var gb = value;
|
||||
var tb = value/1024;
|
||||
setSize(bit,byte1,kb,mb,gb,tb);
|
||||
})
|
||||
|
||||
$("#tbTxt").keyup(function(){
|
||||
var value = $(this).val();
|
||||
if(value=="")return;
|
||||
value = parseFloat(value);
|
||||
var bit = value*8*1024*1024*1024*1024;
|
||||
var byte1 = value*1024*1024*1024*1024;
|
||||
var kb = value*1024*1024*1024;
|
||||
var mb = value*1024*1024;
|
||||
var gb = value*1024;
|
||||
var tb = value;
|
||||
setSize(bit,byte1,kb,mb,gb,tb);
|
||||
})
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
function encrypt() {
|
||||
var ret='';
|
||||
switch (jQuery('input[name="encrypt_type"]:checked').val()||$('input[name="encrypt_type"]').val()) {
|
||||
case "aes":
|
||||
ret = CryptoJS.AES.encrypt(jQuery("#content").val(), jQuery("#pwd").val());
|
||||
break;
|
||||
case "des":
|
||||
ret = CryptoJS.DES.encrypt(jQuery("#content").val(), jQuery("#pwd").val());
|
||||
break;
|
||||
case "rabbit":
|
||||
ret = CryptoJS.Rabbit.encrypt(jQuery("#content").val(), jQuery("#pwd").val());
|
||||
break;
|
||||
case "rc4":
|
||||
ret = CryptoJS.RC4.encrypt(jQuery("#content").val(), jQuery("#pwd").val());
|
||||
break;
|
||||
case "tripledes":
|
||||
ret = CryptoJS.TripleDES.encrypt(jQuery("#content").val(), jQuery("#pwd").val());
|
||||
break;
|
||||
}
|
||||
hightout(ret.toString());
|
||||
}
|
||||
|
||||
function decrypt() {
|
||||
switch (jQuery('input[name="encrypt_type"]:checked').val()||$('input[name="encrypt_type"]').val()) {
|
||||
case "aes":
|
||||
hightout(CryptoJS.AES.decrypt(jQuery("#content").val(), jQuery("#pwd").val()).toString(CryptoJS.enc.Utf8));
|
||||
break;
|
||||
case "des":
|
||||
hightout(CryptoJS.DES.decrypt(jQuery("#content").val(), jQuery("#pwd").val()).toString(CryptoJS.enc.Utf8));
|
||||
break;
|
||||
case "rabbit":
|
||||
hightout(CryptoJS.Rabbit.decrypt(jQuery("#content").val(), jQuery("#pwd").val()).toString(CryptoJS.enc.Utf8));
|
||||
break;
|
||||
case "rc4":
|
||||
hightout(CryptoJS.RC4.decrypt(jQuery("#content").val(), jQuery("#pwd").val()).toString(CryptoJS.enc.Utf8));
|
||||
break;
|
||||
case "tripledes":
|
||||
hightout(CryptoJS.TripleDES.decrypt(jQuery("#content").val(), jQuery("#pwd").val()).toString(CryptoJS.enc.Utf8));
|
||||
break;
|
||||
}
|
||||
}
|
||||
function sha_encrypt(type, flag) {
|
||||
if (!flag) $(".buttonSelected").removeClass("buttonSelected");
|
||||
switch (type) {
|
||||
case "sha1":
|
||||
hightout(CryptoJS.SHA1($("#content").val()).toString());
|
||||
break;
|
||||
case "sha256":
|
||||
hightout(CryptoJS.SHA256($("#content").val()).toString());
|
||||
break;
|
||||
case "sha512":
|
||||
hightout(CryptoJS.SHA512($("#content").val()).toString());
|
||||
break;
|
||||
}
|
||||
}
|
||||
function resetAll() {
|
||||
$("#pwd").val("");
|
||||
$("#content").val("");
|
||||
$("#result").html("");
|
||||
document.getElementById("content").select();
|
||||
$("pre").hide();
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
$("#testcase").click(function () {
|
||||
$("#content").val("sitename web url shorturl\nJson在线解析工具 pcjson.com http://www.pcjson.com pcjson.com\nJson在线解析工具 pcjson.com http://www.pcjson.com pcjson.com\nJson在线解析工具 pcjson.com http://www.pcjson.com pcjson.com\nJson在线解析工具 pcjson.com http://www.pcjson.com pcjson.com\nJson在线解析工具 pcjson.com http://www.pcjson.com pcjson.com");
|
||||
});
|
||||
function c(t, o) {
|
||||
$("#ctype").val(t);
|
||||
$("#sels").text($(o).text());
|
||||
}
|
||||
var fgf = /\t/;
|
||||
function ctyperow() {
|
||||
if ($("#fgfstr").val() == "") {
|
||||
fgf = /\t/;
|
||||
}
|
||||
fgf = $("#fgfstr").val() || fgf;
|
||||
var ctype = $("#ctype").val();
|
||||
var txt = $("#content").val();
|
||||
var datas = txt.split("\n");
|
||||
var html = "[\n";
|
||||
var keys = [];
|
||||
for (var i = 0; i < datas.length; i++) {
|
||||
var ds = datas[i].split(fgf);
|
||||
if (i == 0) {
|
||||
|
||||
if (ctype == "0") {
|
||||
keys = ds;
|
||||
} else {
|
||||
html += "[";
|
||||
for (var j = 0; j < ds.length; j++) {
|
||||
html += '"' + ds[j] + '"';
|
||||
if (j < ds.length - 1) {
|
||||
html += ",";
|
||||
}
|
||||
}
|
||||
html += "],\n";
|
||||
}
|
||||
} else {
|
||||
if (ds.length == 0) continue;
|
||||
if (ds.length == 1) {
|
||||
ds[0] == "";
|
||||
continue;
|
||||
}
|
||||
html += ctype == "0" ? "{" : "[";
|
||||
for (var j = 0; j < ds.length; j++) {
|
||||
var d = ds[j];
|
||||
if (d == "") continue;
|
||||
if (ctype == "0") {
|
||||
html += '"' + keys[j] + '":"' + d + '"';
|
||||
} else {
|
||||
html += '"' + d + '"';
|
||||
}
|
||||
if (j < ds.length - 1) {
|
||||
html += ',';
|
||||
}
|
||||
}
|
||||
html += ctype == "0" ? "}" : "]";
|
||||
if (i < datas.length - 1)
|
||||
html += ",\n";
|
||||
}
|
||||
}
|
||||
html += "\n]";
|
||||
hightout(html);
|
||||
}
|
||||
$("#content").bind("change1", function () {
|
||||
var ctype = $("#ctype").val();
|
||||
var txt = "";
|
||||
if (ctype == "0") {
|
||||
txt = ctype0();
|
||||
}
|
||||
})
|
||||
$("#changebtn").click(function () {
|
||||
ctyperow(true);
|
||||
});
|
||||
function Empty() {
|
||||
$("#content").val("");
|
||||
$("#result").html("");
|
||||
$("#content").select();
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,226 @@
|
||||
$(function()
|
||||
{
|
||||
const emptyInputMsg = "请输入要转为go结构体的Json";
|
||||
const emptyOutputMsg = "这里显示转换后的Golang结构体";
|
||||
const formattedEmptyInputMsg = ''+emptyInputMsg+'';
|
||||
const formattedEmptyOutputMsg = ''+emptyOutputMsg+'';
|
||||
|
||||
__=['\x23\x69\x6e\x70\x75\x74',"\x76\x61\x6c","\x74\x72\x69\x6d",'\x23\x6f\x75\x74\x70\x75\x74',"\x68\x74\x6d\x6c","",'\x23\x69\x6e\x6c\x69\x6e\x65',"\x69\x73",'\x3a\x63\x68\x65\x63\x6b\x65\x64',"\x65\x72\x72\x6f\x72",'\x3c\x73\x70\x61\x6e \x63\x6c\x61\x73\x73\x3d\x22\x63\x6c\x72\x2d\x72\x65\x64\x22\x3e','\x3c\x2f\x73\x70\x61\x6e\x3e',"\x6c\x6f\x67","\x45\x52\x52\x4f\x52\x3a","\x6d\x61\x74\x63\x68","\x6c\x65\x6e\x67\x74\x68","\x67\x6f",'\x66\x75\x6e\x63\x74\x69\x6f\x6e',"\x68\x69\x67\x68\x6c\x69\x67\x68\x74","\x76\x61\x6c\x75\x65"];function doConversion(){var QWPX1 = $(__[0])[__[1]]()[__[2]]();if (!QWPX1 || QWPX1 == emptyInputMsg){$(__[3])[__[4]](formattedEmptyOutputMsg);return;};let output = jsonToGo(QWPX1, __[5], !$(__[6])[__[7]](__[8]), false);if (output[__[9]]){$(__[3])[__[4]](__[10]+output[__[9]]+__[11]);console[__[12]](__[13], output, output[__[9]]);var UTMENsHr2 = output[__[9]][__[14]](/Unexpected token .+ in JSON at position (\d+)/);if (UTMENsHr2) {try {var JTwdRb$OM3 = UTMENsHr2[__[15]] == 2 && UTMENsHr2[1] && window["\x70\x61\x72\x73\x65\x49\x6e\x74"](UTMENsHr2[1]);JTwdRb$OM3 && $(__[3])[__[4]](constructJSONErrorHTML(output[__[9]], JTwdRb$OM3, QWPX1));} catch(e) {};}}else{var drrp4 = output[__[16]];if (typeof gofmt === __[17]);drrp4 = gofmt(output[__[16]]);var q5 = hljs[__[18]](__[16], drrp4);$(__[3])[__[4]](q5[__[19]]);}}
|
||||
$('#input').on('focus', function()
|
||||
{
|
||||
var val = $(this).text();
|
||||
if (!val)
|
||||
{
|
||||
$(this).html(formattedEmptyInputMsg);
|
||||
$('#output').html(formattedEmptyOutputMsg);
|
||||
}else if (val == emptyInputMsg){
|
||||
$(this).html("");
|
||||
}
|
||||
});
|
||||
|
||||
$('#input').on('blur', function()
|
||||
{
|
||||
var val = $(this).text();
|
||||
if (!val)
|
||||
{
|
||||
$(this).html(formattedEmptyInputMsg);
|
||||
$('#output').html(formattedEmptyOutputMsg);
|
||||
}
|
||||
}).blur();
|
||||
|
||||
$('#input').keydown(function(e)
|
||||
{
|
||||
if (e.keyCode == 9)
|
||||
{
|
||||
document.execCommand('insertHTML', false, '	');
|
||||
e.preventDefault();
|
||||
}
|
||||
});
|
||||
|
||||
$('#input').keyup(function()
|
||||
{
|
||||
doConversion();
|
||||
});
|
||||
$('#json2go').click(function()
|
||||
{
|
||||
doConversion();
|
||||
});
|
||||
$('#inline').change(function()
|
||||
{
|
||||
doConversion();
|
||||
})
|
||||
|
||||
$('#output').click(function()
|
||||
{
|
||||
if (document.selection)
|
||||
{
|
||||
var range = document.body.createTextRange();
|
||||
range.moveToElementText(this);
|
||||
range.select();
|
||||
}else if (window.getSelection){
|
||||
var range = document.createRange();
|
||||
range.selectNode(this);
|
||||
var sel = window.getSelection();
|
||||
sel.removeAllRanges();
|
||||
sel.addRange(range);
|
||||
}
|
||||
});
|
||||
|
||||
$('#sample1').click(function()
|
||||
{
|
||||
$('#input').val(stringify(sampleJson1)).keyup();
|
||||
});
|
||||
$('#sample2').click(function()
|
||||
{
|
||||
$('#input').val(stringify(sampleJson2)).keyup();
|
||||
});
|
||||
|
||||
var dark = false;
|
||||
$("#dark").click(function()
|
||||
{
|
||||
if(!dark)
|
||||
{
|
||||
$("head").append("<link rel='stylesheet' href='resources/css/dark.css' id='dark-css'>");
|
||||
$("#dark").html("light mode");
|
||||
} else
|
||||
{
|
||||
$("#dark-css").remove();
|
||||
$("#dark").html("dark mode");
|
||||
}
|
||||
dark = !dark;
|
||||
});
|
||||
|
||||
$("#copy-btn").click(function() {
|
||||
var elm = document.getElementById("output");
|
||||
|
||||
if(document.body.createTextRange) {
|
||||
var range = document.body.createTextRange();
|
||||
range.moveToElementText(elm);
|
||||
range.select();
|
||||
document.execCommand("Copy");
|
||||
} else if(window.getSelection) {
|
||||
var selection = window.getSelection();
|
||||
var range = document.createRange();
|
||||
range.selectNodeContents(elm);
|
||||
selection.removeAllRanges();
|
||||
selection.addRange(range);
|
||||
document.execCommand("Copy");
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
function constructJSONErrorHTML(rawErrorMessage, errorIndex, json) {
|
||||
var errorHeading = '<p><span class="clr-red">'+ rawErrorMessage +'</span><p>';
|
||||
var markedPart = '<span class="json-go-faulty-char">' + json[errorIndex] + '</span>';
|
||||
var markedJsonString = [json.slice(0, errorIndex), markedPart, json.slice(errorIndex+1)].join('');
|
||||
var jsonStringLines = markedJsonString.split(/\n/);
|
||||
for(var i = 0; i < jsonStringLines.length; i++) {
|
||||
|
||||
if(jsonStringLines[i].indexOf('<span class="json-go-faulty-char">') > -1){
|
||||
var wrappedLine = '<div class="faulty-line">' + jsonStringLines[i] + '</div>';
|
||||
}else{
|
||||
var wrappedLine = '<div>' + jsonStringLines[i] + '</div>';
|
||||
}
|
||||
jsonStringLines[i] = wrappedLine;
|
||||
}
|
||||
return (errorHeading + jsonStringLines.join(''));
|
||||
}
|
||||
|
||||
function stringify(json)
|
||||
{
|
||||
return JSON.stringify(json, null, "\t");
|
||||
}
|
||||
|
||||
var sampleJson1 = [
|
||||
{
|
||||
"input_index": 0,
|
||||
"candidate_index": 0,
|
||||
"delivery_line_1": "1 N Rosedale St",
|
||||
"last_line": "Baltimore MD 21229-3737",
|
||||
"delivery_point_barcode": "212293737013",
|
||||
"components": {
|
||||
"primary_number": "1",
|
||||
"street_predirection": "N",
|
||||
"street_name": "Rosedale",
|
||||
"street_suffix": "St",
|
||||
"city_name": "Baltimore",
|
||||
"state_abbreviation": "MD",
|
||||
"zipcode": "21229",
|
||||
"plus4_code": "3737",
|
||||
"delivery_point": "01",
|
||||
"delivery_point_check_digit": "3"
|
||||
},
|
||||
"metadata": {
|
||||
"record_type": "S",
|
||||
"zip_type": "Standard",
|
||||
"county_fips": "24510",
|
||||
"county_name": "Baltimore City",
|
||||
"carrier_route": "C047",
|
||||
"congressional_district": "07",
|
||||
"rdi": "Residential",
|
||||
"elot_sequence": "0059",
|
||||
"elot_sort": "A",
|
||||
"latitude": 39.28602,
|
||||
"longitude": -76.6689,
|
||||
"precision": "Zip9",
|
||||
"time_zone": "Eastern",
|
||||
"utc_offset": -5,
|
||||
"dst": true
|
||||
},
|
||||
"analysis": {
|
||||
"dpv_match_code": "Y",
|
||||
"dpv_footnotes": "AABB",
|
||||
"dpv_cmra": "N",
|
||||
"dpv_vacant": "N",
|
||||
"active": "Y"
|
||||
}
|
||||
},
|
||||
{
|
||||
"input_index": 0,
|
||||
"candidate_index": 1,
|
||||
"delivery_line_1": "1 S Rosedale St",
|
||||
"last_line": "Baltimore MD 21229-3739",
|
||||
"delivery_point_barcode": "212293739011",
|
||||
"components": {
|
||||
"primary_number": "1",
|
||||
"street_predirection": "S",
|
||||
"street_name": "Rosedale",
|
||||
"street_suffix": "St",
|
||||
"city_name": "Baltimore",
|
||||
"state_abbreviation": "MD",
|
||||
"zipcode": "21229",
|
||||
"plus4_code": "3739",
|
||||
"delivery_point": "01",
|
||||
"delivery_point_check_digit": "1"
|
||||
},
|
||||
"metadata": {
|
||||
"record_type": "S",
|
||||
"zip_type": "Standard",
|
||||
"county_fips": "24510",
|
||||
"county_name": "Baltimore City",
|
||||
"carrier_route": "C047",
|
||||
"congressional_district": "07",
|
||||
"rdi": "Residential",
|
||||
"elot_sequence": "0064",
|
||||
"elot_sort": "A",
|
||||
"latitude": 39.2858,
|
||||
"longitude": -76.66889,
|
||||
"precision": "Zip9",
|
||||
"time_zone": "Eastern",
|
||||
"utc_offset": -5,
|
||||
"dst": true
|
||||
},
|
||||
"analysis": {
|
||||
"dpv_match_code": "Y",
|
||||
"dpv_footnotes": "AABB",
|
||||
"dpv_cmra": "N",
|
||||
"dpv_vacant": "N",
|
||||
"active": "Y"
|
||||
}
|
||||
}
|
||||
];
|
||||
function Empty(){
|
||||
$("#input").val('');
|
||||
$("#output").html('');
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user