Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

working on build scriipt

  • Loading branch information...
commit 7e0dc7c7cc80242eb22fd67b8c788c9782d75b75 1 parent 4e6a72c
@josh3ennett authored
Showing with 12,755 additions and 388 deletions.
  1. +27 −11 Cakefile
  2. +7 −1 docs/docco.css
  3. +0 −41 excelFormulaUtilities-0.9.3.min.js
  4. +444 −335 excelFormulaUtilities-0.9.3.js → excelFormulaUtilities-0.9.4.js
  5. +25 −0 excelFormulaUtilities-0.9.4.min.js
  6. +1 −0  node_modules/.bin/cake
  7. +1 −0  node_modules/.bin/coffee
  8. +1 −0  node_modules/.bin/docco
  9. +1 −0  node_modules/closure-compiler/.npmignore
  10. +2 −0  node_modules/closure-compiler/Cakefile
  11. 0  node_modules/closure-compiler/README.md
  12. +49 −0 node_modules/closure-compiler/lib/index.js
  13. BIN  node_modules/closure-compiler/lib/vendor/compiler.jar
  14. +31 −0 node_modules/closure-compiler/package.json
  15. +69 −0 node_modules/closure-compiler/src/index.coffee
  16. +11 −0 node_modules/coffee-script/.npmignore
  17. +1 −0  node_modules/coffee-script/CNAME
  18. +22 −0 node_modules/coffee-script/LICENSE
  19. +51 −0 node_modules/coffee-script/README
  20. +78 −0 node_modules/coffee-script/Rakefile
  21. +7 −0 node_modules/coffee-script/bin/cake
  22. +7 −0 node_modules/coffee-script/bin/coffee
  23. +44 −0 node_modules/coffee-script/extras/jsl.conf
  24. +92 −0 node_modules/coffee-script/lib/coffee-script/browser.js
  25. +111 −0 node_modules/coffee-script/lib/coffee-script/cake.js
  26. +167 −0 node_modules/coffee-script/lib/coffee-script/coffee-script.js
  27. +500 −0 node_modules/coffee-script/lib/coffee-script/command.js
  28. +606 −0 node_modules/coffee-script/lib/coffee-script/grammar.js
  29. +77 −0 node_modules/coffee-script/lib/coffee-script/helpers.js
  30. +11 −0 node_modules/coffee-script/lib/coffee-script/index.js
  31. +788 −0 node_modules/coffee-script/lib/coffee-script/lexer.js
  32. +2,986 −0 node_modules/coffee-script/lib/coffee-script/nodes.js
  33. +138 −0 node_modules/coffee-script/lib/coffee-script/optparse.js
  34. +683 −0 node_modules/coffee-script/lib/coffee-script/parser.js
  35. +261 −0 node_modules/coffee-script/lib/coffee-script/repl.js
  36. +349 −0 node_modules/coffee-script/lib/coffee-script/rewriter.js
  37. +146 −0 node_modules/coffee-script/lib/coffee-script/scope.js
  38. +51 −0 node_modules/coffee-script/package.json
  39. +5 −0 node_modules/docco/.npmignore
  40. +107 −0 node_modules/docco/Cakefile
  41. +25 −0 node_modules/docco/README
  42. +6 −0 node_modules/docco/bin/docco
  43. +238 −0 node_modules/docco/index.html
  44. +265 −0 node_modules/docco/lib/docco.js
  45. +4 −0 node_modules/docco/node_modules/commander/.npmignore
  46. +4 −0 node_modules/docco/node_modules/commander/.travis.yml
  47. +135 −0 node_modules/docco/node_modules/commander/History.md
  48. +7 −0 node_modules/docco/node_modules/commander/Makefile
  49. +262 −0 node_modules/docco/node_modules/commander/Readme.md
  50. +2 −0  node_modules/docco/node_modules/commander/index.js
  51. +1,053 −0 node_modules/docco/node_modules/commander/lib/commander.js
  52. +101 −0 node_modules/docco/node_modules/commander/node_modules/keypress/README.md
  53. +346 −0 node_modules/docco/node_modules/commander/node_modules/keypress/index.js
  54. +39 −0 node_modules/docco/node_modules/commander/node_modules/keypress/package.json
  55. +28 −0 node_modules/docco/node_modules/commander/node_modules/keypress/test.js
  56. +43 −0 node_modules/docco/node_modules/commander/package.json
  57. +44 −0 node_modules/docco/package.json
  58. +26 −0 node_modules/docco/resources/README.md
  59. +192 −0 node_modules/docco/resources/docco.css
  60. +58 −0 node_modules/docco/resources/docco.jst
  61. +31 −0 node_modules/docco/resources/languages.json
  62. +64 −0 node_modules/docco/resources/pagelet.css
  63. +28 −0 node_modules/docco/resources/pagelet.jst
  64. +312 −0 node_modules/docco/src/docco.coffee
  65. +13 −0 node_modules/docco/test/comments/README.md
  66. +8 −0 node_modules/docco/test/comments/c.c
  67. +11 −0 node_modules/docco/test/comments/c.h
  68. +18 −0 node_modules/docco/test/comments/coffee-script.coffee
  69. +11 −0 node_modules/docco/test/comments/comments.jst
  70. +8 −0 node_modules/docco/test/comments/javascript.js
  71. +11 −0 node_modules/docco/test/comments/python.py
  72. +8 −0 node_modules/docco/test/comments/ruby.rb
  73. +13 −0 node_modules/docco/test/comments/tex.tex
  74. +86 −0 node_modules/docco/test/tests.coffee
  75. +1,298 −0 node_modules/docco/vendor/showdown.js
View
38 Cakefile
@@ -16,19 +16,35 @@ LICENSE = fs.readFileSync './license.include', 'utf8'
#Requires:
# (mac, linux, cygwin(windows), minGW(windows)), node, npm, coffee-script, docco, and the google closure compiler.
task 'build', 'Building', ->
- exec "java -jar #{COMPILER_PATH} --compilation_level SIMPLE_OPTIMIZATIONS --js ./src/core.js --js ./src/ExcelFormulaUtilities.js --js_output_file ./excelFormulaUtilities-#{VERSION}.min.js" , (err, stdout, stderr) ->
- throw err if err
- console.log stdout + stderr
- #after it's been compiled stick the license at the top
- exec "sed -i -e '1r ./license.include' -e '1{h; D;}' -e '2{p}' ./excelFormulaUtilities-#{VERSION}.min.js", (err, stdout, stderr) ->
- throw err if err
- console.log stdout + stderr
- exec 'node_modules/.bin/docco ./src/*.js', (err, stdout, stderr) ->
- throw err if err
- console.log stdout + stderr
- exec "cat ./src/core.js ./src/ExcelFormulaUtilities.js > ./excelFormulaUtilities-#{VERSION}.js" , (err, stdout, stderr) ->
+ # Join all the files together
+ CORE_PATH = './src/core.js'
+ EXCEL_FORMULA_UTILITIES_PATH = './src/ExcelFormulaUtilities.js'
+ LICENSE_PATH = './license.include'
+ DEV_BUILD_PATH = "./excelFormulaUtilities-#{VERSION}.js"
+ PROD_BUILD_PATH = "./excelFormulaUtilities-#{VERSION}.min.js"
+
+ fileLicense = fs.readFileSync(LICENSE_PATH, 'utf8').toString().replace('#{VERSION}', "#{VERSION}").replace('#{YEAR}', (new Date()).getFullYear())
+ jsFileCore = fs.readFileSync CORE_PATH, 'utf8'
+ jsFileExcelFormulaUtilities = fs.readFileSync EXCEL_FORMULA_UTILITIES_PATH, 'utf8'
+
+ jsCode = jsFileCore + "\n" + jsFileExcelFormulaUtilities
+
+ # Write the js file
+ fs.writeFile DEV_BUILD_PATH, jsCode, 'utf8', (err)->
+ console.log "Saved script to #{DEV_BUILD_PATH}"
+
+ # Minify
+ exec "java -jar #{COMPILER_PATH} --compilation_level SIMPLE_OPTIMIZATIONS --js ./src/core.js --js ./src/ExcelFormulaUtilities.js --js_output_file ./excelFormulaUtilities-#{VERSION}.min.js" , (err, stdout, stderr) ->
throw err if err
+ cnosole.log stdout + stderr
+
+
+
+ exec 'node_modules/.bin/docco ./src/*.js', (err, stdout, stderr) ->
+ throw err if err
console.log stdout + stderr
+
+
#Build for cloud9IDE
#-------------------
View
8 docs/docco.css
@@ -21,6 +21,12 @@ h1, h2, h3, h4, h5, h6 {
h1 {
margin-top: 40px;
}
+hr {
+ border: 0 none;
+ border-top: 1px solid #e5e5ee;
+ height: 1px;
+ margin: 20px 0;
+}
#container {
position: relative;
}
@@ -115,7 +121,7 @@ table td {
}
pre, tt, code {
font-size: 12px; line-height: 18px;
- font-family: Monaco, Consolas, "Lucida Console", monospace;
+ font-family: Menlo, Monaco, Consolas, "Lucida Console", monospace;
margin: 0; padding: 0;
}
View
41 excelFormulaUtilities-0.9.3.min.js
@@ -1,41 +0,0 @@
-/*
-* excelFormulaUtilitiesJS 0.9.3
-* https://github.com/joshatjben/excelFormulaUtilitiesJS/
-*
-* Copyright 2011, Josh Bennett
-* licensed under the MIT license.
-* https://github.com/joshatjben/excelFormulaUtilitiesJS/blob/master/LICENSE.txt
-*
-* Some functionality based off of the jQuery(1.6.2) core lib
-* Copyright 2011, John Resig
-* Dual licensed under the MIT or GPL Version 2 licenses.
-* http://jquery.org/license
-*
-* Based on Ewbi's Go Calc Prototype Excel Formula Parser. [http://ewbi.blogs.com/develops/2004/12/excel_formula_p.html]
-*/
-(function(){window.excelFormulaUtilities=window.excelFormulaUtilities||{};var n=window.excelFormulaUtilities.core={};window.excelFormulaUtilities.string=window.excelFormulaUtilities.string||{};window.excelFormulaUtilities.string.formatStr=function(k){for(var i=k,m=1;m<arguments.length;m++)i=i.replace(RegExp("\\{{1}"+(m-1).toString()+"{1}\\}{1}","g"),arguments[m]);return i};window.excelFormulaUtilities.string.trim=function(k){return k.replace(/^\s|\s$/,"")};window.excelFormulaUtilities.string.trim=
-function(k){return k.replace(/^(?:\s|&nbsp;|<\s*br\s*\/*\s*>)*|(?:\s|&nbsp;|<\s*br\s*\/*\s*>)*$/,"")};var v=n.isFunction=function(k){return typeof k==="function"},w=n.isArray=function(k){return typeof k==="object"&&k.length},x=n.isWindow=function(){return obj&&typeof obj==="object"&&"setInterval"in obj},o=n.isPlainObject=function(k){if(!k||typeof k!=="object"||k.nodeType||x(k))return!1;if(k.constructor&&!hasOwnProperty.call(k,"constructor")&&!hasOwnProperty.call(k.constructor.prototype,"isPrototypeOf"))return!1;
-for(var i in k);return i===void 0||hasOwnProperty.call(k,i)};n.extend=function(){var k,i,m,h,s,j=arguments[0]||{},l=1,r=arguments.length,t=!1;typeof j==="boolean"&&(t=j,j=arguments[1]||{},l=2);typeof j!=="object"&&!v(j)&&(j={});r===l&&(j=this,--l);for(;l<r;l++)if((k=arguments[l])!=null)for(i in k)m=j[i],h=k[i],j!==h&&(t&&h&&(o(h)||(s=w(h)))?(s?(s=!1,m=m&&w(m)?m:[]):m=m&&o(m)?m:{},j[i]=n.extend(t,m,h)):h!==void 0&&(j[i]=h));return j}})();
-(function(){function n(f,b,c){this.value=f;this.type=b;this.subtype=c}function v(){this.items=[];this.add=function(f,b,c){c||(c="");f=new n(f,b,c);this.addRef(f);return f};this.addRef=function(f){this.items.push(f)};this.index=-1;this.reset=function(){this.index=-1};this.BOF=function(){return this.index<=0};this.EOF=function(){return this.index>=this.items.length-1};this.moveNext=function(){if(this.EOF())return!1;this.index+=1;return!0};this.current=function(){return this.index===-1?null:this.items[this.index]};
-this.next=function(){return this.EOF()?null:this.items[this.index+1]};this.previous=function(){return this.index<1?null:this.items[this.index-1]}}function w(){this.items=[];this.push=function(f){this.items.push(f)};this.pop=function(f){var b=this.items.pop();return new n(f||"",b.type,p)};this.token=function(){return this.items.length>0?this.items[this.items.length-1]:null};this.value=function(){return this.token()?this.token().value.toString():""};this.type=function(){return this.token()?this.token().type.toString():
-""};this.subtype=function(){return this.token()?this.token().subtype.toString():""}}function x(f){for(var b=new v,c=new w,g=0,e=function(){return f.substr(g,1)},a="",d=!1,h=!1,k=!1,i=!1,m=/^[1-9]{1}(\.[0-9]+)?E{1}$/;f.length>0;)if(f.substr(0,1)===" ")f=f.substr(1);else{f.substr(0,1)==="="&&(f=f.substr(1));break}for(;!(g>=f.length);)if(d)e()==='"'?f.substr(g+1,1)==='"'?(a+='"',g+=1):(d=!1,b.add(a,j,F),a=""):a+=e(),g+=1;else if(h)e()==="'"?f.substr(g+1,1)==="'"?(a+="'",g+=1):h=!1:a+=e(),g+=1;else if(k)e()===
-"]"&&(k=!1),a+=e(),g+=1;else if(i)a+=e(),g+=1,",#NULL!,#DIV/0!,#VALUE!,#REF!,#NAME?,#NUM!,#N/A,".indexOf(","+a+",")!==-1&&(i=!1,b.add(a,j,G),a="");else if("+-".indexOf(e())!==-1&&a.length>1&&a.match(m))a+=e(),g+=1;else if(e()==='"')a.length>0&&(b.add(a,y),a=""),d=!0,g+=1;else if(e()==="'")a.length>0&&(b.add(a,y),a=""),h=!0,g+=1;else if(e()==="[")k=!0,a+=e(),g+=1;else if(e()==="#")a.length>0&&(b.add(a,y),a=""),i=!0,a+=e(),g+=1;else if(e()==="{")a.length>0&&(b.add(a,y),a=""),c.push(b.add("ARRAY",l,
-q)),c.push(b.add("ARRAYROW",l,q)),g+=1;else if(e()===";")a.length>0&&(b.add(a,j),a=""),b.addRef(c.pop()),b.add(",",t),c.push(b.add("ARRAYROW",l,q)),g+=1;else if(e()==="}")a.length>0&&(b.add(a,j),a=""),b.addRef(c.pop("ARRAYROWSTOP")),b.addRef(c.pop("ARRAYSTOP")),g+=1;else if(e()===" "){a.length>0&&(b.add(a,j),a="");b.add("",C);for(g+=1;e()===" "&&!(g>=f.length);)g+=1}else",>=,<=,<>,".indexOf(","+f.substr(g,2)+",")!==-1?(a.length>0&&(b.add(a,j),a=""),b.add(f.substr(g,2),u,z),g+=2):("+-*/^&=><".indexOf(e())!==
--1?(a.length>0&&(b.add(a,j),a=""),b.add(e(),u)):"%".indexOf(e())!==-1?(a.length>0&&(b.add(a,j),a=""),b.add(e(),A)):e()==="("?a.length>0?(c.push(b.add(a,l,q)),a=""):c.push(b.add("",r,q)):e()===","?(a.length>0&&(b.add(a,j),a=""),c.type()!==l?b.add(e(),u,H):b.add(e(),t)):e()===")"?(a.length>0&&(b.add(a,j),a=""),b.addRef(c.pop())):a+=e(),g+=1);a.length>0&&b.add(a,j);for(c=new v;b.moveNext();)a=b.current(),a.type.toString()===C?(e=(e=(e=b.BOF()||b.EOF())&&(b.previous().type.toString()===l&&b.previous().subtype.toString()===
-p||b.previous().type.toString()===r&&b.previous().subtype.toString()===p||b.previous().type.toString()===j))&&(b.next().type.toString()===l&&b.next().subtype.toString()===q||b.next().type.toString()===r&&b.next().subtype.toString()===q||b.next().type.toString()===j))&&c.add(a.value.toString(),u,I):c.addRef(a);for(;c.moveNext();)if(a=c.current(),a.type.toString()===u&&a.value.toString()==="-")c.BOF()?a.type=D.toString():c.previous().type.toString()===l&&c.previous().subtype.toString()===p||c.previous().type.toString()===
-r&&c.previous().subtype.toString()===p||c.previous().type.toString()===A||c.previous().type.toString()===j?a.subtype=B.toString():a.type=D.toString();else if(a.type.toString()===u&&a.value.toString()==="+")c.BOF()?a.type=s.toString():c.previous().type.toString()===l&&c.previous().subtype.toString()===p||c.previous().type.toString()===r&&c.previous().subtype.toString()===p||c.previous().type.toString()===A||c.previous().type.toString()===j?a.subtype=B.toString():a.type=s.toString();else if(a.type.toString()===
-u&&a.subtype.length===0)a.subtype="<>=".indexOf(a.value.substr(0,1))!==-1?z.toString():a.value.toString()==="&"?J.toString():B.toString();else if(a.type.toString()===j&&a.subtype.length===0)a.subtype=isNaN(parseFloat(a.value))?a.value.toString()==="TRUE"||a.value.toString()==="FALSE"?z.toString():K.toString():L.toString();else if(a.type.toString()===l&&a.value.substr(0,1)==="@")a.value=a.value.substr(1).toString();c.reset();for(b=new v;c.moveNext();)c.current().type.toString()!==s&&b.addRef(c.current());
-b.reset();return b}var o=window.excelFormulaUtilities=window.excelFormulaUtilities||{},k=window.excelFormulaUtilities.core,i=window.excelFormulaUtilities.string.formatStr,m=window.excelFormulaUtilities.string.trim,h={},s=h.TOK_TYPE_NOOP="noop",j=h.TOK_TYPE_OPERAND="operand",l=h.TOK_TYPE_FUNCTION="function",r=h.TOK_TYPE_SUBEXPR="subexpression",t=h.TOK_TYPE_ARGUMENT="argument",D=h.TOK_TYPE_OP_PRE="operator-prefix",u=h.TOK_TYPE_OP_IN="operator-infix",A=h.TOK_TYPE_OP_POST="operator-postfix",C=h.TOK_TYPE_WSPACE=
-"white-space",y=h.TOK_TYPE_UNKNOWN="unknown",q=h.TOK_SUBTYPE_START="start",p=h.TOK_SUBTYPE_STOP="stop",F=h.TOK_SUBTYPE_TEXT="text",L=h.TOK_SUBTYPE_NUMBER="number",z=h.TOK_SUBTYPE_LOGICAL="logical",G=h.TOK_SUBTYPE_ERROR="error",K=h.TOK_SUBTYPE_RANGE="range",B=h.TOK_SUBTYPE_MATH="math",J=h.TOK_SUBTYPE_CONCAT="concatenate",I=h.TOK_SUBTYPE_INTERSECT="intersect",H=h.TOK_SUBTYPE_UNION="union";o.parseFormula=function(f,b){var c=0,g=function(){for(var a="|",b=0;b<c;b+=1)a+="&nbsp;&nbsp;&nbsp;|";return a},
-e=document.getElementById(f),a=x(e.value),d="";d+="<table cellspacing='0' style='border-top: 1px #cecece solid; margin-top: 5px; margin-bottom: 5px'>";d+="<tr>";d+="<td class='token' style='font-weight: bold; width: 50px'>index</td>";d+="<td class='token' style='font-weight: bold; width: 125px'>type</td>";d+="<td class='token' style='font-weight: bold; width: 125px'>subtype</td>";d+="<td class='token' style='font-weight: bold; width: 150px'>token</td>";for(d+="<td class='token' style='font-weight: bold; width: 300px'>token tree</td></tr>";a.moveNext();){var h=
-a.current();h.subtype===p&&(c-=c>0?1:0);d+="<tr>";d+="<td class='token'>"+(a.index+1)+"</td>";d+="<td class='token'>"+h.type+"</td>";d+="<td class='token'>"+(h.subtype.length===0?"&nbsp;":h.subtype.toString())+"</td>";d+="<td class='token'>"+(h.value.length===0?"&nbsp;":h.value).split(" ").join("&nbsp;")+"</td>";d+="<td class='token'>"+g()+(h.value.length===0?"&nbsp;":h.value).split(" ").join("&nbsp;")+"</td>";d+="</tr>";h.subtype===q&&(c+=1)}d+="</table>";document.getElementById(b).innerHTML=d;e.select();
-e.focus()};var M=function(f,b,c,g,e){var a=function(a){return a.replace(/\{\{token\}\}/gi,"{0}").replace(/\{\{autoindent\}\}/gi,"{1}").replace(/\{\{autolinebreak\}\}/gi,"{2}")},d="",d=f.subtype==="text"||f.type==="text"?f.value.toString():(f.value.length===0?" ":f.value.toString()).split(" ").join("").toString();if(typeof e==="function"&&(e=e(d,f,c,g),d=e.tokenString,!e.useTemplate))return d;switch(f.type){case "function":switch(f.value){case "ARRAY":d=i(a(b.tmplFunctionStartArray),d,c,g);break;case "ARRAYROW":d=
-i(a(b.tmplFunctionStartArrayRow),d,c,g);break;default:d=f.subtype.toString()==="start"?i(a(b.tmplFunctionStart),d,c,g):i(a(b.tmplFunctionStop),d,c,g)}break;case "operand":switch(f.subtype.toString()){case "error":d=i(a(b.tmplOperandError),d,c,g);break;case "range":d=i(a(b.tmplOperandRange),d,c,g);break;case "number":d=i(a(b.tmplOperandNumber),d,c,g);break;case "text":d=i(a(b.tmplOperandText),d,c,g);break;case "argument":d=i(a(b.tmplArgument),d,c,g)}break;case "operator-infix":case "logical":d=i(a(b.tmplOperandLogical),
-d,c,g);break;case "argument":d=i(a(b.tmplArgument),d,c,g);break;case "subexpression":d=f.subtype.toString()==="start"?i(a(b.tmplSubexpressionStart),d,c,g):i(a(b.tmplSubexpressionStop),d,c,g)}return d},E=o.formatFormula=function(f,b){for(var c={tmplFunctionStart:"{{autoindent}}{{token}}\n{{autoindent}}(\n",tmplFunctionStop:"\n{{autoindent}}{{token}})",tmplOperandError:"{{token}}",tmplOperandRange:"{{autoindent}}{{token}}",tmplOperandLogical:" {{token}}{{autolinebreak}}",tmplOperandNumber:"{{autoindent}}{{token}}",
-tmplOperandText:'{{autoindent}}"{{token}}"',tmplArgument:"{{token}}\n",tmplFunctionStartArray:"",tmplFunctionStartArrayRow:"{",tmplFunctionStopArrayRow:"}",tmplFunctionStopArray:"",tmplSubexpressionStart:"{{autoindent}}(",tmplSubexpressionStop:" )",tmplIndentTab:"\t",tmplIndentSpace:" ",autoLineBreak:"TOK_TYPE_FUNCTION | TOK_TYPE_ARGUMENT | TOK_SUBTYPE_LOGICAL | TOK_TYPE_OP_IN ",newLine:"\n",trim:!0,customTokenRender:null},b=b?k.extend(!0,c,b):c,g=0,c=function(){for(var a="",c=0;c<g;c+=1)a+=b.tmplIndentTab;
-return a},e=x(f),a="",d=b.autoLineBreak.replace(/\s/gi,"").split("|"),i=!0,j=function(a){for(var b=0;b<d.length;b+=1)if(a!==null&&typeof a!=="undefined"&&(h[d[b]]===a.type.toString()||h[d[b]]===a.subtype.toString()))return!0;return!1};e.moveNext();){var l=e.current(),n=e.next();l.subtype.toString()===p&&(g-=g>0?1:0);var o=RegExp(b.newLine+"$",""),n=j(n),i=i?c():b.tmplIndentSpace;a+=M(l,b,i,n?b.newLine:"",b.customTokenRender);l.subtype.toString()===q&&(g+=1);i=n||o.test(a)}return b.trim?m(a):a};o.formatFormulaHTML=
-function(f){return E(f,{tmplFunctionStart:'{{autoindent}}<span class="function">{{token}}</span><br />{{autoindent}}<span class="function_start">(</span><br />',tmplFunctionStop:'<br />{{autoindent}}{{token}}<span class="function_stop">)</span>',tmplOperandError:"{{token}}",tmplOperandRange:"{{autoindent}}{{token}}",tmplOperandLogical:" {{token}}{{autolinebreak}}",tmplOperandNumber:"{{autoindent}}{{token}}",tmplOperandText:'{{autoindent}}<span class="quote_mark">"</span><span class="text">{{token}}</span><span class="quote_mark">"</span>',
-tmplArgument:"{{token}}<br />",tmplFunctionStartArray:"",tmplFunctionStartArrayRow:"{",tmplFunctionStopArrayRow:"}",tmplFunctionStopArray:"",tmplSubexpressionStart:"{{autoindent}}(",tmplSubexpressionStop:" )",tmplIndentTab:'<span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span>',tmplIndentSpace:"&nbsp;",newLine:"<br />",autoLineBreak:"TOK_TYPE_FUNCTION | TOK_TYPE_ARGUMENT | TOK_SUBTYPE_LOGICAL | TOK_TYPE_OP_IN ",trim:!0,customTokenRender:null})};var N=o.formula2CSharp=function(f){var b=[];return E(f,
-{tmplFunctionStart:"{{token}}(",tmplFunctionStop:"{{token}})",tmplOperandError:"{{token}}",tmplOperandRange:"{{token}}",tmplOperandLogical:"{{token}}",tmplOperandNumber:"{{token}}",tmplOperandText:'"{{token}}"',tmplArgument:"{{token}}",tmplFunctionStartArray:"",tmplFunctionStartArrayRow:"{",tmplFunctionStopArrayRow:"}",tmplFunctionStopArray:"",tmplSubexpressionStart:"(",tmplSubexpressionStop:")",tmplIndentTab:"\t",tmplIndentSpace:" ",autoLineBreak:"TOK_SUBTYPE_STOP | TOK_SUBTYPE_START | TOK_TYPE_ARGUMENT",
-trim:!0,customTokenRender:function(c,g){var e="",a={"=":"==","<>":"!=",MIN:"Math.Min",MAX:"Math.Max",ABS:"Math.ABS",SUM:"",IF:"","&":"+"},d=b[b.length-1],f=!1;switch(g.type.toString()){case l:switch(g.subtype){case q:b.push({name:c,argumentNumber:0});e=typeof a[c]==="string"?a[c]:c;f=!0;break;case p:f=!0;switch(d.name.toLowerCase()){case "if":e=")";f=!1;break;default:e=typeof a[c]==="string"?a[c]:c}b.pop()}break;case t:switch(d.name.toLowerCase()){case "if":switch(d.argumentNumber){case 0:e="?";break;
-case 1:e=":"}break;case "sum":e="+";break;default:e=typeof a[c]==="string"?a[c]:c,f=!0}d.argumentNumber+=1;break;default:e=typeof a[c]==="string"?a[c]:c,f=!0}return{tokenString:e,useTemplate:f}}})};o.formula2JavaScript=function(f){return N(f)}})();
View
779 excelFormulaUtilities-0.9.3.js → excelFormulaUtilities-0.9.4.js
@@ -16,7 +16,9 @@
(function () {
-
+ if (typeof window === 'undefined') {
+ window = root;
+ }
var excelFormulaUtilities = window.excelFormulaUtilities = window.excelFormulaUtilities || {};
var core = window.excelFormulaUtilities.core = {};
window.excelFormulaUtilities.string = window.excelFormulaUtilities.string || {};
@@ -170,7 +172,6 @@
}());
-
/*
* excelFormulaUtilitiesJS
* https://github.com/joshatjben/excelFormulaUtilitiesJS/
@@ -185,10 +186,13 @@
* http://jquery.org/license
*
* Based on Ewbi's Go Calc Prototype Excel Formula Parser. [http://ewbi.blogs.com/develops/2004/12/excel_formula_p.html]
- */
-(function () {
+ */ (function () {
+ if (typeof window === 'undefined') {
+ window = root;
+ }
+
var excelFormulaUtilities = window.excelFormulaUtilities = window.excelFormulaUtilities || {},
- core = window.excelFormulaUtilities.core,
+ core = window.excelFormulaUtilities.core,
formatStr = window.excelFormulaUtilities.string.formatStr,
trim = window.excelFormulaUtilities.string.trim,
@@ -618,9 +622,9 @@
//if ((tokens.BOF()) || (tokens.EOF())) {}
doAddToken = doAddToken && (((tokens.previous().type.toString() === TOK_TYPE_FUNCTION) && (tokens.previous().subtype.toString() === TOK_SUBTYPE_STOP)) || ((tokens.previous().type.toString() === TOK_TYPE_SUBEXPR) && (tokens.previous().subtype.toString() === TOK_SUBTYPE_STOP)) || (tokens.previous().type.toString() === TOK_TYPE_OPERAND));
//else if (!(
- // ((tokens.previous().type === TOK_TYPE_FUNCTION) && (tokens.previous().subtype == TOK_SUBTYPE_STOP))
- // || ((tokens.previous().type == TOK_TYPE_SUBEXPR) && (tokens.previous().subtype == TOK_SUBTYPE_STOP))
- // || (tokens.previous().type == TOK_TYPE_OPERAND)))
+ // ((tokens.previous().type === TOK_TYPE_FUNCTION) && (tokens.previous().subtype == TOK_SUBTYPE_STOP))
+ // || ((tokens.previous().type == TOK_TYPE_SUBEXPR) && (tokens.previous().subtype == TOK_SUBTYPE_STOP))
+ // || (tokens.previous().type == TOK_TYPE_OPERAND)))
// {}
doAddToken = doAddToken && (((tokens.next().type.toString() === TOK_TYPE_FUNCTION) && (tokens.next().subtype.toString() === TOK_SUBTYPE_START)) || ((tokens.next().type.toString() === TOK_TYPE_SUBEXPR) && (tokens.next().subtype.toString() === TOK_SUBTYPE_START)) || (tokens.next().type.toString() === TOK_TYPE_OPERAND));
//else if (!(
@@ -721,157 +725,233 @@
var parseFormula = excelFormulaUtilities.parseFormula = function (inputID, outputID) {
- var indentCount = 0;
-
- var indent = function () {
- var s = "|",
- i = 0;
- for (; i < indentCount; i += 1) {
- s += "&nbsp;&nbsp;&nbsp;|";
- }
- return s;
- };
+ var indentCount = 0;
- var formulaControl = document.getElementById(inputID);
- var formula = formulaControl.value;
+ var indent = function () {
+ var s = "|",
+ i = 0;
+ for (; i < indentCount; i += 1) {
+ s += "&nbsp;&nbsp;&nbsp;|";
+ }
+ return s;
+ };
- var tokens = getTokens(formula);
+ var formulaControl = document.getElementById(inputID);
+ var formula = formulaControl.value;
- var tokensHtml = "";
+ var tokens = getTokens(formula);
- tokensHtml += "<table cellspacing='0' style='border-top: 1px #cecece solid; margin-top: 5px; margin-bottom: 5px'>";
- tokensHtml += "<tr>";
- tokensHtml += "<td class='token' style='font-weight: bold; width: 50px'>index</td>";
- tokensHtml += "<td class='token' style='font-weight: bold; width: 125px'>type</td>";
- tokensHtml += "<td class='token' style='font-weight: bold; width: 125px'>subtype</td>";
- tokensHtml += "<td class='token' style='font-weight: bold; width: 150px'>token</td>";
- tokensHtml += "<td class='token' style='font-weight: bold; width: 300px'>token tree</td></tr>";
+ var tokensHtml = "";
- while (tokens.moveNext()) {
+ tokensHtml += "<table cellspacing='0' style='border-top: 1px #cecece solid; margin-top: 5px; margin-bottom: 5px'>";
+ tokensHtml += "<tr>";
+ tokensHtml += "<td class='token' style='font-weight: bold; width: 50px'>index</td>";
+ tokensHtml += "<td class='token' style='font-weight: bold; width: 125px'>type</td>";
+ tokensHtml += "<td class='token' style='font-weight: bold; width: 125px'>subtype</td>";
+ tokensHtml += "<td class='token' style='font-weight: bold; width: 150px'>token</td>";
+ tokensHtml += "<td class='token' style='font-weight: bold; width: 300px'>token tree</td></tr>";
- var token = tokens.current();
+ while (tokens.moveNext()) {
- if (token.subtype === TOK_SUBTYPE_STOP) {
- indentCount -= ((indentCount > 0) ? 1 : 0);
- }
+ var token = tokens.current();
- tokensHtml += "<tr>";
+ if (token.subtype === TOK_SUBTYPE_STOP) {
+ indentCount -= ((indentCount > 0) ? 1 : 0);
+ }
- tokensHtml += "<td class='token'>" + (tokens.index + 1) + "</td>";
+ tokensHtml += "<tr>";
- tokensHtml += "<td class='token'>" + token.type + "</td>";
- tokensHtml += "<td class='token'>" + ((token.subtype.length === 0) ? "&nbsp;" : token.subtype.toString()) + "</td>";
- tokensHtml += "<td class='token'>" + ((token.value.length === 0) ? "&nbsp;" : token.value).split(" ").join("&nbsp;") + "</td>";
- tokensHtml += "<td class='token'>" + indent() + ((token.value.length === 0) ? "&nbsp;" : token.value).split(" ").join("&nbsp;") + "</td>";
+ tokensHtml += "<td class='token'>" + (tokens.index + 1) + "</td>";
- tokensHtml += "</tr>";
+ tokensHtml += "<td class='token'>" + token.type + "</td>";
+ tokensHtml += "<td class='token'>" + ((token.subtype.length === 0) ? "&nbsp;" : token.subtype.toString()) + "</td>";
+ tokensHtml += "<td class='token'>" + ((token.value.length === 0) ? "&nbsp;" : token.value).split(" ").join("&nbsp;") + "</td>";
+ tokensHtml += "<td class='token'>" + indent() + ((token.value.length === 0) ? "&nbsp;" : token.value).split(" ").join("&nbsp;") + "</td>";
- if (token.subtype === TOK_SUBTYPE_START) {
- indentCount += 1;
- }
+ tokensHtml += "</tr>";
+ if (token.subtype === TOK_SUBTYPE_START) {
+ indentCount += 1;
}
- tokensHtml += "</table>";
+ }
+
+ tokensHtml += "</table>";
- document.getElementById(outputID).innerHTML = tokensHtml;
+ document.getElementById(outputID).innerHTML = tokensHtml;
- formulaControl.select();
- formulaControl.focus();
+ formulaControl.select();
+ formulaControl.focus();
- };
+ };
+
+ // Pass a range such as A1:B2 along with a
+ // delimiter to get back a full list of ranges.
+ //
+ // Example:
+ // breakOutRanges("A1:B2", "+"); //Returns A1+A2+B1+B2
+ //TODO finish this function.
+ function breakOutRanges(rangeStr, delimStr){
+
+ //Quick Check to see if if rangeStr is a valid range
+ if ( (/\w{1,4}\d+:\w{1,4}\d+/gi).test("A1:B2") ){
+ throw "This is not a valid range: " + rangeStr;
+ }
+
+ //Make the rangeStr lowercase to deal with looping.
+ ranges = rangeStr.split(":");
+
+ startRow = range[0].match(/[0-9]+/gi)[0];
+ startCol = range[0].match(/[A-Z]+/gi)[0];
+
+ endRow = range[1].match(/[0-9]+/gi)[0];
+ endCol = range[1].match(/[A-Z]+/gi)[0];
+
+ debugger;
+ //str.charCodeAt(n)
+ //String.fromCharCode();
+ return "";
+ }
+
+ //Modified from function at http://en.wikipedia.org/wiki/Hexavigesimal
+ function toBase26( value ) {
+
+ value = Math.abs(value);
+
+ var converted = ""
+ ,iteration = false
+ ,remainder;
+
+ // Repeatedly divide the numerb by 26 and convert the
+ // remainder into the appropriate letter.
+ do {
+ remainder = value % 26;
+
+ // Compensate for the last letter of the series being corrected on 2 or more iterations.
+ if (iteration && value < 25) {
+ remainder--;
+ }
+
+ converted = String.fromCharCode((remainder + 'A'.charCodeAt(0))) + converted;
+ value = Math.floor((value - remainder) / 26);
+
+ iteration = true;
+ } while (value > 0);
+
+ return converted;
+ }
+
+ // This was Modified from a function at http://en.wikipedia.org/wiki/Hexavigesimal
+ // Pass in the base 26 string, get back integer
+ function fromBase26(number) {
+ number = number.toUpperCase();
+
+ var s = 0
+ ,i = 1;
+
+ if (
+ number !== null
+ && typeof number !== "undefined"
+ && number.length > 0
+ ) {
+ s = (number.charCodeAt(0) - "A".charCodeAt(0));
+ for (; i < number.length; i++) {
+ s = s === 0 ? 26 : s * 26;
+ s += (number.charCodeAt(i) - ("A".charCodeAt(0) ));
+ }
+ }
+
+ return s;
+ }
+
+ function applyTokenTemplate(token, options, indent, lineBreak, override) {
- var applyTokenTemplate = function (token, options, indent, lineBreak, override) {
+ var indt = indent;
- var indt = indent;
+ var replaceTokenTmpl = function (inStr) {
+ return inStr.replace(/\{\{token\}\}/gi, "{0}").replace(/\{\{autoindent\}\}/gi, "{1}").replace(/\{\{autolinebreak\}\}/gi, "{2}");
+ };
- var replaceTokenTmpl = function (inStr) {
- return inStr.replace(/\{\{token\}\}/gi, "{0}").replace(/\{\{autoindent\}\}/gi, "{1}").replace(/\{\{autolinebreak\}\}/gi, "{2}");
- };
+ var tokenString = "";
- var tokenString = "";
+ if (token.subtype === "text" || token.type === "text") {
+ tokenString = token.value.toString();
+ } else {
+ tokenString = ((token.value.length === 0) ? " " : token.value.toString()).split(" ").join("").toString();
+ }
- if(token.subtype === "text" || token.type === "text") {
- tokenString = token.value.toString();
- } else {
- tokenString = ((token.value.length === 0) ? " " : token.value.toString()).split(" ").join("").toString();
- }
+ if (typeof override === 'function') {
+ var returnVal = override(tokenString, token, indent, lineBreak);
- if (typeof override === 'function') {
- var returnVal = override(tokenString, token, indent, lineBreak);
-
- tokenString = returnVal.tokenString;
+ tokenString = returnVal.tokenString;
- if (!returnVal.useTemplate) {
- return tokenString;
- }
+ if (!returnVal.useTemplate) {
+ return tokenString;
}
+ }
- switch (token.type) {
+ switch (token.type) {
- case "function":
- //-----------------FUNCTION------------------
- switch (token.value) {
- case "ARRAY":
- tokenString = formatStr(replaceTokenTmpl(options.tmplFunctionStartArray), tokenString, indt, lineBreak);
- break;
- case "ARRAYROW":
- tokenString = formatStr(replaceTokenTmpl(options.tmplFunctionStartArrayRow), tokenString, indt, lineBreak);
- break;
- default:
- if (token.subtype.toString() === "start") {
- tokenString = formatStr(replaceTokenTmpl(options.tmplFunctionStart), tokenString, indt, lineBreak);
- } else {
- tokenString = formatStr(replaceTokenTmpl(options.tmplFunctionStop), tokenString, indt, lineBreak);
- }
- break;
- }
+ case "function":
+ //-----------------FUNCTION------------------
+ switch (token.value) {
+ case "ARRAY":
+ tokenString = formatStr(replaceTokenTmpl(options.tmplFunctionStartArray), tokenString, indt, lineBreak);
break;
- case "operand":
- //-----------------OPERAND------------------
- switch (token.subtype.toString()) {
- case "error":
- tokenString = formatStr(replaceTokenTmpl(options.tmplOperandError), tokenString, indt, lineBreak);
- break;
- case "range":
- tokenString = formatStr(replaceTokenTmpl(options.tmplOperandRange), tokenString, indt, lineBreak);
- break;
- case "number":
- tokenString = formatStr(replaceTokenTmpl(options.tmplOperandNumber), tokenString, indt, lineBreak);
- break;
- case "text":
- tokenString = formatStr(replaceTokenTmpl(options.tmplOperandText), tokenString, indt, lineBreak);
- break;
- case "argument":
- tokenString = formatStr(replaceTokenTmpl(options.tmplArgument), tokenString, indt, lineBreak);
- break;
- default:
- break;
+ case "ARRAYROW":
+ tokenString = formatStr(replaceTokenTmpl(options.tmplFunctionStartArrayRow), tokenString, indt, lineBreak);
+ break;
+ default:
+ if (token.subtype.toString() === "start") {
+ tokenString = formatStr(replaceTokenTmpl(options.tmplFunctionStart), tokenString, indt, lineBreak);
+ } else {
+ tokenString = formatStr(replaceTokenTmpl(options.tmplFunctionStop), tokenString, indt, lineBreak);
}
break;
- case "operator-infix":
- case "logical":
- tokenString = formatStr(replaceTokenTmpl(options.tmplOperandLogical), tokenString, indt, lineBreak);
- break;
+ }
+ break;
+ case "operand":
+ //-----------------OPERAND------------------
+ switch (token.subtype.toString()) {
+ case "error":
+ tokenString = formatStr(replaceTokenTmpl(options.tmplOperandError), tokenString, indt, lineBreak);
+ break;
+ case "range":
+ tokenString = formatStr(replaceTokenTmpl(options.tmplOperandRange), tokenString, indt, lineBreak);
+ break;
+ case "number":
+ tokenString = formatStr(replaceTokenTmpl(options.tmplOperandNumber), tokenString, indt, lineBreak);
+ break;
+ case "text":
+ tokenString = formatStr(replaceTokenTmpl(options.tmplOperandText), tokenString, indt, lineBreak);
+ break;
case "argument":
tokenString = formatStr(replaceTokenTmpl(options.tmplArgument), tokenString, indt, lineBreak);
break;
- case "subexpression":
- if (token.subtype.toString() === "start") {
- tokenString = formatStr(replaceTokenTmpl(options.tmplSubexpressionStart), tokenString, indt, lineBreak);
- } else {
- tokenString = formatStr(replaceTokenTmpl(options.tmplSubexpressionStop), tokenString, indt, lineBreak);
- }
- break;
default:
-
break;
-
}
+ break;
+ case "operator-infix":
+ case "logical":
+ tokenString = formatStr(replaceTokenTmpl(options.tmplOperandLogical), tokenString, indt, lineBreak);
+ break;
+ case "argument":
+ tokenString = formatStr(replaceTokenTmpl(options.tmplArgument), tokenString, indt, lineBreak);
+ break;
+ case "subexpression":
+ if (token.subtype.toString() === "start") {
+ tokenString = formatStr(replaceTokenTmpl(options.tmplSubexpressionStart), tokenString, indt, lineBreak);
+ } else {
+ tokenString = formatStr(replaceTokenTmpl(options.tmplSubexpressionStop), tokenString, indt, lineBreak);
+ }
+ break;
+ default:
-
- return tokenString;
- };
+ break;
+ }
+ return tokenString;
+ };
/**
*
@@ -884,7 +964,7 @@
* {{autoindent}} - apply auto indent based on current tree level
* {{token}} - the named token such as FUNCTION_NAME or "string"
* {{autolinebreak}} - apply linbreak automaticly. tests for next element only at this point
- *
+ *
* Options include:
* tmplFunctionStart - template for the start of a function, the {{token}} will contain the name of the function.
* tmplFunctionStop - template for when the end of a function has been reached.
@@ -898,13 +978,13 @@
* tmplFunctionStartArrayRow - template for the start of an array row.
* tmplFunctionStopArrayRow - template for the end of an array row.
* tmplFunctionStopArray - template for the end of an array.
- * tmplSubexpressionStart - template for the sub expresson start
- * tmplSubexpressionStop - template for the sub expresson stop
+ * tmplSubexpressionStart - template for the sub expresson start
+ * tmplSubexpressionStop - template for the sub expresson stop
* tmplIndentTab - template for the tab char.
* tmplIndentSpace - template for space char.
* autoLineBreak - when rendering line breaks automaticly which types should it break on. "TOK_SUBTYPE_STOP | TOK_SUBTYPE_START | TOK_TYPE_ARGUMENT"
* newLine - used for the {{autolinebreak}} replacement as well as some string parsing. if this is not set correctly you may get undesired results. usually \n for text or <br /> for html
- * trim: true - trim the output.
+ * trim: true - trim the output.
* customTokenRender: null - this is a call back to a custom token function. your call back should look like
* EXAMPLE:
*
@@ -920,131 +1000,131 @@
* @returns {string}
*/
var formatFormula = excelFormulaUtilities.formatFormula = function (formula, options) {
- var isFirstToken = true,
- defaultOptions = {
- tmplFunctionStart: '{{autoindent}}{{token}}\n{{autoindent}}(\n',
- tmplFunctionStop: '\n{{autoindent}}{{token}})',
- tmplOperandError: '{{token}}',
- tmplOperandRange: '{{autoindent}}{{token}}',
- tmplOperandLogical: ' {{token}}{{autolinebreak}}',
- tmplOperandNumber: '{{autoindent}}{{token}}',
- tmplOperandText: '{{autoindent}}"{{token}}"',
- tmplArgument: '{{token}}\n',
- tmplFunctionStartArray: '',
- tmplFunctionStartArrayRow: '{',
- tmplFunctionStopArrayRow: '}',
- tmplFunctionStopArray: '',
- tmplSubexpressionStart: '{{autoindent}}(',
- tmplSubexpressionStop: ' )',
- tmplIndentTab: '\t',
- tmplIndentSpace: ' ',
- autoLineBreak: 'TOK_TYPE_FUNCTION | TOK_TYPE_ARGUMENT | TOK_SUBTYPE_LOGICAL | TOK_TYPE_OP_IN ',
- newLine: '\n',
- trim: true,
- customTokenRender: null
- };
-
- if (options) {
- options = core.extend(true, defaultOptions, options);
- } else {
- options = defaultOptions;
- }
-
- var indentCount = 0;
+ var isFirstToken = true,
+ defaultOptions = {
+ tmplFunctionStart: '{{autoindent}}{{token}}\n{{autoindent}}(\n',
+ tmplFunctionStop: '\n{{autoindent}}{{token}})',
+ tmplOperandError: '{{token}}',
+ tmplOperandRange: '{{autoindent}}{{token}}',
+ tmplOperandLogical: ' {{token}}{{autolinebreak}}',
+ tmplOperandNumber: '{{autoindent}}{{token}}',
+ tmplOperandText: '{{autoindent}}"{{token}}"',
+ tmplArgument: '{{token}}\n',
+ tmplFunctionStartArray: '',
+ tmplFunctionStartArrayRow: '{',
+ tmplFunctionStopArrayRow: '}',
+ tmplFunctionStopArray: '',
+ tmplSubexpressionStart: '{{autoindent}}(',
+ tmplSubexpressionStop: ' )',
+ tmplIndentTab: '\t',
+ tmplIndentSpace: ' ',
+ autoLineBreak: 'TOK_TYPE_FUNCTION | TOK_TYPE_ARGUMENT | TOK_SUBTYPE_LOGICAL | TOK_TYPE_OP_IN ',
+ newLine: '\n',
+ trim: true,
+ customTokenRender: null
+ };
- var indent = function () {
- var s = "",
- i = 0;
-
- for (; i < indentCount; i += 1) {
- s += options.tmplIndentTab;
- }
- return s;
- };
+ if (options) {
+ options = core.extend(true, defaultOptions, options);
+ } else {
+ options = defaultOptions;
+ }
- var tokens = getTokens(formula);
+ var indentCount = 0;
- var outputFormula = "";
+ var indent = function () {
+ var s = "",
+ i = 0;
- var autoBreakArray = options.autoLineBreak.replace(/\s/gi, "").split("|");
+ for (; i < indentCount; i += 1) {
+ s += options.tmplIndentTab;
+ }
+ return s;
+ };
- //Tokens
- var isNewLine = true;
+ var tokens = getTokens(formula);
- var testAutoBreak = function (nextToken) {
- var i = 0;
- for (; i < autoBreakArray.length; i += 1) {
- if (nextToken !== null && typeof nextToken !== 'undefined' && (types[autoBreakArray[i]] === nextToken.type.toString() || types[autoBreakArray[i]] === nextToken.subtype.toString())) {
- return true;
- }
- }
- return false;
- };
+ var outputFormula = "";
- while (tokens.moveNext()) {
+ var autoBreakArray = options.autoLineBreak.replace(/\s/gi, "").split("|");
- var token = tokens.current();
- var nextToken = tokens.next();
+ //Tokens
+ var isNewLine = true;
- if (token.subtype.toString() === TOK_SUBTYPE_STOP) {
- indentCount -= ((indentCount > 0) ? 1 : 0);
+ var testAutoBreak = function (nextToken) {
+ var i = 0;
+ for (; i < autoBreakArray.length; i += 1) {
+ if (nextToken !== null && typeof nextToken !== 'undefined' && (types[autoBreakArray[i]] === nextToken.type.toString() || types[autoBreakArray[i]] === nextToken.subtype.toString())) {
+ return true;
}
-
- var matchBeginNewline = new RegExp('^' + options.newLine, ''),
- matchEndNewLine = new RegExp(options.newLine + '$', ''),
- autoBreak = testAutoBreak(nextToken),
- autoIndent = isNewLine,
- indt = autoIndent ? indent() : options.tmplIndentSpace,
- lineBreak = autoBreak ? options.newLine : "";
+ }
+ return false;
+ };
+
+ while (tokens.moveNext()) {
- outputFormula += applyTokenTemplate(token, options, indt, lineBreak, options.customTokenRender);
+ var token = tokens.current();
+ var nextToken = tokens.next();
- if (token.subtype.toString() === TOK_SUBTYPE_START) {
- indentCount += 1;
+ if (token.subtype.toString() === TOK_SUBTYPE_STOP) {
+ indentCount -= ((indentCount > 0) ? 1 : 0);
+ }
+
+ var matchBeginNewline = new RegExp('^' + options.newLine, ''),
+ matchEndNewLine = new RegExp(options.newLine + '$', ''),
+ autoBreak = testAutoBreak(nextToken),
+ autoIndent = isNewLine,
+ indt = autoIndent ? indent() : options.tmplIndentSpace,
+ lineBreak = autoBreak ? options.newLine : "";
+
+ outputFormula += applyTokenTemplate(token, options, indt, lineBreak, options.customTokenRender);
+
+ if (token.subtype.toString() === TOK_SUBTYPE_START) {
+ indentCount += 1;
- }
-
- isNewLine = autoBreak || matchEndNewLine.test(outputFormula);
- isFirstToken = false;
}
- return options.trim ? trim(outputFormula) : outputFormula;
- };
- /**
+ isNewLine = autoBreak || matchEndNewLine.test(outputFormula);
+ isFirstToken = false;
+ }
+
+ return options.trim ? trim(outputFormula) : outputFormula;
+ };
+ /**
* This function calls {@link excelFormulaUtilities.parser.formatFormula}
- *
+ *
* @memberof excelFormulaUtilities.parser
* @function
* @param {string} formula
* @param {object} options optional param
- */
- var formatFormulaHTML = excelFormulaUtilities.formatFormulaHTML = function(formula){
- var options = {
- tmplFunctionStart: '{{autoindent}}<span class="function">{{token}}</span><br />{{autoindent}}<span class="function_start">(</span><br />',
- tmplFunctionStop: '<br />{{autoindent}}{{token}}<span class="function_stop">)</span>',
- tmplOperandError: '{{token}}',
- tmplOperandRange: '{{autoindent}}{{token}}',
- tmplOperandLogical: ' {{token}}{{autolinebreak}}',
- tmplOperandNumber: '{{autoindent}}{{token}}',
- tmplOperandText: '{{autoindent}}<span class="quote_mark">"</span><span class="text">{{token}}</span><span class="quote_mark">"</span>',
- tmplArgument: '{{token}}<br />',
- tmplFunctionStartArray: '',
- tmplFunctionStartArrayRow: '{',
- tmplFunctionStopArrayRow: '}',
- tmplFunctionStopArray: '',
- tmplSubexpressionStart: '{{autoindent}}(',
- tmplSubexpressionStop: ' )',
- tmplIndentTab: '<span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span>',
- tmplIndentSpace: '&nbsp;',
- newLine: '<br />',
- autoLineBreak: 'TOK_TYPE_FUNCTION | TOK_TYPE_ARGUMENT | TOK_SUBTYPE_LOGICAL | TOK_TYPE_OP_IN ',
- trim: true,
- customTokenRender: null
- };
-
- return formatFormula(formula, options);
- }
-
+ */
+ var formatFormulaHTML = excelFormulaUtilities.formatFormulaHTML = function (formula) {
+ var options = {
+ tmplFunctionStart: '{{autoindent}}<span class="function">{{token}}</span><br />{{autoindent}}<span class="function_start">(</span><br />',
+ tmplFunctionStop: '<br />{{autoindent}}{{token}}<span class="function_stop">)</span>',
+ tmplOperandError: '{{token}}',
+ tmplOperandRange: '{{autoindent}}{{token}}',
+ tmplOperandLogical: ' {{token}}{{autolinebreak}}',
+ tmplOperandNumber: '{{autoindent}}{{token}}',
+ tmplOperandText: '{{autoindent}}<span class="quote_mark">"</span><span class="text">{{token}}</span><span class="quote_mark">"</span>',
+ tmplArgument: '{{token}}<br />',
+ tmplFunctionStartArray: '',
+ tmplFunctionStartArrayRow: '{',
+ tmplFunctionStopArrayRow: '}',
+ tmplFunctionStopArray: '',
+ tmplSubexpressionStart: '{{autoindent}}(',
+ tmplSubexpressionStop: ' )',
+ tmplIndentTab: '<span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span>',
+ tmplIndentSpace: '&nbsp;',
+ newLine: '<br />',
+ autoLineBreak: 'TOK_TYPE_FUNCTION | TOK_TYPE_ARGUMENT | TOK_SUBTYPE_LOGICAL | TOK_TYPE_OP_IN ',
+ trim: true,
+ customTokenRender: null
+ };
+
+ return formatFormula(formula, options);
+ }
+
/**
*
* @memberof excelFormulaUtilities.convert
@@ -1054,130 +1134,159 @@
*/
var formula2CSharp = excelFormulaUtilities.formula2CSharp = function (formula) {
- //Custom callback to format as c#
- var functionStack = [];
-
- var tokRender = function (tokenStr, token, indent, linbreak) {
- var outstr = "",
- /*tokenString = (token.value.length === 0) ? "" : token.value.toString(),*/
- tokenString = tokenStr,
- directConversionMap = {
- "=": "==",
- "<>": "!=",
- "MIN": "Math.Min",
- "MAX": "Math.Max",
- "ABS": "Math.ABS",
- "SUM": "",
- "IF": "",
- "&" : "+"
- },
- currentFunctionOnStack = functionStack[functionStack.length - 1],
- useTemplate = false;
+ //Custom callback to format as c#
+ var functionStack = [];
+
+ var tokRender = function (tokenStr, token, indent, linbreak) {
+ var outstr = "",
+ /*tokenString = (token.value.length === 0) ? "" : token.value.toString(),*/
+ tokenString = tokenStr,
+ directConversionMap = {
+ "=": "==",
+ "<>": "!=",
+ "MIN": "Math.Min",
+ "MAX": "Math.Max",
+ "ABS": "Math.ABS",
+ "SUM": "",
+ "IF": "",
+ "&": "+"
+ },
+ currentFunctionOnStack = functionStack[functionStack.length - 1],
+ useTemplate = false;
+
+ switch (token.type.toString()) {
+
+ case TOK_TYPE_FUNCTION:
+
+ switch (token.subtype) {
+
+ case TOK_SUBTYPE_START:
+
+ functionStack.push({
+ name: tokenString,
+ argumentNumber: 0
+ });
+ outstr = typeof directConversionMap[tokenString.toUpperCase()] === "string" ? directConversionMap[tokenString.toUpperCase()] : tokenString;
+ useTemplate = true;
- switch (token.type.toString()) {
+ break;
- case TOK_TYPE_FUNCTION:
+ case TOK_SUBTYPE_STOP:
- switch (token.subtype) {
+ useTemplate = true;
+ switch (currentFunctionOnStack.name.toLowerCase()) {
+ case "if":
+ outstr = ")";
+ useTemplate = false;
+ break;
+ default:
+ outstr = typeof directConversionMap[tokenString.toUpperCase()] === "string" ? directConversionMap[tokenString.toUpperCase()] : tokenString;
+ break
+ }
+ functionStack.pop();
+ break;
+ }
- case TOK_SUBTYPE_START:
-
- functionStack.push({
- name: tokenString,
- argumentNumber: 0
- });
- outstr = typeof directConversionMap[tokenString] === "string" ? directConversionMap[tokenString] : tokenString;
- useTemplate = true;
-
- break;
- case TOK_SUBTYPE_STOP:
-
- useTemplate = true;
- switch (currentFunctionOnStack.name.toLowerCase()){
- case "if":
- outstr = ")";
- useTemplate = false;
- break;
- default:
- outstr = typeof directConversionMap[tokenString] === "string" ? directConversionMap[tokenString] : tokenString;
- break
- }
- functionStack.pop();
- break;
- }
+ break;
+ case TOK_TYPE_ARGUMENT:
+ switch (currentFunctionOnStack.name.toLowerCase()) {
+ case "if":
+ switch (currentFunctionOnStack.argumentNumber) {
+ case 0:
+ outstr = "?";
+ break;
+ case 1:
+ outstr = ":";
break;
+ }
+ break;
+ case "sum":
+ outstr = "+";
+ break;
+ default:
+ outstr = typeof directConversionMap[tokenString.toUpperCase()] === "string" ? directConversionMap[tokenString.toUpperCase()] : tokenString;
+ useTemplate = true;
+ break;
+ }
- case TOK_TYPE_ARGUMENT:
- switch (currentFunctionOnStack.name.toLowerCase()){
- case "if":
- switch (currentFunctionOnStack.argumentNumber) {
- case 0:
- outstr = "?";
- break;
- case 1:
- outstr = ":";
- break;
- }
- break;
- case "sum":
- outstr = "+";
- break;
- default:
- outstr = typeof directConversionMap[tokenString] === "string" ? directConversionMap[tokenString] : tokenString;
- useTemplate = true;
- break;
- }
+ currentFunctionOnStack.argumentNumber += 1;
- currentFunctionOnStack.argumentNumber += 1;
+ break;
+ case TOK_TYPE_OPERAND:
+
+ switch (token.subtype) {
+
+ case TOK_SUBTYPE_RANGE:
+
+ switch (currentFunctionOnStack.name.toLowerCase()) {
+ // If in the sum function break aout cell names and add
+ case "sum":
+ outstr = breakOutRanges(tokenString, "+");
+
+ debugger;
+ //TODO loop through and add ranges together
+ break;
+ // By Default return an array containing all cell names in array
+ default:
+ //TODO create array for ranges
+ break;
+ }
+
break;
-
+
default:
- outstr = typeof directConversionMap[tokenString] === "string" ? directConversionMap[tokenString] : tokenString;
- useTemplate = true;
break;
- }
+ }
- return {
- tokenString: outstr,
- useTemplate: useTemplate
- };
- };
+ default:
+ outstr = typeof directConversionMap[tokenString.toUpperCase()] === "string" ? directConversionMap[tokenString.toUpperCase()] : tokenString;
+ useTemplate = true;
+ break;
+ }
- var cSharpOutput = formatFormula(
- formula, {
- tmplFunctionStart: '{{token}}(',
- tmplFunctionStop: '{{token}})',
- tmplOperandError: '{{token}}',
- tmplOperandRange: '{{token}}',
- tmplOperandLogical: '{{token}}',
- tmplOperandNumber: '{{token}}',
- tmplOperandText: '"{{token}}"',
- tmplArgument: '{{token}}',
- tmplFunctionStartArray: "",
- tmplFunctionStartArrayRow: "{",
- tmplFunctionStopArrayRow: "}",
- tmplFunctionStopArray: "",
- tmplSubexpressionStart: "(",
- tmplSubexpressionStop: ")",
- tmplIndentTab: "\t",
- tmplIndentSpace: " ",
- autoLineBreak: "TOK_SUBTYPE_STOP | TOK_SUBTYPE_START | TOK_TYPE_ARGUMENT",
- trim: true,
- customTokenRender: tokRender
- });
- return cSharpOutput;
+ return {
+ tokenString: outstr,
+ useTemplate: useTemplate
+ };
};
-
- /**
+
+ var cSharpOutput = formatFormula(
+ formula, {
+ tmplFunctionStart: '{{token}}(',
+ tmplFunctionStop: '{{token}})',
+ tmplOperandError: '{{token}}',
+ tmplOperandRange: '{{token}}',
+ tmplOperandLogical: '{{token}}',
+ tmplOperandNumber: '{{token}}',
+ tmplOperandText: '"{{token}}"',
+ tmplArgument: '{{token}}',
+ tmplFunctionStartArray: "",
+ tmplFunctionStartArrayRow: "{",
+ tmplFunctionStopArrayRow: "}",
+ tmplFunctionStopArray: "",
+ tmplSubexpressionStart: "(",
+ tmplSubexpressionStop: ")",
+ tmplIndentTab: "\t",
+ tmplIndentSpace: " ",
+ autoLineBreak: "TOK_SUBTYPE_STOP | TOK_SUBTYPE_START | TOK_TYPE_ARGUMENT",
+ trim: true,
+ customTokenRender: tokRender
+ });
+ return cSharpOutput;
+ };
+
+ /**
* Both the csharp and javascript are the same when converted, this is just an alias for convert2CSharp. there are some subtle differences such as == vrs ===, this will be addressed in a later version.
* @memberof excelFormulaUtilities.convert
* @function
* @param {string} formula
* @returns {string}
*/
- var formula2JavaScript = excelFormulaUtilities.formula2JavaScript = function (formula) {
- return formula2CSharp(formula);
- }
+ var formula2JavaScript = excelFormulaUtilities.formula2JavaScript = function (formula) {
+ return formula2CSharp(formula).replace('==', '===');
+ }
+
+ excelFormulaUtilities.getTokens = getTokens;
}());
View
25 excelFormulaUtilities-0.9.4.min.js
@@ -0,0 +1,25 @@
+(function(){"undefined"===typeof window&&(window=root);window.excelFormulaUtilities=window.excelFormulaUtilities||{};var r=window.excelFormulaUtilities.core={};window.excelFormulaUtilities.string=window.excelFormulaUtilities.string||{};window.excelFormulaUtilities.string.formatStr=function(i){for(var m=i,h=1;h<arguments.length;h++)m=m.replace(RegExp("\\{{1}"+(h-1).toString()+"{1}\\}{1}","g"),arguments[h]);return m};window.excelFormulaUtilities.string.trim=function(i){return i.replace(/^\s|\s$/,"")};
+window.excelFormulaUtilities.string.trim=function(i){return i.replace(/^(?:\s|&nbsp;|<\s*br\s*\/*\s*>)*|(?:\s|&nbsp;|<\s*br\s*\/*\s*>)*$/,"")};var u=r.isFunction=function(i){return"function"===typeof i},w=r.isArray=function(i){return"object"===typeof i&&i.length},v=r.isWindow=function(){return obj&&"object"===typeof obj&&"setInterval"in obj},x=r.isPlainObject=function(i){if(!i||("object"!==typeof i||i.nodeType||v(i))||i.constructor&&!hasOwnProperty.call(i,"constructor")&&!hasOwnProperty.call(i.constructor.prototype,
+"isPrototypeOf"))return!1;for(var m in i);return void 0===m||hasOwnProperty.call(i,m)};r.extend=function(){var i,m,h,o,j,k=arguments[0]||{},l=1,n=arguments.length,s=!1;"boolean"===typeof k&&(s=k,k=arguments[1]||{},l=2);"object"!==typeof k&&!u(k)&&(k={});n===l&&(k=this,--l);for(;l<n;l++)if(null!=(i=arguments[l]))for(m in i)h=k[m],o=i[m],k!==o&&(s&&o&&(x(o)||(j=w(o)))?(j?(j=!1,h=h&&w(h)?h:[]):h=h&&x(h)?h:{},k[m]=r.extend(s,h,o)):void 0!==o&&(k[m]=o));return k}})();(function(){function r(g,b,c){this.value=g;this.type=b;this.subtype=c}function u(){this.items=[];this.add=function(g,b,c){c||(c="");g=new r(g,b,c);this.addRef(g);return g};this.addRef=function(g){this.items.push(g)};this.index=-1;this.reset=function(){this.index=-1};this.BOF=function(){return 0>=this.index};this.EOF=function(){return this.index>=this.items.length-1};this.moveNext=function(){if(this.EOF())return!1;this.index+=1;return!0};this.current=function(){return-1===this.index?null:this.items[this.index]};
+this.next=function(){return this.EOF()?null:this.items[this.index+1]};this.previous=function(){return 1>this.index?null:this.items[this.index-1]}}function w(){this.items=[];this.push=function(g){this.items.push(g)};this.pop=function(g){var b=this.items.pop();return new r(g||"",b.type,p)};this.token=function(){return 0<this.items.length?this.items[this.items.length-1]:null};this.value=function(){return this.token()?this.token().value.toString():""};this.type=function(){return this.token()?this.token().type.toString():
+""};this.subtype=function(){return this.token()?this.token().subtype.toString():""}}function v(g){for(var b=new u,c=new w,d=0,e=function(){return g.substr(d,1)},a="",f=!1,i=!1,h=!1,j=!1,m=/^[1-9]{1}(\.[0-9]+)?E{1}$/;0<g.length;)if(" "===g.substr(0,1))g=g.substr(1);else{"="===g.substr(0,1)&&(g=g.substr(1));break}for(;!(d>=g.length);)if(f)'"'===e()?'"'===g.substr(d+1,1)?(a+='"',d+=1):(f=!1,b.add(a,l,H),a=""):a+=e(),d+=1;else if(i)"'"===e()?"'"===g.substr(d+1,1)?(a+="'",d+=1):i=!1:a+=e(),d+=1;else if(h)"]"===
+e()&&(h=!1),a+=e(),d+=1;else if(j)a+=e(),d+=1,-1!==",#NULL!,#DIV/0!,#VALUE!,#REF!,#NAME?,#NUM!,#N/A,".indexOf(","+a+",")&&(j=!1,b.add(a,l,I),a="");else if(-1!=="+-".indexOf(e())&&1<a.length&&a.match(m))a+=e(),d+=1;else if('"'===e())0<a.length&&(b.add(a,y),a=""),f=!0,d+=1;else if("'"===e())0<a.length&&(b.add(a,y),a=""),i=!0,d+=1;else if("["===e())h=!0,a+=e(),d+=1;else if("#"===e())0<a.length&&(b.add(a,y),a=""),j=!0,a+=e(),d+=1;else if("{"===e())0<a.length&&(b.add(a,y),a=""),c.push(b.add("ARRAY",n,
+q)),c.push(b.add("ARRAYROW",n,q)),d+=1;else if(";"===e())0<a.length&&(b.add(a,l),a=""),b.addRef(c.pop()),b.add(",",z),c.push(b.add("ARRAYROW",n,q)),d+=1;else if("}"===e())0<a.length&&(b.add(a,l),a=""),b.addRef(c.pop("ARRAYROWSTOP")),b.addRef(c.pop("ARRAYSTOP")),d+=1;else if(" "===e()){0<a.length&&(b.add(a,l),a="");b.add("",D);for(d+=1;" "===e()&&!(d>=g.length);)d+=1}else-1!==",>=,<=,<>,".indexOf(","+g.substr(d,2)+",")?(0<a.length&&(b.add(a,l),a=""),b.add(g.substr(d,2),t,A),d+=2):(-1!=="+-*/^&=><".indexOf(e())?
+(0<a.length&&(b.add(a,l),a=""),b.add(e(),t)):-1!=="%".indexOf(e())?(0<a.length&&(b.add(a,l),a=""),b.add(e(),B)):"("===e()?0<a.length?(c.push(b.add(a,n,q)),a=""):c.push(b.add("",s,q)):","===e()?(0<a.length&&(b.add(a,l),a=""),c.type()!==n?b.add(e(),t,J):b.add(e(),z)):")"===e()?(0<a.length&&(b.add(a,l),a=""),b.addRef(c.pop())):a+=e(),d+=1);0<a.length&&b.add(a,l);for(c=new u;b.moveNext();)a=b.current(),a.type.toString()===D?(e=(e=(e=b.BOF()||b.EOF())&&(b.previous().type.toString()===n&&b.previous().subtype.toString()===
+p||b.previous().type.toString()===s&&b.previous().subtype.toString()===p||b.previous().type.toString()===l))&&(b.next().type.toString()===n&&b.next().subtype.toString()===q||b.next().type.toString()===s&&b.next().subtype.toString()===q||b.next().type.toString()===l))&&c.add(a.value.toString(),t,K):c.addRef(a);for(;c.moveNext();)a=c.current(),a.type.toString()===t&&"-"===a.value.toString()?c.BOF()?a.type=E.toString():c.previous().type.toString()===n&&c.previous().subtype.toString()===p||c.previous().type.toString()===
+s&&c.previous().subtype.toString()===p||c.previous().type.toString()===B||c.previous().type.toString()===l?a.subtype=C.toString():a.type=E.toString():a.type.toString()===t&&"+"===a.value.toString()?c.BOF()?a.type=k.toString():c.previous().type.toString()===n&&c.previous().subtype.toString()===p||c.previous().type.toString()===s&&c.previous().subtype.toString()===p||c.previous().type.toString()===B||c.previous().type.toString()===l?a.subtype=C.toString():a.type=k.toString():a.type.toString()===t&&
+0===a.subtype.length?a.subtype=-1!=="<>=".indexOf(a.value.substr(0,1))?A.toString():"&"===a.value.toString()?L.toString():C.toString():a.type.toString()===l&&0===a.subtype.length?a.subtype=isNaN(parseFloat(a.value))?"TRUE"===a.value.toString()||"FALSE"===a.value.toString()?A.toString():F.toString():M.toString():a.type.toString()===n&&"@"===a.value.substr(0,1)&&(a.value=a.value.substr(1).toString());c.reset();for(b=new u;c.moveNext();)c.current().type.toString()!==k&&b.addRef(c.current());b.reset();
+return b}function x(g,b,c,d,e){var a=function(a){return a.replace(/\{\{token\}\}/gi,"{0}").replace(/\{\{autoindent\}\}/gi,"{1}").replace(/\{\{autolinebreak\}\}/gi,"{2}")},f="",f="text"===g.subtype||"text"===g.type?g.value.toString():(0===g.value.length?" ":g.value.toString()).split(" ").join("").toString();if("function"===typeof e&&(e=e(f,g,c,d),f=e.tokenString,!e.useTemplate))return f;switch(g.type){case "function":switch(g.value){case "ARRAY":f=h(a(b.tmplFunctionStartArray),f,c,d);break;case "ARRAYROW":f=
+h(a(b.tmplFunctionStartArrayRow),f,c,d);break;default:f="start"===g.subtype.toString()?h(a(b.tmplFunctionStart),f,c,d):h(a(b.tmplFunctionStop),f,c,d)}break;case "operand":switch(g.subtype.toString()){case "error":f=h(a(b.tmplOperandError),f,c,d);break;case "range":f=h(a(b.tmplOperandRange),f,c,d);break;case "number":f=h(a(b.tmplOperandNumber),f,c,d);break;case "text":f=h(a(b.tmplOperandText),f,c,d);break;case "argument":f=h(a(b.tmplArgument),f,c,d)}break;case "operator-infix":case "logical":f=h(a(b.tmplOperandLogical),
+f,c,d);break;case "argument":f=h(a(b.tmplArgument),f,c,d);break;case "subexpression":f="start"===g.subtype.toString()?h(a(b.tmplSubexpressionStart),f,c,d):h(a(b.tmplSubexpressionStop),f,c,d)}return f}"undefined"===typeof window&&(window=root);var i=window.excelFormulaUtilities=window.excelFormulaUtilities||{},m=window.excelFormulaUtilities.core,h=window.excelFormulaUtilities.string.formatStr,o=window.excelFormulaUtilities.string.trim,j={},k=j.TOK_TYPE_NOOP="noop",l=j.TOK_TYPE_OPERAND="operand",n=
+j.TOK_TYPE_FUNCTION="function",s=j.TOK_TYPE_SUBEXPR="subexpression",z=j.TOK_TYPE_ARGUMENT="argument",E=j.TOK_TYPE_OP_PRE="operator-prefix",t=j.TOK_TYPE_OP_IN="operator-infix",B=j.TOK_TYPE_OP_POST="operator-postfix",D=j.TOK_TYPE_WSPACE="white-space",y=j.TOK_TYPE_UNKNOWN="unknown",q=j.TOK_SUBTYPE_START="start",p=j.TOK_SUBTYPE_STOP="stop",H=j.TOK_SUBTYPE_TEXT="text",M=j.TOK_SUBTYPE_NUMBER="number",A=j.TOK_SUBTYPE_LOGICAL="logical",I=j.TOK_SUBTYPE_ERROR="error",F=j.TOK_SUBTYPE_RANGE="range",C=j.TOK_SUBTYPE_MATH=
+"math",L=j.TOK_SUBTYPE_CONCAT="concatenate",K=j.TOK_SUBTYPE_INTERSECT="intersect",J=j.TOK_SUBTYPE_UNION="union";i.parseFormula=function(g,b){var c=0,d=document.getElementById(g),e=v(d.value),a;for(a="<table cellspacing='0' style='border-top: 1px #cecece solid; margin-top: 5px; margin-bottom: 5px'><tr><td class='token' style='font-weight: bold; width: 50px'>index</td><td class='token' style='font-weight: bold; width: 125px'>type</td><td class='token' style='font-weight: bold; width: 125px'>subtype</td><td class='token' style='font-weight: bold; width: 150px'>token</td><td class='token' style='font-weight: bold; width: 300px'>token tree</td></tr>";e.moveNext();){var f=
+e.current();f.subtype===p&&(c-=0<c?1:0);a+="<tr>";a+="<td class='token'>"+(e.index+1)+"</td>";a+="<td class='token'>"+f.type+"</td>";a+="<td class='token'>"+(0===f.subtype.length?"&nbsp;":f.subtype.toString())+"</td>";a+="<td class='token'>"+(0===f.value.length?"&nbsp;":f.value).split(" ").join("&nbsp;")+"</td>";for(var i="|",h=0;h<c;h+=1)i+="&nbsp;&nbsp;&nbsp;|";a+="<td class='token'>"+i+(0===f.value.length?"&nbsp;":f.value).split(" ").join("&nbsp;")+"</td>";a+="</tr>";f.subtype===q&&(c+=1)}document.getElementById(b).innerHTML=
+a+"</table>";d.select();d.focus()};var G=i.formatFormula=function(g,b){for(var c={tmplFunctionStart:"{{autoindent}}{{token}}\n{{autoindent}}(\n",tmplFunctionStop:"\n{{autoindent}}{{token}})",tmplOperandError:"{{token}}",tmplOperandRange:"{{autoindent}}{{token}}",tmplOperandLogical:" {{token}}{{autolinebreak}}",tmplOperandNumber:"{{autoindent}}{{token}}",tmplOperandText:'{{autoindent}}"{{token}}"',tmplArgument:"{{token}}\n",tmplFunctionStartArray:"",tmplFunctionStartArrayRow:"{",tmplFunctionStopArrayRow:"}",
+tmplFunctionStopArray:"",tmplSubexpressionStart:"{{autoindent}}(",tmplSubexpressionStop:" )",tmplIndentTab:"\t",tmplIndentSpace:" ",autoLineBreak:"TOK_TYPE_FUNCTION | TOK_TYPE_ARGUMENT | TOK_SUBTYPE_LOGICAL | TOK_TYPE_OP_IN ",newLine:"\n",trim:!0,customTokenRender:null},b=b?m.extend(!0,c,b):c,c=0,d=v(g),e="",a=b.autoLineBreak.replace(/\s/gi,"").split("|"),f=!0;d.moveNext();){var i=d.current(),h=d.next();i.subtype.toString()===p&&(c-=0<c?1:0);var l=RegExp(b.newLine+"$","");a:{for(var k=0;k<a.length;k+=
+1)if(null!==h&&"undefined"!==typeof h&&(j[a[k]]===h.type.toString()||j[a[k]]===h.subtype.toString())){h=!0;break a}h=!1}if(f){f="";for(k=0;k<c;k+=1)f+=b.tmplIndentTab}else f=b.tmplIndentSpace;e+=x(i,b,f,h?b.newLine:"",b.customTokenRender);i.subtype.toString()===q&&(c+=1);f=h||l.test(e)}return b.trim?o(e):e};i.formatFormulaHTML=function(g){return G(g,{tmplFunctionStart:'{{autoindent}}<span class="function">{{token}}</span><br />{{autoindent}}<span class="function_start">(</span><br />',tmplFunctionStop:'<br />{{autoindent}}{{token}}<span class="function_stop">)</span>',
+tmplOperandError:"{{token}}",tmplOperandRange:"{{autoindent}}{{token}}",tmplOperandLogical:" {{token}}{{autolinebreak}}",tmplOperandNumber:"{{autoindent}}{{token}}",tmplOperandText:'{{autoindent}}<span class="quote_mark">"</span><span class="text">{{token}}</span><span class="quote_mark">"</span>',tmplArgument:"{{token}}<br />",tmplFunctionStartArray:"",tmplFunctionStartArrayRow:"{",tmplFunctionStopArrayRow:"}",tmplFunctionStopArray:"",tmplSubexpressionStart:"{{autoindent}}(",tmplSubexpressionStop:" )",
+tmplIndentTab:'<span class="tabs">&nbsp;&nbsp;&nbsp;&nbsp;</span>',tmplIndentSpace:"&nbsp;",newLine:"<br />",autoLineBreak:"TOK_TYPE_FUNCTION | TOK_TYPE_ARGUMENT | TOK_SUBTYPE_LOGICAL | TOK_TYPE_OP_IN ",trim:!0,customTokenRender:null})};var N=i.formula2CSharp=function(g){var b=[];return G(g,{tmplFunctionStart:"{{token}}(",tmplFunctionStop:"{{token}})",tmplOperandError:"{{token}}",tmplOperandRange:"{{token}}",tmplOperandLogical:"{{token}}",tmplOperandNumber:"{{token}}",tmplOperandText:'"{{token}}"',
+tmplArgument:"{{token}}",tmplFunctionStartArray:"",tmplFunctionStartArrayRow:"{",tmplFunctionStopArrayRow:"}",tmplFunctionStopArray:"",tmplSubexpressionStart:"(",tmplSubexpressionStop:")",tmplIndentTab:"\t",tmplIndentSpace:" ",autoLineBreak:"TOK_SUBTYPE_STOP | TOK_SUBTYPE_START | TOK_TYPE_ARGUMENT",trim:!0,customTokenRender:function(c,d){var e="",a={"=":"==","<>":"!=",MIN:"Math.Min",MAX:"Math.Max",ABS:"Math.ABS",SUM:"",IF:"","&":"+"},f=b[b.length-1],g=!1;switch(d.type.toString()){case n:switch(d.subtype){case q:b.push({name:c,
+argumentNumber:0});e="string"===typeof a[c.toUpperCase()]?a[c.toUpperCase()]:c;g=!0;break;case p:g=!0;switch(f.name.toLowerCase()){case "if":e=")";g=!1;break;default:e="string"===typeof a[c.toUpperCase()]?a[c.toUpperCase()]:c}b.pop()}break;case z:switch(f.name.toLowerCase()){case "if":switch(f.argumentNumber){case 0:e="?";break;case 1:e=":"}break;case "sum":e="+";break;default:e="string"===typeof a[c.toUpperCase()]?a[c.toUpperCase()]:c,g=!0}f.argumentNumber+=1;break;case l:switch(d.subtype){case F:switch(f.name.toLowerCase()){case "sum":if(/\w{1,4}\d+:\w{1,4}\d+/gi.test("A1:B2"))throw"This is not a valid range: "+
+c;ranges=c.split(":");startRow=range[0].match(/[0-9]+/gi)[0];startCol=range[0].match(/[A-Z]+/gi)[0];endRow=range[1].match(/[0-9]+/gi)[0];endCol=range[1].match(/[A-Z]+/gi)[0];debugger;debugger}break}default:e="string"===typeof a[c.toUpperCase()]?a[c.toUpperCase()]:c,g=!0}return{tokenString:e,useTemplate:g}}})};i.formula2JavaScript=function(g){return N(g).replace("==","===")};i.getTokens=v})();
View
1  node_modules/.bin/cake
View
1  node_modules/.bin/coffee
View
1  node_modules/.bin/docco
View
1  node_modules/closure-compiler/.npmignore
@@ -0,0 +1 @@
+*.swp
View
2  node_modules/closure-compiler/Cakefile
@@ -0,0 +1,2 @@
+task 'build', 'Build the source to Javascript', ->
+ require('child_process').spawn 'coffee', ['-cbo', 'lib/', 'src/index.coffee']
View
0  node_modules/closure-compiler/README.md
No changes.
View
49 node_modules/closure-compiler/lib/index.js
@@ -0,0 +1,49 @@
+var JAR_PATH, JAVA_PATH, OPTIONS, path, spawn;
+spawn = require('child_process').spawn;
+path = require('path');
+JAVA_PATH = exports.JAVA_PATH = 'java';
+JAR_PATH = exports.JAR_PATH = path.join(__dirname, 'vendor/compiler.jar');
+OPTIONS = exports.OPTIONS = {};
+exports.compile = function(input, options, callback) {
+ var args, compiler, result, stderr, stdout;
+ if (callback) {
+ result = {};
+ Object.keys(OPTIONS).forEach(function(key) {
+ return result[key] = OPTIONS[key];
+ });
+ Object.keys(options).forEach(function(key) {
+ return result[key] = options[key];
+ });
+ options = result;
+ } else {
+ callback = options;
+ options = OPTIONS;
+ }
+ args = ['-jar', JAR_PATH];
+ Object.keys(options).forEach(function(key) {
+ args.push("--" + key);
+ return args.push("" + options[key]);
+ });
+ compiler = spawn(JAVA_PATH, args);
+ stdout = '';
+ stderr = '';
+ compiler.stdout.setEncoding('utf8');
+ compiler.stderr.setEncoding('utf8');
+ compiler.stdout.on('data', function(data) {
+ return stdout += data;
+ });
+ compiler.stderr.on('data', function(data) {
+ return stderr += data;
+ });
+ compiler.on('exit', function(code) {
+ var error;
+ if (code !== 0) {
+ error = new Error(stderr);
+ error.code = code;
+ } else {
+ error = null;
+ }
+ return callback(error, stdout);
+ });
+ return compiler.stdin.end(input);
+};
View
BIN  node_modules/closure-compiler/lib/vendor/compiler.jar
Binary file not shown
View
31 node_modules/closure-compiler/package.json
@@ -0,0 +1,31 @@
+{
+ "name": "closure-compiler",
+ "description": "Bindings to Google's Closure Compiler",
+ "version": "0.1.2",
+ "author": {
+ "name": "Tim-Smart"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/Tim-Smart/node-closure.git"
+ },
+ "engine": [
+ "node >=0.4"
+ ],
+ "main": "./lib",
+ "_id": "closure-compiler@0.1.2",
+ "dependencies": {},
+ "devDependencies": {},
+ "optionalDependencies": {},
+ "engines": {
+ "node": "*"
+ },
+ "_engineSupported": true,
+ "_npmVersion": "1.1.24",
+ "_nodeVersion": "v0.6.19",
+ "_defaultsLoaded": true,
+ "dist": {
+ "shasum": "631ae7b5be472d7ccd517ba8bc8b484f929be2fb"
+ },
+ "_from": "closure-compiler"
+}
View
69 node_modules/closure-compiler/src/index.coffee
@@ -0,0 +1,69 @@
+# The MIT License
+#
+# Copyright (c) 2011 Tim Smart
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files
+# (the "Software"), to deal in the Software without restriction,
+# including without limitation the rights to use, copy, modify, merge,
+# publish, distribute, sublicense, and/or sell copies of the Software, and
+# to permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+spawn = require('child_process').spawn
+path = require 'path'
+
+JAVA_PATH = exports.JAVA_PATH = 'java'
+JAR_PATH = exports.JAR_PATH = path.join __dirname, 'vendor/compiler.jar'
+OPTIONS = exports.OPTIONS = {}
+
+exports.compile = (input, options, callback) ->
+ if callback
+ result = {}
+ Object.keys(OPTIONS).forEach (key) ->
+ result[key] = OPTIONS[key]
+ Object.keys(options).forEach (key) ->
+ result[key] = options[key]
+ options = result
+ else
+ callback = options
+ options = OPTIONS
+
+ args = ['-jar', JAR_PATH]
+
+ Object.keys(options).forEach (key) ->
+ args.push "--#{key}"
+ args.push "#{options[key]}"
+
+ compiler = spawn JAVA_PATH, args
+ stdout = ''
+ stderr = ''
+
+ compiler.stdout.setEncoding 'utf8'
+ compiler.stderr.setEncoding 'utf8'
+
+ compiler.stdout.on 'data', (data) ->
+ stdout += data
+
+ compiler.stderr.on 'data', (data) ->
+ stderr += data
+
+ compiler.on 'exit', (code) ->
+ if code isnt 0
+ error = new Error stderr
+ error.code = code
+ else error = null
+ callback error, stdout
+
+ compiler.stdin.end input
View
11 node_modules/coffee-script/.npmignore
@@ -0,0 +1,11 @@
+*.coffee
+*.html
+.DS_Store
+.git*
+Cakefile
+documentation/
+examples/
+extras/coffee-script.js
+raw/
+src/
+test/
View
1  node_modules/coffee-script/CNAME
@@ -0,0 +1 @@
+coffeescript.org
View
22 node_modules/coffee-script/LICENSE
@@ -0,0 +1,22 @@
+Copyright (c) 2009-2012 Jeremy Ashkenas
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
View
51 node_modules/coffee-script/README
@@ -0,0 +1,51 @@
+
+ {
+ } } {
+ { { } }
+ } }{ {
+ { }{ } } _____ __ __
+ ( }{ }{ { ) / ____| / _|/ _|
+ .- { { } { }} -. | | ___ | |_| |_ ___ ___
+ ( ( } { } { } } ) | | / _ \| _| _/ _ \/ _ \
+ |`-..________ ..-'| | |___| (_) | | | || __/ __/
+ | | \_____\___/|_| |_| \___|\___|
+ | ;--.
+ | (__ \ _____ _ _
+ | | ) ) / ____| (_) | |
+ | |/ / | (___ ___ _ __ _ _ __ | |_
+ | ( / \___ \ / __| '__| | '_ \| __|
+ | |/ ____) | (__| | | | |_) | |_
+ | | |_____/ \___|_| |_| .__/ \__|
+ `-.._________..-' | |
+ |_|
+
+
+ CoffeeScript is a little language that compiles into JavaScript.
+
+ Install Node.js, and then the CoffeeScript compiler:
+ sudo bin/cake install
+
+ Or, if you have the Node Package Manager installed:
+ npm install -g coffee-script
+ (Leave off the -g if you don't wish to install globally.)
+
+ Execute a script:
+ coffee /path/to/script.coffee
+
+ Compile a script:
+ coffee -c /path/to/script.coffee
+
+ For documentation, usage, and examples, see:
+ http://coffeescript.org/
+
+ To suggest a feature, report a bug, or general discussion:
+ http://github.com/jashkenas/coffee-script/issues/
+
+ If you'd like to chat, drop by #coffeescript on Freenode IRC,
+ or on webchat.freenode.net.
+
+ The source repository:
+ git://github.com/jashkenas/coffee-script.git
+
+ All contributors are listed here:
+ http://github.com/jashkenas/coffee-script/contributors
View
78 node_modules/coffee-script/Rakefile
@@ -0,0 +1,78 @@
+require 'rubygems'
+require 'erb'
+require 'fileutils'
+require 'rake/testtask'
+require 'json'
+
+desc "Build the documentation page"
+task :doc do
+ source = 'documentation/index.html.erb'
+ child = fork { exec "bin/coffee -bcw -o documentation/js documentation/coffee/*.coffee" }
+ at_exit { Process.kill("INT", child) }
+ Signal.trap("INT") { exit }
+ loop do
+ mtime = File.stat(source).mtime
+ if !@mtime || mtime > @mtime
+ rendered = ERB.new(File.read(source)).result(binding)
+ File.open('index.html', 'w+') {|f| f.write(rendered) }
+ end
+ @mtime = mtime
+ sleep 1
+ end
+end
+
+desc "Build coffee-script-source gem"
+task :gem do
+ require 'rubygems'
+ require 'rubygems/package'
+
+ gemspec = Gem::Specification.new do |s|
+ s.name = 'coffee-script-source'
+ s.version = JSON.parse(File.read('package.json'))["version"]
+ s.date = Time.now.strftime("%Y-%m-%d")
+
+ s.homepage = "http://jashkenas.github.com/coffee-script/"
+ s.summary = "The CoffeeScript Compiler"
+ s.description = <<-EOS
+ CoffeeScript is a little language that compiles into JavaScript.
+ Underneath all of those embarrassing braces and semicolons,
+ JavaScript has always had a gorgeous object model at its heart.
+ CoffeeScript is an attempt to expose the good parts of JavaScript
+ in a simple way.
+ EOS
+
+ s.files = [
+ 'lib/coffee_script/coffee-script.js',
+ 'lib/coffee_script/source.rb'
+ ]
+
+ s.authors = ['Jeremy Ashkenas']
+ s.email = 'jashkenas@gmail.com'
+ s.rubyforge_project = 'coffee-script-source'
+ end
+
+ file = File.open("coffee-script-source.gem", "w")
+ Gem::Package.open(file, 'w') do |pkg|
+ pkg.metadata = gemspec.to_yaml
+
+ path = "lib/coffee_script/source.rb"
+ contents = <<-ERUBY
+module CoffeeScript
+ module Source
+ def self.bundled_path
+ File.expand_path("../coffee-script.js", __FILE__)
+ end
+ end
+end
+ ERUBY
+ pkg.add_file_simple(path, 0644, contents.size) do |tar_io|
+ tar_io.write(contents)
+ end
+
+ contents = File.read("extras/coffee-script.js")
+ path = "lib/coffee_script/coffee-script.js"
+ pkg.add_file_simple(path, 0644, contents.size) do |tar_io|
+ tar_io.write(contents)
+ end
+ end
+end
View
7 node_modules/coffee-script/bin/cake
@@ -0,0 +1,7 @@
+#!/usr/bin/env node
+
+var path = require('path');
+var fs = require('fs');
+var lib = path.join(path.dirname(fs.realpathSync(__filename)), '../lib');
+
+require(lib + '/coffee-script/cake').run();
View
7 node_modules/coffee-script/bin/coffee
@@ -0,0 +1,7 @@
+#!/usr/bin/env node
+
+var path = require('path');
+var fs = require('fs');
+var lib = path.join(path.dirname(fs.realpathSync(__filename)), '../lib');
+
+require(lib + '/coffee-script/command').run();
View
44 node_modules/coffee-script/extras/jsl.conf
@@ -0,0 +1,44 @@
+# JavaScriptLint configuration file for CoffeeScript.
+
++no_return_value # function {0} does not always return a value
++duplicate_formal # duplicate formal argument {0}
+-equal_as_assign # test for equality (==) mistyped as assignment (=)?{0}
++var_hides_arg # variable {0} hides argument
++redeclared_var # redeclaration of {0} {1}
+-anon_no_return_value # anonymous function does not always return a value
++missing_semicolon # missing semicolon
++meaningless_block # meaningless block; curly braces have no impact
+-comma_separated_stmts # multiple statements separated by commas (use semicolons?)
++unreachable_code # unreachable code
++missing_break # missing break statement
+-missing_break_for_last_case # missing break statement for last case in switch
+-comparison_type_conv # comparisons against null, 0, true, false, or an empty string allowing implicit type conversion (use === or !==)
+-inc_dec_within_stmt # increment (++) and decrement (--) operators used as part of greater statement
+-useless_void # use of the void type may be unnecessary (void is always undefined)
++multiple_plus_minus # unknown order of operations for successive plus (e.g. x+++y) or minus (e.g. x---y) signs
++use_of_label # use of label
+-block_without_braces # block statement without curly braces
++leading_decimal_point # leading decimal point may indicate a number or an object member
++trailing_decimal_point # trailing decimal point may indicate a number or an object member
++octal_number # leading zeros make an octal number
++nested_comment # nested comment
++misplaced_regex # regular expressions should be preceded by a left parenthesis, assignment, colon, or comma
++ambiguous_newline # unexpected end of line; it is ambiguous whether these lines are part of the same statement
++empty_statement # empty statement or extra semicolon
+-missing_option_explicit # the "option explicit" control comment is missing
++partial_option_explicit # the "option explicit" control comment, if used, must be in the first script tag
++dup_option_explicit # duplicate "option explicit" control comment
++useless_assign # useless assignment
++ambiguous_nested_stmt # block statements containing block statements should use curly braces to resolve ambiguity
++ambiguous_else_stmt # the else statement could be matched with one of multiple if statements (use curly braces to indicate intent)
+-missing_default_case # missing default case in switch statement
++duplicate_case_in_switch # duplicate case in switch statements
++default_not_at_end # the default case is not at the end of the switch statement
++legacy_cc_not_understood # couldn't understand control comment using /*@keyword@*/ syntax
++jsl_cc_not_understood # couldn't understand control comment using /*jsl:keyword*/ syntax
++useless_comparison # useless comparison; comparing identical expressions
++with_statement # with statement hides undeclared variables; use temporary variable instead
++trailing_comma_in_array # extra comma is not recommended in array initializers
++assign_to_function_call # assignment to a function call
++parseint_missing_radix # parseInt missing radix parameter
++lambda_assign_requires_semicolon
View
92 node_modules/coffee-script/lib/coffee-script/browser.js
@@ -0,0 +1,92 @@
+// Generated by CoffeeScript 1.3.3
+(function() {
+ var CoffeeScript, runScripts;
+
+ CoffeeScript = require('./coffee-script');
+
+ CoffeeScript.require = require;
+
+ CoffeeScript["eval"] = function(code, options) {
+ var _ref;
+ if (options == null) {
+ options = {};
+ }
+ if ((_ref = options.bare) == null) {
+ options.bare = true;
+ }
+ return eval(CoffeeScript.compile(code, options));
+ };
+
+ CoffeeScript.run = function(code, options) {
+ if (options == null) {
+ options = {};
+ }
+ options.bare = true;
+ return Function(CoffeeScript.compile(code, options))();
+ };
+
+ if (typeof window === "undefined" || window === null) {
+ return;
+ }
+
+ CoffeeScript.load = function(url, callback) {
+ var xhr;
+ xhr = new (window.ActiveXObject || XMLHttpRequest)('Microsoft.XMLHTTP');
+ xhr.open('GET', url, true);
+ if ('overrideMimeType' in xhr) {
+ xhr.overrideMimeType('text/plain');
+ }
+ xhr.onreadystatechange = function() {
+ var _ref;
+ if (xhr.readyState === 4) {
+ if ((_ref = xhr.status) === 0 || _ref === 200) {
+ CoffeeScript.run(xhr.responseText);
+ } else {
+ throw new Error("Could not load " + url);
+ }
+ if (callback) {
+ return callback();
+ }
+ }
+ };
+ return xhr.send(null);
+ };
+
+ runScripts = function() {
+ var coffees, execute, index, length, s, scripts;
+ scripts = document.getElementsByTagName('script');
+ coffees = (function() {
+ var _i, _len, _results;
+ _results = [];
+ for (_i = 0, _len = scripts.length; _i < _len; _i++) {
+ s = scripts[_i];
+ if (s.type === 'text/coffeescript') {
+ _results.push(s);
+ }
+ }
+ return _results;
+ })();
+ index = 0;
+ length = coffees.length;
+ (execute = function() {
+ var script;
+ script = coffees[index++];
+ if ((script != null ? script.type : void 0) === 'text/coffeescript') {
+ if (script.src) {
+ return CoffeeScript.load(script.src, execute);
+ } else {
+ CoffeeScript.run(script.innerHTML);
+ return execute();
+ }
+ }
+ })();
+ return null;
+ };
+
+ if (window.addEventListener) {
+ addEventListener('DOMContentLoaded', runScripts, false);
+ } else {
+ attachEvent('onload', runScripts);
+ }
+
+}).call(this);
View
111 node_modules/coffee-script/lib/coffee-script/cake.js
@@ -0,0 +1,111 @@
+// Generated by CoffeeScript 1.3.3
+(function() {
+ var CoffeeScript, cakefileDirectory, fatalError, fs, helpers, missingTask, oparse, options, optparse, path, printTasks, switches, tasks;
+
+ fs = require('fs');
+
+ path = require('path');
+
+ helpers = require('./helpers');
+
+ optparse = require('./optparse');
+
+ CoffeeScript = require('./coffee-script');
+
+ tasks = {};
+
+ options = {};
+
+ switches = [];
+
+ oparse = null;
+
+ helpers.extend(global, {
+ task: function(name, description, action) {
+ var _ref;
+ if (!action) {
+ _ref = [description, action], action = _ref[0], description = _ref[1];
+ }
+ return tasks[name] = {
+ name: name,
+ description: description,
+ action: action
+ };
+ },
+ option: function(letter, flag, description) {
+ return switches.push([letter, flag, description]);
+ },
+ invoke: function(name) {
+ if (!tasks[name]) {
+ missingTask(name);
+ }
+ return tasks[name].action(options);
+ }
+ });
+
+ exports.run = function() {
+ var arg, args, _i, _len, _ref, _results;
+ global.__originalDirname = fs.realpathSync('.');
+ process.chdir(cakefileDirectory(__originalDirname));
+ args = process.argv.slice(2);
+ CoffeeScript.run(fs.readFileSync('Cakefile').toString(), {
+ filename: 'Cakefile'
+ });
+ oparse = new optparse.OptionParser(switches);
+ if (!args.length) {
+ return printTasks();
+ }
+ try {
+ options = oparse.parse(args);
+ } catch (e) {
+ return fatalError("" + e);
+ }
+ _ref = options["arguments"];
+ _results = [];
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
+ arg = _ref[_i];
+ _results.push(invoke(arg));
+ }
+ return _results;
+ };
+
+ printTasks = function() {
+ var cakefilePath, desc, name, relative, spaces, task;
+ relative = path.relative || path.resolve;
+ cakefilePath = path.join(relative(__originalDirname, process.cwd()), 'Cakefile');
+ console.log("" + cakefilePath + " defines the following tasks:\n");
+ for (name in tasks) {
+ task = tasks[name];
+ spaces = 20 - name.length;
+ spaces = spaces > 0 ? Array(spaces + 1).join(' ') : '';
+ desc = task.description ? "# " + task.description : '';
+ console.log("cake " + name + spaces + " " + desc);
+ }
+ if (switches.length) {
+ return console.log(oparse.help());
+ }
+ };
+
+ fatalError = function(message) {
+ console.error(message + '\n');
+ console.log('To see a list of all tasks/options, run "cake"');
+ return process.exit(1);
+ };
+
+ missingTask = function(task) {
+ return fatalError("No such task: " + task);
+ };
+
+ cakefileDirectory = function(dir) {
+ var parent;
+ if (path.existsSync(path.join(dir, 'Cakefile'))) {
+ return dir;
+ }
+ parent = path.normalize(path.join(dir, '..'));
+ if (parent !== dir) {
+ return cakefileDirectory(parent);
+ }
+ throw new Error("Cakefile not found in " + (process.cwd()));
+ };
+
+}).call(this);
View
167 node_modules/coffee-script/lib/coffee-script/coffee-script.js
@@ -0,0 +1,167 @@