├── images
└── wtf.jpg
├── LICENSE
├── index.html
├── javascripts
├── cronwtf.js
├── diff_match_patch.js
├── mootools.js
└── jsspec.js
├── stylesheets
└── jsspec.css
└── test.html
/images/wtf.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/raster/cronwtf/master/images/wtf.jpg
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2008-* Rick Olson
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining
4 | a copy of this software and associated documentation files (the
5 | "Software"), to deal in the Software without restriction, including
6 | without limitation the rights to use, copy, modify, merge, publish,
7 | distribute, sublicense, and/or sell copies of the Software, and to
8 | permit persons to whom the Software is furnished to do so, subject to
9 | the following conditions:
10 |
11 | The above copyright notice and this permission notice shall be
12 | included in all copies or substantial portions of the Software.
13 |
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 |
--------------------------------------------------------------------------------
/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CronWTF!
6 |
7 |
8 |
26 |
45 |
46 |
47 |
57 |
58 |
--------------------------------------------------------------------------------
/javascripts/cronwtf.js:
--------------------------------------------------------------------------------
1 | var CronWTF = {
2 | // parse multiple cron lines, returns an array of messages.
3 | parse: function(s) {
4 | lines = s.split("\n")
5 | messages = []
6 | len = lines.length
7 | for(i = 0; i < len; i++) {
8 | var line = lines[i]
9 | if(line.length > 0 && !line.match(/^#/))
10 | messages.push(this.entry(line).message)
11 | }
12 | return messages
13 | },
14 |
15 | // parses a single cron line, returns an object
16 | entry: function(line) {
17 | pieces = line.replace(/^\s+|\s+$/g, '').split(/\s+/)
18 | e = {
19 | minutes: this.parseAttribute(pieces[0], 60),
20 | hours: this.parseAttribute(pieces[1], 24),
21 | days: this.parseAttribute(pieces[2], 31),
22 | months: this.parseAttribute(pieces[3], 12),
23 | week_days: this.parseAttribute(pieces[4], 8),
24 | command: pieces.slice(5, pieces.length).join(" ")
25 | }
26 | e.message = this.generateMessage(e);
27 | return e;
28 | },
29 |
30 | // parses an individual time attribute into an array of numbers.
31 | // * - every increment (returns '*')
32 | // \d+ - that value
33 | // 1,2,3 - those values
34 | // 1-3 - range of values
35 | // */3 - steps
36 | parseAttribute: function(value, upperBound) {
37 | if(value == '*') return value;
38 |
39 | if(value.match(/^\*\/\d+$/)) {
40 | step = parseInt(value.match(/^\*\/(\d+)$/)[1])
41 | range = []
42 | for(i = 0; i < upperBound; i++) {
43 | if(i % step == 0) range.push(i)
44 | }
45 | return range
46 | }
47 |
48 | if(value.match(/^\d+\-\d+$/)) {
49 | matches = value.match(/^(\d+)\-(\d+)$/)
50 | lower = parseInt(matches[1])
51 | upper = parseInt(matches[2])
52 | range = []
53 | for(var i = lower; i <= upper; i++) {
54 | range.push(i);
55 | }
56 | return range
57 | }
58 |
59 | return value.split(",")
60 | },
61 |
62 | // on minute :00, every hour, on months July, August, every week day
63 | generateMessage: function(entry) {
64 | var attribs = ['minute', 'hour', 'day', 'month', 'week_day']
65 | var attribLen = attribs.length;
66 | var msg = []
67 | for(var i = 0; i < attribLen; i++) {
68 | var key = attribs[i] + 's'
69 | var prev = msg[msg.length -1]
70 | var values = entry[key]
71 | if(values == '*') {
72 | if(!prev || !prev.match(/^every/))
73 | msg.push("every " + attribs[i].replace('_', ' '))
74 | } else {
75 | func = this[key + 'Message']
76 | if(func) msg.push(func(values))
77 | }
78 | }
79 | return "Runs `" + entry.command + "` " + msg.join(", ") + "."
80 | },
81 |
82 | minutesMessage: function(values) {
83 | var m = 'at minute'
84 | var v = []
85 | var len = values.length;
86 | for(var j = 0; j < len; j++) {
87 | num = values[j].toString();
88 | if(num.length == 1) num = "0" + num
89 | v.push(":" + num)
90 | }
91 | if(len > 1) m += 's'
92 | return m + " " + v.join(", ")
93 | },
94 |
95 | hoursMessage: function(values) {
96 | var m = 'on hour'
97 | if(values.length > 1) m += 's'
98 | return m + " " + values.join(", ")
99 | },
100 |
101 | daysMessage: function(values) {
102 | var m = 'on day'
103 | if(values.length > 1) m += 's'
104 | return m + " " + values.join(", ")
105 | },
106 |
107 | months: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
108 | monthsMessage: function(values) {
109 | var v = []
110 | var len = values.length;
111 | for(var j = 0; j < len; j++) {
112 | v.push(CronWTF.months[values[j]])
113 | }
114 | return "in " + v.join(", ")
115 | },
116 |
117 | week_days: ['Sun', 'Mon', "Tue", 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
118 | week_daysMessage: function(values) {
119 | var v = []
120 | var len = values.length;
121 | for(var j = 0; j < len; j++) {
122 | v.push(CronWTF.week_days[values[j]])
123 | }
124 | return "on " + v.join(", ")
125 | }
126 | }
--------------------------------------------------------------------------------
/stylesheets/jsspec.css:
--------------------------------------------------------------------------------
1 | @CHARSET "UTF-8";
2 |
3 | /* --------------------
4 | * @Layout
5 | */
6 |
7 | html {
8 | overflow: hidden;
9 | }
10 |
11 | body, #jsspec_container {
12 | overflow: hidden;
13 | padding: 0;
14 | margin: 0;
15 | width: 100%;
16 | height: 100%;
17 | }
18 |
19 | #title {
20 | padding: 0;
21 | margin: 0;
22 | position: absolute;
23 | top: 0px;
24 | left: 0px;
25 | width: 100%;
26 | height: 40px;
27 | overflow: hidden;
28 | }
29 |
30 | #list {
31 | padding: 0;
32 | margin: 0;
33 | position: absolute;
34 | top: 40px;
35 | left: 0px;
36 | bottom: 0px;
37 | overflow: auto;
38 | width: 250px;
39 | _height:expression(document.body.clientHeight-40);
40 | }
41 |
42 | #log {
43 | padding: 0;
44 | margin: 0;
45 | position: absolute;
46 | top: 40px;
47 | left: 250px;
48 | right: 0px;
49 | bottom: 0px;
50 | overflow: auto;
51 | _height:expression(document.body.clientHeight-40);
52 | _width:expression(document.body.clientWidth-250);
53 | }
54 |
55 |
56 |
57 | /* --------------------
58 | * @Decorations and colors
59 | */
60 | * {
61 | padding: 0;
62 | margin: 0;
63 | font-family: "Lucida Grande", Helvetica, sans-serif;
64 | }
65 |
66 | li {
67 | list-style: none;
68 | }
69 |
70 | /* hiding subtitles */
71 | h2 {
72 | display: none;
73 | }
74 |
75 | /* title section */
76 | div#title {
77 | padding: 0em 0.5em;
78 | }
79 |
80 | div#title h1 {
81 | font-size: 1.5em;
82 | float: left;
83 | }
84 |
85 | div#title ul li {
86 | float: left;
87 | padding: 0.5em 0em 0.5em 0.75em;
88 | }
89 |
90 | div#title p {
91 | float:right;
92 | margin-right:1em;
93 | font-size: 0.75em;
94 | }
95 |
96 | /* spec container */
97 | ul.specs {
98 | margin: 0.5em;
99 | }
100 | ul.specs li {
101 | margin-bottom: 0.1em;
102 | }
103 |
104 | /* spec title */
105 | ul.specs li h3 {
106 | font-weight: bold;
107 | font-size: 0.75em;
108 | padding: 0.2em 1em;
109 | }
110 |
111 | /* example container */
112 | ul.examples li {
113 | border-style: solid;
114 | border-width: 1px 1px 1px 5px;
115 | margin: 0.2em 0em 0.2em 1em;
116 | }
117 |
118 | /* example title */
119 | ul.examples li h4 {
120 | font-weight: normal;
121 | font-size: 0.75em;
122 | margin-left: 1em;
123 | }
124 |
125 | /* example explaination */
126 | ul.examples li div {
127 | padding: 1em 2em;
128 | font-size: 0.75em;
129 | }
130 |
131 | /* styles for ongoing, success, failure, error */
132 | div.success, div.success a {
133 | color: #FFFFFF;
134 | background-color: #65C400;
135 | }
136 |
137 | ul.specs li.success h3, ul.specs li.success h3 a {
138 | color: #FFFFFF;
139 | background-color: #65C400;
140 | }
141 |
142 | ul.examples li.success, ul.examples li.success a {
143 | color: #3D7700;
144 | background-color: #DBFFB4;
145 | border-color: #65C400;
146 | }
147 |
148 | div.exception, div.exception a {
149 | color: #FFFFFF;
150 | background-color: #C20000;
151 | }
152 |
153 | ul.specs li.exception h3, ul.specs li.exception h3 a {
154 | color: #FFFFFF;
155 | background-color: #C20000;
156 | }
157 |
158 | ul.examples li.exception, ul.examples li.exception a {
159 | color: #C20000;
160 | background-color: #FFFBD3;
161 | border-color: #C20000;
162 | }
163 |
164 | div.ongoing, div.ongoing a {
165 | color: #000000;
166 | background-color: #FFFF80;
167 | }
168 |
169 | ul.specs li.ongoing h3, ul.specs li.ongoing h3 a {
170 | color: #000000;
171 | background-color: #FFFF80;
172 | }
173 |
174 | ul.examples li.ongoing, ul.examples li.ongoing a {
175 | color: #000000;
176 | background-color: #FFFF80;
177 | border-color: #DDDD00;
178 | }
179 |
180 |
181 |
182 | /* --------------------
183 | * values
184 | */
185 | .number_value, .string_value, .regexp_value, .boolean_value, .dom_value {
186 | font-family: monospace;
187 | color: blue;
188 | }
189 | .object_value, .array_value {
190 | line-height: 2em;
191 | padding: 0.1em 0.2em;
192 | margin: 0.1em 0;
193 | }
194 | .date_value {
195 | font-family: monospace;
196 | color: olive;
197 | }
198 | .undefined_value, .null_value {
199 | font-style: italic;
200 | color: blue;
201 | }
202 | .dom_attr_name {
203 | }
204 | .dom_attr_value {
205 | color: red;
206 | }
207 | .dom_path {
208 | font-size: 0.75em;
209 | color: gray;
210 | }
211 | strong {
212 | font-weight: normal;
213 | background-color: #FFC6C6;
214 | }
--------------------------------------------------------------------------------
/test.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CronWTF: JSSpec results
6 |
7 |
8 |
9 |
10 |
152 |
153 |
154 |
--------------------------------------------------------------------------------
/javascripts/diff_match_patch.js:
--------------------------------------------------------------------------------
1 | function diff_match_patch(){this.Diff_Timeout=1.0;this.Diff_EditCost=4;this.Diff_DualThreshold=32;this.Match_Balance=0.5;this.Match_Threshold=0.5;this.Match_MinLength=100;this.Match_MaxLength=1000;this.Patch_Margin=4;function getMaxBits(){var maxbits=0;var oldi=1;var newi=2;while(oldi!=newi){maxbits++;oldi=newi;newi=newi<<1}return maxbits}this.Match_MaxBits=getMaxBits()}var DIFF_DELETE=-1;var DIFF_INSERT=1;var DIFF_EQUAL=0;diff_match_patch.prototype.diff_main=function(text1,text2,opt_checklines){if(text1==text2){return[[DIFF_EQUAL,text1]]}if(typeof opt_checklines=='undefined'){opt_checklines=true}var checklines=opt_checklines;var commonlength=this.diff_commonPrefix(text1,text2);var commonprefix=text1.substring(0,commonlength);text1=text1.substring(commonlength);text2=text2.substring(commonlength);commonlength=this.diff_commonSuffix(text1,text2);var commonsuffix=text1.substring(text1.length-commonlength);text1=text1.substring(0,text1.length-commonlength);text2=text2.substring(0,text2.length-commonlength);var diffs=this.diff_compute(text1,text2,checklines);if(commonprefix){diffs.unshift([DIFF_EQUAL,commonprefix])}if(commonsuffix){diffs.push([DIFF_EQUAL,commonsuffix])}this.diff_cleanupMerge(diffs);return diffs};diff_match_patch.prototype.diff_compute=function(text1,text2,checklines){var diffs;if(!text1){return[[DIFF_INSERT,text2]]}if(!text2){return[[DIFF_DELETE,text1]]}var longtext=text1.length>text2.length?text1:text2;var shorttext=text1.length>text2.length?text2:text1;var i=longtext.indexOf(shorttext);if(i!=-1){diffs=[[DIFF_INSERT,longtext.substring(0,i)],[DIFF_EQUAL,shorttext],[DIFF_INSERT,longtext.substring(i+shorttext.length)]];if(text1.length>text2.length){diffs[0][0]=diffs[2][0]=DIFF_DELETE}return diffs}longtext=shorttext=null;var hm=this.diff_halfMatch(text1,text2);if(hm){var text1_a=hm[0];var text1_b=hm[1];var text2_a=hm[2];var text2_b=hm[3];var mid_common=hm[4];var diffs_a=this.diff_main(text1_a,text2_a,checklines);var diffs_b=this.diff_main(text1_b,text2_b,checklines);return diffs_a.concat([[DIFF_EQUAL,mid_common]],diffs_b)}if(checklines&&text1.length+text2.length<250){checklines=false}var linearray;if(checklines){var a=this.diff_linesToChars(text1,text2);text1=a[0];text2=a[1];linearray=a[2]}diffs=this.diff_map(text1,text2);if(!diffs){diffs=[[DIFF_DELETE,text1],[DIFF_INSERT,text2]]}if(checklines){this.diff_charsToLines(diffs,linearray);this.diff_cleanupSemantic(diffs);diffs.push([DIFF_EQUAL,'']);var pointer=0;var count_delete=0;var count_insert=0;var text_delete='';var text_insert='';while(pointer=1&&count_insert>=1){var a=this.diff_main(text_delete,text_insert,false);diffs.splice(pointer-count_delete-count_insert,count_delete+count_insert);pointer=pointer-count_delete-count_insert;for(var j=a.length-1;j>=0;j--){diffs.splice(pointer,0,a[j])}pointer=pointer+a.length}count_insert=0;count_delete=0;text_delete='';text_insert=''}pointer++}diffs.pop()}return diffs};diff_match_patch.prototype.diff_linesToChars=function(text1,text2){var linearray=[];var linehash={};linearray.push('');function diff_linesToCharsMunge(text){var chars='';while(text){var i=text.indexOf('\n');if(i==-1){i=text.length}var line=text.substring(0,i+1);text=text.substring(i+1);if(linehash.hasOwnProperty?linehash.hasOwnProperty(line):(linehash[line]!==undefined)){chars+=String.fromCharCode(linehash[line])}else{linearray.push(line);linehash[line]=linearray.length-1;chars+=String.fromCharCode(linearray.length-1)}}return chars}var chars1=diff_linesToCharsMunge(text1);var chars2=diff_linesToCharsMunge(text2);return[chars1,chars2,linearray]};diff_match_patch.prototype.diff_charsToLines=function(diffs,linearray){for(var x=0;x0&&(new Date()).getTime()>ms_end){return null}v_map1[d]={};for(var k=-d;k<=d;k+=2){if(k==-d||k!=d&&v1[k-1]=0;d--){while(1){if(v_map[d].hasOwnProperty?v_map[d].hasOwnProperty((x-1)+','+y):(v_map[d][(x-1)+','+y]!==undefined)){x--;if(last_op===DIFF_DELETE){path[0][1]=text1.charAt(x)+path[0][1]}else{path.unshift([DIFF_DELETE,text1.charAt(x)])}last_op=DIFF_DELETE;break}else if(v_map[d].hasOwnProperty?v_map[d].hasOwnProperty(x+','+(y-1)):(v_map[d][x+','+(y-1)]!==undefined)){y--;if(last_op===DIFF_INSERT){path[0][1]=text2.charAt(y)+path[0][1]}else{path.unshift([DIFF_INSERT,text2.charAt(y)])}last_op=DIFF_INSERT;break}else{x--;y--;if(last_op===DIFF_EQUAL){path[0][1]=text1.charAt(x)+path[0][1]}else{path.unshift([DIFF_EQUAL,text1.charAt(x)])}last_op=DIFF_EQUAL}}}return path};diff_match_patch.prototype.diff_path2=function(v_map,text1,text2){var path=[];var x=text1.length;var y=text2.length;var last_op=null;for(var d=v_map.length-2;d>=0;d--){while(1){if(v_map[d].hasOwnProperty?v_map[d].hasOwnProperty((x-1)+','+y):(v_map[d][(x-1)+','+y]!==undefined)){x--;if(last_op===DIFF_DELETE){path[path.length-1][1]+=text1.charAt(text1.length-x-1)}else{path.push([DIFF_DELETE,text1.charAt(text1.length-x-1)])}last_op=DIFF_DELETE;break}else if(v_map[d].hasOwnProperty?v_map[d].hasOwnProperty(x+','+(y-1)):(v_map[d][x+','+(y-1)]!==undefined)){y--;if(last_op===DIFF_INSERT){path[path.length-1][1]+=text2.charAt(text2.length-y-1)}else{path.push([DIFF_INSERT,text2.charAt(text2.length-y-1)])}last_op=DIFF_INSERT;break}else{x--;y--;if(last_op===DIFF_EQUAL){path[path.length-1][1]+=text1.charAt(text1.length-x-1)}else{path.push([DIFF_EQUAL,text1.charAt(text1.length-x-1)])}last_op=DIFF_EQUAL}}}return path};diff_match_patch.prototype.diff_commonPrefix=function(text1,text2){if(!text1||!text2||text1.charCodeAt(0)!==text2.charCodeAt(0)){return 0}var pointermin=0;var pointermax=Math.min(text1.length,text2.length);var pointermid=pointermax;var pointerstart=0;while(pointermintext2.length?text1:text2;var shorttext=text1.length>text2.length?text2:text1;if(longtext.length<10||shorttext.length<1){return null}var dmp=this;function diff_halfMatchI(longtext,shorttext,i){var seed=longtext.substring(i,i+Math.floor(longtext.length/4));var j=-1;var best_common='';var best_longtext_a,best_longtext_b,best_shorttext_a,best_shorttext_b;while((j=shorttext.indexOf(seed,j+1))!=-1){var prefixLength=dmp.diff_commonPrefix(longtext.substring(i),shorttext.substring(j));var suffixLength=dmp.diff_commonSuffix(longtext.substring(0,i),shorttext.substring(0,j));if(best_common.length=longtext.length/2){return[best_longtext_a,best_longtext_b,best_shorttext_a,best_shorttext_b,best_common]}else{return null}}var hm1=diff_halfMatchI(longtext,shorttext,Math.ceil(longtext.length/4));var hm2=diff_halfMatchI(longtext,shorttext,Math.ceil(longtext.length/2));var hm;if(!hm1&&!hm2){return null}else if(!hm2){hm=hm1}else if(!hm1){hm=hm2}else{hm=hm1[4].length>hm2[4].length?hm1:hm2}var text1_a,text1_b,text2_a,text2_b;if(text1.length>text2.length){text1_a=hm[0];text1_b=hm[1];text2_a=hm[2];text2_b=hm[3]}else{text2_a=hm[0];text2_b=hm[1];text1_a=hm[2];text1_b=hm[3]}var mid_common=hm[4];return[text1_a,text1_b,text2_a,text2_b,mid_common]};diff_match_patch.prototype.diff_cleanupSemantic=function(diffs){var changes=false;var equalities=[];var lastequality=null;var pointer=0;var length_changes1=0;var length_changes2=0;while(pointer=bestScore){bestScore=score;bestEquality1=equality1;bestEdit=edit;bestEquality2=equality2}}if(diffs[pointer-1][1]!=bestEquality1){diffs[pointer-1][1]=bestEquality1;diffs[pointer][1]=bestEdit;diffs[pointer+1][1]=bestEquality2}}pointer++}};diff_match_patch.prototype.diff_cleanupEfficiency=function(diffs){var changes=false;var equalities=[];var lastequality='';var pointer=0;var pre_ins=false;var pre_del=false;var post_ins=false;var post_del=false;while(pointer0&&diffs[pointer-count_delete-count_insert-1][0]==DIFF_EQUAL){diffs[pointer-count_delete-count_insert-1][1]+=text_insert.substring(0,commonlength)}else{diffs.splice(0,0,[DIFF_EQUAL,text_insert.substring(0,commonlength)]);pointer++}text_insert=text_insert.substring(commonlength);text_delete=text_delete.substring(commonlength)}commonlength=this.diff_commonSuffix(text_insert,text_delete);if(commonlength!==0){diffs[pointer][1]=text_insert.substring(text_insert.length-commonlength)+diffs[pointer][1];text_insert=text_insert.substring(0,text_insert.length-commonlength);text_delete=text_delete.substring(0,text_delete.length-commonlength)}}if(count_delete===0){diffs.splice(pointer-count_delete-count_insert,count_delete+count_insert,[DIFF_INSERT,text_insert])}else if(count_insert===0){diffs.splice(pointer-count_delete-count_insert,count_delete+count_insert,[DIFF_DELETE,text_delete])}else{diffs.splice(pointer-count_delete-count_insert,count_delete+count_insert,[DIFF_DELETE,text_delete],[DIFF_INSERT,text_insert])}pointer=pointer-count_delete-count_insert+(count_delete?1:0)+(count_insert?1:0)+1}else if(pointer!==0&&diffs[pointer-1][0]==DIFF_EQUAL){diffs[pointer-1][1]+=diffs[pointer][1];diffs.splice(pointer,1)}else{pointer++}count_insert=0;count_delete=0;text_delete='';text_insert=''}}if(diffs[diffs.length-1][1]===''){diffs.pop()}var changes=false;pointer=1;while(pointerloc){break}last_chars1=chars1;last_chars2=chars2}if(diffs.length!=x&&diffs[x][0]===DIFF_DELETE){return last_chars2}return last_chars2+(loc-last_chars1)};diff_match_patch.prototype.diff_prettyHtml=function(diffs){this.diff_addIndex(diffs);var html='';for(var x=0;x/g,'>');t=t.replace(/\n/g,'¶ ');if(m===DIFF_DELETE){html+=''+t+''}else if(m===DIFF_INSERT){html+=''+t+' '}else{html+=''+t+' '}}return html};diff_match_patch.prototype.match_main=function(text,pattern,loc){loc=Math.max(0,Math.min(loc,text.length-pattern.length));if(text==pattern){return 0}else if(text.length===0){return null}else if(text.substring(loc,loc+pattern.length)==pattern){return loc}else{return this.match_bitap(text,pattern,loc)}};diff_match_patch.prototype.match_bitap=function(text,pattern,loc){if(pattern.length>this.Match_MaxBits){return alert('Pattern too long for this browser.')}var s=this.match_alphabet(pattern);var score_text_length=text.length;score_text_length=Math.max(score_text_length,this.Match_MinLength);score_text_length=Math.min(score_text_length,this.Match_MaxLength);var dmp=this;function match_bitapScore(e,x){var d=Math.abs(loc-x);return(e/pattern.length/dmp.Match_Balance)+(d/score_text_length/(1.0-dmp.Match_Balance))}var score_threshold=this.Match_Threshold;var best_loc=text.indexOf(pattern,loc);if(best_loc!=-1){score_threshold=Math.min(match_bitapScore(0,best_loc),score_threshold)}best_loc=text.lastIndexOf(pattern,loc+pattern.length);if(best_loc!=-1){score_threshold=Math.min(match_bitapScore(0,best_loc),score_threshold)}var matchmask=1<<(pattern.length-1);best_loc=null;var bin_min,bin_mid;var bin_max=Math.max(loc+loc,text.length);var last_rd;for(var d=0;d=start;j--){if(d===0){rd[j]=((rd[j+1]<<1)|1)&s[text.charAt(j)]}else{rd[j]=((rd[j+1]<<1)|1)&s[text.charAt(j)]|((last_rd[j+1]<<1)|1)|((last_rd[j]<<1)|1)|last_rd[j+1]}if(rd[j]&matchmask){var score=match_bitapScore(d,j);if(score<=score_threshold){score_threshold=score;best_loc=j;if(j>loc){start=Math.max(0,loc-(j-loc))}else{break}}}}if(match_bitapScore(d+1,loc)>score_threshold){break}last_rd=rd}return best_loc};diff_match_patch.prototype.match_alphabet=function(pattern){var s=Object();for(var i=0;i2){this.diff_cleanupSemantic(diffs);this.diff_cleanupEfficiency(diffs)}}if(diffs.length===0){return[]}var patches=[];var patch=new patch_obj();var char_count1=0;var char_count2=0;var prepatch_text=text1;var postpatch_text=text1;for(var x=0;x=2*this.Patch_Margin){if(patch.diffs.length!==0){this.patch_addContext(patch,prepatch_text);patches.push(patch);patch=new patch_obj();prepatch_text=postpatch_text}}if(diff_type!==DIFF_INSERT){char_count1+=diff_text.length}if(diff_type!==DIFF_DELETE){char_count2+=diff_text.length}}if(patch.diffs.length!==0){this.patch_addContext(patch,prepatch_text);patches.push(patch)}return patches};diff_match_patch.prototype.patch_apply=function(patches,text){this.patch_splitMax(patches);var results=[];var delta=0;for(var x=0;xthis.Match_MaxBits){var bigpatch=patches[x];patches.splice(x,1);var patch_size=this.Match_MaxBits;var start1=bigpatch.start1;var start2=bigpatch.start2;var precontext='';while(bigpatch.diffs.length!==0){var patch=new patch_obj();var empty=true;patch.start1=start1-precontext.length;patch.start2=start2-precontext.length;if(precontext!==''){patch.length1=patch.length2=precontext.length;patch.diffs.push([DIFF_EQUAL,precontext])}while(bigpatch.diffs.length!==0&&patch.length1, My Object Oriented (JavaScript) Tools. Copyright (c) 2006-2008 Valerio Proietti, , MIT Style License.
2 |
3 | var MooTools={version:"1.2.1",build:"0d4845aab3d9a4fdee2f0d4a6dd59210e4b697cf"};var Native=function(K){K=K||{};var A=K.name;var I=K.legacy;var B=K.protect;
4 | var C=K.implement;var H=K.generics;var F=K.initialize;var G=K.afterImplement||function(){};var D=F||I;H=H!==false;D.constructor=Native;D.$family={name:"native"};
5 | if(I&&F){D.prototype=I.prototype;}D.prototype.constructor=D;if(A){var E=A.toLowerCase();D.prototype.$family={name:E};Native.typize(D,E);}var J=function(N,L,O,M){if(!B||M||!N.prototype[L]){N.prototype[L]=O;
6 | }if(H){Native.genericize(N,L,B);}G.call(N,L,O);return N;};D.alias=function(N,L,O){if(typeof N=="string"){if((N=this.prototype[N])){return J(this,L,N,O);
7 | }}for(var M in N){this.alias(M,N[M],L);}return this;};D.implement=function(M,L,O){if(typeof M=="string"){return J(this,M,L,O);}for(var N in M){J(this,N,M[N],L);
8 | }return this;};if(C){D.implement(C);}return D;};Native.genericize=function(B,C,A){if((!A||!B[C])&&typeof B.prototype[C]=="function"){B[C]=function(){var D=Array.prototype.slice.call(arguments);
9 | return B.prototype[C].apply(D.shift(),D);};}};Native.implement=function(D,C){for(var B=0,A=D.length;B-1:this.indexOf(A)>-1;},trim:function(){return this.replace(/^\s+|\s+$/g,"");},clean:function(){return this.replace(/\s+/g," ").trim();
65 | },camelCase:function(){return this.replace(/-\D/g,function(A){return A.charAt(1).toUpperCase();});},hyphenate:function(){return this.replace(/[A-Z]/g,function(A){return("-"+A.charAt(0).toLowerCase());
66 | });},capitalize:function(){return this.replace(/\b[a-z]/g,function(A){return A.toUpperCase();});},escapeRegExp:function(){return this.replace(/([-.*+?^${}()|[\]\/\\])/g,"\\$1");
67 | },toInt:function(A){return parseInt(this,A||10);},toFloat:function(){return parseFloat(this);},hexToRgb:function(B){var A=this.match(/^#?(\w{1,2})(\w{1,2})(\w{1,2})$/);
68 | return(A)?A.slice(1).hexToRgb(B):null;},rgbToHex:function(B){var A=this.match(/\d{1,3}/g);return(A)?A.rgbToHex(B):null;},stripScripts:function(B){var A="";
69 | var C=this.replace(/