diff --git a/master.js b/master.js index 9030c38..b9eb849 100644 --- a/master.js +++ b/master.js @@ -6162,95 +6162,125 @@ bot.addCommand({ }()); ; -(function () { -var parse; - -function learn ( args ) { - bot.log( args, '/learn input' ); - - var commandParts = args.parse(); - var command = { - name : commandParts[ 0 ], - output : commandParts[ 1 ], - input : commandParts[ 2 ] || '.*' - }; - - //a truthy value, unintuitively, means it isn't valid, because it returns - // an error message - var errorMessage = checkCommand( command ); - if ( errorMessage ) { - return errorMessage; - } - command.name = command.name.toLowerCase(); - command.input = new RegExp( command.input ); - - parse = bot.getCommand( 'parse' ); - if ( parse.error ) { - console.error( '/parse not loaded, cannot /learn' ); - return 'Failed; /parse not loaded'; - } - console.log( parse ); - - bot.log( command, '/learn parsed' ); - - addCustomCommand( command ); - return 'Command ' + command.name + ' learned'; -}; - -function addCustomCommand ( command ) { - bot.addCommand({ - name : command.name, - description : 'User-taught command: ' + command.output, - - fun : makeCustomCommand( command ), - permissions : { - use : 'ALL', - del : 'ALL' - } - }); -} -function makeCustomCommand ( command ) { - - return function ( args ) { - bot.log( args, command.name + ' input' ); - - var cmdArgs = bot.Message( command.output, args.get() ); - return parse.exec( cmdArgs, command.input.exec(args) ); - }; -} - -//return a truthy value (an error message) if it's invalid, falsy if it's -// valid -function checkCommand ( cmd ) { - var somethingUndefined = Object.keys( cmd ).some(function ( key ) { - return !cmd[ key ]; - }), - error; - - if ( somethingUndefined ) { - error = 'Illegal /learn object'; - } - - if ( !/^[\w\-]+$/.test(cmd.name) ) { - error = 'Invalid command name'; - } - - if ( bot.commandExists(cmd.name.toLowerCase()) ) { - error = 'Command ' + cmd.name + ' already exists'; - } - - return error; -} - - -bot.addCommand({ - name : 'learn', - fun : learn, - privileges : { - del : 'NONE', - }, - - description : 'Teaches the bot a command. ' + - '`/learn cmdName cmdOutputMacro [cmdInputRegex]`' -}); -}()); +(function () { +"use strict"; +var parse = bot.getCommand( 'parse' ); +var storage = JSON.parse( localStorage.bot_learn || '{}' ); +loadCommands(); + +function learn ( args ) { + bot.log( args, '/learn input' ); + + var commandParts = args.parse(); + var command = { + name : commandParts[ 0 ], + output : commandParts[ 1 ], + input : commandParts[ 2 ] || '.*' + }; + + //a truthy value, unintuitively, means it isn't valid, because it returns + // an error message + var errorMessage = checkCommand( command ); + if ( errorMessage ) { + return errorMessage; + } + command.name = command.name.toLowerCase(); + command.input = new RegExp( command.input ); + + bot.log( command, '/learn parsed' ); + + addCustomCommand( command ); + saveCommand( command ); + return 'Command ' + command.name + ' learned'; +} + +function addCustomCommand ( command ) { + var cmd = bot.Command({ + name : command.name, + description : 'User-taught command: ' + command.output, + + fun : makeCustomCommand( command ), + permissions : { + use : 'ALL', + del : 'ALL' + } + }); + + cmd.del = (function ( old ) { + return function () { + deleteCommand( command.name ); + old(); + }; + }( cmd.del )); + + bot.log( cmd, '/learn addCustomCommand' ); + bot.addCommand( cmd ); +} +function makeCustomCommand ( command ) { + bot.log( command, '/learn makeCustomCommand' ); + return function ( args ) { + bot.log( args, command.name + ' input' ); + + var cmdArgs = bot.Message( command.output, args.get() ); + return parse.exec( cmdArgs, command.input.exec(args) ); + }; +} + +//return a truthy value (an error message) if it's invalid, falsy if it's +// valid +function checkCommand ( cmd ) { + var somethingUndefined = Object.keys( cmd ).some(function ( key ) { + return !cmd[ key ]; + }), + error; + + if ( somethingUndefined ) { + error = 'Illegal /learn object'; + } + + else if ( !/^[\w\-]+$/.test(cmd.name) ) { + error = 'Invalid command name'; + } + + else if ( bot.commandExists(cmd.name.toLowerCase()) ) { + error = 'Command ' + cmd.name + ' already exists'; + } + + return error; +} + +function loadCommands () { + Object.keys( storage ).forEach( teach ); + + function teach ( key ) { + var cmd = JSON.parse( storage[key] ); + cmd.input = new RegExp( cmd.input ); + + bot.log( cmd, '/learn loadCommands' ); + addCustomCommand( cmd ); + } +} +function saveCommand ( command ) { + storage[ command.name ] = JSON.stringify({ + name : command.name, + input : command.input.source, + output : command.output + }); + localStorage.bot_learn = JSON.stringify( storage ); +} +function deleteCommand ( name ) { + delete storage[ name ]; + localStorage.bot_learn = JSON.stringify( storage ); +} + +bot.addCommand({ + name : 'learn', + fun : learn, + privileges : { + del : 'NONE' + }, + + description : 'Teaches the bot a command. ' + + '`/learn cmdName cmdOutputMacro [cmdInputRegex]`' +}); +}()); diff --git a/master.min.js b/master.min.js index ad66f2b..39d5fad 100644 --- a/master.min.js +++ b/master.min.js @@ -1,3 +1,3 @@ -function js_beautify(e,t){function n(e){for(e=e===void 0?!1:e;_.length&&(" "===_[_.length-1]||_[_.length-1]===w||_[_.length-1]===G||e&&("\n"===_[_.length-1]||"\r"===_[_.length-1]));)_.pop()}function o(e){return e.replace(/^\s\s*|\s\s*$/,"")}function i(e){e=e.replace(/\x0d/g,"");for(var t=[],n=e.indexOf("\n");-1!==n;)t.push(e.substring(0,n)),e=e.substring(n+1),n=e.indexOf("\n");return e.length&&t.push(e),t}function r(){var e=H;H=!1,a(),H=e}function a(e){if(C.eat_next_space=!1,(!H||!p(C.mode))&&(e=e===void 0?!0:e,C.if_line=!1,n(),_.length)){"\n"===_[_.length-1]&&e||(U=!0,_.push("\n")),G&&_.push(G);for(var t=0;C.indentation_level>t;t+=1)_.push(w);C.var_line&&C.var_line_reindented&&_.push(w),C.case_body&&_.push(w)}}function s(){if("TK_COMMENT"===T)return a();if(C.eat_next_space)return C.eat_next_space=!1,void 0;var e=" ";_.length&&(e=_[_.length-1])," "!==e&&"\n"!==e&&e!==w&&_.push(" ")}function c(){U=!1,C.eat_next_space=!1,_.push(O)}function u(){C.indentation_level+=1}function m(){_.length&&_[_.length-1]===w&&_.pop()}function l(e){C&&A.push(C),C={previous_mode:C?C.mode:"BLOCK",mode:e,var_line:!1,var_line_tainted:!1,var_line_reindented:!1,in_html_comment:!1,if_line:!1,in_case_statement:!1,in_case:!1,case_body:!1,eat_next_space:!1,indentation_baseline:-1,indentation_level:C?C.indentation_level+(C.case_body?1:0)+(C.var_line&&C.var_line_reindented?1:0):0,ternary_depth:0}}function p(e){return"[EXPRESSION]"===e||"[INDENTED-EXPRESSION]"===e}function h(e){return x(e,["[EXPRESSION]","(EXPRESSION)","(FOR-EXPRESSION)","(COND-EXPRESSION)"])}function d(){if(L="DO_BLOCK"===C.mode,A.length>0){var e=C.mode;C=A.pop(),C.previous_mode=e}}function f(e,t){for(var n=0;e.length>n;n++){var i=o(e[n]);if(i.charAt(0)!==t)return!1}return!0}function g(e){return x(e,["case","return","do","if","throw","else"])}function x(e,t){for(var n=0;t.length>n;n+=1)if(t[n]===e)return!0;return!1}function y(e){for(var t=R,n=b.charAt(t);x(n,I)&&n!==e;){if(t++,t>=Z)return 0;n=b.charAt(t)}return n}function v(){var e,t;if(F=0,R>=Z)return["","TK_EOF"];B=!1;var i=b.charAt(R);R+=1;var r=H&&p(C.mode);if(r){for(var s=0;x(i,I);){if("\n"===i?(n(),_.push("\n"),U=!0,s=0):" "===i?s+=4:"\r"===i||(s+=1),R>=Z)return["","TK_EOF"];i=b.charAt(R),R+=1}if(-1===C.indentation_baseline&&(C.indentation_baseline=s),U){for(e=0;C.indentation_level+1>e;e+=1)_.push(w);if(-1!==C.indentation_baseline)for(e=0;s-C.indentation_baseline>e;e++)_.push(" ")}}else{for(;x(i,I);){if("\n"===i&&(F+=V?V>=F?1:0:1),R>=Z)return["","TK_EOF"];i=b.charAt(R),R+=1}if(Y&&F>1)for(e=0;F>e;e+=1)a(0===e),U=!0;B=F>0}if(x(i,k)){if(Z>R)for(;x(b.charAt(R),k)&&(i+=b.charAt(R),R+=1,R!==Z););if(R!==Z&&i.match(/^[0-9]+[Ee]$/)&&("-"===b.charAt(R)||"+"===b.charAt(R))){var c=b.charAt(R);R+=1;var u=v();return i+=c+u[0],[i,"TK_WORD"]}return"in"===i?[i,"TK_OPERATOR"]:(!B||"TK_OPERATOR"===T||"TK_EQUALS"===T||C.if_line||!Y&&"var"===E||a(),[i,"TK_WORD"])}if("("===i||"["===i)return[i,"TK_START_EXPR"];if(")"===i||"]"===i)return[i,"TK_END_EXPR"];if("{"===i)return[i,"TK_START_BLOCK"];if("}"===i)return[i,"TK_END_BLOCK"];if(";"===i)return[i,"TK_SEMICOLON"];if("/"===i){var m="",l=!0;if("*"===b.charAt(R)){if(R+=1,Z>R)for(;Z>R&&("*"!==b.charAt(R)||!b.charAt(R+1)||"/"!==b.charAt(R+1))&&(i=b.charAt(R),m+=i,("\n"===i||"\r"===i)&&(l=!1),R+=1,!(R>=Z)););return R+=2,l&&0===F?["/*"+m+"*/","TK_INLINE_COMMENT"]:["/*"+m+"*/","TK_BLOCK_COMMENT"]}if("/"===b.charAt(R)){for(m=i;"\r"!==b.charAt(R)&&"\n"!==b.charAt(R)&&(m+=b.charAt(R),R+=1,!(R>=Z)););return B&&a(),[m,"TK_COMMENT"]}}if("'"===i||'"'===i||"/"===i&&("TK_WORD"===T&&g(E)||")"===E&&x(C.previous_mode,["(COND-EXPRESSION)","(FOR-EXPRESSION)"])||"TK_COMMA"===T||"TK_COMMENT"===T||"TK_START_EXPR"===T||"TK_START_BLOCK"===T||"TK_END_BLOCK"===T||"TK_OPERATOR"===T||"TK_EQUALS"===T||"TK_EOF"===T||"TK_SEMICOLON"===T)){var h=i,d=!1,f=0,y=0;if(t=i,Z>R)if("/"===h){for(var O=!1;d||O||b.charAt(R)!==h;)if(t+=b.charAt(R),d?d=!1:(d="\\"===b.charAt(R),"["===b.charAt(R)?O=!0:"]"===b.charAt(R)&&(O=!1)),R+=1,R>=Z)return[t,"TK_STRING"]}else for(;d||b.charAt(R)!==h;)if(t+=b.charAt(R),f&&f>=y&&(f=parseInt(t.substr(-y),16),f&&f>=32&&126>=f&&(f=String.fromCharCode(f),t=t.substr(0,t.length-y-2)+(f===h||"\\"===f?"\\":"")+f),f=0),f?f++:d?(d=!1,Q&&("x"===b.charAt(R)?(f++,y=2):"u"===b.charAt(R)&&(f++,y=4))):d="\\"===b.charAt(R),R+=1,R>=Z)return[t,"TK_STRING"];if(R+=1,t+=h,"/"===h)for(;Z>R&&x(b.charAt(R),k);)t+=b.charAt(R),R+=1;return[t,"TK_STRING"]}if("#"===i){if(0===_.length&&"!"===b.charAt(R)){for(t=i;Z>R&&"\n"!==i;)i=b.charAt(R),t+=i,R+=1;return _.push(o(t)+"\n"),a(),v()}var N="#";if(Z>R&&x(b.charAt(R),P)){do i=b.charAt(R),N+=i,R+=1;while(Z>R&&"#"!==i&&"="!==i);return"#"===i||("["===b.charAt(R)&&"]"===b.charAt(R+1)?(N+="[]",R+=2):"{"===b.charAt(R)&&"}"===b.charAt(R+1)&&(N+="{}",R+=2)),[N,"TK_WORD"]}}if("<"===i&&""===b.substring(R-1,R+2))return C.in_html_comment=!1,R+=2,B&&a(),["-->","TK_COMMENT"];if(x(i,j)){for(;Z>R&&x(i+b.charAt(R),j)&&(i+=b.charAt(R),R+=1,!(R>=Z)););return","===i?[i,"TK_COMMA"]:"="===i?[i,"TK_EQUALS"]:[i,"TK_OPERATOR"]}return[i,"TK_UNKNOWN"]}var b,_,O,T,E,N,S,C,A,w,I,k,j,R,D,P,M,K,L,B,U,F,G="";t=t?t:{};var X;void 0!==t.space_after_anon_function&&void 0===t.jslint_happy&&(t.jslint_happy=t.space_after_anon_function),void 0!==t.braces_on_own_line&&(X=t.braces_on_own_line?"expand":"collapse"),X=t.brace_style?t.brace_style:X?X:"collapse";var q=t.indent_size?t.indent_size:4,W=t.indent_char?t.indent_char:" ",Y=t.preserve_newlines===void 0?!0:t.preserve_newlines,V=t.max_preserve_newlines===void 0?!1:t.max_preserve_newlines,z="undefined"===t.jslint_happy?!1:t.jslint_happy,H=t.keep_array_indentation===void 0?!1:t.keep_array_indentation,$=t.space_before_conditional===void 0?!0:t.space_before_conditional,J=t.indent_case===void 0?!1:t.indent_case,Q=t.unescape_strings===void 0?!1:t.unescape_strings;U=!1;var Z=e.length;for(w="";q>0;)w+=W,q-=1;for(;e&&(" "===e.charAt(0)||" "===e.charAt(0));)G+=e.charAt(0),e=e.substring(1);for(b=e,S="",T="TK_START_EXPR",E="",N="",_=[],L=!1,I="\n\r ".split(""),k="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_$".split(""),P="0123456789".split(""),j="+ - * / % & ++ -- = += -= *= /= %= == === != !== > < >= <= >> << >>> >>>= >>= <<= && &= | || ! !! , : ? ^ ^= |= ::",j+=" <%= <% %> ",j=j.split(" "),D="continue,try,throw,return,var,if,switch,case,default,for,while,break,function".split(","),A=[],l("BLOCK"),R=0;;){var et=v();if(O=et[0],K=et[1],"TK_EOF"===K)break;switch(K){case"TK_START_EXPR":if("["===O){if("TK_WORD"===T||")"===E){x(E,D)&&s(),l("(EXPRESSION)"),c();break}"[EXPRESSION]"===C.mode||"[INDENTED-EXPRESSION]"===C.mode?"]"===N&&","===E?("[EXPRESSION]"===C.mode&&(C.mode="[INDENTED-EXPRESSION]",H||u()),l("[EXPRESSION]"),H||a()):"["===E?("[EXPRESSION]"===C.mode&&(C.mode="[INDENTED-EXPRESSION]",H||u()),l("[EXPRESSION]"),H||a()):l("[EXPRESSION]"):l("[EXPRESSION]")}else"for"===S?l("(FOR-EXPRESSION)"):x(S,["if","while"])?l("(COND-EXPRESSION)"):l("(EXPRESSION)");";"===E||"TK_START_BLOCK"===T?a():"TK_END_EXPR"===T||"TK_START_EXPR"===T||"TK_END_BLOCK"===T||"."===E?B&&a():"TK_WORD"!==T&&"TK_OPERATOR"!==T?s():"function"===S||"typeof"===S?z&&s():(x(E,D)||"catch"===E)&&$&&s(),c();break;case"TK_END_EXPR":if("]"===O)if(H){if("}"===E){m(),c(),d();break}}else if("[INDENTED-EXPRESSION]"===C.mode&&"]"===E){d(),a(),c();break}d(),c();break;case"TK_START_BLOCK":if("do"===S?l("DO_BLOCK"):l("BLOCK"),"expand"===X||"expand-strict"===X){var tt=!1;"expand-strict"===X?(tt="}"===y(),tt||a(!0)):"TK_OPERATOR"!==T&&("="===E||g(E)&&"else"!==E?s():a(!0)),c(),tt||u()}else"TK_OPERATOR"!==T&&"TK_START_EXPR"!==T?"TK_START_BLOCK"===T?a():s():p(C.previous_mode)&&","===E&&("}"===N?s():a()),u(),c();break;case"TK_END_BLOCK":d(),"expand"===X||"expand-strict"===X?("{"!==E&&a(),c()):("TK_START_BLOCK"===T?U?m():n():p(C.mode)&&H?(H=!1,a(),H=!0):a(),c());break;case"TK_WORD":if(L){s(),c(),s(),L=!1;break}if(M="NONE","function"===O){if(C.var_line&&"TK_EQUALS"!==T&&(C.var_line_reindented=!0),(U||";"===E)&&"{"!==E&&"TK_BLOCK_COMMENT"!==T&&"TK_COMMENT"!==T){F=U?F:0,Y||(F=1);for(var nt=0;2-F>nt;nt++)a(!1)}"TK_WORD"===T?"get"===E||"set"===E||"new"===E||"return"===E?s():a():"TK_OPERATOR"===T||"="===E?s():h(C.mode)||a(),c(),S=O;break}if("case"===O||"default"===O&&C.in_case_statement){":"===E||C.case_body?m():(J||C.indentation_level--,a(),J||C.indentation_level++),c(),C.in_case=!0,C.in_case_statement=!0,C.case_body=!1;break}"TK_END_BLOCK"===T?x(O.toLowerCase(),["else","catch","finally"])?"expand"===X||"end-expand"===X||"expand-strict"===X?M="NEWLINE":(M="SPACE",s()):M="NEWLINE":"TK_SEMICOLON"!==T||"BLOCK"!==C.mode&&"DO_BLOCK"!==C.mode?"TK_SEMICOLON"===T&&h(C.mode)?M="SPACE":"TK_STRING"===T?M="NEWLINE":"TK_WORD"===T?("else"===E&&n(!0),M="SPACE"):"TK_START_BLOCK"===T?M="NEWLINE":"TK_END_EXPR"===T&&(s(),M="NEWLINE"):M="NEWLINE",x(O,D)&&")"!==E&&(M="else"===E?"SPACE":"NEWLINE"),C.if_line&&"TK_END_EXPR"===T&&(C.if_line=!1),x(O.toLowerCase(),["else","catch","finally"])?"TK_END_BLOCK"!==T||"expand"===X||"end-expand"===X||"expand-strict"===X?a():(n(!0),s()):"NEWLINE"===M?g(E)?s():"TK_END_EXPR"!==T?"TK_START_EXPR"===T&&"var"===O||":"===E||("if"===O&&"else"===S&&"{"!==E?s():(C.var_line=!1,C.var_line_reindented=!1,a())):x(O,D)&&")"!==E&&(C.var_line=!1,C.var_line_reindented=!1,a()):p(C.mode)&&","===E&&"}"===N?a():"SPACE"===M&&s(),c(),S=O,"var"===O&&(C.var_line=!0,C.var_line_reindented=!1,C.var_line_tainted=!1),"if"===O&&(C.if_line=!0),"else"===O&&(C.if_line=!1);break;case"TK_SEMICOLON":c(),C.var_line=!1,C.var_line_reindented=!1,"OBJECT"===C.mode&&(C.mode="BLOCK");break;case"TK_STRING":"TK_END_EXPR"===T&&x(C.previous_mode,["(COND-EXPRESSION)","(FOR-EXPRESSION)"])?s():"TK_COMMENT"===T||"TK_STRING"===T||"TK_START_BLOCK"===T||"TK_END_BLOCK"===T||"TK_SEMICOLON"===T?a():"TK_WORD"===T&&s(),c();break;case"TK_EQUALS":C.var_line&&(C.var_line_tainted=!0),s(),c(),s();break;case"TK_COMMA":if(C.var_line){if((h(C.mode)||"TK_END_BLOCK"===T)&&(C.var_line_tainted=!1),C.var_line_tainted){c(),C.var_line_reindented=!0,C.var_line_tainted=!1,a();break}C.var_line_tainted=!1,c(),s();break}"TK_COMMENT"===T&&a(),"TK_END_BLOCK"===T&&"(EXPRESSION)"!==C.mode?(c(),"OBJECT"===C.mode&&"}"===E?a():s()):"OBJECT"===C.mode?(c(),a()):(c(),s());break;case"TK_OPERATOR":var ot=!0,it=!0;if(g(E)){s(),c();break}if("*"===O&&"TK_UNKNOWN"===T&&!N.match(/^\d+$/)){c();break}if(":"===O&&C.in_case){J&&(C.case_body=!0),c(),a(),C.in_case=!1;break}if("::"===O){c();break}x(O,["--","++","!"])||x(O,["-","+"])&&(x(T,["TK_START_BLOCK","TK_START_EXPR","TK_EQUALS","TK_OPERATOR"])||x(E,D))?(ot=!1,it=!1,";"===E&&h(C.mode)&&(ot=!0),"TK_WORD"===T&&x(E,D)&&(ot=!0),"BLOCK"!==C.mode||"{"!==E&&";"!==E||a()):"."===O?ot=!1:":"===O?0===C.ternary_depth?("BLOCK"===C.mode&&(C.mode="OBJECT"),ot=!1):C.ternary_depth-=1:"?"===O&&(C.ternary_depth+=1),ot&&s(),c(),it&&s();break;case"TK_BLOCK_COMMENT":var rt,at=i(O);if(f(at.slice(1),"*"))for(a(),_.push(at[0]),rt=1;at.length>rt;rt++)a(),_.push(" "),_.push(o(at[rt]));else for(at.length>1?a():"TK_END_BLOCK"===T?a():s(),rt=0;at.length>rt;rt++)_.push(at[rt]),_.push("\n");"\n"!==y("\n")&&a();break;case"TK_INLINE_COMMENT":s(),c(),h(C.mode)?s():r();break;case"TK_COMMENT":","!==E||B||n(!0),"TK_COMMENT"!==T&&(B?a():s()),c(),a();break;case"TK_UNKNOWN":g(E)&&s(),c()}N=E,T=K,E=O}var st=G+_.join("").replace(/[\r\n ]+$/,"");return st}function style_html(e,t){function n(){return this.pos=0,this.token="",this.current_mode="CONTENT",this.tags={parent:"parent1",parentcount:1,parent1:""},this.tag_type="",this.token_text=this.last_token=this.last_text=this.token_type="",this.Utils={whitespace:"\n\r ".split(""),single_token:"br,input,link,meta,!doctype,basefont,base,area,hr,wbr,param,img,isindex,?xml,embed".split(","),extra_liners:"head,body,/html".split(","),in_array:function(e,t){for(var n=0;t.length>n;n++)if(e===t[n])return!0;return!1}},this.get_content=function(){for(var e="",t=[],n=!1;"<"!==this.input.charAt(this.pos);){if(this.pos>=this.input.length)return t.length?t.join(""):["","TK_EOF"];if(e=this.input.charAt(this.pos),this.pos++,this.line_char_count++,this.Utils.in_array(e,this.Utils.whitespace))t.length&&(n=!0),this.line_char_count--;else{if(n){if(this.line_char_count>=this.max_char){t.push("\n");for(var o=0;this.indent_level>o;o++)t.push(this.indent_string);this.line_char_count=0}else t.push(" "),this.line_char_count++;n=!1}t.push(e)}}return t.length?t.join(""):""},this.get_contents_to=function(e){if(this.pos==this.input.length)return["","TK_EOF"];var t="",n=RegExp("","igm");n.lastIndex=this.pos;var o=n.exec(this.input),i=o?o.index:this.input.length;return i>this.pos&&(t=this.input.substring(this.pos,i),this.pos=i),t},this.record_tag=function(e){this.tags[e+"count"]?(this.tags[e+"count"]++,this.tags[e+this.tags[e+"count"]]=this.indent_level):(this.tags[e+"count"]=1,this.tags[e+this.tags[e+"count"]]=this.indent_level),this.tags[e+this.tags[e+"count"]+"parent"]=this.tags.parent,this.tags.parent=e+this.tags[e+"count"]},this.retrieve_tag=function(e){if(this.tags[e+"count"]){for(var t=this.tags.parent;t&&e+this.tags[e+"count"]!==t;)t=this.tags[t+"parent"];t&&(this.indent_level=this.tags[e+this.tags[e+"count"]],this.tags.parent=this.tags[t+"parent"]),delete this.tags[e+this.tags[e+"count"]+"parent"],delete this.tags[e+this.tags[e+"count"]],1==this.tags[e+"count"]?delete this.tags[e+"count"]:this.tags[e+"count"]--}},this.get_tag=function(){var e="",t=[],n=!1;do{if(this.pos>=this.input.length)return t.length?t.join(""):["","TK_EOF"];e=this.input.charAt(this.pos),this.pos++,this.line_char_count++,this.Utils.in_array(e,this.Utils.whitespace)?(n=!0,this.line_char_count--):(("'"===e||'"'===e)&&(t[1]&&"!"===t[1]||(e+=this.get_unformatted(e),n=!0)),"="===e&&(n=!1),t.length&&"="!==t[t.length-1]&&">"!==e&&n&&(this.line_char_count>=this.max_char?(this.print_newline(!1,t),this.line_char_count=0):(t.push(" "),this.line_char_count++),n=!1),t.push(e))}while(">"!==e);var o,i=t.join("");o=-1!=i.indexOf(" ")?i.indexOf(" "):i.indexOf(">");var r=i.substring(1,o).toLowerCase();if("/"===i.charAt(i.length-2)||this.Utils.in_array(r,this.Utils.single_token))this.tag_type="SINGLE";else if("script"===r)this.record_tag(r),this.tag_type="SCRIPT";else if("style"===r)this.record_tag(r),this.tag_type="STYLE";else if(this.Utils.in_array(r,unformatted)){var a=this.get_unformatted("",i);t.push(a),this.tag_type="SINGLE"}else if("!"===r.charAt(0))if(-1!=r.indexOf("[if")){if(-1!=i.indexOf("!IE")){var a=this.get_unformatted("-->",i);t.push(a)}this.tag_type="START"}else if(-1!=r.indexOf("[endif"))this.tag_type="END",this.unindent();else if(-1!=r.indexOf("[cdata[")){var a=this.get_unformatted("]]>",i);t.push(a),this.tag_type="SINGLE"}else{var a=this.get_unformatted("-->",i);t.push(a),this.tag_type="SINGLE"}else"/"===r.charAt(0)?(this.retrieve_tag(r.substring(1)),this.tag_type="END"):(this.record_tag(r),this.tag_type="START"),this.Utils.in_array(r,this.Utils.extra_liners)&&this.print_newline(!0,this.output);return t.join("")},this.get_unformatted=function(e,t){if(t&&-1!=t.indexOf(e))return"";var n="",o="",i=!0;do{if(this.pos>=this.input.length)return o;if(n=this.input.charAt(this.pos),this.pos++,this.Utils.in_array(n,this.Utils.whitespace)){if(!i){this.line_char_count--;continue}if("\n"===n||"\r"===n){o+="\n",this.line_char_count=0;continue}}o+=n,this.line_char_count++,i=!0}while(-1==o.indexOf(e));return o},this.get_token=function(){var e;if("TK_TAG_SCRIPT"===this.last_token||"TK_TAG_STYLE"===this.last_token){var t=this.last_token.substr(7);return e=this.get_contents_to(t),"string"!=typeof e?e:[e,"TK_"+t]}if("CONTENT"===this.current_mode)return e=this.get_content(),"string"!=typeof e?e:[e,"TK_CONTENT"];if("TAG"===this.current_mode){if(e=this.get_tag(),"string"!=typeof e)return e;var n="TK_TAG_"+this.tag_type;return[e,n]}},this.get_full_indent=function(e){return e=this.indent_level+e||0,1>e?"":Array(e+1).join(this.indent_string)},this.printer=function(e,t,n,o,i){this.input=e||"",this.output=[],this.indent_character=t,this.indent_string="",this.indent_size=n,this.brace_style=i,this.indent_level=0,this.max_char=o,this.line_char_count=0;for(var r=0;this.indent_size>r;r++)this.indent_string+=this.indent_character;this.print_newline=function(e,t){if(this.line_char_count=0,t&&t.length){if(!e)for(;this.Utils.in_array(t[t.length-1],this.Utils.whitespace);)t.pop();t.push("\n");for(var n=0;this.indent_level>n;n++)t.push(this.indent_string)}},this.print_token=function(e){this.output.push(e)},this.indent=function(){this.indent_level++},this.unindent=function(){this.indent_level>0&&this.indent_level--}},this}var o,i,r,a,s;for(t=t||{},i=t.indent_size||4,r=t.indent_char||" ",s=t.brace_style||"collapse",a=0==t.max_char?1/0:t.max_char||70,unformatted=t.unformatted||["a"],o=new n,o.printer(e,r,i,a,s);;){var c=o.get_token();if(o.token_text=c[0],o.token_type=c[1],"TK_EOF"===o.token_type)break;switch(o.token_type){case"TK_TAG_START":o.print_newline(!1,o.output),o.print_token(o.token_text),o.indent(),o.current_mode="CONTENT";break;case"TK_TAG_STYLE":case"TK_TAG_SCRIPT":o.print_newline(!1,o.output),o.print_token(o.token_text),o.current_mode="CONTENT";break;case"TK_TAG_END":if("TK_CONTENT"===o.last_token&&""===o.last_text){var u=o.token_text.match(/\w+/)[0],m=o.output[o.output.length-1].match(/<\s*(\w+)/);(null===m||m[1]!==u)&&o.print_newline(!0,o.output)}o.print_token(o.token_text),o.current_mode="CONTENT";break;case"TK_TAG_SINGLE":o.print_newline(!1,o.output),o.print_token(o.token_text),o.current_mode="CONTENT";break;case"TK_CONTENT":""!==o.token_text&&o.print_token(o.token_text),o.current_mode="TAG";break;case"TK_STYLE":case"TK_SCRIPT":if(""!==o.token_text){o.output.push("\n");var l=o.token_text;if("TK_SCRIPT"==o.token_type)var p="function"==typeof js_beautify&&js_beautify;else if("TK_STYLE"==o.token_type)var p="function"==typeof css_beautify&&css_beautify;if("keep"==t.indent_scripts)var h=0;else if("separate"==t.indent_scripts)var h=-o.indent_level;else var h=1;var d=o.get_full_indent(h);if(p)l=p(l.replace(/^\s*/,d),t);else{var f=l.match(/^\s*/)[0],g=f.match(/[^\n\r]*$/)[0].split(o.indent_string).length-1,x=o.get_full_indent(h-g);l=l.replace(/^\s*/,d).replace(/\r\n|\r|\n/g,"\n"+x).replace(/\s*$/,"")}l&&(o.print_token(l),o.print_newline(!0,o.output))}o.current_mode="TAG"}o.last_token=o.token_type,o.last_text=o.token_text}return o.output.join("")}function css_beautify(e,t){function n(){return h=e.charAt(++f)}function o(){return e.charAt(f+1)}function i(t){for(var o=f;n();)if("\\"==h)n(),n();else{if(h==t)break;if("\n"==h)break}return e.substring(o,f+1)}function r(){for(var e=f;d.test(o());)f++;return f!=e}function a(){var e=f;do;while(d.test(n()));return f!=e+1}function s(){var t=f;for(n();n();)if("*"==h&&"/"==o()){f++;break}return e.substring(t,f+1)}function c(e,t){return v.slice(-e.length+(t||0),t).join("").toLowerCase()==e}function u(){y++,g+=x}function m(){y--,g=g.slice(0,-l)}t=t||{};var l=t.indent_size||4,p=t.indent_char||" ";"string"==typeof l&&(l=parseInt(l));var h,d=/^\s+$/,f=-1,g=e.match(/^[\r\n]*[\t ]*/)[0],x=Array(l+1).join(p),y=0;print={},print["{"]=function(e){print.singleSpace(),v.push(e),print.newLine()},print["}"]=function(e){print.newLine(),v.push(e),print.newLine()},print.newLine=function(e){if(!e)for(;d.test(v[v.length-1]);)v.pop();v.length&&v.push("\n"),g&&v.push(g)},print.singleSpace=function(){v.length&&!d.test(v[v.length-1])&&v.push(" ")};var v=[];for(g&&v.push(g);;){var b=a();if(!h)break;"{"==h?(u(),print["{"](h)):"}"==h?(m(),print["}"](h)):'"'==h||"'"==h?v.push(i(h)):";"==h?v.push(h,"\n",g):"/"==h&&"*"==o()?(print.newLine(),v.push(s(),"\n",g)):"("==h?(v.push(h),r(),c("url",-1)&&n()&&(")"!=h&&'"'!=h&&"'"!=h?v.push(i(")")):f--)):")"==h?v.push(h):","==h?(r(),v.push(h),print.singleSpace()):"]"==h?v.push(h):"["==h||"="==h?(r(),v.push(h)):(b&&print.singleSpace(),v.push(h))}var _=v.join("").replace(/[\n ]+$/,"");return _}var IO=window.IO={events:{},preventDefault:!1,register:function(e,t,n){return this.events[e]||(this.events[e]=[]),this.events[e].push({fun:t,thisArg:n,args:Array.prototype.slice.call(arguments,3)}),this},unregister:function(e,t){return this.events[e]?(this.events[e]=this.events[e].filter(function(e){return e.fun!==t}),this):this},fire:function(e){function t(e){var t=e.fun.apply(e.thisArg,e.args.concat(n));o.preventDefault=t===!1}if(this.preventDefault=!1,this.events[e]){var n=Array.prototype.slice.call(arguments,1),o=this;this.events[e].forEach(t)}},urlstringify:function(){var e={number:!0,string:!0,"boolean":!0},t=function(t){return typeof t in e?encodeURIComponent(""+t):""},n=function(e,n){return e=t(e),n.map(function(t){return o(e,t,!0)}).join("&")},o=function(e,n,o){return o||(e=t(e)),e+"="+t(n)};return function(e){return Object.keys(e).map(function(t){var i=e[t];return Array.isArray(i)?n(t,i):o(t,i)}).join("&")}}(),loadScript:function(e,t){var n=document.createElement("script");n.src=e,n.onload=t,document.head.appendChild(n)}};IO.decodehtmlEntities=function(){var e;e={quot:'"',amp:"&",apos:"'",lt:"<",gt:">",nbsp:" ",iexcl:"¡",cent:"¢",pound:"£",curren:"¤",yen:"¥",brvbar:"¦",sect:"§",uml:"¨",copy:"©",ordf:"ª",laquo:"«",not:"¬",reg:"®",macr:"¯",deg:"°",plusmn:"±",sup2:"²",sup3:"³",acute:"´",micro:"µ",para:"¶",middot:"·",cedil:"¸",sup1:"¹",ordm:"º",raquo:"»",frac14:"¼",frac12:"½",frac34:"¾",iquest:"¿",Agrave:"À",Aacute:"Á",Acirc:"Â",Atilde:"Ã",Auml:"Ä",Aring:"Å",AElig:"Æ",Ccedil:"Ç",Egrave:"È",Eacute:"É",Ecirc:"Ê",Euml:"Ë",Igrave:"Ì",Iacute:"Í",Icirc:"Î",Iuml:"Ï",ETH:"Ð",Ntilde:"Ñ",Ograve:"Ò",Oacute:"Ó",Ocirc:"Ô",Otilde:"Õ",Ouml:"Ö",times:"×",Oslash:"Ø",Ugrave:"Ù",Uacute:"Ú",Ucirc:"Û",Uuml:"Ü",Yacute:"Ý",THORN:"Þ",szlig:"ß",agrave:"à",aacute:"á",acirc:"â",atilde:"ã",auml:"ä",aring:"å",aelig:"æ",ccedil:"ç",egrave:"è",eacute:"é",ecirc:"ê",euml:"ë",igrave:"ì",iacute:"í",icirc:"î",iuml:"ï",eth:"ð",ntilde:"ñ",ograve:"ò",oacute:"ó",ocirc:"ô",otilde:"õ",ouml:"ö",divide:"÷",oslash:"ø",ugrave:"ù",uacute:"ú",ucirc:"û",uuml:"ü",yacute:"ý",thorn:"þ",yuml:"ÿ",OElig:"Œ",oelig:"œ",Scaron:"Š",scaron:"š",Yuml:"Ÿ",fnof:"ƒ",circ:"ˆ",tilde:"˜",Alpha:"Α",Beta:"Β",Gamma:"Γ",Delta:"Δ",Epsilon:"Ε",Zeta:"Ζ",Eta:"Η",Theta:"Θ",Iota:"Ι",Kappa:"Κ",Lambda:"Λ",Mu:"Μ",Nu:"Ν",Xi:"Ξ",Omicron:"Ο",Pi:"Π",Rho:"Ρ",Sigma:"Σ",Tau:"Τ",Upsilon:"Υ",Phi:"Φ",Chi:"Χ",Psi:"Ψ",Omega:"Ω",alpha:"α",beta:"β",gamma:"γ",delta:"δ",epsilon:"ε",zeta:"ζ",eta:"η",theta:"θ",iota:"ι",kappa:"κ",lambda:"λ",mu:"μ",nu:"ν",xi:"ξ",omicron:"ο",pi:"π",rho:"ρ",sigmaf:"ς",sigma:"σ",tau:"τ",upsilon:"υ",phi:"φ",chi:"χ",psi:"ψ",omega:"ω",thetasym:"ϑ",upsih:"ϒ",piv:"ϖ",ensp:" ",emsp:" ",thinsp:" ",ndash:"–",mdash:"—",lsquo:"‘",rsquo:"’",sbquo:"‚",ldquo:"“",rdquo:"”",bdquo:"„",dagger:"†",Dagger:"‡",bull:"•",hellip:"…",permil:"‰",prime:"′",Prime:"″",lsaquo:"‹",rsaquo:"›",oline:"‾",frasl:"⁄",euro:"€",image:"ℑ",weierp:"℘",real:"ℜ",trade:"™",alefsym:"ℵ",larr:"←",uarr:"↑",rarr:"→",darr:"↓",harr:"↔",crarr:"↵",lArr:"⇐",uArr:"⇑",rArr:"⇒",dArr:"⇓",hArr:"⇔",forall:"∀",part:"∂",exist:"∃",empty:"∅",nabla:"∇",isin:"∈",notin:"∉",ni:"∋",prod:"∏",sum:"∑",minus:"−",lowast:"∗",radic:"√",prop:"∝",infin:"∞",ang:"∠",and:"∧",or:"∨",cap:"∩",cup:"∪","int":"∫",there4:"∴",sim:"∼",cong:"≅",asymp:"≈",ne:"≠",equiv:"≡",le:"≤",ge:"≥",sub:"⊂",sup:"⊃",nsub:"⊄",sube:"⊆",supe:"⊇",oplus:"⊕",otimes:"⊗",perp:"⊥",sdot:"⋅",lceil:"⌈",rceil:"⌉",lfloor:"⌊",rfloor:"⌋",lang:"〈",rang:"〉",loz:"◊",spades:"♠",clubs:"♣",hearts:"♥",diams:"♦"};var t=/&(#x?)?[\w;]+?;/g,n=function(e){return e.slice(1).split(";").map(o).join("")},o=function(t){return"#"===t[0]?i(t):e[t]||t},i=function(e){e=e.slice(1);var t;return t="x"===e[0]?parseInt(e.slice(1),16):parseInt(e,10),String.fromCharCode(t)};return function(e){return e.replace(t,n)}}(),["in","out"].forEach(function(e){var t=e+"put";IO[e]={buffer:[],receive:function(e){return IO.fire("receive"+t,e),IO.preventDefault?this:(this.buffer.push(e),this)},tick:function(){return this.buffer.length&&IO.fire(t,this.buffer.shift()),this},flush:function(){if(IO.fire("before"+t),!this.buffer.length)return this;for(var e=this.buffer.length;e-->0;)this.tick();return IO.fire("after"+t),this.buffer=[],this}}}),IO.xhr=function(e){e=Object.merge({method:"GET",headers:{},complete:function(){}},e),e.headers=Object.merge({"Content-Type":"application/x-www-form-urlencoded"},e.headers),"object"!=typeof e.data||e.data.charAt||(e.data=IO.urlstringify(e.data));var t=new XMLHttpRequest;return t.open(e.method,e.url),t.addEventListener("readystatechange",function(){4===t.readyState&&e.complete.call(e.thisArg,t.responseText,t)}),Object.keys(e.headers).forEach(function(n){t.setRequestHeader(n,e.headers[n])}),t.send(e.data),t},IO.jsonp=function(e){e.data=e.data||{},e.jsonpName=e.jsonpName||"jsonp";var t,n=document.createElement("script");do t="IO_"+Date.now()*Math.ceil(Math.random());while(window[t]);window[t]=function(){e.fun.apply(e.thisArg,arguments),delete window[t],n.parentNode.removeChild(n)},e.data[e.jsonpName]=t,-1===e.url.indexOf("?")&&(e.url+="?"),e.url+=this.urlstringify(e.data),n.src=e.url,document.head.appendChild(n)},IO.jsonp.define=function(e,t){IO.jsonp({url:"http://api.duckduckgo.com/",jsonpName:"callback",data:{format:"json",q:"define "+e},fun:t})},IO.jsonp.google=function(e,t){IO.jsonp({url:"http://ajax.googleapis.com/ajax/services/search/web",jsonpName:"callback",data:{v:"1.0",q:e},fun:t})},function(){"use strict";var e=window.bot={invocationPattern:"!!",commandRegex:/^\/\s?([\w\-]+)(?:\s(.+))?$/,commands:{},commandDictionary:null,listeners:[],parseMessage:function(t){if(!this.validateMessage(t))return e.log(t,"parseMessage invalid"),void 0;var n=this.prepareMessage(t);if(e.log(n,"parseMessage valid"),this.banlist.contains(n.get("user_id")))return e.log(t,"parseMessage banned"),n.reply("You iz in mindjail"),void 0;try{n.startsWith("/")?this.parseCommand(n):n.startsWith(">")?this.eval(n):this.callListeners(n)}catch(o){var i="Could not process input. Error: "+o.message;o.lineNumber&&(i+=" on line "+o.lineNumber),o.column&&(i+=" on column "+o.column),n.directreply(i),console.error(o,i)}},prepareMessage:function(e){e=this.adapter.transform(e);var t=IO.decodehtmlEntities(e.content);return this.Message(t.slice(this.invocationPattern.length).trim(),e)},parseCommand:function(t){e.log(t,"parseCommand input");var n=this.commandRegex.exec(t);if(!n)return t.reply("Invalid command "+t),void 0;var o=n[1].toLowerCase();e.log(n,"parseCommand matched");var i=this.getCommand(o);if(i.error)return t.reply(i.error),void 0;if(!i.canUse(t.get("user_id")))return t.reply("You do not have permission to use the command "+o),void 0;e.log(i,"parseCommand calling");var r=this.Message(t.slice(o.length+1).trim(),t.get()),a=i.exec(r);a&&t.reply(a)},validateMessage:function(e){var t=e.content.trim();return t.startsWith(this.invocationPattern)},commandExists:function(e){return this.commands.hasOwnProperty(e)},getCommand:function(e){if(this.commandExists(e))return this.commands[e];this.commandDictionary.maxCost=Math.floor(e.length/5+1);var t="Command "+e+" does not exist.",n=this.commandDictionary.search(e);return n.length&&(t+=" Did you mean: "+n.join(", ")),{error:t}},listen:function(e,t,n){Array.isArray(e)?e.forEach(function(e){this.listen(e,t,n)},this):this.listeners.push({pattern:e,fun:t,thisArg:n})},callListeners:function(t){var n=!1;this.listeners.forEach(function(o){var i,r=t.exec(o.pattern);r&&(i=o.fun.call(o.thisArg,t),e.log(r,i),i&&t.reply(i),i!==!1&&(n=!0))}),n||t.reply("Y U NO MAEK SENSE!? Could not understand `"+t+"`")},reply:function(e,t){var n=this.adapter.reply(e,t);this.adapter.out.add(n,t.room_id)},directreply:function(e,t){var n=this.adapter.directreply(e,t);this.adapter.out.add(n,t.room_id)},addCommand:function(e){e.exec&&e.del||(e=this.Command(e)),this.commands[e.name]=e,this.commandDictionary.trie.add(e.name)},stoplog:!1,log:function(){this.stoplog||console.log.apply(console,arguments)},stop:function(){this.stopped=!0},"continue":function(){this.stopped=!1}};e.banlist=[],e.banlist.contains=function(e){return this.indexOf(e)>=0},e.banlist.add=function(e){return this.push(e)},e.banlist.remove=function(e){var t=this.indexOf(e);return t>=0?this.splice(t,1):null},e.eval=function(e){function t(t){r.terminate(),e.directreply(t)}function n(e){var t,n=e.answer,i=e.log;return t=o(n),i&&i.length&&(t+=" Logged: "+o(i)+""),t}function o(e){var t;return t=e.length>400?"(snip) `"+e.slice(0,400)+"`":"`"+e+"`"}var i,r=new Worker("codeWorker.js");r.onmessage=function(e){clearTimeout(i),t(n(e.data))},r.onerror=function(e){clearTimeout(i),t(""+e)},r.postMessage({code:e.content.substr(1)}),i=window.setTimeout(function(){t("Maximum execution time exceeded")},50)},e.Command=function(t){return t.name=t.name.toLowerCase(),t.permissions=t.permissions||{},t.permissions.use=t.permissions.use||"ALL",t.permissions.del=t.permissions.del||"NONE",t.description=t.description||"",["Use","Del"].forEach(function(e){var n=e.toLowerCase();t["can"+e]=function(e){var t=this.permissions[n];return"ALL"===t||"NONE"!==t&&t.indexOf(e)>-1}}),t.exec=function(){return this.fun.apply(this.thisArg,arguments)},t.del=function(){delete e.commands[t.name]},t},e.Message=function(t,n){var o=Object(t);o.content=t;var i={respond:function(t){e.adapter.out.add(t,n.room_id)},reply:function(t,o){o=o||n.user_name,e.reply(t,Object.merge(n,{user_name:o}))},directreply:function(t,o){o=o||n.message_id,e.directreply(t,Object.merge(n,{message_id:o}))},parse:function(o,i){!!o===o&&(i=o,o=t);var r=e.parseCommandArgs(o||t);return i?r.map(function(t){return e.Message(t,n)}):r},exec:function(e){var n=e.exec(t);return this.matches=n?n:[],n},findUserid:function(e){var t=[].slice.call(document.getElementById("sidebar").getElementsByClassName("user-container")),n=t.map(function(e){return e.id.match(/\d+/)[0]}),o=t.map(function(e){return e.getElementsByTagName("img")[0].title.toLowerCase()}),i=o.indexOf((""+e).toLowerCase());return 0>i?void 0:Number(n[i])}.memoize(),codify:e.adapter.codify.bind(e.adapter),escape:e.adapter.escape.bind(e.adapter),link:e.adapter.link.bind(e.adapter),get:function(e){return e?n[e]:n},set:function(e,t){return n[e]=t}};return Object.keys(i).forEach(function(e){o[e]=i[e]}),o},e.owners=[419970,342129,170224,94197,617762],e.isOwner=function(e){return this.owners.indexOf(e)>-1},IO.register("input",e.parseMessage,e),Object.merge=function(){return[].reduce.call(arguments,function(e,t){return Object.keys(t).forEach(function(n){e[n]=t[n]}),e},{})},String.prototype.indexesOf=function(e,t){for(var n=(t||0)-1,o=[];(n=this.indexOf(e,n+1))>-1;)o.push(n);return o},String.prototype.startsWith=function(e){return 0===this.indexOf(e)},Object.defineProperty(Array.prototype,"invoke",{value:function(e){var t=[].slice.call(arguments,1);return this.map(function(n){var o=n;return n[e]&&n[e].apply&&(o=n[e].apply(n,t)),o})},configurable:!0,writable:!0}),Object.defineProperty(Array.prototype,"first",{value:function(e){return this.some(function(t){return e.apply(null,arguments)&&((e=t)||!0)})?e:null},configurable:!0,writable:!0}),Function.prototype.memoize=function(){var e=Object.create(null),t=this;return function(n){if(n in e)return e[n];var o=t.apply(null,arguments);return e[n]=o,o}},Function.prototype.memoizeAsync=function(e){var t=Object.create(null),n=this,e=e||function(e){return e};return function(){function o(){t[a]=arguments,r.apply(null,arguments)}var i=[].slice.call(arguments),r=i.pop(),a=e.apply(null,arguments);return a in t?(r.apply(null,t[a]),void 0):(i.push(o),n.apply(this,i),void 0)}},Number.prototype.maxDecimal=function(e){var t=Math.pow(10,e);return Math.floor(this*t)/t},Math.ratio=function(e,t){e=Number(e),t=Number(t);var n=this.gcd(e,t);return e/n+":"+t/n},Math.gcd=function(e,t){return t?this.gcd(t,e%t):e},String.prototype.supplant=function(e){function t(t,n){return e.hasOwnProperty(n)?e[n]:t}return this.replace(/\{([^\}]+)\}/g,t)},String.prototype.add=function(e,t){return this+e+(t?"":"\n")},function(){var t;t=e!==void 0?e:"undefined"!=typeof exports?exports:window,t.parseCommandArgs=function(){var e=0,t=1,n=2,o=3,i="'",r='"',a={parse:function(t,n,o){this.source=t,this.pos=0,this.length=t.length,this.state=e,this.lookahead="",this.escaper=o||"~",this.separator=n||" "; +function js_beautify(e,t){function n(e){for(e=e===void 0?!1:e;_.length&&(" "===_[_.length-1]||_[_.length-1]===w||_[_.length-1]===G||e&&("\n"===_[_.length-1]||"\r"===_[_.length-1]));)_.pop()}function o(e){return e.replace(/^\s\s*|\s\s*$/,"")}function i(e){e=e.replace(/\x0d/g,"");for(var t=[],n=e.indexOf("\n");-1!==n;)t.push(e.substring(0,n)),e=e.substring(n+1),n=e.indexOf("\n");return e.length&&t.push(e),t}function r(){var e=H;H=!1,a(),H=e}function a(e){if(C.eat_next_space=!1,(!H||!p(C.mode))&&(e=e===void 0?!0:e,C.if_line=!1,n(),_.length)){"\n"===_[_.length-1]&&e||(U=!0,_.push("\n")),G&&_.push(G);for(var t=0;C.indentation_level>t;t+=1)_.push(w);C.var_line&&C.var_line_reindented&&_.push(w),C.case_body&&_.push(w)}}function s(){if("TK_COMMENT"===T)return a();if(C.eat_next_space)return C.eat_next_space=!1,void 0;var e=" ";_.length&&(e=_[_.length-1])," "!==e&&"\n"!==e&&e!==w&&_.push(" ")}function c(){U=!1,C.eat_next_space=!1,_.push(O)}function u(){C.indentation_level+=1}function m(){_.length&&_[_.length-1]===w&&_.pop()}function l(e){C&&A.push(C),C={previous_mode:C?C.mode:"BLOCK",mode:e,var_line:!1,var_line_tainted:!1,var_line_reindented:!1,in_html_comment:!1,if_line:!1,in_case_statement:!1,in_case:!1,case_body:!1,eat_next_space:!1,indentation_baseline:-1,indentation_level:C?C.indentation_level+(C.case_body?1:0)+(C.var_line&&C.var_line_reindented?1:0):0,ternary_depth:0}}function p(e){return"[EXPRESSION]"===e||"[INDENTED-EXPRESSION]"===e}function h(e){return x(e,["[EXPRESSION]","(EXPRESSION)","(FOR-EXPRESSION)","(COND-EXPRESSION)"])}function d(){if(L="DO_BLOCK"===C.mode,A.length>0){var e=C.mode;C=A.pop(),C.previous_mode=e}}function f(e,t){for(var n=0;e.length>n;n++){var i=o(e[n]);if(i.charAt(0)!==t)return!1}return!0}function g(e){return x(e,["case","return","do","if","throw","else"])}function x(e,t){for(var n=0;t.length>n;n+=1)if(t[n]===e)return!0;return!1}function y(e){for(var t=R,n=b.charAt(t);x(n,I)&&n!==e;){if(t++,t>=Z)return 0;n=b.charAt(t)}return n}function v(){var e,t;if(F=0,R>=Z)return["","TK_EOF"];B=!1;var i=b.charAt(R);R+=1;var r=H&&p(C.mode);if(r){for(var s=0;x(i,I);){if("\n"===i?(n(),_.push("\n"),U=!0,s=0):" "===i?s+=4:"\r"===i||(s+=1),R>=Z)return["","TK_EOF"];i=b.charAt(R),R+=1}if(-1===C.indentation_baseline&&(C.indentation_baseline=s),U){for(e=0;C.indentation_level+1>e;e+=1)_.push(w);if(-1!==C.indentation_baseline)for(e=0;s-C.indentation_baseline>e;e++)_.push(" ")}}else{for(;x(i,I);){if("\n"===i&&(F+=V?V>=F?1:0:1),R>=Z)return["","TK_EOF"];i=b.charAt(R),R+=1}if(Y&&F>1)for(e=0;F>e;e+=1)a(0===e),U=!0;B=F>0}if(x(i,k)){if(Z>R)for(;x(b.charAt(R),k)&&(i+=b.charAt(R),R+=1,R!==Z););if(R!==Z&&i.match(/^[0-9]+[Ee]$/)&&("-"===b.charAt(R)||"+"===b.charAt(R))){var c=b.charAt(R);R+=1;var u=v();return i+=c+u[0],[i,"TK_WORD"]}return"in"===i?[i,"TK_OPERATOR"]:(!B||"TK_OPERATOR"===T||"TK_EQUALS"===T||C.if_line||!Y&&"var"===E||a(),[i,"TK_WORD"])}if("("===i||"["===i)return[i,"TK_START_EXPR"];if(")"===i||"]"===i)return[i,"TK_END_EXPR"];if("{"===i)return[i,"TK_START_BLOCK"];if("}"===i)return[i,"TK_END_BLOCK"];if(";"===i)return[i,"TK_SEMICOLON"];if("/"===i){var m="",l=!0;if("*"===b.charAt(R)){if(R+=1,Z>R)for(;Z>R&&("*"!==b.charAt(R)||!b.charAt(R+1)||"/"!==b.charAt(R+1))&&(i=b.charAt(R),m+=i,("\n"===i||"\r"===i)&&(l=!1),R+=1,!(R>=Z)););return R+=2,l&&0===F?["/*"+m+"*/","TK_INLINE_COMMENT"]:["/*"+m+"*/","TK_BLOCK_COMMENT"]}if("/"===b.charAt(R)){for(m=i;"\r"!==b.charAt(R)&&"\n"!==b.charAt(R)&&(m+=b.charAt(R),R+=1,!(R>=Z)););return B&&a(),[m,"TK_COMMENT"]}}if("'"===i||'"'===i||"/"===i&&("TK_WORD"===T&&g(E)||")"===E&&x(C.previous_mode,["(COND-EXPRESSION)","(FOR-EXPRESSION)"])||"TK_COMMA"===T||"TK_COMMENT"===T||"TK_START_EXPR"===T||"TK_START_BLOCK"===T||"TK_END_BLOCK"===T||"TK_OPERATOR"===T||"TK_EQUALS"===T||"TK_EOF"===T||"TK_SEMICOLON"===T)){var h=i,d=!1,f=0,y=0;if(t=i,Z>R)if("/"===h){for(var O=!1;d||O||b.charAt(R)!==h;)if(t+=b.charAt(R),d?d=!1:(d="\\"===b.charAt(R),"["===b.charAt(R)?O=!0:"]"===b.charAt(R)&&(O=!1)),R+=1,R>=Z)return[t,"TK_STRING"]}else for(;d||b.charAt(R)!==h;)if(t+=b.charAt(R),f&&f>=y&&(f=parseInt(t.substr(-y),16),f&&f>=32&&126>=f&&(f=String.fromCharCode(f),t=t.substr(0,t.length-y-2)+(f===h||"\\"===f?"\\":"")+f),f=0),f?f++:d?(d=!1,Q&&("x"===b.charAt(R)?(f++,y=2):"u"===b.charAt(R)&&(f++,y=4))):d="\\"===b.charAt(R),R+=1,R>=Z)return[t,"TK_STRING"];if(R+=1,t+=h,"/"===h)for(;Z>R&&x(b.charAt(R),k);)t+=b.charAt(R),R+=1;return[t,"TK_STRING"]}if("#"===i){if(0===_.length&&"!"===b.charAt(R)){for(t=i;Z>R&&"\n"!==i;)i=b.charAt(R),t+=i,R+=1;return _.push(o(t)+"\n"),a(),v()}var N="#";if(Z>R&&x(b.charAt(R),P)){do i=b.charAt(R),N+=i,R+=1;while(Z>R&&"#"!==i&&"="!==i);return"#"===i||("["===b.charAt(R)&&"]"===b.charAt(R+1)?(N+="[]",R+=2):"{"===b.charAt(R)&&"}"===b.charAt(R+1)&&(N+="{}",R+=2)),[N,"TK_WORD"]}}if("<"===i&&""===b.substring(R-1,R+2))return C.in_html_comment=!1,R+=2,B&&a(),["-->","TK_COMMENT"];if(x(i,j)){for(;Z>R&&x(i+b.charAt(R),j)&&(i+=b.charAt(R),R+=1,!(R>=Z)););return","===i?[i,"TK_COMMA"]:"="===i?[i,"TK_EQUALS"]:[i,"TK_OPERATOR"]}return[i,"TK_UNKNOWN"]}var b,_,O,T,E,N,S,C,A,w,I,k,j,R,D,P,M,K,L,B,U,F,G="";t=t?t:{};var X;void 0!==t.space_after_anon_function&&void 0===t.jslint_happy&&(t.jslint_happy=t.space_after_anon_function),void 0!==t.braces_on_own_line&&(X=t.braces_on_own_line?"expand":"collapse"),X=t.brace_style?t.brace_style:X?X:"collapse";var q=t.indent_size?t.indent_size:4,W=t.indent_char?t.indent_char:" ",Y=t.preserve_newlines===void 0?!0:t.preserve_newlines,V=t.max_preserve_newlines===void 0?!1:t.max_preserve_newlines,z="undefined"===t.jslint_happy?!1:t.jslint_happy,H=t.keep_array_indentation===void 0?!1:t.keep_array_indentation,J=t.space_before_conditional===void 0?!0:t.space_before_conditional,$=t.indent_case===void 0?!1:t.indent_case,Q=t.unescape_strings===void 0?!1:t.unescape_strings;U=!1;var Z=e.length;for(w="";q>0;)w+=W,q-=1;for(;e&&(" "===e.charAt(0)||" "===e.charAt(0));)G+=e.charAt(0),e=e.substring(1);for(b=e,S="",T="TK_START_EXPR",E="",N="",_=[],L=!1,I="\n\r ".split(""),k="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_$".split(""),P="0123456789".split(""),j="+ - * / % & ++ -- = += -= *= /= %= == === != !== > < >= <= >> << >>> >>>= >>= <<= && &= | || ! !! , : ? ^ ^= |= ::",j+=" <%= <% %> ",j=j.split(" "),D="continue,try,throw,return,var,if,switch,case,default,for,while,break,function".split(","),A=[],l("BLOCK"),R=0;;){var et=v();if(O=et[0],K=et[1],"TK_EOF"===K)break;switch(K){case"TK_START_EXPR":if("["===O){if("TK_WORD"===T||")"===E){x(E,D)&&s(),l("(EXPRESSION)"),c();break}"[EXPRESSION]"===C.mode||"[INDENTED-EXPRESSION]"===C.mode?"]"===N&&","===E?("[EXPRESSION]"===C.mode&&(C.mode="[INDENTED-EXPRESSION]",H||u()),l("[EXPRESSION]"),H||a()):"["===E?("[EXPRESSION]"===C.mode&&(C.mode="[INDENTED-EXPRESSION]",H||u()),l("[EXPRESSION]"),H||a()):l("[EXPRESSION]"):l("[EXPRESSION]")}else"for"===S?l("(FOR-EXPRESSION)"):x(S,["if","while"])?l("(COND-EXPRESSION)"):l("(EXPRESSION)");";"===E||"TK_START_BLOCK"===T?a():"TK_END_EXPR"===T||"TK_START_EXPR"===T||"TK_END_BLOCK"===T||"."===E?B&&a():"TK_WORD"!==T&&"TK_OPERATOR"!==T?s():"function"===S||"typeof"===S?z&&s():(x(E,D)||"catch"===E)&&J&&s(),c();break;case"TK_END_EXPR":if("]"===O)if(H){if("}"===E){m(),c(),d();break}}else if("[INDENTED-EXPRESSION]"===C.mode&&"]"===E){d(),a(),c();break}d(),c();break;case"TK_START_BLOCK":if("do"===S?l("DO_BLOCK"):l("BLOCK"),"expand"===X||"expand-strict"===X){var tt=!1;"expand-strict"===X?(tt="}"===y(),tt||a(!0)):"TK_OPERATOR"!==T&&("="===E||g(E)&&"else"!==E?s():a(!0)),c(),tt||u()}else"TK_OPERATOR"!==T&&"TK_START_EXPR"!==T?"TK_START_BLOCK"===T?a():s():p(C.previous_mode)&&","===E&&("}"===N?s():a()),u(),c();break;case"TK_END_BLOCK":d(),"expand"===X||"expand-strict"===X?("{"!==E&&a(),c()):("TK_START_BLOCK"===T?U?m():n():p(C.mode)&&H?(H=!1,a(),H=!0):a(),c());break;case"TK_WORD":if(L){s(),c(),s(),L=!1;break}if(M="NONE","function"===O){if(C.var_line&&"TK_EQUALS"!==T&&(C.var_line_reindented=!0),(U||";"===E)&&"{"!==E&&"TK_BLOCK_COMMENT"!==T&&"TK_COMMENT"!==T){F=U?F:0,Y||(F=1);for(var nt=0;2-F>nt;nt++)a(!1)}"TK_WORD"===T?"get"===E||"set"===E||"new"===E||"return"===E?s():a():"TK_OPERATOR"===T||"="===E?s():h(C.mode)||a(),c(),S=O;break}if("case"===O||"default"===O&&C.in_case_statement){":"===E||C.case_body?m():($||C.indentation_level--,a(),$||C.indentation_level++),c(),C.in_case=!0,C.in_case_statement=!0,C.case_body=!1;break}"TK_END_BLOCK"===T?x(O.toLowerCase(),["else","catch","finally"])?"expand"===X||"end-expand"===X||"expand-strict"===X?M="NEWLINE":(M="SPACE",s()):M="NEWLINE":"TK_SEMICOLON"!==T||"BLOCK"!==C.mode&&"DO_BLOCK"!==C.mode?"TK_SEMICOLON"===T&&h(C.mode)?M="SPACE":"TK_STRING"===T?M="NEWLINE":"TK_WORD"===T?("else"===E&&n(!0),M="SPACE"):"TK_START_BLOCK"===T?M="NEWLINE":"TK_END_EXPR"===T&&(s(),M="NEWLINE"):M="NEWLINE",x(O,D)&&")"!==E&&(M="else"===E?"SPACE":"NEWLINE"),C.if_line&&"TK_END_EXPR"===T&&(C.if_line=!1),x(O.toLowerCase(),["else","catch","finally"])?"TK_END_BLOCK"!==T||"expand"===X||"end-expand"===X||"expand-strict"===X?a():(n(!0),s()):"NEWLINE"===M?g(E)?s():"TK_END_EXPR"!==T?"TK_START_EXPR"===T&&"var"===O||":"===E||("if"===O&&"else"===S&&"{"!==E?s():(C.var_line=!1,C.var_line_reindented=!1,a())):x(O,D)&&")"!==E&&(C.var_line=!1,C.var_line_reindented=!1,a()):p(C.mode)&&","===E&&"}"===N?a():"SPACE"===M&&s(),c(),S=O,"var"===O&&(C.var_line=!0,C.var_line_reindented=!1,C.var_line_tainted=!1),"if"===O&&(C.if_line=!0),"else"===O&&(C.if_line=!1);break;case"TK_SEMICOLON":c(),C.var_line=!1,C.var_line_reindented=!1,"OBJECT"===C.mode&&(C.mode="BLOCK");break;case"TK_STRING":"TK_END_EXPR"===T&&x(C.previous_mode,["(COND-EXPRESSION)","(FOR-EXPRESSION)"])?s():"TK_COMMENT"===T||"TK_STRING"===T||"TK_START_BLOCK"===T||"TK_END_BLOCK"===T||"TK_SEMICOLON"===T?a():"TK_WORD"===T&&s(),c();break;case"TK_EQUALS":C.var_line&&(C.var_line_tainted=!0),s(),c(),s();break;case"TK_COMMA":if(C.var_line){if((h(C.mode)||"TK_END_BLOCK"===T)&&(C.var_line_tainted=!1),C.var_line_tainted){c(),C.var_line_reindented=!0,C.var_line_tainted=!1,a();break}C.var_line_tainted=!1,c(),s();break}"TK_COMMENT"===T&&a(),"TK_END_BLOCK"===T&&"(EXPRESSION)"!==C.mode?(c(),"OBJECT"===C.mode&&"}"===E?a():s()):"OBJECT"===C.mode?(c(),a()):(c(),s());break;case"TK_OPERATOR":var ot=!0,it=!0;if(g(E)){s(),c();break}if("*"===O&&"TK_UNKNOWN"===T&&!N.match(/^\d+$/)){c();break}if(":"===O&&C.in_case){$&&(C.case_body=!0),c(),a(),C.in_case=!1;break}if("::"===O){c();break}x(O,["--","++","!"])||x(O,["-","+"])&&(x(T,["TK_START_BLOCK","TK_START_EXPR","TK_EQUALS","TK_OPERATOR"])||x(E,D))?(ot=!1,it=!1,";"===E&&h(C.mode)&&(ot=!0),"TK_WORD"===T&&x(E,D)&&(ot=!0),"BLOCK"!==C.mode||"{"!==E&&";"!==E||a()):"."===O?ot=!1:":"===O?0===C.ternary_depth?("BLOCK"===C.mode&&(C.mode="OBJECT"),ot=!1):C.ternary_depth-=1:"?"===O&&(C.ternary_depth+=1),ot&&s(),c(),it&&s();break;case"TK_BLOCK_COMMENT":var rt,at=i(O);if(f(at.slice(1),"*"))for(a(),_.push(at[0]),rt=1;at.length>rt;rt++)a(),_.push(" "),_.push(o(at[rt]));else for(at.length>1?a():"TK_END_BLOCK"===T?a():s(),rt=0;at.length>rt;rt++)_.push(at[rt]),_.push("\n");"\n"!==y("\n")&&a();break;case"TK_INLINE_COMMENT":s(),c(),h(C.mode)?s():r();break;case"TK_COMMENT":","!==E||B||n(!0),"TK_COMMENT"!==T&&(B?a():s()),c(),a();break;case"TK_UNKNOWN":g(E)&&s(),c()}N=E,T=K,E=O}var st=G+_.join("").replace(/[\r\n ]+$/,"");return st}function style_html(e,t){function n(){return this.pos=0,this.token="",this.current_mode="CONTENT",this.tags={parent:"parent1",parentcount:1,parent1:""},this.tag_type="",this.token_text=this.last_token=this.last_text=this.token_type="",this.Utils={whitespace:"\n\r ".split(""),single_token:"br,input,link,meta,!doctype,basefont,base,area,hr,wbr,param,img,isindex,?xml,embed".split(","),extra_liners:"head,body,/html".split(","),in_array:function(e,t){for(var n=0;t.length>n;n++)if(e===t[n])return!0;return!1}},this.get_content=function(){for(var e="",t=[],n=!1;"<"!==this.input.charAt(this.pos);){if(this.pos>=this.input.length)return t.length?t.join(""):["","TK_EOF"];if(e=this.input.charAt(this.pos),this.pos++,this.line_char_count++,this.Utils.in_array(e,this.Utils.whitespace))t.length&&(n=!0),this.line_char_count--;else{if(n){if(this.line_char_count>=this.max_char){t.push("\n");for(var o=0;this.indent_level>o;o++)t.push(this.indent_string);this.line_char_count=0}else t.push(" "),this.line_char_count++;n=!1}t.push(e)}}return t.length?t.join(""):""},this.get_contents_to=function(e){if(this.pos==this.input.length)return["","TK_EOF"];var t="",n=RegExp("","igm");n.lastIndex=this.pos;var o=n.exec(this.input),i=o?o.index:this.input.length;return i>this.pos&&(t=this.input.substring(this.pos,i),this.pos=i),t},this.record_tag=function(e){this.tags[e+"count"]?(this.tags[e+"count"]++,this.tags[e+this.tags[e+"count"]]=this.indent_level):(this.tags[e+"count"]=1,this.tags[e+this.tags[e+"count"]]=this.indent_level),this.tags[e+this.tags[e+"count"]+"parent"]=this.tags.parent,this.tags.parent=e+this.tags[e+"count"]},this.retrieve_tag=function(e){if(this.tags[e+"count"]){for(var t=this.tags.parent;t&&e+this.tags[e+"count"]!==t;)t=this.tags[t+"parent"];t&&(this.indent_level=this.tags[e+this.tags[e+"count"]],this.tags.parent=this.tags[t+"parent"]),delete this.tags[e+this.tags[e+"count"]+"parent"],delete this.tags[e+this.tags[e+"count"]],1==this.tags[e+"count"]?delete this.tags[e+"count"]:this.tags[e+"count"]--}},this.get_tag=function(){var e="",t=[],n=!1;do{if(this.pos>=this.input.length)return t.length?t.join(""):["","TK_EOF"];e=this.input.charAt(this.pos),this.pos++,this.line_char_count++,this.Utils.in_array(e,this.Utils.whitespace)?(n=!0,this.line_char_count--):(("'"===e||'"'===e)&&(t[1]&&"!"===t[1]||(e+=this.get_unformatted(e),n=!0)),"="===e&&(n=!1),t.length&&"="!==t[t.length-1]&&">"!==e&&n&&(this.line_char_count>=this.max_char?(this.print_newline(!1,t),this.line_char_count=0):(t.push(" "),this.line_char_count++),n=!1),t.push(e))}while(">"!==e);var o,i=t.join("");o=-1!=i.indexOf(" ")?i.indexOf(" "):i.indexOf(">");var r=i.substring(1,o).toLowerCase();if("/"===i.charAt(i.length-2)||this.Utils.in_array(r,this.Utils.single_token))this.tag_type="SINGLE";else if("script"===r)this.record_tag(r),this.tag_type="SCRIPT";else if("style"===r)this.record_tag(r),this.tag_type="STYLE";else if(this.Utils.in_array(r,unformatted)){var a=this.get_unformatted("",i);t.push(a),this.tag_type="SINGLE"}else if("!"===r.charAt(0))if(-1!=r.indexOf("[if")){if(-1!=i.indexOf("!IE")){var a=this.get_unformatted("-->",i);t.push(a)}this.tag_type="START"}else if(-1!=r.indexOf("[endif"))this.tag_type="END",this.unindent();else if(-1!=r.indexOf("[cdata[")){var a=this.get_unformatted("]]>",i);t.push(a),this.tag_type="SINGLE"}else{var a=this.get_unformatted("-->",i);t.push(a),this.tag_type="SINGLE"}else"/"===r.charAt(0)?(this.retrieve_tag(r.substring(1)),this.tag_type="END"):(this.record_tag(r),this.tag_type="START"),this.Utils.in_array(r,this.Utils.extra_liners)&&this.print_newline(!0,this.output);return t.join("")},this.get_unformatted=function(e,t){if(t&&-1!=t.indexOf(e))return"";var n="",o="",i=!0;do{if(this.pos>=this.input.length)return o;if(n=this.input.charAt(this.pos),this.pos++,this.Utils.in_array(n,this.Utils.whitespace)){if(!i){this.line_char_count--;continue}if("\n"===n||"\r"===n){o+="\n",this.line_char_count=0;continue}}o+=n,this.line_char_count++,i=!0}while(-1==o.indexOf(e));return o},this.get_token=function(){var e;if("TK_TAG_SCRIPT"===this.last_token||"TK_TAG_STYLE"===this.last_token){var t=this.last_token.substr(7);return e=this.get_contents_to(t),"string"!=typeof e?e:[e,"TK_"+t]}if("CONTENT"===this.current_mode)return e=this.get_content(),"string"!=typeof e?e:[e,"TK_CONTENT"];if("TAG"===this.current_mode){if(e=this.get_tag(),"string"!=typeof e)return e;var n="TK_TAG_"+this.tag_type;return[e,n]}},this.get_full_indent=function(e){return e=this.indent_level+e||0,1>e?"":Array(e+1).join(this.indent_string)},this.printer=function(e,t,n,o,i){this.input=e||"",this.output=[],this.indent_character=t,this.indent_string="",this.indent_size=n,this.brace_style=i,this.indent_level=0,this.max_char=o,this.line_char_count=0;for(var r=0;this.indent_size>r;r++)this.indent_string+=this.indent_character;this.print_newline=function(e,t){if(this.line_char_count=0,t&&t.length){if(!e)for(;this.Utils.in_array(t[t.length-1],this.Utils.whitespace);)t.pop();t.push("\n");for(var n=0;this.indent_level>n;n++)t.push(this.indent_string)}},this.print_token=function(e){this.output.push(e)},this.indent=function(){this.indent_level++},this.unindent=function(){this.indent_level>0&&this.indent_level--}},this}var o,i,r,a,s;for(t=t||{},i=t.indent_size||4,r=t.indent_char||" ",s=t.brace_style||"collapse",a=0==t.max_char?1/0:t.max_char||70,unformatted=t.unformatted||["a"],o=new n,o.printer(e,r,i,a,s);;){var c=o.get_token();if(o.token_text=c[0],o.token_type=c[1],"TK_EOF"===o.token_type)break;switch(o.token_type){case"TK_TAG_START":o.print_newline(!1,o.output),o.print_token(o.token_text),o.indent(),o.current_mode="CONTENT";break;case"TK_TAG_STYLE":case"TK_TAG_SCRIPT":o.print_newline(!1,o.output),o.print_token(o.token_text),o.current_mode="CONTENT";break;case"TK_TAG_END":if("TK_CONTENT"===o.last_token&&""===o.last_text){var u=o.token_text.match(/\w+/)[0],m=o.output[o.output.length-1].match(/<\s*(\w+)/);(null===m||m[1]!==u)&&o.print_newline(!0,o.output)}o.print_token(o.token_text),o.current_mode="CONTENT";break;case"TK_TAG_SINGLE":o.print_newline(!1,o.output),o.print_token(o.token_text),o.current_mode="CONTENT";break;case"TK_CONTENT":""!==o.token_text&&o.print_token(o.token_text),o.current_mode="TAG";break;case"TK_STYLE":case"TK_SCRIPT":if(""!==o.token_text){o.output.push("\n");var l=o.token_text;if("TK_SCRIPT"==o.token_type)var p="function"==typeof js_beautify&&js_beautify;else if("TK_STYLE"==o.token_type)var p="function"==typeof css_beautify&&css_beautify;if("keep"==t.indent_scripts)var h=0;else if("separate"==t.indent_scripts)var h=-o.indent_level;else var h=1;var d=o.get_full_indent(h);if(p)l=p(l.replace(/^\s*/,d),t);else{var f=l.match(/^\s*/)[0],g=f.match(/[^\n\r]*$/)[0].split(o.indent_string).length-1,x=o.get_full_indent(h-g);l=l.replace(/^\s*/,d).replace(/\r\n|\r|\n/g,"\n"+x).replace(/\s*$/,"")}l&&(o.print_token(l),o.print_newline(!0,o.output))}o.current_mode="TAG"}o.last_token=o.token_type,o.last_text=o.token_text}return o.output.join("")}function css_beautify(e,t){function n(){return h=e.charAt(++f)}function o(){return e.charAt(f+1)}function i(t){for(var o=f;n();)if("\\"==h)n(),n();else{if(h==t)break;if("\n"==h)break}return e.substring(o,f+1)}function r(){for(var e=f;d.test(o());)f++;return f!=e}function a(){var e=f;do;while(d.test(n()));return f!=e+1}function s(){var t=f;for(n();n();)if("*"==h&&"/"==o()){f++;break}return e.substring(t,f+1)}function c(e,t){return v.slice(-e.length+(t||0),t).join("").toLowerCase()==e}function u(){y++,g+=x}function m(){y--,g=g.slice(0,-l)}t=t||{};var l=t.indent_size||4,p=t.indent_char||" ";"string"==typeof l&&(l=parseInt(l));var h,d=/^\s+$/,f=-1,g=e.match(/^[\r\n]*[\t ]*/)[0],x=Array(l+1).join(p),y=0;print={},print["{"]=function(e){print.singleSpace(),v.push(e),print.newLine()},print["}"]=function(e){print.newLine(),v.push(e),print.newLine()},print.newLine=function(e){if(!e)for(;d.test(v[v.length-1]);)v.pop();v.length&&v.push("\n"),g&&v.push(g)},print.singleSpace=function(){v.length&&!d.test(v[v.length-1])&&v.push(" ")};var v=[];for(g&&v.push(g);;){var b=a();if(!h)break;"{"==h?(u(),print["{"](h)):"}"==h?(m(),print["}"](h)):'"'==h||"'"==h?v.push(i(h)):";"==h?v.push(h,"\n",g):"/"==h&&"*"==o()?(print.newLine(),v.push(s(),"\n",g)):"("==h?(v.push(h),r(),c("url",-1)&&n()&&(")"!=h&&'"'!=h&&"'"!=h?v.push(i(")")):f--)):")"==h?v.push(h):","==h?(r(),v.push(h),print.singleSpace()):"]"==h?v.push(h):"["==h||"="==h?(r(),v.push(h)):(b&&print.singleSpace(),v.push(h))}var _=v.join("").replace(/[\n ]+$/,"");return _}var IO=window.IO={events:{},preventDefault:!1,register:function(e,t,n){return this.events[e]||(this.events[e]=[]),this.events[e].push({fun:t,thisArg:n,args:Array.prototype.slice.call(arguments,3)}),this},unregister:function(e,t){return this.events[e]?(this.events[e]=this.events[e].filter(function(e){return e.fun!==t}),this):this},fire:function(e){function t(e){var t=e.fun.apply(e.thisArg,e.args.concat(n));o.preventDefault=t===!1}if(this.preventDefault=!1,this.events[e]){var n=Array.prototype.slice.call(arguments,1),o=this;this.events[e].forEach(t)}},urlstringify:function(){var e={number:!0,string:!0,"boolean":!0},t=function(t){return typeof t in e?encodeURIComponent(""+t):""},n=function(e,n){return e=t(e),n.map(function(t){return o(e,t,!0)}).join("&")},o=function(e,n,o){return o||(e=t(e)),e+"="+t(n)};return function(e){return Object.keys(e).map(function(t){var i=e[t];return Array.isArray(i)?n(t,i):o(t,i)}).join("&")}}(),loadScript:function(e,t){var n=document.createElement("script");n.src=e,n.onload=t,document.head.appendChild(n)}};IO.decodehtmlEntities=function(){var e;e={quot:'"',amp:"&",apos:"'",lt:"<",gt:">",nbsp:" ",iexcl:"¡",cent:"¢",pound:"£",curren:"¤",yen:"¥",brvbar:"¦",sect:"§",uml:"¨",copy:"©",ordf:"ª",laquo:"«",not:"¬",reg:"®",macr:"¯",deg:"°",plusmn:"±",sup2:"²",sup3:"³",acute:"´",micro:"µ",para:"¶",middot:"·",cedil:"¸",sup1:"¹",ordm:"º",raquo:"»",frac14:"¼",frac12:"½",frac34:"¾",iquest:"¿",Agrave:"À",Aacute:"Á",Acirc:"Â",Atilde:"Ã",Auml:"Ä",Aring:"Å",AElig:"Æ",Ccedil:"Ç",Egrave:"È",Eacute:"É",Ecirc:"Ê",Euml:"Ë",Igrave:"Ì",Iacute:"Í",Icirc:"Î",Iuml:"Ï",ETH:"Ð",Ntilde:"Ñ",Ograve:"Ò",Oacute:"Ó",Ocirc:"Ô",Otilde:"Õ",Ouml:"Ö",times:"×",Oslash:"Ø",Ugrave:"Ù",Uacute:"Ú",Ucirc:"Û",Uuml:"Ü",Yacute:"Ý",THORN:"Þ",szlig:"ß",agrave:"à",aacute:"á",acirc:"â",atilde:"ã",auml:"ä",aring:"å",aelig:"æ",ccedil:"ç",egrave:"è",eacute:"é",ecirc:"ê",euml:"ë",igrave:"ì",iacute:"í",icirc:"î",iuml:"ï",eth:"ð",ntilde:"ñ",ograve:"ò",oacute:"ó",ocirc:"ô",otilde:"õ",ouml:"ö",divide:"÷",oslash:"ø",ugrave:"ù",uacute:"ú",ucirc:"û",uuml:"ü",yacute:"ý",thorn:"þ",yuml:"ÿ",OElig:"Œ",oelig:"œ",Scaron:"Š",scaron:"š",Yuml:"Ÿ",fnof:"ƒ",circ:"ˆ",tilde:"˜",Alpha:"Α",Beta:"Β",Gamma:"Γ",Delta:"Δ",Epsilon:"Ε",Zeta:"Ζ",Eta:"Η",Theta:"Θ",Iota:"Ι",Kappa:"Κ",Lambda:"Λ",Mu:"Μ",Nu:"Ν",Xi:"Ξ",Omicron:"Ο",Pi:"Π",Rho:"Ρ",Sigma:"Σ",Tau:"Τ",Upsilon:"Υ",Phi:"Φ",Chi:"Χ",Psi:"Ψ",Omega:"Ω",alpha:"α",beta:"β",gamma:"γ",delta:"δ",epsilon:"ε",zeta:"ζ",eta:"η",theta:"θ",iota:"ι",kappa:"κ",lambda:"λ",mu:"μ",nu:"ν",xi:"ξ",omicron:"ο",pi:"π",rho:"ρ",sigmaf:"ς",sigma:"σ",tau:"τ",upsilon:"υ",phi:"φ",chi:"χ",psi:"ψ",omega:"ω",thetasym:"ϑ",upsih:"ϒ",piv:"ϖ",ensp:" ",emsp:" ",thinsp:" ",ndash:"–",mdash:"—",lsquo:"‘",rsquo:"’",sbquo:"‚",ldquo:"“",rdquo:"”",bdquo:"„",dagger:"†",Dagger:"‡",bull:"•",hellip:"…",permil:"‰",prime:"′",Prime:"″",lsaquo:"‹",rsaquo:"›",oline:"‾",frasl:"⁄",euro:"€",image:"ℑ",weierp:"℘",real:"ℜ",trade:"™",alefsym:"ℵ",larr:"←",uarr:"↑",rarr:"→",darr:"↓",harr:"↔",crarr:"↵",lArr:"⇐",uArr:"⇑",rArr:"⇒",dArr:"⇓",hArr:"⇔",forall:"∀",part:"∂",exist:"∃",empty:"∅",nabla:"∇",isin:"∈",notin:"∉",ni:"∋",prod:"∏",sum:"∑",minus:"−",lowast:"∗",radic:"√",prop:"∝",infin:"∞",ang:"∠",and:"∧",or:"∨",cap:"∩",cup:"∪","int":"∫",there4:"∴",sim:"∼",cong:"≅",asymp:"≈",ne:"≠",equiv:"≡",le:"≤",ge:"≥",sub:"⊂",sup:"⊃",nsub:"⊄",sube:"⊆",supe:"⊇",oplus:"⊕",otimes:"⊗",perp:"⊥",sdot:"⋅",lceil:"⌈",rceil:"⌉",lfloor:"⌊",rfloor:"⌋",lang:"〈",rang:"〉",loz:"◊",spades:"♠",clubs:"♣",hearts:"♥",diams:"♦"};var t=/&(#x?)?[\w;]+?;/g,n=function(e){return e.slice(1).split(";").map(o).join("")},o=function(t){return"#"===t[0]?i(t):e[t]||t},i=function(e){e=e.slice(1);var t;return t="x"===e[0]?parseInt(e.slice(1),16):parseInt(e,10),String.fromCharCode(t)};return function(e){return e.replace(t,n)}}(),["in","out"].forEach(function(e){var t=e+"put";IO[e]={buffer:[],receive:function(e){return IO.fire("receive"+t,e),IO.preventDefault?this:(this.buffer.push(e),this)},tick:function(){return this.buffer.length&&IO.fire(t,this.buffer.shift()),this},flush:function(){if(IO.fire("before"+t),!this.buffer.length)return this;for(var e=this.buffer.length;e-->0;)this.tick();return IO.fire("after"+t),this.buffer=[],this}}}),IO.xhr=function(e){e=Object.merge({method:"GET",headers:{},complete:function(){}},e),e.headers=Object.merge({"Content-Type":"application/x-www-form-urlencoded"},e.headers),"object"!=typeof e.data||e.data.charAt||(e.data=IO.urlstringify(e.data));var t=new XMLHttpRequest;return t.open(e.method,e.url),t.addEventListener("readystatechange",function(){4===t.readyState&&e.complete.call(e.thisArg,t.responseText,t)}),Object.keys(e.headers).forEach(function(n){t.setRequestHeader(n,e.headers[n])}),t.send(e.data),t},IO.jsonp=function(e){e.data=e.data||{},e.jsonpName=e.jsonpName||"jsonp";var t,n=document.createElement("script");do t="IO_"+Date.now()*Math.ceil(Math.random());while(window[t]);window[t]=function(){e.fun.apply(e.thisArg,arguments),delete window[t],n.parentNode.removeChild(n)},e.data[e.jsonpName]=t,-1===e.url.indexOf("?")&&(e.url+="?"),e.url+=this.urlstringify(e.data),n.src=e.url,document.head.appendChild(n)},IO.jsonp.define=function(e,t){IO.jsonp({url:"http://api.duckduckgo.com/",jsonpName:"callback",data:{format:"json",q:"define "+e},fun:t})},IO.jsonp.google=function(e,t){IO.jsonp({url:"http://ajax.googleapis.com/ajax/services/search/web",jsonpName:"callback",data:{v:"1.0",q:e},fun:t})},function(){"use strict";var e=window.bot={invocationPattern:"!!",commandRegex:/^\/\s?([\w\-]+)(?:\s(.+))?$/,commands:{},commandDictionary:null,listeners:[],parseMessage:function(t){if(!this.validateMessage(t))return e.log(t,"parseMessage invalid"),void 0;var n=this.prepareMessage(t);if(e.log(n,"parseMessage valid"),this.banlist.contains(n.get("user_id")))return e.log(t,"parseMessage banned"),n.reply("You iz in mindjail"),void 0;try{n.startsWith("/")?this.parseCommand(n):n.startsWith(">")?this.eval(n):this.callListeners(n)}catch(o){var i="Could not process input. Error: "+o.message;o.lineNumber&&(i+=" on line "+o.lineNumber),o.column&&(i+=" on column "+o.column),n.directreply(i),console.error(o,i)}},prepareMessage:function(e){e=this.adapter.transform(e);var t=IO.decodehtmlEntities(e.content);return this.Message(t.slice(this.invocationPattern.length).trim(),e)},parseCommand:function(t){e.log(t,"parseCommand input");var n=this.commandRegex.exec(t);if(!n)return t.reply("Invalid command "+t),void 0;var o=n[1].toLowerCase();e.log(n,"parseCommand matched");var i=this.getCommand(o);if(i.error)return t.reply(i.error),void 0;if(!i.canUse(t.get("user_id")))return t.reply("You do not have permission to use the command "+o),void 0;e.log(i,"parseCommand calling");var r=this.Message(t.slice(o.length+1).trim(),t.get()),a=i.exec(r);a&&t.reply(a)},validateMessage:function(e){var t=e.content.trim();return t.startsWith(this.invocationPattern)},commandExists:function(e){return this.commands.hasOwnProperty(e)},getCommand:function(e){if(this.commandExists(e))return this.commands[e];this.commandDictionary.maxCost=Math.floor(e.length/5+1);var t="Command "+e+" does not exist.",n=this.commandDictionary.search(e);return n.length&&(t+=" Did you mean: "+n.join(", ")),{error:t}},listen:function(e,t,n){Array.isArray(e)?e.forEach(function(e){this.listen(e,t,n)},this):this.listeners.push({pattern:e,fun:t,thisArg:n})},callListeners:function(t){var n=!1;this.listeners.forEach(function(o){var i,r=t.exec(o.pattern);r&&(i=o.fun.call(o.thisArg,t),e.log(r,i),i&&t.reply(i),i!==!1&&(n=!0))}),n||t.reply("Y U NO MAEK SENSE!? Could not understand `"+t+"`")},reply:function(e,t){var n=this.adapter.reply(e,t);this.adapter.out.add(n,t.room_id)},directreply:function(e,t){var n=this.adapter.directreply(e,t);this.adapter.out.add(n,t.room_id)},addCommand:function(e){e.exec&&e.del||(e=this.Command(e)),this.commands[e.name]=e,this.commandDictionary.trie.add(e.name)},stoplog:!1,log:function(){this.stoplog||console.log.apply(console,arguments)},stop:function(){this.stopped=!0},"continue":function(){this.stopped=!1}};e.banlist=[],e.banlist.contains=function(e){return this.indexOf(e)>=0},e.banlist.add=function(e){return this.push(e)},e.banlist.remove=function(e){var t=this.indexOf(e);return t>=0?this.splice(t,1):null},e.eval=function(e){function t(t){r.terminate(),e.directreply(t)}function n(e){var t,n=e.answer,i=e.log;return t=o(n),i&&i.length&&(t+=" Logged: "+o(i)+""),t}function o(e){var t;return t=e.length>400?"(snip) `"+e.slice(0,400)+"`":"`"+e+"`"}var i,r=new Worker("codeWorker.js");r.onmessage=function(e){clearTimeout(i),t(n(e.data))},r.onerror=function(e){clearTimeout(i),t(""+e)},r.postMessage({code:e.content.substr(1)}),i=window.setTimeout(function(){t("Maximum execution time exceeded")},50)},e.Command=function(t){return t.name=t.name.toLowerCase(),t.permissions=t.permissions||{},t.permissions.use=t.permissions.use||"ALL",t.permissions.del=t.permissions.del||"NONE",t.description=t.description||"",["Use","Del"].forEach(function(e){var n=e.toLowerCase();t["can"+e]=function(e){var t=this.permissions[n];return"ALL"===t||"NONE"!==t&&t.indexOf(e)>-1}}),t.exec=function(){return this.fun.apply(this.thisArg,arguments)},t.del=function(){delete e.commands[t.name]},t},e.Message=function(t,n){var o=Object(t);o.content=t;var i={respond:function(t){e.adapter.out.add(t,n.room_id)},reply:function(t,o){o=o||n.user_name,e.reply(t,Object.merge(n,{user_name:o}))},directreply:function(t,o){o=o||n.message_id,e.directreply(t,Object.merge(n,{message_id:o}))},parse:function(o,i){!!o===o&&(i=o,o=t);var r=e.parseCommandArgs(o||t);return i?r.map(function(t){return e.Message(t,n)}):r},exec:function(e){var n=e.exec(t);return this.matches=n?n:[],n},findUserid:function(e){var t=[].slice.call(document.getElementById("sidebar").getElementsByClassName("user-container")),n=t.map(function(e){return e.id.match(/\d+/)[0]}),o=t.map(function(e){return e.getElementsByTagName("img")[0].title.toLowerCase()}),i=o.indexOf((""+e).toLowerCase());return 0>i?void 0:Number(n[i])}.memoize(),codify:e.adapter.codify.bind(e.adapter),escape:e.adapter.escape.bind(e.adapter),link:e.adapter.link.bind(e.adapter),get:function(e){return e?n[e]:n},set:function(e,t){return n[e]=t}};return Object.keys(i).forEach(function(e){o[e]=i[e]}),o},e.owners=[419970,342129,170224,94197,617762],e.isOwner=function(e){return this.owners.indexOf(e)>-1},IO.register("input",e.parseMessage,e),Object.merge=function(){return[].reduce.call(arguments,function(e,t){return Object.keys(t).forEach(function(n){e[n]=t[n]}),e},{})},String.prototype.indexesOf=function(e,t){for(var n=(t||0)-1,o=[];(n=this.indexOf(e,n+1))>-1;)o.push(n);return o},String.prototype.startsWith=function(e){return 0===this.indexOf(e)},Object.defineProperty(Array.prototype,"invoke",{value:function(e){var t=[].slice.call(arguments,1);return this.map(function(n){var o=n;return n[e]&&n[e].apply&&(o=n[e].apply(n,t)),o})},configurable:!0,writable:!0}),Object.defineProperty(Array.prototype,"first",{value:function(e){return this.some(function(t){return e.apply(null,arguments)&&((e=t)||!0)})?e:null},configurable:!0,writable:!0}),Function.prototype.memoize=function(){var e=Object.create(null),t=this;return function(n){if(n in e)return e[n];var o=t.apply(null,arguments);return e[n]=o,o}},Function.prototype.memoizeAsync=function(e){var t=Object.create(null),n=this,e=e||function(e){return e};return function(){function o(){t[a]=arguments,r.apply(null,arguments)}var i=[].slice.call(arguments),r=i.pop(),a=e.apply(null,arguments);return a in t?(r.apply(null,t[a]),void 0):(i.push(o),n.apply(this,i),void 0)}},Number.prototype.maxDecimal=function(e){var t=Math.pow(10,e);return Math.floor(this*t)/t},Math.ratio=function(e,t){e=Number(e),t=Number(t);var n=this.gcd(e,t);return e/n+":"+t/n},Math.gcd=function(e,t){return t?this.gcd(t,e%t):e},String.prototype.supplant=function(e){function t(t,n){return e.hasOwnProperty(n)?e[n]:t}return this.replace(/\{([^\}]+)\}/g,t)},String.prototype.add=function(e,t){return this+e+(t?"":"\n")},function(){var t;t=e!==void 0?e:"undefined"!=typeof exports?exports:window,t.parseCommandArgs=function(){var e=0,t=1,n=2,o=3,i="'",r='"',a={parse:function(t,n,o){this.source=t,this.pos=0,this.length=t.length,this.state=e,this.lookahead="",this.escaper=o||"~",this.separator=n||" "; var i=this.tokenize();return this.state!==e&&this.throwFinishError(),i},tokenize:function(){for(var e,t=[];this.length>this.pos;)e=this.nextArg(),e&&t.push(e);return t},nextArg:function(){var t,n="";for(this.state=e;;){if(t=this.nextChar(),null===t||this.state===o)break;n+=t}return n},nextChar:function(t){var n=this.lookahead=this.source[this.pos];return this.pos++,n?t?n:n===this.escaper?this.nextChar(!0):n===this.separator&&this.state===e?(this.state=o,n):this.string():null},string:function(){var e=this.lookahead;return e===i?this.singleQuotedString():e===r?this.doubleQuotedString():e},singleQuotedString:function(){return this.state===n?this.lookahead:(this.state=this.state!==t?t:e,this.nextChar())},doubleQuotedString:function(){return this.state===t?this.lookahead:(this.state=this.state!==n?n:e,this.nextChar())},throwFinishError:function(){var e="";this.state===t?e="Expected "+i:this.state===n&&(e="Expected "+r);var o=Error("Unexpected end of input: "+e);throw o.column=this.pos,o}};return function(){return a.parse.apply(a,arguments)}}()}();var t=function(){function e(){this.word=null,this.children={}}function t(n){if(!(this instanceof t))throw new TypeError("Illegal function call");if(n=parseInt(n,10),isNaN(n)||1>n)throw new TypeError("maxCost must be an integer > 1 ");this.maxCost=n,this.trie=new e}function n(e,t){var n,o,i,r=[];for(void 0===t?(i=0,o=e):(i=e,o=t-i),n=0;o>n;++n)r[n]=i++;return r}function o(e,t,o){var r=[],a=n(e.length+1);return Object.keys(o.children).forEach(function(n){i(o.children[n],n,e,a,r,t)}),r}function i(e,t,n,o,r,a){var s,c,u,m,l,p=n.length+1,h=[o[0]+1];for(s=1;p>s;++s)c=h[s-1]+1,u=o[s]+1,m=n.charAt(s-1)!==t?o[s-1]+1:o[s-1],h.push(Math.min(c,u,m));l=h[h.length-1],a>=l&&null!==e.word&&r.push([e.word,l]),a>=Math.min.apply(Math,h)&&Object.keys(e.children).forEach(function(t){i(e.children[t],t,n,h,r,a)})}return e.prototype.add=function(t){for(var n,o=this,i=0;n=t.charAt(i++);)n in o.children||(o.children[n]=new e),o=o.children[n];o.word=t},t.prototype={constructor:t,build:function(t){if(!Array.isArray(t))throw new TypeError("Cannot build a dictionary from "+t);this.trie=new e,t.forEach(function(e){this.trie.add(e)},this)},__sortfn:function(e,t){return e[1]-t[1]},search:function(e){e=e.valueOf();var t;if("string"!=typeof e)throw new TypeError("Cannot search "+e);if(void 0===this.trie)throw new TypeError("Cannot search, dictionary isn't built yet");return t=o(e,this.maxCost,this.trie),t.sort(this.__sortfn),t.map(function(e){return e[0]})}},t}();e.commandDictionary=new t(3),function(){var t={help:function(t){if(t.length){var n=e.getCommand(t);if(n.error)return n.error;var o=n.description||"No info is available";return t+": "+o}return"https://github.com/Zirak/SO-ChatBot/wiki/Interacting-with-the-bot"},listen:function(t){return e.callListeners(t)},live:function(){return e.stopped?(e.continue(),"And on this day, you shall paint eggs for a giant bunny."):"I'm not dead! Honest!"},die:function(){return e.stopped?"Kill me once, shame on you, kill me twice...":(e.stop(),"You killed me!")},forget:function(t){var n=t.toLowerCase(),o=e.getCommand(n);return o.error?o.error:o.canDel(t.get("user_id"))?(o.del(),"Command "+n+" forgotten."):"You are not authorized to delete the command "+t},ban:function(t){function n(t){0>t||(e.banlist.contains(t)?o+="User "+t+" already in mindjail. ":(e.banlist.add(t),o+="User "+t+" added to mindjail. "))}var o="";return t.parse().map(function(n){var i=Number(n);return/^\d+$/.test(n)&&(i=t.findUserid(n)),i?e.isOwner(i)&&(o+="Cannot mindjail owner "+n+". ",i=-1):o+="Cannot find user "+n+". ",i}).forEach(n),o},unban:function(t){function n(t){e.banlist.contains(t)?(e.banlist.remove(t),o+="User "+t+" freed from mindjail. "):o+="User "+t+" isn't in mindjail. "}var o="";return t.parse().map(function(e){var n=Number(e);return/^\d+$/.test(e)&&(n=t.findUserid(e)),n||(o+="Cannot find user "+e+". "),Number(n)}).forEach(n),o},regex:function(t){var n=t.parse(),o=n.shift(),i=n.shift(),r=n.shift()||"",a=RegExp(i,r.toLowerCase()),s=a.exec(o);return e.log(o,i,r,a,"regex parsed"),e.log(s,"regex matched"),s?s.map(function(e){return"`"+e+"`"}).join(", "):"No matches."},jquery:function n(t){var o=t.parse(!0);if(o.length>1)return o.map(n).join(" ");var i,r=t.trim().replace(/^\$/,"jQuery"),a=r.split("."),s=!1,c=r;return e.log(r,a,"/jquery input"),3===a.length&&(a=[a[2]]),"jQuery"===a[0]&&jQuery[a[1]]?s=!0:1===a.length&&jQuery.prototype[a[0]]?(c=a[0],s=!0):jQuery[a[0]]&&(c="jQuery."+a[0],s=!0),i=s?"http://api.jquery.com/"+c:"http://api.jquery.com/?s="+encodeURIComponent(t),e.log(i,"/jquery link"),i},choose:function(t){function n(e){return"or"!==e}var o=t.parse().filter(n),i=Math.random(),r=o.length;return e.log(o,i,"/choose input"),.1>i?2===r?"Neither":"None of the above":.25>i?2===r?"Both!":"All of the above":o[Math.floor(Math.random()*r)]},user:function(e){var t=e.parse(),n=t[0]||e.get("user_id"),o=n;return/^\d+$/.test(n)||(o=e.findUserid(n))?(e.directreply("http://stackoverflow.com/users/"+o),void 0):"Can't find user "+n+" in this chatroom."},listcommands:function(){return"Available commands: "+Object.keys(e.commands).join(", ")}};t.define=function(){var t=Object.create(null);return function(n,o){function i(o){var i=o.AbstractURL,a=o.AbstractText;e.log(i,a,"/define finishCall input"),"Merriam-Webster"===o.AbstractSource&&(a=a.replace(n+" definition: ",""),e.log(a,"/define finishCall webster")),a?(a=n+": "+a,a+=" [\\(source\\)]("+i+")",t[n]=a):(a="Could not find definition for "+n+". Trying Urban Dictionary",e.getCommand("urban").exec(n)),e.log(a,"/define finishCall output"),r(a)}function r(e){o&&o.call?o(e):n.directreply(e)}return t[n]?r(t[n]):(IO.jsonp.define(""+n,i),void 0)}}(),t.define.async=!0,t.norris=function(e,t){function n(n){var o;o="success"!==n.type?"Chuck Norris is too awesome for this API. Try again.":IO.decodehtmlEntities(n.value.joke),t&&t.call?t(o):e.reply(o)}var o="http://api.icndb.com/jokes/random";IO.jsonp({url:o,fun:n,jsonpName:"callback"})},t.norris.async=!0,t.urban=function(){var e=Object.create(null);return function(t,n){function o(n){var o;o="no_results"===n.result_type?"Y U NO MAEK SENSE!!!???!!?11 No results for "+t:r(n.list[0]),e[t]=o,i(o)}function i(e){n&&n.call?n(e):t.reply(e)}function r(e){return t.link(""+t,e.permalink)+" "+e.definition}return t.length?e[t]?i(e[t]):(IO.jsonp({url:"http://www.urbandictionary.com/iphone/search/define",data:{term:t.content},jsonpName:"callback",fun:o}),void 0):"Y U NO PROVIDE ARGUMENTS!?"}}(),t.urban.async=!0,t.parse=function(){var t={who:function(){return[].pop.call(arguments).get("user_name")},someone:function(){var e=document.getElementById("sidebar").getElementsByClassName("present-user"),t=[].filter.call(e,function(e){return Number(e.style.opacity)>=.5}),n=t[Math.floor(Math.random()*(t.length-1))];return n?n.getElementsByTagName("img")[0].title:"Nobody! I'm all alone :("},digit:function(){return Math.floor(10*Math.random())},encode:function(e){return encodeURIComponent(e)},rand:function(e,t){return e=Number(e),t=Number(t),e?t||(t=e,e=0):(e=0,t=9),Math.floor(Math.random()*(t-e+1))+e}},n=/(?:.|^)\$(\w+)(?:\((.*?)\))?/g;return function o(i,r){function a(t,n,o){if(t.startsWith("$$"))return t.slice(1);var i="";"$"!==t[0]&&(i=t[0]);var r=c(n);return r?(e.log(r,n,o,"/parse replaceMacro"),i+=r.apply?r.apply(null,s(o)):r):n}function s(e){return console.log(e,"/parse parseMacroArgs"),e?o(e,r).split(",").invoke("trim").concat(i):[]}function c(e){function n(t){return t.hasOwnProperty(e)}return([t,u,r].first(n)||[])[e]}var u=i.get&&i.get()||{};return r=r||{},e.log(i,r,"/parse input"),i.replace(n,a)}}(),t.tell=function(){var t={tell:!0,forget:!0};return function(n){function o(e){e&&(c?n.directreply(e):n.reply(e))}var i=n.parse();e.log(n.valueOf(),i,"/tell input");var r,a=i[0],s=i[1];if(!a||!s)return"Invalid /tell arguments. Use /help for usage info";if(r=e.getCommand(s),r.error)return r.error;if(t.hasOwnProperty(s))return"Command "+s+" cannot be used in /tell.";if(!r.canUse(n.get("user_id")))return"You do not have permission to use command "+s;var c=!1,u=n.get();/^:?\d+$/.test(a)?(u.message_id=a.replace(/^:/,""),c=!0):u.user_name=a.replace(/^@/,"");var m=e.Message(n.slice(a.length+s.length+2).trim(),u);e.log(m,"/tell calling "+s),r.async?r.exec(m,o):o(r.exec(m))}}(),t.mdn=function(t,n){function o(t){if(200!==t.responseStatus)return i("Something went on fire; status "+t.responseStatus),void 0;var n=t.responseData.results[0];e.log(n,"/mdn result"),i(r.supplant(n))}function i(e){n&&n.call?n(e):t.reply(e)}var r="[{titleNoFormatting}]({url})";IO.jsonp.google(""+t+" site:developer.mozilla.org",o)},t.mdn.async=!0,t.get=function(){var t={answer:!0,question:!0},n={first:function(e){return e[e.length-1]},last:function(e){return e[0]},between:function(e){return e}};return function(o,i){function r(t){if(t.error)return o.reply(t.error.message),void 0;var r,a=[].concat(n[u](t[c])),m="http://stackoverflow.com/q/";e.log(a.slice(),"/get parseResponse parsing"),r=a[0]?a.map(function(e){return m+(e[s+"_id"]||"")}).join(" "):"User did not submit any "+c,e.log(r,"/get parseResponse parsed"),i&&i.call?i(r):o.directreply(r)}var a=o.parse(),s=a[0]||"answer",c=s+"s",u=a[1]||"last",m=a[2];if("between"===u&&(m=a[4]),m||isNaN(u)||(m=u,u="last"),m||(m=o.get("user_id")),e.log(a,"get input"),!t.hasOwnProperty(s))return'Invalid "getter" name '+s;if(!n.hasOwnProperty(u))return"Invalid range specifier "+u;var l="http://api.stackoverflow.com/1.1/users/"+m+"/"+c,p={sort:"creation"};e.log(l,p,"/get building url"),"between"===u&&(p.fromdate=Date.parse(a[2]),p.todate=Date.parse(a[3]),e.log(l,p,"/get building url between")),IO.jsonp({url:l,data:p,fun:r})}}(),t.get.async=!0;var o={help:"Fetches documentation for given command, or general help article. `/help [cmdName]`",listen:"Forwards the message to the listen API (as if called withoutthe /)",live:"Resurrects the bot if it's down",die:"Kills the bot",forget:"Forgets a given command. `/forget cmdName`",ban:"Bans a user from using a bot. `/ban usr_id|usr_name`",unban:"Removes a user from bot's mindjail. `/unban usr_id|usr_name`",regex:"Executes a regex against text input. `/regex text regex [flags]`",jquery:"Fetches documentation link from jQuery API. `/jquery what`",choose:'"Randomly" choose an option given. `/choose option0 option1 ...`',user:"Fetches user-link for specified user. `/user usr_id|usr_name`",listcommands:"This seems pretty obvious",define:"Fetches definition for a given word. `/define something`",norris:"Random chuck norris joke!",urban:"Fetches UrbanDictionary definition. `/urban something`",parse:'Returns result of "parsing" message according to the bot\'s mini-macro capabilities',tell:"Redirect command result to user/message. /tell `msg_id|usr_name cmdName [cmdArgs]`",mdn:"Fetches mdn documentation. `/mdn what`",get:"",learn:"Teach the bot a command. "};Object.keys(t).forEach(function(n){e.addCommand({name:n,fun:t[n],permissions:{del:"NONE"},description:o[n],async:t[n].async})}),["die","live","ban","unban"].forEach(function(t){e.commands[t].permissions.use=e.owners})}(),function(){var t=["A robot may not injure a human being or, through inaction, allow a human being to come to harm.","A robot must obey the orders given to it by human beings, except where such orders would conflict with the First Law.","A robot must protect its own existence as long as such protection does not conflict with the First or Second Laws."].map(function(e,t,n){return n+1+")"+t}).join("\n");e.listen(/^tell (me (your|the) )?(rules|laws)/,function(){return t}),e.listen(/^give ([\w\s]+) a lick/,function(e){var t=e.matches[1],n="s";return"me"===t?(t="you",n=""):"yourself"===t&&(t="I",n=""),"Mmmm! "+t+" taste"+n+" just like raisin"});var n=[/^what(?:'s|'re)?\s(?:(?:is|are)\s)?(?:(?:an|a)\s)?([\w\s\-]+)\??/,/^define\s(?:(?:an|a)\s)?([\w\s\-]+)/];e.listen(n,function(t){var n=t.matches[1],o=e.getCommand("define");o.exec(n,function(e){e=e.replace(n+":",""),t.reply(e)})})}()}(),function(){var e="[{text}]({url})";bot.adapter={roomid:(/\d+/.exec(location)||[0])[0],transform:function(e){return e},escape:function(e){return e.replace(/([`\*_\(\)\[\]])/g,"\\$1")},reply:function(e,t){var n=t.user_name.replace(/\s/g,"");return"@"+n+" "+e},directreply:function(e,t){return":"+t.message_id+" "+e},codify:function(e){var t=" ",n=e.replace(" ",t),o=n.split(/[\r\n]/g);return 1===o.length?"`"+o[0]+"`":o.map(function(e){return t+e}).join("\n")},link:function(t,n){return e.supplant({text:this.escape(t),url:n})}};var t=bot.adapter.in={times:{},interval:5e3,init:function(){function e(e){e=JSON.parse(e),bot.log(e),t.times["r"+n]=e.time,t.loopage()}var t=this,n=bot.adapter.roomid;IO.xhr({url:"/chats/"+n+"/events/",data:fkey({since:0,mode:"Messages",msgCount:0}),method:"POST",complete:e})},poll:function(){var e=this;IO.xhr({url:"/events",data:fkey(e.times),method:"POST",complete:e.pollComplete,thisArg:e})},pollComplete:function(e){if(e){e=JSON.parse(e);var t=this;Object.keys(e).forEach(function(n){var o=e[n];o.t&&(t.times[n]=o.t),o.e&&o.e.forEach(t.handleMessageObject,t)}),IO.in.flush()}},handleMessageObject:function(e){return 1===e.event_type||2===e.event_type?e.content.startsWith("
")?(this.handleMultilineMessage(e),void 0):(IO.in.receive(e),void 0):void 0},handleMultilineMessage:function(e){var t=e.content.slice(0,e.content.lastIndexOf("
")).replace("
","");t.split("
").forEach(function(t){this.handleMessageObject(Object.merge(e,{content:t.trim()}))},this)},loopage:function(){var e=this;setTimeout(function(){e.poll(),e.loopage()},this.interval)}},n=bot.adapter.out={interval:t.interval+500,messages:{},add:function(e,t){t=t||bot.adapter.roomid,IO.out.receive({text:e+"\n",room:t})},build:function(e){this.messages[e.room]||(this.messages[e.room]=""),this.messages[e.room]+=e.text},send:function(){bot.stopped||Object.keys(this.messages).forEach(function(e){var t=this.messages[e];t&&this.sendToRoom(t,e)},this),this.messages={}},sendToRoom:function(e,t){function o(o,i){bot.log(i.status),409===i.status?n.add(e,t):500===i.status&&n.add("Server error (status 500) occured",t)}IO.xhr({url:"/chats/"+t+"/messages/new",data:{text:e,fkey:fkey().fkey},method:"POST",complete:o})},loopage:function(){var e=this;setTimeout(function(){IO.out.flush(),e.loopage()},this.interval)}};IO.register("output",n.build,n),IO.register("afteroutput",n.send,n),t.init(),n.loopage()}(),function(){function e(){Date.now(),r=r.filter(function(e){return e.time-=a,0>=e.time?(t(e),!1):!0}),setTimeout(e,a)}function t(e){console.log(e,"nudge fire"),bot.reply(e.message,e.msgObj)}function n(e,t,n){var o;if(console.log(e,t,"/nudge input"),e=parseFloat(e),o=6e4*e,isNaN(o))return"Many things can be labeled Not a Number; a delay should not be one of them.";var i={msgObj:n,message:"*nudge*"+(t||""),register:Date.now(),time:o};return r.push(i),console.log(i,r,"/nudge register"),"Nudge registered."}function o(e){var t=e.parse();return n(t[0],t.slice(1).join(" "),e.get())}function i(e){return n(e.matches[1],e.matches[2],e.get())}var r=[],a=bot.adapter&&bot.adapter.in.interval||5e3;setTimeout(e,a),bot.addCommand({name:"nudge",fun:o,permissions:{del:"NONE"},description:"Register a nudge after an interval. `/nudge intervalInMinutes message`, or the listener, `nudge|remind|poke me? in? intervalInMinutes message`"}),bot.listen(/(?:nudge|remind|poke)\s(?:me\s)?(?:in\s)?(\d+m?)\s?(.*)$/,i)}(),function(){function e(e,t,n,i){if(bot.log(e,t,n,i,"/ring activate"),!o[i])return"There are no rings in your chat-room";var r=o[i];return r[t]?(e="Ring "+t+" activated by "+n+"! "+e,r[t].map(function(e){return"@"+e}).join(", ")+": "+e):"There exists no "+t+" ring in your chat-room"}function t(e,t,i){bot.log(e,t,i,"/ring register"),o[i]||(o[i]={});var r=o[i];r[e]||(r[e]=[]);var a=r[e];return a.indexOf(t)>-1?"You are already registered to ring "+e:(a.push(t),n(),"Registered to ring "+e+" in room #"+i)}function n(){localStorage.bot_rings=JSON.stringify(o)}var o;localStorage.bot_rings||(localStorage.bot_rings="{}"),o=JSON.parse(localStorage.bot_rings);var i=function(n){var o,i=n.parse(),r=i[0],a=i[1],s=i[2],c=n.get("user_name"),u=n.get("room_id");return bot.log(i,"/ring input"),o="activate"===r?e(s,a,c,u):"register"===r?t(a,c,u):"Cannot understand command: "+r+". See /help ring"};bot.addCommand({name:"ring",fun:i,permissions:{del:"NONE"},description:"Rings are room specific. `/ring activate ringName message` - activate a ring. `/ring register ringName` - register to a ring."})}(),function(){function e(e){var n=e.matches[1],o=e.matches[3],i=!!t[n],r=!1;if(i&&o?r=bot.isOwner(e.get("user_id")):i||(r=!0),!r)return"You are not allowed to do this, young padawan";var a=e.matches[4];return a?(t[n]=a,localStorage.bot_alias=JSON.stringify(t),"Saved alias "+n):"Provide a value for the alias"}localStorage.bot_alias||(localStorage.bot_alias=JSON.stringify({}));var t=JSON.parse(localStorage.bot_alias);bot.listen(/\~([\w\-_]+)(?:\s?(=)(=)?\s?(.+))?/,function(n){var o=n.matches[1];return n.matches[2]?e(n):t[o]||"Nothing found for "+o})}();var parsePrecedence=function(){var e={" ":!0," ":!0},t={"+":{precedence:1,exec:function(e,t){return e+t}},"-":{precedence:1,exec:function(e,t){return e-t}},"*":{precedence:2,exec:function(e,t){return e*t}},"/":{precedence:2,exec:function(e,t){if(0===t)throw Error("Division by 0");return e/t}},d:{precedence:3,exec:function(e,t,n){if(e>100)throw Error("Maximum roll count is 100");for(var o,i=0;e--;)o=Math.floor(Math.random()*t)+1,i+=o,n.push(o);return i}}},n={numberStack:null,operatorStack:null,rolls:null,source:null,pos:0,len:0,lookahead:"",parse:function(e){return this.source=e,this.pos=0,this.len=e.length,this.numberStack=[],this.operatorStack=[],this.rolls=[],this.tokenize(),this.execute(),this.source=e=null,{total:this.numberStack[0],rolls:this.rolls.reverse()}},tokenize:function(){for(var t,n,o;this.len>this.pos;this.pos++)if(o=this.lookahead=this.source[this.pos],!e.hasOwnProperty(o))if(t=this.nextToken(),"number"===t.type)this.numberStack.push(t.value);else if("operator"===t.type){if(n=this.operatorStack[this.operatorStack.length-1],n&&"d"===t.value&&"d"===n.value){var i=Error("Unexpected unchainable operator d");throw i.column=this.pos,i}this.operatorStack.push(t)}},execute:function(){function e(e,t){var n=this.operatorStack[t+1];n&&n.precedence>e.precedence?this.operate(t+1):t||this.operate(t)}for(var t;t=this.operatorStack.length;)for(;--t>=0;)e.call(this,this.operatorStack[t],t)},nextToken:function(){var e,n=this.lookahead,o={type:null,value:n};if(this.pos>=this.len)throw Error("Unexpected end of input");if(n>=0&&10>n)o.type="number",e=this.fetchNumber(),this.pos+=e.length-1,o.value=e.value;else{if(!t.hasOwnProperty(n)){var i=Error("Invalid character "+n);throw i.column=this.pos,i}o.type="operator",o.precedence=t[n].precedence}return o},operate:function(e){var n=this.numberStack.slice(e,e+2);n.push(this.rolls);var o=t[this.operatorStack.splice(e,1)[0].value];this.numberStack.splice(e,2,o.exec.apply(null,n))},fetchNumber:function(){for(var e,t=0,n="";(e=this.source[this.pos+t])>=0&&10>e;)n+=e,t++;if(0===n.length)throw Error("Incomplete operation: Expected number at "+this.pos);return{value:Number(n),length:t}}};return function(e){return n.parse(e)}}(),roll=function(e){if(!/^[\d\s\+\-\*\/d]+$/.test(e))return"Invalid /roll argument; use `/help roll` for help";var t=parsePrecedence(e);return t.rolls+" => "+t.total};bot.addCommand({name:"roll",fun:roll,permissions:{del:"NONE"},description:["Roll dice in DnD notation. `MdN` rolls `M` `N`-sided dice","`MdN+X` rolls as said above, and adds `X` to the result","You can use any of the four arithmetic operators +-*/,","`X` can also be a die roll: `MdN*XdY` for example"].join(". ")}),function(){function e(e){var n,o,i=Math.max(e.matches[1],1)-1,r=Math.min(e.matches[3],t.length),a=e.matches[2];return console.log(i,r,a,"rulz"),i&&!r?t[i]:("to"===a?(i>r&&(n=i,i=r,r=n),o=t.slice(i,r)):o=[t[i],t[r]],o.join("\n"))}var t=["1. Do not talk about /b/","2. Do NOT talk about /b/","3. We are Anonymous.","4. Anonymous is legion.","5. Anonymous does not forgive, Anonymous does not forget.","6. Anonymous can be horrible, senseless, uncaring monster.","7. Anonymous is still able to deliver.","8. There are no real rules about posting.","9. There are no real rules about moderation either — enjoy your ban.","10. If you enjoy any rival sites — DON'T.","11. You must have pictures to prove your statement.","12. Lurk moar — it's never enough.","13. Nothing is Sacred.","14. Do not argue with a troll — it means that they win.","15. The more beautiful and pure a thing is, the more satisfying it is to corrupt it.","16. There are NO girls on the internet.","17. A cat is fine too.","18. One cat leads to another.","19. The more you hate it, the stronger it gets.","20. It is delicious cake. You must eat it.","21. It is delicious trap. You must hit it.","22. /b/ sucks today.","23. Cock goes in here.","24. You will never have sex.","25. ????","26. PROFIT!","27. It needs more Desu. No exceptions.","28. There will always be more fucked up shit than what you just saw.","29. You can not divide by zero (just because the calculator says so).","30. No real limits of any kind apply here — not even the sky","31. CAPSLOCK IS CRUISE CONTROL FOR COOL.","32. EVEN WITH CRUISE CONTROL YOU STILL HAVE TO STEER.","33. Desu isn't funny. Seriously guys. It's worse than Chuck Norris jokes.","34. There is porn of it. No exceptions.","35. If no porn is found of it, it will be created.","36. No matter what it is, it is somebody's fetish. No exceptions.","37. Even one positive comment about Japanese things can make you a weeaboo.","38. When one sees a lion, one must get into the car","39. There is furry porn of it. No exceptions.","40. The pool is always closed due to AIDS (and stingrays, which also have AIDS).","41. If there isn't enough just ask for Moar.","42. Everything has been cracked and pirated.","43. DISREGARD THAT I SUCK COCKS","44. The internet is not your personal army.","45. Rule 45 is a lie.","46. The cake is a lie.","47. If you post it, they will cum.","48. It will always need moar sauce.","49. The internet makes you stupid.","50. Anything can be a meme.","51. Longcat is looooooooooong.","52. If something goes wrong, Ebaums did it.","53. Anonymous is a virgin by default.","54. Moot has cat ears, even in real life. No exceptions.","55. CP is awwwright, but DSFARGEG will get you b&.","56. Don't mess with football.","57. MrSpooky has never seen so many ingrates.",'58. Anonymous does not "buy", he downloads.','59. The term "sage" does not refer to the spice.',"60. If you say Candlejack, you w","61. You cannot divide by zero.","62. The internet is SERIOUS FUCKING BUSINESS.","63. If you do not believe it, then it must be habeebed for great justice.","64. Not even Spider-Man knows how to shot web.","65. Mitchell Henderson was an hero to us all.","66. This is not lupus, it's SPARTAAAAAAAAAA.","67. One does not simply shoop da whoop into Mordor.","68. Katy is bi, so deal w/it.","69. LOL SIXTY NINE AMIRITE?","70. Also, cocks.","71. This is a showdown, a throwdown, hell no I can't slow down, it's gonna go.","72. Anonymous did NOT, under any circumstances, tk him 2da bar|?","73. If you express astonishment at someone's claim, it is most likely just a clever ruse.","74. If it hadn't been for Cotton Eyed Joe, Anonymous would have been married a long time ago.","75. Around Snacks, CP is lax.","76. All numbers are at least 100 but always OVER NINE THOUSAAAAAND.","77. Hal Turner definitely needs to gb2/hell/.","78. Mods are fucking fags. No exceptions.","79. All Caturday threads will be bombarded with Zippocat. No exceptions.","80. No matter how cute it is, it probably skullfucked your mother last night.","81. That's not mud.","82. Steve Irwin's death is really, really funny.","83. The Internet is SERIOUS FUCKING BUSINESS.","84. Rule 87 is true.","85. Yes, it is some chickens.","86. Bobba bobba is bobba.","87. Rule 84 is false. OH SHI-",'88. If your statement is preceded by "HAY GUYZ", then you are not doing it right.',"89. If you cannot understand it, it is machine code.","90. Anonymous still owes Hal Turner one trillion U.S. dollars.","91. Spengbab Sqarpaint is luv Padtwick Zhstar iz fwend.","92. Disregard Bigmike, he sucks cocks.","93. Secure tripcodes are for jerks.","94. If someone herd u liek Mudkips, deny it constantly for the lulz.","95. Combo breakers are inevitable. If the combo is completed successfully, it is gay.","96. I am a huge faggot. Please rape my face.","97. Shit sucks and will never be stickied.","98. Bricks must are required to be shat whenever Anonymous is surprised.","99. If you have no bricks to shit, you are made of fail and AIDS.","100. ZOMG NONE","101. The internet is always right. No exceptions","102. The internet is really, really great, FOR PORN."],n=/(?:show|tell) (?:me)? rules? (\d+)\s?(?:(,|and|to)\s?(\d+))?/;bot.listen(n,e)}(),IO.register("input",function(e){var t=e.content.match(/\w+/g)||[];1===t.length&&"STOP"===t[0].toUpperCase()&&bot.adapter.out.add("HAMMERTIME!",e.room_id)}),function(){function e(e){function n(e){return e.name.toLowerCase().indexOf(r)>-1}function o(t){var n=e.escape(t.name);return"["+n+"](http://es5.github.com/#"+t.section+")"}var i,r=e.content.toLowerCase();return i=t.filter(n).map(o),bot.log(i,"/spec done"),i.length?i.join(", "):e+" not found in spec"}var t;t=[{section:"introduction",name:"Introduction"},{section:"x1",name:"1 Scope"},{section:"x2",name:"2 Conformance"},{section:"x3",name:"3 Normative references"},{section:"x4",name:"4 Overview"},{section:"x4.1",name:"4.1 Web Scripting"},{section:"x4.2",name:"4.2 Language Overview"},{section:"x4.2.1",name:"4.2.1 Objects"},{section:"x4.2.2",name:"4.2.2 The Strict Variant of ECMAScript"},{section:"x4.3",name:"4.3 Definitions"},{section:"x4.3.1",name:"4.3.1 type"},{section:"x4.3.2",name:"4.3.2 primitive value"},{section:"x4.3.3",name:"4.3.3 object"},{section:"x4.3.4",name:"4.3.4 constructor"},{section:"x4.3.5",name:"4.3.5 prototype"},{section:"x4.3.6",name:"4.3.6 native object"},{section:"x4.3.7",name:"4.3.7 built-in object"},{section:"x4.3.8",name:"4.3.8 host object"},{section:"x4.3.9",name:"4.3.9 undefined value"},{section:"x4.3.10",name:"4.3.10 Undefined type"},{section:"x4.3.11",name:"4.3.11 null value"},{section:"x4.3.12",name:"4.3.12 Null type"},{section:"x4.3.13",name:"4.3.13 Boolean value"},{section:"x4.3.14",name:"4.3.14 Boolean type"},{section:"x4.3.15",name:"4.3.15 Boolean object"},{section:"x4.3.16",name:"4.3.16 String value"},{section:"x4.3.17",name:"4.3.17 String type"},{section:"x4.3.18",name:"4.3.18 String object"},{section:"x4.3.19",name:"4.3.19 Number value"},{section:"x4.3.20",name:"4.3.20 Number type"},{section:"x4.3.21",name:"4.3.21 Number object"},{section:"x4.3.22",name:"4.3.22 Infinity"},{section:"x4.3.23",name:"4.3.23 NaN"},{section:"x4.3.24",name:"4.3.24 function"},{section:"x4.3.25",name:"4.3.25 built-in function"},{section:"x4.3.26",name:"4.3.26 property"},{section:"x4.3.27",name:"4.3.27 method"},{section:"x4.3.28",name:"4.3.28 built-in method"},{section:"x4.3.29",name:"4.3.29 attribute"},{section:"x4.3.30",name:"4.3.30 own property"},{section:"x4.3.31",name:"4.3.31 inherited property"},{section:"x5",name:"5 Notational Conventions"},{section:"x5.1",name:"5.1 Syntactic and Lexical Grammars"},{section:"x5.1.1",name:"5.1.1 Context-Free Grammars"},{section:"x5.1.2",name:"5.1.2 The Lexical and RegExp Grammars"},{section:"x5.1.3",name:"5.1.3 The Numeric String Grammar"},{section:"x5.1.4",name:"5.1.4 The Syntactic Grammar"},{section:"x5.1.5",name:"5.1.5 The JSON Grammar"},{section:"x5.1.6",name:"5.1.6 Grammar Notation"},{section:"x5.2",name:"5.2 Algorithm Conventions"},{section:"x6",name:"6 Source Text"},{section:"x7",name:"7 Lexical Conventions"},{section:"x7.1",name:"7.1 Unicode Format-Control Characters"},{section:"x7.2",name:"7.2 White Space"},{section:"x7.3",name:"7.3 Line Terminators"},{section:"x7.4",name:"7.4 Comments"},{section:"x7.5",name:"7.5 Tokens"},{section:"x7.6",name:"7.6 Identifier Names and Identifiers"},{section:"x7.6.1",name:"7.6.1 Reserved Words"},{section:"x7.6.1.1",name:"7.6.1.1 Keywords"},{section:"x7.6.1.2",name:"7.6.1.2 Future Reserved Words"},{section:"x7.7",name:"7.7 Punctuators"},{section:"x7.8",name:"7.8 Literals"},{section:"x7.8.1",name:"7.8.1 Null Literals"},{section:"x7.8.2",name:"7.8.2 Boolean Literals"},{section:"x7.8.3",name:"7.8.3 Numeric Literals"},{section:"x7.8.4",name:"7.8.4 String Literals"},{section:"x7.8.5",name:"7.8.5 Regular Expression Literals"},{section:"x7.9",name:"7.9 Automatic Semicolon Insertion"},{section:"x7.9.1",name:"7.9.1 Rules of Automatic Semicolon Insertion"},{section:"x7.9.2",name:"7.9.2 Examples of Automatic Semicolon Insertion"},{section:"x8",name:"8 Types"},{section:"x8.1",name:"8.1 The Undefined Type"},{section:"x8.2",name:"8.2 The Null Type"},{section:"x8.3",name:"8.3 The Boolean Type"},{section:"x8.4",name:"8.4 The String Type"},{section:"x8.5",name:"8.5 The Number Type"},{section:"x8.6",name:"8.6 The Object Type"},{section:"x8.6.1",name:"8.6.1 Property Attributes"},{section:"x8.6.2",name:"8.6.2 Object Internal Properties and Methods"},{section:"x8.7",name:"8.7 The Reference Specification Type"},{section:"x8.7.1",name:"8.7.1 GetValue (V)"},{section:"x8.7.2",name:"8.7.2 PutValue (V, W)"},{section:"x8.8",name:"8.8 The List Specification Type"},{section:"x8.9",name:"8.9 The Completion Specification Type"},{section:"x8.10",name:"8.10 The Property Descriptor and Property Identifier Specification Types"},{section:"x8.10.1",name:"8.10.1 IsAccessorDescriptor ( Desc )"},{section:"x8.10.2",name:"8.10.2 IsDataDescriptor ( Desc )"},{section:"x8.10.3",name:"8.10.3 IsGenericDescriptor ( Desc )"},{section:"x8.10.4",name:"8.10.4 FromPropertyDescriptor ( Desc )"},{section:"x8.10.5",name:"8.10.5 ToPropertyDescriptor ( Obj )"},{section:"x8.11",name:"8.11 The Lexical Environment and Environment Record Specification Types"},{section:"x8.12",name:"8.12 Algorithms for Object Internal Methods"},{section:"x8.12.1",name:"8.12.1 [[GetOwnProperty]] (P)"},{section:"x8.12.2",name:"8.12.2 [[GetProperty]] (P)"},{section:"x8.12.3",name:"8.12.3 [[Get]] (P)"},{section:"x8.12.4",name:"8.12.4 [[CanPut]] (P)"},{section:"x8.12.5",name:"8.12.5 [[Put]] ( P, V, Throw )"},{section:"x8.12.6",name:"8.12.6 [[HasProperty]] (P)"},{section:"x8.12.7",name:"8.12.7 [[Delete]] (P, Throw)"},{section:"x8.12.8",name:"8.12.8 [[DefaultValue]] (hint)"},{section:"x8.12.9",name:"8.12.9 [[DefineOwnProperty]] (P, Desc, Throw)"},{section:"x9",name:"9 Type Conversion and Testing"},{section:"x9.1",name:"9.1 ToPrimitive"},{section:"x9.2",name:"9.2 ToBoolean"},{section:"x9.3",name:"9.3 ToNumber"},{section:"x9.3.1",name:"9.3.1 ToNumber Applied to the String Type"},{section:"x9.4",name:"9.4 ToInteger"},{section:"x9.5",name:"9.5 ToInt32: (Signed 32 Bit Integer)"},{section:"x9.6",name:"9.6 ToUint32: (Unsigned 32 Bit Integer)"},{section:"x9.7",name:"9.7 ToUint16: (Unsigned 16 Bit Integer)"},{section:"x9.8",name:"9.8 ToString"},{section:"x9.8.1",name:"9.8.1 ToString Applied to the Number Type"},{section:"x9.9",name:"9.9 ToObject"},{section:"x9.10",name:"9.10 CheckObjectCoercible"},{section:"x9.11",name:"9.11 IsCallable"},{section:"x9.12",name:"9.12 The SameValue Algorithm"},{section:"x10",name:"10 Executable Code and Execution Contexts"},{section:"x10.1",name:"10.1 Types of Executable Code"},{section:"x10.1.1",name:"10.1.1 Strict Mode Code"},{section:"x10.2",name:"10.2 Lexical Environments"},{section:"x10.2.1",name:"10.2.1 Environment Records"},{section:"x10.2.1.1",name:"10.2.1.1 Declarative Environment Records"},{section:"x10.2.1.1.1",name:"10.2.1.1.1 HasBinding(N)"},{section:"x10.2.1.1.2",name:"10.2.1.1.2 CreateMutableBinding (N, D)"},{section:"x10.2.1.1.3",name:"10.2.1.1.3 SetMutableBinding (N,V,S)"},{section:"x10.2.1.1.4",name:"10.2.1.1.4 GetBindingValue(N,S)"},{section:"x10.2.1.1.5",name:"10.2.1.1.5 DeleteBinding (N)"},{section:"x10.2.1.1.6",name:"10.2.1.1.6 ImplicitThisValue()"},{section:"x10.2.1.1.7",name:"10.2.1.1.7 CreateImmutableBinding (N)"},{section:"x10.2.1.1.8",name:"10.2.1.1.8 InitializeImmutableBinding (N,V)"},{section:"x10.2.1.2",name:"10.2.1.2 Object Environment Records"},{section:"x10.2.1.2.1",name:"10.2.1.2.1 HasBinding(N)"},{section:"x10.2.1.2.2",name:"10.2.1.2.2 CreateMutableBinding (N, D)"},{section:"x10.2.1.2.3",name:"10.2.1.2.3 SetMutableBinding (N,V,S)"},{section:"x10.2.1.2.4",name:"10.2.1.2.4 GetBindingValue(N,S)"},{section:"x10.2.1.2.5",name:"10.2.1.2.5 DeleteBinding (N)"},{section:"x10.2.1.2.6",name:"10.2.1.2.6 ImplicitThisValue()"},{section:"x10.2.2",name:"10.2.2 Lexical Environment Operations"},{section:"x10.2.2.1",name:"10.2.2.1 GetIdentifierReference (lex, name, strict)"},{section:"x10.2.2.2",name:"10.2.2.2 NewDeclarativeEnvironment (E)"},{section:"x10.2.2.3",name:"10.2.2.3 NewObjectEnvironment (O, E)"},{section:"x10.2.3",name:"10.2.3 The Global Environment"},{section:"x10.3",name:"10.3 Execution Contexts"},{section:"x10.3.1",name:"10.3.1 Identifier Resolution"},{section:"x10.4",name:"10.4 Establishing an Execution Context"},{section:"x10.4.1",name:"10.4.1 Entering Global Code"},{section:"x10.4.1.1",name:"10.4.1.1 Initial Global Execution Context"},{section:"x10.4.2",name:"10.4.2 Entering Eval Code"},{section:"x10.4.2.1",name:"10.4.2.1 Strict Mode Restrictions"},{section:"x10.4.3",name:"10.4.3 Entering Function Code"},{section:"x10.5",name:"10.5 Declaration Binding Instantiation"},{section:"x10.6",name:"10.6 Arguments Object"},{section:"x11",name:"11 Expressions"},{section:"x11.1",name:"11.1 Primary Expressions"},{section:"x11.1.1",name:"11.1.1 The this Keyword"},{section:"x11.1.2",name:"11.1.2 Identifier Reference"},{section:"x11.1.3",name:"11.1.3 Literal Reference"},{section:"x11.1.4",name:"11.1.4 Array Initialiser"},{section:"x11.1.5",name:"11.1.5 Object Initialiser"},{section:"x11.1.6",name:"11.1.6 The Grouping Operator"},{section:"x11.2",name:"11.2 Left-Hand-Side Expressions"},{section:"x11.2.1",name:"11.2.1 Property Accessors"},{section:"x11.2.2",name:"11.2.2 The new Operator"},{section:"x11.2.3",name:"11.2.3 Function Calls"},{section:"x11.2.4",name:"11.2.4 Argument Lists"},{section:"x11.2.5",name:"11.2.5 Function Expressions"},{section:"x11.3",name:"11.3 Postfix Expressions"},{section:"x11.3.1",name:"11.3.1 Postfix Increment Operator"},{section:"x11.3.2",name:"11.3.2 Postfix Decrement Operator"},{section:"x11.4",name:"11.4 Unary Operators"},{section:"x11.4.1",name:"11.4.1 The delete Operator"},{section:"x11.4.2",name:"11.4.2 The void Operator"},{section:"x11.4.3",name:"11.4.3 The typeof Operator"},{section:"x11.4.4",name:"11.4.4 Prefix Increment Operator"},{section:"x11.4.5",name:"11.4.5 Prefix Decrement Operator"},{section:"x11.4.6",name:"11.4.6 Unary + Operator"},{section:"x11.4.7",name:"11.4.7 Unary - Operator"},{section:"x11.4.8",name:"11.4.8 Bitwise NOT Operator ( ~ )"},{section:"x11.4.9",name:"11.4.9 Logical NOT Operator ( ! )"},{section:"x11.5",name:"11.5 Multiplicative Operators"},{section:"x11.5.1",name:"11.5.1 Applying the * Operator"},{section:"x11.5.2",name:"11.5.2 Applying the / Operator"},{section:"x11.5.3",name:"11.5.3 Applying the % Operator"},{section:"x11.6",name:"11.6 Additive Operators"},{section:"x11.6.1",name:"11.6.1 The Addition operator ( + )"},{section:"x11.6.2",name:"11.6.2 The Subtraction Operator ( - )"},{section:"x11.6.3",name:"11.6.3 Applying the Additive Operators to Numbers"},{section:"x11.7",name:"11.7 Bitwise Shift Operators"},{section:"x11.7.1",name:"11.7.1 The Left Shift Operator ( << )"},{section:"x11.7.2",name:"11.7.2 The Signed Right Shift Operator ( >> )"},{section:"x11.7.3",name:"11.7.3 The Unsigned Right Shift Operator ( >>> )"},{section:"x11.8",name:"11.8 Relational Operators"},{section:"x11.8.1",name:"11.8.1 The Less-than Operator ( < )"},{section:"x11.8.2",name:"11.8.2 The Greater-than Operator ( > )"},{section:"x11.8.3",name:"11.8.3 The Less-than-or-equal Operator ( <= )"},{section:"x11.8.4",name:"11.8.4 The Greater-than-or-equal Operator ( >= )"},{section:"x11.8.5",name:"11.8.5 The Abstract Relational Comparison Algorithm"},{section:"x11.8.6",name:"11.8.6 The instanceof operator"},{section:"x11.8.7",name:"11.8.7 The in operator"},{section:"x11.9",name:"11.9 Equality Operators"},{section:"x11.9.1",name:"11.9.1 The Equals Operator ( == )"},{section:"x11.9.2",name:"11.9.2 The Does-not-equals Operator ( != )"},{section:"x11.9.3",name:"11.9.3 The Abstract Equality Comparison Algorithm"},{section:"x11.9.4",name:"11.9.4 The Strict Equals Operator ( === )"},{section:"x11.9.5",name:"11.9.5 The Strict Does-not-equal Operator ( !== )"},{section:"x11.9.6",name:"11.9.6 The Strict Equality Comparison Algorithm"},{section:"x11.10",name:"11.10 Binary Bitwise Operators"},{section:"x11.11",name:"11.11 Binary Logical Operators"},{section:"x11.12",name:"11.12 Conditional Operator ( ? : )"},{section:"x11.13",name:"11.13 Assignment Operators"},{section:"x11.13.1",name:"11.13.1 Simple Assignment ( = )"},{section:"x11.13.2",name:"11.13.2 Compound Assignment ( op= )"},{section:"x11.14",name:"11.14 Comma Operator ( , )"},{section:"x12",name:"12 Statements"},{section:"x12.1",name:"12.1 Block"},{section:"x12.2",name:"12.2 Variable Statement"},{section:"x12.2.1",name:"12.2.1 Strict Mode Restrictions"},{section:"x12.3",name:"12.3 Empty Statement"},{section:"x12.4",name:"12.4 Expression Statement"},{section:"x12.5",name:"12.5 The if Statement"},{section:"x12.6",name:"12.6 Iteration Statements"},{section:"x12.6.1",name:"12.6.1 The do-while Statement"},{section:"x12.6.2",name:"12.6.2 The while Statement"},{section:"x12.6.3",name:"12.6.3 The for Statement"},{section:"x12.6.4",name:"12.6.4 The for-in Statement"},{section:"x12.7",name:"12.7 The continue Statement"},{section:"x12.8",name:"12.8 The break Statement"},{section:"x12.9",name:"12.9 The return Statement"},{section:"x12.10",name:"12.10 The with Statement"},{section:"x12.10.1",name:"12.10.1 Strict Mode Restrictions"},{section:"x12.11",name:"12.11 The switch Statement"},{section:"x12.12",name:"12.12 Labelled Statements"},{section:"x12.13",name:"12.13 The throw Statement"},{section:"x12.14",name:"12.14 The try Statement"},{section:"x12.14.1",name:"12.14.1 Strict Mode Restrictions"},{section:"x12.15",name:"12.15 The debugger statement"},{section:"x13",name:"13 Function Definition"},{section:"x13.1",name:"13.1 Strict Mode Restrictions"},{section:"x13.2",name:"13.2 Creating Function Objects"},{section:"x13.2.1",name:"13.2.1 [[Call]]"},{section:"x13.2.2",name:"13.2.2 [[Construct]]"},{section:"x13.2.3",name:"13.2.3 The Function Object"},{section:"x14",name:"14 Program"},{section:"x14.1",name:"14.1 Directive Prologues and the Use Strict Directive"},{section:"x15",name:"15 Standard Built-in ECMAScript Objects"},{section:"x15.1",name:"15.1 The Global Object"},{section:"x15.1.1",name:"15.1.1 Value Properties of the Global Object"},{section:"x15.1.1.1",name:"15.1.1.1 NaN"},{section:"x15.1.1.2",name:"15.1.1.2 Infinity"},{section:"x15.1.1.3",name:"15.1.1.3 undefined"},{section:"x15.1.2",name:"15.1.2 Function Properties of the Global Object"},{section:"x15.1.2.1",name:"15.1.2.1 eval (x)"},{section:"x15.1.2.1.1",name:"15.1.2.1.1 Direct Call to Eval"},{section:"x15.1.2.2",name:"15.1.2.2 parseInt (string , radix)"},{section:"x15.1.2.3",name:"15.1.2.3 parseFloat (string)"},{section:"x15.1.2.4",name:"15.1.2.4 isNaN (number)"},{section:"x15.1.2.5",name:"15.1.2.5 isFinite (number)"},{section:"x15.1.3",name:"15.1.3 URI Handling Function Properties"},{section:"x15.1.3.1",name:"15.1.3.1 decodeURI (encodedURI)"},{section:"x15.1.3.2",name:"15.1.3.2 decodeURIComponent (encodedURIComponent)"},{section:"x15.1.3.3",name:"15.1.3.3 encodeURI (uri)"},{section:"x15.1.3.4",name:"15.1.3.4 encodeURIComponent (uriComponent)"},{section:"x15.1.4",name:"15.1.4 Constructor Properties of the Global Object"},{section:"x15.1.4.1",name:"15.1.4.1 Object ( . . . )"},{section:"x15.1.4.2",name:"15.1.4.2 Function ( . . . )"},{section:"x15.1.4.3",name:"15.1.4.3 Array ( . . . )"},{section:"x15.1.4.4",name:"15.1.4.4 String ( . . . )"},{section:"x15.1.4.5",name:"15.1.4.5 Boolean ( . . . )"},{section:"x15.1.4.6",name:"15.1.4.6 Number ( . . . )"},{section:"x15.1.4.7",name:"15.1.4.7 Date ( . . . )"},{section:"x15.1.4.8",name:"15.1.4.8 RegExp ( . . . )"},{section:"x15.1.4.9",name:"15.1.4.9 Error ( . . . )"},{section:"x15.1.4.10",name:"15.1.4.10 EvalError ( . . . )"},{section:"x15.1.4.11",name:"15.1.4.11 RangeError ( . . . )"},{section:"x15.1.4.12",name:"15.1.4.12 ReferenceError ( . . . )"},{section:"x15.1.4.13",name:"15.1.4.13 SyntaxError ( . . . )"},{section:"x15.1.4.14",name:"15.1.4.14 TypeError ( . . . )"},{section:"x15.1.4.15",name:"15.1.4.15 URIError ( . . . )"},{section:"x15.1.5",name:"15.1.5 Other Properties of the Global Object"},{section:"x15.1.5.1",name:"15.1.5.1 Math"},{section:"x15.1.5.2",name:"15.1.5.2 JSON"},{section:"x15.2",name:"15.2 Object Objects"},{section:"x15.2.1",name:"15.2.1 The Object Constructor Called as a Function"},{section:"x15.2.1.1",name:"15.2.1.1 Object ( [ value ] )"},{section:"x15.2.2",name:"15.2.2 The Object Constructor"},{section:"x15.2.2.1",name:"15.2.2.1 new Object ( [ value ] )"},{section:"x15.2.3",name:"15.2.3 Properties of the Object Constructor"},{section:"x15.2.3.1",name:"15.2.3.1 Object.prototype"},{section:"x15.2.3.2",name:"15.2.3.2 Object.getPrototypeOf ( O )"},{section:"x15.2.3.3",name:"15.2.3.3 Object.getOwnPropertyDescriptor ( O, P ) "},{section:"x15.2.3.4",name:"15.2.3.4 Object.getOwnPropertyNames ( O )"},{section:"x15.2.3.5",name:"15.2.3.5 Object.create ( O [, Properties] )"},{section:"x15.2.3.6",name:"15.2.3.6 Object.defineProperty ( O, P, Attributes )"},{section:"x15.2.3.7",name:"15.2.3.7 Object.defineProperties ( O, Properties )"},{section:"x15.2.3.8",name:"15.2.3.8 Object.seal ( O )"},{section:"x15.2.3.9",name:"15.2.3.9 Object.freeze ( O )"},{section:"x15.2.3.10",name:"15.2.3.10 Object.preventExtensions ( O )"},{section:"x15.2.3.11",name:"15.2.3.11 Object.isSealed ( O )"},{section:"x15.2.3.12",name:"15.2.3.12 Object.isFrozen ( O )"},{section:"x15.2.3.13",name:"15.2.3.13 Object.isExtensible ( O )"},{section:"x15.2.3.14",name:"15.2.3.14 Object.keys ( O )"},{section:"x15.2.4",name:"15.2.4 Properties of the Object Prototype Object"},{section:"x15.2.4.1",name:"15.2.4.1 Object.prototype.constructor"},{section:"x15.2.4.2",name:"15.2.4.2 Object.prototype.toString ( )"},{section:"x15.2.4.3",name:"15.2.4.3 Object.prototype.toLocaleString ( )"},{section:"x15.2.4.4",name:"15.2.4.4 Object.prototype.valueOf ( )"},{section:"x15.2.4.5",name:"15.2.4.5 Object.prototype.hasOwnProperty (V)"},{section:"x15.2.4.6",name:"15.2.4.6 Object.prototype.isPrototypeOf (V)"},{section:"x15.2.4.7",name:"15.2.4.7 Object.prototype.propertyIsEnumerable (V)"},{section:"x15.2.5",name:"15.2.5 Properties of Object Instances"},{section:"x15.3",name:"15.3 Function Objects"},{section:"x15.3.1",name:"15.3.1 The Function Constructor Called as a Function"},{section:"x15.3.1.1",name:"15.3.1.1 Function (p1, p2, … , pn, body)"},{section:"x15.3.2",name:"15.3.2 The Function Constructor"},{section:"x15.3.2.1",name:"15.3.2.1 new Function (p1, p2, … , pn, body)"},{section:"x15.3.3",name:"15.3.3 Properties of the Function Constructor"},{section:"x15.3.3.1",name:"15.3.3.1 Function.prototype"},{section:"x15.3.3.2",name:"15.3.3.2 Function.length"},{section:"x15.3.4",name:"15.3.4 Properties of the Function Prototype Object"},{section:"x15.3.4.1",name:"15.3.4.1 Function.prototype.constructor"},{section:"x15.3.4.2",name:"15.3.4.2 Function.prototype.toString ( )"},{section:"x15.3.4.3",name:"15.3.4.3 Function.prototype.apply (thisArg, argArray)"},{section:"x15.3.4.4",name:"15.3.4.4 Function.prototype.call (thisArg [ , arg1 [ , arg2, … ] ] )"},{section:"x15.3.4.5",name:"15.3.4.5 Function.prototype.bind (thisArg [, arg1 [, arg2, …]])"},{section:"x15.3.4.5.1",name:"15.3.4.5.1 [[Call]]"},{section:"x15.3.4.5.2",name:"15.3.4.5.2 [[Construct]]"},{section:"x15.3.4.5.3",name:"15.3.4.5.3 [[HasInstance]] (V)"},{section:"x15.3.5",name:"15.3.5 Properties of Function Instances"},{section:"x15.3.5.1",name:"15.3.5.1 length"},{section:"x15.3.5.2",name:"15.3.5.2 prototype"},{section:"x15.3.5.3",name:"15.3.5.3 [[HasInstance]] (V)"},{section:"x15.3.5.4",name:"15.3.5.4 [[Get]] (P)"},{section:"x15.4",name:"15.4 Array Objects"},{section:"x15.4.1",name:"15.4.1 The Array Constructor Called as a Function"},{section:"x15.4.1.1",name:"15.4.1.1 Array ( [ item1 [ , item2 [ , … ] ] ] )"},{section:"x15.4.2",name:"15.4.2 The Array Constructor"},{section:"x15.4.2.1",name:"15.4.2.1 new Array ( [ item0 [ , item1 [ , … ] ] ] )"},{section:"x15.4.2.2",name:"15.4.2.2 new Array (len)"},{section:"x15.4.3",name:"15.4.3 Properties of the Array Constructor"},{section:"x15.4.3.1",name:"15.4.3.1 Array.prototype"},{section:"x15.4.3.2",name:"15.4.3.2 Array.isArray ( arg )"},{section:"x15.4.4",name:"15.4.4 Properties of the Array Prototype Object"},{section:"x15.4.4.1",name:"15.4.4.1 Array.prototype.constructor"},{section:"x15.4.4.2",name:"15.4.4.2 Array.prototype.toString ( )"},{section:"x15.4.4.3",name:"15.4.4.3 Array.prototype.toLocaleString ( )"},{section:"x15.4.4.4",name:"15.4.4.4 Array.prototype.concat ( [ item1 [ , item2 [ , … ] ] ] )"},{section:"x15.4.4.5",name:"15.4.4.5 Array.prototype.join (separator)"},{section:"x15.4.4.6",name:"15.4.4.6 Array.prototype.pop ( )"},{section:"x15.4.4.7",name:"15.4.4.7 Array.prototype.push ( [ item1 [ , item2 [ , … ] ] ] )"},{section:"x15.4.4.8",name:"15.4.4.8 Array.prototype.reverse ( )"},{section:"x15.4.4.9",name:"15.4.4.9 Array.prototype.shift ( )"},{section:"x15.4.4.10",name:"15.4.4.10 Array.prototype.slice (start, end)"},{section:"x15.4.4.11",name:"15.4.4.11 Array.prototype.sort (comparefn)"},{section:"x15.4.4.12",name:"15.4.4.12 Array.prototype.splice (start, deleteCount [ , item1 [ , item2 [ , … ] ] ] )"},{section:"x15.4.4.13",name:"15.4.4.13 Array.prototype.unshift ( [ item1 [ , item2 [ , … ] ] ] )"},{section:"x15.4.4.14",name:"15.4.4.14 Array.prototype.indexOf ( searchElement [ , fromIndex ] )"},{section:"x15.4.4.15",name:"15.4.4.15 Array.prototype.lastIndexOf ( searchElement [ , fromIndex ] )"},{section:"x15.4.4.16",name:"15.4.4.16 Array.prototype.every ( callbackfn [ , thisArg ] )"},{section:"x15.4.4.17",name:"15.4.4.17 Array.prototype.some ( callbackfn [ , thisArg ] )"},{section:"x15.4.4.18",name:"15.4.4.18 Array.prototype.forEach ( callbackfn [ , thisArg ] )"},{section:"x15.4.4.19",name:"15.4.4.19 Array.prototype.map ( callbackfn [ , thisArg ] )"},{section:"x15.4.4.20",name:"15.4.4.20 Array.prototype.filter ( callbackfn [ , thisArg ] )"},{section:"x15.4.4.21",name:"15.4.4.21 Array.prototype.reduce ( callbackfn [ , initialValue ] )"},{section:"x15.4.4.22",name:"15.4.4.22 Array.prototype.reduceRight ( callbackfn [ , initialValue ] )"},{section:"x15.4.5",name:"15.4.5 Properties of Array Instances"},{section:"x15.4.5.1",name:"15.4.5.1 [[DefineOwnProperty]] ( P, Desc, Throw )"},{section:"x15.4.5.2",name:"15.4.5.2 length"},{section:"x15.5",name:"15.5 String Objects"},{section:"x15.5.1",name:"15.5.1 The String Constructor Called as a Function"},{section:"x15.5.1.1",name:"15.5.1.1 String ( [ value ] )"},{section:"x15.5.2",name:"15.5.2 The String Constructor"},{section:"x15.5.2.1",name:"15.5.2.1 new String ( [ value ] )"},{section:"x15.5.3",name:"15.5.3 Properties of the String Constructor"},{section:"x15.5.3.1",name:"15.5.3.1 String.prototype"},{section:"x15.5.3.2",name:"15.5.3.2 String.fromCharCode ( [ char0 [ , char1 [ , … ] ] ] )"},{section:"x15.5.4",name:"15.5.4 Properties of the String Prototype Object"},{section:"x15.5.4.1",name:"15.5.4.1 String.prototype.constructor"},{section:"x15.5.4.2",name:"15.5.4.2 String.prototype.toString ( )"},{section:"x15.5.4.3",name:"15.5.4.3 String.prototype.valueOf ( )"},{section:"x15.5.4.4",name:"15.5.4.4 String.prototype.charAt (pos)"},{section:"x15.5.4.5",name:"15.5.4.5 String.prototype.charCodeAt (pos)"},{section:"x15.5.4.6",name:"15.5.4.6 String.prototype.concat ( [ string1 [ , string2 [ , … ] ] ] )"},{section:"x15.5.4.7",name:"15.5.4.7 String.prototype.indexOf (searchString, position)"},{section:"x15.5.4.8",name:"15.5.4.8 String.prototype.lastIndexOf (searchString, position)"},{section:"x15.5.4.9",name:"15.5.4.9 String.prototype.localeCompare (that)"},{section:"x15.5.4.10",name:"15.5.4.10 String.prototype.match (regexp)"},{section:"x15.5.4.11",name:"15.5.4.11 String.prototype.replace (searchValue, replaceValue)"},{section:"x15.5.4.12",name:"15.5.4.12 String.prototype.search (regexp)"},{section:"x15.5.4.13",name:"15.5.4.13 String.prototype.slice (start, end)"},{section:"x15.5.4.14",name:"15.5.4.14 String.prototype.split (separator, limit)"},{section:"x15.5.4.15",name:"15.5.4.15 String.prototype.substring (start, end)"},{section:"x15.5.4.16",name:"15.5.4.16 String.prototype.toLowerCase ( )"},{section:"x15.5.4.17",name:"15.5.4.17 String.prototype.toLocaleLowerCase ( )"},{section:"x15.5.4.18",name:"15.5.4.18 String.prototype.toUpperCase ( )"},{section:"x15.5.4.19",name:"15.5.4.19 String.prototype.toLocaleUpperCase ( )"},{section:"x15.5.4.20",name:"15.5.4.20 String.prototype.trim ( )"},{section:"x15.5.5",name:"15.5.5 Properties of String Instances"},{section:"x15.5.5.1",name:"15.5.5.1 length"},{section:"x15.5.5.2",name:"15.5.5.2 [[GetOwnProperty]] ( P )"},{section:"x15.6",name:"15.6 Boolean Objects"},{section:"x15.6.1",name:"15.6.1 The Boolean Constructor Called as a Function"},{section:"x15.6.1.1",name:"15.6.1.1 Boolean (value)"},{section:"x15.6.2",name:"15.6.2 The Boolean Constructor"},{section:"x15.6.2.1",name:"15.6.2.1 new Boolean (value)"},{section:"x15.6.3",name:"15.6.3 Properties of the Boolean Constructor"},{section:"x15.6.3.1",name:"15.6.3.1 Boolean.prototype"},{section:"x15.6.4",name:"15.6.4 Properties of the Boolean Prototype Object"},{section:"x15.6.4.1",name:"15.6.4.1 Boolean.prototype.constructor"},{section:"x15.6.4.2",name:"15.6.4.2 Boolean.prototype.toString ( )"},{section:"x15.6.4.3",name:"15.6.4.3 Boolean.prototype.valueOf ( )"},{section:"x15.6.5",name:"15.6.5 Properties of Boolean Instances"},{section:"x15.7",name:"15.7 Number Objects"},{section:"x15.7.1",name:"15.7.1 The Number Constructor Called as a Function"},{section:"x15.7.1.1",name:"15.7.1.1 Number ( [ value ] )"},{section:"x15.7.2",name:"15.7.2 The Number Constructor"},{section:"x15.7.2.1",name:"15.7.2.1 new Number ( [ value ] )"},{section:"x15.7.3",name:"15.7.3 Properties of the Number Constructor"},{section:"x15.7.3.1",name:"15.7.3.1 Number.prototype"},{section:"x15.7.3.2",name:"15.7.3.2 Number.MAX_VALUE"},{section:"x15.7.3.3",name:"15.7.3.3 Number.MIN_VALUE"},{section:"x15.7.3.4",name:"15.7.3.4 Number.NaN"},{section:"x15.7.3.5",name:"15.7.3.5 Number.NEGATIVE_INFINITY"},{section:"x15.7.3.6",name:"15.7.3.6 Number.POSITIVE_INFINITY"},{section:"x15.7.4",name:"15.7.4 Properties of the Number Prototype Object"},{section:"x15.7.4.1",name:"15.7.4.1 Number.prototype.constructor"},{section:"x15.7.4.2",name:"15.7.4.2 Number.prototype.toString ( [ radix ] )"},{section:"x15.7.4.3",name:"15.7.4.3 Number.prototype.toLocaleString()"},{section:"x15.7.4.4",name:"15.7.4.4 Number.prototype.valueOf ( )"},{section:"x15.7.4.5",name:"15.7.4.5 Number.prototype.toFixed (fractionDigits)"},{section:"x15.7.4.6",name:"15.7.4.6 Number.prototype.toExponential (fractionDigits)"},{section:"x15.7.4.7",name:"15.7.4.7 Number.prototype.toPrecision (precision)"},{section:"x15.7.5",name:"15.7.5 Properties of Number Instances"},{section:"x15.8",name:"15.8 The Math Object"},{section:"x15.8.1",name:"15.8.1 Value Properties of the Math Object"},{section:"x15.8.1.1",name:"15.8.1.1 E"},{section:"x15.8.1.2",name:"15.8.1.2 LN10"},{section:"x15.8.1.3",name:"15.8.1.3 LN2"},{section:"x15.8.1.4",name:"15.8.1.4 LOG2E"},{section:"x15.8.1.5",name:"15.8.1.5 LOG10E"},{section:"x15.8.1.6",name:"15.8.1.6 PI"},{section:"x15.8.1.7",name:"15.8.1.7 SQRT1_2"},{section:"x15.8.1.8",name:"15.8.1.8 SQRT2"},{section:"x15.8.2",name:"15.8.2 Function Properties of the Math Object"},{section:"x15.8.2.1",name:"15.8.2.1 abs (x)"},{section:"x15.8.2.2",name:"15.8.2.2 acos (x)"},{section:"x15.8.2.3",name:"15.8.2.3 asin (x)"},{section:"x15.8.2.4",name:"15.8.2.4 atan (x)"},{section:"x15.8.2.5",name:"15.8.2.5 atan2 (y, x)"},{section:"x15.8.2.6",name:"15.8.2.6 ceil (x)"},{section:"x15.8.2.7",name:"15.8.2.7 cos (x)"},{section:"x15.8.2.8",name:"15.8.2.8 exp (x)"},{section:"x15.8.2.9",name:"15.8.2.9 floor (x)"},{section:"x15.8.2.10",name:"15.8.2.10 log (x)"},{section:"x15.8.2.11",name:"15.8.2.11 max ( [ value1 [ , value2 [ , … ] ] ] )"},{section:"x15.8.2.12",name:"15.8.2.12 min ( [ value1 [ , value2 [ , … ] ] ] )"},{section:"x15.8.2.13",name:"15.8.2.13 pow (x, y)"},{section:"x15.8.2.14",name:"15.8.2.14 random ( )"},{section:"x15.8.2.15",name:"15.8.2.15 round (x)"},{section:"x15.8.2.16",name:"15.8.2.16 sin (x)"},{section:"x15.8.2.17",name:"15.8.2.17 sqrt (x)"},{section:"x15.8.2.18",name:"15.8.2.18 tan (x)"},{section:"x15.9",name:"15.9 Date Objects"},{section:"x15.9.1",name:"15.9.1 Overview of Date Objects and Definitions of Abstract Operators"},{section:"x15.9.1.1",name:"15.9.1.1 Time Values and Time Range"},{section:"x15.9.1.2",name:"15.9.1.2 Day Number and Time within Day"},{section:"x15.9.1.3",name:"15.9.1.3 Year Number"},{section:"x15.9.1.4",name:"15.9.1.4 Month Number"},{section:"x15.9.1.5",name:"15.9.1.5 Date Number"},{section:"x15.9.1.6",name:"15.9.1.6 Week Day"},{section:"x15.9.1.7",name:"15.9.1.7 Local Time Zone Adjustment"},{section:"x15.9.1.8",name:"15.9.1.8 Daylight Saving Time Adjustment"},{section:"x15.9.1.9",name:"15.9.1.9 Local Time"},{section:"x15.9.1.10",name:"15.9.1.10 Hours, Minutes, Second, and Milliseconds"},{section:"x15.9.1.11",name:"15.9.1.11 MakeTime (hour, min, sec, ms)"},{section:"x15.9.1.12",name:"15.9.1.12 MakeDay (year, month, date)"},{section:"x15.9.1.13",name:"15.9.1.13 MakeDate (day, time)"},{section:"x15.9.1.14",name:"15.9.1.14 TimeClip (time)"},{section:"x15.9.1.15",name:"15.9.1.15 Date Time String Format"},{section:"x15.9.1.15.1",name:"15.9.1.15.1 Extended years"},{section:"x15.9.2",name:"15.9.2 The Date Constructor Called as a Function"},{section:"x15.9.2.1",name:"15.9.2.1 Date ( [ year [, month [, date [, hours [, minutes [, seconds [, ms ] ] ] ] ] ] ] )"},{section:"x15.9.3",name:"15.9.3 The Date Constructor"},{section:"x15.9.3.1",name:"15.9.3.1 new Date (year, month [, date [, hours [, minutes [, seconds [, ms ] ] ] ] ] )"},{section:"x15.9.3.2",name:"15.9.3.2 new Date (value)"},{section:"x15.9.3.3",name:"15.9.3.3 new Date ( )"},{section:"x15.9.4",name:"15.9.4 Properties of the Date Constructor"},{section:"x15.9.4.1",name:"15.9.4.1 Date.prototype"},{section:"x15.9.4.2",name:"15.9.4.2 Date.parse (string)"},{section:"x15.9.4.3",name:"15.9.4.3 Date.UTC (year, month [, date [, hours [, minutes [, seconds [, ms ] ] ] ] ])"},{section:"x15.9.4.4",name:"15.9.4.4 Date.now ( )"},{section:"x15.9.5",name:"15.9.5 Properties of the Date Prototype Object"},{section:"x15.9.5.1",name:"15.9.5.1 Date.prototype.constructor"},{section:"x15.9.5.2",name:"15.9.5.2 Date.prototype.toString ( )"},{section:"x15.9.5.3",name:"15.9.5.3 Date.prototype.toDateString ( )"},{section:"x15.9.5.4",name:"15.9.5.4 Date.prototype.toTimeString ( )"},{section:"x15.9.5.5",name:"15.9.5.5 Date.prototype.toLocaleString ( )"},{section:"x15.9.5.6",name:"15.9.5.6 Date.prototype.toLocaleDateString ( )"},{section:"x15.9.5.7",name:"15.9.5.7 Date.prototype.toLocaleTimeString ( )"},{section:"x15.9.5.8",name:"15.9.5.8 Date.prototype.valueOf ( )"},{section:"x15.9.5.9",name:"15.9.5.9 Date.prototype.getTime ( )"},{section:"x15.9.5.10",name:"15.9.5.10 Date.prototype.getFullYear ( )"},{section:"x15.9.5.11",name:"15.9.5.11 Date.prototype.getUTCFullYear ( )"},{section:"x15.9.5.12",name:"15.9.5.12 Date.prototype.getMonth ( )"},{section:"x15.9.5.13",name:"15.9.5.13 Date.prototype.getUTCMonth ( )"},{section:"x15.9.5.14",name:"15.9.5.14 Date.prototype.getDate ( )"},{section:"x15.9.5.15",name:"15.9.5.15 Date.prototype.getUTCDate ( )"},{section:"x15.9.5.16",name:"15.9.5.16 Date.prototype.getDay ( )"},{section:"x15.9.5.17",name:"15.9.5.17 Date.prototype.getUTCDay ( )"},{section:"x15.9.5.18",name:"15.9.5.18 Date.prototype.getHours ( )"},{section:"x15.9.5.19",name:"15.9.5.19 Date.prototype.getUTCHours ( )"},{section:"x15.9.5.20",name:"15.9.5.20 Date.prototype.getMinutes ( )"},{section:"x15.9.5.21",name:"15.9.5.21 Date.prototype.getUTCMinutes ( )"},{section:"x15.9.5.22",name:"15.9.5.22 Date.prototype.getSeconds ( )"},{section:"x15.9.5.23",name:"15.9.5.23 Date.prototype.getUTCSeconds ( )"},{section:"x15.9.5.24",name:"15.9.5.24 Date.prototype.getMilliseconds ( )"},{section:"x15.9.5.25",name:"15.9.5.25 Date.prototype.getUTCMilliseconds ( )"},{section:"x15.9.5.26",name:"15.9.5.26 Date.prototype.getTimezoneOffset ( )"},{section:"x15.9.5.27",name:"15.9.5.27 Date.prototype.setTime (time)"},{section:"x15.9.5.28",name:"15.9.5.28 Date.prototype.setMilliseconds (ms)"},{section:"x15.9.5.29",name:"15.9.5.29 Date.prototype.setUTCMilliseconds (ms)"},{section:"x15.9.5.30",name:"15.9.5.30 Date.prototype.setSeconds (sec [, ms ] )"},{section:"x15.9.5.31",name:"15.9.5.31 Date.prototype.setUTCSeconds (sec [, ms ] )"},{section:"x15.9.5.32",name:"15.9.5.32 Date.prototype.setMinutes (min [, sec [, ms ] ] )"},{section:"x15.9.5.33",name:"15.9.5.33 Date.prototype.setUTCMinutes (min [, sec [, ms ] ] )"},{section:"x15.9.5.34",name:"15.9.5.34 Date.prototype.setHours (hour [, min [, sec [, ms ] ] ] )"},{section:"x15.9.5.35",name:"15.9.5.35 Date.prototype.setUTCHours (hour [, min [, sec [, ms ] ] ] )"},{section:"x15.9.5.36",name:"15.9.5.36 Date.prototype.setDate (date)"},{section:"x15.9.5.37",name:"15.9.5.37 Date.prototype.setUTCDate (date)"},{section:"x15.9.5.38",name:"15.9.5.38 Date.prototype.setMonth (month [, date ] )"},{section:"x15.9.5.39",name:"15.9.5.39 Date.prototype.setUTCMonth (month [, date ] )"},{section:"x15.9.5.40",name:"15.9.5.40 Date.prototype.setFullYear (year [, month [, date ] ] )"},{section:"x15.9.5.41",name:"15.9.5.41 Date.prototype.setUTCFullYear (year [, month [, date ] ] )"},{section:"x15.9.5.42",name:"15.9.5.42 Date.prototype.toUTCString ( )"},{section:"x15.9.5.43",name:"15.9.5.43 Date.prototype.toISOString ( )"},{section:"x15.9.5.44",name:"15.9.5.44 Date.prototype.toJSON ( key )"},{section:"x15.9.6",name:"15.9.6 Properties of Date Instances"},{section:"x15.10",name:"15.10 RegExp (Regular Expression) Objects"},{section:"x15.10.1",name:"15.10.1 Patterns"},{section:"x15.10.2",name:"15.10.2 Pattern Semantics"},{section:"x15.10.2.1",name:"15.10.2.1 Notation"},{section:"x15.10.2.2",name:"15.10.2.2 Pattern"},{section:"x15.10.2.3",name:"15.10.2.3 Disjunction"},{section:"x15.10.2.4",name:"15.10.2.4 Alternative"},{section:"x15.10.2.5",name:"15.10.2.5 Term"},{section:"x15.10.2.6",name:"15.10.2.6 Assertion"},{section:"x15.10.2.7",name:"15.10.2.7 Quantifier"},{section:"x15.10.2.8",name:"15.10.2.8 Atom"},{section:"x15.10.2.9",name:"15.10.2.9 AtomEscape"},{section:"x15.10.2.10",name:"15.10.2.10 CharacterEscape"},{section:"x15.10.2.11",name:"15.10.2.11 DecimalEscape"},{section:"x15.10.2.12",name:"15.10.2.12 CharacterClassEscape"},{section:"x15.10.2.13",name:"15.10.2.13 CharacterClass"},{section:"x15.10.2.14",name:"15.10.2.14 ClassRanges"},{section:"x15.10.2.15",name:"15.10.2.15 NonemptyClassRanges"},{section:"x15.10.2.16",name:"15.10.2.16 NonemptyClassRangesNoDash"},{section:"x15.10.2.17",name:"15.10.2.17 ClassAtom"},{section:"x15.10.2.18",name:"15.10.2.18 ClassAtomNoDash"},{section:"x15.10.2.19",name:"15.10.2.19 ClassEscape"},{section:"x15.10.3",name:"15.10.3 The RegExp Constructor Called as a Function"},{section:"x15.10.3.1",name:"15.10.3.1 RegExp(pattern, flags)"},{section:"x15.10.4",name:"15.10.4 The RegExp Constructor"},{section:"x15.10.4.1",name:"15.10.4.1 new RegExp(pattern, flags)"},{section:"x15.10.5",name:"15.10.5 Properties of the RegExp Constructor"},{section:"x15.10.5.1",name:"15.10.5.1 RegExp.prototype"},{section:"x15.10.6",name:"15.10.6 Properties of the RegExp Prototype Object"},{section:"x15.10.6.1",name:"15.10.6.1 RegExp.prototype.constructor"},{section:"x15.10.6.2",name:"15.10.6.2 RegExp.prototype.exec(string)"},{section:"x15.10.6.3",name:"15.10.6.3 RegExp.prototype.test(string)"},{section:"x15.10.6.4",name:"15.10.6.4 RegExp.prototype.toString()"},{section:"x15.10.7",name:"15.10.7 Properties of RegExp Instances"},{section:"x15.10.7.1",name:"15.10.7.1 source"},{section:"x15.10.7.2",name:"15.10.7.2 global"},{section:"x15.10.7.3",name:"15.10.7.3 ignoreCase"},{section:"x15.10.7.4",name:"15.10.7.4 multiline"},{section:"x15.10.7.5",name:"15.10.7.5 lastIndex"},{section:"x15.11",name:"15.11 Error Objects"},{section:"x15.11.1",name:"15.11.1 The Error Constructor Called as a Function"},{section:"x15.11.1.1",name:"15.11.1.1 Error (message)"},{section:"x15.11.2",name:"15.11.2 The Error Constructor"},{section:"x15.11.2.1",name:"15.11.2.1 new Error (message)"},{section:"x15.11.3",name:"15.11.3 Properties of the Error Constructor"},{section:"x15.11.3.1",name:"15.11.3.1 Error.prototype"},{section:"x15.11.4",name:"15.11.4 Properties of the Error Prototype Object"},{section:"x15.11.4.1",name:"15.11.4.1 Error.prototype.constructor"},{section:"x15.11.4.2",name:"15.11.4.2 Error.prototype.name"},{section:"x15.11.4.3",name:"15.11.4.3 Error.prototype.message"},{section:"x15.11.4.4",name:"15.11.4.4 Error.prototype.toString ( )"},{section:"x15.11.5",name:"15.11.5 Properties of Error Instances"},{section:"x15.11.6",name:"15.11.6 Native Error Types Used in This Standard"},{section:"x15.11.6.1",name:"15.11.6.1 EvalError"},{section:"x15.11.6.2",name:"15.11.6.2 RangeError"},{section:"x15.11.6.3",name:"15.11.6.3 ReferenceError"},{section:"x15.11.6.4",name:"15.11.6.4 SyntaxError"},{section:"x15.11.6.5",name:"15.11.6.5 TypeError"},{section:"x15.11.6.6",name:"15.11.6.6 URIError"},{section:"x15.11.7",name:"15.11.7 NativeError Object Structure"},{section:"x15.11.7.1",name:"15.11.7.1 NativeError Constructors Called as Functions"},{section:"x15.11.7.2",name:"15.11.7.2 NativeError (message)"},{section:"x15.11.7.3",name:"15.11.7.3 The NativeError Constructors"},{section:"x15.11.7.4",name:"15.11.7.4 New NativeError (message)"},{section:"x15.11.7.5",name:"15.11.7.5 Properties of the NativeError Constructors"},{section:"x15.11.7.6",name:"15.11.7.6 NativeError.prototype"},{section:"x15.11.7.7",name:"15.11.7.7 Properties of the NativeError Prototype Objects"},{section:"x15.11.7.8",name:"15.11.7.8 NativeError.prototype.constructor"},{section:"x15.11.7.9",name:"15.11.7.9 NativeError.prototype.name"},{section:"x15.11.7.10",name:"15.11.7.10 NativeError.prototype.message"},{section:"x15.11.7.11",name:"15.11.7.11 Properties of NativeError Instances"},{section:"x15.12",name:"15.12 The JSON Object"},{section:"x15.12.1",name:"15.12.1 The JSON Grammar "},{section:"x15.12.1.1",name:"15.12.1.1 The JSON Lexical Grammar"},{section:"x15.12.1.2",name:"15.12.1.2 The JSON Syntactic Grammar"},{section:"x15.12.2",name:"15.12.2 parse ( text [ , reviver ] )"},{section:"x15.12.3",name:"15.12.3 stringify ( value [ , replacer [ , space ] ] )"},{section:"x16",name:"16 Errors"},{section:"A",name:"Annex A (informative) Grammar Summary"},{section:"A.1",name:"A.1 Lexical Grammar"},{section:"A.2",name:"A.2 Number Conversions"},{section:"A.3",name:"A.3 Expressions"},{section:"A.4",name:"A.4 Statements"},{section:"A.5",name:"A.5 Functions and Programs"},{section:"A.6",name:"A.6 Universal Resource Identifier Character Classes"},{section:"A.7",name:"A.7 Regular Expressions"},{section:"A.8",name:"A.8 JSON"},{section:"A.8.1",name:"A.8.1 JSON Lexical Grammar"},{section:"A.8.2",name:"A.8.2 JSON Syntactic Grammar"},{section:"B",name:"Annex B (informative) Compatibility"},{section:"B.1",name:"B.1 Additional Syntax"},{section:"B.1.1",name:"B.1.1 Numeric Literals"},{section:"B.1.2",name:"B.1.2 String Literals"},{section:"B.2",name:"B.2 Additional Properties"},{section:"B.2.1",name:"B.2.1 escape (string)"},{section:"B.2.2",name:"B.2.2 unescape (string)"},{section:"B.2.3",name:"B.2.3 String.prototype.substr (start, length)"},{section:"B.2.4",name:"B.2.4 Date.prototype.getYear ( )"},{section:"B.2.5",name:"B.2.5 Date.prototype.setYear (year)"},{section:"B.2.6",name:"B.2.6 Date.prototype.toGMTString ( )"},{section:"C",name:"Annex C (informative) The Strict Mode of ECMAScript"},{section:"D",name:"Annex D (informative) Corrections and Clarifications in the 5th Edition with Possible 3rd Edition Compatibility Impact"},{section:"E",name:"Annex E (informative) Additions and Changes in the 5th Edition that Introduce Incompatibilities with the 3rd Edition"},{section:"bibliography",name:"Bibliography"}],bot.addCommand({name:"spec",fun:e,permissions:{del:"NONE"},description:"Find a section in the ES5 spec"}) -}(),function(){var e=JSON.parse(localStorage.getItem("bot_todo")||"{}"),t=Object.create(null),n=function(n){if(t[n])return t[n];var o=e[n],i=[];return o||(o=e[n]=[]),t[n]={get:function(e){return o.slice(e).map(function(e,t){return"("+(t+1)+")"+e}).join(", ")},add:function(e){return o.push(e),!0},remove:function(e){var t=o.indexOf(e);return-1===t?!1:(i.push(t),!0)},removeByIndex:function(e){return e>=o.length?!1:(i.push(e),!0)},save:function(){bot.log(i.slice(),o.slice()),o=o.filter(function(e,t){return-1===i.indexOf(t)}),i.length=0,e[n]=o,localStorage.bot_todo=JSON.stringify(e)},exists:function(e){return e=e.toLowerCase(),o.some(function(t){return e===t.toLowerCase()})}}},o=function(e){var t=e.parse();bot.log(t,"todo input"),t[0]||(t=["get"]);var o,i,r=t[0],a=n(e.get("user_id")),s=t.slice(1);return"get"===r?(i=a.get(s[0]),i||(i="No items on your todo."),bot.log(i,"todo get")):"add"===r?(o=s.every(function(e){return a.exists(e)?(i=e+" already exists.",!1):(a.add(e),!0)}),o&&(i="Item(s) added."),bot.log(i,"todo add")):"rem"===r?(o=s.every(function(e){if(/^\d+$/.test(e))a.removeByIndex(Number(e-1));else{if(!a.exists(e))return i=e+" does not exist.",!1;a.remove(e)}return!0}),o&&(i="Item(s) removed."),bot.log(i,"todo rem")):(i="Unidentified /todo action "+r,bot.log(i,"todo undefined")),a.save(),i};bot.addCommand({name:"todo",fun:o,permissions:{del:"NONE"},description:"Your personal todo list. `get [count]` retrieves everything or count items. `add items` adds items to your todo list (make sure items with spaces are wrapped in quotes) `rem items|indices` removes items specified by indice or content"})}(),function(){"use strict";function e(){return Object.keys(t).concat(Object.keys(n))}var t={C:function(e){return{F:1.8*e+32,K:e+273.15}},F:function(e){return{C:(e-32)/1.8,K:5*(e+459.67)/9}},K:function(e){return 0>e?null:{C:e-273.15,F:1.8*e-459.67}},m:function(e){return{f:3.280839895*e}},f:function(e){return{m:e/3.28083989}},km:function(e){return t.m(1e3*e)},mm:function(e){return t.m(e/1e3)},i:function(e){return t.f(e/12)},d:function(e){return{r:180*e/Math.PI}},r:function(e){return{d:e*Math.PI/180}},g:function(e){return{lb:.0022*e}},lb:function(e){return{g:453.592*e}}},n={},o=/(-?\d+\.?\d*)\s*([^\s]+)/,i=function(i){function r(e){return u[e].maxDecimal(4)+e}if(bot.log(i,"/convert input"),"list"==""+i)return e().join(", ");var a=o.exec(i),s=Number(a[1]),c=a[2];if(bot.log(a,"/convert broken"),n[c]&&(c=n[c]),!t[c])return"Confuse converter with "+c+", receive error message";var u=t[c](s);return bot.log(u,"/console answer"),Object.keys(u).map(r).join(", ")};bot.addCommand({name:"convert",fun:i,permissions:{del:"NONE"},description:"Converts several units, case sensitive. `/convert ` Pass in list for supported units `/convert list`"})}(),function(){function e(e,n){function o(e){if(e.error_message)return i(e.error_message),void 0;var n,o=e.items[0];n=o?t(o,c):"User "+s+" not found",i(n)}function i(t){n?n(t):e.reply(t)}var r=e.parse(),s=r[0],c="extended"===r[1];return s?/^\d+$/.test(s)||(s=e.findUserid(s)):s=e.get("user_id"),.1>=Math.random()?(i("That dude sucks"),void 0):(IO.jsonp({url:"https://api.stackexchange.com/2.0/users/"+s,data:{site:a,filter:"!G*klMsSp1IcBUKxXMwhRe8TaI("},fun:o}),void 0)}function t(e,t){e=n(e);var a=i.supplant(e);return t&&(a+=r.supplant(o(e))),a}function n(e){return e=Object.merge({question_count:0,answer_count:0,reputation_change_day:0},e),e.ratio=!e.question_count&&e.answer_count?"H̸̡̪̯ͨ͊̽̅̾̎Ȩ̬̩̾͛ͪ̈́̀́͘ ̶̧̨̱̹̭̯ͧ̾ͬC̷̙̲̝͖ͭ̏ͥͮ͟Oͮ͏̮̪̝͍M̲̖͊̒ͪͩͬ̚̚͜Ȇ̴̟̟͙̞ͩ͌͝S̨̥̫͎̭ͯ̿̔̀ͅ":!e.answer_count&&e.question_count?"TO͇̹̺ͅƝ̴ȳ̳ TH̘Ë͖́̉ ͠P̯͍̭O̚​N̐Y̡":e.answer_count||e.question_count?Math.ratio(e.question_count,e.answer_count):"http://www.imgzzz.com/i/image_1294737413.png",console.log(e,"/stat normalized"),e}function o(e){return e=Object.merge(e.badge_counts,e),e.avg_rep_post=e.reputation/(e.question_count+e.answer_count),1/0===e.avg_rep_post&&(e.avg_rep_post="T͎͍̘͙̖̤̉̌̇̅ͯ͋͢͜͝H̖͙̗̗̺͚̱͕̒́͟E̫̺̯͖͎̗̒͑̅̈ ̈ͮ̽ͯ̆̋́͏͙͓͓͇̹<̩̟̳̫̪̇ͩ̑̆͗̽̇͆́ͅC̬͎ͪͩ̓̑͊ͮͪ̄̚̕Ě̯̰̤̗̜̗͓͛͝N̶̴̞͇̟̲̪̅̓ͯͅT͍̯̰͓̬͚̅͆̄E̠͇͇̬̬͕͖ͨ̔̓͞R͚̠̻̲̗̹̀>̇̏ͣ҉̳̖̟̫͕ ̧̛͈͙͇͂̓̚͡C͈̞̻̩̯̠̻ͥ̆͐̄ͦ́̀͟A̛̪̫͙̺̱̥̞̙ͦͧ̽͛̈́ͯ̅̍N̦̭͕̹̤͓͙̲̑͋̾͊ͣŅ̜̝͌͟O̡̝͍͚̲̝ͣ̔́͝Ť͈͢ ̪̘̳͔̂̒̋ͭ͆̽͠H̢͈̤͚̬̪̭͗ͧͬ̈́̈̀͌͒͡Ơ̮͍͇̝̰͍͚͖̿ͮ̀̍́L͐̆ͨ̏̎͡҉̧̱̯̤̹͓̗̻̭ͅḐ̲̰͙͑̂̒̐́̊"),console.log(e,"/stat extended"),e}var i="[{display_name}]({link}) has {reputation} reputation, earned {reputation_change_day} rep today, asked {question_count} questions, gave {answer_count} answers, for a q:a ratio of {ratio}.\n",r="avg. rep/post: {avg_rep_post}, {gold} gold badges, {silver} silver badges and {bronze} bronze badges. ",a=/chat\.(\w+)/.exec(location)[1];bot.addCommand({name:"stat",fun:e,permissions:{del:"NONE"},description:"Gives useless stats on a user. `/stat usrid|usrname`",async:!0})}();var moo=function(){function e(e,t){function n(e,n){var i=n.length;return o+i>t&&(e+="\n",o=0),o+=i+1,e+n+" "}var o=0;return e.split(" ").reduce(n,"")}function t(e,t,n){for(n=n||" ";t>e.length;)e+=n;return e}var n={defaults:{e:"oo",T:" ",t:!1,W:40},cow:[""," L ^__^"," L (e)\\_______"," (__)\\ )\\/\\"," T ||----w |"," || ||"].join("\n"),moo:function(n,o){var i=this.defaults;return this.eyes=t(o.e||i.e,2).slice(0,2),this.tongue=t(o.T||i.T,2).slice(0,2),this.line=o.t?"O":"\\",this.thinking=o.t,this.message=e(n,o.W||i.W),this.makeBalloon()+this.makeCow()},makeCow:function(){return this.cow.replace(/e/g,this.eyes).replace(/T/g,this.tongue).replace(/L/g,this.line)},makeBalloon:function(){var e=this.message.trim().split("\n"),n=Math.max.apply(Math,e.map(function(e){return e.length})),o=Array(n+2),i=o.join("_"),r=o.join("-"),a=e.length,s=this.chooseBorders(a),c=e.map(function(e,o){var i;return i=0===o?s.slice(0,2):o===a-1?s.slice(2,4):s.slice(-2),i[0]+" "+t(e,n)+" "+i[1]});return c.unshift(" "+i),c.push(" "+r),c.join("\n")},chooseBorders:function(e){var t;return t=this.thinking?["(",")","(",")","(",")"]:1===e?["<",">"]:["/","\\","\\","/","|","|"]}};return function(){return n.moo.apply(n,arguments)}}();bot.listen(/cow(think|say)\s(?:([eT])=(.{0,2})\s)?(?:([eT])=(.{0,2})\s)?(.+)/,function(e){for(var t=e.matches.slice(2,-1),n={},o=0,i=t.length;i>o;o+=2)t[o]&&t[o+1]&&(n[t[o]]=t[o+1]);n.t="think"===e.matches[1];var r=moo(e.matches.slice(-1)[0],n);e.respond(e.codify(r))}),function(){function e(e,t){function n(t){function n(t){var n=decodeURIComponent(t.titleNoFormatting);return e.link(n,t.url)}if(bot.log(t,"/google response"),200!==t.responseStatus)return o("My Google-Fu is on vacation; status "+t.responseStatus),void 0;var i=t.responseData.results.slice(0,3);return bot.log(i,"/google results"),i.length?(o(i.map(n).join(" ; ")),void 0):(o("The Google contains no such knowledge"),void 0)}function o(n){bot.log(n,"/google final"),t&&t.call?t(n):e.reply(n)}IO.jsonp.google(""+e,n)}bot.addCommand({name:"google",fun:e,permissions:{del:"NONE"},description:"Search Google. `/google query`",async:!0})}(),function(){function e(e){var n=e.parse(),i=n.shift(),r=n.shift()||"js";if(r=r.toLowerCase(),console.log(i,r,"/beautify input"),0>["html","css","js"].indexOf(r))return o;var a={js:js_beautify,css:css_beautify,html:style_html},s=t(i,e);if(!s)return"404 Message "+i+" Not Found";var c=s.getElementsByClassName("content")[0].textContent;console.log(c,"/beautify beautifying"),e.respond(e.codify(a[r](c)))}function t(e,t){return/^\d+$/.test(e)?document.getElementById("message-"+e):(console.log(e,"/beautify fetch_message"),n(t.findUserid(e)))}function n(e){function t(e){return/\bmonologue\b/.test(e.className)}var n=[].filter.call(document.getElementsByClassName("user-"+e),t).pop();return n?[].pop.call(n.getElementsByClassName("message")):void 0}var o="Fetches and beautifies a message containing html, css or js. `/beautify msgid [lang=js]`";bot.addCommand({name:"beautify",fun:e,permission:{del:"NONE"},description:o})}(),"undefined"!=typeof exports&&(exports.js_beautify=js_beautify),"undefined"!=typeof exports&&(exports.css_beautify=css_beautify),function(){"use strict";var e=function(e){function t(t){e(t.word.toLowerCase().trim())}IO.jsonp({url:"http://sleepy-bastion-8674.herokuapp.com/",jsonpName:"callback",fun:t})},t={dude:[" +---+"," | |"," | 413"," | 2"," | 5 6","__+__"].join("\n"),parts:["","O","|","/","\\","/","\\"],word:"",revealed:"",guesses:[],guessNum:0,maxGuess:6,guessMade:!1,end:!0,msg:null,validGuessRegex:/^[\w\s]+$/,receiveMessage:function(e){if(this.msg=e,this.end)this.new();else if(e.content)return this.handleGuess(e)},"new":function(){var n=this;e(function(e){bot.log(e+" /hang random"),t.word=e,n.revealed=Array(e.length+1).join("-"),n.guesses=[],n.guessNum=0,n.guessMade=!0,n.register()})},handleGuess:function(e){var t=e.slice().toLowerCase();if(bot.log(t,"handleGuess"),!this.validGuessRegex.test(t))return"Only alphanumeric and whitespace characters allowed";if(this.guesses.indexOf(t)>-1)return t+" was already submitted";if(t.length>this.word.length)return e.codify(t)+" is longer than the phrase";var n=this.word.indexesOf(t);return n.forEach(function(e){this.uncoverPart(t,e)},this),n.length||this.guessNum++,this.guesses.push(t),this.guessMade=!0,bot.log(t,this.guessMade,"handleGuess handled"),this.loseCheck()?this.lose():this.winCheck()?this.win():void 0},uncoverPart:function(e,t){this.revealed=this.revealed.slice(0,t)+e+this.revealed.slice(t+e.length)},preparePrint:function(){var e=this,t=this.dude.replace(/\d/g,function(t){return t>e.guessNum?" ":e.parts[t]}),n=this.guesses.sort().join(", ")+"\n"+this.revealed,o=this.msg.codify(t+"\n"+n);bot.log(o,this.msg),this.msg.respond(o)},win:function(){return this.unregister(),"Correct! The phrase is "+this.word+"."},lose:function(){return this.unregister(),"You people suck. The phrase was "+this.word},winCheck:function(){return this.word===this.revealed},loseCheck:function(){return this.guessNum>=this.maxGuess},register:function(){this.unregister(),IO.register("beforeoutput",this.buildOutput,this),this.end=!1},unregister:function(){IO.unregister("beforeoutput",this.buildOutput),this.end=!0},buildOutput:function(){this.guessMade&&(this.preparePrint(),this.guessMade=!1)}};bot.addCommand({name:"hang",fun:t.receiveMessage,thisArg:t})}(),function(){function e(e){bot.log(e,"/learn input");var n=e.parse(),r={name:n[0],output:n[1],input:n[2]||".*"},a=o(r);return a?a:(r.name=r.name.toLowerCase(),r.input=RegExp(r.input),i=bot.getCommand("parse"),i.error?(console.error("/parse not loaded, cannot /learn"),"Failed; /parse not loaded"):(console.log(i),bot.log(r,"/learn parsed"),t(r),"Command "+r.name+" learned"))}function t(e){bot.addCommand({name:e.name,description:"User-taught command: "+e.output,fun:n(e),permissions:{use:"ALL",del:"ALL"}})}function n(e){return function(t){bot.log(t,e.name+" input");var n=bot.Message(e.output,t.get());return i.exec(n,e.input.exec(t))}}function o(e){var t,n=Object.keys(e).some(function(t){return!e[t]});return n&&(t="Illegal /learn object"),/^[\w\-]+$/.test(e.name)||(t="Invalid command name"),bot.commandExists(e.name.toLowerCase())&&(t="Command "+e.name+" already exists"),t}var i;bot.addCommand({name:"learn",fun:e,privileges:{del:"NONE"},description:"Teaches the bot a command. `/learn cmdName cmdOutputMacro [cmdInputRegex]`"})}(); \ No newline at end of file +}(),function(){var e=JSON.parse(localStorage.getItem("bot_todo")||"{}"),t=Object.create(null),n=function(n){if(t[n])return t[n];var o=e[n],i=[];return o||(o=e[n]=[]),t[n]={get:function(e){return o.slice(e).map(function(e,t){return"("+(t+1)+")"+e}).join(", ")},add:function(e){return o.push(e),!0},remove:function(e){var t=o.indexOf(e);return-1===t?!1:(i.push(t),!0)},removeByIndex:function(e){return e>=o.length?!1:(i.push(e),!0)},save:function(){bot.log(i.slice(),o.slice()),o=o.filter(function(e,t){return-1===i.indexOf(t)}),i.length=0,e[n]=o,localStorage.bot_todo=JSON.stringify(e)},exists:function(e){return e=e.toLowerCase(),o.some(function(t){return e===t.toLowerCase()})}}},o=function(e){var t=e.parse();bot.log(t,"todo input"),t[0]||(t=["get"]);var o,i,r=t[0],a=n(e.get("user_id")),s=t.slice(1);return"get"===r?(i=a.get(s[0]),i||(i="No items on your todo."),bot.log(i,"todo get")):"add"===r?(o=s.every(function(e){return a.exists(e)?(i=e+" already exists.",!1):(a.add(e),!0)}),o&&(i="Item(s) added."),bot.log(i,"todo add")):"rem"===r?(o=s.every(function(e){if(/^\d+$/.test(e))a.removeByIndex(Number(e-1));else{if(!a.exists(e))return i=e+" does not exist.",!1;a.remove(e)}return!0}),o&&(i="Item(s) removed."),bot.log(i,"todo rem")):(i="Unidentified /todo action "+r,bot.log(i,"todo undefined")),a.save(),i};bot.addCommand({name:"todo",fun:o,permissions:{del:"NONE"},description:"Your personal todo list. `get [count]` retrieves everything or count items. `add items` adds items to your todo list (make sure items with spaces are wrapped in quotes) `rem items|indices` removes items specified by indice or content"})}(),function(){"use strict";function e(){return Object.keys(t).concat(Object.keys(n))}var t={C:function(e){return{F:1.8*e+32,K:e+273.15}},F:function(e){return{C:(e-32)/1.8,K:5*(e+459.67)/9}},K:function(e){return 0>e?null:{C:e-273.15,F:1.8*e-459.67}},m:function(e){return{f:3.280839895*e}},f:function(e){return{m:e/3.28083989}},km:function(e){return t.m(1e3*e)},mm:function(e){return t.m(e/1e3)},i:function(e){return t.f(e/12)},d:function(e){return{r:180*e/Math.PI}},r:function(e){return{d:e*Math.PI/180}},g:function(e){return{lb:.0022*e}},lb:function(e){return{g:453.592*e}}},n={},o=/(-?\d+\.?\d*)\s*([^\s]+)/,i=function(i){function r(e){return u[e].maxDecimal(4)+e}if(bot.log(i,"/convert input"),"list"==""+i)return e().join(", ");var a=o.exec(i),s=Number(a[1]),c=a[2];if(bot.log(a,"/convert broken"),n[c]&&(c=n[c]),!t[c])return"Confuse converter with "+c+", receive error message";var u=t[c](s);return bot.log(u,"/console answer"),Object.keys(u).map(r).join(", ")};bot.addCommand({name:"convert",fun:i,permissions:{del:"NONE"},description:"Converts several units, case sensitive. `/convert ` Pass in list for supported units `/convert list`"})}(),function(){function e(e,n){function o(e){if(e.error_message)return i(e.error_message),void 0;var n,o=e.items[0];n=o?t(o,c):"User "+s+" not found",i(n)}function i(t){n?n(t):e.reply(t)}var r=e.parse(),s=r[0],c="extended"===r[1];return s?/^\d+$/.test(s)||(s=e.findUserid(s)):s=e.get("user_id"),.1>=Math.random()?(i("That dude sucks"),void 0):(IO.jsonp({url:"https://api.stackexchange.com/2.0/users/"+s,data:{site:a,filter:"!G*klMsSp1IcBUKxXMwhRe8TaI("},fun:o}),void 0)}function t(e,t){e=n(e);var a=i.supplant(e);return t&&(a+=r.supplant(o(e))),a}function n(e){return e=Object.merge({question_count:0,answer_count:0,reputation_change_day:0},e),e.ratio=!e.question_count&&e.answer_count?"H̸̡̪̯ͨ͊̽̅̾̎Ȩ̬̩̾͛ͪ̈́̀́͘ ̶̧̨̱̹̭̯ͧ̾ͬC̷̙̲̝͖ͭ̏ͥͮ͟Oͮ͏̮̪̝͍M̲̖͊̒ͪͩͬ̚̚͜Ȇ̴̟̟͙̞ͩ͌͝S̨̥̫͎̭ͯ̿̔̀ͅ":!e.answer_count&&e.question_count?"TO͇̹̺ͅƝ̴ȳ̳ TH̘Ë͖́̉ ͠P̯͍̭O̚​N̐Y̡":e.answer_count||e.question_count?Math.ratio(e.question_count,e.answer_count):"http://www.imgzzz.com/i/image_1294737413.png",console.log(e,"/stat normalized"),e}function o(e){return e=Object.merge(e.badge_counts,e),e.avg_rep_post=e.reputation/(e.question_count+e.answer_count),1/0===e.avg_rep_post&&(e.avg_rep_post="T͎͍̘͙̖̤̉̌̇̅ͯ͋͢͜͝H̖͙̗̗̺͚̱͕̒́͟E̫̺̯͖͎̗̒͑̅̈ ̈ͮ̽ͯ̆̋́͏͙͓͓͇̹<̩̟̳̫̪̇ͩ̑̆͗̽̇͆́ͅC̬͎ͪͩ̓̑͊ͮͪ̄̚̕Ě̯̰̤̗̜̗͓͛͝N̶̴̞͇̟̲̪̅̓ͯͅT͍̯̰͓̬͚̅͆̄E̠͇͇̬̬͕͖ͨ̔̓͞R͚̠̻̲̗̹̀>̇̏ͣ҉̳̖̟̫͕ ̧̛͈͙͇͂̓̚͡C͈̞̻̩̯̠̻ͥ̆͐̄ͦ́̀͟A̛̪̫͙̺̱̥̞̙ͦͧ̽͛̈́ͯ̅̍N̦̭͕̹̤͓͙̲̑͋̾͊ͣŅ̜̝͌͟O̡̝͍͚̲̝ͣ̔́͝Ť͈͢ ̪̘̳͔̂̒̋ͭ͆̽͠H̢͈̤͚̬̪̭͗ͧͬ̈́̈̀͌͒͡Ơ̮͍͇̝̰͍͚͖̿ͮ̀̍́L͐̆ͨ̏̎͡҉̧̱̯̤̹͓̗̻̭ͅḐ̲̰͙͑̂̒̐́̊"),console.log(e,"/stat extended"),e}var i="[{display_name}]({link}) has {reputation} reputation, earned {reputation_change_day} rep today, asked {question_count} questions, gave {answer_count} answers, for a q:a ratio of {ratio}.\n",r="avg. rep/post: {avg_rep_post}, {gold} gold badges, {silver} silver badges and {bronze} bronze badges. ",a=/chat\.(\w+)/.exec(location)[1];bot.addCommand({name:"stat",fun:e,permissions:{del:"NONE"},description:"Gives useless stats on a user. `/stat usrid|usrname`",async:!0})}();var moo=function(){function e(e,t){function n(e,n){var i=n.length;return o+i>t&&(e+="\n",o=0),o+=i+1,e+n+" "}var o=0;return e.split(" ").reduce(n,"")}function t(e,t,n){for(n=n||" ";t>e.length;)e+=n;return e}var n={defaults:{e:"oo",T:" ",t:!1,W:40},cow:[""," L ^__^"," L (e)\\_______"," (__)\\ )\\/\\"," T ||----w |"," || ||"].join("\n"),moo:function(n,o){var i=this.defaults;return this.eyes=t(o.e||i.e,2).slice(0,2),this.tongue=t(o.T||i.T,2).slice(0,2),this.line=o.t?"O":"\\",this.thinking=o.t,this.message=e(n,o.W||i.W),this.makeBalloon()+this.makeCow()},makeCow:function(){return this.cow.replace(/e/g,this.eyes).replace(/T/g,this.tongue).replace(/L/g,this.line)},makeBalloon:function(){var e=this.message.trim().split("\n"),n=Math.max.apply(Math,e.map(function(e){return e.length})),o=Array(n+2),i=o.join("_"),r=o.join("-"),a=e.length,s=this.chooseBorders(a),c=e.map(function(e,o){var i;return i=0===o?s.slice(0,2):o===a-1?s.slice(2,4):s.slice(-2),i[0]+" "+t(e,n)+" "+i[1]});return c.unshift(" "+i),c.push(" "+r),c.join("\n")},chooseBorders:function(e){var t;return t=this.thinking?["(",")","(",")","(",")"]:1===e?["<",">"]:["/","\\","\\","/","|","|"]}};return function(){return n.moo.apply(n,arguments)}}();bot.listen(/cow(think|say)\s(?:([eT])=(.{0,2})\s)?(?:([eT])=(.{0,2})\s)?(.+)/,function(e){for(var t=e.matches.slice(2,-1),n={},o=0,i=t.length;i>o;o+=2)t[o]&&t[o+1]&&(n[t[o]]=t[o+1]);n.t="think"===e.matches[1];var r=moo(e.matches.slice(-1)[0],n);e.respond(e.codify(r))}),function(){function e(e,t){function n(t){function n(t){var n=decodeURIComponent(t.titleNoFormatting);return e.link(n,t.url)}if(bot.log(t,"/google response"),200!==t.responseStatus)return o("My Google-Fu is on vacation; status "+t.responseStatus),void 0;var i=t.responseData.results.slice(0,3);return bot.log(i,"/google results"),i.length?(o(i.map(n).join(" ; ")),void 0):(o("The Google contains no such knowledge"),void 0)}function o(n){bot.log(n,"/google final"),t&&t.call?t(n):e.reply(n)}IO.jsonp.google(""+e,n)}bot.addCommand({name:"google",fun:e,permissions:{del:"NONE"},description:"Search Google. `/google query`",async:!0})}(),function(){function e(e){var n=e.parse(),i=n.shift(),r=n.shift()||"js";if(r=r.toLowerCase(),console.log(i,r,"/beautify input"),0>["html","css","js"].indexOf(r))return o;var a={js:js_beautify,css:css_beautify,html:style_html},s=t(i,e);if(!s)return"404 Message "+i+" Not Found";var c=s.getElementsByClassName("content")[0].textContent;console.log(c,"/beautify beautifying"),e.respond(e.codify(a[r](c)))}function t(e,t){return/^\d+$/.test(e)?document.getElementById("message-"+e):(console.log(e,"/beautify fetch_message"),n(t.findUserid(e)))}function n(e){function t(e){return/\bmonologue\b/.test(e.className)}var n=[].filter.call(document.getElementsByClassName("user-"+e),t).pop();return n?[].pop.call(n.getElementsByClassName("message")):void 0}var o="Fetches and beautifies a message containing html, css or js. `/beautify msgid [lang=js]`";bot.addCommand({name:"beautify",fun:e,permission:{del:"NONE"},description:o})}(),"undefined"!=typeof exports&&(exports.js_beautify=js_beautify),"undefined"!=typeof exports&&(exports.css_beautify=css_beautify),function(){"use strict";var e=function(e){function t(t){e(t.word.toLowerCase().trim())}IO.jsonp({url:"http://sleepy-bastion-8674.herokuapp.com/",jsonpName:"callback",fun:t})},t={dude:[" +---+"," | |"," | 413"," | 2"," | 5 6","__+__"].join("\n"),parts:["","O","|","/","\\","/","\\"],word:"",revealed:"",guesses:[],guessNum:0,maxGuess:6,guessMade:!1,end:!0,msg:null,validGuessRegex:/^[\w\s]+$/,receiveMessage:function(e){if(this.msg=e,this.end)this.new();else if(e.content)return this.handleGuess(e)},"new":function(){var n=this;e(function(e){bot.log(e+" /hang random"),t.word=e,n.revealed=Array(e.length+1).join("-"),n.guesses=[],n.guessNum=0,n.guessMade=!0,n.register()})},handleGuess:function(e){var t=e.slice().toLowerCase();if(bot.log(t,"handleGuess"),!this.validGuessRegex.test(t))return"Only alphanumeric and whitespace characters allowed";if(this.guesses.indexOf(t)>-1)return t+" was already submitted";if(t.length>this.word.length)return e.codify(t)+" is longer than the phrase";var n=this.word.indexesOf(t);return n.forEach(function(e){this.uncoverPart(t,e)},this),n.length||this.guessNum++,this.guesses.push(t),this.guessMade=!0,bot.log(t,this.guessMade,"handleGuess handled"),this.loseCheck()?this.lose():this.winCheck()?this.win():void 0},uncoverPart:function(e,t){this.revealed=this.revealed.slice(0,t)+e+this.revealed.slice(t+e.length)},preparePrint:function(){var e=this,t=this.dude.replace(/\d/g,function(t){return t>e.guessNum?" ":e.parts[t]}),n=this.guesses.sort().join(", ")+"\n"+this.revealed,o=this.msg.codify(t+"\n"+n);bot.log(o,this.msg),this.msg.respond(o)},win:function(){return this.unregister(),"Correct! The phrase is "+this.word+"."},lose:function(){return this.unregister(),"You people suck. The phrase was "+this.word},winCheck:function(){return this.word===this.revealed},loseCheck:function(){return this.guessNum>=this.maxGuess},register:function(){this.unregister(),IO.register("beforeoutput",this.buildOutput,this),this.end=!1},unregister:function(){IO.unregister("beforeoutput",this.buildOutput),this.end=!0},buildOutput:function(){this.guessMade&&(this.preparePrint(),this.guessMade=!1)}};bot.addCommand({name:"hang",fun:t.receiveMessage,thisArg:t})}(),function(){"use strict";function e(e){bot.log(e,"/learn input");var n=e.parse(),i={name:n[0],output:n[1],input:n[2]||".*"},a=o(i);return a?a:(i.name=i.name.toLowerCase(),i.input=RegExp(i.input),bot.log(i,"/learn parsed"),t(i),r(i),"Command "+i.name+" learned")}function t(e){var t=bot.Command({name:e.name,description:"User-taught command: "+e.output,fun:n(e),permissions:{use:"ALL",del:"ALL"}});t.del=function(t){return function(){a(e.name),t()}}(t.del),bot.log(t,"/learn addCustomCommand"),bot.addCommand(t)}function n(e){return bot.log(e,"/learn makeCustomCommand"),function(t){bot.log(t,e.name+" input");var n=bot.Message(e.output,t.get());return s.exec(n,e.input.exec(t))}}function o(e){var t,n=Object.keys(e).some(function(t){return!e[t]});return n?t="Illegal /learn object":/^[\w\-]+$/.test(e.name)?bot.commandExists(e.name.toLowerCase())&&(t="Command "+e.name+" already exists"):t="Invalid command name",t}function i(){function e(e){var n=JSON.parse(c[e]);n.input=RegExp(n.input),bot.log(n,"/learn loadCommands"),t(n)}Object.keys(c).forEach(e)}function r(e){c[e.name]=JSON.stringify({name:e.name,input:e.input.source,output:e.output}),localStorage.bot_learn=JSON.stringify(c)}function a(e){delete c[e],localStorage.bot_learn=JSON.stringify(c)}var s=bot.getCommand("parse"),c=JSON.parse(localStorage.bot_learn||"{}");i(),bot.addCommand({name:"learn",fun:e,privileges:{del:"NONE"},description:"Teaches the bot a command. `/learn cmdName cmdOutputMacro [cmdInputRegex]`"})}(); \ No newline at end of file diff --git a/source/plugins/learn.js b/source/plugins/learn.js index c90e684..64bcdc9 100644 --- a/source/plugins/learn.js +++ b/source/plugins/learn.js @@ -1,92 +1,122 @@ -(function () { -var parse; - -function learn ( args ) { - bot.log( args, '/learn input' ); - - var commandParts = args.parse(); - var command = { - name : commandParts[ 0 ], - output : commandParts[ 1 ], - input : commandParts[ 2 ] || '.*' - }; - - //a truthy value, unintuitively, means it isn't valid, because it returns - // an error message - var errorMessage = checkCommand( command ); - if ( errorMessage ) { - return errorMessage; - } - command.name = command.name.toLowerCase(); - command.input = new RegExp( command.input ); - - parse = bot.getCommand( 'parse' ); - if ( parse.error ) { - console.error( '/parse not loaded, cannot /learn' ); - return 'Failed; /parse not loaded'; - } - console.log( parse ); - - bot.log( command, '/learn parsed' ); - - addCustomCommand( command ); - return 'Command ' + command.name + ' learned'; -}; - -function addCustomCommand ( command ) { - bot.addCommand({ - name : command.name, - description : 'User-taught command: ' + command.output, - - fun : makeCustomCommand( command ), - permissions : { - use : 'ALL', - del : 'ALL' - } - }); -} -function makeCustomCommand ( command ) { - - return function ( args ) { - bot.log( args, command.name + ' input' ); - - var cmdArgs = bot.Message( command.output, args.get() ); - return parse.exec( cmdArgs, command.input.exec(args) ); - }; -} - -//return a truthy value (an error message) if it's invalid, falsy if it's -// valid -function checkCommand ( cmd ) { - var somethingUndefined = Object.keys( cmd ).some(function ( key ) { - return !cmd[ key ]; - }), - error; - - if ( somethingUndefined ) { - error = 'Illegal /learn object'; - } - - if ( !/^[\w\-]+$/.test(cmd.name) ) { - error = 'Invalid command name'; - } - - if ( bot.commandExists(cmd.name.toLowerCase()) ) { - error = 'Command ' + cmd.name + ' already exists'; - } - - return error; -} - - -bot.addCommand({ - name : 'learn', - fun : learn, - privileges : { - del : 'NONE', - }, - - description : 'Teaches the bot a command. ' + - '`/learn cmdName cmdOutputMacro [cmdInputRegex]`' -}); -}()); +(function () { +"use strict"; +var parse = bot.getCommand( 'parse' ); +var storage = JSON.parse( localStorage.bot_learn || '{}' ); +loadCommands(); + +function learn ( args ) { + bot.log( args, '/learn input' ); + + var commandParts = args.parse(); + var command = { + name : commandParts[ 0 ], + output : commandParts[ 1 ], + input : commandParts[ 2 ] || '.*' + }; + + //a truthy value, unintuitively, means it isn't valid, because it returns + // an error message + var errorMessage = checkCommand( command ); + if ( errorMessage ) { + return errorMessage; + } + command.name = command.name.toLowerCase(); + command.input = new RegExp( command.input ); + + bot.log( command, '/learn parsed' ); + + addCustomCommand( command ); + saveCommand( command ); + return 'Command ' + command.name + ' learned'; +} + +function addCustomCommand ( command ) { + var cmd = bot.Command({ + name : command.name, + description : 'User-taught command: ' + command.output, + + fun : makeCustomCommand( command ), + permissions : { + use : 'ALL', + del : 'ALL' + } + }); + + cmd.del = (function ( old ) { + return function () { + deleteCommand( command.name ); + old(); + }; + }( cmd.del )); + + bot.log( cmd, '/learn addCustomCommand' ); + bot.addCommand( cmd ); +} +function makeCustomCommand ( command ) { + bot.log( command, '/learn makeCustomCommand' ); + return function ( args ) { + bot.log( args, command.name + ' input' ); + + var cmdArgs = bot.Message( command.output, args.get() ); + return parse.exec( cmdArgs, command.input.exec(args) ); + }; +} + +//return a truthy value (an error message) if it's invalid, falsy if it's +// valid +function checkCommand ( cmd ) { + var somethingUndefined = Object.keys( cmd ).some(function ( key ) { + return !cmd[ key ]; + }), + error; + + if ( somethingUndefined ) { + error = 'Illegal /learn object'; + } + + else if ( !/^[\w\-]+$/.test(cmd.name) ) { + error = 'Invalid command name'; + } + + else if ( bot.commandExists(cmd.name.toLowerCase()) ) { + error = 'Command ' + cmd.name + ' already exists'; + } + + return error; +} + +function loadCommands () { + Object.keys( storage ).forEach( teach ); + + function teach ( key ) { + var cmd = JSON.parse( storage[key] ); + cmd.input = new RegExp( cmd.input ); + + bot.log( cmd, '/learn loadCommands' ); + addCustomCommand( cmd ); + } +} +function saveCommand ( command ) { + storage[ command.name ] = JSON.stringify({ + name : command.name, + input : command.input.source, + output : command.output + }); + localStorage.bot_learn = JSON.stringify( storage ); +} +function deleteCommand ( name ) { + delete storage[ name ]; + localStorage.bot_learn = JSON.stringify( storage ); +} + +bot.addCommand({ + name : 'learn', + fun : learn, + privileges : { + del : 'NONE' + }, + + description : 'Teaches the bot a command. ' + + '`/learn cmdName cmdOutputMacro [cmdInputRegex]`' +}); +}());