From bae55c1eb82de607e3d32cfc229e869204250dd4 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 8 Nov 2013 11:00:46 +0000 Subject: [PATCH 001/315] docs(help) add "\n" --- HELP.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/HELP.md b/HELP.md index 78f7be4d..59f78baa 100644 --- a/HELP.md +++ b/HELP.md @@ -29,6 +29,7 @@ Cloud Commander v0.6.0 [![NPM version][NPMIMGURL]][NPMURL] [![Dependency Status] Benefits --------------- + - Open Source. - Has 2 classic ortodox panels. - Works on Windows, Linux and Mac OS. @@ -123,6 +124,7 @@ Menu [Demo](http://io.cloudcmd.io#/menu "Menu") ![Menu](/img/screen/menu.png "Menu") Right mouse click button shows context menu with items: + - View - Edit - Rename From 57987d0ea52ac488221bb7243ac8aca10964f9c1 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 8 Nov 2013 11:01:54 +0000 Subject: [PATCH 002/315] docs(help) rm double menu --- HELP.md | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/HELP.md b/HELP.md index 59f78baa..a3e0ee2e 100644 --- a/HELP.md +++ b/HELP.md @@ -139,18 +139,6 @@ Right mouse click button shows context menu with items: - **F9** - open - **Esc** - close -Menu ---------------- -Right mouse click button shows context menu with items: - -- View -- Edit -- Rename -- Delete -- Upload to (Dropbox, Github, GDrive) -- Download -- New (File, Dir, from cloud) - Configuration --------------- All main configuration could be done via [config.json](json/config.json "Config"). From ecbdb1b13970f1d66c1211d938468d9514477b17 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 8 Nov 2013 15:06:20 +0200 Subject: [PATCH 003/315] docs(help) writed -> wrote --- HELP.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/HELP.md b/HELP.md index a3e0ee2e..6e009b41 100644 --- a/HELP.md +++ b/HELP.md @@ -35,7 +35,7 @@ Benefits - Works on Windows, Linux and Mac OS. - Could be used local or remotly. - Has nice console and editor. -- Writed on JavaScript/Node.js. +- Wrote on JavaScript/Node.js. Install --------------- From 7414b84ea525fd80ba3f3dead5ada7a6f5a34543 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 8 Nov 2013 16:17:51 +0200 Subject: [PATCH 004/315] docs(help) add " " --- HELP.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/HELP.md b/HELP.md index 6e009b41..cc4978b3 100644 --- a/HELP.md +++ b/HELP.md @@ -149,7 +149,7 @@ All main configuration could be done via [config.json](json/config.json "Config" "appcache" : false, /* cache files for offline use */ "analytics" : true, /* google analytics suport */ "localStorage" : true, /* cache directory data */ - "minify" : true /* minification of js,css,html and img */ + "minify" : true /* minification of js,css,html and img */ "online" : true, /* load js files from cdn or local path */ "cache" : true, /* add cache-control */ "logs" : false, /* logs or console ouput */ From 6d9d26dcb7f9714962d15939f5bfaf62442e0fde Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 11 Nov 2013 08:28:29 +0000 Subject: [PATCH 005/315] refactor(cloudcmd) processCommanderContent: mv error condition to top --- cloudcmd.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cloudcmd.js b/cloudcmd.js index 2bebe41e..6b4b75fe 100644 --- a/cloudcmd.js +++ b/cloudcmd.js @@ -238,7 +238,9 @@ if (lRet) { var p = pParams; main.commander.getDirContent(p.name, function(pError, pJSON) { - if (!pError) { + if (pError) + main.sendError(pParams, pError); + else { var lQuery = main.getQuery(p.request); if ( Util.isContainStr(lQuery, 'json') ) { p.data = Util.stringifyJSON(pJSON); @@ -248,7 +250,9 @@ else{ /* get back html*/ p.name = Minify.allowed ? Minify.getName(INDEX) : INDEX; fs.readFile(p.name, function(pError, pData) { - if (!pError) { + if (pError) + main.sendError(pParams, pError); + else { var lPanel = CloudFunc.buildFromJSON(pJSON, FileTemplate, PathTemplate), lList = '
    ' + lPanel + '
' + ''; @@ -258,13 +262,9 @@ data : pData.toString(), }), true); } - else - main.sendError(pParams, pError); }); } } - else - main.sendError(pParams, pError); }); } } From 1fa66525e219d88810b4810bb34d47dd6053017a Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 11 Nov 2013 08:35:34 +0000 Subject: [PATCH 006/315] refactor(cloudcmd) processCommanderContent --- cloudcmd.js | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/cloudcmd.js b/cloudcmd.js index 6b4b75fe..ecfbe74b 100644 --- a/cloudcmd.js +++ b/cloudcmd.js @@ -233,16 +233,21 @@ } function processCommanderContent(pParams) { - var lRet = main.checkParams(pParams); + var p, + lRet = main.checkParams(pParams); if (lRet) { - var p = pParams; + p = pParams; main.commander.getDirContent(p.name, function(pError, pJSON) { + var lQuery, isJSON; + if (pError) main.sendError(pParams, pError); else { - var lQuery = main.getQuery(p.request); - if ( Util.isContainStr(lQuery, 'json') ) { + lQuery = main.getQuery(p.request); + isJSON = Util.isContainStr(lQuery, 'json'); + + if (isJSON) { p.data = Util.stringifyJSON(pJSON); p.name +='.json'; main.sendResponse(p, null, true); @@ -250,12 +255,14 @@ else{ /* get back html*/ p.name = Minify.allowed ? Minify.getName(INDEX) : INDEX; fs.readFile(p.name, function(pError, pData) { + var lPanel, lList; + if (pError) main.sendError(pParams, pError); else { - var lPanel = CloudFunc.buildFromJSON(pJSON, FileTemplate, PathTemplate), - lList = '
    ' + lPanel + '
' + - ''; + lPanel = CloudFunc.buildFromJSON(pJSON, FileTemplate, PathTemplate), + lList = '
    ' + lPanel + '
' + + ''; main.sendResponse(p, indexProcessing({ additional : lList, From b80cccad6a9811694e2f6aeb8288c83a51f2d664 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 11 Nov 2013 08:38:13 +0000 Subject: [PATCH 007/315] refactor(cloudcmd) sendCommanderContent -> sendContent --- cloudcmd.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cloudcmd.js b/cloudcmd.js index ecfbe74b..a948554f 100644 --- a/cloudcmd.js +++ b/cloudcmd.js @@ -202,7 +202,7 @@ lRet = main.sendFile( pParams ); } else if ( Util.isContainStrAtBegin(p.name, FS) || Util.strCmp( p.name, '/') ) - lRet = sendCommanderContent( pParams ); + lRet = sendContent( pParams ); else lRet = false; @@ -211,7 +211,7 @@ return lRet; } - function sendCommanderContent(pParams) { + function sendContent(pParams) { var p, lRet = main.checkParams(pParams); if (lRet) { From 4e4e77d22e93d79915a1f3410b0e9d46f389cf1f Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 11 Nov 2013 08:39:06 +0000 Subject: [PATCH 008/315] refactor(cloudcmd) processCommanderContent -> processContent --- cloudcmd.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cloudcmd.js b/cloudcmd.js index a948554f..8d024661 100644 --- a/cloudcmd.js +++ b/cloudcmd.js @@ -221,7 +221,7 @@ fs.stat(p.name, function(pError, pStat) { if (!pError) if ( pStat.isDirectory() ) - processCommanderContent(pParams); + processContent(pParams); else main.sendFile( pParams ); else @@ -232,7 +232,7 @@ return lRet; } - function processCommanderContent(pParams) { + function processContent(pParams) { var p, lRet = main.checkParams(pParams); From ceb0dea179886eb8a4cbc7e5d6d9eb1b5b00ef9e Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 11 Nov 2013 08:45:07 +0000 Subject: [PATCH 009/315] chore(main) add " " --- lib/server/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/server/main.js b/lib/server/main.js index df3f02ac..10106b8d 100644 --- a/lib/server/main.js +++ b/lib/server/main.js @@ -368,7 +368,7 @@ if (!p.error) lParams.data = p.data; - else{ + else { lParams.status = FILE_NOT_FOUND; lParams.data = p.error.toString(); } From 0507647b76fd962ec0018b62a714e49516b6c2ea Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 11 Nov 2013 08:46:25 +0000 Subject: [PATCH 010/315] refactor(main) mv var to top --- lib/server/main.js | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/lib/server/main.js b/lib/server/main.js index 10106b8d..06acb706 100644 --- a/lib/server/main.js +++ b/lib/server/main.js @@ -170,7 +170,7 @@ console.log(pVolumes); exports.VOLUMES = pVolumes; }); - + return lRet; } @@ -270,19 +270,20 @@ * @param pName - имя отсылаемого файла */ function sendResponse(pParams, pData, pNotLog) { - var lRet = checkParams(pParams); + var p, lQuery, lGzip, lHead, + lRet = checkParams(pParams); if (lRet) { - var p = pParams, - lQuery = getQuery(p.request), - /* download, json */ - lGzip = isGZIP(p.request), - lHead = generateHeaders({ - name : p.name, - cache : p.cache, - gzip : lGzip, - query : lQuery - }); + p = pParams, + lQuery = getQuery(p.request), + /* download, json */ + lGzip = isGZIP(p.request), + lHead = generateHeaders({ + name : p.name, + cache : p.cache, + gzip : lGzip, + query : lQuery + }); setHeader(lHead, p.response); From e3bf9a62b42fa1d7129db508a6e72774794e9dd4 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 11 Nov 2013 09:41:11 +0000 Subject: [PATCH 011/315] chore(cloudcmd) Minify.allowed -> minify --- cloudcmd.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cloudcmd.js b/cloudcmd.js index 8d024661..1b1b6612 100644 --- a/cloudcmd.js +++ b/cloudcmd.js @@ -239,7 +239,9 @@ if (lRet) { p = pParams; main.commander.getDirContent(p.name, function(pError, pJSON) { - var lQuery, isJSON; + var lQuery, isJSON, + config = main.config, + minify = config.minify; if (pError) main.sendError(pParams, pError); @@ -253,7 +255,7 @@ main.sendResponse(p, null, true); } else{ /* get back html*/ - p.name = Minify.allowed ? Minify.getName(INDEX) : INDEX; + p.name = minify ? Minify.getName(INDEX) : INDEX; fs.readFile(p.name, function(pError, pData) { var lPanel, lList; From 49d2caf57e736ae0a7c562e9643eb6d9162a78a3 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 11 Nov 2013 09:45:02 +0000 Subject: [PATCH 012/315] chore(cloudcmd) rm " " --- cloudcmd.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cloudcmd.js b/cloudcmd.js index 1b1b6612..dca5b3c0 100644 --- a/cloudcmd.js +++ b/cloudcmd.js @@ -149,7 +149,7 @@ if (pErrors) Util.log(pErrors); else { - FileTemplate = pFiles[FILE_TMPL].toString(); + FileTemplate = pFiles[FILE_TMPL].toString(); PathTemplate = pFiles[PATH_TMPL].toString(); if (Config.ssl) From 1a924fa40363a0ee4caf419d00375f2a899e7674 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 11 Nov 2013 09:55:10 +0000 Subject: [PATCH 013/315] fix(cloudcmd) mv index data to var --- cloudcmd.js | 37 +++++++++++++++---------------------- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/cloudcmd.js b/cloudcmd.js index dca5b3c0..97d16a5f 100644 --- a/cloudcmd.js +++ b/cloudcmd.js @@ -29,10 +29,10 @@ CERT = DIR + 'ssl/ssl.crt', FILE_TMPL = HTMLDIR + 'file.html', - PATH_TMPL = HTMLDIR + 'path.html', + INDEX_TMPL = HTMLDIR + 'index.html', - FileTemplate, PathTemplate, + FileTemplate, PathTemplate, IndexTemplate, FS = CloudFunc.FS; /* reinit main dir os if we on Win32 should be backslashes */ @@ -140,7 +140,7 @@ route : route }, - lFiles = [FILE_TMPL, PATH_TMPL]; + lFiles = [FILE_TMPL, PATH_TMPL, INDEX_TMPL]; if (Config.ssl) lFiles.push(CA, KEY, CERT); @@ -151,6 +151,7 @@ else { FileTemplate = pFiles[FILE_TMPL].toString(); PathTemplate = pFiles[PATH_TMPL].toString(); + IndexTemplate = pFiles[INDEX_TMPL].toString(); if (Config.ssl) lParams.ssl = { @@ -239,7 +240,7 @@ if (lRet) { p = pParams; main.commander.getDirContent(p.name, function(pError, pJSON) { - var lQuery, isJSON, + var lQuery, isJSON, lPanel, lList, config = main.config, minify = config.minify; @@ -254,24 +255,16 @@ p.name +='.json'; main.sendResponse(p, null, true); } - else{ /* get back html*/ - p.name = minify ? Minify.getName(INDEX) : INDEX; - fs.readFile(p.name, function(pError, pData) { - var lPanel, lList; - - if (pError) - main.sendError(pParams, pError); - else { - lPanel = CloudFunc.buildFromJSON(pJSON, FileTemplate, PathTemplate), - lList = '
    ' + lPanel + '
' + - ''; - - main.sendResponse(p, indexProcessing({ - additional : lList, - data : pData.toString(), - }), true); - } - }); + else { + p.name = INDEX, + lPanel = CloudFunc.buildFromJSON(pJSON, FileTemplate, PathTemplate), + lList = '
    ' + lPanel + '
' + + ''; + + main.sendResponse(p, indexProcessing({ + additional : lList, + data : IndexTemplate, + }), true); } } }); From 2c5254dc55473d58a73f50f4612496209dfee7d3 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 11 Nov 2013 10:00:32 +0000 Subject: [PATCH 014/315] refactor(main) console.log -> Util.log --- lib/server/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/server/main.js b/lib/server/main.js index 06acb706..7057bc75 100644 --- a/lib/server/main.js +++ b/lib/server/main.js @@ -167,7 +167,7 @@ if (ISWIN32) srvrequire('win').getVolumes(function(pVolumes) { - console.log(pVolumes); + Util.log(pVolumes); exports.VOLUMES = pVolumes; }); From f7f51e386cb29090584ee0806ce83d654302085d Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 11 Nov 2013 10:02:07 +0000 Subject: [PATCH 015/315] refactor(main) sendResponce: add data --- lib/server/main.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/server/main.js b/lib/server/main.js index 7057bc75..4b1b4aa7 100644 --- a/lib/server/main.js +++ b/lib/server/main.js @@ -275,6 +275,7 @@ if (lRet) { p = pParams, + data = p.data || pData, lQuery = getQuery(p.request), /* download, json */ lGzip = isGZIP(p.request), @@ -288,7 +289,7 @@ setHeader(lHead, p.response); if (!pNotLog) - Util.log(pData || p.data); + Util.log(data); /* если браузер поддерживает gzip-сжатие - сжимаем данные*/ Util.ifExec(!lGzip, @@ -305,7 +306,7 @@ }, function(pCallBack) { - zlib.gzip (p.data || pData, Util.call(gzipData, { + zlib.gzip (data, Util.call(gzipData, { callback : pCallBack })); }); From cdc6770f862195a0bfff05e6f34a032c2073f37f Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 11 Nov 2013 10:22:28 +0000 Subject: [PATCH 016/315] chore(main) "," -> ";" --- lib/server/main.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/server/main.js b/lib/server/main.js index 4b1b4aa7..0a7340e2 100644 --- a/lib/server/main.js +++ b/lib/server/main.js @@ -270,15 +270,15 @@ * @param pName - имя отсылаемого файла */ function sendResponse(pParams, pData, pNotLog) { - var p, lQuery, lGzip, lHead, + var p, lQuery, lGzip, lHead, data, lRet = checkParams(pParams); if (lRet) { - p = pParams, - data = p.data || pData, - lQuery = getQuery(p.request), + p = pParams; + data = p.data || pData; + lQuery = getQuery(p.request); /* download, json */ - lGzip = isGZIP(p.request), + lGzip = isGZIP(p.request); lHead = generateHeaders({ name : p.name, cache : p.cache, From 5568529086485de8fea4cbd0d9403d37e40b513a Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 11 Nov 2013 12:22:40 +0000 Subject: [PATCH 017/315] chore(css) style: add " " --- css/style.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/css/style.css b/css/style.css index 4b585390..4d3233bf 100644 --- a/css/style.css +++ b/css/style.css @@ -162,7 +162,7 @@ body { background-position: 0 0; background-repeat: no-repeat; } -#fm{ +#fm { height: 90%; margin: 26px 26px 0 26px; } From 2719c82815f5340af25f362186801a01cc06ec7c Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 11 Nov 2013 12:33:32 +0000 Subject: [PATCH 018/315] refactor(client) getById("fm") -> getFM --- lib/client.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/client.js b/lib/client.js index bfc4ec53..68da33ba 100644 --- a/lib/client.js +++ b/lib/client.js @@ -276,7 +276,7 @@ var Util, DOM, CloudFunc, CloudCmd; } /* показываем элементы, которые будут работать только, если есть js */ - var lFM = DOM.getById('fm'); + var lFM = DOM.getFM(); lFM.className='localstorage'; CloudCmd.Key(); From 7ffa00b7c07df86f07d6cfa3e01d82cf3109390f Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 11 Nov 2013 12:35:21 +0000 Subject: [PATCH 019/315] feature(index) rm no-js --- html/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/html/index.html b/html/index.html index c2596d49..85c32da3 100644 --- a/html/index.html +++ b/html/index.html @@ -15,7 +15,7 @@ -
{{ fm }}
+
{{ fm }}
From 1d58d6beefbc834ec194eabd92d199141f16331e Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 11 Nov 2013 12:36:49 +0000 Subject: [PATCH 020/315] refactor(client) rm className localstorage --- lib/client.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/client.js b/lib/client.js index 68da33ba..6dcdb299 100644 --- a/lib/client.js +++ b/lib/client.js @@ -277,7 +277,6 @@ var Util, DOM, CloudFunc, CloudCmd; /* показываем элементы, которые будут работать только, если есть js */ var lFM = DOM.getFM(); - lFM.className='localstorage'; CloudCmd.Key(); } From 770317852b5774dd6db1b8e5660579722691be0c Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 11 Nov 2013 12:37:48 +0000 Subject: [PATCH 021/315] refactor(style) #fm -> .fm --- css/style.css | 4 ++-- html/index.html | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/css/style.css b/css/style.css index 4d3233bf..ff0977e5 100644 --- a/css/style.css +++ b/css/style.css @@ -31,7 +31,7 @@ body { background-color:white; } -#fm, #left>li, #right>li, .path, .fm-header, +.fm, #left>li, #right>li, .path, .fm-header, .mini-icon, .name, .size, .owner, .mode, #keyspanel, .cmd-button { -webkit-user-select : none; -moz-user-select : none; @@ -162,7 +162,7 @@ body { background-position: 0 0; background-repeat: no-repeat; } -#fm { +.fm { height: 90%; margin: 26px 26px 0 26px; } diff --git a/html/index.html b/html/index.html index 85c32da3..0870f6b1 100644 --- a/html/index.html +++ b/html/index.html @@ -15,7 +15,7 @@ -
{{ fm }}
+
{{ fm }}
From 4b01334d1dcc1659d9f7397303712531cade4ed0 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 11 Nov 2013 12:49:22 +0000 Subject: [PATCH 022/315] refactor(css) style: #keyspanel -> .keyspanel --- cloudcmd.js | 4 ++-- css/style.css | 4 ++-- html/index.html | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cloudcmd.js b/cloudcmd.js index 97d16a5f..b0e5d0f6 100644 --- a/cloudcmd.js +++ b/cloudcmd.js @@ -58,8 +58,8 @@ ]); if (!Config.show_keys_panel) { - lKeysPanel = '
li, #right>li, .path, .fm-header, -.mini-icon, .name, .size, .owner, .mode, #keyspanel, .cmd-button { +.mini-icon, .name, .size, .owner, .mode, .keyspanel, .cmd-button { -webkit-user-select : none; -moz-user-select : none; -ms-user-select : none; @@ -200,7 +200,7 @@ body { border-color: rgba(254, 159, 224, .40); } -#keyspanel { +.keyspanel { text-align: center; } diff --git a/html/index.html b/html/index.html index 0870f6b1..dc82a90e 100644 --- a/html/index.html +++ b/html/index.html @@ -16,7 +16,7 @@
{{ fm }}
-
+
From b524149b1d0b12ff418c527b87521d5fde2f2e17 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 11 Nov 2013 12:54:56 +0000 Subject: [PATCH 023/315] refactor(config) show_keys_panel -> showKeysPanel --- HELP.md | 2 +- cloudcmd.js | 2 +- html/config.html | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/HELP.md b/HELP.md index cc4978b3..f9c49858 100644 --- a/HELP.md +++ b/HELP.md @@ -153,7 +153,7 @@ All main configuration could be done via [config.json](json/config.json "Config" "online" : true, /* load js files from cdn or local path */ "cache" : true, /* add cache-control */ "logs" : false, /* logs or console ouput */ - "show_keys_panel" : true, /* show classic panel with buttons of keys */ + "showKeysPanel" : true, /* show classic panel with buttons of keys */ "server" : true, /* server mode or testing mode */ "socket" : true /* enable web sockets */ "port" : 8000, /* http port or null(default) */ diff --git a/cloudcmd.js b/cloudcmd.js index b0e5d0f6..d0e7c997 100644 --- a/cloudcmd.js +++ b/cloudcmd.js @@ -57,7 +57,7 @@ ' manifest="/cloudcmd.appcache"' ]); - if (!Config.show_keys_panel) { + if (!Config.showKeysPanel) { lKeysPanel = '
  • -
  • +
  • From 4cf38c57b80c887cb79825078048fea2ff6dc116 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 11 Nov 2013 13:05:42 +0000 Subject: [PATCH 024/315] feature(config) show_keys_panel -> showKeysPanel --- json/config.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/json/config.json b/json/config.json index feeb326b..04f5e7e8 100644 --- a/json/config.json +++ b/json/config.json @@ -7,7 +7,7 @@ "online": true, "cache": true, "logs": false, - "show_keys_panel": true, + "showKeysPanel": true, "server": true, "socket": true, "port": 8000, From 34f2ed73383e0768d973b276b74e740bae54f209 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 11 Nov 2013 13:07:52 +0000 Subject: [PATCH 025/315] feature(config) api_url -> apiURL --- json/config.json | 2 +- lib/client/dom.js | 2 +- lib/server/rest.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/json/config.json b/json/config.json index 04f5e7e8..91ab8dd8 100644 --- a/json/config.json +++ b/json/config.json @@ -1,5 +1,5 @@ { - "api_url": "/api/v1", + "apiURL": "/api/v1", "appcache": false, "analytics": true, "localStorage": true, diff --git a/lib/client/dom.js b/lib/client/dom.js index c22ee5e1..dd335878 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -211,7 +211,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; else lData = p.data; - p.url = pConfig && pConfig.api_url + p.url, + p.url = pConfig && pConfig.apiURL + p.url, Loader.ajax({ method : p.method, url : p.url, diff --git a/lib/server/rest.js b/lib/server/rest.js index 14a3f0f1..3d0b73de 100644 --- a/lib/server/rest.js +++ b/lib/server/rest.js @@ -36,7 +36,7 @@ var lRet = main.checkParams(pParams); if (lRet) { - var lAPIURL = main.config.api_url, + var lAPIURL = main.config.apiURL, p = pParams; lRet = Util.isContainStr(p.name, lAPIURL); From c91187fed55beb6ec573a434a2bd55a3a2c544d3 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 11 Nov 2013 13:10:59 +0000 Subject: [PATCH 026/315] feature(config) appcache -> appCache --- HELP.md | 2 +- cloudcmd.js | 2 +- json/config.json | 2 +- lib/client/listeners.js | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/HELP.md b/HELP.md index f9c49858..a0074a69 100644 --- a/HELP.md +++ b/HELP.md @@ -146,7 +146,7 @@ All main configuration could be done via [config.json](json/config.json "Config" ```js { "api_url" :"/api/v1", - "appcache" : false, /* cache files for offline use */ + "appCache" : false, /* cache files for offline use */ "analytics" : true, /* google analytics suport */ "localStorage" : true, /* cache directory data */ "minify" : true /* minification of js,css,html and img */ diff --git a/cloudcmd.js b/cloudcmd.js index d0e7c997..46b5912d 100644 --- a/cloudcmd.js +++ b/cloudcmd.js @@ -49,7 +49,7 @@ lData = pData.data, lAdditional = pData.additional; - if (!Config.appcache) + if (!Config.appCache) lData = Util.removeStr(lData, [ /* min */ ' manifest=/cloudcmd.appcache', diff --git a/json/config.json b/json/config.json index 91ab8dd8..bde9a007 100644 --- a/json/config.json +++ b/json/config.json @@ -1,6 +1,6 @@ { "apiURL": "/api/v1", - "appcache": false, + "appСache": false, "analytics": true, "localStorage": true, "minify": true, diff --git a/lib/client/listeners.js b/lib/client/listeners.js index 72cb59db..7a05b36b 100644 --- a/lib/client/listeners.js +++ b/lib/client/listeners.js @@ -193,7 +193,7 @@ var Util, DOM, CloudCmd; function appCache() { getConfig(function(config) { - var isAppCache = config.appcache, + var isAppCache = config.appCache, appCache = window.applicationCache; if (isAppCache && appCache) From 6d765e380937efe5fe77d1f306bf8e3bef4d0739 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 11 Nov 2013 13:11:23 +0000 Subject: [PATCH 027/315] feature(config) api_url -> apiURL --- HELP.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/HELP.md b/HELP.md index a0074a69..b5c8de8a 100644 --- a/HELP.md +++ b/HELP.md @@ -145,7 +145,7 @@ All main configuration could be done via [config.json](json/config.json "Config" ```js { - "api_url" :"/api/v1", + "apiURL" :"/api/v1", "appCache" : false, /* cache files for offline use */ "analytics" : true, /* google analytics suport */ "localStorage" : true, /* cache directory data */ From 0296c226875f9442d573ce0da011f23df818895d Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 11 Nov 2013 13:14:57 +0000 Subject: [PATCH 028/315] feature(config) appcache -> appCache --- html/config.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/html/config.html b/html/config.html index d7c4aa73..aca28d82 100644 --- a/html/config.html +++ b/html/config.html @@ -1,6 +1,6 @@
      -
    • +
    • From ceb80b4533c66c3654d1ccef2761245c47758a4f Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 11 Nov 2013 15:09:33 +0000 Subject: [PATCH 029/315] chore(edit) add " " --- lib/client/edit.js | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/lib/client/edit.js b/lib/client/edit.js index 3d90ceb9..72eedd58 100644 --- a/lib/client/edit.js +++ b/lib/client/edit.js @@ -1,10 +1,10 @@ var CloudCmd, Util, DOM, CloudFunc, JsDiff, ace; -(function(CloudCmd, Util, DOM, CloudFunc){ +(function(CloudCmd, Util, DOM, CloudFunc) { 'use strict'; CloudCmd.Edit = new EditProto(CloudCmd, Util, DOM, CloudFunc); - function EditProto(CloudCmd, Util, DOM, CloudFunc){ + function EditProto(CloudCmd, Util, DOM, CloudFunc) { var Name = 'Edit', Loading = false, DIR = CloudCmd.LIBDIRCLIENT + 'edit/', @@ -62,14 +62,13 @@ var CloudCmd, Util, DOM, CloudFunc, JsDiff, ace; Ace.session.setOption('useWorker', lUseWorker); - if ( Util.isString(pValue) ) { + if (Util.isString(pValue)) { Ace.setValue(pValue); CloudCmd.View.show(Element, focus); Key.unsetBind(); - } - else { + } else { DOM.getCurrentData({ - success : function(pData){ + success : function(pData) { var lValue = ''; if (pData) @@ -84,7 +83,7 @@ var CloudCmd, Util, DOM, CloudFunc, JsDiff, ace; } }; - this.hide = function(){ + this.hide = function() { CloudCmd.View.hide(); }; @@ -126,7 +125,7 @@ var CloudCmd, Util, DOM, CloudFunc, JsDiff, ace; }); } - function load(pCallBack){ + function load(pCallBack) { Util.time(Name + ' load'); var lFiles = [ @@ -134,14 +133,14 @@ var CloudCmd, Util, DOM, CloudFunc, JsDiff, ace; DIR + 'ace.js', ]; - DOM.anyLoadOnLoad(lFiles, function(){ + DOM.anyLoadOnLoad(lFiles, function() { Util.timeEnd(Name + ' load'); Loading = false; Util.exec(pCallBack); }); } - function listener(pEvent){ + function listener(pEvent) { var lF4, lKey, lIsBind = Key.isBind(); if (lIsBind) { From 609799c490c0ab7f27a92db3da0484abcf0de34a Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 12 Nov 2013 08:43:38 +0000 Subject: [PATCH 030/315] feature(reset) sendMsg: add status --- lib/server/rest.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/server/rest.js b/lib/server/rest.js index 3d0b73de..23cd84bc 100644 --- a/lib/server/rest.js +++ b/lib/server/rest.js @@ -398,8 +398,8 @@ }); } - function sendMsg(pParams, pMsg, pName) { - var msg = CloudFunc.formatMsg(pMsg, pName); + function sendMsg(pParams, pMsg, pName, pStatus) { + var msg = CloudFunc.formatMsg(pMsg, pName, pStatus); sendResponse(pParams, msg); } From d5be099df56cff5512eacd4b1b1e944877ff3d39 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 12 Nov 2013 08:46:33 +0000 Subject: [PATCH 031/315] refactor(commander) checkParams --- lib/server/commander.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/server/commander.js b/lib/server/commander.js index c2a50924..2189a27e 100644 --- a/lib/server/commander.js +++ b/lib/server/commander.js @@ -12,7 +12,8 @@ var main = global.cloudcmd.main, fs = main.fs, - Util = main.util; + Util = main.util, + checkParams = main.checkCallBackParams; exports.getDirContent = function(pPath, pCallBack) { var lRet = Util.isString(pPath); @@ -155,10 +156,6 @@ } } - function checkParams(pParams) { - return Util.checkObj(pParams, ['error', 'data', 'params']); - } - function getDirPath(pPath) { var lRet = pPath; From 21b3756b6ec845f52a6f48bc1eadc0443f6c7c8f Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 12 Nov 2013 10:21:39 +0000 Subject: [PATCH 032/315] feature(diff) add --- HELP.md | 1 + html/config.html | 1 + lib/client/edit.js | 43 +- lib/diff.js | 21 + lib/diff/diff-match-patch.js | 2193 ++++++++++++++++++++++++++++++++++ lib/server/main.js | 5 +- lib/server/rest.js | 50 +- 7 files changed, 2309 insertions(+), 5 deletions(-) create mode 100644 lib/diff.js create mode 100644 lib/diff/diff-match-patch.js diff --git a/HELP.md b/HELP.md index b5c8de8a..8fec6ed4 100644 --- a/HELP.md +++ b/HELP.md @@ -148,6 +148,7 @@ All main configuration could be done via [config.json](json/config.json "Config" "apiURL" :"/api/v1", "appCache" : false, /* cache files for offline use */ "analytics" : true, /* google analytics suport */ + "diff" : false, /* when save - send patch not whole file */ "localStorage" : true, /* cache directory data */ "minify" : true /* minification of js,css,html and img */ "online" : true, /* load js files from cdn or local path */ diff --git a/html/config.html b/html/config.html index aca28d82..ebf91524 100644 --- a/html/config.html +++ b/html/config.html @@ -2,6 +2,7 @@
      • +
      • diff --git a/lib/client/edit.js b/lib/client/edit.js index 72eedd58..5642c08d 100644 --- a/lib/client/edit.js +++ b/lib/client/edit.js @@ -1,4 +1,4 @@ -var CloudCmd, Util, DOM, CloudFunc, JsDiff, ace; +var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch; (function(CloudCmd, Util, DOM, CloudFunc) { 'use strict'; @@ -7,9 +7,11 @@ var CloudCmd, Util, DOM, CloudFunc, JsDiff, ace; function EditProto(CloudCmd, Util, DOM, CloudFunc) { var Name = 'Edit', Loading = false, - DIR = CloudCmd.LIBDIRCLIENT + 'edit/', + DIR = CloudCmd.LIBDIRCLIENT + 'edit/', + LIBDIR = CloudCmd.LIBDIR, Value, Edit = this, + Diff, Ace, Msg, Key = CloudCmd.Key, @@ -120,11 +122,46 @@ var CloudCmd, Util, DOM, CloudFunc, JsDiff, ace; var lPath = DOM.getCurrentPath(), lValue = Ace.getValue(); - DOM.RESTful.save(lPath, lValue, Edit.showMessage); + CloudCmd.getConfig(function(config) { + var isDiff = config.diff; + + Util.ifExec(!isDiff, function(patch) { + var query; + + if (Util.isString(patch)) { + lValue = patch; + query = '?patch'; + } + + DOM.RESTful.save(lPath, lValue, Edit.showMessage, query); + }, function(callback) { + diff(lValue, function(diff) { + Util.exec(callback, diff); + }); + }); + }); } }); } + function diff(pNewValue, pCallBack) { + var libs = [ + LIBDIR + 'diff.js', + LIBDIR + 'diff/diff-match-patch.js' + ]; + + DOM.anyLoadInParallel(libs, function() { + var patch; + + if (!Diff) + Diff = new DiffProto(diff_match_patch); + + patch = Diff.createPatch(Value, pNewValue); + + Util.exec(pCallBack, patch); + }); + } + function load(pCallBack) { Util.time(Name + ' load'); diff --git a/lib/diff.js b/lib/diff.js new file mode 100644 index 00000000..ce3bf1ac --- /dev/null +++ b/lib/diff.js @@ -0,0 +1,21 @@ +(function (obj) { + obj.DiffProto = function(diffMatchPatch) { + var dmp = new diffMatchPatch(); + + this.createPatch = function(oldText, newText) { + var diff = dmp.diff_main(oldText, newText), + patchList = dmp.patch_make(oldText, newText, diff), + patch = dmp.patch_toText(patchList); + + return patch; + }; + + this.applyPatch = function(oldText, patch) { + var patches = dmp.patch_fromText(patch), + results = dmp.patch_apply(patches, oldText); + + return results; + }; + }; +})(this); + diff --git a/lib/diff/diff-match-patch.js b/lib/diff/diff-match-patch.js new file mode 100644 index 00000000..75b18e03 --- /dev/null +++ b/lib/diff/diff-match-patch.js @@ -0,0 +1,2193 @@ +/** + * Diff Match and Patch + * + * Copyright 2006 Google Inc. + * http://code.google.com/p/google-diff-match-patch/ + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @fileoverview Computes the difference between two texts to create a patch. + * Applies the patch onto another text, allowing for errors. + * @author fraser@google.com (Neil Fraser) + */ + +/** + * Class containing the diff, match and patch methods. + * @constructor + */ +function diff_match_patch() { + + // Defaults. + // Redefine these in your program to override the defaults. + + // Number of seconds to map a diff before giving up (0 for infinity). + this.Diff_Timeout = 1.0; + // Cost of an empty edit operation in terms of edit characters. + this.Diff_EditCost = 4; + // At what point is no match declared (0.0 = perfection, 1.0 = very loose). + this.Match_Threshold = 0.5; + // How far to search for a match (0 = exact location, 1000+ = broad match). + // A match this many characters away from the expected location will add + // 1.0 to the score (0.0 is a perfect match). + this.Match_Distance = 1000; + // When deleting a large block of text (over ~64 characters), how close do + // the contents have to be to match the expected contents. (0.0 = perfection, + // 1.0 = very loose). Note that Match_Threshold controls how closely the + // end points of a delete need to match. + this.Patch_DeleteThreshold = 0.5; + // Chunk size for context length. + this.Patch_Margin = 4; + + // The number of bits in an int. + this.Match_MaxBits = 32; +} + + +// DIFF FUNCTIONS + + +/** + * The data structure representing a diff is an array of tuples: + * [[DIFF_DELETE, 'Hello'], [DIFF_INSERT, 'Goodbye'], [DIFF_EQUAL, ' world.']] + * which means: delete 'Hello', add 'Goodbye' and keep ' world.' + */ +var DIFF_DELETE = -1; +var DIFF_INSERT = 1; +var DIFF_EQUAL = 0; + +/** @typedef {{0: number, 1: string}} */ +diff_match_patch.Diff; + + +/** + * Find the differences between two texts. Simplifies the problem by stripping + * any common prefix or suffix off the texts before diffing. + * @param {string} text1 Old string to be diffed. + * @param {string} text2 New string to be diffed. + * @param {boolean=} opt_checklines Optional speedup flag. If present and false, + * then don't run a line-level diff first to identify the changed areas. + * Defaults to true, which does a faster, slightly less optimal diff. + * @param {number} opt_deadline Optional time when the diff should be complete + * by. Used internally for recursive calls. Users should set DiffTimeout + * instead. + * @return {!Array.} Array of diff tuples. + */ +diff_match_patch.prototype.diff_main = function(text1, text2, opt_checklines, + opt_deadline) { + // Set a deadline by which time the diff must be complete. + if (typeof opt_deadline == 'undefined') { + if (this.Diff_Timeout <= 0) { + opt_deadline = Number.MAX_VALUE; + } else { + opt_deadline = (new Date).getTime() + this.Diff_Timeout * 1000; + } + } + var deadline = opt_deadline; + + // Check for null inputs. + if (text1 == null || text2 == null) { + throw new Error('Null input. (diff_main)'); + } + + // Check for equality (speedup). + if (text1 == text2) { + if (text1) { + return [[DIFF_EQUAL, text1]]; + } + return []; + } + + if (typeof opt_checklines == 'undefined') { + opt_checklines = true; + } + var checklines = opt_checklines; + + // Trim off common prefix (speedup). + var commonlength = this.diff_commonPrefix(text1, text2); + var commonprefix = text1.substring(0, commonlength); + text1 = text1.substring(commonlength); + text2 = text2.substring(commonlength); + + // Trim off common suffix (speedup). + commonlength = this.diff_commonSuffix(text1, text2); + var commonsuffix = text1.substring(text1.length - commonlength); + text1 = text1.substring(0, text1.length - commonlength); + text2 = text2.substring(0, text2.length - commonlength); + + // Compute the diff on the middle block. + var diffs = this.diff_compute_(text1, text2, checklines, deadline); + + // Restore the prefix and suffix. + if (commonprefix) { + diffs.unshift([DIFF_EQUAL, commonprefix]); + } + if (commonsuffix) { + diffs.push([DIFF_EQUAL, commonsuffix]); + } + this.diff_cleanupMerge(diffs); + return diffs; +}; + + +/** + * Find the differences between two texts. Assumes that the texts do not + * have any common prefix or suffix. + * @param {string} text1 Old string to be diffed. + * @param {string} text2 New string to be diffed. + * @param {boolean} checklines Speedup flag. If false, then don't run a + * line-level diff first to identify the changed areas. + * If true, then run a faster, slightly less optimal diff. + * @param {number} deadline Time when the diff should be complete by. + * @return {!Array.} Array of diff tuples. + * @private + */ +diff_match_patch.prototype.diff_compute_ = function(text1, text2, checklines, + deadline) { + var diffs; + + if (!text1) { + // Just add some text (speedup). + return [[DIFF_INSERT, text2]]; + } + + if (!text2) { + // Just delete some text (speedup). + return [[DIFF_DELETE, text1]]; + } + + var longtext = text1.length > text2.length ? text1 : text2; + var shorttext = text1.length > text2.length ? text2 : text1; + var i = longtext.indexOf(shorttext); + if (i != -1) { + // Shorter text is inside the longer text (speedup). + diffs = [[DIFF_INSERT, longtext.substring(0, i)], + [DIFF_EQUAL, shorttext], + [DIFF_INSERT, longtext.substring(i + shorttext.length)]]; + // Swap insertions for deletions if diff is reversed. + if (text1.length > text2.length) { + diffs[0][0] = diffs[2][0] = DIFF_DELETE; + } + return diffs; + } + + if (shorttext.length == 1) { + // Single character string. + // After the previous speedup, the character can't be an equality. + return [[DIFF_DELETE, text1], [DIFF_INSERT, text2]]; + } + + // Check to see if the problem can be split in two. + var hm = this.diff_halfMatch_(text1, text2); + if (hm) { + // A half-match was found, sort out the return data. + var text1_a = hm[0]; + var text1_b = hm[1]; + var text2_a = hm[2]; + var text2_b = hm[3]; + var mid_common = hm[4]; + // Send both pairs off for separate processing. + var diffs_a = this.diff_main(text1_a, text2_a, checklines, deadline); + var diffs_b = this.diff_main(text1_b, text2_b, checklines, deadline); + // Merge the results. + return diffs_a.concat([[DIFF_EQUAL, mid_common]], diffs_b); + } + + if (checklines && text1.length > 100 && text2.length > 100) { + return this.diff_lineMode_(text1, text2, deadline); + } + + return this.diff_bisect_(text1, text2, deadline); +}; + + +/** + * Do a quick line-level diff on both strings, then rediff the parts for + * greater accuracy. + * This speedup can produce non-minimal diffs. + * @param {string} text1 Old string to be diffed. + * @param {string} text2 New string to be diffed. + * @param {number} deadline Time when the diff should be complete by. + * @return {!Array.} Array of diff tuples. + * @private + */ +diff_match_patch.prototype.diff_lineMode_ = function(text1, text2, deadline) { + // Scan the text on a line-by-line basis first. + var a = this.diff_linesToChars_(text1, text2); + text1 = a.chars1; + text2 = a.chars2; + var linearray = a.lineArray; + + var diffs = this.diff_main(text1, text2, false, deadline); + + // Convert the diff back to original text. + this.diff_charsToLines_(diffs, linearray); + // Eliminate freak matches (e.g. blank lines) + this.diff_cleanupSemantic(diffs); + + // Rediff any replacement blocks, this time character-by-character. + // Add a dummy entry at the end. + diffs.push([DIFF_EQUAL, '']); + var pointer = 0; + var count_delete = 0; + var count_insert = 0; + var text_delete = ''; + var text_insert = ''; + while (pointer < diffs.length) { + switch (diffs[pointer][0]) { + case DIFF_INSERT: + count_insert++; + text_insert += diffs[pointer][1]; + break; + case DIFF_DELETE: + count_delete++; + text_delete += diffs[pointer][1]; + break; + case DIFF_EQUAL: + // Upon reaching an equality, check for prior redundancies. + if (count_delete >= 1 && count_insert >= 1) { + // Delete the offending records and add the merged ones. + diffs.splice(pointer - count_delete - count_insert, + count_delete + count_insert); + pointer = pointer - count_delete - count_insert; + var a = this.diff_main(text_delete, text_insert, false, deadline); + for (var j = a.length - 1; j >= 0; j--) { + diffs.splice(pointer, 0, a[j]); + } + pointer = pointer + a.length; + } + count_insert = 0; + count_delete = 0; + text_delete = ''; + text_insert = ''; + break; + } + pointer++; + } + diffs.pop(); // Remove the dummy entry at the end. + + return diffs; +}; + + +/** + * Find the 'middle snake' of a diff, split the problem in two + * and return the recursively constructed diff. + * See Myers 1986 paper: An O(ND) Difference Algorithm and Its Variations. + * @param {string} text1 Old string to be diffed. + * @param {string} text2 New string to be diffed. + * @param {number} deadline Time at which to bail if not yet complete. + * @return {!Array.} Array of diff tuples. + * @private + */ +diff_match_patch.prototype.diff_bisect_ = function(text1, text2, deadline) { + // Cache the text lengths to prevent multiple calls. + var text1_length = text1.length; + var text2_length = text2.length; + var max_d = Math.ceil((text1_length + text2_length) / 2); + var v_offset = max_d; + var v_length = 2 * max_d; + var v1 = new Array(v_length); + var v2 = new Array(v_length); + // Setting all elements to -1 is faster in Chrome & Firefox than mixing + // integers and undefined. + for (var x = 0; x < v_length; x++) { + v1[x] = -1; + v2[x] = -1; + } + v1[v_offset + 1] = 0; + v2[v_offset + 1] = 0; + var delta = text1_length - text2_length; + // If the total number of characters is odd, then the front path will collide + // with the reverse path. + var front = (delta % 2 != 0); + // Offsets for start and end of k loop. + // Prevents mapping of space beyond the grid. + var k1start = 0; + var k1end = 0; + var k2start = 0; + var k2end = 0; + for (var d = 0; d < max_d; d++) { + // Bail out if deadline is reached. + if ((new Date()).getTime() > deadline) { + break; + } + + // Walk the front path one step. + for (var k1 = -d + k1start; k1 <= d - k1end; k1 += 2) { + var k1_offset = v_offset + k1; + var x1; + if (k1 == -d || (k1 != d && v1[k1_offset - 1] < v1[k1_offset + 1])) { + x1 = v1[k1_offset + 1]; + } else { + x1 = v1[k1_offset - 1] + 1; + } + var y1 = x1 - k1; + while (x1 < text1_length && y1 < text2_length && + text1.charAt(x1) == text2.charAt(y1)) { + x1++; + y1++; + } + v1[k1_offset] = x1; + if (x1 > text1_length) { + // Ran off the right of the graph. + k1end += 2; + } else if (y1 > text2_length) { + // Ran off the bottom of the graph. + k1start += 2; + } else if (front) { + var k2_offset = v_offset + delta - k1; + if (k2_offset >= 0 && k2_offset < v_length && v2[k2_offset] != -1) { + // Mirror x2 onto top-left coordinate system. + var x2 = text1_length - v2[k2_offset]; + if (x1 >= x2) { + // Overlap detected. + return this.diff_bisectSplit_(text1, text2, x1, y1, deadline); + } + } + } + } + + // Walk the reverse path one step. + for (var k2 = -d + k2start; k2 <= d - k2end; k2 += 2) { + var k2_offset = v_offset + k2; + var x2; + if (k2 == -d || (k2 != d && v2[k2_offset - 1] < v2[k2_offset + 1])) { + x2 = v2[k2_offset + 1]; + } else { + x2 = v2[k2_offset - 1] + 1; + } + var y2 = x2 - k2; + while (x2 < text1_length && y2 < text2_length && + text1.charAt(text1_length - x2 - 1) == + text2.charAt(text2_length - y2 - 1)) { + x2++; + y2++; + } + v2[k2_offset] = x2; + if (x2 > text1_length) { + // Ran off the left of the graph. + k2end += 2; + } else if (y2 > text2_length) { + // Ran off the top of the graph. + k2start += 2; + } else if (!front) { + var k1_offset = v_offset + delta - k2; + if (k1_offset >= 0 && k1_offset < v_length && v1[k1_offset] != -1) { + var x1 = v1[k1_offset]; + var y1 = v_offset + x1 - k1_offset; + // Mirror x2 onto top-left coordinate system. + x2 = text1_length - x2; + if (x1 >= x2) { + // Overlap detected. + return this.diff_bisectSplit_(text1, text2, x1, y1, deadline); + } + } + } + } + } + // Diff took too long and hit the deadline or + // number of diffs equals number of characters, no commonality at all. + return [[DIFF_DELETE, text1], [DIFF_INSERT, text2]]; +}; + + +/** + * Given the location of the 'middle snake', split the diff in two parts + * and recurse. + * @param {string} text1 Old string to be diffed. + * @param {string} text2 New string to be diffed. + * @param {number} x Index of split point in text1. + * @param {number} y Index of split point in text2. + * @param {number} deadline Time at which to bail if not yet complete. + * @return {!Array.} Array of diff tuples. + * @private + */ +diff_match_patch.prototype.diff_bisectSplit_ = function(text1, text2, x, y, + deadline) { + var text1a = text1.substring(0, x); + var text2a = text2.substring(0, y); + var text1b = text1.substring(x); + var text2b = text2.substring(y); + + // Compute both diffs serially. + var diffs = this.diff_main(text1a, text2a, false, deadline); + var diffsb = this.diff_main(text1b, text2b, false, deadline); + + return diffs.concat(diffsb); +}; + + +/** + * Split two texts into an array of strings. Reduce the texts to a string of + * hashes where each Unicode character represents one line. + * @param {string} text1 First string. + * @param {string} text2 Second string. + * @return {{chars1: string, chars2: string, lineArray: !Array.}} + * An object containing the encoded text1, the encoded text2 and + * the array of unique strings. + * The zeroth element of the array of unique strings is intentionally blank. + * @private + */ +diff_match_patch.prototype.diff_linesToChars_ = function(text1, text2) { + var lineArray = []; // e.g. lineArray[4] == 'Hello\n' + var lineHash = {}; // e.g. lineHash['Hello\n'] == 4 + + // '\x00' is a valid character, but various debuggers don't like it. + // So we'll insert a junk entry to avoid generating a null character. + lineArray[0] = ''; + + /** + * Split a text into an array of strings. Reduce the texts to a string of + * hashes where each Unicode character represents one line. + * Modifies linearray and linehash through being a closure. + * @param {string} text String to encode. + * @return {string} Encoded string. + * @private + */ + function diff_linesToCharsMunge_(text) { + var chars = ''; + // Walk the text, pulling out a substring for each line. + // text.split('\n') would would temporarily double our memory footprint. + // Modifying text would create many large strings to garbage collect. + var lineStart = 0; + var lineEnd = -1; + // Keeping our own length variable is faster than looking it up. + var lineArrayLength = lineArray.length; + while (lineEnd < text.length - 1) { + lineEnd = text.indexOf('\n', lineStart); + if (lineEnd == -1) { + lineEnd = text.length - 1; + } + var line = text.substring(lineStart, lineEnd + 1); + lineStart = lineEnd + 1; + + if (lineHash.hasOwnProperty ? lineHash.hasOwnProperty(line) : + (lineHash[line] !== undefined)) { + chars += String.fromCharCode(lineHash[line]); + } else { + chars += String.fromCharCode(lineArrayLength); + lineHash[line] = lineArrayLength; + lineArray[lineArrayLength++] = line; + } + } + return chars; + } + + var chars1 = diff_linesToCharsMunge_(text1); + var chars2 = diff_linesToCharsMunge_(text2); + return {chars1: chars1, chars2: chars2, lineArray: lineArray}; +}; + + +/** + * Rehydrate the text in a diff from a string of line hashes to real lines of + * text. + * @param {!Array.} diffs Array of diff tuples. + * @param {!Array.} lineArray Array of unique strings. + * @private + */ +diff_match_patch.prototype.diff_charsToLines_ = function(diffs, lineArray) { + for (var x = 0; x < diffs.length; x++) { + var chars = diffs[x][1]; + var text = []; + for (var y = 0; y < chars.length; y++) { + text[y] = lineArray[chars.charCodeAt(y)]; + } + diffs[x][1] = text.join(''); + } +}; + + +/** + * Determine the common prefix of two strings. + * @param {string} text1 First string. + * @param {string} text2 Second string. + * @return {number} The number of characters common to the start of each + * string. + */ +diff_match_patch.prototype.diff_commonPrefix = function(text1, text2) { + // Quick check for common null cases. + if (!text1 || !text2 || text1.charAt(0) != text2.charAt(0)) { + return 0; + } + // Binary search. + // Performance analysis: http://neil.fraser.name/news/2007/10/09/ + var pointermin = 0; + var pointermax = Math.min(text1.length, text2.length); + var pointermid = pointermax; + var pointerstart = 0; + while (pointermin < pointermid) { + if (text1.substring(pointerstart, pointermid) == + text2.substring(pointerstart, pointermid)) { + pointermin = pointermid; + pointerstart = pointermin; + } else { + pointermax = pointermid; + } + pointermid = Math.floor((pointermax - pointermin) / 2 + pointermin); + } + return pointermid; +}; + + +/** + * Determine the common suffix of two strings. + * @param {string} text1 First string. + * @param {string} text2 Second string. + * @return {number} The number of characters common to the end of each string. + */ +diff_match_patch.prototype.diff_commonSuffix = function(text1, text2) { + // Quick check for common null cases. + if (!text1 || !text2 || + text1.charAt(text1.length - 1) != text2.charAt(text2.length - 1)) { + return 0; + } + // Binary search. + // Performance analysis: http://neil.fraser.name/news/2007/10/09/ + var pointermin = 0; + var pointermax = Math.min(text1.length, text2.length); + var pointermid = pointermax; + var pointerend = 0; + while (pointermin < pointermid) { + if (text1.substring(text1.length - pointermid, text1.length - pointerend) == + text2.substring(text2.length - pointermid, text2.length - pointerend)) { + pointermin = pointermid; + pointerend = pointermin; + } else { + pointermax = pointermid; + } + pointermid = Math.floor((pointermax - pointermin) / 2 + pointermin); + } + return pointermid; +}; + + +/** + * Determine if the suffix of one string is the prefix of another. + * @param {string} text1 First string. + * @param {string} text2 Second string. + * @return {number} The number of characters common to the end of the first + * string and the start of the second string. + * @private + */ +diff_match_patch.prototype.diff_commonOverlap_ = function(text1, text2) { + // Cache the text lengths to prevent multiple calls. + var text1_length = text1.length; + var text2_length = text2.length; + // Eliminate the null case. + if (text1_length == 0 || text2_length == 0) { + return 0; + } + // Truncate the longer string. + if (text1_length > text2_length) { + text1 = text1.substring(text1_length - text2_length); + } else if (text1_length < text2_length) { + text2 = text2.substring(0, text1_length); + } + var text_length = Math.min(text1_length, text2_length); + // Quick check for the worst case. + if (text1 == text2) { + return text_length; + } + + // Start by looking for a single character match + // and increase length until no match is found. + // Performance analysis: http://neil.fraser.name/news/2010/11/04/ + var best = 0; + var length = 1; + while (true) { + var pattern = text1.substring(text_length - length); + var found = text2.indexOf(pattern); + if (found == -1) { + return best; + } + length += found; + if (found == 0 || text1.substring(text_length - length) == + text2.substring(0, length)) { + best = length; + length++; + } + } +}; + + +/** + * Do the two texts share a substring which is at least half the length of the + * longer text? + * This speedup can produce non-minimal diffs. + * @param {string} text1 First string. + * @param {string} text2 Second string. + * @return {Array.} Five element Array, containing the prefix of + * text1, the suffix of text1, the prefix of text2, the suffix of + * text2 and the common middle. Or null if there was no match. + * @private + */ +diff_match_patch.prototype.diff_halfMatch_ = function(text1, text2) { + if (this.Diff_Timeout <= 0) { + // Don't risk returning a non-optimal diff if we have unlimited time. + return null; + } + var longtext = text1.length > text2.length ? text1 : text2; + var shorttext = text1.length > text2.length ? text2 : text1; + if (longtext.length < 4 || shorttext.length * 2 < longtext.length) { + return null; // Pointless. + } + var dmp = this; // 'this' becomes 'window' in a closure. + + /** + * Does a substring of shorttext exist within longtext such that the substring + * is at least half the length of longtext? + * Closure, but does not reference any external variables. + * @param {string} longtext Longer string. + * @param {string} shorttext Shorter string. + * @param {number} i Start index of quarter length substring within longtext. + * @return {Array.} Five element Array, containing the prefix of + * longtext, the suffix of longtext, the prefix of shorttext, the suffix + * of shorttext and the common middle. Or null if there was no match. + * @private + */ + function diff_halfMatchI_(longtext, shorttext, i) { + // Start with a 1/4 length substring at position i as a seed. + var seed = longtext.substring(i, i + Math.floor(longtext.length / 4)); + var j = -1; + var best_common = ''; + var best_longtext_a, best_longtext_b, best_shorttext_a, best_shorttext_b; + while ((j = shorttext.indexOf(seed, j + 1)) != -1) { + var prefixLength = dmp.diff_commonPrefix(longtext.substring(i), + shorttext.substring(j)); + var suffixLength = dmp.diff_commonSuffix(longtext.substring(0, i), + shorttext.substring(0, j)); + if (best_common.length < suffixLength + prefixLength) { + best_common = shorttext.substring(j - suffixLength, j) + + shorttext.substring(j, j + prefixLength); + best_longtext_a = longtext.substring(0, i - suffixLength); + best_longtext_b = longtext.substring(i + prefixLength); + best_shorttext_a = shorttext.substring(0, j - suffixLength); + best_shorttext_b = shorttext.substring(j + prefixLength); + } + } + if (best_common.length * 2 >= longtext.length) { + return [best_longtext_a, best_longtext_b, + best_shorttext_a, best_shorttext_b, best_common]; + } else { + return null; + } + } + + // First check if the second quarter is the seed for a half-match. + var hm1 = diff_halfMatchI_(longtext, shorttext, + Math.ceil(longtext.length / 4)); + // Check again based on the third quarter. + var hm2 = diff_halfMatchI_(longtext, shorttext, + Math.ceil(longtext.length / 2)); + var hm; + if (!hm1 && !hm2) { + return null; + } else if (!hm2) { + hm = hm1; + } else if (!hm1) { + hm = hm2; + } else { + // Both matched. Select the longest. + hm = hm1[4].length > hm2[4].length ? hm1 : hm2; + } + + // A half-match was found, sort out the return data. + var text1_a, text1_b, text2_a, text2_b; + if (text1.length > text2.length) { + text1_a = hm[0]; + text1_b = hm[1]; + text2_a = hm[2]; + text2_b = hm[3]; + } else { + text2_a = hm[0]; + text2_b = hm[1]; + text1_a = hm[2]; + text1_b = hm[3]; + } + var mid_common = hm[4]; + return [text1_a, text1_b, text2_a, text2_b, mid_common]; +}; + + +/** + * Reduce the number of edits by eliminating semantically trivial equalities. + * @param {!Array.} diffs Array of diff tuples. + */ +diff_match_patch.prototype.diff_cleanupSemantic = function(diffs) { + var changes = false; + var equalities = []; // Stack of indices where equalities are found. + var equalitiesLength = 0; // Keeping our own length var is faster in JS. + /** @type {?string} */ + var lastequality = null; + // Always equal to diffs[equalities[equalitiesLength - 1]][1] + var pointer = 0; // Index of current position. + // Number of characters that changed prior to the equality. + var length_insertions1 = 0; + var length_deletions1 = 0; + // Number of characters that changed after the equality. + var length_insertions2 = 0; + var length_deletions2 = 0; + while (pointer < diffs.length) { + if (diffs[pointer][0] == DIFF_EQUAL) { // Equality found. + equalities[equalitiesLength++] = pointer; + length_insertions1 = length_insertions2; + length_deletions1 = length_deletions2; + length_insertions2 = 0; + length_deletions2 = 0; + lastequality = diffs[pointer][1]; + } else { // An insertion or deletion. + if (diffs[pointer][0] == DIFF_INSERT) { + length_insertions2 += diffs[pointer][1].length; + } else { + length_deletions2 += diffs[pointer][1].length; + } + // Eliminate an equality that is smaller or equal to the edits on both + // sides of it. + if (lastequality && (lastequality.length <= + Math.max(length_insertions1, length_deletions1)) && + (lastequality.length <= Math.max(length_insertions2, + length_deletions2))) { + // Duplicate record. + diffs.splice(equalities[equalitiesLength - 1], 0, + [DIFF_DELETE, lastequality]); + // Change second copy to insert. + diffs[equalities[equalitiesLength - 1] + 1][0] = DIFF_INSERT; + // Throw away the equality we just deleted. + equalitiesLength--; + // Throw away the previous equality (it needs to be reevaluated). + equalitiesLength--; + pointer = equalitiesLength > 0 ? equalities[equalitiesLength - 1] : -1; + length_insertions1 = 0; // Reset the counters. + length_deletions1 = 0; + length_insertions2 = 0; + length_deletions2 = 0; + lastequality = null; + changes = true; + } + } + pointer++; + } + + // Normalize the diff. + if (changes) { + this.diff_cleanupMerge(diffs); + } + this.diff_cleanupSemanticLossless(diffs); + + // Find any overlaps between deletions and insertions. + // e.g: abcxxxxxxdef + // -> abcxxxdef + // e.g: xxxabcdefxxx + // -> defxxxabc + // Only extract an overlap if it is as big as the edit ahead or behind it. + pointer = 1; + while (pointer < diffs.length) { + if (diffs[pointer - 1][0] == DIFF_DELETE && + diffs[pointer][0] == DIFF_INSERT) { + var deletion = diffs[pointer - 1][1]; + var insertion = diffs[pointer][1]; + var overlap_length1 = this.diff_commonOverlap_(deletion, insertion); + var overlap_length2 = this.diff_commonOverlap_(insertion, deletion); + if (overlap_length1 >= overlap_length2) { + if (overlap_length1 >= deletion.length / 2 || + overlap_length1 >= insertion.length / 2) { + // Overlap found. Insert an equality and trim the surrounding edits. + diffs.splice(pointer, 0, + [DIFF_EQUAL, insertion.substring(0, overlap_length1)]); + diffs[pointer - 1][1] = + deletion.substring(0, deletion.length - overlap_length1); + diffs[pointer + 1][1] = insertion.substring(overlap_length1); + pointer++; + } + } else { + if (overlap_length2 >= deletion.length / 2 || + overlap_length2 >= insertion.length / 2) { + // Reverse overlap found. + // Insert an equality and swap and trim the surrounding edits. + diffs.splice(pointer, 0, + [DIFF_EQUAL, deletion.substring(0, overlap_length2)]); + diffs[pointer - 1][0] = DIFF_INSERT; + diffs[pointer - 1][1] = + insertion.substring(0, insertion.length - overlap_length2); + diffs[pointer + 1][0] = DIFF_DELETE; + diffs[pointer + 1][1] = + deletion.substring(overlap_length2); + pointer++; + } + } + pointer++; + } + pointer++; + } +}; + + +/** + * Look for single edits surrounded on both sides by equalities + * which can be shifted sideways to align the edit to a word boundary. + * e.g: The cat came. -> The cat came. + * @param {!Array.} diffs Array of diff tuples. + */ +diff_match_patch.prototype.diff_cleanupSemanticLossless = function(diffs) { + /** + * Given two strings, compute a score representing whether the internal + * boundary falls on logical boundaries. + * Scores range from 6 (best) to 0 (worst). + * Closure, but does not reference any external variables. + * @param {string} one First string. + * @param {string} two Second string. + * @return {number} The score. + * @private + */ + function diff_cleanupSemanticScore_(one, two) { + if (!one || !two) { + // Edges are the best. + return 6; + } + + // Each port of this function behaves slightly differently due to + // subtle differences in each language's definition of things like + // 'whitespace'. Since this function's purpose is largely cosmetic, + // the choice has been made to use each language's native features + // rather than force total conformity. + var char1 = one.charAt(one.length - 1); + var char2 = two.charAt(0); + var nonAlphaNumeric1 = char1.match(diff_match_patch.nonAlphaNumericRegex_); + var nonAlphaNumeric2 = char2.match(diff_match_patch.nonAlphaNumericRegex_); + var whitespace1 = nonAlphaNumeric1 && + char1.match(diff_match_patch.whitespaceRegex_); + var whitespace2 = nonAlphaNumeric2 && + char2.match(diff_match_patch.whitespaceRegex_); + var lineBreak1 = whitespace1 && + char1.match(diff_match_patch.linebreakRegex_); + var lineBreak2 = whitespace2 && + char2.match(diff_match_patch.linebreakRegex_); + var blankLine1 = lineBreak1 && + one.match(diff_match_patch.blanklineEndRegex_); + var blankLine2 = lineBreak2 && + two.match(diff_match_patch.blanklineStartRegex_); + + if (blankLine1 || blankLine2) { + // Five points for blank lines. + return 5; + } else if (lineBreak1 || lineBreak2) { + // Four points for line breaks. + return 4; + } else if (nonAlphaNumeric1 && !whitespace1 && whitespace2) { + // Three points for end of sentences. + return 3; + } else if (whitespace1 || whitespace2) { + // Two points for whitespace. + return 2; + } else if (nonAlphaNumeric1 || nonAlphaNumeric2) { + // One point for non-alphanumeric. + return 1; + } + return 0; + } + + var pointer = 1; + // Intentionally ignore the first and last element (don't need checking). + while (pointer < diffs.length - 1) { + if (diffs[pointer - 1][0] == DIFF_EQUAL && + diffs[pointer + 1][0] == DIFF_EQUAL) { + // This is a single edit surrounded by equalities. + var equality1 = diffs[pointer - 1][1]; + var edit = diffs[pointer][1]; + var equality2 = diffs[pointer + 1][1]; + + // First, shift the edit as far left as possible. + var commonOffset = this.diff_commonSuffix(equality1, edit); + if (commonOffset) { + var commonString = edit.substring(edit.length - commonOffset); + equality1 = equality1.substring(0, equality1.length - commonOffset); + edit = commonString + edit.substring(0, edit.length - commonOffset); + equality2 = commonString + equality2; + } + + // Second, step character by character right, looking for the best fit. + var bestEquality1 = equality1; + var bestEdit = edit; + var bestEquality2 = equality2; + var bestScore = diff_cleanupSemanticScore_(equality1, edit) + + diff_cleanupSemanticScore_(edit, equality2); + while (edit.charAt(0) === equality2.charAt(0)) { + equality1 += edit.charAt(0); + edit = edit.substring(1) + equality2.charAt(0); + equality2 = equality2.substring(1); + var score = diff_cleanupSemanticScore_(equality1, edit) + + diff_cleanupSemanticScore_(edit, equality2); + // The >= encourages trailing rather than leading whitespace on edits. + if (score >= bestScore) { + bestScore = score; + bestEquality1 = equality1; + bestEdit = edit; + bestEquality2 = equality2; + } + } + + if (diffs[pointer - 1][1] != bestEquality1) { + // We have an improvement, save it back to the diff. + if (bestEquality1) { + diffs[pointer - 1][1] = bestEquality1; + } else { + diffs.splice(pointer - 1, 1); + pointer--; + } + diffs[pointer][1] = bestEdit; + if (bestEquality2) { + diffs[pointer + 1][1] = bestEquality2; + } else { + diffs.splice(pointer + 1, 1); + pointer--; + } + } + } + pointer++; + } +}; + +// Define some regex patterns for matching boundaries. +diff_match_patch.nonAlphaNumericRegex_ = /[^a-zA-Z0-9]/; +diff_match_patch.whitespaceRegex_ = /\s/; +diff_match_patch.linebreakRegex_ = /[\r\n]/; +diff_match_patch.blanklineEndRegex_ = /\n\r?\n$/; +diff_match_patch.blanklineStartRegex_ = /^\r?\n\r?\n/; + +/** + * Reduce the number of edits by eliminating operationally trivial equalities. + * @param {!Array.} diffs Array of diff tuples. + */ +diff_match_patch.prototype.diff_cleanupEfficiency = function(diffs) { + var changes = false; + var equalities = []; // Stack of indices where equalities are found. + var equalitiesLength = 0; // Keeping our own length var is faster in JS. + /** @type {?string} */ + var lastequality = null; + // Always equal to diffs[equalities[equalitiesLength - 1]][1] + var pointer = 0; // Index of current position. + // Is there an insertion operation before the last equality. + var pre_ins = false; + // Is there a deletion operation before the last equality. + var pre_del = false; + // Is there an insertion operation after the last equality. + var post_ins = false; + // Is there a deletion operation after the last equality. + var post_del = false; + while (pointer < diffs.length) { + if (diffs[pointer][0] == DIFF_EQUAL) { // Equality found. + if (diffs[pointer][1].length < this.Diff_EditCost && + (post_ins || post_del)) { + // Candidate found. + equalities[equalitiesLength++] = pointer; + pre_ins = post_ins; + pre_del = post_del; + lastequality = diffs[pointer][1]; + } else { + // Not a candidate, and can never become one. + equalitiesLength = 0; + lastequality = null; + } + post_ins = post_del = false; + } else { // An insertion or deletion. + if (diffs[pointer][0] == DIFF_DELETE) { + post_del = true; + } else { + post_ins = true; + } + /* + * Five types to be split: + * ABXYCD + * AXCD + * ABXC + * AXCD + * ABXC + */ + if (lastequality && ((pre_ins && pre_del && post_ins && post_del) || + ((lastequality.length < this.Diff_EditCost / 2) && + (pre_ins + pre_del + post_ins + post_del) == 3))) { + // Duplicate record. + diffs.splice(equalities[equalitiesLength - 1], 0, + [DIFF_DELETE, lastequality]); + // Change second copy to insert. + diffs[equalities[equalitiesLength - 1] + 1][0] = DIFF_INSERT; + equalitiesLength--; // Throw away the equality we just deleted; + lastequality = null; + if (pre_ins && pre_del) { + // No changes made which could affect previous entry, keep going. + post_ins = post_del = true; + equalitiesLength = 0; + } else { + equalitiesLength--; // Throw away the previous equality. + pointer = equalitiesLength > 0 ? + equalities[equalitiesLength - 1] : -1; + post_ins = post_del = false; + } + changes = true; + } + } + pointer++; + } + + if (changes) { + this.diff_cleanupMerge(diffs); + } +}; + + +/** + * Reorder and merge like edit sections. Merge equalities. + * Any edit section can move as long as it doesn't cross an equality. + * @param {!Array.} diffs Array of diff tuples. + */ +diff_match_patch.prototype.diff_cleanupMerge = function(diffs) { + diffs.push([DIFF_EQUAL, '']); // Add a dummy entry at the end. + var pointer = 0; + var count_delete = 0; + var count_insert = 0; + var text_delete = ''; + var text_insert = ''; + var commonlength; + while (pointer < diffs.length) { + switch (diffs[pointer][0]) { + case DIFF_INSERT: + count_insert++; + text_insert += diffs[pointer][1]; + pointer++; + break; + case DIFF_DELETE: + count_delete++; + text_delete += diffs[pointer][1]; + pointer++; + break; + case DIFF_EQUAL: + // Upon reaching an equality, check for prior redundancies. + if (count_delete + count_insert > 1) { + if (count_delete !== 0 && count_insert !== 0) { + // Factor out any common prefixies. + commonlength = this.diff_commonPrefix(text_insert, text_delete); + if (commonlength !== 0) { + if ((pointer - count_delete - count_insert) > 0 && + diffs[pointer - count_delete - count_insert - 1][0] == + DIFF_EQUAL) { + diffs[pointer - count_delete - count_insert - 1][1] += + text_insert.substring(0, commonlength); + } else { + diffs.splice(0, 0, [DIFF_EQUAL, + text_insert.substring(0, commonlength)]); + pointer++; + } + text_insert = text_insert.substring(commonlength); + text_delete = text_delete.substring(commonlength); + } + // Factor out any common suffixies. + commonlength = this.diff_commonSuffix(text_insert, text_delete); + if (commonlength !== 0) { + diffs[pointer][1] = text_insert.substring(text_insert.length - + commonlength) + diffs[pointer][1]; + text_insert = text_insert.substring(0, text_insert.length - + commonlength); + text_delete = text_delete.substring(0, text_delete.length - + commonlength); + } + } + // Delete the offending records and add the merged ones. + if (count_delete === 0) { + diffs.splice(pointer - count_insert, + count_delete + count_insert, [DIFF_INSERT, text_insert]); + } else if (count_insert === 0) { + diffs.splice(pointer - count_delete, + count_delete + count_insert, [DIFF_DELETE, text_delete]); + } else { + diffs.splice(pointer - count_delete - count_insert, + count_delete + count_insert, [DIFF_DELETE, text_delete], + [DIFF_INSERT, text_insert]); + } + pointer = pointer - count_delete - count_insert + + (count_delete ? 1 : 0) + (count_insert ? 1 : 0) + 1; + } else if (pointer !== 0 && diffs[pointer - 1][0] == DIFF_EQUAL) { + // Merge this equality with the previous one. + diffs[pointer - 1][1] += diffs[pointer][1]; + diffs.splice(pointer, 1); + } else { + pointer++; + } + count_insert = 0; + count_delete = 0; + text_delete = ''; + text_insert = ''; + break; + } + } + if (diffs[diffs.length - 1][1] === '') { + diffs.pop(); // Remove the dummy entry at the end. + } + + // Second pass: look for single edits surrounded on both sides by equalities + // which can be shifted sideways to eliminate an equality. + // e.g: ABAC -> ABAC + var changes = false; + pointer = 1; + // Intentionally ignore the first and last element (don't need checking). + while (pointer < diffs.length - 1) { + if (diffs[pointer - 1][0] == DIFF_EQUAL && + diffs[pointer + 1][0] == DIFF_EQUAL) { + // This is a single edit surrounded by equalities. + if (diffs[pointer][1].substring(diffs[pointer][1].length - + diffs[pointer - 1][1].length) == diffs[pointer - 1][1]) { + // Shift the edit over the previous equality. + diffs[pointer][1] = diffs[pointer - 1][1] + + diffs[pointer][1].substring(0, diffs[pointer][1].length - + diffs[pointer - 1][1].length); + diffs[pointer + 1][1] = diffs[pointer - 1][1] + diffs[pointer + 1][1]; + diffs.splice(pointer - 1, 1); + changes = true; + } else if (diffs[pointer][1].substring(0, diffs[pointer + 1][1].length) == + diffs[pointer + 1][1]) { + // Shift the edit over the next equality. + diffs[pointer - 1][1] += diffs[pointer + 1][1]; + diffs[pointer][1] = + diffs[pointer][1].substring(diffs[pointer + 1][1].length) + + diffs[pointer + 1][1]; + diffs.splice(pointer + 1, 1); + changes = true; + } + } + pointer++; + } + // If shifts were made, the diff needs reordering and another shift sweep. + if (changes) { + this.diff_cleanupMerge(diffs); + } +}; + + +/** + * loc is a location in text1, compute and return the equivalent location in + * text2. + * e.g. 'The cat' vs 'The big cat', 1->1, 5->8 + * @param {!Array.} diffs Array of diff tuples. + * @param {number} loc Location within text1. + * @return {number} Location within text2. + */ +diff_match_patch.prototype.diff_xIndex = function(diffs, loc) { + var chars1 = 0; + var chars2 = 0; + var last_chars1 = 0; + var last_chars2 = 0; + var x; + for (x = 0; x < diffs.length; x++) { + if (diffs[x][0] !== DIFF_INSERT) { // Equality or deletion. + chars1 += diffs[x][1].length; + } + if (diffs[x][0] !== DIFF_DELETE) { // Equality or insertion. + chars2 += diffs[x][1].length; + } + if (chars1 > loc) { // Overshot the location. + break; + } + last_chars1 = chars1; + last_chars2 = chars2; + } + // Was the location was deleted? + if (diffs.length != x && diffs[x][0] === DIFF_DELETE) { + return last_chars2; + } + // Add the remaining character length. + return last_chars2 + (loc - last_chars1); +}; + + +/** + * Convert a diff array into a pretty HTML report. + * @param {!Array.} diffs Array of diff tuples. + * @return {string} HTML representation. + */ +diff_match_patch.prototype.diff_prettyHtml = function(diffs) { + var html = []; + var pattern_amp = /&/g; + var pattern_lt = //g; + var pattern_para = /\n/g; + for (var x = 0; x < diffs.length; x++) { + var op = diffs[x][0]; // Operation (insert, delete, equal) + var data = diffs[x][1]; // Text of change. + var text = data.replace(pattern_amp, '&').replace(pattern_lt, '<') + .replace(pattern_gt, '>').replace(pattern_para, '¶
        '); + switch (op) { + case DIFF_INSERT: + html[x] = '' + text + ''; + break; + case DIFF_DELETE: + html[x] = '' + text + ''; + break; + case DIFF_EQUAL: + html[x] = '' + text + ''; + break; + } + } + return html.join(''); +}; + + +/** + * Compute and return the source text (all equalities and deletions). + * @param {!Array.} diffs Array of diff tuples. + * @return {string} Source text. + */ +diff_match_patch.prototype.diff_text1 = function(diffs) { + var text = []; + for (var x = 0; x < diffs.length; x++) { + if (diffs[x][0] !== DIFF_INSERT) { + text[x] = diffs[x][1]; + } + } + return text.join(''); +}; + + +/** + * Compute and return the destination text (all equalities and insertions). + * @param {!Array.} diffs Array of diff tuples. + * @return {string} Destination text. + */ +diff_match_patch.prototype.diff_text2 = function(diffs) { + var text = []; + for (var x = 0; x < diffs.length; x++) { + if (diffs[x][0] !== DIFF_DELETE) { + text[x] = diffs[x][1]; + } + } + return text.join(''); +}; + + +/** + * Compute the Levenshtein distance; the number of inserted, deleted or + * substituted characters. + * @param {!Array.} diffs Array of diff tuples. + * @return {number} Number of changes. + */ +diff_match_patch.prototype.diff_levenshtein = function(diffs) { + var levenshtein = 0; + var insertions = 0; + var deletions = 0; + for (var x = 0; x < diffs.length; x++) { + var op = diffs[x][0]; + var data = diffs[x][1]; + switch (op) { + case DIFF_INSERT: + insertions += data.length; + break; + case DIFF_DELETE: + deletions += data.length; + break; + case DIFF_EQUAL: + // A deletion and an insertion is one substitution. + levenshtein += Math.max(insertions, deletions); + insertions = 0; + deletions = 0; + break; + } + } + levenshtein += Math.max(insertions, deletions); + return levenshtein; +}; + + +/** + * Crush the diff into an encoded string which describes the operations + * required to transform text1 into text2. + * E.g. =3\t-2\t+ing -> Keep 3 chars, delete 2 chars, insert 'ing'. + * Operations are tab-separated. Inserted text is escaped using %xx notation. + * @param {!Array.} diffs Array of diff tuples. + * @return {string} Delta text. + */ +diff_match_patch.prototype.diff_toDelta = function(diffs) { + var text = []; + for (var x = 0; x < diffs.length; x++) { + switch (diffs[x][0]) { + case DIFF_INSERT: + text[x] = '+' + encodeURI(diffs[x][1]); + break; + case DIFF_DELETE: + text[x] = '-' + diffs[x][1].length; + break; + case DIFF_EQUAL: + text[x] = '=' + diffs[x][1].length; + break; + } + } + return text.join('\t').replace(/%20/g, ' '); +}; + + +/** + * Given the original text1, and an encoded string which describes the + * operations required to transform text1 into text2, compute the full diff. + * @param {string} text1 Source string for the diff. + * @param {string} delta Delta text. + * @return {!Array.} Array of diff tuples. + * @throws {!Error} If invalid input. + */ +diff_match_patch.prototype.diff_fromDelta = function(text1, delta) { + var diffs = []; + var diffsLength = 0; // Keeping our own length var is faster in JS. + var pointer = 0; // Cursor in text1 + var tokens = delta.split(/\t/g); + for (var x = 0; x < tokens.length; x++) { + // Each token begins with a one character parameter which specifies the + // operation of this token (delete, insert, equality). + var param = tokens[x].substring(1); + switch (tokens[x].charAt(0)) { + case '+': + try { + diffs[diffsLength++] = [DIFF_INSERT, decodeURI(param)]; + } catch (ex) { + // Malformed URI sequence. + throw new Error('Illegal escape in diff_fromDelta: ' + param); + } + break; + case '-': + // Fall through. + case '=': + var n = parseInt(param, 10); + if (isNaN(n) || n < 0) { + throw new Error('Invalid number in diff_fromDelta: ' + param); + } + var text = text1.substring(pointer, pointer += n); + if (tokens[x].charAt(0) == '=') { + diffs[diffsLength++] = [DIFF_EQUAL, text]; + } else { + diffs[diffsLength++] = [DIFF_DELETE, text]; + } + break; + default: + // Blank tokens are ok (from a trailing \t). + // Anything else is an error. + if (tokens[x]) { + throw new Error('Invalid diff operation in diff_fromDelta: ' + + tokens[x]); + } + } + } + if (pointer != text1.length) { + throw new Error('Delta length (' + pointer + + ') does not equal source text length (' + text1.length + ').'); + } + return diffs; +}; + + +// MATCH FUNCTIONS + + +/** + * Locate the best instance of 'pattern' in 'text' near 'loc'. + * @param {string} text The text to search. + * @param {string} pattern The pattern to search for. + * @param {number} loc The location to search around. + * @return {number} Best match index or -1. + */ +diff_match_patch.prototype.match_main = function(text, pattern, loc) { + // Check for null inputs. + if (text == null || pattern == null || loc == null) { + throw new Error('Null input. (match_main)'); + } + + loc = Math.max(0, Math.min(loc, text.length)); + if (text == pattern) { + // Shortcut (potentially not guaranteed by the algorithm) + return 0; + } else if (!text.length) { + // Nothing to match. + return -1; + } else if (text.substring(loc, loc + pattern.length) == pattern) { + // Perfect match at the perfect spot! (Includes case of null pattern) + return loc; + } else { + // Do a fuzzy compare. + return this.match_bitap_(text, pattern, loc); + } +}; + + +/** + * Locate the best instance of 'pattern' in 'text' near 'loc' using the + * Bitap algorithm. + * @param {string} text The text to search. + * @param {string} pattern The pattern to search for. + * @param {number} loc The location to search around. + * @return {number} Best match index or -1. + * @private + */ +diff_match_patch.prototype.match_bitap_ = function(text, pattern, loc) { + if (pattern.length > this.Match_MaxBits) { + throw new Error('Pattern too long for this browser.'); + } + + // Initialise the alphabet. + var s = this.match_alphabet_(pattern); + + var dmp = this; // 'this' becomes 'window' in a closure. + + /** + * Compute and return the score for a match with e errors and x location. + * Accesses loc and pattern through being a closure. + * @param {number} e Number of errors in match. + * @param {number} x Location of match. + * @return {number} Overall score for match (0.0 = good, 1.0 = bad). + * @private + */ + function match_bitapScore_(e, x) { + var accuracy = e / pattern.length; + var proximity = Math.abs(loc - x); + if (!dmp.Match_Distance) { + // Dodge divide by zero error. + return proximity ? 1.0 : accuracy; + } + return accuracy + (proximity / dmp.Match_Distance); + } + + // Highest score beyond which we give up. + var score_threshold = this.Match_Threshold; + // Is there a nearby exact match? (speedup) + var best_loc = text.indexOf(pattern, loc); + if (best_loc != -1) { + score_threshold = Math.min(match_bitapScore_(0, best_loc), score_threshold); + // What about in the other direction? (speedup) + best_loc = text.lastIndexOf(pattern, loc + pattern.length); + if (best_loc != -1) { + score_threshold = + Math.min(match_bitapScore_(0, best_loc), score_threshold); + } + } + + // Initialise the bit arrays. + var matchmask = 1 << (pattern.length - 1); + best_loc = -1; + + var bin_min, bin_mid; + var bin_max = pattern.length + text.length; + var last_rd; + for (var d = 0; d < pattern.length; d++) { + // Scan for the best match; each iteration allows for one more error. + // Run a binary search to determine how far from 'loc' we can stray at this + // error level. + bin_min = 0; + bin_mid = bin_max; + while (bin_min < bin_mid) { + if (match_bitapScore_(d, loc + bin_mid) <= score_threshold) { + bin_min = bin_mid; + } else { + bin_max = bin_mid; + } + bin_mid = Math.floor((bin_max - bin_min) / 2 + bin_min); + } + // Use the result from this iteration as the maximum for the next. + bin_max = bin_mid; + var start = Math.max(1, loc - bin_mid + 1); + var finish = Math.min(loc + bin_mid, text.length) + pattern.length; + + var rd = Array(finish + 2); + rd[finish + 1] = (1 << d) - 1; + for (var j = finish; j >= start; j--) { + // The alphabet (s) is a sparse hash, so the following line generates + // warnings. + var charMatch = s[text.charAt(j - 1)]; + if (d === 0) { // First pass: exact match. + rd[j] = ((rd[j + 1] << 1) | 1) & charMatch; + } else { // Subsequent passes: fuzzy match. + rd[j] = (((rd[j + 1] << 1) | 1) & charMatch) | + (((last_rd[j + 1] | last_rd[j]) << 1) | 1) | + last_rd[j + 1]; + } + if (rd[j] & matchmask) { + var score = match_bitapScore_(d, j - 1); + // This match will almost certainly be better than any existing match. + // But check anyway. + if (score <= score_threshold) { + // Told you so. + score_threshold = score; + best_loc = j - 1; + if (best_loc > loc) { + // When passing loc, don't exceed our current distance from loc. + start = Math.max(1, 2 * loc - best_loc); + } else { + // Already passed loc, downhill from here on in. + break; + } + } + } + } + // No hope for a (better) match at greater error levels. + if (match_bitapScore_(d + 1, loc) > score_threshold) { + break; + } + last_rd = rd; + } + return best_loc; +}; + + +/** + * Initialise the alphabet for the Bitap algorithm. + * @param {string} pattern The text to encode. + * @return {!Object} Hash of character locations. + * @private + */ +diff_match_patch.prototype.match_alphabet_ = function(pattern) { + var s = {}; + for (var i = 0; i < pattern.length; i++) { + s[pattern.charAt(i)] = 0; + } + for (var i = 0; i < pattern.length; i++) { + s[pattern.charAt(i)] |= 1 << (pattern.length - i - 1); + } + return s; +}; + + +// PATCH FUNCTIONS + + +/** + * Increase the context until it is unique, + * but don't let the pattern expand beyond Match_MaxBits. + * @param {!diff_match_patch.patch_obj} patch The patch to grow. + * @param {string} text Source text. + * @private + */ +diff_match_patch.prototype.patch_addContext_ = function(patch, text) { + if (text.length == 0) { + return; + } + var pattern = text.substring(patch.start2, patch.start2 + patch.length1); + var padding = 0; + + // Look for the first and last matches of pattern in text. If two different + // matches are found, increase the pattern length. + while (text.indexOf(pattern) != text.lastIndexOf(pattern) && + pattern.length < this.Match_MaxBits - this.Patch_Margin - + this.Patch_Margin) { + padding += this.Patch_Margin; + pattern = text.substring(patch.start2 - padding, + patch.start2 + patch.length1 + padding); + } + // Add one chunk for good luck. + padding += this.Patch_Margin; + + // Add the prefix. + var prefix = text.substring(patch.start2 - padding, patch.start2); + if (prefix) { + patch.diffs.unshift([DIFF_EQUAL, prefix]); + } + // Add the suffix. + var suffix = text.substring(patch.start2 + patch.length1, + patch.start2 + patch.length1 + padding); + if (suffix) { + patch.diffs.push([DIFF_EQUAL, suffix]); + } + + // Roll back the start points. + patch.start1 -= prefix.length; + patch.start2 -= prefix.length; + // Extend the lengths. + patch.length1 += prefix.length + suffix.length; + patch.length2 += prefix.length + suffix.length; +}; + + +/** + * Compute a list of patches to turn text1 into text2. + * Use diffs if provided, otherwise compute it ourselves. + * There are four ways to call this function, depending on what data is + * available to the caller: + * Method 1: + * a = text1, b = text2 + * Method 2: + * a = diffs + * Method 3 (optimal): + * a = text1, b = diffs + * Method 4 (deprecated, use method 3): + * a = text1, b = text2, c = diffs + * + * @param {string|!Array.} a text1 (methods 1,3,4) or + * Array of diff tuples for text1 to text2 (method 2). + * @param {string|!Array.} opt_b text2 (methods 1,4) or + * Array of diff tuples for text1 to text2 (method 3) or undefined (method 2). + * @param {string|!Array.} opt_c Array of diff tuples + * for text1 to text2 (method 4) or undefined (methods 1,2,3). + * @return {!Array.} Array of Patch objects. + */ +diff_match_patch.prototype.patch_make = function(a, opt_b, opt_c) { + var text1, diffs; + if (typeof a == 'string' && typeof opt_b == 'string' && + typeof opt_c == 'undefined') { + // Method 1: text1, text2 + // Compute diffs from text1 and text2. + text1 = /** @type {string} */(a); + diffs = this.diff_main(text1, /** @type {string} */(opt_b), true); + if (diffs.length > 2) { + this.diff_cleanupSemantic(diffs); + this.diff_cleanupEfficiency(diffs); + } + } else if (a && typeof a == 'object' && typeof opt_b == 'undefined' && + typeof opt_c == 'undefined') { + // Method 2: diffs + // Compute text1 from diffs. + diffs = /** @type {!Array.} */(a); + text1 = this.diff_text1(diffs); + } else if (typeof a == 'string' && opt_b && typeof opt_b == 'object' && + typeof opt_c == 'undefined') { + // Method 3: text1, diffs + text1 = /** @type {string} */(a); + diffs = /** @type {!Array.} */(opt_b); + } else if (typeof a == 'string' && typeof opt_b == 'string' && + opt_c && typeof opt_c == 'object') { + // Method 4: text1, text2, diffs + // text2 is not used. + text1 = /** @type {string} */(a); + diffs = /** @type {!Array.} */(opt_c); + } else { + throw new Error('Unknown call format to patch_make.'); + } + + if (diffs.length === 0) { + return []; // Get rid of the null case. + } + var patches = []; + var patch = new diff_match_patch.patch_obj(); + var patchDiffLength = 0; // Keeping our own length var is faster in JS. + var char_count1 = 0; // Number of characters into the text1 string. + var char_count2 = 0; // Number of characters into the text2 string. + // Start with text1 (prepatch_text) and apply the diffs until we arrive at + // text2 (postpatch_text). We recreate the patches one by one to determine + // context info. + var prepatch_text = text1; + var postpatch_text = text1; + for (var x = 0; x < diffs.length; x++) { + var diff_type = diffs[x][0]; + var diff_text = diffs[x][1]; + + if (!patchDiffLength && diff_type !== DIFF_EQUAL) { + // A new patch starts here. + patch.start1 = char_count1; + patch.start2 = char_count2; + } + + switch (diff_type) { + case DIFF_INSERT: + patch.diffs[patchDiffLength++] = diffs[x]; + patch.length2 += diff_text.length; + postpatch_text = postpatch_text.substring(0, char_count2) + diff_text + + postpatch_text.substring(char_count2); + break; + case DIFF_DELETE: + patch.length1 += diff_text.length; + patch.diffs[patchDiffLength++] = diffs[x]; + postpatch_text = postpatch_text.substring(0, char_count2) + + postpatch_text.substring(char_count2 + + diff_text.length); + break; + case DIFF_EQUAL: + if (diff_text.length <= 2 * this.Patch_Margin && + patchDiffLength && diffs.length != x + 1) { + // Small equality inside a patch. + patch.diffs[patchDiffLength++] = diffs[x]; + patch.length1 += diff_text.length; + patch.length2 += diff_text.length; + } else if (diff_text.length >= 2 * this.Patch_Margin) { + // Time for a new patch. + if (patchDiffLength) { + this.patch_addContext_(patch, prepatch_text); + patches.push(patch); + patch = new diff_match_patch.patch_obj(); + patchDiffLength = 0; + // Unlike Unidiff, our patch lists have a rolling context. + // http://code.google.com/p/google-diff-match-patch/wiki/Unidiff + // Update prepatch text & pos to reflect the application of the + // just completed patch. + prepatch_text = postpatch_text; + char_count1 = char_count2; + } + } + break; + } + + // Update the current character count. + if (diff_type !== DIFF_INSERT) { + char_count1 += diff_text.length; + } + if (diff_type !== DIFF_DELETE) { + char_count2 += diff_text.length; + } + } + // Pick up the leftover patch if not empty. + if (patchDiffLength) { + this.patch_addContext_(patch, prepatch_text); + patches.push(patch); + } + + return patches; +}; + + +/** + * Given an array of patches, return another array that is identical. + * @param {!Array.} patches Array of Patch objects. + * @return {!Array.} Array of Patch objects. + */ +diff_match_patch.prototype.patch_deepCopy = function(patches) { + // Making deep copies is hard in JavaScript. + var patchesCopy = []; + for (var x = 0; x < patches.length; x++) { + var patch = patches[x]; + var patchCopy = new diff_match_patch.patch_obj(); + patchCopy.diffs = []; + for (var y = 0; y < patch.diffs.length; y++) { + patchCopy.diffs[y] = patch.diffs[y].slice(); + } + patchCopy.start1 = patch.start1; + patchCopy.start2 = patch.start2; + patchCopy.length1 = patch.length1; + patchCopy.length2 = patch.length2; + patchesCopy[x] = patchCopy; + } + return patchesCopy; +}; + + +/** + * Merge a set of patches onto the text. Return a patched text, as well + * as a list of true/false values indicating which patches were applied. + * @param {!Array.} patches Array of Patch objects. + * @param {string} text Old text. + * @return {!Array.>} Two element Array, containing the + * new text and an array of boolean values. + */ +diff_match_patch.prototype.patch_apply = function(patches, text) { + if (patches.length == 0) { + return [text, []]; + } + + // Deep copy the patches so that no changes are made to originals. + patches = this.patch_deepCopy(patches); + + var nullPadding = this.patch_addPadding(patches); + text = nullPadding + text + nullPadding; + + this.patch_splitMax(patches); + // delta keeps track of the offset between the expected and actual location + // of the previous patch. If there are patches expected at positions 10 and + // 20, but the first patch was found at 12, delta is 2 and the second patch + // has an effective expected position of 22. + var delta = 0; + var results = []; + for (var x = 0; x < patches.length; x++) { + var expected_loc = patches[x].start2 + delta; + var text1 = this.diff_text1(patches[x].diffs); + var start_loc; + var end_loc = -1; + if (text1.length > this.Match_MaxBits) { + // patch_splitMax will only provide an oversized pattern in the case of + // a monster delete. + start_loc = this.match_main(text, text1.substring(0, this.Match_MaxBits), + expected_loc); + if (start_loc != -1) { + end_loc = this.match_main(text, + text1.substring(text1.length - this.Match_MaxBits), + expected_loc + text1.length - this.Match_MaxBits); + if (end_loc == -1 || start_loc >= end_loc) { + // Can't find valid trailing context. Drop this patch. + start_loc = -1; + } + } + } else { + start_loc = this.match_main(text, text1, expected_loc); + } + if (start_loc == -1) { + // No match found. :( + results[x] = false; + // Subtract the delta for this failed patch from subsequent patches. + delta -= patches[x].length2 - patches[x].length1; + } else { + // Found a match. :) + results[x] = true; + delta = start_loc - expected_loc; + var text2; + if (end_loc == -1) { + text2 = text.substring(start_loc, start_loc + text1.length); + } else { + text2 = text.substring(start_loc, end_loc + this.Match_MaxBits); + } + if (text1 == text2) { + // Perfect match, just shove the replacement text in. + text = text.substring(0, start_loc) + + this.diff_text2(patches[x].diffs) + + text.substring(start_loc + text1.length); + } else { + // Imperfect match. Run a diff to get a framework of equivalent + // indices. + var diffs = this.diff_main(text1, text2, false); + if (text1.length > this.Match_MaxBits && + this.diff_levenshtein(diffs) / text1.length > + this.Patch_DeleteThreshold) { + // The end points match, but the content is unacceptably bad. + results[x] = false; + } else { + this.diff_cleanupSemanticLossless(diffs); + var index1 = 0; + var index2; + for (var y = 0; y < patches[x].diffs.length; y++) { + var mod = patches[x].diffs[y]; + if (mod[0] !== DIFF_EQUAL) { + index2 = this.diff_xIndex(diffs, index1); + } + if (mod[0] === DIFF_INSERT) { // Insertion + text = text.substring(0, start_loc + index2) + mod[1] + + text.substring(start_loc + index2); + } else if (mod[0] === DIFF_DELETE) { // Deletion + text = text.substring(0, start_loc + index2) + + text.substring(start_loc + this.diff_xIndex(diffs, + index1 + mod[1].length)); + } + if (mod[0] !== DIFF_DELETE) { + index1 += mod[1].length; + } + } + } + } + } + } + // Strip the padding off. + text = text.substring(nullPadding.length, text.length - nullPadding.length); + return [text, results]; +}; + + +/** + * Add some padding on text start and end so that edges can match something. + * Intended to be called only from within patch_apply. + * @param {!Array.} patches Array of Patch objects. + * @return {string} The padding string added to each side. + */ +diff_match_patch.prototype.patch_addPadding = function(patches) { + var paddingLength = this.Patch_Margin; + var nullPadding = ''; + for (var x = 1; x <= paddingLength; x++) { + nullPadding += String.fromCharCode(x); + } + + // Bump all the patches forward. + for (var x = 0; x < patches.length; x++) { + patches[x].start1 += paddingLength; + patches[x].start2 += paddingLength; + } + + // Add some padding on start of first diff. + var patch = patches[0]; + var diffs = patch.diffs; + if (diffs.length == 0 || diffs[0][0] != DIFF_EQUAL) { + // Add nullPadding equality. + diffs.unshift([DIFF_EQUAL, nullPadding]); + patch.start1 -= paddingLength; // Should be 0. + patch.start2 -= paddingLength; // Should be 0. + patch.length1 += paddingLength; + patch.length2 += paddingLength; + } else if (paddingLength > diffs[0][1].length) { + // Grow first equality. + var extraLength = paddingLength - diffs[0][1].length; + diffs[0][1] = nullPadding.substring(diffs[0][1].length) + diffs[0][1]; + patch.start1 -= extraLength; + patch.start2 -= extraLength; + patch.length1 += extraLength; + patch.length2 += extraLength; + } + + // Add some padding on end of last diff. + patch = patches[patches.length - 1]; + diffs = patch.diffs; + if (diffs.length == 0 || diffs[diffs.length - 1][0] != DIFF_EQUAL) { + // Add nullPadding equality. + diffs.push([DIFF_EQUAL, nullPadding]); + patch.length1 += paddingLength; + patch.length2 += paddingLength; + } else if (paddingLength > diffs[diffs.length - 1][1].length) { + // Grow last equality. + var extraLength = paddingLength - diffs[diffs.length - 1][1].length; + diffs[diffs.length - 1][1] += nullPadding.substring(0, extraLength); + patch.length1 += extraLength; + patch.length2 += extraLength; + } + + return nullPadding; +}; + + +/** + * Look through the patches and break up any which are longer than the maximum + * limit of the match algorithm. + * Intended to be called only from within patch_apply. + * @param {!Array.} patches Array of Patch objects. + */ +diff_match_patch.prototype.patch_splitMax = function(patches) { + var patch_size = this.Match_MaxBits; + for (var x = 0; x < patches.length; x++) { + if (patches[x].length1 <= patch_size) { + continue; + } + var bigpatch = patches[x]; + // Remove the big old patch. + patches.splice(x--, 1); + var start1 = bigpatch.start1; + var start2 = bigpatch.start2; + var precontext = ''; + while (bigpatch.diffs.length !== 0) { + // Create one of several smaller patches. + var patch = new diff_match_patch.patch_obj(); + var empty = true; + patch.start1 = start1 - precontext.length; + patch.start2 = start2 - precontext.length; + if (precontext !== '') { + patch.length1 = patch.length2 = precontext.length; + patch.diffs.push([DIFF_EQUAL, precontext]); + } + while (bigpatch.diffs.length !== 0 && + patch.length1 < patch_size - this.Patch_Margin) { + var diff_type = bigpatch.diffs[0][0]; + var diff_text = bigpatch.diffs[0][1]; + if (diff_type === DIFF_INSERT) { + // Insertions are harmless. + patch.length2 += diff_text.length; + start2 += diff_text.length; + patch.diffs.push(bigpatch.diffs.shift()); + empty = false; + } else if (diff_type === DIFF_DELETE && patch.diffs.length == 1 && + patch.diffs[0][0] == DIFF_EQUAL && + diff_text.length > 2 * patch_size) { + // This is a large deletion. Let it pass in one chunk. + patch.length1 += diff_text.length; + start1 += diff_text.length; + empty = false; + patch.diffs.push([diff_type, diff_text]); + bigpatch.diffs.shift(); + } else { + // Deletion or equality. Only take as much as we can stomach. + diff_text = diff_text.substring(0, + patch_size - patch.length1 - this.Patch_Margin); + patch.length1 += diff_text.length; + start1 += diff_text.length; + if (diff_type === DIFF_EQUAL) { + patch.length2 += diff_text.length; + start2 += diff_text.length; + } else { + empty = false; + } + patch.diffs.push([diff_type, diff_text]); + if (diff_text == bigpatch.diffs[0][1]) { + bigpatch.diffs.shift(); + } else { + bigpatch.diffs[0][1] = + bigpatch.diffs[0][1].substring(diff_text.length); + } + } + } + // Compute the head context for the next patch. + precontext = this.diff_text2(patch.diffs); + precontext = + precontext.substring(precontext.length - this.Patch_Margin); + // Append the end context for this patch. + var postcontext = this.diff_text1(bigpatch.diffs) + .substring(0, this.Patch_Margin); + if (postcontext !== '') { + patch.length1 += postcontext.length; + patch.length2 += postcontext.length; + if (patch.diffs.length !== 0 && + patch.diffs[patch.diffs.length - 1][0] === DIFF_EQUAL) { + patch.diffs[patch.diffs.length - 1][1] += postcontext; + } else { + patch.diffs.push([DIFF_EQUAL, postcontext]); + } + } + if (!empty) { + patches.splice(++x, 0, patch); + } + } + } +}; + + +/** + * Take a list of patches and return a textual representation. + * @param {!Array.} patches Array of Patch objects. + * @return {string} Text representation of patches. + */ +diff_match_patch.prototype.patch_toText = function(patches) { + var text = []; + for (var x = 0; x < patches.length; x++) { + text[x] = patches[x]; + } + return text.join(''); +}; + + +/** + * Parse a textual representation of patches and return a list of Patch objects. + * @param {string} textline Text representation of patches. + * @return {!Array.} Array of Patch objects. + * @throws {!Error} If invalid input. + */ +diff_match_patch.prototype.patch_fromText = function(textline) { + var patches = []; + if (!textline) { + return patches; + } + var text = textline.split('\n'); + var textPointer = 0; + var patchHeader = /^@@ -(\d+),?(\d*) \+(\d+),?(\d*) @@$/; + while (textPointer < text.length) { + var m = text[textPointer].match(patchHeader); + if (!m) { + throw new Error('Invalid patch string: ' + text[textPointer]); + } + var patch = new diff_match_patch.patch_obj(); + patches.push(patch); + patch.start1 = parseInt(m[1], 10); + if (m[2] === '') { + patch.start1--; + patch.length1 = 1; + } else if (m[2] == '0') { + patch.length1 = 0; + } else { + patch.start1--; + patch.length1 = parseInt(m[2], 10); + } + + patch.start2 = parseInt(m[3], 10); + if (m[4] === '') { + patch.start2--; + patch.length2 = 1; + } else if (m[4] == '0') { + patch.length2 = 0; + } else { + patch.start2--; + patch.length2 = parseInt(m[4], 10); + } + textPointer++; + + while (textPointer < text.length) { + var sign = text[textPointer].charAt(0); + try { + var line = decodeURI(text[textPointer].substring(1)); + } catch (ex) { + // Malformed URI sequence. + throw new Error('Illegal escape in patch_fromText: ' + line); + } + if (sign == '-') { + // Deletion. + patch.diffs.push([DIFF_DELETE, line]); + } else if (sign == '+') { + // Insertion. + patch.diffs.push([DIFF_INSERT, line]); + } else if (sign == ' ') { + // Minor equality. + patch.diffs.push([DIFF_EQUAL, line]); + } else if (sign == '@') { + // Start of next patch. + break; + } else if (sign === '') { + // Blank line? Whatever. + } else { + // WTF? + throw new Error('Invalid patch mode "' + sign + '" in: ' + line); + } + textPointer++; + } + } + return patches; +}; + + +/** + * Class representing one patch operation. + * @constructor + */ +diff_match_patch.patch_obj = function() { + /** @type {!Array.} */ + this.diffs = []; + /** @type {?number} */ + this.start1 = null; + /** @type {?number} */ + this.start2 = null; + /** @type {number} */ + this.length1 = 0; + /** @type {number} */ + this.length2 = 0; +}; + + +/** + * Emmulate GNU diff's format. + * Header: @@ -382,8 +481,9 @@ + * Indicies are printed as 1-based, not 0-based. + * @return {string} The GNU diff string. + */ +diff_match_patch.patch_obj.prototype.toString = function() { + var coords1, coords2; + if (this.length1 === 0) { + coords1 = this.start1 + ',0'; + } else if (this.length1 == 1) { + coords1 = this.start1 + 1; + } else { + coords1 = (this.start1 + 1) + ',' + this.length1; + } + if (this.length2 === 0) { + coords2 = this.start2 + ',0'; + } else if (this.length2 == 1) { + coords2 = this.start2 + 1; + } else { + coords2 = (this.start2 + 1) + ',' + this.length2; + } + var text = ['@@ -' + coords1 + ' +' + coords2 + ' @@\n']; + var op; + // Escape the body of the patch with %xx notation. + for (var x = 0; x < this.diffs.length; x++) { + switch (this.diffs[x][0]) { + case DIFF_INSERT: + op = '+'; + break; + case DIFF_DELETE: + op = '-'; + break; + case DIFF_EQUAL: + op = ' '; + break; + } + text[x + 1] = op + encodeURI(this.diffs[x][1]) + '\n'; + } + return text.join('').replace(/%20/g, ' '); +}; + + +// Export these global variables so that they survive Google's JS compiler. +// In a browser, 'this' will be 'window'. +// Users of node.js should 'require' the uncompressed version since Google's +// JS compiler may break the following exports for non-browser environments. +this['diff_match_patch'] = diff_match_patch; +this['DIFF_DELETE'] = DIFF_DELETE; +this['DIFF_INSERT'] = DIFF_INSERT; +this['DIFF_EQUAL'] = DIFF_EQUAL; \ No newline at end of file diff --git a/lib/server/main.js b/lib/server/main.js index 0a7340e2..14164184 100644 --- a/lib/server/main.js +++ b/lib/server/main.js @@ -11,7 +11,7 @@ SLASH, ISWIN32, ext, - path, fs, zlib, url, pipe, CloudFunc, + path, fs, zlib, url, pipe, CloudFunc, diffPatch, OK, FILE_NOT_FOUND, MOVED_PERMANENTLY, REQUEST, RESPONSE, @@ -108,6 +108,9 @@ exports.auth = srvrequire('auth').auth, exports.appcache = srvrequire('appcache'), exports.dir = srvrequire('dir'), + diffPatch = librequire('diff/diff-match-patch').diff_match_patch, + exports.diff = new (librequire('diff').DiffProto)(diffPatch), + console.log(exports.diff); exports.rest = srvrequire('rest').api, exports.update = srvrequire('update'), exports.ischanged = srvrequire('ischanged'); diff --git a/lib/server/rest.js b/lib/server/rest.js index 23cd84bc..0b1a8feb 100644 --- a/lib/server/rest.js +++ b/lib/server/rest.js @@ -20,6 +20,7 @@ pipe = main.pipe, CloudFunc = main.cloudfunc, dir = main.dir, + diff = main.diff, JSONDIR = main.JSONDIR, OK = 200, sendError = main.sendError, @@ -145,7 +146,54 @@ else sendMsg(pParams, 'make dir', p.name); }); - + else if(lQuery === 'patch') + getBody(p.request, function(pPatch) { + fs.readFile(p.name, Util.call(read, pParams)); + + function read(pParams) { + var lDiff, lStr, p, lData, lName, + lRet = main.checkCallBackParams(pParams) && + main.checkParams(pParams.params); + + if (lRet) { + p = pParams; + lName = p.params.name; + + if (p.error) + main.sendError(p.params, p.error); + else { + lStr = p.data.toString(); + lRet = Util.tryCatchLog(function() { + lDiff = diff.applyPatch(lStr, pPatch); + }); + + if (lDiff && !lRet) + fs.writeFile(lName, lDiff, Util.call(write, p.params)); + else { + lName = path.basename(lName); + sendMsg(p.params, 'patch', lName, 'fail'); + } + } + } + } + + function write(pParams) { + var p, lName, + lRet = main.checkCallBackParams(pParams) && + main.checkParams(pParams.params); + + if (lRet) { + p = pParams; + + if (p.error) + main.sendError(p.params, p.error); + else { + lName = path.basename(p.params.name); + sendMsg(p.params, 'patch', lName); + } + } + } + }); else pipe.create({ read : p.request, From abbf260df8c7f18366c7035e6b59e30bb967677e Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 12 Nov 2013 10:32:58 +0000 Subject: [PATCH 033/315] feature(config) add diff --- json/config.json | 1 + 1 file changed, 1 insertion(+) diff --git a/json/config.json b/json/config.json index bde9a007..26dd04be 100644 --- a/json/config.json +++ b/json/config.json @@ -2,6 +2,7 @@ "apiURL": "/api/v1", "appСache": false, "analytics": true, + "diff": false, "localStorage": true, "minify": true, "online": true, From 610cd2c1fa4ca3bd5e50e4fdbe751d6a99357d07 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 12 Nov 2013 10:33:37 +0000 Subject: [PATCH 034/315] chore(help) add "," --- HELP.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/HELP.md b/HELP.md index 8fec6ed4..de6c6e7b 100644 --- a/HELP.md +++ b/HELP.md @@ -148,7 +148,7 @@ All main configuration could be done via [config.json](json/config.json "Config" "apiURL" :"/api/v1", "appCache" : false, /* cache files for offline use */ "analytics" : true, /* google analytics suport */ - "diff" : false, /* when save - send patch not whole file */ + "diff" : false, /* when save - send patch, not whole file */ "localStorage" : true, /* cache directory data */ "minify" : true /* minification of js,css,html and img */ "online" : true, /* load js files from cdn or local path */ From c8254b07cf806fff8de7b591ed7282f504b0d626 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 12 Nov 2013 10:45:34 +0000 Subject: [PATCH 035/315] fix(diff) applyPatch: results -> results[0] --- lib/diff.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/diff.js b/lib/diff.js index ce3bf1ac..b0e44ecf 100644 --- a/lib/diff.js +++ b/lib/diff.js @@ -12,7 +12,7 @@ this.applyPatch = function(oldText, patch) { var patches = dmp.patch_fromText(patch), - results = dmp.patch_apply(patches, oldText); + results = dmp.patch_apply(patches, oldText)[0]; return results; }; From 30be394ace0bde4767a63002830a03ab828c69b3 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 12 Nov 2013 11:16:20 +0000 Subject: [PATCH 036/315] refactor(diff) applyPatch --- lib/diff.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/diff.js b/lib/diff.js index b0e44ecf..21ed339c 100644 --- a/lib/diff.js +++ b/lib/diff.js @@ -12,9 +12,10 @@ this.applyPatch = function(oldText, patch) { var patches = dmp.patch_fromText(patch), - results = dmp.patch_apply(patches, oldText)[0]; + result = dmp.patch_apply(patches, oldText); + newText = result[0]; - return results; + return newText; }; }; })(this); From 8ad5d09e0132945bf12c742f0908e6b3f79769d4 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 12 Nov 2013 12:16:37 +0000 Subject: [PATCH 037/315] feature(client) add setConfig --- lib/client.js | 4 ++-- lib/client/config.js | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/client.js b/lib/client.js index 6dcdb299..0ee020f4 100644 --- a/lib/client.js +++ b/lib/client.js @@ -298,8 +298,8 @@ var Util, DOM, CloudFunc, CloudCmd; return lGetSysFile; } - - + CloudCmd.setConfig = function(config) { Config = config }; + CloudCmd.setConfig = function(config) {Config = config}; CloudCmd.getConfig = getSystemFile(Config, CloudCmd.JSONDIR + 'config.json'); CloudCmd.getModules = getSystemFile(Modules, CloudCmd.JSONDIR + 'modules.json'); CloudCmd.getFileTemplate = getSystemFile(FileTemplate, CloudCmd.HTMLDIR + 'file.html'); diff --git a/lib/client/config.js b/lib/client/config.js index 8aff72d3..dfc0a658 100644 --- a/lib/client/config.js +++ b/lib/client/config.js @@ -137,6 +137,7 @@ var CloudCmd, Util, DOM; obj[name] = data; CONFIG[name] = data; + CloudCmd.setConfig(CONFIG); DOM.RESTful.config(obj); } From e0d83457600db0451584b7692bbfed415ada7db7 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 12 Nov 2013 12:18:58 +0000 Subject: [PATCH 038/315] refactor(config) key --- lib/client/config.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/client/config.js b/lib/client/config.js index dfc0a658..565a38ca 100644 --- a/lib/client/config.js +++ b/lib/client/config.js @@ -8,7 +8,6 @@ var CloudCmd, Util, DOM; var Key = CloudCmd.Key, Images = DOM.Images, Events = DOM.Events, - ESC = CloudCmd.Key.ESC, INPUT = 'INPUT', CONFIG, TEMPLATE, @@ -143,7 +142,8 @@ var CloudCmd, Util, DOM; } function key(event) { - var keyCode = event.keyCode; + var keyCode = event.keyCode, + ESC = Key.ESC; if (keyCode === ESC) Config.hide(); From 66faa8639e715f4bd933c4583357d7ce470bceb0 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 12 Nov 2013 12:25:11 +0000 Subject: [PATCH 039/315] refactor(config) fillTemplate --- lib/client/config.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/client/config.js b/lib/client/config.js index 565a38ca..880829f1 100644 --- a/lib/client/config.js +++ b/lib/client/config.js @@ -58,9 +58,10 @@ var CloudCmd, Util, DOM; } function fillTemplate() { - Util.ifExec(CONFIG, function() { + CloudCmd.getConfig(function(config) { var i, n, div, data, li, param, obj = {}; + CONFIG = config; Util.copyObj(CONFIG, obj); changeConfig(obj); data = Util.render(TEMPLATE, obj); @@ -83,11 +84,6 @@ var CloudCmd, Util, DOM; CloudCmd.View.show(div, null, { autoSize: true }); - }, function(callback) { - CloudCmd.getConfig(function(config){ - CONFIG = config; - callback(); - }); }); } From e01e08590770986b97319f01659c71724a7bce67 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 12 Nov 2013 12:34:13 +0000 Subject: [PATCH 040/315] chore(client) rm lFM --- lib/client.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/lib/client.js b/lib/client.js index 0ee020f4..7cd5e32d 100644 --- a/lib/client.js +++ b/lib/client.js @@ -275,9 +275,6 @@ var Util, DOM, CloudFunc, CloudCmd; DOM.setCurrentFile(lCurrent); } - /* показываем элементы, которые будут работать только, если есть js */ - var lFM = DOM.getFM(); - CloudCmd.Key(); } From 1bde7dcff088beb803fe6d535ee29e252ceb8186 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 12 Nov 2013 12:53:03 +0000 Subject: [PATCH 041/315] chore(main) rm console.log --- lib/server/main.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/server/main.js b/lib/server/main.js index 14164184..38f64f17 100644 --- a/lib/server/main.js +++ b/lib/server/main.js @@ -110,7 +110,6 @@ exports.dir = srvrequire('dir'), diffPatch = librequire('diff/diff-match-patch').diff_match_patch, exports.diff = new (librequire('diff').DiffProto)(diffPatch), - console.log(exports.diff); exports.rest = srvrequire('rest').api, exports.update = srvrequire('update'), exports.ischanged = srvrequire('ischanged'); From 64c5f477efacf9b400e433b608a436e5bc4db84c Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 13 Nov 2013 08:06:13 +0000 Subject: [PATCH 042/315] refactor(config) change --- lib/client/config.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/client/config.js b/lib/client/config.js index 880829f1..5d225ea3 100644 --- a/lib/client/config.js +++ b/lib/client/config.js @@ -131,8 +131,10 @@ var CloudCmd, Util, DOM; data = el.value; obj[name] = data; - CONFIG[name] = data; - CloudCmd.setConfig(CONFIG); + + CloudCmd.setConfig(CONFIG, function() { + CONFIG[name] = data; + }); DOM.RESTful.config(obj); } From 52991e1047ec09abf90ddee26302441967174a7c Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 13 Nov 2013 08:51:23 +0000 Subject: [PATCH 043/315] fix(edit) diff --- lib/client/edit.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/client/edit.js b/lib/client/edit.js index 5642c08d..1ae9e9f0 100644 --- a/lib/client/edit.js +++ b/lib/client/edit.js @@ -136,6 +136,7 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch; DOM.RESTful.save(lPath, lValue, Edit.showMessage, query); }, function(callback) { diff(lValue, function(diff) { + Value = lValue; Util.exec(callback, diff); }); }); From 2fef19c76e781bc9e101b573e56a10fecf1943af Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 13 Nov 2013 09:21:24 +0000 Subject: [PATCH 044/315] refactor(cloudcmd) constructor init: public -> private --- lib/client.js | 8 ++++++-- lib/client/config.js | 12 ++++++------ lib/client/console.js | 12 ++++++------ lib/client/edit.js | 12 ++++++------ lib/client/help.js | 14 +++++++------- lib/client/key.js | 4 ++-- lib/client/menu.js | 12 ++++++------ lib/client/view.js | 25 +++++++++++++------------ 8 files changed, 52 insertions(+), 47 deletions(-) diff --git a/lib/client.js b/lib/client.js index 7cd5e32d..3f4226b9 100644 --- a/lib/client.js +++ b/lib/client.js @@ -107,7 +107,10 @@ var Util, DOM, CloudFunc, CloudCmd; return DOM.jsload(CloudCmd.LIBDIRCLIENT + lPath, lFunc || function() { - Util.exec(CloudCmd[lName].init, pArg); + var Proto = CloudCmd[lName]; + + if (Util.isFunction(Proto)) + CloudCmd[lName] = new Proto(pArg); }); }; } @@ -186,7 +189,8 @@ var Util, DOM, CloudFunc, CloudCmd; /* привязываем клавиши к функциям */ path : 'key.js', func : function() { - Key = CloudCmd.Key; + Key = new CloudCmd.Key(); + CloudCmd.Key = Key; Key.bind(); } }); diff --git a/lib/client/config.js b/lib/client/config.js index 5d225ea3..13bc2c32 100644 --- a/lib/client/config.js +++ b/lib/client/config.js @@ -2,9 +2,9 @@ var CloudCmd, Util, DOM; (function(CloudCmd, Util, DOM){ 'use strict'; - CloudCmd.Config = new ConfigProto(CloudCmd, Util, DOM); + CloudCmd.Config = ConfigProto; - function ConfigProto(CloudCmd, Util, DOM){ + function ConfigProto() { var Key = CloudCmd.Key, Images = DOM.Images, Events = DOM.Events, @@ -13,7 +13,7 @@ var CloudCmd, Util, DOM; TEMPLATE, Config = this; - this.init = function(pCallBack){ + function init(pCallBack) { Util.loadOnLoad([ Config.show, CloudCmd.View, @@ -21,9 +21,7 @@ var CloudCmd, Util, DOM; DOM.Events.addKey(listener); DOM.setButtonKey('f10', Config.show); - - delete Config.init; - }; + } this.show = function() { var funcs = [ @@ -146,6 +144,8 @@ var CloudCmd, Util, DOM; if (keyCode === ESC) Config.hide(); } + + init(); } })(CloudCmd, Util, DOM); diff --git a/lib/client/console.js b/lib/client/console.js index 294d3992..c7879021 100644 --- a/lib/client/console.js +++ b/lib/client/console.js @@ -7,9 +7,9 @@ var CloudCmd, Util, DOM, $; error : '' }; - CloudCmd.Console = new ConsoleProto(CloudCmd, Util, DOM); + CloudCmd.Console = ConsoleProto; - function ConsoleProto(CloudCmd, Util, DOM) { + function ConsoleProto(CallBack) { var Name = 'Console', Loading, jqconsole, @@ -19,7 +19,7 @@ var CloudCmd, Util, DOM, $; Images = DOM.Images, Console = this; - this.init = function(pCallBack) { + function init() { var lFunc, lIsFunc = Util.isFunction(CloudCmd.View); Loading = true; @@ -39,9 +39,7 @@ var CloudCmd, Util, DOM, $; DOM.Events.addKey(listener); DOM.setButtonKey('~', Console.show); - - delete Console.init; - }; + } this.show = function() { if (!Loading) { @@ -170,6 +168,8 @@ var CloudCmd, Util, DOM, $; } } + + init(); } })(CloudCmd, Util, DOM); diff --git a/lib/client/edit.js b/lib/client/edit.js index 1ae9e9f0..81760362 100644 --- a/lib/client/edit.js +++ b/lib/client/edit.js @@ -2,9 +2,9 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch; (function(CloudCmd, Util, DOM, CloudFunc) { 'use strict'; - CloudCmd.Edit = new EditProto(CloudCmd, Util, DOM, CloudFunc); + CloudCmd.Edit = EditProto; - function EditProto(CloudCmd, Util, DOM, CloudFunc) { + function EditProto(CallBack) { var Name = 'Edit', Loading = false, DIR = CloudCmd.LIBDIRCLIENT + 'edit/', @@ -19,7 +19,7 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch; Element; - this.init = function(pCallBack) { + function init() { var lFunc, lIsFunc = Util.isFunction(CloudCmd.View); Loading = true; @@ -36,9 +36,7 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch; DOM.Events.addKey(listener); DOM.setButtonKey('f4', Edit.show); - - delete Edit.init; - }; + } this.show = function(pValue) { var lName = DOM.getCurrentName(), @@ -222,6 +220,8 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch; DOM.show(Msg); setTimeout(Util.retExec(DOM.hide, Msg), 2000); }; + + init(); } })(CloudCmd, Util, DOM, CloudFunc); diff --git a/lib/client/help.js b/lib/client/help.js index 5229cd08..37d13030 100644 --- a/lib/client/help.js +++ b/lib/client/help.js @@ -2,14 +2,14 @@ var CloudCmd, Util, DOM; (function(CloudCmd, Util, DOM){ 'use strict'; - CloudCmd.Help = new HelpProto(CloudCmd, Util, DOM); + CloudCmd.Help = HelpProto; - function HelpProto(CloudCmd, Util, DOM){ + function HelpProto(CallBack){ var Key = CloudCmd.Key, Images = DOM.Images, Help = this; - this.init = function(pCallBack) { + function init() { Util.loadOnLoad([ Help.show, CloudCmd.View, @@ -17,9 +17,7 @@ var CloudCmd, Util, DOM; DOM.Events.addKey(listener); DOM.setButtonKey('f1', Help.show); - - delete Help.init; - }; + } this.show = function() { Images.showLoad({top:true}); @@ -77,6 +75,8 @@ var CloudCmd, Util, DOM; if (lIsBind && lKey === lF1) Help.show(); } + + init(); } -})(CloudCmd, Util, DOM); \ No newline at end of file +})(CloudCmd, Util, DOM); diff --git a/lib/client/key.js b/lib/client/key.js index b8d91b74..aabca0e9 100644 --- a/lib/client/key.js +++ b/lib/client/key.js @@ -45,9 +45,9 @@ var CloudCmd, Util, DOM; }; KeyProto.prototype = KEY; - CloudCmd.Key = new KeyProto(CloudCmd, Util, DOM); + CloudCmd.Key = KeyProto; - function KeyProto(CloudCmd, Util, DOM) { + function KeyProto() { var Key = this, Binded, lTabPanel = { diff --git a/lib/client/menu.js b/lib/client/menu.js index 392d61bb..5a576739 100644 --- a/lib/client/menu.js +++ b/lib/client/menu.js @@ -6,9 +6,9 @@ var CloudCmd, Util, DOM, CloudFunc, $; (function(CloudCmd, Util, DOM, CloudFunc){ 'use strict'; - CloudCmd.Menu = new MenuProto(CloudCmd, Util, DOM, CloudFunc); + CloudCmd.Menu = MenuProto; - function MenuProto(CloudCmd, Util, DOM, CloudFunc) { + function MenuProto(pPosition) { var Name = 'Menu', Loading = false, Key = CloudCmd.Key, @@ -20,7 +20,7 @@ var CloudCmd, Util, DOM, CloudFunc, $; this.ENABLED = false; - this.init = function(pPosition){ + function init() { Loading = true; Position = pPosition; @@ -39,9 +39,7 @@ var CloudCmd, Util, DOM, CloudFunc, $; Events.dispatch('contextmenu', lCurrent); }); - - delete Menu.init; - }; + } this.show = function() { if (!Loading) { @@ -320,5 +318,7 @@ var CloudCmd, Util, DOM, CloudFunc, $; else if (lKey === lESC) Key.setBind(); } + + init(); } })(CloudCmd, Util, DOM, CloudFunc); diff --git a/lib/client/view.js b/lib/client/view.js index 2f4a702d..9166a623 100644 --- a/lib/client/view.js +++ b/lib/client/view.js @@ -3,9 +3,9 @@ var CloudCmd, Util, DOM, CloudFunc, $; (function(CloudCmd, Util, DOM, CloudFunc){ 'use strict'; - CloudCmd.View = new ViewProto(CloudCmd, Util, DOM, CloudFunc); + CloudCmd.View = ViewProto; - function ViewProto(CloudCmd, Util, DOM, CloudFunc){ + function ViewProto(CallBack) { var Name = 'View', Loading = false, Key = CloudCmd.Key, @@ -42,19 +42,20 @@ var CloudCmd, Util, DOM, CloudFunc, $; padding : 0 }; - this.init = function(pCallBack) { + function init() { var lFunc, lIsFunc, lIsCallBack; Loading = true; - if (pCallBack){ - lIsFunc = Util.isFunction(pCallBack); - lIsCallBack = Util.isFunction(pCallBack.callback); + + if (CallBack){ + lIsFunc = Util.isFunction(CallBack); + lIsCallBack = Util.isFunction(CallBack.callback); } if (lIsFunc) - lFunc = pCallBack; + lFunc = CallBack; else if (lIsCallBack) - lFunc = pCallBack.callback; + lFunc = CallBack.callback; Util.loadOnLoad([ lFunc || Util.retExec(View.show, null), @@ -64,9 +65,7 @@ var CloudCmd, Util, DOM, CloudFunc, $; DOM.Events.addKey(listener); DOM.setButtonKey('f3', view); - - delete View.init; - }; + } /** * function shows FancyBox @@ -168,6 +167,8 @@ var CloudCmd, Util, DOM, CloudFunc, $; DOM.preventDefault(pEvent); } } + + init(); } -})(CloudCmd, Util, DOM, CloudFunc); \ No newline at end of file +})(CloudCmd, Util, DOM, CloudFunc); From 6e213b35e2c6ca0cecaa1dec3199c4012ec5864b Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 13 Nov 2013 15:28:24 +0000 Subject: [PATCH 045/315] feature(rest) add checkSendError --- lib/server/rest.js | 87 ++++++++++++++++++++-------------------------- 1 file changed, 38 insertions(+), 49 deletions(-) diff --git a/lib/server/rest.js b/lib/server/rest.js index 0b1a8feb..32048eed 100644 --- a/lib/server/rest.js +++ b/lib/server/rest.js @@ -110,19 +110,14 @@ case 'GET': if (Util.strCmp(lQuery, 'size')) dir.getSize(p.name, function(pErr, pSize) { - if (pErr) - sendError(p, pErr); - else { + checkSendError(pError, p, function() { lSize = CloudFunc.getShortSize(pSize); sendResponse(p, lSize); - } - + }); }); else fs.stat(p.name, function(pError, pStat) { - if (pError) - sendError(p, pError); - else + checkSendError(pError, p, function() { if (!pStat.isDirectory()) main.sendFile(p); else @@ -135,16 +130,16 @@ sendResponse(p); } }); + }); }); break; case 'PUT': if (lQuery === 'dir') fs.mkdir(p.name, function(pError) { - if (pError) - sendError(pParams, pError); - else + heckSendError(pError, pParams, function() { sendMsg(pParams, 'make dir', p.name); + }); }); else if(lQuery === 'patch') getBody(p.request, function(pPatch) { @@ -159,9 +154,7 @@ p = pParams; lName = p.params.name; - if (p.error) - main.sendError(p.params, p.error); - else { + checkSendError(p.error, p.params, function() { lStr = p.data.toString(); lRet = Util.tryCatchLog(function() { lDiff = diff.applyPatch(lStr, pPatch); @@ -173,7 +166,7 @@ lName = path.basename(lName); sendMsg(p.params, 'patch', lName, 'fail'); } - } + }); } } @@ -185,12 +178,10 @@ if (lRet) { p = pParams; - if (p.error) - main.sendError(p.params, p.error); - else { + checkSendError(p.error, p.params, function() { lName = path.basename(p.params.name); sendMsg(p.params, 'patch', lName); - } + }); } } }); @@ -199,14 +190,10 @@ read : p.request, to : p.name, callback : function(pError) { - var lName; - - if (pError) - sendError(pParams, pError); - else { - lName = path.basename(p.name); + checkSendError(pError, pParams, function() { + var lName = path.basename(p.name); sendMsg(pParams, 'save', lName); - } + }); } }); break; @@ -214,11 +201,10 @@ case 'DELETE': if (lQuery === 'dir') fs.rmdir(p.name, function(pError){ - if (pError) - sendError(pParams, pError); - else + checkSendError(pError, pParams, function() { sendMsg(pParams, 'delete', p.name); }); + }); else if (lQuery === 'files') { getBody(p.request, function(pBody) { var lFiles = Util.parseJSON(pBody), @@ -237,16 +223,13 @@ ++lAssync; - if (p.error){ - sendError(pParams, p.error); - log(p.error); - } - else + checkSendError(p.error, pParams, function() { if (p.data.isDirectory()) fs.rmdir(d.name, log); else if (p.data.isFile()) fs.unlink(d.name, log); + }); if (lAssync === n && !p.error) sendMsg(pParams, 'delete', pBody); @@ -264,10 +247,9 @@ }); }else fs.unlink(p.name, function(pError) { - if (pError) - sendError(pParams, pError); - else + checkSendError(pError, pParams, function() { sendMsg(pParams, 'delete', p.name); + }); }); break; @@ -356,17 +338,18 @@ case 'mv': if( Util.checkObjTrue(lFiles, ['from', 'to']) ) fs.rename(lFiles.from, lFiles.to, function(pError) { - if (pError) - sendError(pParams, pError); - else + checkSendError(pError, pParams, function() { sendResponse(pParams); + }); }); else sendError(pParams, p.data); break; case 'cp': - if (Util.checkObjTrue(lFiles, ['from', 'to'])) + if (!Util.checkObjTrue(lFiles, ['from', 'to'])) + sendError(pParams, p.data); + else pipe.create({ from : lFiles.from, to : lFiles.to, @@ -377,12 +360,13 @@ sendMsg(pParams, 'copy', lFiles.to); } }); - else - sendError(pParams, p.data); + break; case 'zip': - if (Util.checkObjTrue(lFiles, ['from'])) + if (!Util.checkObjTrue(lFiles, ['from'])) + sendError(pParams, p.data); + else pipe.create({ from : lFiles.from, to : lFiles.to || lFiles.from + '.zip', @@ -398,8 +382,7 @@ } } }); - else - sendError(pParams, p.data); + break; case 'config': @@ -411,10 +394,9 @@ json = Util.stringifyJSON(config) + '\n'; fs.writeFile(JSONDIR + 'config.json', json, function(error) { - if (error) - sendError(pParams, error); - else + checkSendError(error, pParams, function() { sendMsg(pParams, 'config', name); + }); }); break; @@ -451,4 +433,11 @@ sendResponse(pParams, msg); } + function checkSendError(error, params, callback) { + if (error) + sendError(params, error); + else + Util.exec(callback); + } + })(); From 4bf246f7ec076292c9d89968e98b7cb8bde78858 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 13 Nov 2013 15:35:58 +0000 Subject: [PATCH 046/315] feature(rest) GET: rm kill, zip; PUT: rm cmd --- lib/server/rest.js | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/lib/server/rest.js b/lib/server/rest.js index 32048eed..75a70697 100644 --- a/lib/server/rest.js +++ b/lib/server/rest.js @@ -277,17 +277,6 @@ }; send(p); break; - - case 'zip': - main.sendFile(pParams); - break; - - case 'kill': - p.data = { - mesage: 'Cloud Commander was killed' - }; - send(p); - break; default: p.data = { @@ -325,16 +314,6 @@ }); break; - case 'cmd': - main.child_process.exec(p.body, function(pError, pStdout, pStderr) { - var lError = pError || pStderr; - if (!lError) - sendResponse(pParams, pStdout); - else - sendError(pParams, lError); - }); - break; - case 'mv': if( Util.checkObjTrue(lFiles, ['from', 'to']) ) fs.rename(lFiles.from, lFiles.to, function(pError) { From 13c4dfcc69c1c67a4a4d8188d54045ad3f678399 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 13 Nov 2013 15:37:41 +0000 Subject: [PATCH 047/315] refactor(rest) zip: add checkSendError --- lib/server/rest.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/lib/server/rest.js b/lib/server/rest.js index 75a70697..abeeb24b 100644 --- a/lib/server/rest.js +++ b/lib/server/rest.js @@ -351,14 +351,10 @@ to : lFiles.to || lFiles.from + '.zip', zip : true, callback : function(pError) { - var lName; - - if (pError) - sendError(pParams, pError); - else { - lName = path.basename(lFiles.from); + checkSendError(pError, pParams, function() { + var lName = path.basename(lFiles.from); sendMsg(pParams, 'zip', lName); - } + }); } }); From f257ef42fc2ef6a6ca38cdf8263890244d71d456 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 14 Nov 2013 07:41:08 +0000 Subject: [PATCH 048/315] feature(socket) add chat --- lib/server/socket.js | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/lib/server/socket.js b/lib/server/socket.js index 32fa379c..de862e58 100644 --- a/lib/server/socket.js +++ b/lib/server/socket.js @@ -12,7 +12,7 @@ Util = main.util, mainpackage = main.mainpackage, CLOUDCMD = mainpackage.name, - + lListen, ClientFuncs = [], OnMessageFuncs = [], INFO_LOG_LEVEL = 2, @@ -40,7 +40,7 @@ * @pServer {Object} started server object */ exports.listen = function(pServer) { - var lRet, lListen, lConnNum, lMsg, lConn_func; + var lRet, lConnNum, lMsg, lConn_func; if (io) { lListen = io.listen(pServer), @@ -119,10 +119,12 @@ */ function onMessage(pConnNum, pSocket) { return function(pCommand) { - var lMsg, lJSON, lWinCommand, lExec_func, lDir, + var lMsg, lJSON, lWinCommand, lExec_func, lDir, firstChar, + connName, lHome, lError, lRet, lExecSymbols, isContain; - Util.log('#' + pConnNum + ': ' + pCommand); + connName = '#' + pConnNum + ': '; + Util.log(connName + pCommand); if (Util.isContainStrAtBegin(pCommand, CLOUDCMD)) { pCommand = Util.removeStr(pCommand, CLOUDCMD); @@ -192,10 +194,22 @@ ClientFuncs[pConnNum] = getExec(pSocket, pConnNum); lExec_func = ClientFuncs[pConnNum]; - lExecSymbols = ['*','#', '&', '{', '}', '|', '\'', '"']; + lExecSymbols = ['*', '&', '{', '}', '|', '\'', '"']; isContain = Util.isContainStr(pCommand, lExecSymbols); + firstChar = pCommand[0]; - if (pCommand[0] === ' ' || isContain) + if (firstChar === '#') { + pCommand = pCommand.slice(1); + pCommand = connName + pCommand +'\n'; + + lJSON = { + stdout: pCommand + }; + + lMsg = Util.stringifyJSON(lJSON); + + lListen.sockets.emit('message', lMsg); + } else if (firstChar === ' ' || isContain) exec(pCommand, lExec_func); else getSpawn(pSocket, pConnNum, pCommand); From 071ad9efee214359f10a808bffb6698dfa8dd0d7 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 14 Nov 2013 08:03:10 +0000 Subject: [PATCH 049/315] feature(socket) add jsonSend --- lib/server/socket.js | 76 +++++++++++++++++++++----------------------- 1 file changed, 36 insertions(+), 40 deletions(-) diff --git a/lib/server/socket.js b/lib/server/socket.js index de862e58..341e261c 100644 --- a/lib/server/socket.js +++ b/lib/server/socket.js @@ -12,7 +12,6 @@ Util = main.util, mainpackage = main.mainpackage, CLOUDCMD = mainpackage.name, - lListen, ClientFuncs = [], OnMessageFuncs = [], INFO_LOG_LEVEL = 2, @@ -43,10 +42,10 @@ var lRet, lConnNum, lMsg, lConn_func; if (io) { - lListen = io.listen(pServer), + io = io.listen(pServer), lConnNum = 0; - lListen.set('log level', INFO_LOG_LEVEL); + io.set('log level', INFO_LOG_LEVEL); /* * on Win7 application is crashing, @@ -56,30 +55,27 @@ * */ if (!WIN32) { - lListen.enable('browser client minification'); - lListen.enable('browser client gzip'); - lListen.enable('browser client etag'); + io.enable('browser client minification'); + io.enable('browser client gzip'); + io.enable('browser client etag'); } - lListen.set('transports', [ + io.set('transports', [ 'websocket', 'htmlfile', 'xhr-polling', 'jsonp-polling' ]); - lRet = lListen.sockets.on('connection', function (socket) { - var lJSON; + lRet = io.sockets.on('connection', function (socket) { ++lConnNum; if(!OnMessageFuncs[lConnNum]) { lMsg = log(lConnNum, 'connected\n'); - lJSON = { - stdout : lMsg - }; - lMsg = Util.stringifyJSON(lJSON); - socket.send(lMsg); + jsonSend(socket, { + stdout : lMsg + }); OnMessageFuncs[lConnNum] = onMessage(lConnNum, socket); lConn_func = OnMessageFuncs[lConnNum]; @@ -88,7 +84,11 @@ socket.on('disconnect', Util.call(disconnect, lConnNum)); } else { lMsg = log(lConnNum, ' in use. Reconnecting...'); - socket.send('{"stdout":"' + lMsg + '"}'); + + jsonSend(socket, { + stdout: lMsg + }); + socket.disconnect(); } @@ -119,7 +119,7 @@ */ function onMessage(pConnNum, pSocket) { return function(pCommand) { - var lMsg, lJSON, lWinCommand, lExec_func, lDir, firstChar, + var lMsg, lWinCommand, lExec_func, lDir, firstChar, connName, lHome, lError, lRet, lExecSymbols, isContain; @@ -142,14 +142,11 @@ pCommand = 'kill -9 ' + process.pid; } else { - lJSON = { + jsonSend(pSocket, { stdout : CLOUDCMD + ' exit \n' + CLOUDCMD + ' update \n', stderr : null - }; - - lMsg = Util.stringifyJSON( lJSON ); - pSocket.send(lMsg); + }); Util.log('received from client: ' + pCommand); Util.log('sended to client: ' + lMsg); @@ -168,13 +165,11 @@ if (!lError) lRet = true; else { - lJSON = { - stderr: Util.stringifyJSON( lError ) - }; + lError = Util.stringifyJSON(lError); - lMsg = Util.stringifyJSON( lJSON ); - - pSocket.send(lMsg); + jsonSend(pSocket, { + stderr: lError + }); } } @@ -200,15 +195,14 @@ if (firstChar === '#') { pCommand = pCommand.slice(1); - pCommand = connName + pCommand +'\n'; + pCommand = connName + pCommand; + pCommand = Util.addNewLine(pCommand); - lJSON = { + lMsg = Util.stringifyJSON({ stdout: pCommand - }; + }); - lMsg = Util.stringifyJSON(lJSON); - - lListen.sockets.emit('message', lMsg); + io.sockets.emit('message', lMsg); } else if (firstChar === ' ' || isContain) exec(pCommand, lExec_func); else @@ -240,13 +234,11 @@ stdout : pStdout, stderr : lErrorStr || lError }; - - lExecStr = Util.stringifyJSON(lExec); log(pConnNum, pError, 'error'); log(pConnNum, pStderr, 'stderror'); - pSocket.send(lExecStr); + jsonSend(pSocket, lExec); }; } @@ -259,8 +251,7 @@ spawn = main.child_process.spawn; cmd = spawn(pCommand, args); send = function(data, isError) { - var lExecStr, - lExec = {}, + var lExec = {}, msg = data.toString(); if (isError) @@ -268,8 +259,7 @@ else lExec.stdout = msg; - lExecStr = JSON.stringify(lExec); - pSocket.send(lExecStr); + jsonSend(pSocket, lExec); }; cmd.stdout.on('data', send); @@ -296,4 +286,10 @@ return lRet; } + + function jsonSend(socket, json) { + var msg = Util.stringifyJSON(json); + console.log(msg); + socket.send(msg); + } })(); From 446ce5370490698cce907701f822b4e5e594fb1d Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 14 Nov 2013 08:08:27 +0000 Subject: [PATCH 050/315] fix(socket) exit on cloudcmd command --- lib/server/socket.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/server/socket.js b/lib/server/socket.js index 341e261c..f72e116c 100644 --- a/lib/server/socket.js +++ b/lib/server/socket.js @@ -132,8 +132,10 @@ if( Util.isContainStrAtBegin(pCommand, ' ') ) { pCommand = Util.removeStr(pCommand, ' '); - if( Util.isContainStrAtBegin(pCommand, 'update') && update ) + if( Util.isContainStrAtBegin(pCommand, 'update') && update ) { update.get(); + lRet = true; + } if( Util.strCmp(pCommand, 'exit') ) if(WIN32) @@ -148,8 +150,7 @@ stderr : null }); - Util.log('received from client: ' + pCommand); - Util.log('sended to client: ' + lMsg); + lRet = true; } } else if( Util.isContainStrAtBegin(pCommand, 'cd ') ) { lDir = Util.removeStr(pCommand, 'cd '); From ab6b780ef71c9527718f3ed76298a4b552adf284 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 14 Nov 2013 08:17:52 +0000 Subject: [PATCH 051/315] refactor(socket) add onCloudCmd, onCD --- lib/server/socket.js | 112 ++++++++++++++++++++++++------------------- 1 file changed, 63 insertions(+), 49 deletions(-) diff --git a/lib/server/socket.js b/lib/server/socket.js index f72e116c..855c708a 100644 --- a/lib/server/socket.js +++ b/lib/server/socket.js @@ -119,60 +119,17 @@ */ function onMessage(pConnNum, pSocket) { return function(pCommand) { - var lMsg, lWinCommand, lExec_func, lDir, firstChar, + var lMsg, lWinCommand, lExec_func, firstChar, connName, - lHome, lError, lRet, lExecSymbols, isContain; + lError, lRet, lExecSymbols, isContain; connName = '#' + pConnNum + ': '; Util.log(connName + pCommand); - if (Util.isContainStrAtBegin(pCommand, CLOUDCMD)) { - pCommand = Util.removeStr(pCommand, CLOUDCMD); - - if( Util.isContainStrAtBegin(pCommand, ' ') ) { - pCommand = Util.removeStr(pCommand, ' '); - - if( Util.isContainStrAtBegin(pCommand, 'update') && update ) { - update.get(); - lRet = true; - } - - if( Util.strCmp(pCommand, 'exit') ) - if(WIN32) - pCommand = 'taskkill -f /PID ' + process.pid; - else - pCommand = 'kill -9 ' + process.pid; - } - else { - jsonSend(pSocket, { - stdout : CLOUDCMD + ' exit \n' + - CLOUDCMD + ' update \n', - stderr : null - }); - - lRet = true; - } - } else if( Util.isContainStrAtBegin(pCommand, 'cd ') ) { - lDir = Util.removeStr(pCommand, 'cd '); - lHome = process.env.HOME; - - if ( Util.isContainStr(lDir, '~') ) - lDir = Util.replaceStr(lDir, '~', lHome); - - lError = Util.tryCatchLog(function() { - process.chdir(lDir); - }); - - if (!lError) - lRet = true; - else { - lError = Util.stringifyJSON(lError); - - jsonSend(pSocket, { - stderr: lError - }); - } - } + if (Util.isContainStrAtBegin(pCommand, CLOUDCMD)) + lRet = onCloudCmd(pCommand, pSocket); + else if( Util.isContainStrAtBegin(pCommand, 'cd ') ) + lRet = onCD(pCommand, pSocket); if (!lRet) { /* if we on windows and command is build in @@ -272,6 +229,63 @@ cmd.on('error', Util.retFalse); } + function onCloudCmd(pCommand, pSocket) { + var lRet; + + pCommand = Util.removeStr(pCommand, CLOUDCMD); + + if( Util.isContainStrAtBegin(pCommand, ' ') ) { + pCommand = Util.removeStr(pCommand, ' '); + + if( Util.isContainStrAtBegin(pCommand, 'update') && update ) { + update.get(); + lRet = true; + } + + if( Util.strCmp(pCommand, 'exit') ) + if(WIN32) + pCommand = 'taskkill -f /PID ' + process.pid; + else + pCommand = 'kill -9 ' + process.pid; + } + else { + jsonSend(pSocket, { + stdout : CLOUDCMD + ' exit \n' + + CLOUDCMD + ' update \n', + stderr : null + }); + + lRet = true; + } + + return lRet; + } + + function onCD(pCommand, pSocket) { + var lRet, lDir, lHome, lError; + + lDir = Util.removeStr(pCommand, 'cd '); + lHome = process.env.HOME; + + if ( Util.isContainStr(lDir, '~') ) + lDir = Util.replaceStr(lDir, '~', lHome); + + lError = Util.tryCatchLog(function() { + process.chdir(lDir); + }); + + if (!lError) + lRet = true; + else { + lError = Util.stringifyJSON(lError); + + jsonSend(pSocket, { + stderr: lError + }); + } + } + + function log(pConnNum, pStr, pType) { var lRet, lType = ' '; From 1b7ca9f7cd4775ebc49b87c197fb66ff20606a32 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 14 Nov 2013 08:19:11 +0000 Subject: [PATCH 052/315] feature(socket) onCloudCmd: add process.exit --- lib/server/socket.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/server/socket.js b/lib/server/socket.js index 855c708a..6d182e34 100644 --- a/lib/server/socket.js +++ b/lib/server/socket.js @@ -243,10 +243,7 @@ } if( Util.strCmp(pCommand, 'exit') ) - if(WIN32) - pCommand = 'taskkill -f /PID ' + process.pid; - else - pCommand = 'kill -9 ' + process.pid; + process.exit(); } else { jsonSend(pSocket, { From 86fd6cd917bc2904599a4edc6b9fac62927942c6 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 14 Nov 2013 08:19:28 +0000 Subject: [PATCH 053/315] feature(socket) jsonSend: rm console.log --- lib/server/socket.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/server/socket.js b/lib/server/socket.js index 6d182e34..55c2a411 100644 --- a/lib/server/socket.js +++ b/lib/server/socket.js @@ -301,7 +301,6 @@ function jsonSend(socket, json) { var msg = Util.stringifyJSON(json); - console.log(msg); socket.send(msg); } })(); From 3f4ed02f4081567636d5ef1a29b32f0a30f4b381 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 14 Nov 2013 08:26:01 +0000 Subject: [PATCH 054/315] refactor(socket) onCloudCmd, onCD: rm pSocket --- lib/server/socket.js | 45 ++++++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/lib/server/socket.js b/lib/server/socket.js index 55c2a411..58c54603 100644 --- a/lib/server/socket.js +++ b/lib/server/socket.js @@ -127,11 +127,13 @@ Util.log(connName + pCommand); if (Util.isContainStrAtBegin(pCommand, CLOUDCMD)) - lRet = onCloudCmd(pCommand, pSocket); + lRet = onCloudCmd(pCommand); else if( Util.isContainStrAtBegin(pCommand, 'cd ') ) - lRet = onCD(pCommand, pSocket); - - if (!lRet) { + lRet = onCD(pCommand); + + if (lRet) + jsonSend(pSocket, lRet); + else { /* if we on windows and command is build in * change code page to unicode becouse * windows use unicode on non English versions @@ -229,7 +231,7 @@ cmd.on('error', Util.retFalse); } - function onCloudCmd(pCommand, pSocket) { + function onCloudCmd(pCommand) { var lRet; pCommand = Util.removeStr(pCommand, CLOUDCMD); @@ -239,27 +241,29 @@ if( Util.isContainStrAtBegin(pCommand, 'update') && update ) { update.get(); - lRet = true; + lRet = { + stdout: Util.addNewLine('update: ok') + }; + } if( Util.strCmp(pCommand, 'exit') ) process.exit(); } else { - jsonSend(pSocket, { + lRet = { stdout : CLOUDCMD + ' exit \n' + CLOUDCMD + ' update \n', stderr : null - }); - - lRet = true; + }; } return lRet; } - function onCD(pCommand, pSocket) { - var lRet, lDir, lHome, lError; + function onCD(pCommand) { + var lRet, lDir, lHome, lError, + lMsg = ''; lDir = Util.removeStr(pCommand, 'cd '); lHome = process.env.HOME; @@ -271,15 +275,16 @@ process.chdir(lDir); }); - if (!lError) - lRet = true; - else { - lError = Util.stringifyJSON(lError); - - jsonSend(pSocket, { - stderr: lError - }); + if (lError) { + lError = Util.stringifyJSON(lError); + lMsg = lError; } + + lRet = { + stderr: lMsg + }; + + return lRet; } From fdac6fb121066d70a80a5542f1c23902cb350a1d Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 14 Nov 2013 08:28:37 +0000 Subject: [PATCH 055/315] refactor(socket) Util.isContainStrAtBegin -> equalPart --- lib/server/socket.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/server/socket.js b/lib/server/socket.js index 58c54603..b28aa874 100644 --- a/lib/server/socket.js +++ b/lib/server/socket.js @@ -11,6 +11,7 @@ exec = main.child_process.exec, Util = main.util, mainpackage = main.mainpackage, + equalPart = Util.isContainStrAtBegin, CLOUDCMD = mainpackage.name, ClientFuncs = [], OnMessageFuncs = [], @@ -126,9 +127,9 @@ connName = '#' + pConnNum + ': '; Util.log(connName + pCommand); - if (Util.isContainStrAtBegin(pCommand, CLOUDCMD)) + if (equalPart(pCommand, CLOUDCMD)) lRet = onCloudCmd(pCommand); - else if( Util.isContainStrAtBegin(pCommand, 'cd ') ) + else if (equalPart(pCommand, 'cd ')) lRet = onCD(pCommand); if (lRet) @@ -236,10 +237,10 @@ pCommand = Util.removeStr(pCommand, CLOUDCMD); - if( Util.isContainStrAtBegin(pCommand, ' ') ) { + if (equalPart(pCommand, ' ')) { pCommand = Util.removeStr(pCommand, ' '); - if( Util.isContainStrAtBegin(pCommand, 'update') && update ) { + if (equalPart(pCommand, 'update') && update) { update.get(); lRet = { stdout: Util.addNewLine('update: ok') From e02455dc8c40a83811ae03f484f43c0103aba9ec Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 14 Nov 2013 08:31:59 +0000 Subject: [PATCH 056/315] refactor(socket) add HELP --- lib/server/socket.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/server/socket.js b/lib/server/socket.js index b28aa874..73868053 100644 --- a/lib/server/socket.js +++ b/lib/server/socket.js @@ -17,6 +17,10 @@ OnMessageFuncs = [], INFO_LOG_LEVEL = 2, WIN32 = main.WIN32, + HELP = { + stdout : CLOUDCMD + ' exit \n' + + CLOUDCMD + ' update \n', + }, /* windows commands thet require * unicode charset on locales @@ -252,11 +256,7 @@ process.exit(); } else { - lRet = { - stdout : CLOUDCMD + ' exit \n' + - CLOUDCMD + ' update \n', - stderr : null - }; + lRet = HELP; } return lRet; From de6f3096ffdbc4953c0745e1d35aef23af381e7b Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 14 Nov 2013 09:08:49 +0000 Subject: [PATCH 057/315] chore(dom) add " " --- lib/client/dom.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/client/dom.js b/lib/client/dom.js index dd335878..80ffeabc 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -126,7 +126,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; }; }, - RESTfulProto = function() { + RESTfulProto = function() { this.delete = function(pUrl, pData, pCallBack, pQuery) { sendRequest({ method : 'DELETE', @@ -1955,7 +1955,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; Events = Util.extendProto(EventsProto), Loader = Util.extendProto(LoaderProto), Images = Util.extendProto(ImagesProto), - RESTful = Util.extendProto(RESTfulProto), + RESTful = Util.extendProto(RESTfulProto), Cache = Util.extendProto(CacheProto); DOMProto = DOMFunc.prototype = new CmdProto(); @@ -1972,6 +1972,6 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; } ]); - DOM = new DOMFunc(); + DOM = new DOMFunc(); })(Util); From 4cb7ec21e5f1b84c77e1b204bb023c055f886fc4 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 14 Nov 2013 10:46:42 +0000 Subject: [PATCH 058/315] feature(config) add Notifications --- HELP.md | 1 + html/config.html | 1 + json/config.json | 1 + lib/client/config.js | 6 ++++++ lib/client/console.js | 2 ++ lib/client/dom.js | 42 +++++++++++++++++++++++++++++++++++++++++- 6 files changed, 52 insertions(+), 1 deletion(-) diff --git a/HELP.md b/HELP.md index de6c6e7b..2b3885e1 100644 --- a/HELP.md +++ b/HELP.md @@ -149,6 +149,7 @@ All main configuration could be done via [config.json](json/config.json "Config" "appCache" : false, /* cache files for offline use */ "analytics" : true, /* google analytics suport */ "diff" : false, /* when save - send patch, not whole file */ + "notifications" : false, /* show notifications when tab is not active*/ "localStorage" : true, /* cache directory data */ "minify" : true /* minification of js,css,html and img */ "online" : true, /* load js files from cdn or local path */ diff --git a/html/config.html b/html/config.html index ebf91524..d98df612 100644 --- a/html/config.html +++ b/html/config.html @@ -3,6 +3,7 @@
      • +
      • diff --git a/json/config.json b/json/config.json index 26dd04be..2527a0b8 100644 --- a/json/config.json +++ b/json/config.json @@ -3,6 +3,7 @@ "appСache": false, "analytics": true, "diff": false, + "notifications": false, "localStorage": true, "minify": true, "online": true, diff --git a/lib/client/config.js b/lib/client/config.js index 13bc2c32..52cbe890 100644 --- a/lib/client/config.js +++ b/lib/client/config.js @@ -11,6 +11,7 @@ var CloudCmd, Util, DOM; INPUT = 'INPUT', CONFIG, TEMPLATE, + Notify = DOM.Notify, Config = this; function init(pCallBack) { @@ -130,6 +131,11 @@ var CloudCmd, Util, DOM; obj[name] = data; + if (name === 'notifications') { + if (data && !Notify.check()) + Notify.request(); + } + CloudCmd.setConfig(CONFIG, function() { CONFIG[name] = data; }); diff --git a/lib/client/console.js b/lib/client/console.js index c7879021..e68e49e5 100644 --- a/lib/client/console.js +++ b/lib/client/console.js @@ -17,6 +17,7 @@ var CloudCmd, Util, DOM, $; MouseBinded, Key = CloudCmd.Key, Images = DOM.Images, + Notify = DOM.Notify, Console = this; function init() { @@ -126,6 +127,7 @@ var CloudCmd, Util, DOM, $; if (jqconsole && ret) { jqconsole.Write(Buffer[status], status + '-msg'); + Notify.send(Buffer[status]); Buffer[status] = ''; } } diff --git a/lib/client/dom.js b/lib/client/dom.js index 80ffeabc..68a3272f 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -642,6 +642,44 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; return lRet; }; }, + NotifyProto = function() { + var Notify = this, + Show = false; + + Events.add({ + 'blur' :function() { + Show = true; + }, + 'focus': function() { + Show = false; + } + }, window); + + this.send = function(msg) { + var notify, granted = Notify.check(); + + if (granted && Show) + notify = new Notification(msg); + }; + + this.check = function () { + var ret, + Not = Notification, + perm = Not.permission; + + if (perm === 'granted') + ret = true; + + return ret; + }; + + this.request = function () { + var Not = Notification; + + if (Not) + Not.requestPermission(); + }; + }, LoaderProto = function() { var Loader = this; @@ -1953,6 +1991,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; DOMTree = Util.extendProto(DOMTreeProto), Events = Util.extendProto(EventsProto), + Notify = Util.extendProto(NotifyProto), Loader = Util.extendProto(LoaderProto), Images = Util.extendProto(ImagesProto), RESTful = Util.extendProto(RESTfulProto), @@ -1968,7 +2007,8 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; Events : Events, RESTful: RESTful, Images : Images, - Cache : Cache + Cache : Cache, + Notify : Notify } ]); From 9e73fc94824dc59df60d31348734b12bca9ff122 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 14 Nov 2013 10:49:44 +0000 Subject: [PATCH 059/315] chore(dom) add " " --- lib/client/dom.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/client/dom.js b/lib/client/dom.js index 68a3272f..760445fb 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -2005,7 +2005,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; DOMTree, Loader, { Events : Events, - RESTful: RESTful, + RESTful : RESTful, Images : Images, Cache : Cache, Notify : Notify From 50f259bea2c186d5b0c07a225141ffed0c948ff6 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 14 Nov 2013 11:51:28 +0000 Subject: [PATCH 060/315] refactor(dom) notify --- lib/client/dom.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/client/dom.js b/lib/client/dom.js index 760445fb..0d1c9788 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -643,8 +643,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; }; }, NotifyProto = function() { - var Notify = this, - Show = false; + var Show, Notify = this; Events.add({ 'blur' :function() { @@ -665,7 +664,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; this.check = function () { var ret, Not = Notification, - perm = Not.permission; + perm = Not && Not.permission; if (perm === 'granted') ret = true; @@ -674,7 +673,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; }; this.request = function () { - var Not = Notification; + var Not = window.Notification; if (Not) Not.requestPermission(); From b04b09a2471bca3773fcc644603e403870ed569d Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 14 Nov 2013 12:25:21 +0000 Subject: [PATCH 061/315] feature(dom) add notify-icon --- img/favicon/favicon-notify.png | Bin 0 -> 4320 bytes lib/client/dom.js | 4 +++- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 img/favicon/favicon-notify.png diff --git a/img/favicon/favicon-notify.png b/img/favicon/favicon-notify.png new file mode 100644 index 0000000000000000000000000000000000000000..e27dc918421a3bf5b98d44043f76a61f99b46cf2 GIT binary patch literal 4320 zcmV<65FhV}P)004&%004{+008|`004nN004b?008NW002DY000@xb3BE2000U( zX+uL$P-t&-Z*ypGa3D!TLm+T+Z)Rz1WdHz3$DNjUR8-d%htIutdZEoQ0#b(FyTAa_ zdy`&8VVD_UC<6{NG_fI~0ue<-nj%P0#DLLIBvwSR5EN9f2P6n6F&ITuEN@2Ei>|D^ z_ww@lRz|vC zuzLs)$;-`!o*{AqUjza0dRV*yaMRE;fKCVhpQKsoe1Yhg01=zBIT!&C1$=TK@rP|Ibo3vKKm@PqnO#LJhq6%Ij6Hz*<$V$@wQAMN5qJ)hzm2h zoGcOF60t^#FqJFfH{#e-4l@G)6iI9sa9D{VHW4w29}?su;^hF~NC{tY+*d5%WDCTX za!E_i;d2ub1#}&jF5T4HnnCyEWTkKf0>c0%E1Ah>(_PY1)0w;+02c53Su*0<(nUqK zG_|(0G&D0Z{i;y^b@OjZ+}lNZ8Th$p5Uu}MTtq^NHl*T1?CO*}7&0ztZsv2j*bmJyf3G7=Z`5B*PvzoDiKdLpOAxi2$L0#SX*@cY z_n(^h55xYX#km%V()bZjV~l{*bt*u9?FT3d5g^g~#a;iSZ@&02Abxq_DwB(I|L-^b zXThc7C4-yrInE_0gw7K3GZ**7&k~>k0Z0NWkO#^@9q0fwx1%qj zZ=)yBuQ3=54Wo^*!gyjLF-e%Um=erBOdIALW)L%unZshS@>qSW9o8Sq#0s#5*edK% z>{;v(b^`kbN5rY%%y90wC>#%$kE_5P!JWYk;U;klcqzOl-UjcFXXA75rT9jCH~u<) z0>40zCTJ7v2qAyk54cquI@7b&LHdZ`+zlTss6bJ7%PQ)z$cROu4wBhpu-r)01) zS~6}jY?%U?gEALn#wiFzo#H}aQ8rT=DHkadR18&{>P1bW7E`~Y4p3)hWn`DhhRJ5j z*2tcg9i<^OEt(fCg;q*CP8+7ZTcWhYX$fb^_9d-LhL+6BEtPYWVlfKTBusSTASKKb%HuWJzl+By+?gkLq)?+BTu761 zjmyXF)a;mc^>(B7bo*HQ1NNg1st!zt28YLv>W*y3CdWx9U8f|cqfXDAO`Q48?auQq zHZJR2&bcD49Ip>EY~kKEPV6Wm+eXFV)D)_R=tM0@&p?(!V*Qu1PXHG9o^ zTY0bZ?)4%01p8F`JoeS|<@=<@RE7GY07EYX@lwd>4oW|Yi!o+Su@M`;WuSK z8LKk71XR(_RKHM1xJ5XYX`fk>`6eqY>qNG6HZQwBM=xi4&Sb88?zd}EYguc1@>KIS z<&CX#T35dwS|7K*XM_5Nf(;WJJvJWRMA($P>8E^?{IdL4o5MGE7bq2MEEwP7v8AO@ zqL5!WvekBL-8R%V?zVyL=G&{be=K4bT`e{#t|)$A!YaA?jp;X)-+bB;zhj`(vULAW z%ue3U;av{94wp%n<(7@__S@Z2PA@Mif3+uO&y|X06?J#oSi8M;ejj_^(0<4Lt#wLu#dYrva1Y$6_o(k^&}yhSh&h;f@JVA>W8b%o zZ=0JGnu?n~9O4}sJsfnnx7n(>`H13?(iXTy*fM=I`sj`CT)*pTHEgYKqqP+u1IL8N zo_-(u{qS+0<2@%BCt82d{Gqm;(q7a7b>wu+b|!X?c13m#p7cK1({0<`{-e>4hfb-U zsyQuty7Ua;Ou?B?XLHZaol8GAb3Wnxcu!2v{R_`T4=x`(GvqLI{-*2AOSimk zUAw*F_TX^n@STz9kDQ z$NC=!KfXWC8h`dn#xL(D3Z9UkR7|Q&Hcy#Notk!^zVUSB(}`#4&lYA1f0h2V_PNgU zAAWQEt$#LRcH#y9#i!p(Udq2b^lI6wp1FXzN3T;~FU%Lck$-deE#qz9yYP3D3t8{6 z?<+s(e(3(_^YOu_)K8!O1p}D#{JO;G(*OVf32;bRa{vGf5dZ)S5dnW>Uy%R+1`$a_ zK~z{r?O17S6=f7X-^{%Cy3&@iL!p2b2`GvX!V(ZggG4YaK_bRAU`!wZ1x-+5Y>Y}- z6{!JJLIgDujWre*A|i{8qJ%)DAPS{JVw8B?=Ej+z0grvl4Z=FaXNHWJ(cney;!{T>=$wR!%)nj zVpbVf_`m=S(}(G}r1Sb%3bv4Uv13W z#L6Ky&-I~{*|nJ^H-i-+xG>hqb_H)6#y)|fqlf7-tpqX}vy`stpKSg|{dA25W?wnYe zpu6;O>5T&MIkA?uhNMDlP9PPo?f%nC=d7_BF0qeFYimo0k&CnhB0KHyDRv6#Oty0M zQwH)2-D_dIYy~YSIi{ zp_uJx;tF~SF>kzqwa*$jQQ(bPHxe?br%t2C5!-WZce`Dx(E)|rJO>ZccLY<1>iFYr zzgskgr8g#+{DQ4RuL3LF_SVZB+n0G<8IG?7ECa3EeVWD5bd%>GwYwsZ$NN^@Jg-&)jQc+d&(<=%p9Apa91?IlFLY*pa;ZB-0{xAtn|wl(A&=pEb66 z@;FoEU@Dy??}CH4sM-symtYt{ZmF1fVywb!8u}9>b;L7JO~^c%bHc$CrlM)pkxm&}SJ2VVW zQ9R*Y9lS0`A%3&p!lrB+|B_&Ql$ZHyopG8(uqMPKWy_>*$`MkIpK`wF&1}iBGJy~F zaj%PLA9>8^;d}=Nm|>w2!FwY~N~*LWG@D>eNB}7S_fSr~NjH$6KIC&5j$B>xC5NS^ z{uEMM6wQP@QmQySnnklJ#aG2Dq(bF0xz?QDX|4;w*2FD>EyYbv5cnU7?3sN)hsyN; O0000 Date: Fri, 15 Nov 2013 10:15:49 +0200 Subject: [PATCH 062/315] docs(help) Configuration ports, sslPort: rm "or null" --- HELP.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/HELP.md b/HELP.md index 2b3885e1..6c0d6484 100644 --- a/HELP.md +++ b/HELP.md @@ -158,8 +158,8 @@ All main configuration could be done via [config.json](json/config.json "Config" "showKeysPanel" : true, /* show classic panel with buttons of keys */ "server" : true, /* server mode or testing mode */ "socket" : true /* enable web sockets */ - "port" : 8000, /* http port or null(default) */ - "sslPort" : 443, /* https port or null(default) */ + "port" : 8000, /* http port */ + "sslPort" : 443, /* https port */ "ip" : null, /* ip or null(default) */ "ssl" : false /* should use https? */ "rest" : true /* enable rest interface */ From ad4e3cc6454a71b4bc7f7e98528998ad57d98fd9 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 15 Nov 2013 10:31:54 +0000 Subject: [PATCH 063/315] feature(dom) Notify click: add focus --- lib/client/dom.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/client/dom.js b/lib/client/dom.js index d53667b4..c08159f2 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -655,12 +655,17 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; }, window); this.send = function(msg) { - var notify, granted = Notify.check(); + var notify, + focus = window.focus.bind(window), + granted = Notify.check(); - if (granted && Show) + if (granted && Show) { notify = new Notification(msg, { icon: '/img/favicon/favicon-notify.png', }); + + Events.addClick(focus, notify); + } }; this.check = function () { From f3815495348d9e1f1cee7f40533f0d181cc58df1 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 15 Nov 2013 12:18:26 +0000 Subject: [PATCH 064/315] chore(listeners) add " " --- lib/client/listeners.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/client/listeners.js b/lib/client/listeners.js index 7a05b36b..b4bede34 100644 --- a/lib/client/listeners.js +++ b/lib/client/listeners.js @@ -78,7 +78,7 @@ var Util, DOM, CloudCmd; * функция меняет ссыки на ajax-овые * @param pPanelID */ - this.changeLinks = function(pPanelID){ + this.changeLinks = function(pPanelID) { /* назначаем кнопку очистить кэш и показываем её */ var lClearcache = DOM.getById('clear-cache'); Events.addClick(Cache.clear, lClearcache); @@ -101,7 +101,7 @@ var Util, DOM, CloudCmd; var lTarget = pEvent.currentTarget || pEvent.target; DOM.setCurrentFile(lTarget); - if(Util.isFunction(CloudCmd.Menu) ){ + if(Util.isFunction(CloudCmd.Menu)) { CloudCmd.Menu({ x: pEvent.clientX, y: pEvent.clientY @@ -119,7 +119,7 @@ var Util, DOM, CloudCmd; * download file from browser to descktop * in Chrome (HTML5) */ - lOnDragStart_f = function(pEvent){ + lOnDragStart_f = function(pEvent) { var lElement = pEvent.target, lLink = lElement.href, lName = lElement.textContent; @@ -140,11 +140,11 @@ var Util, DOM, CloudCmd; var pElement = pEvent.target, lTag = pElement.tagName; - if(lTag !== 'LI') - do{ + if (lTag !== 'LI') + do { pElement = pElement.parentElement; lTag = pElement.tagName; - }while(lTag !== 'LI'); + } while(lTag !== 'LI'); DOM.setCurrentFile(pElement); }, From 17cd636f1fb05e8d09e6c8bbb6944191f70139f9 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 15 Nov 2013 12:25:12 +0000 Subject: [PATCH 065/315] feature(dom) Notify send: add getConfig --- lib/client/dom.js | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/lib/client/dom.js b/lib/client/dom.js index c08159f2..70258d43 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -643,7 +643,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; }; }, NotifyProto = function() { - var Show, Notify = this; + var Show, Allow, Notify = this; Events.add({ 'blur' :function() { @@ -655,17 +655,20 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; }, window); this.send = function(msg) { - var notify, - focus = window.focus.bind(window), - granted = Notify.check(); - - if (granted && Show) { - notify = new Notification(msg, { - icon: '/img/favicon/favicon-notify.png', - }); - - Events.addClick(focus, notify); - } + CloudCmd.getConfig(function(config) { + var notify, + notifications = config.notifications, + focus = window.focus.bind(window), + granted = Notify.check(); + + if (notifications && granted && Show) { + notify = new Notification(msg, { + icon: '/img/favicon/favicon-notify.png', + }); + + Events.addClick(focus, notify); + } + }) }; this.check = function () { From 6696f7e9382ee0692b42501836664fbc1da2736b Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 15 Nov 2013 13:12:10 +0000 Subject: [PATCH 066/315] fix(rest) heckSendError -> checkSendError --- lib/server/rest.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/server/rest.js b/lib/server/rest.js index abeeb24b..2c23082a 100644 --- a/lib/server/rest.js +++ b/lib/server/rest.js @@ -137,7 +137,7 @@ case 'PUT': if (lQuery === 'dir') fs.mkdir(p.name, function(pError) { - heckSendError(pError, pParams, function() { + checkSendError(pError, pParams, function() { sendMsg(pParams, 'make dir', p.name); }); }); From 99ac9e6395ef41eda5911fb2cfa08a7b39dfbf70 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 18 Nov 2013 08:12:09 +0000 Subject: [PATCH 067/315] chore(cloudcmd) "," -> ";" --- lib/server/commander.js | 4 ++-- lib/server/main.js | 3 +-- lib/server/rest.js | 2 +- lib/server/socket.js | 2 +- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/server/commander.js b/lib/server/commander.js index 2189a27e..38b2753b 100644 --- a/lib/server/commander.js +++ b/lib/server/commander.js @@ -131,11 +131,11 @@ var lName, lStats, lMode, lIsDir; for (i = 0; i < n; i++ ) { /* Переводим права доступа в 8-ричную систему */ - lName = p.files[i], + lName = p.files[i]; lStats = p.stats[lName]; if (lStats) { - lMode = (lStats.mode - 0).toString(8), + lMode = (lStats.mode - 0).toString(8); lIsDir = lStats.isDirectory(); } diff --git a/lib/server/main.js b/lib/server/main.js index 38f64f17..fe9cbec6 100644 --- a/lib/server/main.js +++ b/lib/server/main.js @@ -244,7 +244,6 @@ query : getQuery(p.request) }); - //p.response.writeHead(OK, header); setHeader(header, p.response); p.response.statusCode = p.status || OK; @@ -328,7 +327,7 @@ header = { 'Location': p.url - }, + }; setHeader(header, p.response); p.response.statusCode = MOVED_PERMANENTLY; diff --git a/lib/server/rest.js b/lib/server/rest.js index 2c23082a..b6edb70d 100644 --- a/lib/server/rest.js +++ b/lib/server/rest.js @@ -102,7 +102,7 @@ lRet = main.checkParams(pParams); if (lRet){ - p = pParams, + p = pParams; lQuery = main.getQuery(p.request); p.name = Util.removeStrOneTime(p.name, CloudFunc.FS) || '/'; diff --git a/lib/server/socket.js b/lib/server/socket.js index 73868053..40a8e1ad 100644 --- a/lib/server/socket.js +++ b/lib/server/socket.js @@ -47,7 +47,7 @@ var lRet, lConnNum, lMsg, lConn_func; if (io) { - io = io.listen(pServer), + io = io.listen(pServer); lConnNum = 0; io.set('log level', INFO_LOG_LEVEL); From 7ea932359dcd82c07d012408f2f6c66bca9e26b6 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 18 Nov 2013 08:19:24 +0000 Subject: [PATCH 068/315] chore(socket) add " " --- lib/server/socket.js | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/lib/server/socket.js b/lib/server/socket.js index 40a8e1ad..093e7be6 100644 --- a/lib/server/socket.js +++ b/lib/server/socket.js @@ -252,7 +252,7 @@ } - if( Util.strCmp(pCommand, 'exit') ) + if(Util.strCmp(pCommand, 'exit')) process.exit(); } else { @@ -264,15 +264,15 @@ function onCD(pCommand) { var lRet, lDir, lHome, lError, - lMsg = ''; + lMsg = ''; - lDir = Util.removeStr(pCommand, 'cd '); - lHome = process.env.HOME; + lDir = Util.removeStr(pCommand, 'cd '); + lHome = process.env.HOME; - if ( Util.isContainStr(lDir, '~') ) - lDir = Util.replaceStr(lDir, '~', lHome); + if (Util.isContainStr(lDir, '~')) + lDir = Util.replaceStr(lDir, '~', lHome); - lError = Util.tryCatchLog(function() { + lError = Util.tryCatchLog(function() { process.chdir(lDir); }); @@ -281,7 +281,7 @@ lMsg = lError; } - lRet = { + lRet = { stderr: lMsg }; @@ -290,14 +290,15 @@ function log(pConnNum, pStr, pType) { - var lRet, lType = ' '; + var lRet, + lType = ' '; if (pStr) { if (pType) - lType += pType + ':'; + lType += pType + ':'; - lRet = 'client #' + pConnNum + lType + pStr; + lRet = 'client #' + pConnNum + lType + pStr; Util.log(lRet); } From a0b3171e34f1377f9b36a5f4d799e21f16b37801 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 18 Nov 2013 08:20:45 +0000 Subject: [PATCH 069/315] refactor(socket) onCloudCmd --- lib/server/socket.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/server/socket.js b/lib/server/socket.js index 093e7be6..91b0a0d2 100644 --- a/lib/server/socket.js +++ b/lib/server/socket.js @@ -241,7 +241,9 @@ pCommand = Util.removeStr(pCommand, CLOUDCMD); - if (equalPart(pCommand, ' ')) { + if (!equalPart(pCommand, ' ')) + lRet = HELP; + else { pCommand = Util.removeStr(pCommand, ' '); if (equalPart(pCommand, 'update') && update) { @@ -255,9 +257,6 @@ if(Util.strCmp(pCommand, 'exit')) process.exit(); } - else { - lRet = HELP; - } return lRet; } From 9cb375fcef204e81099dcb3d59aead077a36ce41 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 18 Nov 2013 08:22:29 +0000 Subject: [PATCH 070/315] chore(socket) add " " --- lib/server/socket.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/server/socket.js b/lib/server/socket.js index 91b0a0d2..bdad9fe3 100644 --- a/lib/server/socket.js +++ b/lib/server/socket.js @@ -144,10 +144,10 @@ * windows use unicode on non English versions */ if(WIN32) { - lWinCommand = pCommand.toUpperCase(); + lWinCommand = pCommand.toUpperCase(); - if( Win32Commands.indexOf(lWinCommand) >= 0 ) - pCommand = 'chcp 65001 |' + pCommand; + if (Win32Commands.indexOf(lWinCommand) >= 0) + pCommand = 'chcp 65001 |' + pCommand; } if(!ClientFuncs[pConnNum]) From 5d3a4715f1bcf5aedab52cc698df7a7f3d59080a Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 18 Nov 2013 08:32:15 +0000 Subject: [PATCH 071/315] refactor(socket) getExec, getSpawn --- lib/server/socket.js | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/lib/server/socket.js b/lib/server/socket.js index bdad9fe3..caf20c4b 100644 --- a/lib/server/socket.js +++ b/lib/server/socket.js @@ -151,7 +151,12 @@ } if(!ClientFuncs[pConnNum]) - ClientFuncs[pConnNum] = getExec(pSocket, pConnNum); + ClientFuncs[pConnNum] = getExec(function(json, pError, pStderr) { + log(pConnNum, pError, 'error'); + log(pConnNum, pStderr, 'stderror'); + + jsonSend(pSocket, json); + }); lExec_func = ClientFuncs[pConnNum]; lExecSymbols = ['*', '&', '{', '}', '|', '\'', '"']; @@ -171,7 +176,9 @@ } else if (firstChar === ' ' || isContain) exec(pCommand, lExec_func); else - getSpawn(pSocket, pConnNum, pCommand); + getSpawn(pCommand, function(json) { + jsonSend(pSocket, json); + }); } }; } @@ -181,7 +188,7 @@ * function send result of command to client * @param pSocket */ - function getExec(pSocket, pConnNum) { + function getExec(callback) { return function(pError, pStdout, pStderr) { var lErrorStr, lExecStr, lExec, lError = pStderr || pError; @@ -200,14 +207,11 @@ stderr : lErrorStr || lError }; - log(pConnNum, pError, 'error'); - log(pConnNum, pStderr, 'stderror'); - - jsonSend(pSocket, lExec); + Util.exec(callback, lExec, pError, pStderr); }; } - function getSpawn(pSocket, pConnNum, pCommand) { + function getSpawn(pCommand, callback) { var send, cmd, spawn, args = pCommand.split(' '); @@ -224,7 +228,7 @@ else lExec.stdout = msg; - jsonSend(pSocket, lExec); + Util.exec(callback, lExec); }; cmd.stdout.on('data', send); From 042e0ba70c8d6adebe4d9e9fd5275927201d4be4 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 18 Nov 2013 08:36:56 +0000 Subject: [PATCH 072/315] feature(socket) add HOME --- lib/server/socket.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/server/socket.js b/lib/server/socket.js index caf20c4b..ff7f7816 100644 --- a/lib/server/socket.js +++ b/lib/server/socket.js @@ -16,6 +16,7 @@ ClientFuncs = [], OnMessageFuncs = [], INFO_LOG_LEVEL = 2, + HOME = process.env.HOME, WIN32 = main.WIN32, HELP = { stdout : CLOUDCMD + ' exit \n' + @@ -266,14 +267,13 @@ } function onCD(pCommand) { - var lRet, lDir, lHome, lError, + var lRet, lDir, lError, lMsg = ''; lDir = Util.removeStr(pCommand, 'cd '); - lHome = process.env.HOME; if (Util.isContainStr(lDir, '~')) - lDir = Util.replaceStr(lDir, '~', lHome); + lDir = Util.replaceStr(lDir, '~', HOME); lError = Util.tryCatchLog(function() { process.chdir(lDir); From c5e11681f17cb95d73eeaa8073e908f9b9ec160c Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 18 Nov 2013 09:37:44 +0000 Subject: [PATCH 073/315] feature(util) add rmNewLine --- lib/util.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/util.js b/lib/util.js index 5918902f..74fb5fe3 100644 --- a/lib/util.js +++ b/lib/util.js @@ -60,6 +60,19 @@ Util = exports || {}; return pText + lNewLine; }; + /** + * rm new line (if it's) + * @param {string} pText + */ + Util.rmNewLine = function(pText){ + var n = pText && pText.length - 1; + + if (n && pText[n] == '\n') + pText = pText.substr(pText, n); + + return pText; + }; + /** setting function context * @param {function} pFunction * @param {object} pContext From baf5629ddd1b744cff2530d234692a5d4ff0242a Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 18 Nov 2013 10:02:10 +0000 Subject: [PATCH 074/315] feature(util) isContainStrAtBegin: pStr2 could be array --- lib/server/socket.js | 102 +++++++++++++++++++++++++++---------------- lib/util.js | 24 +++++++--- 2 files changed, 82 insertions(+), 44 deletions(-) diff --git a/lib/server/socket.js b/lib/server/socket.js index ff7f7816..b77f8d34 100644 --- a/lib/server/socket.js +++ b/lib/server/socket.js @@ -10,10 +10,12 @@ update = main.srvrequire('update'), exec = main.child_process.exec, Util = main.util, + path = main.path, mainpackage = main.mainpackage, equalPart = Util.isContainStrAtBegin, CLOUDCMD = mainpackage.name, ClientFuncs = [], + ClientDirs = [], OnMessageFuncs = [], INFO_LOG_LEVEL = 2, HOME = process.env.HOME, @@ -127,19 +129,37 @@ return function(pCommand) { var lMsg, lWinCommand, lExec_func, firstChar, connName, - lError, lRet, lExecSymbols, isContain; + lError, lRet, lExecSymbols, isContain, + dir, options = {}; + + dir = ClientDirs[pConnNum]; + + if (!dir) + dir = ClientDirs[pConnNum] = HOME; connName = '#' + pConnNum + ': '; Util.log(connName + pCommand); if (equalPart(pCommand, CLOUDCMD)) - lRet = onCloudCmd(pCommand); - else if (equalPart(pCommand, 'cd ')) - lRet = onCD(pCommand); + lRet = onCloudCmd(pCommand, function(json) { + jsonSend(pSocket, json); + }); + else if (equalPart(pCommand, 'cd ')) { + lRet = true; - if (lRet) - jsonSend(pSocket, lRet); - else { + onCD(pCommand, dir, function(json) { + var error = json.stderr, + stdout = json.stdout; + + console.log(stdout); + if (error) + jsonSend(pSocket, json); + else + ClientDirs[pConnNum] = stdout; + }); + } + + if (!lRet) { /* if we on windows and command is build in * change code page to unicode becouse * windows use unicode on non English versions @@ -163,6 +183,8 @@ lExecSymbols = ['*', '&', '{', '}', '|', '\'', '"']; isContain = Util.isContainStr(pCommand, lExecSymbols); firstChar = pCommand[0]; + options.cwd = dir; + console.log(options); if (firstChar === '#') { pCommand = pCommand.slice(1); @@ -175,9 +197,9 @@ io.sockets.emit('message', lMsg); } else if (firstChar === ' ' || isContain) - exec(pCommand, lExec_func); + exec(pCommand, options, lExec_func); else - getSpawn(pCommand, function(json) { + getSpawn(pCommand, options, function(json) { jsonSend(pSocket, json); }); } @@ -212,14 +234,14 @@ }; } - function getSpawn(pCommand, callback) { + function getSpawn(pCommand, options, callback) { var send, cmd, spawn, args = pCommand.split(' '); pCommand = args.shift(); spawn = main.child_process.spawn; - cmd = spawn(pCommand, args); + cmd = spawn(pCommand, args, options); send = function(data, isError) { var lExec = {}, msg = data.toString(); @@ -241,54 +263,60 @@ cmd.on('error', Util.retFalse); } - function onCloudCmd(pCommand) { + function onCloudCmd(pCommand, callback) { var lRet; pCommand = Util.removeStr(pCommand, CLOUDCMD); - if (!equalPart(pCommand, ' ')) - lRet = HELP; + if (!equalPart(pCommand, ' ')) { + lRet = true; + Util.exec(callback, HELP); + } else { pCommand = Util.removeStr(pCommand, ' '); if (equalPart(pCommand, 'update') && update) { + lRet = true; update.get(); - lRet = { - stdout: Util.addNewLine('update: ok') - }; + Util.exec(callback, { + stdout: Util.addNewLine('update: ok') + }); } - if(Util.strCmp(pCommand, 'exit')) + if (Util.strCmp(pCommand, 'exit')) process.exit(); } return lRet; } - function onCD(pCommand) { - var lRet, lDir, lError, - lMsg = ''; + function onCD(pCommand, currDir, callback) { + var dir, + paramDir = Util.removeStr(pCommand, 'cd '); - lDir = Util.removeStr(pCommand, 'cd '); + if (equalPart(paramDir, ['/', '~', '.'])) + dir = paramDir; + else + dir = path.join(currDir, paramDir); - if (Util.isContainStr(lDir, '~')) - lDir = Util.replaceStr(lDir, '~', HOME); + console.log(dir, paramDir); - lError = Util.tryCatchLog(function() { - process.chdir(lDir); + exec('cd ' + dir + ' && pwd', function (error, stdout, stderr) { + var lRet, + lMsg = '', + lError = error || stderr; + + if (lError) { + lError = Util.stringifyJSON(lError); + lMsg = lError; + } + + Util.exec(callback, { + stderr : lMsg, + stdout : Util.rmNewLine(stdout) + }); }); - - if (lError) { - lError = Util.stringifyJSON(lError); - lMsg = lError; - } - - lRet = { - stderr: lMsg - }; - - return lRet; } diff --git a/lib/util.js b/lib/util.js index 74fb5fe3..226743ab 100644 --- a/lib/util.js +++ b/lib/util.js @@ -404,15 +404,25 @@ Util = exports || {}; * @param pStr2 */ Util.isContainStrAtBegin = function(pStr1, pStr2) { - var lRet; + var i, n, length, subStr, lRet; - if ( Util.isString(pStr1) && Util.isString(pStr2) ) { - var lLength = pStr2.length, - lSubStr = pStr1.substring(0, lLength); + if (Util.isString(pStr1)) + if (Util.isArray(pStr2)) { + n = pStr2.length; + + for(i = 0; i < n; i++) { + lRet = Util.isContainStrAtBegin(pStr1, pStr2[i]); + + if (lRet) + break; + } + } else { + length = pStr2.length, + subStr = pStr1.substring(0, length); + + lRet = subStr === pStr2; + } - lRet = lSubStr === pStr2; - } - return lRet; }; From 7035a5a52fb57d8c60bd320fabcf8214a3067d01 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 18 Nov 2013 10:05:48 +0000 Subject: [PATCH 075/315] feature(socket) any client could work with own dir --- lib/server/socket.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/server/socket.js b/lib/server/socket.js index b77f8d34..395623d5 100644 --- a/lib/server/socket.js +++ b/lib/server/socket.js @@ -293,6 +293,7 @@ function onCD(pCommand, currDir, callback) { var dir, + getDir = WIN32 ? 'chdir' : 'pwd', paramDir = Util.removeStr(pCommand, 'cd '); if (equalPart(paramDir, ['/', '~', '.'])) @@ -302,7 +303,7 @@ console.log(dir, paramDir); - exec('cd ' + dir + ' && pwd', function (error, stdout, stderr) { + exec('cd ' + dir + ' && ' + getDir, function (error, stdout, stderr) { var lRet, lMsg = '', lError = error || stderr; From 4969c1d433a340353f6091257b253f2190b61027 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 18 Nov 2013 10:15:40 +0000 Subject: [PATCH 076/315] feature(socket) add pwd, homepath --- lib/server/socket.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/server/socket.js b/lib/server/socket.js index 395623d5..36b08795 100644 --- a/lib/server/socket.js +++ b/lib/server/socket.js @@ -18,7 +18,8 @@ ClientDirs = [], OnMessageFuncs = [], INFO_LOG_LEVEL = 2, - HOME = process.env.HOME, + ENV = process.env; + HOME = ENV.PWD || ENV.HOMEPATH, WIN32 = main.WIN32, HELP = { stdout : CLOUDCMD + ' exit \n' + From a39d62c45c2f77baffd0828130ecb9421ce0e7ee Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 18 Nov 2013 10:16:31 +0000 Subject: [PATCH 077/315] chore(socket) ";" -> "," --- lib/server/socket.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/server/socket.js b/lib/server/socket.js index 36b08795..c6cafc38 100644 --- a/lib/server/socket.js +++ b/lib/server/socket.js @@ -18,7 +18,7 @@ ClientDirs = [], OnMessageFuncs = [], INFO_LOG_LEVEL = 2, - ENV = process.env; + ENV = process.env, HOME = ENV.PWD || ENV.HOMEPATH, WIN32 = main.WIN32, HELP = { From ae7571fbd32b5c1c46350885298fae1e4b4bfaa9 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 18 Nov 2013 10:18:05 +0000 Subject: [PATCH 078/315] chore(socket) rm console.log --- lib/server/socket.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lib/server/socket.js b/lib/server/socket.js index c6cafc38..75739938 100644 --- a/lib/server/socket.js +++ b/lib/server/socket.js @@ -152,7 +152,6 @@ var error = json.stderr, stdout = json.stdout; - console.log(stdout); if (error) jsonSend(pSocket, json); else @@ -185,7 +184,6 @@ isContain = Util.isContainStr(pCommand, lExecSymbols); firstChar = pCommand[0]; options.cwd = dir; - console.log(options); if (firstChar === '#') { pCommand = pCommand.slice(1); @@ -302,8 +300,6 @@ else dir = path.join(currDir, paramDir); - console.log(dir, paramDir); - exec('cd ' + dir + ' && ' + getDir, function (error, stdout, stderr) { var lRet, lMsg = '', From 2356403889628aa585d91acdb6d01e9d9dbb37f9 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 18 Nov 2013 10:21:17 +0000 Subject: [PATCH 079/315] feature(socket) add Win32 condition --- lib/server/socket.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/server/socket.js b/lib/server/socket.js index 75739938..85a28d4b 100644 --- a/lib/server/socket.js +++ b/lib/server/socket.js @@ -195,7 +195,7 @@ }); io.sockets.emit('message', lMsg); - } else if (firstChar === ' ' || isContain) + } else if (WIN32 || firstChar === ' ' || isContain) exec(pCommand, options, lExec_func); else getSpawn(pCommand, options, function(json) { From 50142b6a48080a65de8f6505439fe65a514f2ec5 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 18 Nov 2013 10:42:25 +0000 Subject: [PATCH 080/315] feature(socket) HOMEPATH -> SYSTEMDRIVE --- lib/server/socket.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/server/socket.js b/lib/server/socket.js index 85a28d4b..0eca14b1 100644 --- a/lib/server/socket.js +++ b/lib/server/socket.js @@ -19,7 +19,7 @@ OnMessageFuncs = [], INFO_LOG_LEVEL = 2, ENV = process.env, - HOME = ENV.PWD || ENV.HOMEPATH, + HOME = ENV.PWD || ENV.SYSTEMDRIVE, WIN32 = main.WIN32, HELP = { stdout : CLOUDCMD + ' exit \n' + From 8d2e0548e9223be46c13178423ad972e5f48e5a4 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 18 Nov 2013 10:59:16 +0000 Subject: [PATCH 081/315] feature(util) rmNewLine: add "\r" --- lib/util.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/util.js b/lib/util.js index 226743ab..2327e3fe 100644 --- a/lib/util.js +++ b/lib/util.js @@ -65,9 +65,10 @@ Util = exports || {}; * @param {string} pText */ Util.rmNewLine = function(pText){ - var n = pText && pText.length - 1; + var n = pText && pText.length - 1, + char = pText[n]; - if (n && pText[n] == '\n') + if (n && char === '\n' || char === '\r') pText = pText.substr(pText, n); return pText; From 6ada9d6ace7bfd1d2e1899f2f9a535dc18e8eeaf Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 18 Nov 2013 11:56:06 +0000 Subject: [PATCH 082/315] refactor(util) rmNewLine: substr -> removeStr --- lib/util.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/lib/util.js b/lib/util.js index 2327e3fe..dcc2f7cd 100644 --- a/lib/util.js +++ b/lib/util.js @@ -65,13 +65,10 @@ Util = exports || {}; * @param {string} pText */ Util.rmNewLine = function(pText){ - var n = pText && pText.length - 1, - char = pText[n]; + var strs = ['\n', '\r'], + text = Util.removeStr(pText, strs); - if (n && char === '\n' || char === '\r') - pText = pText.substr(pText, n); - - return pText; + return text; }; /** setting function context From 52d09918f51f6668e6760704501b2d69edad9d50 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 18 Nov 2013 12:11:47 +0000 Subject: [PATCH 083/315] feature(socket) HOME -> DIR --- lib/server/socket.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/server/socket.js b/lib/server/socket.js index 0eca14b1..1b42f16f 100644 --- a/lib/server/socket.js +++ b/lib/server/socket.js @@ -4,6 +4,7 @@ 'use strict'; var main = global.cloudcmd.main, + DIR = main.DIR, SRVDIR = main.SRVDIR, io = main.require('socket.io'), @@ -19,7 +20,6 @@ OnMessageFuncs = [], INFO_LOG_LEVEL = 2, ENV = process.env, - HOME = ENV.PWD || ENV.SYSTEMDRIVE, WIN32 = main.WIN32, HELP = { stdout : CLOUDCMD + ' exit \n' + @@ -136,7 +136,7 @@ dir = ClientDirs[pConnNum]; if (!dir) - dir = ClientDirs[pConnNum] = HOME; + dir = ClientDirs[pConnNum] = DIR; connName = '#' + pConnNum + ': '; Util.log(connName + pCommand); From 428e933b49edc6bed7033b8760a8a068709e746e Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 18 Nov 2013 12:13:18 +0000 Subject: [PATCH 084/315] fix(socket) onCD: rm "." --- lib/server/socket.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/server/socket.js b/lib/server/socket.js index 1b42f16f..8d54e10d 100644 --- a/lib/server/socket.js +++ b/lib/server/socket.js @@ -295,7 +295,7 @@ getDir = WIN32 ? 'chdir' : 'pwd', paramDir = Util.removeStr(pCommand, 'cd '); - if (equalPart(paramDir, ['/', '~', '.'])) + if (equalPart(paramDir, ['/', '~'])) dir = paramDir; else dir = path.join(currDir, paramDir); From 1ac91bb4a4d825934b41974f3efabdb568dcbb5e Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 18 Nov 2013 12:15:20 +0000 Subject: [PATCH 085/315] chore(edit) rm " " --- lib/client/edit.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/client/edit.js b/lib/client/edit.js index 81760362..f4f3a8d4 100644 --- a/lib/client/edit.js +++ b/lib/client/edit.js @@ -176,7 +176,7 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch; }); } - function listener(pEvent) { + function listener(pEvent) { var lF4, lKey, lIsBind = Key.isBind(); if (lIsBind) { From 5cecffda001cd1b38272d57685ceed9f20687d4e Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 18 Nov 2013 12:26:53 +0000 Subject: [PATCH 086/315] feature(dom) add Dialog --- lib/client/dom.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/client/dom.js b/lib/client/dom.js index 70258d43..6fb89ff1 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -2017,7 +2017,8 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; RESTful : RESTful, Images : Images, Cache : Cache, - Notify : Notify + Notify : Notify, + Dialog : Dialog } ]); From 1ae9256a566c578c540f6e5c053426b0cc22d6b7 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 18 Nov 2013 12:27:41 +0000 Subject: [PATCH 087/315] feature(edit) if on server would be error with diff, try to save without diff --- lib/client/edit.js | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/lib/client/edit.js b/lib/client/edit.js index f4f3a8d4..048dc495 100644 --- a/lib/client/edit.js +++ b/lib/client/edit.js @@ -15,6 +15,7 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch; Ace, Msg, Key = CloudCmd.Key, + Dialog = DOM.Dialog, Images = DOM.Images, Element; @@ -131,12 +132,9 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch; query = '?patch'; } - DOM.RESTful.save(lPath, lValue, Edit.showMessage, query); + DOM.RESTful.save(lPath, lValue, onSave, query); }, function(callback) { - diff(lValue, function(diff) { - Value = lValue; - Util.exec(callback, diff); - }); + diff(lValue, callback); }); }); } @@ -188,6 +186,24 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch; } } + function onSave(text) { + var ret, + isError = Util.isContainStrAtBegin(text, 'error'), + path = DOM.getCurrentPath(), + msg = '\nShould I save file anyway?'; + + if (!isError) + Edit.showMessage(text); + else { + ret = Dialog.confirm(text + msg); + + if (ret) { + DOM.RESTful.save(path, Value, onSave); + Value = Ace.getValue(); + } + } + } + this.showMessage = function(text) { var parent, TWO_SECONDS = 2000; From 4e49eb50951a4cce2e2b61141431a0c14160ef64 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 18 Nov 2013 13:45:12 +0000 Subject: [PATCH 088/315] fix(rest) pErr -> pError --- lib/server/rest.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/server/rest.js b/lib/server/rest.js index b6edb70d..d34d2290 100644 --- a/lib/server/rest.js +++ b/lib/server/rest.js @@ -109,7 +109,7 @@ switch (p.request.method) { case 'GET': if (Util.strCmp(lQuery, 'size')) - dir.getSize(p.name, function(pErr, pSize) { + dir.getSize(p.name, function(pError, pSize) { checkSendError(pError, p, function() { lSize = CloudFunc.getShortSize(pSize); sendResponse(p, lSize); From 3dbcb08c97ac7ed5a20755beda1e0b2184a47532 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 18 Nov 2013 16:13:34 +0000 Subject: [PATCH 089/315] feature(rest) add ?hash --- lib/server/hash.js | 39 +++++++++++++++++++++++++++++++++++++++ lib/server/main.js | 1 + lib/server/rest.js | 18 ++++++++++++++++-- 3 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 lib/server/hash.js diff --git a/lib/server/hash.js b/lib/server/hash.js new file mode 100644 index 00000000..6aecf778 --- /dev/null +++ b/lib/server/hash.js @@ -0,0 +1,39 @@ +(function (object) { + 'use strict'; + + var util = require('util'), + Writable = require('stream').Writable; + + util.inherits(HashProto, Writable); + + object.Hash = new HashProto(); + + function HashProto() { + var shasum, + crypto = require('crypto'); + + Writable.call(this); + this.create = function() { + var ws = new Writable(); + + ws._write = write; + ws.get = get; + + shasum = crypto.createHash('sha1'); + + return ws; + }; + + function get() { + var hex = shasum.digest('hex'); + + return hex; + } + + function write (chunk, enc, next) { + shasum.update(chunk); + next(); + } + } + +})(this); diff --git a/lib/server/main.js b/lib/server/main.js index fe9cbec6..0edf8d0f 100644 --- a/lib/server/main.js +++ b/lib/server/main.js @@ -108,6 +108,7 @@ exports.auth = srvrequire('auth').auth, exports.appcache = srvrequire('appcache'), exports.dir = srvrequire('dir'), + exports.hash = srvrequire('hash').Hash; diffPatch = librequire('diff/diff-match-patch').diff_match_patch, exports.diff = new (librequire('diff').DiffProto)(diffPatch), exports.rest = srvrequire('rest').api, diff --git a/lib/server/rest.js b/lib/server/rest.js index d34d2290..176110bd 100644 --- a/lib/server/rest.js +++ b/lib/server/rest.js @@ -16,6 +16,7 @@ var main = global.cloudcmd.main, fs = main.fs, path = main.path, + Hash = main.hash, Util = main.util, pipe = main.pipe, CloudFunc = main.cloudfunc, @@ -98,7 +99,7 @@ } function onFS(pParams) { - var p, lError, lMsg, lSize, lQuery, + var p, lError, lMsg, lSize, lQuery, hash, lRet = main.checkParams(pParams); if (lRet){ @@ -115,7 +116,20 @@ sendResponse(p, lSize); }); }); - else + else if (Util.strCmp(lQuery, 'hash')) { + hash = Hash.create(); + + pipe.create({ + from : p.name, + write : hash, + callback : function (error) { + checkSendError(error, p, function() { + var hex = hash.get(); + sendResponse(p, hex); + }); + } + }); + } else fs.stat(p.name, function(pError, pStat) { checkSendError(pError, p, function() { if (!pStat.isDirectory()) From c49d2021835c25fc643be2edad1ab923fc66f6e2 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 19 Nov 2013 07:51:24 +0000 Subject: [PATCH 090/315] chore(diff) lint --- lib/diff.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/diff.js b/lib/diff.js index 21ed339c..4f81a262 100644 --- a/lib/diff.js +++ b/lib/diff.js @@ -1,6 +1,8 @@ (function (obj) { - obj.DiffProto = function(diffMatchPatch) { - var dmp = new diffMatchPatch(); + 'use strict'; + + obj.DiffProto = function(DiffMatchPatch) { + var dmp = new DiffMatchPatch(); this.createPatch = function(oldText, newText) { var diff = dmp.diff_main(oldText, newText), @@ -12,7 +14,7 @@ this.applyPatch = function(oldText, patch) { var patches = dmp.patch_fromText(patch), - result = dmp.patch_apply(patches, oldText); + result = dmp.patch_apply(patches, oldText), newText = result[0]; return newText; From 89b416c9f069b1fcbd21588957885240ed5c1c00 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 19 Nov 2013 07:52:17 +0000 Subject: [PATCH 091/315] chore(client) double setConfig --- lib/client.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/client.js b/lib/client.js index 3f4226b9..28cabf3d 100644 --- a/lib/client.js +++ b/lib/client.js @@ -299,8 +299,7 @@ var Util, DOM, CloudFunc, CloudCmd; return lGetSysFile; } - CloudCmd.setConfig = function(config) { Config = config }; - CloudCmd.setConfig = function(config) {Config = config}; + CloudCmd.setConfig = function(config) { Config = config; }; CloudCmd.getConfig = getSystemFile(Config, CloudCmd.JSONDIR + 'config.json'); CloudCmd.getModules = getSystemFile(Modules, CloudCmd.JSONDIR + 'modules.json'); CloudCmd.getFileTemplate = getSystemFile(FileTemplate, CloudCmd.HTMLDIR + 'file.html'); From 7eaf2e266d4ee07b7aa33bc4dcf95e69beaca9c1 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 19 Nov 2013 07:53:30 +0000 Subject: [PATCH 092/315] chore(dom) add ";" --- lib/client/dom.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/client/dom.js b/lib/client/dom.js index 6fb89ff1..85596204 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -668,7 +668,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; Events.addClick(focus, notify); } - }) + }); }; this.check = function () { From 1a6a1ca3b5c551f85f14076a5f27b819a982be65 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 19 Nov 2013 08:03:16 +0000 Subject: [PATCH 093/315] chore(dom) Notify --- lib/client/dom.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/client/dom.js b/lib/client/dom.js index 85596204..0c90e551 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -643,7 +643,9 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; }; }, NotifyProto = function() { - var Show, Allow, Notify = this; + var Show, Allow, + Notify = this, + Notification = window.Notification; Events.add({ 'blur' :function() { @@ -683,7 +685,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; }; this.request = function () { - var Not = window.Notification; + var Not = Notification; if (Not) Not.requestPermission(); From fa2e947a9c9be47250acc99cadc9447ed98fe7ea Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 19 Nov 2013 08:23:12 +0000 Subject: [PATCH 094/315] chore(hash) cr-lf -> lf --- lib/server/hash.js | 78 +++++++++++++++++++++++----------------------- 1 file changed, 39 insertions(+), 39 deletions(-) diff --git a/lib/server/hash.js b/lib/server/hash.js index 6aecf778..9003881a 100644 --- a/lib/server/hash.js +++ b/lib/server/hash.js @@ -1,39 +1,39 @@ -(function (object) { - 'use strict'; - - var util = require('util'), - Writable = require('stream').Writable; - - util.inherits(HashProto, Writable); - - object.Hash = new HashProto(); - - function HashProto() { - var shasum, - crypto = require('crypto'); - - Writable.call(this); - this.create = function() { - var ws = new Writable(); - - ws._write = write; - ws.get = get; - - shasum = crypto.createHash('sha1'); - - return ws; - }; - - function get() { - var hex = shasum.digest('hex'); - - return hex; - } - - function write (chunk, enc, next) { - shasum.update(chunk); - next(); - } - } - -})(this); +(function (object) { + 'use strict'; + + var util = require('util'), + Writable = require('stream').Writable; + + util.inherits(HashProto, Writable); + + object.Hash = new HashProto(); + + function HashProto() { + var shasum, + crypto = require('crypto'); + + Writable.call(this); + this.create = function() { + var ws = new Writable(); + + ws._write = write; + ws.get = get; + + shasum = crypto.createHash('sha1'); + + return ws; + }; + + function get() { + var hex = shasum.digest('hex'); + + return hex; + } + + function write (chunk, enc, next) { + shasum.update(chunk); + next(); + } + } + +})(this); From c506da11c711c9b2e00d23add9d1d7cbb61d8e8c Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 19 Nov 2013 08:42:12 +0000 Subject: [PATCH 095/315] feature(hash) rm Writable.call --- lib/server/hash.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/server/hash.js b/lib/server/hash.js index 9003881a..7ef3ce3a 100644 --- a/lib/server/hash.js +++ b/lib/server/hash.js @@ -12,7 +12,6 @@ var shasum, crypto = require('crypto'); - Writable.call(this); this.create = function() { var ws = new Writable(); From ece4742e9b9f57fb7a1be5beefeded9b4f2baa3d Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 19 Nov 2013 08:42:31 +0000 Subject: [PATCH 096/315] chore(hash) rm " " --- lib/server/hash.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/server/hash.js b/lib/server/hash.js index 7ef3ce3a..011c59fe 100644 --- a/lib/server/hash.js +++ b/lib/server/hash.js @@ -13,7 +13,7 @@ crypto = require('crypto'); this.create = function() { - var ws = new Writable(); + var ws = new Writable(); ws._write = write; ws.get = get; From 62546f1eaeeb1f47fba9842321e2fcd7203fd9d6 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 19 Nov 2013 08:58:30 +0000 Subject: [PATCH 097/315] feature(hash) add handling old node versions --- lib/server/hash.js | 2 +- lib/server/main.js | 2 +- lib/server/rest.js | 30 ++++++++++++++++++------------ 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/lib/server/hash.js b/lib/server/hash.js index 011c59fe..a4f88c5c 100644 --- a/lib/server/hash.js +++ b/lib/server/hash.js @@ -6,7 +6,7 @@ util.inherits(HashProto, Writable); - object.Hash = new HashProto(); + object.create = new HashProto().create; function HashProto() { var shasum, diff --git a/lib/server/main.js b/lib/server/main.js index 0edf8d0f..b6b51ec9 100644 --- a/lib/server/main.js +++ b/lib/server/main.js @@ -108,7 +108,7 @@ exports.auth = srvrequire('auth').auth, exports.appcache = srvrequire('appcache'), exports.dir = srvrequire('dir'), - exports.hash = srvrequire('hash').Hash; + exports.hash = srvrequire('hash'), diffPatch = librequire('diff/diff-match-patch').diff_match_patch, exports.diff = new (librequire('diff').DiffProto)(diffPatch), exports.rest = srvrequire('rest').api, diff --git a/lib/server/rest.js b/lib/server/rest.js index 176110bd..c3822079 100644 --- a/lib/server/rest.js +++ b/lib/server/rest.js @@ -117,18 +117,24 @@ }); }); else if (Util.strCmp(lQuery, 'hash')) { - hash = Hash.create(); - - pipe.create({ - from : p.name, - write : hash, - callback : function (error) { - checkSendError(error, p, function() { - var hex = hash.get(); - sendResponse(p, hex); - }); - } - }); + if (!Hash) { + lMsg = 'not suported, try update node'; + lMsg = CloudFunc.formatMsg('hash', lMsg, 'error'); + sendError(p, lMsg); + } else { + hash = Hash.create(); + + pipe.create({ + from : p.name, + write : hash, + callback : function (error) { + checkSendError(error, p, function() { + var hex = hash.get(); + sendResponse(p, hex); + }); + } + }); + } } else fs.stat(p.name, function(pError, pStat) { checkSendError(pError, p, function() { From 2cea2c70bca45cb5a8a951753e1acd5c2ea692c2 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 19 Nov 2013 09:33:51 +0000 Subject: [PATCH 098/315] refactor(hash) change structure --- lib/server/hash.js | 46 ++++++++++++++++++++++------------------------ lib/server/rest.js | 9 ++++----- 2 files changed, 26 insertions(+), 29 deletions(-) diff --git a/lib/server/hash.js b/lib/server/hash.js index a4f88c5c..70a1b59d 100644 --- a/lib/server/hash.js +++ b/lib/server/hash.js @@ -2,37 +2,35 @@ 'use strict'; var util = require('util'), + crypto = require('crypto'), Writable = require('stream').Writable; - - util.inherits(HashProto, Writable); - object.create = new HashProto().create; - - function HashProto() { - var shasum, - crypto = require('crypto'); + object.create = function() { + var ret; - this.create = function() { - var ws = new Writable(); - - ws._write = write; - ws.get = get; - - shasum = crypto.createHash('sha1'); - - return ws; + if (Writable) { + util.inherits(WS, Writable); + ret = new WS(); + } + + return ret; + }; + + function WS(opt) { + var sha = crypto.createHash('sha1'); + + Writable.call(this, opt); + + this._write = function(chunk, enc, next) { + sha.update(chunk); + next(); }; - function get() { - var hex = shasum.digest('hex'); + this.get = function() { + var hex = sha.digest('hex'); return hex; - } - - function write (chunk, enc, next) { - shasum.update(chunk); - next(); - } + }; } })(this); diff --git a/lib/server/rest.js b/lib/server/rest.js index c3822079..e464e564 100644 --- a/lib/server/rest.js +++ b/lib/server/rest.js @@ -117,13 +117,13 @@ }); }); else if (Util.strCmp(lQuery, 'hash')) { - if (!Hash) { + hash = Hash.create(); + + if (!hash) { lMsg = 'not suported, try update node'; lMsg = CloudFunc.formatMsg('hash', lMsg, 'error'); sendError(p, lMsg); - } else { - hash = Hash.create(); - + } else pipe.create({ from : p.name, write : hash, @@ -134,7 +134,6 @@ }); } }); - } } else fs.stat(p.name, function(pError, pStat) { checkSendError(pError, p, function() { From 0ee645ce04dd4e94dceb8d4a6898ccc08a185a97 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 19 Nov 2013 10:02:55 +0000 Subject: [PATCH 099/315] feature(dom) add loadCurrentHash --- lib/client/dom.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/client/dom.js b/lib/client/dom.js index 0c90e551..96892d41 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -1389,6 +1389,21 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; return lRet; }; + /** + * load hash + * @pCurrentFile + */ + this.loadCurrentHash = function(pCallBack, pCurrent) { + var lRet, + lCurrent = pCurrent || this.getCurrentFile(), + lLink = this.getCurrentPath(lCurrent), + lName = this.getCurrentName(lCurrent); + + RESTful.read(lLink, pCallBack, '?hash'); + + return lRet; + }; + /** * set size * @pCurrentFile From 6a9e81980e87b24b3f0caaafa35b915315753090 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 19 Nov 2013 10:03:35 +0000 Subject: [PATCH 100/315] chore(dom) rm old comment --- lib/client/dom.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/client/dom.js b/lib/client/dom.js index 96892d41..a34dc228 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -1378,7 +1378,6 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; lCurrent = pCurrent || this.getCurrentFile(), lLink = this.getCurrentPath(lCurrent), lName = this.getCurrentName(lCurrent); - /* если это папка - возвращаем слово dir вместо размера*/ if (lName !== '..') RESTful.read(lLink, function(pSize) { From 7a0a0b18ea71b8a31a8fb9132d9822d9af727e0a Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 19 Nov 2013 10:21:49 +0000 Subject: [PATCH 101/315] chore(dom) add " " --- lib/client/dom.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/client/dom.js b/lib/client/dom.js index a34dc228..b9123d82 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -1473,13 +1473,15 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; this.getCurrentData = function(pCallBack, pCurrentFile) { var lParams, lCurrentFile = pCurrentFile ? pCurrentFile : this.getCurrentFile(), - lFunc = function(pData) { - var lName = DOM.getCurrentName(lCurrentFile); - if ( Util.isObject(pData) ) { + + lFunc = function(pData) { + var lExt = '.json', + lName = DOM.getCurrentName(lCurrentFile); + + if (Util.isObject(pData)) { pData = Util.stringifyJSON(pData); - var lExt = '.json'; - if ( !Util.checkExtension(lName, lExt) ) + if (!Util.checkExtension(lName, lExt)) lName += lExt; } From ac6d4d6c91b9b10c03f6bc9d77417718bfbad5db Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 19 Nov 2013 10:24:57 +0000 Subject: [PATCH 102/315] refactor(dom) cache: add "!!" --- lib/client/dom.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/client/dom.js b/lib/client/dom.js index b9123d82..fab37ae8 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -576,7 +576,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; /* функция проверяет возможно ли работать с кэшем каким-либо образом */ this.isAllowed = function() { - var lRet = CacheAllowed && window.localStorage; + var lRet = CacheAllowed && !!window.localStorage; return lRet; }; From 2332b147e52df21f52778b236663edad41ca892d Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 19 Nov 2013 11:56:01 +0000 Subject: [PATCH 103/315] feature(dom) add getDataFromCache, saveDataInCache --- lib/client/dom.js | 69 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 67 insertions(+), 2 deletions(-) diff --git a/lib/client/dom.js b/lib/client/dom.js index fab37ae8..2ab3392b 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -1485,6 +1485,8 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; lName += lExt; } + DOM.saveDataInCache(lName, pData); + Util.exec(pCallBack, { data: pData, name: lName @@ -1498,9 +1500,15 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; success : lFunc, error : pCallBack.error }; - - return this.getCurrentFileContent(lParams, lCurrentFile); + var lName = DOM.getCurrentName(lCurrentFile); + + DOM.getDataFromCache(lName, function(data) { + if (data) + lFunc(data); + else + DOM.getCurrentFileContent(lParams, lCurrentFile); + }); }; /** @@ -1731,6 +1739,63 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; return lLink; }; + /** + * save data to storage + * + * @param name + * @param data + * @param callback + */ + this.saveDataInCache = function(name, data, callback) { + CloudCmd.getConfig(function(config) { + var allowed = config.localStorage; + + if (!allowed) + Util.exec(callback); + else { + Cache.set(name + '-data', data); + DOM.loadCurrentHash(function(hash) { + var isContain = Util.isContainStr(hash, 'error'); + + if (!isContain) + Cache.set(name + '-hash', hash); + + Util.exec(callback, hash); + }); + } + }); + }; + + /** + * save data to storage + * + * @param name + * @param data + * @param callback + */ + this.getDataFromCache = function(name, callback) { + CloudCmd.getConfig(function(config) { + var hash, allowed = config.localStorage, + isDir = DOM.isCurrentIsDir(); + + if (!allowed || isDir) + Util.exec(callback); + else { + hash = Cache.get(name + '-hash'); + + DOM.loadCurrentHash(function(pHash) { + var data, + isContain = Util.isContainStr(hash, 'error'); + + if (!isContain && hash === pHash) + data = Cache.get(name + '-data'); + + Util.exec(callback, data); + }); + } + }); + }; + /** function getting FM * @param pPanel_o = {active: true} */ From c1a7796843fbd9b3ad31810a874d9b7ffd1a3323 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 19 Nov 2013 12:09:52 +0000 Subject: [PATCH 104/315] feature(dom) add saveCurrentData --- lib/client/dom.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/client/dom.js b/lib/client/dom.js index 2ab3392b..02d12ca5 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -1511,6 +1511,19 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; }); }; + + /** + * unified way to save current file content + * + * @pCallBack - function({data, name}) {} + * @pCurrentFile + */ + this.saveCurrentData = function(pUrl, pData, pCallBack, pQuery) { + RESTful.save(pUrl, pData, function() { + DOM.saveDataInCache(pUrl, pData); + }, pQuery); + }; + /** * unified way to get RefreshButton */ From 1b311f08a4dd44f51dd06996601e30e6206d6341 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 19 Nov 2013 12:10:35 +0000 Subject: [PATCH 105/315] refactor(dom) getCurrentData: rm saveDataInCache --- lib/client/dom.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/client/dom.js b/lib/client/dom.js index 02d12ca5..d41dc672 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -1485,8 +1485,6 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; lName += lExt; } - DOM.saveDataInCache(lName, pData); - Util.exec(pCallBack, { data: pData, name: lName From 7f7c82356be6e890dbb79878bd07d240e960dd35 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 19 Nov 2013 12:11:16 +0000 Subject: [PATCH 106/315] feature(dom) saveDataInCache -> saveDataToCache --- lib/client/dom.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/client/dom.js b/lib/client/dom.js index d41dc672..967a8e5b 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -1518,7 +1518,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; */ this.saveCurrentData = function(pUrl, pData, pCallBack, pQuery) { RESTful.save(pUrl, pData, function() { - DOM.saveDataInCache(pUrl, pData); + DOM.saveDataToCache(pUrl, pData); }, pQuery); }; @@ -1757,7 +1757,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; * @param data * @param callback */ - this.saveDataInCache = function(name, data, callback) { + this.saveDataToCache = function(name, data, callback) { CloudCmd.getConfig(function(config) { var allowed = config.localStorage; From 325cf98da2ba5577987d0945f8d6601e77f23a59 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 19 Nov 2013 12:17:05 +0000 Subject: [PATCH 107/315] feature(edit) RESTful.save -> saveCurrentData --- lib/client/edit.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/client/edit.js b/lib/client/edit.js index 048dc495..765b0b66 100644 --- a/lib/client/edit.js +++ b/lib/client/edit.js @@ -132,7 +132,7 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch; query = '?patch'; } - DOM.RESTful.save(lPath, lValue, onSave, query); + DOM.saveCurrentData(lPath, lValue, onSave, query); }, function(callback) { diff(lValue, callback); }); From f528c351facb0a86f3ea7182bd63b7b62e21eba3 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 19 Nov 2013 12:23:54 +0000 Subject: [PATCH 108/315] refactor(dom) getCurrentData --- lib/client/dom.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/client/dom.js b/lib/client/dom.js index 967a8e5b..fbd2c919 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -1473,6 +1473,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; this.getCurrentData = function(pCallBack, pCurrentFile) { var lParams, lCurrentFile = pCurrentFile ? pCurrentFile : this.getCurrentFile(), + lPath = DOM.getCurrentPath(lCurrentFile), lFunc = function(pData) { var lExt = '.json', @@ -1499,9 +1500,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; error : pCallBack.error }; - var lName = DOM.getCurrentName(lCurrentFile); - - DOM.getDataFromCache(lName, function(data) { + DOM.getDataFromCache(lPath, function(data) { if (data) lFunc(data); else From 9e36587f7a249d8e5e7ab677ad3b1f8622f94170 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 19 Nov 2013 12:24:14 +0000 Subject: [PATCH 109/315] feature(edit) add saveDataToCache --- lib/client/edit.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/client/edit.js b/lib/client/edit.js index 765b0b66..1b5ffec0 100644 --- a/lib/client/edit.js +++ b/lib/client/edit.js @@ -132,7 +132,7 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch; query = '?patch'; } - DOM.saveCurrentData(lPath, lValue, onSave, query); + DOM.RESTful.save(lPath, lValue, onSave, query); }, function(callback) { diff(lValue, callback); }); @@ -192,15 +192,15 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch; path = DOM.getCurrentPath(), msg = '\nShould I save file anyway?'; - if (!isError) + if (!isError) { + Value = Ace.getValue(); Edit.showMessage(text); - else { - ret = Dialog.confirm(text + msg); + DOM.saveDataToCache(path, Value); + } else { + ret = Dialog.confirm(text + msg); - if (ret) { + if (ret) DOM.RESTful.save(path, Value, onSave); - Value = Ace.getValue(); - } } } From 444eb6041ef7b0b5f1daacd5d0f18b0177ec9a0b Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 19 Nov 2013 12:27:25 +0000 Subject: [PATCH 110/315] feature(dom) saveDataToCache: add Cache.get --- lib/client/dom.js | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/lib/client/dom.js b/lib/client/dom.js index fbd2c919..836fc545 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -1758,20 +1758,25 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; */ this.saveDataToCache = function(name, data, callback) { CloudCmd.getConfig(function(config) { - var allowed = config.localStorage; + var cacheName, + allowed = config.localStorage; if (!allowed) Util.exec(callback); else { - Cache.set(name + '-data', data); - DOM.loadCurrentHash(function(hash) { - var isContain = Util.isContainStr(hash, 'error'); - - if (!isContain) - Cache.set(name + '-hash', hash); - - Util.exec(callback, hash); - }); + cacheName = name + '-data'; + + if (!!Cache.get(cacheName)) { + Cache.set(cacheName, data); + DOM.loadCurrentHash(function(hash) { + var isContain = Util.isContainStr(hash, 'error'); + + if (!isContain) + Cache.set(name + '-hash', hash); + + Util.exec(callback, hash); + }); + } } }); }; From 1d42aed7eb715474b25681ac17a112502f14bd99 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 19 Nov 2013 12:32:42 +0000 Subject: [PATCH 111/315] fix(config) change config before setConfig --- lib/client/config.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/client/config.js b/lib/client/config.js index 52cbe890..682da486 100644 --- a/lib/client/config.js +++ b/lib/client/config.js @@ -136,9 +136,8 @@ var CloudCmd, Util, DOM; Notify.request(); } - CloudCmd.setConfig(CONFIG, function() { - CONFIG[name] = data; - }); + CONFIG[name] = data; + CloudCmd.setConfig(CONFIG); DOM.RESTful.config(obj); } From b7d4277f6dcba82f8a376db786fed76e6a19e149 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 19 Nov 2013 12:35:54 +0000 Subject: [PATCH 112/315] feature(dom) getDataFromCache: add !hash --- lib/client/dom.js | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/lib/client/dom.js b/lib/client/dom.js index 836fc545..d030c520 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -1798,15 +1798,18 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; else { hash = Cache.get(name + '-hash'); - DOM.loadCurrentHash(function(pHash) { - var data, - isContain = Util.isContainStr(hash, 'error'); - - if (!isContain && hash === pHash) - data = Cache.get(name + '-data'); - - Util.exec(callback, data); - }); + if (!hash) + Util.exec(callback); + else + DOM.loadCurrentHash(function(pHash) { + var data, + isContain = Util.isContainStr(hash, 'error'); + + if (!isContain && hash === pHash) + data = Cache.get(name + '-data'); + + Util.exec(callback, data); + }); } }); }; From 6a3dc106c6979377ab7955c6042bdcf0c454e02b Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 19 Nov 2013 12:44:59 +0000 Subject: [PATCH 113/315] refactor(dom) saveDataToCache --- lib/client/dom.js | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/lib/client/dom.js b/lib/client/dom.js index d030c520..b5604638 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -1486,6 +1486,8 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; lName += lExt; } + DOM.saveDataToCache(lName, pData); + Util.exec(pCallBack, { data: pData, name: lName @@ -1758,25 +1760,26 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; */ this.saveDataToCache = function(name, data, callback) { CloudCmd.getConfig(function(config) { - var cacheName, - allowed = config.localStorage; + var hash, + nameHash = name + '-hash', + nameData = name + '-data', + allowed = config.localStorage; if (!allowed) Util.exec(callback); else { - cacheName = name + '-data'; + hash = Cache.get(name + '-hash'); - if (!!Cache.get(cacheName)) { - Cache.set(cacheName, data); - DOM.loadCurrentHash(function(hash) { - var isContain = Util.isContainStr(hash, 'error'); - - if (!isContain) - Cache.set(name + '-hash', hash); - - Util.exec(callback, hash); - }); - } + DOM.loadCurrentHash(function(pHash) { + var isContain = Util.isContainStr(hash, 'error'); + + if (!isContain && hash !== pHash) { + Cache.set(nameHash, pHash); + Cache.set(nameData, data); + } + + Util.exec(callback, hash); + }); } }); }; From a0430de4aed97938d1e03a5a452af8c7dad2f70b Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 19 Nov 2013 12:46:38 +0000 Subject: [PATCH 114/315] fix(dom) getCurrentData --- lib/client/dom.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/client/dom.js b/lib/client/dom.js index b5604638..3c2f1314 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -1486,7 +1486,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; lName += lExt; } - DOM.saveDataToCache(lName, pData); + DOM.saveDataToCache(lPath, pData); Util.exec(pCallBack, { data: pData, From 0894835e6c6f06085e5e3b12e8188d128845303e Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 20 Nov 2013 07:51:19 +0000 Subject: [PATCH 115/315] docs(readme, help) status-ok: add fs?json --- HELP.md | 8 ++++---- README.md | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/HELP.md b/HELP.md index 6c0d6484..7e45f512 100644 --- a/HELP.md +++ b/HELP.md @@ -16,10 +16,10 @@ Cloud Commander v0.6.0 [![NPM version][NPMIMGURL]][NPMURL] [![Dependency Status] [JitSuURL]: http://cloudcmd.jit.su "JitSu" [HerokuURL]: http://cloudcmd.herokuapp.com/ "Heroku" [RunKiteURL]: http://cloudcmd.apps.runkite.com/ "RunKite" -[IO_LIVE_IMG]: http://status-ok.cloudcmd.io/host/io.cloudcmd.io "IO" -[JitSu_LIVE_IMG]: http://status-ok.cloudcmd.io/host/cloudcmd.jit.su "JitSu" -[HEROKU_LIVE_IMG]: http://status-ok.cloudcmd.io/host/cloudcmd.herokuapp.com "Heroku" -[RunKite_LIVE_IMG]: http://status-ok.cloudcmd.io/host/cloudcmd.apps.runkite.com/ "RunKite" +[IO_LIVE_IMG]: http://status-ok.cloudcmd.io/host/io.cloudcmd.io/fs?json "IO" +[JitSu_LIVE_IMG]: http://status-ok.cloudcmd.io/host/cloudcmd.jit.su/fs?json "JitSu" +[HEROKU_LIVE_IMG]: http://status-ok.cloudcmd.io/host/cloudcmd.herokuapp.com/fs?json "Heroku" +[RunKite_LIVE_IMG]: http://status-ok.cloudcmd.io/host/cloudcmd.apps.runkite.com/fs?json "RunKite" **Cloud Commander** - cloud file manager with console and editor. diff --git a/README.md b/README.md index bdddd2f4..1f6ce08f 100644 --- a/README.md +++ b/README.md @@ -16,10 +16,10 @@ Cloud Commander v0.6.0 [![NPM version][NPMIMGURL]][NPMURL] [![Dependency Status] [JitSuURL]: http://cloudcmd.jit.su "JitSu" [HerokuURL]: http://cloudcmd.herokuapp.com/ "Heroku" [RunKiteURL]: http://cloudcmd.apps.runkite.com/ "RunKite" -[IO_LIVE_IMG]: http://status-ok.cloudcmd.io/host/io.cloudcmd.io "IO" -[JitSu_LIVE_IMG]: http://status-ok.cloudcmd.io/host/cloudcmd.jit.su "JitSu" -[HEROKU_LIVE_IMG]: http://status-ok.cloudcmd.io/host/cloudcmd.herokuapp.com "Heroku" -[RunKite_LIVE_IMG]: http://status-ok.cloudcmd.io/host/cloudcmd.apps.runkite.com/ "RunKite" +[IO_LIVE_IMG]: http://status-ok.cloudcmd.io/host/io.cloudcmd.io/fs?json "IO" +[JitSu_LIVE_IMG]: http://status-ok.cloudcmd.io/host/cloudcmd.jit.su/fs?json "JitSu" +[HEROKU_LIVE_IMG]: http://status-ok.cloudcmd.io/host/cloudcmd.herokuapp.com/fs?json "Heroku" +[RunKite_LIVE_IMG]: http://status-ok.cloudcmd.io/host/cloudcmd.apps.runkite.com/fs?json "RunKite" **Cloud Commander** - cloud file manager with console and editor. From 6e3cc80b00a28a254a9ee9eeece410b868c1d0df Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 20 Nov 2013 08:07:03 +0000 Subject: [PATCH 116/315] fix(edit) set Value befor onSave --- lib/client/edit.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/client/edit.js b/lib/client/edit.js index 1b5ffec0..c5699aba 100644 --- a/lib/client/edit.js +++ b/lib/client/edit.js @@ -127,6 +127,8 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch; Util.ifExec(!isDiff, function(patch) { var query; + Value = lValue; + if (Util.isString(patch)) { lValue = patch; query = '?patch'; @@ -193,7 +195,6 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch; msg = '\nShould I save file anyway?'; if (!isError) { - Value = Ace.getValue(); Edit.showMessage(text); DOM.saveDataToCache(path, Value); } else { From 989373b55416f91fdb61c5cba3d826a3f84f5c01 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 20 Nov 2013 08:09:41 +0000 Subject: [PATCH 117/315] chore(ischanged) add " " --- lib/server/ischanged.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/server/ischanged.js b/lib/server/ischanged.js index 2ed2392f..b9905f40 100644 --- a/lib/server/ischanged.js +++ b/lib/server/ischanged.js @@ -1,4 +1,4 @@ -(function(){ +(function() { 'use strict'; var main = global.cloudcmd.main, @@ -13,27 +13,27 @@ Times = main.require(CHANGESNAME) || []; - exports.isFileChanged = function(pFileName, pCallBack){ + exports.isFileChanged = function(pFileName, pCallBack) { var lReadedTime, lData, i, n = Times.length; - for(i = 0; i < n; i++){ + for (i = 0; i < n; i++) { lData = Times[i]; /* if founded row with file name - save hash */ - if(lData.name === pFileName){ + if (lData.name === pFileName) { lReadedTime = lData.time; break; } } - fs.stat(pFileName, function(pError, pStat){ + fs.stat(pFileName, function(pError, pStat) { var lTimeChanged, lFileTime; if (!pError) { lFileTime = pStat.mtime.getTime(); - if(lReadedTime !== lFileTime) + if (lReadedTime !== lFileTime) lTimeChanged = Times[i] = { name: pFileName, time: lFileTime @@ -42,7 +42,7 @@ else Util.log(pError); - if(lTimeChanged) + if (lTimeChanged) writeFile(CHANGES_JSON, Util.stringifyJSON(Times)); Util.exec(pCallBack, lTimeChanged); @@ -54,9 +54,9 @@ * и выводит ошибку или сообщает, * что файл успешно записан */ - function writeFile(pFileName, pData){ - fs.writeFile(pFileName, pData, function(pError){ - if(pError) + function writeFile(pFileName, pData) { + fs.writeFile(pFileName, pData, function(pError) { + if (pError) Util.log(pError); else Util.log('file ' + path.basename(pFileName) + ' writed...'); From d13f610f163d0fcfcaa2505abefadad74ca6075c Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 20 Nov 2013 08:27:38 +0000 Subject: [PATCH 118/315] feature(time) add --- lib/server/ischanged.js | 28 +++++++++++++--------------- lib/server/main.js | 1 + lib/server/rest.js | 9 +++++++++ lib/server/time.js | 27 +++++++++++++++++++++++++++ 4 files changed, 50 insertions(+), 15 deletions(-) create mode 100644 lib/server/time.js diff --git a/lib/server/ischanged.js b/lib/server/ischanged.js index b9905f40..7da5abcc 100644 --- a/lib/server/ischanged.js +++ b/lib/server/ischanged.js @@ -7,6 +7,7 @@ fs = main.fs, path = main.path, Util = main.util, + time = main.time, CHANGESNAME = JSONDIR + 'changes', CHANGES_JSON = CHANGESNAME + '.json', @@ -27,25 +28,22 @@ } } - fs.stat(pFileName, function(pError, pStat) { - var lTimeChanged, lFileTime; + time.get(pFileName, function(error, fileTime) { + var timeChanged; - if (!pError) { - lFileTime = pStat.mtime.getTime(); - - if (lReadedTime !== lFileTime) - lTimeChanged = Times[i] = { - name: pFileName, - time: lFileTime - }; - } - else - Util.log(pError); + if (error) + Util.log(error); + else if (lReadedTime !== fileTime) + timeChanged = Times[i] = { + name: pFileName, + time: fileTime + }; + - if (lTimeChanged) + if (timeChanged) writeFile(CHANGES_JSON, Util.stringifyJSON(Times)); - Util.exec(pCallBack, lTimeChanged); + Util.exec(pCallBack, timeChanged); }); }; diff --git a/lib/server/main.js b/lib/server/main.js index b6b51ec9..6557e5d9 100644 --- a/lib/server/main.js +++ b/lib/server/main.js @@ -111,6 +111,7 @@ exports.hash = srvrequire('hash'), diffPatch = librequire('diff/diff-match-patch').diff_match_patch, exports.diff = new (librequire('diff').DiffProto)(diffPatch), + exports.time = srvrequire('time'); exports.rest = srvrequire('rest').api, exports.update = srvrequire('update'), exports.ischanged = srvrequire('ischanged'); diff --git a/lib/server/rest.js b/lib/server/rest.js index e464e564..5d08a760 100644 --- a/lib/server/rest.js +++ b/lib/server/rest.js @@ -22,6 +22,7 @@ CloudFunc = main.cloudfunc, dir = main.dir, diff = main.diff, + time = main.time, JSONDIR = main.JSONDIR, OK = 200, sendError = main.sendError, @@ -116,6 +117,14 @@ sendResponse(p, lSize); }); }); + else if (Util.strCmp(lQuery, 'time')) + time.get(p.name, function(error, time) { + checkSendError(error, p, function() { + var timeStr = time.toString(); + + sendResponse(p, timeStr); + }); + }); else if (Util.strCmp(lQuery, 'hash')) { hash = Hash.create(); diff --git a/lib/server/time.js b/lib/server/time.js new file mode 100644 index 00000000..0aaf5ea3 --- /dev/null +++ b/lib/server/time.js @@ -0,0 +1,27 @@ +(function (object) { + 'use strict'; + + if(!global.cloudcmd) + return console.log( + '# dir.js' + '\n' + + '# -----------' + '\n' + + '# Module is part of Cloud Commander,' + '\n' + + '# used for getting file change time.' + '\n' + + '# http://cloudcmd.io' + '\n'); + + var main = global.cloudcmd.main, + fs = require('fs'), + Util = main.util; + + object.get = function(filename, callback) { + fs.stat(filename, function(error, stat) { + var time; + + if (!error) + time = stat.mtime.getTime(); + + Util.exec(callback, error, time); + }); + }; + +})(this); From 5511c6678c6c99a52f363548a9565bd484aa6429 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 20 Nov 2013 09:41:20 +0000 Subject: [PATCH 119/315] feature(dom) Cache -> Storage --- css/style.css | 4 +-- html/path.html | 2 +- lib/client.js | 12 ++++----- lib/client/dom.js | 50 +++++++++++++++++------------------ lib/client/key.js | 8 +++--- lib/client/listeners.js | 18 ++++++------- lib/client/polyfill.js | 24 ++++++++--------- lib/client/storage/_github.js | 8 +++--- 8 files changed, 63 insertions(+), 63 deletions(-) diff --git a/css/style.css b/css/style.css index 7d305fd1..2e5f9833 100644 --- a/css/style.css +++ b/css/style.css @@ -115,12 +115,12 @@ body { transition: ease 0.1s; } -.clear-cache { +.clear-storage { margin-right: 6px; margin-left: 7px; background:url(/img/console_clear.png) -4px -4px no-repeat; } -.clear-cache:active { +.clear-storage:active { top:5px; } diff --git a/html/path.html b/html/path.html index 08ac9edf..ca997182 100644 --- a/html/path.html +++ b/html/path.html @@ -1 +1 @@ -
      • {{ path }}
      • \ No newline at end of file +
      • {{ path }}
      • \ No newline at end of file diff --git a/lib/client.js b/lib/client.js index 28cabf3d..e2e9bb03 100644 --- a/lib/client.js +++ b/lib/client.js @@ -8,7 +8,7 @@ var Util, DOM, CloudFunc, CloudCmd; 'use strict'; var Key, Config, Modules, FileTemplate, PathTemplate, Listeners, - Cache = DOM.Cache; + Storage = DOM.Storage; CloudCmd = { LIBDIR : '/lib/', @@ -262,11 +262,11 @@ var Util, DOM, CloudFunc, CloudCmd; CloudCmd.getConfig(function(config) { var localStorage = config.localStorage; /* устанавливаем переменную доступности кэша */ - Cache.setAllowed(localStorage); + Storage.setAllowed(localStorage); /* Устанавливаем кэш корневого каталога */ var lDirPath = DOM.getCurrentDirPath(); - if (!Cache.get(lDirPath)) - Cache.set(lDirPath, getJSONfromFileTable()); + if (!Storage.get(lDirPath)) + Storage.set(lDirPath, getJSONfromFileTable()); }); Util.exec(pCallBack); @@ -368,7 +368,7 @@ var Util, DOM, CloudFunc, CloudCmd; */ var lRet = pOptions.refresh; if (!lRet) { - var lJSON = Cache.get(lCleanPath); + var lJSON = Storage.get(lCleanPath); if (lJSON) { lJSON = Util.parseJSON(lJSON); @@ -399,7 +399,7 @@ var Util, DOM, CloudFunc, CloudCmd; /* если размер данных не очень бошьой * * сохраняем их в кэше */ if (lJSON_s.length < 50000 ) - Cache.set(lCleanPath, lJSON_s); + Storage.set(lCleanPath, lJSON_s); } }); }; diff --git a/lib/client/dom.js b/lib/client/dom.js index 3c2f1314..c109993a 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -570,21 +570,21 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; } } }, - CacheProto = function() { + StorageProto = function() { /* приватный переключатель возможности работы с кэшем */ - var CacheAllowed; + var StorageAllowed; /* функция проверяет возможно ли работать с кэшем каким-либо образом */ this.isAllowed = function() { - var lRet = CacheAllowed && !!window.localStorage; + var lRet = StorageAllowed && !!window.localStorage; return lRet; }; /** - * allow cache usage + * allow Storage usage */ this.setAllowed = function(pAllowd) { - CacheAllowed = pAllowd; + StorageAllowed = pAllowd; return pAllowd; }; @@ -593,7 +593,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; this.remove = function(pItem) { var lRet = this; - if (CacheAllowed) + if (StorageAllowed) localStorage.removeItem(pItem); return lRet; @@ -606,27 +606,27 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; this.set = function(pName, pData) { var lRet = this; - if (CacheAllowed && pName && pData) + if (StorageAllowed && pName && pData) localStorage.setItem(pName,pData); return lRet; }, - /** Если доступен Cache принимаем из него данные*/ + /** Если доступен Storage принимаем из него данные*/ this.get = function(pName) { var lRet; - if (CacheAllowed) + if (StorageAllowed) lRet = localStorage.getItem(pName); return lRet; }, - /* get all cache from local storage */ + /* get all Storage from local storage */ this.getAll = function() { var lRet = null; - if (CacheAllowed) + if (StorageAllowed) lRet = localStorage; return lRet; @@ -636,7 +636,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; this.clear = function() { var lRet = this; - if (CacheAllowed) + if (StorageAllowed) localStorage.clear(); return lRet; @@ -1262,7 +1262,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; DOM.getCurrentDirPath() ); - Cache.remove(lDir); + Storage.remove(lDir); }, lQuery); return lCurrent; @@ -1486,7 +1486,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; lName += lExt; } - DOM.saveDataToCache(lPath, pData); + DOM.saveDataToStorage(lPath, pData); Util.exec(pCallBack, { data: pData, @@ -1502,7 +1502,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; error : pCallBack.error }; - DOM.getDataFromCache(lPath, function(data) { + DOM.getDataFromStorage(lPath, function(data) { if (data) lFunc(data); else @@ -1519,7 +1519,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; */ this.saveCurrentData = function(pUrl, pData, pCallBack, pQuery) { RESTful.save(pUrl, pData, function() { - DOM.saveDataToCache(pUrl, pData); + DOM.saveDataToStorage(pUrl, pData); }, pQuery); }; @@ -1758,7 +1758,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; * @param data * @param callback */ - this.saveDataToCache = function(name, data, callback) { + this.saveDataToStorage = function(name, data, callback) { CloudCmd.getConfig(function(config) { var hash, nameHash = name + '-hash', @@ -1768,14 +1768,14 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; if (!allowed) Util.exec(callback); else { - hash = Cache.get(name + '-hash'); + hash = Storage.get(name + '-hash'); DOM.loadCurrentHash(function(pHash) { var isContain = Util.isContainStr(hash, 'error'); if (!isContain && hash !== pHash) { - Cache.set(nameHash, pHash); - Cache.set(nameData, data); + Storage.set(nameHash, pHash); + Storage.set(nameData, data); } Util.exec(callback, hash); @@ -1791,7 +1791,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; * @param data * @param callback */ - this.getDataFromCache = function(name, callback) { + this.getDataFromStorage = function(name, callback) { CloudCmd.getConfig(function(config) { var hash, allowed = config.localStorage, isDir = DOM.isCurrentIsDir(); @@ -1799,7 +1799,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; if (!allowed || isDir) Util.exec(callback); else { - hash = Cache.get(name + '-hash'); + hash = Storage.get(name + '-hash'); if (!hash) Util.exec(callback); @@ -1809,7 +1809,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; isContain = Util.isContainStr(hash, 'error'); if (!isContain && hash === pHash) - data = Cache.get(name + '-data'); + data = Storage.get(name + '-data'); Util.exec(callback, data); }); @@ -2108,7 +2108,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; Loader = Util.extendProto(LoaderProto), Images = Util.extendProto(ImagesProto), RESTful = Util.extendProto(RESTfulProto), - Cache = Util.extendProto(CacheProto); + Storage = Util.extendProto(StorageProto); DOMProto = DOMFunc.prototype = new CmdProto(); @@ -2120,7 +2120,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; Events : Events, RESTful : RESTful, Images : Images, - Cache : Cache, + Storage : Storage, Notify : Notify, Dialog : Dialog } diff --git a/lib/client/key.js b/lib/client/key.js index aabca0e9..ed799fe9 100644 --- a/lib/client/key.js +++ b/lib/client/key.js @@ -303,10 +303,10 @@ var CloudCmd, Util, DOM; case Key.D: if (lCtrl) { Util.log('+d pressed\n' + - 'clearing cache...\n' + + 'clearing Storage...\n' + 'press +q to remove all key-handlers'); - DOM.Cache.clear(); + DOM.Storage.clear(); DOM.preventDefault(); } break; @@ -316,7 +316,7 @@ var CloudCmd, Util, DOM; if (lAlt) { Util.log('+q pressed\n' + '+r reload key-handerl - removed' + - '+s clear cache key-handler - removed'+ + '+s clear Storage key-handler - removed'+ 'press +s to to set them'); Binded = false; @@ -334,7 +334,7 @@ var CloudCmd, Util, DOM; Binded = true; Util.log('+s pressed \n' + '+r reload key-handerl - set \n' + - '+s clear cache key-handler - set \n' + + '+s clear Storage key-handler - set \n' + 'press +q to remove them'); DOM.preventDefault(pEvent); diff --git a/lib/client/listeners.js b/lib/client/listeners.js index b4bede34..b153e9dd 100644 --- a/lib/client/listeners.js +++ b/lib/client/listeners.js @@ -6,7 +6,7 @@ var Util, DOM, CloudCmd; CloudCmd.Listeners = new ListenersProto(CloudCmd, Util, DOM); function ListenersProto(CloudCmd, Util, DOM){ - var Cache = DOM.Cache, + var Storage = DOM.Storage, Events = DOM.Events, getConfig = CloudCmd.getConfig; @@ -29,7 +29,7 @@ var Util, DOM, CloudCmd; }; this.init = function () { - appCache(); + appStorage(); contextMenu(); dragndrop(); unload(); @@ -80,8 +80,8 @@ var Util, DOM, CloudCmd; */ this.changeLinks = function(pPanelID) { /* назначаем кнопку очистить кэш и показываем её */ - var lClearcache = DOM.getById('clear-cache'); - Events.addClick(Cache.clear, lClearcache); + var lClearStorage = DOM.getById('clear-storage'); + Events.addClick(Storage.clear, lClearStorage); /* меняем ссылки на ajax-запросы */ var lPanel = DOM.getById(pPanelID), @@ -191,19 +191,19 @@ var Util, DOM, CloudCmd; } }; - function appCache() { + function appStorage() { getConfig(function(config) { - var isAppCache = config.appCache, - appCache = window.applicationCache; + var isAppStorage = config.appStorage, + appStorage = window.applicationStorage; - if (isAppCache && appCache) + if (isAppStorage && appStorage) Events.add('updateready', function() { var ret = confirm('An update is available. Reload now?'); if (ret) location.reload(); - }, appCache); + }, appStorage); }); } diff --git a/lib/client/polyfill.js b/lib/client/polyfill.js index 172a7aa3..8e8b54a6 100644 --- a/lib/client/polyfill.js +++ b/lib/client/polyfill.js @@ -214,25 +214,25 @@ var Util, DOM, jQuery; } if(!window.localStorage){ - var Cache = function(){ + var Storage = function(){ /* приватный переключатель возможности работы с кэшем */ - var CacheAllowed, + var StorageAllowed, Data = {}; /* функция проверяет возможно ли работать с кэшем каким-либо образом */ this.isAllowed = function(){ - return CacheAllowed; + return StorageAllowed; }; this.setAllowed = function(pAllowed){ - CacheAllowed = pAllowed; + StorageAllowed = pAllowed; return pAllowed; }; /** remove element */ this.remove = function(pItem){ var lRet = this; - if(CacheAllowed) + if(StorageAllowed) delete Data[pItem]; return lRet; @@ -245,27 +245,27 @@ var Util, DOM, jQuery; this.set = function(pName, pData){ var lRet = this; - if(CacheAllowed && pName && pData) + if(StorageAllowed && pName && pData) Data[pName] = pData; return lRet; }, - /** Если доступен Cache принимаем из него данные*/ + /** Если доступен Storage принимаем из него данные*/ this.get = function(pName){ var lRet = false; - if(CacheAllowed) + if(StorageAllowed) lRet = Data[pName]; return lRet; }, - /* get all cache from local storage */ + /* get all Storage from local storage */ this.getAll = function(){ var lRet = null; - if(CacheAllowed) + if(StorageAllowed) lRet = Data; return lRet; @@ -275,14 +275,14 @@ var Util, DOM, jQuery; this.clear = function(){ var lRet = this; - if(CacheAllowed) + if(StorageAllowed) Data = {}; return lRet; }; }; - DOM.Cache = new Cache(); + DOM.Storage = new Storage(); } })(Util, DOM, jQuery); \ No newline at end of file diff --git a/lib/client/storage/_github.js b/lib/client/storage/_github.js index 9ee2b8e4..06258d87 100644 --- a/lib/client/storage/_github.js +++ b/lib/client/storage/_github.js @@ -4,7 +4,7 @@ var CloudCmd, Util, DOM, $, Github, cb; (function(CloudCmd, Util, DOM){ 'use strict'; - var Cache = DOM.Cache, + var Storage = DOM.Storage, GithubLocal, User, GitHubStore = {}; @@ -37,7 +37,7 @@ var CloudCmd, Util, DOM, $, Github, cb; GitHubStore.autorize = function(pCallBack, pCode){ - var lToken = Cache.get('token'); + var lToken = Storage.get('token'); if(lToken){ GitHubStore.Login(lToken); Util.exec(pCallBack); @@ -55,7 +55,7 @@ var CloudCmd, Util, DOM, $, Github, cb; lToken = pData.token; GitHubStore.Login(lToken); - Cache.set('token', lToken); + Storage.set('token', lToken); Util.exec(pCallBack); } else @@ -77,7 +77,7 @@ var CloudCmd, Util, DOM, $, Github, cb; Util.log('Hello ' + lName + ' :)!'); } else - DOM.Cache.remove('token'); + DOM.Storage.remove('token'); }); Util.exec(pCallBack); From acf6e2c63366f019a081b70d12a541f725098c2b Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 20 Nov 2013 09:45:15 +0000 Subject: [PATCH 120/315] feature(dom) getDataFromStorage: add isDir condition --- lib/client/dom.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/client/dom.js b/lib/client/dom.js index c109993a..a2b463bc 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -1763,9 +1763,10 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; var hash, nameHash = name + '-hash', nameData = name + '-data', - allowed = config.localStorage; + allowed = config.localStorage, + isDir = DOM.isCurrentIsDir(); - if (!allowed) + if (!allowed || isDir) Util.exec(callback); else { hash = Storage.get(name + '-hash'); From a02a4a3ee612cde8a8e0c0c773d0645b36a0d735 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 20 Nov 2013 11:14:52 +0000 Subject: [PATCH 121/315] feature(config) port, sslPort input: add type=number --- html/config.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/html/config.html b/html/config.html index d98df612..af73339d 100644 --- a/html/config.html +++ b/html/config.html @@ -11,8 +11,8 @@
      • -
      • -
      • +
      • +
    From 846b2a46bc51fc5331486b2ca8d4312efacd1a0d Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 20 Nov 2013 11:15:42 +0000 Subject: [PATCH 122/315] feature(config) port, sslPort: add focus:invalid:focus --- css/config.css | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/css/config.css b/css/config.css index 3a38141f..dc66b8a3 100644 --- a/css/config.css +++ b/css/config.css @@ -23,6 +23,13 @@ transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s; } +.config .form-control:focus:invalid:focus { + border-color: #e9322d; + -webkit-box-shadow: 0 0 6px #f8b9b7; + -moz-box-shadow: 0 0 6px #f8b9b7; + box-shadow: 0 0 6px #f8b9b7; +} + .config .form-control:focus { border-color: #66afe9; outline: 0; From e1ff4dc22253e3a6fb682f221835e34a85c5ebc5 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 20 Nov 2013 11:20:17 +0000 Subject: [PATCH 123/315] fix(edit) saveDataToCache -> saveDataToStorage --- lib/client/edit.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/client/edit.js b/lib/client/edit.js index c5699aba..1adee29e 100644 --- a/lib/client/edit.js +++ b/lib/client/edit.js @@ -196,7 +196,7 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch; if (!isError) { Edit.showMessage(text); - DOM.saveDataToCache(path, Value); + DOM.saveDataToStorage(path, Value); } else { ret = Dialog.confirm(text + msg); From 60e84ae172ed00701c354a1893631a149a7b3db6 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 20 Nov 2013 11:21:00 +0000 Subject: [PATCH 124/315] feature(config) css line-height: 1.428571429 -> 1.5 --- css/config.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/css/config.css b/css/config.css index dc66b8a3..36e0345d 100644 --- a/css/config.css +++ b/css/config.css @@ -13,7 +13,7 @@ .config .form-control{ padding: 0 12px; font-size: 16px; - line-height: 1.428571429; + line-height: 1.5; color: #555555; background-color: #ffffff; border: 1px solid #cccccc; From 68a12b2f56e94a808d12010a7c81c7aa189f44d6 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 20 Nov 2013 12:58:43 +0000 Subject: [PATCH 125/315] feature(dom) rm getTime --- lib/client/dom.js | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/lib/client/dom.js b/lib/client/dom.js index a2b463bc..776f7d37 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -2083,24 +2083,6 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; return lRet; }; - - /** - * function gets time - */ - this.getTime = function() { - var lRet, - lDate = new Date(), - lHours = lDate.getHours(), - lMinutes = lDate.getMinutes(), - lSeconds = lDate.getSeconds(); - - lMinutes = lMinutes < 10 ? '0' + lMinutes : lMinutes; - lSeconds = lSeconds < 10 ? '0' + lSeconds : lSeconds; - - lRet = lHours + ":" + lMinutes + ":" + lSeconds; - - return lRet; - }; }, DOMTree = Util.extendProto(DOMTreeProto), From 2b35b44291ca8ef5955fea45f5ae2b1c3b5c0cd0 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 20 Nov 2013 13:11:08 +0000 Subject: [PATCH 126/315] feature(client) add getExt --- lib/client.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/client.js b/lib/client.js index e2e9bb03..05a7df01 100644 --- a/lib/client.js +++ b/lib/client.js @@ -7,7 +7,7 @@ var Util, DOM, CloudFunc, CloudCmd; (function(Util, DOM) { 'use strict'; - var Key, Config, Modules, FileTemplate, PathTemplate, Listeners, + var Key, Config, Modules, Extensions, FileTemplate, PathTemplate, Listeners, Storage = DOM.Storage; CloudCmd = { @@ -302,6 +302,7 @@ var Util, DOM, CloudFunc, CloudCmd; CloudCmd.setConfig = function(config) { Config = config; }; CloudCmd.getConfig = getSystemFile(Config, CloudCmd.JSONDIR + 'config.json'); CloudCmd.getModules = getSystemFile(Modules, CloudCmd.JSONDIR + 'modules.json'); + CloudCmd.getExt = getSystemFile(Extensions, CloudCmd.JSONDIR + 'ext.json'); CloudCmd.getFileTemplate = getSystemFile(FileTemplate, CloudCmd.HTMLDIR + 'file.html'); CloudCmd.getPathTemplate = getSystemFile(PathTemplate, CloudCmd.HTMLDIR + 'path.html'); From 0b77463f642446f9b44522055d229d81adfef1f4 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 20 Nov 2013 13:11:16 +0000 Subject: [PATCH 127/315] feature(client) add getType --- lib/client/dom.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/client/dom.js b/lib/client/dom.js index 776f7d37..2e017669 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -2083,6 +2083,21 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; return lRet; }; + + this.getType = function(name, callback) { + CloudCmd.getExt(function(extensions) { + var str, index, + ext = Util.getExtension(name); + ext = extensions[ext]; + + if (ext) { + index = ext.indexOf('/') + 1; + ext = ext.substr(index); + } + + Util.exec(callback, ext); + }); + }; }, DOMTree = Util.extendProto(DOMTreeProto), From 6d5ee1f1d5647db1091ca6aa8d30afbd56d12c20 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 20 Nov 2013 13:47:32 +0000 Subject: [PATCH 128/315] feature(edit) add autocompletion --- lib/client/edit.js | 9 +- lib/client/edit/ext-language_tools.js | 1429 ++++++++++++++++++++++++ lib/client/edit/snippets/javascript.js | 202 ++++ 3 files changed, 1639 insertions(+), 1 deletion(-) create mode 100644 lib/client/edit/ext-language_tools.js create mode 100644 lib/client/edit/snippets/javascript.js diff --git a/lib/client/edit.js b/lib/client/edit.js index 1adee29e..fdb2d3ec 100644 --- a/lib/client/edit.js +++ b/lib/client/edit.js @@ -61,7 +61,11 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch; initAce(); } - Ace.session.setOption('useWorker', lUseWorker); + Ace.setOptions({ + useWorker : lUseWorker, + enableBasicAutocompletion : true, + enableSnippets : true + }); if (Util.isString(pValue)) { Ace.setValue(pValue); @@ -97,6 +101,8 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch; function initAce() { var lSession; + ace.require('ace/ext/language_tools'); + Ace = ace.edit(Element); lSession = Ace.getSession(); @@ -166,6 +172,7 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch; var lFiles = [ DIR + 'theme-tomorrow_night_blue.js', + DIR + 'ext-language_tools.js', DIR + 'ace.js', ]; diff --git a/lib/client/edit/ext-language_tools.js b/lib/client/edit/ext-language_tools.js new file mode 100644 index 00000000..1679e3af --- /dev/null +++ b/lib/client/edit/ext-language_tools.js @@ -0,0 +1,1429 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2012, Ajax.org B.V. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Ajax.org B.V. nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * ***** END LICENSE BLOCK ***** */ + +ace.define('ace/ext/language_tools', ['require', 'exports', 'module' , 'ace/snippets', 'ace/autocomplete', 'ace/config', 'ace/autocomplete/text_completer', 'ace/editor'], function(require, exports, module) { + + +var snippetManager = require("../snippets").snippetManager; +var Autocomplete = require("../autocomplete").Autocomplete; +var config = require("../config"); + +var textCompleter = require("../autocomplete/text_completer"); +var keyWordCompleter = { + getCompletions: function(editor, session, pos, prefix, callback) { + var keywords = session.$mode.$keywordList || []; + keywords = keywords.filter(function(w) { + return w.lastIndexOf(prefix, 0) == 0; + }); + callback(null, keywords.map(function(word) { + return { + name: word, + value: word, + score: 0, + meta: "keyword" + }; + })); + } +}; + +var snippetCompleter = { + getCompletions: function(editor, session, pos, prefix, callback) { + var scope = snippetManager.$getScope(editor); + var snippetMap = snippetManager.snippetMap; + var completions = []; + [scope, "_"].forEach(function(scope) { + var snippets = snippetMap[scope] || []; + for (var i = snippets.length; i--;) { + var s = snippets[i]; + if (s.tabTrigger && s.tabTrigger.indexOf(prefix) === 0) + completions.push({ + caption: s.tabTrigger, + snippet: s.content, + meta: "snippet" + }); + } + }, this); + callback(null, completions); + } +}; + +var completers = [snippetCompleter, textCompleter, keyWordCompleter]; +exports.addCompleter = function(completer) { + completers.push(completer); +}; + +var expandSnippet = { + name: "expandSnippet", + exec: function(editor) { + var success = snippetManager.expandWithTab(editor); + if (!success) + editor.execCommand("indent"); + }, + bindKey: "tab" +} + +var onChangeMode = function(e, editor) { + var mode = editor.session.$mode; + var id = mode.$id + if (!snippetManager.files) snippetManager.files = {}; + if (id && !snippetManager.files[id]) { + var snippetFilePath = id.replace("mode", "snippets"); + config.loadModule(snippetFilePath, function(m) { + if (m) { + snippetManager.files[id] = m; + m.snippets = snippetManager.parseSnippetFile(m.snippetText); + snippetManager.register(m.snippets, m.scope); + } + }); + } +}; + +var Editor = require("../editor").Editor; +require("../config").defineOptions(Editor.prototype, "editor", { + enableBasicAutocompletion: { + set: function(val) { + if (val) { + this.completers = completers + this.commands.addCommand(Autocomplete.startCommand); + } else { + this.commands.removeCommand(Autocomplete.startCommand); + } + }, + value: false + }, + enableSnippets: { + set: function(val) { + if (val) { + this.commands.addCommand(expandSnippet); + this.on("changeMode", onChangeMode); + onChangeMode(null, this) + } else { + this.commands.removeCommand(expandSnippet); + this.off("changeMode", onChangeMode); + } + }, + value: false + } +}); + +}); + +ace.define('ace/snippets', ['require', 'exports', 'module' , 'ace/lib/lang', 'ace/range', 'ace/keyboard/hash_handler', 'ace/tokenizer', 'ace/lib/dom'], function(require, exports, module) { + +var lang = require("./lib/lang") +var Range = require("./range").Range +var HashHandler = require("./keyboard/hash_handler").HashHandler; +var Tokenizer = require("./tokenizer").Tokenizer; +var comparePoints = Range.comparePoints; + +var SnippetManager = function() { + this.snippetMap = {}; + this.snippetNameMap = {}; +}; + +(function() { + this.getTokenizer = function() { + function TabstopToken(str, _, stack) { + str = str.substr(1); + if (/^\d+$/.test(str) && !stack.inFormatString) + return [{tabstopId: parseInt(str, 10)}]; + return [{text: str}] + } + function escape(ch) { + return "(?:[^\\\\" + ch + "]|\\\\.)"; + } + SnippetManager.$tokenizer = new Tokenizer({ + start: [ + {regex: /:/, onMatch: function(val, state, stack) { + if (stack.length && stack[0].expectIf) { + stack[0].expectIf = false; + stack[0].elseBranch = stack[0]; + return [stack[0]]; + } + return ":"; + }}, + {regex: /\\./, onMatch: function(val, state, stack) { + var ch = val[1]; + if (ch == "}" && stack.length) { + val = ch; + }else if ("`$\\".indexOf(ch) != -1) { + val = ch; + } else if (stack.inFormatString) { + if (ch == "n") + val = "\n"; + else if (ch == "t") + val = "\n"; + else if ("ulULE".indexOf(ch) != -1) { + val = {changeCase: ch, local: ch > "a"}; + } + } + + return [val]; + }}, + {regex: /}/, onMatch: function(val, state, stack) { + return [stack.length ? stack.shift() : val]; + }}, + {regex: /\$(?:\d+|\w+)/, onMatch: TabstopToken}, + {regex: /\$\{[\dA-Z_a-z]+/, onMatch: function(str, state, stack) { + var t = TabstopToken(str.substr(1), state, stack); + stack.unshift(t[0]); + return t; + }, next: "snippetVar"}, + {regex: /\n/, token: "newline", merge: false} + ], + snippetVar: [ + {regex: "\\|" + escape("\\|") + "*\\|", onMatch: function(val, state, stack) { + stack[0].choices = val.slice(1, -1).split(","); + }, next: "start"}, + {regex: "/(" + escape("/") + "+)/(?:(" + escape("/") + "*)/)(\\w*):?", + onMatch: function(val, state, stack) { + var ts = stack[0]; + ts.fmtString = val; + + val = this.splitRegex.exec(val); + ts.guard = val[1]; + ts.fmt = val[2]; + ts.flag = val[3]; + return ""; + }, next: "start"}, + {regex: "`" + escape("`") + "*`", onMatch: function(val, state, stack) { + stack[0].code = val.splice(1, -1); + return ""; + }, next: "start"}, + {regex: "\\?", onMatch: function(val, state, stack) { + if (stack[0]) + stack[0].expectIf = true; + }, next: "start"}, + {regex: "([^:}\\\\]|\\\\.)*:?", token: "", next: "start"} + ], + formatString: [ + {regex: "/(" + escape("/") + "+)/", token: "regex"}, + {regex: "", onMatch: function(val, state, stack) { + stack.inFormatString = true; + }, next: "start"} + ] + }); + SnippetManager.prototype.getTokenizer = function() { + return SnippetManager.$tokenizer; + } + return SnippetManager.$tokenizer; + }; + + this.tokenizeTmSnippet = function(str, startState) { + return this.getTokenizer().getLineTokens(str, startState).tokens.map(function(x) { + return x.value || x; + }); + }; + + this.$getDefaultValue = function(editor, name) { + if (/^[A-Z]\d+$/.test(name)) { + var i = name.substr(1); + return (this.variables[name[0] + "__"] || {})[i]; + } + if (/^\d+$/.test(name)) { + return (this.variables.__ || {})[name]; + } + name = name.replace(/^TM_/, ""); + + if (!editor) + return; + var s = editor.session; + switch(name) { + case "CURRENT_WORD": + var r = s.getWordRange(); + case "SELECTION": + case "SELECTED_TEXT": + return s.getTextRange(r); + case "CURRENT_LINE": + return s.getLine(e.getCursorPosition().row); + case "LINE_INDEX": + return e.getCursorPosition().column; + case "LINE_NUMBER": + return e.getCursorPosition().row + 1; + case "SOFT_TABS": + return s.getUseSoftTabs() ? "YES" : "NO"; + case "TAB_SIZE": + return s.getTabSize(); + case "FILENAME": + case "FILEPATH": + return "ace.ajax.org"; + case "FULLNAME": + return "Ace"; + } + }; + this.variables = {}; + this.getVariableValue = function(editor, varName) { + if (this.variables.hasOwnProperty(varName)) + return this.variables[varName](editor, varName) || ""; + return this.$getDefaultValue(editor, varName) || ""; + }; + this.tmStrFormat = function(str, ch, editor) { + var flag = ch.flag || ""; + var re = ch.guard; + re = new RegExp(re, flag.replace(/[^gi]/, "")); + var fmtTokens = this.tokenizeTmSnippet(ch.fmt, "formatString"); + var _self = this; + var formatted = str.replace(re, function() { + _self.variables.__ = arguments; + var fmtParts = _self.resolveVariables(fmtTokens, editor); + var gChangeCase = "E"; + for (var i = 0; i < fmtParts.length; i++) { + var ch = fmtParts[i]; + if (typeof ch == "object") { + fmtParts[i] = ""; + if (ch.changeCase && ch.local) { + var next = fmtParts[i + 1]; + if (next && typeof next == "string") { + if (ch.changeCase == "u") + fmtParts[i] = next[0].toUpperCase(); + else + fmtParts[i] = next[0].toLowerCase(); + fmtParts[i + 1] = next.substr(1); + } + } else if (ch.changeCase) { + gChangeCase = ch.changeCase; + } + } else if (gChangeCase == "U") { + fmtParts[i] = ch.toUpperCase(); + } else if (gChangeCase == "L") { + fmtParts[i] = ch.toLowerCase(); + } + } + return fmtParts.join(""); + }); + this.variables.__ = null; + return formatted; + }; + + this.resolveVariables = function(snippet, editor) { + var result = []; + for (var i = 0; i < snippet.length; i++) { + var ch = snippet[i]; + if (typeof ch == "string") { + result.push(ch); + } else if (typeof ch != "object") { + continue; + } else if (ch.skip) { + gotoNext(ch); + } else if (ch.processed < i) { + continue; + } else if (ch.text) { + var value = this.getVariableValue(editor, ch.text); + if (value && ch.fmtString) + value = this.tmStrFormat(value, ch); + ch.processed = i; + if (ch.expectIf == null) { + if (value) { + result.push(value); + gotoNext(ch); + } + } else { + if (value) { + ch.skip = ch.elseBranch; + } else + gotoNext(ch); + } + } else if (ch.tabstopId != null) { + result.push(ch); + } else if (ch.changeCase != null) { + result.push(ch); + } + } + function gotoNext(ch) { + var i1 = snippet.indexOf(ch, i + 1); + if (i1 != -1) + i = i1; + } + return result; + }; + + this.insertSnippet = function(editor, snippetText) { + var cursor = editor.getCursorPosition(); + var line = editor.session.getLine(cursor.row); + var indentString = line.match(/^\s*/)[0]; + var tabString = editor.session.getTabString(); + + var tokens = this.tokenizeTmSnippet(snippetText); + tokens = this.resolveVariables(tokens, editor); + tokens = tokens.map(function(x) { + if (x == "\n") + return x + indentString; + if (typeof x == "string") + return x.replace(/\t/g, tabString); + return x; + }); + var tabstops = []; + tokens.forEach(function(p, i) { + if (typeof p != "object") + return; + var id = p.tabstopId; + if (!tabstops[id]) { + tabstops[id] = []; + tabstops[id].index = id; + tabstops[id].value = ""; + } + if (tabstops[id].indexOf(p) != -1) + return; + tabstops[id].push(p); + var i1 = tokens.indexOf(p, i + 1); + if (i1 == -1) + return; + var value = tokens.slice(i + 1, i1).join(""); + if (value) + tabstops[id].value = value; + }); + + tabstops.forEach(function(ts) { + ts.value && ts.forEach(function(p) { + var i = tokens.indexOf(p); + var i1 = tokens.indexOf(p, i + 1); + if (i1 == -1) + tokens.splice(i + 1, 0, ts.value, p); + else if (i1 == i + 1) + tokens.splice(i + 1, 0, ts.value); + }); + }); + var row = 0, column = 0; + var text = ""; + tokens.forEach(function(t) { + if (typeof t == "string") { + if (t[0] == "\n"){ + column = t.length - 1; + row ++; + } else + column += t.length; + text += t; + } else { + if (!t.start) + t.start = {row: row, column: column}; + else + t.end = {row: row, column: column}; + } + }); + var range = editor.getSelectionRange(); + var end = editor.session.replace(range, text); + + var tabstopManager = new TabstopManager(editor); + tabstopManager.addTabstops(tabstops, range.start, end); + tabstopManager.tabNext(); + }; + + this.$getScope = function(editor) { + var scope = editor.session.$mode.$id || ""; + scope = scope.split("/").pop(); + if (editor.session.$mode.$modes) { + var c = editor.getCursorPosition() + var state = editor.session.getState(c.row); + if (state.substring) { + if (state.substring(0, 3) == "js-") + scope = "javascript"; + else if (state.substring(0, 4) == "css-") + scope = "css"; + else if (state.substring(0, 4) == "php-") + scope = "php"; + } + } + return scope; + }; + + this.expandWithTab = function(editor) { + var cursor = editor.getCursorPosition(); + var line = editor.session.getLine(cursor.row); + var before = line.substring(0, cursor.column); + var after = line.substr(cursor.column); + + var scope = this.$getScope(editor); + var snippetMap = this.snippetMap; + var snippet; + [scope, "_"].some(function(scope) { + var snippets = snippetMap[scope]; + if (snippets) + snippet = this.findMatchingSnippet(snippets, before, after); + return !!snippet; + }, this); + if (!snippet) + return false; + + editor.session.doc.removeInLine(cursor.row, + cursor.column - snippet.replaceBefore.length, + cursor.column + snippet.replaceAfter.length + ); + + this.variables.M__ = snippet.matchBefore; + this.variables.T__ = snippet.matchAfter; + this.insertSnippet(editor, snippet.content); + + this.variables.M__ = this.variables.T__ = null; + return true; + }; + + this.findMatchingSnippet = function(snippetList, before, after) { + for (var i = snippetList.length; i--;) { + var s = snippetList[i]; + if (s.startRe && !s.startRe.test(before)) + continue; + if (s.endRe && !s.endRe.test(after)) + continue; + if (!s.startRe && !s.endRe) + continue; + + s.matchBefore = s.startRe ? s.startRe.exec(before) : [""]; + s.matchAfter = s.endRe ? s.endRe.exec(after) : [""]; + s.replaceBefore = s.triggerRe ? s.triggerRe.exec(before)[0] : ""; + s.replaceAfter = s.endTriggerRe ? s.endTriggerRe.exec(after)[0] : ""; + return s; + } + }; + + this.snippetMap = {}; + this.snippetNameMap = {}; + this.register = function(snippets, scope) { + var snippetMap = this.snippetMap; + var snippetNameMap = this.snippetNameMap; + var self = this; + function wrapRegexp(src) { + if (src && !/^\^?\(.*\)\$?$|^\\b$/.test(src)) + src = "(?:" + src + ")" + + return src || ""; + } + function guardedRegexp(re, guard, opening) { + re = wrapRegexp(re); + guard = wrapRegexp(guard); + if (opening) { + re = guard + re; + if (re && re[re.length - 1] != "$") + re = re + "$"; + } else { + re = re + guard; + if (re && re[0] != "^") + re = "^" + re; + } + return new RegExp(re); + } + + function addSnippet(s) { + if (!s.scope) + s.scope = scope || "_"; + scope = s.scope + if (!snippetMap[scope]) { + snippetMap[scope] = []; + snippetNameMap[scope] = {}; + } + + var map = snippetNameMap[scope]; + if (s.name) { + var old = map[s.name]; + if (old) + self.unregister(old); + map[s.name] = s; + } + snippetMap[scope].push(s); + + if (s.tabTrigger && !s.trigger) { + if (!s.guard && /^\w/.test(s.tabTrigger)) + s.guard = "\\b"; + s.trigger = lang.escapeRegExp(s.tabTrigger); + } + + s.startRe = guardedRegexp(s.trigger, s.guard, true); + s.triggerRe = new RegExp(s.trigger, "", true); + + s.endRe = guardedRegexp(s.endTrigger, s.endGuard, true); + s.endTriggerRe = new RegExp(s.endTrigger, "", true); + }; + + if (snippets.content) + addSnippet(snippets); + else if (Array.isArray(snippets)) + snippets.forEach(addSnippet); + }; + this.unregister = function(snippets, scope) { + var snippetMap = this.snippetMap; + var snippetNameMap = this.snippetNameMap; + + function removeSnippet(s) { + var nameMap = snippetNameMap[s.scope||scope]; + if (nameMap && nameMap[s.name]) { + delete nameMap[s.name]; + var map = snippetMap[s.scope||scope]; + var i = map && map.indexOf(s); + if (i >= 0) + map.splice(i, 1); + } + } + if (snippets.content) + removeSnippet(snippets); + else if (Array.isArray(snippets)) + snippets.forEach(removeSnippet); + }; + this.parseSnippetFile = function(str) { + str = str.replace(/\r/, ""); + var list = [], snippet = {}; + var re = /^#.*|^({[\s\S]*})\s*$|^(\S+) (.*)$|^((?:\n*\t.*)+)/gm; + var m; + while (m = re.exec(str)) { + if (m[1]) { + try { + snippet = JSON.parse(m[1]) + list.push(snippet); + } catch (e) {} + } if (m[4]) { + snippet.content = m[4].replace(/^\t/gm, ""); + list.push(snippet); + snippet = {}; + } else { + var key = m[2], val = m[3]; + if (key == "regex") { + var guardRe = /\/((?:[^\/\\]|\\.)*)|$/g; + snippet.guard = guardRe.exec(val)[1]; + snippet.trigger = guardRe.exec(val)[1]; + snippet.endTrigger = guardRe.exec(val)[1]; + snippet.endGuard = guardRe.exec(val)[1]; + } else if (key == "snippet") { + snippet.tabTrigger = val.match(/^\S*/)[0]; + if (!snippet.name) + snippet.name = val; + } else { + snippet[key] = val; + } + } + } + return list; + }; + this.getSnippetByName = function(name, editor) { + var scope = editor && this.$getScope(editor); + var snippetMap = this.snippetNameMap; + var snippet; + [scope, "_"].some(function(scope) { + var snippets = snippetMap[scope]; + if (snippets) + snippet = snippets[name]; + return !!snippet; + }, this); + return snippet; + }; + +}).call(SnippetManager.prototype); + + +var TabstopManager = function(editor) { + if (editor.tabstopManager) + return editor.tabstopManager; + editor.tabstopManager = this; + this.$onChange = this.onChange.bind(this); + this.$onChangeSelection = lang.delayedCall(this.onChangeSelection.bind(this)).schedule; + this.$onChangeSession = this.onChangeSession.bind(this); + this.$onAfterExec = this.onAfterExec.bind(this); + this.attach(editor); +}; +(function() { + this.attach = function(editor) { + this.index = -1; + this.ranges = []; + this.tabstops = []; + this.selectedTabstop = null; + + this.editor = editor; + this.editor.on("change", this.$onChange); + this.editor.on("changeSelection", this.$onChangeSelection); + this.editor.on("changeSession", this.$onChangeSession); + this.editor.commands.on("afterExec", this.$onAfterExec); + this.editor.keyBinding.addKeyboardHandler(this.keyboardHandler); + }; + this.detach = function() { + this.tabstops.forEach(this.removeTabstopMarkers, this); + this.ranges = null; + this.tabstops = null; + this.selectedTabstop = null; + this.editor.removeListener("change", this.$onChange); + this.editor.removeListener("changeSelection", this.$onChangeSelection); + this.editor.removeListener("changeSession", this.$onChangeSession); + this.editor.commands.removeListener("afterExec", this.$onAfterExec); + this.editor.keyBinding.removeKeyboardHandler(this.keyboardHandler); + this.editor.tabstopManager = null; + this.editor = null; + }; + + this.onChange = function(e) { + var changeRange = e.data.range; + var isRemove = e.data.action[0] == "r"; + var start = changeRange.start; + var end = changeRange.end; + var startRow = start.row; + var endRow = end.row; + var lineDif = endRow - startRow; + var colDiff = end.column - start.column; + + if (isRemove) { + lineDif = -lineDif; + colDiff = -colDiff; + } + if (!this.$inChange && isRemove) { + var ts = this.selectedTabstop; + var changedOutside = !ts.some(function(r) { + return comparePoints(r.start, start) <= 0 && comparePoints(r.end, end) >= 0; + }); + if (changedOutside) + return this.detach(); + } + var ranges = this.ranges; + for (var i = 0; i < ranges.length; i++) { + var r = ranges[i]; + if (r.end.row < start.row) + continue; + + if (comparePoints(start, r.start) < 0 && comparePoints(end, r.end) > 0) { + this.removeRange(r); + i--; + continue; + } + + if (r.start.row == startRow && r.start.column > start.column) + r.start.column += colDiff; + if (r.end.row == startRow && r.end.column >= start.column) + r.end.column += colDiff; + if (r.start.row >= startRow) + r.start.row += lineDif; + if (r.end.row >= startRow) + r.end.row += lineDif; + + if (comparePoints(r.start, r.end) > 0) + this.removeRange(r); + } + if (!ranges.length) + this.detach(); + }; + this.updateLinkedFields = function() { + var ts = this.selectedTabstop; + if (!ts.hasLinkedRanges) + return; + this.$inChange = true; + var session = this.editor.session; + var text = session.getTextRange(ts.firstNonLinked); + for (var i = ts.length; i--;) { + var range = ts[i]; + if (!range.linked) + continue; + var fmt = exports.snippetManager.tmStrFormat(text, range.original) + session.replace(range, fmt); + } + this.$inChange = false; + }; + this.onAfterExec = function(e) { + if (e.command && !e.command.readOnly) + this.updateLinkedFields(); + }; + this.onChangeSelection = function() { + if (!this.editor) + return + var lead = this.editor.selection.lead; + var anchor = this.editor.selection.anchor; + var isEmpty = this.editor.selection.isEmpty(); + for (var i = this.ranges.length; i--;) { + if (this.ranges[i].linked) + continue; + var containsLead = this.ranges[i].contains(lead.row, lead.column); + var containsAnchor = isEmpty || this.ranges[i].contains(anchor.row, anchor.column); + if (containsLead && containsAnchor) + return; + } + this.detach(); + }; + this.onChangeSession = function() { + this.detach(); + }; + this.tabNext = function(dir) { + var max = this.tabstops.length - 1; + var index = this.index + (dir || 1); + index = Math.min(Math.max(index, 0), max); + this.selectTabstop(index); + if (index == max) + this.detach(); + }; + this.selectTabstop = function(index) { + var ts = this.tabstops[this.index]; + if (ts) + this.addTabstopMarkers(ts); + this.index = index; + ts = this.tabstops[this.index]; + if (!ts || !ts.length) + return; + + this.selectedTabstop = ts; + if (!this.editor.inVirtualSelectionMode) { + var sel = this.editor.multiSelect; + sel.toSingleRange(ts.firstNonLinked.clone()); + for (var i = ts.length; i--;) { + if (ts.hasLinkedRanges && ts[i].linked) + continue; + sel.addRange(ts[i].clone(), true); + } + } else { + this.editor.selection.setRange(ts.firstNonLinked); + } + + this.editor.keyBinding.addKeyboardHandler(this.keyboardHandler); + }; + this.addTabstops = function(tabstops, start, end) { + if (!tabstops[0]) { + var p = Range.fromPoints(end, end); + moveRelative(p.start, start); + moveRelative(p.end, start); + tabstops[0] = [p]; + tabstops[0].index = 0; + } + + var i = this.index; + var arg = [i, 0]; + var ranges = this.ranges; + var editor = this.editor; + tabstops.forEach(function(ts) { + for (var i = ts.length; i--;) { + var p = ts[i]; + var range = Range.fromPoints(p.start, p.end || p.start); + movePoint(range.start, start); + movePoint(range.end, start); + range.original = p; + range.tabstop = ts; + ranges.push(range); + ts[i] = range; + if (p.fmtString) { + range.linked = true; + ts.hasLinkedRanges = true; + } else if (!ts.firstNonLinked) + ts.firstNonLinked = range; + } + if (!ts.firstNonLinked) + ts.hasLinkedRanges = false; + arg.push(ts); + this.addTabstopMarkers(ts); + }, this); + arg.push(arg.splice(2, 1)[0]); + this.tabstops.splice.apply(this.tabstops, arg); + }; + + this.addTabstopMarkers = function(ts) { + var session = this.editor.session; + ts.forEach(function(range) { + if (!range.markerId) + range.markerId = session.addMarker(range, "ace_snippet-marker", "text"); + }); + }; + this.removeTabstopMarkers = function(ts) { + var session = this.editor.session; + ts.forEach(function(range) { + session.removeMarker(range.markerId); + range.markerId = null; + }); + }; + this.removeRange = function(range) { + var i = range.tabstop.indexOf(range); + range.tabstop.splice(i, 1); + i = this.ranges.indexOf(range); + this.ranges.splice(i, 1); + this.editor.session.removeMarker(range.markerId); + }; + + this.keyboardHandler = new HashHandler(); + this.keyboardHandler.bindKeys({ + "Tab": function(ed) { + ed.tabstopManager.tabNext(1); + }, + "Shift-Tab": function(ed) { + ed.tabstopManager.tabNext(-1); + }, + "Esc": function(ed) { + ed.tabstopManager.detach(); + }, + "Return": function(ed) { + return false; + } + }); +}).call(TabstopManager.prototype); + + +var movePoint = function(point, diff) { + if (point.row == 0) + point.column += diff.column; + point.row += diff.row; +}; + +var moveRelative = function(point, start) { + if (point.row == start.row) + point.column -= start.column; + point.row -= start.row; +}; + + +require("./lib/dom").importCssString("\ +.ace_snippet-marker {\ + -moz-box-sizing: border-box;\ + box-sizing: border-box;\ + background: rgba(194, 193, 208, 0.09);\ + border: 1px dotted rgba(211, 208, 235, 0.62);\ + position: absolute;\ +}"); + +exports.snippetManager = new SnippetManager(); + + +}); + +ace.define('ace/autocomplete', ['require', 'exports', 'module' , 'ace/keyboard/hash_handler', 'ace/autocomplete/popup', 'ace/autocomplete/util', 'ace/lib/event', 'ace/lib/lang', 'ace/snippets'], function(require, exports, module) { + + +var HashHandler = require("./keyboard/hash_handler").HashHandler; +var AcePopup = require("./autocomplete/popup").AcePopup; +var util = require("./autocomplete/util"); +var event = require("./lib/event"); +var lang = require("./lib/lang"); +var snippetManager = require("./snippets").snippetManager; + +var Autocomplete = function() { + this.keyboardHandler = new HashHandler(); + this.keyboardHandler.bindKeys(this.commands); + + this.blurListener = this.blurListener.bind(this); + this.changeListener = this.changeListener.bind(this); + this.mousedownListener = this.mousedownListener.bind(this); + this.mousewheelListener = this.mousewheelListener.bind(this); + + this.changeTimer = lang.delayedCall(function() { + this.updateCompletions(true); + }.bind(this)) +}; + +(function() { + this.$init = function() { + this.popup = new AcePopup(document.body || document.documentElement); + this.popup.on("click", function(e) { + this.insertMatch(); + e.stop(); + }.bind(this)); + }; + + this.openPopup = function(editor, keepPopupPosition) { + if (!this.popup) + this.$init(); + + this.popup.setData(this.completions.filtered); + + var renderer = editor.renderer; + if (!keepPopupPosition) { + var lineHeight = renderer.layerConfig.lineHeight; + var pos = renderer.$cursorLayer.getPixelPosition(null, true); + var rect = editor.container.getBoundingClientRect(); + pos.top += rect.top - renderer.layerConfig.offset; + pos.left += rect.left; + pos.left += renderer.$gutterLayer.gutterWidth; + + this.popup.show(pos, lineHeight); + } + renderer.updateText(); + }; + + this.detach = function() { + this.editor.keyBinding.removeKeyboardHandler(this.keyboardHandler); + this.editor.removeEventListener("changeSelection", this.changeListener); + this.editor.removeEventListener("blur", this.changeListener); + this.editor.removeEventListener("mousedown", this.changeListener); + this.changeTimer.cancel(); + + if (this.popup) + this.popup.hide(); + + this.activated = false; + }; + + this.changeListener = function(e) { + if (this.activated) + this.changeTimer.schedule(); + else + this.detach(); + }; + + this.blurListener = function() { + if (document.activeElement != this.editor.textInput.getElement()) + this.detach(); + }; + + this.mousedownListener = function(e) { + this.detach(); + }; + + this.mousewheelListener = function(e) { + this.detach(); + }; + + this.goTo = function(where) { + var row = this.popup.getRow(); + var max = this.popup.session.getLength() - 1; + + switch(where) { + case "up": row = row <= 0 ? max : row - 1; break; + case "down": row = row >= max ? 0 : row + 1; break; + case "start": row = 0; break; + case "end": row = max; break; + } + + this.popup.setRow(row); + }; + + this.insertMatch = function(data) { + this.detach(); + if (!data) + data = this.popup.getData(this.popup.getRow()); + if (!data) + return false; + if (data.completer && data.completer.insertMatch) { + data.completer.insertMatch(this.editor); + } else { + if (this.completions.filterText) { + var range = this.editor.selection.getRange(); + range.start.column -= this.completions.filterText.length; + this.editor.session.remove(range); + } + if (data.snippet) + snippetManager.insertSnippet(this.editor, data.snippet); + else + this.editor.insert(data.value || data); + } + }; + + this.commands = { + "Up": function(editor) { editor.completer.goTo("up"); }, + "Down": function(editor) { editor.completer.goTo("down"); }, + "Ctrl-Up|Ctrl-Home": function(editor) { editor.completer.goTo("start"); }, + "Ctrl-Down|Ctrl-End": function(editor) { editor.completer.goTo("end"); }, + + "Esc": function(editor) { editor.completer.detach(); }, + "Space": function(editor) { editor.completer.detach(); editor.insert(" ");}, + "Return": function(editor) { editor.completer.insertMatch(); }, + "Shift-Return": function(editor) { editor.completer.insertMatch(true); }, + "Tab": function(editor) { editor.completer.insertMatch(); }, + + "PageUp": function(editor) { editor.completer.popup.gotoPageDown(); }, + "PageDown": function(editor) { editor.completer.popup.gotoPageUp(); } + }; + + this.gatherCompletions = function(editor, callback) { + var session = editor.getSession(); + var pos = editor.getCursorPosition(); + + var line = session.getLine(pos.row); + var prefix = util.retrievePrecedingIdentifier(line, pos.column); + + var matches = []; + util.parForEach(editor.completers, function(completer, next) { + completer.getCompletions(editor, session, pos, prefix, function(err, results) { + if (!err) + matches = matches.concat(results); + next(); + }); + }, function() { + matches.sort(function(a, b) { + return b.score - a.score; + }); + callback(null, { + prefix: prefix, + matches: matches + }); + }); + return true; + }; + + this.showPopup = function(editor) { + if (this.editor) + this.detach(); + + this.activated = true; + + this.editor = editor; + if (editor.completer != this) { + if (editor.completer) + editor.completer.detach(); + editor.completer = this; + } + + editor.keyBinding.addKeyboardHandler(this.keyboardHandler); + editor.on("changeSelection", this.changeListener); + editor.on("blur", this.blurListener); + editor.on("mousedown", this.mousedownListener); + this.updateCompletions(); + } + + this.updateCompletions = function(keepPopupPosition) { + this.gatherCompletions(this.editor, function(err, results) { + var matches = results && results.matches; + if (!matches || !matches.length) + return this.detach(); + + this.completions = new FilteredList(matches); + this.completions.setFilter(results.prefix); + this.openPopup(this.editor, keepPopupPosition); + this.popup.setHighlight(results.prefix); + }.bind(this)); + }; + + this.cancelContextMenu = function() { + var stop = function(e) { + this.editor.off("nativecontextmenu", stop); + if (e && e.domEvent) + event.stopEvent(e.domEvent); + }.bind(this); + setTimeout(stop, 10); + this.editor.on("nativecontextmenu", stop); + }; + +}).call(Autocomplete.prototype); + +Autocomplete.startCommand = { + name: "startAutocomplete", + exec: function(editor) { + if (!editor.completer) + editor.completer = new Autocomplete(); + editor.completer.showPopup(editor); + editor.completer.cancelContextMenu(); + }, + bindKey: "Ctrl-Space|Ctrl-Shift-Space|Alt-Space" +}; + +var FilteredList = function(array, mutateData) { + this.all = array; + this.filtered = array.concat(); + this.filterText = ""; +}; +(function(){ + this.setFilter = function(str) { + this.filterText = str; + }; + +}).call(FilteredList.prototype); + +exports.Autocomplete = Autocomplete; +exports.FilteredList = FilteredList; + +}); + +ace.define('ace/autocomplete/popup', ['require', 'exports', 'module' , 'ace/edit_session', 'ace/virtual_renderer', 'ace/editor', 'ace/range', 'ace/lib/event', 'ace/lib/lang', 'ace/lib/dom'], function(require, exports, module) { + + +var EditSession = require("../edit_session").EditSession; +var Renderer = require("../virtual_renderer").VirtualRenderer; +var Editor = require("../editor").Editor; +var Range = require("../range").Range; +var event = require("../lib/event"); +var lang = require("../lib/lang"); +var dom = require("../lib/dom"); + +var $singleLineEditor = function(el) { + var renderer = new Renderer(el); + + renderer.$maxLines = 4; + + var editor = new Editor(renderer); + + editor.setHighlightActiveLine(false); + editor.setShowPrintMargin(false); + editor.renderer.setShowGutter(false); + editor.renderer.setHighlightGutterLine(false); + + editor.$mouseHandler.$focusWaitTimout = 0; + + return editor; +}; + +var AcePopup = function(parentNode) { + var el = dom.createElement("div"); + var popup = new $singleLineEditor(el); + + if (parentNode) + parentNode.appendChild(el); + el.style.display = "none"; + popup.renderer.content.style.cursor = "default"; + popup.renderer.setStyle("ace_autocomplete"); + + var noop = function(){}; + + popup.focus = noop; + popup.$isFocused = true; + + popup.renderer.$cursorLayer.restartTimer = noop; + popup.renderer.$cursorLayer.element.style.opacity = 0; + + popup.renderer.$maxLines = 8; + popup.renderer.$keepTextAreaAtCursor = false; + + popup.setHighlightActiveLine(true); + popup.session.highlight(""); + popup.session.$searchHighlight.clazz = "ace_highlight-marker"; + + popup.on("mousedown", function(e) { + var pos = e.getDocumentPosition(); + popup.moveCursorToPosition(pos); + popup.selection.clearSelection(); + e.stop(); + }); + + var hoverMarker = new Range(-1,0,-1,Infinity); + hoverMarker.id = popup.session.addMarker(hoverMarker, "ace_line-hover", "fullLine"); + popup.on("mousemove", function(e) { + var row = e.getDocumentPosition().row; + hoverMarker.start.row = hoverMarker.end.row = row; + popup.session._emit("changeBackMarker"); + }); + var hideHoverMarker = function() { + hoverMarker.start.row = hoverMarker.end.row = -1; + popup.session._emit("changeBackMarker"); + }; + event.addListener(popup.container, "mouseout", hideHoverMarker); + popup.on("hide", hideHoverMarker); + popup.on("changeSelection", hideHoverMarker); + popup.on("mousewheel", function(e) { + setTimeout(function() { + popup._signal("mousemove", e); + }); + }); + + popup.session.doc.getLength = function() { + return popup.data.length; + }; + popup.session.doc.getLine = function(i) { + var data = popup.data[i]; + if (typeof data == "string") + return data; + return (data && data.value) || ""; + }; + + var bgTokenizer = popup.session.bgTokenizer; + bgTokenizer.$tokenizeRow = function(i) { + var data = popup.data[i]; + var tokens = []; + if (!data) + return tokens; + if (typeof data == "string") + data = {value: data}; + if (!data.caption) + data.caption = data.value; + + tokens.push({type: data.className || "", value: data.caption}); + if (data.meta) { + var maxW = popup.renderer.$size.scrollerWidth / popup.renderer.layerConfig.characterWidth; + if (data.meta.length + data.caption.length < maxW - 2) + tokens.push({type: "rightAlignedText", value: data.meta}); + } + return tokens; + }; + bgTokenizer.$updateOnChange = noop; + + popup.session.$computeWidth = function() { + return this.screenWidth = 0; + } + popup.data = []; + popup.setData = function(list) { + popup.data = list || []; + popup.setValue(lang.stringRepeat("\n", list.length), -1); + }; + popup.getData = function(row) { + return popup.data[row]; + }; + + popup.getRow = function() { + var line = this.getCursorPosition().row; + if (line == 0 && !this.getHighlightActiveLine()) + line = -1; + return line; + }; + popup.setRow = function(line) { + popup.setHighlightActiveLine(line != -1); + popup.selection.clearSelection(); + popup.moveCursorTo(line, 0 || 0); + }; + + popup.setHighlight = function(re) { + popup.session.highlight(re); + popup.session._emit("changeFrontMarker"); + }; + + popup.hide = function() { + this.container.style.display = "none"; + this._signal("hide"); + }; + popup.show = function(pos, lineHeight) { + var el = this.container; + if (pos.top > window.innerHeight / 2 + lineHeight) { + el.style.top = ""; + el.style.bottom = window.innerHeight - pos.top + "px"; + } else { + pos.top += lineHeight; + el.style.top = pos.top + "px"; + el.style.bottom = ""; + } + + el.style.left = pos.left + "px"; + el.style.display = ""; + this.renderer.$textLayer.checkForSizeChanges(); + + this._signal("show"); + }; + + return popup; +}; + +dom.importCssString("\ +.ace_autocomplete.ace-tm .ace_marker-layer .ace_active-line {\ + background-color: #abbffe;\ +}\ +.ace_autocomplete.ace-tm .ace_line-hover {\ + border: 1px solid #abbffe;\ + position: absolute;\ + background: rgba(233,233,253,0.4);\ + z-index: 2;\ + margin-top: -1px;\ +}\ +.ace_rightAlignedText {\ + color: gray;\ + display: inline-block;\ + position: absolute;\ + right: 4px;\ + text-align: right;\ + z-index: -1;\ +}\ +.ace_autocomplete {\ + width: 200px;\ + z-index: 200000;\ + background: #f8f8f8;\ + border: 1px lightgray solid;\ + position: fixed;\ + box-shadow: 2px 3px 5px rgba(0,0,0,.2);\ +}"); + +exports.AcePopup = AcePopup; + +}); + +ace.define('ace/autocomplete/util', ['require', 'exports', 'module' ], function(require, exports, module) { + + +exports.parForEach = function(array, fn, callback) { + var completed = 0; + var arLength = array.length; + if (arLength === 0) + callback(); + for (var i = 0; i < arLength; i++) { + fn(array[i], function(result, err) { + completed++; + if (completed === arLength) + callback(result, err); + }); + } +} + +var ID_REGEX = /[a-zA-Z_0-9\$-]/; + +exports.retrievePrecedingIdentifier = function(text, pos, regex) { + regex = regex || ID_REGEX; + var buf = []; + for (var i = pos-1; i >= 0; i--) { + if (regex.test(text[i])) + buf.push(text[i]); + else + break; + } + return buf.reverse().join(""); +} + +exports.retrieveFollowingIdentifier = function(text, pos, regex) { + regex = regex || ID_REGEX; + var buf = []; + for (var i = pos; i < text.length; i++) { + if (regex.test(text[i])) + buf.push(text[i]); + else + break; + } + return buf; +} + +}); + +ace.define('ace/autocomplete/text_completer', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) { + var Range = require("ace/range").Range; + + var splitRegex = /[^a-zA-Z_0-9\$\-]+/; + + function getWordIndex(doc, pos) { + var textBefore = doc.getTextRange(Range.fromPoints({row: 0, column:0}, pos)); + return textBefore.split(splitRegex).length - 1; + } + function filterPrefix(prefix, words) { + var results = []; + for (var i = 0; i < words.length; i++) { + if (words[i].lastIndexOf(prefix, 0) === 0) { + results.push(words[i]); + } + } + return results; + } + function wordDistance(doc, pos) { + var prefixPos = getWordIndex(doc, pos); + var words = doc.getValue().split(splitRegex); + var wordScores = Object.create(null); + + var currentWord = words[prefixPos]; + + words.forEach(function(word, idx) { + if (!word || word === currentWord) return; + + var distance = Math.abs(prefixPos - idx); + var score = words.length - distance; + if (wordScores[word]) { + wordScores[word] = Math.max(score, wordScores[word]); + } else { + wordScores[word] = score; + } + }); + return wordScores; + } + + exports.getCompletions = function(editor, session, pos, prefix, callback) { + var wordScore = wordDistance(session, pos, prefix); + var wordList = filterPrefix(prefix, Object.keys(wordScore)); + callback(null, wordList.map(function(word) { + return { + name: word, + value: word, + score: wordScore[word], + meta: "local" + }; + })); + }; +}); \ No newline at end of file diff --git a/lib/client/edit/snippets/javascript.js b/lib/client/edit/snippets/javascript.js new file mode 100644 index 00000000..c8845fbe --- /dev/null +++ b/lib/client/edit/snippets/javascript.js @@ -0,0 +1,202 @@ +ace.define('ace/snippets/javascript', ['require', 'exports', 'module' ], function(require, exports, module) { + + +exports.snippetText = "# Prototype\n\ +snippet proto\n\ + ${1:class_name}.prototype.${2:method_name} = function(${3:first_argument}) {\n\ + ${4:// body...}\n\ + };\n\ +# Function\n\ +snippet fun\n\ + function ${1?:function_name}(${2:argument}) {\n\ + ${3:// body...}\n\ + }\n\ +# Anonymous Function\n\ +regex /((=)\\s*|(:)\\s*|(\\()|\\b)/f/(\\))?/\n\ +name f\n\ + function${M1?: ${1:functionName}}($2) {\n\ + ${0:$TM_SELECTED_TEXT}\n\ + }${M2?;}${M3?,}${M4?)}\n\ +# Immediate function\n\ +trigger \\(?f\\(\n\ +endTrigger \\)?\n\ +snippet f(\n\ + (function(${1}) {\n\ + ${0:${TM_SELECTED_TEXT:/* code */}}\n\ + }(${1}));\n\ +# if\n\ +snippet if\n\ + if (${1:true}) {\n\ + ${0}\n\ + }\n\ +# if ... else\n\ +snippet ife\n\ + if (${1:true}) {\n\ + ${2}\n\ + } else {\n\ + ${0}\n\ + }\n\ +# tertiary conditional\n\ +snippet ter\n\ + ${1:/* condition */} ? ${2:a} : ${3:b}\n\ +# switch\n\ +snippet switch\n\ + switch (${1:expression}) {\n\ + case '${3:case}':\n\ + ${4:// code}\n\ + break;\n\ + ${5}\n\ + default:\n\ + ${2:// code}\n\ + }\n\ +# case\n\ +snippet case\n\ + case '${1:case}':\n\ + ${2:// code}\n\ + break;\n\ + ${3}\n\ +\n\ +# while (...) {...}\n\ +snippet wh\n\ + while (${1:/* condition */}) {\n\ + ${0:/* code */}\n\ + }\n\ +# try\n\ +snippet try\n\ + try {\n\ + ${0:/* code */}\n\ + } catch (e) {}\n\ +# do...while\n\ +snippet do\n\ + do {\n\ + ${2:/* code */}\n\ + } while (${1:/* condition */});\n\ +# Object Method\n\ +snippet :f\n\ +regex /([,{[])|^\\s*/:f/\n\ + ${1:method_name}: function(${2:attribute}) {\n\ + ${0}\n\ + }${3:,}\n\ +# setTimeout function\n\ +snippet setTimeout\n\ +regex /\\b/st|timeout|setTimeo?u?t?/\n\ + setTimeout(function() {${3:$TM_SELECTED_TEXT}}, ${1:10});\n\ +# Get Elements\n\ +snippet gett\n\ + getElementsBy${1:TagName}('${2}')${3}\n\ +# Get Element\n\ +snippet get\n\ + getElementBy${1:Id}('${2}')${3}\n\ +# console.log (Firebug)\n\ +snippet cl\n\ + console.log(${1});\n\ +# return\n\ +snippet ret\n\ + return ${1:result}\n\ +# for (property in object ) { ... }\n\ +snippet fori\n\ + for (var ${1:prop} in ${2:Things}) {\n\ + ${0:$2[$1]}\n\ + }\n\ +# hasOwnProperty\n\ +snippet has\n\ + hasOwnProperty(${1})\n\ +# docstring\n\ +snippet /**\n\ + /**\n\ + * ${1:description}\n\ + *\n\ + */\n\ +snippet @par\n\ +regex /^\\s*\\*\\s*/@(para?m?)?/\n\ + @param {${1:type}} ${2:name} ${3:description}\n\ +snippet @ret\n\ + @return {${1:type}} ${2:description}\n\ +# JSON.parse\n\ +snippet jsonp\n\ + JSON.parse(${1:jstr});\n\ +# JSON.stringify\n\ +snippet jsons\n\ + JSON.stringify(${1:object});\n\ +# self-defining function\n\ +snippet sdf\n\ + var ${1:function_name} = function(${2:argument}) {\n\ + ${3:// initial code ...}\n\ +\n\ + $1 = function($2) {\n\ + ${4:// main code}\n\ + };\n\ + }\n\ +# singleton\n\ +snippet sing\n\ + function ${1:Singleton} (${2:argument}) {\n\ + // the cached instance\n\ + var instance;\n\ +\n\ + // rewrite the constructor\n\ + $1 = function $1($2) {\n\ + return instance;\n\ + };\n\ + \n\ + // carry over the prototype properties\n\ + $1.prototype = this;\n\ +\n\ + // the instance\n\ + instance = new $1();\n\ +\n\ + // reset the constructor pointer\n\ + instance.constructor = $1;\n\ +\n\ + ${3:// code ...}\n\ +\n\ + return instance;\n\ + }\n\ +# class\n\ +name class\n\ +regex /^\\s*/clas{0,2}/\n\ + var ${1:class} = function(${20}) {\n\ + $40$0\n\ + };\n\ + \n\ + (function() {\n\ + ${60:this.prop = \"\"}\n\ + }).call(${1:class}.prototype);\n\ + \n\ + exports.${1:class} = ${1:class};\n\ +# \n\ +snippet for-\n\ + for (var ${1:i} = ${2:Things}.length; ${1:i}--; ) {\n\ + ${0:${2:Things}[${1:i}];}\n\ + }\n\ +# for (...) {...}\n\ +snippet for\n\ + for (var ${1:i} = 0; $1 < ${2:Things}.length; $1++) {\n\ + ${3:$2[$1]}$0\n\ + }\n\ +# for (...) {...} (Improved Native For-Loop)\n\ +snippet forr\n\ + for (var ${1:i} = ${2:Things}.length - 1; $1 >= 0; $1--) {\n\ + ${3:$2[$1]}$0\n\ + }\n\ +\n\ +\n\ +#modules\n\ +snippet def\n\ + ace.define(function(require, exports, module) {\n\ + \"use strict\";\n\ + var ${1/.*\\///} = require(\"${1}\");\n\ + \n\ + $TM_SELECTED_TEXT\n\ + });\n\ +snippet req\n\ +guard ^\\s*\n\ + var ${1/.*\\///} = require(\"${1}\");\n\ + $0\n\ +snippet requ\n\ +guard ^\\s*\n\ + var ${1/.*\\/(.)/\\u$1/} = require(\"${1}\").${1/.*\\/(.)/\\u$1/};\n\ + $0\n\ +"; +exports.scope = "javascript"; + +}); From a73bc6b16ac9a59ee9a875c51eec2bb47a6b11fd Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 20 Nov 2013 15:46:17 +0000 Subject: [PATCH 129/315] feature(edit) add go to line --- HELP.md | 1 + lib/client/edit.js | 23 +++++++++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/HELP.md b/HELP.md index 7e45f512..6b02121b 100644 --- a/HELP.md +++ b/HELP.md @@ -97,6 +97,7 @@ Edit ###Hot keys - **F4** - open - **Ctrl + s** - save +- **Ctrl + g** - go to line - **Esc** - close For more details see [Ace keyboard shortcuts](https://github.com/ajaxorg/ace/wiki/Default-Keyboard-Shortcuts "Ace keyboard shortcuts"). diff --git a/lib/client/edit.js b/lib/client/edit.js index fdb2d3ec..506d1f31 100644 --- a/lib/client/edit.js +++ b/lib/client/edit.js @@ -15,9 +15,7 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch; Ace, Msg, Key = CloudCmd.Key, - Dialog = DOM.Dialog, Images = DOM.Images, - Element; function init() { @@ -92,6 +90,19 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch; CloudCmd.View.hide(); }; + this.goToLine = function() { + var dialog = DOM.Dialog, + msg = 'Line number:', + cursor = Ace.selection.getCursor(), + number = cursor.row + 1, + line = dialog.prompt(msg, number); + + number = line - 0; + + if (number) + Ace.gotoLine(number); + }; + function focus() { Ace.focus(); Ace.clearSelection(); @@ -120,6 +131,14 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch; } }); + Ace.commands.addCommand({ + name : 'goToLine', + bindKey : { win: 'Ctrl-G', mac: 'Command-G' }, + exec : function () { + Edit.goToLine(); + } + }); + Ace.commands.addCommand({ name : 'save', bindKey : { win: 'Ctrl-S', mac: 'Command-S' }, From 9cecbdf47a2d7e9e50ed18f16835135f65324615 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 20 Nov 2013 15:59:52 +0000 Subject: [PATCH 130/315] docs(help) add find, replace --- HELP.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/HELP.md b/HELP.md index 6b02121b..824393e8 100644 --- a/HELP.md +++ b/HELP.md @@ -97,6 +97,8 @@ Edit ###Hot keys - **F4** - open - **Ctrl + s** - save +- **Ctrl + f** - find +- **Ctrl + f + f** - replace - **Ctrl + g** - go to line - **Esc** - close From 4a3ccac73c94698f61a79684710a94cad4d5c29c Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 20 Nov 2013 16:03:10 +0000 Subject: [PATCH 131/315] chore(edit) "Line number" -> "Enter line number" --- lib/client/edit.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/client/edit.js b/lib/client/edit.js index 506d1f31..c6f02f15 100644 --- a/lib/client/edit.js +++ b/lib/client/edit.js @@ -92,7 +92,7 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch; this.goToLine = function() { var dialog = DOM.Dialog, - msg = 'Line number:', + msg = 'Enter line number:', cursor = Ace.selection.getCursor(), number = cursor.row + 1, line = dialog.prompt(msg, number); From 92ff4b614ee23e7d9206dc54d1fe8e7e66add4e7 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 21 Nov 2013 08:31:57 +0000 Subject: [PATCH 132/315] feature(dom) getCurrentData: if data from storage do not save it --- lib/client/dom.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/client/dom.js b/lib/client/dom.js index 2e017669..f8ebe525 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -1472,6 +1472,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; */ this.getCurrentData = function(pCallBack, pCurrentFile) { var lParams, + isFromStorage, lCurrentFile = pCurrentFile ? pCurrentFile : this.getCurrentFile(), lPath = DOM.getCurrentPath(lCurrentFile), @@ -1486,7 +1487,8 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; lName += lExt; } - DOM.saveDataToStorage(lPath, pData); + if (!isFromStorage) + DOM.saveDataToStorage(lPath, pData); Util.exec(pCallBack, { data: pData, @@ -1503,9 +1505,10 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; }; DOM.getDataFromStorage(lPath, function(data) { - if (data) + if (data) { + isFromStorage = true; lFunc(data); - else + } else DOM.getCurrentFileContent(lParams, lCurrentFile); }); }; From c94515d0a23861fe91266b9b2dc50f5be53706a3 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 21 Nov 2013 10:37:09 +0000 Subject: [PATCH 133/315] feature(dom) add checkStorageHash --- lib/client/dom.js | 86 +++++++++----- lib/client/edit.js | 37 ++++-- lib/sha1/README.md | 60 ++++++++++ lib/sha1/package.json | 22 ++++ lib/sha1/rusha.js | 270 ++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 435 insertions(+), 40 deletions(-) create mode 100644 lib/sha1/README.md create mode 100644 lib/sha1/package.json create mode 100644 lib/sha1/rusha.js diff --git a/lib/client/dom.js b/lib/client/dom.js index f8ebe525..8c878f5e 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -1472,7 +1472,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; */ this.getCurrentData = function(pCallBack, pCurrentFile) { var lParams, - isFromStorage, + lHash, lCurrentFile = pCurrentFile ? pCurrentFile : this.getCurrentFile(), lPath = DOM.getCurrentPath(lCurrentFile), @@ -1487,8 +1487,8 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; lName += lExt; } - if (!isFromStorage) - DOM.saveDataToStorage(lPath, pData); + if (lHash) + DOM.saveDataToStorage(lPath, pData, lHash); Util.exec(pCallBack, { data: pData, @@ -1504,12 +1504,13 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; error : pCallBack.error }; - DOM.getDataFromStorage(lPath, function(data) { - if (data) { - isFromStorage = true; + DOM.getDataFromStorage(lPath, function(data, hash) { + if (data) lFunc(data); - } else + else { + lHash = hash; DOM.getCurrentFileContent(lParams, lCurrentFile); + } }); }; @@ -1754,6 +1755,25 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; return lLink; }; + /** + * check storage hash + */ + this.checkStorageHash = function(name, callback) { + DOM.loadCurrentHash(function(loadHash) { + var equal, error, + nameHash = name + '-hash', + storeHash = Storage.get(name + '-hash'), + isContain = Util.isContainStr(loadHash, 'error'); + + if (isContain) + error = loadHash; + else if (!storeHash || loadHash === storeHash) + equal = true; + + Util.exec(callback, error, equal, loadHash); + }); + }; + /** * save data to storage * @@ -1761,29 +1781,29 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; * @param data * @param callback */ - this.saveDataToStorage = function(name, data, callback) { + this.saveDataToStorage = function(name, data, hash, callback) { CloudCmd.getConfig(function(config) { - var hash, + var allowed = config.localStorage, + isDir = DOM.isCurrentIsDir(), nameHash = name + '-hash', nameData = name + '-data', - allowed = config.localStorage, - isDir = DOM.isCurrentIsDir(); + save = function(hash) { + Storage.set(nameHash, hash); + Storage.set(nameData, data); + }; if (!allowed || isDir) Util.exec(callback); else { - hash = Storage.get(name + '-hash'); - - DOM.loadCurrentHash(function(pHash) { - var isContain = Util.isContainStr(hash, 'error'); - - if (!isContain && hash !== pHash) { - Storage.set(nameHash, pHash); - Storage.set(nameData, data); - } - - Util.exec(callback, hash); - }); + if (hash) + save(hash); + else + DOM.checkStorageHash(name, function(error, equal, hash) { + if (!error && !equal) + save(hash); + + Util.exec(callback, hash); + }); } }); }; @@ -1797,25 +1817,27 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; */ this.getDataFromStorage = function(name, callback) { CloudCmd.getConfig(function(config) { - var hash, allowed = config.localStorage, - isDir = DOM.isCurrentIsDir(); + var hash, + nameHash = name + '-hash', + nameData = name + '-data', + allowed = config.localStorage, + isDir = DOM.isCurrentIsDir(); if (!allowed || isDir) Util.exec(callback); else { - hash = Storage.get(name + '-hash'); + hash = Storage.get(nameHash); if (!hash) Util.exec(callback); else - DOM.loadCurrentHash(function(pHash) { - var data, - isContain = Util.isContainStr(hash, 'error'); + DOM.checkStorageHash(name, function(error, equal, hash) { + var data; - if (!isContain && hash === pHash) - data = Storage.get(name + '-data'); + if (!error && equal) + data = Storage.get(nameData, data); - Util.exec(callback, data); + Util.exec(callback, data, hash); }); } }); diff --git a/lib/client/edit.js b/lib/client/edit.js index c6f02f15..75640e74 100644 --- a/lib/client/edit.js +++ b/lib/client/edit.js @@ -12,8 +12,10 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch; Value, Edit = this, Diff, + SHA, Ace, Msg, + Dialog = DOM.Dialog, Key = CloudCmd.Key, Images = DOM.Images, Element; @@ -91,11 +93,10 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch; }; this.goToLine = function() { - var dialog = DOM.Dialog, - msg = 'Enter line number:', + var msg = 'Enter line number:', cursor = Ace.selection.getCursor(), number = cursor.row + 1, - line = dialog.prompt(msg, number); + line = Dialog.prompt(msg, number); number = line - 0; @@ -154,12 +155,28 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch; Value = lValue; - if (Util.isString(patch)) { + if (Util.isString(patch) && patch) { lValue = patch; query = '?patch'; } - DOM.RESTful.save(lPath, lValue, onSave, query); + DOM.checkStorageHash(lPath, function(error, equal) { + var ret, + msg = 'File is changed, overwrite?', + saveFunc = function(text) { + var hash = SHA.digest(Value); + onSave(text, hash); + }; + + if (!error && !equal) + ret = Dialog.confirm(msg); + else + DOM.RESTful.save(lPath, lValue, saveFunc, query); + + if (ret) + DOM.RESTful.save(lPath, lValue, saveFunc); + }); + }, function(callback) { diff(lValue, callback); }); @@ -171,12 +188,16 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch; function diff(pNewValue, pCallBack) { var libs = [ LIBDIR + 'diff.js', - LIBDIR + 'diff/diff-match-patch.js' + LIBDIR + 'diff/diff-match-patch.js', + LIBDIR + 'sha1/rusha.js' ]; DOM.anyLoadInParallel(libs, function() { var patch; + if (!SHA) + SHA = new Rusha(); + if (!Diff) Diff = new DiffProto(diff_match_patch); @@ -214,7 +235,7 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch; } } - function onSave(text) { + function onSave(text, hash) { var ret, isError = Util.isContainStrAtBegin(text, 'error'), path = DOM.getCurrentPath(), @@ -222,7 +243,7 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch; if (!isError) { Edit.showMessage(text); - DOM.saveDataToStorage(path, Value); + DOM.saveDataToStorage(path, Value, hash); } else { ret = Dialog.confirm(text + msg); diff --git a/lib/sha1/README.md b/lib/sha1/README.md new file mode 100644 index 00000000..6d806560 --- /dev/null +++ b/lib/sha1/README.md @@ -0,0 +1,60 @@ +# Rusha +*A high-performance pure-javascript SHA1 implementation suitable for large binary data.* + +## Prologue: The Sad State of Javascript SHA1 implementations + +When we started experimenting with alternative upload technologies at [doctape](http://doctape.com) that required creating SHA1 hashes of the data locally on the client, it quickly became obvious that there were no performant pure-js implementations of SHA1 that worked correctly on binary data. + +Jeff Mott's [CryptoJS](http://code.google.com/p/crypto-js/) and Brian Turek's [jsSHA](http://caligatio.github.com/jsSHA/) were both hash functions that worked correctly on ASCII strings of a small size, but didn't scale to large data and/or didn't work correctly with binary data. + +(On a sidenode, as of now Tim Caswell's [Cifre](http://github.com/openpeer/cifre) actually works with large binary data, as opposed to previously statet.) + +By modifying Paul Johnston's [sha1.js](http://pajhome.org.uk/crypt/md5/sha1.html) slightly, it worked correctly on binary data but was unfortunately very slow, especially on V8. So a few days were invested on my side to implement a Johnston-inspired SHA1 hashing function with a heavy focus on performance. + +The result of this process is Rusha, a SHA1 hash function that works flawlessly on large amounts binary data, such as binary strings or ArrayBuffers returned by the HTML5 File API, and leverages the soon-to-be-landed-in-firefox [asm.js](http://asmjs.org/spec/latest/) with whose support its within *half of native speed*! + +## Installing + +### Node.JS + +There is really no point in doing this, since Node.JS already has a wonderful `crypto` module that is leveraging low-level hardware instructions to perform really nice. Your can see the comparison below in the benchmarks. + +Rusha is available on [npm](http://npmjs.org/) via `npm install rusha`. + +If you still want to do this, anyhow, just `require()` the `rusha.js` file, follow the instructions on _Using the Rusha Object_. + +### Browser + +Rusha is available on [bower](http://twitter.github.com/bower/) via `bower install rusha`. + +It is highly recommended to run CPU-intensive tasks in a [Web Worker](http://developer.mozilla.org/en-US/docs/DOM/Using_web_workers). To do so, just start a worker with `var worker = new Worker('rusha.js')` and start sending it jobs. Follow the instructions on _Using the Rusha Worker_. + +If you can't, for any reason, use Web Workers, include the `rusha.js` file in a ` + - - + From dd75959826e2ac66ef7bb978d6d7d5133728fc2a Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 26 Nov 2013 14:22:19 +0000 Subject: [PATCH 179/315] feature(index) add async --- html/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/html/index.html b/html/index.html index 3d66ab5f..a2d2d0da 100644 --- a/html/index.html +++ b/html/index.html @@ -28,6 +28,6 @@
    - + From 0f359cd77cbc578efd3a5744945478ac50f92d12 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 26 Nov 2013 14:34:15 +0000 Subject: [PATCH 180/315] chore(main) add " " --- lib/server/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/server/main.js b/lib/server/main.js index 79ddce0d..e611d203 100644 --- a/lib/server/main.js +++ b/lib/server/main.js @@ -117,7 +117,7 @@ exports.ischanged = srvrequire('ischanged'); exports.commander = srvrequire('commander'); exports.files = srvrequire('files'); - + exports.minify = srvrequire('minify').Minify; /* second initializing after all modules load, so global var is * From cdec597f6e3e5cb415a726c44b4f23da4236258e Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 26 Nov 2013 14:35:27 +0000 Subject: [PATCH 181/315] test(test) main.readFile -> files.readFiles --- test/test.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/test/test.js b/test/test.js index 2ead67a1..0ba98ede 100644 --- a/test/test.js +++ b/test/test.js @@ -3,11 +3,12 @@ var DIR = process.cwd() + '/', main = require(DIR + 'lib/server/main'), - + Util = main.util, CloudFunc = main.cloudfunc, HTMLDIR = main.HTMLDIR, + files = main.files, TEMPLATEPATH = HTMLDIR + 'file.html', PATHTEMPLATE_PATH = HTMLDIR + 'path.html', @@ -52,9 +53,9 @@ 'owner' + 'mode' + ''; - - main.readFiles(Files, function(pErrors, pFiles){ + + files.readFiles(Files, function(pErrors, pFiles){ if(pErrors) Util.log(pErrors); else{ From b0a453c6df3c2ab54f6af9f5e53fc98aee1d9b18 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 26 Nov 2013 14:49:20 +0000 Subject: [PATCH 182/315] fix(server) add gzip --- lib/server.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/server.js b/lib/server.js index 3634021b..27f00a66 100644 --- a/lib/server.js +++ b/lib/server.js @@ -214,7 +214,7 @@ } function combine(params) { - var names, i, n, name, minName, + var names, i, n, name, minName, stream, funcs = [], config = main.config, dir = DIR, @@ -226,24 +226,30 @@ isCombine = Util.isContainStrAtBegin(path, COMBINE), readPipe = function() { main.mainSetHeader({ - name : name, + name : names[0], cache : config.cache, gzip : isGzip, request : p.request, response : p.response }); + if (!isGzip) + stream = p.response; + else + stream = gzip; + files.readPipe({ names : names, dir : dir, - write : gzip, + write : stream, callback : function(error) { if (error) main.sendError(params, error); } }); - gzip.pipe(p.response); + if (isGzip) + gzip.pipe(p.response); }; if (isCombine) { @@ -265,10 +271,8 @@ funcs.push(minify(name)); } - Util.asyncCall(funcs, readPipe); } - } return isCombine; From 24adfd4bb45a8cddc4b3f9d38275342160ba82ac Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 26 Nov 2013 14:52:18 +0000 Subject: [PATCH 183/315] feature(dom) add combineLoad --- lib/client/dom.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/client/dom.js b/lib/client/dom.js index df81f6cf..bdff4baa 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -1108,6 +1108,19 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; } + this.combineLoad = function(names, callback) { + var COMBINE = '/combine/'; + + names = names + '' + .replace(',', ':'); + Loader.ajax({ + url : COMBINE + names, + error : Images.showError, + success : Util.retExec(callback) + }); + }; + + /** * load jquery from google cdn or local copy * @param pCallBack From ea4b7d03c59cd51ebf372a6571578b7ddfde2f54 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 26 Nov 2013 15:53:29 +0000 Subject: [PATCH 184/315] fix(util) lExtLenght -> lExtLength --- lib/util.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/util.js b/lib/util.js index ed3d5e0b..82f9a318 100644 --- a/lib/util.js +++ b/lib/util.js @@ -117,7 +117,7 @@ Util = exports || {}; /* если длина имени больше длинны расширения - имеет смысл продолжать */ - if (Util.isString(pExt) && lLength > lExtLenght) { + if (Util.isString(pExt) && lLength > lExtLength) { lExtNum = pName.lastIndexOf(pExt), /* последнее вхождение расширения*/ lExtSub = lLength - lExtNum; /* длина расширения*/ From 7f3f3c4e73918da8818e8dbb62c2864d4ede34c9 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 26 Nov 2013 15:54:15 +0000 Subject: [PATCH 185/315] reafactore(dom) combineLoad -> combineURL --- lib/client/dom.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/lib/client/dom.js b/lib/client/dom.js index bdff4baa..afd26df8 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -1108,16 +1108,15 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; } - this.combineLoad = function(names, callback) { - var COMBINE = '/combine/'; + this.combineURL = function(names, callback) { + var url, + COMBINE = '/combine', + nameStr = names + ''; - names = names + '' - .replace(',', ':'); - Loader.ajax({ - url : COMBINE + names, - error : Images.showError, - success : Util.retExec(callback) - }); + nameStr = Util.replaceStr(nameStr, ',', ':'); + url = COMBINE + nameStr; + + return url; }; From 265536e1057e94b65fd5a352adc489594c2efe98 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 26 Nov 2013 15:54:40 +0000 Subject: [PATCH 186/315] feature(edit) anyLoadOnLoad -> combineURL && jsload --- lib/client/edit.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/client/edit.js b/lib/client/edit.js index cd707d39..ab486b62 100644 --- a/lib/client/edit.js +++ b/lib/client/edit.js @@ -200,12 +200,14 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch; Util.time(Name + ' load'); var lFiles = [ - DIR + 'theme-tomorrow_night_blue.js', - DIR + 'ext-language_tools.js', - DIR + 'ace.js', - ]; + DIR + 'theme-tomorrow_night_blue.js', + DIR + 'ext-language_tools.js', + DIR + 'ace.js', + ], + lURL = DOM.combineURL(lFiles); - DOM.anyLoadOnLoad(lFiles, function() { + + DOM.jsload(lURL, function() { Util.timeEnd(Name + ' load'); Loading = false; Util.exec(pCallBack); From 3decb610f5421a70cf1cae9e2c505f4af7d46a2b Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 26 Nov 2013 15:57:12 +0000 Subject: [PATCH 187/315] chore(dom) combineURL: rm callback --- lib/client/dom.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/client/dom.js b/lib/client/dom.js index afd26df8..19cbf336 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -1108,7 +1108,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; } - this.combineURL = function(names, callback) { + this.combineURL = function(names) { var url, COMBINE = '/combine', nameStr = names + ''; From 8ed8c5298d8f1774db10f932fe22ebfef2d1bb03 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 26 Nov 2013 15:59:27 +0000 Subject: [PATCH 188/315] feature(console) add combineURL --- lib/client/console.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/client/console.js b/lib/client/console.js index e68e49e5..62f5f6a6 100644 --- a/lib/client/console.js +++ b/lib/client/console.js @@ -137,10 +137,14 @@ var CloudCmd, Util, DOM, $; Util.time(Name + ' load'); var lDir = CloudCmd.LIBDIRCLIENT + 'console/', - lFiles = [ - lDir + 'jqconsole.js', + lCSS = [ lDir + 'jqconsole.css', lDir + 'ansi.css' + ], + lAllCSS = DOM.combineURL(lCSS), + lFiles = [ + lDir + 'jqconsole.js', + lAllCSS ]; DOM.anyLoadInParallel(lFiles, function() { From 4b837b54ebaef19066678a3e6066ab0f79c9679f Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 26 Nov 2013 16:26:23 +0000 Subject: [PATCH 189/315] refactor(server) getExtension && strCmp -> checkExtension --- lib/server.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/server.js b/lib/server.js index 27f00a66..9c6806e0 100644 --- a/lib/server.js +++ b/lib/server.js @@ -146,7 +146,7 @@ */ function controller(pReq, pRes) { /* Читаем содержимое папки, переданное в url */ - var lRet, lName, lMin, lExt, lResult, + var lRet, lName, lMin, lCheck, lResult, lConfig = main.config, lParsedUrl = URL.parse(pReq.url), lQuery = lParsedUrl.search || '', @@ -182,8 +182,8 @@ lName = Path.join(DIR, lName); lMin = lConfig.minify, - lExt = Util.getExtension(lName), - lResult = lMin && Util.strCmp(lExt, ['.js', '.css', '.html']); + lCheck = Util.checkExtension(lName, ['.js', '.css', '.html']); + lResult = lMin && lCheck; Util.ifExec(!lResult, function(pParams) { From a1a304d3263fef4ffb89c68a660a2c6175aa598b Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 26 Nov 2013 16:30:54 +0000 Subject: [PATCH 190/315] feature(server) add checkExtension --- lib/server.js | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/lib/server.js b/lib/server.js index 9c6806e0..aa295c3f 100644 --- a/lib/server.js +++ b/lib/server.js @@ -182,7 +182,7 @@ lName = Path.join(DIR, lName); lMin = lConfig.minify, - lCheck = Util.checkExtension(lName, ['.js', '.css', '.html']); + lCheck = checkExtension(lName); lResult = lMin && lCheck; Util.ifExec(!lResult, @@ -214,7 +214,7 @@ } function combine(params) { - var names, i, n, name, minName, stream, + var names, i, n, name, minName, stream, check, funcs = [], config = main.config, dir = DIR, @@ -262,11 +262,15 @@ else { for (i = 0; i < n; i++) { name = Path.join(DIR, names[i]); - minName = Minify.getName(name); + check = checkExtension(name); - if (name !== minName) { - names[i] = minName; - dir = ''; + if (check) { + minName = Minify.getName(name); + + if (name !== minName) { + names[i] = minName; + dir = ''; + } } funcs.push(minify(name)); @@ -278,6 +282,13 @@ return isCombine; } + function checkExtension(name) { + var ret; + + ret = Util.checkExtension(name, ['.js', '.css', '.html']); + + return ret;c + } exports.start = start; From b125e049ef74167ec98833da863566ffa8a74693 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 27 Nov 2013 08:00:23 +0000 Subject: [PATCH 191/315] refactor(ace) add files to combine --- lib/client/edit.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/client/edit.js b/lib/client/edit.js index ab486b62..ec7f7dc1 100644 --- a/lib/client/edit.js +++ b/lib/client/edit.js @@ -112,8 +112,6 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch; function initAce() { var lSession; - ace.require('ace/ext/language_tools'); - Ace = ace.edit(Element); lSession = Ace.getSession(); @@ -202,12 +200,15 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch; var lFiles = [ DIR + 'theme-tomorrow_night_blue.js', DIR + 'ext-language_tools.js', - DIR + 'ace.js', + DIR + 'ext-searchbox.js', + DIR + 'snippets/javascript.js', + DIR + 'mode-javascript.js', ], + lAce = DIR + 'ace.js', lURL = DOM.combineURL(lFiles); - DOM.jsload(lURL, function() { + DOM.anyLoadOnLoad([lURL, lAce], function() { Util.timeEnd(Name + ' load'); Loading = false; Util.exec(pCallBack); From db54cda00ce9fb0e2cc8a9848c934b29271d8e97 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 27 Nov 2013 08:04:03 +0000 Subject: [PATCH 192/315] feature(edit) diff: anyLoadInParallel -> combineURL --- lib/client/edit.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/client/edit.js b/lib/client/edit.js index ec7f7dc1..fa0a8569 100644 --- a/lib/client/edit.js +++ b/lib/client/edit.js @@ -180,9 +180,10 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch; var libs = [ LIBDIR + 'diff.js', LIBDIR + 'diff/diff-match-patch.js' - ]; + ], + url = DOM.combineURL(libs); - DOM.anyLoadInParallel(libs, function() { + DOM.jsload(url, function() { var patch; if (!Diff) From 8a5522e305890026f27ea83f2368eb4338cd8410 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 27 Nov 2013 08:15:58 +0000 Subject: [PATCH 193/315] feature(cloudfunc) add getCombineURL, getCombineArray, isCombineURL --- lib/client/console.js | 8 ++++---- lib/client/dom.js | 13 ------------- lib/client/edit.js | 4 ++-- lib/cloudfunc.js | 26 +++++++++++++++++++++++++- lib/server.js | 9 ++++----- 5 files changed, 35 insertions(+), 25 deletions(-) diff --git a/lib/client/console.js b/lib/client/console.js index 62f5f6a6..a47f7150 100644 --- a/lib/client/console.js +++ b/lib/client/console.js @@ -1,5 +1,5 @@ -var CloudCmd, Util, DOM, $; -(function(CloudCmd, Util, DOM) { +var CloudCmd, Util, DOM, CloudFunc, $; +(function(CloudCmd, Util, DOM, CloudFunc) { 'use strict'; var Buffer = { @@ -141,7 +141,7 @@ var CloudCmd, Util, DOM, $; lDir + 'jqconsole.css', lDir + 'ansi.css' ], - lAllCSS = DOM.combineURL(lCSS), + lAllCSS = CloudFunc.getCombineURL(lCSS), lFiles = [ lDir + 'jqconsole.js', lAllCSS @@ -178,4 +178,4 @@ var CloudCmd, Util, DOM, $; init(); } -})(CloudCmd, Util, DOM); +})(CloudCmd, Util, DOM, CloudFunc); diff --git a/lib/client/dom.js b/lib/client/dom.js index 19cbf336..039b9d08 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -1107,19 +1107,6 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; return lRet; } - - this.combineURL = function(names) { - var url, - COMBINE = '/combine', - nameStr = names + ''; - - nameStr = Util.replaceStr(nameStr, ',', ':'); - url = COMBINE + nameStr; - - return url; - }; - - /** * load jquery from google cdn or local copy * @param pCallBack diff --git a/lib/client/edit.js b/lib/client/edit.js index fa0a8569..9feda662 100644 --- a/lib/client/edit.js +++ b/lib/client/edit.js @@ -181,7 +181,7 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch; LIBDIR + 'diff.js', LIBDIR + 'diff/diff-match-patch.js' ], - url = DOM.combineURL(libs); + url = CloudFunc.getCombineURL(libs); DOM.jsload(url, function() { var patch; @@ -206,7 +206,7 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch; DIR + 'mode-javascript.js', ], lAce = DIR + 'ace.js', - lURL = DOM.combineURL(lFiles); + lURL = CloudFunc.getCombineURL(lFiles); DOM.anyLoadOnLoad([lURL, lAce], function() { diff --git a/lib/cloudfunc.js b/lib/cloudfunc.js index 5a9cab15..4cb01bf6 100644 --- a/lib/cloudfunc.js +++ b/lib/cloudfunc.js @@ -7,7 +7,6 @@ var Util, exports, CloudFunc = {}; * Модуль, содержащий функции, которые * будут работать и на клиенте и на сервере */ - var FS; if(exports) { if(!global.cloudcmd) return console.log( @@ -22,6 +21,8 @@ var Util, exports, CloudFunc = {}; CloudFunc = exports; } + var FS, + COMBINE = '/combine'; /* Путь с которым мы сейчас работаем */ CloudFunc.Path = ''; @@ -41,6 +42,29 @@ var Util, exports, CloudFunc = {}; CloudFunc.LEFTPANEL = 'left'; CloudFunc.RIGHTPANEL = 'right'; + CloudFunc.getCombineURL = function(names) { + var url, + nameStr = names + ''; + + nameStr = Util.replaceStr(nameStr, ',', ':'); + url = COMBINE + nameStr; + + return url; + }; + + CloudFunc.getCombineArray = function(url) { + var str = Util.removeStrOneTime(url, COMBINE), + names = str.split(':'); + + return names; + }; + + CloudFunc.isCombineURL = function(url) { + var ret = Util.isContainStrAtBegin(url, COMBINE); + + return ret; + }; + CloudFunc.formatMsg = function(pMsg, pName, pStatus) { var status = pStatus || 'ok', name = !pName ? '': '("' + pName + '")', diff --git a/lib/server.js b/lib/server.js index aa295c3f..5ddbd6a1 100644 --- a/lib/server.js +++ b/lib/server.js @@ -223,7 +223,7 @@ isGzip = main.isGZIP(p.request), path = params.name, COMBINE = '/combine/', - isCombine = Util.isContainStrAtBegin(path, COMBINE), + isCombine = CloudFunc.isCombineURL(path), readPipe = function() { main.mainSetHeader({ name : names[0], @@ -253,9 +253,8 @@ }; if (isCombine) { - path = Util.removeStrOneTime(path, COMBINE); - names = path.split(':'); - n = names.length; + names = CloudFunc.getCombineArray(path); + n = names.length; if (!config.minify) readPipe(); @@ -287,7 +286,7 @@ ret = Util.checkExtension(name, ['.js', '.css', '.html']); - return ret;c + return ret; } exports.start = start; From 0937e0986379d4c425f5b9619b8386b1593e2f38 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 27 Nov 2013 08:21:31 +0000 Subject: [PATCH 194/315] chore(server) combine: add comment --- lib/server.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/server.js b/lib/server.js index 5ddbd6a1..dd9fe405 100644 --- a/lib/server.js +++ b/lib/server.js @@ -248,6 +248,10 @@ } }); + /* + * pipe should be setted up after + * readPipe called with stream param + */ if (isGzip) gzip.pipe(p.response); }; From 081740155b8d668e47a1dfa44eb0794e061ec391 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 27 Nov 2013 10:55:29 +0000 Subject: [PATCH 195/315] fix(minify) ret -> callback --- lib/server/minify.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/lib/server/minify.js b/lib/server/minify.js index 90d54745..c1d4a90e 100644 --- a/lib/server/minify.js +++ b/lib/server/minify.js @@ -30,11 +30,10 @@ INDEX : HTMLDIR + 'index.html', optimize: function(pName, pParams) { - var lRet; - - if (!Minify) + if (!Minify) { Util.log(COULD_NOT_MINIFY); - else { + Util.exec(pParams.callback); + } else { pParams.name = Minify.getName(pName); if (!this.MinFolder) @@ -47,8 +46,6 @@ Util.exec(pParams.callback, pParams); }); } - - return lRet; }, /* minification folder name */ From f519e15343ca0975fbae7b519eb3d354adbcefad Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 27 Nov 2013 11:02:14 +0000 Subject: [PATCH 196/315] docs(help) mv additional modules to top --- HELP.md | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/HELP.md b/HELP.md index 019ef8ce..53605e79 100644 --- a/HELP.md +++ b/HELP.md @@ -60,6 +60,18 @@ or install in npm: cloudcmd ``` +Additional modules +--------------- +**Cloud Commander's Server Side** not using additional modules for main functionality. +But for console and minification and optimization tricks optional can be +assingned (and installed) modules: [Minify] (https://github.com/coderaiser/minify "Minify") +and [socket.io] (https://github.com/LearnBoost/socket.io "Socket.IO"). + +Install addtitional modules (type in **Cloud Commander** directory): + + npm i + + Hot keys --------------- @@ -315,17 +327,6 @@ and then, if there is new version npm r cloudcmd npm i cloudcmd -Additional modules ---------------- -**Cloud Commander's Server Side** not using additional modules for main functionality. -But for minification and optimization tricks optional can be -assingned (and installed) modules: [Minify] (https://github.com/coderaiser/minify "Minify") -and [socket.io] (https://github.com/LearnBoost/socket.io "Socket.IO"). - -Install addtitional modules (type in **Cloud Commander** directory): - - npm i - Extensions --------------- **Cloud Commander** desinged to easily porting extensions. From 89857f6717fcb10bc48e04a2355e0987678ed4a5 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 27 Nov 2013 12:47:22 +0000 Subject: [PATCH 197/315] feature(edit) add snippets --- lib/client/edit.js | 14 +- lib/client/edit/mode-javascript.js | 6 +- lib/client/edit/snippets/actionscript.js | 164 + lib/client/edit/snippets/asciidoc.js | 7 + lib/client/edit/snippets/assembly_x86.js | 7 + lib/client/edit/snippets/batchfile.js | 7 + lib/client/edit/snippets/c_cpp.js | 138 + lib/client/edit/snippets/coffee.js | 102 + lib/client/edit/snippets/csharp.js | 7 + lib/client/edit/snippets/css.js | 974 +++++ lib/client/edit/snippets/dart.js | 90 + lib/client/edit/snippets/diff.js | 18 + lib/client/edit/snippets/django.js | 115 + lib/client/edit/snippets/ejs.js | 7 + lib/client/edit/snippets/erlang.js | 167 + lib/client/edit/snippets/haml.js | 27 + lib/client/edit/snippets/handlebars.js | 7 + lib/client/edit/snippets/haskell.js | 89 + lib/client/edit/snippets/html.js | 835 ++++ lib/client/edit/snippets/html_completions.js | 7 + lib/client/edit/snippets/html_ruby.js | 7 + lib/client/edit/snippets/ini.js | 7 + lib/client/edit/snippets/jade.js | 7 + lib/client/edit/snippets/java.js | 247 ++ lib/client/edit/snippets/javascript.js | 4 +- lib/client/edit/snippets/json.js | 7 + lib/client/edit/snippets/jsoniq.js | 7 + lib/client/edit/snippets/jsp.js | 106 + lib/client/edit/snippets/less.js | 7 + lib/client/edit/snippets/livescript.js | 7 + lib/client/edit/snippets/makefile.js | 11 + lib/client/edit/snippets/markdown.js | 95 + lib/client/edit/snippets/matlab.js | 7 + lib/client/edit/snippets/mysql.js | 7 + lib/client/edit/snippets/nix.js | 7 + lib/client/edit/snippets/objectivec.js | 7 + lib/client/edit/snippets/pascal.js | 7 + lib/client/edit/snippets/perl.js | 354 ++ lib/client/edit/snippets/php.js | 384 ++ lib/client/edit/snippets/plain_text.js | 7 + lib/client/edit/snippets/powershell.js | 7 + lib/client/edit/snippets/properties.js | 7 + lib/client/edit/snippets/python.js | 165 + lib/client/edit/snippets/ruby.js | 935 +++++ lib/client/edit/snippets/sass.js | 7 + lib/client/edit/snippets/scala.js | 7 + lib/client/edit/snippets/sh.js | 90 + lib/client/edit/snippets/snippets.js | 16 + lib/client/edit/snippets/sql.js | 33 + lib/client/edit/snippets/stylus.js | 7 + lib/client/edit/snippets/svg.js | 7 + lib/client/edit/snippets/tcl.js | 99 + lib/client/edit/snippets/tex.js | 197 + lib/client/edit/snippets/text.js | 7 + lib/client/edit/snippets/textile.js | 37 + lib/client/edit/snippets/typescript.js | 7 + lib/client/edit/snippets/xml.js | 7 + lib/client/edit/snippets/yaml.js | 7 + lib/client/edit/worker-javascript.js | 3660 +++++++++--------- 59 files changed, 7598 insertions(+), 1784 deletions(-) create mode 100644 lib/client/edit/snippets/actionscript.js create mode 100644 lib/client/edit/snippets/asciidoc.js create mode 100644 lib/client/edit/snippets/assembly_x86.js create mode 100644 lib/client/edit/snippets/batchfile.js create mode 100644 lib/client/edit/snippets/c_cpp.js create mode 100644 lib/client/edit/snippets/coffee.js create mode 100644 lib/client/edit/snippets/csharp.js create mode 100644 lib/client/edit/snippets/css.js create mode 100644 lib/client/edit/snippets/dart.js create mode 100644 lib/client/edit/snippets/diff.js create mode 100644 lib/client/edit/snippets/django.js create mode 100644 lib/client/edit/snippets/ejs.js create mode 100644 lib/client/edit/snippets/erlang.js create mode 100644 lib/client/edit/snippets/haml.js create mode 100644 lib/client/edit/snippets/handlebars.js create mode 100644 lib/client/edit/snippets/haskell.js create mode 100644 lib/client/edit/snippets/html.js create mode 100644 lib/client/edit/snippets/html_completions.js create mode 100644 lib/client/edit/snippets/html_ruby.js create mode 100644 lib/client/edit/snippets/ini.js create mode 100644 lib/client/edit/snippets/jade.js create mode 100644 lib/client/edit/snippets/java.js create mode 100644 lib/client/edit/snippets/json.js create mode 100644 lib/client/edit/snippets/jsoniq.js create mode 100644 lib/client/edit/snippets/jsp.js create mode 100644 lib/client/edit/snippets/less.js create mode 100644 lib/client/edit/snippets/livescript.js create mode 100644 lib/client/edit/snippets/makefile.js create mode 100644 lib/client/edit/snippets/markdown.js create mode 100644 lib/client/edit/snippets/matlab.js create mode 100644 lib/client/edit/snippets/mysql.js create mode 100644 lib/client/edit/snippets/nix.js create mode 100644 lib/client/edit/snippets/objectivec.js create mode 100644 lib/client/edit/snippets/pascal.js create mode 100644 lib/client/edit/snippets/perl.js create mode 100644 lib/client/edit/snippets/php.js create mode 100644 lib/client/edit/snippets/plain_text.js create mode 100644 lib/client/edit/snippets/powershell.js create mode 100644 lib/client/edit/snippets/properties.js create mode 100644 lib/client/edit/snippets/python.js create mode 100644 lib/client/edit/snippets/ruby.js create mode 100644 lib/client/edit/snippets/sass.js create mode 100644 lib/client/edit/snippets/scala.js create mode 100644 lib/client/edit/snippets/sh.js create mode 100644 lib/client/edit/snippets/snippets.js create mode 100644 lib/client/edit/snippets/sql.js create mode 100644 lib/client/edit/snippets/stylus.js create mode 100644 lib/client/edit/snippets/svg.js create mode 100644 lib/client/edit/snippets/tcl.js create mode 100644 lib/client/edit/snippets/tex.js create mode 100644 lib/client/edit/snippets/text.js create mode 100644 lib/client/edit/snippets/textile.js create mode 100644 lib/client/edit/snippets/typescript.js create mode 100644 lib/client/edit/snippets/xml.js create mode 100644 lib/client/edit/snippets/yaml.js diff --git a/lib/client/edit.js b/lib/client/edit.js index 9feda662..ab3748fa 100644 --- a/lib/client/edit.js +++ b/lib/client/edit.js @@ -13,6 +13,7 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch; Edit = this, Diff, Ace, + Modelist, Msg, Dialog = DOM.Dialog, Key = CloudCmd.Key, @@ -39,7 +40,8 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch; } this.show = function(pValue) { - var lName = DOM.getCurrentName(), + var lMode, + lName = DOM.getCurrentName(), lExt = Util.getExtension(lName), lUseWorker = Util.strCmp(lExt, ['.js', '.json']); @@ -66,6 +68,13 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch; enableSnippets : true }); + + if (!Modelist) + Modelist = ace.require('ace/ext/modelist'); + + lMode = Modelist.getModeForPath(lName).mode; + Ace.session.setMode(lMode); + if (Util.isString(pValue)) { Ace.setValue(pValue); CloudCmd.View.show(Element, focus); @@ -116,7 +125,7 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch; lSession = Ace.getSession(); Ace.setTheme('ace/theme/tomorrow_night_blue'); - lSession.setMode('ace/mode/javascript'); + Ace.setShowPrintMargin(false); Ace.setShowInvisibles(true); lSession.setUseSoftTabs(true); @@ -202,6 +211,7 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch; DIR + 'theme-tomorrow_night_blue.js', DIR + 'ext-language_tools.js', DIR + 'ext-searchbox.js', + DIR + 'ext-modelist.js', DIR + 'snippets/javascript.js', DIR + 'mode-javascript.js', ], diff --git a/lib/client/edit/mode-javascript.js b/lib/client/edit/mode-javascript.js index bf541754..ee603eaa 100644 --- a/lib/client/edit/mode-javascript.js +++ b/lib/client/edit/mode-javascript.js @@ -42,12 +42,10 @@ var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; var CStyleFoldMode = require("./folding/cstyle").FoldMode; var Mode = function() { - var highlighter = new JavaScriptHighlightRules(); + this.HighlightRules = JavaScriptHighlightRules; - this.$tokenizer = new Tokenizer(highlighter.getRules()); this.$outdent = new MatchingBraceOutdent(); this.$behaviour = new CstyleBehaviour(); - this.$keywordList = highlighter.$keywordList; this.foldingRules = new CStyleFoldMode(); }; oop.inherits(Mode, TextMode); @@ -60,7 +58,7 @@ oop.inherits(Mode, TextMode); this.getNextLineIndent = function(state, line, tab) { var indent = this.$getIndent(line); - var tokenizedLine = this.$tokenizer.getLineTokens(line, state); + var tokenizedLine = this.getTokenizer().getLineTokens(line, state); var tokens = tokenizedLine.tokens; var endState = tokenizedLine.state; diff --git a/lib/client/edit/snippets/actionscript.js b/lib/client/edit/snippets/actionscript.js new file mode 100644 index 00000000..5d144064 --- /dev/null +++ b/lib/client/edit/snippets/actionscript.js @@ -0,0 +1,164 @@ +ace.define('ace/snippets/actionscript', ['require', 'exports', 'module' ], function(require, exports, module) { + + +exports.snippetText = "snippet main\n\ + package {\n\ + import flash.display.*;\n\ + import flash.Events.*;\n\ + \n\ + public class Main extends Sprite {\n\ + public function Main ( ) {\n\ + trace(\"start\");\n\ + stage.scaleMode = StageScaleMode.NO_SCALE;\n\ + stage.addEventListener(Event.RESIZE, resizeListener);\n\ + }\n\ + \n\ + private function resizeListener (e:Event):void {\n\ + trace(\"The application window changed size!\");\n\ + trace(\"New width: \" + stage.stageWidth);\n\ + trace(\"New height: \" + stage.stageHeight);\n\ + }\n\ + \n\ + }\n\ + \n\ + }\n\ +snippet class\n\ + ${1:public|internal} class ${2:name} ${3:extends } {\n\ + public function $2 ( ) {\n\ + (\"start\");\n\ + }\n\ + }\n\ +snippet all\n\ + package name {\n\ +\n\ + ${1:public|internal|final} class ${2:name} ${3:extends } {\n\ + private|public| static const FOO = \"abc\";\n\ + private|public| static var BAR = \"abc\";\n\ +\n\ + // class initializer - no JIT !! one time setup\n\ + if Cababilities.os == \"Linux|MacOS\" {\n\ + FOO = \"other\";\n\ + }\n\ +\n\ + // constructor:\n\ + public function $2 ( ){\n\ + super2();\n\ + trace(\"start\");\n\ + }\n\ + public function name (a, b...){\n\ + super.name(..);\n\ + lable:break\n\ + }\n\ + }\n\ + }\n\ +\n\ + function A(){\n\ + // A can only be accessed within this file\n\ + }\n\ +snippet switch\n\ + switch(${1}){\n\ + case ${2}:\n\ + ${3}\n\ + break;\n\ + default:\n\ + }\n\ +snippet case\n\ + case ${1}:\n\ + ${2}\n\ + break;\n\ +snippet package\n\ + package ${1:package}{\n\ + ${2}\n\ + }\n\ +snippet wh\n\ + while ${1:cond}{\n\ + ${2}\n\ + }\n\ +snippet do\n\ + do {\n\ + ${2}\n\ + } while (${1:cond})\n\ +snippet while\n\ + while ${1:cond}{\n\ + ${2}\n\ + }\n\ +snippet for enumerate names\n\ + for (${1:var} in ${2:object}){\n\ + ${3}\n\ + }\n\ +snippet for enumerate values\n\ + for each (${1:var} in ${2:object}){\n\ + ${3}\n\ + }\n\ +snippet get_set\n\ + function get ${1:name} {\n\ + return ${2}\n\ + }\n\ + function set $1 (newValue) {\n\ + ${3}\n\ + }\n\ +snippet interface\n\ + interface name {\n\ + function method(${1}):${2:returntype};\n\ + }\n\ +snippet try\n\ + try {\n\ + ${1}\n\ + } catch (error:ErrorType) {\n\ + ${2}\n\ + } finally {\n\ + ${3}\n\ + }\n\ +# For Loop (same as c.snippet)\n\ +snippet for for (..) {..}\n\ + for (${2:i} = 0; $2 < ${1:count}; $2${3:++}) {\n\ + ${4:/* code */}\n\ + }\n\ +# Custom For Loop\n\ +snippet forr\n\ + for (${1:i} = ${2:0}; ${3:$1 < 10}; $1${4:++}) {\n\ + ${5:/* code */}\n\ + }\n\ +# If Condition\n\ +snippet if\n\ + if (${1:/* condition */}) {\n\ + ${2:/* code */}\n\ + }\n\ +snippet el\n\ + else {\n\ + ${1}\n\ + }\n\ +# Ternary conditional\n\ +snippet t\n\ + ${1:/* condition */} ? ${2:a} : ${3:b}\n\ +snippet fun\n\ + function ${1:function_name}(${2})${3}\n\ + {\n\ + ${4:/* code */}\n\ + }\n\ +# FlxSprite (usefull when using the flixel library)\n\ +snippet FlxSprite\n\ + package\n\ + {\n\ + import org.flixel.*\n\ +\n\ + public class ${1:ClassName} extends ${2:FlxSprite}\n\ + {\n\ + public function $1(${3: X:Number, Y:Number}):void\n\ + {\n\ + super(X,Y);\n\ + ${4: //code...}\n\ + }\n\ +\n\ + override public function update():void\n\ + {\n\ + super.update();\n\ + ${5: //code...}\n\ + }\n\ + }\n\ + }\n\ +\n\ +"; +exports.scope = "actionscript"; + +}); diff --git a/lib/client/edit/snippets/asciidoc.js b/lib/client/edit/snippets/asciidoc.js new file mode 100644 index 00000000..a0f6d84a --- /dev/null +++ b/lib/client/edit/snippets/asciidoc.js @@ -0,0 +1,7 @@ +ace.define('ace/snippets/asciidoc', ['require', 'exports', 'module' ], function(require, exports, module) { + + +exports.snippetText = ""; +exports.scope = "asciidoc"; + +}); diff --git a/lib/client/edit/snippets/assembly_x86.js b/lib/client/edit/snippets/assembly_x86.js new file mode 100644 index 00000000..13d226ca --- /dev/null +++ b/lib/client/edit/snippets/assembly_x86.js @@ -0,0 +1,7 @@ +ace.define('ace/snippets/assembly_x86', ['require', 'exports', 'module' ], function(require, exports, module) { + + +exports.snippetText = ""; +exports.scope = "assembly_x86"; + +}); diff --git a/lib/client/edit/snippets/batchfile.js b/lib/client/edit/snippets/batchfile.js new file mode 100644 index 00000000..c6dea23e --- /dev/null +++ b/lib/client/edit/snippets/batchfile.js @@ -0,0 +1,7 @@ +ace.define('ace/snippets/batchfile', ['require', 'exports', 'module' ], function(require, exports, module) { + + +exports.snippetText = ""; +exports.scope = "batchfile"; + +}); diff --git a/lib/client/edit/snippets/c_cpp.js b/lib/client/edit/snippets/c_cpp.js new file mode 100644 index 00000000..95d09c84 --- /dev/null +++ b/lib/client/edit/snippets/c_cpp.js @@ -0,0 +1,138 @@ +ace.define('ace/snippets/c_cpp', ['require', 'exports', 'module' ], function(require, exports, module) { + + +exports.snippetText = "## STL Collections\n\ +# std::array\n\ +snippet array\n\ + std::array<${1:T}, ${2:N}> ${3};${4}\n\ +# std::vector\n\ +snippet vector\n\ + std::vector<${1:T}> ${2};${3}\n\ +# std::deque\n\ +snippet deque\n\ + std::deque<${1:T}> ${2};${3}\n\ +# std::forward_list\n\ +snippet flist\n\ + std::forward_list<${1:T}> ${2};${3}\n\ +# std::list\n\ +snippet list\n\ + std::list<${1:T}> ${2};${3}\n\ +# std::set\n\ +snippet set\n\ + std::set<${1:T}> ${2};${3}\n\ +# std::map\n\ +snippet map\n\ + std::map<${1:Key}, ${2:T}> ${3};${4}\n\ +# std::multiset\n\ +snippet mset\n\ + std::multiset<${1:T}> ${2};${3}\n\ +# std::multimap\n\ +snippet mmap\n\ + std::multimap<${1:Key}, ${2:T}> ${3};${4}\n\ +# std::unordered_set\n\ +snippet uset\n\ + std::unordered_set<${1:T}> ${2};${3}\n\ +# std::unordered_map\n\ +snippet umap\n\ + std::unordered_map<${1:Key}, ${2:T}> ${3};${4}\n\ +# std::unordered_multiset\n\ +snippet umset\n\ + std::unordered_multiset<${1:T}> ${2};${3}\n\ +# std::unordered_multimap\n\ +snippet ummap\n\ + std::unordered_multimap<${1:Key}, ${2:T}> ${3};${4}\n\ +# std::stack\n\ +snippet stack\n\ + std::stack<${1:T}> ${2};${3}\n\ +# std::queue\n\ +snippet queue\n\ + std::queue<${1:T}> ${2};${3}\n\ +# std::priority_queue\n\ +snippet pqueue\n\ + std::priority_queue<${1:T}> ${2};${3}\n\ +##\n\ +## Access Modifiers\n\ +# private\n\ +snippet pri\n\ + private\n\ +# protected\n\ +snippet pro\n\ + protected\n\ +# public\n\ +snippet pub\n\ + public\n\ +# friend\n\ +snippet fr\n\ + friend\n\ +# mutable\n\ +snippet mu\n\ + mutable\n\ +## \n\ +## Class\n\ +# class\n\ +snippet cl\n\ + class ${1:`Filename('$1', 'name')`} \n\ + {\n\ + public:\n\ + $1(${2});\n\ + ~$1();\n\ +\n\ + private:\n\ + ${3:/* data */}\n\ + };\n\ +# member function implementation\n\ +snippet mfun\n\ + ${4:void} ${1:`Filename('$1', 'ClassName')`}::${2:memberFunction}(${3}) {\n\ + ${5:/* code */}\n\ + }\n\ +# namespace\n\ +snippet ns\n\ + namespace ${1:`Filename('', 'my')`} {\n\ + ${2}\n\ + } /* namespace $1 */\n\ +##\n\ +## Input/Output\n\ +# std::cout\n\ +snippet cout\n\ + std::cout << ${1} << std::endl;${2}\n\ +# std::cin\n\ +snippet cin\n\ + std::cin >> ${1};${2}\n\ +##\n\ +## Iteration\n\ +# for i \n\ +snippet fori\n\ + for (int ${2:i} = 0; $2 < ${1:count}; $2${3:++}) {\n\ + ${4:/* code */}\n\ + }${5}\n\ +\n\ +# foreach\n\ +snippet fore\n\ + for (${1:auto} ${2:i} : ${3:container}) {\n\ + ${4:/* code */}\n\ + }${5}\n\ +# iterator\n\ +snippet iter\n\ + for (${1:std::vector}<${2:type}>::${3:const_iterator} ${4:i} = ${5:container}.begin(); $4 != $5.end(); ++$4) {\n\ + ${6}\n\ + }${7}\n\ +\n\ +# auto iterator\n\ +snippet itera\n\ + for (auto ${1:i} = $1.begin(); $1 != $1.end(); ++$1) {\n\ + ${2:std::cout << *$1 << std::endl;}\n\ + }${3}\n\ +##\n\ +## Lambdas\n\ +# lamda (one line)\n\ +snippet ld\n\ + [${1}](${2}){${3:/* code */}}${4}\n\ +# lambda (multi-line)\n\ +snippet lld\n\ + [${1}](${2}){\n\ + ${3:/* code */}\n\ + }${4}\n\ +"; +exports.scope = "c_cpp"; + +}); diff --git a/lib/client/edit/snippets/coffee.js b/lib/client/edit/snippets/coffee.js new file mode 100644 index 00000000..3c690a4a --- /dev/null +++ b/lib/client/edit/snippets/coffee.js @@ -0,0 +1,102 @@ +ace.define('ace/snippets/coffee', ['require', 'exports', 'module' ], function(require, exports, module) { + + +exports.snippetText = "# Closure loop\n\ +snippet forindo\n\ + for ${1:name} in ${2:array}\n\ + do ($1) ->\n\ + ${3:// body}\n\ +# Array comprehension\n\ +snippet fora\n\ + for ${1:name} in ${2:array}\n\ + ${3:// body...}\n\ +# Object comprehension\n\ +snippet foro\n\ + for ${1:key}, ${2:value} of ${3:object}\n\ + ${4:// body...}\n\ +# Range comprehension (inclusive)\n\ +snippet forr\n\ + for ${1:name} in [${2:start}..${3:finish}]\n\ + ${4:// body...}\n\ +snippet forrb\n\ + for ${1:name} in [${2:start}..${3:finish}] by ${4:step}\n\ + ${5:// body...}\n\ +# Range comprehension (exclusive)\n\ +snippet forrex\n\ + for ${1:name} in [${2:start}...${3:finish}]\n\ + ${4:// body...}\n\ +snippet forrexb\n\ + for ${1:name} in [${2:start}...${3:finish}] by ${4:step}\n\ + ${5:// body...}\n\ +# Function\n\ +snippet fun\n\ + (${1:args}) ->\n\ + ${2:// body...}\n\ +# Function (bound)\n\ +snippet bfun\n\ + (${1:args}) =>\n\ + ${2:// body...}\n\ +# Class\n\ +snippet cla class ..\n\ + class ${1:`substitute(Filename(), '\\(_\\|^\\)\\(.\\)', '\\u\\2', 'g')`}\n\ + ${2}\n\ +snippet cla class .. constructor: ..\n\ + class ${1:`substitute(Filename(), '\\(_\\|^\\)\\(.\\)', '\\u\\2', 'g')`}\n\ + constructor: (${2:args}) ->\n\ + ${3}\n\ +\n\ + ${4}\n\ +snippet cla class .. extends ..\n\ + class ${1:`substitute(Filename(), '\\(_\\|^\\)\\(.\\)', '\\u\\2', 'g')`} extends ${2:ParentClass}\n\ + ${3}\n\ +snippet cla class .. extends .. constructor: ..\n\ + class ${1:`substitute(Filename(), '\\(_\\|^\\)\\(.\\)', '\\u\\2', 'g')`} extends ${2:ParentClass}\n\ + constructor: (${3:args}) ->\n\ + ${4}\n\ +\n\ + ${5}\n\ +# If\n\ +snippet if\n\ + if ${1:condition}\n\ + ${2:// body...}\n\ +# If __ Else\n\ +snippet ife\n\ + if ${1:condition}\n\ + ${2:// body...}\n\ + else\n\ + ${3:// body...}\n\ +# Else if\n\ +snippet elif\n\ + else if ${1:condition}\n\ + ${2:// body...}\n\ +# Ternary If\n\ +snippet ifte\n\ + if ${1:condition} then ${2:value} else ${3:other}\n\ +# Unless\n\ +snippet unl\n\ + ${1:action} unless ${2:condition}\n\ +# Switch\n\ +snippet swi\n\ + switch ${1:object}\n\ + when ${2:value}\n\ + ${3:// body...}\n\ +\n\ +# Log\n\ +snippet log\n\ + console.log ${1}\n\ +# Try __ Catch\n\ +snippet try\n\ + try\n\ + ${1}\n\ + catch ${2:error}\n\ + ${3}\n\ +# Require\n\ +snippet req\n\ + ${2:$1} = require '${1:sys}'${3}\n\ +# Export\n\ +snippet exp\n\ + ${1:root} = exports ? this\n\ +"; +exports.scope = "coffee"; + +}); diff --git a/lib/client/edit/snippets/csharp.js b/lib/client/edit/snippets/csharp.js new file mode 100644 index 00000000..cccf4c57 --- /dev/null +++ b/lib/client/edit/snippets/csharp.js @@ -0,0 +1,7 @@ +ace.define('ace/snippets/csharp', ['require', 'exports', 'module' ], function(require, exports, module) { + + +exports.snippetText = ""; +exports.scope = "csharp"; + +}); diff --git a/lib/client/edit/snippets/css.js b/lib/client/edit/snippets/css.js new file mode 100644 index 00000000..79fbb1fb --- /dev/null +++ b/lib/client/edit/snippets/css.js @@ -0,0 +1,974 @@ +ace.define('ace/snippets/css', ['require', 'exports', 'module' ], function(require, exports, module) { + + +exports.snippetText = "snippet .\n\ + ${1} {\n\ + ${2}\n\ + }\n\ +snippet !\n\ + !important\n\ +snippet bdi:m+\n\ + -moz-border-image: url(${1}) ${2:0} ${3:0} ${4:0} ${5:0} ${6:stretch} ${7:stretch};\n\ +snippet bdi:m\n\ + -moz-border-image: ${1};\n\ +snippet bdrz:m\n\ + -moz-border-radius: ${1};\n\ +snippet bxsh:m+\n\ + -moz-box-shadow: ${1:0} ${2:0} ${3:0} #${4:000};\n\ +snippet bxsh:m\n\ + -moz-box-shadow: ${1};\n\ +snippet bdi:w+\n\ + -webkit-border-image: url(${1}) ${2:0} ${3:0} ${4:0} ${5:0} ${6:stretch} ${7:stretch};\n\ +snippet bdi:w\n\ + -webkit-border-image: ${1};\n\ +snippet bdrz:w\n\ + -webkit-border-radius: ${1};\n\ +snippet bxsh:w+\n\ + -webkit-box-shadow: ${1:0} ${2:0} ${3:0} #${4:000};\n\ +snippet bxsh:w\n\ + -webkit-box-shadow: ${1};\n\ +snippet @f\n\ + @font-face {\n\ + font-family: ${1};\n\ + src: url(${2});\n\ + }\n\ +snippet @i\n\ + @import url(${1});\n\ +snippet @m\n\ + @media ${1:print} {\n\ + ${2}\n\ + }\n\ +snippet bg+\n\ + background: #${1:FFF} url(${2}) ${3:0} ${4:0} ${5:no-repeat};\n\ +snippet bga\n\ + background-attachment: ${1};\n\ +snippet bga:f\n\ + background-attachment: fixed;\n\ +snippet bga:s\n\ + background-attachment: scroll;\n\ +snippet bgbk\n\ + background-break: ${1};\n\ +snippet bgbk:bb\n\ + background-break: bounding-box;\n\ +snippet bgbk:c\n\ + background-break: continuous;\n\ +snippet bgbk:eb\n\ + background-break: each-box;\n\ +snippet bgcp\n\ + background-clip: ${1};\n\ +snippet bgcp:bb\n\ + background-clip: border-box;\n\ +snippet bgcp:cb\n\ + background-clip: content-box;\n\ +snippet bgcp:nc\n\ + background-clip: no-clip;\n\ +snippet bgcp:pb\n\ + background-clip: padding-box;\n\ +snippet bgc\n\ + background-color: #${1:FFF};\n\ +snippet bgc:t\n\ + background-color: transparent;\n\ +snippet bgi\n\ + background-image: url(${1});\n\ +snippet bgi:n\n\ + background-image: none;\n\ +snippet bgo\n\ + background-origin: ${1};\n\ +snippet bgo:bb\n\ + background-origin: border-box;\n\ +snippet bgo:cb\n\ + background-origin: content-box;\n\ +snippet bgo:pb\n\ + background-origin: padding-box;\n\ +snippet bgpx\n\ + background-position-x: ${1};\n\ +snippet bgpy\n\ + background-position-y: ${1};\n\ +snippet bgp\n\ + background-position: ${1:0} ${2:0};\n\ +snippet bgr\n\ + background-repeat: ${1};\n\ +snippet bgr:n\n\ + background-repeat: no-repeat;\n\ +snippet bgr:x\n\ + background-repeat: repeat-x;\n\ +snippet bgr:y\n\ + background-repeat: repeat-y;\n\ +snippet bgr:r\n\ + background-repeat: repeat;\n\ +snippet bgz\n\ + background-size: ${1};\n\ +snippet bgz:a\n\ + background-size: auto;\n\ +snippet bgz:ct\n\ + background-size: contain;\n\ +snippet bgz:cv\n\ + background-size: cover;\n\ +snippet bg\n\ + background: ${1};\n\ +snippet bg:ie\n\ + filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='${1}',sizingMethod='${2:crop}');\n\ +snippet bg:n\n\ + background: none;\n\ +snippet bd+\n\ + border: ${1:1px} ${2:solid} #${3:000};\n\ +snippet bdb+\n\ + border-bottom: ${1:1px} ${2:solid} #${3:000};\n\ +snippet bdbc\n\ + border-bottom-color: #${1:000};\n\ +snippet bdbi\n\ + border-bottom-image: url(${1});\n\ +snippet bdbi:n\n\ + border-bottom-image: none;\n\ +snippet bdbli\n\ + border-bottom-left-image: url(${1});\n\ +snippet bdbli:c\n\ + border-bottom-left-image: continue;\n\ +snippet bdbli:n\n\ + border-bottom-left-image: none;\n\ +snippet bdblrz\n\ + border-bottom-left-radius: ${1};\n\ +snippet bdbri\n\ + border-bottom-right-image: url(${1});\n\ +snippet bdbri:c\n\ + border-bottom-right-image: continue;\n\ +snippet bdbri:n\n\ + border-bottom-right-image: none;\n\ +snippet bdbrrz\n\ + border-bottom-right-radius: ${1};\n\ +snippet bdbs\n\ + border-bottom-style: ${1};\n\ +snippet bdbs:n\n\ + border-bottom-style: none;\n\ +snippet bdbw\n\ + border-bottom-width: ${1};\n\ +snippet bdb\n\ + border-bottom: ${1};\n\ +snippet bdb:n\n\ + border-bottom: none;\n\ +snippet bdbk\n\ + border-break: ${1};\n\ +snippet bdbk:c\n\ + border-break: close;\n\ +snippet bdcl\n\ + border-collapse: ${1};\n\ +snippet bdcl:c\n\ + border-collapse: collapse;\n\ +snippet bdcl:s\n\ + border-collapse: separate;\n\ +snippet bdc\n\ + border-color: #${1:000};\n\ +snippet bdci\n\ + border-corner-image: url(${1});\n\ +snippet bdci:c\n\ + border-corner-image: continue;\n\ +snippet bdci:n\n\ + border-corner-image: none;\n\ +snippet bdf\n\ + border-fit: ${1};\n\ +snippet bdf:c\n\ + border-fit: clip;\n\ +snippet bdf:of\n\ + border-fit: overwrite;\n\ +snippet bdf:ow\n\ + border-fit: overwrite;\n\ +snippet bdf:r\n\ + border-fit: repeat;\n\ +snippet bdf:sc\n\ + border-fit: scale;\n\ +snippet bdf:sp\n\ + border-fit: space;\n\ +snippet bdf:st\n\ + border-fit: stretch;\n\ +snippet bdi\n\ + border-image: url(${1}) ${2:0} ${3:0} ${4:0} ${5:0} ${6:stretch} ${7:stretch};\n\ +snippet bdi:n\n\ + border-image: none;\n\ +snippet bdl+\n\ + border-left: ${1:1px} ${2:solid} #${3:000};\n\ +snippet bdlc\n\ + border-left-color: #${1:000};\n\ +snippet bdli\n\ + border-left-image: url(${1});\n\ +snippet bdli:n\n\ + border-left-image: none;\n\ +snippet bdls\n\ + border-left-style: ${1};\n\ +snippet bdls:n\n\ + border-left-style: none;\n\ +snippet bdlw\n\ + border-left-width: ${1};\n\ +snippet bdl\n\ + border-left: ${1};\n\ +snippet bdl:n\n\ + border-left: none;\n\ +snippet bdlt\n\ + border-length: ${1};\n\ +snippet bdlt:a\n\ + border-length: auto;\n\ +snippet bdrz\n\ + border-radius: ${1};\n\ +snippet bdr+\n\ + border-right: ${1:1px} ${2:solid} #${3:000};\n\ +snippet bdrc\n\ + border-right-color: #${1:000};\n\ +snippet bdri\n\ + border-right-image: url(${1});\n\ +snippet bdri:n\n\ + border-right-image: none;\n\ +snippet bdrs\n\ + border-right-style: ${1};\n\ +snippet bdrs:n\n\ + border-right-style: none;\n\ +snippet bdrw\n\ + border-right-width: ${1};\n\ +snippet bdr\n\ + border-right: ${1};\n\ +snippet bdr:n\n\ + border-right: none;\n\ +snippet bdsp\n\ + border-spacing: ${1};\n\ +snippet bds\n\ + border-style: ${1};\n\ +snippet bds:ds\n\ + border-style: dashed;\n\ +snippet bds:dtds\n\ + border-style: dot-dash;\n\ +snippet bds:dtdtds\n\ + border-style: dot-dot-dash;\n\ +snippet bds:dt\n\ + border-style: dotted;\n\ +snippet bds:db\n\ + border-style: double;\n\ +snippet bds:g\n\ + border-style: groove;\n\ +snippet bds:h\n\ + border-style: hidden;\n\ +snippet bds:i\n\ + border-style: inset;\n\ +snippet bds:n\n\ + border-style: none;\n\ +snippet bds:o\n\ + border-style: outset;\n\ +snippet bds:r\n\ + border-style: ridge;\n\ +snippet bds:s\n\ + border-style: solid;\n\ +snippet bds:w\n\ + border-style: wave;\n\ +snippet bdt+\n\ + border-top: ${1:1px} ${2:solid} #${3:000};\n\ +snippet bdtc\n\ + border-top-color: #${1:000};\n\ +snippet bdti\n\ + border-top-image: url(${1});\n\ +snippet bdti:n\n\ + border-top-image: none;\n\ +snippet bdtli\n\ + border-top-left-image: url(${1});\n\ +snippet bdtli:c\n\ + border-corner-image: continue;\n\ +snippet bdtli:n\n\ + border-corner-image: none;\n\ +snippet bdtlrz\n\ + border-top-left-radius: ${1};\n\ +snippet bdtri\n\ + border-top-right-image: url(${1});\n\ +snippet bdtri:c\n\ + border-top-right-image: continue;\n\ +snippet bdtri:n\n\ + border-top-right-image: none;\n\ +snippet bdtrrz\n\ + border-top-right-radius: ${1};\n\ +snippet bdts\n\ + border-top-style: ${1};\n\ +snippet bdts:n\n\ + border-top-style: none;\n\ +snippet bdtw\n\ + border-top-width: ${1};\n\ +snippet bdt\n\ + border-top: ${1};\n\ +snippet bdt:n\n\ + border-top: none;\n\ +snippet bdw\n\ + border-width: ${1};\n\ +snippet bd\n\ + border: ${1};\n\ +snippet bd:n\n\ + border: none;\n\ +snippet b\n\ + bottom: ${1};\n\ +snippet b:a\n\ + bottom: auto;\n\ +snippet bxsh+\n\ + box-shadow: ${1:0} ${2:0} ${3:0} #${4:000};\n\ +snippet bxsh\n\ + box-shadow: ${1};\n\ +snippet bxsh:n\n\ + box-shadow: none;\n\ +snippet bxz\n\ + box-sizing: ${1};\n\ +snippet bxz:bb\n\ + box-sizing: border-box;\n\ +snippet bxz:cb\n\ + box-sizing: content-box;\n\ +snippet cps\n\ + caption-side: ${1};\n\ +snippet cps:b\n\ + caption-side: bottom;\n\ +snippet cps:t\n\ + caption-side: top;\n\ +snippet cl\n\ + clear: ${1};\n\ +snippet cl:b\n\ + clear: both;\n\ +snippet cl:l\n\ + clear: left;\n\ +snippet cl:n\n\ + clear: none;\n\ +snippet cl:r\n\ + clear: right;\n\ +snippet cp\n\ + clip: ${1};\n\ +snippet cp:a\n\ + clip: auto;\n\ +snippet cp:r\n\ + clip: rect(${1:0} ${2:0} ${3:0} ${4:0});\n\ +snippet c\n\ + color: #${1:000};\n\ +snippet ct\n\ + content: ${1};\n\ +snippet ct:a\n\ + content: attr(${1});\n\ +snippet ct:cq\n\ + content: close-quote;\n\ +snippet ct:c\n\ + content: counter(${1});\n\ +snippet ct:cs\n\ + content: counters(${1});\n\ +snippet ct:ncq\n\ + content: no-close-quote;\n\ +snippet ct:noq\n\ + content: no-open-quote;\n\ +snippet ct:n\n\ + content: normal;\n\ +snippet ct:oq\n\ + content: open-quote;\n\ +snippet coi\n\ + counter-increment: ${1};\n\ +snippet cor\n\ + counter-reset: ${1};\n\ +snippet cur\n\ + cursor: ${1};\n\ +snippet cur:a\n\ + cursor: auto;\n\ +snippet cur:c\n\ + cursor: crosshair;\n\ +snippet cur:d\n\ + cursor: default;\n\ +snippet cur:ha\n\ + cursor: hand;\n\ +snippet cur:he\n\ + cursor: help;\n\ +snippet cur:m\n\ + cursor: move;\n\ +snippet cur:p\n\ + cursor: pointer;\n\ +snippet cur:t\n\ + cursor: text;\n\ +snippet d\n\ + display: ${1};\n\ +snippet d:mib\n\ + display: -moz-inline-box;\n\ +snippet d:mis\n\ + display: -moz-inline-stack;\n\ +snippet d:b\n\ + display: block;\n\ +snippet d:cp\n\ + display: compact;\n\ +snippet d:ib\n\ + display: inline-block;\n\ +snippet d:itb\n\ + display: inline-table;\n\ +snippet d:i\n\ + display: inline;\n\ +snippet d:li\n\ + display: list-item;\n\ +snippet d:n\n\ + display: none;\n\ +snippet d:ri\n\ + display: run-in;\n\ +snippet d:tbcp\n\ + display: table-caption;\n\ +snippet d:tbc\n\ + display: table-cell;\n\ +snippet d:tbclg\n\ + display: table-column-group;\n\ +snippet d:tbcl\n\ + display: table-column;\n\ +snippet d:tbfg\n\ + display: table-footer-group;\n\ +snippet d:tbhg\n\ + display: table-header-group;\n\ +snippet d:tbrg\n\ + display: table-row-group;\n\ +snippet d:tbr\n\ + display: table-row;\n\ +snippet d:tb\n\ + display: table;\n\ +snippet ec\n\ + empty-cells: ${1};\n\ +snippet ec:h\n\ + empty-cells: hide;\n\ +snippet ec:s\n\ + empty-cells: show;\n\ +snippet exp\n\ + expression()\n\ +snippet fl\n\ + float: ${1};\n\ +snippet fl:l\n\ + float: left;\n\ +snippet fl:n\n\ + float: none;\n\ +snippet fl:r\n\ + float: right;\n\ +snippet f+\n\ + font: ${1:1em} ${2:Arial},${3:sans-serif};\n\ +snippet fef\n\ + font-effect: ${1};\n\ +snippet fef:eb\n\ + font-effect: emboss;\n\ +snippet fef:eg\n\ + font-effect: engrave;\n\ +snippet fef:n\n\ + font-effect: none;\n\ +snippet fef:o\n\ + font-effect: outline;\n\ +snippet femp\n\ + font-emphasize-position: ${1};\n\ +snippet femp:a\n\ + font-emphasize-position: after;\n\ +snippet femp:b\n\ + font-emphasize-position: before;\n\ +snippet fems\n\ + font-emphasize-style: ${1};\n\ +snippet fems:ac\n\ + font-emphasize-style: accent;\n\ +snippet fems:c\n\ + font-emphasize-style: circle;\n\ +snippet fems:ds\n\ + font-emphasize-style: disc;\n\ +snippet fems:dt\n\ + font-emphasize-style: dot;\n\ +snippet fems:n\n\ + font-emphasize-style: none;\n\ +snippet fem\n\ + font-emphasize: ${1};\n\ +snippet ff\n\ + font-family: ${1};\n\ +snippet ff:c\n\ + font-family: ${1:'Monotype Corsiva','Comic Sans MS'},cursive;\n\ +snippet ff:f\n\ + font-family: ${1:Capitals,Impact},fantasy;\n\ +snippet ff:m\n\ + font-family: ${1:Monaco,'Courier New'},monospace;\n\ +snippet ff:ss\n\ + font-family: ${1:Helvetica,Arial},sans-serif;\n\ +snippet ff:s\n\ + font-family: ${1:Georgia,'Times New Roman'},serif;\n\ +snippet fza\n\ + font-size-adjust: ${1};\n\ +snippet fza:n\n\ + font-size-adjust: none;\n\ +snippet fz\n\ + font-size: ${1};\n\ +snippet fsm\n\ + font-smooth: ${1};\n\ +snippet fsm:aw\n\ + font-smooth: always;\n\ +snippet fsm:a\n\ + font-smooth: auto;\n\ +snippet fsm:n\n\ + font-smooth: never;\n\ +snippet fst\n\ + font-stretch: ${1};\n\ +snippet fst:c\n\ + font-stretch: condensed;\n\ +snippet fst:e\n\ + font-stretch: expanded;\n\ +snippet fst:ec\n\ + font-stretch: extra-condensed;\n\ +snippet fst:ee\n\ + font-stretch: extra-expanded;\n\ +snippet fst:n\n\ + font-stretch: normal;\n\ +snippet fst:sc\n\ + font-stretch: semi-condensed;\n\ +snippet fst:se\n\ + font-stretch: semi-expanded;\n\ +snippet fst:uc\n\ + font-stretch: ultra-condensed;\n\ +snippet fst:ue\n\ + font-stretch: ultra-expanded;\n\ +snippet fs\n\ + font-style: ${1};\n\ +snippet fs:i\n\ + font-style: italic;\n\ +snippet fs:n\n\ + font-style: normal;\n\ +snippet fs:o\n\ + font-style: oblique;\n\ +snippet fv\n\ + font-variant: ${1};\n\ +snippet fv:n\n\ + font-variant: normal;\n\ +snippet fv:sc\n\ + font-variant: small-caps;\n\ +snippet fw\n\ + font-weight: ${1};\n\ +snippet fw:b\n\ + font-weight: bold;\n\ +snippet fw:br\n\ + font-weight: bolder;\n\ +snippet fw:lr\n\ + font-weight: lighter;\n\ +snippet fw:n\n\ + font-weight: normal;\n\ +snippet f\n\ + font: ${1};\n\ +snippet h\n\ + height: ${1};\n\ +snippet h:a\n\ + height: auto;\n\ +snippet l\n\ + left: ${1};\n\ +snippet l:a\n\ + left: auto;\n\ +snippet lts\n\ + letter-spacing: ${1};\n\ +snippet lh\n\ + line-height: ${1};\n\ +snippet lisi\n\ + list-style-image: url(${1});\n\ +snippet lisi:n\n\ + list-style-image: none;\n\ +snippet lisp\n\ + list-style-position: ${1};\n\ +snippet lisp:i\n\ + list-style-position: inside;\n\ +snippet lisp:o\n\ + list-style-position: outside;\n\ +snippet list\n\ + list-style-type: ${1};\n\ +snippet list:c\n\ + list-style-type: circle;\n\ +snippet list:dclz\n\ + list-style-type: decimal-leading-zero;\n\ +snippet list:dc\n\ + list-style-type: decimal;\n\ +snippet list:d\n\ + list-style-type: disc;\n\ +snippet list:lr\n\ + list-style-type: lower-roman;\n\ +snippet list:n\n\ + list-style-type: none;\n\ +snippet list:s\n\ + list-style-type: square;\n\ +snippet list:ur\n\ + list-style-type: upper-roman;\n\ +snippet lis\n\ + list-style: ${1};\n\ +snippet lis:n\n\ + list-style: none;\n\ +snippet mb\n\ + margin-bottom: ${1};\n\ +snippet mb:a\n\ + margin-bottom: auto;\n\ +snippet ml\n\ + margin-left: ${1};\n\ +snippet ml:a\n\ + margin-left: auto;\n\ +snippet mr\n\ + margin-right: ${1};\n\ +snippet mr:a\n\ + margin-right: auto;\n\ +snippet mt\n\ + margin-top: ${1};\n\ +snippet mt:a\n\ + margin-top: auto;\n\ +snippet m\n\ + margin: ${1};\n\ +snippet m:4\n\ + margin: ${1:0} ${2:0} ${3:0} ${4:0};\n\ +snippet m:3\n\ + margin: ${1:0} ${2:0} ${3:0};\n\ +snippet m:2\n\ + margin: ${1:0} ${2:0};\n\ +snippet m:0\n\ + margin: 0;\n\ +snippet m:a\n\ + margin: auto;\n\ +snippet mah\n\ + max-height: ${1};\n\ +snippet mah:n\n\ + max-height: none;\n\ +snippet maw\n\ + max-width: ${1};\n\ +snippet maw:n\n\ + max-width: none;\n\ +snippet mih\n\ + min-height: ${1};\n\ +snippet miw\n\ + min-width: ${1};\n\ +snippet op\n\ + opacity: ${1};\n\ +snippet op:ie\n\ + filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=${1:100});\n\ +snippet op:ms\n\ + -ms-filter: 'progid:DXImageTransform.Microsoft.Alpha(Opacity=${1:100})';\n\ +snippet orp\n\ + orphans: ${1};\n\ +snippet o+\n\ + outline: ${1:1px} ${2:solid} #${3:000};\n\ +snippet oc\n\ + outline-color: ${1:#000};\n\ +snippet oc:i\n\ + outline-color: invert;\n\ +snippet oo\n\ + outline-offset: ${1};\n\ +snippet os\n\ + outline-style: ${1};\n\ +snippet ow\n\ + outline-width: ${1};\n\ +snippet o\n\ + outline: ${1};\n\ +snippet o:n\n\ + outline: none;\n\ +snippet ovs\n\ + overflow-style: ${1};\n\ +snippet ovs:a\n\ + overflow-style: auto;\n\ +snippet ovs:mq\n\ + overflow-style: marquee;\n\ +snippet ovs:mv\n\ + overflow-style: move;\n\ +snippet ovs:p\n\ + overflow-style: panner;\n\ +snippet ovs:s\n\ + overflow-style: scrollbar;\n\ +snippet ovx\n\ + overflow-x: ${1};\n\ +snippet ovx:a\n\ + overflow-x: auto;\n\ +snippet ovx:h\n\ + overflow-x: hidden;\n\ +snippet ovx:s\n\ + overflow-x: scroll;\n\ +snippet ovx:v\n\ + overflow-x: visible;\n\ +snippet ovy\n\ + overflow-y: ${1};\n\ +snippet ovy:a\n\ + overflow-y: auto;\n\ +snippet ovy:h\n\ + overflow-y: hidden;\n\ +snippet ovy:s\n\ + overflow-y: scroll;\n\ +snippet ovy:v\n\ + overflow-y: visible;\n\ +snippet ov\n\ + overflow: ${1};\n\ +snippet ov:a\n\ + overflow: auto;\n\ +snippet ov:h\n\ + overflow: hidden;\n\ +snippet ov:s\n\ + overflow: scroll;\n\ +snippet ov:v\n\ + overflow: visible;\n\ +snippet pb\n\ + padding-bottom: ${1};\n\ +snippet pl\n\ + padding-left: ${1};\n\ +snippet pr\n\ + padding-right: ${1};\n\ +snippet pt\n\ + padding-top: ${1};\n\ +snippet p\n\ + padding: ${1};\n\ +snippet p:4\n\ + padding: ${1:0} ${2:0} ${3:0} ${4:0};\n\ +snippet p:3\n\ + padding: ${1:0} ${2:0} ${3:0};\n\ +snippet p:2\n\ + padding: ${1:0} ${2:0};\n\ +snippet p:0\n\ + padding: 0;\n\ +snippet pgba\n\ + page-break-after: ${1};\n\ +snippet pgba:aw\n\ + page-break-after: always;\n\ +snippet pgba:a\n\ + page-break-after: auto;\n\ +snippet pgba:l\n\ + page-break-after: left;\n\ +snippet pgba:r\n\ + page-break-after: right;\n\ +snippet pgbb\n\ + page-break-before: ${1};\n\ +snippet pgbb:aw\n\ + page-break-before: always;\n\ +snippet pgbb:a\n\ + page-break-before: auto;\n\ +snippet pgbb:l\n\ + page-break-before: left;\n\ +snippet pgbb:r\n\ + page-break-before: right;\n\ +snippet pgbi\n\ + page-break-inside: ${1};\n\ +snippet pgbi:a\n\ + page-break-inside: auto;\n\ +snippet pgbi:av\n\ + page-break-inside: avoid;\n\ +snippet pos\n\ + position: ${1};\n\ +snippet pos:a\n\ + position: absolute;\n\ +snippet pos:f\n\ + position: fixed;\n\ +snippet pos:r\n\ + position: relative;\n\ +snippet pos:s\n\ + position: static;\n\ +snippet q\n\ + quotes: ${1};\n\ +snippet q:en\n\ + quotes: '\\201C' '\\201D' '\\2018' '\\2019';\n\ +snippet q:n\n\ + quotes: none;\n\ +snippet q:ru\n\ + quotes: '\\00AB' '\\00BB' '\\201E' '\\201C';\n\ +snippet rz\n\ + resize: ${1};\n\ +snippet rz:b\n\ + resize: both;\n\ +snippet rz:h\n\ + resize: horizontal;\n\ +snippet rz:n\n\ + resize: none;\n\ +snippet rz:v\n\ + resize: vertical;\n\ +snippet r\n\ + right: ${1};\n\ +snippet r:a\n\ + right: auto;\n\ +snippet tbl\n\ + table-layout: ${1};\n\ +snippet tbl:a\n\ + table-layout: auto;\n\ +snippet tbl:f\n\ + table-layout: fixed;\n\ +snippet tal\n\ + text-align-last: ${1};\n\ +snippet tal:a\n\ + text-align-last: auto;\n\ +snippet tal:c\n\ + text-align-last: center;\n\ +snippet tal:l\n\ + text-align-last: left;\n\ +snippet tal:r\n\ + text-align-last: right;\n\ +snippet ta\n\ + text-align: ${1};\n\ +snippet ta:c\n\ + text-align: center;\n\ +snippet ta:l\n\ + text-align: left;\n\ +snippet ta:r\n\ + text-align: right;\n\ +snippet td\n\ + text-decoration: ${1};\n\ +snippet td:l\n\ + text-decoration: line-through;\n\ +snippet td:n\n\ + text-decoration: none;\n\ +snippet td:o\n\ + text-decoration: overline;\n\ +snippet td:u\n\ + text-decoration: underline;\n\ +snippet te\n\ + text-emphasis: ${1};\n\ +snippet te:ac\n\ + text-emphasis: accent;\n\ +snippet te:a\n\ + text-emphasis: after;\n\ +snippet te:b\n\ + text-emphasis: before;\n\ +snippet te:c\n\ + text-emphasis: circle;\n\ +snippet te:ds\n\ + text-emphasis: disc;\n\ +snippet te:dt\n\ + text-emphasis: dot;\n\ +snippet te:n\n\ + text-emphasis: none;\n\ +snippet th\n\ + text-height: ${1};\n\ +snippet th:a\n\ + text-height: auto;\n\ +snippet th:f\n\ + text-height: font-size;\n\ +snippet th:m\n\ + text-height: max-size;\n\ +snippet th:t\n\ + text-height: text-size;\n\ +snippet ti\n\ + text-indent: ${1};\n\ +snippet ti:-\n\ + text-indent: -9999px;\n\ +snippet tj\n\ + text-justify: ${1};\n\ +snippet tj:a\n\ + text-justify: auto;\n\ +snippet tj:d\n\ + text-justify: distribute;\n\ +snippet tj:ic\n\ + text-justify: inter-cluster;\n\ +snippet tj:ii\n\ + text-justify: inter-ideograph;\n\ +snippet tj:iw\n\ + text-justify: inter-word;\n\ +snippet tj:k\n\ + text-justify: kashida;\n\ +snippet tj:t\n\ + text-justify: tibetan;\n\ +snippet to+\n\ + text-outline: ${1:0} ${2:0} #${3:000};\n\ +snippet to\n\ + text-outline: ${1};\n\ +snippet to:n\n\ + text-outline: none;\n\ +snippet tr\n\ + text-replace: ${1};\n\ +snippet tr:n\n\ + text-replace: none;\n\ +snippet tsh+\n\ + text-shadow: ${1:0} ${2:0} ${3:0} #${4:000};\n\ +snippet tsh\n\ + text-shadow: ${1};\n\ +snippet tsh:n\n\ + text-shadow: none;\n\ +snippet tt\n\ + text-transform: ${1};\n\ +snippet tt:c\n\ + text-transform: capitalize;\n\ +snippet tt:l\n\ + text-transform: lowercase;\n\ +snippet tt:n\n\ + text-transform: none;\n\ +snippet tt:u\n\ + text-transform: uppercase;\n\ +snippet tw\n\ + text-wrap: ${1};\n\ +snippet tw:no\n\ + text-wrap: none;\n\ +snippet tw:n\n\ + text-wrap: normal;\n\ +snippet tw:s\n\ + text-wrap: suppress;\n\ +snippet tw:u\n\ + text-wrap: unrestricted;\n\ +snippet t\n\ + top: ${1};\n\ +snippet t:a\n\ + top: auto;\n\ +snippet va\n\ + vertical-align: ${1};\n\ +snippet va:bl\n\ + vertical-align: baseline;\n\ +snippet va:b\n\ + vertical-align: bottom;\n\ +snippet va:m\n\ + vertical-align: middle;\n\ +snippet va:sub\n\ + vertical-align: sub;\n\ +snippet va:sup\n\ + vertical-align: super;\n\ +snippet va:tb\n\ + vertical-align: text-bottom;\n\ +snippet va:tt\n\ + vertical-align: text-top;\n\ +snippet va:t\n\ + vertical-align: top;\n\ +snippet v\n\ + visibility: ${1};\n\ +snippet v:c\n\ + visibility: collapse;\n\ +snippet v:h\n\ + visibility: hidden;\n\ +snippet v:v\n\ + visibility: visible;\n\ +snippet whsc\n\ + white-space-collapse: ${1};\n\ +snippet whsc:ba\n\ + white-space-collapse: break-all;\n\ +snippet whsc:bs\n\ + white-space-collapse: break-strict;\n\ +snippet whsc:k\n\ + white-space-collapse: keep-all;\n\ +snippet whsc:l\n\ + white-space-collapse: loose;\n\ +snippet whsc:n\n\ + white-space-collapse: normal;\n\ +snippet whs\n\ + white-space: ${1};\n\ +snippet whs:n\n\ + white-space: normal;\n\ +snippet whs:nw\n\ + white-space: nowrap;\n\ +snippet whs:pl\n\ + white-space: pre-line;\n\ +snippet whs:pw\n\ + white-space: pre-wrap;\n\ +snippet whs:p\n\ + white-space: pre;\n\ +snippet wid\n\ + widows: ${1};\n\ +snippet w\n\ + width: ${1};\n\ +snippet w:a\n\ + width: auto;\n\ +snippet wob\n\ + word-break: ${1};\n\ +snippet wob:ba\n\ + word-break: break-all;\n\ +snippet wob:bs\n\ + word-break: break-strict;\n\ +snippet wob:k\n\ + word-break: keep-all;\n\ +snippet wob:l\n\ + word-break: loose;\n\ +snippet wob:n\n\ + word-break: normal;\n\ +snippet wos\n\ + word-spacing: ${1};\n\ +snippet wow\n\ + word-wrap: ${1};\n\ +snippet wow:no\n\ + word-wrap: none;\n\ +snippet wow:n\n\ + word-wrap: normal;\n\ +snippet wow:s\n\ + word-wrap: suppress;\n\ +snippet wow:u\n\ + word-wrap: unrestricted;\n\ +snippet z\n\ + z-index: ${1};\n\ +snippet z:a\n\ + z-index: auto;\n\ +snippet zoo\n\ + zoom: 1;\n\ +"; +exports.scope = "css"; + +}); diff --git a/lib/client/edit/snippets/dart.js b/lib/client/edit/snippets/dart.js new file mode 100644 index 00000000..bd655734 --- /dev/null +++ b/lib/client/edit/snippets/dart.js @@ -0,0 +1,90 @@ +ace.define('ace/snippets/dart', ['require', 'exports', 'module' ], function(require, exports, module) { + + +exports.snippetText = "snippet lib\n\ + library ${1};\n\ + ${2}\n\ +snippet im\n\ + import '${1}';\n\ + ${2}\n\ +snippet pa\n\ + part '${1}';\n\ + ${2}\n\ +snippet pao\n\ + part of ${1};\n\ + ${2}\n\ +snippet main\n\ + void main() {\n\ + ${1:/* code */}\n\ + }\n\ +snippet st\n\ + static ${1}\n\ +snippet fi\n\ + final ${1}\n\ +snippet re\n\ + return ${1}\n\ +snippet br\n\ + break;\n\ +snippet th\n\ + throw ${1}\n\ +snippet cl\n\ + class ${1:`Filename(\"\", \"untitled\")`} ${2}\n\ +snippet imp\n\ + implements ${1}\n\ +snippet ext\n\ + extends ${1}\n\ +snippet if\n\ + if (${1:true}) {\n\ + ${2}\n\ + }\n\ +snippet ife\n\ + if (${1:true}) {\n\ + ${2}\n\ + } else {\n\ + ${3}\n\ + }\n\ +snippet el\n\ + else\n\ +snippet sw\n\ + switch (${1}) {\n\ + ${2}\n\ + }\n\ +snippet cs\n\ + case ${1}:\n\ + ${2}\n\ +snippet de\n\ + default:\n\ + ${1}\n\ +snippet for\n\ + for (var ${2:i} = 0, len = ${1:things}.length; $2 < len; ${3:++}$2) {\n\ + ${4:$1[$2]}\n\ + }\n\ +snippet fore\n\ + for (final ${2:item} in ${1:itemList}) {\n\ + ${3:/* code */}\n\ + }\n\ +snippet wh\n\ + while (${1:/* condition */}) {\n\ + ${2:/* code */}\n\ + }\n\ +snippet dowh\n\ + do {\n\ + ${2:/* code */}\n\ + } while (${1:/* condition */});\n\ +snippet as\n\ + assert(${1:/* condition */});\n\ +snippet try\n\ + try {\n\ + ${2}\n\ + } catch (${1:Exception e}) {\n\ + }\n\ +snippet tryf\n\ + try {\n\ + ${2}\n\ + } catch (${1:Exception e}) {\n\ + } finally {\n\ + }\n\ +"; +exports.scope = "dart"; + +}); diff --git a/lib/client/edit/snippets/diff.js b/lib/client/edit/snippets/diff.js new file mode 100644 index 00000000..d39023cc --- /dev/null +++ b/lib/client/edit/snippets/diff.js @@ -0,0 +1,18 @@ +ace.define('ace/snippets/diff', ['require', 'exports', 'module' ], function(require, exports, module) { + + +exports.snippetText = "# DEP-3 (http://dep.debian.net/deps/dep3/) style patch header\n\ +snippet header DEP-3 style header\n\ + Description: ${1}\n\ + Origin: ${2:vendor|upstream|other}, ${3:url of the original patch}\n\ + Bug: ${4:url in upstream bugtracker}\n\ + Forwarded: ${5:no|not-needed|url}\n\ + Author: ${6:`g:snips_author`}\n\ + Reviewed-by: ${7:name and email}\n\ + Last-Update: ${8:`strftime(\"%Y-%m-%d\")`}\n\ + Applied-Upstream: ${9:upstream version|url|commit}\n\ +\n\ +"; +exports.scope = "diff"; + +}); diff --git a/lib/client/edit/snippets/django.js b/lib/client/edit/snippets/django.js new file mode 100644 index 00000000..97eefc03 --- /dev/null +++ b/lib/client/edit/snippets/django.js @@ -0,0 +1,115 @@ +ace.define('ace/snippets/django', ['require', 'exports', 'module' ], function(require, exports, module) { + + +exports.snippetText = "# Model Fields\n\ +\n\ +# Note: Optional arguments are using defaults that match what Django will use\n\ +# as a default, e.g. with max_length fields. Doing this as a form of self\n\ +# documentation and to make it easy to know whether you should override the\n\ +# default or not.\n\ +\n\ +# Note: Optional arguments that are booleans will use the opposite since you\n\ +# can either not specify them, or override them, e.g. auto_now_add=False.\n\ +\n\ +snippet auto\n\ + ${1:FIELDNAME} = models.AutoField(${2})\n\ +snippet bool\n\ + ${1:FIELDNAME} = models.BooleanField(${2:default=True})\n\ +snippet char\n\ + ${1:FIELDNAME} = models.CharField(max_length=${2}${3:, blank=True})\n\ +snippet comma\n\ + ${1:FIELDNAME} = models.CommaSeparatedIntegerField(max_length=${2}${3:, blank=True})\n\ +snippet date\n\ + ${1:FIELDNAME} = models.DateField(${2:auto_now_add=True, auto_now=True}${3:, blank=True, null=True})\n\ +snippet datetime\n\ + ${1:FIELDNAME} = models.DateTimeField(${2:auto_now_add=True, auto_now=True}${3:, blank=True, null=True})\n\ +snippet decimal\n\ + ${1:FIELDNAME} = models.DecimalField(max_digits=${2}, decimal_places=${3})\n\ +snippet email\n\ + ${1:FIELDNAME} = models.EmailField(max_length=${2:75}${3:, blank=True})\n\ +snippet file\n\ + ${1:FIELDNAME} = models.FileField(upload_to=${2:path/for/upload}${3:, max_length=100})\n\ +snippet filepath\n\ + ${1:FIELDNAME} = models.FilePathField(path=${2:\"/abs/path/to/dir\"}${3:, max_length=100}${4:, match=\"*.ext\"}${5:, recursive=True}${6:, blank=True, })\n\ +snippet float\n\ + ${1:FIELDNAME} = models.FloatField(${2})\n\ +snippet image\n\ + ${1:FIELDNAME} = models.ImageField(upload_to=${2:path/for/upload}${3:, height_field=height, width_field=width}${4:, max_length=100})\n\ +snippet int\n\ + ${1:FIELDNAME} = models.IntegerField(${2})\n\ +snippet ip\n\ + ${1:FIELDNAME} = models.IPAddressField(${2})\n\ +snippet nullbool\n\ + ${1:FIELDNAME} = models.NullBooleanField(${2})\n\ +snippet posint\n\ + ${1:FIELDNAME} = models.PositiveIntegerField(${2})\n\ +snippet possmallint\n\ + ${1:FIELDNAME} = models.PositiveSmallIntegerField(${2})\n\ +snippet slug\n\ + ${1:FIELDNAME} = models.SlugField(max_length=${2:50}${3:, blank=True})\n\ +snippet smallint\n\ + ${1:FIELDNAME} = models.SmallIntegerField(${2})\n\ +snippet text\n\ + ${1:FIELDNAME} = models.TextField(${2:blank=True})\n\ +snippet time\n\ + ${1:FIELDNAME} = models.TimeField(${2:auto_now_add=True, auto_now=True}${3:, blank=True, null=True})\n\ +snippet url\n\ + ${1:FIELDNAME} = models.URLField(${2:verify_exists=False}${3:, max_length=200}${4:, blank=True})\n\ +snippet xml\n\ + ${1:FIELDNAME} = models.XMLField(schema_path=${2:None}${3:, blank=True})\n\ +# Relational Fields\n\ +snippet fk\n\ + ${1:FIELDNAME} = models.ForeignKey(${2:OtherModel}${3:, related_name=''}${4:, limit_choices_to=}${5:, to_field=''})\n\ +snippet m2m\n\ + ${1:FIELDNAME} = models.ManyToManyField(${2:OtherModel}${3:, related_name=''}${4:, limit_choices_to=}${5:, symmetrical=False}${6:, through=''}${7:, db_table=''})\n\ +snippet o2o\n\ + ${1:FIELDNAME} = models.OneToOneField(${2:OtherModel}${3:, parent_link=True}${4:, related_name=''}${5:, limit_choices_to=}${6:, to_field=''})\n\ +\n\ +# Code Skeletons\n\ +\n\ +snippet form\n\ + class ${1:FormName}(forms.Form):\n\ + \"\"\"${2:docstring}\"\"\"\n\ + ${3}\n\ +\n\ +snippet model\n\ + class ${1:ModelName}(models.Model):\n\ + \"\"\"${2:docstring}\"\"\"\n\ + ${3}\n\ + \n\ + class Meta:\n\ + ${4}\n\ + \n\ + def __unicode__(self):\n\ + ${5}\n\ + \n\ + def save(self, force_insert=False, force_update=False):\n\ + ${6}\n\ + \n\ + @models.permalink\n\ + def get_absolute_url(self):\n\ + return ('${7:view_or_url_name}' ${8})\n\ +\n\ +snippet modeladmin\n\ + class ${1:ModelName}Admin(admin.ModelAdmin):\n\ + ${2}\n\ + \n\ + admin.site.register($1, $1Admin)\n\ + \n\ +snippet tabularinline\n\ + class ${1:ModelName}Inline(admin.TabularInline):\n\ + model = $1\n\ +\n\ +snippet stackedinline\n\ + class ${1:ModelName}Inline(admin.StackedInline):\n\ + model = $1\n\ +\n\ +snippet r2r\n\ + return render_to_response('${1:template.html}', {\n\ + ${2}\n\ + }${3:, context_instance=RequestContext(request)}\n\ + )\n\ +"; +exports.scope = "django"; + +}); diff --git a/lib/client/edit/snippets/ejs.js b/lib/client/edit/snippets/ejs.js new file mode 100644 index 00000000..bdeec6ce --- /dev/null +++ b/lib/client/edit/snippets/ejs.js @@ -0,0 +1,7 @@ +ace.define('ace/snippets/ejs', ['require', 'exports', 'module' ], function(require, exports, module) { + + +exports.snippetText = ""; +exports.scope = "ejs"; + +}); diff --git a/lib/client/edit/snippets/erlang.js b/lib/client/edit/snippets/erlang.js new file mode 100644 index 00000000..b40f8d19 --- /dev/null +++ b/lib/client/edit/snippets/erlang.js @@ -0,0 +1,167 @@ +ace.define('ace/snippets/erlang', ['require', 'exports', 'module' ], function(require, exports, module) { + + +exports.snippetText = "# module and export all\n\ +snippet mod\n\ + -module(${1:`Filename('', 'my')`}).\n\ + \n\ + -compile([export_all]).\n\ + \n\ + start() ->\n\ + ${2}\n\ + \n\ + stop() ->\n\ + ok.\n\ +# define directive\n\ +snippet def\n\ + -ace.define(${1:macro}, ${2:body}).${3}\n\ +# export directive\n\ +snippet exp\n\ + -export([${1:function}/${2:arity}]).\n\ +# include directive\n\ +snippet inc\n\ + -include(\"${1:file}\").${2}\n\ +# behavior directive\n\ +snippet beh\n\ + -behaviour(${1:behaviour}).${2}\n\ +# if expression\n\ +snippet if\n\ + if\n\ + ${1:guard} ->\n\ + ${2:body}\n\ + end\n\ +# case expression\n\ +snippet case\n\ + case ${1:expression} of\n\ + ${2:pattern} ->\n\ + ${3:body};\n\ + end\n\ +# anonymous function\n\ +snippet fun\n\ + fun (${1:Parameters}) -> ${2:body} end${3}\n\ +# try...catch\n\ +snippet try\n\ + try\n\ + ${1}\n\ + catch\n\ + ${2:_:_} -> ${3:got_some_exception}\n\ + end\n\ +# record directive\n\ +snippet rec\n\ + -record(${1:record}, {\n\ + ${2:field}=${3:value}}).${4}\n\ +# todo comment\n\ +snippet todo\n\ + %% TODO: ${1}\n\ +## Snippets below (starting with '%') are in EDoc format.\n\ +## See http://www.erlang.org/doc/apps/edoc/chapter.html#id56887 for more details\n\ +# doc comment\n\ +snippet %d\n\ + %% @doc ${1}\n\ +# end of doc comment\n\ +snippet %e\n\ + %% @end\n\ +# specification comment\n\ +snippet %s\n\ + %% @spec ${1}\n\ +# private function marker\n\ +snippet %p\n\ + %% @private\n\ +# OTP application\n\ +snippet application\n\ + -module(${1:`Filename('', 'my')`}).\n\ +\n\ + -behaviour(application).\n\ +\n\ + -export([start/2, stop/1]).\n\ +\n\ + start(_Type, _StartArgs) ->\n\ + case ${2:root_supervisor}:start_link() of\n\ + {ok, Pid} ->\n\ + {ok, Pid};\n\ + Other ->\n\ + {error, Other}\n\ + end.\n\ +\n\ + stop(_State) ->\n\ + ok. \n\ +# OTP supervisor\n\ +snippet supervisor\n\ + -module(${1:`Filename('', 'my')`}).\n\ +\n\ + -behaviour(supervisor).\n\ +\n\ + %% API\n\ + -export([start_link/0]).\n\ +\n\ + %% Supervisor callbacks\n\ + -export([init/1]).\n\ +\n\ + -ace.define(SERVER, ?MODULE).\n\ +\n\ + start_link() ->\n\ + supervisor:start_link({local, ?SERVER}, ?MODULE, []).\n\ +\n\ + init([]) ->\n\ + Server = {${2:my_server}, {$2, start_link, []},\n\ + permanent, 2000, worker, [$2]},\n\ + Children = [Server],\n\ + RestartStrategy = {one_for_one, 0, 1},\n\ + {ok, {RestartStrategy, Children}}.\n\ +# OTP gen_server\n\ +snippet gen_server\n\ + -module(${1:`Filename('', 'my')`}).\n\ +\n\ + -behaviour(gen_server).\n\ +\n\ + %% API\n\ + -export([\n\ + start_link/0\n\ + ]).\n\ +\n\ + %% gen_server callbacks\n\ + -export([init/1, handle_call/3, handle_cast/2, handle_info/2,\n\ + terminate/2, code_change/3]).\n\ +\n\ + -ace.define(SERVER, ?MODULE).\n\ +\n\ + -record(state, {}).\n\ +\n\ + %%%===================================================================\n\ + %%% API\n\ + %%%===================================================================\n\ +\n\ + start_link() ->\n\ + gen_server:start_link({local, ?SERVER}, ?MODULE, [], []).\n\ +\n\ + %%%===================================================================\n\ + %%% gen_server callbacks\n\ + %%%===================================================================\n\ +\n\ + init([]) ->\n\ + {ok, #state{}}.\n\ +\n\ + handle_call(_Request, _From, State) ->\n\ + Reply = ok,\n\ + {reply, Reply, State}.\n\ +\n\ + handle_cast(_Msg, State) ->\n\ + {noreply, State}.\n\ +\n\ + handle_info(_Info, State) ->\n\ + {noreply, State}.\n\ +\n\ + terminate(_Reason, _State) ->\n\ + ok.\n\ +\n\ + code_change(_OldVsn, State, _Extra) ->\n\ + {ok, State}.\n\ +\n\ + %%%===================================================================\n\ + %%% Internal functions\n\ + %%%===================================================================\n\ +\n\ +"; +exports.scope = "erlang"; + +}); diff --git a/lib/client/edit/snippets/haml.js b/lib/client/edit/snippets/haml.js new file mode 100644 index 00000000..50199971 --- /dev/null +++ b/lib/client/edit/snippets/haml.js @@ -0,0 +1,27 @@ +ace.define('ace/snippets/haml', ['require', 'exports', 'module' ], function(require, exports, module) { + + +exports.snippetText = "snippet t\n\ + %table\n\ + %tr\n\ + %th\n\ + ${1:headers}\n\ + %tr\n\ + %td\n\ + ${2:headers}\n\ +snippet ul\n\ + %ul\n\ + %li\n\ + ${1:item}\n\ + %li\n\ +snippet =rp\n\ + = render :partial => '${1:partial}'\n\ +snippet =rpl\n\ + = render :partial => '${1:partial}', :locals => {}\n\ +snippet =rpc\n\ + = render :partial => '${1:partial}', :collection => @$1\n\ +\n\ +"; +exports.scope = "haml"; + +}); diff --git a/lib/client/edit/snippets/handlebars.js b/lib/client/edit/snippets/handlebars.js new file mode 100644 index 00000000..5aec6e97 --- /dev/null +++ b/lib/client/edit/snippets/handlebars.js @@ -0,0 +1,7 @@ +ace.define('ace/snippets/handlebars', ['require', 'exports', 'module' ], function(require, exports, module) { + + +exports.snippetText = ""; +exports.scope = "handlebars"; + +}); diff --git a/lib/client/edit/snippets/haskell.js b/lib/client/edit/snippets/haskell.js new file mode 100644 index 00000000..e107ece8 --- /dev/null +++ b/lib/client/edit/snippets/haskell.js @@ -0,0 +1,89 @@ +ace.define('ace/snippets/haskell', ['require', 'exports', 'module' ], function(require, exports, module) { + + +exports.snippetText = "snippet lang\n\ + {-# LANGUAGE ${1:OverloadedStrings} #-}\n\ +snippet info\n\ + -- |\n\ + -- Module : ${1:Module.Namespace}\n\ + -- Copyright : ${2:Author} ${3:2011-2012}\n\ + -- License : ${4:BSD3}\n\ + --\n\ + -- Maintainer : ${5:email@something.com}\n\ + -- Stability : ${6:experimental}\n\ + -- Portability : ${7:unknown}\n\ + --\n\ + -- ${8:Description}\n\ + --\n\ +snippet import\n\ + import ${1:Data.Text}\n\ +snippet import2\n\ + import ${1:Data.Text} (${2:head})\n\ +snippet importq\n\ + import qualified ${1:Data.Text} as ${2:T}\n\ +snippet inst\n\ + instance ${1:Monoid} ${2:Type} where\n\ + ${3}\n\ +snippet type\n\ + type ${1:Type} = ${2:Type}\n\ +snippet data\n\ + data ${1:Type} = ${2:$1} ${3:Int}\n\ +snippet newtype\n\ + newtype ${1:Type} = ${2:$1} ${3:Int}\n\ +snippet class\n\ + class ${1:Class} a where\n\ + ${2}\n\ +snippet module\n\ + module `substitute(substitute(expand('%:r'), '[/\\\\]','.','g'),'^\\%(\\l*\\.\\)\\?','','')` (\n\ + ) where\n\ + `expand('%') =~ 'Main' ? \"\\n\\nmain = do\\n print \\\"hello world\\\"\" : \"\"`\n\ +\n\ +snippet const\n\ + ${1:name} :: ${2:a}\n\ + $1 = ${3:undefined}\n\ +snippet fn\n\ + ${1:fn} :: ${2:a} -> ${3:a}\n\ + $1 ${4} = ${5:undefined}\n\ +snippet fn2\n\ + ${1:fn} :: ${2:a} -> ${3:a} -> ${4:a}\n\ + $1 ${5} = ${6:undefined}\n\ +snippet ap\n\ + ${1:map} ${2:fn} ${3:list}\n\ +snippet do\n\ + do\n\ + \n\ +snippet λ\n\ + \\${1:x} -> ${2}\n\ +snippet \\\n\ + \\${1:x} -> ${2}\n\ +snippet <-\n\ + ${1:a} <- ${2:m a}\n\ +snippet ←\n\ + ${1:a} <- ${2:m a}\n\ +snippet ->\n\ + ${1:m a} -> ${2:a}\n\ +snippet →\n\ + ${1:m a} -> ${2:a}\n\ +snippet tup\n\ + (${1:a}, ${2:b})\n\ +snippet tup2\n\ + (${1:a}, ${2:b}, ${3:c})\n\ +snippet tup3\n\ + (${1:a}, ${2:b}, ${3:c}, ${4:d})\n\ +snippet rec\n\ + ${1:Record} { ${2:recFieldA} = ${3:undefined}\n\ + , ${4:recFieldB} = ${5:undefined}\n\ + }\n\ +snippet case\n\ + case ${1:something} of\n\ + ${2} -> ${3}\n\ +snippet let\n\ + let ${1} = ${2}\n\ + in ${3}\n\ +snippet where\n\ + where\n\ + ${1:fn} = ${2:undefined}\n\ +"; +exports.scope = "haskell"; + +}); diff --git a/lib/client/edit/snippets/html.js b/lib/client/edit/snippets/html.js new file mode 100644 index 00000000..66857671 --- /dev/null +++ b/lib/client/edit/snippets/html.js @@ -0,0 +1,835 @@ +ace.define('ace/snippets/html', ['require', 'exports', 'module' ], function(require, exports, module) { + + +exports.snippetText = "# Some useful Unicode entities\n\ +# Non-Breaking Space\n\ +snippet nbs\n\ +  \n\ +# ←\n\ +snippet left\n\ + ←\n\ +# →\n\ +snippet right\n\ + →\n\ +# ↑\n\ +snippet up\n\ + ↑\n\ +# ↓\n\ +snippet down\n\ + ↓\n\ +# ↩\n\ +snippet return\n\ + ↩\n\ +# ⇤\n\ +snippet backtab\n\ + ⇤\n\ +# ⇥\n\ +snippet tab\n\ + ⇥\n\ +# ⇧\n\ +snippet shift\n\ + ⇧\n\ +# ⌃\n\ +snippet ctrl\n\ + ⌃\n\ +# ⌅\n\ +snippet enter\n\ + ⌅\n\ +# ⌘\n\ +snippet cmd\n\ + ⌘\n\ +# ⌥\n\ +snippet option\n\ + ⌥\n\ +# ⌦\n\ +snippet delete\n\ + ⌦\n\ +# ⌫\n\ +snippet backspace\n\ + ⌫\n\ +# ⎋\n\ +snippet esc\n\ + ⎋\n\ +# Generic Doctype\n\ +snippet doctype HTML 4.01 Strict\n\ + \n\ +snippet doctype HTML 4.01 Transitional\n\ + \n\ +snippet doctype HTML 5\n\ + \n\ +snippet doctype XHTML 1.0 Frameset\n\ + \n\ +snippet doctype XHTML 1.0 Strict\n\ + \n\ +snippet doctype XHTML 1.0 Transitional\n\ + \n\ +snippet doctype XHTML 1.1\n\ + \n\ +# HTML Doctype 4.01 Strict\n\ +snippet docts\n\ + \n\ +# HTML Doctype 4.01 Transitional\n\ +snippet doct\n\ + \n\ +# HTML Doctype 5\n\ +snippet doct5\n\ + \n\ +# XHTML Doctype 1.0 Frameset\n\ +snippet docxf\n\ + \n\ +# XHTML Doctype 1.0 Strict\n\ +snippet docxs\n\ + \n\ +# XHTML Doctype 1.0 Transitional\n\ +snippet docxt\n\ + \n\ +# XHTML Doctype 1.1\n\ +snippet docx\n\ + \n\ +# Attributes\n\ +snippet attr\n\ + ${1:attribute}=\"${2:property}\"\n\ +snippet attr+\n\ + ${1:attribute}=\"${2:property}\" attr+${3}\n\ +snippet .\n\ + class=\"${1}\"${2}\n\ +snippet #\n\ + id=\"${1}\"${2}\n\ +snippet alt\n\ + alt=\"${1}\"${2}\n\ +snippet charset\n\ + charset=\"${1:utf-8}\"${2}\n\ +snippet data\n\ + data-${1}=\"${2:$1}\"${3}\n\ +snippet for\n\ + for=\"${1}\"${2}\n\ +snippet height\n\ + height=\"${1}\"${2}\n\ +snippet href\n\ + href=\"${1:#}\"${2}\n\ +snippet lang\n\ + lang=\"${1:en}\"${2}\n\ +snippet media\n\ + media=\"${1}\"${2}\n\ +snippet name\n\ + name=\"${1}\"${2}\n\ +snippet rel\n\ + rel=\"${1}\"${2}\n\ +snippet scope\n\ + scope=\"${1:row}\"${2}\n\ +snippet src\n\ + src=\"${1}\"${2}\n\ +snippet title=\n\ + title=\"${1}\"${2}\n\ +snippet type\n\ + type=\"${1}\"${2}\n\ +snippet value\n\ + value=\"${1}\"${2}\n\ +snippet width\n\ + width=\"${1}\"${2}\n\ +# Elements\n\ +snippet a\n\ + ${2:$1}\n\ +snippet a.\n\ + ${3:$1}\n\ +snippet a#\n\ + ${3:$1}\n\ +snippet a:ext\n\ + ${2:$1}\n\ +snippet a:mail\n\ + ${3:email me}\n\ +snippet abbr\n\ + ${2}\n\ +snippet address\n\ +
    \n\ + ${1}\n\ +
    \n\ +snippet area\n\ + \"${4}\"\n\ +snippet area+\n\ + \"${4}\"\n\ + area+${5}\n\ +snippet area:c\n\ + \"${3}\"\n\ +snippet area:d\n\ + \"${3}\"\n\ +snippet area:p\n\ + \"${3}\"\n\ +snippet area:r\n\ + \"${3}\"\n\ +snippet article\n\ +
    \n\ + ${1}\n\ +
    \n\ +snippet article.\n\ +
    \n\ + ${2}\n\ +
    \n\ +snippet article#\n\ +
    \n\ + ${2}\n\ +
    \n\ +snippet aside\n\ + \n\ +snippet aside.\n\ + \n\ +snippet aside#\n\ + \n\ +snippet audio\n\ + \n\ +snippet b\n\ + ${1}\n\ +snippet base\n\ + \n\ +snippet bdi\n\ + ${1}\n\ +snippet bdo\n\ + ${2}\n\ +snippet bdo:l\n\ + ${1}\n\ +snippet bdo:r\n\ + ${1}\n\ +snippet blockquote\n\ +
    \n\ + ${1}\n\ +
    \n\ +snippet body\n\ + \n\ + ${1}\n\ + \n\ +snippet br\n\ +
    ${1}\n\ +snippet button\n\ + \n\ +snippet button.\n\ + \n\ +snippet button#\n\ + \n\ +snippet button:s\n\ + \n\ +snippet button:r\n\ + \n\ +snippet canvas\n\ + \n\ + ${1}\n\ + \n\ +snippet caption\n\ + ${1}\n\ +snippet cite\n\ + ${1}\n\ +snippet code\n\ + ${1}\n\ +snippet col\n\ + ${1}\n\ +snippet col+\n\ + \n\ + col+${1}\n\ +snippet colgroup\n\ + \n\ + ${1}\n\ + \n\ +snippet colgroup+\n\ + \n\ + \n\ + col+${1}\n\ + \n\ +snippet command\n\ + \n\ +snippet command:c\n\ + \n\ +snippet command:r\n\ + \n\ +snippet datagrid\n\ + \n\ + ${1}\n\ + \n\ +snippet datalist\n\ + \n\ + ${1}\n\ + \n\ +snippet datatemplate\n\ + \n\ + ${1}\n\ + \n\ +snippet dd\n\ +
    ${1}
    \n\ +snippet dd.\n\ +
    ${2}
    \n\ +snippet dd#\n\ +
    ${2}
    \n\ +snippet del\n\ + ${1}\n\ +snippet details\n\ +
    ${1}
    \n\ +snippet dfn\n\ + ${1}\n\ +snippet dialog\n\ + \n\ + ${1}\n\ + \n\ +snippet div\n\ +
    \n\ + ${1}\n\ +
    \n\ +snippet div.\n\ +
    \n\ + ${2}\n\ +
    \n\ +snippet div#\n\ +
    \n\ + ${2}\n\ +
    \n\ +snippet dl\n\ +
    \n\ + ${1}\n\ +
    \n\ +snippet dl.\n\ +
    \n\ + ${2}\n\ +
    \n\ +snippet dl#\n\ +
    \n\ + ${2}\n\ +
    \n\ +snippet dl+\n\ +
    \n\ +
    ${1}
    \n\ +
    ${2}
    \n\ + dt+${3}\n\ +
    \n\ +snippet dt\n\ +
    ${1}
    \n\ +snippet dt.\n\ +
    ${2}
    \n\ +snippet dt#\n\ +
    ${2}
    \n\ +snippet dt+\n\ +
    ${1}
    \n\ +
    ${2}
    \n\ + dt+${3}\n\ +snippet em\n\ + ${1}\n\ +snippet embed\n\ + \n\ +snippet fieldset\n\ +
    \n\ + ${1}\n\ +
    \n\ +snippet fieldset.\n\ +
    \n\ + ${2}\n\ +
    \n\ +snippet fieldset#\n\ +
    \n\ + ${2}\n\ +
    \n\ +snippet fieldset+\n\ +
    \n\ + ${1}\n\ + ${2}\n\ +
    \n\ + fieldset+${3}\n\ +snippet figcaption\n\ +
    ${1}
    \n\ +snippet figure\n\ +
    ${1}
    \n\ +snippet footer\n\ +
    \n\ + ${1}\n\ +
    \n\ +snippet footer.\n\ +
    \n\ + ${2}\n\ +
    \n\ +snippet footer#\n\ +
    \n\ + ${2}\n\ +
    \n\ +snippet form\n\ +
    \n\ + ${3}\n\ +
    \n\ +snippet form.\n\ +
    \n\ + ${4}\n\ +
    \n\ +snippet form#\n\ +
    \n\ + ${4}\n\ +
    \n\ +snippet h1\n\ +

    ${1}

    \n\ +snippet h1.\n\ +

    ${2}

    \n\ +snippet h1#\n\ +

    ${2}

    \n\ +snippet h2\n\ +

    ${1}

    \n\ +snippet h2.\n\ +

    ${2}

    \n\ +snippet h2#\n\ +

    ${2}

    \n\ +snippet h3\n\ +

    ${1}

    \n\ +snippet h3.\n\ +

    ${2}

    \n\ +snippet h3#\n\ +

    ${2}

    \n\ +snippet h4\n\ +

    ${1}

    \n\ +snippet h4.\n\ +

    ${2}

    \n\ +snippet h4#\n\ +

    ${2}

    \n\ +snippet h5\n\ +
    ${1}
    \n\ +snippet h5.\n\ +
    ${2}
    \n\ +snippet h5#\n\ +
    ${2}
    \n\ +snippet h6\n\ +
    ${1}
    \n\ +snippet h6.\n\ +
    ${2}
    \n\ +snippet h6#\n\ +
    ${2}
    \n\ +snippet head\n\ + \n\ + \n\ +\n\ + ${1:`substitute(Filename('', 'Page Title'), '^.', '\\u&', '')`}\n\ + ${2}\n\ + \n\ +snippet header\n\ +
    \n\ + ${1}\n\ +
    \n\ +snippet header.\n\ +
    \n\ + ${2}\n\ +
    \n\ +snippet header#\n\ +
    \n\ + ${2}\n\ +
    \n\ +snippet hgroup\n\ +
    \n\ + ${1}\n\ +
    \n\ +snippet hgroup.\n\ +
    \n\ + ${2}\n\ +
    \n\ +snippet hr\n\ +
    ${1}\n\ +snippet html\n\ + \n\ + ${1}\n\ + \n\ +snippet xhtml\n\ + \n\ + ${1}\n\ + \n\ +snippet html5\n\ + \n\ + \n\ + \n\ + \n\ + ${1:`substitute(Filename('', 'Page Title'), '^.', '\\u&', '')`}\n\ + ${2:meta}\n\ + \n\ + \n\ + ${3:body}\n\ + \n\ + \n\ +snippet i\n\ + ${1}\n\ +snippet iframe\n\ + ${2}\n\ +snippet iframe.\n\ + ${3}\n\ +snippet iframe#\n\ + ${3}\n\ +snippet img\n\ + \"${2}\"${3}\n\ +snippet img.\n\ + \"${3}\"${4}\n\ +snippet img#\n\ + \"${3}\"${4}\n\ +snippet input\n\ + ${5}\n\ +snippet input.\n\ + ${6}\n\ +snippet input:text\n\ + ${4}\n\ +snippet input:submit\n\ + ${4}\n\ +snippet input:hidden\n\ + ${4}\n\ +snippet input:button\n\ + ${4}\n\ +snippet input:image\n\ + ${5}\n\ +snippet input:checkbox\n\ + ${3}\n\ +snippet input:radio\n\ + ${3}\n\ +snippet input:color\n\ + ${4}\n\ +snippet input:date\n\ + ${4}\n\ +snippet input:datetime\n\ + ${4}\n\ +snippet input:datetime-local\n\ + ${4}\n\ +snippet input:email\n\ + ${4}\n\ +snippet input:file\n\ + ${4}\n\ +snippet input:month\n\ + ${4}\n\ +snippet input:number\n\ + ${4}\n\ +snippet input:password\n\ + ${4}\n\ +snippet input:range\n\ + ${4}\n\ +snippet input:reset\n\ + ${4}\n\ +snippet input:search\n\ + ${4}\n\ +snippet input:time\n\ + ${4}\n\ +snippet input:url\n\ + ${4}\n\ +snippet input:week\n\ + ${4}\n\ +snippet ins\n\ + ${1}\n\ +snippet kbd\n\ + ${1}\n\ +snippet keygen\n\ + ${1}\n\ +snippet label\n\ + \n\ +snippet label:i\n\ + \n\ + ${7}\n\ +snippet label:s\n\ + \n\ + \n\ +snippet legend\n\ + ${1}\n\ +snippet legend+\n\ + ${1}\n\ +snippet li\n\ +
  • ${1}
  • \n\ +snippet li.\n\ +
  • ${2}
  • \n\ +snippet li+\n\ +
  • ${1}
  • \n\ + li+${2}\n\ +snippet lia\n\ +
  • ${1}
  • \n\ +snippet lia+\n\ +
  • ${1}
  • \n\ + lia+${3}\n\ +snippet link\n\ + ${5}\n\ +snippet link:atom\n\ + ${2}\n\ +snippet link:css\n\ + ${4}\n\ +snippet link:favicon\n\ + ${2}\n\ +snippet link:rss\n\ + ${2}\n\ +snippet link:touch\n\ + ${2}\n\ +snippet map\n\ + \n\ + ${2}\n\ + \n\ +snippet map.\n\ + \n\ + ${3}\n\ + \n\ +snippet map#\n\ + \n\ + ${3}\n\ + \n\ +snippet map+\n\ + \n\ + \"${5}\"${6}\n\ + ${7}\n\ +snippet mark\n\ + ${1}\n\ +snippet menu\n\ + \n\ + ${1}\n\ + \n\ +snippet menu:c\n\ + \n\ + ${1}\n\ + \n\ +snippet menu:t\n\ + \n\ + ${1}\n\ + \n\ +snippet meta\n\ + ${3}\n\ +snippet meta:compat\n\ + ${3}\n\ +snippet meta:refresh\n\ + ${3}\n\ +snippet meta:utf\n\ + ${3}\n\ +snippet meter\n\ + ${1}\n\ +snippet nav\n\ + \n\ +snippet nav.\n\ + \n\ +snippet nav#\n\ + \n\ +snippet noscript\n\ + \n\ +snippet object\n\ + \n\ + ${3}\n\ + ${4}\n\ +# Embed QT Movie\n\ +snippet movie\n\ + \n\ + \n\ + \n\ + \n\ + \n\ + ${6}\n\ +snippet ol\n\ +
      \n\ + ${1}\n\ +
    \n\ +snippet ol.\n\ +
      \n\ + ${2}\n\ +
    \n\ +snippet ol#\n\ +
      \n\ + ${2}\n\ +
    \n\ +snippet ol+\n\ +
      \n\ +
    1. ${1}
    2. \n\ + li+${2}\n\ +
    \n\ +snippet opt\n\ + \n\ +snippet opt+\n\ + \n\ + opt+${3}\n\ +snippet optt\n\ + \n\ +snippet optgroup\n\ + \n\ + \n\ + opt+${3}\n\ + \n\ +snippet output\n\ + ${1}\n\ +snippet p\n\ +

    ${1}

    \n\ +snippet param\n\ + ${3}\n\ +snippet pre\n\ +
    \n\
    +		${1}\n\
    +	
    \n\ +snippet progress\n\ + ${1}\n\ +snippet q\n\ + ${1}\n\ +snippet rp\n\ + ${1}\n\ +snippet rt\n\ + ${1}\n\ +snippet ruby\n\ + \n\ + ${1}\n\ + \n\ +snippet s\n\ + ${1}\n\ +snippet samp\n\ + \n\ + ${1}\n\ + \n\ +snippet script\n\ + \n\ +snippet scriptsrc\n\ + \n\ +snippet section\n\ +
    \n\ + ${1}\n\ +
    \n\ +snippet section.\n\ +
    \n\ + ${2}\n\ +
    \n\ +snippet section#\n\ +
    \n\ + ${2}\n\ +
    \n\ +snippet select\n\ + \n\ +snippet select.\n\ + \n\ +snippet select+\n\ + \n\ +snippet small\n\ + ${1}\n\ +snippet source\n\ + \n\ +snippet span\n\ + ${1}\n\ +snippet strong\n\ + ${1}\n\ +snippet style\n\ + \n\ +snippet sub\n\ + ${1}\n\ +snippet summary\n\ + \n\ + ${1}\n\ + \n\ +snippet sup\n\ + ${1}\n\ +snippet table\n\ + \n\ + ${2}\n\ +
    \n\ +snippet table.\n\ + \n\ + ${3}\n\ +
    \n\ +snippet table#\n\ + \n\ + ${3}\n\ +
    \n\ +snippet tbody\n\ + \n\ + ${1}\n\ + \n\ +snippet td\n\ + ${1}\n\ +snippet td.\n\ + ${2}\n\ +snippet td#\n\ + ${2}\n\ +snippet td+\n\ + ${1}\n\ + td+${2}\n\ +snippet textarea\n\ + ${6}\n\ +snippet tfoot\n\ + \n\ + ${1}\n\ + \n\ +snippet th\n\ + ${1}\n\ +snippet th.\n\ + ${2}\n\ +snippet th#\n\ + ${2}\n\ +snippet th+\n\ + ${1}\n\ + th+${2}\n\ +snippet thead\n\ + \n\ + ${1}\n\ + \n\ +snippet time\n\ + \n\ +snippet title\n\ + ${1:`substitute(Filename('', 'Page Title'), '^.', '\\u&', '')`}\n\ +snippet tr\n\ + \n\ + ${1}\n\ + \n\ +snippet tr+\n\ + \n\ + ${1}\n\ + td+${2}\n\ + \n\ +snippet track\n\ + ${5}${6}\n\ +snippet ul\n\ +
      \n\ + ${1}\n\ +
    \n\ +snippet ul.\n\ +
      \n\ + ${2}\n\ +
    \n\ +snippet ul#\n\ +
      \n\ + ${2}\n\ +
    \n\ +snippet ul+\n\ +
      \n\ +
    • ${1}
    • \n\ + li+${2}\n\ +
    \n\ +snippet var\n\ + ${1}\n\ +snippet video\n\ + ${8}\n\ +snippet wbr\n\ + ${1}\n\ +"; +exports.scope = "html"; + +}); diff --git a/lib/client/edit/snippets/html_completions.js b/lib/client/edit/snippets/html_completions.js new file mode 100644 index 00000000..25c308a4 --- /dev/null +++ b/lib/client/edit/snippets/html_completions.js @@ -0,0 +1,7 @@ +ace.define('ace/snippets/html_completions', ['require', 'exports', 'module' ], function(require, exports, module) { + + +exports.snippetText = ""; +exports.scope = "html_completions"; + +}); diff --git a/lib/client/edit/snippets/html_ruby.js b/lib/client/edit/snippets/html_ruby.js new file mode 100644 index 00000000..8e0e7539 --- /dev/null +++ b/lib/client/edit/snippets/html_ruby.js @@ -0,0 +1,7 @@ +ace.define('ace/snippets/html_ruby', ['require', 'exports', 'module' ], function(require, exports, module) { + + +exports.snippetText = ""; +exports.scope = "html_ruby"; + +}); diff --git a/lib/client/edit/snippets/ini.js b/lib/client/edit/snippets/ini.js new file mode 100644 index 00000000..dea4a945 --- /dev/null +++ b/lib/client/edit/snippets/ini.js @@ -0,0 +1,7 @@ +ace.define('ace/snippets/ini', ['require', 'exports', 'module' ], function(require, exports, module) { + + +exports.snippetText = ""; +exports.scope = "ini"; + +}); diff --git a/lib/client/edit/snippets/jade.js b/lib/client/edit/snippets/jade.js new file mode 100644 index 00000000..964ddf4f --- /dev/null +++ b/lib/client/edit/snippets/jade.js @@ -0,0 +1,7 @@ +ace.define('ace/snippets/jade', ['require', 'exports', 'module' ], function(require, exports, module) { + + +exports.snippetText = ""; +exports.scope = "jade"; + +}); diff --git a/lib/client/edit/snippets/java.js b/lib/client/edit/snippets/java.js new file mode 100644 index 00000000..c3972050 --- /dev/null +++ b/lib/client/edit/snippets/java.js @@ -0,0 +1,247 @@ +ace.define('ace/snippets/java', ['require', 'exports', 'module' ], function(require, exports, module) { + + +exports.snippetText = "## Access Modifiers\n\ +snippet po\n\ + protected\n\ +snippet pu\n\ + public\n\ +snippet pr\n\ + private\n\ +##\n\ +## Annotations\n\ +snippet before\n\ + @Before\n\ + static void ${1:intercept}(${2:args}) { ${3} }\n\ +snippet mm\n\ + @ManyToMany\n\ + ${1}\n\ +snippet mo\n\ + @ManyToOne\n\ + ${1}\n\ +snippet om\n\ + @OneToMany${1:(cascade=CascadeType.ALL)}\n\ + ${2}\n\ +snippet oo\n\ + @OneToOne\n\ + ${1}\n\ +##\n\ +## Basic Java packages and import\n\ +snippet im\n\ + import\n\ +snippet j.b\n\ + java.beans.\n\ +snippet j.i\n\ + java.io.\n\ +snippet j.m\n\ + java.math.\n\ +snippet j.n\n\ + java.net.\n\ +snippet j.u\n\ + java.util.\n\ +##\n\ +## Class\n\ +snippet cl\n\ + class ${1:`Filename(\"\", \"untitled\")`} ${2}\n\ +snippet in\n\ + interface ${1:`Filename(\"\", \"untitled\")`} ${2:extends Parent}${3}\n\ +snippet tc\n\ + public class ${1:`Filename()`} extends ${2:TestCase}\n\ +##\n\ +## Class Enhancements\n\ +snippet ext\n\ + extends \n\ +snippet imp\n\ + implements\n\ +##\n\ +## Comments\n\ +snippet /*\n\ + /*\n\ + * ${1}\n\ + */\n\ +##\n\ +## Constants\n\ +snippet co\n\ + static public final ${1:String} ${2:var} = ${3};${4}\n\ +snippet cos\n\ + static public final String ${1:var} = \"${2}\";${3}\n\ +##\n\ +## Control Statements\n\ +snippet case\n\ + case ${1}:\n\ + ${2}\n\ +snippet def\n\ + default:\n\ + ${2}\n\ +snippet el\n\ + else\n\ +snippet elif\n\ + else if (${1}) ${2}\n\ +snippet if\n\ + if (${1}) ${2}\n\ +snippet sw\n\ + switch (${1}) {\n\ + ${2}\n\ + }\n\ +##\n\ +## Create a Method\n\ +snippet m\n\ + ${1:void} ${2:method}(${3}) ${4:throws }${5}\n\ +##\n\ +## Create a Variable\n\ +snippet v\n\ + ${1:String} ${2:var}${3: = null}${4};${5}\n\ +##\n\ +## Enhancements to Methods, variables, classes, etc.\n\ +snippet ab\n\ + abstract\n\ +snippet fi\n\ + final\n\ +snippet st\n\ + static\n\ +snippet sy\n\ + synchronized\n\ +##\n\ +## Error Methods\n\ +snippet err\n\ + System.err.print(\"${1:Message}\");\n\ +snippet errf\n\ + System.err.printf(\"${1:Message}\", ${2:exception});\n\ +snippet errln\n\ + System.err.println(\"${1:Message}\");\n\ +##\n\ +## Exception Handling\n\ +snippet as\n\ + assert ${1:test} : \"${2:Failure message}\";${3}\n\ +snippet ca\n\ + catch(${1:Exception} ${2:e}) ${3}\n\ +snippet thr\n\ + throw\n\ +snippet ths\n\ + throws\n\ +snippet try\n\ + try {\n\ + ${3}\n\ + } catch(${1:Exception} ${2:e}) {\n\ + }\n\ +snippet tryf\n\ + try {\n\ + ${3}\n\ + } catch(${1:Exception} ${2:e}) {\n\ + } finally {\n\ + }\n\ +##\n\ +## Find Methods\n\ +snippet findall\n\ + List<${1:listName}> ${2:items} = ${1}.findAll();${3}\n\ +snippet findbyid\n\ + ${1:var} ${2:item} = ${1}.findById(${3});${4}\n\ +##\n\ +## Javadocs\n\ +snippet /**\n\ + /**\n\ + * ${1}\n\ + */\n\ +snippet @au\n\ + @author `system(\"grep \\`id -un\\` /etc/passwd | cut -d \\\":\\\" -f5 | cut -d \\\",\\\" -f1\")`\n\ +snippet @br\n\ + @brief ${1:Description}\n\ +snippet @fi\n\ + @file ${1:`Filename()`}.java\n\ +snippet @pa\n\ + @param ${1:param}\n\ +snippet @re\n\ + @return ${1:param}\n\ +##\n\ +## Logger Methods\n\ +snippet debug\n\ + Logger.debug(${1:param});${2}\n\ +snippet error\n\ + Logger.error(${1:param});${2}\n\ +snippet info\n\ + Logger.info(${1:param});${2}\n\ +snippet warn\n\ + Logger.warn(${1:param});${2}\n\ +##\n\ +## Loops\n\ +snippet enfor\n\ + for (${1} : ${2}) ${3}\n\ +snippet for\n\ + for (${1}; ${2}; ${3}) ${4}\n\ +snippet wh\n\ + while (${1}) ${2}\n\ +##\n\ +## Main method\n\ +snippet main\n\ + public static void main (String[] args) {\n\ + ${1:/* code */}\n\ + }\n\ +##\n\ +## Print Methods\n\ +snippet print\n\ + System.out.print(\"${1:Message}\");\n\ +snippet printf\n\ + System.out.printf(\"${1:Message}\", ${2:args});\n\ +snippet println\n\ + System.out.println(${1});\n\ +##\n\ +## Render Methods\n\ +snippet ren\n\ + render(${1:param});${2}\n\ +snippet rena\n\ + renderArgs.put(\"${1}\", ${2});${3}\n\ +snippet renb\n\ + renderBinary(${1:param});${2}\n\ +snippet renj\n\ + renderJSON(${1:param});${2}\n\ +snippet renx\n\ + renderXml(${1:param});${2}\n\ +##\n\ +## Setter and Getter Methods\n\ +snippet set\n\ + ${1:public} void set${3:}(${2:String} ${4:}){\n\ + this.$4 = $4;\n\ + }\n\ +snippet get\n\ + ${1:public} ${2:String} get${3:}(){\n\ + return this.${4:};\n\ + }\n\ +##\n\ +## Terminate Methods or Loops\n\ +snippet re\n\ + return\n\ +snippet br\n\ + break;\n\ +##\n\ +## Test Methods\n\ +snippet t\n\ + public void test${1:Name}() throws Exception {\n\ + ${2}\n\ + }\n\ +snippet test\n\ + @Test\n\ + public void test${1:Name}() throws Exception {\n\ + ${2}\n\ + }\n\ +##\n\ +## Utils\n\ +snippet Sc\n\ + Scanner\n\ +##\n\ +## Miscellaneous\n\ +snippet action\n\ + public static void ${1:index}(${2:args}) { ${3} }\n\ +snippet rnf\n\ + notFound(${1:param});${2}\n\ +snippet rnfin\n\ + notFoundIfNull(${1:param});${2}\n\ +snippet rr\n\ + redirect(${1:param});${2}\n\ +snippet ru\n\ + unauthorized(${1:param});${2}\n\ +snippet unless\n\ + (unless=${1:param});${2}\n\ +"; +exports.scope = "java"; + +}); diff --git a/lib/client/edit/snippets/javascript.js b/lib/client/edit/snippets/javascript.js index c8845fbe..a1b33e1a 100644 --- a/lib/client/edit/snippets/javascript.js +++ b/lib/client/edit/snippets/javascript.js @@ -13,7 +13,7 @@ snippet fun\n\ }\n\ # Anonymous Function\n\ regex /((=)\\s*|(:)\\s*|(\\()|\\b)/f/(\\))?/\n\ -name f\n\ +snippet f\n\ function${M1?: ${1:functionName}}($2) {\n\ ${0:$TM_SELECTED_TEXT}\n\ }${M2?;}${M3?,}${M4?)}\n\ @@ -152,7 +152,7 @@ snippet sing\n\ return instance;\n\ }\n\ # class\n\ -name class\n\ +snippet class\n\ regex /^\\s*/clas{0,2}/\n\ var ${1:class} = function(${20}) {\n\ $40$0\n\ diff --git a/lib/client/edit/snippets/json.js b/lib/client/edit/snippets/json.js new file mode 100644 index 00000000..838cfe3e --- /dev/null +++ b/lib/client/edit/snippets/json.js @@ -0,0 +1,7 @@ +ace.define('ace/snippets/json', ['require', 'exports', 'module' ], function(require, exports, module) { + + +exports.snippetText = ""; +exports.scope = "json"; + +}); diff --git a/lib/client/edit/snippets/jsoniq.js b/lib/client/edit/snippets/jsoniq.js new file mode 100644 index 00000000..533a361f --- /dev/null +++ b/lib/client/edit/snippets/jsoniq.js @@ -0,0 +1,7 @@ +ace.define('ace/snippets/jsoniq', ['require', 'exports', 'module' ], function(require, exports, module) { + + +exports.snippetText = ""; +exports.scope = "jsoniq"; + +}); diff --git a/lib/client/edit/snippets/jsp.js b/lib/client/edit/snippets/jsp.js new file mode 100644 index 00000000..a3989e44 --- /dev/null +++ b/lib/client/edit/snippets/jsp.js @@ -0,0 +1,106 @@ +ace.define('ace/snippets/jsp', ['require', 'exports', 'module' ], function(require, exports, module) { + + +exports.snippetText = "snippet @page\n\ + <%@page contentType=\"text/html\" pageEncoding=\"UTF-8\"%>\n\ +snippet jstl\n\ + <%@ taglib uri=\"http://java.sun.com/jsp/jstl/core\" prefix=\"c\" %>\n\ + <%@ taglib uri=\"http://java.sun.com/jsp/jstl/functions\" prefix=\"fn\" %>\n\ +snippet jstl:c\n\ + <%@ taglib uri=\"http://java.sun.com/jsp/jstl/core\" prefix=\"c\" %>\n\ +snippet jstl:fn\n\ + <%@ taglib uri=\"http://java.sun.com/jsp/jstl/functions\" prefix=\"fn\" %>\n\ +snippet cpath\n\ + ${pageContext.request.contextPath}\n\ +snippet cout\n\ + \n\ +snippet cset\n\ + \n\ +snippet cremove\n\ + \n\ +snippet ccatch\n\ + \n\ +snippet cif\n\ + \n\ + ${2}\n\ + \n\ +snippet cchoose\n\ + \n\ + ${1}\n\ + \n\ +snippet cwhen\n\ + \n\ + ${2}\n\ + \n\ +snippet cother\n\ + \n\ + ${1}\n\ + \n\ +snippet cfore\n\ + \n\ + ${4:}\n\ + \n\ +snippet cfort\n\ + ${2:item1,item2,item3}\n\ + \n\ + ${5:}\n\ + \n\ +snippet cparam\n\ + \n\ +snippet cparam+\n\ + \n\ + cparam+${3}\n\ +snippet cimport\n\ + \n\ +snippet cimport+\n\ + \n\ + \n\ + cparam+${4}\n\ + \n\ +snippet curl\n\ + \n\ + ${3}\n\ +snippet curl+\n\ + \n\ + \n\ + cparam+${6}\n\ + \n\ + ${3}\n\ +snippet credirect\n\ + \n\ +snippet contains\n\ + ${fn:contains(${1:string}, ${2:substr})}\n\ +snippet contains:i\n\ + ${fn:containsIgnoreCase(${1:string}, ${2:substr})}\n\ +snippet endswith\n\ + ${fn:endsWith(${1:string}, ${2:suffix})}\n\ +snippet escape\n\ + ${fn:escapeXml(${1:string})}\n\ +snippet indexof\n\ + ${fn:indexOf(${1:string}, ${2:substr})}\n\ +snippet join\n\ + ${fn:join(${1:collection}, ${2:delims})}\n\ +snippet length\n\ + ${fn:length(${1:collection_or_string})}\n\ +snippet replace\n\ + ${fn:replace(${1:string}, ${2:substr}, ${3:replace})}\n\ +snippet split\n\ + ${fn:split(${1:string}, ${2:delims})}\n\ +snippet startswith\n\ + ${fn:startsWith(${1:string}, ${2:prefix})}\n\ +snippet substr\n\ + ${fn:substring(${1:string}, ${2:begin}, ${3:end})}\n\ +snippet substr:a\n\ + ${fn:substringAfter(${1:string}, ${2:substr})}\n\ +snippet substr:b\n\ + ${fn:substringBefore(${1:string}, ${2:substr})}\n\ +snippet lc\n\ + ${fn:toLowerCase(${1:string})}\n\ +snippet uc\n\ + ${fn:toUpperCase(${1:string})}\n\ +snippet trim\n\ + ${fn:trim(${1:string})}\n\ +"; +exports.scope = "jsp"; + +}); diff --git a/lib/client/edit/snippets/less.js b/lib/client/edit/snippets/less.js new file mode 100644 index 00000000..d781e4f2 --- /dev/null +++ b/lib/client/edit/snippets/less.js @@ -0,0 +1,7 @@ +ace.define('ace/snippets/less', ['require', 'exports', 'module' ], function(require, exports, module) { + + +exports.snippetText = ""; +exports.scope = "less"; + +}); diff --git a/lib/client/edit/snippets/livescript.js b/lib/client/edit/snippets/livescript.js new file mode 100644 index 00000000..3aee2ef0 --- /dev/null +++ b/lib/client/edit/snippets/livescript.js @@ -0,0 +1,7 @@ +ace.define('ace/snippets/livescript', ['require', 'exports', 'module' ], function(require, exports, module) { + + +exports.snippetText = ""; +exports.scope = "livescript"; + +}); diff --git a/lib/client/edit/snippets/makefile.js b/lib/client/edit/snippets/makefile.js new file mode 100644 index 00000000..3e6215bd --- /dev/null +++ b/lib/client/edit/snippets/makefile.js @@ -0,0 +1,11 @@ +ace.define('ace/snippets/makefile', ['require', 'exports', 'module' ], function(require, exports, module) { + + +exports.snippetText = "snippet ifeq\n\ + ifeq (${1:cond0},${2:cond1})\n\ + ${3:code}\n\ + endif\n\ +"; +exports.scope = "makefile"; + +}); diff --git a/lib/client/edit/snippets/markdown.js b/lib/client/edit/snippets/markdown.js new file mode 100644 index 00000000..628cb656 --- /dev/null +++ b/lib/client/edit/snippets/markdown.js @@ -0,0 +1,95 @@ +ace.define('ace/snippets/markdown', ['require', 'exports', 'module' ], function(require, exports, module) { + + +exports.snippetText = "# Markdown\n\ +\n\ +# Includes octopress (http://octopress.org/) snippets\n\ +\n\ +snippet [\n\ + [${1:text}](http://${2:address} \"${3:title}\")\n\ +snippet [*\n\ + [${1:link}](${2:`@*`} \"${3:title}\")${4}\n\ +\n\ +snippet [:\n\ + [${1:id}]: http://${2:url} \"${3:title}\"\n\ +snippet [:*\n\ + [${1:id}]: ${2:`@*`} \"${3:title}\"\n\ +\n\ +snippet ![\n\ + ![${1:alttext}](${2:/images/image.jpg} \"${3:title}\")\n\ +snippet ![*\n\ + ![${1:alt}](${2:`@*`} \"${3:title}\")${4}\n\ +\n\ +snippet ![:\n\ + ![${1:id}]: ${2:url} \"${3:title}\"\n\ +snippet ![:*\n\ + ![${1:id}]: ${2:`@*`} \"${3:title}\"\n\ +\n\ +snippet ===\n\ +regex /^/=+/=*//\n\ + ${PREV_LINE/./=/g}\n\ + \n\ + ${0}\n\ +snippet ---\n\ +regex /^/-+/-*//\n\ + ${PREV_LINE/./-/g}\n\ + \n\ + ${0}\n\ +snippet blockquote\n\ + {% blockquote %}\n\ + ${1:quote}\n\ + {% endblockquote %}\n\ +\n\ +snippet blockquote-author\n\ + {% blockquote ${1:author}, ${2:title} %}\n\ + ${3:quote}\n\ + {% endblockquote %}\n\ +\n\ +snippet blockquote-link\n\ + {% blockquote ${1:author} ${2:URL} ${3:link_text} %}\n\ + ${4:quote}\n\ + {% endblockquote %}\n\ +\n\ +snippet bt-codeblock-short\n\ + ```\n\ + ${1:code_snippet}\n\ + ```\n\ +\n\ +snippet bt-codeblock-full\n\ + ``` ${1:language} ${2:title} ${3:URL} ${4:link_text}\n\ + ${5:code_snippet}\n\ + ```\n\ +\n\ +snippet codeblock-short\n\ + {% codeblock %}\n\ + ${1:code_snippet}\n\ + {% endcodeblock %}\n\ +\n\ +snippet codeblock-full\n\ + {% codeblock ${1:title} lang:${2:language} ${3:URL} ${4:link_text} %}\n\ + ${5:code_snippet}\n\ + {% endcodeblock %}\n\ +\n\ +snippet gist-full\n\ + {% gist ${1:gist_id} ${2:filename} %}\n\ +\n\ +snippet gist-short\n\ + {% gist ${1:gist_id} %}\n\ +\n\ +snippet img\n\ + {% img ${1:class} ${2:URL} ${3:width} ${4:height} ${5:title_text} ${6:alt_text} %}\n\ +\n\ +snippet youtube\n\ + {% youtube ${1:video_id} %}\n\ +\n\ +# The quote should appear only once in the text. It is inherently part of it.\n\ +# See http://octopress.org/docs/plugins/pullquote/ for more info.\n\ +\n\ +snippet pullquote\n\ + {% pullquote %}\n\ + ${1:text} {\" ${2:quote} \"} ${3:text}\n\ + {% endpullquote %}\n\ +"; +exports.scope = "markdown"; + +}); diff --git a/lib/client/edit/snippets/matlab.js b/lib/client/edit/snippets/matlab.js new file mode 100644 index 00000000..8e4a4037 --- /dev/null +++ b/lib/client/edit/snippets/matlab.js @@ -0,0 +1,7 @@ +ace.define('ace/snippets/matlab', ['require', 'exports', 'module' ], function(require, exports, module) { + + +exports.snippetText = ""; +exports.scope = "matlab"; + +}); diff --git a/lib/client/edit/snippets/mysql.js b/lib/client/edit/snippets/mysql.js new file mode 100644 index 00000000..3a49569e --- /dev/null +++ b/lib/client/edit/snippets/mysql.js @@ -0,0 +1,7 @@ +ace.define('ace/snippets/mysql', ['require', 'exports', 'module' ], function(require, exports, module) { + + +exports.snippetText = ""; +exports.scope = "mysql"; + +}); diff --git a/lib/client/edit/snippets/nix.js b/lib/client/edit/snippets/nix.js new file mode 100644 index 00000000..fc4a18f3 --- /dev/null +++ b/lib/client/edit/snippets/nix.js @@ -0,0 +1,7 @@ +ace.define('ace/snippets/nix', ['require', 'exports', 'module' ], function(require, exports, module) { + + +exports.snippetText = ""; +exports.scope = "nix"; + +}); diff --git a/lib/client/edit/snippets/objectivec.js b/lib/client/edit/snippets/objectivec.js new file mode 100644 index 00000000..a74db180 --- /dev/null +++ b/lib/client/edit/snippets/objectivec.js @@ -0,0 +1,7 @@ +ace.define('ace/snippets/objectivec', ['require', 'exports', 'module' ], function(require, exports, module) { + + +exports.snippetText = ""; +exports.scope = "objectivec"; + +}); diff --git a/lib/client/edit/snippets/pascal.js b/lib/client/edit/snippets/pascal.js new file mode 100644 index 00000000..5b4721c7 --- /dev/null +++ b/lib/client/edit/snippets/pascal.js @@ -0,0 +1,7 @@ +ace.define('ace/snippets/pascal', ['require', 'exports', 'module' ], function(require, exports, module) { + + +exports.snippetText = ""; +exports.scope = "pascal"; + +}); diff --git a/lib/client/edit/snippets/perl.js b/lib/client/edit/snippets/perl.js new file mode 100644 index 00000000..16f2d3f7 --- /dev/null +++ b/lib/client/edit/snippets/perl.js @@ -0,0 +1,354 @@ +ace.define('ace/snippets/perl', ['require', 'exports', 'module' ], function(require, exports, module) { + + +exports.snippetText = "# #!/usr/bin/perl\n\ +snippet #!\n\ + #!/usr/bin/env perl\n\ +\n\ +# Hash Pointer\n\ +snippet .\n\ + =>\n\ +# Function\n\ +snippet sub\n\ + sub ${1:function_name} {\n\ + ${2:#body ...}\n\ + }\n\ +# Conditional\n\ +snippet if\n\ + if (${1}) {\n\ + ${2:# body...}\n\ + }\n\ +# Conditional if..else\n\ +snippet ife\n\ + if (${1}) {\n\ + ${2:# body...}\n\ + }\n\ + else {\n\ + ${3:# else...}\n\ + }\n\ +# Conditional if..elsif..else\n\ +snippet ifee\n\ + if (${1}) {\n\ + ${2:# body...}\n\ + }\n\ + elsif (${3}) {\n\ + ${4:# elsif...}\n\ + }\n\ + else {\n\ + ${5:# else...}\n\ + }\n\ +# Conditional One-line\n\ +snippet xif\n\ + ${1:expression} if ${2:condition};${3}\n\ +# Unless conditional\n\ +snippet unless\n\ + unless (${1}) {\n\ + ${2:# body...}\n\ + }\n\ +# Unless conditional One-line\n\ +snippet xunless\n\ + ${1:expression} unless ${2:condition};${3}\n\ +# Try/Except\n\ +snippet eval\n\ + local $@;\n\ + eval {\n\ + ${1:# do something risky...}\n\ + };\n\ + if (my $e = $@) {\n\ + ${2:# handle failure...}\n\ + }\n\ +# While Loop\n\ +snippet wh\n\ + while (${1}) {\n\ + ${2:# body...}\n\ + }\n\ +# While Loop One-line\n\ +snippet xwh\n\ + ${1:expression} while ${2:condition};${3}\n\ +# C-style For Loop\n\ +snippet cfor\n\ + for (my $${2:var} = 0; $$2 < ${1:count}; $$2${3:++}) {\n\ + ${4:# body...}\n\ + }\n\ +# For loop one-line\n\ +snippet xfor\n\ + ${1:expression} for @${2:array};${3}\n\ +# Foreach Loop\n\ +snippet for\n\ + foreach my $${1:x} (@${2:array}) {\n\ + ${3:# body...}\n\ + }\n\ +# Foreach Loop One-line\n\ +snippet fore\n\ + ${1:expression} foreach @${2:array};${3}\n\ +# Package\n\ +snippet package\n\ + package ${1:`substitute(Filename('', 'Page Title'), '^.', '\\u&', '')`};\n\ +\n\ + ${2}\n\ +\n\ + 1;\n\ +\n\ + __END__\n\ +# Package syntax perl >= 5.14\n\ +snippet packagev514\n\ + package ${1:`substitute(Filename('', 'Page Title'), '^.', '\\u&', '')`} ${2:0.99};\n\ +\n\ + ${3}\n\ +\n\ + 1;\n\ +\n\ + __END__\n\ +#moose\n\ +snippet moose\n\ + use Moose;\n\ + use namespace::autoclean;\n\ + ${1:#}BEGIN {extends '${2:ParentClass}'};\n\ +\n\ + ${3}\n\ +# parent\n\ +snippet parent\n\ + use parent qw(${1:Parent Class});\n\ +# Read File\n\ +snippet slurp\n\ + my $${1:var} = do { local $/; open my $file, '<', \"${2:file}\"; <$file> };\n\ + ${3}\n\ +# strict warnings\n\ +snippet strwar\n\ + use strict;\n\ + use warnings;\n\ +# older versioning with perlcritic bypass\n\ +snippet vers\n\ + ## no critic\n\ + our $VERSION = '${1:version}';\n\ + eval $VERSION;\n\ + ## use critic\n\ +# new 'switch' like feature\n\ +snippet switch\n\ + use feature 'switch';\n\ +\n\ +# Anonymous subroutine\n\ +snippet asub\n\ + sub {\n\ + ${1:# body }\n\ + }\n\ +\n\ +\n\ +\n\ +# Begin block\n\ +snippet begin\n\ + BEGIN {\n\ + ${1:# begin body}\n\ + }\n\ +\n\ +# call package function with some parameter\n\ +snippet pkgmv\n\ + __PACKAGE__->${1:package_method}(${2:var})\n\ +\n\ +# call package function without a parameter\n\ +snippet pkgm\n\ + __PACKAGE__->${1:package_method}()\n\ +\n\ +# call package \"get_\" function without a parameter\n\ +snippet pkget\n\ + __PACKAGE__->get_${1:package_method}()\n\ +\n\ +# call package function with a parameter\n\ +snippet pkgetv\n\ + __PACKAGE__->get_${1:package_method}(${2:var})\n\ +\n\ +# complex regex\n\ +snippet qrx\n\ + qr/\n\ + ${1:regex}\n\ + /xms\n\ +\n\ +#simpler regex\n\ +snippet qr/\n\ + qr/${1:regex}/x\n\ +\n\ +#given\n\ +snippet given\n\ + given ($${1:var}) {\n\ + ${2:# cases}\n\ + ${3:# default}\n\ + }\n\ +\n\ +# switch-like case\n\ +snippet when\n\ + when (${1:case}) {\n\ + ${2:# body}\n\ + }\n\ +\n\ +# hash slice\n\ +snippet hslice\n\ + @{ ${1:hash} }{ ${2:array} }\n\ +\n\ +\n\ +# map\n\ +snippet map\n\ + map { ${2: body } } ${1: @array } ;\n\ +\n\ +\n\ +\n\ +# Pod stub\n\ +snippet ppod\n\ + =head1 NAME\n\ +\n\ + ${1:ClassName} - ${2:ShortDesc}\n\ +\n\ + =head1 SYNOPSIS\n\ +\n\ + use $1;\n\ +\n\ + ${3:# synopsis...}\n\ +\n\ + =head1 DESCRIPTION\n\ +\n\ + ${4:# longer description...}\n\ +\n\ +\n\ + =head1 INTERFACE\n\ +\n\ +\n\ + =head1 DEPENDENCIES\n\ +\n\ +\n\ + =head1 SEE ALSO\n\ +\n\ +\n\ +# Heading for a subroutine stub\n\ +snippet psub\n\ + =head2 ${1:MethodName}\n\ +\n\ + ${2:Summary....}\n\ +\n\ +# Heading for inline subroutine pod\n\ +snippet psubi\n\ + =head2 ${1:MethodName}\n\ +\n\ + ${2:Summary...}\n\ +\n\ +\n\ + =cut\n\ +# inline documented subroutine\n\ +snippet subpod\n\ + =head2 $1\n\ +\n\ + Summary of $1\n\ +\n\ + =cut\n\ +\n\ + sub ${1:subroutine_name} {\n\ + ${2:# body...}\n\ + }\n\ +# Subroutine signature\n\ +snippet parg\n\ + =over 2\n\ +\n\ + =item\n\ + Arguments\n\ +\n\ +\n\ + =over 3\n\ +\n\ + =item\n\ + C<${1:DataStructure}>\n\ +\n\ + ${2:Sample}\n\ +\n\ +\n\ + =back\n\ +\n\ +\n\ + =item\n\ + Return\n\ +\n\ + =over 3\n\ +\n\ +\n\ + =item\n\ + C<${3:...return data}>\n\ +\n\ +\n\ + =back\n\ +\n\ +\n\ + =back\n\ +\n\ +\n\ +\n\ +# Moose has\n\ +snippet has\n\ + has ${1:attribute} => (\n\ + is => '${2:ro|rw}',\n\ + isa => '${3:Str|Int|HashRef|ArrayRef|etc}',\n\ + default => sub {\n\ + ${4:defaultvalue}\n\ + },\n\ + ${5:# other attributes}\n\ + );\n\ +\n\ +\n\ +# override\n\ +snippet override\n\ + override ${1:attribute} => sub {\n\ + ${2:# my $self = shift;};\n\ + ${3:# my ($self, $args) = @_;};\n\ + };\n\ +\n\ +\n\ +# use test classes\n\ +snippet tuse\n\ + use Test::More;\n\ + use Test::Deep; # (); # uncomment to stop prototype errors\n\ + use Test::Exception;\n\ +\n\ +# local test lib\n\ +snippet tlib\n\ + use lib qw{ ./t/lib };\n\ +\n\ +#test methods\n\ +snippet tmeths\n\ + $ENV{TEST_METHOD} = '${1:regex}';\n\ +\n\ +# runtestclass\n\ +snippet trunner\n\ + use ${1:test_class};\n\ + $1->runtests();\n\ +\n\ +# Test::Class-style test\n\ +snippet tsub\n\ + sub t${1:number}_${2:test_case} :Test(${3:num_of_tests}) {\n\ + my $self = shift;\n\ + ${4:# body}\n\ +\n\ + }\n\ +\n\ +# Test::Routine-style test\n\ +snippet trsub\n\ + test ${1:test_name} => { description => '${2:Description of test.}'} => sub {\n\ + my ($self) = @_;\n\ + ${3:# test code}\n\ + };\n\ +\n\ +#prep test method\n\ +snippet tprep\n\ + sub prep${1:number}_${2:test_case} :Test(startup) {\n\ + my $self = shift;\n\ + ${4:# body}\n\ + }\n\ +\n\ +# cause failures to print stack trace\n\ +snippet debug_trace\n\ + use Carp; # 'verbose';\n\ + # cloak \"die\"\n\ + # warn \"warning\"\n\ + $SIG{'__DIE__'} = sub {\n\ + require Carp; Carp::confess\n\ + };\n\ +\n\ +"; +exports.scope = "perl"; + +}); diff --git a/lib/client/edit/snippets/php.js b/lib/client/edit/snippets/php.js new file mode 100644 index 00000000..5a23a1a9 --- /dev/null +++ b/lib/client/edit/snippets/php.js @@ -0,0 +1,384 @@ +ace.define('ace/snippets/php', ['require', 'exports', 'module' ], function(require, exports, module) { + + +exports.snippetText = "snippet \n\ +# this one is for php5.4\n\ +snippet \n\ +snippet ns\n\ + namespace ${1:Foo\\Bar\\Baz};\n\ + ${2}\n\ +snippet use\n\ + use ${1:Foo\\Bar\\Baz};\n\ + ${2}\n\ +snippet c\n\ + ${1:abstract }class ${2:$FILENAME}\n\ + {\n\ + ${3}\n\ + }\n\ +snippet i\n\ + interface ${1:$FILENAME}\n\ + {\n\ + ${2}\n\ + }\n\ +snippet t.\n\ + $this->${1}\n\ +snippet f\n\ + function ${1:foo}(${2:array }${3:$bar})\n\ + {\n\ + ${4}\n\ + }\n\ +# method\n\ +snippet m\n\ + ${1:abstract }${2:protected}${3: static} function ${4:foo}(${5:array }${6:$bar})\n\ + {\n\ + ${7}\n\ + }\n\ +# setter method\n\ +snippet sm \n\ + /**\n\ + * Sets the value of ${1:foo}\n\ + *\n\ + * @param ${2:$1} $$1 ${3:description}\n\ + *\n\ + * @return ${4:$FILENAME}\n\ + */\n\ + ${5:public} function set${6:$2}(${7:$2 }$$1)\n\ + {\n\ + $this->${8:$1} = $$1;\n\ + return $this;\n\ + }${9}\n\ +# getter method\n\ +snippet gm\n\ + /**\n\ + * Gets the value of ${1:foo}\n\ + *\n\ + * @return ${2:$1}\n\ + */\n\ + ${3:public} function get${4:$2}()\n\ + {\n\ + return $this->${5:$1};\n\ + }${6}\n\ +#setter\n\ +snippet $s\n\ + ${1:$foo}->set${2:Bar}(${3});\n\ +#getter\n\ +snippet $g\n\ + ${1:$foo}->get${2:Bar}();\n\ +\n\ +# Tertiary conditional\n\ +snippet =?:\n\ + $${1:foo} = ${2:true} ? ${3:a} : ${4};\n\ +snippet ?:\n\ + ${1:true} ? ${2:a} : ${3}\n\ +\n\ +snippet C\n\ + $_COOKIE['${1:variable}']${2}\n\ +snippet E\n\ + $_ENV['${1:variable}']${2}\n\ +snippet F\n\ + $_FILES['${1:variable}']${2}\n\ +snippet G\n\ + $_GET['${1:variable}']${2}\n\ +snippet P\n\ + $_POST['${1:variable}']${2}\n\ +snippet R\n\ + $_REQUEST['${1:variable}']${2}\n\ +snippet S\n\ + $_SERVER['${1:variable}']${2}\n\ +snippet SS\n\ + $_SESSION['${1:variable}']${2}\n\ + \n\ +# the following are old ones\n\ +snippet inc\n\ + include '${1:file}';${2}\n\ +snippet inc1\n\ + include_once '${1:file}';${2}\n\ +snippet req\n\ + require '${1:file}';${2}\n\ +snippet req1\n\ + require_once '${1:file}';${2}\n\ +# Start Docblock\n\ +snippet /*\n\ + /**\n\ + * ${1}\n\ + */\n\ +# Class - post doc\n\ +snippet doc_cp\n\ + /**\n\ + * ${1:undocumented class}\n\ + *\n\ + * @package ${2:default}\n\ + * @subpackage ${3:default}\n\ + * @author ${4:`g:snips_author`}\n\ + */${5}\n\ +# Class Variable - post doc\n\ +snippet doc_vp\n\ + /**\n\ + * ${1:undocumented class variable}\n\ + *\n\ + * @var ${2:string}\n\ + */${3}\n\ +# Class Variable\n\ +snippet doc_v\n\ + /**\n\ + * ${3:undocumented class variable}\n\ + *\n\ + * @var ${4:string}\n\ + */\n\ + ${1:var} $${2};${5}\n\ +# Class\n\ +snippet doc_c\n\ + /**\n\ + * ${3:undocumented class}\n\ + *\n\ + * @package ${4:default}\n\ + * @subpackage ${5:default}\n\ + * @author ${6:`g:snips_author`}\n\ + */\n\ + ${1:}class ${2:}\n\ + {\n\ + ${7}\n\ + } // END $1class $2\n\ +# Constant Definition - post doc\n\ +snippet doc_dp\n\ + /**\n\ + * ${1:undocumented constant}\n\ + */${2}\n\ +# Constant Definition\n\ +snippet doc_d\n\ + /**\n\ + * ${3:undocumented constant}\n\ + */\n\ + ace.define(${1}, ${2});${4}\n\ +# Function - post doc\n\ +snippet doc_fp\n\ + /**\n\ + * ${1:undocumented function}\n\ + *\n\ + * @return ${2:void}\n\ + * @author ${3:`g:snips_author`}\n\ + */${4}\n\ +# Function signature\n\ +snippet doc_s\n\ + /**\n\ + * ${4:undocumented function}\n\ + *\n\ + * @return ${5:void}\n\ + * @author ${6:`g:snips_author`}\n\ + */\n\ + ${1}function ${2}(${3});${7}\n\ +# Function\n\ +snippet doc_f\n\ + /**\n\ + * ${4:undocumented function}\n\ + *\n\ + * @return ${5:void}\n\ + * @author ${6:`g:snips_author`}\n\ + */\n\ + ${1}function ${2}(${3})\n\ + {${7}\n\ + }\n\ +# Header\n\ +snippet doc_h\n\ + /**\n\ + * ${1}\n\ + *\n\ + * @author ${2:`g:snips_author`}\n\ + * @version ${3:$Id$}\n\ + * @copyright ${4:$2}, `strftime('%d %B, %Y')`\n\ + * @package ${5:default}\n\ + */\n\ + \n\ +# Interface\n\ +snippet interface\n\ + /**\n\ + * ${2:undocumented class}\n\ + *\n\ + * @package ${3:default}\n\ + * @author ${4:`g:snips_author`}\n\ + */\n\ + interface ${1:$FILENAME}\n\ + {\n\ + ${5}\n\ + }\n\ +# class ...\n\ +snippet class\n\ + /**\n\ + * ${1}\n\ + */\n\ + class ${2:$FILENAME}\n\ + {\n\ + ${3}\n\ + /**\n\ + * ${4}\n\ + */\n\ + ${5:public} function ${6:__construct}(${7:argument})\n\ + {\n\ + ${8:// code...}\n\ + }\n\ + }\n\ +# ace.define(...)\n\ +snippet def\n\ + ace.define('${1}'${2});${3}\n\ +# defined(...)\n\ +snippet def?\n\ + ${1}defined('${2}')${3}\n\ +snippet wh\n\ + while (${1:/* condition */}) {\n\ + ${2:// code...}\n\ + }\n\ +# do ... while\n\ +snippet do\n\ + do {\n\ + ${2:// code... }\n\ + } while (${1:/* condition */});\n\ +snippet if\n\ + if (${1:/* condition */}) {\n\ + ${2:// code...}\n\ + }\n\ +snippet ifil\n\ + \n\ + ${2:}\n\ + \n\ +snippet ife\n\ + if (${1:/* condition */}) {\n\ + ${2:// code...}\n\ + } else {\n\ + ${3:// code...}\n\ + }\n\ + ${4}\n\ +snippet ifeil\n\ + \n\ + ${2:}\n\ + \n\ + ${3:}\n\ + \n\ + ${4}\n\ +snippet else\n\ + else {\n\ + ${1:// code...}\n\ + }\n\ +snippet elseif\n\ + elseif (${1:/* condition */}) {\n\ + ${2:// code...}\n\ + }\n\ +snippet switch\n\ + switch ($${1:variable}) {\n\ + case '${2:value}':\n\ + ${3:// code...}\n\ + break;\n\ + ${5}\n\ + default:\n\ + ${4:// code...}\n\ + break;\n\ + }\n\ +snippet case\n\ + case '${1:value}':\n\ + ${2:// code...}\n\ + break;${3}\n\ +snippet for\n\ + for ($${2:i} = 0; $$2 < ${1:count}; $$2${3:++}) {\n\ + ${4: // code...}\n\ + }\n\ +snippet foreach\n\ + foreach ($${1:variable} as $${2:value}) {\n\ + ${3:// code...}\n\ + }\n\ +snippet foreachil\n\ + \n\ + ${3:}\n\ + \n\ +snippet foreachk\n\ + foreach ($${1:variable} as $${2:key} => $${3:value}) {\n\ + ${4:// code...}\n\ + }\n\ +snippet foreachkil\n\ + $${3:value}): ?>\n\ + ${4:}\n\ + \n\ +# $... = array (...)\n\ +snippet array\n\ + $${1:arrayName} = array('${2}' => ${3});${4}\n\ +snippet try\n\ + try {\n\ + ${2}\n\ + } catch (${1:Exception} $e) {\n\ + }\n\ +# lambda with closure\n\ +snippet lambda\n\ + ${1:static }function (${2:args}) use (${3:&$x, $y /*put vars in scope (closure) */}) {\n\ + ${4}\n\ + };\n\ +# pre_dump();\n\ +snippet pd\n\ + echo '
    '; var_dump(${1}); echo '
    ';\n\ +# pre_dump(); die();\n\ +snippet pdd\n\ + echo '
    '; var_dump(${1}); echo '
    '; die(${2:});\n\ +snippet vd\n\ + var_dump(${1});\n\ +snippet vdd\n\ + var_dump(${1}); die(${2:});\n\ +snippet http_redirect\n\ + header (\"HTTP/1.1 301 Moved Permanently\"); \n\ + header (\"Location: \".URL); \n\ + exit();\n\ +# Getters & Setters\n\ +snippet gs\n\ + /**\n\ + * Gets the value of ${1:foo}\n\ + *\n\ + * @return ${2:$1}\n\ + */\n\ + public function get${3:$2}()\n\ + {\n\ + return $this->${4:$1};\n\ + }\n\ +\n\ + /**\n\ + * Sets the value of $1\n\ + *\n\ + * @param $2 $$1 ${5:description}\n\ + *\n\ + * @return ${6:$FILENAME}\n\ + */\n\ + public function set$3(${7:$2 }$$1)\n\ + {\n\ + $this->$4 = $$1;\n\ + return $this;\n\ + }${8}\n\ +# anotation, get, and set, useful for doctrine\n\ +snippet ags\n\ + /**\n\ + * ${1:description}\n\ + * \n\ + * @${7}\n\ + */\n\ + ${2:protected} $${3:foo};\n\ +\n\ + public function get${4:$3}()\n\ + {\n\ + return $this->$3;\n\ + }\n\ +\n\ + public function set$4(${5:$4 }$${6:$3})\n\ + {\n\ + $this->$3 = $$6;\n\ + return $this;\n\ + }\n\ +snippet rett\n\ + return true;\n\ +snippet retf\n\ + return false;\n\ +"; +exports.scope = "php"; + +}); diff --git a/lib/client/edit/snippets/plain_text.js b/lib/client/edit/snippets/plain_text.js new file mode 100644 index 00000000..1c76fdd7 --- /dev/null +++ b/lib/client/edit/snippets/plain_text.js @@ -0,0 +1,7 @@ +ace.define('ace/snippets/plain_text', ['require', 'exports', 'module' ], function(require, exports, module) { + + +exports.snippetText = ""; +exports.scope = "plain_text"; + +}); diff --git a/lib/client/edit/snippets/powershell.js b/lib/client/edit/snippets/powershell.js new file mode 100644 index 00000000..c7bc2d30 --- /dev/null +++ b/lib/client/edit/snippets/powershell.js @@ -0,0 +1,7 @@ +ace.define('ace/snippets/powershell', ['require', 'exports', 'module' ], function(require, exports, module) { + + +exports.snippetText = ""; +exports.scope = "powershell"; + +}); diff --git a/lib/client/edit/snippets/properties.js b/lib/client/edit/snippets/properties.js new file mode 100644 index 00000000..ec389d5d --- /dev/null +++ b/lib/client/edit/snippets/properties.js @@ -0,0 +1,7 @@ +ace.define('ace/snippets/properties', ['require', 'exports', 'module' ], function(require, exports, module) { + + +exports.snippetText = ""; +exports.scope = "properties"; + +}); diff --git a/lib/client/edit/snippets/python.js b/lib/client/edit/snippets/python.js new file mode 100644 index 00000000..1a0be2aa --- /dev/null +++ b/lib/client/edit/snippets/python.js @@ -0,0 +1,165 @@ +ace.define('ace/snippets/python', ['require', 'exports', 'module' ], function(require, exports, module) { + + +exports.snippetText = "snippet #!\n\ + #!/usr/bin/env python\n\ +snippet imp\n\ + import ${1:module}\n\ +snippet from\n\ + from ${1:package} import ${2:module}\n\ +# Module Docstring\n\ +snippet docs\n\ + '''\n\ + File: ${1:`Filename('$1.py', 'foo.py')`}\n\ + Author: ${2:`g:snips_author`}\n\ + Description: ${3}\n\ + '''\n\ +snippet wh\n\ + while ${1:condition}:\n\ + ${2:# TODO: write code...}\n\ +# dowh - does the same as do...while in other languages\n\ +snippet dowh\n\ + while True:\n\ + ${1:# TODO: write code...}\n\ + if ${2:condition}:\n\ + break\n\ +snippet with\n\ + with ${1:expr} as ${2:var}:\n\ + ${3:# TODO: write code...}\n\ +# New Class\n\ +snippet cl\n\ + class ${1:ClassName}(${2:object}):\n\ + \"\"\"${3:docstring for $1}\"\"\"\n\ + def __init__(self, ${4:arg}):\n\ + ${5:super($1, self).__init__()}\n\ + self.$4 = $4\n\ + ${6}\n\ +# New Function\n\ +snippet def\n\ + def ${1:fname}(${2:`indent('.') ? 'self' : ''`}):\n\ + \"\"\"${3:docstring for $1}\"\"\"\n\ + ${4:# TODO: write code...}\n\ +snippet deff\n\ + def ${1:fname}(${2:`indent('.') ? 'self' : ''`}):\n\ + ${3:# TODO: write code...}\n\ +# New Method\n\ +snippet defs\n\ + def ${1:mname}(self, ${2:arg}):\n\ + ${3:# TODO: write code...}\n\ +# New Property\n\ +snippet property\n\ + def ${1:foo}():\n\ + doc = \"${2:The $1 property.}\"\n\ + def fget(self):\n\ + ${3:return self._$1}\n\ + def fset(self, value):\n\ + ${4:self._$1 = value}\n\ +# Ifs\n\ +snippet if\n\ + if ${1:condition}:\n\ + ${2:# TODO: write code...}\n\ +snippet el\n\ + else:\n\ + ${1:# TODO: write code...}\n\ +snippet ei\n\ + elif ${1:condition}:\n\ + ${2:# TODO: write code...}\n\ +# For\n\ +snippet for\n\ + for ${1:item} in ${2:items}:\n\ + ${3:# TODO: write code...}\n\ +# Encodes\n\ +snippet cutf8\n\ + # -*- coding: utf-8 -*-\n\ +snippet clatin1\n\ + # -*- coding: latin-1 -*-\n\ +snippet cascii\n\ + # -*- coding: ascii -*-\n\ +# Lambda\n\ +snippet ld\n\ + ${1:var} = lambda ${2:vars} : ${3:action}\n\ +snippet .\n\ + self.\n\ +snippet try Try/Except\n\ + try:\n\ + ${1:# TODO: write code...}\n\ + except ${2:Exception}, ${3:e}:\n\ + ${4:raise $3}\n\ +snippet try Try/Except/Else\n\ + try:\n\ + ${1:# TODO: write code...}\n\ + except ${2:Exception}, ${3:e}:\n\ + ${4:raise $3}\n\ + else:\n\ + ${5:# TODO: write code...}\n\ +snippet try Try/Except/Finally\n\ + try:\n\ + ${1:# TODO: write code...}\n\ + except ${2:Exception}, ${3:e}:\n\ + ${4:raise $3}\n\ + finally:\n\ + ${5:# TODO: write code...}\n\ +snippet try Try/Except/Else/Finally\n\ + try:\n\ + ${1:# TODO: write code...}\n\ + except ${2:Exception}, ${3:e}:\n\ + ${4:raise $3}\n\ + else:\n\ + ${5:# TODO: write code...}\n\ + finally:\n\ + ${6:# TODO: write code...}\n\ +# if __name__ == '__main__':\n\ +snippet ifmain\n\ + if __name__ == '__main__':\n\ + ${1:main()}\n\ +# __magic__\n\ +snippet _\n\ + __${1:init}__${2}\n\ +# python debugger (pdb)\n\ +snippet pdb\n\ + import pdb; pdb.set_trace()\n\ +# ipython debugger (ipdb)\n\ +snippet ipdb\n\ + import ipdb; ipdb.set_trace()\n\ +# ipython debugger (pdbbb)\n\ +snippet pdbbb\n\ + import pdbpp; pdbpp.set_trace()\n\ +snippet pprint\n\ + import pprint; pprint.pprint(${1})${2}\n\ +snippet \"\n\ + \"\"\"\n\ + ${1:doc}\n\ + \"\"\"\n\ +# test function/method\n\ +snippet test\n\ + def test_${1:description}(${2:`indent('.') ? 'self' : ''`}):\n\ + ${3:# TODO: write code...}\n\ +# test case\n\ +snippet testcase\n\ + class ${1:ExampleCase}(unittest.TestCase):\n\ + \n\ + def test_${2:description}(self):\n\ + ${3:# TODO: write code...}\n\ +snippet fut\n\ + from __future__ import ${1}\n\ +#getopt\n\ +snippet getopt\n\ + try:\n\ + # Short option syntax: \"hv:\"\n\ + # Long option syntax: \"help\" or \"verbose=\"\n\ + opts, args = getopt.getopt(sys.argv[1:], \"${1:short_options}\", [${2:long_options}])\n\ + \n\ + except getopt.GetoptError, err:\n\ + # Print debug info\n\ + print str(err)\n\ + ${3:error_action}\n\ +\n\ + for option, argument in opts:\n\ + if option in (\"-h\", \"--help\"):\n\ + ${4}\n\ + elif option in (\"-v\", \"--verbose\"):\n\ + verbose = argument\n\ +"; +exports.scope = "python"; + +}); diff --git a/lib/client/edit/snippets/ruby.js b/lib/client/edit/snippets/ruby.js new file mode 100644 index 00000000..7830e20a --- /dev/null +++ b/lib/client/edit/snippets/ruby.js @@ -0,0 +1,935 @@ +ace.define('ace/snippets/ruby', ['require', 'exports', 'module' ], function(require, exports, module) { + + +exports.snippetText = "########################################\n\ +# Ruby snippets - for Rails, see below #\n\ +########################################\n\ +\n\ +# encoding for Ruby 1.9\n\ +snippet enc\n\ + # encoding: utf-8\n\ +\n\ +# #!/usr/bin/env ruby\n\ +snippet #!\n\ + #!/usr/bin/env ruby\n\ + # encoding: utf-8\n\ +\n\ +# New Block\n\ +snippet =b\n\ + =begin rdoc\n\ + ${1}\n\ + =end\n\ +snippet y\n\ + :yields: ${1:arguments}\n\ +snippet rb\n\ + #!/usr/bin/env ruby -wKU\n\ +snippet beg\n\ + begin\n\ + ${3}\n\ + rescue ${1:Exception} => ${2:e}\n\ + end\n\ +\n\ +snippet req require\n\ + require \"${1}\"${2}\n\ +snippet #\n\ + # =>\n\ +snippet end\n\ + __END__\n\ +snippet case\n\ + case ${1:object}\n\ + when ${2:condition}\n\ + ${3}\n\ + end\n\ +snippet when\n\ + when ${1:condition}\n\ + ${2}\n\ +snippet def\n\ + def ${1:method_name}\n\ + ${2}\n\ + end\n\ +snippet deft\n\ + def test_${1:case_name}\n\ + ${2}\n\ + end\n\ +snippet if\n\ + if ${1:condition}\n\ + ${2}\n\ + end\n\ +snippet ife\n\ + if ${1:condition}\n\ + ${2}\n\ + else\n\ + ${3}\n\ + end\n\ +snippet elsif\n\ + elsif ${1:condition}\n\ + ${2}\n\ +snippet unless\n\ + unless ${1:condition}\n\ + ${2}\n\ + end\n\ +snippet while\n\ + while ${1:condition}\n\ + ${2}\n\ + end\n\ +snippet for\n\ + for ${1:e} in ${2:c}\n\ + ${3}\n\ + end\n\ +snippet until\n\ + until ${1:condition}\n\ + ${2}\n\ + end\n\ +snippet cla class .. end\n\ + class ${1:`substitute(Filename(), '\\(_\\|^\\)\\(.\\)', '\\u\\2', 'g')`}\n\ + ${2}\n\ + end\n\ +snippet cla class .. initialize .. end\n\ + class ${1:`substitute(Filename(), '\\(_\\|^\\)\\(.\\)', '\\u\\2', 'g')`}\n\ + def initialize(${2:args})\n\ + ${3}\n\ + end\n\ + end\n\ +snippet cla class .. < ParentClass .. initialize .. end\n\ + class ${1:`substitute(Filename(), '\\(_\\|^\\)\\(.\\)', '\\u\\2', 'g')`} < ${2:ParentClass}\n\ + def initialize(${3:args})\n\ + ${4}\n\ + end\n\ + end\n\ +snippet cla ClassName = Struct .. do .. end\n\ + ${1:`substitute(Filename(), '\\(_\\|^\\)\\(.\\)', '\\u\\2', 'g')`} = Struct.new(:${2:attr_names}) do\n\ + def ${3:method_name}\n\ + ${4}\n\ + end\n\ + end\n\ +snippet cla class BlankSlate .. initialize .. end\n\ + class ${1:BlankSlate}\n\ + instance_methods.each { |meth| undef_method(meth) unless meth =~ /\\A__/ }\n\ + end\n\ +snippet cla class << self .. end\n\ + class << ${1:self}\n\ + ${2}\n\ + end\n\ +# class .. < DelegateClass .. initialize .. end\n\ +snippet cla-\n\ + class ${1:`substitute(Filename(), '\\(_\\|^\\)\\(.\\)', '\\u\\2', 'g')`} < DelegateClass(${2:ParentClass})\n\ + def initialize(${3:args})\n\ + super(${4:del_obj})\n\ +\n\ + ${5}\n\ + end\n\ + end\n\ +snippet mod module .. end\n\ + module ${1:`substitute(Filename(), '\\(_\\|^\\)\\(.\\)', '\\u\\2', 'g')`}\n\ + ${2}\n\ + end\n\ +snippet mod module .. module_function .. end\n\ + module ${1:`substitute(Filename(), '\\(_\\|^\\)\\(.\\)', '\\u\\2', 'g')`}\n\ + module_function\n\ +\n\ + ${2}\n\ + end\n\ +snippet mod module .. ClassMethods .. end\n\ + module ${1:`substitute(Filename(), '\\(_\\|^\\)\\(.\\)', '\\u\\2', 'g')`}\n\ + module ClassMethods\n\ + ${2}\n\ + end\n\ +\n\ + module InstanceMethods\n\ +\n\ + end\n\ +\n\ + def self.included(receiver)\n\ + receiver.extend ClassMethods\n\ + receiver.send :include, InstanceMethods\n\ + end\n\ + end\n\ +# attr_reader\n\ +snippet r\n\ + attr_reader :${1:attr_names}\n\ +# attr_writer\n\ +snippet w\n\ + attr_writer :${1:attr_names}\n\ +# attr_accessor\n\ +snippet rw\n\ + attr_accessor :${1:attr_names}\n\ +snippet atp\n\ + attr_protected :${1:attr_names}\n\ +snippet ata\n\ + attr_accessible :${1:attr_names}\n\ +# include Enumerable\n\ +snippet Enum\n\ + include Enumerable\n\ +\n\ + def each(&block)\n\ + ${1}\n\ + end\n\ +# include Comparable\n\ +snippet Comp\n\ + include Comparable\n\ +\n\ + def <=>(other)\n\ + ${1}\n\ + end\n\ +# extend Forwardable\n\ +snippet Forw-\n\ + extend Forwardable\n\ +# def self\n\ +snippet defs\n\ + def self.${1:class_method_name}\n\ + ${2}\n\ + end\n\ +# def method_missing\n\ +snippet defmm\n\ + def method_missing(meth, *args, &blk)\n\ + ${1}\n\ + end\n\ +snippet defd\n\ + def_delegator :${1:@del_obj}, :${2:del_meth}, :${3:new_name}\n\ +snippet defds\n\ + def_delegators :${1:@del_obj}, :${2:del_methods}\n\ +snippet am\n\ + alias_method :${1:new_name}, :${2:old_name}\n\ +snippet app\n\ + if __FILE__ == $PROGRAM_NAME\n\ + ${1}\n\ + end\n\ +# usage_if()\n\ +snippet usai\n\ + if ARGV.${1}\n\ + abort \"Usage: #{$PROGRAM_NAME} ${2:ARGS_GO_HERE}\"${3}\n\ + end\n\ +# usage_unless()\n\ +snippet usau\n\ + unless ARGV.${1}\n\ + abort \"Usage: #{$PROGRAM_NAME} ${2:ARGS_GO_HERE}\"${3}\n\ + end\n\ +snippet array\n\ + Array.new(${1:10}) { |${2:i}| ${3} }\n\ +snippet hash\n\ + Hash.new { |${1:hash}, ${2:key}| $1[$2] = ${3} }\n\ +snippet file File.foreach() { |line| .. }\n\ + File.foreach(${1:\"path/to/file\"}) { |${2:line}| ${3} }\n\ +snippet file File.read()\n\ + File.read(${1:\"path/to/file\"})${2}\n\ +snippet Dir Dir.global() { |file| .. }\n\ + Dir.glob(${1:\"dir/glob/*\"}) { |${2:file}| ${3} }\n\ +snippet Dir Dir[\"..\"]\n\ + Dir[${1:\"glob/**/*.rb\"}]${2}\n\ +snippet dir\n\ + Filename.dirname(__FILE__)\n\ +snippet deli\n\ + delete_if { |${1:e}| ${2} }\n\ +snippet fil\n\ + fill(${1:range}) { |${2:i}| ${3} }\n\ +# flatten_once()\n\ +snippet flao\n\ + inject(Array.new) { |${1:arr}, ${2:a}| $1.push(*$2)}${3}\n\ +snippet zip\n\ + zip(${1:enums}) { |${2:row}| ${3} }\n\ +# downto(0) { |n| .. }\n\ +snippet dow\n\ + downto(${1:0}) { |${2:n}| ${3} }\n\ +snippet ste\n\ + step(${1:2}) { |${2:n}| ${3} }\n\ +snippet tim\n\ + times { |${1:n}| ${2} }\n\ +snippet upt\n\ + upto(${1:1.0/0.0}) { |${2:n}| ${3} }\n\ +snippet loo\n\ + loop { ${1} }\n\ +snippet ea\n\ + each { |${1:e}| ${2} }\n\ +snippet ead\n\ + each do |${1:e}|\n\ + ${2}\n\ + end\n\ +snippet eab\n\ + each_byte { |${1:byte}| ${2} }\n\ +snippet eac- each_char { |chr| .. }\n\ + each_char { |${1:chr}| ${2} }\n\ +snippet eac- each_cons(..) { |group| .. }\n\ + each_cons(${1:2}) { |${2:group}| ${3} }\n\ +snippet eai\n\ + each_index { |${1:i}| ${2} }\n\ +snippet eaid\n\ + each_index do |${1:i}|\n\ + ${2}\n\ + end\n\ +snippet eak\n\ + each_key { |${1:key}| ${2} }\n\ +snippet eakd\n\ + each_key do |${1:key}|\n\ + ${2}\n\ + end\n\ +snippet eal\n\ + each_line { |${1:line}| ${2} }\n\ +snippet eald\n\ + each_line do |${1:line}|\n\ + ${2}\n\ + end\n\ +snippet eap\n\ + each_pair { |${1:name}, ${2:val}| ${3} }\n\ +snippet eapd\n\ + each_pair do |${1:name}, ${2:val}|\n\ + ${3}\n\ + end\n\ +snippet eas-\n\ + each_slice(${1:2}) { |${2:group}| ${3} }\n\ +snippet easd-\n\ + each_slice(${1:2}) do |${2:group}|\n\ + ${3}\n\ + end\n\ +snippet eav\n\ + each_value { |${1:val}| ${2} }\n\ +snippet eavd\n\ + each_value do |${1:val}|\n\ + ${2}\n\ + end\n\ +snippet eawi\n\ + each_with_index { |${1:e}, ${2:i}| ${3} }\n\ +snippet eawid\n\ + each_with_index do |${1:e},${2:i}|\n\ + ${3}\n\ + end\n\ +snippet reve\n\ + reverse_each { |${1:e}| ${2} }\n\ +snippet reved\n\ + reverse_each do |${1:e}|\n\ + ${2}\n\ + end\n\ +snippet inj\n\ + inject(${1:init}) { |${2:mem}, ${3:var}| ${4} }\n\ +snippet injd\n\ + inject(${1:init}) do |${2:mem}, ${3:var}|\n\ + ${4}\n\ + end\n\ +snippet map\n\ + map { |${1:e}| ${2} }\n\ +snippet mapd\n\ + map do |${1:e}|\n\ + ${2}\n\ + end\n\ +snippet mapwi-\n\ + enum_with_index.map { |${1:e}, ${2:i}| ${3} }\n\ +snippet sor\n\ + sort { |a, b| ${1} }\n\ +snippet sorb\n\ + sort_by { |${1:e}| ${2} }\n\ +snippet ran\n\ + sort_by { rand }\n\ +snippet all\n\ + all? { |${1:e}| ${2} }\n\ +snippet any\n\ + any? { |${1:e}| ${2} }\n\ +snippet cl\n\ + classify { |${1:e}| ${2} }\n\ +snippet col\n\ + collect { |${1:e}| ${2} }\n\ +snippet cold\n\ + collect do |${1:e}|\n\ + ${2}\n\ + end\n\ +snippet det\n\ + detect { |${1:e}| ${2} }\n\ +snippet detd\n\ + detect do |${1:e}|\n\ + ${2}\n\ + end\n\ +snippet fet\n\ + fetch(${1:name}) { |${2:key}| ${3} }\n\ +snippet fin\n\ + find { |${1:e}| ${2} }\n\ +snippet find\n\ + find do |${1:e}|\n\ + ${2}\n\ + end\n\ +snippet fina\n\ + find_all { |${1:e}| ${2} }\n\ +snippet finad\n\ + find_all do |${1:e}|\n\ + ${2}\n\ + end\n\ +snippet gre\n\ + grep(${1:/pattern/}) { |${2:match}| ${3} }\n\ +snippet sub\n\ + ${1:g}sub(${2:/pattern/}) { |${3:match}| ${4} }\n\ +snippet sca\n\ + scan(${1:/pattern/}) { |${2:match}| ${3} }\n\ +snippet scad\n\ + scan(${1:/pattern/}) do |${2:match}|\n\ + ${3}\n\ + end\n\ +snippet max\n\ + max { |a, b| ${1} }\n\ +snippet min\n\ + min { |a, b| ${1} }\n\ +snippet par\n\ + partition { |${1:e}| ${2} }\n\ +snippet pard\n\ + partition do |${1:e}|\n\ + ${2}\n\ + end\n\ +snippet rej\n\ + reject { |${1:e}| ${2} }\n\ +snippet rejd\n\ + reject do |${1:e}|\n\ + ${2}\n\ + end\n\ +snippet sel\n\ + select { |${1:e}| ${2} }\n\ +snippet seld\n\ + select do |${1:e}|\n\ + ${2}\n\ + end\n\ +snippet lam\n\ + lambda { |${1:args}| ${2} }\n\ +snippet doo\n\ + do\n\ + ${1}\n\ + end\n\ +snippet dov\n\ + do |${1:variable}|\n\ + ${2}\n\ + end\n\ +snippet :\n\ + :${1:key} => ${2:\"value\"}${3}\n\ +snippet ope\n\ + open(${1:\"path/or/url/or/pipe\"}, \"${2:w}\") { |${3:io}| ${4} }\n\ +# path_from_here()\n\ +snippet fpath\n\ + File.join(File.dirname(__FILE__), *%2[${1:rel path here}])${2}\n\ +# unix_filter {}\n\ +snippet unif\n\ + ARGF.each_line${1} do |${2:line}|\n\ + ${3}\n\ + end\n\ +# option_parse {}\n\ +snippet optp\n\ + require \"optparse\"\n\ +\n\ + options = {${1:default => \"args\"}}\n\ +\n\ + ARGV.options do |opts|\n\ + opts.banner = \"Usage: #{File.basename($PROGRAM_NAME)}\n\ +snippet opt\n\ + opts.on( \"-${1:o}\", \"--${2:long-option-name}\", ${3:String},\n\ + \"${4:Option description.}\") do |${5:opt}|\n\ + ${6}\n\ + end\n\ +snippet tc\n\ + require \"test/unit\"\n\ +\n\ + require \"${1:library_file_name}\"\n\ +\n\ + class Test${2:$1} < Test::Unit::TestCase\n\ + def test_${3:case_name}\n\ + ${4}\n\ + end\n\ + end\n\ +snippet ts\n\ + require \"test/unit\"\n\ +\n\ + require \"tc_${1:test_case_file}\"\n\ + require \"tc_${2:test_case_file}\"${3}\n\ +snippet as\n\ + assert ${1:test}, \"${2:Failure message.}\"${3}\n\ +snippet ase\n\ + assert_equal ${1:expected}, ${2:actual}${3}\n\ +snippet asne\n\ + assert_not_equal ${1:unexpected}, ${2:actual}${3}\n\ +snippet asid\n\ + assert_in_delta ${1:expected_float}, ${2:actual_float}, ${3:2 ** -20}${4}\n\ +snippet asio\n\ + assert_instance_of ${1:ExpectedClass}, ${2:actual_instance}${3}\n\ +snippet asko\n\ + assert_kind_of ${1:ExpectedKind}, ${2:actual_instance}${3}\n\ +snippet asn\n\ + assert_nil ${1:instance}${2}\n\ +snippet asnn\n\ + assert_not_nil ${1:instance}${2}\n\ +snippet asm\n\ + assert_match /${1:expected_pattern}/, ${2:actual_string}${3}\n\ +snippet asnm\n\ + assert_no_match /${1:unexpected_pattern}/, ${2:actual_string}${3}\n\ +snippet aso\n\ + assert_operator ${1:left}, :${2:operator}, ${3:right}${4}\n\ +snippet asr\n\ + assert_raise ${1:Exception} { ${2} }\n\ +snippet asrd\n\ + assert_raise ${1:Exception} do\n\ + ${2}\n\ + end\n\ +snippet asnr\n\ + assert_nothing_raised ${1:Exception} { ${2} }\n\ +snippet asnrd\n\ + assert_nothing_raised ${1:Exception} do\n\ + ${2}\n\ + end\n\ +snippet asrt\n\ + assert_respond_to ${1:object}, :${2:method}${3}\n\ +snippet ass assert_same(..)\n\ + assert_same ${1:expected}, ${2:actual}${3}\n\ +snippet ass assert_send(..)\n\ + assert_send [${1:object}, :${2:message}, ${3:args}]${4}\n\ +snippet asns\n\ + assert_not_same ${1:unexpected}, ${2:actual}${3}\n\ +snippet ast\n\ + assert_throws :${1:expected} { ${2} }\n\ +snippet astd\n\ + assert_throws :${1:expected} do\n\ + ${2}\n\ + end\n\ +snippet asnt\n\ + assert_nothing_thrown { ${1} }\n\ +snippet asntd\n\ + assert_nothing_thrown do\n\ + ${1}\n\ + end\n\ +snippet fl\n\ + flunk \"${1:Failure message.}\"${2}\n\ +# Benchmark.bmbm do .. end\n\ +snippet bm-\n\ + TESTS = ${1:10_000}\n\ + Benchmark.bmbm do |results|\n\ + ${2}\n\ + end\n\ +snippet rep\n\ + results.report(\"${1:name}:\") { TESTS.times { ${2} }}\n\ +# Marshal.dump(.., file)\n\ +snippet Md\n\ + File.open(${1:\"path/to/file.dump\"}, \"wb\") { |${2:file}| Marshal.dump(${3:obj}, $2) }${4}\n\ +# Mashal.load(obj)\n\ +snippet Ml\n\ + File.open(${1:\"path/to/file.dump\"}, \"rb\") { |${2:file}| Marshal.load($2) }${3}\n\ +# deep_copy(..)\n\ +snippet deec\n\ + Marshal.load(Marshal.dump(${1:obj_to_copy}))${2}\n\ +snippet Pn-\n\ + PStore.new(${1:\"file_name.pstore\"})${2}\n\ +snippet tra\n\ + transaction(${1:true}) { ${2} }\n\ +# xmlread(..)\n\ +snippet xml-\n\ + REXML::Document.new(File.read(${1:\"path/to/file\"}))${2}\n\ +# xpath(..) { .. }\n\ +snippet xpa\n\ + elements.each(${1:\"//Xpath\"}) do |${2:node}|\n\ + ${3}\n\ + end\n\ +# class_from_name()\n\ +snippet clafn\n\ + split(\"::\").inject(Object) { |par, const| par.const_get(const) }\n\ +# singleton_class()\n\ +snippet sinc\n\ + class << self; self end\n\ +snippet nam\n\ + namespace :${1:`Filename()`} do\n\ + ${2}\n\ + end\n\ +snippet tas\n\ + desc \"${1:Task description}\"\n\ + task :${2:task_name => [:dependent, :tasks]} do\n\ + ${3}\n\ + end\n\ +# block\n\ +snippet b\n\ + { |${1:var}| ${2} }\n\ +snippet begin\n\ + begin\n\ + raise 'A test exception.'\n\ + rescue Exception => e\n\ + puts e.message\n\ + puts e.backtrace.inspect\n\ + else\n\ + # other exception\n\ + ensure\n\ + # always executed\n\ + end\n\ +\n\ +#debugging\n\ +snippet debug\n\ + require 'ruby-debug'; debugger; true;\n\ +snippet pry\n\ + require 'pry'; binding.pry\n\ +\n\ +#############################################\n\ +# Rails snippets - for pure Ruby, see above #\n\ +#############################################\n\ +snippet art\n\ + assert_redirected_to ${1::action => \"${2:index}\"}\n\ +snippet artnp\n\ + assert_redirected_to ${1:parent}_${2:child}_path(${3:@$1}, ${4:@$2})\n\ +snippet artnpp\n\ + assert_redirected_to ${1:parent}_${2:child}_path(${3:@$1})\n\ +snippet artp\n\ + assert_redirected_to ${1:model}_path(${2:@$1})\n\ +snippet artpp\n\ + assert_redirected_to ${1:model}s_path\n\ +snippet asd\n\ + assert_difference \"${1:Model}.${2:count}\", $1 do\n\ + ${3}\n\ + end\n\ +snippet asnd\n\ + assert_no_difference \"${1:Model}.${2:count}\" do\n\ + ${3}\n\ + end\n\ +snippet asre\n\ + assert_response :${1:success}, @response.body${2}\n\ +snippet asrj\n\ + assert_rjs :${1:replace}, \"${2:dom id}\"\n\ +snippet ass assert_select(..)\n\ + assert_select '${1:path}', :${2:text} => '${3:inner_html' ${4:do}\n\ +snippet bf\n\ + before_filter :${1:method}\n\ +snippet bt\n\ + belongs_to :${1:association}\n\ +snippet crw\n\ + cattr_accessor :${1:attr_names}\n\ +snippet defcreate\n\ + def create\n\ + @${1:model_class_name} = ${2:ModelClassName}.new(params[:$1])\n\ +\n\ + respond_to do |wants|\n\ + if @$1.save\n\ + flash[:notice] = '$2 was successfully created.'\n\ + wants.html { redirect_to(@$1) }\n\ + wants.xml { render :xml => @$1, :status => :created, :location => @$1 }\n\ + else\n\ + wants.html { render :action => \"new\" }\n\ + wants.xml { render :xml => @$1.errors, :status => :unprocessable_entity }\n\ + end\n\ + end\n\ + end${3}\n\ +snippet defdestroy\n\ + def destroy\n\ + @${1:model_class_name} = ${2:ModelClassName}.find(params[:id])\n\ + @$1.destroy\n\ +\n\ + respond_to do |wants|\n\ + wants.html { redirect_to($1s_url) }\n\ + wants.xml { head :ok }\n\ + end\n\ + end${3}\n\ +snippet defedit\n\ + def edit\n\ + @${1:model_class_name} = ${2:ModelClassName}.find(params[:id])\n\ + end\n\ +snippet defindex\n\ + def index\n\ + @${1:model_class_name} = ${2:ModelClassName}.all\n\ +\n\ + respond_to do |wants|\n\ + wants.html # index.html.erb\n\ + wants.xml { render :xml => @$1s }\n\ + end\n\ + end${3}\n\ +snippet defnew\n\ + def new\n\ + @${1:model_class_name} = ${2:ModelClassName}.new\n\ +\n\ + respond_to do |wants|\n\ + wants.html # new.html.erb\n\ + wants.xml { render :xml => @$1 }\n\ + end\n\ + end${3}\n\ +snippet defshow\n\ + def show\n\ + @${1:model_class_name} = ${2:ModelClassName}.find(params[:id])\n\ +\n\ + respond_to do |wants|\n\ + wants.html # show.html.erb\n\ + wants.xml { render :xml => @$1 }\n\ + end\n\ + end${3}\n\ +snippet defupdate\n\ + def update\n\ + @${1:model_class_name} = ${2:ModelClassName}.find(params[:id])\n\ +\n\ + respond_to do |wants|\n\ + if @$1.update_attributes(params[:$1])\n\ + flash[:notice] = '$2 was successfully updated.'\n\ + wants.html { redirect_to(@$1) }\n\ + wants.xml { head :ok }\n\ + else\n\ + wants.html { render :action => \"edit\" }\n\ + wants.xml { render :xml => @$1.errors, :status => :unprocessable_entity }\n\ + end\n\ + end\n\ + end${3}\n\ +snippet flash\n\ + flash[:${1:notice}] = \"${2}\"\n\ +snippet habtm\n\ + has_and_belongs_to_many :${1:object}, :join_table => \"${2:table_name}\", :foreign_key => \"${3}_id\"${4}\n\ +snippet hm\n\ + has_many :${1:object}\n\ +snippet hmd\n\ + has_many :${1:other}s, :class_name => \"${2:$1}\", :foreign_key => \"${3:$1}_id\", :dependent => :destroy${4}\n\ +snippet hmt\n\ + has_many :${1:object}, :through => :${2:object}\n\ +snippet ho\n\ + has_one :${1:object}\n\ +snippet i18\n\ + I18n.t('${1:type.key}')${2}\n\ +snippet ist\n\ + <%= image_submit_tag(\"${1:agree.png}\", :id => \"${2:id}\"${3} %>\n\ +snippet log\n\ + Rails.logger.${1:debug} ${2}\n\ +snippet log2\n\ + RAILS_DEFAULT_LOGGER.${1:debug} ${2}\n\ +snippet logd\n\ + logger.debug { \"${1:message}\" }${2}\n\ +snippet loge\n\ + logger.error { \"${1:message}\" }${2}\n\ +snippet logf\n\ + logger.fatal { \"${1:message}\" }${2}\n\ +snippet logi\n\ + logger.info { \"${1:message}\" }${2}\n\ +snippet logw\n\ + logger.warn { \"${1:message}\" }${2}\n\ +snippet mapc\n\ + ${1:map}.${2:connect} '${3:controller/:action/:id}'\n\ +snippet mapca\n\ + ${1:map}.catch_all \"*${2:anything}\", :controller => \"${3:default}\", :action => \"${4:error}\"${5}\n\ +snippet mapr\n\ + ${1:map}.resource :${2:resource}\n\ +snippet maprs\n\ + ${1:map}.resources :${2:resource}\n\ +snippet mapwo\n\ + ${1:map}.with_options :${2:controller} => '${3:thing}' do |$3|\n\ + ${4}\n\ + end\n\ +snippet mbs\n\ + before_save :${1:method}\n\ +snippet mcht\n\ + change_table :${1:table_name} do |t|\n\ + ${2}\n\ + end\n\ +snippet mp\n\ + map(&:${1:id})\n\ +snippet mrw\n\ + mattr_accessor :${1:attr_names}\n\ +snippet oa\n\ + order(\"${1:field}\")\n\ +snippet od\n\ + order(\"${1:field} DESC\")\n\ +snippet pa\n\ + params[:${1:id}]${2}\n\ +snippet ra\n\ + render :action => \"${1:action}\"\n\ +snippet ral\n\ + render :action => \"${1:action}\", :layout => \"${2:layoutname}\"\n\ +snippet rest\n\ + respond_to do |wants|\n\ + wants.${1:html} { ${2} }\n\ + end\n\ +snippet rf\n\ + render :file => \"${1:filepath}\"\n\ +snippet rfu\n\ + render :file => \"${1:filepath}\", :use_full_path => ${2:false}\n\ +snippet ri\n\ + render :inline => \"${1:<%= 'hello' %>}\"\n\ +snippet ril\n\ + render :inline => \"${1:<%= 'hello' %>}\", :locals => { ${2::name} => \"${3:value}\"${4} }\n\ +snippet rit\n\ + render :inline => \"${1:<%= 'hello' %>}\", :type => ${2::rxml}\n\ +snippet rjson\n\ + render :json => ${1:text to render}\n\ +snippet rl\n\ + render :layout => \"${1:layoutname}\"\n\ +snippet rn\n\ + render :nothing => ${1:true}\n\ +snippet rns\n\ + render :nothing => ${1:true}, :status => ${2:401}\n\ +snippet rp\n\ + render :partial => \"${1:item}\"\n\ +snippet rpc\n\ + render :partial => \"${1:item}\", :collection => ${2:@$1s}\n\ +snippet rpl\n\ + render :partial => \"${1:item}\", :locals => { :${2:$1} => ${3:@$1}\n\ +snippet rpo\n\ + render :partial => \"${1:item}\", :object => ${2:@$1}\n\ +snippet rps\n\ + render :partial => \"${1:item}\", :status => ${2:500}\n\ +snippet rt\n\ + render :text => \"${1:text to render}\"\n\ +snippet rtl\n\ + render :text => \"${1:text to render}\", :layout => \"${2:layoutname}\"\n\ +snippet rtlt\n\ + render :text => \"${1:text to render}\", :layout => ${2:true}\n\ +snippet rts\n\ + render :text => \"${1:text to render}\", :status => ${2:401}\n\ +snippet ru\n\ + render :update do |${1:page}|\n\ + $1.${2}\n\ + end\n\ +snippet rxml\n\ + render :xml => ${1:text to render}\n\ +snippet sc\n\ + scope :${1:name}, :where(:@${2:field} => ${3:value})\n\ +snippet sl\n\ + scope :${1:name}, lambda do |${2:value}|\n\ + where(\"${3:field = ?}\", ${4:bind var})\n\ + end\n\ +snippet sha1\n\ + Digest::SHA1.hexdigest(${1:string})\n\ +snippet sweeper\n\ + class ${1:ModelClassName}Sweeper < ActionController::Caching::Sweeper\n\ + observe $1\n\ +\n\ + def after_save(${2:model_class_name})\n\ + expire_cache($2)\n\ + end\n\ +\n\ + def after_destroy($2)\n\ + expire_cache($2)\n\ + end\n\ +\n\ + def expire_cache($2)\n\ + expire_page\n\ + end\n\ + end\n\ +snippet tcb\n\ + t.boolean :${1:title}\n\ + ${2}\n\ +snippet tcbi\n\ + t.binary :${1:title}, :limit => ${2:2}.megabytes\n\ + ${3}\n\ +snippet tcd\n\ + t.decimal :${1:title}, :precision => ${2:10}, :scale => ${3:2}\n\ + ${4}\n\ +snippet tcda\n\ + t.date :${1:title}\n\ + ${2}\n\ +snippet tcdt\n\ + t.datetime :${1:title}\n\ + ${2}\n\ +snippet tcf\n\ + t.float :${1:title}\n\ + ${2}\n\ +snippet tch\n\ + t.change :${1:name}, :${2:string}, :${3:limit} => ${4:80}\n\ + ${5}\n\ +snippet tci\n\ + t.integer :${1:title}\n\ + ${2}\n\ +snippet tcl\n\ + t.integer :lock_version, :null => false, :default => 0\n\ + ${1}\n\ +snippet tcr\n\ + t.references :${1:taggable}, :polymorphic => { :default => '${2:Photo}' }\n\ + ${3}\n\ +snippet tcs\n\ + t.string :${1:title}\n\ + ${2}\n\ +snippet tct\n\ + t.text :${1:title}\n\ + ${2}\n\ +snippet tcti\n\ + t.time :${1:title}\n\ + ${2}\n\ +snippet tcts\n\ + t.timestamp :${1:title}\n\ + ${2}\n\ +snippet tctss\n\ + t.timestamps\n\ + ${1}\n\ +snippet va\n\ + validates_associated :${1:attribute}\n\ +snippet vao\n\ + validates_acceptance_of :${1:terms}\n\ +snippet vc\n\ + validates_confirmation_of :${1:attribute}\n\ +snippet ve\n\ + validates_exclusion_of :${1:attribute}, :in => ${2:%w( mov avi )}\n\ +snippet vf\n\ + validates_format_of :${1:attribute}, :with => /${2:regex}/\n\ +snippet vi\n\ + validates_inclusion_of :${1:attribute}, :in => %w(${2: mov avi })\n\ +snippet vl\n\ + validates_length_of :${1:attribute}, :within => ${2:3}..${3:20}\n\ +snippet vn\n\ + validates_numericality_of :${1:attribute}\n\ +snippet vpo\n\ + validates_presence_of :${1:attribute}\n\ +snippet vu\n\ + validates_uniqueness_of :${1:attribute}\n\ +snippet wants\n\ + wants.${1:js|xml|html} { ${2} }\n\ +snippet wc\n\ + where(${1:\"conditions\"}${2:, bind_var})\n\ +snippet wh\n\ + where(${1:field} => ${2:value})\n\ +snippet xdelete\n\ + xhr :delete, :${1:destroy}, :id => ${2:1}${3}\n\ +snippet xget\n\ + xhr :get, :${1:show}, :id => ${2:1}${3}\n\ +snippet xpost\n\ + xhr :post, :${1:create}, :${2:object} => { ${3} }\n\ +snippet xput\n\ + xhr :put, :${1:update}, :id => ${2:1}, :${3:object} => { ${4} }${5}\n\ +snippet test\n\ + test \"should ${1:do something}\" do\n\ + ${2}\n\ + end\n\ +#migrations\n\ +snippet mac\n\ + add_column :${1:table_name}, :${2:column_name}, :${3:data_type}\n\ +snippet mrc\n\ + remove_column :${1:table_name}, :${2:column_name}\n\ +snippet mrnc\n\ + rename_column :${1:table_name}, :${2:old_column_name}, :${3:new_column_name}\n\ +snippet mcc\n\ + change_column :${1:table}, :${2:column}, :${3:type}\n\ +snippet mccc\n\ + t.column :${1:title}, :${2:string}\n\ +snippet mct\n\ + create_table :${1:table_name} do |t|\n\ + t.column :${2:name}, :${3:type}\n\ + end\n\ +snippet migration\n\ + class ${1:class_name} < ActiveRecord::Migration\n\ + def self.up\n\ + ${2}\n\ + end\n\ +\n\ + def self.down\n\ + end\n\ + end\n\ +\n\ +snippet trc\n\ + t.remove :${1:column}\n\ +snippet tre\n\ + t.rename :${1:old_column_name}, :${2:new_column_name}\n\ + ${3}\n\ +snippet tref\n\ + t.references :${1:model}\n\ +\n\ +#rspec\n\ +snippet it\n\ + it \"${1:spec_name}\" do\n\ + ${2}\n\ + end\n\ +snippet itp\n\ + it \"${1:spec_name}\"\n\ + ${2}\n\ +snippet desc\n\ + describe ${1:class_name} do\n\ + ${2}\n\ + end\n\ +snippet cont\n\ + context \"${1:message}\" do\n\ + ${2}\n\ + end\n\ +snippet bef\n\ + before :${1:each} do\n\ + ${2}\n\ + end\n\ +snippet aft\n\ + after :${1:each} do\n\ + ${2}\n\ + end\n\ +"; +exports.scope = "ruby"; + +}); diff --git a/lib/client/edit/snippets/sass.js b/lib/client/edit/snippets/sass.js new file mode 100644 index 00000000..b17eb4d7 --- /dev/null +++ b/lib/client/edit/snippets/sass.js @@ -0,0 +1,7 @@ +ace.define('ace/snippets/sass', ['require', 'exports', 'module' ], function(require, exports, module) { + + +exports.snippetText = ""; +exports.scope = "sass"; + +}); diff --git a/lib/client/edit/snippets/scala.js b/lib/client/edit/snippets/scala.js new file mode 100644 index 00000000..e9f7d033 --- /dev/null +++ b/lib/client/edit/snippets/scala.js @@ -0,0 +1,7 @@ +ace.define('ace/snippets/scala', ['require', 'exports', 'module' ], function(require, exports, module) { + + +exports.snippetText = ""; +exports.scope = "scala"; + +}); diff --git a/lib/client/edit/snippets/sh.js b/lib/client/edit/snippets/sh.js new file mode 100644 index 00000000..b052e858 --- /dev/null +++ b/lib/client/edit/snippets/sh.js @@ -0,0 +1,90 @@ +ace.define('ace/snippets/sh', ['require', 'exports', 'module' ], function(require, exports, module) { + + +exports.snippetText = "# Shebang. Executing bash via /usr/bin/env makes scripts more portable.\n\ +snippet #!\n\ + #!/usr/bin/env bash\n\ + \n\ +snippet if\n\ + if [[ ${1:condition} ]]; then\n\ + ${2:#statements}\n\ + fi\n\ +snippet elif\n\ + elif [[ ${1:condition} ]]; then\n\ + ${2:#statements}\n\ +snippet for\n\ + for (( ${2:i} = 0; $2 < ${1:count}; $2++ )); do\n\ + ${3:#statements}\n\ + done\n\ +snippet fori\n\ + for ${1:needle} in ${2:haystack} ; do\n\ + ${3:#statements}\n\ + done\n\ +snippet wh\n\ + while [[ ${1:condition} ]]; do\n\ + ${2:#statements}\n\ + done\n\ +snippet until\n\ + until [[ ${1:condition} ]]; do\n\ + ${2:#statements}\n\ + done\n\ +snippet case\n\ + case ${1:word} in\n\ + ${2:pattern})\n\ + ${3};;\n\ + esac\n\ +snippet go \n\ + while getopts '${1:o}' ${2:opts} \n\ + do \n\ + case $$2 in\n\ + ${3:o0})\n\ + ${4:#staments};;\n\ + esac\n\ + done\n\ +# Set SCRIPT_DIR variable to directory script is located.\n\ +snippet sdir\n\ + SCRIPT_DIR=\"$( cd \"$( dirname \"${BASH_SOURCE[0]}\" )\" && pwd )\"\n\ +# getopt\n\ +snippet getopt\n\ + __ScriptVersion=\"${1:version}\"\n\ +\n\ + #=== FUNCTION ================================================================\n\ + # NAME: usage\n\ + # DESCRIPTION: Display usage information.\n\ + #===============================================================================\n\ + function usage ()\n\ + {\n\ + cat <<- EOT\n\ +\n\ + Usage : $${0:0} [options] [--] \n\ +\n\ + Options: \n\ + -h|help Display this message\n\ + -v|version Display script version\n\ +\n\ + EOT\n\ + } # ---------- end of function usage ----------\n\ +\n\ + #-----------------------------------------------------------------------\n\ + # Handle command line arguments\n\ + #-----------------------------------------------------------------------\n\ +\n\ + while getopts \":hv\" opt\n\ + do\n\ + case $opt in\n\ +\n\ + h|help ) usage; exit 0 ;;\n\ +\n\ + v|version ) echo \"$${0:0} -- Version $__ScriptVersion\"; exit 0 ;;\n\ +\n\ + \\? ) echo -e \"\\n Option does not exist : $OPTARG\\n\"\n\ + usage; exit 1 ;;\n\ +\n\ + esac # --- end of case ---\n\ + done\n\ + shift $(($OPTIND-1))\n\ +\n\ +"; +exports.scope = "sh"; + +}); diff --git a/lib/client/edit/snippets/snippets.js b/lib/client/edit/snippets/snippets.js new file mode 100644 index 00000000..25b10ecd --- /dev/null +++ b/lib/client/edit/snippets/snippets.js @@ -0,0 +1,16 @@ +ace.define('ace/snippets/snippets', ['require', 'exports', 'module' ], function(require, exports, module) { + + +exports.snippetText = "# snippets for making snippets :)\n\ +snippet snip\n\ + snippet ${1:trigger}\n\ + ${2}\n\ +snippet msnip\n\ + snippet ${1:trigger} ${2:description}\n\ + ${3}\n\ +snippet v\n\ + {VISUAL}\n\ +"; +exports.scope = "snippets"; + +}); diff --git a/lib/client/edit/snippets/sql.js b/lib/client/edit/snippets/sql.js new file mode 100644 index 00000000..a9b359ba --- /dev/null +++ b/lib/client/edit/snippets/sql.js @@ -0,0 +1,33 @@ +ace.define('ace/snippets/sql', ['require', 'exports', 'module' ], function(require, exports, module) { + + +exports.snippetText = "snippet tbl\n\ + create table ${1:table} (\n\ + ${2:columns}\n\ + );\n\ +snippet col\n\ + ${1:name} ${2:type} ${3:default ''} ${4:not null}\n\ +snippet ccol\n\ + ${1:name} varchar2(${2:size}) ${3:default ''} ${4:not null}\n\ +snippet ncol\n\ + ${1:name} number ${3:default 0} ${4:not null}\n\ +snippet dcol\n\ + ${1:name} date ${3:default sysdate} ${4:not null}\n\ +snippet ind\n\ + create index ${3:$1_$2} on ${1:table}(${2:column});\n\ +snippet uind\n\ + create unique index ${1:name} on ${2:table}(${3:column});\n\ +snippet tblcom\n\ + comment on table ${1:table} is '${2:comment}';\n\ +snippet colcom\n\ + comment on column ${1:table}.${2:column} is '${3:comment}';\n\ +snippet addcol\n\ + alter table ${1:table} add (${2:column} ${3:type});\n\ +snippet seq\n\ + create sequence ${1:name} start with ${2:1} increment by ${3:1} minvalue ${4:1};\n\ +snippet s*\n\ + select * from ${1:table}\n\ +"; +exports.scope = "sql"; + +}); diff --git a/lib/client/edit/snippets/stylus.js b/lib/client/edit/snippets/stylus.js new file mode 100644 index 00000000..3369c4c3 --- /dev/null +++ b/lib/client/edit/snippets/stylus.js @@ -0,0 +1,7 @@ +ace.define('ace/snippets/stylus', ['require', 'exports', 'module' ], function(require, exports, module) { + + +exports.snippetText = ""; +exports.scope = "stylus"; + +}); diff --git a/lib/client/edit/snippets/svg.js b/lib/client/edit/snippets/svg.js new file mode 100644 index 00000000..24ff8ed0 --- /dev/null +++ b/lib/client/edit/snippets/svg.js @@ -0,0 +1,7 @@ +ace.define('ace/snippets/svg', ['require', 'exports', 'module' ], function(require, exports, module) { + + +exports.snippetText = ""; +exports.scope = "svg"; + +}); diff --git a/lib/client/edit/snippets/tcl.js b/lib/client/edit/snippets/tcl.js new file mode 100644 index 00000000..4347cbc9 --- /dev/null +++ b/lib/client/edit/snippets/tcl.js @@ -0,0 +1,99 @@ +ace.define('ace/snippets/tcl', ['require', 'exports', 'module' ], function(require, exports, module) { + + +exports.snippetText = "# #!/usr/bin/env tclsh\n\ +snippet #!\n\ + #!/usr/bin/env tclsh\n\ + \n\ +# Process\n\ +snippet pro\n\ + proc ${1:function_name} {${2:args}} {\n\ + ${3:#body ...}\n\ + }\n\ +#xif\n\ +snippet xif\n\ + ${1:expr}? ${2:true} : ${3:false}\n\ +# Conditional\n\ +snippet if\n\ + if {${1}} {\n\ + ${2:# body...}\n\ + }\n\ +# Conditional if..else\n\ +snippet ife\n\ + if {${1}} {\n\ + ${2:# body...}\n\ + } else {\n\ + ${3:# else...}\n\ + }\n\ +# Conditional if..elsif..else\n\ +snippet ifee\n\ + if {${1}} {\n\ + ${2:# body...}\n\ + } elseif {${3}} {\n\ + ${4:# elsif...}\n\ + } else {\n\ + ${5:# else...}\n\ + }\n\ +# If catch then\n\ +snippet ifc\n\ + if { [catch {${1:#do something...}} ${2:err}] } {\n\ + ${3:# handle failure...}\n\ + }\n\ +# Catch\n\ +snippet catch\n\ + catch {${1}} ${2:err} ${3:options}\n\ +# While Loop\n\ +snippet wh\n\ + while {${1}} {\n\ + ${2:# body...}\n\ + }\n\ +# For Loop\n\ +snippet for\n\ + for {set ${2:var} 0} {$$2 < ${1:count}} {${3:incr} $2} {\n\ + ${4:# body...}\n\ + }\n\ +# Foreach Loop\n\ +snippet fore\n\ + foreach ${1:x} {${2:#list}} {\n\ + ${3:# body...}\n\ + }\n\ +# after ms script...\n\ +snippet af\n\ + after ${1:ms} ${2:#do something}\n\ +# after cancel id\n\ +snippet afc\n\ + after cancel ${1:id or script}\n\ +# after idle\n\ +snippet afi\n\ + after idle ${1:script}\n\ +# after info id\n\ +snippet afin\n\ + after info ${1:id}\n\ +# Expr\n\ +snippet exp\n\ + expr {${1:#expression here}}\n\ +# Switch\n\ +snippet sw\n\ + switch ${1:var} {\n\ + ${3:pattern 1} {\n\ + ${4:#do something}\n\ + }\n\ + default {\n\ + ${2:#do something}\n\ + }\n\ + }\n\ +# Case\n\ +snippet ca\n\ + ${1:pattern} {\n\ + ${2:#do something}\n\ + }${3}\n\ +# Namespace eval\n\ +snippet ns\n\ + namespace eval ${1:path} {${2:#script...}}\n\ +# Namespace current\n\ +snippet nsc\n\ + namespace current\n\ +"; +exports.scope = "tcl"; + +}); diff --git a/lib/client/edit/snippets/tex.js b/lib/client/edit/snippets/tex.js new file mode 100644 index 00000000..ce490778 --- /dev/null +++ b/lib/client/edit/snippets/tex.js @@ -0,0 +1,197 @@ +ace.define('ace/snippets/tex', ['require', 'exports', 'module' ], function(require, exports, module) { + + +exports.snippetText = "#PREAMBLE\n\ +#newcommand\n\ +snippet nc\n\ + \\newcommand{\\${1:cmd}}[${2:opt}]{${3:realcmd}}${4}\n\ +#usepackage\n\ +snippet up\n\ + \\usepackage[${1:[options}]{${2:package}}\n\ +#newunicodechar\n\ +snippet nuc\n\ + \\newunicodechar{${1}}{${2:\\ensuremath}${3:tex-substitute}}}\n\ +#DeclareMathOperator\n\ +snippet dmo\n\ + \\DeclareMathOperator{${1}}{${2}}\n\ +\n\ +#DOCUMENT\n\ +# \\begin{}...\\end{}\n\ +snippet begin\n\ + \\begin{${1:env}}\n\ + ${2}\n\ + \\end{$1}\n\ +# Tabular\n\ +snippet tab\n\ + \\begin{${1:tabular}}{${2:c}}\n\ + ${3}\n\ + \\end{$1}\n\ +snippet thm\n\ + \\begin[${1:author}]{${2:thm}}\n\ + ${3}\n\ + \\end{$1}\n\ +snippet center\n\ + \\begin{center}\n\ + ${1}\n\ + \\end{center}\n\ +# Align(ed)\n\ +snippet ali\n\ + \\begin{align${1:ed}}\n\ + ${2}\n\ + \\end{align$1}\n\ +# Gather(ed)\n\ +snippet gat\n\ + \\begin{gather${1:ed}}\n\ + ${2}\n\ + \\end{gather$1}\n\ +# Equation\n\ +snippet eq\n\ + \\begin{equation}\n\ + ${1}\n\ + \\end{equation}\n\ +# Equation\n\ +snippet eq*\n\ + \\begin{equation*}\n\ + ${1}\n\ + \\end{equation*}\n\ +# Unnumbered Equation\n\ +snippet \\\n\ + \\[\n\ + ${1}\n\ + \\]\n\ +# Enumerate\n\ +snippet enum\n\ + \\begin{enumerate}\n\ + \\item ${1}\n\ + \\end{enumerate}\n\ +# Itemize\n\ +snippet itemize\n\ + \\begin{itemize}\n\ + \\item ${1}\n\ + \\end{itemize}\n\ +# Description\n\ +snippet desc\n\ + \\begin{description}\n\ + \\item[${1}] ${2}\n\ + \\end{description}\n\ +# Matrix\n\ +snippet mat\n\ + \\begin{${1:p/b/v/V/B/small}matrix}\n\ + ${2}\n\ + \\end{$1matrix}\n\ +# Cases\n\ +snippet cas\n\ + \\begin{cases}\n\ + ${1:equation}, &\\text{ if }${2:case}\\\\\n\ + ${3}\n\ + \\end{cases}\n\ +# Split\n\ +snippet spl\n\ + \\begin{split}\n\ + ${1}\n\ + \\end{split}\n\ +# Part\n\ +snippet part\n\ + \\part{${1:part name}} % (fold)\n\ + \\label{prt:${2:$1}}\n\ + ${3}\n\ + % part $2 (end)\n\ +# Chapter\n\ +snippet cha\n\ + \\chapter{${1:chapter name}}\n\ + \\label{cha:${2:$1}}\n\ + ${3}\n\ +# Section\n\ +snippet sec\n\ + \\section{${1:section name}}\n\ + \\label{sec:${2:$1}}\n\ + ${3}\n\ +# Sub Section\n\ +snippet sub\n\ + \\subsection{${1:subsection name}}\n\ + \\label{sub:${2:$1}}\n\ + ${3}\n\ +# Sub Sub Section\n\ +snippet subs\n\ + \\subsubsection{${1:subsubsection name}}\n\ + \\label{ssub:${2:$1}}\n\ + ${3}\n\ +# Paragraph\n\ +snippet par\n\ + \\paragraph{${1:paragraph name}}\n\ + \\label{par:${2:$1}}\n\ + ${3}\n\ +# Sub Paragraph\n\ +snippet subp\n\ + \\subparagraph{${1:subparagraph name}}\n\ + \\label{subp:${2:$1}}\n\ + ${3}\n\ +#References\n\ +snippet itd\n\ + \\item[${1:description}] ${2:item}\n\ +snippet figure\n\ + ${1:Figure}~\\ref{${2:fig:}}${3}\n\ +snippet table\n\ + ${1:Table}~\\ref{${2:tab:}}${3}\n\ +snippet listing\n\ + ${1:Listing}~\\ref{${2:list}}${3}\n\ +snippet section\n\ + ${1:Section}~\\ref{${2:sec:}}${3}\n\ +snippet page\n\ + ${1:page}~\\pageref{${2}}${3}\n\ +snippet index\n\ + \\index{${1:index}}${2}\n\ +#Citations\n\ +snippet cite\n\ + \\cite[${1}]{${2}}${3}\n\ +snippet fcite\n\ + \\footcite[${1}]{${2}}${3}\n\ +#Formating text: italic, bold, underline, small capital, emphase ..\n\ +snippet it\n\ + \\textit{${1:text}}\n\ +snippet bf\n\ + \\textbf{${1:text}}\n\ +snippet under\n\ + \\underline{${1:text}}\n\ +snippet emp\n\ + \\emph{${1:text}}\n\ +snippet sc\n\ + \\textsc{${1:text}}\n\ +#Choosing font\n\ +snippet sf\n\ + \\textsf{${1:text}}\n\ +snippet rm\n\ + \\textrm{${1:text}}\n\ +snippet tt\n\ + \\texttt{${1:text}}\n\ +#misc\n\ +snippet ft\n\ + \\footnote{${1:text}}\n\ +snippet fig\n\ + \\begin{figure}\n\ + \\begin{center}\n\ + \\includegraphics[scale=${1}]{Figures/${2}}\n\ + \\end{center}\n\ + \\caption{${3}}\n\ + \\label{fig:${4}}\n\ + \\end{figure}\n\ +snippet tikz\n\ + \\begin{figure}\n\ + \\begin{center}\n\ + \\begin{tikzpicture}[scale=${1:1}]\n\ + ${2}\n\ + \\end{tikzpicture}\n\ + \\end{center}\n\ + \\caption{${3}}\n\ + \\label{fig:${4}}\n\ + \\end{figure}\n\ +#math\n\ +snippet stackrel\n\ + \\stackrel{${1:above}}{${2:below}} ${3}\n\ +snippet frac\n\ + \\frac{${1:num}}{${2:denom}}\n\ +snippet sum\n\ + \\sum^{${1:n}}_{${2:i=1}}{${3}}"; +exports.scope = "tex"; + +}); diff --git a/lib/client/edit/snippets/text.js b/lib/client/edit/snippets/text.js new file mode 100644 index 00000000..0834cfca --- /dev/null +++ b/lib/client/edit/snippets/text.js @@ -0,0 +1,7 @@ +ace.define('ace/snippets/text', ['require', 'exports', 'module' ], function(require, exports, module) { + + +exports.snippetText = ""; +exports.scope = "text"; + +}); diff --git a/lib/client/edit/snippets/textile.js b/lib/client/edit/snippets/textile.js new file mode 100644 index 00000000..106849b7 --- /dev/null +++ b/lib/client/edit/snippets/textile.js @@ -0,0 +1,37 @@ +ace.define('ace/snippets/textile', ['require', 'exports', 'module' ], function(require, exports, module) { + + +exports.snippetText = "# Jekyll post header\n\ +snippet header\n\ + ---\n\ + title: ${1:title}\n\ + layout: post\n\ + date: ${2:date} ${3:hour:minute:second} -05:00\n\ + ---\n\ +\n\ +# Image\n\ +snippet img\n\ + !${1:url}(${2:title}):${3:link}!\n\ +\n\ +# Table\n\ +snippet |\n\ + |${1}|${2}\n\ +\n\ +# Link\n\ +snippet link\n\ + \"${1:link text}\":${2:url}\n\ +\n\ +# Acronym\n\ +snippet (\n\ + (${1:Expand acronym})${2}\n\ +\n\ +# Footnote\n\ +snippet fn\n\ + [${1:ref number}] ${3}\n\ +\n\ + fn$1. ${2:footnote}\n\ + \n\ +"; +exports.scope = "textile"; + +}); diff --git a/lib/client/edit/snippets/typescript.js b/lib/client/edit/snippets/typescript.js new file mode 100644 index 00000000..0c0affd4 --- /dev/null +++ b/lib/client/edit/snippets/typescript.js @@ -0,0 +1,7 @@ +ace.define('ace/snippets/typescript', ['require', 'exports', 'module' ], function(require, exports, module) { + + +exports.snippetText = ""; +exports.scope = "typescript"; + +}); diff --git a/lib/client/edit/snippets/xml.js b/lib/client/edit/snippets/xml.js new file mode 100644 index 00000000..d26f8fdf --- /dev/null +++ b/lib/client/edit/snippets/xml.js @@ -0,0 +1,7 @@ +ace.define('ace/snippets/xml', ['require', 'exports', 'module' ], function(require, exports, module) { + + +exports.snippetText = ""; +exports.scope = "xml"; + +}); diff --git a/lib/client/edit/snippets/yaml.js b/lib/client/edit/snippets/yaml.js new file mode 100644 index 00000000..1c2df806 --- /dev/null +++ b/lib/client/edit/snippets/yaml.js @@ -0,0 +1,7 @@ +ace.define('ace/snippets/yaml', ['require', 'exports', 'module' ], function(require, exports, module) { + + +exports.snippetText = ""; +exports.scope = "yaml"; + +}); diff --git a/lib/client/edit/worker-javascript.js b/lib/client/edit/worker-javascript.js index 8beac737..08d7e996 100644 --- a/lib/client/edit/worker-javascript.js +++ b/lib/client/edit/worker-javascript.js @@ -19,15 +19,15 @@ window.ace = window; window.normalizeModule = function(parentId, moduleName) { if (moduleName.indexOf("!") !== -1) { var chunks = moduleName.split("!"); - return normalizeModule(parentId, chunks[0]) + "!" + normalizeModule(parentId, chunks[1]); + return window.normalizeModule(parentId, chunks[0]) + "!" + window.normalizeModule(parentId, chunks[1]); } if (moduleName.charAt(0) == ".") { var base = parentId.split("/").slice(0, -1).join("/"); - moduleName = base + "/" + moduleName; + moduleName = (base ? base + "/" : "") + moduleName; while(moduleName.indexOf(".") !== -1 && previous != moduleName) { var previous = moduleName; - moduleName = moduleName.replace(/\/\.\//, "/").replace(/[^\/]+\/\.\.\//, ""); + moduleName = moduleName.replace(/^\.\//, "").replace(/\/\.\//, "/").replace(/[^\/]+\/\.\.\//, ""); } } @@ -42,9 +42,9 @@ window.require = function(parentId, id) { if (!id.charAt) throw new Error("worker.js require() accepts only (parentId, id) as arguments"); - id = normalizeModule(parentId, id); + id = window.normalizeModule(parentId, id); - var module = require.modules[id]; + var module = window.require.modules[id]; if (module) { if (!module.initialized) { module.initialized = true; @@ -54,47 +54,60 @@ window.require = function(parentId, id) { } var chunks = id.split("/"); - chunks[0] = require.tlns[chunks[0]] || chunks[0]; + if (!window.require.tlns) + return console.log("unable to load " + id); + chunks[0] = window.require.tlns[chunks[0]] || chunks[0]; var path = chunks.join("/") + ".js"; - require.id = id; + window.require.id = id; importScripts(path); - return require(parentId, id); + return window.require(parentId, id); }; - -require.modules = {}; -require.tlns = {}; +window.require.modules = {}; +window.require.tlns = {}; window.define = function(id, deps, factory) { if (arguments.length == 2) { factory = deps; if (typeof id != "string") { deps = id; - id = require.id; + id = window.require.id; } } else if (arguments.length == 1) { factory = id; - id = require.id; + deps = [] + id = window.require.id; } + if (!deps.length) + deps = ['require', 'exports', 'module'] + if (id.indexOf("text!") === 0) return; - var req = function(deps, factory) { - return require(id, deps, factory); + var req = function(childId) { + return window.require(id, childId); }; - require.modules[id] = { + window.require.modules[id] = { exports: {}, factory: function() { var module = this; - var returnExports = factory(req, module.exports, module); + var returnExports = factory.apply(this, deps.map(function(dep) { + switch(dep) { + case 'require': return req + case 'exports': return module.exports + case 'module': return module + default: return req(dep) + } + })); if (returnExports) module.exports = returnExports; return module; } }; }; +window.define.amd = {} window.initBaseUrls = function initBaseUrls(topLevelNamespaces) { require.tlns = topLevelNamespaces; @@ -102,8 +115,8 @@ window.initBaseUrls = function initBaseUrls(topLevelNamespaces) { window.initSender = function initSender() { - var EventEmitter = require("ace/lib/event_emitter").EventEmitter; - var oop = require("ace/lib/oop"); + var EventEmitter = window.require("ace/lib/event_emitter").EventEmitter; + var oop = window.require("ace/lib/oop"); var Sender = function() {}; @@ -154,158 +167,7 @@ window.onmessage = function(e) { sender._emit(msg.event, msg.data); } }; -})(this); - -ace.define('ace/lib/event_emitter', ['require', 'exports', 'module' ], function(require, exports, module) { - - -var EventEmitter = {}; -var stopPropagation = function() { this.propagationStopped = true; }; -var preventDefault = function() { this.defaultPrevented = true; }; - -EventEmitter._emit = -EventEmitter._dispatchEvent = function(eventName, e) { - this._eventRegistry || (this._eventRegistry = {}); - this._defaultHandlers || (this._defaultHandlers = {}); - - var listeners = this._eventRegistry[eventName] || []; - var defaultHandler = this._defaultHandlers[eventName]; - if (!listeners.length && !defaultHandler) - return; - - if (typeof e != "object" || !e) - e = {}; - - if (!e.type) - e.type = eventName; - if (!e.stopPropagation) - e.stopPropagation = stopPropagation; - if (!e.preventDefault) - e.preventDefault = preventDefault; - - for (var i=0; i 2; + if (obj == null) obj = []; + if (nativeReduce && obj.reduce === nativeReduce) { + if (context) iterator = _.bind(iterator, context); + return initial ? obj.reduce(iterator, memo) : obj.reduce(iterator); + } + each(obj, function(value, index, list) { + if (!initial) { + memo = value; + initial = true; + } else { + memo = iterator.call(context, memo, value, index, list); + } + }); + if (!initial) throw new TypeError(reduceError); + return memo; + }; + _.reduceRight = _.foldr = function(obj, iterator, memo, context) { + var initial = arguments.length > 2; + if (obj == null) obj = []; + if (nativeReduceRight && obj.reduceRight === nativeReduceRight) { + if (context) iterator = _.bind(iterator, context); + return initial ? obj.reduceRight(iterator, memo) : obj.reduceRight(iterator); + } + var length = obj.length; + if (length !== +length) { + var keys = _.keys(obj); + length = keys.length; + } + each(obj, function(value, index, list) { + index = keys ? keys[--length] : --length; + if (!initial) { + memo = obj[index]; + initial = true; + } else { + memo = iterator.call(context, memo, obj[index], index, list); + } + }); + if (!initial) throw new TypeError(reduceError); + return memo; + }; + _.find = _.detect = function(obj, iterator, context) { + var result; + any(obj, function(value, index, list) { + if (iterator.call(context, value, index, list)) { + result = value; + return true; + } + }); + return result; + }; + _.filter = _.select = function(obj, iterator, context) { + var results = []; + if (obj == null) return results; + if (nativeFilter && obj.filter === nativeFilter) return obj.filter(iterator, context); + each(obj, function(value, index, list) { + if (iterator.call(context, value, index, list)) results[results.length] = value; + }); + return results; + }; + _.reject = function(obj, iterator, context) { + return _.filter(obj, function(value, index, list) { + return !iterator.call(context, value, index, list); + }, context); + }; + _.every = _.all = function(obj, iterator, context) { + iterator || (iterator = _.identity); + var result = true; + if (obj == null) return result; + if (nativeEvery && obj.every === nativeEvery) return obj.every(iterator, context); + each(obj, function(value, index, list) { + if (!(result = result && iterator.call(context, value, index, list))) return breaker; + }); + return !!result; + }; + var any = _.some = _.any = function(obj, iterator, context) { + iterator || (iterator = _.identity); + var result = false; + if (obj == null) return result; + if (nativeSome && obj.some === nativeSome) return obj.some(iterator, context); + each(obj, function(value, index, list) { + if (result || (result = iterator.call(context, value, index, list))) return breaker; + }); + return !!result; + }; + _.contains = _.include = function(obj, target) { + if (obj == null) return false; + if (nativeIndexOf && obj.indexOf === nativeIndexOf) return obj.indexOf(target) != -1; + return any(obj, function(value) { + return value === target; + }); + }; + _.invoke = function(obj, method) { + var args = slice.call(arguments, 2); + var isFunc = _.isFunction(method); + return _.map(obj, function(value) { + return (isFunc ? method : value[method]).apply(value, args); + }); + }; + _.pluck = function(obj, key) { + return _.map(obj, function(value){ return value[key]; }); + }; + _.where = function(obj, attrs, first) { + if (_.isEmpty(attrs)) return first ? null : []; + return _[first ? 'find' : 'filter'](obj, function(value) { + for (var key in attrs) { + if (attrs[key] !== value[key]) return false; + } + return true; + }); + }; + _.findWhere = function(obj, attrs) { + return _.where(obj, attrs, true); + }; + _.max = function(obj, iterator, context) { + if (!iterator && _.isArray(obj) && obj[0] === +obj[0] && obj.length < 65535) { + return Math.max.apply(Math, obj); + } + if (!iterator && _.isEmpty(obj)) return -Infinity; + var result = {computed : -Infinity, value: -Infinity}; + each(obj, function(value, index, list) { + var computed = iterator ? iterator.call(context, value, index, list) : value; + computed >= result.computed && (result = {value : value, computed : computed}); + }); + return result.value; + }; + _.min = function(obj, iterator, context) { + if (!iterator && _.isArray(obj) && obj[0] === +obj[0] && obj.length < 65535) { + return Math.min.apply(Math, obj); + } + if (!iterator && _.isEmpty(obj)) return Infinity; + var result = {computed : Infinity, value: Infinity}; + each(obj, function(value, index, list) { + var computed = iterator ? iterator.call(context, value, index, list) : value; + computed < result.computed && (result = {value : value, computed : computed}); + }); + return result.value; + }; + _.shuffle = function(obj) { + var rand; + var index = 0; + var shuffled = []; + each(obj, function(value) { + rand = _.random(index++); + shuffled[index - 1] = shuffled[rand]; + shuffled[rand] = value; + }); + return shuffled; + }; + var lookupIterator = function(value) { + return _.isFunction(value) ? value : function(obj){ return obj[value]; }; + }; + _.sortBy = function(obj, value, context) { + var iterator = lookupIterator(value); + return _.pluck(_.map(obj, function(value, index, list) { + return { + value : value, + index : index, + criteria : iterator.call(context, value, index, list) + }; + }).sort(function(left, right) { + var a = left.criteria; + var b = right.criteria; + if (a !== b) { + if (a > b || a === void 0) return 1; + if (a < b || b === void 0) return -1; + } + return left.index < right.index ? -1 : 1; + }), 'value'); + }; + var group = function(obj, value, context, behavior) { + var result = {}; + var iterator = lookupIterator(value || _.identity); + each(obj, function(value, index) { + var key = iterator.call(context, value, index, obj); + behavior(result, key, value); + }); + return result; + }; + _.groupBy = function(obj, value, context) { + return group(obj, value, context, function(result, key, value) { + (_.has(result, key) ? result[key] : (result[key] = [])).push(value); + }); + }; + _.countBy = function(obj, value, context) { + return group(obj, value, context, function(result, key) { + if (!_.has(result, key)) result[key] = 0; + result[key]++; + }); + }; + _.sortedIndex = function(array, obj, iterator, context) { + iterator = iterator == null ? _.identity : lookupIterator(iterator); + var value = iterator.call(context, obj); + var low = 0, high = array.length; + while (low < high) { + var mid = (low + high) >>> 1; + iterator.call(context, array[mid]) < value ? low = mid + 1 : high = mid; + } + return low; + }; + _.toArray = function(obj) { + if (!obj) return []; + if (_.isArray(obj)) return slice.call(obj); + if (obj.length === +obj.length) return _.map(obj, _.identity); + return _.values(obj); + }; + _.size = function(obj) { + if (obj == null) return 0; + return (obj.length === +obj.length) ? obj.length : _.keys(obj).length; + }; + _.first = _.head = _.take = function(array, n, guard) { + if (array == null) return void 0; + return (n != null) && !guard ? slice.call(array, 0, n) : array[0]; + }; + _.initial = function(array, n, guard) { + return slice.call(array, 0, array.length - ((n == null) || guard ? 1 : n)); + }; + _.last = function(array, n, guard) { + if (array == null) return void 0; + if ((n != null) && !guard) { + return slice.call(array, Math.max(array.length - n, 0)); + } else { + return array[array.length - 1]; + } + }; + _.rest = _.tail = _.drop = function(array, n, guard) { + return slice.call(array, (n == null) || guard ? 1 : n); + }; + _.compact = function(array) { + return _.filter(array, _.identity); + }; + var flatten = function(input, shallow, output) { + each(input, function(value) { + if (_.isArray(value)) { + shallow ? push.apply(output, value) : flatten(value, shallow, output); + } else { + output.push(value); + } + }); + return output; + }; + _.flatten = function(array, shallow) { + return flatten(array, shallow, []); + }; + _.without = function(array) { + return _.difference(array, slice.call(arguments, 1)); + }; + _.uniq = _.unique = function(array, isSorted, iterator, context) { + if (_.isFunction(isSorted)) { + context = iterator; + iterator = isSorted; + isSorted = false; + } + var initial = iterator ? _.map(array, iterator, context) : array; + var results = []; + var seen = []; + each(initial, function(value, index) { + if (isSorted ? (!index || seen[seen.length - 1] !== value) : !_.contains(seen, value)) { + seen.push(value); + results.push(array[index]); + } + }); + return results; + }; + _.union = function() { + return _.uniq(concat.apply(ArrayProto, arguments)); + }; + _.intersection = function(array) { + var rest = slice.call(arguments, 1); + return _.filter(_.uniq(array), function(item) { + return _.every(rest, function(other) { + return _.indexOf(other, item) >= 0; + }); + }); + }; + _.difference = function(array) { + var rest = concat.apply(ArrayProto, slice.call(arguments, 1)); + return _.filter(array, function(value){ return !_.contains(rest, value); }); + }; + _.zip = function() { + var args = slice.call(arguments); + var length = _.max(_.pluck(args, 'length')); + var results = new Array(length); + for (var i = 0; i < length; i++) { + results[i] = _.pluck(args, "" + i); + } + return results; + }; + _.object = function(list, values) { + if (list == null) return {}; + var result = {}; + for (var i = 0, l = list.length; i < l; i++) { + if (values) { + result[list[i]] = values[i]; + } else { + result[list[i][0]] = list[i][1]; + } + } + return result; + }; + _.indexOf = function(array, item, isSorted) { + if (array == null) return -1; + var i = 0, l = array.length; + if (isSorted) { + if (typeof isSorted == 'number') { + i = (isSorted < 0 ? Math.max(0, l + isSorted) : isSorted); + } else { + i = _.sortedIndex(array, item); + return array[i] === item ? i : -1; + } + } + if (nativeIndexOf && array.indexOf === nativeIndexOf) return array.indexOf(item, isSorted); + for (; i < l; i++) if (array[i] === item) return i; + return -1; + }; + _.lastIndexOf = function(array, item, from) { + if (array == null) return -1; + var hasIndex = from != null; + if (nativeLastIndexOf && array.lastIndexOf === nativeLastIndexOf) { + return hasIndex ? array.lastIndexOf(item, from) : array.lastIndexOf(item); + } + var i = (hasIndex ? from : array.length); + while (i--) if (array[i] === item) return i; + return -1; + }; + _.range = function(start, stop, step) { + if (arguments.length <= 1) { + stop = start || 0; + start = 0; + } + step = arguments[2] || 1; - if (canSetImmediate) { - return function (f) { return window.setImmediate(f) }; + var len = Math.max(Math.ceil((stop - start) / step), 0); + var idx = 0; + var range = new Array(len); + + while(idx < len) { + range[idx++] = start; + start += step; } - if (canPost) { - var queue = []; - window.addEventListener('message', function (ev) { - if (ev.source === window && ev.data === 'process-tick') { - ev.stopPropagation(); - if (queue.length > 0) { - var fn = queue.shift(); - fn(); - } - } - }, true); - - return function nextTick(fn) { - queue.push(fn); - window.postMessage('process-tick', '*'); - }; - } - - return function nextTick(fn) { - setTimeout(fn, 0); + return range; + }; + _.bind = function(func, context) { + if (func.bind === nativeBind && nativeBind) return nativeBind.apply(func, slice.call(arguments, 1)); + var args = slice.call(arguments, 2); + return function() { + return func.apply(context, args.concat(slice.call(arguments))); }; -})(); + }; + _.partial = function(func) { + var args = slice.call(arguments, 1); + return function() { + return func.apply(this, args.concat(slice.call(arguments))); + }; + }; + _.bindAll = function(obj) { + var funcs = slice.call(arguments, 1); + if (funcs.length === 0) funcs = _.functions(obj); + each(funcs, function(f) { obj[f] = _.bind(obj[f], obj); }); + return obj; + }; + _.memoize = function(func, hasher) { + var memo = {}; + hasher || (hasher = _.identity); + return function() { + var key = hasher.apply(this, arguments); + return _.has(memo, key) ? memo[key] : (memo[key] = func.apply(this, arguments)); + }; + }; + _.delay = function(func, wait) { + var args = slice.call(arguments, 2); + return setTimeout(function(){ return func.apply(null, args); }, wait); + }; + _.defer = function(func) { + return _.delay.apply(_, [func, 1].concat(slice.call(arguments, 1))); + }; + _.throttle = function(func, wait) { + var context, args, timeout, result; + var previous = 0; + var later = function() { + previous = new Date; + timeout = null; + result = func.apply(context, args); + }; + return function() { + var now = new Date; + var remaining = wait - (now - previous); + context = this; + args = arguments; + if (remaining <= 0) { + clearTimeout(timeout); + timeout = null; + previous = now; + result = func.apply(context, args); + } else if (!timeout) { + timeout = setTimeout(later, remaining); + } + return result; + }; + }; + _.debounce = function(func, wait, immediate) { + var timeout, result; + return function() { + var context = this, args = arguments; + var later = function() { + timeout = null; + if (!immediate) result = func.apply(context, args); + }; + var callNow = immediate && !timeout; + clearTimeout(timeout); + timeout = setTimeout(later, wait); + if (callNow) result = func.apply(context, args); + return result; + }; + }; + _.once = function(func) { + var ran = false, memo; + return function() { + if (ran) return memo; + ran = true; + memo = func.apply(this, arguments); + func = null; + return memo; + }; + }; + _.wrap = function(func, wrapper) { + return function() { + var args = [func]; + push.apply(args, arguments); + return wrapper.apply(this, args); + }; + }; + _.compose = function() { + var funcs = arguments; + return function() { + var args = arguments; + for (var i = funcs.length - 1; i >= 0; i--) { + args = [funcs[i].apply(this, args)]; + } + return args[0]; + }; + }; + _.after = function(times, func) { + if (times <= 0) return func(); + return function() { + if (--times < 1) { + return func.apply(this, arguments); + } + }; + }; + _.keys = nativeKeys || function(obj) { + if (obj !== Object(obj)) throw new TypeError('Invalid object'); + var keys = []; + for (var key in obj) if (_.has(obj, key)) keys[keys.length] = key; + return keys; + }; + _.values = function(obj) { + var values = []; + for (var key in obj) if (_.has(obj, key)) values.push(obj[key]); + return values; + }; + _.pairs = function(obj) { + var pairs = []; + for (var key in obj) if (_.has(obj, key)) pairs.push([key, obj[key]]); + return pairs; + }; + _.invert = function(obj) { + var result = {}; + for (var key in obj) if (_.has(obj, key)) result[obj[key]] = key; + return result; + }; + _.functions = _.methods = function(obj) { + var names = []; + for (var key in obj) { + if (_.isFunction(obj[key])) names.push(key); + } + return names.sort(); + }; + _.extend = function(obj) { + each(slice.call(arguments, 1), function(source) { + if (source) { + for (var prop in source) { + obj[prop] = source[prop]; + } + } + }); + return obj; + }; + _.pick = function(obj) { + var copy = {}; + var keys = concat.apply(ArrayProto, slice.call(arguments, 1)); + each(keys, function(key) { + if (key in obj) copy[key] = obj[key]; + }); + return copy; + }; + _.omit = function(obj) { + var copy = {}; + var keys = concat.apply(ArrayProto, slice.call(arguments, 1)); + for (var key in obj) { + if (!_.contains(keys, key)) copy[key] = obj[key]; + } + return copy; + }; + _.defaults = function(obj) { + each(slice.call(arguments, 1), function(source) { + if (source) { + for (var prop in source) { + if (obj[prop] == null) obj[prop] = source[prop]; + } + } + }); + return obj; + }; + _.clone = function(obj) { + if (!_.isObject(obj)) return obj; + return _.isArray(obj) ? obj.slice() : _.extend({}, obj); + }; + _.tap = function(obj, interceptor) { + interceptor(obj); + return obj; + }; + var eq = function(a, b, aStack, bStack) { + if (a === b) return a !== 0 || 1 / a == 1 / b; + if (a == null || b == null) return a === b; + if (a instanceof _) a = a._wrapped; + if (b instanceof _) b = b._wrapped; + var className = toString.call(a); + if (className != toString.call(b)) return false; + switch (className) { + case '[object String]': + return a == String(b); + case '[object Number]': + return a != +a ? b != +b : (a == 0 ? 1 / a == 1 / b : a == +b); + case '[object Date]': + case '[object Boolean]': + return +a == +b; + case '[object RegExp]': + return a.source == b.source && + a.global == b.global && + a.multiline == b.multiline && + a.ignoreCase == b.ignoreCase; + } + if (typeof a != 'object' || typeof b != 'object') return false; + var length = aStack.length; + while (length--) { + if (aStack[length] == a) return bStack[length] == b; + } + aStack.push(a); + bStack.push(b); + var size = 0, result = true; + if (className == '[object Array]') { + size = a.length; + result = size == b.length; + if (result) { + while (size--) { + if (!(result = eq(a[size], b[size], aStack, bStack))) break; + } + } + } else { + var aCtor = a.constructor, bCtor = b.constructor; + if (aCtor !== bCtor && !(_.isFunction(aCtor) && (aCtor instanceof aCtor) && + _.isFunction(bCtor) && (bCtor instanceof bCtor))) { + return false; + } + for (var key in a) { + if (_.has(a, key)) { + size++; + if (!(result = _.has(b, key) && eq(a[key], b[key], aStack, bStack))) break; + } + } + if (result) { + for (key in b) { + if (_.has(b, key) && !(size--)) break; + } + result = !size; + } + } + aStack.pop(); + bStack.pop(); + return result; + }; + _.isEqual = function(a, b) { + return eq(a, b, [], []); + }; + _.isEmpty = function(obj) { + if (obj == null) return true; + if (_.isArray(obj) || _.isString(obj)) return obj.length === 0; + for (var key in obj) if (_.has(obj, key)) return false; + return true; + }; + _.isElement = function(obj) { + return !!(obj && obj.nodeType === 1); + }; + _.isArray = nativeIsArray || function(obj) { + return toString.call(obj) == '[object Array]'; + }; + _.isObject = function(obj) { + return obj === Object(obj); + }; + each(['Arguments', 'Function', 'String', 'Number', 'Date', 'RegExp'], function(name) { + _['is' + name] = function(obj) { + return toString.call(obj) == '[object ' + name + ']'; + }; + }); + if (!_.isArguments(arguments)) { + _.isArguments = function(obj) { + return !!(obj && _.has(obj, 'callee')); + }; + } + if (typeof (/./) !== 'function') { + _.isFunction = function(obj) { + return typeof obj === 'function'; + }; + } + _.isFinite = function(obj) { + return isFinite(obj) && !isNaN(parseFloat(obj)); + }; + _.isNaN = function(obj) { + return _.isNumber(obj) && obj != +obj; + }; + _.isBoolean = function(obj) { + return obj === true || obj === false || toString.call(obj) == '[object Boolean]'; + }; + _.isNull = function(obj) { + return obj === null; + }; + _.isUndefined = function(obj) { + return obj === void 0; + }; + _.has = function(obj, key) { + return hasOwnProperty.call(obj, key); + }; + _.noConflict = function() { + root._ = previousUnderscore; + return this; + }; + _.identity = function(value) { + return value; + }; + _.times = function(n, iterator, context) { + var accum = Array(n); + for (var i = 0; i < n; i++) accum[i] = iterator.call(context, i); + return accum; + }; + _.random = function(min, max) { + if (max == null) { + max = min; + min = 0; + } + return min + Math.floor(Math.random() * (max - min + 1)); + }; + var entityMap = { + escape: { + '&': '&', + '<': '<', + '>': '>', + '"': '"', + "'": ''', + '/': '/' + } + }; + entityMap.unescape = _.invert(entityMap.escape); + var entityRegexes = { + escape: new RegExp('[' + _.keys(entityMap.escape).join('') + ']', 'g'), + unescape: new RegExp('(' + _.keys(entityMap.unescape).join('|') + ')', 'g') + }; + _.each(['escape', 'unescape'], function(method) { + _[method] = function(string) { + if (string == null) return ''; + return ('' + string).replace(entityRegexes[method], function(match) { + return entityMap[method][match]; + }); + }; + }); + _.result = function(object, property) { + if (object == null) return null; + var value = object[property]; + return _.isFunction(value) ? value.call(object) : value; + }; + _.mixin = function(obj) { + each(_.functions(obj), function(name){ + var func = _[name] = obj[name]; + _.prototype[name] = function() { + var args = [this._wrapped]; + push.apply(args, arguments); + return result.call(this, func.apply(_, args)); + }; + }); + }; + var idCounter = 0; + _.uniqueId = function(prefix) { + var id = ++idCounter + ''; + return prefix ? prefix + id : id; + }; + _.templateSettings = { + evaluate : /<%([\s\S]+?)%>/g, + interpolate : /<%=([\s\S]+?)%>/g, + escape : /<%-([\s\S]+?)%>/g + }; + var noMatch = /(.)^/; + var escapes = { + "'": "'", + '\\': '\\', + '\r': 'r', + '\n': 'n', + '\t': 't', + '\u2028': 'u2028', + '\u2029': 'u2029' + }; -process.title = 'browser'; -process.browser = true; -process.env = {}; -process.argv = []; + var escaper = /\\|'|\r|\n|\t|\u2028|\u2029/g; + _.template = function(text, data, settings) { + var render; + settings = _.defaults({}, settings, _.templateSettings); + var matcher = new RegExp([ + (settings.escape || noMatch).source, + (settings.interpolate || noMatch).source, + (settings.evaluate || noMatch).source + ].join('|') + '|$', 'g'); + var index = 0; + var source = "__p+='"; + text.replace(matcher, function(match, escape, interpolate, evaluate, offset) { + source += text.slice(index, offset) + .replace(escaper, function(match) { return '\\' + escapes[match]; }); -process.binding = function (name) { - throw new Error('process.binding is not supported'); -} -process.cwd = function () { return '/' }; -process.chdir = function (dir) { - throw new Error('process.chdir is not supported'); -}; + if (escape) { + source += "'+\n((__t=(" + escape + "))==null?'':_.escape(__t))+\n'"; + } + if (interpolate) { + source += "'+\n((__t=(" + interpolate + "))==null?'':__t)+\n'"; + } + if (evaluate) { + source += "';\n" + evaluate + "\n__p+='"; + } + index = offset + match.length; + return match; + }); + source += "';\n"; + if (!settings.variable) source = 'with(obj||{}){\n' + source + '}\n'; + + source = "var __t,__p='',__j=Array.prototype.join," + + "print=function(){__p+=__j.call(arguments,'');};\n" + + source + "return __p;\n"; + + try { + render = new Function(settings.variable || 'obj', '_', source); + } catch (e) { + e.source = source; + throw e; + } + + if (data) return render(data, _); + var template = function(data) { + return render.call(this, data, _); + }; + template.source = 'function(' + (settings.variable || 'obj') + '){\n' + source + '}'; + + return template; + }; + _.chain = function(obj) { + return _(obj).chain(); + }; + var result = function(obj) { + return this._chain ? _(obj).chain() : obj; + }; + _.mixin(_); + each(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(name) { + var method = ArrayProto[name]; + _.prototype[name] = function() { + var obj = this._wrapped; + method.apply(obj, arguments); + if ((name == 'shift' || name == 'splice') && obj.length === 0) delete obj[0]; + return result.call(this, obj); + }; + }); + each(['concat', 'join', 'slice'], function(name) { + var method = ArrayProto[name]; + _.prototype[name] = function() { + return result.call(this, method.apply(this._wrapped, arguments)); + }; + }); + + _.extend(_.prototype, { + chain: function() { + this._chain = true; + return this; + }, + value: function() { + return this._wrapped; + } + + }); + +}).call(this); }, {}], 2:[function(req,module,exports){ -(function(process){if (!process.EventEmitter) process.EventEmitter = function () {}; -var EventEmitter = exports.EventEmitter = process.EventEmitter; -var isArray = typeof Array.isArray === 'function' - ? Array.isArray - : function (xs) { - return Object.prototype.toString.call(xs) === '[object Array]' - } -; -function indexOf (xs, x) { - if (xs.indexOf) return xs.indexOf(x); - for (var i = 0; i < xs.length; i++) { - if (x === xs[i]) return i; - } - return -1; -} -var defaultMaxListeners = 200; -EventEmitter.prototype.setMaxListeners = function(n) { - if (!this._events) this._events = {}; - this._events.maxListeners = n; + +var _ = req("underscore"); + +var errors = { + E001: "Bad option: '{a}'.", + E002: "Bad option value.", + E003: "Expected a JSON value.", + E004: "Input is neither a string nor an array of strings.", + E005: "Input is empty.", + E006: "Unexpected early end of program.", + E007: "Missing \"use strict\" statement.", + E008: "Strict violation.", + E009: "Option 'validthis' can't be used in a global scope.", + E010: "'with' is not allowed in strict mode.", + E011: "const '{a}' has already been declared.", + E012: "const '{a}' is initialized to 'undefined'.", + E013: "Attempting to override '{a}' which is a constant.", + E014: "A regular expression literal can be confused with '/='.", + E015: "Unclosed regular expression.", + E016: "Invalid regular expression.", + E017: "Unclosed comment.", + E018: "Unbegun comment.", + E019: "Unmatched '{a}'.", + E020: "Expected '{a}' to match '{b}' from line {c} and instead saw '{d}'.", + E021: "Expected '{a}' and instead saw '{b}'.", + E022: "Line breaking error '{a}'.", + E023: "Missing '{a}'.", + E024: "Unexpected '{a}'.", + E025: "Missing ':' on a case clause.", + E026: "Missing '}' to match '{' from line {a}.", + E027: "Missing ']' to match '[' form line {a}.", + E028: "Illegal comma.", + E029: "Unclosed string.", + E030: "Expected an identifier and instead saw '{a}'.", + E031: "Bad assignment.", // FIXME: Rephrase + E032: "Expected a small integer or 'false' and instead saw '{a}'.", + E033: "Expected an operator and instead saw '{a}'.", + E034: "get/set are ES5 features.", + E035: "Missing property name.", + E036: "Expected to see a statement and instead saw a block.", + E037: null, // Vacant + E038: null, // Vacant + E039: "Function declarations are not invocable. Wrap the whole function invocation in parens.", + E040: "Each value should have its own case label.", + E041: "Unrecoverable syntax error.", + E042: "Stopping.", + E043: "Too many errors.", + E044: "'{a}' is already defined and can't be redefined.", + E045: "Invalid for each loop.", + E046: "A yield statement shall be within a generator function (with syntax: `function*`)", + E047: "A generator function shall contain a yield statement.", + E048: "Let declaration not directly within block.", + E049: "A {a} cannot be named '{b}'.", + E050: "Mozilla requires the yield expression to be parenthesized here.", + E051: "Regular parameters cannot come after default parameters." }; - -EventEmitter.prototype.emit = function(type) { - if (type === 'error') { - if (!this._events || !this._events.error || - (isArray(this._events.error) && !this._events.error.length)) - { - if (arguments[1] instanceof Error) { - throw arguments[1]; // Unhandled 'error' event - } else { - throw new Error("Uncaught, unspecified 'error' event."); - } - return false; - } - } - - if (!this._events) return false; - var handler = this._events[type]; - if (!handler) return false; - - if (typeof handler == 'function') { - switch (arguments.length) { - case 1: - handler.call(this); - break; - case 2: - handler.call(this, arguments[1]); - break; - case 3: - handler.call(this, arguments[1], arguments[2]); - break; - default: - var args = Array.prototype.slice.call(arguments, 1); - handler.apply(this, args); - } - return true; - - } else if (isArray(handler)) { - var args = Array.prototype.slice.call(arguments, 1); - - var listeners = handler.slice(); - for (var i = 0, l = listeners.length; i < l; i++) { - listeners[i].apply(this, args); - } - return true; - - } else { - return false; - } -}; -EventEmitter.prototype.addListener = function(type, listener) { - if ('function' !== typeof listener) { - throw new Error('addListener only takes instances of Function'); - } - - if (!this._events) this._events = {}; - this.emit('newListener', type, listener); - - if (!this._events[type]) { - this._events[type] = listener; - } else if (isArray(this._events[type])) { - if (!this._events[type].warned) { - var m; - if (this._events.maxListeners !== undefined) { - m = this._events.maxListeners; - } else { - m = defaultMaxListeners; - } - - if (m && m > 0 && this._events[type].length > m) { - this._events[type].warned = true; - console.error('(node) warning: possible EventEmitter memory ' + - 'leak detected. %d listeners added. ' + - 'Use emitter.setMaxListeners() to increase limit.', - this._events[type].length); - console.trace(); - } - } - this._events[type].push(listener); - } else { - this._events[type] = [this._events[type], listener]; - } - - return this; +var warnings = { + W001: "'hasOwnProperty' is a really bad name.", + W002: "Value of '{a}' may be overwritten in IE 8 and earlier.", + W003: "'{a}' was used before it was defined.", + W004: "'{a}' is already defined.", + W005: "A dot following a number can be confused with a decimal point.", + W006: "Confusing minuses.", + W007: "Confusing pluses.", + W008: "A leading decimal point can be confused with a dot: '{a}'.", + W009: "The array literal notation [] is preferrable.", + W010: "The object literal notation {} is preferrable.", + W011: "Unexpected space after '{a}'.", + W012: "Unexpected space before '{a}'.", + W013: "Missing space after '{a}'.", + W014: "Bad line breaking before '{a}'.", + W015: "Expected '{a}' to have an indentation at {b} instead at {c}.", + W016: "Unexpected use of '{a}'.", + W017: "Bad operand.", + W018: "Confusing use of '{a}'.", + W019: "Use the isNaN function to compare with NaN.", + W020: "Read only.", + W021: "'{a}' is a function.", + W022: "Do not assign to the exception parameter.", + W023: "Expected an identifier in an assignment and instead saw a function invocation.", + W024: "Expected an identifier and instead saw '{a}' (a reserved word).", + W025: "Missing name in function declaration.", + W026: "Inner functions should be listed at the top of the outer function.", + W027: "Unreachable '{a}' after '{b}'.", + W028: "Label '{a}' on {b} statement.", + W030: "Expected an assignment or function call and instead saw an expression.", + W031: "Do not use 'new' for side effects.", + W032: "Unnecessary semicolon.", + W033: "Missing semicolon.", + W034: "Unnecessary directive \"{a}\".", + W035: "Empty block.", + W036: "Unexpected /*member '{a}'.", + W037: "'{a}' is a statement label.", + W038: "'{a}' used out of scope.", + W039: "'{a}' is not allowed.", + W040: "Possible strict violation.", + W041: "Use '{a}' to compare with '{b}'.", + W042: "Avoid EOL escaping.", + W043: "Bad escaping of EOL. Use option multistr if needed.", + W044: "Bad or unnecessary escaping.", + W045: "Bad number '{a}'.", + W046: "Don't use extra leading zeros '{a}'.", + W047: "A trailing decimal point can be confused with a dot: '{a}'.", + W048: "Unexpected control character in regular expression.", + W049: "Unexpected escaped character '{a}' in regular expression.", + W050: "JavaScript URL.", + W051: "Variables should not be deleted.", + W052: "Unexpected '{a}'.", + W053: "Do not use {a} as a constructor.", + W054: "The Function constructor is a form of eval.", + W055: "A constructor name should start with an uppercase letter.", + W056: "Bad constructor.", + W057: "Weird construction. Is 'new' unnecessary?", + W058: "Missing '()' invoking a constructor.", + W059: "Avoid arguments.{a}.", + W060: "document.write can be a form of eval.", + W061: "eval can be harmful.", + W062: "Wrap an immediate function invocation in parens " + + "to assist the reader in understanding that the expression " + + "is the result of a function, and not the function itself.", + W063: "Math is not a function.", + W064: "Missing 'new' prefix when invoking a constructor.", + W065: "Missing radix parameter.", + W066: "Implied eval. Consider passing a function instead of a string.", + W067: "Bad invocation.", + W068: "Wrapping non-IIFE function literals in parens is unnecessary.", + W069: "['{a}'] is better written in dot notation.", + W070: "Extra comma. (it breaks older versions of IE)", + W071: "This function has too many statements. ({a})", + W072: "This function has too many parameters. ({a})", + W073: "Blocks are nested too deeply. ({a})", + W074: "This function's cyclomatic complexity is too high. ({a})", + W075: "Duplicate key '{a}'.", + W076: "Unexpected parameter '{a}' in get {b} function.", + W077: "Expected a single parameter in set {a} function.", + W078: "Setter is defined without getter.", + W079: "Redefinition of '{a}'.", + W080: "It's not necessary to initialize '{a}' to 'undefined'.", + W081: "Too many var statements.", + W082: "Function declarations should not be placed in blocks. " + + "Use a function expression or move the statement to the top of " + + "the outer function.", + W083: "Don't make functions within a loop.", + W084: "Assignment in conditional expression", + W085: "Don't use 'with'.", + W086: "Expected a 'break' statement before '{a}'.", + W087: "Forgotten 'debugger' statement?", + W088: "Creating global 'for' variable. Should be 'for (var {a} ...'.", + W089: "The body of a for in should be wrapped in an if statement to filter " + + "unwanted properties from the prototype.", + W090: "'{a}' is not a statement label.", + W091: "'{a}' is out of scope.", + W092: "Wrap the /regexp/ literal in parens to disambiguate the slash operator.", + W093: "Did you mean to return a conditional instead of an assignment?", + W094: "Unexpected comma.", + W095: "Expected a string and instead saw {a}.", + W096: "The '{a}' key may produce unexpected results.", + W097: "Use the function form of \"use strict\".", + W098: "'{a}' is defined but never used.", + W099: "Mixed spaces and tabs.", + W100: "This character may get silently deleted by one or more browsers.", + W101: "Line is too long.", + W102: "Trailing whitespace.", + W103: "The '{a}' property is deprecated.", + W104: "'{a}' is only available in JavaScript 1.7.", + W105: "Unexpected {a} in '{b}'.", + W106: "Identifier '{a}' is not in camel case.", + W107: "Script URL.", + W108: "Strings must use doublequote.", + W109: "Strings must use singlequote.", + W110: "Mixed double and single quotes.", + W112: "Unclosed string.", + W113: "Control character in string: {a}.", + W114: "Avoid {a}.", + W115: "Octal literals are not allowed in strict mode.", + W116: "Expected '{a}' and instead saw '{b}'.", + W117: "'{a}' is not defined.", + W118: "'{a}' is only available in Mozilla JavaScript extensions (use moz option).", + W119: "'{a}' is only available in ES6 (use esnext option).", + W120: "You might be leaking a variable ({a}) here." }; -EventEmitter.prototype.on = EventEmitter.prototype.addListener; - -EventEmitter.prototype.once = function(type, listener) { - var self = this; - self.on(type, function g() { - self.removeListener(type, g); - listener.apply(this, arguments); - }); - - return this; +var info = { + I001: "Comma warnings can be turned off with 'laxcomma'.", + I002: "Reserved words as properties can be used under the 'es5' option.", + I003: "ES5 option is now set per default" }; -EventEmitter.prototype.removeListener = function(type, listener) { - if ('function' !== typeof listener) { - throw new Error('removeListener only takes instances of Function'); - } - if (!this._events || !this._events[type]) return this; +exports.errors = {}; +exports.warnings = {}; +exports.info = {}; - var list = this._events[type]; +_.each(errors, function (desc, code) { + exports.errors[code] = { code: code, desc: desc }; +}); - if (isArray(list)) { - var i = indexOf(list, listener); - if (i < 0) return this; - list.splice(i, 1); - if (list.length == 0) - delete this._events[type]; - } else if (this._events[type] === listener) { - delete this._events[type]; - } +_.each(warnings, function (desc, code) { + exports.warnings[code] = { code: code, desc: desc }; +}); - return this; -}; +_.each(info, function (desc, code) { + exports.info[code] = { code: code, desc: desc }; +}); -EventEmitter.prototype.removeAllListeners = function(type) { - if (arguments.length === 0) { - this._events = {}; - return this; - } - if (type && this._events && this._events[type]) this._events[type] = null; - return this; -}; - -EventEmitter.prototype.listeners = function(type) { - if (!this._events) this._events = {}; - if (!this._events[type]) this._events[type] = []; - if (!isArray(this._events[type])) { - this._events[type] = [this._events[type]]; - } - return this._events[type]; -}; - -})(req("__browserify_process")) }, -{"__browserify_process":1}], +{"underscore":1}], 3:[function(req,module,exports){ -(function(){// jshint -W001 exports.reservedVars = { arguments : false, @@ -2379,6 +3264,7 @@ exports.browser = { clearTimeout : false, close : false, closed : false, + CustomEvent : false, DataView : false, DOMParser : false, defaultStatus : false, @@ -2458,6 +3344,7 @@ exports.browser = { MessageChannel : false, MessageEvent : false, MessagePort : false, + MouseEvent : false, moveBy : false, moveTo : false, MutationObserver : false, @@ -2896,283 +3783,9 @@ exports.yui = { }; -})() }, {}], -4:[function(req,module,exports){ - -"use string"; -exports.unsafeString = - /@cc|<\/?|script|\]\s*\]|<\s*!|</i; -exports.unsafeChars = - /[\u0000-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/; -exports.needEsc = - /[\u0000-\u001f&<"\/\\\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/; - -exports.needEscGlobal = - /[\u0000-\u001f&<"\/\\\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g; -exports.starSlash = /\*\//; -exports.identifier = /^([a-zA-Z_$][a-zA-Z0-9_$]*)$/; -exports.javascriptURL = /^(?:javascript|jscript|ecmascript|vbscript|mocha|livescript)\s*:/i; -exports.fallsThrough = /^\s*\/\*\s*falls?\sthrough\s*\*\/\s*$/; - -}, -{}], -5:[function(req,module,exports){ - - -var state = { - syntax: {}, - - reset: function () { - this.tokens = { - prev: null, - next: null, - curr: null - }; - - this.option = {}; - this.ignored = {}; - this.directive = {}; - this.jsonMode = false; - this.jsonWarnings = []; - this.lines = []; - this.tab = ""; - this.cache = {}; // Node.JS doesn't have Map. Sniff. - } -}; - -exports.state = state; - -}, -{}], -6:[function(req,module,exports){ -(function(){ - -exports.register = function (linter) { - - linter.on("Identifier", function style_scanProto(data) { - if (linter.getOption("proto")) { - return; - } - - if (data.name === "__proto__") { - linter.warn("W103", { - line: data.line, - char: data.char, - data: [ data.name ] - }); - } - }); - - linter.on("Identifier", function style_scanIterator(data) { - if (linter.getOption("iterator")) { - return; - } - - if (data.name === "__iterator__") { - linter.warn("W104", { - line: data.line, - char: data.char, - data: [ data.name ] - }); - } - }); - - linter.on("Identifier", function style_scanDangling(data) { - if (!linter.getOption("nomen")) { - return; - } - if (data.name === "_") { - return; - } - if (linter.getOption("node")) { - if (/^(__dirname|__filename)$/.test(data.name) && !data.isProperty) { - return; - } - } - - if (/^(_+.*|.*_+)$/.test(data.name)) { - linter.warn("W105", { - line: data.line, - char: data.from, - data: [ "dangling '_'", data.name ] - }); - } - }); - - linter.on("Identifier", function style_scanCamelCase(data) { - if (!linter.getOption("camelcase")) { - return; - } - - if (data.name.replace(/^_+/, "").indexOf("_") > -1 && !data.name.match(/^[A-Z0-9_]*$/)) { - linter.warn("W106", { - line: data.line, - char: data.from, - data: [ data.name ] - }); - } - }); - - linter.on("String", function style_scanQuotes(data) { - var quotmark = linter.getOption("quotmark"); - var code; - - if (!quotmark) { - return; - } - - if (quotmark === "single" && data.quote !== "'") { - code = "W109"; - } - - if (quotmark === "double" && data.quote !== "\"") { - code = "W108"; - } - - if (quotmark === true) { - if (!linter.getCache("quotmark")) { - linter.setCache("quotmark", data.quote); - } - - if (linter.getCache("quotmark") !== data.quote) { - code = "W110"; - } - } - - if (code) { - linter.warn(code, { - line: data.line, - char: data.char, - }); - } - }); - - linter.on("Number", function style_scanNumbers(data) { - if (data.value.charAt(0) === ".") { - linter.warn("W008", { - line: data.line, - char: data.char, - data: [ data.value ] - }); - } - - if (data.value.substr(data.value.length - 1) === ".") { - linter.warn("W047", { - line: data.line, - char: data.char, - data: [ data.value ] - }); - } - - if (/^00+/.test(data.value)) { - linter.warn("W046", { - line: data.line, - char: data.char, - data: [ data.value ] - }); - } - }); - - linter.on("String", function style_scanJavaScriptURLs(data) { - var re = /^(?:javascript|jscript|ecmascript|vbscript|mocha|livescript)\s*:/i; - - if (linter.getOption("scripturl")) { - return; - } - - if (re.test(data.value)) { - linter.warn("W107", { - line: data.line, - char: data.char - }); - } - }); -}; -})() -}, -{}], -7:[function(req,module,exports){ -(function(global){/*global window, global*/ -var functions = [ - [log, "log"] - , [info, "info"] - , [warn, "warn"] - , [error, "error"] - , [time, "time"] - , [timeEnd, "timeEnd"] - , [trace, "trace"] - , [dir, "dir"] - , [assert, "assert"] -] - -for (var i = 0; i < functions.length; i++) { - var tuple = functions[i] - var f = tuple[0] - var name = tuple[1] - - if (!console[name]) { - console[name] = f - } -} - -module.exports = console - -function log() {} - -function info() {} - -function warn() {} - -function error() {} - -function time(label) {} - -function timeEnd(label) {} - -function trace() {} - -function dir(object) {} - -function assert(expression) {} - -})(window) -}, -{}], -"jshint":[function(req,module,exports){ -module.exports=req('E/GbHF'); -}, -{}],"E/GbHF":[function(req,module,exports){ -(function(){/*! - * JSHint, by JSHint Community. - * - * This file (and this file only) is licensed under the same slightly modified - * MIT license that JSLint is. It stops evil-doers everywhere: - * - * Copyright (c) 2002 Douglas Crockford (www.JSLint.com) - * - * 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 shall be used for Good, not Evil. - * - * 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. - * - */ +"n4bKNg":[function(req,module,exports){ var _ = req("underscore"); var events = req("events"); @@ -3369,12 +3982,13 @@ var JSHINT = (function () { if (!token.reserved) { return false; } + var meta = token.meta; - if (token.meta && token.meta.isFutureReservedWord) { - if (state.option.inES5(true) && !token.meta.es5) { + if (meta && meta.isFutureReservedWord && state.option.inES5()) { + if (!meta.es5) { return false; } - if (token.meta.strictOnly) { + if (meta.strictOnly) { if (!state.option.strict && !state.directive["use strict"]) { return false; } @@ -3421,6 +4035,7 @@ var JSHINT = (function () { if (state.option.shelljs) { combine(predefined, vars.shelljs); + combine(predefined, vars.node); } if (state.option.phantom) { @@ -3503,7 +4118,8 @@ var JSHINT = (function () { line: line, character: chr, message: message + " (" + percentage + "% scanned).", - raw: message + raw: message, + code: code }; } @@ -3647,14 +4263,14 @@ var JSHINT = (function () { function doOption() { var nt = state.tokens.next; - var body = nt.body.split(",").map(function (s) { return s.trim(); }); + var body = nt.body.match(/(-\s+)?[^\s,]+(?:\s*:\s*(-\s+)?[^\s,]+)?/g); var predef = {}; if (nt.type === "globals") { body.forEach(function (g) { g = g.split(":"); - var key = g[0]; - var val = g[1]; + var key = (g[0] || "").trim(); + var val = (g[1] || "").trim(); if (key.charAt(0) === "-") { key = key.slice(1); @@ -3921,6 +4537,22 @@ var JSHINT = (function () { } } + function isInfix(token) { + return token.infix || (!token.identifier && !!token.led); + } + + function isEndOfExpr() { + var curr = state.tokens.curr; + var next = state.tokens.next; + if (next.id === ";" || next.id === "}" || next.id === ":") { + return true; + } + if (isInfix(next) === isInfix(curr) || (curr.id === "yield" && state.option.inMoz(true))) { + return curr.line !== next.line; + } + return false; + } + function expression(rbp, initial) { var left, isArray = false, isObject = false, isLetExpr = false; if (!initial && state.tokens.next.value === "let" && peek(0).value === "(") { @@ -3954,10 +4586,7 @@ var JSHINT = (function () { error("E030", state.tokens.curr, state.tokens.curr.id); } - var end_of_expr = state.tokens.next.identifier && - !state.tokens.curr.led && - state.tokens.curr.line !== state.tokens.next.line; - while (rbp < state.tokens.next.lbp && !end_of_expr) { + while (rbp < state.tokens.next.lbp && !isEndOfExpr()) { isArray = state.tokens.curr.value === "Array"; isObject = state.tokens.curr.value === "Object"; if (left && (left.value || (left.first && left.first.value))) { @@ -4042,7 +4671,7 @@ var JSHINT = (function () { left = left || state.tokens.curr; right = right || state.tokens.next; if (!state.option.laxbreak && left.line !== right.line) { - warning("W014", right, right.id); + warning("W014", right, right.value); } else if (state.option.white) { left = left || state.tokens.curr; right = right || state.tokens.next; @@ -4075,26 +4704,29 @@ var JSHINT = (function () { } } + function nobreakcomma(left, right) { + if (left.line !== right.line) { + if (!state.option.laxcomma) { + if (comma.first) { + warning("I001"); + comma.first = false; + } + warning("W014", left, right.value); + } + } else if (!left.comment && left.character !== right.from && state.option.white) { + left.from += (left.character - left.from); + warning("W011", left, left.value); + } + } function comma(opts) { opts = opts || {}; if (!opts.peek) { - if (state.tokens.curr.line !== state.tokens.next.line) { - if (!state.option.laxcomma) { - if (comma.first) { - warning("I001"); - comma.first = false; - } - warning("W014", state.tokens.curr, state.tokens.next.value); - } - } else if (!state.tokens.curr.comment && - state.tokens.curr.character !== state.tokens.next.from && state.option.white) { - state.tokens.curr.from += (state.tokens.curr.character - state.tokens.curr.from); - warning("W011", state.tokens.curr, state.tokens.curr.value); - } - + nobreakcomma(state.tokens.curr, state.tokens.next); advance(","); + } else { + nobreakcomma(state.tokens.prev, state.tokens.curr); } if (state.tokens.next.value !== "]" && state.tokens.next.value !== "}") { @@ -4116,7 +4748,6 @@ var JSHINT = (function () { case "in": case "instanceof": case "return": - case "yield": case "switch": case "throw": case "try": @@ -4243,6 +4874,7 @@ var JSHINT = (function () { function infix(s, f, p, w) { var x = symbol(s, p); reserveName(x); + x.infix = true; x.led = function (left) { if (!w) { nobreaknonadjacent(state.tokens.prev, state.tokens.curr); @@ -4324,10 +4956,8 @@ var JSHINT = (function () { node.type === "undefined"); } - function assignop(s) { - symbol(s, 20).exps = true; - - return infix(s, function (left, that) { + function assignop(s, f, p) { + var x = infix(s, typeof f === "function" ? f : function (left, that) { that.left = left; if (left) { @@ -4349,7 +4979,7 @@ var JSHINT = (function () { warning("E031", that); } - that.right = expression(19); + that.right = expression(10); return that; } else if (left.id === "[") { if (state.tokens.curr.left.first) { @@ -4363,13 +4993,13 @@ var JSHINT = (function () { } else if (left.left.value === "arguments" && !state.directive["use strict"]) { warning("E031", that); } - that.right = expression(19); + that.right = expression(10); return that; } else if (left.identifier && !isReserved(left)) { if (funct[left.value] === "exception") { warning("W022", left); } - that.right = expression(19); + that.right = expression(10); return that; } @@ -4379,7 +5009,11 @@ var JSHINT = (function () { } error("E031", that); - }, 20); + }, p); + + x.exps = true; + x.assign = true; + return x; } @@ -4399,8 +5033,7 @@ var JSHINT = (function () { function bitwiseassignop(s) { - symbol(s, 20).exps = true; - return infix(s, function (left, that) { + return assignop(s, function (left, that) { if (state.option.bitwise) { warning("W016", that, that.id); } @@ -4409,7 +5042,7 @@ var JSHINT = (function () { if (left) { if (left.id === "." || left.id === "[" || (left.identifier && !isReserved(left))) { - expression(19); + expression(10); return that; } if (left === state.syntax["function"]) { @@ -4446,7 +5079,6 @@ var JSHINT = (function () { advance(); var curr = state.tokens.curr; - var meta = curr.meta || {}; var val = state.tokens.curr.value; if (!isReserved(curr)) { @@ -4454,7 +5086,7 @@ var JSHINT = (function () { } if (prop) { - if (state.option.inES5() || meta.isFutureReservedWord) { + if (state.option.inES5()) { return val; } } @@ -4535,7 +5167,7 @@ var JSHINT = (function () { isundef(funct, "W117", tok.token, tok.id); }); advance("="); - destructuringExpressionMatch(values, expression(5, true)); + destructuringExpressionMatch(values, expression(10, true)); advance(";"); return; } @@ -4742,7 +5374,7 @@ var JSHINT = (function () { } } } - expression(5); + expression(10); if (state.option.strict && funct["(context)"]["(global)"]) { if (!m["use strict"] && !state.directive["use strict"]) { @@ -4987,7 +5619,7 @@ var JSHINT = (function () { return that; } while (true) { - if (!(expr = expression(5))) { + if (!(expr = expression(10))) { break; } that.exprs.push(expr); @@ -4996,8 +5628,10 @@ var JSHINT = (function () { } } return that; - }, 5, true); + }, 10, true); + infix("?", function (left, that) { + increaseComplexityCount(); that.left = left; that.right = expression(10); advance(":"); @@ -5005,7 +5639,13 @@ var JSHINT = (function () { return that; }, 30); - infix("||", "or", 40); + var orPrecendence = 40; + infix("||", function (left, that) { + increaseComplexityCount(); + that.left = left; + that.right = expression(orPrecendence); + return that; + }, orPrecendence); infix("&&", "and", 50); bitwise("|", "bitor", 70); bitwise("^", "bitxor", 80); @@ -5099,7 +5739,7 @@ var JSHINT = (function () { prefix("--", "predec"); state.syntax["--"].exps = true; prefix("delete", function () { - var p = expression(5); + var p = expression(10); if (!p || (p.id !== "." && p.id !== "[")) { warning("W051"); } @@ -5330,7 +5970,7 @@ var JSHINT = (function () { exprs.push(bracket.left[t].token); } } else { - exprs.push(expression(5)); + exprs.push(expression(10)); } if (state.tokens.next.id !== ",") { break; @@ -5371,7 +6011,7 @@ var JSHINT = (function () { infix("[", function (left, that) { nobreak(state.tokens.prev, state.tokens.curr); nospace(); - var e = expression(5), s; + var e = expression(10), s; if (e && e.type === "(string)") { if (!state.option.evil && (e.value === "eval" || e.value === "execScript")) { warning("W061", that); @@ -5402,7 +6042,7 @@ var JSHINT = (function () { res.exps = true; funct["(comparray)"].stack(); - res.right = expression(5); + res.right = expression(10); advance("for"); if (state.tokens.next.value === "each") { advance("each"); @@ -5412,13 +6052,13 @@ var JSHINT = (function () { } advance("("); funct["(comparray)"].setState("define"); - res.left = expression(5); + res.left = expression(10); advance(")"); if (state.tokens.next.value === "if") { advance("if"); advance("("); funct["(comparray)"].setState("filter"); - res.filter = expression(5); + res.filter = expression(10); advance(")"); } advance("]"); @@ -5503,6 +6143,7 @@ var JSHINT = (function () { var ident; var tokens = []; var t; + var pastDefault = false; if (parsed) { if (parsed instanceof Array) { @@ -5568,6 +6209,19 @@ var JSHINT = (function () { params.push(ident); addlabel(ident, "unused", state.tokens.curr); } + if (pastDefault) { + if (state.tokens.next.id !== "=") { + error("E051", state.tokens.current); + } + } + if (state.tokens.next.id === "=") { + if (!state.option.inESNext()) { + warning("W119", state.tokens.next, "default parameters"); + } + advance("="); + pastDefault = true; + expression(10); + } if (state.tokens.next.id === ",") { comma(); } else { @@ -6007,9 +6661,9 @@ var JSHINT = (function () { warning("W080", state.tokens.prev, state.tokens.prev.value); } if (peek(0).id === "=" && state.tokens.next.identifier) { - error("E037", state.tokens.next, state.tokens.next.value); + warning("W120", state.tokens.next, state.tokens.next.value); } - value = expression(5); + value = expression(10); if (lone) { tokens[0].first = value; } else { @@ -6072,9 +6726,9 @@ var JSHINT = (function () { warning("W080", state.tokens.prev, state.tokens.prev.value); } if (peek(0).id === "=" && state.tokens.next.identifier) { - error("E038", state.tokens.next, state.tokens.next.value); + warning("W120", state.tokens.next, state.tokens.next.value); } - value = expression(5); + value = expression(10); if (lone) { tokens[0].first = value; } else { @@ -6152,9 +6806,9 @@ var JSHINT = (function () { warning("W080", state.tokens.prev, state.tokens.prev.value); } if (peek(0).id === "=" && state.tokens.next.identifier) { - error("E037", state.tokens.next, state.tokens.next.value); + warning("W120", state.tokens.next, state.tokens.next.value); } - value = expression(5); + value = expression(10); if (lone) { tokens[0].first = value; } else { @@ -6729,30 +7383,39 @@ var JSHINT = (function () { return this; }).exps = true; - stmt("yield", function () { - if (state.option.inESNext(true) && funct["(generator)"] !== true) { + (function (x) { + x.exps = true; + x.lbp = 25; + }(prefix("yield", function () { + var prev = state.tokens.prev; + if (state.option.inESNext(true) && !funct["(generator)"]) { error("E046", state.tokens.curr, "yield"); } else if (!state.option.inESNext()) { warning("W104", state.tokens.curr, "yield"); } funct["(generator)"] = "yielded"; - if (this.line === state.tokens.next.line) { + if (this.line === state.tokens.next.line || !state.option.inMoz(true)) { if (state.tokens.next.id === "(regexp)") warning("W092"); - if (state.tokens.next.id !== ";" && !state.tokens.next.reach) { - nonadjacent(state.tokens.curr, state.tokens.next); - this.first = expression(0); + if (state.tokens.next.id !== ";" && !state.tokens.next.reach && state.tokens.next.nud) { + nobreaknonadjacent(state.tokens.curr, state.tokens.next); + this.first = expression(10); if (this.first.type === "(punctuator)" && this.first.value === "=" && !state.option.boss) { warningAt("W093", this.first.line, this.first.character); } } + + if (state.option.inMoz(true) && state.tokens.next.id !== ")" && + (prev.lbp > 30 || (!prev.assign && !isEndOfExpr()) || prev.id === "yield")) { + error("E050", this); + } } else if (!state.option.asi) { nolinebreak(this); // always warn (Line breaking error) } return this; - }).exps = true; + }))); stmt("throw", function () { @@ -6763,6 +7426,104 @@ var JSHINT = (function () { return this; }).exps = true; + stmt("import", function () { + if (!state.option.inESNext()) { + warning("W119", state.tokens.curr, "import"); + } + + if (state.tokens.next.identifier) { + this.name = identifier(); + addlabel(this.name, "unused", state.tokens.curr); + } else { + advance("{"); + for (;;) { + var importName; + if (state.tokens.next.type === "default") { + importName = "default"; + advance("default"); + } else { + importName = identifier(); + } + if (state.tokens.next.value === "as") { + advance("as"); + importName = identifier(); + } + addlabel(importName, "unused", state.tokens.curr); + + if (state.tokens.next.value === ",") { + advance(","); + } else if (state.tokens.next.value === "}") { + advance("}"); + break; + } else { + error("E024", state.tokens.next, state.tokens.next.value); + break; + } + } + } + + advance("from"); + advance("(string)"); + return this; + }).exps = true; + + stmt("export", function () { + if (!state.option.inESNext()) { + warning("W119", state.tokens.curr, "export"); + } + + if (state.tokens.next.type === "default") { + advance("default"); + if (state.tokens.next.id === "function" || state.tokens.next.id === "class") { + this.block = true; + } + this.exportee = expression(10); + + return this; + } + + if (state.tokens.next.value === "{") { + advance("{"); + for (;;) { + identifier(); + + if (state.tokens.next.value === ",") { + advance(","); + } else if (state.tokens.next.value === "}") { + advance("}"); + break; + } else { + error("E024", state.tokens.next, state.tokens.next.value); + break; + } + } + return this; + } + + if (state.tokens.next.id === "var") { + advance("var"); + state.syntax["var"].fud.call(state.syntax["var"].fud); + } else if (state.tokens.next.id === "let") { + advance("let"); + state.syntax["let"].fud.call(state.syntax["let"].fud); + } else if (state.tokens.next.id === "const") { + advance("const"); + state.syntax["const"].fud.call(state.syntax["const"].fud); + } else if (state.tokens.next.id === "function") { + this.block = true; + advance("function"); + state.syntax["function"].fud(); + } else if (state.tokens.next.id === "class") { + this.block = true; + advance("class"); + state.syntax["class"].fud(); + } else { + error("E024", state.tokens.next, state.tokens.next.value); + } + + return this; + }).exps = true; + FutureReservedWord("abstract"); FutureReservedWord("boolean"); FutureReservedWord("byte"); @@ -7396,6 +8157,7 @@ var JSHINT = (function () { JSHINT.errors.push({ scope : "(main)", raw : err.raw, + code : err.code, reason : err.message, line : err.line || nt.line, character : err.character || nt.from @@ -7507,220 +8269,9 @@ if (typeof exports === "object" && exports) { exports.JSHINT = JSHINT; } -})() }, -{"events":2,"../shared/vars.js":3,"../shared/messages.js":10,"./lex.js":11,"./reg.js":4,"./state.js":5,"./style.js":6,"console-browserify":7,"underscore":12}], -10:[function(req,module,exports){ -(function(){ - -var _ = req("underscore"); - -var errors = { - E001: "Bad option: '{a}'.", - E002: "Bad option value.", - E003: "Expected a JSON value.", - E004: "Input is neither a string nor an array of strings.", - E005: "Input is empty.", - E006: "Unexpected early end of program.", - E007: "Missing \"use strict\" statement.", - E008: "Strict violation.", - E009: "Option 'validthis' can't be used in a global scope.", - E010: "'with' is not allowed in strict mode.", - E011: "const '{a}' has already been declared.", - E012: "const '{a}' is initialized to 'undefined'.", - E013: "Attempting to override '{a}' which is a constant.", - E014: "A regular expression literal can be confused with '/='.", - E015: "Unclosed regular expression.", - E016: "Invalid regular expression.", - E017: "Unclosed comment.", - E018: "Unbegun comment.", - E019: "Unmatched '{a}'.", - E020: "Expected '{a}' to match '{b}' from line {c} and instead saw '{d}'.", - E021: "Expected '{a}' and instead saw '{b}'.", - E022: "Line breaking error '{a}'.", - E023: "Missing '{a}'.", - E024: "Unexpected '{a}'.", - E025: "Missing ':' on a case clause.", - E026: "Missing '}' to match '{' from line {a}.", - E027: "Missing ']' to match '[' form line {a}.", - E028: "Illegal comma.", - E029: "Unclosed string.", - E030: "Expected an identifier and instead saw '{a}'.", - E031: "Bad assignment.", // FIXME: Rephrase - E032: "Expected a small integer or 'false' and instead saw '{a}'.", - E033: "Expected an operator and instead saw '{a}'.", - E034: "get/set are ES5 features.", - E035: "Missing property name.", - E036: "Expected to see a statement and instead saw a block.", - E037: "Constant {a} was not declared correctly.", - E038: "Variable {a} was not declared correctly.", - E039: "Function declarations are not invocable. Wrap the whole function invocation in parens.", - E040: "Each value should have its own case label.", - E041: "Unrecoverable syntax error.", - E042: "Stopping.", - E043: "Too many errors.", - E044: "'{a}' is already defined and can't be redefined.", - E045: "Invalid for each loop.", - E046: "A yield statement shall be within a generator function (with syntax: `function*`)", - E047: "A generator function shall contain a yield statement.", - E048: "Let declaration not directly within block.", - E049: "A {a} cannot be named '{b}'." -}; - -var warnings = { - W001: "'hasOwnProperty' is a really bad name.", - W002: "Value of '{a}' may be overwritten in IE 8 and earlier.", - W003: "'{a}' was used before it was defined.", - W004: "'{a}' is already defined.", - W005: "A dot following a number can be confused with a decimal point.", - W006: "Confusing minuses.", - W007: "Confusing pluses.", - W008: "A leading decimal point can be confused with a dot: '{a}'.", - W009: "The array literal notation [] is preferrable.", - W010: "The object literal notation {} is preferrable.", - W011: "Unexpected space after '{a}'.", - W012: "Unexpected space before '{a}'.", - W013: "Missing space after '{a}'.", - W014: "Bad line breaking before '{a}'.", - W015: "Expected '{a}' to have an indentation at {b} instead at {c}.", - W016: "Unexpected use of '{a}'.", - W017: "Bad operand.", - W018: "Confusing use of '{a}'.", - W019: "Use the isNaN function to compare with NaN.", - W020: "Read only.", - W021: "'{a}' is a function.", - W022: "Do not assign to the exception parameter.", - W023: "Expected an identifier in an assignment and instead saw a function invocation.", - W024: "Expected an identifier and instead saw '{a}' (a reserved word).", - W025: "Missing name in function declaration.", - W026: "Inner functions should be listed at the top of the outer function.", - W027: "Unreachable '{a}' after '{b}'.", - W028: "Label '{a}' on {b} statement.", - W030: "Expected an assignment or function call and instead saw an expression.", - W031: "Do not use 'new' for side effects.", - W032: "Unnecessary semicolon.", - W033: "Missing semicolon.", - W034: "Unnecessary directive \"{a}\".", - W035: "Empty block.", - W036: "Unexpected /*member '{a}'.", - W037: "'{a}' is a statement label.", - W038: "'{a}' used out of scope.", - W039: "'{a}' is not allowed.", - W040: "Possible strict violation.", - W041: "Use '{a}' to compare with '{b}'.", - W042: "Avoid EOL escaping.", - W043: "Bad escaping of EOL. Use option multistr if needed.", - W044: "Bad or unnecessary escaping.", - W045: "Bad number '{a}'.", - W046: "Don't use extra leading zeros '{a}'.", - W047: "A trailing decimal point can be confused with a dot: '{a}'.", - W048: "Unexpected control character in regular expression.", - W049: "Unexpected escaped character '{a}' in regular expression.", - W050: "JavaScript URL.", - W051: "Variables should not be deleted.", - W052: "Unexpected '{a}'.", - W053: "Do not use {a} as a constructor.", - W054: "The Function constructor is a form of eval.", - W055: "A constructor name should start with an uppercase letter.", - W056: "Bad constructor.", - W057: "Weird construction. Is 'new' unnecessary?", - W058: "Missing '()' invoking a constructor.", - W059: "Avoid arguments.{a}.", - W060: "document.write can be a form of eval.", - W061: "eval can be harmful.", - W062: "Wrap an immediate function invocation in parens " + - "to assist the reader in understanding that the expression " + - "is the result of a function, and not the function itself.", - W063: "Math is not a function.", - W064: "Missing 'new' prefix when invoking a constructor.", - W065: "Missing radix parameter.", - W066: "Implied eval. Consider passing a function instead of a string.", - W067: "Bad invocation.", - W068: "Wrapping non-IIFE function literals in parens is unnecessary.", - W069: "['{a}'] is better written in dot notation.", - W070: "Extra comma. (it breaks older versions of IE)", - W071: "This function has too many statements. ({a})", - W072: "This function has too many parameters. ({a})", - W073: "Blocks are nested too deeply. ({a})", - W074: "This function's cyclomatic complexity is too high. ({a})", - W075: "Duplicate key '{a}'.", - W076: "Unexpected parameter '{a}' in get {b} function.", - W077: "Expected a single parameter in set {a} function.", - W078: "Setter is defined without getter.", - W079: "Redefinition of '{a}'.", - W080: "It's not necessary to initialize '{a}' to 'undefined'.", - W081: "Too many var statements.", - W082: "Function declarations should not be placed in blocks. " + - "Use a function expression or move the statement to the top of " + - "the outer function.", - W083: "Don't make functions within a loop.", - W084: "Assignment in conditional expression", - W085: "Don't use 'with'.", - W086: "Expected a 'break' statement before '{a}'.", - W087: "Forgotten 'debugger' statement?", - W088: "Creating global 'for' variable. Should be 'for (var {a} ...'.", - W089: "The body of a for in should be wrapped in an if statement to filter " + - "unwanted properties from the prototype.", - W090: "'{a}' is not a statement label.", - W091: "'{a}' is out of scope.", - W092: "Wrap the /regexp/ literal in parens to disambiguate the slash operator.", - W093: "Did you mean to return a conditional instead of an assignment?", - W094: "Unexpected comma.", - W095: "Expected a string and instead saw {a}.", - W096: "The '{a}' key may produce unexpected results.", - W097: "Use the function form of \"use strict\".", - W098: "'{a}' is defined but never used.", - W099: "Mixed spaces and tabs.", - W100: "This character may get silently deleted by one or more browsers.", - W101: "Line is too long.", - W102: "Trailing whitespace.", - W103: "The '{a}' property is deprecated.", - W104: "'{a}' is only available in JavaScript 1.7.", - W105: "Unexpected {a} in '{b}'.", - W106: "Identifier '{a}' is not in camel case.", - W107: "Script URL.", - W108: "Strings must use doublequote.", - W109: "Strings must use singlequote.", - W110: "Mixed double and single quotes.", - W112: "Unclosed string.", - W113: "Control character in string: {a}.", - W114: "Avoid {a}.", - W115: "Octal literals are not allowed in strict mode.", - W116: "Expected '{a}' and instead saw '{b}'.", - W117: "'{a}' is not defined.", - W118: "'{a}' is only available in Mozilla JavaScript extensions (use moz option).", - W119: "'{a}' is only available in ES6 (use esnext option)." -}; - -var info = { - I001: "Comma warnings can be turned off with 'laxcomma'.", - I002: "Reserved words as properties can be used under the 'es5' option.", - I003: "ES5 option is now set per default" -}; - -exports.errors = {}; -exports.warnings = {}; -exports.info = {}; - -_.each(errors, function (desc, code) { - exports.errors[code] = { code: code, desc: desc }; -}); - -_.each(warnings, function (desc, code) { - exports.warnings[code] = { code: code, desc: desc }; -}); - -_.each(info, function (desc, code) { - exports.info[code] = { code: code, desc: desc }; -}); - -})() -}, -{"underscore":12}], -11:[function(req,module,exports){ -(function(){/* - * Lexical analysis and token construction. - */ +{"../shared/messages.js":2,"../shared/vars.js":3,"./lex.js":5,"./reg.js":6,"./state.js":7,"./style.js":8,"console-browserify":9,"events":10,"underscore":1}], +5:[function(req,module,exports){ @@ -8912,12 +9463,13 @@ Lexer.prototype = { if (!token.reserved) { return false; } + var meta = token.meta; - if (token.meta && token.meta.isFutureReservedWord) { - if (state.option.inES5(true) && !token.meta.es5) { + if (meta && meta.isFutureReservedWord && state.option.inES5()) { + if (!meta.es5) { return false; } - if (token.meta.strictOnly) { + if (meta.strictOnly) { if (!state.option.strict && !state.directive["use strict"]) { return false; } @@ -9100,878 +9652,434 @@ Lexer.prototype = { exports.Lexer = Lexer; -})() }, -{"events":2,"./reg.js":4,"./state.js":5,"underscore":12}], -12:[function(req,module,exports){ -(function(){// Underscore.js 1.4.4 +{"./reg.js":6,"./state.js":7,"events":10,"underscore":1}], +6:[function(req,module,exports){ -(function() { - var root = this; - var previousUnderscore = root._; - var breaker = {}; - var ArrayProto = Array.prototype, ObjProto = Object.prototype, FuncProto = Function.prototype; - var push = ArrayProto.push, - slice = ArrayProto.slice, - concat = ArrayProto.concat, - toString = ObjProto.toString, - hasOwnProperty = ObjProto.hasOwnProperty; - var - nativeForEach = ArrayProto.forEach, - nativeMap = ArrayProto.map, - nativeReduce = ArrayProto.reduce, - nativeReduceRight = ArrayProto.reduceRight, - nativeFilter = ArrayProto.filter, - nativeEvery = ArrayProto.every, - nativeSome = ArrayProto.some, - nativeIndexOf = ArrayProto.indexOf, - nativeLastIndexOf = ArrayProto.lastIndexOf, - nativeIsArray = Array.isArray, - nativeKeys = Object.keys, - nativeBind = FuncProto.bind; - var _ = function(obj) { - if (obj instanceof _) return obj; - if (!(this instanceof _)) return new _(obj); - this._wrapped = obj; - }; - if (typeof exports !== 'undefined') { - if (typeof module !== 'undefined' && module.exports) { - exports = module.exports = _; +"use string"; +exports.unsafeString = + /@cc|<\/?|script|\]\s*\]|<\s*!|</i; +exports.unsafeChars = + /[\u0000-\u001f\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/; +exports.needEsc = + /[\u0000-\u001f&<"\/\\\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/; + +exports.needEscGlobal = + /[\u0000-\u001f&<"\/\\\u007f-\u009f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g; +exports.starSlash = /\*\//; +exports.identifier = /^([a-zA-Z_$][a-zA-Z0-9_$]*)$/; +exports.javascriptURL = /^(?:javascript|jscript|ecmascript|vbscript|mocha|livescript)\s*:/i; +exports.fallsThrough = /^\s*\/\*\s*falls?\sthrough\s*\*\/\s*$/; + +}, +{}], +7:[function(req,module,exports){ + + +var state = { + syntax: {}, + + reset: function () { + this.tokens = { + prev: null, + next: null, + curr: null + }; + + this.option = {}; + this.ignored = {}; + this.directive = {}; + this.jsonMode = false; + this.jsonWarnings = []; + this.lines = []; + this.tab = ""; + this.cache = {}; // Node.JS doesn't have Map. Sniff. + } +}; + +exports.state = state; + +}, +{}], +8:[function(req,module,exports){ + + +exports.register = function (linter) { + + linter.on("Identifier", function style_scanProto(data) { + if (linter.getOption("proto")) { + return; + } + + if (data.name === "__proto__") { + linter.warn("W103", { + line: data.line, + char: data.char, + data: [ data.name ] + }); + } + }); + + linter.on("Identifier", function style_scanIterator(data) { + if (linter.getOption("iterator")) { + return; + } + + if (data.name === "__iterator__") { + linter.warn("W104", { + line: data.line, + char: data.char, + data: [ data.name ] + }); + } + }); + + linter.on("Identifier", function style_scanDangling(data) { + if (!linter.getOption("nomen")) { + return; + } + if (data.name === "_") { + return; + } + if (linter.getOption("node")) { + if (/^(__dirname|__filename)$/.test(data.name) && !data.isProperty) { + return; + } + } + + if (/^(_+.*|.*_+)$/.test(data.name)) { + linter.warn("W105", { + line: data.line, + char: data.from, + data: [ "dangling '_'", data.name ] + }); + } + }); + + linter.on("Identifier", function style_scanCamelCase(data) { + if (!linter.getOption("camelcase")) { + return; + } + + if (data.name.replace(/^_+/, "").indexOf("_") > -1 && !data.name.match(/^[A-Z0-9_]*$/)) { + linter.warn("W106", { + line: data.line, + char: data.from, + data: [ data.name ] + }); + } + }); + + linter.on("String", function style_scanQuotes(data) { + var quotmark = linter.getOption("quotmark"); + var code; + + if (!quotmark) { + return; + } + + if (quotmark === "single" && data.quote !== "'") { + code = "W109"; + } + + if (quotmark === "double" && data.quote !== "\"") { + code = "W108"; + } + + if (quotmark === true) { + if (!linter.getCache("quotmark")) { + linter.setCache("quotmark", data.quote); + } + + if (linter.getCache("quotmark") !== data.quote) { + code = "W110"; + } + } + + if (code) { + linter.warn(code, { + line: data.line, + char: data.char, + }); + } + }); + + linter.on("Number", function style_scanNumbers(data) { + if (data.value.charAt(0) === ".") { + linter.warn("W008", { + line: data.line, + char: data.char, + data: [ data.value ] + }); + } + + if (data.value.substr(data.value.length - 1) === ".") { + linter.warn("W047", { + line: data.line, + char: data.char, + data: [ data.value ] + }); + } + + if (/^00+/.test(data.value)) { + linter.warn("W046", { + line: data.line, + char: data.char, + data: [ data.value ] + }); + } + }); + + linter.on("String", function style_scanJavaScriptURLs(data) { + var re = /^(?:javascript|jscript|ecmascript|vbscript|mocha|livescript)\s*:/i; + + if (linter.getOption("scripturl")) { + return; + } + + if (re.test(data.value)) { + linter.warn("W107", { + line: data.line, + char: data.char + }); + } + }); +}; +}, +{}], +9:[function(req,module,exports){ + +}, +{}], +10:[function(req,module,exports){ +var process=req("__browserify_process");if (!process.EventEmitter) process.EventEmitter = function () {}; + +var EventEmitter = exports.EventEmitter = process.EventEmitter; +var isArray = typeof Array.isArray === 'function' + ? Array.isArray + : function (xs) { + return Object.prototype.toString.call(xs) === '[object Array]' + } +; +function indexOf (xs, x) { + if (xs.indexOf) return xs.indexOf(x); + for (var i = 0; i < xs.length; i++) { + if (x === xs[i]) return i; + } + return -1; +} +var defaultMaxListeners = 200; +EventEmitter.prototype.setMaxListeners = function(n) { + if (!this._events) this._events = {}; + this._events.maxListeners = n; +}; + + +EventEmitter.prototype.emit = function(type) { + if (type === 'error') { + if (!this._events || !this._events.error || + (isArray(this._events.error) && !this._events.error.length)) + { + if (arguments[1] instanceof Error) { + throw arguments[1]; // Unhandled 'error' event + } else { + throw new Error("Uncaught, unspecified 'error' event."); + } + return false; } - exports._ = _; - } else { - root._ = _; } - _.VERSION = '1.4.4'; - var each = _.each = _.forEach = function(obj, iterator, context) { - if (obj == null) return; - if (nativeForEach && obj.forEach === nativeForEach) { - obj.forEach(iterator, context); - } else if (obj.length === +obj.length) { - for (var i = 0, l = obj.length; i < l; i++) { - if (iterator.call(context, obj[i], i, obj) === breaker) return; - } - } else { - for (var key in obj) { - if (_.has(obj, key)) { - if (iterator.call(context, obj[key], key, obj) === breaker) return; - } - } - } - }; - _.map = _.collect = function(obj, iterator, context) { - var results = []; - if (obj == null) return results; - if (nativeMap && obj.map === nativeMap) return obj.map(iterator, context); - each(obj, function(value, index, list) { - results[results.length] = iterator.call(context, value, index, list); - }); - return results; - }; - var reduceError = 'Reduce of empty array with no initial value'; - _.reduce = _.foldl = _.inject = function(obj, iterator, memo, context) { - var initial = arguments.length > 2; - if (obj == null) obj = []; - if (nativeReduce && obj.reduce === nativeReduce) { - if (context) iterator = _.bind(iterator, context); - return initial ? obj.reduce(iterator, memo) : obj.reduce(iterator); - } - each(obj, function(value, index, list) { - if (!initial) { - memo = value; - initial = true; - } else { - memo = iterator.call(context, memo, value, index, list); - } - }); - if (!initial) throw new TypeError(reduceError); - return memo; - }; - _.reduceRight = _.foldr = function(obj, iterator, memo, context) { - var initial = arguments.length > 2; - if (obj == null) obj = []; - if (nativeReduceRight && obj.reduceRight === nativeReduceRight) { - if (context) iterator = _.bind(iterator, context); - return initial ? obj.reduceRight(iterator, memo) : obj.reduceRight(iterator); - } - var length = obj.length; - if (length !== +length) { - var keys = _.keys(obj); - length = keys.length; - } - each(obj, function(value, index, list) { - index = keys ? keys[--length] : --length; - if (!initial) { - memo = obj[index]; - initial = true; - } else { - memo = iterator.call(context, memo, obj[index], index, list); - } - }); - if (!initial) throw new TypeError(reduceError); - return memo; - }; - _.find = _.detect = function(obj, iterator, context) { - var result; - any(obj, function(value, index, list) { - if (iterator.call(context, value, index, list)) { - result = value; - return true; - } - }); - return result; - }; - _.filter = _.select = function(obj, iterator, context) { - var results = []; - if (obj == null) return results; - if (nativeFilter && obj.filter === nativeFilter) return obj.filter(iterator, context); - each(obj, function(value, index, list) { - if (iterator.call(context, value, index, list)) results[results.length] = value; - }); - return results; - }; - _.reject = function(obj, iterator, context) { - return _.filter(obj, function(value, index, list) { - return !iterator.call(context, value, index, list); - }, context); - }; - _.every = _.all = function(obj, iterator, context) { - iterator || (iterator = _.identity); - var result = true; - if (obj == null) return result; - if (nativeEvery && obj.every === nativeEvery) return obj.every(iterator, context); - each(obj, function(value, index, list) { - if (!(result = result && iterator.call(context, value, index, list))) return breaker; - }); - return !!result; - }; - var any = _.some = _.any = function(obj, iterator, context) { - iterator || (iterator = _.identity); - var result = false; - if (obj == null) return result; - if (nativeSome && obj.some === nativeSome) return obj.some(iterator, context); - each(obj, function(value, index, list) { - if (result || (result = iterator.call(context, value, index, list))) return breaker; - }); - return !!result; - }; - _.contains = _.include = function(obj, target) { - if (obj == null) return false; - if (nativeIndexOf && obj.indexOf === nativeIndexOf) return obj.indexOf(target) != -1; - return any(obj, function(value) { - return value === target; - }); - }; - _.invoke = function(obj, method) { - var args = slice.call(arguments, 2); - var isFunc = _.isFunction(method); - return _.map(obj, function(value) { - return (isFunc ? method : value[method]).apply(value, args); - }); - }; - _.pluck = function(obj, key) { - return _.map(obj, function(value){ return value[key]; }); - }; - _.where = function(obj, attrs, first) { - if (_.isEmpty(attrs)) return first ? null : []; - return _[first ? 'find' : 'filter'](obj, function(value) { - for (var key in attrs) { - if (attrs[key] !== value[key]) return false; - } - return true; - }); - }; - _.findWhere = function(obj, attrs) { - return _.where(obj, attrs, true); - }; - _.max = function(obj, iterator, context) { - if (!iterator && _.isArray(obj) && obj[0] === +obj[0] && obj.length < 65535) { - return Math.max.apply(Math, obj); - } - if (!iterator && _.isEmpty(obj)) return -Infinity; - var result = {computed : -Infinity, value: -Infinity}; - each(obj, function(value, index, list) { - var computed = iterator ? iterator.call(context, value, index, list) : value; - computed >= result.computed && (result = {value : value, computed : computed}); - }); - return result.value; - }; - _.min = function(obj, iterator, context) { - if (!iterator && _.isArray(obj) && obj[0] === +obj[0] && obj.length < 65535) { - return Math.min.apply(Math, obj); - } - if (!iterator && _.isEmpty(obj)) return Infinity; - var result = {computed : Infinity, value: Infinity}; - each(obj, function(value, index, list) { - var computed = iterator ? iterator.call(context, value, index, list) : value; - computed < result.computed && (result = {value : value, computed : computed}); - }); - return result.value; - }; - _.shuffle = function(obj) { - var rand; - var index = 0; - var shuffled = []; - each(obj, function(value) { - rand = _.random(index++); - shuffled[index - 1] = shuffled[rand]; - shuffled[rand] = value; - }); - return shuffled; - }; - var lookupIterator = function(value) { - return _.isFunction(value) ? value : function(obj){ return obj[value]; }; - }; - _.sortBy = function(obj, value, context) { - var iterator = lookupIterator(value); - return _.pluck(_.map(obj, function(value, index, list) { - return { - value : value, - index : index, - criteria : iterator.call(context, value, index, list) - }; - }).sort(function(left, right) { - var a = left.criteria; - var b = right.criteria; - if (a !== b) { - if (a > b || a === void 0) return 1; - if (a < b || b === void 0) return -1; - } - return left.index < right.index ? -1 : 1; - }), 'value'); - }; - var group = function(obj, value, context, behavior) { - var result = {}; - var iterator = lookupIterator(value || _.identity); - each(obj, function(value, index) { - var key = iterator.call(context, value, index, obj); - behavior(result, key, value); - }); - return result; - }; - _.groupBy = function(obj, value, context) { - return group(obj, value, context, function(result, key, value) { - (_.has(result, key) ? result[key] : (result[key] = [])).push(value); - }); - }; - _.countBy = function(obj, value, context) { - return group(obj, value, context, function(result, key) { - if (!_.has(result, key)) result[key] = 0; - result[key]++; - }); - }; - _.sortedIndex = function(array, obj, iterator, context) { - iterator = iterator == null ? _.identity : lookupIterator(iterator); - var value = iterator.call(context, obj); - var low = 0, high = array.length; - while (low < high) { - var mid = (low + high) >>> 1; - iterator.call(context, array[mid]) < value ? low = mid + 1 : high = mid; - } - return low; - }; - _.toArray = function(obj) { - if (!obj) return []; - if (_.isArray(obj)) return slice.call(obj); - if (obj.length === +obj.length) return _.map(obj, _.identity); - return _.values(obj); - }; - _.size = function(obj) { - if (obj == null) return 0; - return (obj.length === +obj.length) ? obj.length : _.keys(obj).length; - }; - _.first = _.head = _.take = function(array, n, guard) { - if (array == null) return void 0; - return (n != null) && !guard ? slice.call(array, 0, n) : array[0]; - }; - _.initial = function(array, n, guard) { - return slice.call(array, 0, array.length - ((n == null) || guard ? 1 : n)); - }; - _.last = function(array, n, guard) { - if (array == null) return void 0; - if ((n != null) && !guard) { - return slice.call(array, Math.max(array.length - n, 0)); - } else { - return array[array.length - 1]; - } - }; - _.rest = _.tail = _.drop = function(array, n, guard) { - return slice.call(array, (n == null) || guard ? 1 : n); - }; - _.compact = function(array) { - return _.filter(array, _.identity); - }; - var flatten = function(input, shallow, output) { - each(input, function(value) { - if (_.isArray(value)) { - shallow ? push.apply(output, value) : flatten(value, shallow, output); - } else { - output.push(value); - } - }); - return output; - }; - _.flatten = function(array, shallow) { - return flatten(array, shallow, []); - }; - _.without = function(array) { - return _.difference(array, slice.call(arguments, 1)); - }; - _.uniq = _.unique = function(array, isSorted, iterator, context) { - if (_.isFunction(isSorted)) { - context = iterator; - iterator = isSorted; - isSorted = false; - } - var initial = iterator ? _.map(array, iterator, context) : array; - var results = []; - var seen = []; - each(initial, function(value, index) { - if (isSorted ? (!index || seen[seen.length - 1] !== value) : !_.contains(seen, value)) { - seen.push(value); - results.push(array[index]); - } - }); - return results; - }; - _.union = function() { - return _.uniq(concat.apply(ArrayProto, arguments)); - }; - _.intersection = function(array) { - var rest = slice.call(arguments, 1); - return _.filter(_.uniq(array), function(item) { - return _.every(rest, function(other) { - return _.indexOf(other, item) >= 0; - }); - }); - }; - _.difference = function(array) { - var rest = concat.apply(ArrayProto, slice.call(arguments, 1)); - return _.filter(array, function(value){ return !_.contains(rest, value); }); - }; - _.zip = function() { - var args = slice.call(arguments); - var length = _.max(_.pluck(args, 'length')); - var results = new Array(length); - for (var i = 0; i < length; i++) { - results[i] = _.pluck(args, "" + i); - } - return results; - }; - _.object = function(list, values) { - if (list == null) return {}; - var result = {}; - for (var i = 0, l = list.length; i < l; i++) { - if (values) { - result[list[i]] = values[i]; - } else { - result[list[i][0]] = list[i][1]; - } - } - return result; - }; - _.indexOf = function(array, item, isSorted) { - if (array == null) return -1; - var i = 0, l = array.length; - if (isSorted) { - if (typeof isSorted == 'number') { - i = (isSorted < 0 ? Math.max(0, l + isSorted) : isSorted); - } else { - i = _.sortedIndex(array, item); - return array[i] === item ? i : -1; - } - } - if (nativeIndexOf && array.indexOf === nativeIndexOf) return array.indexOf(item, isSorted); - for (; i < l; i++) if (array[i] === item) return i; - return -1; - }; - _.lastIndexOf = function(array, item, from) { - if (array == null) return -1; - var hasIndex = from != null; - if (nativeLastIndexOf && array.lastIndexOf === nativeLastIndexOf) { - return hasIndex ? array.lastIndexOf(item, from) : array.lastIndexOf(item); - } - var i = (hasIndex ? from : array.length); - while (i--) if (array[i] === item) return i; - return -1; - }; - _.range = function(start, stop, step) { - if (arguments.length <= 1) { - stop = start || 0; - start = 0; - } - step = arguments[2] || 1; + if (!this._events) return false; + var handler = this._events[type]; + if (!handler) return false; - var len = Math.max(Math.ceil((stop - start) / step), 0); - var idx = 0; - var range = new Array(len); - - while(idx < len) { - range[idx++] = start; - start += step; + if (typeof handler == 'function') { + switch (arguments.length) { + case 1: + handler.call(this); + break; + case 2: + handler.call(this, arguments[1]); + break; + case 3: + handler.call(this, arguments[1], arguments[2]); + break; + default: + var args = Array.prototype.slice.call(arguments, 1); + handler.apply(this, args); } - - return range; - }; - _.bind = function(func, context) { - if (func.bind === nativeBind && nativeBind) return nativeBind.apply(func, slice.call(arguments, 1)); - var args = slice.call(arguments, 2); - return function() { - return func.apply(context, args.concat(slice.call(arguments))); - }; - }; - _.partial = function(func) { - var args = slice.call(arguments, 1); - return function() { - return func.apply(this, args.concat(slice.call(arguments))); - }; - }; - _.bindAll = function(obj) { - var funcs = slice.call(arguments, 1); - if (funcs.length === 0) funcs = _.functions(obj); - each(funcs, function(f) { obj[f] = _.bind(obj[f], obj); }); - return obj; - }; - _.memoize = function(func, hasher) { - var memo = {}; - hasher || (hasher = _.identity); - return function() { - var key = hasher.apply(this, arguments); - return _.has(memo, key) ? memo[key] : (memo[key] = func.apply(this, arguments)); - }; - }; - _.delay = function(func, wait) { - var args = slice.call(arguments, 2); - return setTimeout(function(){ return func.apply(null, args); }, wait); - }; - _.defer = function(func) { - return _.delay.apply(_, [func, 1].concat(slice.call(arguments, 1))); - }; - _.throttle = function(func, wait) { - var context, args, timeout, result; - var previous = 0; - var later = function() { - previous = new Date; - timeout = null; - result = func.apply(context, args); - }; - return function() { - var now = new Date; - var remaining = wait - (now - previous); - context = this; - args = arguments; - if (remaining <= 0) { - clearTimeout(timeout); - timeout = null; - previous = now; - result = func.apply(context, args); - } else if (!timeout) { - timeout = setTimeout(later, remaining); - } - return result; - }; - }; - _.debounce = function(func, wait, immediate) { - var timeout, result; - return function() { - var context = this, args = arguments; - var later = function() { - timeout = null; - if (!immediate) result = func.apply(context, args); - }; - var callNow = immediate && !timeout; - clearTimeout(timeout); - timeout = setTimeout(later, wait); - if (callNow) result = func.apply(context, args); - return result; - }; - }; - _.once = function(func) { - var ran = false, memo; - return function() { - if (ran) return memo; - ran = true; - memo = func.apply(this, arguments); - func = null; - return memo; - }; - }; - _.wrap = function(func, wrapper) { - return function() { - var args = [func]; - push.apply(args, arguments); - return wrapper.apply(this, args); - }; - }; - _.compose = function() { - var funcs = arguments; - return function() { - var args = arguments; - for (var i = funcs.length - 1; i >= 0; i--) { - args = [funcs[i].apply(this, args)]; - } - return args[0]; - }; - }; - _.after = function(times, func) { - if (times <= 0) return func(); - return function() { - if (--times < 1) { - return func.apply(this, arguments); - } - }; - }; - _.keys = nativeKeys || function(obj) { - if (obj !== Object(obj)) throw new TypeError('Invalid object'); - var keys = []; - for (var key in obj) if (_.has(obj, key)) keys[keys.length] = key; - return keys; - }; - _.values = function(obj) { - var values = []; - for (var key in obj) if (_.has(obj, key)) values.push(obj[key]); - return values; - }; - _.pairs = function(obj) { - var pairs = []; - for (var key in obj) if (_.has(obj, key)) pairs.push([key, obj[key]]); - return pairs; - }; - _.invert = function(obj) { - var result = {}; - for (var key in obj) if (_.has(obj, key)) result[obj[key]] = key; - return result; - }; - _.functions = _.methods = function(obj) { - var names = []; - for (var key in obj) { - if (_.isFunction(obj[key])) names.push(key); - } - return names.sort(); - }; - _.extend = function(obj) { - each(slice.call(arguments, 1), function(source) { - if (source) { - for (var prop in source) { - obj[prop] = source[prop]; - } - } - }); - return obj; - }; - _.pick = function(obj) { - var copy = {}; - var keys = concat.apply(ArrayProto, slice.call(arguments, 1)); - each(keys, function(key) { - if (key in obj) copy[key] = obj[key]; - }); - return copy; - }; - _.omit = function(obj) { - var copy = {}; - var keys = concat.apply(ArrayProto, slice.call(arguments, 1)); - for (var key in obj) { - if (!_.contains(keys, key)) copy[key] = obj[key]; - } - return copy; - }; - _.defaults = function(obj) { - each(slice.call(arguments, 1), function(source) { - if (source) { - for (var prop in source) { - if (obj[prop] == null) obj[prop] = source[prop]; - } - } - }); - return obj; - }; - _.clone = function(obj) { - if (!_.isObject(obj)) return obj; - return _.isArray(obj) ? obj.slice() : _.extend({}, obj); - }; - _.tap = function(obj, interceptor) { - interceptor(obj); - return obj; - }; - var eq = function(a, b, aStack, bStack) { - if (a === b) return a !== 0 || 1 / a == 1 / b; - if (a == null || b == null) return a === b; - if (a instanceof _) a = a._wrapped; - if (b instanceof _) b = b._wrapped; - var className = toString.call(a); - if (className != toString.call(b)) return false; - switch (className) { - case '[object String]': - return a == String(b); - case '[object Number]': - return a != +a ? b != +b : (a == 0 ? 1 / a == 1 / b : a == +b); - case '[object Date]': - case '[object Boolean]': - return +a == +b; - case '[object RegExp]': - return a.source == b.source && - a.global == b.global && - a.multiline == b.multiline && - a.ignoreCase == b.ignoreCase; - } - if (typeof a != 'object' || typeof b != 'object') return false; - var length = aStack.length; - while (length--) { - if (aStack[length] == a) return bStack[length] == b; - } - aStack.push(a); - bStack.push(b); - var size = 0, result = true; - if (className == '[object Array]') { - size = a.length; - result = size == b.length; - if (result) { - while (size--) { - if (!(result = eq(a[size], b[size], aStack, bStack))) break; - } - } - } else { - var aCtor = a.constructor, bCtor = b.constructor; - if (aCtor !== bCtor && !(_.isFunction(aCtor) && (aCtor instanceof aCtor) && - _.isFunction(bCtor) && (bCtor instanceof bCtor))) { - return false; - } - for (var key in a) { - if (_.has(a, key)) { - size++; - if (!(result = _.has(b, key) && eq(a[key], b[key], aStack, bStack))) break; - } - } - if (result) { - for (key in b) { - if (_.has(b, key) && !(size--)) break; - } - result = !size; - } - } - aStack.pop(); - bStack.pop(); - return result; - }; - _.isEqual = function(a, b) { - return eq(a, b, [], []); - }; - _.isEmpty = function(obj) { - if (obj == null) return true; - if (_.isArray(obj) || _.isString(obj)) return obj.length === 0; - for (var key in obj) if (_.has(obj, key)) return false; return true; - }; - _.isElement = function(obj) { - return !!(obj && obj.nodeType === 1); - }; - _.isArray = nativeIsArray || function(obj) { - return toString.call(obj) == '[object Array]'; - }; - _.isObject = function(obj) { - return obj === Object(obj); - }; - each(['Arguments', 'Function', 'String', 'Number', 'Date', 'RegExp'], function(name) { - _['is' + name] = function(obj) { - return toString.call(obj) == '[object ' + name + ']'; - }; + + } else if (isArray(handler)) { + var args = Array.prototype.slice.call(arguments, 1); + + var listeners = handler.slice(); + for (var i = 0, l = listeners.length; i < l; i++) { + listeners[i].apply(this, args); + } + return true; + + } else { + return false; + } +}; +EventEmitter.prototype.addListener = function(type, listener) { + if ('function' !== typeof listener) { + throw new Error('addListener only takes instances of Function'); + } + + if (!this._events) this._events = {}; + this.emit('newListener', type, listener); + + if (!this._events[type]) { + this._events[type] = listener; + } else if (isArray(this._events[type])) { + if (!this._events[type].warned) { + var m; + if (this._events.maxListeners !== undefined) { + m = this._events.maxListeners; + } else { + m = defaultMaxListeners; + } + + if (m && m > 0 && this._events[type].length > m) { + this._events[type].warned = true; + console.error('(node) warning: possible EventEmitter memory ' + + 'leak detected. %d listeners added. ' + + 'Use emitter.setMaxListeners() to increase limit.', + this._events[type].length); + console.trace(); + } + } + this._events[type].push(listener); + } else { + this._events[type] = [this._events[type], listener]; + } + + return this; +}; + +EventEmitter.prototype.on = EventEmitter.prototype.addListener; + +EventEmitter.prototype.once = function(type, listener) { + var self = this; + self.on(type, function g() { + self.removeListener(type, g); + listener.apply(this, arguments); }); - if (!_.isArguments(arguments)) { - _.isArguments = function(obj) { - return !!(obj && _.has(obj, 'callee')); - }; + + return this; +}; + +EventEmitter.prototype.removeListener = function(type, listener) { + if ('function' !== typeof listener) { + throw new Error('removeListener only takes instances of Function'); } - if (typeof (/./) !== 'function') { - _.isFunction = function(obj) { - return typeof obj === 'function'; - }; + if (!this._events || !this._events[type]) return this; + + var list = this._events[type]; + + if (isArray(list)) { + var i = indexOf(list, listener); + if (i < 0) return this; + list.splice(i, 1); + if (list.length == 0) + delete this._events[type]; + } else if (this._events[type] === listener) { + delete this._events[type]; } - _.isFinite = function(obj) { - return isFinite(obj) && !isNaN(parseFloat(obj)); - }; - _.isNaN = function(obj) { - return _.isNumber(obj) && obj != +obj; - }; - _.isBoolean = function(obj) { - return obj === true || obj === false || toString.call(obj) == '[object Boolean]'; - }; - _.isNull = function(obj) { - return obj === null; - }; - _.isUndefined = function(obj) { - return obj === void 0; - }; - _.has = function(obj, key) { - return hasOwnProperty.call(obj, key); - }; - _.noConflict = function() { - root._ = previousUnderscore; + + return this; +}; + +EventEmitter.prototype.removeAllListeners = function(type) { + if (arguments.length === 0) { + this._events = {}; return this; - }; - _.identity = function(value) { - return value; - }; - _.times = function(n, iterator, context) { - var accum = Array(n); - for (var i = 0; i < n; i++) accum[i] = iterator.call(context, i); - return accum; - }; - _.random = function(min, max) { - if (max == null) { - max = min; - min = 0; - } - return min + Math.floor(Math.random() * (max - min + 1)); - }; - var entityMap = { - escape: { - '&': '&', - '<': '<', - '>': '>', - '"': '"', - "'": ''', - '/': '/' - } - }; - entityMap.unescape = _.invert(entityMap.escape); - var entityRegexes = { - escape: new RegExp('[' + _.keys(entityMap.escape).join('') + ']', 'g'), - unescape: new RegExp('(' + _.keys(entityMap.unescape).join('|') + ')', 'g') - }; - _.each(['escape', 'unescape'], function(method) { - _[method] = function(string) { - if (string == null) return ''; - return ('' + string).replace(entityRegexes[method], function(match) { - return entityMap[method][match]; - }); - }; - }); - _.result = function(object, property) { - if (object == null) return null; - var value = object[property]; - return _.isFunction(value) ? value.call(object) : value; - }; - _.mixin = function(obj) { - each(_.functions(obj), function(name){ - var func = _[name] = obj[name]; - _.prototype[name] = function() { - var args = [this._wrapped]; - push.apply(args, arguments); - return result.call(this, func.apply(_, args)); - }; - }); - }; - var idCounter = 0; - _.uniqueId = function(prefix) { - var id = ++idCounter + ''; - return prefix ? prefix + id : id; - }; - _.templateSettings = { - evaluate : /<%([\s\S]+?)%>/g, - interpolate : /<%=([\s\S]+?)%>/g, - escape : /<%-([\s\S]+?)%>/g - }; - var noMatch = /(.)^/; - var escapes = { - "'": "'", - '\\': '\\', - '\r': 'r', - '\n': 'n', - '\t': 't', - '\u2028': 'u2028', - '\u2029': 'u2029' - }; + } + if (type && this._events && this._events[type]) this._events[type] = null; + return this; +}; - var escaper = /\\|'|\r|\n|\t|\u2028|\u2029/g; - _.template = function(text, data, settings) { - var render; - settings = _.defaults({}, settings, _.templateSettings); - var matcher = new RegExp([ - (settings.escape || noMatch).source, - (settings.interpolate || noMatch).source, - (settings.evaluate || noMatch).source - ].join('|') + '|$', 'g'); - var index = 0; - var source = "__p+='"; - text.replace(matcher, function(match, escape, interpolate, evaluate, offset) { - source += text.slice(index, offset) - .replace(escaper, function(match) { return '\\' + escapes[match]; }); +EventEmitter.prototype.listeners = function(type) { + if (!this._events) this._events = {}; + if (!this._events[type]) this._events[type] = []; + if (!isArray(this._events[type])) { + this._events[type] = [this._events[type]]; + } + return this._events[type]; +}; - if (escape) { - source += "'+\n((__t=(" + escape + "))==null?'':_.escape(__t))+\n'"; - } - if (interpolate) { - source += "'+\n((__t=(" + interpolate + "))==null?'':__t)+\n'"; - } - if (evaluate) { - source += "';\n" + evaluate + "\n__p+='"; - } - index = offset + match.length; - return match; - }); - source += "';\n"; - if (!settings.variable) source = 'with(obj||{}){\n' + source + '}\n'; +EventEmitter.listenerCount = function(emitter, type) { + var ret; + if (!emitter._events || !emitter._events[type]) + ret = 0; + else if (typeof emitter._events[type] === 'function') + ret = 1; + else + ret = emitter._events[type].length; + return ret; +}; - source = "var __t,__p='',__j=Array.prototype.join," + - "print=function(){__p+=__j.call(arguments,'');};\n" + - source + "return __p;\n"; - - try { - render = new Function(settings.variable || 'obj', '_', source); - } catch (e) { - e.source = source; - throw e; - } - - if (data) return render(data, _); - var template = function(data) { - return render.call(this, data, _); - }; - template.source = 'function(' + (settings.variable || 'obj') + '){\n' + source + '}'; - - return template; - }; - _.chain = function(obj) { - return _(obj).chain(); - }; - var result = function(obj) { - return this._chain ? _(obj).chain() : obj; - }; - _.mixin(_); - each(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(name) { - var method = ArrayProto[name]; - _.prototype[name] = function() { - var obj = this._wrapped; - method.apply(obj, arguments); - if ((name == 'shift' || name == 'splice') && obj.length === 0) delete obj[0]; - return result.call(this, obj); - }; - }); - each(['concat', 'join', 'slice'], function(name) { - var method = ArrayProto[name]; - _.prototype[name] = function() { - return result.call(this, method.apply(this._wrapped, arguments)); - }; - }); - - _.extend(_.prototype, { - chain: function() { - this._chain = true; - return this; - }, - value: function() { - return this._wrapped; - } - - }); - -}).call(this); - -})() }, -{}] -},{},["E/GbHF"]) +{"__browserify_process":11}], +11:[function(req,module,exports){ + +var process = module.exports = {}; + +process.nextTick = (function () { + var canSetImmediate = typeof window !== 'undefined' + && window.setImmediate; + var canPost = typeof window !== 'undefined' + && window.postMessage && window.addEventListener + ; + + if (canSetImmediate) { + return function (f) { return window.setImmediate(f) }; + } + + if (canPost) { + var queue = []; + window.addEventListener('message', function (ev) { + if (ev.source === window && ev.data === 'process-tick') { + ev.stopPropagation(); + if (queue.length > 0) { + var fn = queue.shift(); + fn(); + } + } + }, true); + + return function nextTick(fn) { + queue.push(fn); + window.postMessage('process-tick', '*'); + }; + } + + return function nextTick(fn) { + setTimeout(fn, 0); + }; +})(); + +process.title = 'browser'; +process.browser = true; +process.env = {}; +process.argv = []; + +process.binding = function (name) { + throw new Error('process.binding is not supported'); +} +process.cwd = function () { return '/' }; +process.chdir = function (dir) { + throw new Error('process.chdir is not supported'); +}; + +}, +{}], +"jshint":[function(req,module,exports){ +module.exports=req('n4bKNg'); +}, +{}]},{},["n4bKNg"]) ; function req() {return require.apply(this, arguments)} From 0f95277bd5d6ca1937f3498d1caaba9dcb1e6243 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 27 Nov 2013 12:47:59 +0000 Subject: [PATCH 198/315] feature(edit) add workers --- lib/client/edit/worker-coffee.js | 7518 ++++++++++ lib/client/edit/worker-css.js | 8256 +++++++++++ lib/client/edit/worker-json.js | 2271 +++ lib/client/edit/worker-lua.js | 3507 +++++ lib/client/edit/worker-php.js | 6870 +++++++++ lib/client/edit/worker-xquery.js | 21863 +++++++++++++++++++++++++++++ 6 files changed, 50285 insertions(+) create mode 100644 lib/client/edit/worker-coffee.js create mode 100644 lib/client/edit/worker-css.js create mode 100644 lib/client/edit/worker-json.js create mode 100644 lib/client/edit/worker-lua.js create mode 100644 lib/client/edit/worker-php.js create mode 100644 lib/client/edit/worker-xquery.js diff --git a/lib/client/edit/worker-coffee.js b/lib/client/edit/worker-coffee.js new file mode 100644 index 00000000..1c1e2725 --- /dev/null +++ b/lib/client/edit/worker-coffee.js @@ -0,0 +1,7518 @@ +"no use strict"; +;(function(window) { +if (typeof window.window != "undefined" && window.document) { + return; +} + +window.console = function() { + var msgs = Array.prototype.slice.call(arguments, 0); + postMessage({type: "log", data: msgs}); +}; +window.console.error = +window.console.warn = +window.console.log = +window.console.trace = window.console; + +window.window = window; +window.ace = window; + +window.normalizeModule = function(parentId, moduleName) { + if (moduleName.indexOf("!") !== -1) { + var chunks = moduleName.split("!"); + return window.normalizeModule(parentId, chunks[0]) + "!" + window.normalizeModule(parentId, chunks[1]); + } + if (moduleName.charAt(0) == ".") { + var base = parentId.split("/").slice(0, -1).join("/"); + moduleName = (base ? base + "/" : "") + moduleName; + + while(moduleName.indexOf(".") !== -1 && previous != moduleName) { + var previous = moduleName; + moduleName = moduleName.replace(/^\.\//, "").replace(/\/\.\//, "/").replace(/[^\/]+\/\.\.\//, ""); + } + } + + return moduleName; +}; + +window.require = function(parentId, id) { + if (!id) { + id = parentId + parentId = null; + } + if (!id.charAt) + throw new Error("worker.js require() accepts only (parentId, id) as arguments"); + + id = window.normalizeModule(parentId, id); + + var module = window.require.modules[id]; + if (module) { + if (!module.initialized) { + module.initialized = true; + module.exports = module.factory().exports; + } + return module.exports; + } + + var chunks = id.split("/"); + if (!window.require.tlns) + return console.log("unable to load " + id); + chunks[0] = window.require.tlns[chunks[0]] || chunks[0]; + var path = chunks.join("/") + ".js"; + + window.require.id = id; + importScripts(path); + return window.require(parentId, id); +}; +window.require.modules = {}; +window.require.tlns = {}; + +window.define = function(id, deps, factory) { + if (arguments.length == 2) { + factory = deps; + if (typeof id != "string") { + deps = id; + id = window.require.id; + } + } else if (arguments.length == 1) { + factory = id; + deps = [] + id = window.require.id; + } + + if (!deps.length) + deps = ['require', 'exports', 'module'] + + if (id.indexOf("text!") === 0) + return; + + var req = function(childId) { + return window.require(id, childId); + }; + + window.require.modules[id] = { + exports: {}, + factory: function() { + var module = this; + var returnExports = factory.apply(this, deps.map(function(dep) { + switch(dep) { + case 'require': return req + case 'exports': return module.exports + case 'module': return module + default: return req(dep) + } + })); + if (returnExports) + module.exports = returnExports; + return module; + } + }; +}; +window.define.amd = {} + +window.initBaseUrls = function initBaseUrls(topLevelNamespaces) { + require.tlns = topLevelNamespaces; +} + +window.initSender = function initSender() { + + var EventEmitter = window.require("ace/lib/event_emitter").EventEmitter; + var oop = window.require("ace/lib/oop"); + + var Sender = function() {}; + + (function() { + + oop.implement(this, EventEmitter); + + this.callback = function(data, callbackId) { + postMessage({ + type: "call", + id: callbackId, + data: data + }); + }; + + this.emit = function(name, data) { + postMessage({ + type: "event", + name: name, + data: data + }); + }; + + }).call(Sender.prototype); + + return new Sender(); +} + +window.main = null; +window.sender = null; + +window.onmessage = function(e) { + var msg = e.data; + if (msg.command) { + if (main[msg.command]) + main[msg.command].apply(main, msg.args); + else + throw new Error("Unknown command:" + msg.command); + } + else if (msg.init) { + initBaseUrls(msg.tlns); + require("ace/lib/es5-shim"); + sender = initSender(); + var clazz = require(msg.module)[msg.classname]; + main = new clazz(sender); + } + else if (msg.event && sender) { + sender._emit(msg.event, msg.data); + } +}; +})(this);// https://github.com/kriskowal/es5-shim + +ace.define('ace/lib/es5-shim', ['require', 'exports', 'module' ], function(require, exports, module) { + +function Empty() {} + +if (!Function.prototype.bind) { + Function.prototype.bind = function bind(that) { // .length is 1 + var target = this; + if (typeof target != "function") { + throw new TypeError("Function.prototype.bind called on incompatible " + target); + } + var args = slice.call(arguments, 1); // for normal call + var bound = function () { + + if (this instanceof bound) { + + var result = target.apply( + this, + args.concat(slice.call(arguments)) + ); + if (Object(result) === result) { + return result; + } + return this; + + } else { + return target.apply( + that, + args.concat(slice.call(arguments)) + ); + + } + + }; + if(target.prototype) { + Empty.prototype = target.prototype; + bound.prototype = new Empty(); + Empty.prototype = null; + } + return bound; + }; +} +var call = Function.prototype.call; +var prototypeOfArray = Array.prototype; +var prototypeOfObject = Object.prototype; +var slice = prototypeOfArray.slice; +var _toString = call.bind(prototypeOfObject.toString); +var owns = call.bind(prototypeOfObject.hasOwnProperty); +var defineGetter; +var defineSetter; +var lookupGetter; +var lookupSetter; +var supportsAccessors; +if ((supportsAccessors = owns(prototypeOfObject, "__defineGetter__"))) { + defineGetter = call.bind(prototypeOfObject.__defineGetter__); + defineSetter = call.bind(prototypeOfObject.__defineSetter__); + lookupGetter = call.bind(prototypeOfObject.__lookupGetter__); + lookupSetter = call.bind(prototypeOfObject.__lookupSetter__); +} +if ([1,2].splice(0).length != 2) { + if(function() { // test IE < 9 to splice bug - see issue #138 + function makeArray(l) { + var a = new Array(l+2); + a[0] = a[1] = 0; + return a; + } + var array = [], lengthBefore; + + array.splice.apply(array, makeArray(20)); + array.splice.apply(array, makeArray(26)); + + lengthBefore = array.length; //46 + array.splice(5, 0, "XXX"); // add one element + + lengthBefore + 1 == array.length + + if (lengthBefore + 1 == array.length) { + return true;// has right splice implementation without bugs + } + }()) {//IE 6/7 + var array_splice = Array.prototype.splice; + Array.prototype.splice = function(start, deleteCount) { + if (!arguments.length) { + return []; + } else { + return array_splice.apply(this, [ + start === void 0 ? 0 : start, + deleteCount === void 0 ? (this.length - start) : deleteCount + ].concat(slice.call(arguments, 2))) + } + }; + } else {//IE8 + Array.prototype.splice = function(pos, removeCount){ + var length = this.length; + if (pos > 0) { + if (pos > length) + pos = length; + } else if (pos == void 0) { + pos = 0; + } else if (pos < 0) { + pos = Math.max(length + pos, 0); + } + + if (!(pos+removeCount < length)) + removeCount = length - pos; + + var removed = this.slice(pos, pos+removeCount); + var insert = slice.call(arguments, 2); + var add = insert.length; + if (pos === length) { + if (add) { + this.push.apply(this, insert); + } + } else { + var remove = Math.min(removeCount, length - pos); + var tailOldPos = pos + remove; + var tailNewPos = tailOldPos + add - remove; + var tailCount = length - tailOldPos; + var lengthAfterRemove = length - remove; + + if (tailNewPos < tailOldPos) { // case A + for (var i = 0; i < tailCount; ++i) { + this[tailNewPos+i] = this[tailOldPos+i]; + } + } else if (tailNewPos > tailOldPos) { // case B + for (i = tailCount; i--; ) { + this[tailNewPos+i] = this[tailOldPos+i]; + } + } // else, add == remove (nothing to do) + + if (add && pos === lengthAfterRemove) { + this.length = lengthAfterRemove; // truncate array + this.push.apply(this, insert); + } else { + this.length = lengthAfterRemove + add; // reserves space + for (i = 0; i < add; ++i) { + this[pos+i] = insert[i]; + } + } + } + return removed; + }; + } +} +if (!Array.isArray) { + Array.isArray = function isArray(obj) { + return _toString(obj) == "[object Array]"; + }; +} +var boxedString = Object("a"), + splitString = boxedString[0] != "a" || !(0 in boxedString); + +if (!Array.prototype.forEach) { + Array.prototype.forEach = function forEach(fun /*, thisp*/) { + var object = toObject(this), + self = splitString && _toString(this) == "[object String]" ? + this.split("") : + object, + thisp = arguments[1], + i = -1, + length = self.length >>> 0; + if (_toString(fun) != "[object Function]") { + throw new TypeError(); // TODO message + } + + while (++i < length) { + if (i in self) { + fun.call(thisp, self[i], i, object); + } + } + }; +} +if (!Array.prototype.map) { + Array.prototype.map = function map(fun /*, thisp*/) { + var object = toObject(this), + self = splitString && _toString(this) == "[object String]" ? + this.split("") : + object, + length = self.length >>> 0, + result = Array(length), + thisp = arguments[1]; + if (_toString(fun) != "[object Function]") { + throw new TypeError(fun + " is not a function"); + } + + for (var i = 0; i < length; i++) { + if (i in self) + result[i] = fun.call(thisp, self[i], i, object); + } + return result; + }; +} +if (!Array.prototype.filter) { + Array.prototype.filter = function filter(fun /*, thisp */) { + var object = toObject(this), + self = splitString && _toString(this) == "[object String]" ? + this.split("") : + object, + length = self.length >>> 0, + result = [], + value, + thisp = arguments[1]; + if (_toString(fun) != "[object Function]") { + throw new TypeError(fun + " is not a function"); + } + + for (var i = 0; i < length; i++) { + if (i in self) { + value = self[i]; + if (fun.call(thisp, value, i, object)) { + result.push(value); + } + } + } + return result; + }; +} +if (!Array.prototype.every) { + Array.prototype.every = function every(fun /*, thisp */) { + var object = toObject(this), + self = splitString && _toString(this) == "[object String]" ? + this.split("") : + object, + length = self.length >>> 0, + thisp = arguments[1]; + if (_toString(fun) != "[object Function]") { + throw new TypeError(fun + " is not a function"); + } + + for (var i = 0; i < length; i++) { + if (i in self && !fun.call(thisp, self[i], i, object)) { + return false; + } + } + return true; + }; +} +if (!Array.prototype.some) { + Array.prototype.some = function some(fun /*, thisp */) { + var object = toObject(this), + self = splitString && _toString(this) == "[object String]" ? + this.split("") : + object, + length = self.length >>> 0, + thisp = arguments[1]; + if (_toString(fun) != "[object Function]") { + throw new TypeError(fun + " is not a function"); + } + + for (var i = 0; i < length; i++) { + if (i in self && fun.call(thisp, self[i], i, object)) { + return true; + } + } + return false; + }; +} +if (!Array.prototype.reduce) { + Array.prototype.reduce = function reduce(fun /*, initial*/) { + var object = toObject(this), + self = splitString && _toString(this) == "[object String]" ? + this.split("") : + object, + length = self.length >>> 0; + if (_toString(fun) != "[object Function]") { + throw new TypeError(fun + " is not a function"); + } + if (!length && arguments.length == 1) { + throw new TypeError("reduce of empty array with no initial value"); + } + + var i = 0; + var result; + if (arguments.length >= 2) { + result = arguments[1]; + } else { + do { + if (i in self) { + result = self[i++]; + break; + } + if (++i >= length) { + throw new TypeError("reduce of empty array with no initial value"); + } + } while (true); + } + + for (; i < length; i++) { + if (i in self) { + result = fun.call(void 0, result, self[i], i, object); + } + } + + return result; + }; +} +if (!Array.prototype.reduceRight) { + Array.prototype.reduceRight = function reduceRight(fun /*, initial*/) { + var object = toObject(this), + self = splitString && _toString(this) == "[object String]" ? + this.split("") : + object, + length = self.length >>> 0; + if (_toString(fun) != "[object Function]") { + throw new TypeError(fun + " is not a function"); + } + if (!length && arguments.length == 1) { + throw new TypeError("reduceRight of empty array with no initial value"); + } + + var result, i = length - 1; + if (arguments.length >= 2) { + result = arguments[1]; + } else { + do { + if (i in self) { + result = self[i--]; + break; + } + if (--i < 0) { + throw new TypeError("reduceRight of empty array with no initial value"); + } + } while (true); + } + + do { + if (i in this) { + result = fun.call(void 0, result, self[i], i, object); + } + } while (i--); + + return result; + }; +} +if (!Array.prototype.indexOf || ([0, 1].indexOf(1, 2) != -1)) { + Array.prototype.indexOf = function indexOf(sought /*, fromIndex */ ) { + var self = splitString && _toString(this) == "[object String]" ? + this.split("") : + toObject(this), + length = self.length >>> 0; + + if (!length) { + return -1; + } + + var i = 0; + if (arguments.length > 1) { + i = toInteger(arguments[1]); + } + i = i >= 0 ? i : Math.max(0, length + i); + for (; i < length; i++) { + if (i in self && self[i] === sought) { + return i; + } + } + return -1; + }; +} +if (!Array.prototype.lastIndexOf || ([0, 1].lastIndexOf(0, -3) != -1)) { + Array.prototype.lastIndexOf = function lastIndexOf(sought /*, fromIndex */) { + var self = splitString && _toString(this) == "[object String]" ? + this.split("") : + toObject(this), + length = self.length >>> 0; + + if (!length) { + return -1; + } + var i = length - 1; + if (arguments.length > 1) { + i = Math.min(i, toInteger(arguments[1])); + } + i = i >= 0 ? i : length - Math.abs(i); + for (; i >= 0; i--) { + if (i in self && sought === self[i]) { + return i; + } + } + return -1; + }; +} +if (!Object.getPrototypeOf) { + Object.getPrototypeOf = function getPrototypeOf(object) { + return object.__proto__ || ( + object.constructor ? + object.constructor.prototype : + prototypeOfObject + ); + }; +} +if (!Object.getOwnPropertyDescriptor) { + var ERR_NON_OBJECT = "Object.getOwnPropertyDescriptor called on a " + + "non-object: "; + Object.getOwnPropertyDescriptor = function getOwnPropertyDescriptor(object, property) { + if ((typeof object != "object" && typeof object != "function") || object === null) + throw new TypeError(ERR_NON_OBJECT + object); + if (!owns(object, property)) + return; + + var descriptor, getter, setter; + descriptor = { enumerable: true, configurable: true }; + if (supportsAccessors) { + var prototype = object.__proto__; + object.__proto__ = prototypeOfObject; + + var getter = lookupGetter(object, property); + var setter = lookupSetter(object, property); + object.__proto__ = prototype; + + if (getter || setter) { + if (getter) descriptor.get = getter; + if (setter) descriptor.set = setter; + return descriptor; + } + } + descriptor.value = object[property]; + return descriptor; + }; +} +if (!Object.getOwnPropertyNames) { + Object.getOwnPropertyNames = function getOwnPropertyNames(object) { + return Object.keys(object); + }; +} +if (!Object.create) { + var createEmpty; + if (Object.prototype.__proto__ === null) { + createEmpty = function () { + return { "__proto__": null }; + }; + } else { + createEmpty = function () { + var empty = {}; + for (var i in empty) + empty[i] = null; + empty.constructor = + empty.hasOwnProperty = + empty.propertyIsEnumerable = + empty.isPrototypeOf = + empty.toLocaleString = + empty.toString = + empty.valueOf = + empty.__proto__ = null; + return empty; + } + } + + Object.create = function create(prototype, properties) { + var object; + if (prototype === null) { + object = createEmpty(); + } else { + if (typeof prototype != "object") + throw new TypeError("typeof prototype["+(typeof prototype)+"] != 'object'"); + var Type = function () {}; + Type.prototype = prototype; + object = new Type(); + object.__proto__ = prototype; + } + if (properties !== void 0) + Object.defineProperties(object, properties); + return object; + }; +} + +function doesDefinePropertyWork(object) { + try { + Object.defineProperty(object, "sentinel", {}); + return "sentinel" in object; + } catch (exception) { + } +} +if (Object.defineProperty) { + var definePropertyWorksOnObject = doesDefinePropertyWork({}); + var definePropertyWorksOnDom = typeof document == "undefined" || + doesDefinePropertyWork(document.createElement("div")); + if (!definePropertyWorksOnObject || !definePropertyWorksOnDom) { + var definePropertyFallback = Object.defineProperty; + } +} + +if (!Object.defineProperty || definePropertyFallback) { + var ERR_NON_OBJECT_DESCRIPTOR = "Property description must be an object: "; + var ERR_NON_OBJECT_TARGET = "Object.defineProperty called on non-object: " + var ERR_ACCESSORS_NOT_SUPPORTED = "getters & setters can not be defined " + + "on this javascript engine"; + + Object.defineProperty = function defineProperty(object, property, descriptor) { + if ((typeof object != "object" && typeof object != "function") || object === null) + throw new TypeError(ERR_NON_OBJECT_TARGET + object); + if ((typeof descriptor != "object" && typeof descriptor != "function") || descriptor === null) + throw new TypeError(ERR_NON_OBJECT_DESCRIPTOR + descriptor); + if (definePropertyFallback) { + try { + return definePropertyFallback.call(Object, object, property, descriptor); + } catch (exception) { + } + } + if (owns(descriptor, "value")) { + + if (supportsAccessors && (lookupGetter(object, property) || + lookupSetter(object, property))) + { + var prototype = object.__proto__; + object.__proto__ = prototypeOfObject; + delete object[property]; + object[property] = descriptor.value; + object.__proto__ = prototype; + } else { + object[property] = descriptor.value; + } + } else { + if (!supportsAccessors) + throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED); + if (owns(descriptor, "get")) + defineGetter(object, property, descriptor.get); + if (owns(descriptor, "set")) + defineSetter(object, property, descriptor.set); + } + + return object; + }; +} +if (!Object.defineProperties) { + Object.defineProperties = function defineProperties(object, properties) { + for (var property in properties) { + if (owns(properties, property)) + Object.defineProperty(object, property, properties[property]); + } + return object; + }; +} +if (!Object.seal) { + Object.seal = function seal(object) { + return object; + }; +} +if (!Object.freeze) { + Object.freeze = function freeze(object) { + return object; + }; +} +try { + Object.freeze(function () {}); +} catch (exception) { + Object.freeze = (function freeze(freezeObject) { + return function freeze(object) { + if (typeof object == "function") { + return object; + } else { + return freezeObject(object); + } + }; + })(Object.freeze); +} +if (!Object.preventExtensions) { + Object.preventExtensions = function preventExtensions(object) { + return object; + }; +} +if (!Object.isSealed) { + Object.isSealed = function isSealed(object) { + return false; + }; +} +if (!Object.isFrozen) { + Object.isFrozen = function isFrozen(object) { + return false; + }; +} +if (!Object.isExtensible) { + Object.isExtensible = function isExtensible(object) { + if (Object(object) === object) { + throw new TypeError(); // TODO message + } + var name = ''; + while (owns(object, name)) { + name += '?'; + } + object[name] = true; + var returnValue = owns(object, name); + delete object[name]; + return returnValue; + }; +} +if (!Object.keys) { + var hasDontEnumBug = true, + dontEnums = [ + "toString", + "toLocaleString", + "valueOf", + "hasOwnProperty", + "isPrototypeOf", + "propertyIsEnumerable", + "constructor" + ], + dontEnumsLength = dontEnums.length; + + for (var key in {"toString": null}) { + hasDontEnumBug = false; + } + + Object.keys = function keys(object) { + + if ( + (typeof object != "object" && typeof object != "function") || + object === null + ) { + throw new TypeError("Object.keys called on a non-object"); + } + + var keys = []; + for (var name in object) { + if (owns(object, name)) { + keys.push(name); + } + } + + if (hasDontEnumBug) { + for (var i = 0, ii = dontEnumsLength; i < ii; i++) { + var dontEnum = dontEnums[i]; + if (owns(object, dontEnum)) { + keys.push(dontEnum); + } + } + } + return keys; + }; + +} +if (!Date.now) { + Date.now = function now() { + return new Date().getTime(); + }; +} +var ws = "\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003" + + "\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028" + + "\u2029\uFEFF"; +if (!String.prototype.trim || ws.trim()) { + ws = "[" + ws + "]"; + var trimBeginRegexp = new RegExp("^" + ws + ws + "*"), + trimEndRegexp = new RegExp(ws + ws + "*$"); + String.prototype.trim = function trim() { + return String(this).replace(trimBeginRegexp, "").replace(trimEndRegexp, ""); + }; +} + +function toInteger(n) { + n = +n; + if (n !== n) { // isNaN + n = 0; + } else if (n !== 0 && n !== (1/0) && n !== -(1/0)) { + n = (n > 0 || -1) * Math.floor(Math.abs(n)); + } + return n; +} + +function isPrimitive(input) { + var type = typeof input; + return ( + input === null || + type === "undefined" || + type === "boolean" || + type === "number" || + type === "string" + ); +} + +function toPrimitive(input) { + var val, valueOf, toString; + if (isPrimitive(input)) { + return input; + } + valueOf = input.valueOf; + if (typeof valueOf === "function") { + val = valueOf.call(input); + if (isPrimitive(val)) { + return val; + } + } + toString = input.toString; + if (typeof toString === "function") { + val = toString.call(input); + if (isPrimitive(val)) { + return val; + } + } + throw new TypeError(); +} +var toObject = function (o) { + if (o == null) { // this matches both null and undefined + throw new TypeError("can't convert "+o+" to object"); + } + return Object(o); +}; + +}); + +ace.define('ace/mode/coffee_worker', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/worker/mirror', 'ace/mode/coffee/coffee-script'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var Mirror = require("../worker/mirror").Mirror; +var coffee = require("../mode/coffee/coffee-script"); + +window.addEventListener = function() {}; + + +var Worker = exports.Worker = function(sender) { + Mirror.call(this, sender); + this.setTimeout(250); +}; + +oop.inherits(Worker, Mirror); + +(function() { + + this.onUpdate = function() { + var value = this.doc.getValue(); + + try { + coffee.parse(value).compile(); + } catch(e) { + var loc = e.location; + if (loc) { + this.sender.emit("error", { + row: loc.first_line, + column: loc.first_column, + endRow: loc.last_line, + endColumn: loc.last_column, + text: e.message, + type: "error" + }); + } + return; + } + this.sender.emit("ok"); + }; + +}).call(Worker.prototype); + +}); + +ace.define('ace/lib/oop', ['require', 'exports', 'module' ], function(require, exports, module) { + + +exports.inherits = (function() { + var tempCtor = function() {}; + return function(ctor, superCtor) { + tempCtor.prototype = superCtor.prototype; + ctor.super_ = superCtor.prototype; + ctor.prototype = new tempCtor(); + ctor.prototype.constructor = ctor; + }; +}()); + +exports.mixin = function(obj, mixin) { + for (var key in mixin) { + obj[key] = mixin[key]; + } + return obj; +}; + +exports.implement = function(proto, mixin) { + exports.mixin(proto, mixin); +}; + +}); +ace.define('ace/worker/mirror', ['require', 'exports', 'module' , 'ace/document', 'ace/lib/lang'], function(require, exports, module) { + + +var Document = require("../document").Document; +var lang = require("../lib/lang"); + +var Mirror = exports.Mirror = function(sender) { + this.sender = sender; + var doc = this.doc = new Document(""); + + var deferredUpdate = this.deferredUpdate = lang.delayedCall(this.onUpdate.bind(this)); + + var _self = this; + sender.on("change", function(e) { + doc.applyDeltas(e.data); + deferredUpdate.schedule(_self.$timeout); + }); +}; + +(function() { + + this.$timeout = 500; + + this.setTimeout = function(timeout) { + this.$timeout = timeout; + }; + + this.setValue = function(value) { + this.doc.setValue(value); + this.deferredUpdate.schedule(this.$timeout); + }; + + this.getValue = function(callbackId) { + this.sender.callback(this.doc.getValue(), callbackId); + }; + + this.onUpdate = function() { + }; + +}).call(Mirror.prototype); + +}); + +ace.define('ace/document', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/event_emitter', 'ace/range', 'ace/anchor'], function(require, exports, module) { + + +var oop = require("./lib/oop"); +var EventEmitter = require("./lib/event_emitter").EventEmitter; +var Range = require("./range").Range; +var Anchor = require("./anchor").Anchor; + +var Document = function(text) { + this.$lines = []; + if (text.length == 0) { + this.$lines = [""]; + } else if (Array.isArray(text)) { + this._insertLines(0, text); + } else { + this.insert({row: 0, column:0}, text); + } +}; + +(function() { + + oop.implement(this, EventEmitter); + this.setValue = function(text) { + var len = this.getLength(); + this.remove(new Range(0, 0, len, this.getLine(len-1).length)); + this.insert({row: 0, column:0}, text); + }; + this.getValue = function() { + return this.getAllLines().join(this.getNewLineCharacter()); + }; + this.createAnchor = function(row, column) { + return new Anchor(this, row, column); + }; + if ("aaa".split(/a/).length == 0) + this.$split = function(text) { + return text.replace(/\r\n|\r/g, "\n").split("\n"); + } + else + this.$split = function(text) { + return text.split(/\r\n|\r|\n/); + }; + + + this.$detectNewLine = function(text) { + var match = text.match(/^.*?(\r\n|\r|\n)/m); + this.$autoNewLine = match ? match[1] : "\n"; + }; + this.getNewLineCharacter = function() { + switch (this.$newLineMode) { + case "windows": + return "\r\n"; + case "unix": + return "\n"; + default: + return this.$autoNewLine; + } + }; + + this.$autoNewLine = "\n"; + this.$newLineMode = "auto"; + this.setNewLineMode = function(newLineMode) { + if (this.$newLineMode === newLineMode) + return; + + this.$newLineMode = newLineMode; + }; + this.getNewLineMode = function() { + return this.$newLineMode; + }; + this.isNewLine = function(text) { + return (text == "\r\n" || text == "\r" || text == "\n"); + }; + this.getLine = function(row) { + return this.$lines[row] || ""; + }; + this.getLines = function(firstRow, lastRow) { + return this.$lines.slice(firstRow, lastRow + 1); + }; + this.getAllLines = function() { + return this.getLines(0, this.getLength()); + }; + this.getLength = function() { + return this.$lines.length; + }; + this.getTextRange = function(range) { + if (range.start.row == range.end.row) { + return this.getLine(range.start.row) + .substring(range.start.column, range.end.column); + } + var lines = this.getLines(range.start.row, range.end.row); + lines[0] = (lines[0] || "").substring(range.start.column); + var l = lines.length - 1; + if (range.end.row - range.start.row == l) + lines[l] = lines[l].substring(0, range.end.column); + return lines.join(this.getNewLineCharacter()); + }; + + this.$clipPosition = function(position) { + var length = this.getLength(); + if (position.row >= length) { + position.row = Math.max(0, length - 1); + position.column = this.getLine(length-1).length; + } else if (position.row < 0) + position.row = 0; + return position; + }; + this.insert = function(position, text) { + if (!text || text.length === 0) + return position; + + position = this.$clipPosition(position); + if (this.getLength() <= 1) + this.$detectNewLine(text); + + var lines = this.$split(text); + var firstLine = lines.splice(0, 1)[0]; + var lastLine = lines.length == 0 ? null : lines.splice(lines.length - 1, 1)[0]; + + position = this.insertInLine(position, firstLine); + if (lastLine !== null) { + position = this.insertNewLine(position); // terminate first line + position = this._insertLines(position.row, lines); + position = this.insertInLine(position, lastLine || ""); + } + return position; + }; + this.insertLines = function(row, lines) { + if (row >= this.getLength()) + return this.insert({row: row, column: 0}, "\n" + lines.join("\n")); + return this._insertLines(Math.max(row, 0), lines); + }; + this._insertLines = function(row, lines) { + if (lines.length == 0) + return {row: row, column: 0}; + if (lines.length > 0xFFFF) { + var end = this._insertLines(row, lines.slice(0xFFFF)); + lines = lines.slice(0, 0xFFFF); + } + + var args = [row, 0]; + args.push.apply(args, lines); + this.$lines.splice.apply(this.$lines, args); + + var range = new Range(row, 0, row + lines.length, 0); + var delta = { + action: "insertLines", + range: range, + lines: lines + }; + this._emit("change", { data: delta }); + return end || range.end; + }; + this.insertNewLine = function(position) { + position = this.$clipPosition(position); + var line = this.$lines[position.row] || ""; + + this.$lines[position.row] = line.substring(0, position.column); + this.$lines.splice(position.row + 1, 0, line.substring(position.column, line.length)); + + var end = { + row : position.row + 1, + column : 0 + }; + + var delta = { + action: "insertText", + range: Range.fromPoints(position, end), + text: this.getNewLineCharacter() + }; + this._emit("change", { data: delta }); + + return end; + }; + this.insertInLine = function(position, text) { + if (text.length == 0) + return position; + + var line = this.$lines[position.row] || ""; + + this.$lines[position.row] = line.substring(0, position.column) + text + + line.substring(position.column); + + var end = { + row : position.row, + column : position.column + text.length + }; + + var delta = { + action: "insertText", + range: Range.fromPoints(position, end), + text: text + }; + this._emit("change", { data: delta }); + + return end; + }; + this.remove = function(range) { + if (!range instanceof Range) + range = Range.fromPoints(range.start, range.end); + range.start = this.$clipPosition(range.start); + range.end = this.$clipPosition(range.end); + + if (range.isEmpty()) + return range.start; + + var firstRow = range.start.row; + var lastRow = range.end.row; + + if (range.isMultiLine()) { + var firstFullRow = range.start.column == 0 ? firstRow : firstRow + 1; + var lastFullRow = lastRow - 1; + + if (range.end.column > 0) + this.removeInLine(lastRow, 0, range.end.column); + + if (lastFullRow >= firstFullRow) + this._removeLines(firstFullRow, lastFullRow); + + if (firstFullRow != firstRow) { + this.removeInLine(firstRow, range.start.column, this.getLine(firstRow).length); + this.removeNewLine(range.start.row); + } + } + else { + this.removeInLine(firstRow, range.start.column, range.end.column); + } + return range.start; + }; + this.removeInLine = function(row, startColumn, endColumn) { + if (startColumn == endColumn) + return; + + var range = new Range(row, startColumn, row, endColumn); + var line = this.getLine(row); + var removed = line.substring(startColumn, endColumn); + var newLine = line.substring(0, startColumn) + line.substring(endColumn, line.length); + this.$lines.splice(row, 1, newLine); + + var delta = { + action: "removeText", + range: range, + text: removed + }; + this._emit("change", { data: delta }); + return range.start; + }; + this.removeLines = function(firstRow, lastRow) { + if (firstRow < 0 || lastRow >= this.getLength()) + return this.remove(new Range(firstRow, 0, lastRow + 1, 0)); + return this._removeLines(firstRow, lastRow); + }; + + this._removeLines = function(firstRow, lastRow) { + var range = new Range(firstRow, 0, lastRow + 1, 0); + var removed = this.$lines.splice(firstRow, lastRow - firstRow + 1); + + var delta = { + action: "removeLines", + range: range, + nl: this.getNewLineCharacter(), + lines: removed + }; + this._emit("change", { data: delta }); + return removed; + }; + this.removeNewLine = function(row) { + var firstLine = this.getLine(row); + var secondLine = this.getLine(row+1); + + var range = new Range(row, firstLine.length, row+1, 0); + var line = firstLine + secondLine; + + this.$lines.splice(row, 2, line); + + var delta = { + action: "removeText", + range: range, + text: this.getNewLineCharacter() + }; + this._emit("change", { data: delta }); + }; + this.replace = function(range, text) { + if (!range instanceof Range) + range = Range.fromPoints(range.start, range.end); + if (text.length == 0 && range.isEmpty()) + return range.start; + if (text == this.getTextRange(range)) + return range.end; + + this.remove(range); + if (text) { + var end = this.insert(range.start, text); + } + else { + end = range.start; + } + + return end; + }; + this.applyDeltas = function(deltas) { + for (var i=0; i=0; i--) { + var delta = deltas[i]; + + var range = Range.fromPoints(delta.range.start, delta.range.end); + + if (delta.action == "insertLines") + this._removeLines(range.start.row, range.end.row - 1); + else if (delta.action == "insertText") + this.remove(range); + else if (delta.action == "removeLines") + this._insertLines(range.start.row, delta.lines); + else if (delta.action == "removeText") + this.insert(range.start, delta.text); + } + }; + this.indexToPosition = function(index, startRow) { + var lines = this.$lines || this.getAllLines(); + var newlineLength = this.getNewLineCharacter().length; + for (var i = startRow || 0, l = lines.length; i < l; i++) { + index -= lines[i].length + newlineLength; + if (index < 0) + return {row: i, column: index + lines[i].length + newlineLength}; + } + return {row: l-1, column: lines[l-1].length}; + }; + this.positionToIndex = function(pos, startRow) { + var lines = this.$lines || this.getAllLines(); + var newlineLength = this.getNewLineCharacter().length; + var index = 0; + var row = Math.min(pos.row, lines.length); + for (var i = startRow || 0; i < row; ++i) + index += lines[i].length + newlineLength; + + return index + pos.column; + }; + +}).call(Document.prototype); + +exports.Document = Document; +}); + +ace.define('ace/lib/event_emitter', ['require', 'exports', 'module' ], function(require, exports, module) { + + +var EventEmitter = {}; +var stopPropagation = function() { this.propagationStopped = true; }; +var preventDefault = function() { this.defaultPrevented = true; }; + +EventEmitter._emit = +EventEmitter._dispatchEvent = function(eventName, e) { + this._eventRegistry || (this._eventRegistry = {}); + this._defaultHandlers || (this._defaultHandlers = {}); + + var listeners = this._eventRegistry[eventName] || []; + var defaultHandler = this._defaultHandlers[eventName]; + if (!listeners.length && !defaultHandler) + return; + + if (typeof e != "object" || !e) + e = {}; + + if (!e.type) + e.type = eventName; + if (!e.stopPropagation) + e.stopPropagation = stopPropagation; + if (!e.preventDefault) + e.preventDefault = preventDefault; + + listeners = listeners.slice(); + for (var i=0; i [" + this.end.row + "/" + this.end.column + "]"); + }; + + this.contains = function(row, column) { + return this.compare(row, column) == 0; + }; + this.compareRange = function(range) { + var cmp, + end = range.end, + start = range.start; + + cmp = this.compare(end.row, end.column); + if (cmp == 1) { + cmp = this.compare(start.row, start.column); + if (cmp == 1) { + return 2; + } else if (cmp == 0) { + return 1; + } else { + return 0; + } + } else if (cmp == -1) { + return -2; + } else { + cmp = this.compare(start.row, start.column); + if (cmp == -1) { + return -1; + } else if (cmp == 1) { + return 42; + } else { + return 0; + } + } + }; + this.comparePoint = function(p) { + return this.compare(p.row, p.column); + }; + this.containsRange = function(range) { + return this.comparePoint(range.start) == 0 && this.comparePoint(range.end) == 0; + }; + this.intersects = function(range) { + var cmp = this.compareRange(range); + return (cmp == -1 || cmp == 0 || cmp == 1); + }; + this.isEnd = function(row, column) { + return this.end.row == row && this.end.column == column; + }; + this.isStart = function(row, column) { + return this.start.row == row && this.start.column == column; + }; + this.setStart = function(row, column) { + if (typeof row == "object") { + this.start.column = row.column; + this.start.row = row.row; + } else { + this.start.row = row; + this.start.column = column; + } + }; + this.setEnd = function(row, column) { + if (typeof row == "object") { + this.end.column = row.column; + this.end.row = row.row; + } else { + this.end.row = row; + this.end.column = column; + } + }; + this.inside = function(row, column) { + if (this.compare(row, column) == 0) { + if (this.isEnd(row, column) || this.isStart(row, column)) { + return false; + } else { + return true; + } + } + return false; + }; + this.insideStart = function(row, column) { + if (this.compare(row, column) == 0) { + if (this.isEnd(row, column)) { + return false; + } else { + return true; + } + } + return false; + }; + this.insideEnd = function(row, column) { + if (this.compare(row, column) == 0) { + if (this.isStart(row, column)) { + return false; + } else { + return true; + } + } + return false; + }; + this.compare = function(row, column) { + if (!this.isMultiLine()) { + if (row === this.start.row) { + return column < this.start.column ? -1 : (column > this.end.column ? 1 : 0); + }; + } + + if (row < this.start.row) + return -1; + + if (row > this.end.row) + return 1; + + if (this.start.row === row) + return column >= this.start.column ? 0 : -1; + + if (this.end.row === row) + return column <= this.end.column ? 0 : 1; + + return 0; + }; + this.compareStart = function(row, column) { + if (this.start.row == row && this.start.column == column) { + return -1; + } else { + return this.compare(row, column); + } + }; + this.compareEnd = function(row, column) { + if (this.end.row == row && this.end.column == column) { + return 1; + } else { + return this.compare(row, column); + } + }; + this.compareInside = function(row, column) { + if (this.end.row == row && this.end.column == column) { + return 1; + } else if (this.start.row == row && this.start.column == column) { + return -1; + } else { + return this.compare(row, column); + } + }; + this.clipRows = function(firstRow, lastRow) { + if (this.end.row > lastRow) + var end = {row: lastRow + 1, column: 0}; + else if (this.end.row < firstRow) + var end = {row: firstRow, column: 0}; + + if (this.start.row > lastRow) + var start = {row: lastRow + 1, column: 0}; + else if (this.start.row < firstRow) + var start = {row: firstRow, column: 0}; + + return Range.fromPoints(start || this.start, end || this.end); + }; + this.extend = function(row, column) { + var cmp = this.compare(row, column); + + if (cmp == 0) + return this; + else if (cmp == -1) + var start = {row: row, column: column}; + else + var end = {row: row, column: column}; + + return Range.fromPoints(start || this.start, end || this.end); + }; + + this.isEmpty = function() { + return (this.start.row === this.end.row && this.start.column === this.end.column); + }; + this.isMultiLine = function() { + return (this.start.row !== this.end.row); + }; + this.clone = function() { + return Range.fromPoints(this.start, this.end); + }; + this.collapseRows = function() { + if (this.end.column == 0) + return new Range(this.start.row, 0, Math.max(this.start.row, this.end.row-1), 0) + else + return new Range(this.start.row, 0, this.end.row, 0) + }; + this.toScreenRange = function(session) { + var screenPosStart = session.documentToScreenPosition(this.start); + var screenPosEnd = session.documentToScreenPosition(this.end); + + return new Range( + screenPosStart.row, screenPosStart.column, + screenPosEnd.row, screenPosEnd.column + ); + }; + this.moveBy = function(row, column) { + this.start.row += row; + this.start.column += column; + this.end.row += row; + this.end.column += column; + }; + +}).call(Range.prototype); +Range.fromPoints = function(start, end) { + return new Range(start.row, start.column, end.row, end.column); +}; +Range.comparePoints = comparePoints; + +Range.comparePoints = function(p1, p2) { + return p1.row - p2.row || p1.column - p2.column; +}; + + +exports.Range = Range; +}); + +ace.define('ace/anchor', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/event_emitter'], function(require, exports, module) { + + +var oop = require("./lib/oop"); +var EventEmitter = require("./lib/event_emitter").EventEmitter; + +var Anchor = exports.Anchor = function(doc, row, column) { + this.$onChange = this.onChange.bind(this); + this.attach(doc); + + if (typeof column == "undefined") + this.setPosition(row.row, row.column); + else + this.setPosition(row, column); +}; + +(function() { + + oop.implement(this, EventEmitter); + this.getPosition = function() { + return this.$clipPositionToDocument(this.row, this.column); + }; + this.getDocument = function() { + return this.document; + }; + this.$insertRight = false; + this.onChange = function(e) { + var delta = e.data; + var range = delta.range; + + if (range.start.row == range.end.row && range.start.row != this.row) + return; + + if (range.start.row > this.row) + return; + + if (range.start.row == this.row && range.start.column > this.column) + return; + + var row = this.row; + var column = this.column; + var start = range.start; + var end = range.end; + + if (delta.action === "insertText") { + if (start.row === row && start.column <= column) { + if (start.column === column && this.$insertRight) { + } else if (start.row === end.row) { + column += end.column - start.column; + } else { + column -= start.column; + row += end.row - start.row; + } + } else if (start.row !== end.row && start.row < row) { + row += end.row - start.row; + } + } else if (delta.action === "insertLines") { + if (start.row <= row) { + row += end.row - start.row; + } + } else if (delta.action === "removeText") { + if (start.row === row && start.column < column) { + if (end.column >= column) + column = start.column; + else + column = Math.max(0, column - (end.column - start.column)); + + } else if (start.row !== end.row && start.row < row) { + if (end.row === row) + column = Math.max(0, column - end.column) + start.column; + row -= (end.row - start.row); + } else if (end.row === row) { + row -= end.row - start.row; + column = Math.max(0, column - end.column) + start.column; + } + } else if (delta.action == "removeLines") { + if (start.row <= row) { + if (end.row <= row) + row -= end.row - start.row; + else { + row = start.row; + column = 0; + } + } + } + + this.setPosition(row, column, true); + }; + this.setPosition = function(row, column, noClip) { + var pos; + if (noClip) { + pos = { + row: row, + column: column + }; + } else { + pos = this.$clipPositionToDocument(row, column); + } + + if (this.row == pos.row && this.column == pos.column) + return; + + var old = { + row: this.row, + column: this.column + }; + + this.row = pos.row; + this.column = pos.column; + this._emit("change", { + old: old, + value: pos + }); + }; + this.detach = function() { + this.document.removeEventListener("change", this.$onChange); + }; + this.attach = function(doc) { + this.document = doc || this.document; + this.document.on("change", this.$onChange); + }; + this.$clipPositionToDocument = function(row, column) { + var pos = {}; + + if (row >= this.document.getLength()) { + pos.row = Math.max(0, this.document.getLength() - 1); + pos.column = this.document.getLine(pos.row).length; + } + else if (row < 0) { + pos.row = 0; + pos.column = 0; + } + else { + pos.row = row; + pos.column = Math.min(this.document.getLine(pos.row).length, Math.max(0, column)); + } + + if (column < 0) + pos.column = 0; + + return pos; + }; + +}).call(Anchor.prototype); + +}); + +ace.define('ace/lib/lang', ['require', 'exports', 'module' ], function(require, exports, module) { + + +exports.stringReverse = function(string) { + return string.split("").reverse().join(""); +}; + +exports.stringRepeat = function (string, count) { + var result = ''; + while (count > 0) { + if (count & 1) + result += string; + + if (count >>= 1) + string += string; + } + return result; +}; + +var trimBeginRegexp = /^\s\s*/; +var trimEndRegexp = /\s\s*$/; + +exports.stringTrimLeft = function (string) { + return string.replace(trimBeginRegexp, ''); +}; + +exports.stringTrimRight = function (string) { + return string.replace(trimEndRegexp, ''); +}; + +exports.copyObject = function(obj) { + var copy = {}; + for (var key in obj) { + copy[key] = obj[key]; + } + return copy; +}; + +exports.copyArray = function(array){ + var copy = []; + for (var i=0, l=array.length; i= 0 || __indexOf.call(COFFEE_KEYWORDS, id) >= 0)) { + tag = id.toUpperCase(); + if (tag === 'WHEN' && (_ref3 = this.tag(), __indexOf.call(LINE_BREAK, _ref3) >= 0)) { + tag = 'LEADING_WHEN'; + } else if (tag === 'FOR') { + this.seenFor = true; + } else if (tag === 'UNLESS') { + tag = 'IF'; + } else if (__indexOf.call(UNARY, tag) >= 0) { + tag = 'UNARY'; + } else if (__indexOf.call(RELATION, tag) >= 0) { + if (tag !== 'INSTANCEOF' && this.seenFor) { + tag = 'FOR' + tag; + this.seenFor = false; + } else { + tag = 'RELATION'; + if (this.value() === '!') { + poppedToken = this.tokens.pop(); + id = '!' + id; + } + } + } + } + if (__indexOf.call(JS_FORBIDDEN, id) >= 0) { + if (forcedIdentifier) { + tag = 'IDENTIFIER'; + id = new String(id); + id.reserved = true; + } else if (__indexOf.call(RESERVED, id) >= 0) { + this.error("reserved word \"" + id + "\""); + } + } + if (!forcedIdentifier) { + if (__indexOf.call(COFFEE_ALIASES, id) >= 0) { + id = COFFEE_ALIAS_MAP[id]; + } + tag = (function() { + switch (id) { + case '!': + return 'UNARY'; + case '==': + case '!=': + return 'COMPARE'; + case '&&': + case '||': + return 'LOGIC'; + case 'true': + case 'false': + return 'BOOL'; + case 'break': + case 'continue': + return 'STATEMENT'; + default: + return tag; + } + })(); + } + tagToken = this.token(tag, id, 0, idLength); + if (poppedToken) { + _ref4 = [poppedToken[2].first_line, poppedToken[2].first_column], tagToken[2].first_line = _ref4[0], tagToken[2].first_column = _ref4[1]; + } + if (colon) { + colonOffset = input.lastIndexOf(':'); + this.token(':', ':', colonOffset, colon.length); + } + return input.length; + }; + + Lexer.prototype.numberToken = function() { + var binaryLiteral, lexedLength, match, number, octalLiteral; + if (!(match = NUMBER.exec(this.chunk))) { + return 0; + } + number = match[0]; + if (/^0[BOX]/.test(number)) { + this.error("radix prefix '" + number + "' must be lowercase"); + } else if (/E/.test(number) && !/^0x/.test(number)) { + this.error("exponential notation '" + number + "' must be indicated with a lowercase 'e'"); + } else if (/^0\d*[89]/.test(number)) { + this.error("decimal literal '" + number + "' must not be prefixed with '0'"); + } else if (/^0\d+/.test(number)) { + this.error("octal literal '" + number + "' must be prefixed with '0o'"); + } + lexedLength = number.length; + if (octalLiteral = /^0o([0-7]+)/.exec(number)) { + number = '0x' + parseInt(octalLiteral[1], 8).toString(16); + } + if (binaryLiteral = /^0b([01]+)/.exec(number)) { + number = '0x' + parseInt(binaryLiteral[1], 2).toString(16); + } + this.token('NUMBER', number, 0, lexedLength); + return lexedLength; + }; + + Lexer.prototype.stringToken = function() { + var match, octalEsc, string; + switch (this.chunk.charAt(0)) { + case "'": + if (!(match = SIMPLESTR.exec(this.chunk))) { + return 0; + } + string = match[0]; + this.token('STRING', string.replace(MULTILINER, '\\\n'), 0, string.length); + break; + case '"': + if (!(string = this.balancedString(this.chunk, '"'))) { + return 0; + } + if (0 < string.indexOf('#{', 1)) { + this.interpolateString(string.slice(1, -1), { + strOffset: 1, + lexedLength: string.length + }); + } else { + this.token('STRING', this.escapeLines(string, 0, string.length)); + } + break; + default: + return 0; + } + if (octalEsc = /^(?:\\.|[^\\])*\\(?:0[0-7]|[1-7])/.test(string)) { + this.error("octal escape sequences " + string + " are not allowed"); + } + return string.length; + }; + + Lexer.prototype.heredocToken = function() { + var doc, heredoc, match, quote; + if (!(match = HEREDOC.exec(this.chunk))) { + return 0; + } + heredoc = match[0]; + quote = heredoc.charAt(0); + doc = this.sanitizeHeredoc(match[2], { + quote: quote, + indent: null + }); + if (quote === '"' && 0 <= doc.indexOf('#{')) { + this.interpolateString(doc, { + heredoc: true, + strOffset: 3, + lexedLength: heredoc.length + }); + } else { + this.token('STRING', this.makeString(doc, quote, true), 0, heredoc.length); + } + return heredoc.length; + }; + + Lexer.prototype.commentToken = function() { + var comment, here, match; + if (!(match = this.chunk.match(COMMENT))) { + return 0; + } + comment = match[0], here = match[1]; + if (here) { + this.token('HERECOMMENT', this.sanitizeHeredoc(here, { + herecomment: true, + indent: repeat(' ', this.indent) + }), 0, comment.length); + } + return comment.length; + }; + + Lexer.prototype.jsToken = function() { + var match, script; + if (!(this.chunk.charAt(0) === '`' && (match = JSTOKEN.exec(this.chunk)))) { + return 0; + } + this.token('JS', (script = match[0]).slice(1, -1), 0, script.length); + return script.length; + }; + + Lexer.prototype.regexToken = function() { + var flags, length, match, prev, regex, _ref2, _ref3; + if (this.chunk.charAt(0) !== '/') { + return 0; + } + if (match = HEREGEX.exec(this.chunk)) { + length = this.heregexToken(match); + return length; + } + prev = last(this.tokens); + if (prev && (_ref2 = prev[0], __indexOf.call((prev.spaced ? NOT_REGEX : NOT_SPACED_REGEX), _ref2) >= 0)) { + return 0; + } + if (!(match = REGEX.exec(this.chunk))) { + return 0; + } + _ref3 = match, match = _ref3[0], regex = _ref3[1], flags = _ref3[2]; + if (regex.slice(0, 2) === '/*') { + this.error('regular expressions cannot begin with `*`'); + } + if (regex === '//') { + regex = '/(?:)/'; + } + this.token('REGEX', "" + regex + flags, 0, match.length); + return match.length; + }; + + Lexer.prototype.heregexToken = function(match) { + var body, flags, flagsOffset, heregex, plusToken, prev, re, tag, token, tokens, value, _i, _len, _ref2, _ref3, _ref4; + heregex = match[0], body = match[1], flags = match[2]; + if (0 > body.indexOf('#{')) { + re = body.replace(HEREGEX_OMIT, '').replace(/\//g, '\\/'); + if (re.match(/^\*/)) { + this.error('regular expressions cannot begin with `*`'); + } + this.token('REGEX', "/" + (re || '(?:)') + "/" + flags, 0, heregex.length); + return heregex.length; + } + this.token('IDENTIFIER', 'RegExp', 0, 0); + this.token('CALL_START', '(', 0, 0); + tokens = []; + _ref2 = this.interpolateString(body, { + regex: true + }); + for (_i = 0, _len = _ref2.length; _i < _len; _i++) { + token = _ref2[_i]; + tag = token[0], value = token[1]; + if (tag === 'TOKENS') { + tokens.push.apply(tokens, value); + } else if (tag === 'NEOSTRING') { + if (!(value = value.replace(HEREGEX_OMIT, ''))) { + continue; + } + value = value.replace(/\\/g, '\\\\'); + token[0] = 'STRING'; + token[1] = this.makeString(value, '"', true); + tokens.push(token); + } else { + this.error("Unexpected " + tag); + } + prev = last(this.tokens); + plusToken = ['+', '+']; + plusToken[2] = prev[2]; + tokens.push(plusToken); + } + tokens.pop(); + if (((_ref3 = tokens[0]) != null ? _ref3[0] : void 0) !== 'STRING') { + this.token('STRING', '""', 0, 0); + this.token('+', '+', 0, 0); + } + (_ref4 = this.tokens).push.apply(_ref4, tokens); + if (flags) { + flagsOffset = heregex.lastIndexOf(flags); + this.token(',', ',', flagsOffset, 0); + this.token('STRING', '"' + flags + '"', flagsOffset, flags.length); + } + this.token(')', ')', heregex.length - 1, 0); + return heregex.length; + }; + + Lexer.prototype.lineToken = function() { + var diff, indent, match, noNewlines, size; + if (!(match = MULTI_DENT.exec(this.chunk))) { + return 0; + } + indent = match[0]; + this.seenFor = false; + size = indent.length - 1 - indent.lastIndexOf('\n'); + noNewlines = this.unfinished(); + if (size - this.indebt === this.indent) { + if (noNewlines) { + this.suppressNewlines(); + } else { + this.newlineToken(0); + } + return indent.length; + } + if (size > this.indent) { + if (noNewlines) { + this.indebt = size - this.indent; + this.suppressNewlines(); + return indent.length; + } + if (!this.tokens.length) { + this.baseIndent = this.indent = size; + return indent.length; + } + diff = size - this.indent + this.outdebt; + this.token('INDENT', diff, indent.length - size, size); + this.indents.push(diff); + this.ends.push('OUTDENT'); + this.outdebt = this.indebt = 0; + } else if (size < this.baseIndent) { + this.error('missing indentation', indent.length); + } else { + this.indebt = 0; + this.outdentToken(this.indent - size, noNewlines, indent.length); + } + this.indent = size; + return indent.length; + }; + + Lexer.prototype.outdentToken = function(moveOut, noNewlines, outdentLength) { + var dent, len; + while (moveOut > 0) { + len = this.indents.length - 1; + if (this.indents[len] === void 0) { + moveOut = 0; + } else if (this.indents[len] === this.outdebt) { + moveOut -= this.outdebt; + this.outdebt = 0; + } else if (this.indents[len] < this.outdebt) { + this.outdebt -= this.indents[len]; + moveOut -= this.indents[len]; + } else { + dent = this.indents.pop() + this.outdebt; + moveOut -= dent; + this.outdebt = 0; + this.pair('OUTDENT'); + this.token('OUTDENT', dent, 0, outdentLength); + } + } + if (dent) { + this.outdebt -= moveOut; + } + while (this.value() === ';') { + this.tokens.pop(); + } + if (!(this.tag() === 'TERMINATOR' || noNewlines)) { + this.token('TERMINATOR', '\n', outdentLength, 0); + } + return this; + }; + + Lexer.prototype.whitespaceToken = function() { + var match, nline, prev; + if (!((match = WHITESPACE.exec(this.chunk)) || (nline = this.chunk.charAt(0) === '\n'))) { + return 0; + } + prev = last(this.tokens); + if (prev) { + prev[match ? 'spaced' : 'newLine'] = true; + } + if (match) { + return match[0].length; + } else { + return 0; + } + }; + + Lexer.prototype.newlineToken = function(offset) { + while (this.value() === ';') { + this.tokens.pop(); + } + if (this.tag() !== 'TERMINATOR') { + this.token('TERMINATOR', '\n', offset, 0); + } + return this; + }; + + Lexer.prototype.suppressNewlines = function() { + if (this.value() === '\\') { + this.tokens.pop(); + } + return this; + }; + + Lexer.prototype.literalToken = function() { + var match, prev, tag, value, _ref2, _ref3, _ref4, _ref5; + if (match = OPERATOR.exec(this.chunk)) { + value = match[0]; + if (CODE.test(value)) { + this.tagParameters(); + } + } else { + value = this.chunk.charAt(0); + } + tag = value; + prev = last(this.tokens); + if (value === '=' && prev) { + if (!prev[1].reserved && (_ref2 = prev[1], __indexOf.call(JS_FORBIDDEN, _ref2) >= 0)) { + this.error("reserved word \"" + (this.value()) + "\" can't be assigned"); + } + if ((_ref3 = prev[1]) === '||' || _ref3 === '&&') { + prev[0] = 'COMPOUND_ASSIGN'; + prev[1] += '='; + return value.length; + } + } + if (value === ';') { + this.seenFor = false; + tag = 'TERMINATOR'; + } else if (__indexOf.call(MATH, value) >= 0) { + tag = 'MATH'; + } else if (__indexOf.call(COMPARE, value) >= 0) { + tag = 'COMPARE'; + } else if (__indexOf.call(COMPOUND_ASSIGN, value) >= 0) { + tag = 'COMPOUND_ASSIGN'; + } else if (__indexOf.call(UNARY, value) >= 0) { + tag = 'UNARY'; + } else if (__indexOf.call(SHIFT, value) >= 0) { + tag = 'SHIFT'; + } else if (__indexOf.call(LOGIC, value) >= 0 || value === '?' && (prev != null ? prev.spaced : void 0)) { + tag = 'LOGIC'; + } else if (prev && !prev.spaced) { + if (value === '(' && (_ref4 = prev[0], __indexOf.call(CALLABLE, _ref4) >= 0)) { + if (prev[0] === '?') { + prev[0] = 'FUNC_EXIST'; + } + tag = 'CALL_START'; + } else if (value === '[' && (_ref5 = prev[0], __indexOf.call(INDEXABLE, _ref5) >= 0)) { + tag = 'INDEX_START'; + switch (prev[0]) { + case '?': + prev[0] = 'INDEX_SOAK'; + } + } + } + switch (value) { + case '(': + case '{': + case '[': + this.ends.push(INVERSES[value]); + break; + case ')': + case '}': + case ']': + this.pair(value); + } + this.token(tag, value); + return value.length; + }; + + Lexer.prototype.sanitizeHeredoc = function(doc, options) { + var attempt, herecomment, indent, match, _ref2; + indent = options.indent, herecomment = options.herecomment; + if (herecomment) { + if (HEREDOC_ILLEGAL.test(doc)) { + this.error("block comment cannot contain \"*/\", starting"); + } + if (doc.indexOf('\n') < 0) { + return doc; + } + } else { + while (match = HEREDOC_INDENT.exec(doc)) { + attempt = match[1]; + if (indent === null || (0 < (_ref2 = attempt.length) && _ref2 < indent.length)) { + indent = attempt; + } + } + } + if (indent) { + doc = doc.replace(RegExp("\\n" + indent, "g"), '\n'); + } + if (!herecomment) { + doc = doc.replace(/^\n/, ''); + } + return doc; + }; + + Lexer.prototype.tagParameters = function() { + var i, stack, tok, tokens; + if (this.tag() !== ')') { + return this; + } + stack = []; + tokens = this.tokens; + i = tokens.length; + tokens[--i][0] = 'PARAM_END'; + while (tok = tokens[--i]) { + switch (tok[0]) { + case ')': + stack.push(tok); + break; + case '(': + case 'CALL_START': + if (stack.length) { + stack.pop(); + } else if (tok[0] === '(') { + tok[0] = 'PARAM_START'; + return this; + } else { + return this; + } + } + } + return this; + }; + + Lexer.prototype.closeIndentation = function() { + return this.outdentToken(this.indent); + }; + + Lexer.prototype.balancedString = function(str, end) { + var continueCount, i, letter, match, prev, stack, _i, _ref2; + continueCount = 0; + stack = [end]; + for (i = _i = 1, _ref2 = str.length; 1 <= _ref2 ? _i < _ref2 : _i > _ref2; i = 1 <= _ref2 ? ++_i : --_i) { + if (continueCount) { + --continueCount; + continue; + } + switch (letter = str.charAt(i)) { + case '\\': + ++continueCount; + continue; + case end: + stack.pop(); + if (!stack.length) { + return str.slice(0, +i + 1 || 9e9); + } + end = stack[stack.length - 1]; + continue; + } + if (end === '}' && (letter === '"' || letter === "'")) { + stack.push(end = letter); + } else if (end === '}' && letter === '/' && (match = HEREGEX.exec(str.slice(i)) || REGEX.exec(str.slice(i)))) { + continueCount += match[0].length - 1; + } else if (end === '}' && letter === '{') { + stack.push(end = '}'); + } else if (end === '"' && prev === '#' && letter === '{') { + stack.push(end = '}'); + } + prev = letter; + } + return this.error("missing " + (stack.pop()) + ", starting"); + }; + + Lexer.prototype.interpolateString = function(str, options) { + var column, expr, heredoc, i, inner, interpolated, len, letter, lexedLength, line, locationToken, nested, offsetInChunk, pi, plusToken, popped, regex, rparen, strOffset, tag, token, tokens, value, _i, _len, _ref2, _ref3, _ref4; + if (options == null) { + options = {}; + } + heredoc = options.heredoc, regex = options.regex, offsetInChunk = options.offsetInChunk, strOffset = options.strOffset, lexedLength = options.lexedLength; + offsetInChunk = offsetInChunk || 0; + strOffset = strOffset || 0; + lexedLength = lexedLength || str.length; + if (heredoc && str.length > 0 && str[0] === '\n') { + str = str.slice(1); + strOffset++; + } + tokens = []; + pi = 0; + i = -1; + while (letter = str.charAt(i += 1)) { + if (letter === '\\') { + i += 1; + continue; + } + if (!(letter === '#' && str.charAt(i + 1) === '{' && (expr = this.balancedString(str.slice(i + 1), '}')))) { + continue; + } + if (pi < i) { + tokens.push(this.makeToken('NEOSTRING', str.slice(pi, i), strOffset + pi)); + } + inner = expr.slice(1, -1); + if (inner.length) { + _ref2 = this.getLineAndColumnFromChunk(strOffset + i + 1), line = _ref2[0], column = _ref2[1]; + nested = new Lexer().tokenize(inner, { + line: line, + column: column, + rewrite: false + }); + popped = nested.pop(); + if (((_ref3 = nested[0]) != null ? _ref3[0] : void 0) === 'TERMINATOR') { + popped = nested.shift(); + } + if (len = nested.length) { + if (len > 1) { + nested.unshift(this.makeToken('(', '(', strOffset + i + 1, 0)); + nested.push(this.makeToken(')', ')', strOffset + i + 1 + inner.length, 0)); + } + tokens.push(['TOKENS', nested]); + } + } + i += expr.length; + pi = i + 1; + } + if ((i > pi && pi < str.length)) { + tokens.push(this.makeToken('NEOSTRING', str.slice(pi), strOffset + pi)); + } + if (regex) { + return tokens; + } + if (!tokens.length) { + return this.token('STRING', '""', offsetInChunk, lexedLength); + } + if (tokens[0][0] !== 'NEOSTRING') { + tokens.unshift(this.makeToken('NEOSTRING', '', offsetInChunk)); + } + if (interpolated = tokens.length > 1) { + this.token('(', '(', offsetInChunk, 0); + } + for (i = _i = 0, _len = tokens.length; _i < _len; i = ++_i) { + token = tokens[i]; + tag = token[0], value = token[1]; + if (i) { + if (i) { + plusToken = this.token('+', '+'); + } + locationToken = tag === 'TOKENS' ? value[0] : token; + plusToken[2] = { + first_line: locationToken[2].first_line, + first_column: locationToken[2].first_column, + last_line: locationToken[2].first_line, + last_column: locationToken[2].first_column + }; + } + if (tag === 'TOKENS') { + (_ref4 = this.tokens).push.apply(_ref4, value); + } else if (tag === 'NEOSTRING') { + token[0] = 'STRING'; + token[1] = this.makeString(value, '"', heredoc); + this.tokens.push(token); + } else { + this.error("Unexpected " + tag); + } + } + if (interpolated) { + rparen = this.makeToken(')', ')', offsetInChunk + lexedLength, 0); + rparen.stringEnd = true; + this.tokens.push(rparen); + } + return tokens; + }; + + Lexer.prototype.pair = function(tag) { + var size, wanted; + if (tag !== (wanted = last(this.ends))) { + if ('OUTDENT' !== wanted) { + this.error("unmatched " + tag); + } + this.indent -= size = last(this.indents); + this.outdentToken(size, true); + return this.pair(tag); + } + return this.ends.pop(); + }; + + Lexer.prototype.getLineAndColumnFromChunk = function(offset) { + var column, lineCount, lines, string; + if (offset === 0) { + return [this.chunkLine, this.chunkColumn]; + } + if (offset >= this.chunk.length) { + string = this.chunk; + } else { + string = this.chunk.slice(0, +(offset - 1) + 1 || 9e9); + } + lineCount = count(string, '\n'); + column = this.chunkColumn; + if (lineCount > 0) { + lines = string.split('\n'); + column = last(lines).length; + } else { + column += string.length; + } + return [this.chunkLine + lineCount, column]; + }; + + Lexer.prototype.makeToken = function(tag, value, offsetInChunk, length) { + var lastCharacter, locationData, token, _ref2, _ref3; + if (offsetInChunk == null) { + offsetInChunk = 0; + } + if (length == null) { + length = value.length; + } + locationData = {}; + _ref2 = this.getLineAndColumnFromChunk(offsetInChunk), locationData.first_line = _ref2[0], locationData.first_column = _ref2[1]; + lastCharacter = Math.max(0, length - 1); + _ref3 = this.getLineAndColumnFromChunk(offsetInChunk + lastCharacter), locationData.last_line = _ref3[0], locationData.last_column = _ref3[1]; + token = [tag, value, locationData]; + return token; + }; + + Lexer.prototype.token = function(tag, value, offsetInChunk, length) { + var token; + token = this.makeToken(tag, value, offsetInChunk, length); + this.tokens.push(token); + return token; + }; + + Lexer.prototype.tag = function(index, tag) { + var tok; + return (tok = last(this.tokens, index)) && (tag ? tok[0] = tag : tok[0]); + }; + + Lexer.prototype.value = function(index, val) { + var tok; + return (tok = last(this.tokens, index)) && (val ? tok[1] = val : tok[1]); + }; + + Lexer.prototype.unfinished = function() { + var _ref2; + return LINE_CONTINUER.test(this.chunk) || ((_ref2 = this.tag()) === '\\' || _ref2 === '.' || _ref2 === '?.' || _ref2 === '?::' || _ref2 === 'UNARY' || _ref2 === 'MATH' || _ref2 === '+' || _ref2 === '-' || _ref2 === 'SHIFT' || _ref2 === 'RELATION' || _ref2 === 'COMPARE' || _ref2 === 'LOGIC' || _ref2 === 'THROW' || _ref2 === 'EXTENDS'); + }; + + Lexer.prototype.escapeLines = function(str, heredoc) { + return str.replace(MULTILINER, heredoc ? '\\n' : ''); + }; + + Lexer.prototype.makeString = function(body, quote, heredoc) { + if (!body) { + return quote + quote; + } + body = body.replace(/\\([\s\S])/g, function(match, contents) { + if (contents === '\n' || contents === quote) { + return contents; + } else { + return match; + } + }); + body = body.replace(RegExp("" + quote, "g"), '\\$&'); + return quote + this.escapeLines(body, heredoc) + quote; + }; + + Lexer.prototype.error = function(message, offset) { + var first_column, first_line, _ref2; + if (offset == null) { + offset = 0; + } + _ref2 = this.getLineAndColumnFromChunk(offset), first_line = _ref2[0], first_column = _ref2[1]; + return throwSyntaxError(message, { + first_line: first_line, + first_column: first_column + }); + }; + + return Lexer; + + })(); + + JS_KEYWORDS = ['true', 'false', 'null', 'this', 'new', 'delete', 'typeof', 'in', 'instanceof', 'return', 'throw', 'break', 'continue', 'debugger', 'if', 'else', 'switch', 'for', 'while', 'do', 'try', 'catch', 'finally', 'class', 'extends', 'super']; + + COFFEE_KEYWORDS = ['undefined', 'then', 'unless', 'until', 'loop', 'of', 'by', 'when']; + + COFFEE_ALIAS_MAP = { + and: '&&', + or: '||', + is: '==', + isnt: '!=', + not: '!', + yes: 'true', + no: 'false', + on: 'true', + off: 'false' + }; + + COFFEE_ALIASES = (function() { + var _results; + _results = []; + for (key in COFFEE_ALIAS_MAP) { + _results.push(key); + } + return _results; + })(); + + COFFEE_KEYWORDS = COFFEE_KEYWORDS.concat(COFFEE_ALIASES); + + RESERVED = ['case', 'default', 'function', 'var', 'void', 'with', 'const', 'let', 'enum', 'export', 'import', 'native', '__hasProp', '__extends', '__slice', '__bind', '__indexOf', 'implements', 'interface', 'package', 'private', 'protected', 'public', 'static', 'yield']; + + STRICT_PROSCRIBED = ['arguments', 'eval']; + + JS_FORBIDDEN = JS_KEYWORDS.concat(RESERVED).concat(STRICT_PROSCRIBED); + + exports.RESERVED = RESERVED.concat(JS_KEYWORDS).concat(COFFEE_KEYWORDS).concat(STRICT_PROSCRIBED); + + exports.STRICT_PROSCRIBED = STRICT_PROSCRIBED; + + BOM = 65279; + + IDENTIFIER = /^([$A-Za-z_\x7f-\uffff][$\w\x7f-\uffff]*)([^\n\S]*:(?!:))?/; + + NUMBER = /^0b[01]+|^0o[0-7]+|^0x[\da-f]+|^\d*\.?\d+(?:e[+-]?\d+)?/i; + + HEREDOC = /^("""|''')([\s\S]*?)(?:\n[^\n\S]*)?\1/; + + OPERATOR = /^(?:[-=]>|[-+*\/%<>&|^!?=]=|>>>=?|([-+:])\1|([&|<>])\2=?|\?(\.|::)|\.{2,3})/; + + WHITESPACE = /^[^\n\S]+/; + + COMMENT = /^###([^#][\s\S]*?)(?:###[^\n\S]*|(?:###)$)|^(?:\s*#(?!##[^#]).*)+/; + + CODE = /^[-=]>/; + + MULTI_DENT = /^(?:\n[^\n\S]*)+/; + + SIMPLESTR = /^'[^\\']*(?:\\.[^\\']*)*'/; + + JSTOKEN = /^`[^\\`]*(?:\\.[^\\`]*)*`/; + + REGEX = /^(\/(?![\s=])[^[\/\n\\]*(?:(?:\\[\s\S]|\[[^\]\n\\]*(?:\\[\s\S][^\]\n\\]*)*])[^[\/\n\\]*)*\/)([imgy]{0,4})(?!\w)/; + + HEREGEX = /^\/{3}([\s\S]+?)\/{3}([imgy]{0,4})(?!\w)/; + + HEREGEX_OMIT = /\s+(?:#.*)?/g; + + MULTILINER = /\n/g; + + HEREDOC_INDENT = /\n+([^\n\S]*)/g; + + HEREDOC_ILLEGAL = /\*\//; + + LINE_CONTINUER = /^\s*(?:,|\??\.(?![.\d])|::)/; + + TRAILING_SPACES = /\s+$/; + + COMPOUND_ASSIGN = ['-=', '+=', '/=', '*=', '%=', '||=', '&&=', '?=', '<<=', '>>=', '>>>=', '&=', '^=', '|=']; + + UNARY = ['!', '~', 'NEW', 'TYPEOF', 'DELETE', 'DO']; + + LOGIC = ['&&', '||', '&', '|', '^']; + + SHIFT = ['<<', '>>', '>>>']; + + COMPARE = ['==', '!=', '<', '>', '<=', '>=']; + + MATH = ['*', '/', '%']; + + RELATION = ['IN', 'OF', 'INSTANCEOF']; + + BOOL = ['TRUE', 'FALSE']; + + NOT_REGEX = ['NUMBER', 'REGEX', 'BOOL', 'NULL', 'UNDEFINED', '++', '--']; + + NOT_SPACED_REGEX = NOT_REGEX.concat(')', '}', 'THIS', 'IDENTIFIER', 'STRING', ']'); + + CALLABLE = ['IDENTIFIER', 'STRING', 'REGEX', ')', ']', '}', '?', '::', '@', 'THIS', 'SUPER']; + + INDEXABLE = CALLABLE.concat('NUMBER', 'BOOL', 'NULL', 'UNDEFINED'); + + LINE_BREAK = ['INDENT', 'OUTDENT', 'TERMINATOR']; + + +}); + +ace.define('ace/mode/coffee/rewriter', ['require', 'exports', 'module' ], function(require, exports, module) { + + var BALANCED_PAIRS, EXPRESSION_CLOSE, EXPRESSION_END, EXPRESSION_START, IMPLICIT_CALL, IMPLICIT_END, IMPLICIT_FUNC, IMPLICIT_UNSPACED_CALL, INVERSES, LINEBREAKS, SINGLE_CLOSERS, SINGLE_LINERS, generate, left, rite, _i, _len, _ref, + __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }, + __slice = [].slice; + + generate = function(tag, value) { + var tok; + tok = [tag, value]; + tok.generated = true; + return tok; + }; + + exports.Rewriter = (function() { + function Rewriter() {} + + Rewriter.prototype.rewrite = function(tokens) { + this.tokens = tokens; + this.removeLeadingNewlines(); + this.removeMidExpressionNewlines(); + this.closeOpenCalls(); + this.closeOpenIndexes(); + this.addImplicitIndentation(); + this.tagPostfixConditionals(); + this.addImplicitBracesAndParens(); + this.addLocationDataToGeneratedTokens(); + return this.tokens; + }; + + Rewriter.prototype.scanTokens = function(block) { + var i, token, tokens; + tokens = this.tokens; + i = 0; + while (token = tokens[i]) { + i += block.call(this, token, i, tokens); + } + return true; + }; + + Rewriter.prototype.detectEnd = function(i, condition, action) { + var levels, token, tokens, _ref, _ref1; + tokens = this.tokens; + levels = 0; + while (token = tokens[i]) { + if (levels === 0 && condition.call(this, token, i)) { + return action.call(this, token, i); + } + if (!token || levels < 0) { + return action.call(this, token, i - 1); + } + if (_ref = token[0], __indexOf.call(EXPRESSION_START, _ref) >= 0) { + levels += 1; + } else if (_ref1 = token[0], __indexOf.call(EXPRESSION_END, _ref1) >= 0) { + levels -= 1; + } + i += 1; + } + return i - 1; + }; + + Rewriter.prototype.removeLeadingNewlines = function() { + var i, tag, _i, _len, _ref; + _ref = this.tokens; + for (i = _i = 0, _len = _ref.length; _i < _len; i = ++_i) { + tag = _ref[i][0]; + if (tag !== 'TERMINATOR') { + break; + } + } + if (i) { + return this.tokens.splice(0, i); + } + }; + + Rewriter.prototype.removeMidExpressionNewlines = function() { + return this.scanTokens(function(token, i, tokens) { + var _ref; + if (!(token[0] === 'TERMINATOR' && (_ref = this.tag(i + 1), __indexOf.call(EXPRESSION_CLOSE, _ref) >= 0))) { + return 1; + } + tokens.splice(i, 1); + return 0; + }); + }; + + Rewriter.prototype.closeOpenCalls = function() { + var action, condition; + condition = function(token, i) { + var _ref; + return ((_ref = token[0]) === ')' || _ref === 'CALL_END') || token[0] === 'OUTDENT' && this.tag(i - 1) === ')'; + }; + action = function(token, i) { + return this.tokens[token[0] === 'OUTDENT' ? i - 1 : i][0] = 'CALL_END'; + }; + return this.scanTokens(function(token, i) { + if (token[0] === 'CALL_START') { + this.detectEnd(i + 1, condition, action); + } + return 1; + }); + }; + + Rewriter.prototype.closeOpenIndexes = function() { + var action, condition; + condition = function(token, i) { + var _ref; + return (_ref = token[0]) === ']' || _ref === 'INDEX_END'; + }; + action = function(token, i) { + return token[0] = 'INDEX_END'; + }; + return this.scanTokens(function(token, i) { + if (token[0] === 'INDEX_START') { + this.detectEnd(i + 1, condition, action); + } + return 1; + }); + }; + + Rewriter.prototype.matchTags = function() { + var fuzz, i, j, pattern, _i, _ref, _ref1; + i = arguments[0], pattern = 2 <= arguments.length ? __slice.call(arguments, 1) : []; + fuzz = 0; + for (j = _i = 0, _ref = pattern.length; 0 <= _ref ? _i < _ref : _i > _ref; j = 0 <= _ref ? ++_i : --_i) { + while (this.tag(i + j + fuzz) === 'HERECOMMENT') { + fuzz += 2; + } + if (pattern[j] == null) { + continue; + } + if (typeof pattern[j] === 'string') { + pattern[j] = [pattern[j]]; + } + if (_ref1 = this.tag(i + j + fuzz), __indexOf.call(pattern[j], _ref1) < 0) { + return false; + } + } + return true; + }; + + Rewriter.prototype.looksObjectish = function(j) { + return this.matchTags(j, '@', null, ':') || this.matchTags(j, null, ':'); + }; + + Rewriter.prototype.findTagsBackwards = function(i, tags) { + var backStack, _ref, _ref1, _ref2, _ref3, _ref4, _ref5; + backStack = []; + while (i >= 0 && (backStack.length || (_ref2 = this.tag(i), __indexOf.call(tags, _ref2) < 0) && ((_ref3 = this.tag(i), __indexOf.call(EXPRESSION_START, _ref3) < 0) || this.tokens[i].generated) && (_ref4 = this.tag(i), __indexOf.call(LINEBREAKS, _ref4) < 0))) { + if (_ref = this.tag(i), __indexOf.call(EXPRESSION_END, _ref) >= 0) { + backStack.push(this.tag(i)); + } + if ((_ref1 = this.tag(i), __indexOf.call(EXPRESSION_START, _ref1) >= 0) && backStack.length) { + backStack.pop(); + } + i -= 1; + } + return _ref5 = this.tag(i), __indexOf.call(tags, _ref5) >= 0; + }; + + Rewriter.prototype.addImplicitBracesAndParens = function() { + var stack; + stack = []; + return this.scanTokens(function(token, i, tokens) { + var endImplicitCall, endImplicitObject, forward, inImplicit, inImplicitCall, inImplicitControl, inImplicitObject, nextTag, offset, prevTag, s, sameLine, stackIdx, stackTag, stackTop, startIdx, startImplicitCall, startImplicitObject, startsLine, tag, _ref, _ref1, _ref2, _ref3, _ref4, _ref5; + tag = token[0]; + prevTag = (i > 0 ? tokens[i - 1] : [])[0]; + nextTag = (i < tokens.length - 1 ? tokens[i + 1] : [])[0]; + stackTop = function() { + return stack[stack.length - 1]; + }; + startIdx = i; + forward = function(n) { + return i - startIdx + n; + }; + inImplicit = function() { + var _ref, _ref1; + return (_ref = stackTop()) != null ? (_ref1 = _ref[2]) != null ? _ref1.ours : void 0 : void 0; + }; + inImplicitCall = function() { + var _ref; + return inImplicit() && ((_ref = stackTop()) != null ? _ref[0] : void 0) === '('; + }; + inImplicitObject = function() { + var _ref; + return inImplicit() && ((_ref = stackTop()) != null ? _ref[0] : void 0) === '{'; + }; + inImplicitControl = function() { + var _ref; + return inImplicit && ((_ref = stackTop()) != null ? _ref[0] : void 0) === 'CONTROL'; + }; + startImplicitCall = function(j) { + var idx; + idx = j != null ? j : i; + stack.push([ + '(', idx, { + ours: true + } + ]); + tokens.splice(idx, 0, generate('CALL_START', '(')); + if (j == null) { + return i += 1; + } + }; + endImplicitCall = function() { + stack.pop(); + tokens.splice(i, 0, generate('CALL_END', ')')); + return i += 1; + }; + startImplicitObject = function(j, startsLine) { + var idx; + if (startsLine == null) { + startsLine = true; + } + idx = j != null ? j : i; + stack.push([ + '{', idx, { + sameLine: true, + startsLine: startsLine, + ours: true + } + ]); + tokens.splice(idx, 0, generate('{', generate(new String('{')))); + if (j == null) { + return i += 1; + } + }; + endImplicitObject = function(j) { + j = j != null ? j : i; + stack.pop(); + tokens.splice(j, 0, generate('}', '}')); + return i += 1; + }; + if (inImplicitCall() && (tag === 'IF' || tag === 'TRY' || tag === 'FINALLY' || tag === 'CATCH' || tag === 'CLASS' || tag === 'SWITCH')) { + stack.push([ + 'CONTROL', i, { + ours: true + } + ]); + return forward(1); + } + if (tag === 'INDENT' && inImplicit()) { + if (prevTag !== '=>' && prevTag !== '->' && prevTag !== '[' && prevTag !== '(' && prevTag !== ',' && prevTag !== '{' && prevTag !== 'TRY' && prevTag !== 'ELSE' && prevTag !== '=') { + while (inImplicitCall()) { + endImplicitCall(); + } + } + if (inImplicitControl()) { + stack.pop(); + } + stack.push([tag, i]); + return forward(1); + } + if (__indexOf.call(EXPRESSION_START, tag) >= 0) { + stack.push([tag, i]); + return forward(1); + } + if (__indexOf.call(EXPRESSION_END, tag) >= 0) { + while (inImplicit()) { + if (inImplicitCall()) { + endImplicitCall(); + } else if (inImplicitObject()) { + endImplicitObject(); + } else { + stack.pop(); + } + } + stack.pop(); + } + if ((__indexOf.call(IMPLICIT_FUNC, tag) >= 0 && token.spaced && !token.stringEnd || tag === '?' && i > 0 && !tokens[i - 1].spaced) && (__indexOf.call(IMPLICIT_CALL, nextTag) >= 0 || __indexOf.call(IMPLICIT_UNSPACED_CALL, nextTag) >= 0 && !((_ref = tokens[i + 1]) != null ? _ref.spaced : void 0) && !((_ref1 = tokens[i + 1]) != null ? _ref1.newLine : void 0))) { + if (tag === '?') { + tag = token[0] = 'FUNC_EXIST'; + } + startImplicitCall(i + 1); + return forward(2); + } + if (__indexOf.call(IMPLICIT_FUNC, tag) >= 0 && this.matchTags(i + 1, 'INDENT', null, ':') && !this.findTagsBackwards(i, ['CLASS', 'EXTENDS', 'IF', 'CATCH', 'SWITCH', 'LEADING_WHEN', 'FOR', 'WHILE', 'UNTIL'])) { + startImplicitCall(i + 1); + stack.push(['INDENT', i + 2]); + return forward(3); + } + if (tag === ':') { + if (this.tag(i - 2) === '@') { + s = i - 2; + } else { + s = i - 1; + } + while (this.tag(s - 2) === 'HERECOMMENT') { + s -= 2; + } + startsLine = s === 0 || (_ref2 = this.tag(s - 1), __indexOf.call(LINEBREAKS, _ref2) >= 0) || tokens[s - 1].newLine; + if (stackTop()) { + _ref3 = stackTop(), stackTag = _ref3[0], stackIdx = _ref3[1]; + if ((stackTag === '{' || stackTag === 'INDENT' && this.tag(stackIdx - 1) === '{') && (startsLine || this.tag(s - 1) === ',' || this.tag(s - 1) === '{')) { + return forward(1); + } + } + startImplicitObject(s, !!startsLine); + return forward(2); + } + if (prevTag === 'OUTDENT' && inImplicitCall() && (tag === '.' || tag === '?.' || tag === '::' || tag === '?::')) { + endImplicitCall(); + return forward(1); + } + if (inImplicitObject() && __indexOf.call(LINEBREAKS, tag) >= 0) { + stackTop()[2].sameLine = false; + } + if (__indexOf.call(IMPLICIT_END, tag) >= 0) { + while (inImplicit()) { + _ref4 = stackTop(), stackTag = _ref4[0], stackIdx = _ref4[1], (_ref5 = _ref4[2], sameLine = _ref5.sameLine, startsLine = _ref5.startsLine); + if (inImplicitCall() && prevTag !== ',') { + endImplicitCall(); + } else if (inImplicitObject() && sameLine && !startsLine) { + endImplicitObject(); + } else if (inImplicitObject() && tag === 'TERMINATOR' && prevTag !== ',' && !(startsLine && this.looksObjectish(i + 1))) { + endImplicitObject(); + } else { + break; + } + } + } + if (tag === ',' && !this.looksObjectish(i + 1) && inImplicitObject() && (nextTag !== 'TERMINATOR' || !this.looksObjectish(i + 2))) { + offset = nextTag === 'OUTDENT' ? 1 : 0; + while (inImplicitObject()) { + endImplicitObject(i + offset); + } + } + return forward(1); + }); + }; + + Rewriter.prototype.addLocationDataToGeneratedTokens = function() { + return this.scanTokens(function(token, i, tokens) { + var column, line, nextLocation, prevLocation, _ref, _ref1; + if (token[2]) { + return 1; + } + if (!(token.generated || token.explicit)) { + return 1; + } + if (token[0] === '{' && (nextLocation = (_ref = tokens[i + 1]) != null ? _ref[2] : void 0)) { + line = nextLocation.first_line, column = nextLocation.first_column; + } else if (prevLocation = (_ref1 = tokens[i - 1]) != null ? _ref1[2] : void 0) { + line = prevLocation.last_line, column = prevLocation.last_column; + } else { + line = column = 0; + } + token[2] = { + first_line: line, + first_column: column, + last_line: line, + last_column: column + }; + return 1; + }); + }; + + Rewriter.prototype.addImplicitIndentation = function() { + var action, condition, indent, outdent, starter; + starter = indent = outdent = null; + condition = function(token, i) { + var _ref, _ref1; + return token[1] !== ';' && (_ref = token[0], __indexOf.call(SINGLE_CLOSERS, _ref) >= 0) && !(token[0] === 'ELSE' && starter !== 'THEN') && !(((_ref1 = token[0]) === 'CATCH' || _ref1 === 'FINALLY') && (starter === '->' || starter === '=>')); + }; + action = function(token, i) { + return this.tokens.splice((this.tag(i - 1) === ',' ? i - 1 : i), 0, outdent); + }; + return this.scanTokens(function(token, i, tokens) { + var j, tag, _i, _ref, _ref1; + tag = token[0]; + if (tag === 'TERMINATOR' && this.tag(i + 1) === 'THEN') { + tokens.splice(i, 1); + return 0; + } + if (tag === 'ELSE' && this.tag(i - 1) !== 'OUTDENT') { + tokens.splice.apply(tokens, [i, 0].concat(__slice.call(this.indentation()))); + return 2; + } + if (tag === 'CATCH') { + for (j = _i = 1; _i <= 2; j = ++_i) { + if (!((_ref = this.tag(i + j)) === 'OUTDENT' || _ref === 'TERMINATOR' || _ref === 'FINALLY')) { + continue; + } + tokens.splice.apply(tokens, [i + j, 0].concat(__slice.call(this.indentation()))); + return 2 + j; + } + } + if (__indexOf.call(SINGLE_LINERS, tag) >= 0 && this.tag(i + 1) !== 'INDENT' && !(tag === 'ELSE' && this.tag(i + 1) === 'IF')) { + starter = tag; + _ref1 = this.indentation(true), indent = _ref1[0], outdent = _ref1[1]; + if (starter === 'THEN') { + indent.fromThen = true; + } + tokens.splice(i + 1, 0, indent); + this.detectEnd(i + 2, condition, action); + if (tag === 'THEN') { + tokens.splice(i, 1); + } + return 1; + } + return 1; + }); + }; + + Rewriter.prototype.tagPostfixConditionals = function() { + var action, condition, original; + original = null; + condition = function(token, i) { + var prevTag, tag; + tag = token[0]; + prevTag = this.tokens[i - 1][0]; + return tag === 'TERMINATOR' || (tag === 'INDENT' && __indexOf.call(SINGLE_LINERS, prevTag) < 0); + }; + action = function(token, i) { + if (token[0] !== 'INDENT' || (token.generated && !token.fromThen)) { + return original[0] = 'POST_' + original[0]; + } + }; + return this.scanTokens(function(token, i) { + if (token[0] !== 'IF') { + return 1; + } + original = token; + this.detectEnd(i + 1, condition, action); + return 1; + }); + }; + + Rewriter.prototype.indentation = function(implicit) { + var indent, outdent; + if (implicit == null) { + implicit = false; + } + indent = ['INDENT', 2]; + outdent = ['OUTDENT', 2]; + if (implicit) { + indent.generated = outdent.generated = true; + } + if (!implicit) { + indent.explicit = outdent.explicit = true; + } + return [indent, outdent]; + }; + + Rewriter.prototype.generate = generate; + + Rewriter.prototype.tag = function(i) { + var _ref; + return (_ref = this.tokens[i]) != null ? _ref[0] : void 0; + }; + + return Rewriter; + + })(); + + BALANCED_PAIRS = [['(', ')'], ['[', ']'], ['{', '}'], ['INDENT', 'OUTDENT'], ['CALL_START', 'CALL_END'], ['PARAM_START', 'PARAM_END'], ['INDEX_START', 'INDEX_END']]; + + exports.INVERSES = INVERSES = {}; + + EXPRESSION_START = []; + + EXPRESSION_END = []; + + for (_i = 0, _len = BALANCED_PAIRS.length; _i < _len; _i++) { + _ref = BALANCED_PAIRS[_i], left = _ref[0], rite = _ref[1]; + EXPRESSION_START.push(INVERSES[rite] = left); + EXPRESSION_END.push(INVERSES[left] = rite); + } + + EXPRESSION_CLOSE = ['CATCH', 'WHEN', 'ELSE', 'FINALLY'].concat(EXPRESSION_END); + + IMPLICIT_FUNC = ['IDENTIFIER', 'SUPER', ')', 'CALL_END', ']', 'INDEX_END', '@', 'THIS']; + + IMPLICIT_CALL = ['IDENTIFIER', 'NUMBER', 'STRING', 'JS', 'REGEX', 'NEW', 'PARAM_START', 'CLASS', 'IF', 'TRY', 'SWITCH', 'THIS', 'BOOL', 'NULL', 'UNDEFINED', 'UNARY', 'SUPER', 'THROW', '@', '->', '=>', '[', '(', '{', '--', '++']; + + IMPLICIT_UNSPACED_CALL = ['+', '-']; + + IMPLICIT_END = ['POST_IF', 'FOR', 'WHILE', 'UNTIL', 'WHEN', 'BY', 'LOOP', 'TERMINATOR']; + + SINGLE_LINERS = ['ELSE', '->', '=>', 'TRY', 'FINALLY', 'THEN']; + + SINGLE_CLOSERS = ['TERMINATOR', 'CATCH', 'FINALLY', 'ELSE', 'OUTDENT', 'LEADING_WHEN']; + + LINEBREAKS = ['TERMINATOR', 'INDENT', 'OUTDENT']; + + +}); + +ace.define('ace/mode/coffee/helpers', ['require', 'exports', 'module' ], function(require, exports, module) { + + var buildLocationData, extend, flatten, last, repeat, syntaxErrorToString, _ref; + + exports.starts = function(string, literal, start) { + return literal === string.substr(start, literal.length); + }; + + exports.ends = function(string, literal, back) { + var len; + len = literal.length; + return literal === string.substr(string.length - len - (back || 0), len); + }; + + exports.repeat = repeat = function(str, n) { + var res; + res = ''; + while (n > 0) { + if (n & 1) { + res += str; + } + n >>>= 1; + str += str; + } + return res; + }; + + exports.compact = function(array) { + var item, _i, _len, _results; + _results = []; + for (_i = 0, _len = array.length; _i < _len; _i++) { + item = array[_i]; + if (item) { + _results.push(item); + } + } + return _results; + }; + + exports.count = function(string, substr) { + var num, pos; + num = pos = 0; + if (!substr.length) { + return 1 / 0; + } + while (pos = 1 + string.indexOf(substr, pos)) { + num++; + } + return num; + }; + + exports.merge = function(options, overrides) { + return extend(extend({}, options), overrides); + }; + + extend = exports.extend = function(object, properties) { + var key, val; + for (key in properties) { + val = properties[key]; + object[key] = val; + } + return object; + }; + + exports.flatten = flatten = function(array) { + var element, flattened, _i, _len; + flattened = []; + for (_i = 0, _len = array.length; _i < _len; _i++) { + element = array[_i]; + if (element instanceof Array) { + flattened = flattened.concat(flatten(element)); + } else { + flattened.push(element); + } + } + return flattened; + }; + + exports.del = function(obj, key) { + var val; + val = obj[key]; + delete obj[key]; + return val; + }; + + exports.last = last = function(array, back) { + return array[array.length - (back || 0) - 1]; + }; + + exports.some = (_ref = Array.prototype.some) != null ? _ref : function(fn) { + var e, _i, _len; + for (_i = 0, _len = this.length; _i < _len; _i++) { + e = this[_i]; + if (fn(e)) { + return true; + } + } + return false; + }; + + exports.invertLiterate = function(code) { + var line, lines, maybe_code; + maybe_code = true; + lines = (function() { + var _i, _len, _ref1, _results; + _ref1 = code.split('\n'); + _results = []; + for (_i = 0, _len = _ref1.length; _i < _len; _i++) { + line = _ref1[_i]; + if (maybe_code && /^([ ]{4}|[ ]{0,3}\t)/.test(line)) { + _results.push(line); + } else if (maybe_code = /^\s*$/.test(line)) { + _results.push(line); + } else { + _results.push('# ' + line); + } + } + return _results; + })(); + return lines.join('\n'); + }; + + buildLocationData = function(first, last) { + if (!last) { + return first; + } else { + return { + first_line: first.first_line, + first_column: first.first_column, + last_line: last.last_line, + last_column: last.last_column + }; + } + }; + + exports.addLocationDataFn = function(first, last) { + return function(obj) { + if (((typeof obj) === 'object') && (!!obj['updateLocationDataIfMissing'])) { + obj.updateLocationDataIfMissing(buildLocationData(first, last)); + } + return obj; + }; + }; + + exports.locationDataToString = function(obj) { + var locationData; + if (("2" in obj) && ("first_line" in obj[2])) { + locationData = obj[2]; + } else if ("first_line" in obj) { + locationData = obj; + } + if (locationData) { + return ("" + (locationData.first_line + 1) + ":" + (locationData.first_column + 1) + "-") + ("" + (locationData.last_line + 1) + ":" + (locationData.last_column + 1)); + } else { + return "No location data"; + } + }; + + exports.baseFileName = function(file, stripExt, useWinPathSep) { + var parts, pathSep; + if (stripExt == null) { + stripExt = false; + } + if (useWinPathSep == null) { + useWinPathSep = false; + } + pathSep = useWinPathSep ? /\\|\// : /\//; + parts = file.split(pathSep); + file = parts[parts.length - 1]; + if (!stripExt) { + return file; + } + parts = file.split('.'); + parts.pop(); + if (parts[parts.length - 1] === 'coffee' && parts.length > 1) { + parts.pop(); + } + return parts.join('.'); + }; + + exports.isCoffee = function(file) { + return /\.((lit)?coffee|coffee\.md)$/.test(file); + }; + + exports.isLiterate = function(file) { + return /\.(litcoffee|coffee\.md)$/.test(file); + }; + + exports.throwSyntaxError = function(message, location) { + var error; + if (location.last_line == null) { + location.last_line = location.first_line; + } + if (location.last_column == null) { + location.last_column = location.first_column; + } + error = new SyntaxError(message); + error.location = location; + error.toString = syntaxErrorToString; + error.stack = error.toString(); + throw error; + }; + + exports.updateSyntaxError = function(error, code, filename) { + if (error.toString === syntaxErrorToString) { + error.code || (error.code = code); + error.filename || (error.filename = filename); + error.stack = error.toString(); + } + return error; + }; + + syntaxErrorToString = function() { + var codeLine, colorize, colorsEnabled, end, filename, first_column, first_line, last_column, last_line, marker, start, _ref1, _ref2; + if (!(this.code && this.location)) { + return Error.prototype.toString.call(this); + } + _ref1 = this.location, first_line = _ref1.first_line, first_column = _ref1.first_column, last_line = _ref1.last_line, last_column = _ref1.last_column; + if (last_line == null) { + last_line = first_line; + } + if (last_column == null) { + last_column = first_column; + } + filename = this.filename || '[stdin]'; + codeLine = this.code.split('\n')[first_line]; + start = first_column; + end = first_line === last_line ? last_column + 1 : codeLine.length; + marker = repeat(' ', start) + repeat('^', end - start); + if (typeof process !== "undefined" && process !== null) { + colorsEnabled = process.stdout.isTTY && !process.env.NODE_DISABLE_COLORS; + } + if ((_ref2 = this.colorful) != null ? _ref2 : colorsEnabled) { + colorize = function(str) { + return "\x1B[1;31m" + str + "\x1B[0m"; + }; + codeLine = codeLine.slice(0, start) + colorize(codeLine.slice(start, end)) + codeLine.slice(end); + marker = colorize(marker); + } + return "" + filename + ":" + (first_line + 1) + ":" + (first_column + 1) + ": error: " + this.message + "\n" + codeLine + "\n" + marker; + }; + + +}); + +ace.define('ace/mode/coffee/parser', ['require', 'exports', 'module' ], function(require, exports, module) { + +var parser = {trace: function trace() { }, +yy: {}, +symbols_: {"error":2,"Root":3,"Body":4,"Line":5,"TERMINATOR":6,"Expression":7,"Statement":8,"Return":9,"Comment":10,"STATEMENT":11,"Value":12,"Invocation":13,"Code":14,"Operation":15,"Assign":16,"If":17,"Try":18,"While":19,"For":20,"Switch":21,"Class":22,"Throw":23,"Block":24,"INDENT":25,"OUTDENT":26,"Identifier":27,"IDENTIFIER":28,"AlphaNumeric":29,"NUMBER":30,"STRING":31,"Literal":32,"JS":33,"REGEX":34,"DEBUGGER":35,"UNDEFINED":36,"NULL":37,"BOOL":38,"Assignable":39,"=":40,"AssignObj":41,"ObjAssignable":42,":":43,"ThisProperty":44,"RETURN":45,"HERECOMMENT":46,"PARAM_START":47,"ParamList":48,"PARAM_END":49,"FuncGlyph":50,"->":51,"=>":52,"OptComma":53,",":54,"Param":55,"ParamVar":56,"...":57,"Array":58,"Object":59,"Splat":60,"SimpleAssignable":61,"Accessor":62,"Parenthetical":63,"Range":64,"This":65,".":66,"?.":67,"::":68,"?::":69,"Index":70,"INDEX_START":71,"IndexValue":72,"INDEX_END":73,"INDEX_SOAK":74,"Slice":75,"{":76,"AssignList":77,"}":78,"CLASS":79,"EXTENDS":80,"OptFuncExist":81,"Arguments":82,"SUPER":83,"FUNC_EXIST":84,"CALL_START":85,"CALL_END":86,"ArgList":87,"THIS":88,"@":89,"[":90,"]":91,"RangeDots":92,"..":93,"Arg":94,"SimpleArgs":95,"TRY":96,"Catch":97,"FINALLY":98,"CATCH":99,"THROW":100,"(":101,")":102,"WhileSource":103,"WHILE":104,"WHEN":105,"UNTIL":106,"Loop":107,"LOOP":108,"ForBody":109,"FOR":110,"ForStart":111,"ForSource":112,"ForVariables":113,"OWN":114,"ForValue":115,"FORIN":116,"FOROF":117,"BY":118,"SWITCH":119,"Whens":120,"ELSE":121,"When":122,"LEADING_WHEN":123,"IfBlock":124,"IF":125,"POST_IF":126,"UNARY":127,"-":128,"+":129,"--":130,"++":131,"?":132,"MATH":133,"SHIFT":134,"COMPARE":135,"LOGIC":136,"RELATION":137,"COMPOUND_ASSIGN":138,"$accept":0,"$end":1}, +terminals_: {2:"error",6:"TERMINATOR",11:"STATEMENT",25:"INDENT",26:"OUTDENT",28:"IDENTIFIER",30:"NUMBER",31:"STRING",33:"JS",34:"REGEX",35:"DEBUGGER",36:"UNDEFINED",37:"NULL",38:"BOOL",40:"=",43:":",45:"RETURN",46:"HERECOMMENT",47:"PARAM_START",49:"PARAM_END",51:"->",52:"=>",54:",",57:"...",66:".",67:"?.",68:"::",69:"?::",71:"INDEX_START",73:"INDEX_END",74:"INDEX_SOAK",76:"{",78:"}",79:"CLASS",80:"EXTENDS",83:"SUPER",84:"FUNC_EXIST",85:"CALL_START",86:"CALL_END",88:"THIS",89:"@",90:"[",91:"]",93:"..",96:"TRY",98:"FINALLY",99:"CATCH",100:"THROW",101:"(",102:")",104:"WHILE",105:"WHEN",106:"UNTIL",108:"LOOP",110:"FOR",114:"OWN",116:"FORIN",117:"FOROF",118:"BY",119:"SWITCH",121:"ELSE",123:"LEADING_WHEN",125:"IF",126:"POST_IF",127:"UNARY",128:"-",129:"+",130:"--",131:"++",132:"?",133:"MATH",134:"SHIFT",135:"COMPARE",136:"LOGIC",137:"RELATION",138:"COMPOUND_ASSIGN"}, +productions_: [0,[3,0],[3,1],[4,1],[4,3],[4,2],[5,1],[5,1],[8,1],[8,1],[8,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[7,1],[24,2],[24,3],[27,1],[29,1],[29,1],[32,1],[32,1],[32,1],[32,1],[32,1],[32,1],[32,1],[16,3],[16,4],[16,5],[41,1],[41,3],[41,5],[41,1],[42,1],[42,1],[42,1],[9,2],[9,1],[10,1],[14,5],[14,2],[50,1],[50,1],[53,0],[53,1],[48,0],[48,1],[48,3],[48,4],[48,6],[55,1],[55,2],[55,3],[56,1],[56,1],[56,1],[56,1],[60,2],[61,1],[61,2],[61,2],[61,1],[39,1],[39,1],[39,1],[12,1],[12,1],[12,1],[12,1],[12,1],[62,2],[62,2],[62,2],[62,2],[62,1],[62,1],[70,3],[70,2],[72,1],[72,1],[59,4],[77,0],[77,1],[77,3],[77,4],[77,6],[22,1],[22,2],[22,3],[22,4],[22,2],[22,3],[22,4],[22,5],[13,3],[13,3],[13,1],[13,2],[81,0],[81,1],[82,2],[82,4],[65,1],[65,1],[44,2],[58,2],[58,4],[92,1],[92,1],[64,5],[75,3],[75,2],[75,2],[75,1],[87,1],[87,3],[87,4],[87,4],[87,6],[94,1],[94,1],[95,1],[95,3],[18,2],[18,3],[18,4],[18,5],[97,3],[97,3],[97,2],[23,2],[63,3],[63,5],[103,2],[103,4],[103,2],[103,4],[19,2],[19,2],[19,2],[19,1],[107,2],[107,2],[20,2],[20,2],[20,2],[109,2],[109,2],[111,2],[111,3],[115,1],[115,1],[115,1],[115,1],[113,1],[113,3],[112,2],[112,2],[112,4],[112,4],[112,4],[112,6],[112,6],[21,5],[21,7],[21,4],[21,6],[120,1],[120,2],[122,3],[122,4],[124,3],[124,5],[17,1],[17,3],[17,3],[17,3],[15,2],[15,2],[15,2],[15,2],[15,2],[15,2],[15,2],[15,2],[15,3],[15,3],[15,3],[15,3],[15,3],[15,3],[15,3],[15,3],[15,5],[15,4],[15,3]], +performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate /* action[1] */, $$ /* vstack */, _$ /* lstack */) { + +var $0 = $$.length - 1; +switch (yystate) { +case 1:return this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Block); +break; +case 2:return this.$ = $$[$0]; +break; +case 3:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(yy.Block.wrap([$$[$0]])); +break; +case 4:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])($$[$0-2].push($$[$0])); +break; +case 5:this.$ = $$[$0-1]; +break; +case 6:this.$ = $$[$0]; +break; +case 7:this.$ = $$[$0]; +break; +case 8:this.$ = $$[$0]; +break; +case 9:this.$ = $$[$0]; +break; +case 10:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Literal($$[$0])); +break; +case 11:this.$ = $$[$0]; +break; +case 12:this.$ = $$[$0]; +break; +case 13:this.$ = $$[$0]; +break; +case 14:this.$ = $$[$0]; +break; +case 15:this.$ = $$[$0]; +break; +case 16:this.$ = $$[$0]; +break; +case 17:this.$ = $$[$0]; +break; +case 18:this.$ = $$[$0]; +break; +case 19:this.$ = $$[$0]; +break; +case 20:this.$ = $$[$0]; +break; +case 21:this.$ = $$[$0]; +break; +case 22:this.$ = $$[$0]; +break; +case 23:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.Block); +break; +case 24:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])($$[$0-1]); +break; +case 25:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Literal($$[$0])); +break; +case 26:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Literal($$[$0])); +break; +case 27:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Literal($$[$0])); +break; +case 28:this.$ = $$[$0]; +break; +case 29:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Literal($$[$0])); +break; +case 30:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Literal($$[$0])); +break; +case 31:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Literal($$[$0])); +break; +case 32:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Undefined); +break; +case 33:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Null); +break; +case 34:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Bool($$[$0])); +break; +case 35:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])(new yy.Assign($$[$0-2], $$[$0])); +break; +case 36:this.$ = yy.addLocationDataFn(_$[$0-3], _$[$0])(new yy.Assign($$[$0-3], $$[$0])); +break; +case 37:this.$ = yy.addLocationDataFn(_$[$0-4], _$[$0])(new yy.Assign($$[$0-4], $$[$0-1])); +break; +case 38:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Value($$[$0])); +break; +case 39:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])(new yy.Assign(yy.addLocationDataFn(_$[$0-2])(new yy.Value($$[$0-2])), $$[$0], 'object')); +break; +case 40:this.$ = yy.addLocationDataFn(_$[$0-4], _$[$0])(new yy.Assign(yy.addLocationDataFn(_$[$0-4])(new yy.Value($$[$0-4])), $$[$0-1], 'object')); +break; +case 41:this.$ = $$[$0]; +break; +case 42:this.$ = $$[$0]; +break; +case 43:this.$ = $$[$0]; +break; +case 44:this.$ = $$[$0]; +break; +case 45:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.Return($$[$0])); +break; +case 46:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Return); +break; +case 47:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Comment($$[$0])); +break; +case 48:this.$ = yy.addLocationDataFn(_$[$0-4], _$[$0])(new yy.Code($$[$0-3], $$[$0], $$[$0-1])); +break; +case 49:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.Code([], $$[$0], $$[$0-1])); +break; +case 50:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])('func'); +break; +case 51:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])('boundfunc'); +break; +case 52:this.$ = $$[$0]; +break; +case 53:this.$ = $$[$0]; +break; +case 54:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])([]); +break; +case 55:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])([$$[$0]]); +break; +case 56:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])($$[$0-2].concat($$[$0])); +break; +case 57:this.$ = yy.addLocationDataFn(_$[$0-3], _$[$0])($$[$0-3].concat($$[$0])); +break; +case 58:this.$ = yy.addLocationDataFn(_$[$0-5], _$[$0])($$[$0-5].concat($$[$0-2])); +break; +case 59:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Param($$[$0])); +break; +case 60:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.Param($$[$0-1], null, true)); +break; +case 61:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])(new yy.Param($$[$0-2], $$[$0])); +break; +case 62:this.$ = $$[$0]; +break; +case 63:this.$ = $$[$0]; +break; +case 64:this.$ = $$[$0]; +break; +case 65:this.$ = $$[$0]; +break; +case 66:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.Splat($$[$0-1])); +break; +case 67:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Value($$[$0])); +break; +case 68:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])($$[$0-1].add($$[$0])); +break; +case 69:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.Value($$[$0-1], [].concat($$[$0]))); +break; +case 70:this.$ = $$[$0]; +break; +case 71:this.$ = $$[$0]; +break; +case 72:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Value($$[$0])); +break; +case 73:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Value($$[$0])); +break; +case 74:this.$ = $$[$0]; +break; +case 75:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Value($$[$0])); +break; +case 76:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Value($$[$0])); +break; +case 77:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Value($$[$0])); +break; +case 78:this.$ = $$[$0]; +break; +case 79:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.Access($$[$0])); +break; +case 80:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.Access($$[$0], 'soak')); +break; +case 81:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])([yy.addLocationDataFn(_$[$0-1])(new yy.Access(new yy.Literal('prototype'))), yy.addLocationDataFn(_$[$0])(new yy.Access($$[$0]))]); +break; +case 82:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])([yy.addLocationDataFn(_$[$0-1])(new yy.Access(new yy.Literal('prototype'), 'soak')), yy.addLocationDataFn(_$[$0])(new yy.Access($$[$0]))]); +break; +case 83:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Access(new yy.Literal('prototype'))); +break; +case 84:this.$ = $$[$0]; +break; +case 85:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])($$[$0-1]); +break; +case 86:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(yy.extend($$[$0], { + soak: true + })); +break; +case 87:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Index($$[$0])); +break; +case 88:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Slice($$[$0])); +break; +case 89:this.$ = yy.addLocationDataFn(_$[$0-3], _$[$0])(new yy.Obj($$[$0-2], $$[$0-3].generated)); +break; +case 90:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])([]); +break; +case 91:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])([$$[$0]]); +break; +case 92:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])($$[$0-2].concat($$[$0])); +break; +case 93:this.$ = yy.addLocationDataFn(_$[$0-3], _$[$0])($$[$0-3].concat($$[$0])); +break; +case 94:this.$ = yy.addLocationDataFn(_$[$0-5], _$[$0])($$[$0-5].concat($$[$0-2])); +break; +case 95:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Class); +break; +case 96:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.Class(null, null, $$[$0])); +break; +case 97:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])(new yy.Class(null, $$[$0])); +break; +case 98:this.$ = yy.addLocationDataFn(_$[$0-3], _$[$0])(new yy.Class(null, $$[$0-1], $$[$0])); +break; +case 99:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.Class($$[$0])); +break; +case 100:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])(new yy.Class($$[$0-1], null, $$[$0])); +break; +case 101:this.$ = yy.addLocationDataFn(_$[$0-3], _$[$0])(new yy.Class($$[$0-2], $$[$0])); +break; +case 102:this.$ = yy.addLocationDataFn(_$[$0-4], _$[$0])(new yy.Class($$[$0-3], $$[$0-1], $$[$0])); +break; +case 103:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])(new yy.Call($$[$0-2], $$[$0], $$[$0-1])); +break; +case 104:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])(new yy.Call($$[$0-2], $$[$0], $$[$0-1])); +break; +case 105:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Call('super', [new yy.Splat(new yy.Literal('arguments'))])); +break; +case 106:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.Call('super', $$[$0])); +break; +case 107:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(false); +break; +case 108:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(true); +break; +case 109:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])([]); +break; +case 110:this.$ = yy.addLocationDataFn(_$[$0-3], _$[$0])($$[$0-2]); +break; +case 111:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Value(new yy.Literal('this'))); +break; +case 112:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Value(new yy.Literal('this'))); +break; +case 113:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.Value(yy.addLocationDataFn(_$[$0-1])(new yy.Literal('this')), [yy.addLocationDataFn(_$[$0])(new yy.Access($$[$0]))], 'this')); +break; +case 114:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.Arr([])); +break; +case 115:this.$ = yy.addLocationDataFn(_$[$0-3], _$[$0])(new yy.Arr($$[$0-2])); +break; +case 116:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])('inclusive'); +break; +case 117:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])('exclusive'); +break; +case 118:this.$ = yy.addLocationDataFn(_$[$0-4], _$[$0])(new yy.Range($$[$0-3], $$[$0-1], $$[$0-2])); +break; +case 119:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])(new yy.Range($$[$0-2], $$[$0], $$[$0-1])); +break; +case 120:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.Range($$[$0-1], null, $$[$0])); +break; +case 121:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.Range(null, $$[$0], $$[$0-1])); +break; +case 122:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Range(null, null, $$[$0])); +break; +case 123:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])([$$[$0]]); +break; +case 124:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])($$[$0-2].concat($$[$0])); +break; +case 125:this.$ = yy.addLocationDataFn(_$[$0-3], _$[$0])($$[$0-3].concat($$[$0])); +break; +case 126:this.$ = yy.addLocationDataFn(_$[$0-3], _$[$0])($$[$0-2]); +break; +case 127:this.$ = yy.addLocationDataFn(_$[$0-5], _$[$0])($$[$0-5].concat($$[$0-2])); +break; +case 128:this.$ = $$[$0]; +break; +case 129:this.$ = $$[$0]; +break; +case 130:this.$ = $$[$0]; +break; +case 131:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])([].concat($$[$0-2], $$[$0])); +break; +case 132:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.Try($$[$0])); +break; +case 133:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])(new yy.Try($$[$0-1], $$[$0][0], $$[$0][1])); +break; +case 134:this.$ = yy.addLocationDataFn(_$[$0-3], _$[$0])(new yy.Try($$[$0-2], null, null, $$[$0])); +break; +case 135:this.$ = yy.addLocationDataFn(_$[$0-4], _$[$0])(new yy.Try($$[$0-3], $$[$0-2][0], $$[$0-2][1], $$[$0])); +break; +case 136:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])([$$[$0-1], $$[$0]]); +break; +case 137:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])([yy.addLocationDataFn(_$[$0-1])(new yy.Value($$[$0-1])), $$[$0]]); +break; +case 138:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])([null, $$[$0]]); +break; +case 139:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.Throw($$[$0])); +break; +case 140:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])(new yy.Parens($$[$0-1])); +break; +case 141:this.$ = yy.addLocationDataFn(_$[$0-4], _$[$0])(new yy.Parens($$[$0-2])); +break; +case 142:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.While($$[$0])); +break; +case 143:this.$ = yy.addLocationDataFn(_$[$0-3], _$[$0])(new yy.While($$[$0-2], { + guard: $$[$0] + })); +break; +case 144:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.While($$[$0], { + invert: true + })); +break; +case 145:this.$ = yy.addLocationDataFn(_$[$0-3], _$[$0])(new yy.While($$[$0-2], { + invert: true, + guard: $$[$0] + })); +break; +case 146:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])($$[$0-1].addBody($$[$0])); +break; +case 147:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])($$[$0].addBody(yy.addLocationDataFn(_$[$0-1])(yy.Block.wrap([$$[$0-1]])))); +break; +case 148:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])($$[$0].addBody(yy.addLocationDataFn(_$[$0-1])(yy.Block.wrap([$$[$0-1]])))); +break; +case 149:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])($$[$0]); +break; +case 150:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.While(yy.addLocationDataFn(_$[$0-1])(new yy.Literal('true'))).addBody($$[$0])); +break; +case 151:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.While(yy.addLocationDataFn(_$[$0-1])(new yy.Literal('true'))).addBody(yy.addLocationDataFn(_$[$0])(yy.Block.wrap([$$[$0]])))); +break; +case 152:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.For($$[$0-1], $$[$0])); +break; +case 153:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.For($$[$0-1], $$[$0])); +break; +case 154:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.For($$[$0], $$[$0-1])); +break; +case 155:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])({ + source: yy.addLocationDataFn(_$[$0])(new yy.Value($$[$0])) + }); +break; +case 156:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])((function () { + $$[$0].own = $$[$0-1].own; + $$[$0].name = $$[$0-1][0]; + $$[$0].index = $$[$0-1][1]; + return $$[$0]; + }())); +break; +case 157:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])($$[$0]); +break; +case 158:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])((function () { + $$[$0].own = true; + return $$[$0]; + }())); +break; +case 159:this.$ = $$[$0]; +break; +case 160:this.$ = $$[$0]; +break; +case 161:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Value($$[$0])); +break; +case 162:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])(new yy.Value($$[$0])); +break; +case 163:this.$ = yy.addLocationDataFn(_$[$0], _$[$0])([$$[$0]]); +break; +case 164:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])([$$[$0-2], $$[$0]]); +break; +case 165:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])({ + source: $$[$0] + }); +break; +case 166:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])({ + source: $$[$0], + object: true + }); +break; +case 167:this.$ = yy.addLocationDataFn(_$[$0-3], _$[$0])({ + source: $$[$0-2], + guard: $$[$0] + }); +break; +case 168:this.$ = yy.addLocationDataFn(_$[$0-3], _$[$0])({ + source: $$[$0-2], + guard: $$[$0], + object: true + }); +break; +case 169:this.$ = yy.addLocationDataFn(_$[$0-3], _$[$0])({ + source: $$[$0-2], + step: $$[$0] + }); +break; +case 170:this.$ = yy.addLocationDataFn(_$[$0-5], _$[$0])({ + source: $$[$0-4], + guard: $$[$0-2], + step: $$[$0] + }); +break; +case 171:this.$ = yy.addLocationDataFn(_$[$0-5], _$[$0])({ + source: $$[$0-4], + step: $$[$0-2], + guard: $$[$0] + }); +break; +case 172:this.$ = yy.addLocationDataFn(_$[$0-4], _$[$0])(new yy.Switch($$[$0-3], $$[$0-1])); +break; +case 173:this.$ = yy.addLocationDataFn(_$[$0-6], _$[$0])(new yy.Switch($$[$0-5], $$[$0-3], $$[$0-1])); +break; +case 174:this.$ = yy.addLocationDataFn(_$[$0-3], _$[$0])(new yy.Switch(null, $$[$0-1])); +break; +case 175:this.$ = yy.addLocationDataFn(_$[$0-5], _$[$0])(new yy.Switch(null, $$[$0-3], $$[$0-1])); +break; +case 176:this.$ = $$[$0]; +break; +case 177:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])($$[$0-1].concat($$[$0])); +break; +case 178:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])([[$$[$0-1], $$[$0]]]); +break; +case 179:this.$ = yy.addLocationDataFn(_$[$0-3], _$[$0])([[$$[$0-2], $$[$0-1]]]); +break; +case 180:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])(new yy.If($$[$0-1], $$[$0], { + type: $$[$0-2] + })); +break; +case 181:this.$ = yy.addLocationDataFn(_$[$0-4], _$[$0])($$[$0-4].addElse(yy.addLocationDataFn(_$[$0-2], _$[$0])(new yy.If($$[$0-1], $$[$0], { + type: $$[$0-2] + })))); +break; +case 182:this.$ = $$[$0]; +break; +case 183:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])($$[$0-2].addElse($$[$0])); +break; +case 184:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])(new yy.If($$[$0], yy.addLocationDataFn(_$[$0-2])(yy.Block.wrap([$$[$0-2]])), { + type: $$[$0-1], + statement: true + })); +break; +case 185:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])(new yy.If($$[$0], yy.addLocationDataFn(_$[$0-2])(yy.Block.wrap([$$[$0-2]])), { + type: $$[$0-1], + statement: true + })); +break; +case 186:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.Op($$[$0-1], $$[$0])); +break; +case 187:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.Op('-', $$[$0])); +break; +case 188:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.Op('+', $$[$0])); +break; +case 189:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.Op('--', $$[$0])); +break; +case 190:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.Op('++', $$[$0])); +break; +case 191:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.Op('--', $$[$0-1], null, true)); +break; +case 192:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.Op('++', $$[$0-1], null, true)); +break; +case 193:this.$ = yy.addLocationDataFn(_$[$0-1], _$[$0])(new yy.Existence($$[$0-1])); +break; +case 194:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])(new yy.Op('+', $$[$0-2], $$[$0])); +break; +case 195:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])(new yy.Op('-', $$[$0-2], $$[$0])); +break; +case 196:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])(new yy.Op($$[$0-1], $$[$0-2], $$[$0])); +break; +case 197:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])(new yy.Op($$[$0-1], $$[$0-2], $$[$0])); +break; +case 198:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])(new yy.Op($$[$0-1], $$[$0-2], $$[$0])); +break; +case 199:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])(new yy.Op($$[$0-1], $$[$0-2], $$[$0])); +break; +case 200:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])((function () { + if ($$[$0-1].charAt(0) === '!') { + return new yy.Op($$[$0-1].slice(1), $$[$0-2], $$[$0]).invert(); + } else { + return new yy.Op($$[$0-1], $$[$0-2], $$[$0]); + } + }())); +break; +case 201:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])(new yy.Assign($$[$0-2], $$[$0], $$[$0-1])); +break; +case 202:this.$ = yy.addLocationDataFn(_$[$0-4], _$[$0])(new yy.Assign($$[$0-4], $$[$0-1], $$[$0-3])); +break; +case 203:this.$ = yy.addLocationDataFn(_$[$0-3], _$[$0])(new yy.Assign($$[$0-3], $$[$0], $$[$0-2])); +break; +case 204:this.$ = yy.addLocationDataFn(_$[$0-2], _$[$0])(new yy.Extends($$[$0-2], $$[$0])); +break; +} +}, +table: [{1:[2,1],3:1,4:2,5:3,7:4,8:5,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{1:[3]},{1:[2,2],6:[1,72]},{1:[2,3],6:[2,3],26:[2,3],102:[2,3]},{1:[2,6],6:[2,6],26:[2,6],102:[2,6],103:82,104:[1,63],106:[1,64],109:83,110:[1,66],111:67,126:[1,81],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[1,79],137:[1,80]},{1:[2,7],6:[2,7],26:[2,7],102:[2,7],103:85,104:[1,63],106:[1,64],109:86,110:[1,66],111:67,126:[1,84]},{1:[2,11],6:[2,11],25:[2,11],26:[2,11],49:[2,11],54:[2,11],57:[2,11],62:88,66:[1,90],67:[1,91],68:[1,92],69:[1,93],70:94,71:[1,95],73:[2,11],74:[1,96],78:[2,11],81:87,84:[1,89],85:[2,107],86:[2,11],91:[2,11],93:[2,11],102:[2,11],104:[2,11],105:[2,11],106:[2,11],110:[2,11],118:[2,11],126:[2,11],128:[2,11],129:[2,11],132:[2,11],133:[2,11],134:[2,11],135:[2,11],136:[2,11],137:[2,11]},{1:[2,12],6:[2,12],25:[2,12],26:[2,12],49:[2,12],54:[2,12],57:[2,12],62:98,66:[1,90],67:[1,91],68:[1,92],69:[1,93],70:94,71:[1,95],73:[2,12],74:[1,96],78:[2,12],81:97,84:[1,89],85:[2,107],86:[2,12],91:[2,12],93:[2,12],102:[2,12],104:[2,12],105:[2,12],106:[2,12],110:[2,12],118:[2,12],126:[2,12],128:[2,12],129:[2,12],132:[2,12],133:[2,12],134:[2,12],135:[2,12],136:[2,12],137:[2,12]},{1:[2,13],6:[2,13],25:[2,13],26:[2,13],49:[2,13],54:[2,13],57:[2,13],73:[2,13],78:[2,13],86:[2,13],91:[2,13],93:[2,13],102:[2,13],104:[2,13],105:[2,13],106:[2,13],110:[2,13],118:[2,13],126:[2,13],128:[2,13],129:[2,13],132:[2,13],133:[2,13],134:[2,13],135:[2,13],136:[2,13],137:[2,13]},{1:[2,14],6:[2,14],25:[2,14],26:[2,14],49:[2,14],54:[2,14],57:[2,14],73:[2,14],78:[2,14],86:[2,14],91:[2,14],93:[2,14],102:[2,14],104:[2,14],105:[2,14],106:[2,14],110:[2,14],118:[2,14],126:[2,14],128:[2,14],129:[2,14],132:[2,14],133:[2,14],134:[2,14],135:[2,14],136:[2,14],137:[2,14]},{1:[2,15],6:[2,15],25:[2,15],26:[2,15],49:[2,15],54:[2,15],57:[2,15],73:[2,15],78:[2,15],86:[2,15],91:[2,15],93:[2,15],102:[2,15],104:[2,15],105:[2,15],106:[2,15],110:[2,15],118:[2,15],126:[2,15],128:[2,15],129:[2,15],132:[2,15],133:[2,15],134:[2,15],135:[2,15],136:[2,15],137:[2,15]},{1:[2,16],6:[2,16],25:[2,16],26:[2,16],49:[2,16],54:[2,16],57:[2,16],73:[2,16],78:[2,16],86:[2,16],91:[2,16],93:[2,16],102:[2,16],104:[2,16],105:[2,16],106:[2,16],110:[2,16],118:[2,16],126:[2,16],128:[2,16],129:[2,16],132:[2,16],133:[2,16],134:[2,16],135:[2,16],136:[2,16],137:[2,16]},{1:[2,17],6:[2,17],25:[2,17],26:[2,17],49:[2,17],54:[2,17],57:[2,17],73:[2,17],78:[2,17],86:[2,17],91:[2,17],93:[2,17],102:[2,17],104:[2,17],105:[2,17],106:[2,17],110:[2,17],118:[2,17],126:[2,17],128:[2,17],129:[2,17],132:[2,17],133:[2,17],134:[2,17],135:[2,17],136:[2,17],137:[2,17]},{1:[2,18],6:[2,18],25:[2,18],26:[2,18],49:[2,18],54:[2,18],57:[2,18],73:[2,18],78:[2,18],86:[2,18],91:[2,18],93:[2,18],102:[2,18],104:[2,18],105:[2,18],106:[2,18],110:[2,18],118:[2,18],126:[2,18],128:[2,18],129:[2,18],132:[2,18],133:[2,18],134:[2,18],135:[2,18],136:[2,18],137:[2,18]},{1:[2,19],6:[2,19],25:[2,19],26:[2,19],49:[2,19],54:[2,19],57:[2,19],73:[2,19],78:[2,19],86:[2,19],91:[2,19],93:[2,19],102:[2,19],104:[2,19],105:[2,19],106:[2,19],110:[2,19],118:[2,19],126:[2,19],128:[2,19],129:[2,19],132:[2,19],133:[2,19],134:[2,19],135:[2,19],136:[2,19],137:[2,19]},{1:[2,20],6:[2,20],25:[2,20],26:[2,20],49:[2,20],54:[2,20],57:[2,20],73:[2,20],78:[2,20],86:[2,20],91:[2,20],93:[2,20],102:[2,20],104:[2,20],105:[2,20],106:[2,20],110:[2,20],118:[2,20],126:[2,20],128:[2,20],129:[2,20],132:[2,20],133:[2,20],134:[2,20],135:[2,20],136:[2,20],137:[2,20]},{1:[2,21],6:[2,21],25:[2,21],26:[2,21],49:[2,21],54:[2,21],57:[2,21],73:[2,21],78:[2,21],86:[2,21],91:[2,21],93:[2,21],102:[2,21],104:[2,21],105:[2,21],106:[2,21],110:[2,21],118:[2,21],126:[2,21],128:[2,21],129:[2,21],132:[2,21],133:[2,21],134:[2,21],135:[2,21],136:[2,21],137:[2,21]},{1:[2,22],6:[2,22],25:[2,22],26:[2,22],49:[2,22],54:[2,22],57:[2,22],73:[2,22],78:[2,22],86:[2,22],91:[2,22],93:[2,22],102:[2,22],104:[2,22],105:[2,22],106:[2,22],110:[2,22],118:[2,22],126:[2,22],128:[2,22],129:[2,22],132:[2,22],133:[2,22],134:[2,22],135:[2,22],136:[2,22],137:[2,22]},{1:[2,8],6:[2,8],26:[2,8],102:[2,8],104:[2,8],106:[2,8],110:[2,8],126:[2,8]},{1:[2,9],6:[2,9],26:[2,9],102:[2,9],104:[2,9],106:[2,9],110:[2,9],126:[2,9]},{1:[2,10],6:[2,10],26:[2,10],102:[2,10],104:[2,10],106:[2,10],110:[2,10],126:[2,10]},{1:[2,74],6:[2,74],25:[2,74],26:[2,74],40:[1,99],49:[2,74],54:[2,74],57:[2,74],66:[2,74],67:[2,74],68:[2,74],69:[2,74],71:[2,74],73:[2,74],74:[2,74],78:[2,74],84:[2,74],85:[2,74],86:[2,74],91:[2,74],93:[2,74],102:[2,74],104:[2,74],105:[2,74],106:[2,74],110:[2,74],118:[2,74],126:[2,74],128:[2,74],129:[2,74],132:[2,74],133:[2,74],134:[2,74],135:[2,74],136:[2,74],137:[2,74]},{1:[2,75],6:[2,75],25:[2,75],26:[2,75],49:[2,75],54:[2,75],57:[2,75],66:[2,75],67:[2,75],68:[2,75],69:[2,75],71:[2,75],73:[2,75],74:[2,75],78:[2,75],84:[2,75],85:[2,75],86:[2,75],91:[2,75],93:[2,75],102:[2,75],104:[2,75],105:[2,75],106:[2,75],110:[2,75],118:[2,75],126:[2,75],128:[2,75],129:[2,75],132:[2,75],133:[2,75],134:[2,75],135:[2,75],136:[2,75],137:[2,75]},{1:[2,76],6:[2,76],25:[2,76],26:[2,76],49:[2,76],54:[2,76],57:[2,76],66:[2,76],67:[2,76],68:[2,76],69:[2,76],71:[2,76],73:[2,76],74:[2,76],78:[2,76],84:[2,76],85:[2,76],86:[2,76],91:[2,76],93:[2,76],102:[2,76],104:[2,76],105:[2,76],106:[2,76],110:[2,76],118:[2,76],126:[2,76],128:[2,76],129:[2,76],132:[2,76],133:[2,76],134:[2,76],135:[2,76],136:[2,76],137:[2,76]},{1:[2,77],6:[2,77],25:[2,77],26:[2,77],49:[2,77],54:[2,77],57:[2,77],66:[2,77],67:[2,77],68:[2,77],69:[2,77],71:[2,77],73:[2,77],74:[2,77],78:[2,77],84:[2,77],85:[2,77],86:[2,77],91:[2,77],93:[2,77],102:[2,77],104:[2,77],105:[2,77],106:[2,77],110:[2,77],118:[2,77],126:[2,77],128:[2,77],129:[2,77],132:[2,77],133:[2,77],134:[2,77],135:[2,77],136:[2,77],137:[2,77]},{1:[2,78],6:[2,78],25:[2,78],26:[2,78],49:[2,78],54:[2,78],57:[2,78],66:[2,78],67:[2,78],68:[2,78],69:[2,78],71:[2,78],73:[2,78],74:[2,78],78:[2,78],84:[2,78],85:[2,78],86:[2,78],91:[2,78],93:[2,78],102:[2,78],104:[2,78],105:[2,78],106:[2,78],110:[2,78],118:[2,78],126:[2,78],128:[2,78],129:[2,78],132:[2,78],133:[2,78],134:[2,78],135:[2,78],136:[2,78],137:[2,78]},{1:[2,105],6:[2,105],25:[2,105],26:[2,105],49:[2,105],54:[2,105],57:[2,105],66:[2,105],67:[2,105],68:[2,105],69:[2,105],71:[2,105],73:[2,105],74:[2,105],78:[2,105],82:100,84:[2,105],85:[1,101],86:[2,105],91:[2,105],93:[2,105],102:[2,105],104:[2,105],105:[2,105],106:[2,105],110:[2,105],118:[2,105],126:[2,105],128:[2,105],129:[2,105],132:[2,105],133:[2,105],134:[2,105],135:[2,105],136:[2,105],137:[2,105]},{6:[2,54],25:[2,54],27:105,28:[1,71],44:106,48:102,49:[2,54],54:[2,54],55:103,56:104,58:107,59:108,76:[1,68],89:[1,109],90:[1,110]},{24:111,25:[1,112]},{7:113,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{7:115,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{7:116,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{12:118,13:119,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:120,44:61,58:45,59:46,61:117,63:23,64:24,65:25,76:[1,68],83:[1,26],88:[1,56],89:[1,57],90:[1,55],101:[1,54]},{12:118,13:119,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:120,44:61,58:45,59:46,61:121,63:23,64:24,65:25,76:[1,68],83:[1,26],88:[1,56],89:[1,57],90:[1,55],101:[1,54]},{1:[2,71],6:[2,71],25:[2,71],26:[2,71],40:[2,71],49:[2,71],54:[2,71],57:[2,71],66:[2,71],67:[2,71],68:[2,71],69:[2,71],71:[2,71],73:[2,71],74:[2,71],78:[2,71],80:[1,125],84:[2,71],85:[2,71],86:[2,71],91:[2,71],93:[2,71],102:[2,71],104:[2,71],105:[2,71],106:[2,71],110:[2,71],118:[2,71],126:[2,71],128:[2,71],129:[2,71],130:[1,122],131:[1,123],132:[2,71],133:[2,71],134:[2,71],135:[2,71],136:[2,71],137:[2,71],138:[1,124]},{1:[2,182],6:[2,182],25:[2,182],26:[2,182],49:[2,182],54:[2,182],57:[2,182],73:[2,182],78:[2,182],86:[2,182],91:[2,182],93:[2,182],102:[2,182],104:[2,182],105:[2,182],106:[2,182],110:[2,182],118:[2,182],121:[1,126],126:[2,182],128:[2,182],129:[2,182],132:[2,182],133:[2,182],134:[2,182],135:[2,182],136:[2,182],137:[2,182]},{24:127,25:[1,112]},{24:128,25:[1,112]},{1:[2,149],6:[2,149],25:[2,149],26:[2,149],49:[2,149],54:[2,149],57:[2,149],73:[2,149],78:[2,149],86:[2,149],91:[2,149],93:[2,149],102:[2,149],104:[2,149],105:[2,149],106:[2,149],110:[2,149],118:[2,149],126:[2,149],128:[2,149],129:[2,149],132:[2,149],133:[2,149],134:[2,149],135:[2,149],136:[2,149],137:[2,149]},{24:129,25:[1,112]},{7:130,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,25:[1,131],27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{1:[2,95],6:[2,95],12:118,13:119,24:132,25:[1,112],26:[2,95],27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:120,44:61,49:[2,95],54:[2,95],57:[2,95],58:45,59:46,61:134,63:23,64:24,65:25,73:[2,95],76:[1,68],78:[2,95],80:[1,133],83:[1,26],86:[2,95],88:[1,56],89:[1,57],90:[1,55],91:[2,95],93:[2,95],101:[1,54],102:[2,95],104:[2,95],105:[2,95],106:[2,95],110:[2,95],118:[2,95],126:[2,95],128:[2,95],129:[2,95],132:[2,95],133:[2,95],134:[2,95],135:[2,95],136:[2,95],137:[2,95]},{7:135,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{1:[2,46],6:[2,46],7:136,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,26:[2,46],27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],102:[2,46],103:37,104:[2,46],106:[2,46],107:38,108:[1,65],109:39,110:[2,46],111:67,119:[1,40],124:35,125:[1,62],126:[2,46],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{1:[2,47],6:[2,47],25:[2,47],26:[2,47],54:[2,47],78:[2,47],102:[2,47],104:[2,47],106:[2,47],110:[2,47],126:[2,47]},{1:[2,72],6:[2,72],25:[2,72],26:[2,72],40:[2,72],49:[2,72],54:[2,72],57:[2,72],66:[2,72],67:[2,72],68:[2,72],69:[2,72],71:[2,72],73:[2,72],74:[2,72],78:[2,72],84:[2,72],85:[2,72],86:[2,72],91:[2,72],93:[2,72],102:[2,72],104:[2,72],105:[2,72],106:[2,72],110:[2,72],118:[2,72],126:[2,72],128:[2,72],129:[2,72],132:[2,72],133:[2,72],134:[2,72],135:[2,72],136:[2,72],137:[2,72]},{1:[2,73],6:[2,73],25:[2,73],26:[2,73],40:[2,73],49:[2,73],54:[2,73],57:[2,73],66:[2,73],67:[2,73],68:[2,73],69:[2,73],71:[2,73],73:[2,73],74:[2,73],78:[2,73],84:[2,73],85:[2,73],86:[2,73],91:[2,73],93:[2,73],102:[2,73],104:[2,73],105:[2,73],106:[2,73],110:[2,73],118:[2,73],126:[2,73],128:[2,73],129:[2,73],132:[2,73],133:[2,73],134:[2,73],135:[2,73],136:[2,73],137:[2,73]},{1:[2,28],6:[2,28],25:[2,28],26:[2,28],49:[2,28],54:[2,28],57:[2,28],66:[2,28],67:[2,28],68:[2,28],69:[2,28],71:[2,28],73:[2,28],74:[2,28],78:[2,28],84:[2,28],85:[2,28],86:[2,28],91:[2,28],93:[2,28],102:[2,28],104:[2,28],105:[2,28],106:[2,28],110:[2,28],118:[2,28],126:[2,28],128:[2,28],129:[2,28],132:[2,28],133:[2,28],134:[2,28],135:[2,28],136:[2,28],137:[2,28]},{1:[2,29],6:[2,29],25:[2,29],26:[2,29],49:[2,29],54:[2,29],57:[2,29],66:[2,29],67:[2,29],68:[2,29],69:[2,29],71:[2,29],73:[2,29],74:[2,29],78:[2,29],84:[2,29],85:[2,29],86:[2,29],91:[2,29],93:[2,29],102:[2,29],104:[2,29],105:[2,29],106:[2,29],110:[2,29],118:[2,29],126:[2,29],128:[2,29],129:[2,29],132:[2,29],133:[2,29],134:[2,29],135:[2,29],136:[2,29],137:[2,29]},{1:[2,30],6:[2,30],25:[2,30],26:[2,30],49:[2,30],54:[2,30],57:[2,30],66:[2,30],67:[2,30],68:[2,30],69:[2,30],71:[2,30],73:[2,30],74:[2,30],78:[2,30],84:[2,30],85:[2,30],86:[2,30],91:[2,30],93:[2,30],102:[2,30],104:[2,30],105:[2,30],106:[2,30],110:[2,30],118:[2,30],126:[2,30],128:[2,30],129:[2,30],132:[2,30],133:[2,30],134:[2,30],135:[2,30],136:[2,30],137:[2,30]},{1:[2,31],6:[2,31],25:[2,31],26:[2,31],49:[2,31],54:[2,31],57:[2,31],66:[2,31],67:[2,31],68:[2,31],69:[2,31],71:[2,31],73:[2,31],74:[2,31],78:[2,31],84:[2,31],85:[2,31],86:[2,31],91:[2,31],93:[2,31],102:[2,31],104:[2,31],105:[2,31],106:[2,31],110:[2,31],118:[2,31],126:[2,31],128:[2,31],129:[2,31],132:[2,31],133:[2,31],134:[2,31],135:[2,31],136:[2,31],137:[2,31]},{1:[2,32],6:[2,32],25:[2,32],26:[2,32],49:[2,32],54:[2,32],57:[2,32],66:[2,32],67:[2,32],68:[2,32],69:[2,32],71:[2,32],73:[2,32],74:[2,32],78:[2,32],84:[2,32],85:[2,32],86:[2,32],91:[2,32],93:[2,32],102:[2,32],104:[2,32],105:[2,32],106:[2,32],110:[2,32],118:[2,32],126:[2,32],128:[2,32],129:[2,32],132:[2,32],133:[2,32],134:[2,32],135:[2,32],136:[2,32],137:[2,32]},{1:[2,33],6:[2,33],25:[2,33],26:[2,33],49:[2,33],54:[2,33],57:[2,33],66:[2,33],67:[2,33],68:[2,33],69:[2,33],71:[2,33],73:[2,33],74:[2,33],78:[2,33],84:[2,33],85:[2,33],86:[2,33],91:[2,33],93:[2,33],102:[2,33],104:[2,33],105:[2,33],106:[2,33],110:[2,33],118:[2,33],126:[2,33],128:[2,33],129:[2,33],132:[2,33],133:[2,33],134:[2,33],135:[2,33],136:[2,33],137:[2,33]},{1:[2,34],6:[2,34],25:[2,34],26:[2,34],49:[2,34],54:[2,34],57:[2,34],66:[2,34],67:[2,34],68:[2,34],69:[2,34],71:[2,34],73:[2,34],74:[2,34],78:[2,34],84:[2,34],85:[2,34],86:[2,34],91:[2,34],93:[2,34],102:[2,34],104:[2,34],105:[2,34],106:[2,34],110:[2,34],118:[2,34],126:[2,34],128:[2,34],129:[2,34],132:[2,34],133:[2,34],134:[2,34],135:[2,34],136:[2,34],137:[2,34]},{4:137,5:3,7:4,8:5,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,25:[1,138],27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{7:139,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,25:[1,143],27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,60:144,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],87:141,88:[1,56],89:[1,57],90:[1,55],91:[1,140],94:142,96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{1:[2,111],6:[2,111],25:[2,111],26:[2,111],49:[2,111],54:[2,111],57:[2,111],66:[2,111],67:[2,111],68:[2,111],69:[2,111],71:[2,111],73:[2,111],74:[2,111],78:[2,111],84:[2,111],85:[2,111],86:[2,111],91:[2,111],93:[2,111],102:[2,111],104:[2,111],105:[2,111],106:[2,111],110:[2,111],118:[2,111],126:[2,111],128:[2,111],129:[2,111],132:[2,111],133:[2,111],134:[2,111],135:[2,111],136:[2,111],137:[2,111]},{1:[2,112],6:[2,112],25:[2,112],26:[2,112],27:145,28:[1,71],49:[2,112],54:[2,112],57:[2,112],66:[2,112],67:[2,112],68:[2,112],69:[2,112],71:[2,112],73:[2,112],74:[2,112],78:[2,112],84:[2,112],85:[2,112],86:[2,112],91:[2,112],93:[2,112],102:[2,112],104:[2,112],105:[2,112],106:[2,112],110:[2,112],118:[2,112],126:[2,112],128:[2,112],129:[2,112],132:[2,112],133:[2,112],134:[2,112],135:[2,112],136:[2,112],137:[2,112]},{25:[2,50]},{25:[2,51]},{1:[2,67],6:[2,67],25:[2,67],26:[2,67],40:[2,67],49:[2,67],54:[2,67],57:[2,67],66:[2,67],67:[2,67],68:[2,67],69:[2,67],71:[2,67],73:[2,67],74:[2,67],78:[2,67],80:[2,67],84:[2,67],85:[2,67],86:[2,67],91:[2,67],93:[2,67],102:[2,67],104:[2,67],105:[2,67],106:[2,67],110:[2,67],118:[2,67],126:[2,67],128:[2,67],129:[2,67],130:[2,67],131:[2,67],132:[2,67],133:[2,67],134:[2,67],135:[2,67],136:[2,67],137:[2,67],138:[2,67]},{1:[2,70],6:[2,70],25:[2,70],26:[2,70],40:[2,70],49:[2,70],54:[2,70],57:[2,70],66:[2,70],67:[2,70],68:[2,70],69:[2,70],71:[2,70],73:[2,70],74:[2,70],78:[2,70],80:[2,70],84:[2,70],85:[2,70],86:[2,70],91:[2,70],93:[2,70],102:[2,70],104:[2,70],105:[2,70],106:[2,70],110:[2,70],118:[2,70],126:[2,70],128:[2,70],129:[2,70],130:[2,70],131:[2,70],132:[2,70],133:[2,70],134:[2,70],135:[2,70],136:[2,70],137:[2,70],138:[2,70]},{7:146,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{7:147,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{7:148,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{7:150,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,24:149,25:[1,112],27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{27:155,28:[1,71],44:156,58:157,59:158,64:151,76:[1,68],89:[1,109],90:[1,55],113:152,114:[1,153],115:154},{112:159,116:[1,160],117:[1,161]},{6:[2,90],10:165,25:[2,90],27:166,28:[1,71],29:167,30:[1,69],31:[1,70],41:163,42:164,44:168,46:[1,44],54:[2,90],77:162,78:[2,90],89:[1,109]},{1:[2,26],6:[2,26],25:[2,26],26:[2,26],43:[2,26],49:[2,26],54:[2,26],57:[2,26],66:[2,26],67:[2,26],68:[2,26],69:[2,26],71:[2,26],73:[2,26],74:[2,26],78:[2,26],84:[2,26],85:[2,26],86:[2,26],91:[2,26],93:[2,26],102:[2,26],104:[2,26],105:[2,26],106:[2,26],110:[2,26],118:[2,26],126:[2,26],128:[2,26],129:[2,26],132:[2,26],133:[2,26],134:[2,26],135:[2,26],136:[2,26],137:[2,26]},{1:[2,27],6:[2,27],25:[2,27],26:[2,27],43:[2,27],49:[2,27],54:[2,27],57:[2,27],66:[2,27],67:[2,27],68:[2,27],69:[2,27],71:[2,27],73:[2,27],74:[2,27],78:[2,27],84:[2,27],85:[2,27],86:[2,27],91:[2,27],93:[2,27],102:[2,27],104:[2,27],105:[2,27],106:[2,27],110:[2,27],118:[2,27],126:[2,27],128:[2,27],129:[2,27],132:[2,27],133:[2,27],134:[2,27],135:[2,27],136:[2,27],137:[2,27]},{1:[2,25],6:[2,25],25:[2,25],26:[2,25],40:[2,25],43:[2,25],49:[2,25],54:[2,25],57:[2,25],66:[2,25],67:[2,25],68:[2,25],69:[2,25],71:[2,25],73:[2,25],74:[2,25],78:[2,25],80:[2,25],84:[2,25],85:[2,25],86:[2,25],91:[2,25],93:[2,25],102:[2,25],104:[2,25],105:[2,25],106:[2,25],110:[2,25],116:[2,25],117:[2,25],118:[2,25],126:[2,25],128:[2,25],129:[2,25],130:[2,25],131:[2,25],132:[2,25],133:[2,25],134:[2,25],135:[2,25],136:[2,25],137:[2,25],138:[2,25]},{1:[2,5],5:169,6:[2,5],7:4,8:5,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,26:[2,5],27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],102:[2,5],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{1:[2,193],6:[2,193],25:[2,193],26:[2,193],49:[2,193],54:[2,193],57:[2,193],73:[2,193],78:[2,193],86:[2,193],91:[2,193],93:[2,193],102:[2,193],104:[2,193],105:[2,193],106:[2,193],110:[2,193],118:[2,193],126:[2,193],128:[2,193],129:[2,193],132:[2,193],133:[2,193],134:[2,193],135:[2,193],136:[2,193],137:[2,193]},{7:170,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{7:171,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{7:172,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{7:173,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{7:174,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{7:175,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{7:176,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{7:177,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{1:[2,148],6:[2,148],25:[2,148],26:[2,148],49:[2,148],54:[2,148],57:[2,148],73:[2,148],78:[2,148],86:[2,148],91:[2,148],93:[2,148],102:[2,148],104:[2,148],105:[2,148],106:[2,148],110:[2,148],118:[2,148],126:[2,148],128:[2,148],129:[2,148],132:[2,148],133:[2,148],134:[2,148],135:[2,148],136:[2,148],137:[2,148]},{1:[2,153],6:[2,153],25:[2,153],26:[2,153],49:[2,153],54:[2,153],57:[2,153],73:[2,153],78:[2,153],86:[2,153],91:[2,153],93:[2,153],102:[2,153],104:[2,153],105:[2,153],106:[2,153],110:[2,153],118:[2,153],126:[2,153],128:[2,153],129:[2,153],132:[2,153],133:[2,153],134:[2,153],135:[2,153],136:[2,153],137:[2,153]},{7:178,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{1:[2,147],6:[2,147],25:[2,147],26:[2,147],49:[2,147],54:[2,147],57:[2,147],73:[2,147],78:[2,147],86:[2,147],91:[2,147],93:[2,147],102:[2,147],104:[2,147],105:[2,147],106:[2,147],110:[2,147],118:[2,147],126:[2,147],128:[2,147],129:[2,147],132:[2,147],133:[2,147],134:[2,147],135:[2,147],136:[2,147],137:[2,147]},{1:[2,152],6:[2,152],25:[2,152],26:[2,152],49:[2,152],54:[2,152],57:[2,152],73:[2,152],78:[2,152],86:[2,152],91:[2,152],93:[2,152],102:[2,152],104:[2,152],105:[2,152],106:[2,152],110:[2,152],118:[2,152],126:[2,152],128:[2,152],129:[2,152],132:[2,152],133:[2,152],134:[2,152],135:[2,152],136:[2,152],137:[2,152]},{82:179,85:[1,101]},{1:[2,68],6:[2,68],25:[2,68],26:[2,68],40:[2,68],49:[2,68],54:[2,68],57:[2,68],66:[2,68],67:[2,68],68:[2,68],69:[2,68],71:[2,68],73:[2,68],74:[2,68],78:[2,68],80:[2,68],84:[2,68],85:[2,68],86:[2,68],91:[2,68],93:[2,68],102:[2,68],104:[2,68],105:[2,68],106:[2,68],110:[2,68],118:[2,68],126:[2,68],128:[2,68],129:[2,68],130:[2,68],131:[2,68],132:[2,68],133:[2,68],134:[2,68],135:[2,68],136:[2,68],137:[2,68],138:[2,68]},{85:[2,108]},{27:180,28:[1,71]},{27:181,28:[1,71]},{1:[2,83],6:[2,83],25:[2,83],26:[2,83],27:182,28:[1,71],40:[2,83],49:[2,83],54:[2,83],57:[2,83],66:[2,83],67:[2,83],68:[2,83],69:[2,83],71:[2,83],73:[2,83],74:[2,83],78:[2,83],80:[2,83],84:[2,83],85:[2,83],86:[2,83],91:[2,83],93:[2,83],102:[2,83],104:[2,83],105:[2,83],106:[2,83],110:[2,83],118:[2,83],126:[2,83],128:[2,83],129:[2,83],130:[2,83],131:[2,83],132:[2,83],133:[2,83],134:[2,83],135:[2,83],136:[2,83],137:[2,83],138:[2,83]},{27:183,28:[1,71]},{1:[2,84],6:[2,84],25:[2,84],26:[2,84],40:[2,84],49:[2,84],54:[2,84],57:[2,84],66:[2,84],67:[2,84],68:[2,84],69:[2,84],71:[2,84],73:[2,84],74:[2,84],78:[2,84],80:[2,84],84:[2,84],85:[2,84],86:[2,84],91:[2,84],93:[2,84],102:[2,84],104:[2,84],105:[2,84],106:[2,84],110:[2,84],118:[2,84],126:[2,84],128:[2,84],129:[2,84],130:[2,84],131:[2,84],132:[2,84],133:[2,84],134:[2,84],135:[2,84],136:[2,84],137:[2,84],138:[2,84]},{7:185,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],57:[1,189],58:45,59:46,61:34,63:23,64:24,65:25,72:184,75:186,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],92:187,93:[1,188],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{70:190,71:[1,95],74:[1,96]},{82:191,85:[1,101]},{1:[2,69],6:[2,69],25:[2,69],26:[2,69],40:[2,69],49:[2,69],54:[2,69],57:[2,69],66:[2,69],67:[2,69],68:[2,69],69:[2,69],71:[2,69],73:[2,69],74:[2,69],78:[2,69],80:[2,69],84:[2,69],85:[2,69],86:[2,69],91:[2,69],93:[2,69],102:[2,69],104:[2,69],105:[2,69],106:[2,69],110:[2,69],118:[2,69],126:[2,69],128:[2,69],129:[2,69],130:[2,69],131:[2,69],132:[2,69],133:[2,69],134:[2,69],135:[2,69],136:[2,69],137:[2,69],138:[2,69]},{6:[1,193],7:192,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,25:[1,194],27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{1:[2,106],6:[2,106],25:[2,106],26:[2,106],49:[2,106],54:[2,106],57:[2,106],66:[2,106],67:[2,106],68:[2,106],69:[2,106],71:[2,106],73:[2,106],74:[2,106],78:[2,106],84:[2,106],85:[2,106],86:[2,106],91:[2,106],93:[2,106],102:[2,106],104:[2,106],105:[2,106],106:[2,106],110:[2,106],118:[2,106],126:[2,106],128:[2,106],129:[2,106],132:[2,106],133:[2,106],134:[2,106],135:[2,106],136:[2,106],137:[2,106]},{7:197,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,25:[1,143],27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,60:144,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],86:[1,195],87:196,88:[1,56],89:[1,57],90:[1,55],94:142,96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{6:[2,52],25:[2,52],49:[1,198],53:200,54:[1,199]},{6:[2,55],25:[2,55],26:[2,55],49:[2,55],54:[2,55]},{6:[2,59],25:[2,59],26:[2,59],40:[1,202],49:[2,59],54:[2,59],57:[1,201]},{6:[2,62],25:[2,62],26:[2,62],40:[2,62],49:[2,62],54:[2,62],57:[2,62]},{6:[2,63],25:[2,63],26:[2,63],40:[2,63],49:[2,63],54:[2,63],57:[2,63]},{6:[2,64],25:[2,64],26:[2,64],40:[2,64],49:[2,64],54:[2,64],57:[2,64]},{6:[2,65],25:[2,65],26:[2,65],40:[2,65],49:[2,65],54:[2,65],57:[2,65]},{27:145,28:[1,71]},{7:197,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,25:[1,143],27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,60:144,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],87:141,88:[1,56],89:[1,57],90:[1,55],91:[1,140],94:142,96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{1:[2,49],6:[2,49],25:[2,49],26:[2,49],49:[2,49],54:[2,49],57:[2,49],73:[2,49],78:[2,49],86:[2,49],91:[2,49],93:[2,49],102:[2,49],104:[2,49],105:[2,49],106:[2,49],110:[2,49],118:[2,49],126:[2,49],128:[2,49],129:[2,49],132:[2,49],133:[2,49],134:[2,49],135:[2,49],136:[2,49],137:[2,49]},{4:204,5:3,7:4,8:5,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,26:[1,203],27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{1:[2,186],6:[2,186],25:[2,186],26:[2,186],49:[2,186],54:[2,186],57:[2,186],73:[2,186],78:[2,186],86:[2,186],91:[2,186],93:[2,186],102:[2,186],103:82,104:[2,186],105:[2,186],106:[2,186],109:83,110:[2,186],111:67,118:[2,186],126:[2,186],128:[2,186],129:[2,186],132:[1,73],133:[2,186],134:[2,186],135:[2,186],136:[2,186],137:[2,186]},{103:85,104:[1,63],106:[1,64],109:86,110:[1,66],111:67,126:[1,84]},{1:[2,187],6:[2,187],25:[2,187],26:[2,187],49:[2,187],54:[2,187],57:[2,187],73:[2,187],78:[2,187],86:[2,187],91:[2,187],93:[2,187],102:[2,187],103:82,104:[2,187],105:[2,187],106:[2,187],109:83,110:[2,187],111:67,118:[2,187],126:[2,187],128:[2,187],129:[2,187],132:[1,73],133:[2,187],134:[2,187],135:[2,187],136:[2,187],137:[2,187]},{1:[2,188],6:[2,188],25:[2,188],26:[2,188],49:[2,188],54:[2,188],57:[2,188],73:[2,188],78:[2,188],86:[2,188],91:[2,188],93:[2,188],102:[2,188],103:82,104:[2,188],105:[2,188],106:[2,188],109:83,110:[2,188],111:67,118:[2,188],126:[2,188],128:[2,188],129:[2,188],132:[1,73],133:[2,188],134:[2,188],135:[2,188],136:[2,188],137:[2,188]},{1:[2,189],6:[2,189],25:[2,189],26:[2,189],49:[2,189],54:[2,189],57:[2,189],66:[2,71],67:[2,71],68:[2,71],69:[2,71],71:[2,71],73:[2,189],74:[2,71],78:[2,189],84:[2,71],85:[2,71],86:[2,189],91:[2,189],93:[2,189],102:[2,189],104:[2,189],105:[2,189],106:[2,189],110:[2,189],118:[2,189],126:[2,189],128:[2,189],129:[2,189],132:[2,189],133:[2,189],134:[2,189],135:[2,189],136:[2,189],137:[2,189]},{62:88,66:[1,90],67:[1,91],68:[1,92],69:[1,93],70:94,71:[1,95],74:[1,96],81:87,84:[1,89],85:[2,107]},{62:98,66:[1,90],67:[1,91],68:[1,92],69:[1,93],70:94,71:[1,95],74:[1,96],81:97,84:[1,89],85:[2,107]},{66:[2,74],67:[2,74],68:[2,74],69:[2,74],71:[2,74],74:[2,74],84:[2,74],85:[2,74]},{1:[2,190],6:[2,190],25:[2,190],26:[2,190],49:[2,190],54:[2,190],57:[2,190],66:[2,71],67:[2,71],68:[2,71],69:[2,71],71:[2,71],73:[2,190],74:[2,71],78:[2,190],84:[2,71],85:[2,71],86:[2,190],91:[2,190],93:[2,190],102:[2,190],104:[2,190],105:[2,190],106:[2,190],110:[2,190],118:[2,190],126:[2,190],128:[2,190],129:[2,190],132:[2,190],133:[2,190],134:[2,190],135:[2,190],136:[2,190],137:[2,190]},{1:[2,191],6:[2,191],25:[2,191],26:[2,191],49:[2,191],54:[2,191],57:[2,191],73:[2,191],78:[2,191],86:[2,191],91:[2,191],93:[2,191],102:[2,191],104:[2,191],105:[2,191],106:[2,191],110:[2,191],118:[2,191],126:[2,191],128:[2,191],129:[2,191],132:[2,191],133:[2,191],134:[2,191],135:[2,191],136:[2,191],137:[2,191]},{1:[2,192],6:[2,192],25:[2,192],26:[2,192],49:[2,192],54:[2,192],57:[2,192],73:[2,192],78:[2,192],86:[2,192],91:[2,192],93:[2,192],102:[2,192],104:[2,192],105:[2,192],106:[2,192],110:[2,192],118:[2,192],126:[2,192],128:[2,192],129:[2,192],132:[2,192],133:[2,192],134:[2,192],135:[2,192],136:[2,192],137:[2,192]},{6:[1,207],7:205,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,25:[1,206],27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{7:208,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{24:209,25:[1,112],125:[1,210]},{1:[2,132],6:[2,132],25:[2,132],26:[2,132],49:[2,132],54:[2,132],57:[2,132],73:[2,132],78:[2,132],86:[2,132],91:[2,132],93:[2,132],97:211,98:[1,212],99:[1,213],102:[2,132],104:[2,132],105:[2,132],106:[2,132],110:[2,132],118:[2,132],126:[2,132],128:[2,132],129:[2,132],132:[2,132],133:[2,132],134:[2,132],135:[2,132],136:[2,132],137:[2,132]},{1:[2,146],6:[2,146],25:[2,146],26:[2,146],49:[2,146],54:[2,146],57:[2,146],73:[2,146],78:[2,146],86:[2,146],91:[2,146],93:[2,146],102:[2,146],104:[2,146],105:[2,146],106:[2,146],110:[2,146],118:[2,146],126:[2,146],128:[2,146],129:[2,146],132:[2,146],133:[2,146],134:[2,146],135:[2,146],136:[2,146],137:[2,146]},{1:[2,154],6:[2,154],25:[2,154],26:[2,154],49:[2,154],54:[2,154],57:[2,154],73:[2,154],78:[2,154],86:[2,154],91:[2,154],93:[2,154],102:[2,154],104:[2,154],105:[2,154],106:[2,154],110:[2,154],118:[2,154],126:[2,154],128:[2,154],129:[2,154],132:[2,154],133:[2,154],134:[2,154],135:[2,154],136:[2,154],137:[2,154]},{25:[1,214],103:82,104:[1,63],106:[1,64],109:83,110:[1,66],111:67,126:[1,81],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[1,79],137:[1,80]},{120:215,122:216,123:[1,217]},{1:[2,96],6:[2,96],25:[2,96],26:[2,96],49:[2,96],54:[2,96],57:[2,96],73:[2,96],78:[2,96],86:[2,96],91:[2,96],93:[2,96],102:[2,96],104:[2,96],105:[2,96],106:[2,96],110:[2,96],118:[2,96],126:[2,96],128:[2,96],129:[2,96],132:[2,96],133:[2,96],134:[2,96],135:[2,96],136:[2,96],137:[2,96]},{7:218,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{1:[2,99],6:[2,99],24:219,25:[1,112],26:[2,99],49:[2,99],54:[2,99],57:[2,99],66:[2,71],67:[2,71],68:[2,71],69:[2,71],71:[2,71],73:[2,99],74:[2,71],78:[2,99],80:[1,220],84:[2,71],85:[2,71],86:[2,99],91:[2,99],93:[2,99],102:[2,99],104:[2,99],105:[2,99],106:[2,99],110:[2,99],118:[2,99],126:[2,99],128:[2,99],129:[2,99],132:[2,99],133:[2,99],134:[2,99],135:[2,99],136:[2,99],137:[2,99]},{1:[2,139],6:[2,139],25:[2,139],26:[2,139],49:[2,139],54:[2,139],57:[2,139],73:[2,139],78:[2,139],86:[2,139],91:[2,139],93:[2,139],102:[2,139],103:82,104:[2,139],105:[2,139],106:[2,139],109:83,110:[2,139],111:67,118:[2,139],126:[2,139],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[1,79],137:[1,80]},{1:[2,45],6:[2,45],26:[2,45],102:[2,45],103:82,104:[2,45],106:[2,45],109:83,110:[2,45],111:67,126:[2,45],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[1,79],137:[1,80]},{6:[1,72],102:[1,221]},{4:222,5:3,7:4,8:5,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{6:[2,128],25:[2,128],54:[2,128],57:[1,224],91:[2,128],92:223,93:[1,188],103:82,104:[1,63],106:[1,64],109:83,110:[1,66],111:67,126:[1,81],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[1,79],137:[1,80]},{1:[2,114],6:[2,114],25:[2,114],26:[2,114],40:[2,114],49:[2,114],54:[2,114],57:[2,114],66:[2,114],67:[2,114],68:[2,114],69:[2,114],71:[2,114],73:[2,114],74:[2,114],78:[2,114],84:[2,114],85:[2,114],86:[2,114],91:[2,114],93:[2,114],102:[2,114],104:[2,114],105:[2,114],106:[2,114],110:[2,114],116:[2,114],117:[2,114],118:[2,114],126:[2,114],128:[2,114],129:[2,114],132:[2,114],133:[2,114],134:[2,114],135:[2,114],136:[2,114],137:[2,114]},{6:[2,52],25:[2,52],53:225,54:[1,226],91:[2,52]},{6:[2,123],25:[2,123],26:[2,123],54:[2,123],86:[2,123],91:[2,123]},{7:197,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,25:[1,143],27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,60:144,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],87:227,88:[1,56],89:[1,57],90:[1,55],94:142,96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{6:[2,129],25:[2,129],26:[2,129],54:[2,129],86:[2,129],91:[2,129]},{1:[2,113],6:[2,113],25:[2,113],26:[2,113],40:[2,113],43:[2,113],49:[2,113],54:[2,113],57:[2,113],66:[2,113],67:[2,113],68:[2,113],69:[2,113],71:[2,113],73:[2,113],74:[2,113],78:[2,113],80:[2,113],84:[2,113],85:[2,113],86:[2,113],91:[2,113],93:[2,113],102:[2,113],104:[2,113],105:[2,113],106:[2,113],110:[2,113],116:[2,113],117:[2,113],118:[2,113],126:[2,113],128:[2,113],129:[2,113],130:[2,113],131:[2,113],132:[2,113],133:[2,113],134:[2,113],135:[2,113],136:[2,113],137:[2,113],138:[2,113]},{24:228,25:[1,112],103:82,104:[1,63],106:[1,64],109:83,110:[1,66],111:67,126:[1,81],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[1,79],137:[1,80]},{1:[2,142],6:[2,142],25:[2,142],26:[2,142],49:[2,142],54:[2,142],57:[2,142],73:[2,142],78:[2,142],86:[2,142],91:[2,142],93:[2,142],102:[2,142],103:82,104:[1,63],105:[1,229],106:[1,64],109:83,110:[1,66],111:67,118:[2,142],126:[2,142],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[1,79],137:[1,80]},{1:[2,144],6:[2,144],25:[2,144],26:[2,144],49:[2,144],54:[2,144],57:[2,144],73:[2,144],78:[2,144],86:[2,144],91:[2,144],93:[2,144],102:[2,144],103:82,104:[1,63],105:[1,230],106:[1,64],109:83,110:[1,66],111:67,118:[2,144],126:[2,144],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[1,79],137:[1,80]},{1:[2,150],6:[2,150],25:[2,150],26:[2,150],49:[2,150],54:[2,150],57:[2,150],73:[2,150],78:[2,150],86:[2,150],91:[2,150],93:[2,150],102:[2,150],104:[2,150],105:[2,150],106:[2,150],110:[2,150],118:[2,150],126:[2,150],128:[2,150],129:[2,150],132:[2,150],133:[2,150],134:[2,150],135:[2,150],136:[2,150],137:[2,150]},{1:[2,151],6:[2,151],25:[2,151],26:[2,151],49:[2,151],54:[2,151],57:[2,151],73:[2,151],78:[2,151],86:[2,151],91:[2,151],93:[2,151],102:[2,151],103:82,104:[1,63],105:[2,151],106:[1,64],109:83,110:[1,66],111:67,118:[2,151],126:[2,151],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[1,79],137:[1,80]},{1:[2,155],6:[2,155],25:[2,155],26:[2,155],49:[2,155],54:[2,155],57:[2,155],73:[2,155],78:[2,155],86:[2,155],91:[2,155],93:[2,155],102:[2,155],104:[2,155],105:[2,155],106:[2,155],110:[2,155],118:[2,155],126:[2,155],128:[2,155],129:[2,155],132:[2,155],133:[2,155],134:[2,155],135:[2,155],136:[2,155],137:[2,155]},{116:[2,157],117:[2,157]},{27:155,28:[1,71],44:156,58:157,59:158,76:[1,68],89:[1,109],90:[1,110],113:231,115:154},{54:[1,232],116:[2,163],117:[2,163]},{54:[2,159],116:[2,159],117:[2,159]},{54:[2,160],116:[2,160],117:[2,160]},{54:[2,161],116:[2,161],117:[2,161]},{54:[2,162],116:[2,162],117:[2,162]},{1:[2,156],6:[2,156],25:[2,156],26:[2,156],49:[2,156],54:[2,156],57:[2,156],73:[2,156],78:[2,156],86:[2,156],91:[2,156],93:[2,156],102:[2,156],104:[2,156],105:[2,156],106:[2,156],110:[2,156],118:[2,156],126:[2,156],128:[2,156],129:[2,156],132:[2,156],133:[2,156],134:[2,156],135:[2,156],136:[2,156],137:[2,156]},{7:233,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{7:234,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{6:[2,52],25:[2,52],53:235,54:[1,236],78:[2,52]},{6:[2,91],25:[2,91],26:[2,91],54:[2,91],78:[2,91]},{6:[2,38],25:[2,38],26:[2,38],43:[1,237],54:[2,38],78:[2,38]},{6:[2,41],25:[2,41],26:[2,41],54:[2,41],78:[2,41]},{6:[2,42],25:[2,42],26:[2,42],43:[2,42],54:[2,42],78:[2,42]},{6:[2,43],25:[2,43],26:[2,43],43:[2,43],54:[2,43],78:[2,43]},{6:[2,44],25:[2,44],26:[2,44],43:[2,44],54:[2,44],78:[2,44]},{1:[2,4],6:[2,4],26:[2,4],102:[2,4]},{1:[2,194],6:[2,194],25:[2,194],26:[2,194],49:[2,194],54:[2,194],57:[2,194],73:[2,194],78:[2,194],86:[2,194],91:[2,194],93:[2,194],102:[2,194],103:82,104:[2,194],105:[2,194],106:[2,194],109:83,110:[2,194],111:67,118:[2,194],126:[2,194],128:[2,194],129:[2,194],132:[1,73],133:[1,76],134:[2,194],135:[2,194],136:[2,194],137:[2,194]},{1:[2,195],6:[2,195],25:[2,195],26:[2,195],49:[2,195],54:[2,195],57:[2,195],73:[2,195],78:[2,195],86:[2,195],91:[2,195],93:[2,195],102:[2,195],103:82,104:[2,195],105:[2,195],106:[2,195],109:83,110:[2,195],111:67,118:[2,195],126:[2,195],128:[2,195],129:[2,195],132:[1,73],133:[1,76],134:[2,195],135:[2,195],136:[2,195],137:[2,195]},{1:[2,196],6:[2,196],25:[2,196],26:[2,196],49:[2,196],54:[2,196],57:[2,196],73:[2,196],78:[2,196],86:[2,196],91:[2,196],93:[2,196],102:[2,196],103:82,104:[2,196],105:[2,196],106:[2,196],109:83,110:[2,196],111:67,118:[2,196],126:[2,196],128:[2,196],129:[2,196],132:[1,73],133:[2,196],134:[2,196],135:[2,196],136:[2,196],137:[2,196]},{1:[2,197],6:[2,197],25:[2,197],26:[2,197],49:[2,197],54:[2,197],57:[2,197],73:[2,197],78:[2,197],86:[2,197],91:[2,197],93:[2,197],102:[2,197],103:82,104:[2,197],105:[2,197],106:[2,197],109:83,110:[2,197],111:67,118:[2,197],126:[2,197],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[2,197],135:[2,197],136:[2,197],137:[2,197]},{1:[2,198],6:[2,198],25:[2,198],26:[2,198],49:[2,198],54:[2,198],57:[2,198],73:[2,198],78:[2,198],86:[2,198],91:[2,198],93:[2,198],102:[2,198],103:82,104:[2,198],105:[2,198],106:[2,198],109:83,110:[2,198],111:67,118:[2,198],126:[2,198],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[2,198],136:[2,198],137:[1,80]},{1:[2,199],6:[2,199],25:[2,199],26:[2,199],49:[2,199],54:[2,199],57:[2,199],73:[2,199],78:[2,199],86:[2,199],91:[2,199],93:[2,199],102:[2,199],103:82,104:[2,199],105:[2,199],106:[2,199],109:83,110:[2,199],111:67,118:[2,199],126:[2,199],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[2,199],137:[1,80]},{1:[2,200],6:[2,200],25:[2,200],26:[2,200],49:[2,200],54:[2,200],57:[2,200],73:[2,200],78:[2,200],86:[2,200],91:[2,200],93:[2,200],102:[2,200],103:82,104:[2,200],105:[2,200],106:[2,200],109:83,110:[2,200],111:67,118:[2,200],126:[2,200],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[2,200],136:[2,200],137:[2,200]},{1:[2,185],6:[2,185],25:[2,185],26:[2,185],49:[2,185],54:[2,185],57:[2,185],73:[2,185],78:[2,185],86:[2,185],91:[2,185],93:[2,185],102:[2,185],103:82,104:[1,63],105:[2,185],106:[1,64],109:83,110:[1,66],111:67,118:[2,185],126:[1,81],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[1,79],137:[1,80]},{1:[2,184],6:[2,184],25:[2,184],26:[2,184],49:[2,184],54:[2,184],57:[2,184],73:[2,184],78:[2,184],86:[2,184],91:[2,184],93:[2,184],102:[2,184],103:82,104:[1,63],105:[2,184],106:[1,64],109:83,110:[1,66],111:67,118:[2,184],126:[1,81],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[1,79],137:[1,80]},{1:[2,103],6:[2,103],25:[2,103],26:[2,103],49:[2,103],54:[2,103],57:[2,103],66:[2,103],67:[2,103],68:[2,103],69:[2,103],71:[2,103],73:[2,103],74:[2,103],78:[2,103],84:[2,103],85:[2,103],86:[2,103],91:[2,103],93:[2,103],102:[2,103],104:[2,103],105:[2,103],106:[2,103],110:[2,103],118:[2,103],126:[2,103],128:[2,103],129:[2,103],132:[2,103],133:[2,103],134:[2,103],135:[2,103],136:[2,103],137:[2,103]},{1:[2,79],6:[2,79],25:[2,79],26:[2,79],40:[2,79],49:[2,79],54:[2,79],57:[2,79],66:[2,79],67:[2,79],68:[2,79],69:[2,79],71:[2,79],73:[2,79],74:[2,79],78:[2,79],80:[2,79],84:[2,79],85:[2,79],86:[2,79],91:[2,79],93:[2,79],102:[2,79],104:[2,79],105:[2,79],106:[2,79],110:[2,79],118:[2,79],126:[2,79],128:[2,79],129:[2,79],130:[2,79],131:[2,79],132:[2,79],133:[2,79],134:[2,79],135:[2,79],136:[2,79],137:[2,79],138:[2,79]},{1:[2,80],6:[2,80],25:[2,80],26:[2,80],40:[2,80],49:[2,80],54:[2,80],57:[2,80],66:[2,80],67:[2,80],68:[2,80],69:[2,80],71:[2,80],73:[2,80],74:[2,80],78:[2,80],80:[2,80],84:[2,80],85:[2,80],86:[2,80],91:[2,80],93:[2,80],102:[2,80],104:[2,80],105:[2,80],106:[2,80],110:[2,80],118:[2,80],126:[2,80],128:[2,80],129:[2,80],130:[2,80],131:[2,80],132:[2,80],133:[2,80],134:[2,80],135:[2,80],136:[2,80],137:[2,80],138:[2,80]},{1:[2,81],6:[2,81],25:[2,81],26:[2,81],40:[2,81],49:[2,81],54:[2,81],57:[2,81],66:[2,81],67:[2,81],68:[2,81],69:[2,81],71:[2,81],73:[2,81],74:[2,81],78:[2,81],80:[2,81],84:[2,81],85:[2,81],86:[2,81],91:[2,81],93:[2,81],102:[2,81],104:[2,81],105:[2,81],106:[2,81],110:[2,81],118:[2,81],126:[2,81],128:[2,81],129:[2,81],130:[2,81],131:[2,81],132:[2,81],133:[2,81],134:[2,81],135:[2,81],136:[2,81],137:[2,81],138:[2,81]},{1:[2,82],6:[2,82],25:[2,82],26:[2,82],40:[2,82],49:[2,82],54:[2,82],57:[2,82],66:[2,82],67:[2,82],68:[2,82],69:[2,82],71:[2,82],73:[2,82],74:[2,82],78:[2,82],80:[2,82],84:[2,82],85:[2,82],86:[2,82],91:[2,82],93:[2,82],102:[2,82],104:[2,82],105:[2,82],106:[2,82],110:[2,82],118:[2,82],126:[2,82],128:[2,82],129:[2,82],130:[2,82],131:[2,82],132:[2,82],133:[2,82],134:[2,82],135:[2,82],136:[2,82],137:[2,82],138:[2,82]},{73:[1,238]},{57:[1,189],73:[2,87],92:239,93:[1,188],103:82,104:[1,63],106:[1,64],109:83,110:[1,66],111:67,126:[1,81],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[1,79],137:[1,80]},{73:[2,88]},{7:240,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,73:[2,122],76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{11:[2,116],28:[2,116],30:[2,116],31:[2,116],33:[2,116],34:[2,116],35:[2,116],36:[2,116],37:[2,116],38:[2,116],45:[2,116],46:[2,116],47:[2,116],51:[2,116],52:[2,116],73:[2,116],76:[2,116],79:[2,116],83:[2,116],88:[2,116],89:[2,116],90:[2,116],96:[2,116],100:[2,116],101:[2,116],104:[2,116],106:[2,116],108:[2,116],110:[2,116],119:[2,116],125:[2,116],127:[2,116],128:[2,116],129:[2,116],130:[2,116],131:[2,116]},{11:[2,117],28:[2,117],30:[2,117],31:[2,117],33:[2,117],34:[2,117],35:[2,117],36:[2,117],37:[2,117],38:[2,117],45:[2,117],46:[2,117],47:[2,117],51:[2,117],52:[2,117],73:[2,117],76:[2,117],79:[2,117],83:[2,117],88:[2,117],89:[2,117],90:[2,117],96:[2,117],100:[2,117],101:[2,117],104:[2,117],106:[2,117],108:[2,117],110:[2,117],119:[2,117],125:[2,117],127:[2,117],128:[2,117],129:[2,117],130:[2,117],131:[2,117]},{1:[2,86],6:[2,86],25:[2,86],26:[2,86],40:[2,86],49:[2,86],54:[2,86],57:[2,86],66:[2,86],67:[2,86],68:[2,86],69:[2,86],71:[2,86],73:[2,86],74:[2,86],78:[2,86],80:[2,86],84:[2,86],85:[2,86],86:[2,86],91:[2,86],93:[2,86],102:[2,86],104:[2,86],105:[2,86],106:[2,86],110:[2,86],118:[2,86],126:[2,86],128:[2,86],129:[2,86],130:[2,86],131:[2,86],132:[2,86],133:[2,86],134:[2,86],135:[2,86],136:[2,86],137:[2,86],138:[2,86]},{1:[2,104],6:[2,104],25:[2,104],26:[2,104],49:[2,104],54:[2,104],57:[2,104],66:[2,104],67:[2,104],68:[2,104],69:[2,104],71:[2,104],73:[2,104],74:[2,104],78:[2,104],84:[2,104],85:[2,104],86:[2,104],91:[2,104],93:[2,104],102:[2,104],104:[2,104],105:[2,104],106:[2,104],110:[2,104],118:[2,104],126:[2,104],128:[2,104],129:[2,104],132:[2,104],133:[2,104],134:[2,104],135:[2,104],136:[2,104],137:[2,104]},{1:[2,35],6:[2,35],25:[2,35],26:[2,35],49:[2,35],54:[2,35],57:[2,35],73:[2,35],78:[2,35],86:[2,35],91:[2,35],93:[2,35],102:[2,35],103:82,104:[2,35],105:[2,35],106:[2,35],109:83,110:[2,35],111:67,118:[2,35],126:[2,35],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[1,79],137:[1,80]},{7:241,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{7:242,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{1:[2,109],6:[2,109],25:[2,109],26:[2,109],49:[2,109],54:[2,109],57:[2,109],66:[2,109],67:[2,109],68:[2,109],69:[2,109],71:[2,109],73:[2,109],74:[2,109],78:[2,109],84:[2,109],85:[2,109],86:[2,109],91:[2,109],93:[2,109],102:[2,109],104:[2,109],105:[2,109],106:[2,109],110:[2,109],118:[2,109],126:[2,109],128:[2,109],129:[2,109],132:[2,109],133:[2,109],134:[2,109],135:[2,109],136:[2,109],137:[2,109]},{6:[2,52],25:[2,52],53:243,54:[1,226],86:[2,52]},{6:[2,128],25:[2,128],26:[2,128],54:[2,128],57:[1,244],86:[2,128],91:[2,128],103:82,104:[1,63],106:[1,64],109:83,110:[1,66],111:67,126:[1,81],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[1,79],137:[1,80]},{50:245,51:[1,58],52:[1,59]},{6:[2,53],25:[2,53],26:[2,53],27:105,28:[1,71],44:106,55:246,56:104,58:107,59:108,76:[1,68],89:[1,109],90:[1,110]},{6:[1,247],25:[1,248]},{6:[2,60],25:[2,60],26:[2,60],49:[2,60],54:[2,60]},{7:249,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{1:[2,23],6:[2,23],25:[2,23],26:[2,23],49:[2,23],54:[2,23],57:[2,23],73:[2,23],78:[2,23],86:[2,23],91:[2,23],93:[2,23],98:[2,23],99:[2,23],102:[2,23],104:[2,23],105:[2,23],106:[2,23],110:[2,23],118:[2,23],121:[2,23],123:[2,23],126:[2,23],128:[2,23],129:[2,23],132:[2,23],133:[2,23],134:[2,23],135:[2,23],136:[2,23],137:[2,23]},{6:[1,72],26:[1,250]},{1:[2,201],6:[2,201],25:[2,201],26:[2,201],49:[2,201],54:[2,201],57:[2,201],73:[2,201],78:[2,201],86:[2,201],91:[2,201],93:[2,201],102:[2,201],103:82,104:[2,201],105:[2,201],106:[2,201],109:83,110:[2,201],111:67,118:[2,201],126:[2,201],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[1,79],137:[1,80]},{7:251,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{7:252,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{1:[2,204],6:[2,204],25:[2,204],26:[2,204],49:[2,204],54:[2,204],57:[2,204],73:[2,204],78:[2,204],86:[2,204],91:[2,204],93:[2,204],102:[2,204],103:82,104:[2,204],105:[2,204],106:[2,204],109:83,110:[2,204],111:67,118:[2,204],126:[2,204],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[1,79],137:[1,80]},{1:[2,183],6:[2,183],25:[2,183],26:[2,183],49:[2,183],54:[2,183],57:[2,183],73:[2,183],78:[2,183],86:[2,183],91:[2,183],93:[2,183],102:[2,183],104:[2,183],105:[2,183],106:[2,183],110:[2,183],118:[2,183],126:[2,183],128:[2,183],129:[2,183],132:[2,183],133:[2,183],134:[2,183],135:[2,183],136:[2,183],137:[2,183]},{7:253,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{1:[2,133],6:[2,133],25:[2,133],26:[2,133],49:[2,133],54:[2,133],57:[2,133],73:[2,133],78:[2,133],86:[2,133],91:[2,133],93:[2,133],98:[1,254],102:[2,133],104:[2,133],105:[2,133],106:[2,133],110:[2,133],118:[2,133],126:[2,133],128:[2,133],129:[2,133],132:[2,133],133:[2,133],134:[2,133],135:[2,133],136:[2,133],137:[2,133]},{24:255,25:[1,112]},{24:258,25:[1,112],27:256,28:[1,71],59:257,76:[1,68]},{120:259,122:216,123:[1,217]},{26:[1,260],121:[1,261],122:262,123:[1,217]},{26:[2,176],121:[2,176],123:[2,176]},{7:264,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],95:263,96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{1:[2,97],6:[2,97],24:265,25:[1,112],26:[2,97],49:[2,97],54:[2,97],57:[2,97],73:[2,97],78:[2,97],86:[2,97],91:[2,97],93:[2,97],102:[2,97],103:82,104:[1,63],105:[2,97],106:[1,64],109:83,110:[1,66],111:67,118:[2,97],126:[2,97],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[1,79],137:[1,80]},{1:[2,100],6:[2,100],25:[2,100],26:[2,100],49:[2,100],54:[2,100],57:[2,100],73:[2,100],78:[2,100],86:[2,100],91:[2,100],93:[2,100],102:[2,100],104:[2,100],105:[2,100],106:[2,100],110:[2,100],118:[2,100],126:[2,100],128:[2,100],129:[2,100],132:[2,100],133:[2,100],134:[2,100],135:[2,100],136:[2,100],137:[2,100]},{7:266,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{1:[2,140],6:[2,140],25:[2,140],26:[2,140],49:[2,140],54:[2,140],57:[2,140],66:[2,140],67:[2,140],68:[2,140],69:[2,140],71:[2,140],73:[2,140],74:[2,140],78:[2,140],84:[2,140],85:[2,140],86:[2,140],91:[2,140],93:[2,140],102:[2,140],104:[2,140],105:[2,140],106:[2,140],110:[2,140],118:[2,140],126:[2,140],128:[2,140],129:[2,140],132:[2,140],133:[2,140],134:[2,140],135:[2,140],136:[2,140],137:[2,140]},{6:[1,72],26:[1,267]},{7:268,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{6:[2,66],11:[2,117],25:[2,66],28:[2,117],30:[2,117],31:[2,117],33:[2,117],34:[2,117],35:[2,117],36:[2,117],37:[2,117],38:[2,117],45:[2,117],46:[2,117],47:[2,117],51:[2,117],52:[2,117],54:[2,66],76:[2,117],79:[2,117],83:[2,117],88:[2,117],89:[2,117],90:[2,117],91:[2,66],96:[2,117],100:[2,117],101:[2,117],104:[2,117],106:[2,117],108:[2,117],110:[2,117],119:[2,117],125:[2,117],127:[2,117],128:[2,117],129:[2,117],130:[2,117],131:[2,117]},{6:[1,270],25:[1,271],91:[1,269]},{6:[2,53],7:197,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,25:[2,53],26:[2,53],27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,60:144,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],86:[2,53],88:[1,56],89:[1,57],90:[1,55],91:[2,53],94:272,96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{6:[2,52],25:[2,52],26:[2,52],53:273,54:[1,226]},{1:[2,180],6:[2,180],25:[2,180],26:[2,180],49:[2,180],54:[2,180],57:[2,180],73:[2,180],78:[2,180],86:[2,180],91:[2,180],93:[2,180],102:[2,180],104:[2,180],105:[2,180],106:[2,180],110:[2,180],118:[2,180],121:[2,180],126:[2,180],128:[2,180],129:[2,180],132:[2,180],133:[2,180],134:[2,180],135:[2,180],136:[2,180],137:[2,180]},{7:274,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{7:275,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{116:[2,158],117:[2,158]},{27:155,28:[1,71],44:156,58:157,59:158,76:[1,68],89:[1,109],90:[1,110],115:276},{1:[2,165],6:[2,165],25:[2,165],26:[2,165],49:[2,165],54:[2,165],57:[2,165],73:[2,165],78:[2,165],86:[2,165],91:[2,165],93:[2,165],102:[2,165],103:82,104:[2,165],105:[1,277],106:[2,165],109:83,110:[2,165],111:67,118:[1,278],126:[2,165],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[1,79],137:[1,80]},{1:[2,166],6:[2,166],25:[2,166],26:[2,166],49:[2,166],54:[2,166],57:[2,166],73:[2,166],78:[2,166],86:[2,166],91:[2,166],93:[2,166],102:[2,166],103:82,104:[2,166],105:[1,279],106:[2,166],109:83,110:[2,166],111:67,118:[2,166],126:[2,166],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[1,79],137:[1,80]},{6:[1,281],25:[1,282],78:[1,280]},{6:[2,53],10:165,25:[2,53],26:[2,53],27:166,28:[1,71],29:167,30:[1,69],31:[1,70],41:283,42:164,44:168,46:[1,44],78:[2,53],89:[1,109]},{7:284,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,25:[1,285],27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{1:[2,85],6:[2,85],25:[2,85],26:[2,85],40:[2,85],49:[2,85],54:[2,85],57:[2,85],66:[2,85],67:[2,85],68:[2,85],69:[2,85],71:[2,85],73:[2,85],74:[2,85],78:[2,85],80:[2,85],84:[2,85],85:[2,85],86:[2,85],91:[2,85],93:[2,85],102:[2,85],104:[2,85],105:[2,85],106:[2,85],110:[2,85],118:[2,85],126:[2,85],128:[2,85],129:[2,85],130:[2,85],131:[2,85],132:[2,85],133:[2,85],134:[2,85],135:[2,85],136:[2,85],137:[2,85],138:[2,85]},{7:286,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,73:[2,120],76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{73:[2,121],103:82,104:[1,63],106:[1,64],109:83,110:[1,66],111:67,126:[1,81],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[1,79],137:[1,80]},{1:[2,36],6:[2,36],25:[2,36],26:[2,36],49:[2,36],54:[2,36],57:[2,36],73:[2,36],78:[2,36],86:[2,36],91:[2,36],93:[2,36],102:[2,36],103:82,104:[2,36],105:[2,36],106:[2,36],109:83,110:[2,36],111:67,118:[2,36],126:[2,36],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[1,79],137:[1,80]},{26:[1,287],103:82,104:[1,63],106:[1,64],109:83,110:[1,66],111:67,126:[1,81],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[1,79],137:[1,80]},{6:[1,270],25:[1,271],86:[1,288]},{6:[2,66],25:[2,66],26:[2,66],54:[2,66],86:[2,66],91:[2,66]},{24:289,25:[1,112]},{6:[2,56],25:[2,56],26:[2,56],49:[2,56],54:[2,56]},{27:105,28:[1,71],44:106,55:290,56:104,58:107,59:108,76:[1,68],89:[1,109],90:[1,110]},{6:[2,54],25:[2,54],26:[2,54],27:105,28:[1,71],44:106,48:291,54:[2,54],55:103,56:104,58:107,59:108,76:[1,68],89:[1,109],90:[1,110]},{6:[2,61],25:[2,61],26:[2,61],49:[2,61],54:[2,61],103:82,104:[1,63],106:[1,64],109:83,110:[1,66],111:67,126:[1,81],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[1,79],137:[1,80]},{1:[2,24],6:[2,24],25:[2,24],26:[2,24],49:[2,24],54:[2,24],57:[2,24],73:[2,24],78:[2,24],86:[2,24],91:[2,24],93:[2,24],98:[2,24],99:[2,24],102:[2,24],104:[2,24],105:[2,24],106:[2,24],110:[2,24],118:[2,24],121:[2,24],123:[2,24],126:[2,24],128:[2,24],129:[2,24],132:[2,24],133:[2,24],134:[2,24],135:[2,24],136:[2,24],137:[2,24]},{26:[1,292],103:82,104:[1,63],106:[1,64],109:83,110:[1,66],111:67,126:[1,81],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[1,79],137:[1,80]},{1:[2,203],6:[2,203],25:[2,203],26:[2,203],49:[2,203],54:[2,203],57:[2,203],73:[2,203],78:[2,203],86:[2,203],91:[2,203],93:[2,203],102:[2,203],103:82,104:[2,203],105:[2,203],106:[2,203],109:83,110:[2,203],111:67,118:[2,203],126:[2,203],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[1,79],137:[1,80]},{24:293,25:[1,112],103:82,104:[1,63],106:[1,64],109:83,110:[1,66],111:67,126:[1,81],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[1,79],137:[1,80]},{24:294,25:[1,112]},{1:[2,134],6:[2,134],25:[2,134],26:[2,134],49:[2,134],54:[2,134],57:[2,134],73:[2,134],78:[2,134],86:[2,134],91:[2,134],93:[2,134],102:[2,134],104:[2,134],105:[2,134],106:[2,134],110:[2,134],118:[2,134],126:[2,134],128:[2,134],129:[2,134],132:[2,134],133:[2,134],134:[2,134],135:[2,134],136:[2,134],137:[2,134]},{24:295,25:[1,112]},{24:296,25:[1,112]},{1:[2,138],6:[2,138],25:[2,138],26:[2,138],49:[2,138],54:[2,138],57:[2,138],73:[2,138],78:[2,138],86:[2,138],91:[2,138],93:[2,138],98:[2,138],102:[2,138],104:[2,138],105:[2,138],106:[2,138],110:[2,138],118:[2,138],126:[2,138],128:[2,138],129:[2,138],132:[2,138],133:[2,138],134:[2,138],135:[2,138],136:[2,138],137:[2,138]},{26:[1,297],121:[1,298],122:262,123:[1,217]},{1:[2,174],6:[2,174],25:[2,174],26:[2,174],49:[2,174],54:[2,174],57:[2,174],73:[2,174],78:[2,174],86:[2,174],91:[2,174],93:[2,174],102:[2,174],104:[2,174],105:[2,174],106:[2,174],110:[2,174],118:[2,174],126:[2,174],128:[2,174],129:[2,174],132:[2,174],133:[2,174],134:[2,174],135:[2,174],136:[2,174],137:[2,174]},{24:299,25:[1,112]},{26:[2,177],121:[2,177],123:[2,177]},{24:300,25:[1,112],54:[1,301]},{25:[2,130],54:[2,130],103:82,104:[1,63],106:[1,64],109:83,110:[1,66],111:67,126:[1,81],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[1,79],137:[1,80]},{1:[2,98],6:[2,98],25:[2,98],26:[2,98],49:[2,98],54:[2,98],57:[2,98],73:[2,98],78:[2,98],86:[2,98],91:[2,98],93:[2,98],102:[2,98],104:[2,98],105:[2,98],106:[2,98],110:[2,98],118:[2,98],126:[2,98],128:[2,98],129:[2,98],132:[2,98],133:[2,98],134:[2,98],135:[2,98],136:[2,98],137:[2,98]},{1:[2,101],6:[2,101],24:302,25:[1,112],26:[2,101],49:[2,101],54:[2,101],57:[2,101],73:[2,101],78:[2,101],86:[2,101],91:[2,101],93:[2,101],102:[2,101],103:82,104:[1,63],105:[2,101],106:[1,64],109:83,110:[1,66],111:67,118:[2,101],126:[2,101],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[1,79],137:[1,80]},{102:[1,303]},{91:[1,304],103:82,104:[1,63],106:[1,64],109:83,110:[1,66],111:67,126:[1,81],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[1,79],137:[1,80]},{1:[2,115],6:[2,115],25:[2,115],26:[2,115],40:[2,115],49:[2,115],54:[2,115],57:[2,115],66:[2,115],67:[2,115],68:[2,115],69:[2,115],71:[2,115],73:[2,115],74:[2,115],78:[2,115],84:[2,115],85:[2,115],86:[2,115],91:[2,115],93:[2,115],102:[2,115],104:[2,115],105:[2,115],106:[2,115],110:[2,115],116:[2,115],117:[2,115],118:[2,115],126:[2,115],128:[2,115],129:[2,115],132:[2,115],133:[2,115],134:[2,115],135:[2,115],136:[2,115],137:[2,115]},{7:197,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,60:144,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],94:305,96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{7:197,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,25:[1,143],27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,60:144,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],87:306,88:[1,56],89:[1,57],90:[1,55],94:142,96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{6:[2,124],25:[2,124],26:[2,124],54:[2,124],86:[2,124],91:[2,124]},{6:[1,270],25:[1,271],26:[1,307]},{1:[2,143],6:[2,143],25:[2,143],26:[2,143],49:[2,143],54:[2,143],57:[2,143],73:[2,143],78:[2,143],86:[2,143],91:[2,143],93:[2,143],102:[2,143],103:82,104:[1,63],105:[2,143],106:[1,64],109:83,110:[1,66],111:67,118:[2,143],126:[2,143],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[1,79],137:[1,80]},{1:[2,145],6:[2,145],25:[2,145],26:[2,145],49:[2,145],54:[2,145],57:[2,145],73:[2,145],78:[2,145],86:[2,145],91:[2,145],93:[2,145],102:[2,145],103:82,104:[1,63],105:[2,145],106:[1,64],109:83,110:[1,66],111:67,118:[2,145],126:[2,145],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[1,79],137:[1,80]},{116:[2,164],117:[2,164]},{7:308,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{7:309,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{7:310,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{1:[2,89],6:[2,89],25:[2,89],26:[2,89],40:[2,89],49:[2,89],54:[2,89],57:[2,89],66:[2,89],67:[2,89],68:[2,89],69:[2,89],71:[2,89],73:[2,89],74:[2,89],78:[2,89],84:[2,89],85:[2,89],86:[2,89],91:[2,89],93:[2,89],102:[2,89],104:[2,89],105:[2,89],106:[2,89],110:[2,89],116:[2,89],117:[2,89],118:[2,89],126:[2,89],128:[2,89],129:[2,89],132:[2,89],133:[2,89],134:[2,89],135:[2,89],136:[2,89],137:[2,89]},{10:165,27:166,28:[1,71],29:167,30:[1,69],31:[1,70],41:311,42:164,44:168,46:[1,44],89:[1,109]},{6:[2,90],10:165,25:[2,90],26:[2,90],27:166,28:[1,71],29:167,30:[1,69],31:[1,70],41:163,42:164,44:168,46:[1,44],54:[2,90],77:312,89:[1,109]},{6:[2,92],25:[2,92],26:[2,92],54:[2,92],78:[2,92]},{6:[2,39],25:[2,39],26:[2,39],54:[2,39],78:[2,39],103:82,104:[1,63],106:[1,64],109:83,110:[1,66],111:67,126:[1,81],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[1,79],137:[1,80]},{7:313,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{73:[2,119],103:82,104:[1,63],106:[1,64],109:83,110:[1,66],111:67,126:[1,81],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[1,79],137:[1,80]},{1:[2,37],6:[2,37],25:[2,37],26:[2,37],49:[2,37],54:[2,37],57:[2,37],73:[2,37],78:[2,37],86:[2,37],91:[2,37],93:[2,37],102:[2,37],104:[2,37],105:[2,37],106:[2,37],110:[2,37],118:[2,37],126:[2,37],128:[2,37],129:[2,37],132:[2,37],133:[2,37],134:[2,37],135:[2,37],136:[2,37],137:[2,37]},{1:[2,110],6:[2,110],25:[2,110],26:[2,110],49:[2,110],54:[2,110],57:[2,110],66:[2,110],67:[2,110],68:[2,110],69:[2,110],71:[2,110],73:[2,110],74:[2,110],78:[2,110],84:[2,110],85:[2,110],86:[2,110],91:[2,110],93:[2,110],102:[2,110],104:[2,110],105:[2,110],106:[2,110],110:[2,110],118:[2,110],126:[2,110],128:[2,110],129:[2,110],132:[2,110],133:[2,110],134:[2,110],135:[2,110],136:[2,110],137:[2,110]},{1:[2,48],6:[2,48],25:[2,48],26:[2,48],49:[2,48],54:[2,48],57:[2,48],73:[2,48],78:[2,48],86:[2,48],91:[2,48],93:[2,48],102:[2,48],104:[2,48],105:[2,48],106:[2,48],110:[2,48],118:[2,48],126:[2,48],128:[2,48],129:[2,48],132:[2,48],133:[2,48],134:[2,48],135:[2,48],136:[2,48],137:[2,48]},{6:[2,57],25:[2,57],26:[2,57],49:[2,57],54:[2,57]},{6:[2,52],25:[2,52],26:[2,52],53:314,54:[1,199]},{1:[2,202],6:[2,202],25:[2,202],26:[2,202],49:[2,202],54:[2,202],57:[2,202],73:[2,202],78:[2,202],86:[2,202],91:[2,202],93:[2,202],102:[2,202],104:[2,202],105:[2,202],106:[2,202],110:[2,202],118:[2,202],126:[2,202],128:[2,202],129:[2,202],132:[2,202],133:[2,202],134:[2,202],135:[2,202],136:[2,202],137:[2,202]},{1:[2,181],6:[2,181],25:[2,181],26:[2,181],49:[2,181],54:[2,181],57:[2,181],73:[2,181],78:[2,181],86:[2,181],91:[2,181],93:[2,181],102:[2,181],104:[2,181],105:[2,181],106:[2,181],110:[2,181],118:[2,181],121:[2,181],126:[2,181],128:[2,181],129:[2,181],132:[2,181],133:[2,181],134:[2,181],135:[2,181],136:[2,181],137:[2,181]},{1:[2,135],6:[2,135],25:[2,135],26:[2,135],49:[2,135],54:[2,135],57:[2,135],73:[2,135],78:[2,135],86:[2,135],91:[2,135],93:[2,135],102:[2,135],104:[2,135],105:[2,135],106:[2,135],110:[2,135],118:[2,135],126:[2,135],128:[2,135],129:[2,135],132:[2,135],133:[2,135],134:[2,135],135:[2,135],136:[2,135],137:[2,135]},{1:[2,136],6:[2,136],25:[2,136],26:[2,136],49:[2,136],54:[2,136],57:[2,136],73:[2,136],78:[2,136],86:[2,136],91:[2,136],93:[2,136],98:[2,136],102:[2,136],104:[2,136],105:[2,136],106:[2,136],110:[2,136],118:[2,136],126:[2,136],128:[2,136],129:[2,136],132:[2,136],133:[2,136],134:[2,136],135:[2,136],136:[2,136],137:[2,136]},{1:[2,137],6:[2,137],25:[2,137],26:[2,137],49:[2,137],54:[2,137],57:[2,137],73:[2,137],78:[2,137],86:[2,137],91:[2,137],93:[2,137],98:[2,137],102:[2,137],104:[2,137],105:[2,137],106:[2,137],110:[2,137],118:[2,137],126:[2,137],128:[2,137],129:[2,137],132:[2,137],133:[2,137],134:[2,137],135:[2,137],136:[2,137],137:[2,137]},{1:[2,172],6:[2,172],25:[2,172],26:[2,172],49:[2,172],54:[2,172],57:[2,172],73:[2,172],78:[2,172],86:[2,172],91:[2,172],93:[2,172],102:[2,172],104:[2,172],105:[2,172],106:[2,172],110:[2,172],118:[2,172],126:[2,172],128:[2,172],129:[2,172],132:[2,172],133:[2,172],134:[2,172],135:[2,172],136:[2,172],137:[2,172]},{24:315,25:[1,112]},{26:[1,316]},{6:[1,317],26:[2,178],121:[2,178],123:[2,178]},{7:318,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{1:[2,102],6:[2,102],25:[2,102],26:[2,102],49:[2,102],54:[2,102],57:[2,102],73:[2,102],78:[2,102],86:[2,102],91:[2,102],93:[2,102],102:[2,102],104:[2,102],105:[2,102],106:[2,102],110:[2,102],118:[2,102],126:[2,102],128:[2,102],129:[2,102],132:[2,102],133:[2,102],134:[2,102],135:[2,102],136:[2,102],137:[2,102]},{1:[2,141],6:[2,141],25:[2,141],26:[2,141],49:[2,141],54:[2,141],57:[2,141],66:[2,141],67:[2,141],68:[2,141],69:[2,141],71:[2,141],73:[2,141],74:[2,141],78:[2,141],84:[2,141],85:[2,141],86:[2,141],91:[2,141],93:[2,141],102:[2,141],104:[2,141],105:[2,141],106:[2,141],110:[2,141],118:[2,141],126:[2,141],128:[2,141],129:[2,141],132:[2,141],133:[2,141],134:[2,141],135:[2,141],136:[2,141],137:[2,141]},{1:[2,118],6:[2,118],25:[2,118],26:[2,118],49:[2,118],54:[2,118],57:[2,118],66:[2,118],67:[2,118],68:[2,118],69:[2,118],71:[2,118],73:[2,118],74:[2,118],78:[2,118],84:[2,118],85:[2,118],86:[2,118],91:[2,118],93:[2,118],102:[2,118],104:[2,118],105:[2,118],106:[2,118],110:[2,118],118:[2,118],126:[2,118],128:[2,118],129:[2,118],132:[2,118],133:[2,118],134:[2,118],135:[2,118],136:[2,118],137:[2,118]},{6:[2,125],25:[2,125],26:[2,125],54:[2,125],86:[2,125],91:[2,125]},{6:[2,52],25:[2,52],26:[2,52],53:319,54:[1,226]},{6:[2,126],25:[2,126],26:[2,126],54:[2,126],86:[2,126],91:[2,126]},{1:[2,167],6:[2,167],25:[2,167],26:[2,167],49:[2,167],54:[2,167],57:[2,167],73:[2,167],78:[2,167],86:[2,167],91:[2,167],93:[2,167],102:[2,167],103:82,104:[2,167],105:[2,167],106:[2,167],109:83,110:[2,167],111:67,118:[1,320],126:[2,167],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[1,79],137:[1,80]},{1:[2,169],6:[2,169],25:[2,169],26:[2,169],49:[2,169],54:[2,169],57:[2,169],73:[2,169],78:[2,169],86:[2,169],91:[2,169],93:[2,169],102:[2,169],103:82,104:[2,169],105:[1,321],106:[2,169],109:83,110:[2,169],111:67,118:[2,169],126:[2,169],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[1,79],137:[1,80]},{1:[2,168],6:[2,168],25:[2,168],26:[2,168],49:[2,168],54:[2,168],57:[2,168],73:[2,168],78:[2,168],86:[2,168],91:[2,168],93:[2,168],102:[2,168],103:82,104:[2,168],105:[2,168],106:[2,168],109:83,110:[2,168],111:67,118:[2,168],126:[2,168],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[1,79],137:[1,80]},{6:[2,93],25:[2,93],26:[2,93],54:[2,93],78:[2,93]},{6:[2,52],25:[2,52],26:[2,52],53:322,54:[1,236]},{26:[1,323],103:82,104:[1,63],106:[1,64],109:83,110:[1,66],111:67,126:[1,81],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[1,79],137:[1,80]},{6:[1,247],25:[1,248],26:[1,324]},{26:[1,325]},{1:[2,175],6:[2,175],25:[2,175],26:[2,175],49:[2,175],54:[2,175],57:[2,175],73:[2,175],78:[2,175],86:[2,175],91:[2,175],93:[2,175],102:[2,175],104:[2,175],105:[2,175],106:[2,175],110:[2,175],118:[2,175],126:[2,175],128:[2,175],129:[2,175],132:[2,175],133:[2,175],134:[2,175],135:[2,175],136:[2,175],137:[2,175]},{26:[2,179],121:[2,179],123:[2,179]},{25:[2,131],54:[2,131],103:82,104:[1,63],106:[1,64],109:83,110:[1,66],111:67,126:[1,81],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[1,79],137:[1,80]},{6:[1,270],25:[1,271],26:[1,326]},{7:327,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{7:328,8:114,9:18,10:19,11:[1,20],12:6,13:7,14:8,15:9,16:10,17:11,18:12,19:13,20:14,21:15,22:16,23:17,27:60,28:[1,71],29:47,30:[1,69],31:[1,70],32:22,33:[1,48],34:[1,49],35:[1,50],36:[1,51],37:[1,52],38:[1,53],39:21,44:61,45:[1,43],46:[1,44],47:[1,27],50:28,51:[1,58],52:[1,59],58:45,59:46,61:34,63:23,64:24,65:25,76:[1,68],79:[1,41],83:[1,26],88:[1,56],89:[1,57],90:[1,55],96:[1,36],100:[1,42],101:[1,54],103:37,104:[1,63],106:[1,64],107:38,108:[1,65],109:39,110:[1,66],111:67,119:[1,40],124:35,125:[1,62],127:[1,29],128:[1,30],129:[1,31],130:[1,32],131:[1,33]},{6:[1,281],25:[1,282],26:[1,329]},{6:[2,40],25:[2,40],26:[2,40],54:[2,40],78:[2,40]},{6:[2,58],25:[2,58],26:[2,58],49:[2,58],54:[2,58]},{1:[2,173],6:[2,173],25:[2,173],26:[2,173],49:[2,173],54:[2,173],57:[2,173],73:[2,173],78:[2,173],86:[2,173],91:[2,173],93:[2,173],102:[2,173],104:[2,173],105:[2,173],106:[2,173],110:[2,173],118:[2,173],126:[2,173],128:[2,173],129:[2,173],132:[2,173],133:[2,173],134:[2,173],135:[2,173],136:[2,173],137:[2,173]},{6:[2,127],25:[2,127],26:[2,127],54:[2,127],86:[2,127],91:[2,127]},{1:[2,170],6:[2,170],25:[2,170],26:[2,170],49:[2,170],54:[2,170],57:[2,170],73:[2,170],78:[2,170],86:[2,170],91:[2,170],93:[2,170],102:[2,170],103:82,104:[2,170],105:[2,170],106:[2,170],109:83,110:[2,170],111:67,118:[2,170],126:[2,170],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[1,79],137:[1,80]},{1:[2,171],6:[2,171],25:[2,171],26:[2,171],49:[2,171],54:[2,171],57:[2,171],73:[2,171],78:[2,171],86:[2,171],91:[2,171],93:[2,171],102:[2,171],103:82,104:[2,171],105:[2,171],106:[2,171],109:83,110:[2,171],111:67,118:[2,171],126:[2,171],128:[1,75],129:[1,74],132:[1,73],133:[1,76],134:[1,77],135:[1,78],136:[1,79],137:[1,80]},{6:[2,94],25:[2,94],26:[2,94],54:[2,94],78:[2,94]}], +defaultActions: {58:[2,50],59:[2,51],89:[2,108],186:[2,88]}, +parseError: function parseError(str, hash) { + if (hash.recoverable) { + this.trace(str); + } else { + var e = new Error(str) + e.location = hash.loc + throw e; + } +}, +parse: function parse(input) { + var self = this, stack = [0], vstack = [null], lstack = [], table = this.table, yytext = '', yylineno = 0, yyleng = 0, recovering = 0, TERROR = 2, EOF = 1; + this.lexer.setInput(input); + this.lexer.yy = this.yy; + this.yy.lexer = this.lexer; + this.yy.parser = this; + if (typeof this.lexer.yylloc == 'undefined') { + this.lexer.yylloc = {}; + } + var yyloc = this.lexer.yylloc; + lstack.push(yyloc); + var ranges = this.lexer.options && this.lexer.options.ranges; + if (typeof this.yy.parseError === 'function') { + this.parseError = this.yy.parseError; + } else { + this.parseError = Object.getPrototypeOf(this).parseError; + } + function popStack(n) { + stack.length = stack.length - 2 * n; + vstack.length = vstack.length - n; + lstack.length = lstack.length - n; + } + function lex() { + var token; + token = self.lexer.lex() || EOF; + if (typeof token !== 'number') { + token = self.symbols_[token] || token; + } + return token; + } + var symbol, preErrorSymbol, state, action, a, r, yyval = {}, p, len, newState, expected; + while (true) { + state = stack[stack.length - 1]; + if (this.defaultActions[state]) { + action = this.defaultActions[state]; + } else { + if (symbol === null || typeof symbol == 'undefined') { + symbol = lex(); + } + action = table[state] && table[state][symbol]; + } + if (typeof action === 'undefined' || !action.length || !action[0]) { + var errStr = ''; + expected = []; + for (p in table[state]) { + if (this.terminals_[p] && p > TERROR) { + expected.push('\'' + this.terminals_[p] + '\''); + } + } + if (this.lexer.showPosition) { + errStr = 'Expecting ' + expected.join(', ') + ', got \'' + (this.terminals_[symbol] || symbol) + '\''; + } else { + errStr = 'Unexpected ' + (symbol == EOF ? 'end of input' : '\'' + (this.terminals_[symbol] || symbol) + '\''); + } + if (this.lexer.yylloc.first_line !== yyloc.first_line) yyloc = this.lexer.yylloc; + this.parseError(errStr, { + text: this.lexer.match, + token: this.terminals_[symbol] || symbol, + line: this.lexer.yylineno, + loc: yyloc, + expected: expected + }); + } + if (action[0] instanceof Array && action.length > 1) { + throw new Error('Parse Error: multiple actions possible at state: ' + state + ', token: ' + symbol); + } + switch (action[0]) { + case 1: + stack.push(symbol); + vstack.push(this.lexer.yytext); + lstack.push(this.lexer.yylloc); + stack.push(action[1]); + symbol = null; + if (!preErrorSymbol) { + yyleng = this.lexer.yyleng; + yytext = this.lexer.yytext; + yylineno = this.lexer.yylineno; + yyloc = this.lexer.yylloc; + if (recovering > 0) { + recovering--; + } + } else { + symbol = preErrorSymbol; + preErrorSymbol = null; + } + break; + case 2: + len = this.productions_[action[1]][1]; + yyval.$ = vstack[vstack.length - len]; + yyval._$ = { + first_line: lstack[lstack.length - (len || 1)].first_line, + last_line: lstack[lstack.length - 1].last_line, + first_column: lstack[lstack.length - (len || 1)].first_column, + last_column: lstack[lstack.length - 1].last_column + }; + if (ranges) { + yyval._$.range = [ + lstack[lstack.length - (len || 1)].range[0], + lstack[lstack.length - 1].range[1] + ]; + } + r = this.performAction.call(yyval, yytext, yyleng, yylineno, this.yy, action[1], vstack, lstack); + if (typeof r !== 'undefined') { + return r; + } + if (len) { + stack = stack.slice(0, -1 * len * 2); + vstack = vstack.slice(0, -1 * len); + lstack = lstack.slice(0, -1 * len); + } + stack.push(this.productions_[action[1]][0]); + vstack.push(yyval.$); + lstack.push(yyval._$); + newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; + stack.push(newState); + break; + case 3: + return true; + } + } + return true; +}}; +undefined +function Parser () { + this.yy = {}; +} +Parser.prototype = parser;parser.Parser = Parser; + +module.exports = new Parser; + + +}); + +ace.define('ace/mode/coffee/nodes', ['require', 'exports', 'module' , 'ace/mode/coffee/scope', 'ace/mode/coffee/lexer', 'ace/mode/coffee/helpers'], function(require, exports, module) { + + var Access, Arr, Assign, Base, Block, Call, Class, Closure, Code, CodeFragment, Comment, Existence, Extends, For, IDENTIFIER, IDENTIFIER_STR, IS_STRING, If, In, Index, LEVEL_ACCESS, LEVEL_COND, LEVEL_LIST, LEVEL_OP, LEVEL_PAREN, LEVEL_TOP, Literal, METHOD_DEF, NEGATE, NO, Obj, Op, Param, Parens, RESERVED, Range, Return, SIMPLENUM, STRICT_PROSCRIBED, Scope, Slice, Splat, Switch, TAB, THIS, Throw, Try, UTILITIES, Value, While, YES, addLocationDataFn, compact, del, ends, extend, flatten, fragmentsToText, last, locationDataToString, merge, multident, some, starts, throwSyntaxError, unfoldSoak, utility, _ref, _ref1, _ref2, _ref3, + __hasProp = {}.hasOwnProperty, + __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, + __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }, + __slice = [].slice; + + Error.stackTraceLimit = Infinity; + + Scope = require('./scope').Scope; + + _ref = require('./lexer'), RESERVED = _ref.RESERVED, STRICT_PROSCRIBED = _ref.STRICT_PROSCRIBED; + + _ref1 = require('./helpers'), compact = _ref1.compact, flatten = _ref1.flatten, extend = _ref1.extend, merge = _ref1.merge, del = _ref1.del, starts = _ref1.starts, ends = _ref1.ends, last = _ref1.last, some = _ref1.some, addLocationDataFn = _ref1.addLocationDataFn, locationDataToString = _ref1.locationDataToString, throwSyntaxError = _ref1.throwSyntaxError; + + exports.extend = extend; + + exports.addLocationDataFn = addLocationDataFn; + + YES = function() { + return true; + }; + + NO = function() { + return false; + }; + + THIS = function() { + return this; + }; + + NEGATE = function() { + this.negated = !this.negated; + return this; + }; + + exports.CodeFragment = CodeFragment = (function() { + function CodeFragment(parent, code) { + var _ref2; + this.code = "" + code; + this.locationData = parent != null ? parent.locationData : void 0; + this.type = (parent != null ? (_ref2 = parent.constructor) != null ? _ref2.name : void 0 : void 0) || 'unknown'; + } + + CodeFragment.prototype.toString = function() { + return "" + this.code + (this.locationData ? ": " + locationDataToString(this.locationData) : ''); + }; + + return CodeFragment; + + })(); + + fragmentsToText = function(fragments) { + var fragment; + return ((function() { + var _i, _len, _results; + _results = []; + for (_i = 0, _len = fragments.length; _i < _len; _i++) { + fragment = fragments[_i]; + _results.push(fragment.code); + } + return _results; + })()).join(''); + }; + + exports.Base = Base = (function() { + function Base() {} + + Base.prototype.compile = function(o, lvl) { + return fragmentsToText(this.compileToFragments(o, lvl)); + }; + + Base.prototype.compileToFragments = function(o, lvl) { + var node; + o = extend({}, o); + if (lvl) { + o.level = lvl; + } + node = this.unfoldSoak(o) || this; + node.tab = o.indent; + if (o.level === LEVEL_TOP || !node.isStatement(o)) { + return node.compileNode(o); + } else { + return node.compileClosure(o); + } + }; + + Base.prototype.compileClosure = function(o) { + var jumpNode; + if (jumpNode = this.jumps()) { + jumpNode.error('cannot use a pure statement in an expression'); + } + o.sharedScope = true; + return Closure.wrap(this).compileNode(o); + }; + + Base.prototype.cache = function(o, level, reused) { + var ref, sub; + if (!this.isComplex()) { + ref = level ? this.compileToFragments(o, level) : this; + return [ref, ref]; + } else { + ref = new Literal(reused || o.scope.freeVariable('ref')); + sub = new Assign(ref, this); + if (level) { + return [sub.compileToFragments(o, level), [this.makeCode(ref.value)]]; + } else { + return [sub, ref]; + } + } + }; + + Base.prototype.cacheToCodeFragments = function(cacheValues) { + return [fragmentsToText(cacheValues[0]), fragmentsToText(cacheValues[1])]; + }; + + Base.prototype.makeReturn = function(res) { + var me; + me = this.unwrapAll(); + if (res) { + return new Call(new Literal("" + res + ".push"), [me]); + } else { + return new Return(me); + } + }; + + Base.prototype.contains = function(pred) { + var node; + node = void 0; + this.traverseChildren(false, function(n) { + if (pred(n)) { + node = n; + return false; + } + }); + return node; + }; + + Base.prototype.lastNonComment = function(list) { + var i; + i = list.length; + while (i--) { + if (!(list[i] instanceof Comment)) { + return list[i]; + } + } + return null; + }; + + Base.prototype.toString = function(idt, name) { + var tree; + if (idt == null) { + idt = ''; + } + if (name == null) { + name = this.constructor.name; + } + tree = '\n' + idt + name; + if (this.soak) { + tree += '?'; + } + this.eachChild(function(node) { + return tree += node.toString(idt + TAB); + }); + return tree; + }; + + Base.prototype.eachChild = function(func) { + var attr, child, _i, _j, _len, _len1, _ref2, _ref3; + if (!this.children) { + return this; + } + _ref2 = this.children; + for (_i = 0, _len = _ref2.length; _i < _len; _i++) { + attr = _ref2[_i]; + if (this[attr]) { + _ref3 = flatten([this[attr]]); + for (_j = 0, _len1 = _ref3.length; _j < _len1; _j++) { + child = _ref3[_j]; + if (func(child) === false) { + return this; + } + } + } + } + return this; + }; + + Base.prototype.traverseChildren = function(crossScope, func) { + return this.eachChild(function(child) { + var recur; + recur = func(child); + if (recur !== false) { + return child.traverseChildren(crossScope, func); + } + }); + }; + + Base.prototype.invert = function() { + return new Op('!', this); + }; + + Base.prototype.unwrapAll = function() { + var node; + node = this; + while (node !== (node = node.unwrap())) { + continue; + } + return node; + }; + + Base.prototype.children = []; + + Base.prototype.isStatement = NO; + + Base.prototype.jumps = NO; + + Base.prototype.isComplex = YES; + + Base.prototype.isChainable = NO; + + Base.prototype.isAssignable = NO; + + Base.prototype.unwrap = THIS; + + Base.prototype.unfoldSoak = NO; + + Base.prototype.assigns = NO; + + Base.prototype.updateLocationDataIfMissing = function(locationData) { + if (this.locationData) { + return this; + } + this.locationData = locationData; + return this.eachChild(function(child) { + return child.updateLocationDataIfMissing(locationData); + }); + }; + + Base.prototype.error = function(message) { + return throwSyntaxError(message, this.locationData); + }; + + Base.prototype.makeCode = function(code) { + return new CodeFragment(this, code); + }; + + Base.prototype.wrapInBraces = function(fragments) { + return [].concat(this.makeCode('('), fragments, this.makeCode(')')); + }; + + Base.prototype.joinFragmentArrays = function(fragmentsList, joinStr) { + var answer, fragments, i, _i, _len; + answer = []; + for (i = _i = 0, _len = fragmentsList.length; _i < _len; i = ++_i) { + fragments = fragmentsList[i]; + if (i) { + answer.push(this.makeCode(joinStr)); + } + answer = answer.concat(fragments); + } + return answer; + }; + + return Base; + + })(); + + exports.Block = Block = (function(_super) { + __extends(Block, _super); + + function Block(nodes) { + this.expressions = compact(flatten(nodes || [])); + } + + Block.prototype.children = ['expressions']; + + Block.prototype.push = function(node) { + this.expressions.push(node); + return this; + }; + + Block.prototype.pop = function() { + return this.expressions.pop(); + }; + + Block.prototype.unshift = function(node) { + this.expressions.unshift(node); + return this; + }; + + Block.prototype.unwrap = function() { + if (this.expressions.length === 1) { + return this.expressions[0]; + } else { + return this; + } + }; + + Block.prototype.isEmpty = function() { + return !this.expressions.length; + }; + + Block.prototype.isStatement = function(o) { + var exp, _i, _len, _ref2; + _ref2 = this.expressions; + for (_i = 0, _len = _ref2.length; _i < _len; _i++) { + exp = _ref2[_i]; + if (exp.isStatement(o)) { + return true; + } + } + return false; + }; + + Block.prototype.jumps = function(o) { + var exp, _i, _len, _ref2; + _ref2 = this.expressions; + for (_i = 0, _len = _ref2.length; _i < _len; _i++) { + exp = _ref2[_i]; + if (exp.jumps(o)) { + return exp; + } + } + }; + + Block.prototype.makeReturn = function(res) { + var expr, len; + len = this.expressions.length; + while (len--) { + expr = this.expressions[len]; + if (!(expr instanceof Comment)) { + this.expressions[len] = expr.makeReturn(res); + if (expr instanceof Return && !expr.expression) { + this.expressions.splice(len, 1); + } + break; + } + } + return this; + }; + + Block.prototype.compileToFragments = function(o, level) { + if (o == null) { + o = {}; + } + if (o.scope) { + return Block.__super__.compileToFragments.call(this, o, level); + } else { + return this.compileRoot(o); + } + }; + + Block.prototype.compileNode = function(o) { + var answer, compiledNodes, fragments, index, node, top, _i, _len, _ref2; + this.tab = o.indent; + top = o.level === LEVEL_TOP; + compiledNodes = []; + _ref2 = this.expressions; + for (index = _i = 0, _len = _ref2.length; _i < _len; index = ++_i) { + node = _ref2[index]; + node = node.unwrapAll(); + node = node.unfoldSoak(o) || node; + if (node instanceof Block) { + compiledNodes.push(node.compileNode(o)); + } else if (top) { + node.front = true; + fragments = node.compileToFragments(o); + if (!node.isStatement(o)) { + fragments.unshift(this.makeCode("" + this.tab)); + fragments.push(this.makeCode(";")); + } + compiledNodes.push(fragments); + } else { + compiledNodes.push(node.compileToFragments(o, LEVEL_LIST)); + } + } + if (top) { + if (this.spaced) { + return [].concat(this.joinFragmentArrays(compiledNodes, '\n\n'), this.makeCode("\n")); + } else { + return this.joinFragmentArrays(compiledNodes, '\n'); + } + } + if (compiledNodes.length) { + answer = this.joinFragmentArrays(compiledNodes, ', '); + } else { + answer = [this.makeCode("void 0")]; + } + if (compiledNodes.length > 1 && o.level >= LEVEL_LIST) { + return this.wrapInBraces(answer); + } else { + return answer; + } + }; + + Block.prototype.compileRoot = function(o) { + var exp, fragments, i, name, prelude, preludeExps, rest, _i, _len, _ref2; + o.indent = o.bare ? '' : TAB; + o.level = LEVEL_TOP; + this.spaced = true; + o.scope = new Scope(null, this, null); + _ref2 = o.locals || []; + for (_i = 0, _len = _ref2.length; _i < _len; _i++) { + name = _ref2[_i]; + o.scope.parameter(name); + } + prelude = []; + if (!o.bare) { + preludeExps = (function() { + var _j, _len1, _ref3, _results; + _ref3 = this.expressions; + _results = []; + for (i = _j = 0, _len1 = _ref3.length; _j < _len1; i = ++_j) { + exp = _ref3[i]; + if (!(exp.unwrap() instanceof Comment)) { + break; + } + _results.push(exp); + } + return _results; + }).call(this); + rest = this.expressions.slice(preludeExps.length); + this.expressions = preludeExps; + if (preludeExps.length) { + prelude = this.compileNode(merge(o, { + indent: '' + })); + prelude.push(this.makeCode("\n")); + } + this.expressions = rest; + } + fragments = this.compileWithDeclarations(o); + if (o.bare) { + return fragments; + } + return [].concat(prelude, this.makeCode("(function() {\n"), fragments, this.makeCode("\n}).call(this);\n")); + }; + + Block.prototype.compileWithDeclarations = function(o) { + var assigns, declars, exp, fragments, i, post, rest, scope, spaced, _i, _len, _ref2, _ref3, _ref4; + fragments = []; + post = []; + _ref2 = this.expressions; + for (i = _i = 0, _len = _ref2.length; _i < _len; i = ++_i) { + exp = _ref2[i]; + exp = exp.unwrap(); + if (!(exp instanceof Comment || exp instanceof Literal)) { + break; + } + } + o = merge(o, { + level: LEVEL_TOP + }); + if (i) { + rest = this.expressions.splice(i, 9e9); + _ref3 = [this.spaced, false], spaced = _ref3[0], this.spaced = _ref3[1]; + _ref4 = [this.compileNode(o), spaced], fragments = _ref4[0], this.spaced = _ref4[1]; + this.expressions = rest; + } + post = this.compileNode(o); + scope = o.scope; + if (scope.expressions === this) { + declars = o.scope.hasDeclarations(); + assigns = scope.hasAssignments; + if (declars || assigns) { + if (i) { + fragments.push(this.makeCode('\n')); + } + fragments.push(this.makeCode("" + this.tab + "var ")); + if (declars) { + fragments.push(this.makeCode(scope.declaredVariables().join(', '))); + } + if (assigns) { + if (declars) { + fragments.push(this.makeCode(",\n" + (this.tab + TAB))); + } + fragments.push(this.makeCode(scope.assignedVariables().join(",\n" + (this.tab + TAB)))); + } + fragments.push(this.makeCode(";\n" + (this.spaced ? '\n' : ''))); + } else if (fragments.length && post.length) { + fragments.push(this.makeCode("\n")); + } + } + return fragments.concat(post); + }; + + Block.wrap = function(nodes) { + if (nodes.length === 1 && nodes[0] instanceof Block) { + return nodes[0]; + } + return new Block(nodes); + }; + + return Block; + + })(Base); + + exports.Literal = Literal = (function(_super) { + __extends(Literal, _super); + + function Literal(value) { + this.value = value; + } + + Literal.prototype.makeReturn = function() { + if (this.isStatement()) { + return this; + } else { + return Literal.__super__.makeReturn.apply(this, arguments); + } + }; + + Literal.prototype.isAssignable = function() { + return IDENTIFIER.test(this.value); + }; + + Literal.prototype.isStatement = function() { + var _ref2; + return (_ref2 = this.value) === 'break' || _ref2 === 'continue' || _ref2 === 'debugger'; + }; + + Literal.prototype.isComplex = NO; + + Literal.prototype.assigns = function(name) { + return name === this.value; + }; + + Literal.prototype.jumps = function(o) { + if (this.value === 'break' && !((o != null ? o.loop : void 0) || (o != null ? o.block : void 0))) { + return this; + } + if (this.value === 'continue' && !(o != null ? o.loop : void 0)) { + return this; + } + }; + + Literal.prototype.compileNode = function(o) { + var answer, code, _ref2; + code = this.value === 'this' ? ((_ref2 = o.scope.method) != null ? _ref2.bound : void 0) ? o.scope.method.context : this.value : this.value.reserved ? "\"" + this.value + "\"" : this.value; + answer = this.isStatement() ? "" + this.tab + code + ";" : code; + return [this.makeCode(answer)]; + }; + + Literal.prototype.toString = function() { + return ' "' + this.value + '"'; + }; + + return Literal; + + })(Base); + + exports.Undefined = (function(_super) { + __extends(Undefined, _super); + + function Undefined() { + _ref2 = Undefined.__super__.constructor.apply(this, arguments); + return _ref2; + } + + Undefined.prototype.isAssignable = NO; + + Undefined.prototype.isComplex = NO; + + Undefined.prototype.compileNode = function(o) { + return [this.makeCode(o.level >= LEVEL_ACCESS ? '(void 0)' : 'void 0')]; + }; + + return Undefined; + + })(Base); + + exports.Null = (function(_super) { + __extends(Null, _super); + + function Null() { + _ref3 = Null.__super__.constructor.apply(this, arguments); + return _ref3; + } + + Null.prototype.isAssignable = NO; + + Null.prototype.isComplex = NO; + + Null.prototype.compileNode = function() { + return [this.makeCode("null")]; + }; + + return Null; + + })(Base); + + exports.Bool = (function(_super) { + __extends(Bool, _super); + + Bool.prototype.isAssignable = NO; + + Bool.prototype.isComplex = NO; + + Bool.prototype.compileNode = function() { + return [this.makeCode(this.val)]; + }; + + function Bool(val) { + this.val = val; + } + + return Bool; + + })(Base); + + exports.Return = Return = (function(_super) { + __extends(Return, _super); + + function Return(expr) { + if (expr && !expr.unwrap().isUndefined) { + this.expression = expr; + } + } + + Return.prototype.children = ['expression']; + + Return.prototype.isStatement = YES; + + Return.prototype.makeReturn = THIS; + + Return.prototype.jumps = THIS; + + Return.prototype.compileToFragments = function(o, level) { + var expr, _ref4; + expr = (_ref4 = this.expression) != null ? _ref4.makeReturn() : void 0; + if (expr && !(expr instanceof Return)) { + return expr.compileToFragments(o, level); + } else { + return Return.__super__.compileToFragments.call(this, o, level); + } + }; + + Return.prototype.compileNode = function(o) { + var answer; + answer = []; + answer.push(this.makeCode(this.tab + ("return" + (this.expression ? " " : "")))); + if (this.expression) { + answer = answer.concat(this.expression.compileToFragments(o, LEVEL_PAREN)); + } + answer.push(this.makeCode(";")); + return answer; + }; + + return Return; + + })(Base); + + exports.Value = Value = (function(_super) { + __extends(Value, _super); + + function Value(base, props, tag) { + if (!props && base instanceof Value) { + return base; + } + this.base = base; + this.properties = props || []; + if (tag) { + this[tag] = true; + } + return this; + } + + Value.prototype.children = ['base', 'properties']; + + Value.prototype.add = function(props) { + this.properties = this.properties.concat(props); + return this; + }; + + Value.prototype.hasProperties = function() { + return !!this.properties.length; + }; + + Value.prototype.isArray = function() { + return !this.properties.length && this.base instanceof Arr; + }; + + Value.prototype.isComplex = function() { + return this.hasProperties() || this.base.isComplex(); + }; + + Value.prototype.isAssignable = function() { + return this.hasProperties() || this.base.isAssignable(); + }; + + Value.prototype.isSimpleNumber = function() { + return this.base instanceof Literal && SIMPLENUM.test(this.base.value); + }; + + Value.prototype.isString = function() { + return this.base instanceof Literal && IS_STRING.test(this.base.value); + }; + + Value.prototype.isAtomic = function() { + var node, _i, _len, _ref4; + _ref4 = this.properties.concat(this.base); + for (_i = 0, _len = _ref4.length; _i < _len; _i++) { + node = _ref4[_i]; + if (node.soak || node instanceof Call) { + return false; + } + } + return true; + }; + + Value.prototype.isStatement = function(o) { + return !this.properties.length && this.base.isStatement(o); + }; + + Value.prototype.assigns = function(name) { + return !this.properties.length && this.base.assigns(name); + }; + + Value.prototype.jumps = function(o) { + return !this.properties.length && this.base.jumps(o); + }; + + Value.prototype.isObject = function(onlyGenerated) { + if (this.properties.length) { + return false; + } + return (this.base instanceof Obj) && (!onlyGenerated || this.base.generated); + }; + + Value.prototype.isSplice = function() { + return last(this.properties) instanceof Slice; + }; + + Value.prototype.unwrap = function() { + if (this.properties.length) { + return this; + } else { + return this.base; + } + }; + + Value.prototype.cacheReference = function(o) { + var base, bref, name, nref; + name = last(this.properties); + if (this.properties.length < 2 && !this.base.isComplex() && !(name != null ? name.isComplex() : void 0)) { + return [this, this]; + } + base = new Value(this.base, this.properties.slice(0, -1)); + if (base.isComplex()) { + bref = new Literal(o.scope.freeVariable('base')); + base = new Value(new Parens(new Assign(bref, base))); + } + if (!name) { + return [base, bref]; + } + if (name.isComplex()) { + nref = new Literal(o.scope.freeVariable('name')); + name = new Index(new Assign(nref, name.index)); + nref = new Index(nref); + } + return [base.add(name), new Value(bref || base.base, [nref || name])]; + }; + + Value.prototype.compileNode = function(o) { + var fragments, prop, props, _i, _len; + this.base.front = this.front; + props = this.properties; + fragments = this.base.compileToFragments(o, (props.length ? LEVEL_ACCESS : null)); + if ((this.base instanceof Parens || props.length) && SIMPLENUM.test(fragmentsToText(fragments))) { + fragments.push(this.makeCode('.')); + } + for (_i = 0, _len = props.length; _i < _len; _i++) { + prop = props[_i]; + fragments.push.apply(fragments, prop.compileToFragments(o)); + } + return fragments; + }; + + Value.prototype.unfoldSoak = function(o) { + var _this = this; + return this.unfoldedSoak != null ? this.unfoldedSoak : this.unfoldedSoak = (function() { + var fst, i, ifn, prop, ref, snd, _i, _len, _ref4, _ref5; + if (ifn = _this.base.unfoldSoak(o)) { + (_ref4 = ifn.body.properties).push.apply(_ref4, _this.properties); + return ifn; + } + _ref5 = _this.properties; + for (i = _i = 0, _len = _ref5.length; _i < _len; i = ++_i) { + prop = _ref5[i]; + if (!prop.soak) { + continue; + } + prop.soak = false; + fst = new Value(_this.base, _this.properties.slice(0, i)); + snd = new Value(_this.base, _this.properties.slice(i)); + if (fst.isComplex()) { + ref = new Literal(o.scope.freeVariable('ref')); + fst = new Parens(new Assign(ref, fst)); + snd.base = ref; + } + return new If(new Existence(fst), snd, { + soak: true + }); + } + return false; + })(); + }; + + return Value; + + })(Base); + + exports.Comment = Comment = (function(_super) { + __extends(Comment, _super); + + function Comment(comment) { + this.comment = comment; + } + + Comment.prototype.isStatement = YES; + + Comment.prototype.makeReturn = THIS; + + Comment.prototype.compileNode = function(o, level) { + var code; + code = "/*" + (multident(this.comment, this.tab)) + (__indexOf.call(this.comment, '\n') >= 0 ? "\n" + this.tab : '') + "*/"; + if ((level || o.level) === LEVEL_TOP) { + code = o.indent + code; + } + return [this.makeCode("\n"), this.makeCode(code)]; + }; + + return Comment; + + })(Base); + + exports.Call = Call = (function(_super) { + __extends(Call, _super); + + function Call(variable, args, soak) { + this.args = args != null ? args : []; + this.soak = soak; + this.isNew = false; + this.isSuper = variable === 'super'; + this.variable = this.isSuper ? null : variable; + } + + Call.prototype.children = ['variable', 'args']; + + Call.prototype.newInstance = function() { + var base, _ref4; + base = ((_ref4 = this.variable) != null ? _ref4.base : void 0) || this.variable; + if (base instanceof Call && !base.isNew) { + base.newInstance(); + } else { + this.isNew = true; + } + return this; + }; + + Call.prototype.superReference = function(o) { + var accesses, method; + method = o.scope.namedMethod(); + if (method != null ? method.klass : void 0) { + accesses = [new Access(new Literal('__super__'))]; + if (method["static"]) { + accesses.push(new Access(new Literal('constructor'))); + } + accesses.push(new Access(new Literal(method.name))); + return (new Value(new Literal(method.klass), accesses)).compile(o); + } else if (method != null ? method.ctor : void 0) { + return "" + method.name + ".__super__.constructor"; + } else { + return this.error('cannot call super outside of an instance method.'); + } + }; + + Call.prototype.superThis = function(o) { + var method; + method = o.scope.method; + return (method && !method.klass && method.context) || "this"; + }; + + Call.prototype.unfoldSoak = function(o) { + var call, ifn, left, list, rite, _i, _len, _ref4, _ref5; + if (this.soak) { + if (this.variable) { + if (ifn = unfoldSoak(o, this, 'variable')) { + return ifn; + } + _ref4 = new Value(this.variable).cacheReference(o), left = _ref4[0], rite = _ref4[1]; + } else { + left = new Literal(this.superReference(o)); + rite = new Value(left); + } + rite = new Call(rite, this.args); + rite.isNew = this.isNew; + left = new Literal("typeof " + (left.compile(o)) + " === \"function\""); + return new If(left, new Value(rite), { + soak: true + }); + } + call = this; + list = []; + while (true) { + if (call.variable instanceof Call) { + list.push(call); + call = call.variable; + continue; + } + if (!(call.variable instanceof Value)) { + break; + } + list.push(call); + if (!((call = call.variable.base) instanceof Call)) { + break; + } + } + _ref5 = list.reverse(); + for (_i = 0, _len = _ref5.length; _i < _len; _i++) { + call = _ref5[_i]; + if (ifn) { + if (call.variable instanceof Call) { + call.variable = ifn; + } else { + call.variable.base = ifn; + } + } + ifn = unfoldSoak(o, call, 'variable'); + } + return ifn; + }; + + Call.prototype.compileNode = function(o) { + var arg, argIndex, compiledArgs, compiledArray, fragments, preface, _i, _len, _ref4, _ref5; + if ((_ref4 = this.variable) != null) { + _ref4.front = this.front; + } + compiledArray = Splat.compileSplattedArray(o, this.args, true); + if (compiledArray.length) { + return this.compileSplat(o, compiledArray); + } + compiledArgs = []; + _ref5 = this.args; + for (argIndex = _i = 0, _len = _ref5.length; _i < _len; argIndex = ++_i) { + arg = _ref5[argIndex]; + if (argIndex) { + compiledArgs.push(this.makeCode(", ")); + } + compiledArgs.push.apply(compiledArgs, arg.compileToFragments(o, LEVEL_LIST)); + } + fragments = []; + if (this.isSuper) { + preface = this.superReference(o) + (".call(" + (this.superThis(o))); + if (compiledArgs.length) { + preface += ", "; + } + fragments.push(this.makeCode(preface)); + } else { + if (this.isNew) { + fragments.push(this.makeCode('new ')); + } + fragments.push.apply(fragments, this.variable.compileToFragments(o, LEVEL_ACCESS)); + fragments.push(this.makeCode("(")); + } + fragments.push.apply(fragments, compiledArgs); + fragments.push(this.makeCode(")")); + return fragments; + }; + + Call.prototype.compileSplat = function(o, splatArgs) { + var answer, base, fun, idt, name, ref; + if (this.isSuper) { + return [].concat(this.makeCode("" + (this.superReference(o)) + ".apply(" + (this.superThis(o)) + ", "), splatArgs, this.makeCode(")")); + } + if (this.isNew) { + idt = this.tab + TAB; + return [].concat(this.makeCode("(function(func, args, ctor) {\n" + idt + "ctor.prototype = func.prototype;\n" + idt + "var child = new ctor, result = func.apply(child, args);\n" + idt + "return Object(result) === result ? result : child;\n" + this.tab + "})("), this.variable.compileToFragments(o, LEVEL_LIST), this.makeCode(", "), splatArgs, this.makeCode(", function(){})")); + } + answer = []; + base = new Value(this.variable); + if ((name = base.properties.pop()) && base.isComplex()) { + ref = o.scope.freeVariable('ref'); + answer = answer.concat(this.makeCode("(" + ref + " = "), base.compileToFragments(o, LEVEL_LIST), this.makeCode(")"), name.compileToFragments(o)); + } else { + fun = base.compileToFragments(o, LEVEL_ACCESS); + if (SIMPLENUM.test(fragmentsToText(fun))) { + fun = this.wrapInBraces(fun); + } + if (name) { + ref = fragmentsToText(fun); + fun.push.apply(fun, name.compileToFragments(o)); + } else { + ref = 'null'; + } + answer = answer.concat(fun); + } + return answer = answer.concat(this.makeCode(".apply(" + ref + ", "), splatArgs, this.makeCode(")")); + }; + + return Call; + + })(Base); + + exports.Extends = Extends = (function(_super) { + __extends(Extends, _super); + + function Extends(child, parent) { + this.child = child; + this.parent = parent; + } + + Extends.prototype.children = ['child', 'parent']; + + Extends.prototype.compileToFragments = function(o) { + return new Call(new Value(new Literal(utility('extends'))), [this.child, this.parent]).compileToFragments(o); + }; + + return Extends; + + })(Base); + + exports.Access = Access = (function(_super) { + __extends(Access, _super); + + function Access(name, tag) { + this.name = name; + this.name.asKey = true; + this.soak = tag === 'soak'; + } + + Access.prototype.children = ['name']; + + Access.prototype.compileToFragments = function(o) { + var name; + name = this.name.compileToFragments(o); + if (IDENTIFIER.test(fragmentsToText(name))) { + name.unshift(this.makeCode(".")); + } else { + name.unshift(this.makeCode("[")); + name.push(this.makeCode("]")); + } + return name; + }; + + Access.prototype.isComplex = NO; + + return Access; + + })(Base); + + exports.Index = Index = (function(_super) { + __extends(Index, _super); + + function Index(index) { + this.index = index; + } + + Index.prototype.children = ['index']; + + Index.prototype.compileToFragments = function(o) { + return [].concat(this.makeCode("["), this.index.compileToFragments(o, LEVEL_PAREN), this.makeCode("]")); + }; + + Index.prototype.isComplex = function() { + return this.index.isComplex(); + }; + + return Index; + + })(Base); + + exports.Range = Range = (function(_super) { + __extends(Range, _super); + + Range.prototype.children = ['from', 'to']; + + function Range(from, to, tag) { + this.from = from; + this.to = to; + this.exclusive = tag === 'exclusive'; + this.equals = this.exclusive ? '' : '='; + } + + Range.prototype.compileVariables = function(o) { + var step, _ref4, _ref5, _ref6, _ref7; + o = merge(o, { + top: true + }); + _ref4 = this.cacheToCodeFragments(this.from.cache(o, LEVEL_LIST)), this.fromC = _ref4[0], this.fromVar = _ref4[1]; + _ref5 = this.cacheToCodeFragments(this.to.cache(o, LEVEL_LIST)), this.toC = _ref5[0], this.toVar = _ref5[1]; + if (step = del(o, 'step')) { + _ref6 = this.cacheToCodeFragments(step.cache(o, LEVEL_LIST)), this.step = _ref6[0], this.stepVar = _ref6[1]; + } + _ref7 = [this.fromVar.match(SIMPLENUM), this.toVar.match(SIMPLENUM)], this.fromNum = _ref7[0], this.toNum = _ref7[1]; + if (this.stepVar) { + return this.stepNum = this.stepVar.match(SIMPLENUM); + } + }; + + Range.prototype.compileNode = function(o) { + var cond, condPart, from, gt, idx, idxName, known, lt, namedIndex, stepPart, to, varPart, _ref4, _ref5; + if (!this.fromVar) { + this.compileVariables(o); + } + if (!o.index) { + return this.compileArray(o); + } + known = this.fromNum && this.toNum; + idx = del(o, 'index'); + idxName = del(o, 'name'); + namedIndex = idxName && idxName !== idx; + varPart = "" + idx + " = " + this.fromC; + if (this.toC !== this.toVar) { + varPart += ", " + this.toC; + } + if (this.step !== this.stepVar) { + varPart += ", " + this.step; + } + _ref4 = ["" + idx + " <" + this.equals, "" + idx + " >" + this.equals], lt = _ref4[0], gt = _ref4[1]; + condPart = this.stepNum ? +this.stepNum > 0 ? "" + lt + " " + this.toVar : "" + gt + " " + this.toVar : known ? ((_ref5 = [+this.fromNum, +this.toNum], from = _ref5[0], to = _ref5[1], _ref5), from <= to ? "" + lt + " " + to : "" + gt + " " + to) : (cond = this.stepVar ? "" + this.stepVar + " > 0" : "" + this.fromVar + " <= " + this.toVar, "" + cond + " ? " + lt + " " + this.toVar + " : " + gt + " " + this.toVar); + stepPart = this.stepVar ? "" + idx + " += " + this.stepVar : known ? namedIndex ? from <= to ? "++" + idx : "--" + idx : from <= to ? "" + idx + "++" : "" + idx + "--" : namedIndex ? "" + cond + " ? ++" + idx + " : --" + idx : "" + cond + " ? " + idx + "++ : " + idx + "--"; + if (namedIndex) { + varPart = "" + idxName + " = " + varPart; + } + if (namedIndex) { + stepPart = "" + idxName + " = " + stepPart; + } + return [this.makeCode("" + varPart + "; " + condPart + "; " + stepPart)]; + }; + + Range.prototype.compileArray = function(o) { + var args, body, cond, hasArgs, i, idt, post, pre, range, result, vars, _i, _ref4, _ref5, _results; + if (this.fromNum && this.toNum && Math.abs(this.fromNum - this.toNum) <= 20) { + range = (function() { + _results = []; + for (var _i = _ref4 = +this.fromNum, _ref5 = +this.toNum; _ref4 <= _ref5 ? _i <= _ref5 : _i >= _ref5; _ref4 <= _ref5 ? _i++ : _i--){ _results.push(_i); } + return _results; + }).apply(this); + if (this.exclusive) { + range.pop(); + } + return [this.makeCode("[" + (range.join(', ')) + "]")]; + } + idt = this.tab + TAB; + i = o.scope.freeVariable('i'); + result = o.scope.freeVariable('results'); + pre = "\n" + idt + result + " = [];"; + if (this.fromNum && this.toNum) { + o.index = i; + body = fragmentsToText(this.compileNode(o)); + } else { + vars = ("" + i + " = " + this.fromC) + (this.toC !== this.toVar ? ", " + this.toC : ''); + cond = "" + this.fromVar + " <= " + this.toVar; + body = "var " + vars + "; " + cond + " ? " + i + " <" + this.equals + " " + this.toVar + " : " + i + " >" + this.equals + " " + this.toVar + "; " + cond + " ? " + i + "++ : " + i + "--"; + } + post = "{ " + result + ".push(" + i + "); }\n" + idt + "return " + result + ";\n" + o.indent; + hasArgs = function(node) { + return node != null ? node.contains(function(n) { + return n instanceof Literal && n.value === 'arguments' && !n.asKey; + }) : void 0; + }; + if (hasArgs(this.from) || hasArgs(this.to)) { + args = ', arguments'; + } + return [this.makeCode("(function() {" + pre + "\n" + idt + "for (" + body + ")" + post + "}).apply(this" + (args != null ? args : '') + ")")]; + }; + + return Range; + + })(Base); + + exports.Slice = Slice = (function(_super) { + __extends(Slice, _super); + + Slice.prototype.children = ['range']; + + function Slice(range) { + this.range = range; + Slice.__super__.constructor.call(this); + } + + Slice.prototype.compileNode = function(o) { + var compiled, compiledText, from, fromCompiled, to, toStr, _ref4; + _ref4 = this.range, to = _ref4.to, from = _ref4.from; + fromCompiled = from && from.compileToFragments(o, LEVEL_PAREN) || [this.makeCode('0')]; + if (to) { + compiled = to.compileToFragments(o, LEVEL_PAREN); + compiledText = fragmentsToText(compiled); + if (!(!this.range.exclusive && +compiledText === -1)) { + toStr = ', ' + (this.range.exclusive ? compiledText : SIMPLENUM.test(compiledText) ? "" + (+compiledText + 1) : (compiled = to.compileToFragments(o, LEVEL_ACCESS), "+" + (fragmentsToText(compiled)) + " + 1 || 9e9")); + } + } + return [this.makeCode(".slice(" + (fragmentsToText(fromCompiled)) + (toStr || '') + ")")]; + }; + + return Slice; + + })(Base); + + exports.Obj = Obj = (function(_super) { + __extends(Obj, _super); + + function Obj(props, generated) { + this.generated = generated != null ? generated : false; + this.objects = this.properties = props || []; + } + + Obj.prototype.children = ['properties']; + + Obj.prototype.compileNode = function(o) { + var answer, i, idt, indent, join, lastNoncom, node, prop, props, _i, _j, _len, _len1; + props = this.properties; + if (!props.length) { + return [this.makeCode(this.front ? '({})' : '{}')]; + } + if (this.generated) { + for (_i = 0, _len = props.length; _i < _len; _i++) { + node = props[_i]; + if (node instanceof Value) { + node.error('cannot have an implicit value in an implicit object'); + } + } + } + idt = o.indent += TAB; + lastNoncom = this.lastNonComment(this.properties); + answer = []; + for (i = _j = 0, _len1 = props.length; _j < _len1; i = ++_j) { + prop = props[i]; + join = i === props.length - 1 ? '' : prop === lastNoncom || prop instanceof Comment ? '\n' : ',\n'; + indent = prop instanceof Comment ? '' : idt; + if (prop instanceof Assign && prop.variable instanceof Value && prop.variable.hasProperties()) { + prop.variable.error('Invalid object key'); + } + if (prop instanceof Value && prop["this"]) { + prop = new Assign(prop.properties[0].name, prop, 'object'); + } + if (!(prop instanceof Comment)) { + if (!(prop instanceof Assign)) { + prop = new Assign(prop, prop, 'object'); + } + (prop.variable.base || prop.variable).asKey = true; + } + if (indent) { + answer.push(this.makeCode(indent)); + } + answer.push.apply(answer, prop.compileToFragments(o, LEVEL_TOP)); + if (join) { + answer.push(this.makeCode(join)); + } + } + answer.unshift(this.makeCode("{" + (props.length && '\n'))); + answer.push(this.makeCode("" + (props.length && '\n' + this.tab) + "}")); + if (this.front) { + return this.wrapInBraces(answer); + } else { + return answer; + } + }; + + Obj.prototype.assigns = function(name) { + var prop, _i, _len, _ref4; + _ref4 = this.properties; + for (_i = 0, _len = _ref4.length; _i < _len; _i++) { + prop = _ref4[_i]; + if (prop.assigns(name)) { + return true; + } + } + return false; + }; + + return Obj; + + })(Base); + + exports.Arr = Arr = (function(_super) { + __extends(Arr, _super); + + function Arr(objs) { + this.objects = objs || []; + } + + Arr.prototype.children = ['objects']; + + Arr.prototype.compileNode = function(o) { + var answer, compiledObjs, fragments, index, obj, _i, _len; + if (!this.objects.length) { + return [this.makeCode('[]')]; + } + o.indent += TAB; + answer = Splat.compileSplattedArray(o, this.objects); + if (answer.length) { + return answer; + } + answer = []; + compiledObjs = (function() { + var _i, _len, _ref4, _results; + _ref4 = this.objects; + _results = []; + for (_i = 0, _len = _ref4.length; _i < _len; _i++) { + obj = _ref4[_i]; + _results.push(obj.compileToFragments(o, LEVEL_LIST)); + } + return _results; + }).call(this); + for (index = _i = 0, _len = compiledObjs.length; _i < _len; index = ++_i) { + fragments = compiledObjs[index]; + if (index) { + answer.push(this.makeCode(", ")); + } + answer.push.apply(answer, fragments); + } + if (fragmentsToText(answer).indexOf('\n') >= 0) { + answer.unshift(this.makeCode("[\n" + o.indent)); + answer.push(this.makeCode("\n" + this.tab + "]")); + } else { + answer.unshift(this.makeCode("[")); + answer.push(this.makeCode("]")); + } + return answer; + }; + + Arr.prototype.assigns = function(name) { + var obj, _i, _len, _ref4; + _ref4 = this.objects; + for (_i = 0, _len = _ref4.length; _i < _len; _i++) { + obj = _ref4[_i]; + if (obj.assigns(name)) { + return true; + } + } + return false; + }; + + return Arr; + + })(Base); + + exports.Class = Class = (function(_super) { + __extends(Class, _super); + + function Class(variable, parent, body) { + this.variable = variable; + this.parent = parent; + this.body = body != null ? body : new Block; + this.boundFuncs = []; + this.body.classBody = true; + } + + Class.prototype.children = ['variable', 'parent', 'body']; + + Class.prototype.determineName = function() { + var decl, tail; + if (!this.variable) { + return null; + } + decl = (tail = last(this.variable.properties)) ? tail instanceof Access && tail.name.value : this.variable.base.value; + if (__indexOf.call(STRICT_PROSCRIBED, decl) >= 0) { + this.variable.error("class variable name may not be " + decl); + } + return decl && (decl = IDENTIFIER.test(decl) && decl); + }; + + Class.prototype.setContext = function(name) { + return this.body.traverseChildren(false, function(node) { + if (node.classBody) { + return false; + } + if (node instanceof Literal && node.value === 'this') { + return node.value = name; + } else if (node instanceof Code) { + node.klass = name; + if (node.bound) { + return node.context = name; + } + } + }); + }; + + Class.prototype.addBoundFunctions = function(o) { + var bvar, lhs, _i, _len, _ref4; + _ref4 = this.boundFuncs; + for (_i = 0, _len = _ref4.length; _i < _len; _i++) { + bvar = _ref4[_i]; + lhs = (new Value(new Literal("this"), [new Access(bvar)])).compile(o); + this.ctor.body.unshift(new Literal("" + lhs + " = " + (utility('bind')) + "(" + lhs + ", this)")); + } + }; + + Class.prototype.addProperties = function(node, name, o) { + var assign, base, exprs, func, props; + props = node.base.properties.slice(0); + exprs = (function() { + var _results; + _results = []; + while (assign = props.shift()) { + if (assign instanceof Assign) { + base = assign.variable.base; + delete assign.context; + func = assign.value; + if (base.value === 'constructor') { + if (this.ctor) { + assign.error('cannot define more than one constructor in a class'); + } + if (func.bound) { + assign.error('cannot define a constructor as a bound function'); + } + if (func instanceof Code) { + assign = this.ctor = func; + } else { + this.externalCtor = o.scope.freeVariable('class'); + assign = new Assign(new Literal(this.externalCtor), func); + } + } else { + if (assign.variable["this"]) { + func["static"] = true; + if (func.bound) { + func.context = name; + } + } else { + assign.variable = new Value(new Literal(name), [new Access(new Literal('prototype')), new Access(base)]); + if (func instanceof Code && func.bound) { + this.boundFuncs.push(base); + func.bound = false; + } + } + } + } + _results.push(assign); + } + return _results; + }).call(this); + return compact(exprs); + }; + + Class.prototype.walkBody = function(name, o) { + var _this = this; + return this.traverseChildren(false, function(child) { + var cont, exps, i, node, _i, _len, _ref4; + cont = true; + if (child instanceof Class) { + return false; + } + if (child instanceof Block) { + _ref4 = exps = child.expressions; + for (i = _i = 0, _len = _ref4.length; _i < _len; i = ++_i) { + node = _ref4[i]; + if (node instanceof Value && node.isObject(true)) { + cont = false; + exps[i] = _this.addProperties(node, name, o); + } + } + child.expressions = exps = flatten(exps); + } + return cont && !(child instanceof Class); + }); + }; + + Class.prototype.hoistDirectivePrologue = function() { + var expressions, index, node; + index = 0; + expressions = this.body.expressions; + while ((node = expressions[index]) && node instanceof Comment || node instanceof Value && node.isString()) { + ++index; + } + return this.directives = expressions.splice(0, index); + }; + + Class.prototype.ensureConstructor = function(name, o) { + var missing, ref, superCall; + missing = !this.ctor; + this.ctor || (this.ctor = new Code); + this.ctor.ctor = this.ctor.name = name; + this.ctor.klass = null; + this.ctor.noReturn = true; + if (missing) { + if (this.parent) { + superCall = new Literal("" + name + ".__super__.constructor.apply(this, arguments)"); + } + if (this.externalCtor) { + superCall = new Literal("" + this.externalCtor + ".apply(this, arguments)"); + } + if (superCall) { + ref = new Literal(o.scope.freeVariable('ref')); + this.ctor.body.unshift(new Assign(ref, superCall)); + } + this.addBoundFunctions(o); + if (superCall) { + this.ctor.body.push(ref); + this.ctor.body.makeReturn(); + } + return this.body.expressions.unshift(this.ctor); + } else { + return this.addBoundFunctions(o); + } + }; + + Class.prototype.compileNode = function(o) { + var call, decl, klass, lname, name, params, _ref4; + decl = this.determineName(); + name = decl || '_Class'; + if (name.reserved) { + name = "_" + name; + } + lname = new Literal(name); + this.hoistDirectivePrologue(); + this.setContext(name); + this.walkBody(name, o); + this.ensureConstructor(name, o); + this.body.spaced = true; + if (!(this.ctor instanceof Code)) { + this.body.expressions.unshift(this.ctor); + } + this.body.expressions.push(lname); + (_ref4 = this.body.expressions).unshift.apply(_ref4, this.directives); + call = Closure.wrap(this.body); + if (this.parent) { + this.superClass = new Literal(o.scope.freeVariable('super', false)); + this.body.expressions.unshift(new Extends(lname, this.superClass)); + call.args.push(this.parent); + params = call.variable.params || call.variable.base.params; + params.push(new Param(this.superClass)); + } + klass = new Parens(call, true); + if (this.variable) { + klass = new Assign(this.variable, klass); + } + return klass.compileToFragments(o); + }; + + return Class; + + })(Base); + + exports.Assign = Assign = (function(_super) { + __extends(Assign, _super); + + function Assign(variable, value, context, options) { + var forbidden, name, _ref4; + this.variable = variable; + this.value = value; + this.context = context; + this.param = options && options.param; + this.subpattern = options && options.subpattern; + forbidden = (_ref4 = (name = this.variable.unwrapAll().value), __indexOf.call(STRICT_PROSCRIBED, _ref4) >= 0); + if (forbidden && this.context !== 'object') { + this.variable.error("variable name may not be \"" + name + "\""); + } + } + + Assign.prototype.children = ['variable', 'value']; + + Assign.prototype.isStatement = function(o) { + return (o != null ? o.level : void 0) === LEVEL_TOP && (this.context != null) && __indexOf.call(this.context, "?") >= 0; + }; + + Assign.prototype.assigns = function(name) { + return this[this.context === 'object' ? 'value' : 'variable'].assigns(name); + }; + + Assign.prototype.unfoldSoak = function(o) { + return unfoldSoak(o, this, 'variable'); + }; + + Assign.prototype.compileNode = function(o) { + var answer, compiledName, isValue, match, name, val, varBase, _ref4, _ref5, _ref6, _ref7; + if (isValue = this.variable instanceof Value) { + if (this.variable.isArray() || this.variable.isObject()) { + return this.compilePatternMatch(o); + } + if (this.variable.isSplice()) { + return this.compileSplice(o); + } + if ((_ref4 = this.context) === '||=' || _ref4 === '&&=' || _ref4 === '?=') { + return this.compileConditional(o); + } + } + compiledName = this.variable.compileToFragments(o, LEVEL_LIST); + name = fragmentsToText(compiledName); + if (!this.context) { + varBase = this.variable.unwrapAll(); + if (!varBase.isAssignable()) { + this.variable.error("\"" + (this.variable.compile(o)) + "\" cannot be assigned"); + } + if (!(typeof varBase.hasProperties === "function" ? varBase.hasProperties() : void 0)) { + if (this.param) { + o.scope.add(name, 'var'); + } else { + o.scope.find(name); + } + } + } + if (this.value instanceof Code && (match = METHOD_DEF.exec(name))) { + if (match[1]) { + this.value.klass = match[1]; + } + this.value.name = (_ref5 = (_ref6 = (_ref7 = match[2]) != null ? _ref7 : match[3]) != null ? _ref6 : match[4]) != null ? _ref5 : match[5]; + } + val = this.value.compileToFragments(o, LEVEL_LIST); + if (this.context === 'object') { + return compiledName.concat(this.makeCode(": "), val); + } + answer = compiledName.concat(this.makeCode(" " + (this.context || '=') + " "), val); + if (o.level <= LEVEL_LIST) { + return answer; + } else { + return this.wrapInBraces(answer); + } + }; + + Assign.prototype.compilePatternMatch = function(o) { + var acc, assigns, code, fragments, i, idx, isObject, ivar, name, obj, objects, olen, ref, rest, splat, top, val, value, vvar, vvarText, _i, _len, _ref4, _ref5, _ref6, _ref7, _ref8, _ref9; + top = o.level === LEVEL_TOP; + value = this.value; + objects = this.variable.base.objects; + if (!(olen = objects.length)) { + code = value.compileToFragments(o); + if (o.level >= LEVEL_OP) { + return this.wrapInBraces(code); + } else { + return code; + } + } + isObject = this.variable.isObject(); + if (top && olen === 1 && !((obj = objects[0]) instanceof Splat)) { + if (obj instanceof Assign) { + _ref4 = obj, (_ref5 = _ref4.variable, idx = _ref5.base), obj = _ref4.value; + } else { + idx = isObject ? obj["this"] ? obj.properties[0].name : obj : new Literal(0); + } + acc = IDENTIFIER.test(idx.unwrap().value || 0); + value = new Value(value); + value.properties.push(new (acc ? Access : Index)(idx)); + if (_ref6 = obj.unwrap().value, __indexOf.call(RESERVED, _ref6) >= 0) { + obj.error("assignment to a reserved word: " + (obj.compile(o))); + } + return new Assign(obj, value, null, { + param: this.param + }).compileToFragments(o, LEVEL_TOP); + } + vvar = value.compileToFragments(o, LEVEL_LIST); + vvarText = fragmentsToText(vvar); + assigns = []; + splat = false; + if (!IDENTIFIER.test(vvarText) || this.variable.assigns(vvarText)) { + assigns.push([this.makeCode("" + (ref = o.scope.freeVariable('ref')) + " = ")].concat(__slice.call(vvar))); + vvar = [this.makeCode(ref)]; + vvarText = ref; + } + for (i = _i = 0, _len = objects.length; _i < _len; i = ++_i) { + obj = objects[i]; + idx = i; + if (isObject) { + if (obj instanceof Assign) { + _ref7 = obj, (_ref8 = _ref7.variable, idx = _ref8.base), obj = _ref7.value; + } else { + if (obj.base instanceof Parens) { + _ref9 = new Value(obj.unwrapAll()).cacheReference(o), obj = _ref9[0], idx = _ref9[1]; + } else { + idx = obj["this"] ? obj.properties[0].name : obj; + } + } + } + if (!splat && obj instanceof Splat) { + name = obj.name.unwrap().value; + obj = obj.unwrap(); + val = "" + olen + " <= " + vvarText + ".length ? " + (utility('slice')) + ".call(" + vvarText + ", " + i; + if (rest = olen - i - 1) { + ivar = o.scope.freeVariable('i'); + val += ", " + ivar + " = " + vvarText + ".length - " + rest + ") : (" + ivar + " = " + i + ", [])"; + } else { + val += ") : []"; + } + val = new Literal(val); + splat = "" + ivar + "++"; + } else { + name = obj.unwrap().value; + if (obj instanceof Splat) { + obj.error("multiple splats are disallowed in an assignment"); + } + if (typeof idx === 'number') { + idx = new Literal(splat || idx); + acc = false; + } else { + acc = isObject && IDENTIFIER.test(idx.unwrap().value || 0); + } + val = new Value(new Literal(vvarText), [new (acc ? Access : Index)(idx)]); + } + if ((name != null) && __indexOf.call(RESERVED, name) >= 0) { + obj.error("assignment to a reserved word: " + (obj.compile(o))); + } + assigns.push(new Assign(obj, val, null, { + param: this.param, + subpattern: true + }).compileToFragments(o, LEVEL_LIST)); + } + if (!(top || this.subpattern)) { + assigns.push(vvar); + } + fragments = this.joinFragmentArrays(assigns, ', '); + if (o.level < LEVEL_LIST) { + return fragments; + } else { + return this.wrapInBraces(fragments); + } + }; + + Assign.prototype.compileConditional = function(o) { + var left, right, _ref4; + _ref4 = this.variable.cacheReference(o), left = _ref4[0], right = _ref4[1]; + if (!left.properties.length && left.base instanceof Literal && left.base.value !== "this" && !o.scope.check(left.base.value)) { + this.variable.error("the variable \"" + left.base.value + "\" can't be assigned with " + this.context + " because it has not been declared before"); + } + if (__indexOf.call(this.context, "?") >= 0) { + o.isExistentialEquals = true; + } + return new Op(this.context.slice(0, -1), left, new Assign(right, this.value, '=')).compileToFragments(o); + }; + + Assign.prototype.compileSplice = function(o) { + var answer, exclusive, from, fromDecl, fromRef, name, to, valDef, valRef, _ref4, _ref5, _ref6; + _ref4 = this.variable.properties.pop().range, from = _ref4.from, to = _ref4.to, exclusive = _ref4.exclusive; + name = this.variable.compile(o); + if (from) { + _ref5 = this.cacheToCodeFragments(from.cache(o, LEVEL_OP)), fromDecl = _ref5[0], fromRef = _ref5[1]; + } else { + fromDecl = fromRef = '0'; + } + if (to) { + if ((from != null ? from.isSimpleNumber() : void 0) && to.isSimpleNumber()) { + to = +to.compile(o) - +fromRef; + if (!exclusive) { + to += 1; + } + } else { + to = to.compile(o, LEVEL_ACCESS) + ' - ' + fromRef; + if (!exclusive) { + to += ' + 1'; + } + } + } else { + to = "9e9"; + } + _ref6 = this.value.cache(o, LEVEL_LIST), valDef = _ref6[0], valRef = _ref6[1]; + answer = [].concat(this.makeCode("[].splice.apply(" + name + ", [" + fromDecl + ", " + to + "].concat("), valDef, this.makeCode(")), "), valRef); + if (o.level > LEVEL_TOP) { + return this.wrapInBraces(answer); + } else { + return answer; + } + }; + + return Assign; + + })(Base); + + exports.Code = Code = (function(_super) { + __extends(Code, _super); + + function Code(params, body, tag) { + this.params = params || []; + this.body = body || new Block; + this.bound = tag === 'boundfunc'; + if (this.bound) { + this.context = '_this'; + } + } + + Code.prototype.children = ['params', 'body']; + + Code.prototype.isStatement = function() { + return !!this.ctor; + }; + + Code.prototype.jumps = NO; + + Code.prototype.compileNode = function(o) { + var answer, code, exprs, i, idt, lit, p, param, params, ref, splats, uniqs, val, wasEmpty, _i, _j, _k, _l, _len, _len1, _len2, _len3, _len4, _m, _ref4, _ref5, _ref6, _ref7, _ref8; + o.scope = new Scope(o.scope, this.body, this); + o.scope.shared = del(o, 'sharedScope'); + o.indent += TAB; + delete o.bare; + delete o.isExistentialEquals; + params = []; + exprs = []; + this.eachParamName(function(name) { + if (!o.scope.check(name)) { + return o.scope.parameter(name); + } + }); + _ref4 = this.params; + for (_i = 0, _len = _ref4.length; _i < _len; _i++) { + param = _ref4[_i]; + if (!param.splat) { + continue; + } + _ref5 = this.params; + for (_j = 0, _len1 = _ref5.length; _j < _len1; _j++) { + p = _ref5[_j].name; + if (p["this"]) { + p = p.properties[0].name; + } + if (p.value) { + o.scope.add(p.value, 'var', true); + } + } + splats = new Assign(new Value(new Arr((function() { + var _k, _len2, _ref6, _results; + _ref6 = this.params; + _results = []; + for (_k = 0, _len2 = _ref6.length; _k < _len2; _k++) { + p = _ref6[_k]; + _results.push(p.asReference(o)); + } + return _results; + }).call(this))), new Value(new Literal('arguments'))); + break; + } + _ref6 = this.params; + for (_k = 0, _len2 = _ref6.length; _k < _len2; _k++) { + param = _ref6[_k]; + if (param.isComplex()) { + val = ref = param.asReference(o); + if (param.value) { + val = new Op('?', ref, param.value); + } + exprs.push(new Assign(new Value(param.name), val, '=', { + param: true + })); + } else { + ref = param; + if (param.value) { + lit = new Literal(ref.name.value + ' == null'); + val = new Assign(new Value(param.name), param.value, '='); + exprs.push(new If(lit, val)); + } + } + if (!splats) { + params.push(ref); + } + } + wasEmpty = this.body.isEmpty(); + if (splats) { + exprs.unshift(splats); + } + if (exprs.length) { + (_ref7 = this.body.expressions).unshift.apply(_ref7, exprs); + } + for (i = _l = 0, _len3 = params.length; _l < _len3; i = ++_l) { + p = params[i]; + params[i] = p.compileToFragments(o); + o.scope.parameter(fragmentsToText(params[i])); + } + uniqs = []; + this.eachParamName(function(name, node) { + if (__indexOf.call(uniqs, name) >= 0) { + node.error("multiple parameters named '" + name + "'"); + } + return uniqs.push(name); + }); + if (!(wasEmpty || this.noReturn)) { + this.body.makeReturn(); + } + if (this.bound) { + if ((_ref8 = o.scope.parent.method) != null ? _ref8.bound : void 0) { + this.bound = this.context = o.scope.parent.method.context; + } else if (!this["static"]) { + o.scope.parent.assign('_this', 'this'); + } + } + idt = o.indent; + code = 'function'; + if (this.ctor) { + code += ' ' + this.name; + } + code += '('; + answer = [this.makeCode(code)]; + for (i = _m = 0, _len4 = params.length; _m < _len4; i = ++_m) { + p = params[i]; + if (i) { + answer.push(this.makeCode(", ")); + } + answer.push.apply(answer, p); + } + answer.push(this.makeCode(') {')); + if (!this.body.isEmpty()) { + answer = answer.concat(this.makeCode("\n"), this.body.compileWithDeclarations(o), this.makeCode("\n" + this.tab)); + } + answer.push(this.makeCode('}')); + if (this.ctor) { + return [this.makeCode(this.tab)].concat(__slice.call(answer)); + } + if (this.front || (o.level >= LEVEL_ACCESS)) { + return this.wrapInBraces(answer); + } else { + return answer; + } + }; + + Code.prototype.eachParamName = function(iterator) { + var param, _i, _len, _ref4, _results; + _ref4 = this.params; + _results = []; + for (_i = 0, _len = _ref4.length; _i < _len; _i++) { + param = _ref4[_i]; + _results.push(param.eachName(iterator)); + } + return _results; + }; + + Code.prototype.traverseChildren = function(crossScope, func) { + if (crossScope) { + return Code.__super__.traverseChildren.call(this, crossScope, func); + } + }; + + return Code; + + })(Base); + + exports.Param = Param = (function(_super) { + __extends(Param, _super); + + function Param(name, value, splat) { + var _ref4; + this.name = name; + this.value = value; + this.splat = splat; + if (_ref4 = (name = this.name.unwrapAll().value), __indexOf.call(STRICT_PROSCRIBED, _ref4) >= 0) { + this.name.error("parameter name \"" + name + "\" is not allowed"); + } + } + + Param.prototype.children = ['name', 'value']; + + Param.prototype.compileToFragments = function(o) { + return this.name.compileToFragments(o, LEVEL_LIST); + }; + + Param.prototype.asReference = function(o) { + var node; + if (this.reference) { + return this.reference; + } + node = this.name; + if (node["this"]) { + node = node.properties[0].name; + if (node.value.reserved) { + node = new Literal(o.scope.freeVariable(node.value)); + } + } else if (node.isComplex()) { + node = new Literal(o.scope.freeVariable('arg')); + } + node = new Value(node); + if (this.splat) { + node = new Splat(node); + } + return this.reference = node; + }; + + Param.prototype.isComplex = function() { + return this.name.isComplex(); + }; + + Param.prototype.eachName = function(iterator, name) { + var atParam, node, obj, _i, _len, _ref4; + if (name == null) { + name = this.name; + } + atParam = function(obj) { + var node; + node = obj.properties[0].name; + if (!node.value.reserved) { + return iterator(node.value, node); + } + }; + if (name instanceof Literal) { + return iterator(name.value, name); + } + if (name instanceof Value) { + return atParam(name); + } + _ref4 = name.objects; + for (_i = 0, _len = _ref4.length; _i < _len; _i++) { + obj = _ref4[_i]; + if (obj instanceof Assign) { + this.eachName(iterator, obj.value.unwrap()); + } else if (obj instanceof Splat) { + node = obj.name.unwrap(); + iterator(node.value, node); + } else if (obj instanceof Value) { + if (obj.isArray() || obj.isObject()) { + this.eachName(iterator, obj.base); + } else if (obj["this"]) { + atParam(obj); + } else { + iterator(obj.base.value, obj.base); + } + } else { + obj.error("illegal parameter " + (obj.compile())); + } + } + }; + + return Param; + + })(Base); + + exports.Splat = Splat = (function(_super) { + __extends(Splat, _super); + + Splat.prototype.children = ['name']; + + Splat.prototype.isAssignable = YES; + + function Splat(name) { + this.name = name.compile ? name : new Literal(name); + } + + Splat.prototype.assigns = function(name) { + return this.name.assigns(name); + }; + + Splat.prototype.compileToFragments = function(o) { + return this.name.compileToFragments(o); + }; + + Splat.prototype.unwrap = function() { + return this.name; + }; + + Splat.compileSplattedArray = function(o, list, apply) { + var args, base, compiledNode, concatPart, fragments, i, index, node, _i, _len; + index = -1; + while ((node = list[++index]) && !(node instanceof Splat)) { + continue; + } + if (index >= list.length) { + return []; + } + if (list.length === 1) { + node = list[0]; + fragments = node.compileToFragments(o, LEVEL_LIST); + if (apply) { + return fragments; + } + return [].concat(node.makeCode("" + (utility('slice')) + ".call("), fragments, node.makeCode(")")); + } + args = list.slice(index); + for (i = _i = 0, _len = args.length; _i < _len; i = ++_i) { + node = args[i]; + compiledNode = node.compileToFragments(o, LEVEL_LIST); + args[i] = node instanceof Splat ? [].concat(node.makeCode("" + (utility('slice')) + ".call("), compiledNode, node.makeCode(")")) : [].concat(node.makeCode("["), compiledNode, node.makeCode("]")); + } + if (index === 0) { + node = list[0]; + concatPart = node.joinFragmentArrays(args.slice(1), ', '); + return args[0].concat(node.makeCode(".concat("), concatPart, node.makeCode(")")); + } + base = (function() { + var _j, _len1, _ref4, _results; + _ref4 = list.slice(0, index); + _results = []; + for (_j = 0, _len1 = _ref4.length; _j < _len1; _j++) { + node = _ref4[_j]; + _results.push(node.compileToFragments(o, LEVEL_LIST)); + } + return _results; + })(); + base = list[0].joinFragmentArrays(base, ', '); + concatPart = list[index].joinFragmentArrays(args, ', '); + return [].concat(list[0].makeCode("["), base, list[index].makeCode("].concat("), concatPart, (last(list)).makeCode(")")); + }; + + return Splat; + + })(Base); + + exports.While = While = (function(_super) { + __extends(While, _super); + + function While(condition, options) { + this.condition = (options != null ? options.invert : void 0) ? condition.invert() : condition; + this.guard = options != null ? options.guard : void 0; + } + + While.prototype.children = ['condition', 'guard', 'body']; + + While.prototype.isStatement = YES; + + While.prototype.makeReturn = function(res) { + if (res) { + return While.__super__.makeReturn.apply(this, arguments); + } else { + this.returns = !this.jumps({ + loop: true + }); + return this; + } + }; + + While.prototype.addBody = function(body) { + this.body = body; + return this; + }; + + While.prototype.jumps = function() { + var expressions, node, _i, _len; + expressions = this.body.expressions; + if (!expressions.length) { + return false; + } + for (_i = 0, _len = expressions.length; _i < _len; _i++) { + node = expressions[_i]; + if (node.jumps({ + loop: true + })) { + return node; + } + } + return false; + }; + + While.prototype.compileNode = function(o) { + var answer, body, rvar, set; + o.indent += TAB; + set = ''; + body = this.body; + if (body.isEmpty()) { + body = this.makeCode(''); + } else { + if (this.returns) { + body.makeReturn(rvar = o.scope.freeVariable('results')); + set = "" + this.tab + rvar + " = [];\n"; + } + if (this.guard) { + if (body.expressions.length > 1) { + body.expressions.unshift(new If((new Parens(this.guard)).invert(), new Literal("continue"))); + } else { + if (this.guard) { + body = Block.wrap([new If(this.guard, body)]); + } + } + } + body = [].concat(this.makeCode("\n"), body.compileToFragments(o, LEVEL_TOP), this.makeCode("\n" + this.tab)); + } + answer = [].concat(this.makeCode(set + this.tab + "while ("), this.condition.compileToFragments(o, LEVEL_PAREN), this.makeCode(") {"), body, this.makeCode("}")); + if (this.returns) { + answer.push(this.makeCode("\n" + this.tab + "return " + rvar + ";")); + } + return answer; + }; + + return While; + + })(Base); + + exports.Op = Op = (function(_super) { + var CONVERSIONS, INVERSIONS; + + __extends(Op, _super); + + function Op(op, first, second, flip) { + if (op === 'in') { + return new In(first, second); + } + if (op === 'do') { + return this.generateDo(first); + } + if (op === 'new') { + if (first instanceof Call && !first["do"] && !first.isNew) { + return first.newInstance(); + } + if (first instanceof Code && first.bound || first["do"]) { + first = new Parens(first); + } + } + this.operator = CONVERSIONS[op] || op; + this.first = first; + this.second = second; + this.flip = !!flip; + return this; + } + + CONVERSIONS = { + '==': '===', + '!=': '!==', + 'of': 'in' + }; + + INVERSIONS = { + '!==': '===', + '===': '!==' + }; + + Op.prototype.children = ['first', 'second']; + + Op.prototype.isSimpleNumber = NO; + + Op.prototype.isUnary = function() { + return !this.second; + }; + + Op.prototype.isComplex = function() { + var _ref4; + return !(this.isUnary() && ((_ref4 = this.operator) === '+' || _ref4 === '-')) || this.first.isComplex(); + }; + + Op.prototype.isChainable = function() { + var _ref4; + return (_ref4 = this.operator) === '<' || _ref4 === '>' || _ref4 === '>=' || _ref4 === '<=' || _ref4 === '===' || _ref4 === '!=='; + }; + + Op.prototype.invert = function() { + var allInvertable, curr, fst, op, _ref4; + if (this.isChainable() && this.first.isChainable()) { + allInvertable = true; + curr = this; + while (curr && curr.operator) { + allInvertable && (allInvertable = curr.operator in INVERSIONS); + curr = curr.first; + } + if (!allInvertable) { + return new Parens(this).invert(); + } + curr = this; + while (curr && curr.operator) { + curr.invert = !curr.invert; + curr.operator = INVERSIONS[curr.operator]; + curr = curr.first; + } + return this; + } else if (op = INVERSIONS[this.operator]) { + this.operator = op; + if (this.first.unwrap() instanceof Op) { + this.first.invert(); + } + return this; + } else if (this.second) { + return new Parens(this).invert(); + } else if (this.operator === '!' && (fst = this.first.unwrap()) instanceof Op && ((_ref4 = fst.operator) === '!' || _ref4 === 'in' || _ref4 === 'instanceof')) { + return fst; + } else { + return new Op('!', this); + } + }; + + Op.prototype.unfoldSoak = function(o) { + var _ref4; + return ((_ref4 = this.operator) === '++' || _ref4 === '--' || _ref4 === 'delete') && unfoldSoak(o, this, 'first'); + }; + + Op.prototype.generateDo = function(exp) { + var call, func, param, passedParams, ref, _i, _len, _ref4; + passedParams = []; + func = exp instanceof Assign && (ref = exp.value.unwrap()) instanceof Code ? ref : exp; + _ref4 = func.params || []; + for (_i = 0, _len = _ref4.length; _i < _len; _i++) { + param = _ref4[_i]; + if (param.value) { + passedParams.push(param.value); + delete param.value; + } else { + passedParams.push(param); + } + } + call = new Call(exp, passedParams); + call["do"] = true; + return call; + }; + + Op.prototype.compileNode = function(o) { + var answer, isChain, _ref4, _ref5; + isChain = this.isChainable() && this.first.isChainable(); + if (!isChain) { + this.first.front = this.front; + } + if (this.operator === 'delete' && o.scope.check(this.first.unwrapAll().value)) { + this.error('delete operand may not be argument or var'); + } + if (((_ref4 = this.operator) === '--' || _ref4 === '++') && (_ref5 = this.first.unwrapAll().value, __indexOf.call(STRICT_PROSCRIBED, _ref5) >= 0)) { + this.error("cannot increment/decrement \"" + (this.first.unwrapAll().value) + "\""); + } + if (this.isUnary()) { + return this.compileUnary(o); + } + if (isChain) { + return this.compileChain(o); + } + if (this.operator === '?') { + return this.compileExistence(o); + } + answer = [].concat(this.first.compileToFragments(o, LEVEL_OP), this.makeCode(' ' + this.operator + ' '), this.second.compileToFragments(o, LEVEL_OP)); + if (o.level <= LEVEL_OP) { + return answer; + } else { + return this.wrapInBraces(answer); + } + }; + + Op.prototype.compileChain = function(o) { + var fragments, fst, shared, _ref4; + _ref4 = this.first.second.cache(o), this.first.second = _ref4[0], shared = _ref4[1]; + fst = this.first.compileToFragments(o, LEVEL_OP); + fragments = fst.concat(this.makeCode(" " + (this.invert ? '&&' : '||') + " "), shared.compileToFragments(o), this.makeCode(" " + this.operator + " "), this.second.compileToFragments(o, LEVEL_OP)); + return this.wrapInBraces(fragments); + }; + + Op.prototype.compileExistence = function(o) { + var fst, ref; + if (!o.isExistentialEquals && this.first.isComplex()) { + ref = new Literal(o.scope.freeVariable('ref')); + fst = new Parens(new Assign(ref, this.first)); + } else { + fst = this.first; + ref = fst; + } + return new If(new Existence(fst), ref, { + type: 'if' + }).addElse(this.second).compileToFragments(o); + }; + + Op.prototype.compileUnary = function(o) { + var op, parts, plusMinus; + parts = []; + op = this.operator; + parts.push([this.makeCode(op)]); + if (op === '!' && this.first instanceof Existence) { + this.first.negated = !this.first.negated; + return this.first.compileToFragments(o); + } + if (o.level >= LEVEL_ACCESS) { + return (new Parens(this)).compileToFragments(o); + } + plusMinus = op === '+' || op === '-'; + if ((op === 'new' || op === 'typeof' || op === 'delete') || plusMinus && this.first instanceof Op && this.first.operator === op) { + parts.push([this.makeCode(' ')]); + } + if ((plusMinus && this.first instanceof Op) || (op === 'new' && this.first.isStatement(o))) { + this.first = new Parens(this.first); + } + parts.push(this.first.compileToFragments(o, LEVEL_OP)); + if (this.flip) { + parts.reverse(); + } + return this.joinFragmentArrays(parts, ''); + }; + + Op.prototype.toString = function(idt) { + return Op.__super__.toString.call(this, idt, this.constructor.name + ' ' + this.operator); + }; + + return Op; + + })(Base); + + exports.In = In = (function(_super) { + __extends(In, _super); + + function In(object, array) { + this.object = object; + this.array = array; + } + + In.prototype.children = ['object', 'array']; + + In.prototype.invert = NEGATE; + + In.prototype.compileNode = function(o) { + var hasSplat, obj, _i, _len, _ref4; + if (this.array instanceof Value && this.array.isArray()) { + _ref4 = this.array.base.objects; + for (_i = 0, _len = _ref4.length; _i < _len; _i++) { + obj = _ref4[_i]; + if (!(obj instanceof Splat)) { + continue; + } + hasSplat = true; + break; + } + if (!hasSplat) { + return this.compileOrTest(o); + } + } + return this.compileLoopTest(o); + }; + + In.prototype.compileOrTest = function(o) { + var cmp, cnj, i, item, ref, sub, tests, _i, _len, _ref4, _ref5, _ref6; + if (this.array.base.objects.length === 0) { + return [this.makeCode("" + (!!this.negated))]; + } + _ref4 = this.object.cache(o, LEVEL_OP), sub = _ref4[0], ref = _ref4[1]; + _ref5 = this.negated ? [' !== ', ' && '] : [' === ', ' || '], cmp = _ref5[0], cnj = _ref5[1]; + tests = []; + _ref6 = this.array.base.objects; + for (i = _i = 0, _len = _ref6.length; _i < _len; i = ++_i) { + item = _ref6[i]; + if (i) { + tests.push(this.makeCode(cnj)); + } + tests = tests.concat((i ? ref : sub), this.makeCode(cmp), item.compileToFragments(o, LEVEL_ACCESS)); + } + if (o.level < LEVEL_OP) { + return tests; + } else { + return this.wrapInBraces(tests); + } + }; + + In.prototype.compileLoopTest = function(o) { + var fragments, ref, sub, _ref4; + _ref4 = this.object.cache(o, LEVEL_LIST), sub = _ref4[0], ref = _ref4[1]; + fragments = [].concat(this.makeCode(utility('indexOf') + ".call("), this.array.compileToFragments(o, LEVEL_LIST), this.makeCode(", "), ref, this.makeCode(") " + (this.negated ? '< 0' : '>= 0'))); + if (fragmentsToText(sub) === fragmentsToText(ref)) { + return fragments; + } + fragments = sub.concat(this.makeCode(', '), fragments); + if (o.level < LEVEL_LIST) { + return fragments; + } else { + return this.wrapInBraces(fragments); + } + }; + + In.prototype.toString = function(idt) { + return In.__super__.toString.call(this, idt, this.constructor.name + (this.negated ? '!' : '')); + }; + + return In; + + })(Base); + + exports.Try = Try = (function(_super) { + __extends(Try, _super); + + function Try(attempt, errorVariable, recovery, ensure) { + this.attempt = attempt; + this.errorVariable = errorVariable; + this.recovery = recovery; + this.ensure = ensure; + } + + Try.prototype.children = ['attempt', 'recovery', 'ensure']; + + Try.prototype.isStatement = YES; + + Try.prototype.jumps = function(o) { + var _ref4; + return this.attempt.jumps(o) || ((_ref4 = this.recovery) != null ? _ref4.jumps(o) : void 0); + }; + + Try.prototype.makeReturn = function(res) { + if (this.attempt) { + this.attempt = this.attempt.makeReturn(res); + } + if (this.recovery) { + this.recovery = this.recovery.makeReturn(res); + } + return this; + }; + + Try.prototype.compileNode = function(o) { + var catchPart, ensurePart, placeholder, tryPart; + o.indent += TAB; + tryPart = this.attempt.compileToFragments(o, LEVEL_TOP); + catchPart = this.recovery ? (placeholder = new Literal('_error'), this.errorVariable ? this.recovery.unshift(new Assign(this.errorVariable, placeholder)) : void 0, [].concat(this.makeCode(" catch ("), placeholder.compileToFragments(o), this.makeCode(") {\n"), this.recovery.compileToFragments(o, LEVEL_TOP), this.makeCode("\n" + this.tab + "}"))) : !(this.ensure || this.recovery) ? [this.makeCode(' catch (_error) {}')] : []; + ensurePart = this.ensure ? [].concat(this.makeCode(" finally {\n"), this.ensure.compileToFragments(o, LEVEL_TOP), this.makeCode("\n" + this.tab + "}")) : []; + return [].concat(this.makeCode("" + this.tab + "try {\n"), tryPart, this.makeCode("\n" + this.tab + "}"), catchPart, ensurePart); + }; + + return Try; + + })(Base); + + exports.Throw = Throw = (function(_super) { + __extends(Throw, _super); + + function Throw(expression) { + this.expression = expression; + } + + Throw.prototype.children = ['expression']; + + Throw.prototype.isStatement = YES; + + Throw.prototype.jumps = NO; + + Throw.prototype.makeReturn = THIS; + + Throw.prototype.compileNode = function(o) { + return [].concat(this.makeCode(this.tab + "throw "), this.expression.compileToFragments(o), this.makeCode(";")); + }; + + return Throw; + + })(Base); + + exports.Existence = Existence = (function(_super) { + __extends(Existence, _super); + + function Existence(expression) { + this.expression = expression; + } + + Existence.prototype.children = ['expression']; + + Existence.prototype.invert = NEGATE; + + Existence.prototype.compileNode = function(o) { + var cmp, cnj, code, _ref4; + this.expression.front = this.front; + code = this.expression.compile(o, LEVEL_OP); + if (IDENTIFIER.test(code) && !o.scope.check(code)) { + _ref4 = this.negated ? ['===', '||'] : ['!==', '&&'], cmp = _ref4[0], cnj = _ref4[1]; + code = "typeof " + code + " " + cmp + " \"undefined\" " + cnj + " " + code + " " + cmp + " null"; + } else { + code = "" + code + " " + (this.negated ? '==' : '!=') + " null"; + } + return [this.makeCode(o.level <= LEVEL_COND ? code : "(" + code + ")")]; + }; + + return Existence; + + })(Base); + + exports.Parens = Parens = (function(_super) { + __extends(Parens, _super); + + function Parens(body) { + this.body = body; + } + + Parens.prototype.children = ['body']; + + Parens.prototype.unwrap = function() { + return this.body; + }; + + Parens.prototype.isComplex = function() { + return this.body.isComplex(); + }; + + Parens.prototype.compileNode = function(o) { + var bare, expr, fragments; + expr = this.body.unwrap(); + if (expr instanceof Value && expr.isAtomic()) { + expr.front = this.front; + return expr.compileToFragments(o); + } + fragments = expr.compileToFragments(o, LEVEL_PAREN); + bare = o.level < LEVEL_OP && (expr instanceof Op || expr instanceof Call || (expr instanceof For && expr.returns)); + if (bare) { + return fragments; + } else { + return this.wrapInBraces(fragments); + } + }; + + return Parens; + + })(Base); + + exports.For = For = (function(_super) { + __extends(For, _super); + + function For(body, source) { + var _ref4; + this.source = source.source, this.guard = source.guard, this.step = source.step, this.name = source.name, this.index = source.index; + this.body = Block.wrap([body]); + this.own = !!source.own; + this.object = !!source.object; + if (this.object) { + _ref4 = [this.index, this.name], this.name = _ref4[0], this.index = _ref4[1]; + } + if (this.index instanceof Value) { + this.index.error('index cannot be a pattern matching expression'); + } + this.range = this.source instanceof Value && this.source.base instanceof Range && !this.source.properties.length; + this.pattern = this.name instanceof Value; + if (this.range && this.index) { + this.index.error('indexes do not apply to range loops'); + } + if (this.range && this.pattern) { + this.name.error('cannot pattern match over range loops'); + } + if (this.own && !this.object) { + this.index.error('cannot use own with for-in'); + } + this.returns = false; + } + + For.prototype.children = ['body', 'source', 'guard', 'step']; + + For.prototype.compileNode = function(o) { + var body, bodyFragments, compare, compareDown, declare, declareDown, defPart, defPartFragments, down, forPartFragments, guardPart, idt1, increment, index, ivar, kvar, kvarAssign, lastJumps, lvar, name, namePart, ref, resultPart, returnResult, rvar, scope, source, step, stepNum, stepVar, svar, varPart, _ref4, _ref5; + body = Block.wrap([this.body]); + lastJumps = (_ref4 = last(body.expressions)) != null ? _ref4.jumps() : void 0; + if (lastJumps && lastJumps instanceof Return) { + this.returns = false; + } + source = this.range ? this.source.base : this.source; + scope = o.scope; + name = this.name && (this.name.compile(o, LEVEL_LIST)); + index = this.index && (this.index.compile(o, LEVEL_LIST)); + if (name && !this.pattern) { + scope.find(name); + } + if (index) { + scope.find(index); + } + if (this.returns) { + rvar = scope.freeVariable('results'); + } + ivar = (this.object && index) || scope.freeVariable('i'); + kvar = (this.range && name) || index || ivar; + kvarAssign = kvar !== ivar ? "" + kvar + " = " : ""; + if (this.step && !this.range) { + _ref5 = this.cacheToCodeFragments(this.step.cache(o, LEVEL_LIST)), step = _ref5[0], stepVar = _ref5[1]; + stepNum = stepVar.match(SIMPLENUM); + } + if (this.pattern) { + name = ivar; + } + varPart = ''; + guardPart = ''; + defPart = ''; + idt1 = this.tab + TAB; + if (this.range) { + forPartFragments = source.compileToFragments(merge(o, { + index: ivar, + name: name, + step: this.step + })); + } else { + svar = this.source.compile(o, LEVEL_LIST); + if ((name || this.own) && !IDENTIFIER.test(svar)) { + defPart += "" + this.tab + (ref = scope.freeVariable('ref')) + " = " + svar + ";\n"; + svar = ref; + } + if (name && !this.pattern) { + namePart = "" + name + " = " + svar + "[" + kvar + "]"; + } + if (!this.object) { + if (step !== stepVar) { + defPart += "" + this.tab + step + ";\n"; + } + if (!(this.step && stepNum && (down = +stepNum < 0))) { + lvar = scope.freeVariable('len'); + } + declare = "" + kvarAssign + ivar + " = 0, " + lvar + " = " + svar + ".length"; + declareDown = "" + kvarAssign + ivar + " = " + svar + ".length - 1"; + compare = "" + ivar + " < " + lvar; + compareDown = "" + ivar + " >= 0"; + if (this.step) { + if (stepNum) { + if (down) { + compare = compareDown; + declare = declareDown; + } + } else { + compare = "" + stepVar + " > 0 ? " + compare + " : " + compareDown; + declare = "(" + stepVar + " > 0 ? (" + declare + ") : " + declareDown + ")"; + } + increment = "" + ivar + " += " + stepVar; + } else { + increment = "" + (kvar !== ivar ? "++" + ivar : "" + ivar + "++"); + } + forPartFragments = [this.makeCode("" + declare + "; " + compare + "; " + kvarAssign + increment)]; + } + } + if (this.returns) { + resultPart = "" + this.tab + rvar + " = [];\n"; + returnResult = "\n" + this.tab + "return " + rvar + ";"; + body.makeReturn(rvar); + } + if (this.guard) { + if (body.expressions.length > 1) { + body.expressions.unshift(new If((new Parens(this.guard)).invert(), new Literal("continue"))); + } else { + if (this.guard) { + body = Block.wrap([new If(this.guard, body)]); + } + } + } + if (this.pattern) { + body.expressions.unshift(new Assign(this.name, new Literal("" + svar + "[" + kvar + "]"))); + } + defPartFragments = [].concat(this.makeCode(defPart), this.pluckDirectCall(o, body)); + if (namePart) { + varPart = "\n" + idt1 + namePart + ";"; + } + if (this.object) { + forPartFragments = [this.makeCode("" + kvar + " in " + svar)]; + if (this.own) { + guardPart = "\n" + idt1 + "if (!" + (utility('hasProp')) + ".call(" + svar + ", " + kvar + ")) continue;"; + } + } + bodyFragments = body.compileToFragments(merge(o, { + indent: idt1 + }), LEVEL_TOP); + if (bodyFragments && (bodyFragments.length > 0)) { + bodyFragments = [].concat(this.makeCode("\n"), bodyFragments, this.makeCode("\n")); + } + return [].concat(defPartFragments, this.makeCode("" + (resultPart || '') + this.tab + "for ("), forPartFragments, this.makeCode(") {" + guardPart + varPart), bodyFragments, this.makeCode("" + this.tab + "}" + (returnResult || ''))); + }; + + For.prototype.pluckDirectCall = function(o, body) { + var base, defs, expr, fn, idx, ref, val, _i, _len, _ref4, _ref5, _ref6, _ref7, _ref8, _ref9; + defs = []; + _ref4 = body.expressions; + for (idx = _i = 0, _len = _ref4.length; _i < _len; idx = ++_i) { + expr = _ref4[idx]; + expr = expr.unwrapAll(); + if (!(expr instanceof Call)) { + continue; + } + val = expr.variable.unwrapAll(); + if (!((val instanceof Code) || (val instanceof Value && ((_ref5 = val.base) != null ? _ref5.unwrapAll() : void 0) instanceof Code && val.properties.length === 1 && ((_ref6 = (_ref7 = val.properties[0].name) != null ? _ref7.value : void 0) === 'call' || _ref6 === 'apply')))) { + continue; + } + fn = ((_ref8 = val.base) != null ? _ref8.unwrapAll() : void 0) || val; + ref = new Literal(o.scope.freeVariable('fn')); + base = new Value(ref); + if (val.base) { + _ref9 = [base, val], val.base = _ref9[0], base = _ref9[1]; + } + body.expressions[idx] = new Call(base, expr.args); + defs = defs.concat(this.makeCode(this.tab), new Assign(ref, fn).compileToFragments(o, LEVEL_TOP), this.makeCode(';\n')); + } + return defs; + }; + + return For; + + })(While); + + exports.Switch = Switch = (function(_super) { + __extends(Switch, _super); + + function Switch(subject, cases, otherwise) { + this.subject = subject; + this.cases = cases; + this.otherwise = otherwise; + } + + Switch.prototype.children = ['subject', 'cases', 'otherwise']; + + Switch.prototype.isStatement = YES; + + Switch.prototype.jumps = function(o) { + var block, conds, _i, _len, _ref4, _ref5, _ref6; + if (o == null) { + o = { + block: true + }; + } + _ref4 = this.cases; + for (_i = 0, _len = _ref4.length; _i < _len; _i++) { + _ref5 = _ref4[_i], conds = _ref5[0], block = _ref5[1]; + if (block.jumps(o)) { + return block; + } + } + return (_ref6 = this.otherwise) != null ? _ref6.jumps(o) : void 0; + }; + + Switch.prototype.makeReturn = function(res) { + var pair, _i, _len, _ref4, _ref5; + _ref4 = this.cases; + for (_i = 0, _len = _ref4.length; _i < _len; _i++) { + pair = _ref4[_i]; + pair[1].makeReturn(res); + } + if (res) { + this.otherwise || (this.otherwise = new Block([new Literal('void 0')])); + } + if ((_ref5 = this.otherwise) != null) { + _ref5.makeReturn(res); + } + return this; + }; + + Switch.prototype.compileNode = function(o) { + var block, body, cond, conditions, expr, fragments, i, idt1, idt2, _i, _j, _len, _len1, _ref4, _ref5, _ref6; + idt1 = o.indent + TAB; + idt2 = o.indent = idt1 + TAB; + fragments = [].concat(this.makeCode(this.tab + "switch ("), (this.subject ? this.subject.compileToFragments(o, LEVEL_PAREN) : this.makeCode("false")), this.makeCode(") {\n")); + _ref4 = this.cases; + for (i = _i = 0, _len = _ref4.length; _i < _len; i = ++_i) { + _ref5 = _ref4[i], conditions = _ref5[0], block = _ref5[1]; + _ref6 = flatten([conditions]); + for (_j = 0, _len1 = _ref6.length; _j < _len1; _j++) { + cond = _ref6[_j]; + if (!this.subject) { + cond = cond.invert(); + } + fragments = fragments.concat(this.makeCode(idt1 + "case "), cond.compileToFragments(o, LEVEL_PAREN), this.makeCode(":\n")); + } + if ((body = block.compileToFragments(o, LEVEL_TOP)).length > 0) { + fragments = fragments.concat(body, this.makeCode('\n')); + } + if (i === this.cases.length - 1 && !this.otherwise) { + break; + } + expr = this.lastNonComment(block.expressions); + if (expr instanceof Return || (expr instanceof Literal && expr.jumps() && expr.value !== 'debugger')) { + continue; + } + fragments.push(cond.makeCode(idt2 + 'break;\n')); + } + if (this.otherwise && this.otherwise.expressions.length) { + fragments.push.apply(fragments, [this.makeCode(idt1 + "default:\n")].concat(__slice.call(this.otherwise.compileToFragments(o, LEVEL_TOP)), [this.makeCode("\n")])); + } + fragments.push(this.makeCode(this.tab + '}')); + return fragments; + }; + + return Switch; + + })(Base); + + exports.If = If = (function(_super) { + __extends(If, _super); + + function If(condition, body, options) { + this.body = body; + if (options == null) { + options = {}; + } + this.condition = options.type === 'unless' ? condition.invert() : condition; + this.elseBody = null; + this.isChain = false; + this.soak = options.soak; + } + + If.prototype.children = ['condition', 'body', 'elseBody']; + + If.prototype.bodyNode = function() { + var _ref4; + return (_ref4 = this.body) != null ? _ref4.unwrap() : void 0; + }; + + If.prototype.elseBodyNode = function() { + var _ref4; + return (_ref4 = this.elseBody) != null ? _ref4.unwrap() : void 0; + }; + + If.prototype.addElse = function(elseBody) { + if (this.isChain) { + this.elseBodyNode().addElse(elseBody); + } else { + this.isChain = elseBody instanceof If; + this.elseBody = this.ensureBlock(elseBody); + this.elseBody.updateLocationDataIfMissing(elseBody.locationData); + } + return this; + }; + + If.prototype.isStatement = function(o) { + var _ref4; + return (o != null ? o.level : void 0) === LEVEL_TOP || this.bodyNode().isStatement(o) || ((_ref4 = this.elseBodyNode()) != null ? _ref4.isStatement(o) : void 0); + }; + + If.prototype.jumps = function(o) { + var _ref4; + return this.body.jumps(o) || ((_ref4 = this.elseBody) != null ? _ref4.jumps(o) : void 0); + }; + + If.prototype.compileNode = function(o) { + if (this.isStatement(o)) { + return this.compileStatement(o); + } else { + return this.compileExpression(o); + } + }; + + If.prototype.makeReturn = function(res) { + if (res) { + this.elseBody || (this.elseBody = new Block([new Literal('void 0')])); + } + this.body && (this.body = new Block([this.body.makeReturn(res)])); + this.elseBody && (this.elseBody = new Block([this.elseBody.makeReturn(res)])); + return this; + }; + + If.prototype.ensureBlock = function(node) { + if (node instanceof Block) { + return node; + } else { + return new Block([node]); + } + }; + + If.prototype.compileStatement = function(o) { + var answer, body, child, cond, exeq, ifPart, indent; + child = del(o, 'chainChild'); + exeq = del(o, 'isExistentialEquals'); + if (exeq) { + return new If(this.condition.invert(), this.elseBodyNode(), { + type: 'if' + }).compileToFragments(o); + } + indent = o.indent + TAB; + cond = this.condition.compileToFragments(o, LEVEL_PAREN); + body = this.ensureBlock(this.body).compileToFragments(merge(o, { + indent: indent + })); + ifPart = [].concat(this.makeCode("if ("), cond, this.makeCode(") {\n"), body, this.makeCode("\n" + this.tab + "}")); + if (!child) { + ifPart.unshift(this.makeCode(this.tab)); + } + if (!this.elseBody) { + return ifPart; + } + answer = ifPart.concat(this.makeCode(' else ')); + if (this.isChain) { + o.chainChild = true; + answer = answer.concat(this.elseBody.unwrap().compileToFragments(o, LEVEL_TOP)); + } else { + answer = answer.concat(this.makeCode("{\n"), this.elseBody.compileToFragments(merge(o, { + indent: indent + }), LEVEL_TOP), this.makeCode("\n" + this.tab + "}")); + } + return answer; + }; + + If.prototype.compileExpression = function(o) { + var alt, body, cond, fragments; + cond = this.condition.compileToFragments(o, LEVEL_COND); + body = this.bodyNode().compileToFragments(o, LEVEL_LIST); + alt = this.elseBodyNode() ? this.elseBodyNode().compileToFragments(o, LEVEL_LIST) : [this.makeCode('void 0')]; + fragments = cond.concat(this.makeCode(" ? "), body, this.makeCode(" : "), alt); + if (o.level >= LEVEL_COND) { + return this.wrapInBraces(fragments); + } else { + return fragments; + } + }; + + If.prototype.unfoldSoak = function() { + return this.soak && this; + }; + + return If; + + })(Base); + + Closure = { + wrap: function(expressions, statement, noReturn) { + var args, argumentsNode, call, func, meth; + if (expressions.jumps()) { + return expressions; + } + func = new Code([], Block.wrap([expressions])); + args = []; + argumentsNode = expressions.contains(this.isLiteralArguments); + if (argumentsNode && expressions.classBody) { + argumentsNode.error("Class bodies shouldn't reference arguments"); + } + if (argumentsNode || expressions.contains(this.isLiteralThis)) { + meth = new Literal(argumentsNode ? 'apply' : 'call'); + args = [new Literal('this')]; + if (argumentsNode) { + args.push(new Literal('arguments')); + } + func = new Value(func, [new Access(meth)]); + } + func.noReturn = noReturn; + call = new Call(func, args); + if (statement) { + return Block.wrap([call]); + } else { + return call; + } + }, + isLiteralArguments: function(node) { + return node instanceof Literal && node.value === 'arguments' && !node.asKey; + }, + isLiteralThis: function(node) { + return (node instanceof Literal && node.value === 'this' && !node.asKey) || (node instanceof Code && node.bound) || (node instanceof Call && node.isSuper); + } + }; + + unfoldSoak = function(o, parent, name) { + var ifn; + if (!(ifn = parent[name].unfoldSoak(o))) { + return; + } + parent[name] = ifn.body; + ifn.body = new Value(parent); + return ifn; + }; + + UTILITIES = { + "extends": function() { + return "function(child, parent) { for (var key in parent) { if (" + (utility('hasProp')) + ".call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }"; + }, + bind: function() { + return 'function(fn, me){ return function(){ return fn.apply(me, arguments); }; }'; + }, + indexOf: function() { + return "[].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }"; + }, + hasProp: function() { + return '{}.hasOwnProperty'; + }, + slice: function() { + return '[].slice'; + } + }; + + LEVEL_TOP = 1; + + LEVEL_PAREN = 2; + + LEVEL_LIST = 3; + + LEVEL_COND = 4; + + LEVEL_OP = 5; + + LEVEL_ACCESS = 6; + + TAB = ' '; + + IDENTIFIER_STR = "[$A-Za-z_\\x7f-\\uffff][$\\w\\x7f-\\uffff]*"; + + IDENTIFIER = RegExp("^" + IDENTIFIER_STR + "$"); + + SIMPLENUM = /^[+-]?\d+$/; + + METHOD_DEF = RegExp("^(?:(" + IDENTIFIER_STR + ")\\.prototype(?:\\.(" + IDENTIFIER_STR + ")|\\[(\"(?:[^\\\\\"\\r\\n]|\\\\.)*\"|'(?:[^\\\\'\\r\\n]|\\\\.)*')\\]|\\[(0x[\\da-fA-F]+|\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)\\]))|(" + IDENTIFIER_STR + ")$"); + + IS_STRING = /^['"]/; + + utility = function(name) { + var ref; + ref = "__" + name; + Scope.root.assign(ref, UTILITIES[name]()); + return ref; + }; + + multident = function(code, tab) { + code = code.replace(/\n/g, '$&' + tab); + return code.replace(/\s+$/, ''); + }; + + +}); + +ace.define('ace/mode/coffee/scope', ['require', 'exports', 'module' , 'ace/mode/coffee/helpers'], function(require, exports, module) { + + var Scope, extend, last, _ref; + + _ref = require('./helpers'), extend = _ref.extend, last = _ref.last; + + exports.Scope = Scope = (function() { + Scope.root = null; + + function Scope(parent, expressions, method) { + this.parent = parent; + this.expressions = expressions; + this.method = method; + this.variables = [ + { + name: 'arguments', + type: 'arguments' + } + ]; + this.positions = {}; + if (!this.parent) { + Scope.root = this; + } + } + + Scope.prototype.add = function(name, type, immediate) { + if (this.shared && !immediate) { + return this.parent.add(name, type, immediate); + } + if (Object.prototype.hasOwnProperty.call(this.positions, name)) { + return this.variables[this.positions[name]].type = type; + } else { + return this.positions[name] = this.variables.push({ + name: name, + type: type + }) - 1; + } + }; + + Scope.prototype.namedMethod = function() { + var _ref1; + if (((_ref1 = this.method) != null ? _ref1.name : void 0) || !this.parent) { + return this.method; + } + return this.parent.namedMethod(); + }; + + Scope.prototype.find = function(name) { + if (this.check(name)) { + return true; + } + this.add(name, 'var'); + return false; + }; + + Scope.prototype.parameter = function(name) { + if (this.shared && this.parent.check(name, true)) { + return; + } + return this.add(name, 'param'); + }; + + Scope.prototype.check = function(name) { + var _ref1; + return !!(this.type(name) || ((_ref1 = this.parent) != null ? _ref1.check(name) : void 0)); + }; + + Scope.prototype.temporary = function(name, index) { + if (name.length > 1) { + return '_' + name + (index > 1 ? index - 1 : ''); + } else { + return '_' + (index + parseInt(name, 36)).toString(36).replace(/\d/g, 'a'); + } + }; + + Scope.prototype.type = function(name) { + var v, _i, _len, _ref1; + _ref1 = this.variables; + for (_i = 0, _len = _ref1.length; _i < _len; _i++) { + v = _ref1[_i]; + if (v.name === name) { + return v.type; + } + } + return null; + }; + + Scope.prototype.freeVariable = function(name, reserve) { + var index, temp; + if (reserve == null) { + reserve = true; + } + index = 0; + while (this.check((temp = this.temporary(name, index)))) { + index++; + } + if (reserve) { + this.add(temp, 'var', true); + } + return temp; + }; + + Scope.prototype.assign = function(name, value) { + this.add(name, { + value: value, + assigned: true + }, true); + return this.hasAssignments = true; + }; + + Scope.prototype.hasDeclarations = function() { + return !!this.declaredVariables().length; + }; + + Scope.prototype.declaredVariables = function() { + var realVars, tempVars, v, _i, _len, _ref1; + realVars = []; + tempVars = []; + _ref1 = this.variables; + for (_i = 0, _len = _ref1.length; _i < _len; _i++) { + v = _ref1[_i]; + if (v.type === 'var') { + (v.name.charAt(0) === '_' ? tempVars : realVars).push(v.name); + } + } + return realVars.sort().concat(tempVars.sort()); + }; + + Scope.prototype.assignedVariables = function() { + var v, _i, _len, _ref1, _results; + _ref1 = this.variables; + _results = []; + for (_i = 0, _len = _ref1.length; _i < _len; _i++) { + v = _ref1[_i]; + if (v.type.assigned) { + _results.push("" + v.name + " = " + v.type.value); + } + } + return _results; + }; + + return Scope; + + })(); + + +}); \ No newline at end of file diff --git a/lib/client/edit/worker-css.js b/lib/client/edit/worker-css.js new file mode 100644 index 00000000..94c850a0 --- /dev/null +++ b/lib/client/edit/worker-css.js @@ -0,0 +1,8256 @@ +"no use strict"; +;(function(window) { +if (typeof window.window != "undefined" && window.document) { + return; +} + +window.console = function() { + var msgs = Array.prototype.slice.call(arguments, 0); + postMessage({type: "log", data: msgs}); +}; +window.console.error = +window.console.warn = +window.console.log = +window.console.trace = window.console; + +window.window = window; +window.ace = window; + +window.normalizeModule = function(parentId, moduleName) { + if (moduleName.indexOf("!") !== -1) { + var chunks = moduleName.split("!"); + return window.normalizeModule(parentId, chunks[0]) + "!" + window.normalizeModule(parentId, chunks[1]); + } + if (moduleName.charAt(0) == ".") { + var base = parentId.split("/").slice(0, -1).join("/"); + moduleName = (base ? base + "/" : "") + moduleName; + + while(moduleName.indexOf(".") !== -1 && previous != moduleName) { + var previous = moduleName; + moduleName = moduleName.replace(/^\.\//, "").replace(/\/\.\//, "/").replace(/[^\/]+\/\.\.\//, ""); + } + } + + return moduleName; +}; + +window.require = function(parentId, id) { + if (!id) { + id = parentId + parentId = null; + } + if (!id.charAt) + throw new Error("worker.js require() accepts only (parentId, id) as arguments"); + + id = window.normalizeModule(parentId, id); + + var module = window.require.modules[id]; + if (module) { + if (!module.initialized) { + module.initialized = true; + module.exports = module.factory().exports; + } + return module.exports; + } + + var chunks = id.split("/"); + if (!window.require.tlns) + return console.log("unable to load " + id); + chunks[0] = window.require.tlns[chunks[0]] || chunks[0]; + var path = chunks.join("/") + ".js"; + + window.require.id = id; + importScripts(path); + return window.require(parentId, id); +}; +window.require.modules = {}; +window.require.tlns = {}; + +window.define = function(id, deps, factory) { + if (arguments.length == 2) { + factory = deps; + if (typeof id != "string") { + deps = id; + id = window.require.id; + } + } else if (arguments.length == 1) { + factory = id; + deps = [] + id = window.require.id; + } + + if (!deps.length) + deps = ['require', 'exports', 'module'] + + if (id.indexOf("text!") === 0) + return; + + var req = function(childId) { + return window.require(id, childId); + }; + + window.require.modules[id] = { + exports: {}, + factory: function() { + var module = this; + var returnExports = factory.apply(this, deps.map(function(dep) { + switch(dep) { + case 'require': return req + case 'exports': return module.exports + case 'module': return module + default: return req(dep) + } + })); + if (returnExports) + module.exports = returnExports; + return module; + } + }; +}; +window.define.amd = {} + +window.initBaseUrls = function initBaseUrls(topLevelNamespaces) { + require.tlns = topLevelNamespaces; +} + +window.initSender = function initSender() { + + var EventEmitter = window.require("ace/lib/event_emitter").EventEmitter; + var oop = window.require("ace/lib/oop"); + + var Sender = function() {}; + + (function() { + + oop.implement(this, EventEmitter); + + this.callback = function(data, callbackId) { + postMessage({ + type: "call", + id: callbackId, + data: data + }); + }; + + this.emit = function(name, data) { + postMessage({ + type: "event", + name: name, + data: data + }); + }; + + }).call(Sender.prototype); + + return new Sender(); +} + +window.main = null; +window.sender = null; + +window.onmessage = function(e) { + var msg = e.data; + if (msg.command) { + if (main[msg.command]) + main[msg.command].apply(main, msg.args); + else + throw new Error("Unknown command:" + msg.command); + } + else if (msg.init) { + initBaseUrls(msg.tlns); + require("ace/lib/es5-shim"); + sender = initSender(); + var clazz = require(msg.module)[msg.classname]; + main = new clazz(sender); + } + else if (msg.event && sender) { + sender._emit(msg.event, msg.data); + } +}; +})(this);// https://github.com/kriskowal/es5-shim + +ace.define('ace/lib/es5-shim', ['require', 'exports', 'module' ], function(require, exports, module) { + +function Empty() {} + +if (!Function.prototype.bind) { + Function.prototype.bind = function bind(that) { // .length is 1 + var target = this; + if (typeof target != "function") { + throw new TypeError("Function.prototype.bind called on incompatible " + target); + } + var args = slice.call(arguments, 1); // for normal call + var bound = function () { + + if (this instanceof bound) { + + var result = target.apply( + this, + args.concat(slice.call(arguments)) + ); + if (Object(result) === result) { + return result; + } + return this; + + } else { + return target.apply( + that, + args.concat(slice.call(arguments)) + ); + + } + + }; + if(target.prototype) { + Empty.prototype = target.prototype; + bound.prototype = new Empty(); + Empty.prototype = null; + } + return bound; + }; +} +var call = Function.prototype.call; +var prototypeOfArray = Array.prototype; +var prototypeOfObject = Object.prototype; +var slice = prototypeOfArray.slice; +var _toString = call.bind(prototypeOfObject.toString); +var owns = call.bind(prototypeOfObject.hasOwnProperty); +var defineGetter; +var defineSetter; +var lookupGetter; +var lookupSetter; +var supportsAccessors; +if ((supportsAccessors = owns(prototypeOfObject, "__defineGetter__"))) { + defineGetter = call.bind(prototypeOfObject.__defineGetter__); + defineSetter = call.bind(prototypeOfObject.__defineSetter__); + lookupGetter = call.bind(prototypeOfObject.__lookupGetter__); + lookupSetter = call.bind(prototypeOfObject.__lookupSetter__); +} +if ([1,2].splice(0).length != 2) { + if(function() { // test IE < 9 to splice bug - see issue #138 + function makeArray(l) { + var a = new Array(l+2); + a[0] = a[1] = 0; + return a; + } + var array = [], lengthBefore; + + array.splice.apply(array, makeArray(20)); + array.splice.apply(array, makeArray(26)); + + lengthBefore = array.length; //46 + array.splice(5, 0, "XXX"); // add one element + + lengthBefore + 1 == array.length + + if (lengthBefore + 1 == array.length) { + return true;// has right splice implementation without bugs + } + }()) {//IE 6/7 + var array_splice = Array.prototype.splice; + Array.prototype.splice = function(start, deleteCount) { + if (!arguments.length) { + return []; + } else { + return array_splice.apply(this, [ + start === void 0 ? 0 : start, + deleteCount === void 0 ? (this.length - start) : deleteCount + ].concat(slice.call(arguments, 2))) + } + }; + } else {//IE8 + Array.prototype.splice = function(pos, removeCount){ + var length = this.length; + if (pos > 0) { + if (pos > length) + pos = length; + } else if (pos == void 0) { + pos = 0; + } else if (pos < 0) { + pos = Math.max(length + pos, 0); + } + + if (!(pos+removeCount < length)) + removeCount = length - pos; + + var removed = this.slice(pos, pos+removeCount); + var insert = slice.call(arguments, 2); + var add = insert.length; + if (pos === length) { + if (add) { + this.push.apply(this, insert); + } + } else { + var remove = Math.min(removeCount, length - pos); + var tailOldPos = pos + remove; + var tailNewPos = tailOldPos + add - remove; + var tailCount = length - tailOldPos; + var lengthAfterRemove = length - remove; + + if (tailNewPos < tailOldPos) { // case A + for (var i = 0; i < tailCount; ++i) { + this[tailNewPos+i] = this[tailOldPos+i]; + } + } else if (tailNewPos > tailOldPos) { // case B + for (i = tailCount; i--; ) { + this[tailNewPos+i] = this[tailOldPos+i]; + } + } // else, add == remove (nothing to do) + + if (add && pos === lengthAfterRemove) { + this.length = lengthAfterRemove; // truncate array + this.push.apply(this, insert); + } else { + this.length = lengthAfterRemove + add; // reserves space + for (i = 0; i < add; ++i) { + this[pos+i] = insert[i]; + } + } + } + return removed; + }; + } +} +if (!Array.isArray) { + Array.isArray = function isArray(obj) { + return _toString(obj) == "[object Array]"; + }; +} +var boxedString = Object("a"), + splitString = boxedString[0] != "a" || !(0 in boxedString); + +if (!Array.prototype.forEach) { + Array.prototype.forEach = function forEach(fun /*, thisp*/) { + var object = toObject(this), + self = splitString && _toString(this) == "[object String]" ? + this.split("") : + object, + thisp = arguments[1], + i = -1, + length = self.length >>> 0; + if (_toString(fun) != "[object Function]") { + throw new TypeError(); // TODO message + } + + while (++i < length) { + if (i in self) { + fun.call(thisp, self[i], i, object); + } + } + }; +} +if (!Array.prototype.map) { + Array.prototype.map = function map(fun /*, thisp*/) { + var object = toObject(this), + self = splitString && _toString(this) == "[object String]" ? + this.split("") : + object, + length = self.length >>> 0, + result = Array(length), + thisp = arguments[1]; + if (_toString(fun) != "[object Function]") { + throw new TypeError(fun + " is not a function"); + } + + for (var i = 0; i < length; i++) { + if (i in self) + result[i] = fun.call(thisp, self[i], i, object); + } + return result; + }; +} +if (!Array.prototype.filter) { + Array.prototype.filter = function filter(fun /*, thisp */) { + var object = toObject(this), + self = splitString && _toString(this) == "[object String]" ? + this.split("") : + object, + length = self.length >>> 0, + result = [], + value, + thisp = arguments[1]; + if (_toString(fun) != "[object Function]") { + throw new TypeError(fun + " is not a function"); + } + + for (var i = 0; i < length; i++) { + if (i in self) { + value = self[i]; + if (fun.call(thisp, value, i, object)) { + result.push(value); + } + } + } + return result; + }; +} +if (!Array.prototype.every) { + Array.prototype.every = function every(fun /*, thisp */) { + var object = toObject(this), + self = splitString && _toString(this) == "[object String]" ? + this.split("") : + object, + length = self.length >>> 0, + thisp = arguments[1]; + if (_toString(fun) != "[object Function]") { + throw new TypeError(fun + " is not a function"); + } + + for (var i = 0; i < length; i++) { + if (i in self && !fun.call(thisp, self[i], i, object)) { + return false; + } + } + return true; + }; +} +if (!Array.prototype.some) { + Array.prototype.some = function some(fun /*, thisp */) { + var object = toObject(this), + self = splitString && _toString(this) == "[object String]" ? + this.split("") : + object, + length = self.length >>> 0, + thisp = arguments[1]; + if (_toString(fun) != "[object Function]") { + throw new TypeError(fun + " is not a function"); + } + + for (var i = 0; i < length; i++) { + if (i in self && fun.call(thisp, self[i], i, object)) { + return true; + } + } + return false; + }; +} +if (!Array.prototype.reduce) { + Array.prototype.reduce = function reduce(fun /*, initial*/) { + var object = toObject(this), + self = splitString && _toString(this) == "[object String]" ? + this.split("") : + object, + length = self.length >>> 0; + if (_toString(fun) != "[object Function]") { + throw new TypeError(fun + " is not a function"); + } + if (!length && arguments.length == 1) { + throw new TypeError("reduce of empty array with no initial value"); + } + + var i = 0; + var result; + if (arguments.length >= 2) { + result = arguments[1]; + } else { + do { + if (i in self) { + result = self[i++]; + break; + } + if (++i >= length) { + throw new TypeError("reduce of empty array with no initial value"); + } + } while (true); + } + + for (; i < length; i++) { + if (i in self) { + result = fun.call(void 0, result, self[i], i, object); + } + } + + return result; + }; +} +if (!Array.prototype.reduceRight) { + Array.prototype.reduceRight = function reduceRight(fun /*, initial*/) { + var object = toObject(this), + self = splitString && _toString(this) == "[object String]" ? + this.split("") : + object, + length = self.length >>> 0; + if (_toString(fun) != "[object Function]") { + throw new TypeError(fun + " is not a function"); + } + if (!length && arguments.length == 1) { + throw new TypeError("reduceRight of empty array with no initial value"); + } + + var result, i = length - 1; + if (arguments.length >= 2) { + result = arguments[1]; + } else { + do { + if (i in self) { + result = self[i--]; + break; + } + if (--i < 0) { + throw new TypeError("reduceRight of empty array with no initial value"); + } + } while (true); + } + + do { + if (i in this) { + result = fun.call(void 0, result, self[i], i, object); + } + } while (i--); + + return result; + }; +} +if (!Array.prototype.indexOf || ([0, 1].indexOf(1, 2) != -1)) { + Array.prototype.indexOf = function indexOf(sought /*, fromIndex */ ) { + var self = splitString && _toString(this) == "[object String]" ? + this.split("") : + toObject(this), + length = self.length >>> 0; + + if (!length) { + return -1; + } + + var i = 0; + if (arguments.length > 1) { + i = toInteger(arguments[1]); + } + i = i >= 0 ? i : Math.max(0, length + i); + for (; i < length; i++) { + if (i in self && self[i] === sought) { + return i; + } + } + return -1; + }; +} +if (!Array.prototype.lastIndexOf || ([0, 1].lastIndexOf(0, -3) != -1)) { + Array.prototype.lastIndexOf = function lastIndexOf(sought /*, fromIndex */) { + var self = splitString && _toString(this) == "[object String]" ? + this.split("") : + toObject(this), + length = self.length >>> 0; + + if (!length) { + return -1; + } + var i = length - 1; + if (arguments.length > 1) { + i = Math.min(i, toInteger(arguments[1])); + } + i = i >= 0 ? i : length - Math.abs(i); + for (; i >= 0; i--) { + if (i in self && sought === self[i]) { + return i; + } + } + return -1; + }; +} +if (!Object.getPrototypeOf) { + Object.getPrototypeOf = function getPrototypeOf(object) { + return object.__proto__ || ( + object.constructor ? + object.constructor.prototype : + prototypeOfObject + ); + }; +} +if (!Object.getOwnPropertyDescriptor) { + var ERR_NON_OBJECT = "Object.getOwnPropertyDescriptor called on a " + + "non-object: "; + Object.getOwnPropertyDescriptor = function getOwnPropertyDescriptor(object, property) { + if ((typeof object != "object" && typeof object != "function") || object === null) + throw new TypeError(ERR_NON_OBJECT + object); + if (!owns(object, property)) + return; + + var descriptor, getter, setter; + descriptor = { enumerable: true, configurable: true }; + if (supportsAccessors) { + var prototype = object.__proto__; + object.__proto__ = prototypeOfObject; + + var getter = lookupGetter(object, property); + var setter = lookupSetter(object, property); + object.__proto__ = prototype; + + if (getter || setter) { + if (getter) descriptor.get = getter; + if (setter) descriptor.set = setter; + return descriptor; + } + } + descriptor.value = object[property]; + return descriptor; + }; +} +if (!Object.getOwnPropertyNames) { + Object.getOwnPropertyNames = function getOwnPropertyNames(object) { + return Object.keys(object); + }; +} +if (!Object.create) { + var createEmpty; + if (Object.prototype.__proto__ === null) { + createEmpty = function () { + return { "__proto__": null }; + }; + } else { + createEmpty = function () { + var empty = {}; + for (var i in empty) + empty[i] = null; + empty.constructor = + empty.hasOwnProperty = + empty.propertyIsEnumerable = + empty.isPrototypeOf = + empty.toLocaleString = + empty.toString = + empty.valueOf = + empty.__proto__ = null; + return empty; + } + } + + Object.create = function create(prototype, properties) { + var object; + if (prototype === null) { + object = createEmpty(); + } else { + if (typeof prototype != "object") + throw new TypeError("typeof prototype["+(typeof prototype)+"] != 'object'"); + var Type = function () {}; + Type.prototype = prototype; + object = new Type(); + object.__proto__ = prototype; + } + if (properties !== void 0) + Object.defineProperties(object, properties); + return object; + }; +} + +function doesDefinePropertyWork(object) { + try { + Object.defineProperty(object, "sentinel", {}); + return "sentinel" in object; + } catch (exception) { + } +} +if (Object.defineProperty) { + var definePropertyWorksOnObject = doesDefinePropertyWork({}); + var definePropertyWorksOnDom = typeof document == "undefined" || + doesDefinePropertyWork(document.createElement("div")); + if (!definePropertyWorksOnObject || !definePropertyWorksOnDom) { + var definePropertyFallback = Object.defineProperty; + } +} + +if (!Object.defineProperty || definePropertyFallback) { + var ERR_NON_OBJECT_DESCRIPTOR = "Property description must be an object: "; + var ERR_NON_OBJECT_TARGET = "Object.defineProperty called on non-object: " + var ERR_ACCESSORS_NOT_SUPPORTED = "getters & setters can not be defined " + + "on this javascript engine"; + + Object.defineProperty = function defineProperty(object, property, descriptor) { + if ((typeof object != "object" && typeof object != "function") || object === null) + throw new TypeError(ERR_NON_OBJECT_TARGET + object); + if ((typeof descriptor != "object" && typeof descriptor != "function") || descriptor === null) + throw new TypeError(ERR_NON_OBJECT_DESCRIPTOR + descriptor); + if (definePropertyFallback) { + try { + return definePropertyFallback.call(Object, object, property, descriptor); + } catch (exception) { + } + } + if (owns(descriptor, "value")) { + + if (supportsAccessors && (lookupGetter(object, property) || + lookupSetter(object, property))) + { + var prototype = object.__proto__; + object.__proto__ = prototypeOfObject; + delete object[property]; + object[property] = descriptor.value; + object.__proto__ = prototype; + } else { + object[property] = descriptor.value; + } + } else { + if (!supportsAccessors) + throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED); + if (owns(descriptor, "get")) + defineGetter(object, property, descriptor.get); + if (owns(descriptor, "set")) + defineSetter(object, property, descriptor.set); + } + + return object; + }; +} +if (!Object.defineProperties) { + Object.defineProperties = function defineProperties(object, properties) { + for (var property in properties) { + if (owns(properties, property)) + Object.defineProperty(object, property, properties[property]); + } + return object; + }; +} +if (!Object.seal) { + Object.seal = function seal(object) { + return object; + }; +} +if (!Object.freeze) { + Object.freeze = function freeze(object) { + return object; + }; +} +try { + Object.freeze(function () {}); +} catch (exception) { + Object.freeze = (function freeze(freezeObject) { + return function freeze(object) { + if (typeof object == "function") { + return object; + } else { + return freezeObject(object); + } + }; + })(Object.freeze); +} +if (!Object.preventExtensions) { + Object.preventExtensions = function preventExtensions(object) { + return object; + }; +} +if (!Object.isSealed) { + Object.isSealed = function isSealed(object) { + return false; + }; +} +if (!Object.isFrozen) { + Object.isFrozen = function isFrozen(object) { + return false; + }; +} +if (!Object.isExtensible) { + Object.isExtensible = function isExtensible(object) { + if (Object(object) === object) { + throw new TypeError(); // TODO message + } + var name = ''; + while (owns(object, name)) { + name += '?'; + } + object[name] = true; + var returnValue = owns(object, name); + delete object[name]; + return returnValue; + }; +} +if (!Object.keys) { + var hasDontEnumBug = true, + dontEnums = [ + "toString", + "toLocaleString", + "valueOf", + "hasOwnProperty", + "isPrototypeOf", + "propertyIsEnumerable", + "constructor" + ], + dontEnumsLength = dontEnums.length; + + for (var key in {"toString": null}) { + hasDontEnumBug = false; + } + + Object.keys = function keys(object) { + + if ( + (typeof object != "object" && typeof object != "function") || + object === null + ) { + throw new TypeError("Object.keys called on a non-object"); + } + + var keys = []; + for (var name in object) { + if (owns(object, name)) { + keys.push(name); + } + } + + if (hasDontEnumBug) { + for (var i = 0, ii = dontEnumsLength; i < ii; i++) { + var dontEnum = dontEnums[i]; + if (owns(object, dontEnum)) { + keys.push(dontEnum); + } + } + } + return keys; + }; + +} +if (!Date.now) { + Date.now = function now() { + return new Date().getTime(); + }; +} +var ws = "\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003" + + "\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028" + + "\u2029\uFEFF"; +if (!String.prototype.trim || ws.trim()) { + ws = "[" + ws + "]"; + var trimBeginRegexp = new RegExp("^" + ws + ws + "*"), + trimEndRegexp = new RegExp(ws + ws + "*$"); + String.prototype.trim = function trim() { + return String(this).replace(trimBeginRegexp, "").replace(trimEndRegexp, ""); + }; +} + +function toInteger(n) { + n = +n; + if (n !== n) { // isNaN + n = 0; + } else if (n !== 0 && n !== (1/0) && n !== -(1/0)) { + n = (n > 0 || -1) * Math.floor(Math.abs(n)); + } + return n; +} + +function isPrimitive(input) { + var type = typeof input; + return ( + input === null || + type === "undefined" || + type === "boolean" || + type === "number" || + type === "string" + ); +} + +function toPrimitive(input) { + var val, valueOf, toString; + if (isPrimitive(input)) { + return input; + } + valueOf = input.valueOf; + if (typeof valueOf === "function") { + val = valueOf.call(input); + if (isPrimitive(val)) { + return val; + } + } + toString = input.toString; + if (typeof toString === "function") { + val = toString.call(input); + if (isPrimitive(val)) { + return val; + } + } + throw new TypeError(); +} +var toObject = function (o) { + if (o == null) { // this matches both null and undefined + throw new TypeError("can't convert "+o+" to object"); + } + return Object(o); +}; + +}); + +ace.define('ace/mode/css_worker', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/lang', 'ace/worker/mirror', 'ace/mode/css/csslint'], function(require, exports, module) { + + +var oop = require("../lib/oop"); +var lang = require("../lib/lang"); +var Mirror = require("../worker/mirror").Mirror; +var CSSLint = require("./css/csslint").CSSLint; + +var Worker = exports.Worker = function(sender) { + Mirror.call(this, sender); + this.setTimeout(400); + this.ruleset = null; + this.setDisabledRules("ids"); + this.setInfoRules("adjoining-classes|qualified-headings|zero-units|gradients|import|outline-none"); +}; + +oop.inherits(Worker, Mirror); + +(function() { + this.setInfoRules = function(ruleNames) { + if (typeof ruleNames == "string") + ruleNames = ruleNames.split("|"); + this.infoRules = lang.arrayToMap(ruleNames); + this.doc.getValue() && this.deferredUpdate.schedule(100); + }; + + this.setDisabledRules = function(ruleNames) { + if (!ruleNames) { + this.ruleset = null; + } else { + if (typeof ruleNames == "string") + ruleNames = ruleNames.split("|"); + var all = {}; + + CSSLint.getRules().forEach(function(x){ + all[x.id] = true; + }); + ruleNames.forEach(function(x) { + delete all[x]; + }); + + this.ruleset = all; + } + this.doc.getValue() && this.deferredUpdate.schedule(100); + }; + + this.onUpdate = function() { + var value = this.doc.getValue(); + var infoRules = this.infoRules; + + var result = CSSLint.verify(value, this.ruleset); + this.sender.emit("csslint", result.messages.map(function(msg) { + return { + row: msg.line - 1, + column: msg.col - 1, + text: msg.message, + type: infoRules[msg.rule.id] ? "info" : msg.type, + rule: msg.rule.name + } + })); + }; + +}).call(Worker.prototype); + +}); + +ace.define('ace/lib/oop', ['require', 'exports', 'module' ], function(require, exports, module) { + + +exports.inherits = (function() { + var tempCtor = function() {}; + return function(ctor, superCtor) { + tempCtor.prototype = superCtor.prototype; + ctor.super_ = superCtor.prototype; + ctor.prototype = new tempCtor(); + ctor.prototype.constructor = ctor; + }; +}()); + +exports.mixin = function(obj, mixin) { + for (var key in mixin) { + obj[key] = mixin[key]; + } + return obj; +}; + +exports.implement = function(proto, mixin) { + exports.mixin(proto, mixin); +}; + +}); + +ace.define('ace/lib/lang', ['require', 'exports', 'module' ], function(require, exports, module) { + + +exports.stringReverse = function(string) { + return string.split("").reverse().join(""); +}; + +exports.stringRepeat = function (string, count) { + var result = ''; + while (count > 0) { + if (count & 1) + result += string; + + if (count >>= 1) + string += string; + } + return result; +}; + +var trimBeginRegexp = /^\s\s*/; +var trimEndRegexp = /\s\s*$/; + +exports.stringTrimLeft = function (string) { + return string.replace(trimBeginRegexp, ''); +}; + +exports.stringTrimRight = function (string) { + return string.replace(trimEndRegexp, ''); +}; + +exports.copyObject = function(obj) { + var copy = {}; + for (var key in obj) { + copy[key] = obj[key]; + } + return copy; +}; + +exports.copyArray = function(array){ + var copy = []; + for (var i=0, l=array.length; i= length) { + position.row = Math.max(0, length - 1); + position.column = this.getLine(length-1).length; + } else if (position.row < 0) + position.row = 0; + return position; + }; + this.insert = function(position, text) { + if (!text || text.length === 0) + return position; + + position = this.$clipPosition(position); + if (this.getLength() <= 1) + this.$detectNewLine(text); + + var lines = this.$split(text); + var firstLine = lines.splice(0, 1)[0]; + var lastLine = lines.length == 0 ? null : lines.splice(lines.length - 1, 1)[0]; + + position = this.insertInLine(position, firstLine); + if (lastLine !== null) { + position = this.insertNewLine(position); // terminate first line + position = this._insertLines(position.row, lines); + position = this.insertInLine(position, lastLine || ""); + } + return position; + }; + this.insertLines = function(row, lines) { + if (row >= this.getLength()) + return this.insert({row: row, column: 0}, "\n" + lines.join("\n")); + return this._insertLines(Math.max(row, 0), lines); + }; + this._insertLines = function(row, lines) { + if (lines.length == 0) + return {row: row, column: 0}; + if (lines.length > 0xFFFF) { + var end = this._insertLines(row, lines.slice(0xFFFF)); + lines = lines.slice(0, 0xFFFF); + } + + var args = [row, 0]; + args.push.apply(args, lines); + this.$lines.splice.apply(this.$lines, args); + + var range = new Range(row, 0, row + lines.length, 0); + var delta = { + action: "insertLines", + range: range, + lines: lines + }; + this._emit("change", { data: delta }); + return end || range.end; + }; + this.insertNewLine = function(position) { + position = this.$clipPosition(position); + var line = this.$lines[position.row] || ""; + + this.$lines[position.row] = line.substring(0, position.column); + this.$lines.splice(position.row + 1, 0, line.substring(position.column, line.length)); + + var end = { + row : position.row + 1, + column : 0 + }; + + var delta = { + action: "insertText", + range: Range.fromPoints(position, end), + text: this.getNewLineCharacter() + }; + this._emit("change", { data: delta }); + + return end; + }; + this.insertInLine = function(position, text) { + if (text.length == 0) + return position; + + var line = this.$lines[position.row] || ""; + + this.$lines[position.row] = line.substring(0, position.column) + text + + line.substring(position.column); + + var end = { + row : position.row, + column : position.column + text.length + }; + + var delta = { + action: "insertText", + range: Range.fromPoints(position, end), + text: text + }; + this._emit("change", { data: delta }); + + return end; + }; + this.remove = function(range) { + if (!range instanceof Range) + range = Range.fromPoints(range.start, range.end); + range.start = this.$clipPosition(range.start); + range.end = this.$clipPosition(range.end); + + if (range.isEmpty()) + return range.start; + + var firstRow = range.start.row; + var lastRow = range.end.row; + + if (range.isMultiLine()) { + var firstFullRow = range.start.column == 0 ? firstRow : firstRow + 1; + var lastFullRow = lastRow - 1; + + if (range.end.column > 0) + this.removeInLine(lastRow, 0, range.end.column); + + if (lastFullRow >= firstFullRow) + this._removeLines(firstFullRow, lastFullRow); + + if (firstFullRow != firstRow) { + this.removeInLine(firstRow, range.start.column, this.getLine(firstRow).length); + this.removeNewLine(range.start.row); + } + } + else { + this.removeInLine(firstRow, range.start.column, range.end.column); + } + return range.start; + }; + this.removeInLine = function(row, startColumn, endColumn) { + if (startColumn == endColumn) + return; + + var range = new Range(row, startColumn, row, endColumn); + var line = this.getLine(row); + var removed = line.substring(startColumn, endColumn); + var newLine = line.substring(0, startColumn) + line.substring(endColumn, line.length); + this.$lines.splice(row, 1, newLine); + + var delta = { + action: "removeText", + range: range, + text: removed + }; + this._emit("change", { data: delta }); + return range.start; + }; + this.removeLines = function(firstRow, lastRow) { + if (firstRow < 0 || lastRow >= this.getLength()) + return this.remove(new Range(firstRow, 0, lastRow + 1, 0)); + return this._removeLines(firstRow, lastRow); + }; + + this._removeLines = function(firstRow, lastRow) { + var range = new Range(firstRow, 0, lastRow + 1, 0); + var removed = this.$lines.splice(firstRow, lastRow - firstRow + 1); + + var delta = { + action: "removeLines", + range: range, + nl: this.getNewLineCharacter(), + lines: removed + }; + this._emit("change", { data: delta }); + return removed; + }; + this.removeNewLine = function(row) { + var firstLine = this.getLine(row); + var secondLine = this.getLine(row+1); + + var range = new Range(row, firstLine.length, row+1, 0); + var line = firstLine + secondLine; + + this.$lines.splice(row, 2, line); + + var delta = { + action: "removeText", + range: range, + text: this.getNewLineCharacter() + }; + this._emit("change", { data: delta }); + }; + this.replace = function(range, text) { + if (!range instanceof Range) + range = Range.fromPoints(range.start, range.end); + if (text.length == 0 && range.isEmpty()) + return range.start; + if (text == this.getTextRange(range)) + return range.end; + + this.remove(range); + if (text) { + var end = this.insert(range.start, text); + } + else { + end = range.start; + } + + return end; + }; + this.applyDeltas = function(deltas) { + for (var i=0; i=0; i--) { + var delta = deltas[i]; + + var range = Range.fromPoints(delta.range.start, delta.range.end); + + if (delta.action == "insertLines") + this._removeLines(range.start.row, range.end.row - 1); + else if (delta.action == "insertText") + this.remove(range); + else if (delta.action == "removeLines") + this._insertLines(range.start.row, delta.lines); + else if (delta.action == "removeText") + this.insert(range.start, delta.text); + } + }; + this.indexToPosition = function(index, startRow) { + var lines = this.$lines || this.getAllLines(); + var newlineLength = this.getNewLineCharacter().length; + for (var i = startRow || 0, l = lines.length; i < l; i++) { + index -= lines[i].length + newlineLength; + if (index < 0) + return {row: i, column: index + lines[i].length + newlineLength}; + } + return {row: l-1, column: lines[l-1].length}; + }; + this.positionToIndex = function(pos, startRow) { + var lines = this.$lines || this.getAllLines(); + var newlineLength = this.getNewLineCharacter().length; + var index = 0; + var row = Math.min(pos.row, lines.length); + for (var i = startRow || 0; i < row; ++i) + index += lines[i].length + newlineLength; + + return index + pos.column; + }; + +}).call(Document.prototype); + +exports.Document = Document; +}); + +ace.define('ace/lib/event_emitter', ['require', 'exports', 'module' ], function(require, exports, module) { + + +var EventEmitter = {}; +var stopPropagation = function() { this.propagationStopped = true; }; +var preventDefault = function() { this.defaultPrevented = true; }; + +EventEmitter._emit = +EventEmitter._dispatchEvent = function(eventName, e) { + this._eventRegistry || (this._eventRegistry = {}); + this._defaultHandlers || (this._defaultHandlers = {}); + + var listeners = this._eventRegistry[eventName] || []; + var defaultHandler = this._defaultHandlers[eventName]; + if (!listeners.length && !defaultHandler) + return; + + if (typeof e != "object" || !e) + e = {}; + + if (!e.type) + e.type = eventName; + if (!e.stopPropagation) + e.stopPropagation = stopPropagation; + if (!e.preventDefault) + e.preventDefault = preventDefault; + + listeners = listeners.slice(); + for (var i=0; i [" + this.end.row + "/" + this.end.column + "]"); + }; + + this.contains = function(row, column) { + return this.compare(row, column) == 0; + }; + this.compareRange = function(range) { + var cmp, + end = range.end, + start = range.start; + + cmp = this.compare(end.row, end.column); + if (cmp == 1) { + cmp = this.compare(start.row, start.column); + if (cmp == 1) { + return 2; + } else if (cmp == 0) { + return 1; + } else { + return 0; + } + } else if (cmp == -1) { + return -2; + } else { + cmp = this.compare(start.row, start.column); + if (cmp == -1) { + return -1; + } else if (cmp == 1) { + return 42; + } else { + return 0; + } + } + }; + this.comparePoint = function(p) { + return this.compare(p.row, p.column); + }; + this.containsRange = function(range) { + return this.comparePoint(range.start) == 0 && this.comparePoint(range.end) == 0; + }; + this.intersects = function(range) { + var cmp = this.compareRange(range); + return (cmp == -1 || cmp == 0 || cmp == 1); + }; + this.isEnd = function(row, column) { + return this.end.row == row && this.end.column == column; + }; + this.isStart = function(row, column) { + return this.start.row == row && this.start.column == column; + }; + this.setStart = function(row, column) { + if (typeof row == "object") { + this.start.column = row.column; + this.start.row = row.row; + } else { + this.start.row = row; + this.start.column = column; + } + }; + this.setEnd = function(row, column) { + if (typeof row == "object") { + this.end.column = row.column; + this.end.row = row.row; + } else { + this.end.row = row; + this.end.column = column; + } + }; + this.inside = function(row, column) { + if (this.compare(row, column) == 0) { + if (this.isEnd(row, column) || this.isStart(row, column)) { + return false; + } else { + return true; + } + } + return false; + }; + this.insideStart = function(row, column) { + if (this.compare(row, column) == 0) { + if (this.isEnd(row, column)) { + return false; + } else { + return true; + } + } + return false; + }; + this.insideEnd = function(row, column) { + if (this.compare(row, column) == 0) { + if (this.isStart(row, column)) { + return false; + } else { + return true; + } + } + return false; + }; + this.compare = function(row, column) { + if (!this.isMultiLine()) { + if (row === this.start.row) { + return column < this.start.column ? -1 : (column > this.end.column ? 1 : 0); + }; + } + + if (row < this.start.row) + return -1; + + if (row > this.end.row) + return 1; + + if (this.start.row === row) + return column >= this.start.column ? 0 : -1; + + if (this.end.row === row) + return column <= this.end.column ? 0 : 1; + + return 0; + }; + this.compareStart = function(row, column) { + if (this.start.row == row && this.start.column == column) { + return -1; + } else { + return this.compare(row, column); + } + }; + this.compareEnd = function(row, column) { + if (this.end.row == row && this.end.column == column) { + return 1; + } else { + return this.compare(row, column); + } + }; + this.compareInside = function(row, column) { + if (this.end.row == row && this.end.column == column) { + return 1; + } else if (this.start.row == row && this.start.column == column) { + return -1; + } else { + return this.compare(row, column); + } + }; + this.clipRows = function(firstRow, lastRow) { + if (this.end.row > lastRow) + var end = {row: lastRow + 1, column: 0}; + else if (this.end.row < firstRow) + var end = {row: firstRow, column: 0}; + + if (this.start.row > lastRow) + var start = {row: lastRow + 1, column: 0}; + else if (this.start.row < firstRow) + var start = {row: firstRow, column: 0}; + + return Range.fromPoints(start || this.start, end || this.end); + }; + this.extend = function(row, column) { + var cmp = this.compare(row, column); + + if (cmp == 0) + return this; + else if (cmp == -1) + var start = {row: row, column: column}; + else + var end = {row: row, column: column}; + + return Range.fromPoints(start || this.start, end || this.end); + }; + + this.isEmpty = function() { + return (this.start.row === this.end.row && this.start.column === this.end.column); + }; + this.isMultiLine = function() { + return (this.start.row !== this.end.row); + }; + this.clone = function() { + return Range.fromPoints(this.start, this.end); + }; + this.collapseRows = function() { + if (this.end.column == 0) + return new Range(this.start.row, 0, Math.max(this.start.row, this.end.row-1), 0) + else + return new Range(this.start.row, 0, this.end.row, 0) + }; + this.toScreenRange = function(session) { + var screenPosStart = session.documentToScreenPosition(this.start); + var screenPosEnd = session.documentToScreenPosition(this.end); + + return new Range( + screenPosStart.row, screenPosStart.column, + screenPosEnd.row, screenPosEnd.column + ); + }; + this.moveBy = function(row, column) { + this.start.row += row; + this.start.column += column; + this.end.row += row; + this.end.column += column; + }; + +}).call(Range.prototype); +Range.fromPoints = function(start, end) { + return new Range(start.row, start.column, end.row, end.column); +}; +Range.comparePoints = comparePoints; + +Range.comparePoints = function(p1, p2) { + return p1.row - p2.row || p1.column - p2.column; +}; + + +exports.Range = Range; +}); + +ace.define('ace/anchor', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/event_emitter'], function(require, exports, module) { + + +var oop = require("./lib/oop"); +var EventEmitter = require("./lib/event_emitter").EventEmitter; + +var Anchor = exports.Anchor = function(doc, row, column) { + this.$onChange = this.onChange.bind(this); + this.attach(doc); + + if (typeof column == "undefined") + this.setPosition(row.row, row.column); + else + this.setPosition(row, column); +}; + +(function() { + + oop.implement(this, EventEmitter); + this.getPosition = function() { + return this.$clipPositionToDocument(this.row, this.column); + }; + this.getDocument = function() { + return this.document; + }; + this.$insertRight = false; + this.onChange = function(e) { + var delta = e.data; + var range = delta.range; + + if (range.start.row == range.end.row && range.start.row != this.row) + return; + + if (range.start.row > this.row) + return; + + if (range.start.row == this.row && range.start.column > this.column) + return; + + var row = this.row; + var column = this.column; + var start = range.start; + var end = range.end; + + if (delta.action === "insertText") { + if (start.row === row && start.column <= column) { + if (start.column === column && this.$insertRight) { + } else if (start.row === end.row) { + column += end.column - start.column; + } else { + column -= start.column; + row += end.row - start.row; + } + } else if (start.row !== end.row && start.row < row) { + row += end.row - start.row; + } + } else if (delta.action === "insertLines") { + if (start.row <= row) { + row += end.row - start.row; + } + } else if (delta.action === "removeText") { + if (start.row === row && start.column < column) { + if (end.column >= column) + column = start.column; + else + column = Math.max(0, column - (end.column - start.column)); + + } else if (start.row !== end.row && start.row < row) { + if (end.row === row) + column = Math.max(0, column - end.column) + start.column; + row -= (end.row - start.row); + } else if (end.row === row) { + row -= end.row - start.row; + column = Math.max(0, column - end.column) + start.column; + } + } else if (delta.action == "removeLines") { + if (start.row <= row) { + if (end.row <= row) + row -= end.row - start.row; + else { + row = start.row; + column = 0; + } + } + } + + this.setPosition(row, column, true); + }; + this.setPosition = function(row, column, noClip) { + var pos; + if (noClip) { + pos = { + row: row, + column: column + }; + } else { + pos = this.$clipPositionToDocument(row, column); + } + + if (this.row == pos.row && this.column == pos.column) + return; + + var old = { + row: this.row, + column: this.column + }; + + this.row = pos.row; + this.column = pos.column; + this._emit("change", { + old: old, + value: pos + }); + }; + this.detach = function() { + this.document.removeEventListener("change", this.$onChange); + }; + this.attach = function(doc) { + this.document = doc || this.document; + this.document.on("change", this.$onChange); + }; + this.$clipPositionToDocument = function(row, column) { + var pos = {}; + + if (row >= this.document.getLength()) { + pos.row = Math.max(0, this.document.getLength() - 1); + pos.column = this.document.getLine(pos.row).length; + } + else if (row < 0) { + pos.row = 0; + pos.column = 0; + } + else { + pos.row = row; + pos.column = Math.min(this.document.getLine(pos.row).length, Math.max(0, column)); + } + + if (column < 0) + pos.column = 0; + + return pos; + }; + +}).call(Anchor.prototype); + +}); +ace.define('ace/mode/css/csslint', ['require', 'exports', 'module' ], function(require, exports, module) { +var parserlib = {}; +(function(){ +function EventTarget(){ + this._listeners = {}; +} + +EventTarget.prototype = { + constructor: EventTarget, + addListener: function(type, listener){ + if (!this._listeners[type]){ + this._listeners[type] = []; + } + + this._listeners[type].push(listener); + }, + fire: function(event){ + if (typeof event == "string"){ + event = { type: event }; + } + if (typeof event.target != "undefined"){ + event.target = this; + } + + if (typeof event.type == "undefined"){ + throw new Error("Event object missing 'type' property."); + } + + if (this._listeners[event.type]){ + var listeners = this._listeners[event.type].concat(); + for (var i=0, len=listeners.length; i < len; i++){ + listeners[i].call(this, event); + } + } + }, + removeListener: function(type, listener){ + if (this._listeners[type]){ + var listeners = this._listeners[type]; + for (var i=0, len=listeners.length; i < len; i++){ + if (listeners[i] === listener){ + listeners.splice(i, 1); + break; + } + } + + + } + } +}; +function StringReader(text){ + this._input = text.replace(/\n\r?/g, "\n"); + this._line = 1; + this._col = 1; + this._cursor = 0; +} + +StringReader.prototype = { + constructor: StringReader, + getCol: function(){ + return this._col; + }, + getLine: function(){ + return this._line ; + }, + eof: function(){ + return (this._cursor == this._input.length); + }, + peek: function(count){ + var c = null; + count = (typeof count == "undefined" ? 1 : count); + if (this._cursor < this._input.length){ + c = this._input.charAt(this._cursor + count - 1); + } + + return c; + }, + read: function(){ + var c = null; + if (this._cursor < this._input.length){ + if (this._input.charAt(this._cursor) == "\n"){ + this._line++; + this._col=1; + } else { + this._col++; + } + c = this._input.charAt(this._cursor++); + } + + return c; + }, + mark: function(){ + this._bookmark = { + cursor: this._cursor, + line: this._line, + col: this._col + }; + }, + + reset: function(){ + if (this._bookmark){ + this._cursor = this._bookmark.cursor; + this._line = this._bookmark.line; + this._col = this._bookmark.col; + delete this._bookmark; + } + }, + readTo: function(pattern){ + + var buffer = "", + c; + while (buffer.length < pattern.length || buffer.lastIndexOf(pattern) != buffer.length - pattern.length){ + c = this.read(); + if (c){ + buffer += c; + } else { + throw new Error("Expected \"" + pattern + "\" at line " + this._line + ", col " + this._col + "."); + } + } + + return buffer; + + }, + readWhile: function(filter){ + + var buffer = "", + c = this.read(); + + while(c !== null && filter(c)){ + buffer += c; + c = this.read(); + } + + return buffer; + + }, + readMatch: function(matcher){ + + var source = this._input.substring(this._cursor), + value = null; + if (typeof matcher == "string"){ + if (source.indexOf(matcher) === 0){ + value = this.readCount(matcher.length); + } + } else if (matcher instanceof RegExp){ + if (matcher.test(source)){ + value = this.readCount(RegExp.lastMatch.length); + } + } + + return value; + }, + readCount: function(count){ + var buffer = ""; + + while(count--){ + buffer += this.read(); + } + + return buffer; + } + +}; +function SyntaxError(message, line, col){ + this.col = col; + this.line = line; + this.message = message; + +} +SyntaxError.prototype = new Error(); +function SyntaxUnit(text, line, col, type){ + this.col = col; + this.line = line; + this.text = text; + this.type = type; +} +SyntaxUnit.fromToken = function(token){ + return new SyntaxUnit(token.value, token.startLine, token.startCol); +}; + +SyntaxUnit.prototype = { + constructor: SyntaxUnit, + valueOf: function(){ + return this.toString(); + }, + toString: function(){ + return this.text; + } + +}; +function TokenStreamBase(input, tokenData){ + this._reader = input ? new StringReader(input.toString()) : null; + this._token = null; + this._tokenData = tokenData; + this._lt = []; + this._ltIndex = 0; + + this._ltIndexCache = []; +} +TokenStreamBase.createTokenData = function(tokens){ + + var nameMap = [], + typeMap = {}, + tokenData = tokens.concat([]), + i = 0, + len = tokenData.length+1; + + tokenData.UNKNOWN = -1; + tokenData.unshift({name:"EOF"}); + + for (; i < len; i++){ + nameMap.push(tokenData[i].name); + tokenData[tokenData[i].name] = i; + if (tokenData[i].text){ + typeMap[tokenData[i].text] = i; + } + } + + tokenData.name = function(tt){ + return nameMap[tt]; + }; + + tokenData.type = function(c){ + return typeMap[c]; + }; + + return tokenData; +}; + +TokenStreamBase.prototype = { + constructor: TokenStreamBase, + match: function(tokenTypes, channel){ + if (!(tokenTypes instanceof Array)){ + tokenTypes = [tokenTypes]; + } + + var tt = this.get(channel), + i = 0, + len = tokenTypes.length; + + while(i < len){ + if (tt == tokenTypes[i++]){ + return true; + } + } + this.unget(); + return false; + }, + mustMatch: function(tokenTypes, channel){ + + var token; + if (!(tokenTypes instanceof Array)){ + tokenTypes = [tokenTypes]; + } + + if (!this.match.apply(this, arguments)){ + token = this.LT(1); + throw new SyntaxError("Expected " + this._tokenData[tokenTypes[0]].name + + " at line " + token.startLine + ", col " + token.startCol + ".", token.startLine, token.startCol); + } + }, + advance: function(tokenTypes, channel){ + + while(this.LA(0) !== 0 && !this.match(tokenTypes, channel)){ + this.get(); + } + + return this.LA(0); + }, + get: function(channel){ + + var tokenInfo = this._tokenData, + reader = this._reader, + value, + i =0, + len = tokenInfo.length, + found = false, + token, + info; + if (this._lt.length && this._ltIndex >= 0 && this._ltIndex < this._lt.length){ + + i++; + this._token = this._lt[this._ltIndex++]; + info = tokenInfo[this._token.type]; + while((info.channel !== undefined && channel !== info.channel) && + this._ltIndex < this._lt.length){ + this._token = this._lt[this._ltIndex++]; + info = tokenInfo[this._token.type]; + i++; + } + if ((info.channel === undefined || channel === info.channel) && + this._ltIndex <= this._lt.length){ + this._ltIndexCache.push(i); + return this._token.type; + } + } + token = this._getToken(); + if (token.type > -1 && !tokenInfo[token.type].hide){ + token.channel = tokenInfo[token.type].channel; + this._token = token; + this._lt.push(token); + this._ltIndexCache.push(this._lt.length - this._ltIndex + i); + if (this._lt.length > 5){ + this._lt.shift(); + } + if (this._ltIndexCache.length > 5){ + this._ltIndexCache.shift(); + } + this._ltIndex = this._lt.length; + } + info = tokenInfo[token.type]; + if (info && + (info.hide || + (info.channel !== undefined && channel !== info.channel))){ + return this.get(channel); + } else { + return token.type; + } + }, + LA: function(index){ + var total = index, + tt; + if (index > 0){ + if (index > 5){ + throw new Error("Too much lookahead."); + } + while(total){ + tt = this.get(); + total--; + } + while(total < index){ + this.unget(); + total++; + } + } else if (index < 0){ + + if(this._lt[this._ltIndex+index]){ + tt = this._lt[this._ltIndex+index].type; + } else { + throw new Error("Too much lookbehind."); + } + + } else { + tt = this._token.type; + } + + return tt; + + }, + LT: function(index){ + this.LA(index); + return this._lt[this._ltIndex+index-1]; + }, + peek: function(){ + return this.LA(1); + }, + token: function(){ + return this._token; + }, + tokenName: function(tokenType){ + if (tokenType < 0 || tokenType > this._tokenData.length){ + return "UNKNOWN_TOKEN"; + } else { + return this._tokenData[tokenType].name; + } + }, + tokenType: function(tokenName){ + return this._tokenData[tokenName] || -1; + }, + unget: function(){ + if (this._ltIndexCache.length){ + this._ltIndex -= this._ltIndexCache.pop();//--; + this._token = this._lt[this._ltIndex - 1]; + } else { + throw new Error("Too much lookahead."); + } + } + +}; + + + + +parserlib.util = { +StringReader: StringReader, +SyntaxError : SyntaxError, +SyntaxUnit : SyntaxUnit, +EventTarget : EventTarget, +TokenStreamBase : TokenStreamBase +}; +})(); +(function(){ +var EventTarget = parserlib.util.EventTarget, +TokenStreamBase = parserlib.util.TokenStreamBase, +StringReader = parserlib.util.StringReader, +SyntaxError = parserlib.util.SyntaxError, +SyntaxUnit = parserlib.util.SyntaxUnit; + + +var Colors = { + aliceblue :"#f0f8ff", + antiquewhite :"#faebd7", + aqua :"#00ffff", + aquamarine :"#7fffd4", + azure :"#f0ffff", + beige :"#f5f5dc", + bisque :"#ffe4c4", + black :"#000000", + blanchedalmond :"#ffebcd", + blue :"#0000ff", + blueviolet :"#8a2be2", + brown :"#a52a2a", + burlywood :"#deb887", + cadetblue :"#5f9ea0", + chartreuse :"#7fff00", + chocolate :"#d2691e", + coral :"#ff7f50", + cornflowerblue :"#6495ed", + cornsilk :"#fff8dc", + crimson :"#dc143c", + cyan :"#00ffff", + darkblue :"#00008b", + darkcyan :"#008b8b", + darkgoldenrod :"#b8860b", + darkgray :"#a9a9a9", + darkgreen :"#006400", + darkkhaki :"#bdb76b", + darkmagenta :"#8b008b", + darkolivegreen :"#556b2f", + darkorange :"#ff8c00", + darkorchid :"#9932cc", + darkred :"#8b0000", + darksalmon :"#e9967a", + darkseagreen :"#8fbc8f", + darkslateblue :"#483d8b", + darkslategray :"#2f4f4f", + darkturquoise :"#00ced1", + darkviolet :"#9400d3", + deeppink :"#ff1493", + deepskyblue :"#00bfff", + dimgray :"#696969", + dodgerblue :"#1e90ff", + firebrick :"#b22222", + floralwhite :"#fffaf0", + forestgreen :"#228b22", + fuchsia :"#ff00ff", + gainsboro :"#dcdcdc", + ghostwhite :"#f8f8ff", + gold :"#ffd700", + goldenrod :"#daa520", + gray :"#808080", + green :"#008000", + greenyellow :"#adff2f", + honeydew :"#f0fff0", + hotpink :"#ff69b4", + indianred :"#cd5c5c", + indigo :"#4b0082", + ivory :"#fffff0", + khaki :"#f0e68c", + lavender :"#e6e6fa", + lavenderblush :"#fff0f5", + lawngreen :"#7cfc00", + lemonchiffon :"#fffacd", + lightblue :"#add8e6", + lightcoral :"#f08080", + lightcyan :"#e0ffff", + lightgoldenrodyellow :"#fafad2", + lightgray :"#d3d3d3", + lightgreen :"#90ee90", + lightpink :"#ffb6c1", + lightsalmon :"#ffa07a", + lightseagreen :"#20b2aa", + lightskyblue :"#87cefa", + lightslategray :"#778899", + lightsteelblue :"#b0c4de", + lightyellow :"#ffffe0", + lime :"#00ff00", + limegreen :"#32cd32", + linen :"#faf0e6", + magenta :"#ff00ff", + maroon :"#800000", + mediumaquamarine:"#66cdaa", + mediumblue :"#0000cd", + mediumorchid :"#ba55d3", + mediumpurple :"#9370d8", + mediumseagreen :"#3cb371", + mediumslateblue :"#7b68ee", + mediumspringgreen :"#00fa9a", + mediumturquoise :"#48d1cc", + mediumvioletred :"#c71585", + midnightblue :"#191970", + mintcream :"#f5fffa", + mistyrose :"#ffe4e1", + moccasin :"#ffe4b5", + navajowhite :"#ffdead", + navy :"#000080", + oldlace :"#fdf5e6", + olive :"#808000", + olivedrab :"#6b8e23", + orange :"#ffa500", + orangered :"#ff4500", + orchid :"#da70d6", + palegoldenrod :"#eee8aa", + palegreen :"#98fb98", + paleturquoise :"#afeeee", + palevioletred :"#d87093", + papayawhip :"#ffefd5", + peachpuff :"#ffdab9", + peru :"#cd853f", + pink :"#ffc0cb", + plum :"#dda0dd", + powderblue :"#b0e0e6", + purple :"#800080", + red :"#ff0000", + rosybrown :"#bc8f8f", + royalblue :"#4169e1", + saddlebrown :"#8b4513", + salmon :"#fa8072", + sandybrown :"#f4a460", + seagreen :"#2e8b57", + seashell :"#fff5ee", + sienna :"#a0522d", + silver :"#c0c0c0", + skyblue :"#87ceeb", + slateblue :"#6a5acd", + slategray :"#708090", + snow :"#fffafa", + springgreen :"#00ff7f", + steelblue :"#4682b4", + tan :"#d2b48c", + teal :"#008080", + thistle :"#d8bfd8", + tomato :"#ff6347", + turquoise :"#40e0d0", + violet :"#ee82ee", + wheat :"#f5deb3", + white :"#ffffff", + whitesmoke :"#f5f5f5", + yellow :"#ffff00", + yellowgreen :"#9acd32", + activeBorder :"Active window border.", + activecaption :"Active window caption.", + appworkspace :"Background color of multiple document interface.", + background :"Desktop background.", + buttonface :"The face background color for 3-D elements that appear 3-D due to one layer of surrounding border.", + buttonhighlight :"The color of the border facing the light source for 3-D elements that appear 3-D due to one layer of surrounding border.", + buttonshadow :"The color of the border away from the light source for 3-D elements that appear 3-D due to one layer of surrounding border.", + buttontext :"Text on push buttons.", + captiontext :"Text in caption, size box, and scrollbar arrow box.", + graytext :"Grayed (disabled) text. This color is set to #000 if the current display driver does not support a solid gray color.", + highlight :"Item(s) selected in a control.", + highlighttext :"Text of item(s) selected in a control.", + inactiveborder :"Inactive window border.", + inactivecaption :"Inactive window caption.", + inactivecaptiontext :"Color of text in an inactive caption.", + infobackground :"Background color for tooltip controls.", + infotext :"Text color for tooltip controls.", + menu :"Menu background.", + menutext :"Text in menus.", + scrollbar :"Scroll bar gray area.", + threeddarkshadow :"The color of the darker (generally outer) of the two borders away from the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border.", + threedface :"The face background color for 3-D elements that appear 3-D due to two concentric layers of surrounding border.", + threedhighlight :"The color of the lighter (generally outer) of the two borders facing the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border.", + threedlightshadow :"The color of the darker (generally inner) of the two borders facing the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border.", + threedshadow :"The color of the lighter (generally inner) of the two borders away from the light source for 3-D elements that appear 3-D due to two concentric layers of surrounding border.", + window :"Window background.", + windowframe :"Window frame.", + windowtext :"Text in windows." +}; +function Combinator(text, line, col){ + + SyntaxUnit.call(this, text, line, col, Parser.COMBINATOR_TYPE); + this.type = "unknown"; + if (/^\s+$/.test(text)){ + this.type = "descendant"; + } else if (text == ">"){ + this.type = "child"; + } else if (text == "+"){ + this.type = "adjacent-sibling"; + } else if (text == "~"){ + this.type = "sibling"; + } + +} + +Combinator.prototype = new SyntaxUnit(); +Combinator.prototype.constructor = Combinator; +function MediaFeature(name, value){ + + SyntaxUnit.call(this, "(" + name + (value !== null ? ":" + value : "") + ")", name.startLine, name.startCol, Parser.MEDIA_FEATURE_TYPE); + this.name = name; + this.value = value; +} + +MediaFeature.prototype = new SyntaxUnit(); +MediaFeature.prototype.constructor = MediaFeature; +function MediaQuery(modifier, mediaType, features, line, col){ + + SyntaxUnit.call(this, (modifier ? modifier + " ": "") + (mediaType ? mediaType : "") + (mediaType && features.length > 0 ? " and " : "") + features.join(" and "), line, col, Parser.MEDIA_QUERY_TYPE); + this.modifier = modifier; + this.mediaType = mediaType; + this.features = features; + +} + +MediaQuery.prototype = new SyntaxUnit(); +MediaQuery.prototype.constructor = MediaQuery; +function Parser(options){ + EventTarget.call(this); + + + this.options = options || {}; + + this._tokenStream = null; +} +Parser.DEFAULT_TYPE = 0; +Parser.COMBINATOR_TYPE = 1; +Parser.MEDIA_FEATURE_TYPE = 2; +Parser.MEDIA_QUERY_TYPE = 3; +Parser.PROPERTY_NAME_TYPE = 4; +Parser.PROPERTY_VALUE_TYPE = 5; +Parser.PROPERTY_VALUE_PART_TYPE = 6; +Parser.SELECTOR_TYPE = 7; +Parser.SELECTOR_PART_TYPE = 8; +Parser.SELECTOR_SUB_PART_TYPE = 9; + +Parser.prototype = function(){ + + var proto = new EventTarget(), //new prototype + prop, + additions = { + constructor: Parser, + DEFAULT_TYPE : 0, + COMBINATOR_TYPE : 1, + MEDIA_FEATURE_TYPE : 2, + MEDIA_QUERY_TYPE : 3, + PROPERTY_NAME_TYPE : 4, + PROPERTY_VALUE_TYPE : 5, + PROPERTY_VALUE_PART_TYPE : 6, + SELECTOR_TYPE : 7, + SELECTOR_PART_TYPE : 8, + SELECTOR_SUB_PART_TYPE : 9, + + _stylesheet: function(){ + + var tokenStream = this._tokenStream, + charset = null, + count, + token, + tt; + + this.fire("startstylesheet"); + this._charset(); + + this._skipCruft(); + while (tokenStream.peek() == Tokens.IMPORT_SYM){ + this._import(); + this._skipCruft(); + } + while (tokenStream.peek() == Tokens.NAMESPACE_SYM){ + this._namespace(); + this._skipCruft(); + } + tt = tokenStream.peek(); + while(tt > Tokens.EOF){ + + try { + + switch(tt){ + case Tokens.MEDIA_SYM: + this._media(); + this._skipCruft(); + break; + case Tokens.PAGE_SYM: + this._page(); + this._skipCruft(); + break; + case Tokens.FONT_FACE_SYM: + this._font_face(); + this._skipCruft(); + break; + case Tokens.KEYFRAMES_SYM: + this._keyframes(); + this._skipCruft(); + break; + case Tokens.UNKNOWN_SYM: //unknown @ rule + tokenStream.get(); + if (!this.options.strict){ + this.fire({ + type: "error", + error: null, + message: "Unknown @ rule: " + tokenStream.LT(0).value + ".", + line: tokenStream.LT(0).startLine, + col: tokenStream.LT(0).startCol + }); + count=0; + while (tokenStream.advance([Tokens.LBRACE, Tokens.RBRACE]) == Tokens.LBRACE){ + count++; //keep track of nesting depth + } + + while(count){ + tokenStream.advance([Tokens.RBRACE]); + count--; + } + + } else { + throw new SyntaxError("Unknown @ rule.", tokenStream.LT(0).startLine, tokenStream.LT(0).startCol); + } + break; + case Tokens.S: + this._readWhitespace(); + break; + default: + if(!this._ruleset()){ + switch(tt){ + case Tokens.CHARSET_SYM: + token = tokenStream.LT(1); + this._charset(false); + throw new SyntaxError("@charset not allowed here.", token.startLine, token.startCol); + case Tokens.IMPORT_SYM: + token = tokenStream.LT(1); + this._import(false); + throw new SyntaxError("@import not allowed here.", token.startLine, token.startCol); + case Tokens.NAMESPACE_SYM: + token = tokenStream.LT(1); + this._namespace(false); + throw new SyntaxError("@namespace not allowed here.", token.startLine, token.startCol); + default: + tokenStream.get(); //get the last token + this._unexpectedToken(tokenStream.token()); + } + + } + } + } catch(ex) { + if (ex instanceof SyntaxError && !this.options.strict){ + this.fire({ + type: "error", + error: ex, + message: ex.message, + line: ex.line, + col: ex.col + }); + } else { + throw ex; + } + } + + tt = tokenStream.peek(); + } + + if (tt != Tokens.EOF){ + this._unexpectedToken(tokenStream.token()); + } + + this.fire("endstylesheet"); + }, + + _charset: function(emit){ + var tokenStream = this._tokenStream, + charset, + token, + line, + col; + + if (tokenStream.match(Tokens.CHARSET_SYM)){ + line = tokenStream.token().startLine; + col = tokenStream.token().startCol; + + this._readWhitespace(); + tokenStream.mustMatch(Tokens.STRING); + + token = tokenStream.token(); + charset = token.value; + + this._readWhitespace(); + tokenStream.mustMatch(Tokens.SEMICOLON); + + if (emit !== false){ + this.fire({ + type: "charset", + charset:charset, + line: line, + col: col + }); + } + } + }, + + _import: function(emit){ + + var tokenStream = this._tokenStream, + tt, + uri, + importToken, + mediaList = []; + tokenStream.mustMatch(Tokens.IMPORT_SYM); + importToken = tokenStream.token(); + this._readWhitespace(); + + tokenStream.mustMatch([Tokens.STRING, Tokens.URI]); + uri = tokenStream.token().value.replace(/(?:url\()?["']([^"']+)["']\)?/, "$1"); + + this._readWhitespace(); + + mediaList = this._media_query_list(); + tokenStream.mustMatch(Tokens.SEMICOLON); + this._readWhitespace(); + + if (emit !== false){ + this.fire({ + type: "import", + uri: uri, + media: mediaList, + line: importToken.startLine, + col: importToken.startCol + }); + } + + }, + + _namespace: function(emit){ + + var tokenStream = this._tokenStream, + line, + col, + prefix, + uri; + tokenStream.mustMatch(Tokens.NAMESPACE_SYM); + line = tokenStream.token().startLine; + col = tokenStream.token().startCol; + this._readWhitespace(); + if (tokenStream.match(Tokens.IDENT)){ + prefix = tokenStream.token().value; + this._readWhitespace(); + } + + tokenStream.mustMatch([Tokens.STRING, Tokens.URI]); + uri = tokenStream.token().value.replace(/(?:url\()?["']([^"']+)["']\)?/, "$1"); + + this._readWhitespace(); + tokenStream.mustMatch(Tokens.SEMICOLON); + this._readWhitespace(); + + if (emit !== false){ + this.fire({ + type: "namespace", + prefix: prefix, + uri: uri, + line: line, + col: col + }); + } + + }, + + _media: function(){ + var tokenStream = this._tokenStream, + line, + col, + mediaList;// = []; + tokenStream.mustMatch(Tokens.MEDIA_SYM); + line = tokenStream.token().startLine; + col = tokenStream.token().startCol; + + this._readWhitespace(); + + mediaList = this._media_query_list(); + + tokenStream.mustMatch(Tokens.LBRACE); + this._readWhitespace(); + + this.fire({ + type: "startmedia", + media: mediaList, + line: line, + col: col + }); + + while(true) { + if (tokenStream.peek() == Tokens.PAGE_SYM){ + this._page(); + } else if (!this._ruleset()){ + break; + } + } + + tokenStream.mustMatch(Tokens.RBRACE); + this._readWhitespace(); + + this.fire({ + type: "endmedia", + media: mediaList, + line: line, + col: col + }); + }, + _media_query_list: function(){ + var tokenStream = this._tokenStream, + mediaList = []; + + + this._readWhitespace(); + + if (tokenStream.peek() == Tokens.IDENT || tokenStream.peek() == Tokens.LPAREN){ + mediaList.push(this._media_query()); + } + + while(tokenStream.match(Tokens.COMMA)){ + this._readWhitespace(); + mediaList.push(this._media_query()); + } + + return mediaList; + }, + _media_query: function(){ + var tokenStream = this._tokenStream, + type = null, + ident = null, + token = null, + expressions = []; + + if (tokenStream.match(Tokens.IDENT)){ + ident = tokenStream.token().value.toLowerCase(); + if (ident != "only" && ident != "not"){ + tokenStream.unget(); + ident = null; + } else { + token = tokenStream.token(); + } + } + + this._readWhitespace(); + + if (tokenStream.peek() == Tokens.IDENT){ + type = this._media_type(); + if (token === null){ + token = tokenStream.token(); + } + } else if (tokenStream.peek() == Tokens.LPAREN){ + if (token === null){ + token = tokenStream.LT(1); + } + expressions.push(this._media_expression()); + } + + if (type === null && expressions.length === 0){ + return null; + } else { + this._readWhitespace(); + while (tokenStream.match(Tokens.IDENT)){ + if (tokenStream.token().value.toLowerCase() != "and"){ + this._unexpectedToken(tokenStream.token()); + } + + this._readWhitespace(); + expressions.push(this._media_expression()); + } + } + + return new MediaQuery(ident, type, expressions, token.startLine, token.startCol); + }, + _media_type: function(){ + return this._media_feature(); + }, + _media_expression: function(){ + var tokenStream = this._tokenStream, + feature = null, + token, + expression = null; + + tokenStream.mustMatch(Tokens.LPAREN); + + feature = this._media_feature(); + this._readWhitespace(); + + if (tokenStream.match(Tokens.COLON)){ + this._readWhitespace(); + token = tokenStream.LT(1); + expression = this._expression(); + } + + tokenStream.mustMatch(Tokens.RPAREN); + this._readWhitespace(); + + return new MediaFeature(feature, (expression ? new SyntaxUnit(expression, token.startLine, token.startCol) : null)); + }, + _media_feature: function(){ + var tokenStream = this._tokenStream; + + tokenStream.mustMatch(Tokens.IDENT); + + return SyntaxUnit.fromToken(tokenStream.token()); + }, + _page: function(){ + var tokenStream = this._tokenStream, + line, + col, + identifier = null, + pseudoPage = null; + tokenStream.mustMatch(Tokens.PAGE_SYM); + line = tokenStream.token().startLine; + col = tokenStream.token().startCol; + + this._readWhitespace(); + + if (tokenStream.match(Tokens.IDENT)){ + identifier = tokenStream.token().value; + if (identifier.toLowerCase() === "auto"){ + this._unexpectedToken(tokenStream.token()); + } + } + if (tokenStream.peek() == Tokens.COLON){ + pseudoPage = this._pseudo_page(); + } + + this._readWhitespace(); + + this.fire({ + type: "startpage", + id: identifier, + pseudo: pseudoPage, + line: line, + col: col + }); + + this._readDeclarations(true, true); + + this.fire({ + type: "endpage", + id: identifier, + pseudo: pseudoPage, + line: line, + col: col + }); + + }, + _margin: function(){ + var tokenStream = this._tokenStream, + line, + col, + marginSym = this._margin_sym(); + + if (marginSym){ + line = tokenStream.token().startLine; + col = tokenStream.token().startCol; + + this.fire({ + type: "startpagemargin", + margin: marginSym, + line: line, + col: col + }); + + this._readDeclarations(true); + + this.fire({ + type: "endpagemargin", + margin: marginSym, + line: line, + col: col + }); + return true; + } else { + return false; + } + }, + _margin_sym: function(){ + + var tokenStream = this._tokenStream; + + if(tokenStream.match([Tokens.TOPLEFTCORNER_SYM, Tokens.TOPLEFT_SYM, + Tokens.TOPCENTER_SYM, Tokens.TOPRIGHT_SYM, Tokens.TOPRIGHTCORNER_SYM, + Tokens.BOTTOMLEFTCORNER_SYM, Tokens.BOTTOMLEFT_SYM, + Tokens.BOTTOMCENTER_SYM, Tokens.BOTTOMRIGHT_SYM, + Tokens.BOTTOMRIGHTCORNER_SYM, Tokens.LEFTTOP_SYM, + Tokens.LEFTMIDDLE_SYM, Tokens.LEFTBOTTOM_SYM, Tokens.RIGHTTOP_SYM, + Tokens.RIGHTMIDDLE_SYM, Tokens.RIGHTBOTTOM_SYM])) + { + return SyntaxUnit.fromToken(tokenStream.token()); + } else { + return null; + } + + }, + + _pseudo_page: function(){ + + var tokenStream = this._tokenStream; + + tokenStream.mustMatch(Tokens.COLON); + tokenStream.mustMatch(Tokens.IDENT); + + return tokenStream.token().value; + }, + + _font_face: function(){ + var tokenStream = this._tokenStream, + line, + col; + tokenStream.mustMatch(Tokens.FONT_FACE_SYM); + line = tokenStream.token().startLine; + col = tokenStream.token().startCol; + + this._readWhitespace(); + + this.fire({ + type: "startfontface", + line: line, + col: col + }); + + this._readDeclarations(true); + + this.fire({ + type: "endfontface", + line: line, + col: col + }); + }, + + _operator: function(inFunction){ + + var tokenStream = this._tokenStream, + token = null; + + if (tokenStream.match([Tokens.SLASH, Tokens.COMMA]) || + (inFunction && tokenStream.match([Tokens.PLUS, Tokens.STAR, Tokens.MINUS]))){ + token = tokenStream.token(); + this._readWhitespace(); + } + return token ? PropertyValuePart.fromToken(token) : null; + + }, + + _combinator: function(){ + + var tokenStream = this._tokenStream, + value = null, + token; + + if(tokenStream.match([Tokens.PLUS, Tokens.GREATER, Tokens.TILDE])){ + token = tokenStream.token(); + value = new Combinator(token.value, token.startLine, token.startCol); + this._readWhitespace(); + } + + return value; + }, + + _unary_operator: function(){ + + var tokenStream = this._tokenStream; + + if (tokenStream.match([Tokens.MINUS, Tokens.PLUS])){ + return tokenStream.token().value; + } else { + return null; + } + }, + + _property: function(){ + + var tokenStream = this._tokenStream, + value = null, + hack = null, + tokenValue, + token, + line, + col; + if (tokenStream.peek() == Tokens.STAR && this.options.starHack){ + tokenStream.get(); + token = tokenStream.token(); + hack = token.value; + line = token.startLine; + col = token.startCol; + } + + if(tokenStream.match(Tokens.IDENT)){ + token = tokenStream.token(); + tokenValue = token.value; + if (tokenValue.charAt(0) == "_" && this.options.underscoreHack){ + hack = "_"; + tokenValue = tokenValue.substring(1); + } + + value = new PropertyName(tokenValue, hack, (line||token.startLine), (col||token.startCol)); + this._readWhitespace(); + } + + return value; + }, + _ruleset: function(){ + + var tokenStream = this._tokenStream, + tt, + selectors; + try { + selectors = this._selectors_group(); + } catch (ex){ + if (ex instanceof SyntaxError && !this.options.strict){ + this.fire({ + type: "error", + error: ex, + message: ex.message, + line: ex.line, + col: ex.col + }); + tt = tokenStream.advance([Tokens.RBRACE]); + if (tt == Tokens.RBRACE){ + } else { + throw ex; + } + + } else { + throw ex; + } + return true; + } + if (selectors){ + + this.fire({ + type: "startrule", + selectors: selectors, + line: selectors[0].line, + col: selectors[0].col + }); + + this._readDeclarations(true); + + this.fire({ + type: "endrule", + selectors: selectors, + line: selectors[0].line, + col: selectors[0].col + }); + + } + + return selectors; + + }, + _selectors_group: function(){ + var tokenStream = this._tokenStream, + selectors = [], + selector; + + selector = this._selector(); + if (selector !== null){ + + selectors.push(selector); + while(tokenStream.match(Tokens.COMMA)){ + this._readWhitespace(); + selector = this._selector(); + if (selector !== null){ + selectors.push(selector); + } else { + this._unexpectedToken(tokenStream.LT(1)); + } + } + } + + return selectors.length ? selectors : null; + }, + _selector: function(){ + + var tokenStream = this._tokenStream, + selector = [], + nextSelector = null, + combinator = null, + ws = null; + nextSelector = this._simple_selector_sequence(); + if (nextSelector === null){ + return null; + } + + selector.push(nextSelector); + + do { + combinator = this._combinator(); + + if (combinator !== null){ + selector.push(combinator); + nextSelector = this._simple_selector_sequence(); + if (nextSelector === null){ + this._unexpectedToken(tokenStream.LT(1)); + } else { + selector.push(nextSelector); + } + } else { + if (this._readWhitespace()){ + ws = new Combinator(tokenStream.token().value, tokenStream.token().startLine, tokenStream.token().startCol); + combinator = this._combinator(); + nextSelector = this._simple_selector_sequence(); + if (nextSelector === null){ + if (combinator !== null){ + this._unexpectedToken(tokenStream.LT(1)); + } + } else { + + if (combinator !== null){ + selector.push(combinator); + } else { + selector.push(ws); + } + + selector.push(nextSelector); + } + } else { + break; + } + + } + } while(true); + + return new Selector(selector, selector[0].line, selector[0].col); + }, + _simple_selector_sequence: function(){ + + var tokenStream = this._tokenStream, + elementName = null, + modifiers = [], + selectorText= "", + components = [ + function(){ + return tokenStream.match(Tokens.HASH) ? + new SelectorSubPart(tokenStream.token().value, "id", tokenStream.token().startLine, tokenStream.token().startCol) : + null; + }, + this._class, + this._attrib, + this._pseudo, + this._negation + ], + i = 0, + len = components.length, + component = null, + found = false, + line, + col; + line = tokenStream.LT(1).startLine; + col = tokenStream.LT(1).startCol; + + elementName = this._type_selector(); + if (!elementName){ + elementName = this._universal(); + } + + if (elementName !== null){ + selectorText += elementName; + } + + while(true){ + if (tokenStream.peek() === Tokens.S){ + break; + } + while(i < len && component === null){ + component = components[i++].call(this); + } + + if (component === null){ + if (selectorText === ""){ + return null; + } else { + break; + } + } else { + i = 0; + modifiers.push(component); + selectorText += component.toString(); + component = null; + } + } + + + return selectorText !== "" ? + new SelectorPart(elementName, modifiers, selectorText, line, col) : + null; + }, + _type_selector: function(){ + + var tokenStream = this._tokenStream, + ns = this._namespace_prefix(), + elementName = this._element_name(); + + if (!elementName){ + if (ns){ + tokenStream.unget(); + if (ns.length > 1){ + tokenStream.unget(); + } + } + + return null; + } else { + if (ns){ + elementName.text = ns + elementName.text; + elementName.col -= ns.length; + } + return elementName; + } + }, + _class: function(){ + + var tokenStream = this._tokenStream, + token; + + if (tokenStream.match(Tokens.DOT)){ + tokenStream.mustMatch(Tokens.IDENT); + token = tokenStream.token(); + return new SelectorSubPart("." + token.value, "class", token.startLine, token.startCol - 1); + } else { + return null; + } + + }, + _element_name: function(){ + + var tokenStream = this._tokenStream, + token; + + if (tokenStream.match(Tokens.IDENT)){ + token = tokenStream.token(); + return new SelectorSubPart(token.value, "elementName", token.startLine, token.startCol); + + } else { + return null; + } + }, + _namespace_prefix: function(){ + var tokenStream = this._tokenStream, + value = ""; + if (tokenStream.LA(1) === Tokens.PIPE || tokenStream.LA(2) === Tokens.PIPE){ + + if(tokenStream.match([Tokens.IDENT, Tokens.STAR])){ + value += tokenStream.token().value; + } + + tokenStream.mustMatch(Tokens.PIPE); + value += "|"; + + } + + return value.length ? value : null; + }, + _universal: function(){ + var tokenStream = this._tokenStream, + value = "", + ns; + + ns = this._namespace_prefix(); + if(ns){ + value += ns; + } + + if(tokenStream.match(Tokens.STAR)){ + value += "*"; + } + + return value.length ? value : null; + + }, + _attrib: function(){ + + var tokenStream = this._tokenStream, + value = null, + ns, + token; + + if (tokenStream.match(Tokens.LBRACKET)){ + token = tokenStream.token(); + value = token.value; + value += this._readWhitespace(); + + ns = this._namespace_prefix(); + + if (ns){ + value += ns; + } + + tokenStream.mustMatch(Tokens.IDENT); + value += tokenStream.token().value; + value += this._readWhitespace(); + + if(tokenStream.match([Tokens.PREFIXMATCH, Tokens.SUFFIXMATCH, Tokens.SUBSTRINGMATCH, + Tokens.EQUALS, Tokens.INCLUDES, Tokens.DASHMATCH])){ + + value += tokenStream.token().value; + value += this._readWhitespace(); + + tokenStream.mustMatch([Tokens.IDENT, Tokens.STRING]); + value += tokenStream.token().value; + value += this._readWhitespace(); + } + + tokenStream.mustMatch(Tokens.RBRACKET); + + return new SelectorSubPart(value + "]", "attribute", token.startLine, token.startCol); + } else { + return null; + } + }, + _pseudo: function(){ + + var tokenStream = this._tokenStream, + pseudo = null, + colons = ":", + line, + col; + + if (tokenStream.match(Tokens.COLON)){ + + if (tokenStream.match(Tokens.COLON)){ + colons += ":"; + } + + if (tokenStream.match(Tokens.IDENT)){ + pseudo = tokenStream.token().value; + line = tokenStream.token().startLine; + col = tokenStream.token().startCol - colons.length; + } else if (tokenStream.peek() == Tokens.FUNCTION){ + line = tokenStream.LT(1).startLine; + col = tokenStream.LT(1).startCol - colons.length; + pseudo = this._functional_pseudo(); + } + + if (pseudo){ + pseudo = new SelectorSubPart(colons + pseudo, "pseudo", line, col); + } + } + + return pseudo; + }, + _functional_pseudo: function(){ + + var tokenStream = this._tokenStream, + value = null; + + if(tokenStream.match(Tokens.FUNCTION)){ + value = tokenStream.token().value; + value += this._readWhitespace(); + value += this._expression(); + tokenStream.mustMatch(Tokens.RPAREN); + value += ")"; + } + + return value; + }, + _expression: function(){ + + var tokenStream = this._tokenStream, + value = ""; + + while(tokenStream.match([Tokens.PLUS, Tokens.MINUS, Tokens.DIMENSION, + Tokens.NUMBER, Tokens.STRING, Tokens.IDENT, Tokens.LENGTH, + Tokens.FREQ, Tokens.ANGLE, Tokens.TIME, + Tokens.RESOLUTION, Tokens.SLASH])){ + + value += tokenStream.token().value; + value += this._readWhitespace(); + } + + return value.length ? value : null; + + }, + _negation: function(){ + + var tokenStream = this._tokenStream, + line, + col, + value = "", + arg, + subpart = null; + + if (tokenStream.match(Tokens.NOT)){ + value = tokenStream.token().value; + line = tokenStream.token().startLine; + col = tokenStream.token().startCol; + value += this._readWhitespace(); + arg = this._negation_arg(); + value += arg; + value += this._readWhitespace(); + tokenStream.match(Tokens.RPAREN); + value += tokenStream.token().value; + + subpart = new SelectorSubPart(value, "not", line, col); + subpart.args.push(arg); + } + + return subpart; + }, + _negation_arg: function(){ + + var tokenStream = this._tokenStream, + args = [ + this._type_selector, + this._universal, + function(){ + return tokenStream.match(Tokens.HASH) ? + new SelectorSubPart(tokenStream.token().value, "id", tokenStream.token().startLine, tokenStream.token().startCol) : + null; + }, + this._class, + this._attrib, + this._pseudo + ], + arg = null, + i = 0, + len = args.length, + elementName, + line, + col, + part; + + line = tokenStream.LT(1).startLine; + col = tokenStream.LT(1).startCol; + + while(i < len && arg === null){ + + arg = args[i].call(this); + i++; + } + if (arg === null){ + this._unexpectedToken(tokenStream.LT(1)); + } + if (arg.type == "elementName"){ + part = new SelectorPart(arg, [], arg.toString(), line, col); + } else { + part = new SelectorPart(null, [arg], arg.toString(), line, col); + } + + return part; + }, + + _declaration: function(){ + + var tokenStream = this._tokenStream, + property = null, + expr = null, + prio = null, + error = null, + invalid = null, + propertyName= ""; + + property = this._property(); + if (property !== null){ + + tokenStream.mustMatch(Tokens.COLON); + this._readWhitespace(); + + expr = this._expr(); + if (!expr || expr.length === 0){ + this._unexpectedToken(tokenStream.LT(1)); + } + + prio = this._prio(); + propertyName = property.toString(); + if (this.options.starHack && property.hack == "*" || + this.options.underscoreHack && property.hack == "_") { + + propertyName = property.text; + } + + try { + this._validateProperty(propertyName, expr); + } catch (ex) { + invalid = ex; + } + + this.fire({ + type: "property", + property: property, + value: expr, + important: prio, + line: property.line, + col: property.col, + invalid: invalid + }); + + return true; + } else { + return false; + } + }, + + _prio: function(){ + + var tokenStream = this._tokenStream, + result = tokenStream.match(Tokens.IMPORTANT_SYM); + + this._readWhitespace(); + return result; + }, + + _expr: function(inFunction){ + + var tokenStream = this._tokenStream, + values = [], + value = null, + operator = null; + + value = this._term(); + if (value !== null){ + + values.push(value); + + do { + operator = this._operator(inFunction); + if (operator){ + values.push(operator); + } /*else { + values.push(new PropertyValue(valueParts, valueParts[0].line, valueParts[0].col)); + valueParts = []; + }*/ + + value = this._term(); + + if (value === null){ + break; + } else { + values.push(value); + } + } while(true); + } + + return values.length > 0 ? new PropertyValue(values, values[0].line, values[0].col) : null; + }, + + _term: function(){ + + var tokenStream = this._tokenStream, + unary = null, + value = null, + token, + line, + col; + unary = this._unary_operator(); + if (unary !== null){ + line = tokenStream.token().startLine; + col = tokenStream.token().startCol; + } + if (tokenStream.peek() == Tokens.IE_FUNCTION && this.options.ieFilters){ + + value = this._ie_function(); + if (unary === null){ + line = tokenStream.token().startLine; + col = tokenStream.token().startCol; + } + } else if (tokenStream.match([Tokens.NUMBER, Tokens.PERCENTAGE, Tokens.LENGTH, + Tokens.ANGLE, Tokens.TIME, + Tokens.FREQ, Tokens.STRING, Tokens.IDENT, Tokens.URI, Tokens.UNICODE_RANGE])){ + + value = tokenStream.token().value; + if (unary === null){ + line = tokenStream.token().startLine; + col = tokenStream.token().startCol; + } + this._readWhitespace(); + } else { + token = this._hexcolor(); + if (token === null){ + if (unary === null){ + line = tokenStream.LT(1).startLine; + col = tokenStream.LT(1).startCol; + } + if (value === null){ + if (tokenStream.LA(3) == Tokens.EQUALS && this.options.ieFilters){ + value = this._ie_function(); + } else { + value = this._function(); + } + } + + } else { + value = token.value; + if (unary === null){ + line = token.startLine; + col = token.startCol; + } + } + + } + + return value !== null ? + new PropertyValuePart(unary !== null ? unary + value : value, line, col) : + null; + + }, + + _function: function(){ + + var tokenStream = this._tokenStream, + functionText = null, + expr = null, + lt; + + if (tokenStream.match(Tokens.FUNCTION)){ + functionText = tokenStream.token().value; + this._readWhitespace(); + expr = this._expr(true); + functionText += expr; + if (this.options.ieFilters && tokenStream.peek() == Tokens.EQUALS){ + do { + + if (this._readWhitespace()){ + functionText += tokenStream.token().value; + } + if (tokenStream.LA(0) == Tokens.COMMA){ + functionText += tokenStream.token().value; + } + + tokenStream.match(Tokens.IDENT); + functionText += tokenStream.token().value; + + tokenStream.match(Tokens.EQUALS); + functionText += tokenStream.token().value; + lt = tokenStream.peek(); + while(lt != Tokens.COMMA && lt != Tokens.S && lt != Tokens.RPAREN){ + tokenStream.get(); + functionText += tokenStream.token().value; + lt = tokenStream.peek(); + } + } while(tokenStream.match([Tokens.COMMA, Tokens.S])); + } + + tokenStream.match(Tokens.RPAREN); + functionText += ")"; + this._readWhitespace(); + } + + return functionText; + }, + + _ie_function: function(){ + + var tokenStream = this._tokenStream, + functionText = null, + expr = null, + lt; + if (tokenStream.match([Tokens.IE_FUNCTION, Tokens.FUNCTION])){ + functionText = tokenStream.token().value; + + do { + + if (this._readWhitespace()){ + functionText += tokenStream.token().value; + } + if (tokenStream.LA(0) == Tokens.COMMA){ + functionText += tokenStream.token().value; + } + + tokenStream.match(Tokens.IDENT); + functionText += tokenStream.token().value; + + tokenStream.match(Tokens.EQUALS); + functionText += tokenStream.token().value; + lt = tokenStream.peek(); + while(lt != Tokens.COMMA && lt != Tokens.S && lt != Tokens.RPAREN){ + tokenStream.get(); + functionText += tokenStream.token().value; + lt = tokenStream.peek(); + } + } while(tokenStream.match([Tokens.COMMA, Tokens.S])); + + tokenStream.match(Tokens.RPAREN); + functionText += ")"; + this._readWhitespace(); + } + + return functionText; + }, + + _hexcolor: function(){ + + var tokenStream = this._tokenStream, + token = null, + color; + + if(tokenStream.match(Tokens.HASH)){ + + token = tokenStream.token(); + color = token.value; + if (!/#[a-f0-9]{3,6}/i.test(color)){ + throw new SyntaxError("Expected a hex color but found '" + color + "' at line " + token.startLine + ", col " + token.startCol + ".", token.startLine, token.startCol); + } + this._readWhitespace(); + } + + return token; + }, + + _keyframes: function(){ + var tokenStream = this._tokenStream, + token, + tt, + name, + prefix = ""; + + tokenStream.mustMatch(Tokens.KEYFRAMES_SYM); + token = tokenStream.token(); + if (/^@\-([^\-]+)\-/.test(token.value)) { + prefix = RegExp.$1; + } + + this._readWhitespace(); + name = this._keyframe_name(); + + this._readWhitespace(); + tokenStream.mustMatch(Tokens.LBRACE); + + this.fire({ + type: "startkeyframes", + name: name, + prefix: prefix, + line: token.startLine, + col: token.startCol + }); + + this._readWhitespace(); + tt = tokenStream.peek(); + while(tt == Tokens.IDENT || tt == Tokens.PERCENTAGE) { + this._keyframe_rule(); + this._readWhitespace(); + tt = tokenStream.peek(); + } + + this.fire({ + type: "endkeyframes", + name: name, + prefix: prefix, + line: token.startLine, + col: token.startCol + }); + + this._readWhitespace(); + tokenStream.mustMatch(Tokens.RBRACE); + + }, + + _keyframe_name: function(){ + var tokenStream = this._tokenStream, + token; + + tokenStream.mustMatch([Tokens.IDENT, Tokens.STRING]); + return SyntaxUnit.fromToken(tokenStream.token()); + }, + + _keyframe_rule: function(){ + var tokenStream = this._tokenStream, + token, + keyList = this._key_list(); + + this.fire({ + type: "startkeyframerule", + keys: keyList, + line: keyList[0].line, + col: keyList[0].col + }); + + this._readDeclarations(true); + + this.fire({ + type: "endkeyframerule", + keys: keyList, + line: keyList[0].line, + col: keyList[0].col + }); + + }, + + _key_list: function(){ + var tokenStream = this._tokenStream, + token, + key, + keyList = []; + keyList.push(this._key()); + + this._readWhitespace(); + + while(tokenStream.match(Tokens.COMMA)){ + this._readWhitespace(); + keyList.push(this._key()); + this._readWhitespace(); + } + + return keyList; + }, + + _key: function(){ + + var tokenStream = this._tokenStream, + token; + + if (tokenStream.match(Tokens.PERCENTAGE)){ + return SyntaxUnit.fromToken(tokenStream.token()); + } else if (tokenStream.match(Tokens.IDENT)){ + token = tokenStream.token(); + + if (/from|to/i.test(token.value)){ + return SyntaxUnit.fromToken(token); + } + + tokenStream.unget(); + } + this._unexpectedToken(tokenStream.LT(1)); + }, + _skipCruft: function(){ + while(this._tokenStream.match([Tokens.S, Tokens.CDO, Tokens.CDC])){ + } + }, + _readDeclarations: function(checkStart, readMargins){ + var tokenStream = this._tokenStream, + tt; + + + this._readWhitespace(); + + if (checkStart){ + tokenStream.mustMatch(Tokens.LBRACE); + } + + this._readWhitespace(); + + try { + + while(true){ + + if (tokenStream.match(Tokens.SEMICOLON) || (readMargins && this._margin())){ + } else if (this._declaration()){ + if (!tokenStream.match(Tokens.SEMICOLON)){ + break; + } + } else { + break; + } + this._readWhitespace(); + } + + tokenStream.mustMatch(Tokens.RBRACE); + this._readWhitespace(); + + } catch (ex) { + if (ex instanceof SyntaxError && !this.options.strict){ + this.fire({ + type: "error", + error: ex, + message: ex.message, + line: ex.line, + col: ex.col + }); + tt = tokenStream.advance([Tokens.SEMICOLON, Tokens.RBRACE]); + if (tt == Tokens.SEMICOLON){ + this._readDeclarations(false, readMargins); + } else if (tt != Tokens.RBRACE){ + throw ex; + } + + } else { + throw ex; + } + } + + }, + _readWhitespace: function(){ + + var tokenStream = this._tokenStream, + ws = ""; + + while(tokenStream.match(Tokens.S)){ + ws += tokenStream.token().value; + } + + return ws; + }, + _unexpectedToken: function(token){ + throw new SyntaxError("Unexpected token '" + token.value + "' at line " + token.startLine + ", col " + token.startCol + ".", token.startLine, token.startCol); + }, + _verifyEnd: function(){ + if (this._tokenStream.LA(1) != Tokens.EOF){ + this._unexpectedToken(this._tokenStream.LT(1)); + } + }, + _validateProperty: function(property, value){ + Validation.validate(property, value); + }, + + parse: function(input){ + this._tokenStream = new TokenStream(input, Tokens); + this._stylesheet(); + }, + + parseStyleSheet: function(input){ + return this.parse(input); + }, + + parseMediaQuery: function(input){ + this._tokenStream = new TokenStream(input, Tokens); + var result = this._media_query(); + this._verifyEnd(); + return result; + }, + parsePropertyValue: function(input){ + + this._tokenStream = new TokenStream(input, Tokens); + this._readWhitespace(); + + var result = this._expr(); + this._readWhitespace(); + this._verifyEnd(); + return result; + }, + parseRule: function(input){ + this._tokenStream = new TokenStream(input, Tokens); + this._readWhitespace(); + + var result = this._ruleset(); + this._readWhitespace(); + this._verifyEnd(); + return result; + }, + parseSelector: function(input){ + + this._tokenStream = new TokenStream(input, Tokens); + this._readWhitespace(); + + var result = this._selector(); + this._readWhitespace(); + this._verifyEnd(); + return result; + }, + parseStyleAttribute: function(input){ + input += "}"; // for error recovery in _readDeclarations() + this._tokenStream = new TokenStream(input, Tokens); + this._readDeclarations(); + } + }; + for (prop in additions){ + if (additions.hasOwnProperty(prop)){ + proto[prop] = additions[prop]; + } + } + + return proto; +}(); +var Properties = { + "alignment-adjust" : "auto | baseline | before-edge | text-before-edge | middle | central | after-edge | text-after-edge | ideographic | alphabetic | hanging | mathematical | | ", + "alignment-baseline" : "baseline | use-script | before-edge | text-before-edge | after-edge | text-after-edge | central | middle | ideographic | alphabetic | hanging | mathematical", + "animation" : 1, + "animation-delay" : { multi: "
    From 964fc79d06c839a9875376ad3f635cd9479162ff Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 29 Nov 2013 14:12:01 +0000 Subject: [PATCH 231/315] feature(util) copyObj: add ability take one param --- lib/client/config.js | 6 +++--- lib/util.js | 7 +++---- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/client/config.js b/lib/client/config.js index 682da486..115de4c0 100644 --- a/lib/client/config.js +++ b/lib/client/config.js @@ -58,10 +58,10 @@ var CloudCmd, Util, DOM; function fillTemplate() { CloudCmd.getConfig(function(config) { - var i, n, div, data, li, param, obj = {}; + var i, n, div, data, li, param, obj; - CONFIG = config; - Util.copyObj(CONFIG, obj); + CONFIG = config; + obj = Util.copyObj(CONFIG); changeConfig(obj); data = Util.render(TEMPLATE, obj); div = DOM.anyload({ diff --git a/lib/util.js b/lib/util.js index 5a06abc8..8716c1f8 100644 --- a/lib/util.js +++ b/lib/util.js @@ -217,11 +217,10 @@ * @param pProps */ this.copyObj = function(pFromObj, pToObj, pProps) { - var lRet = pToObj || pProps || {}, - + var toObj = pToObj || pProps || {}, forIn = function(obj) { Util.forIn(obj, function(name) { - pToObj[name] = obj[name]; + toObj[name] = obj[name]; }); }; @@ -232,7 +231,7 @@ forIn(pFromObj); } - return lRet; + return toObj; }; this.convertArrToObj = function(pArrKeys, pArrVal) { From 91e3025efb30ad473f78986df04acdd2846fe269 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 29 Nov 2013 14:12:22 +0000 Subject: [PATCH 232/315] refactor(commander) fillJSON --- lib/server/commander.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/server/commander.js b/lib/server/commander.js index 38b2753b..8ea1be40 100644 --- a/lib/server/commander.js +++ b/lib/server/commander.js @@ -129,7 +129,7 @@ }; var lName, lStats, lMode, lIsDir; - for (i = 0; i < n; i++ ) { + for (i = 1; i < n; i++ ) { /* Переводим права доступа в 8-ричную систему */ lName = p.files[i]; lStats = p.stats[lName]; @@ -148,7 +148,7 @@ 'mode' : lMode }; - lJSON[i+1] = lJSONFile; + lJSON[i] = lJSONFile; } Util.exec(p.callback, null, lJSON); From 9cc4b2b9389134d86ba6479daaf401f7c7e296b5 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 29 Nov 2013 14:44:26 +0000 Subject: [PATCH 233/315] fix(key) add !alt, !ctrl condition to setCurrentByLetter --- lib/client/key.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/client/key.js b/lib/client/key.js index f5c408c0..ce8bf021 100644 --- a/lib/client/key.js +++ b/lib/client/key.js @@ -75,10 +75,11 @@ var CloudCmd, Util, DOM; var i, n, lCurrent = DOM.getCurrentFile(), lKeyCode = pEvent.keyCode, - lAlt = pEvent.altKey; + lAlt = pEvent.altKey, + lCtrl = pEvent.ctrlKey; /* если клавиши можно обрабатывать*/ if (Binded) { - if (lKeyCode >= KEY.A && lKeyCode <= KEY.Z) + if (!lAlt && !lCtrl && lKeyCode >= KEY.A && lKeyCode <= KEY.Z) setCurrentByLetter(lKeyCode); else switchKey(pEvent); From 41e124ad4c623169b803bd8781d4635aed7ca416 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 29 Nov 2013 14:53:18 +0000 Subject: [PATCH 234/315] fix(commander) fillJSON: add push --- lib/server/commander.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/server/commander.js b/lib/server/commander.js index 8ea1be40..d0c24b5e 100644 --- a/lib/server/commander.js +++ b/lib/server/commander.js @@ -129,7 +129,7 @@ }; var lName, lStats, lMode, lIsDir; - for (i = 1; i < n; i++ ) { + for (i = 0; i < n; i++ ) { /* Переводим права доступа в 8-ричную систему */ lName = p.files[i]; lStats = p.stats[lName]; @@ -148,7 +148,7 @@ 'mode' : lMode }; - lJSON[i] = lJSONFile; + lJSON.push(lJSONFile); } Util.exec(p.callback, null, lJSON); From 9df2503db5bdf95f5b11f79239e901399d46c7f6 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 29 Nov 2013 14:55:50 +0000 Subject: [PATCH 235/315] feature(commander) add changeOrder --- HELP.md | 1 + lib/server/commander.js | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/HELP.md b/HELP.md index 53605e79..7a4790dd 100644 --- a/HELP.md +++ b/HELP.md @@ -394,3 +394,4 @@ Special Thanks - [Elec-ua](https://github.com/elec-ua) - [ru](http://ru.cloudcmd.io "Cloud Commander in Russian") and [ua](http://ua.cloudcmd.io "Cloud Commander in Ukrainian") translations; - config [template](html/config.html) and [style](css/config.css); + - change order of directories and files in [commander](lib/server/commander.js "Commander") diff --git a/lib/server/commander.js b/lib/server/commander.js index d0c24b5e..95bffc31 100644 --- a/lib/server/commander.js +++ b/lib/server/commander.js @@ -156,6 +156,39 @@ } } + function changeOrder(json) { + var file, i, n, + files = [], + dirs = [], + current = [], + path = json[0], + sorted = [path]; + + n = json.length; + for (i = 1; i < n; i++) { + current = json[i]; + + if (current.size === "dir") + dirs.push(current); + else + files.push(current); + } + + n = dirs.length; + for (i = 0; i < n; i++) { + current = dirs[i]; + sorted.push(current); + } + + n = files.length; + for (i = 0; i < n; i++) { + current = files[i]; + sorted.push(current); + } + + return sorted; + } + function getDirPath(pPath) { var lRet = pPath; From 062114fc801546009af739124677862ac851ecb3 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 29 Nov 2013 14:56:56 +0000 Subject: [PATCH 236/315] feature(commander) fillJSON: add changeOrder --- lib/server/commander.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/server/commander.js b/lib/server/commander.js index 95bffc31..21c826bb 100644 --- a/lib/server/commander.js +++ b/lib/server/commander.js @@ -151,6 +151,8 @@ lJSON.push(lJSONFile); } + lJSON = changeOrder(lJSON); + Util.exec(p.callback, null, lJSON); } From 3f9afe5aa123dbe58aeda340c00be047fae9758f Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 29 Nov 2013 15:54:31 +0000 Subject: [PATCH 237/315] refactor(commander) fillJSON --- lib/server/commander.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/server/commander.js b/lib/server/commander.js index 21c826bb..e57f5517 100644 --- a/lib/server/commander.js +++ b/lib/server/commander.js @@ -119,14 +119,12 @@ i, n = p.files.length || 0, /* данные о файлах в формате JSON*/ - lJSON = [], lJSONFile = {}, - lDirPath = getDirPath(p.path); - - lJSON[0] = { - path : lDirPath, - size : 'dir' - }; + lDirPath = getDirPath(p.path), + lJSON = [{ + path : lDirPath, + size : 'dir' + }]; var lName, lStats, lMode, lIsDir; for (i = 0; i < n; i++ ) { From 5cf62055b9c43181cec1c21af8d62c76c916d15a Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 29 Nov 2013 16:05:12 +0000 Subject: [PATCH 238/315] refactor(commander) fillJSON --- lib/server/commander.js | 51 ++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/lib/server/commander.js b/lib/server/commander.js index e57f5517..814cb333 100644 --- a/lib/server/commander.js +++ b/lib/server/commander.js @@ -112,46 +112,49 @@ * @param pFiles - array of files of current directory */ function fillJSON(pParams) { - var lRet = Util.checkObjTrue(pParams, ['files', 'stats', 'path']); + var name, stat, mode, isDir, size, uid, + p, i, n, file, path, json, + ret = Util.checkObjTrue(pParams, ['files', 'stats', 'path']); - if (lRet) { - var p = pParams, - i, n = p.files.length || 0, + if (ret) { + p = pParams; + n = p.files.length; - /* данные о файлах в формате JSON*/ - lJSONFile = {}, - lDirPath = getDirPath(p.path), - lJSON = [{ - path : lDirPath, - size : 'dir' - }]; + /* данные о файлах в формате JSON*/ + file = {}; + path = getDirPath(p.path); + json = [{ + path : path, + size : 'dir' + }]; - var lName, lStats, lMode, lIsDir; for (i = 0; i < n; i++ ) { /* Переводим права доступа в 8-ричную систему */ - lName = p.files[i]; - lStats = p.stats[lName]; + name = p.files[i]; + stat = p.stats[name]; + uid = stat.uid; - if (lStats) { - lMode = (lStats.mode - 0).toString(8); - lIsDir = lStats.isDirectory(); + if (stat) { + mode = Number(stat.mode).toString(8); + isDir = stat.isDirectory(); + size = isDir ? 'dir' : stat.size; } /* Если папка - выводим пиктограмму папки * * В противоположном случае - файла */ - lJSONFile = { + file = { 'name' : p.files[i], - 'size' : lIsDir ? 'dir' : lStats.size, - 'uid' : lStats.uid, - 'mode' : lMode + 'size' : size, + 'uid' : uid, + 'mode' : mode }; - lJSON.push(lJSONFile); + json.push(file); } - lJSON = changeOrder(lJSON); + json = changeOrder(json); - Util.exec(p.callback, null, lJSON); + Util.exec(p.callback, null, json); } } From 03ddc34aee761f9735a5dd86ec14486590c4ed17 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 29 Nov 2013 16:37:40 +0000 Subject: [PATCH 239/315] feature(files) add options --- cloudcmd.js | 6 +++--- lib/server/files.js | 7 +++++-- test/test.js | 8 ++++---- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/cloudcmd.js b/cloudcmd.js index 91fd04ad..da518df0 100644 --- a/cloudcmd.js +++ b/cloudcmd.js @@ -144,12 +144,12 @@ if (Config.ssl) lFiles.push(KEY, CERT); - files.read(lFiles, function(pErrors, pFiles) { + files.read(lFiles, 'utf-8', function(pErrors, pFiles) { if (pErrors) Util.log(pErrors); else { - FileTemplate = pFiles[FILE_TMPL].toString(); - PathTemplate = pFiles[PATH_TMPL].toString(); + FileTemplate = pFiles[FILE_TMPL]; + PathTemplate = pFiles[PATH_TMPL]; if (Config.ssl) lParams.ssl = { diff --git a/lib/server/files.js b/lib/server/files.js index 3809e56a..6a3cb71f 100644 --- a/lib/server/files.js +++ b/lib/server/files.js @@ -16,7 +16,7 @@ CloudFunc = main.cloudfunc, Util = main.util; - object.read = function(pFiles, pCallBack) { + object.read = function(pFiles, pOptions, pCallBack) { var lDone = [], lFiles, lErrors, @@ -55,6 +55,9 @@ } }; + if (!pCallBack) + pCallback = pOptions; + if (Util.isArray(pFiles)) lFiles = pFiles; else @@ -64,7 +67,7 @@ lName = lFiles.pop(); lDone.push(lName); - fs.readFile(lName, Util.call(lDoneFunc, lName)); + fs.readFile(lName, pOptions, Util.call(lDoneFunc, lName)); } }; diff --git a/test/test.js b/test/test.js index aa989413..59c6ccae 100644 --- a/test/test.js +++ b/test/test.js @@ -55,15 +55,15 @@ ''; - files.read(Files, function(pErrors, pFiles){ + files.read(Files, 'utf-8', function(pErrors, pFiles){ if(pErrors) Util.log(pErrors); else{ console.time('CloudFunc.buildFromJSON'); - var lTemplate = pFiles[TEMPLATEPATH].toString(), - lPathTemplate = pFiles[PATHTEMPLATE_PATH].toString(), - lExpect = pFiles[EXPECT_PATH].toString(), + var lTemplate = pFiles[TEMPLATEPATH], + lPathTemplate = pFiles[PATHTEMPLATE_PATH], + lExpect = pFiles[EXPECT_PATH], lResult = CloudFunc.buildFromJSON(lJSON, lTemplate, lPathTemplate); From 1f302296c1c146c1f4757eb30af1139ddc5905b4 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 29 Nov 2013 16:50:41 +0000 Subject: [PATCH 240/315] fix(files) add isFunction condition --- lib/server/files.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/server/files.js b/lib/server/files.js index 6a3cb71f..3c8f6818 100644 --- a/lib/server/files.js +++ b/lib/server/files.js @@ -55,8 +55,10 @@ } }; - if (!pCallBack) - pCallback = pOptions; + if (Util.isFunction(pOptions)) { + pCallBack = pOptions; + pOptions = null; + } if (Util.isArray(pFiles)) lFiles = pFiles; From 0d9331033872e9601090139f68db794820c1153e Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 2 Dec 2013 10:11:19 +0000 Subject: [PATCH 241/315] fix(dom) checkStorageHash: always equal result, never store data --- lib/client/dom.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/client/dom.js b/lib/client/dom.js index b5b5154e..53b47dae 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -1783,7 +1783,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; if (isContain) error = loadHash; - else if (!storeHash || loadHash === storeHash) + else if (loadHash === storeHash) equal = true; Util.exec(callback, error, equal, loadHash); From 0dc0b3e74abb6488ae075b72e204e7d1b812e40c Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 2 Dec 2013 10:28:23 +0000 Subject: [PATCH 242/315] fix(dom) getDataFromStorage: never return hash --- lib/client/dom.js | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/lib/client/dom.js b/lib/client/dom.js index 53b47dae..95d4f0e0 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -1835,21 +1835,15 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; if (!allowed || isDir) Util.exec(callback); - else { - hash = Storage.get(nameHash); - - if (!hash) - Util.exec(callback); - else - DOM.checkStorageHash(name, function(error, equal, hash) { - var data; - - if (!error && equal) - data = Storage.get(nameData, data); - - Util.exec(callback, data, hash); - }); - } + else + DOM.checkStorageHash(name, function(error, equal, hash) { + var data; + + if (!error && equal) + data = Storage.get(nameData, data); + + Util.exec(callback, data, hash); + }); }); }; From b21910f2eb5661d66d6f0518f2f3f662a351be8f Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 2 Dec 2013 10:38:07 +0000 Subject: [PATCH 243/315] feature(edit) add get data from storage before diff --- lib/client/edit.js | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/lib/client/edit.js b/lib/client/edit.js index 991563f8..fcfa903c 100644 --- a/lib/client/edit.js +++ b/lib/client/edit.js @@ -189,21 +189,28 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch; } function diff(pNewValue, pCallBack) { - var libs = [ + var libs = [ LIBDIR + 'diff.js', LIBDIR + 'diff/diff-match-patch.js' ], - url = CloudFunc.getCombineURL(libs); + url = CloudFunc.getCombineURL(libs); DOM.jsload(url, function() { - var patch; + var patch, + isAllowed = DOM.Storage.isAllowed(); if (!Diff) - Diff = new DiffProto(diff_match_patch); + Diff = new DiffProto(diff_match_patch); - patch = Diff.createPatch(Value, pNewValue); - - Util.exec(pCallBack, patch); + Util.ifExec(!isAllowed, function() { + patch = Diff.createPatch(Value, pNewValue); + Util.exec(pCallBack, patch); + }, function(callback) { + DOM.getCurrentData(function(data) { + Value = data.data; + callback(); + }); + }); }); } From f2f41f9643018767a02cc12841d218a0003336f8 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 2 Dec 2013 10:43:21 +0000 Subject: [PATCH 244/315] chore(cloudfunc) add " " --- lib/cloudfunc.js | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/lib/cloudfunc.js b/lib/cloudfunc.js index 4d0c2d36..4181905b 100644 --- a/lib/cloudfunc.js +++ b/lib/cloudfunc.js @@ -271,10 +271,11 @@ var Util; var lShortName, folders = [], i = 0; - do{ + + do { folders[i++] = url; - url = url.substr(url,url.lastIndexOf('/')); - }while(url !== ''); + url = url.substr(url, url.lastIndexOf('/')); + } while(url !== ''); /* Формируем ссылки на каждый каталог в пути */ var lHref = ' Date: Mon, 2 Dec 2013 12:44:06 +0000 Subject: [PATCH 247/315] refactor(dom) saveDatatToStorage && getDataFromStorage do not call checkStorageHash --- lib/client/dom.js | 49 +++++++++++++++++++++++----------------------- lib/client/edit.js | 23 ++++++++++++++-------- 2 files changed, 40 insertions(+), 32 deletions(-) diff --git a/lib/client/dom.js b/lib/client/dom.js index 95d4f0e0..47419a6e 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -1520,14 +1520,15 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; error : pCallBack.error }; - DOM.getDataFromStorage(lPath, function(data, hash) { - if (data) - lFunc(data); - else { - lHash = hash; - DOM.getCurrentFileContent(lParams, lCurrentFile); - } - }); + + DOM.checkStorageHash(lPath, function(error, equal, hash) { + Util.ifExec(!error && equal, function() { + DOM.getDataFromStorage(lPath, lFunc); + }, function() { + lHash = hash; + DOM.getCurrentFileContent(lParams, lCurrentFile); + }); + }); }; @@ -1797,7 +1798,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; * @param data * @param callback */ - this.saveDataToStorage = function(name, data, callback) { + this.saveDataToStorage = function(name, data, hash, callback) { CloudCmd.getConfig(function(config) { var allowed = config.localStorage, isDir = DOM.isCurrentIsDir(), @@ -1807,13 +1808,16 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; if (!allowed || isDir) Util.exec(callback); else - DOM.checkStorageHash(name, function(error, equal, hash) { - if (!error && !equal) { - Storage.set(nameHash, hash); - Storage.set(nameData, data); - } + Util.ifExec(hash, function() { + Storage.set(nameHash, hash); + Storage.set(nameData, data); Util.exec(callback, hash); + }, function(callback) { + DOM.loadCurrentHash(function(loadHash) { + hash = loadHash; + callback(); + }); }); }); }; @@ -1827,7 +1831,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; */ this.getDataFromStorage = function(name, callback) { CloudCmd.getConfig(function(config) { - var hash, + var data, hash, nameHash = name + '-hash', nameData = name + '-data', allowed = config.localStorage, @@ -1835,15 +1839,12 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; if (!allowed || isDir) Util.exec(callback); - else - DOM.checkStorageHash(name, function(error, equal, hash) { - var data; - - if (!error && equal) - data = Storage.get(nameData, data); - - Util.exec(callback, data, hash); - }); + else { + data = Storage.get(nameData); + hash = Storage.get(nameHash); + + Util.exec(callback, data, hash); + } }); }; diff --git a/lib/client/edit.js b/lib/client/edit.js index fcfa903c..3375bebe 100644 --- a/lib/client/edit.js +++ b/lib/client/edit.js @@ -159,7 +159,12 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch; var query, isAllowed = DOM.Storage.isAllowed(), isString = Util.isString(patch), - lessLength = patch.length < lValue.length; + lessLength = patch.length < lValue.length, + onSave = function(hash) { + return function(data) { + onSave(data, hash); + }; + }; Value = lValue; @@ -169,15 +174,15 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch; } - Util.ifExec(!isAllowed, function() { - DOM.RESTful.save(lPath, lValue, onSave, query); + Util.ifExec(!isAllowed, function(loadHash) { + DOM.RESTful.save(lPath, lValue, onSave(loadHash), query); }, function(callback) { - DOM.checkStorageHash(lPath, function(error, equal) { + DOM.checkStorageHash(lPath, function(error, equal, loadHash) { if (!error) { if (!equal) query = ''; - callback(); + callback(loadHash); } }); }); @@ -206,8 +211,10 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch; patch = Diff.createPatch(Value, pNewValue); Util.exec(pCallBack, patch); }, function(callback) { - DOM.getCurrentData(function(data) { - Value = data.data; + var path = DOM.getCurrentPath(); + + DOM.getDataFromStorage(path, function(data) { + Value = data; callback(); }); }); @@ -254,7 +261,7 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch; if (!isError) { Edit.showMessage(text); - DOM.saveDataToStorage(path, Value); + DOM.saveDataToStorage(path, Value, hash); } else { ret = Dialog.confirm(text + msg); From 7286d211979e8ee8e0456690dd8100854ad13725 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 2 Dec 2013 12:48:58 +0000 Subject: [PATCH 248/315] fix(edit) onSave -> getSave --- lib/client/edit.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/client/edit.js b/lib/client/edit.js index 3375bebe..8d216bf7 100644 --- a/lib/client/edit.js +++ b/lib/client/edit.js @@ -160,7 +160,7 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch; isAllowed = DOM.Storage.isAllowed(), isString = Util.isString(patch), lessLength = patch.length < lValue.length, - onSave = function(hash) { + getSave = function(hash) { return function(data) { onSave(data, hash); }; @@ -175,7 +175,7 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch; Util.ifExec(!isAllowed, function(loadHash) { - DOM.RESTful.save(lPath, lValue, onSave(loadHash), query); + DOM.RESTful.save(lPath, lValue, getSave(loadHash), query); }, function(callback) { DOM.checkStorageHash(lPath, function(error, equal, loadHash) { if (!error) { From 56372060d7a0c510d6145c805b58175c84677781 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 2 Dec 2013 13:02:33 +0000 Subject: [PATCH 249/315] chore(commander) mv comment to cloudfunc --- lib/cloudfunc.js | 2 ++ lib/server/commander.js | 4 +--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/cloudfunc.js b/lib/cloudfunc.js index b87324b3..13d6d313 100644 --- a/lib/cloudfunc.js +++ b/lib/cloudfunc.js @@ -391,6 +391,8 @@ var Util; var lFile = files[i]; lFileTable += Util.render(pTemplate,{ + /* Если папка - выводим пиктограмму папки * + * В противоположном случае - файла */ type : lFile.size === 'dir' ? 'directory' : 'text-file', link : FS + lPath + lFile.name, target : lFile.size === 'dir' ? '' : "_blank", diff --git a/lib/server/commander.js b/lib/server/commander.js index b1c54a66..2f1835a6 100644 --- a/lib/server/commander.js +++ b/lib/server/commander.js @@ -130,19 +130,17 @@ files = json.files; for (i = 0; i < n; i++ ) { - /* Переводим права доступа в 8-ричную систему */ name = p.files[i]; stat = p.stats[name]; uid = stat.uid; if (stat) { + /* Переводим права доступа в 8-ричную систему */ mode = Number(stat.mode).toString(8); isDir = stat.isDirectory(); size = isDir ? 'dir' : stat.size; } - /* Если папка - выводим пиктограмму папки * - * В противоположном случае - файла */ file = { 'name' : name, 'size' : size, From 25675ce4d38bb31d6e9d29e1ab54e95d55f78976 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 2 Dec 2013 13:04:10 +0000 Subject: [PATCH 250/315] chore(cloudfunc) getUserUIDsAndNames: add " " --- lib/cloudfunc.js | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/lib/cloudfunc.js b/lib/cloudfunc.js index 13d6d313..f82b649a 100644 --- a/lib/cloudfunc.js +++ b/lib/cloudfunc.js @@ -236,29 +236,28 @@ var Util; var lUsers = {name:'', uid:''}, lUsersData = [], i = 0; - do{ + do { /* получаем первую строку */ var lLine = pPasswd_s.substr(pPasswd_s, pPasswd_s.indexOf('\n') + 1); if(lLine) { - - /* удаляем первую строку из /etc/passwd*/ - pPasswd_s = Util.removeStr(pPasswd_s, lLine); - - /* получаем первое слово строки */ - var lName = lLine.substr(lLine,lLine.indexOf(':')); - lLine = Util.removeStr(lLine, lName + ':x:'); - - /* получаем uid*/ - var lUID = lLine.substr(lLine,lLine.indexOf(':')); - if((lUID - 0).toString()!=='NaN') { - lUsers.name = lName; - lUsers.uid = lUID; - lUsersData[i++] = lUsers; - console.log('uid='+lUID+' name='+lName); + /* удаляем первую строку из /etc/passwd*/ + pPasswd_s = Util.removeStr(pPasswd_s, lLine); + + /* получаем первое слово строки */ + var lName = lLine.substr(lLine,lLine.indexOf(':')); + lLine = Util.removeStr(lLine, lName + ':x:'); + + /* получаем uid*/ + var lUID = lLine.substr(lLine,lLine.indexOf(':')); + if((lUID - 0).toString()!=='NaN') { + lUsers.name = lName; + lUsers.uid = lUID; + lUsersData[i++] = lUsers; + console.log('uid='+lUID+' name='+lName); + } } - } - }while(pPasswd_s !== ''); + } while(pPasswd_s !== ''); return lUsersData; }; From 0b6dfcb7b3717d3b83398c68d2c08c9207205881 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 2 Dec 2013 13:19:30 +0000 Subject: [PATCH 251/315] refactor(cloudfunc) getNumericPermissions --- lib/cloudfunc.js | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/lib/cloudfunc.js b/lib/cloudfunc.js index f82b649a..a5ed37c6 100644 --- a/lib/cloudfunc.js +++ b/lib/cloudfunc.js @@ -184,22 +184,28 @@ var Util; * в цыфровой */ this.getNumericPermissions = function(pPerm_s) { - if(!pPerm_s || pPerm_s.length!==11)return pPerm_s; + var owner, group, all, + perms = pPerm_s, + length = perms && perms.length === 11; - var lOwner= (pPerm_s[0] === 'r' ? 4 : 0) + - (pPerm_s[1] === 'w' ? 2 : 0) + - (pPerm_s[2] === 'x' ? 1 : 0), + if (length) { + owner = (pPerm_s[0] === 'r' ? 4 : 0) + + (pPerm_s[1] === 'w' ? 2 : 0) + + (pPerm_s[2] === 'x' ? 1 : 0), + + group = (pPerm_s[4] === 'r' ? 4 : 0) + + (pPerm_s[5] === 'w' ? 2 : 0) + + (pPerm_s[6] === 'x' ? 1 : 0), - lGroup= (pPerm_s[4] === 'r' ? 4 : 0) + - (pPerm_s[5] === 'w' ? 2 : 0) + - (pPerm_s[6] === 'x' ? 1 : 0), - - lAll = (pPerm_s[8] === 'r' ? 4 : 0) + - (pPerm_s[9] === 'w' ? 2 : 0) + - (pPerm_s[10] === 'x' ? 1 : 0); + all = (pPerm_s[8] === 'r' ? 4 : 0) + + (pPerm_s[9] === 'w' ? 2 : 0) + + (pPerm_s[10] === 'x' ? 1 : 0); + + /* добавляем 2 цыфры до 5 */ + perms = '00' + owner + group + all; + } - /* добавляем 2 цыфры до 5 */ - return '00' + lOwner + lGroup + lAll; + return perms; }; /** Функция получает короткие размеры From d90427c50eed94093455ab87d324704f1ab18436 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 2 Dec 2013 13:20:16 +0000 Subject: [PATCH 252/315] =?UTF-8?q?chore(cloudfunc)=20=D1=86=D1=8B=D1=84?= =?UTF-8?q?=D1=80=D1=8B=20->=20=D1=86=D0=B8=D1=84=D1=80=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/cloudfunc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/cloudfunc.js b/lib/cloudfunc.js index a5ed37c6..a91e157b 100644 --- a/lib/cloudfunc.js +++ b/lib/cloudfunc.js @@ -201,7 +201,7 @@ var Util; (pPerm_s[9] === 'w' ? 2 : 0) + (pPerm_s[10] === 'x' ? 1 : 0); - /* добавляем 2 цыфры до 5 */ + /* добавляем 2 цифры до 5 */ perms = '00' + owner + group + all; } From 482d6a17e66a601ad4894d3914f87b99e439815c Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 2 Dec 2013 13:34:55 +0000 Subject: [PATCH 253/315] refactor(cloudfunc) buildFromJSON --- lib/cloudfunc.js | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/lib/cloudfunc.js b/lib/cloudfunc.js index a91e157b..71aa1be1 100644 --- a/lib/cloudfunc.js +++ b/lib/cloudfunc.js @@ -339,7 +339,8 @@ var Util; * {name:'имя',size:'размер',mode:'права доступа'}] */ this.buildFromJSON = function(pJSON, pTemplate, pPathTemplate) { - var files = pJSON.files, + var lFile, type, link, target, size, owner, mode, + files = pJSON.files, /* сохраняем путь каталога в котором мы сейчас находимся*/ lPath = pJSON.path, @@ -393,18 +394,24 @@ var Util; } for(var i = 0, n = files.length; i < n; i++) { - var lFile = files[i]; + lFile = files[i]; + type = lFile.size === 'dir' ? 'directory' : 'text-file'; + link = FS + lPath + lFile.name; + target = lFile.size === 'dir' ? '' : "_blank"; + size = lFile.size === 'dir' ? '<dir>' : CloudFunc.getShortSize( lFile.size ); + owner = !lFile.uid ? 'root' : lFile.uid; + mode = CloudFunc.getSymbolicPermissions(lFile.mode); lFileTable += Util.render(pTemplate,{ /* Если папка - выводим пиктограмму папки * * В противоположном случае - файла */ - type : lFile.size === 'dir' ? 'directory' : 'text-file', - link : FS + lPath + lFile.name, - target : lFile.size === 'dir' ? '' : "_blank", + type : type, + link : link, + target : target, name : lFile.name, - size : lFile.size === 'dir' ? '<dir>' : CloudFunc.getShortSize( lFile.size ), - owner : !lFile.uid ? 'root' : lFile.uid, - mode : CloudFunc.getSymbolicPermissions(lFile.mode) + size : size, + owner : owner, + mode : mode }); } From 63eda23f1a5711b7e7990579891346fda588a97b Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 2 Dec 2013 13:42:49 +0000 Subject: [PATCH 254/315] fix(edit) set patch only if hashes same --- lib/client/edit.js | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/lib/client/edit.js b/lib/client/edit.js index 8d216bf7..21e3b121 100644 --- a/lib/client/edit.js +++ b/lib/client/edit.js @@ -158,8 +158,6 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch; Util.ifExec(!isDiff, function(patch) { var query, isAllowed = DOM.Storage.isAllowed(), - isString = Util.isString(patch), - lessLength = patch.length < lValue.length, getSave = function(hash) { return function(data) { onSave(data, hash); @@ -167,20 +165,19 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch; }; Value = lValue; - - if (isString && patch.length && lessLength) { - lValue = patch; - query = '?patch'; - } - - + Util.ifExec(!isAllowed, function(loadHash) { DOM.RESTful.save(lPath, lValue, getSave(loadHash), query); }, function(callback) { DOM.checkStorageHash(lPath, function(error, equal, loadHash) { + var isString = Util.isString(patch), + lessLength = patch.length < lValue.length; + if (!error) { - if (!equal) - query = ''; + if (equal && isString && patch.length && lessLength) { + lValue = patch; + query = '?patch'; + } callback(loadHash); } From 8cbc2bcd12ebd29912b6ef8347f95690794fd9f3 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 2 Dec 2013 16:45:39 +0000 Subject: [PATCH 255/315] fix(edit) add data check condition --- lib/client/edit.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/client/edit.js b/lib/client/edit.js index 21e3b121..0a1f3bd0 100644 --- a/lib/client/edit.js +++ b/lib/client/edit.js @@ -211,7 +211,9 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch; var path = DOM.getCurrentPath(); DOM.getDataFromStorage(path, function(data) { - Value = data; + if (data) + Value = data; + callback(); }); }); From 47a5d6ad907b10cea8c98ed04b4ed222f2418096 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 2 Dec 2013 16:57:18 +0000 Subject: [PATCH 256/315] feature(ssl) add signed ssl --- ssl/certrequest.csr | 18 ++++++++++++ ssl/privatekey.pem | 27 ++++++++++++++++++ ssl/self-signed-certificate.pem | 22 +++++++++++++++ ssl/signed-ssl.crt | 30 ++++++++++++++++++++ ssl/ssl.crt | 39 ++++++++++++------------- ssl/ssl.key | 50 ++++++++++++++++----------------- 6 files changed, 142 insertions(+), 44 deletions(-) create mode 100644 ssl/certrequest.csr create mode 100644 ssl/privatekey.pem create mode 100644 ssl/self-signed-certificate.pem create mode 100644 ssl/signed-ssl.crt diff --git a/ssl/certrequest.csr b/ssl/certrequest.csr new file mode 100644 index 00000000..d96e85a6 --- /dev/null +++ b/ssl/certrequest.csr @@ -0,0 +1,18 @@ +-----BEGIN CERTIFICATE REQUEST----- +MIIC1TCCAb0CAQAwgY8xCzAJBgNVBAYTAk5SMRMwEQYDVQQIDApTb21lLVN0YXRl +MRIwEAYDVQQHDAlBbXN0ZXJkYW0xGDAWBgNVBAoMD0Nsb3VkIENvbW1hbmRlcjEW +MBQGA1UEAwwNKi5jbG91ZGNtZC5pbzElMCMGCSqGSIb3DQEJARYWY29kZXJhaXNl +ckBjbG91ZGNtZC5pbzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBANDe +gEVSuTXljMsa/YPK0xqW4I+WKzZIbgoXxEqzAIogNH/yo17wFloS2ZvnY1vsTwrB +8Dde4y5loOOz+Kp40yNadApGihpvuw5IKy5AiIPC8HOdZhEmrG0IrPPGJiNsCfP2 +0b4cyW492mNnlx9PuY6NW4Q6PlSnFXR07NIFeBYRycXhYe9JZKChqYTutkn66wn6 +07LXX74h1nUvyuU8miXpRPjpu+ND+gMNuKNox1rn/P/gr4JiuZ+i+eNSpHpKdfKy +/r1GPty9c1QuGbTTpwP+BfPW/5OppYCuQ1lpaoGLg52IGzF4SJ0LZKITs4oi/8Nv +jOhl3afVxxyGunvqZpECAwEAAaAAMA0GCSqGSIb3DQEBBQUAA4IBAQDIstGSmldk +4O2IJ+VF1a3/h6kh5gDFmli9CZzrXcrr+oMSTGemF3o6qkkLMsKNreGGqhRVlDR/ +YlYevxEx0PP/dv6zMhrEgvC1IAYOdS4bCZFWlQMIaVnyRbMw/cTO7Xm00DrPR/1E +fLkq8RMU98PonJzD+jjddlE8mX7I7LwmHOgbwjSJ5yZgHj+WgTtRRLt+PxwSsW8z +bGMBEFFvT7ypOubcDThZXjeuI26C7XFPDQLYBy30sGV+cUJ8ZuWNoKU+lsyy0C8N +dx4XuTI6QEt4LIoKypU5/JhfCsTehDWfcNMNWgytcTubqnbIXpcYCDvE0dcS15oF +QGHlJzt4I5Bg +-----END CERTIFICATE REQUEST----- diff --git a/ssl/privatekey.pem b/ssl/privatekey.pem new file mode 100644 index 00000000..31e55bbb --- /dev/null +++ b/ssl/privatekey.pem @@ -0,0 +1,27 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEowIBAAKCAQEA0N6ARVK5NeWMyxr9g8rTGpbgj5YrNkhuChfESrMAiiA0f/Kj +XvAWWhLZm+djW+xPCsHwN17jLmWg47P4qnjTI1p0CkaKGm+7DkgrLkCIg8Lwc51m +ESasbQis88YmI2wJ8/bRvhzJbj3aY2eXH0+5jo1bhDo+VKcVdHTs0gV4FhHJxeFh +70lkoKGphO62SfrrCfrTstdfviHWdS/K5TyaJelE+Om740P6Aw24o2jHWuf8/+Cv +gmK5n6L541Kkekp18rL+vUY+3L1zVC4ZtNOnA/4F89b/k6mlgK5DWWlqgYuDnYgb +MXhInQtkohOziiL/w2+M6GXdp9XHHIa6e+pmkQIDAQABAoIBAFR/fyMMaVMtj3zn +aWI03pxmJ2jPVqH6QVIh9U5HBlPa3YJZldAljtVXxOM2g9K/UebHOLgd0giGIsWb +nGDSypAF2uYBTYOOaf1IIvfuMYwkhAQxzAXqQF1H4jgolGtGHOyukIG5wZ+wtDX8 +xX1sUmQiOcDPk0HJ6nsXhmscvU0nnyD3eb7o9ls4dok2qPNSYV77cDi8wYCPKDl7 +Z+esk8memgWJNmHIeLfhuy01Vrw2R5PRO+t0PelHOAnMBklpt3IaX+ZMMakX44Bw +iyuPY2H02jQb+fCqF2f2qkV+Z4+UxnPnYZ3a2xfcluUfgf5w1YTH7T0wIZLSTCtf +PR76UHUCgYEA/r04RhO/qbIZRR3h2CV4xQ8xr8ujcAF3OApj8ktIsikjVPo+2QDe +kfPnp6tpZz5Fxee5PDGMHu6dRevg2CvXgt/2kvMQg8pe0dozgEdvnijWQJHmK3jr +mJssQZ0Aa6DrpWS19JDRrfJLTiOa9Oes/HC/3iT6drQVt7dam3TJk8sCgYEA0eco +ycL3m9uvzJmEtkPWduF4b7oo1v8F+RFcEZQbP5xFXc6b8KwzTuSmXrAE+eu/O4GM +F/7om8cOIRqodTVVrMqhIlossYd6ROUgikRW2HVr13y+OQxJnzoq9Xs/UkOBMRb6 +v3HxIHy8EFYlVBXKJJmcv22J6BjH5o4WyYF4e5MCgYBl145c7d5NYKebq1O0T17W +Ibnyl05TJDLek8DbiF+a4rl+asGfjiptXX662Nu96/aHJZo3x3NGlo0H/EKbCgQS +DaoNm+F5XvnDmiHG4khsidUGYY4MyT4fd8IcxUD6xo4PRJE+InvBuEGFDtUPnmPZ +VNZQYKZFuL+KAGLYDbvdOwKBgQCbNwJUYBXVbNhMxWD7nqJiekwi4lf808xI52tb +nFeh7B7nRTbO+6ddOXtFHYgwfwGEMUG1JMxBFSr/k8TqFyxpf9Uzn9bY2EOz2nL7 +i5lkqz+5swa/DLUMR2ko6aBjZoOMF2AIXWtfCJ3QvsMPsKUv91+PtqJ5vIlllcCH +9XNwfQKBgAzII/P6h9dXO/RkmjMmK+ahpJhk+gwUn93TaIL6VN/NMhKf3jHylRKD +843x+BC26ZuK2wAZHI8TMR6VQVbepe1ewyP0lknx73qgS+nnpK31Ez9GsNp7MgP+ +J4DQTLEl2vzhYiHEcgEOO4J/Jm0TBfjkxSVIVg2RufQTZ+aNIeNM +-----END RSA PRIVATE KEY----- diff --git a/ssl/self-signed-certificate.pem b/ssl/self-signed-certificate.pem new file mode 100644 index 00000000..2b1ce200 --- /dev/null +++ b/ssl/self-signed-certificate.pem @@ -0,0 +1,22 @@ +-----BEGIN CERTIFICATE----- +MIIDnDCCAoQCCQCJOiYxvMr/GDANBgkqhkiG9w0BAQUFADCBjzELMAkGA1UEBhMC +TlIxEzARBgNVBAgMClNvbWUtU3RhdGUxEjAQBgNVBAcMCUFtc3RlcmRhbTEYMBYG +A1UECgwPQ2xvdWQgQ29tbWFuZGVyMRYwFAYDVQQDDA0qLmNsb3VkY21kLmlvMSUw +IwYJKoZIhvcNAQkBFhZjb2RlcmFpc2VyQGNsb3VkY21kLmlvMB4XDTEzMTIwMjE2 +Mjc1MVoXDTE0MDEwMTE2Mjc1MVowgY8xCzAJBgNVBAYTAk5SMRMwEQYDVQQIDApT +b21lLVN0YXRlMRIwEAYDVQQHDAlBbXN0ZXJkYW0xGDAWBgNVBAoMD0Nsb3VkIENv +bW1hbmRlcjEWMBQGA1UEAwwNKi5jbG91ZGNtZC5pbzElMCMGCSqGSIb3DQEJARYW +Y29kZXJhaXNlckBjbG91ZGNtZC5pbzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC +AQoCggEBANDegEVSuTXljMsa/YPK0xqW4I+WKzZIbgoXxEqzAIogNH/yo17wFloS +2ZvnY1vsTwrB8Dde4y5loOOz+Kp40yNadApGihpvuw5IKy5AiIPC8HOdZhEmrG0I +rPPGJiNsCfP20b4cyW492mNnlx9PuY6NW4Q6PlSnFXR07NIFeBYRycXhYe9JZKCh +qYTutkn66wn607LXX74h1nUvyuU8miXpRPjpu+ND+gMNuKNox1rn/P/gr4JiuZ+i ++eNSpHpKdfKy/r1GPty9c1QuGbTTpwP+BfPW/5OppYCuQ1lpaoGLg52IGzF4SJ0L +ZKITs4oi/8NvjOhl3afVxxyGunvqZpECAwEAATANBgkqhkiG9w0BAQUFAAOCAQEA +e3UIplqybxn0tJzENCqrel+For7oH3MnUee9UbhpQKxsvsXvlnpeETapSGDIiU6x +6Dh4nze0SYw9aQCCdPGYbO59pWGgBgJ7YjY/saNKImB2sKIocMKx5Afaec19y71I +ZzuAWXXFpPWJt1MogmOOmE5aPhiXIu+eEhNkuc8GVDMEKi0Xm4gCaiOzj7GupZPM +UeYE+h7Lh8RYwhOqKNHLXACYGKF8/bidhJdYnRj0Mpht/evwkstt5XrZ/NrkBc1O +0Q8rIyufZa462DGrWTwpbSaJggNtRPgKQgSWDclo+dPHwCOb661WvMtKy/xZaCpW +ilAZADBmvZjPf8SNOjWYew== +-----END CERTIFICATE----- diff --git a/ssl/signed-ssl.crt b/ssl/signed-ssl.crt new file mode 100644 index 00000000..1d7f1ed1 --- /dev/null +++ b/ssl/signed-ssl.crt @@ -0,0 +1,30 @@ +-----BEGIN CERTIFICATE----- +MIIFGTCCBAGgAwIBAgISESHsZvgJjilB3QcdXIlJqtAhMA0GCSqGSIb3DQEBBQUA +MFcxCzAJBgNVBAYTAkJFMRkwFwYDVQQKExBHbG9iYWxTaWduIG52LXNhMS0wKwYD +VQQDEyRHbG9iYWxTaWduIERvbWFpbiBWYWxpZGF0aW9uIENBIC0gRzIwHhcNMTMx +MjAyMTYzODQ5WhcNMTQxMjAzMTYzODQ5WjA7MSEwHwYDVQQLExhEb21haW4gQ29u +dHJvbCBWYWxpZGF0ZWQxFjAUBgNVBAMMDSouY2xvdWRjbWQuaW8wggEiMA0GCSqG +SIb3DQEBAQUAA4IBDwAwggEKAoIBAQDQ3oBFUrk15YzLGv2DytMaluCPlis2SG4K +F8RKswCKIDR/8qNe8BZaEtmb52Nb7E8KwfA3XuMuZaDjs/iqeNMjWnQKRooab7sO +SCsuQIiDwvBznWYRJqxtCKzzxiYjbAnz9tG+HMluPdpjZ5cfT7mOjVuEOj5UpxV0 +dOzSBXgWEcnF4WHvSWSgoamE7rZJ+usJ+tOy11++IdZ1L8rlPJol6UT46bvjQ/oD +DbijaMda5/z/4K+CYrmfovnjUqR6SnXysv69Rj7cvXNULhm006cD/gXz1v+TqaWA +rkNZaWqBi4OdiBsxeEidC2SiE7OKIv/Db4zoZd2n1ccchrp76maRAgMBAAGjggH5 +MIIB9TAOBgNVHQ8BAf8EBAMCBaAwSQYDVR0gBEIwQDA+BgZngQwBAgEwNDAyBggr +BgEFBQcCARYmaHR0cHM6Ly93d3cuZ2xvYmFsc2lnbi5jb20vcmVwb3NpdG9yeS8w +YgYDVR0RBFswWYINKi5jbG91ZGNtZC5pb4IPb3dhLmNsb3VkY21kLmlvghBtYWls +LmNsb3VkY21kLmlvghhhdXRvZGlzY292ZXIuY2xvdWRjbWQuaW+CC2Nsb3VkY21k +LmlvMAkGA1UdEwQCMAAwHQYDVR0lBBYwFAYIKwYBBQUHAwEGCCsGAQUFBwMCMD8G +A1UdHwQ4MDYwNKAyoDCGLmh0dHA6Ly9jcmwuZ2xvYmFsc2lnbi5jb20vZ3MvZ3Nk +b21haW52YWxnMi5jcmwwgYgGCCsGAQUFBwEBBHwwejBBBggrBgEFBQcwAoY1aHR0 +cDovL3NlY3VyZS5nbG9iYWxzaWduLmNvbS9jYWNlcnQvZ3Nkb21haW52YWxnMi5j +cnQwNQYIKwYBBQUHMAGGKWh0dHA6Ly9vY3NwMi5nbG9iYWxzaWduLmNvbS9nc2Rv +bWFpbnZhbGcyMB0GA1UdDgQWBBQjVy2oLxx/HjEYvqXqbpsoU1g/bDAfBgNVHSME +GDAWgBSWrfqwW7mDZCp2whyKadpC3P79KDANBgkqhkiG9w0BAQUFAAOCAQEApoAT +EZo8UDrxKKH6aq5Mj+r2TpXfUsHclyTeW09/BQpfTBV/DYVygAL0cUvaHMaKCoP0 +EN+P6lbffo2Iho+9QZdP4katpeDRkTRNsFlnVhL8K6M2p7YFkn6HBqYE6woDdMM0 +RJU3N6Jyowbb5XFHnfc0Tpkjrn846FUA+19QTszX1/0rkfuTJdhEJNlnwVE/Jyr4 +6rKCWpfWoVCopOcXJU+IMMiee8IFFSWZP3wZnBL5rc3i+lk3n69+Zio9nBIy+NUi +bR9KDIIUq04LH/kkY1I4lJW0B4jFgxz4cq5aEMR4nWUZMElb9rQAh9lquByXk8uc +/5/OJUsYcYSmwJd2Ag== +-----END CERTIFICATE----- \ No newline at end of file diff --git a/ssl/ssl.crt b/ssl/ssl.crt index bceeeee9..2b1ce200 100644 --- a/ssl/ssl.crt +++ b/ssl/ssl.crt @@ -1,21 +1,22 @@ -----BEGIN CERTIFICATE----- -MIIDcjCCAloCCQCJ1Y1N9jxT4zANBgkqhkiG9w0BAQUFADB7MQswCQYDVQQGEwJJ -TzEYMBYGA1UECAwPQ2xvdWQgQ29tbWFuZGVyMRgwFgYDVQQKDA9DbG91ZCBDb21t -YW5kZXIxETAPBgNVBAMMCGNsb3VkY21kMSUwIwYJKoZIhvcNAQkBFhZjb2RlcmFp -c2VyQGNsb3VkY21kLmlvMB4XDTEzMTEyMjA5MTY0N1oXDTEzMTIyMjA5MTY0N1ow -ezELMAkGA1UEBhMCSU8xGDAWBgNVBAgMD0Nsb3VkIENvbW1hbmRlcjEYMBYGA1UE -CgwPQ2xvdWQgQ29tbWFuZGVyMREwDwYDVQQDDAhjbG91ZGNtZDElMCMGCSqGSIb3 -DQEJARYWY29kZXJhaXNlckBjbG91ZGNtZC5pbzCCASIwDQYJKoZIhvcNAQEBBQAD -ggEPADCCAQoCggEBAL5O4g6yQKstjiEQ66nLUCUHil1rVTvPhqEDkgb5jeM3HP8M -iexEyM2soLBJZQnILbtasVqkqDDduvmHyQ0hqNyKfMwJcmUXQyKg45XJX7sLvSk5 -0eJPSfg9Xq+taZiTpE4ZKX0DeJ7ZJr/VjtK5LewV0/uP+lfzQ2BlUyxOsEDm+83o -D9cve7N+7ZnyDzo8VEMgHufaFgMBurbHi1BeiXor3Uwqpa6RoGa0AR1LL9h30mY4 -0/Jl7Cy+XewQ92SJuzOGqSTaCfMZvDBNkcz5EjRQ/6/RmhgA98cIBaU2OPxeXpmh -nNchOAuW87eltcDkwLTwwm+6APX+TywiE/SEZ50CAwEAATANBgkqhkiG9w0BAQUF -AAOCAQEAJWwnlCcj9iP8xr3lupRZlyoUMcB2xywdT9Du3R9nhIND5e1ZbF6xAIAL -LHwiSGzebV2nnfCCkppFfg02uWIKvmqGCqB0t02G2roV7loNhcjUUIWGSpwENK5/ -GYIHBqYlEz00iLH4h6NyHqGwBjiOzsKem5ufFp3UTbQ4Bvl24p0fAyAaCUt+SDfM -VeZMrYwa71cPX8BdUkYjcePQlcWrhou3GbFQDcvaAFA1fnUCk4BOz6Z4xhB+Dw45 -VRcD7wG/XIkmHck3G02PatR1dXD1Zi3HsHpr+fOBwfKUBkNUX0nOA9lBDVIxo2JB -E+0KI0O/sSWYqKlGLv2Lnayn+s56Ag== +MIIDnDCCAoQCCQCJOiYxvMr/GDANBgkqhkiG9w0BAQUFADCBjzELMAkGA1UEBhMC +TlIxEzARBgNVBAgMClNvbWUtU3RhdGUxEjAQBgNVBAcMCUFtc3RlcmRhbTEYMBYG +A1UECgwPQ2xvdWQgQ29tbWFuZGVyMRYwFAYDVQQDDA0qLmNsb3VkY21kLmlvMSUw +IwYJKoZIhvcNAQkBFhZjb2RlcmFpc2VyQGNsb3VkY21kLmlvMB4XDTEzMTIwMjE2 +Mjc1MVoXDTE0MDEwMTE2Mjc1MVowgY8xCzAJBgNVBAYTAk5SMRMwEQYDVQQIDApT +b21lLVN0YXRlMRIwEAYDVQQHDAlBbXN0ZXJkYW0xGDAWBgNVBAoMD0Nsb3VkIENv +bW1hbmRlcjEWMBQGA1UEAwwNKi5jbG91ZGNtZC5pbzElMCMGCSqGSIb3DQEJARYW +Y29kZXJhaXNlckBjbG91ZGNtZC5pbzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC +AQoCggEBANDegEVSuTXljMsa/YPK0xqW4I+WKzZIbgoXxEqzAIogNH/yo17wFloS +2ZvnY1vsTwrB8Dde4y5loOOz+Kp40yNadApGihpvuw5IKy5AiIPC8HOdZhEmrG0I +rPPGJiNsCfP20b4cyW492mNnlx9PuY6NW4Q6PlSnFXR07NIFeBYRycXhYe9JZKCh +qYTutkn66wn607LXX74h1nUvyuU8miXpRPjpu+ND+gMNuKNox1rn/P/gr4JiuZ+i ++eNSpHpKdfKy/r1GPty9c1QuGbTTpwP+BfPW/5OppYCuQ1lpaoGLg52IGzF4SJ0L +ZKITs4oi/8NvjOhl3afVxxyGunvqZpECAwEAATANBgkqhkiG9w0BAQUFAAOCAQEA +e3UIplqybxn0tJzENCqrel+For7oH3MnUee9UbhpQKxsvsXvlnpeETapSGDIiU6x +6Dh4nze0SYw9aQCCdPGYbO59pWGgBgJ7YjY/saNKImB2sKIocMKx5Afaec19y71I +ZzuAWXXFpPWJt1MogmOOmE5aPhiXIu+eEhNkuc8GVDMEKi0Xm4gCaiOzj7GupZPM +UeYE+h7Lh8RYwhOqKNHLXACYGKF8/bidhJdYnRj0Mpht/evwkstt5XrZ/NrkBc1O +0Q8rIyufZa462DGrWTwpbSaJggNtRPgKQgSWDclo+dPHwCOb661WvMtKy/xZaCpW +ilAZADBmvZjPf8SNOjWYew== -----END CERTIFICATE----- diff --git a/ssl/ssl.key b/ssl/ssl.key index 080b9170..31e55bbb 100644 --- a/ssl/ssl.key +++ b/ssl/ssl.key @@ -1,27 +1,27 @@ -----BEGIN RSA PRIVATE KEY----- -MIIEpAIBAAKCAQEAvk7iDrJAqy2OIRDrqctQJQeKXWtVO8+GoQOSBvmN4zcc/wyJ -7ETIzaygsEllCcgtu1qxWqSoMN26+YfJDSGo3Ip8zAlyZRdDIqDjlclfuwu9KTnR -4k9J+D1er61pmJOkThkpfQN4ntkmv9WO0rkt7BXT+4/6V/NDYGVTLE6wQOb7zegP -1y97s37tmfIPOjxUQyAe59oWAwG6tseLUF6JeivdTCqlrpGgZrQBHUsv2HfSZjjT -8mXsLL5d7BD3ZIm7M4apJNoJ8xm8ME2RzPkSNFD/r9GaGAD3xwgFpTY4/F5emaGc -1yE4C5bzt6W1wOTAtPDCb7oA9f5PLCIT9IRnnQIDAQABAoIBAQCxBS1PoE15LPHV -HikoEr+lAiOZjDqHXR2M7oZJyJ5L6Tsmn2I4DS9/6YC7GjpK5BJuAQmSGDF+6vF+ -JOlGNrYdFxDItkzbbcz8DA5GiT9r/JpjG654xWo359YIsdTUoRknsE4gRDdSAwoB -TUQCDVCDFzbM/HtQji5xHy9DuppGczqjKb8vfhuadE6LnLLlV8tca9ueUqfOL5iH -6qWF/C3ZQtElXRclCR7mG7F16mhs5ijGTwfg/ExCdc7bM3vGIscIocPqcrHQhG+G -MDUY/aTJVJ+z7DuF10VhX+8QMdfxmXkg/Hn/o605GVbQ891f3tItZnikQakwXCC/ -zW/LGNihAoGBAOLpVgnO4HWEmxBPxiYvJCcEHWqXh6Qkws06/ySwBcimNN4/9mBX -tGGAl3ft6KuL+zFlm3oFRLYVhRGITfScVM8woFUcXqfZyhsKLpA1YoxSvsw9Zflc -vjRYK6gizLrWAOZj0gL8d6ZqCgdjwpn5C93lK5eLJ6ynqdCd0uHIMgnJAoGBANa0 -UU8rFkGU1uad8LR4hhwrojKX5USh/9ukbZl3RgdeJc8+vSToIhhhhnwIwUqwpgt5 -8/8wjOqoZaJn9bGQHOnHm/Eeko3ubx7jnK9SHCHY4XxRI/Eu83tdRKbHtgjmjJed -mdYH+a+LW8PoPJizlZG9uyOiGzg9wxbm+Y8nddk1AoGAbXZAoiShVS+uGhVRslPl -bcjnY+dLcNym+JgwQwODFsNPF7PlZ56Hjs2YxCsJpc+2UqMAeMGX3vrMoaOOb6UG -qJh9j/FKnFBM1fR4d+q46pZ0IlSwH7Ykr12lWcvH1Y2tC3c19WjTU30t71ippNtm -ZRnLiKSBdCHBoriv5WlM8jkCgYBsIVgp1PtagAlTEAwf9+si2N7ROCqhTC09gywn -dChyoXnNTD2aDsbNHKDMauReJ2UYtoyp4tu1eqXlCxJ0IK5PFtZ0sv8AOCsClYNd -0K6WZVH6eCrv1sONR8XBcSc+iE4aNac6Yb3gKQFIQvfxt9AGHFXZdlTbGE/egukA -rdDuWQKBgQDAPVAH16KT1hiFHSjlfoUUWfNKwhExtfvxNDImMniVFFZbWsuQmpFP -F3ucGWfYQE2k16tHDxWhIJ7GJC0U2VhPG6128lYzCYBhK6299C4kcg9IK3LmLhJs -JEoXiUNtP559g4iC/pg/W5KvoWaG8C0Z9m+tjhVAaos3TX0lATdgug== +MIIEowIBAAKCAQEA0N6ARVK5NeWMyxr9g8rTGpbgj5YrNkhuChfESrMAiiA0f/Kj +XvAWWhLZm+djW+xPCsHwN17jLmWg47P4qnjTI1p0CkaKGm+7DkgrLkCIg8Lwc51m +ESasbQis88YmI2wJ8/bRvhzJbj3aY2eXH0+5jo1bhDo+VKcVdHTs0gV4FhHJxeFh +70lkoKGphO62SfrrCfrTstdfviHWdS/K5TyaJelE+Om740P6Aw24o2jHWuf8/+Cv +gmK5n6L541Kkekp18rL+vUY+3L1zVC4ZtNOnA/4F89b/k6mlgK5DWWlqgYuDnYgb +MXhInQtkohOziiL/w2+M6GXdp9XHHIa6e+pmkQIDAQABAoIBAFR/fyMMaVMtj3zn +aWI03pxmJ2jPVqH6QVIh9U5HBlPa3YJZldAljtVXxOM2g9K/UebHOLgd0giGIsWb +nGDSypAF2uYBTYOOaf1IIvfuMYwkhAQxzAXqQF1H4jgolGtGHOyukIG5wZ+wtDX8 +xX1sUmQiOcDPk0HJ6nsXhmscvU0nnyD3eb7o9ls4dok2qPNSYV77cDi8wYCPKDl7 +Z+esk8memgWJNmHIeLfhuy01Vrw2R5PRO+t0PelHOAnMBklpt3IaX+ZMMakX44Bw +iyuPY2H02jQb+fCqF2f2qkV+Z4+UxnPnYZ3a2xfcluUfgf5w1YTH7T0wIZLSTCtf +PR76UHUCgYEA/r04RhO/qbIZRR3h2CV4xQ8xr8ujcAF3OApj8ktIsikjVPo+2QDe +kfPnp6tpZz5Fxee5PDGMHu6dRevg2CvXgt/2kvMQg8pe0dozgEdvnijWQJHmK3jr +mJssQZ0Aa6DrpWS19JDRrfJLTiOa9Oes/HC/3iT6drQVt7dam3TJk8sCgYEA0eco +ycL3m9uvzJmEtkPWduF4b7oo1v8F+RFcEZQbP5xFXc6b8KwzTuSmXrAE+eu/O4GM +F/7om8cOIRqodTVVrMqhIlossYd6ROUgikRW2HVr13y+OQxJnzoq9Xs/UkOBMRb6 +v3HxIHy8EFYlVBXKJJmcv22J6BjH5o4WyYF4e5MCgYBl145c7d5NYKebq1O0T17W +Ibnyl05TJDLek8DbiF+a4rl+asGfjiptXX662Nu96/aHJZo3x3NGlo0H/EKbCgQS +DaoNm+F5XvnDmiHG4khsidUGYY4MyT4fd8IcxUD6xo4PRJE+InvBuEGFDtUPnmPZ +VNZQYKZFuL+KAGLYDbvdOwKBgQCbNwJUYBXVbNhMxWD7nqJiekwi4lf808xI52tb +nFeh7B7nRTbO+6ddOXtFHYgwfwGEMUG1JMxBFSr/k8TqFyxpf9Uzn9bY2EOz2nL7 +i5lkqz+5swa/DLUMR2ko6aBjZoOMF2AIXWtfCJ3QvsMPsKUv91+PtqJ5vIlllcCH +9XNwfQKBgAzII/P6h9dXO/RkmjMmK+ahpJhk+gwUn93TaIL6VN/NMhKf3jHylRKD +843x+BC26ZuK2wAZHI8TMR6VQVbepe1ewyP0lknx73qgS+nnpK31Ez9GsNp7MgP+ +J4DQTLEl2vzhYiHEcgEOO4J/Jm0TBfjkxSVIVg2RufQTZ+aNIeNM -----END RSA PRIVATE KEY----- From ea077962ca52ee15e56c27d88ea0cd159fcac593 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 3 Dec 2013 09:23:28 +0000 Subject: [PATCH 257/315] fix(client) getJSONfromFileTable: json --- lib/client.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/client.js b/lib/client.js index 95990829..2bf7c051 100644 --- a/lib/client.js +++ b/lib/client.js @@ -450,13 +450,15 @@ var Util, DOM, CloudFunc, CloudCmd; var lLeft = DOM.getById('left'), lPath = DOM.getByClass('path')[0].textContent, - lFileTable = [{ + lFileTable = { path : lPath, - size : 'dir' - }], + files : [] + }, + + files = lFileTable.files, lLI = DOM.getByTag('li', lLeft), - i, n, j = 1; /* счётчик реальных файлов */ + i, n = lLI.length; /* счётчик элементов файлов в DOM * Если путь отличный от корневного @@ -465,7 +467,7 @@ var Util, DOM, CloudFunc, CloudCmd; */ /* пропускам Path и Header*/ - for(i = 2, n = lLI.length; i < n; i++) { + for (i = 2; i < n; i++) { var lCurrent = lLI[i], lName = DOM.getCurrentName(lCurrent), lSize = DOM.getCurrentSize(lCurrent), @@ -474,11 +476,11 @@ var Util, DOM, CloudFunc, CloudCmd; lMode = CloudFunc.getNumericPermissions(lMode); if (lName !== '..') - lFileTable[ j++ ] = { + lFileTable.files.push({ name: lName, size: lSize, mode: lMode - }; + }); } return Util.stringifyJSON(lFileTable); } From a34c6806769d3ff411a0ae81a255b90e49e3c8ff Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 3 Dec 2013 09:26:49 +0000 Subject: [PATCH 258/315] refactor(cloudfunc) getDirPath --- lib/cloudfunc.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/cloudfunc.js b/lib/cloudfunc.js index 71aa1be1..4976034b 100644 --- a/lib/cloudfunc.js +++ b/lib/cloudfunc.js @@ -275,10 +275,10 @@ var Util; this._getDirPath = function(url) { var lShortName, folders = [], - i = 0; + i; do { - folders[i++] = url; + folders.push(url); url = url.substr(url, url.lastIndexOf('/')); } while(url !== ''); From e444e932305e3e920b92e95b4383336758bdb1df Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 3 Dec 2013 09:29:42 +0000 Subject: [PATCH 259/315] fix(commander) fillJSON: files -> json.files --- lib/server/commander.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/server/commander.js b/lib/server/commander.js index 2f1835a6..6c9e1056 100644 --- a/lib/server/commander.js +++ b/lib/server/commander.js @@ -151,7 +151,7 @@ files.push(file); } - files = changeOrder(files); + json.files = changeOrder(files); Util.exec(p.callback, null, json); } From a01bf69776b75f0f9fc2d46ba0da892964bfd6af Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 3 Dec 2013 09:35:09 +0000 Subject: [PATCH 260/315] fix(edit) do not save hash when file update --- lib/client/edit.js | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/lib/client/edit.js b/lib/client/edit.js index 0a1f3bd0..cef834c7 100644 --- a/lib/client/edit.js +++ b/lib/client/edit.js @@ -157,19 +157,14 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch; Util.ifExec(!isDiff, function(patch) { var query, - isAllowed = DOM.Storage.isAllowed(), - getSave = function(hash) { - return function(data) { - onSave(data, hash); - }; - }; + isAllowed = DOM.Storage.isAllowed(); - Value = lValue; - - Util.ifExec(!isAllowed, function(loadHash) { - DOM.RESTful.save(lPath, lValue, getSave(loadHash), query); + Value = lValue; + + Util.ifExec(!isAllowed, function() { + DOM.RESTful.save(lPath, lValue, onSave, query); }, function(callback) { - DOM.checkStorageHash(lPath, function(error, equal, loadHash) { + DOM.checkStorageHash(lPath, function(error, equal) { var isString = Util.isString(patch), lessLength = patch.length < lValue.length; @@ -179,7 +174,7 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch; query = '?patch'; } - callback(loadHash); + callback(); } }); }); @@ -252,7 +247,7 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch; } } - function onSave(text, hash) { + function onSave(text) { var ret, isError = Util.isContainStrAtBegin(text, 'error'), path = DOM.getCurrentPath(), @@ -260,7 +255,7 @@ var CloudCmd, Util, DOM, CloudFunc, ace, DiffProto, diff_match_patch; if (!isError) { Edit.showMessage(text); - DOM.saveDataToStorage(path, Value, hash); + DOM.saveDataToStorage(path, Value); } else { ret = Dialog.confirm(text + msg); From 518bcf756ef8fad66c11b8b53d5b8c83f8e8a35b Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 3 Dec 2013 09:41:56 +0000 Subject: [PATCH 261/315] docs(readme, help) status-ok: http -> https --- HELP.md | 8 ++++---- README.md | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/HELP.md b/HELP.md index 7a4790dd..429d7de8 100644 --- a/HELP.md +++ b/HELP.md @@ -16,10 +16,10 @@ Cloud Commander v0.6.0 [![NPM version][NPMIMGURL]][NPMURL] [![Dependency Status] [JitSuURL]: http://cloudcmd.jit.su "JitSu" [HerokuURL]: http://cloudcmd.herokuapp.com/ "Heroku" [RunKiteURL]: http://cloudcmd.apps.runkite.com/ "RunKite" -[IO_LIVE_IMG]: http://status-ok.cloudcmd.io/host/io.cloudcmd.io/fs?json "IO" -[JitSu_LIVE_IMG]: http://status-ok.cloudcmd.io/host/cloudcmd.jit.su/fs?json "JitSu" -[HEROKU_LIVE_IMG]: http://status-ok.cloudcmd.io/host/cloudcmd.herokuapp.com/fs?json "Heroku" -[RunKite_LIVE_IMG]: http://status-ok.cloudcmd.io/host/cloudcmd.apps.runkite.com/fs?json "RunKite" +[IO_LIVE_IMG]: https://status-ok.cloudcmd.io/host/io.cloudcmd.io/fs?json "IO" +[JitSu_LIVE_IMG]: https://status-ok.cloudcmd.io/host/cloudcmd.jit.su/fs?json "JitSu" +[HEROKU_LIVE_IMG]: https://status-ok.cloudcmd.io/host/cloudcmd.herokuapp.com/fs?json "Heroku" +[RunKite_LIVE_IMG]: https://status-ok.cloudcmd.io/host/cloudcmd.apps.runkite.com/fs?json "RunKite" **Cloud Commander** - cloud file manager with console and editor. diff --git a/README.md b/README.md index 1f6ce08f..797f257a 100644 --- a/README.md +++ b/README.md @@ -16,10 +16,10 @@ Cloud Commander v0.6.0 [![NPM version][NPMIMGURL]][NPMURL] [![Dependency Status] [JitSuURL]: http://cloudcmd.jit.su "JitSu" [HerokuURL]: http://cloudcmd.herokuapp.com/ "Heroku" [RunKiteURL]: http://cloudcmd.apps.runkite.com/ "RunKite" -[IO_LIVE_IMG]: http://status-ok.cloudcmd.io/host/io.cloudcmd.io/fs?json "IO" -[JitSu_LIVE_IMG]: http://status-ok.cloudcmd.io/host/cloudcmd.jit.su/fs?json "JitSu" -[HEROKU_LIVE_IMG]: http://status-ok.cloudcmd.io/host/cloudcmd.herokuapp.com/fs?json "Heroku" -[RunKite_LIVE_IMG]: http://status-ok.cloudcmd.io/host/cloudcmd.apps.runkite.com/fs?json "RunKite" +[IO_LIVE_IMG]: https://status-ok.cloudcmd.io/host/io.cloudcmd.io/fs?json "IO" +[JitSu_LIVE_IMG]: https://status-ok.cloudcmd.io/host/cloudcmd.jit.su/fs?json "JitSu" +[HEROKU_LIVE_IMG]: https://status-ok.cloudcmd.io/host/cloudcmd.herokuapp.com/fs?json "Heroku" +[RunKite_LIVE_IMG]: https://status-ok.cloudcmd.io/host/cloudcmd.apps.runkite.com/fs?json "RunKite" **Cloud Commander** - cloud file manager with console and editor. From 204ffc351be43b7fd9753b4a0905c120fd64282a Mon Sep 17 00:00:00 2001 From: coderaiser Date: Tue, 3 Dec 2013 10:49:05 +0000 Subject: [PATCH 262/315] fix(dom) storage set: rm data condition --- lib/client/dom.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/client/dom.js b/lib/client/dom.js index 47419a6e..6494cfa6 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -606,8 +606,8 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; this.set = function(pName, pData) { var lRet = this; - if (StorageAllowed && pName && pData) - localStorage.setItem(pName,pData); + if (StorageAllowed && pName) + localStorage.setItem(pName, pData); return lRet; }, From 3e83bc7912ff80de4da6e96015a56f9f22f277e7 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 4 Dec 2013 10:34:10 +0000 Subject: [PATCH 263/315] docs(help) flattr img: http -> https --- HELP.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/HELP.md b/HELP.md index 429d7de8..e74c54ac 100644 --- a/HELP.md +++ b/HELP.md @@ -4,7 +4,7 @@ Cloud Commander v0.6.0 [![NPM version][NPMIMGURL]][NPMURL] [![Dependency Status] [NPMIMGURL]: https://badge.fury.io/js/cloudcmd.png [BuildStatusIMGURL]: https://secure.travis-ci.org/coderaiser/cloudcmd.png?branch=master [DependencyStatusIMGURL]: https://gemnasium.com/coderaiser/cloudcmd.png -[FlattrIMGURL]: http://api.flattr.com/button/flattr-badge-large.png +[FlattrIMGURL]: https://api.flattr.com/button/flattr-badge-large.png [NPM_INFO_IMG]: https://nodei.co/npm/cloudcmd.png?downloads=true&&stars [NPMURL]: https://npmjs.org/package/cloudcmd "npm" [BuildStatusURL]: http://travis-ci.org/coderaiser/cloudcmd "Build Status" From ead9d2775e1ec1d22756aa9a5d1a6417b767ddce Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 4 Dec 2013 13:52:31 +0000 Subject: [PATCH 264/315] fix(dom) getCurrentData: add isCurrentIsDir --- lib/client/dom.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/lib/client/dom.js b/lib/client/dom.js index 6494cfa6..40261a7a 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -1490,7 +1490,8 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; var lParams, lHash, lCurrentFile = pCurrentFile ? pCurrentFile : this.getCurrentFile(), - lPath = DOM.getCurrentPath(lCurrentFile), + lPath = DOM.getCurrentPath(lCurrentFile), + isDir = DOM.isCurrentIsDir(lCurrentFile), lFunc = function(pData) { var lExt = '.json', @@ -1521,14 +1522,17 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; }; - DOM.checkStorageHash(lPath, function(error, equal, hash) { - Util.ifExec(!error && equal, function() { - DOM.getDataFromStorage(lPath, lFunc); - }, function() { - lHash = hash; - DOM.getCurrentFileContent(lParams, lCurrentFile); + if (isDir) + DOM.getCurrentFileContent(lParams, lCurrentFile); + else + DOM.checkStorageHash(lPath, function(error, equal, hash) { + Util.ifExec(!error && equal, function() { + DOM.getDataFromStorage(lPath, lFunc); + }, function() { + lHash = hash; + DOM.getCurrentFileContent(lParams, lCurrentFile); + }); }); - }); }; From 4a116312abef267cfe514ed7c55f116446a9ab74 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 4 Dec 2013 14:23:06 +0000 Subject: [PATCH 265/315] refactor(cloudfunc) _getFileTableHeader --- lib/cloudfunc.js | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/lib/cloudfunc.js b/lib/cloudfunc.js index 4976034b..12d4903c 100644 --- a/lib/cloudfunc.js +++ b/lib/cloudfunc.js @@ -314,21 +314,18 @@ var Util; * Функция формирует заголовки столбиков * @pFileTableTitles - массив названий столбиков */ - this._getFileTableHeader = function(pFileTableTitles) { - var i, lStr, lHeader='
  • '; + this._getFileTableHeader = function(pTemplate) { + var lFileTable = Util.render(pTemplate, { + type : '', + link : '', + target : '', + name : 'name', + size : 'size', + owner : 'owner', + mode : 'mode' + }); - lHeader+=''; - - for(i = 0;i < pFileTableTitles.length; i++) { - lStr = pFileTableTitles[i]; - lHeader +='' + - lStr + - ''; - } - - lHeader += '
  • '; - - return lHeader; + return lFileTable; }; /** @@ -356,14 +353,12 @@ var Util; */ lRefreshPath = CloudFunc.removeLastSlash(lPath), - lFileTable = Util.render(pPathTemplate, { + lFileTable = Util.render(pPathTemplate, { link: FS + lRefreshPath, path: lHtmlPath - }), + }); - fileTableTitles = ['name','size','owner','mode']; - - lFileTable += CloudFunc._getFileTableHeader(fileTableTitles); + lFileTable += CloudFunc._getFileTableHeader(pTemplate); /* сохраняем путь */ CloudFunc.Path = lPath; From 283ad7bc9f61cd6b0b7f20f87878653e4f6ab9bc Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 4 Dec 2013 14:25:26 +0000 Subject: [PATCH 266/315] refactor(cloudfunc) mv getFileTableHeader to buildFromJSON --- lib/cloudfunc.js | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/lib/cloudfunc.js b/lib/cloudfunc.js index 12d4903c..ca1ce3f8 100644 --- a/lib/cloudfunc.js +++ b/lib/cloudfunc.js @@ -310,24 +310,6 @@ var Util; return lHtmlPath; }; - /** - * Функция формирует заголовки столбиков - * @pFileTableTitles - массив названий столбиков - */ - this._getFileTableHeader = function(pTemplate) { - var lFileTable = Util.render(pTemplate, { - type : '', - link : '', - target : '', - name : 'name', - size : 'size', - owner : 'owner', - mode : 'mode' - }); - - return lFileTable; - }; - /** * Функция строит таблицу файлв из JSON-информации о файлах * @param pJSON - информация о файлах @@ -358,7 +340,15 @@ var Util; path: lHtmlPath }); - lFileTable += CloudFunc._getFileTableHeader(pTemplate); + lFileTable += Util.render(pTemplate, { + type : '', + link : '', + target : '', + name : 'name', + size : 'size', + owner : 'owner', + mode : 'mode' + }); /* сохраняем путь */ CloudFunc.Path = lPath; From 9e3d8e2bf63c79fee9a57d4d66fcc049fcdedc3f Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 4 Dec 2013 14:27:17 +0000 Subject: [PATCH 267/315] chore(cloudfunc) bildFromJSON: add " " --- lib/cloudfunc.js | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/lib/cloudfunc.js b/lib/cloudfunc.js index ca1ce3f8..e7ed47b0 100644 --- a/lib/cloudfunc.js +++ b/lib/cloudfunc.js @@ -318,29 +318,29 @@ var Util; * {name:'имя',size:'размер',mode:'права доступа'}] */ this.buildFromJSON = function(pJSON, pTemplate, pPathTemplate) { - var lFile, type, link, target, size, owner, mode, - files = pJSON.files, + var lFile, i, n, type, link, target, size, owner, mode, + files = pJSON.files, /* сохраняем путь каталога в котором мы сейчас находимся*/ - lPath = pJSON.path, + lPath = pJSON.path, /* * Строим путь каталога в котором мы находимся * со всеми подкаталогами */ - lHtmlPath = CloudFunc._getDirPath(lPath), + lHtmlPath = CloudFunc._getDirPath(lPath), /* Убираем последний слэш * с пути для кнопки обновить страницу * если он есть */ - lRefreshPath = CloudFunc.removeLastSlash(lPath), + lRefreshPath = CloudFunc.removeLastSlash(lPath), - lFileTable = Util.render(pPathTemplate, { + lFileTable = Util.render(pPathTemplate, { link: FS + lRefreshPath, path: lHtmlPath }); - lFileTable += Util.render(pTemplate, { + lFileTable += Util.render(pTemplate, { type : '', link : '', target : '', @@ -351,10 +351,10 @@ var Util; }); /* сохраняем путь */ - CloudFunc.Path = lPath; + CloudFunc.Path = lPath; /* Если мы не в корне */ - if(lPath !== '/') { + if (lPath !== '/') { /* ссылка на верхний каталог*/ var lDotDot, lLink; /* убираем последний слеш и каталог в котором мы сейчас находимся*/ @@ -378,7 +378,8 @@ var Util; }); } - for(var i = 0, n = files.length; i < n; i++) { + n = files.length; + for (i = 0; i < n; i++) { lFile = files[i]; type = lFile.size === 'dir' ? 'directory' : 'text-file'; link = FS + lPath + lFile.name; From b92e1fe81b904cebdf529763dad4fa81f59172fe Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 4 Dec 2013 14:42:56 +0000 Subject: [PATCH 268/315] chore(listeners) comment: path -> refresh --- lib/client/listeners.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/client/listeners.js b/lib/client/listeners.js index b153e9dd..ff371bde 100644 --- a/lib/client/listeners.js +++ b/lib/client/listeners.js @@ -155,7 +155,7 @@ var Util, DOM, CloudCmd; /* ставим загрузку гифа на клик*/ Events.addClick( CloudCmd.refresh, a[0].parentElement ); - /* start from 1 cous 0 is a path and it's setted up */ + /* start from 1 cous 0 is a refresh and it's setted up */ for(var i = 1, n = a.length; i < n ; i++){ /* убираем адрес хоста*/ var ai = a[i], From b99d17ffc637003fb89d0e78eae61087d3b6c112 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 4 Dec 2013 14:47:54 +0000 Subject: [PATCH 269/315] feature(file) add className --- html/file.html | 2 +- lib/cloudfunc.js | 47 +++++++++++++++++++++++++---------------------- 2 files changed, 26 insertions(+), 23 deletions(-) diff --git a/html/file.html b/html/file.html index 00e2c31d..3bfe194e 100644 --- a/html/file.html +++ b/html/file.html @@ -1,4 +1,4 @@ -
  • +
  • {{ name }} diff --git a/lib/cloudfunc.js b/lib/cloudfunc.js index e7ed47b0..3c8b9d70 100644 --- a/lib/cloudfunc.js +++ b/lib/cloudfunc.js @@ -341,14 +341,15 @@ var Util; }); lFileTable += Util.render(pTemplate, { - type : '', - link : '', - target : '', - name : 'name', - size : 'size', - owner : 'owner', - mode : 'mode' - }); + className : 'fm-header', + type : '', + link : '', + target : '', + name : 'name', + size : 'size', + owner : 'owner', + mode : 'mode' + }); /* сохраняем путь */ CloudFunc.Path = lPath; @@ -368,13 +369,14 @@ var Util; /* Сохраняем путь к каталогу верхнего уровня*/ lFileTable += Util.render(pTemplate,{ - type : 'directory', - link : lLink, - target : '', - name : '..', - size : '<dir>', - owner : '.', - mode : '' + className : '', + type : 'directory', + link : lLink, + target : '', + name : '..', + size : '<dir>', + owner : '.', + mode : '' }); } @@ -389,15 +391,16 @@ var Util; mode = CloudFunc.getSymbolicPermissions(lFile.mode); lFileTable += Util.render(pTemplate,{ + className : '', /* Если папка - выводим пиктограмму папки * * В противоположном случае - файла */ - type : type, - link : link, - target : target, - name : lFile.name, - size : size, - owner : owner, - mode : mode + type : type, + link : link, + target : target, + name : lFile.name, + size : size, + owner : owner, + mode : mode }); } From 39ca504ebf5f63ac9950b6e0c57ee88ac9781342 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 4 Dec 2013 14:54:58 +0000 Subject: [PATCH 270/315] feature(html) rm link to cloudfunc --- html/file.html | 6 ++---- lib/cloudfunc.js | 26 ++++++++++++++++++-------- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/html/file.html b/html/file.html index 3bfe194e..46903b76 100644 --- a/html/file.html +++ b/html/file.html @@ -1,8 +1,6 @@
  • - - {{ name }} - + {{ name }} {{ size }}{{ owner }} {{ mode }} -
  • \ No newline at end of file + diff --git a/lib/cloudfunc.js b/lib/cloudfunc.js index 3c8b9d70..b32ecef3 100644 --- a/lib/cloudfunc.js +++ b/lib/cloudfunc.js @@ -319,6 +319,8 @@ var Util; */ this.buildFromJSON = function(pJSON, pTemplate, pPathTemplate) { var lFile, i, n, type, link, target, size, owner, mode, + linkTemplate = '{{ name }}', + linkResult, files = pJSON.files, /* сохраняем путь каталога в котором мы сейчас находимся*/ lPath = pJSON.path, @@ -343,8 +345,6 @@ var Util; lFileTable += Util.render(pTemplate, { className : 'fm-header', type : '', - link : '', - target : '', name : 'name', size : 'size', owner : 'owner', @@ -367,13 +367,17 @@ var Util; lLink = FS + lDotDot; + linkResult = Util.render(linkTemplate, { + link : lLink, + name : '..', + target : '' + }); + /* Сохраняем путь к каталогу верхнего уровня*/ lFileTable += Util.render(pTemplate,{ className : '', type : 'directory', - link : lLink, - target : '', - name : '..', + name : linkResult, size : '<dir>', owner : '.', mode : '' @@ -390,14 +394,20 @@ var Util; owner = !lFile.uid ? 'root' : lFile.uid; mode = CloudFunc.getSymbolicPermissions(lFile.mode); + + linkResult = Util.render(linkTemplate, { + link : link, + name : lFile.name, + target : target + }); + + lFileTable += Util.render(pTemplate,{ className : '', /* Если папка - выводим пиктограмму папки * * В противоположном случае - файла */ type : type, - link : link, - target : target, - name : lFile.name, + name : linkResult, size : size, owner : owner, mode : mode From 29b07cdedfa3bbd97bc28ecbbb5ce817f2201105 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 4 Dec 2013 14:56:20 +0000 Subject: [PATCH 271/315] chore(cloudfunc) add " " --- lib/cloudfunc.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/cloudfunc.js b/lib/cloudfunc.js index b32ecef3..a073a04f 100644 --- a/lib/cloudfunc.js +++ b/lib/cloudfunc.js @@ -147,16 +147,16 @@ var Util; /* Рекомендации гугла советуют вместо string[3] * использовать string.charAt(3) */ - /* - http://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml?showone=Standards_features#Standards_features - - Always preferred over non-standards featuresFor - maximum portability and compatibility, always - prefer standards features over non-standards - features (e.g., string.charAt(3) over string[3] - and element access with DOM functions instead - of using an application-specific shorthand). - */ + /* + http://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml?showone=Standards_features#Standards_features + + Always preferred over non-standards featuresFor + maximum portability and compatibility, always + prefer standards features over non-standards + features (e.g., string.charAt(3) over string[3] + and element access with DOM functions instead + of using an application-specific shorthand). + */ /* Переводим в двоичную систему */ var lOwner = ( pPerm_s[0] - 0 ).toString(2), lGroup = ( pPerm_s[1] - 0 ).toString(2), @@ -175,7 +175,7 @@ var Util; ( lAll[0]- 0 > 0 ? 'r' : '-' ) + ( lAll[1]- 0 > 0 ? 'w' : '-' ) + ( lAll[2]- 0 > 0 ? 'x' : '-' ); - + return lPermissions; }; From d849593f19d9a846269c49fabc15ed8b8b25a3ca Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 4 Dec 2013 15:04:27 +0000 Subject: [PATCH 272/315] fix(file) rm new line at end --- html/file.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/html/file.html b/html/file.html index 46903b76..e441048f 100644 --- a/html/file.html +++ b/html/file.html @@ -3,4 +3,4 @@ {{ name }} {{ size }}{{ owner }} {{ mode }} - + \ No newline at end of file From a4ef905bbd0bbec5d011ab62dc018af70d14038d Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 4 Dec 2013 15:04:45 +0000 Subject: [PATCH 273/315] feature(link) add --- cloudcmd.js | 8 +++++--- html/link.html | 1 + lib/client.js | 10 ++++++---- lib/cloudfunc.js | 7 +++---- 4 files changed, 15 insertions(+), 11 deletions(-) create mode 100644 html/link.html diff --git a/cloudcmd.js b/cloudcmd.js index da518df0..3ace7ec0 100644 --- a/cloudcmd.js +++ b/cloudcmd.js @@ -30,8 +30,9 @@ FILE_TMPL = HTMLDIR + 'file.html', PATH_TMPL = HTMLDIR + 'path.html', + LINK_TMPL = HTMLDIR + 'path.html', - FileTemplate, PathTemplate, + FileTemplate, PathTemplate, LinkTemplate, FS = CloudFunc.FS; /* reinit main dir os if we on Win32 should be backslashes */ @@ -139,7 +140,7 @@ route : route }, - lFiles = [FILE_TMPL, PATH_TMPL]; + lFiles = [FILE_TMPL, PATH_TMPL, LINK_TMPL]; if (Config.ssl) lFiles.push(KEY, CERT); @@ -150,6 +151,7 @@ else { FileTemplate = pFiles[FILE_TMPL]; PathTemplate = pFiles[PATH_TMPL]; + LinkTemplate = pFiles[LINK_TMPL]; if (Config.ssl) lParams.ssl = { @@ -257,7 +259,7 @@ main.sendError(p, error); else { p.name = INDEX_PATH, - lPanel = CloudFunc.buildFromJSON(pJSON, FileTemplate, PathTemplate), + lPanel = CloudFunc.buildFromJSON(pJSON, FileTemplate, PathTemplate, LinkTemplate), lList = '
      ' + lPanel + '
    ' + ''; diff --git a/html/link.html b/html/link.html new file mode 100644 index 00000000..c06af763 --- /dev/null +++ b/html/link.html @@ -0,0 +1 @@ +{{ name }} \ No newline at end of file diff --git a/lib/client.js b/lib/client.js index 2bf7c051..6ebd8917 100644 --- a/lib/client.js +++ b/lib/client.js @@ -11,7 +11,7 @@ var Util, DOM, CloudFunc, CloudCmd; function CloudCmdProto(Util, DOM) { var Key, Config, Modules, Extensions, - FileTemplate, PathTemplate, Listeners, + FileTemplate, PathTemplate, LinkTemplate, Listeners, CloudCmd = this; Storage = DOM.Storage; @@ -284,6 +284,7 @@ var Util, DOM, CloudFunc, CloudCmd; this.getExt = getSystemFile(Extensions, CloudCmd.JSONDIR + 'ext.json'); this.getFileTemplate = getSystemFile(FileTemplate, CloudCmd.HTMLDIR + 'file.html'); this.getPathTemplate = getSystemFile(PathTemplate, CloudCmd.HTMLDIR + 'path.html'); + this.getLinkTemplate = getSystemFile(PathTemplate, CloudCmd.HTMLDIR + 'link.html'); this.execFromModule = function(pModuleName, pFuncName, pParams) { var lObject = CloudCmd[pModuleName]; @@ -401,17 +402,18 @@ var Util, DOM, CloudFunc, CloudCmd; lWasRefresh_b = lPath[0].textContent === pJSON.path, lFuncs = [ CloudCmd.getFileTemplate, - CloudCmd.getPathTemplate + CloudCmd.getPathTemplate, + CloudCmd.getLinkTemplate ]; - Util.asyncCall(lFuncs, function(pTemplate, pPathTemplate) { + Util.asyncCall(lFuncs, function(pTemplate, pPathTemplate, pLinkTemplate) { /* очищаем панель */ var i = lElem.childNodes.length; while(i--) lElem.removeChild(lElem.lastChild); - lElem.innerHTML = CloudFunc.buildFromJSON(pJSON, pTemplate, pPathTemplate); + lElem.innerHTML = CloudFunc.buildFromJSON(pJSON, pTemplate, pPathTemplate, pLinkTemplate); /* если нажали на ссылку на верхний каталог*/ var lFound; diff --git a/lib/cloudfunc.js b/lib/cloudfunc.js index a073a04f..f3b16e70 100644 --- a/lib/cloudfunc.js +++ b/lib/cloudfunc.js @@ -317,9 +317,8 @@ var Util; * [{path:'путь',size:'dir'}, * {name:'имя',size:'размер',mode:'права доступа'}] */ - this.buildFromJSON = function(pJSON, pTemplate, pPathTemplate) { + this.buildFromJSON = function(pJSON, pTemplate, pPathTemplate, pLinkTemplate) { var lFile, i, n, type, link, target, size, owner, mode, - linkTemplate = '{{ name }}', linkResult, files = pJSON.files, /* сохраняем путь каталога в котором мы сейчас находимся*/ @@ -367,7 +366,7 @@ var Util; lLink = FS + lDotDot; - linkResult = Util.render(linkTemplate, { + linkResult = Util.render(pLinkTemplate, { link : lLink, name : '..', target : '' @@ -395,7 +394,7 @@ var Util; mode = CloudFunc.getSymbolicPermissions(lFile.mode); - linkResult = Util.render(linkTemplate, { + linkResult = Util.render(pLinkTemplate, { link : link, name : lFile.name, target : target From 5f9b6a66991df0140d11447aec5d21841076885c Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 5 Dec 2013 08:47:51 +0000 Subject: [PATCH 274/315] fix(cloudcmd) path -> link --- cloudcmd.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cloudcmd.js b/cloudcmd.js index 3ace7ec0..42b02abe 100644 --- a/cloudcmd.js +++ b/cloudcmd.js @@ -30,7 +30,7 @@ FILE_TMPL = HTMLDIR + 'file.html', PATH_TMPL = HTMLDIR + 'path.html', - LINK_TMPL = HTMLDIR + 'path.html', + LINK_TMPL = HTMLDIR + 'link.html', FileTemplate, PathTemplate, LinkTemplate, From 530428ec1405c45de490e9d1d947f3f1bd58225e Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 5 Dec 2013 08:56:04 +0000 Subject: [PATCH 275/315] fix(client) rm last slash before first save to storage --- lib/client.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/client.js b/lib/client.js index 6ebd8917..a14bf474 100644 --- a/lib/client.js +++ b/lib/client.js @@ -245,6 +245,9 @@ var Util, DOM, CloudFunc, CloudCmd; Storage.setAllowed(localStorage); /* Устанавливаем кэш корневого каталога */ var lDirPath = DOM.getCurrentDirPath(); + + lDirPath = CloudFunc.removeLastSlash(lDirPath) || '/'; + if (!Storage.get(lDirPath)) Storage.set(lDirPath, getJSONfromFileTable()); }); From 025718978b2639ed713b553e6bef7aae88ecd22e Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 5 Dec 2013 08:58:19 +0000 Subject: [PATCH 276/315] docs(help) thanks: rm links --- HELP.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/HELP.md b/HELP.md index e74c54ac..fba03313 100644 --- a/HELP.md +++ b/HELP.md @@ -393,5 +393,5 @@ Special Thanks - [Polietilena](http://polietilena.github.io/ "Polietilena") for [logo](img/logo/cloudcmd.png "logo") and [favicon](img/favicon/favicon.png "favicon"); - [Elec-ua](https://github.com/elec-ua) - [ru](http://ru.cloudcmd.io "Cloud Commander in Russian") and [ua](http://ua.cloudcmd.io "Cloud Commander in Ukrainian") translations; - - config [template](html/config.html) and [style](css/config.css); - - change order of directories and files in [commander](lib/server/commander.js "Commander") + - config template and style; + - change order of directories and files; From a5a29d298bc560ae410f87b0b390658f5d3ec3df Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 5 Dec 2013 08:59:06 +0000 Subject: [PATCH 277/315] docs(help) Elec-ua -> Tarzak --- HELP.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/HELP.md b/HELP.md index fba03313..d1ed3b35 100644 --- a/HELP.md +++ b/HELP.md @@ -391,7 +391,7 @@ Special Thanks --------------- - [Polietilena](http://polietilena.github.io/ "Polietilena") for [logo](img/logo/cloudcmd.png "logo") and [favicon](img/favicon/favicon.png "favicon"); -- [Elec-ua](https://github.com/elec-ua) +- [Tarzak](https://github.com/jobtarzak) - [ru](http://ru.cloudcmd.io "Cloud Commander in Russian") and [ua](http://ua.cloudcmd.io "Cloud Commander in Ukrainian") translations; - config template and style; - change order of directories and files; From 6940c0f76f7cb51c4ab9282245ce0a0761aa4368 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 5 Dec 2013 10:07:19 +0000 Subject: [PATCH 278/315] feature(style) rm GeneralFoundicons --- css/style.css | 8 -------- font/general_foundicons.woff | Bin 9728 -> 0 bytes 2 files changed, 8 deletions(-) delete mode 100644 font/general_foundicons.woff diff --git a/css/style.css b/css/style.css index 2e5f9833..4d97503d 100644 --- a/css/style.css +++ b/css/style.css @@ -2,14 +2,6 @@ @import url(//fonts.googleapis.com/css?family=Droid+Sans+Mono); */ -/* символьный шрифт от гитхаба*/ -@font-face { - font-family: "GeneralFoundicons"; - src: url('/font/general_foundicons.woff') format('woff'); - font-weight: normal; - font-style: normal; -} - /* http://fontello.com/ */ @font-face { font-family: 'Fontello'; diff --git a/font/general_foundicons.woff b/font/general_foundicons.woff deleted file mode 100644 index daab63141b07e0a1fa8efd931a98945b837bd4aa..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 9728 zcmZvCWmFtZwCxP8fdq#D0}1Z#5@dn~cM0w?xVyW%y9Eis-3fyQAKcv~Sdhne?|c7V zb?sAqWLH<6>b3gEX*UHh7ytykHEI9=^S@Eh|3CTvYYHkX>;M3;_{}H&27_RTKdP~< zAp`(`(|yzJ-bTggtOa*tS7#6afbgG<_&>n)!&R6;%x&NNV{d%8H#i|_W%HQZc$mG# zxdQ-XZ!2IiU=#1uwlFm`dGoWr@i^bW{rIS}V)15tv%T2?q;L3)l7RrSuyuap0T14E z=QsT6f}kbZ*c-paQF_1WR{w#%oh;ba(EV+Fz~DEX>0ko zN!x<}&>n~Hf1CLK`dJNUO*V`GKrkz+2?rZ1eo#69GahjKzkai|ao&J{lz;$BEENKH zcyX*?vyM@Nfr}_09xEEi0gXN?l8Bg)Q22nY8{nwmFP%@!$`+snlmfB=I@d5A|9i&$ zAOP46N`F8MV#Ia={1n8!hIhclW`J`b!LCIxLI$M*jO;<`03#t#6OxgBIT=NH3j*#P z;1U7E48J7@Iz!xIrA4Z6LojjxafcnnAZ`VTGNLqoN22E;f$kamBDyks!ma}RB*G55 z-vZ#=@g@DYF9QQJfH5^U5*P_P9(d)?I3$E&6OG4ye_EfrjBi{hZ-ctG{J^A&c_d~f8qFBf7r3T$KOIvy8kD)QR@dnez@w824&ByolAGr z^E%o5z;v5F%rsFFL5ku(a_^35n?JYLfkw7o84z5m<2V=WU(*rNE0HdfZjn0GM?E1j6kvTH@l-^j8A-IR=7k2-(EDMi&Zl5?ZR#7^i~7Ka`RTW4N+$gw}J~OVROY zxLO{NKOb4|{7(*Ih0yv$vBBSsg(9?)rrS96XZENZ^0Cgp=>?uBcf9Mj7aJFl0QdsX z2Y3R?06lxA=!Ae z8TiA8qW6i6`fx;l`jOu2NZVix^=N}=+@IfjB*9SXer_Ra#>POzjJ6U?k{W+vI>Ouy z+@1#sGoHHy=WoxDyeI}9)Mpl*?B+0nPJ)ZgE6=KR?mW&sp7vKLlbw^8o>=ZbnUK;Y zN{Sst6_eKx>I&c#Czw9ut(7e*X$SXHDa;`~xkqlCPd2CMVA_90#*=i7z&5 z|Jy_6c>Y8uz};$jEkQmbFMF{TF`h+j>}pjk!ok~J%jMNld(P@-V&Lm%ZM8nJ$jq~t zNl5;iP2RXQ;4(se`ZRO3)xNUP&o^I)eVY2hSb_%eMdY4uTAVwPdW;kKS5~NOkZjm! zFaul~x&~eiuqAXu8+k#BbT1dzN|4TcwahBTs)Y2sszGPmsAJBicxw=RR84d z6U9ttSTtOZA9UX)V#}b3#yN?`=^FvLt{nfih>zGES??C^TZ=cS65U0XK#};7MlXi6 zRWA59@g8tWx6^aXNv|bm4h5sIoW+Fypt=s%(qkUs@G(Ejzc983Nkoubp)2eDAoVhp zARKNQM<*Yef10Q>_XzUUy?XZo@5?gMBctwan^3%|yw*_F;?$MDgw3F4Y3gm0+Ju(e zmx@d4_a%JyA7_%XxU>F;t)SdH!1K?7;~``|JO_6g1g25*1)umA1S{;;(9Rv17gS%7 zLmEEEOLrgvUvCRDqHDPd#ku2!6)PfPXAIAe#4U21EknbDp@(aCKh2qmej8yrZ%nkU z3z=*Y1r-Lq@+vLrj%hhr9lC(D{mK3n-1xrb`@8#p{=%Im*)}x4So`tEEDU2*OGW9` z;-UCbyF^AcdnX#gG0>-Xo74(?fsN zcJ))a0uTUg$RyfDXc~Bu1*Lt9)!B}J`)ERHAf6$GXEFbHEVIv)RiV7!L(@oe9gW0P z1e}tcmMksUvR?Nl2{jJRE2F2w2vtu7f6!J!aYLr)LU@?0wUzP=t;|_wH)gkW4Tm2_ z*}S^*W%l!EOT?7cEQiCv!g9>p$N_%38+nNJc`FLS3e9;`MFXII2_k;BEjAiuC znTdQPP~IJU)Hvo3E|v+fcqi))7%^57u# zH}y>)vaTW>8cMl|w!!mSu-tgGXWsy6JIQ2f!z6{!9=2tBoP|wp2FU8okF8+4w zjo64(>=Sirzwc3(QIk8)d9C-AtreNpUZAa11?0KxvU~o}2=8^~Cu0EYJM=bKguK-9 zw3#Y6oJowDPBwKq@*Vvcx1VkN$ECLh{lL>d%*&SoWvZ_4j?mBxi?H zNsVH8RkTHDyJIeDLK70=tdqZrGQnSBiRp2OpA&0boU;MXA*Dr3Pm~#3s4pIgNH2ig zbNH87snT$%Gs$hjqdi<*#Fj|quj0Zx_;RxGsV0k-2VcG9tu7i(LRYO218Y-3h>ZZM za(o#3(dDjF>b9oe_CT+qNm_T|^(17i_V~%E$z}7Sx&a@K{!63jtD8^!HO`7V7|Z72 zW5!P2HcgM?DRt{FlS~wLz;zhk!m;@Xb-Wz`*%vn|lGAz3MmU=-m9Ro;$Cf{ppXRPK zEjy-jH*II3)wdY(T#5OkfOJT@!3RyGQvUwpp8!`GtEg{z@FFcgS=4T0Zj$+H>owiD zgxHW|OjR#bxd$!#Nq?xhWa9axQ{pD{u^*og5ZLkq9c=jW9hUaN(Ng)5t;-svJ>f)e!)Tl%a%9jd)xw^O`Dk&?Ua*iyQ7c-KR#NlYZD^Ok_?3W8 zE3m3d>Q_9ucLd|K*fXQNKYgo)&S8T$TE}|uTP;dlpc-fy|alLpe-2Pzk zP1MK+D@=K^6{`lJdE&eRz&%Lgixb8HO7w4xoDvSk2%q95&33eL3B0T{hCdic0X~7R zGL6BLeWvb4h{ah)M}E^D<5lhk8Uzk*W>S_b zW@Xv1QcX0}=-as=`U2$`WlG#2{a$zeb+7}ZeLftYY@@)HRhXo|$X>TU%aybldkj;Y8WDnso8AJ*>5a#)l#@k&Zdy>PW1 zsc{Pi9)%Jn%rIB4+TZz{Z=}W9t^3}LBKP0Ca-Da5Mx7mau*ihN1ws!TX7KSD6-KF@ zvIm|2)U*+g@XBqg_f0#~h^72A%5~@s_{OiRs)QFbT%_dxK7TWxZ9-haMs!sBb83WS zVX4fuupF93zZx(w#o-A!L@I#jT&5gGqN_yNW=YvtAQ!Yo=q!PU$v<%`j%TJ-2|R#9 zLcj&e`)e|OaPe8-daks?1>{EsThq9x43y$b^#+iQJ7Tue91i=38{i`FVB~x?vTXJ! z|G8^+R!b2k_g>bHM(7D0)UEd+>{D#C%t^XCd_e6UwgZ=PvdG7XMUkJzIU2^d3a6UE zz7h(=H@yG!gxa2dkVY-uv`rMH*P|}vCy6sW|B;}M4-EZI^N|Px; zv<+J1ia#Mv#x;#VqGD16`kPIWCkkVuDP50Sb*;knGQ7yvD*J;&!Uc!kX-$>SJ+$rm zTw8KL9Z9p$SKC_BbDHFmN<`o!zfw+F1fM-kBuanU(@V9S`p%5>SN+rX?Xm~fig>0S z>Z>sG-c?R1y}+Cx1A<%8cMZ8fqFGM?kPxlQYV0H0{Z;-WcLl1Kh7;3o%n?tfavtQ1 zQw;YQCU%?OUPMqxv_cRPTz#Ob%E=J{6QJ?uKsOOICQs_r=>pItQnd^>xD8*dZAf{OsTJQluD z$qCItzuBV&RGxZucB+9dO&U`z^rT^K#d$tn8*b!S%9I<*#D zfmOp`KL#EMJX^Q)`pN-srswwS*Y0e-y=KJPl&FSmLn5{&{fEa)rOAuo9b={}HdHZ0`GMBQ@a;0P#FT^s`rE(>Fik`Fi@E>cqd&mg zG=U-5AdT%-QuP5+)ST5cU!_IRWnf8#se3M>*|hj{WwbiE>+SmCeAJ7@e@b!LUBDpg zSROOpzLs@9>(P21n1n& zUbrV&IF_^Xw$HjW3ki0bnGB zooSuIVL&#Y}NMh3wW)Y+m?qPfGYDG$;H(dW-My@v5 z+;w55qPM*%y35Basxd{?N5!;ouZ07ByfdqE>85l#v?_eSQK%R__4cD;h1``3!%wk!q^zRBE@Pn z`i#-YRM`v&HiGAQyHSRUW!~vH3=a)kML&1ix^j>7OsJGTKL)6LCBTo(<%e9%3ZbLl zW%Kj;?S#7i3;lF$2&MkH$A-FdUB70m`T8>mb{1q!4^pyUbSdo^FU=0A5dVha=A@L+y!vUMvJwmoWl1;M%+aJ*RU2oomqvY1`QCl-EN zt;;@vr0~8Z!{jwQ$nO+GLzj|YJ|B7902^|0+&uIfIBb`1biCtAvVJ0e$$Ejs3LPA` zN%Lgb%@$`BtQ!~i)NcDBK2zF%)^LX(+r-vu3^qk*PxPYm(?Mvtr62_Gd(qZpy>FAg z6U@=?Ylxcv%Y-~1;`Ay+X#9Fa7#i&o6FmeJQJ7L=OV#8?Y4)c77+Bg*!LP81ol`rN z*WM!h5pH4Mwba08Jr%a`TpYLFmxr{3_5P+W{ zZuWj{f~9Y)9{~u8;jzV7E}b**`8!sRsmPxxYT@r@VtSo@BzUGkb!^y3 z+^jiXbT_UXe?UibGx4fd(>CAf+a;Hb%zLG8H34<(?`NOf~5uu`Cf4C?eH z>uMdY=kHyI4Ze+7BQa$&c-uf9a(lQ%u(Cmxf3`R-ga3>!c$mnNUTB}%tJl%ht;;;S zn8)o_=bheSlsf3Uzks1p3{#B1;3l{)~B1@n!z(NM2H{p#_5%x zZ_x*8(aAVCp*#dnc2V*DKvoL&OE|d}AddY82crkN;w6TSXpl{URA|kfW_nPYVy%v{ z0BW^Y{$G5le?JMNhWl_U;(#NeoZ67NAkSq7g8BY_RUwqP@j158!G6dJ_;<<9yPM!t zA6|qXBosLqGelD6iZ7LcPzx#;HYf8O8X*?QQS_b;KRpBRcngXGuDsI9 zx~|Id+9zzD-CPN<1c3Po<0*n`d0TTmyxhuvu9jNQUhObCJI|7gfl`SZC-lKVC}Pc};Vf z+w1IEM+1IE{kzHD{}1A{Y8pmOW8Y=7I>x#T!I5+)4D#d&5GF~g8Fq3#q4w@RtIwi2 zj0rgF%uF_5T1TwizUny^MF@TgMdtW>^dV0JkcSK^mt{7REEJ?AN}ara?(LvXn&A8HftV*fvSANDSFBg-up2DD+*EFGvtjy3$L1coz zIxXd!r##=35#@>1`=H&8j;U98zV9x^H?%$=3pFrb@N>H7F9iLS7jODr?*Q-kjn$r0 zzz6VTt`(E2A0?KKaOerlcOLf#dEibxH~?)T_~K zV{0?+kmc?Pbvg)7&(zt5!zFH+<0XJrob zz{nP5n+LGeX&bxa0*rV=nUp<3Cn)Ct_s>qQHR)rp> z$YciD_>jOWU8123mCCdX-s4;k7gB@k6~o%cQ%eG7p}IWa?LC+kNRd4b=e6Wc=|4FwSLh`D#UDpm;c70M zc<vY$v0ti-P7862m^I1-PqU8^ex*h~cv));_A@S5i_B1#Kwlwk)Y2Dq zZLxGU&&%X)_Z23+t`4m`W-n1Tdzg}=`@>*cpCi(%(Br&i;sf~@oORTH4~HpufJbc} z96Euycbh1d=nWT%63H# zR3HaL@guNbANPJ?BqLD>Gs9`r6Nz3=<=okbZl>DpU=8!U;3P`^WnE+`3B~L?fzx3_ zYW1~b2&K|gci^+Apt8!7^tGj4zQji%hlN?C&(c1UT)dRd_6aWC5*YkzfP%qp><(4NNp z^r%7pjm;{RF|2*l})ppu3&`75n+_7Gq$J8S9EF5EA6+|2&&jLG(?wO zkgsruxwU=sAzA`d_jG&oNvwmq+W(@^4=GTu;#a&02N1{x%9K!G0@1@@xQ`C*WNVqG z9?{EC6ju6HZm=<%`}^SdrK>;S*l_qEpBp)o^0X+&m{EU*>O$dcqx`kSpmdc!}Nti8kN4(7_ldhAxMUJ0I063S;&?hnf?W^l=@NI07 z;<8kfcDlC^aj%rx=STUvow;O^_icZZOQOQFD$yXBQ7Y|Ud!Ej7>7UyQQViIs#(53= z1A|&q3L6G(Mz1o)Pr~ucZx`l@O;H;eajKo;Ql>Z!^{h$|sdLI+g&KdM?AInYPgHI6 zU2E3Yx2KYyhL}=$e!Xs7#hc-YNq7KL&!m5S_=iNaqt=6uzQgldN%6{<1Gn?Uj*Q=r zq$OJN3u;?vFU2?PENvCg>J^U_#KSDi+_BC!;IJ|_EY1M76k)baDH1@ccIQIc!%Pd}ZS_7~Tu99ty{8OnS}@+JnqhPE->wMu?0r@i?XpGvkkCNfHnoaPxU zmvonlIEZskQ67qrp&KFcO~#u8^^q3N0vs6RtHl{whxb>5{P%jiP53Z(4X%aw5sP5V zY5(<7TA(wogg44Gw4?I)pU0;$y5=rF!hDxtE-I^XF8N4Dyd-{gRU*M7Lk5i?5%RuwNlp;758s0v8Dms!DnYWSX_b9^nMz(%QY)f38`VlN#^pT+P>!Ca*uHIf%3oh`ZG@W83ev7$Z;4&ODBw{;b{ zDqo9+glp>1?MWjF0Rr{@3AxAfwGElr zamb%Co6yVl6$y!7f__#nw(V{yNHtyF1??vXFZrHP`tGB^y{^8Np z_hqxY6(Q522~;N&=D#{SwLI@LsFZ4OB}$d){o zqufD}j_@Cc#`{T1%g}d}waEK;b0r(-%_-MjPg}Z~tO3h)nd`guykqUK5Pga5k+cFN$MmD0&*Lrl4@~-=zJYU~x zDeU`bC8s238D-8dxg<+B4<@ER+P!`x>PjzuDXp;U{Y!9r*6j_g$pV)U-t zr#Fn?iq`%m*9QmZ-&uynnuWGJb(OKThX|&1ruf=Atq5FlhY03d7v%p>c8D-}h_HD0 z850g2Ag|f~xbTJNEdq9|1J>*T=RBX!_Y01wcb>T+-jMKwfR(oRJ2pZrUiv3OIbWnu z?MJ3hwSHB{EY|pq1L9)Qk-;sG2rFQ}7j?Lc@Qc4`h@5aMtn>r9IDtn+&Kv8L@bCD> zCa+%s)ArKBn$O_#@$c>iDD?q~`M(uR7*b9`L`Kx;TbWeepZ`p*z&E;ybGN5z_kJg< zC7`1PNi0kRkbzBaj9)&%qVVYq%P|c+FEEjZct%pKSrO6%F!`4eb z7%t(Dvg_HPWYnhvI++FQN~<&OLHIR0K)}*=rCs@VvvbL*Hi*cYUox%Lnp*YzT(0_! z-+-^d!CsXAnm(u8vl@l|v*h=tYdX5{^Re5K=e-k~83i1euT12V-<7$46@ub##7}C} zaYZv`zghA49o@}B_~7`6$y5=mFycK;P%*tXxagI1E8R~yBVW22N zcwX(G(_ELY(jTw|1E|Puy=M6`4XOs2uFx`mS3mcbnWK2rT+5f)nPVg zd1|)N@{NPZLZ66UY#|bDJ%VG2#^wR;K<2)STp$MafTW!BMra^yA-%0&AQf`&he#c) z@c-!-vTrwWxI7q?cHYwboM;_Axn}t;23!B~8S}XVOWoZG!wdR}4$TXT;IGsWzHC$3 zR(Ig7Kf$_q@|@f(G<0=NffdW#OysS`~HMUdDHwp4?d0ySUm}VBH8NnVX5wv z$;7A&DolO&DT4>y(O@@b5@a8;Hx~uL&=H?bJG{*esjfE=p5~v2{@L5-IC@oe)*SPm zjX0*Ql4aZ<3=7LB;JKcysnPCShxFB~*5mmQf0z4VJ@{0kqN&3zuqf=fbDMBG5S(ou zS$uzOz_Yz0q-?FLF+7Q?XpP{k%ZB7LZ7+%of;-1X)XKdrh>Iv&G{PfSWnBa<%vcrS z5P7#Ri^buDkQ$rXY9%Az;gB6#TgM<3-_%}mYza_SkOoE~8WL@Vz7(LijAhA(fkPkd z|G1z-D_{wcE0=qfZN5rsh8;>NWNk39&X%SbUe(!o*NQJ+p0?h-Hd+Ng`LV&7r2cOi z`2R^&zzUEMCTE*Y7ecoihj13e0#L4>UQ-jephhi^y_aKylUnD`g#Yfe$RCD|kH9N&6aB6qspPw7&OJ+w+G})<^)ia7GqI$#IM=fpRbzdU zf*p!E2=rVS=DrJQe;xPy6szo$e)oOA%woUf1Z%pX`II-Px2NkYi=&ML;Fq zLAJadK~GC9r4t*`$*sCZaSr$2D9Vr?f?ejh!Aalxv>|M?%lR&mjB znH6Jpsn~?Za;EeyNB_|0n;%GRf{1S$>~Jk78$QS;38D3z_SNjJElFB9gRct$x&l9U z?!fuIe*T{Hx~Y?xpLUZd{D>Vdm0;*kpLSYAL-*YS(qMfI9YZ7?g907H$le1q-rsP$!i%Jpe#0vZhqKeN44F-hBs8(@ zVX8TK6zUueNLh0HPNC3Y$(oIxR#9lO+UeS)i-5P2e$j;FJIkG5n0{*FuTwzZg%jYj zgC&k(vRJhq3;jzm7P9VhE#B`BoM6`Cc1TMh6>cVw%XOdQs#sVra&LlY)rT(8P%BGPgLcDpoc-iL8jyhv$SoAysw3XE=#$S(3O`k3dM z^EH2S$$@cLafe^gTQrTv6itz3Wp)TQsJx`)OgGG2{;8h}^(`~?)}O=U8At~J From 1e580a75f73f4bddbcacd8e00f8821bfa2219a60 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 5 Dec 2013 10:08:53 +0000 Subject: [PATCH 279/315] refactor(style) fontello --- css/style.css | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/css/style.css b/css/style.css index 4d97503d..dca752f3 100644 --- a/css/style.css +++ b/css/style.css @@ -6,7 +6,10 @@ @font-face { font-family: 'Fontello'; src: url("/font/fontello.eot"); - src: url("/font/fontello.eot?#iefix") format('embedded-opentype'), url("/font/fontello.woff") format('woff'), url("/font/fontello.ttf") format('truetype'), url("/font/fontello.svg#cloudcmd") format('svg'); + src: url("/font/fontello.eot?#iefix") format('embedded-opentype'), + url("/font/fontello.woff") format('woff'), + url("/font/fontello.ttf") format('truetype'), + url("/font/fontello.svg#cloudcmd") format('svg'); font-weight: normal; font-style: normal; } From 921ac86ca4bfeb3bc75125d07e894814190b08fc Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 5 Dec 2013 10:16:07 +0000 Subject: [PATCH 280/315] feature(style) rm .current-file > .mini-icon --- css/style.css | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/css/style.css b/css/style.css index dca752f3..b8c02f16 100644 --- a/css/style.css +++ b/css/style.css @@ -136,14 +136,7 @@ body { * рамки */ } -/* уменьшаем отступ - * между между иконкой и - * именем файла во время - * установления курсора - */ -.current-file > .mini-icon { - left: -6px; -} + /* freeupex */ .directory { /*list-style-image*/ From 0384bc8fa8e184a0d347033765b8b1e7423507da Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 5 Dec 2013 10:17:20 +0000 Subject: [PATCH 281/315] chore(style) rm comments --- css/style.css | 3 --- 1 file changed, 3 deletions(-) diff --git a/css/style.css b/css/style.css index b8c02f16..266cdf30 100644 --- a/css/style.css +++ b/css/style.css @@ -137,15 +137,12 @@ body { */ } -/* freeupex */ .directory { - /*list-style-image*/ background-image:url('/img/dir.png'); background-position: 0 0; background-repeat: no-repeat; } .text-file { - /*list-style-image*/ background-image:url('/img/txt.png'); background-position: 0 0; background-repeat: no-repeat; From 14df5aab3babdd6debf8537f1a9640cb1542c784 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 5 Dec 2013 10:18:45 +0000 Subject: [PATCH 282/315] refactor(style) .mini-icon: background --- css/style.css | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/css/style.css b/css/style.css index 266cdf30..19abb375 100644 --- a/css/style.css +++ b/css/style.css @@ -131,6 +131,8 @@ body { width: 16px; height: 16px; margin-left: 6px; + background-position: 0 0; + background-repeat: no-repeat; /* отступ перед картинкой * для нормального отображения * рамки @@ -139,13 +141,9 @@ body { .directory { background-image:url('/img/dir.png'); - background-position: 0 0; - background-repeat: no-repeat; } .text-file { background-image:url('/img/txt.png'); - background-position: 0 0; - background-repeat: no-repeat; } .fm { height: 90%; From 47035c62766d0d91be457599ced772188948e991 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 5 Dec 2013 10:23:00 +0000 Subject: [PATCH 283/315] chore(style) mv comment --- css/style.css | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/css/style.css b/css/style.css index 19abb375..2e3f1244 100644 --- a/css/style.css +++ b/css/style.css @@ -126,6 +126,10 @@ body { .mini-icon { position: relative; top: 2px; + /* отступ перед картинкой + * для нормального отображения + * рамки + */ left: -5px; float: left; width: 16px; @@ -133,10 +137,6 @@ body { margin-left: 6px; background-position: 0 0; background-repeat: no-repeat; - /* отступ перед картинкой - * для нормального отображения - * рамки - */ } .directory { From 0961d775e4309e0ea5fa3c105b9cfb91ab1ebb09 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 5 Dec 2013 10:26:29 +0000 Subject: [PATCH 284/315] refactor(style) add rgb before rgba --- css/style.css | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/css/style.css b/css/style.css index 2e3f1244..8b06cf6f 100644 --- a/css/style.css +++ b/css/style.css @@ -94,7 +94,9 @@ body { text-overflow: ellipsis; white-space: nowrap; background-color: white; - border: 1.5px solid rgba(49,123,249,.40); + border: 1.5px solid; + border-color: rgb(49,123,249); + border-color: rgba(49,123,249,.40); outline: 0; transition: ease 0.1s; } @@ -176,10 +178,13 @@ body { padding: 20px; margin: 0; overflow-y: auto; - border: 1.5px solid rgba(49, 123, 249, .40); + border: 1.5px solid; + border-color: rgb(49, 123, 249); + border-color: rgba(49, 123, 249, .40); } .selected-panel { + border-color: rgb(254, 159, 224); border-color: rgba(254, 159, 224, .40); } From 0ac8a9a123b5ddff79650d7ae2b01562baa87280 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 5 Dec 2013 10:27:43 +0000 Subject: [PATCH 285/315] feature(style) .cmd-button: rm outline --- css/style.css | 1 - 1 file changed, 1 deletion(-) diff --git a/css/style.css b/css/style.css index 8b06cf6f..66de819d 100644 --- a/css/style.css +++ b/css/style.css @@ -97,7 +97,6 @@ body { border: 1.5px solid; border-color: rgb(49,123,249); border-color: rgba(49,123,249,.40); - outline: 0; transition: ease 0.1s; } From 65ef0428ec869bcad223da2434f506a64635761a Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 5 Dec 2013 12:01:44 +0000 Subject: [PATCH 286/315] refactor(client) createFileTable --- lib/client.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/client.js b/lib/client.js index a14bf474..44d5c3c0 100644 --- a/lib/client.js +++ b/lib/client.js @@ -396,13 +396,13 @@ var Util, DOM, CloudFunc, CloudCmd; function createFileTable(pElem, pJSON) { var lElem = DOM.getById(pElem), /* getting current element if was refresh */ - lPath = DOM.getByClass('path', lElem), + lPath = DOM.getCurrentDirPath(lElem), lCurrent = DOM.getCurrentFile(), lDir = DOM.getCurrentDirName(), lName = DOM.getCurrentName(lCurrent), - lWasRefresh_b = lPath[0].textContent === pJSON.path, + lWasRefresh_b = lPath === pJSON.path, lFuncs = [ CloudCmd.getFileTemplate, CloudCmd.getPathTemplate, From 8469c700a773ff63d3b6e68bfe64f43e509f60d5 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 5 Dec 2013 12:10:52 +0000 Subject: [PATCH 287/315] refactor(client) createFileTable: rm pElem --- lib/client.js | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/lib/client.js b/lib/client.js index 44d5c3c0..2fe6e784 100644 --- a/lib/client.js +++ b/lib/client.js @@ -342,7 +342,6 @@ var Util, DOM, CloudFunc, CloudCmd; DOM.setTitle( CloudFunc.getTitle(lCleanPath) ); - var lPanel = DOM.getPanel().id; /* если доступен localStorage и * в нём есть нужная нам директория - * читаем данные с него и @@ -356,7 +355,7 @@ var Util, DOM, CloudFunc, CloudCmd; if (lJSON) { lJSON = Util.parseJSON(lJSON); - createFileTable(lPanel, lJSON); + createFileTable(lJSON); } else lRet = true; @@ -373,7 +372,7 @@ var Util, DOM, CloudFunc, CloudCmd; }, success : function(pData) { - createFileTable(lPanel, pData); + createFileTable(pData); /* переводим таблицу файлов в строку, для * * сохранения в localStorage */ @@ -390,13 +389,12 @@ var Util, DOM, CloudFunc, CloudCmd; /** * Функция строит файловую таблицу - * @param pEleme - родительский элемент * @param pJSON - данные о файлах */ - function createFileTable(pElem, pJSON) { - var lElem = DOM.getById(pElem), + function createFileTable(pJSON) { + var panel = DOM.getPanel(), /* getting current element if was refresh */ - lPath = DOM.getCurrentDirPath(lElem), + lPath = DOM.getCurrentDirPath(panel), lCurrent = DOM.getCurrentFile(), lDir = DOM.getCurrentDirName(), @@ -411,36 +409,36 @@ var Util, DOM, CloudFunc, CloudCmd; Util.asyncCall(lFuncs, function(pTemplate, pPathTemplate, pLinkTemplate) { /* очищаем панель */ - var i = lElem.childNodes.length; + var i = panel.childNodes.length; while(i--) - lElem.removeChild(lElem.lastChild); + panel.removeChild(panel.lastChild); - lElem.innerHTML = CloudFunc.buildFromJSON(pJSON, pTemplate, pPathTemplate, pLinkTemplate); + panel.innerHTML = CloudFunc.buildFromJSON(pJSON, pTemplate, pPathTemplate, pLinkTemplate); /* если нажали на ссылку на верхний каталог*/ var lFound; /* searching current file */ if (lWasRefresh_b) { - var n = lElem.childNodes.length; + var n = panel.childNodes.length; for(i = 2; i < n ; i++) { - var lVarCurrent = lElem.childNodes[i], + var lVarCurrent = panel.childNodes[i], lVarName = DOM.getCurrentName(lVarCurrent); lFound = lVarName === lName; if (lFound) { - lCurrent = lElem.childNodes[i]; + lCurrent = panel.childNodes[i]; break; } } } if (!lFound) /* .. */ - lCurrent = lElem.childNodes[2]; + lCurrent = panel.childNodes[2]; DOM.setCurrentFile(lCurrent); - Listeners.changeLinks(pElem); + Listeners.changeLinks(panel.id); if (lName === '..' && lDir !== '/') currentToParent(lDir); From 45f59f18c22d9a05bcab8dd4aeac72b24147da00 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 5 Dec 2013 14:51:42 +0000 Subject: [PATCH 288/315] feature(cloudcmd) do not hide path and header when files are scrolling --- cloudcmd.js | 4 ++-- css/style.css | 6 ++++-- html/index.html | 2 +- html/path.html | 2 +- lib/client.js | 22 +++++++++++----------- lib/client/dom.js | 15 ++++++++++++++- lib/cloudfunc.js | 22 ++++++++++++++-------- 7 files changed, 47 insertions(+), 26 deletions(-) diff --git a/cloudcmd.js b/cloudcmd.js index 42b02abe..364d0d96 100644 --- a/cloudcmd.js +++ b/cloudcmd.js @@ -260,8 +260,8 @@ else { p.name = INDEX_PATH, lPanel = CloudFunc.buildFromJSON(pJSON, FileTemplate, PathTemplate, LinkTemplate), - lList = '
      ' + lPanel + '
    ' + - ''; + lList = '
    ' + lPanel + '
    ' + + ''; main.sendResponse(p, indexProcessing({ additional : lList, diff --git a/css/style.css b/css/style.css index 66de819d..878d05cb 100644 --- a/css/style.css +++ b/css/style.css @@ -176,7 +176,6 @@ body { width: 46%; padding: 20px; margin: 0; - overflow-y: auto; border: 1.5px solid; border-color: rgb(49, 123, 249); border-color: rgba(49, 123, 249, .40); @@ -210,7 +209,10 @@ body { width: 23%; } -.panel, li { +.files { + overflow-y: auto; + padding: 0; + margin: 0; list-style-type: none; cursor: default; } diff --git a/html/index.html b/html/index.html index adcd949c..3b140811 100644 --- a/html/index.html +++ b/html/index.html @@ -84,7 +84,7 @@ Height = (Height / 100).toFixed() * 100; style = document.createElement('style'); - style.innerText = '.panel {' + + style.innerText = '.files {' + 'height:' + Height +'px;' + '}'; diff --git a/html/path.html b/html/path.html index ca997182..e876eea1 100644 --- a/html/path.html +++ b/html/path.html @@ -1 +1 @@ -
  • {{ path }}
  • \ No newline at end of file +
    {{ path }}
    \ No newline at end of file diff --git a/lib/client.js b/lib/client.js index 2fe6e784..5564d13e 100644 --- a/lib/client.js +++ b/lib/client.js @@ -255,11 +255,9 @@ var Util, DOM, CloudFunc, CloudCmd; Util.exec(pCallBack); /* выделяем строку с первым файлом */ - var lFmHeader = DOM.getByClass('fm-header'); - if (lFmHeader && lFmHeader[0]) { - var lCurrent = lFmHeader[0].nextSibling; - DOM.setCurrentFile(lCurrent); - } + var lFiles = DOM.getFiles(); + if (lFiles) + DOM.setCurrentFile(lFiles[0]); Util.exec(CloudCmd.Key); } @@ -392,7 +390,8 @@ var Util, DOM, CloudFunc, CloudCmd; * @param pJSON - данные о файлах */ function createFileTable(pJSON) { - var panel = DOM.getPanel(), + var files, + panel = DOM.getPanel(), /* getting current element if was refresh */ lPath = DOM.getCurrentDirPath(panel), @@ -416,25 +415,26 @@ var Util, DOM, CloudFunc, CloudCmd; panel.innerHTML = CloudFunc.buildFromJSON(pJSON, pTemplate, pPathTemplate, pLinkTemplate); + files = DOM.getFiles(panel); /* если нажали на ссылку на верхний каталог*/ var lFound; /* searching current file */ if (lWasRefresh_b) { - var n = panel.childNodes.length; - for(i = 2; i < n ; i++) { - var lVarCurrent = panel.childNodes[i], + var n = files.length; + for(i = 0; i < n ; i++) { + var lVarCurrent = files[i], lVarName = DOM.getCurrentName(lVarCurrent); lFound = lVarName === lName; if (lFound) { - lCurrent = panel.childNodes[i]; + lCurrent = files[i]; break; } } } if (!lFound) /* .. */ - lCurrent = panel.childNodes[2]; + lCurrent = files[0]; DOM.setCurrentFile(lCurrent); diff --git a/lib/client/dom.js b/lib/client/dom.js index 40261a7a..d342e14d 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -1863,7 +1863,7 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; * @param pPanel_o = {active: true} */ this.getPanel = function(pActive) { - var lPanel = this.getCurrentFile().parentElement; + var lPanel = this.getCurrentFile().parentElement.parentElement; /* if {active : false} getting passive panel */ if (pActive && !pActive.active) { @@ -1885,6 +1885,19 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; return lPanel; }; + this.getFiles = function() { + var files = DOM.getByClass('files')[0]; + + return files; + }; + + this.getFiles = function(element) { + var files = DOM.getByClass('files', element)[0], + ret = files.children || []; + + return ret; + }; + /** prevent default event */ this.preventDefault = function(pEvent) { var lRet, diff --git a/lib/cloudfunc.js b/lib/cloudfunc.js index f3b16e70..ea9afccb 100644 --- a/lib/cloudfunc.js +++ b/lib/cloudfunc.js @@ -339,20 +339,24 @@ var Util; lFileTable = Util.render(pPathTemplate, { link: FS + lRefreshPath, path: lHtmlPath + }), + + lHeader = Util.render(pTemplate, { + className : 'fm-header', + type : '', + name : 'name', + size : 'size', + owner : 'owner', + mode : 'mode' }); - lFileTable += Util.render(pTemplate, { - className : 'fm-header', - type : '', - name : 'name', - size : 'size', - owner : 'owner', - mode : 'mode' - }); + lHeader = Util.replaceStr(lHeader, 'li', 'div'); + lFileTable += lHeader; /* сохраняем путь */ CloudFunc.Path = lPath; + lFileTable += '
      '; /* Если мы не в корне */ if (lPath !== '/') { /* ссылка на верхний каталог*/ @@ -413,6 +417,8 @@ var Util; }); } + lFileTable += '
    '; + return lFileTable; }; } From 40c1d825ad4ae386af5314fb172c2a3b7e38fbce Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 5 Dec 2013 14:56:58 +0000 Subject: [PATCH 289/315] refactor(dom) getPanel --- lib/client/dom.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/client/dom.js b/lib/client/dom.js index d342e14d..659aa465 100644 --- a/lib/client/dom.js +++ b/lib/client/dom.js @@ -1863,7 +1863,9 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog; * @param pPanel_o = {active: true} */ this.getPanel = function(pActive) { - var lPanel = this.getCurrentFile().parentElement.parentElement; + var lCurrent = this.getCurrentFile(), + files = lCurrent.parentElement, + lPanel = files.parentElement; /* if {active : false} getting passive panel */ if (pActive && !pActive.active) { From 15d85997b836734cc080cc757fc1e572fb6f29de Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 5 Dec 2013 15:13:23 +0000 Subject: [PATCH 290/315] docs(help) Tarzak: add ability do not hide path and header --- HELP.md | 1 + 1 file changed, 1 insertion(+) diff --git a/HELP.md b/HELP.md index d1ed3b35..95c0b7ff 100644 --- a/HELP.md +++ b/HELP.md @@ -395,3 +395,4 @@ Special Thanks - [ru](http://ru.cloudcmd.io "Cloud Commander in Russian") and [ua](http://ua.cloudcmd.io "Cloud Commander in Ukrainian") translations; - config template and style; - change order of directories and files; + - add ability do not hide path and header when files are scrolling; From 424cf51c1a4d2dc2dc5ba5cf100691c442162e47 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 5 Dec 2013 15:13:45 +0000 Subject: [PATCH 291/315] docs(help) Tarzak -> TarZak --- HELP.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/HELP.md b/HELP.md index 95c0b7ff..da23b4de 100644 --- a/HELP.md +++ b/HELP.md @@ -391,7 +391,7 @@ Special Thanks --------------- - [Polietilena](http://polietilena.github.io/ "Polietilena") for [logo](img/logo/cloudcmd.png "logo") and [favicon](img/favicon/favicon.png "favicon"); -- [Tarzak](https://github.com/jobtarzak) +- [TarZak](https://github.com/jobtarzak) - [ru](http://ru.cloudcmd.io "Cloud Commander in Russian") and [ua](http://ua.cloudcmd.io "Cloud Commander in Ukrainian") translations; - config template and style; - change order of directories and files; From 14eeffb01f0c0e58def1a34a3665612dbef7d313 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 5 Dec 2013 16:35:57 +0000 Subject: [PATCH 292/315] fix(key) panel -> files --- lib/client/key.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/client/key.js b/lib/client/key.js index ce8bf021..9407bee1 100644 --- a/lib/client/key.js +++ b/lib/client/key.js @@ -102,14 +102,13 @@ var CloudCmd, Util, DOM; function setCurrentByLetter(pKeyCode) { var i, n, name, isCurrent, isContain, lCurrent = DOM.getCurrentFile(), - panel = DOM.getPanel(), - nodes = panel.childNodes, + files = DOM.getFiles(), SMALL = 32, char = String.fromCharCode(pKeyCode + SMALL); - n = nodes.length; + n = files.length; for (i = 2; i < n; i++) { - lCurrent = panel.childNodes[i]; + lCurrent = files[i]; name = DOM.getCurrentName(lCurrent); isContain = Util.isContainStrAtBegin(name, char); From e46317f1f1568305e781dd0997dcbf2490948c4f Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 5 Dec 2013 16:38:42 +0000 Subject: [PATCH 293/315] feature(config) list: add list-style-type --- css/config.css | 1 + 1 file changed, 1 insertion(+) diff --git a/css/config.css b/css/config.css index 36e0345d..dec431ea 100644 --- a/css/config.css +++ b/css/config.css @@ -8,6 +8,7 @@ -ms-user-select: none; -o-user-select: none; user-select: none; + list-style-type: none; } .config .form-control{ From 7385fd6242c04445cbfc5393ddaf640a8a3d6434 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 5 Dec 2013 16:39:44 +0000 Subject: [PATCH 294/315] feature(config) add -moz and -o --- css/config.css | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/css/config.css b/css/config.css index dec431ea..c5c9e7e8 100644 --- a/css/config.css +++ b/css/config.css @@ -19,8 +19,11 @@ background-color: #ffffff; border: 1px solid #cccccc; -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); + -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075); -webkit-transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s; + -moz-transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s; + -o-transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s; transition: border-color ease-in-out 0.15s, box-shadow ease-in-out 0.15s; } @@ -35,6 +38,7 @@ border-color: #66afe9; outline: 0; -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 1px rgba(102, 175, 233, 0.6); + -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 1px rgba(102, 175, 233, 0.6); box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 1px rgba(102, 175, 233, 0.6); } From 8a08fef833ff5acff0c636e6edac6e83c0058988 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Thu, 5 Dec 2013 16:55:53 +0000 Subject: [PATCH 295/315] feature(cloudcmd) add readIndex; when minify - index to --- cloudcmd.js | 59 +++++++++++++++++++++++++++++++++++------------------ 1 file changed, 39 insertions(+), 20 deletions(-) diff --git a/cloudcmd.js b/cloudcmd.js index 364d0d96..ad66ad20 100644 --- a/cloudcmd.js +++ b/cloudcmd.js @@ -239,9 +239,7 @@ if (lRet) { p = pParams; main.commander.getDirContent(p.name, function(pError, pJSON) { - var lQuery, isJSON, lPanel, lList, - config = main.config, - minify = config.minify; + var lQuery, isJSON; if (pError) main.sendError(pParams, pError); @@ -249,31 +247,52 @@ lQuery = main.getQuery(p.request); isJSON = Util.isContainStr(lQuery, 'json'); - if (isJSON) { + if (!isJSON) + readIndex(pJSON, pParams); + else { p.data = Util.stringifyJSON(pJSON); p.name +='.json'; main.sendResponse(p, null, true); - } else - fs.readFile(INDEX_PATH, 'utf8', function(error, template) { - if (error) - main.sendError(p, error); - else { - p.name = INDEX_PATH, - lPanel = CloudFunc.buildFromJSON(pJSON, FileTemplate, PathTemplate, LinkTemplate), - lList = '
    ' + lPanel + '
    ' + - ''; - - main.sendResponse(p, indexProcessing({ - additional : lList, - data : template, - }), true); - } - }); + } + } }); } } + function readIndex(pJSON, params) { + var p = params; + + Util.ifExec(!minify, function(params) { + var name = params && params.name; + + fs.readFile(name || INDEX_PATH, 'utf8', function(error, template) { + var lPanel, lList, + config = main.config, + minify = config.minify; + + if (error) + main.sendError(p, error); + else { + p.name = INDEX_PATH, + lPanel = CloudFunc.buildFromJSON(pJSON, FileTemplate, PathTemplate, LinkTemplate), + lList = '
    ' + lPanel + '
    ' + + ''; + + main.sendResponse(p, indexProcessing({ + additional : lList, + data : template, + }), true); + } + }); + }, function(callback) { + Minify.optimize(INDEX_PATH, { + callback : callback, + returnName : true + }); + }); + } + /* function sets stdout to file log.txt */ function writeLogsToFile() { From f43939337027e1690377f34ccb1eb6b69dd619c7 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 6 Dec 2013 08:20:29 +0000 Subject: [PATCH 296/315] fix(key) setCurrentByLetter i: 2 -> 0 --- lib/client/key.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/client/key.js b/lib/client/key.js index 9407bee1..c555b24e 100644 --- a/lib/client/key.js +++ b/lib/client/key.js @@ -107,7 +107,7 @@ var CloudCmd, Util, DOM; char = String.fromCharCode(pKeyCode + SMALL); n = files.length; - for (i = 2; i < n; i++) { + for (i = 0; i < n; i++) { lCurrent = files[i]; name = DOM.getCurrentName(lCurrent); isContain = Util.isContainStrAtBegin(name, char); From 29f1cbbc5e38b3e5f2b92235f8e7977647ac40fc Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 6 Dec 2013 09:07:14 +0000 Subject: [PATCH 297/315] feature(key) add moving by first letter --- lib/client/key.js | 46 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 39 insertions(+), 7 deletions(-) diff --git a/lib/client/key.js b/lib/client/key.js index c555b24e..ea8fa9d9 100644 --- a/lib/client/key.js +++ b/lib/client/key.js @@ -2,7 +2,8 @@ var CloudCmd, Util, DOM; (function(CloudCmd, Util, DOM) { 'use strict'; - var KEY = { + var Chars = [], + KEY = { TAB : 9, ENTER : 13, ESC : 27, @@ -81,8 +82,10 @@ var CloudCmd, Util, DOM; if (Binded) { if (!lAlt && !lCtrl && lKeyCode >= KEY.A && lKeyCode <= KEY.Z) setCurrentByLetter(lKeyCode); - else + else { + Chars = []; switchKey(pEvent); + } /* устанавливаем все обработчики * нажатий клавиш @@ -100,24 +103,53 @@ var CloudCmd, Util, DOM; } function setCurrentByLetter(pKeyCode) { - var i, n, name, isCurrent, isContain, + var i, n, name, isCurrent, isContain, byName, firstByName, + skipCount = 0, + skipN = 0, + setted = false, lCurrent = DOM.getCurrentFile(), files = DOM.getFiles(), SMALL = 32, + charBig = String.fromCharCode(pKeyCode), char = String.fromCharCode(pKeyCode + SMALL); + + n = Chars.length; + for (i = 0; i < n; i++) + if (char !== Chars[i]) + break; + + if (!i) + Chars = []; + + skipN = skipCount = i; + Chars.push(char); n = files.length; for (i = 0; i < n; i++) { lCurrent = files[i]; name = DOM.getCurrentName(lCurrent); - isContain = Util.isContainStrAtBegin(name, char); + isContain = Util.isContainStrAtBegin(name, [char, charBig]); if (isContain) { - lCurrent = DOM.getCurrentFileByName(name); - DOM.setCurrentFile(lCurrent); - break; + byName = DOM.getCurrentFileByName(name); + + if (!skipCount) { + setted = true; + DOM.setCurrentFile(byName); + break; + } else { + if (skipN === skipCount) + firstByName = byName; + + --skipCount; + } } } + + if (!setted) { + DOM.setCurrentFile(firstByName); + Chars = [char]; + } } function switchKey(pEvent) { From 2ca1ac53babf3b13ada7320cde4a93cf9de91693 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 6 Dec 2013 09:08:39 +0000 Subject: [PATCH 298/315] refactor(key) charBig -> char, char -> charSmall --- lib/client/key.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/client/key.js b/lib/client/key.js index ea8fa9d9..8303821f 100644 --- a/lib/client/key.js +++ b/lib/client/key.js @@ -110,8 +110,8 @@ var CloudCmd, Util, DOM; lCurrent = DOM.getCurrentFile(), files = DOM.getFiles(), SMALL = 32, - charBig = String.fromCharCode(pKeyCode), - char = String.fromCharCode(pKeyCode + SMALL); + char = String.fromCharCode(pKeyCode), + charSmall = String.fromCharCode(pKeyCode + SMALL); n = Chars.length; for (i = 0; i < n; i++) @@ -128,7 +128,7 @@ var CloudCmd, Util, DOM; for (i = 0; i < n; i++) { lCurrent = files[i]; name = DOM.getCurrentName(lCurrent); - isContain = Util.isContainStrAtBegin(name, [char, charBig]); + isContain = Util.isContainStrAtBegin(name, [char, charSmall]); if (isContain) { byName = DOM.getCurrentFileByName(name); From 551958f713020c3bb1a01d2a9237334d0e7feb99 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 6 Dec 2013 12:28:12 +0000 Subject: [PATCH 299/315] fix(dropbox) Drivers -> Dropbox.AuthDriver --- html/auth/dropbox.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/html/auth/dropbox.html b/html/auth/dropbox.html index d3cf199e..21a731e3 100644 --- a/html/auth/dropbox.html +++ b/html/auth/dropbox.html @@ -5,7 +5,7 @@ - \ No newline at end of file + From 2cb28da206402579d9251781bf68716efda8a642 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 6 Dec 2013 13:25:17 +0000 Subject: [PATCH 300/315] feature(dropbox) add getToken, mkDir, writeFile, readFile, readDir --- lib/client/storage/_dropbox.js | 66 ++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/lib/client/storage/_dropbox.js b/lib/client/storage/_dropbox.js index 687c42d8..612ab797 100644 --- a/lib/client/storage/_dropbox.js +++ b/lib/client/storage/_dropbox.js @@ -83,6 +83,72 @@ var CloudCmd, Util, DOM, Dropbox, cb, Client; }); }; + + + this.readDir = function(dirPath, callback) { + var path = dirPath || '/'; + + Client.readdir(path, function(error, names, obj, files) { + var i, n, name, size, file, fullSize, msg, + json = { + path : path, + files : [] + }; + + if (error) + msg = error.responseText; + + n = files && files.length; + + for (i = 0; i < n; i++) { + file = files[i]; + name = file.name; + + if (!file.isFile) + size = 'dir'; + else + size = CloudFunc.getShortSize(file.size); + + json.files.push({ + name: name, + size: size + }); + } + + Util.exec(callback, msg, json); + }); + }; + + this.readFile = function(name, callback) { + Client.readFile(name, function(error, data) { + var msg; + + if (error) + msg = error.responseText; + + callback(msg, data); + }); + }; + + this.writeFile = function(name, data, callback) { + Client.writeFile(name, data, function(error, data) { + var msg; + + if (error) + msg = error.responseText; + + callback(msg, data); + }); + }; + + this.mkDir = function(path, callback) { + Client.mkdir(path, callback); + }; + + this.getToken = function() { + return Client.credentials().token; + }; + /** * upload file to DropBox */ From 4605992cdf98341dffab9d270ea1845ed9f3acb3 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 6 Dec 2013 13:40:31 +0000 Subject: [PATCH 301/315] feature(dropbox) add read --- lib/client/storage/_dropbox.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/client/storage/_dropbox.js b/lib/client/storage/_dropbox.js index 612ab797..6babc146 100644 --- a/lib/client/storage/_dropbox.js +++ b/lib/client/storage/_dropbox.js @@ -130,6 +130,23 @@ var CloudCmd, Util, DOM, Dropbox, cb, Client; }); }; + this.read = function(path, callback) { + Client.stat(path, function(error, stat) { + var msg, read; + + if (error) + msg = error.responseText; + else { + if (stat.isFile) + read = DropBoxStore.readFile; + else + read = DropBoxStore.readDir; + + read(path, callback); + } + }); + }; + this.writeFile = function(name, data, callback) { Client.writeFile(name, data, function(error, data) { var msg; From d82dc61bfef84340291d0f35d34063bc444d224d Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 6 Dec 2013 13:55:35 +0000 Subject: [PATCH 302/315] feature(dropbox) add save --- lib/client/storage/_dropbox.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/client/storage/_dropbox.js b/lib/client/storage/_dropbox.js index 6babc146..3cce3cb5 100644 --- a/lib/client/storage/_dropbox.js +++ b/lib/client/storage/_dropbox.js @@ -147,6 +147,13 @@ var CloudCmd, Util, DOM, Dropbox, cb, Client; }); }; + this.save = function(path, data, callback, query) { + if (query === '?dir') + DropBoxStore.mkDir(path, callback); + else + DropBox.writeFile(path, data, callback); + }; + this.writeFile = function(name, data, callback) { Client.writeFile(name, data, function(error, data) { var msg; From 615a80a132d41205e9d32ab8251c475ad99be70b Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 6 Dec 2013 13:59:56 +0000 Subject: [PATCH 303/315] refactor(dropbox) public -> private: mkDir, readDir, readFile, writeFile --- lib/client/storage/_dropbox.js | 119 ++++++++++++++++----------------- 1 file changed, 59 insertions(+), 60 deletions(-) diff --git a/lib/client/storage/_dropbox.js b/lib/client/storage/_dropbox.js index 3cce3cb5..3fb7bb8f 100644 --- a/lib/client/storage/_dropbox.js +++ b/lib/client/storage/_dropbox.js @@ -84,8 +84,57 @@ var CloudCmd, Util, DOM, Dropbox, cb, Client; }; + this.read = function(path, callback) { + Client.stat(path, function(error, stat) { + var msg, read; + + if (error) + msg = error.responseText; + else { + if (stat.isFile) + read = readFile; + else + read = readDir; + + read(path, callback); + } + }); + }; - this.readDir = function(dirPath, callback) { + this.save = function(path, data, callback, query) { + if (query === '?dir') + mkDir(path, callback); + else + writeFile(path, data, callback); + }; + + this.getToken = function() { + return Client.credentials().token; + }; + + /** + * upload file to DropBox + */ + this.uploadFile = function(pParams, pCallBack){ + var lContent = pParams.data, + lName = pParams.name; + + if(lContent){ + DOM.Images.showLoad(); + if(!lName) + lName = Util.getDate(); + + Client.writeFile(lName, lContent, function(pError, pData){ + DOM.Images.hideLoad(); + Util.log(pError || pData); + Util.exec(pCallBack); + }); + } + + return lContent; + }; + + function readDir(dirPath, callback) { var path = dirPath || '/'; Client.readdir(path, function(error, names, obj, files) { @@ -117,9 +166,13 @@ var CloudCmd, Util, DOM, Dropbox, cb, Client; Util.exec(callback, msg, json); }); - }; + } - this.readFile = function(name, callback) { + function mkDir(path, callback) { + Client.mkdir(path, callback); + } + + function readFile(name, callback) { Client.readFile(name, function(error, data) { var msg; @@ -128,33 +181,9 @@ var CloudCmd, Util, DOM, Dropbox, cb, Client; callback(msg, data); }); - }; + } - this.read = function(path, callback) { - Client.stat(path, function(error, stat) { - var msg, read; - - if (error) - msg = error.responseText; - else { - if (stat.isFile) - read = DropBoxStore.readFile; - else - read = DropBoxStore.readDir; - - read(path, callback); - } - }); - }; - - this.save = function(path, data, callback, query) { - if (query === '?dir') - DropBoxStore.mkDir(path, callback); - else - DropBox.writeFile(path, data, callback); - }; - - this.writeFile = function(name, data, callback) { + function writeFile(name, data, callback) { Client.writeFile(name, data, function(error, data) { var msg; @@ -163,37 +192,7 @@ var CloudCmd, Util, DOM, Dropbox, cb, Client; callback(msg, data); }); - }; - - this.mkDir = function(path, callback) { - Client.mkdir(path, callback); - }; - - this.getToken = function() { - return Client.credentials().token; - }; - - /** - * upload file to DropBox - */ - this.uploadFile = function(pParams, pCallBack){ - var lContent = pParams.data, - lName = pParams.name; - - if(lContent){ - DOM.Images.showLoad(); - if(!lName) - lName = Util.getDate(); - - Client.writeFile(lName, lContent, function(pError, pData){ - DOM.Images.hideLoad(); - Util.log(pError || pData); - Util.exec(pCallBack); - }); - } - - return lContent; - }; + } init(pCallBack); } From f99cb5c765f0d398dcd84943f4698fcaa8a0f188 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 6 Dec 2013 14:12:03 +0000 Subject: [PATCH 304/315] feature(dropbox) add delete, cp, mv --- lib/client/storage/_dropbox.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/client/storage/_dropbox.js b/lib/client/storage/_dropbox.js index 3fb7bb8f..7b0cccb2 100644 --- a/lib/client/storage/_dropbox.js +++ b/lib/client/storage/_dropbox.js @@ -108,6 +108,18 @@ var CloudCmd, Util, DOM, Dropbox, cb, Client; writeFile(path, data, callback); }; + this.delete = function(path, callback) { + Client.delete(path, callback); + }; + + this.cp = function(from, to, callback) { + Client.copy(from, to, callback); + }; + + this.mv = function(from, to, callback) { + Client.move(from, to, callback); + }; + this.getToken = function() { return Client.credentials().token; }; From 5e0c09b338a353753fc18c0c5941fdf5484b13de Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 6 Dec 2013 16:28:11 +0200 Subject: [PATCH 305/315] docs(help) jobtarzak -> tarzak --- HELP.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/HELP.md b/HELP.md index da23b4de..d7a5cc5a 100644 --- a/HELP.md +++ b/HELP.md @@ -391,7 +391,7 @@ Special Thanks --------------- - [Polietilena](http://polietilena.github.io/ "Polietilena") for [logo](img/logo/cloudcmd.png "logo") and [favicon](img/favicon/favicon.png "favicon"); -- [TarZak](https://github.com/jobtarzak) +- [TarZak](https://github.com/tarzak) - [ru](http://ru.cloudcmd.io "Cloud Commander in Russian") and [ua](http://ua.cloudcmd.io "Cloud Commander in Ukrainian") translations; - config template and style; - change order of directories and files; From a6c2fa183a80b5e88271a3f6e80f2d7a15c9b0fe Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 6 Dec 2013 16:00:27 +0000 Subject: [PATCH 306/315] refactor(client) private -> public: createFileTable --- lib/client.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/client.js b/lib/client.js index 5564d13e..3da247f0 100644 --- a/lib/client.js +++ b/lib/client.js @@ -353,7 +353,7 @@ var Util, DOM, CloudFunc, CloudCmd; if (lJSON) { lJSON = Util.parseJSON(lJSON); - createFileTable(lJSON); + CloudCmd.createFileTable(lJSON); } else lRet = true; @@ -370,7 +370,7 @@ var Util, DOM, CloudFunc, CloudCmd; }, success : function(pData) { - createFileTable(pData); + CloudCmd.createFileTable(pData); /* переводим таблицу файлов в строку, для * * сохранения в localStorage */ @@ -389,7 +389,7 @@ var Util, DOM, CloudFunc, CloudCmd; * Функция строит файловую таблицу * @param pJSON - данные о файлах */ - function createFileTable(pJSON) { + this.createFileTable = function(pJSON) { var files, panel = DOM.getPanel(), /* getting current element if was refresh */ From 73741cce73326e5a46ae28ac08d0756d9293e850 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 6 Dec 2013 16:03:40 +0000 Subject: [PATCH 307/315] feature(dropbox) readDir: add path condition --- lib/client/storage/_dropbox.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/client/storage/_dropbox.js b/lib/client/storage/_dropbox.js index 7b0cccb2..24366158 100644 --- a/lib/client/storage/_dropbox.js +++ b/lib/client/storage/_dropbox.js @@ -155,6 +155,9 @@ var CloudCmd, Util, DOM, Dropbox, cb, Client; path : path, files : [] }; + + if (path !== '/') + path += '/'; if (error) msg = error.responseText; From e7c59aaa68a536a304ef517ea93b480bff8af458 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 6 Dec 2013 16:07:21 +0000 Subject: [PATCH 308/315] fix(dropbox) path -> json.path --- lib/client/storage/_dropbox.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/client/storage/_dropbox.js b/lib/client/storage/_dropbox.js index 24366158..cba522a4 100644 --- a/lib/client/storage/_dropbox.js +++ b/lib/client/storage/_dropbox.js @@ -157,7 +157,7 @@ var CloudCmd, Util, DOM, Dropbox, cb, Client; }; if (path !== '/') - path += '/'; + json.path += '/'; if (error) msg = error.responseText; From b713bf5c8760d490b000ff2bb7cc883cddbc6f6c Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 6 Dec 2013 16:14:38 +0000 Subject: [PATCH 309/315] refactor(cloudfunc) getSymbolicPermissions --- lib/cloudfunc.js | 80 +++++++++++++++++++++++++----------------------- 1 file changed, 41 insertions(+), 39 deletions(-) diff --git a/lib/cloudfunc.js b/lib/cloudfunc.js index ea9afccb..b1f0980c 100644 --- a/lib/cloudfunc.js +++ b/lib/cloudfunc.js @@ -111,6 +111,8 @@ var Util; * к файлу в 8-миричной системе */ this.getSymbolicPermissions = function(pPerm_s) { + var lType, lOwner, lGroup, lAll, + lPermissions = pPerm_s; /* S_IRUSR 0000400 protection: readable by owner S_IWUSR 0000200 writable by owner @@ -122,47 +124,46 @@ var Util; S_IWOTH 0000002 writable by all S_IXOTH 0000001 executable by all */ - if(!pPerm_s) return; - - /* тип файла */ - var lType = pPerm_s.charAt(0); - - switch (lType-0) { - case 1: /* обычный файл */ - lType='-'; - break; - case 2: /* байт-ориентированное (символьное) устройство*/ - lType='c'; - break; - case 4: /* каталог */ - lType='d'; - break; - default: - lType='-'; - } - - /* оставляем последние 3 символа*/ - pPerm_s = pPerm_s.length > 5 ? pPerm_s.substr(3) : pPerm_s.substr(2); - - /* Рекомендации гугла советуют вместо string[3] - * использовать string.charAt(3) - */ - /* - http://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml?showone=Standards_features#Standards_features + if (pPerm_s) { + /* тип файла */ + lType = pPerm_s.charAt(0); - Always preferred over non-standards featuresFor - maximum portability and compatibility, always - prefer standards features over non-standards - features (e.g., string.charAt(3) over string[3] - and element access with DOM functions instead - of using an application-specific shorthand). - */ - /* Переводим в двоичную систему */ - var lOwner = ( pPerm_s[0] - 0 ).toString(2), + switch (lType-0) { + case 1: /* обычный файл */ + lType='-'; + break; + case 2: /* байт-ориентированное (символьное) устройство*/ + lType='c'; + break; + case 4: /* каталог */ + lType='d'; + break; + default: + lType='-'; + } + + /* оставляем последние 3 символа*/ + pPerm_s = pPerm_s.length > 5 ? pPerm_s.substr(3) : pPerm_s.substr(2); + + /* Рекомендации гугла советуют вместо string[3] + * использовать string.charAt(3) + */ + /* + http://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml?showone=Standards_features#Standards_features + + Always preferred over non-standards featuresFor + maximum portability and compatibility, always + prefer standards features over non-standards + features (e.g., string.charAt(3) over string[3] + and element access with DOM functions instead + of using an application-specific shorthand). + */ + /* Переводим в двоичную систему */ + lOwner = ( pPerm_s[0] - 0 ).toString(2), lGroup = ( pPerm_s[1] - 0 ).toString(2), lAll = ( pPerm_s[2] - 0 ).toString(2), - - /* переводим в символьную систему*/ + + /* переводим в символьную систему*/ lPermissions = ( lOwner[0] - 0 > 0 ? 'r' : '-' ) + ( lOwner[1] - 0 > 0 ? 'w' : '-' ) + @@ -175,7 +176,8 @@ var Util; ( lAll[0]- 0 > 0 ? 'r' : '-' ) + ( lAll[1]- 0 > 0 ? 'w' : '-' ) + ( lAll[2]- 0 > 0 ? 'x' : '-' ); - + } + return lPermissions; }; From 0c91664b7812b378d1a63d6bf27140ed3ad1561b Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 6 Dec 2013 16:14:55 +0000 Subject: [PATCH 310/315] feature(dropbox) readDir json: add mode --- lib/client/storage/_dropbox.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/client/storage/_dropbox.js b/lib/client/storage/_dropbox.js index cba522a4..6e483477 100644 --- a/lib/client/storage/_dropbox.js +++ b/lib/client/storage/_dropbox.js @@ -175,7 +175,8 @@ var CloudCmd, Util, DOM, Dropbox, cb, Client; json.files.push({ name: name, - size: size + size: size, + mode: '.' }); } From da49d9c5bf2339772e62053a71b36eb271723be4 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 6 Dec 2013 16:18:04 +0000 Subject: [PATCH 311/315] feature(cloudfunc) buildFromJSON mode: -> getSymbolicPermissions(".") --- lib/cloudfunc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/cloudfunc.js b/lib/cloudfunc.js index b1f0980c..b38a19eb 100644 --- a/lib/cloudfunc.js +++ b/lib/cloudfunc.js @@ -385,7 +385,7 @@ var Util; name : linkResult, size : '<dir>', owner : '.', - mode : '' + mode : CloudFunc.getSymbolicPermissions('.') }); } From c32de8b4d0e5c88bc26e4ad808c3651dfa2cafb1 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 6 Dec 2013 16:28:14 +0000 Subject: [PATCH 312/315] refactor(cloudfunc) getSymbolicPermissions --- lib/cloudfunc.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/cloudfunc.js b/lib/cloudfunc.js index b38a19eb..4d3daefc 100644 --- a/lib/cloudfunc.js +++ b/lib/cloudfunc.js @@ -112,7 +112,8 @@ var Util; */ this.getSymbolicPermissions = function(pPerm_s) { var lType, lOwner, lGroup, lAll, - lPermissions = pPerm_s; + perms = pPerm_s && pPerm_s.toString(), + lPermissions = perms; /* S_IRUSR 0000400 protection: readable by owner S_IWUSR 0000200 writable by owner @@ -124,9 +125,9 @@ var Util; S_IWOTH 0000002 writable by all S_IXOTH 0000001 executable by all */ - if (pPerm_s) { + if (perms) { /* тип файла */ - lType = pPerm_s.charAt(0); + lType = perms.toString().charAt(0); switch (lType-0) { case 1: /* обычный файл */ @@ -143,7 +144,7 @@ var Util; } /* оставляем последние 3 символа*/ - pPerm_s = pPerm_s.length > 5 ? pPerm_s.substr(3) : pPerm_s.substr(2); + perms = perms.length > 5 ? perms.substr(3) : perms.substr(2); /* Рекомендации гугла советуют вместо string[3] * использовать string.charAt(3) @@ -159,9 +160,9 @@ var Util; of using an application-specific shorthand). */ /* Переводим в двоичную систему */ - lOwner = ( pPerm_s[0] - 0 ).toString(2), - lGroup = ( pPerm_s[1] - 0 ).toString(2), - lAll = ( pPerm_s[2] - 0 ).toString(2), + lOwner = ( perms[0] - 0 ).toString(2), + lGroup = ( perms[1] - 0 ).toString(2), + lAll = ( perms[2] - 0 ).toString(2), /* переводим в символьную систему*/ lPermissions = From aa84085c6b50349f3c127b723f962b66336512b0 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 6 Dec 2013 16:34:17 +0000 Subject: [PATCH 313/315] feature(commander) mode: str -> number --- lib/server/commander.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/server/commander.js b/lib/server/commander.js index 6c9e1056..52221a78 100644 --- a/lib/server/commander.js +++ b/lib/server/commander.js @@ -112,7 +112,7 @@ * @param pFiles - array of files of current directory */ function fillJSON(pParams) { - var name, stat, mode, isDir, size, uid, + var name, stat, mode, isDir, size, uid, modeStr, p, i, n, file, path, json, files, ret = Util.checkObjTrue(pParams, ['files', 'stats', 'path']); @@ -136,7 +136,8 @@ if (stat) { /* Переводим права доступа в 8-ричную систему */ - mode = Number(stat.mode).toString(8); + modeStr = Number(stat.mode).toString(8); + mode = Number(modeStr); isDir = stat.isDirectory(); size = isDir ? 'dir' : stat.size; } From 2ae80f61614d19e6190c22e46ed1520e2db5f2d9 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 9 Dec 2013 09:06:27 +0000 Subject: [PATCH 314/315] feature(cloudcmd) v0.7.0 --- ChangeLog | 174 +++++++++++++++++++++++++++++++++++++++++++++++++++ HELP.md | 3 +- LICENSE | 2 +- README.md | 2 +- package.json | 2 +- 5 files changed, 179 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index d624365b..c1e3b95e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,177 @@ +2013.12.09, v0.7.0 + +fix: +- (dropbox) path -> json.path +- (dropbox) Drivers -> Dropbox.AuthDriver +- (key) setCurrentByLetter i: 2 -> 0 +- (key) panel -> files +- (client) rm last slash before first save to storage +- (cloudcmd) path -> link +- (file) rm new line at end +- (dom) getCurrentData: add isCurrentIsDir +- (dom) storage set: rm data condition +- (edit) do not save hash when file update +- (commander) fillJSON: files -> json.files +- (client) getJSONfromFileTable: json +- (edit) add data check condition +- (edit) set patch only if hashes same +- (edit) onSave -> getSave +- (dom) getDataFromStorage: never return hash +- (dom) checkStorageHash: always equal result, never store data +- (files) add isFunction condition +- (commander) fillJSON: add push +- (key) add !alt, !ctrl condition to setCurrentByLetter +- (server) combine: write error to pipe if headers sent +- (main) set Header only if it was not sent +- (Edit) change patch condition +- (Edit) length of patch condition +- (minify) ret -> callback +- (util) lExtLenght -> lExtLength +- (server) add gzip +- (util) lExtLenght -> lExtLength +- (edit) value size < then patch size -> save value +- (client) format -> formatMsg +- (server) redirect port +- (server) add redirection port +- (github) CloudCommander -> CloudCmd +- (edit) saveDataToCache -> saveDataToStorage +- (edit) set Value befor onSave +- (dom) getCurrentData +- (config) change config before setConfig +- (rest) pErr -> pError +- (socket) onCD: rm "." +- (rest) heckSendError -> checkSendError +- (socket) exit on cloudcmd command +- (edit) diff +- (diff) applyPatch: results -> results[0] +- (cloudcmd) mv index data to var + +feature: +- (commander) mode: str -> number +- (cloudfunc) buildFromJSON mode: -> getSymbolicPermissions(".") +- (dropbox) readDir json: add mode +- (dropbox) readDir: add path condition +- (dropbox) add delete, cp, mv +- (dropbox) add save +- (dropbox) add read +- (dropbox) add getToken, mkDir, writeFile, readFile, readDir +- (key) add moving by first letter +- (cloudcmd) add readIndex; when minify - index to +- (config) add -moz and -o +- (config) list: add list-style-type +- (cloudcmd) do not hide path and header when files are scrolling +- (style) .cmd-button: rm outline +- (style) rm .current-file > .mini-icon +- (style) rm GeneralFoundicons +- (link) add +- (html) rm link to cloudfunc +- (file) add className +- (ssl) add signed ssl +- (commander) change json structure: [path, files] -> {path: "", files: []} +- (server) fillJSON path: rm size +- (edit) add get data from storage before diff +- (files) add options +- (commander) fillJSON: add changeOrder +- (commander) add changeOrder +- (util) copyObj: add ability take one param +- (config) add min, max port +- (cloudcmd) add read index on every request +- (edit) if storage disabled - hash not getted +- (client) rm HEIGHT +- (index) add key +- (client) mv cloudfunc, listeners to index +- (key) add setCurrentByLetter +- (edit) rm setOptions +- (edit) modelist: add yml +- (edit) add modelist +- (edit) add json mode for dir +- (edit) update ace +- (edit) add mode +- (edit) add workers +- (edit) add snippets +- (cloudfunc) add getCombineURL, getCombineArray, isCombineURL +- (edit) diff: anyLoadInParallel -> combineURL +- (server) add checkExtension +- (console) add combineURL +- (edit) anyLoadOnLoad -> combineURL && jsload +- (dom) add combineLoad +- (index) add async +- (index) combine +- (server) combine: add mainSetHeader +- (main) exports: add mainSetHeader +- (files) files, dir, writeStream, callback -> params +- (server) add minify +- (server) combine: add minify +- (pipe) add notEnd +- (main) sendFile: rm stat +- (server) add combine +- (files) readPipe: add dir +- (pipe) pipe -> on("data") +- (files) add readPipe +- (main) mv readFiles -> files.read +- (cloudcmd) rm CA +- (ssl) rm ssl.rastakoding.rv.ua cert +- (dropbox) v0.9.2 -> v0.10.2 +- (dropbox) encodedKey -> key +- (dom) add loadCurrentTime +- (edit) rm client sha +- (dom) add checkStorageHash +- (dom) getCurrentData: if data from storage do not save it +- (edit) add go to line +- (edit) add autocompletion +- (client) add getType +- (client) add getExt +- (dom) rm getTime +- (config) css line-height: 1.428571429 -> 1.5 +- (config) port, sslPort: add focus:invalid:focus +- (config) port, sslPort input: add type=number +- (dom) getDataFromStorage: add isDir condition +- (dom) Cache -> Storage +- (time) add +- (dom) getDataFromCache: add !hash +- (dom) saveDataToCache: add Cache.get +- (edit) add saveDataToCache +- (edit) RESTful.save -> saveCurrentData +- (dom) saveDataInCache -> saveDataToCache +- (dom) add saveCurrentData +- (dom) add getDataFromCache, saveDataInCache +- (dom) add loadCurrentHash +- (hash) add handling old node versions +- (hash) rm Writable.call +- (rest) add ?hash +- (edit) if on server would be error with diff, try to save without diff +- (dom) add Dialog +- (socket) HOME -> DIR +- (util) rmNewLine: add "\r" +- (socket) HOMEPATH -> SYSTEMDRIVE +- (socket) add Win32 condition +- (socket) add pwd, homepath +- (socket) any client could work with own dir +- (util) isContainStrAtBegin: pStr2 could be array +- (util) add rmNewLine +- (socket) add HOME +- (dom) Notify send: add getConfig +- (dom) Notify click: add focus +- (dom) add notify-icon +- (config) add Notifications +- (socket) jsonSend: rm console.log +- (socket) onCloudCmd: add process.exit +- (socket) add jsonSend +- (socket) add chat +- (rest) GET: rm kill, zip; PUT: rm cmd +- (rest) add checkSendError +- (client) add setConfig +- (config) add diff +- (diff) add +- (reset) sendMsg: add status +- (config) appcache -> appCache +- (config) api_url -> apiURL +- (config) appcache -> appCache +- (config) api_url -> apiURL +- (config) show_keys_panel -> showKeysPanel +- (index) rm no-js + + 2013.11.08, v0.6.0 update: diff --git a/HELP.md b/HELP.md index d7a5cc5a..cf76a84b 100644 --- a/HELP.md +++ b/HELP.md @@ -1,4 +1,4 @@ -Cloud Commander v0.6.0 [![NPM version][NPMIMGURL]][NPMURL] [![Dependency Status][DependencyStatusIMGURL]][DependencyStatusURL] [![Build Status][BuildStatusIMGURL]][BuildStatusURL] +Cloud Commander v0.7.0 [![NPM version][NPMIMGURL]][NPMURL] [![Dependency Status][DependencyStatusIMGURL]][DependencyStatusURL] [![Build Status][BuildStatusIMGURL]][BuildStatusURL] =============== ###[Main][MainURL] [Blog][BlogURL] Live(![IO][IO_LIVE_IMG] [IO][IOURL], ![JitSu][JitSu_LIVE_IMG] [JitSu][JitSuURL], ![Heroku][Heroku_LIVE_IMG] [Heroku][HerokuURL] ![RunKite][RunKite_LIVE_IMG] [RunKite][RunKiteURL]) [NPMIMGURL]: https://badge.fury.io/js/cloudcmd.png @@ -367,6 +367,7 @@ so to get it you should type a couple more commands: Version history --------------- +- *2013.12.09*, **[v0.7.0](//github.com/coderaiser/cloudcmd-archive/raw/master/cloudcmd-v0.7.0.zip)** - *2013.11.08*, **[v0.6.0](//github.com/coderaiser/cloudcmd-archive/raw/master/cloudcmd-v0.6.0.zip)** - *2013.10.17*, **[v0.5.0](//github.com/coderaiser/cloudcmd-archive/raw/master/cloudcmd-v0.5.0.zip)** - *2013.09.27*, **[v0.4.0](//github.com/coderaiser/cloudcmd-archive/raw/master/cloudcmd-v0.4.0.zip)** diff --git a/LICENSE b/LICENSE index b9f49cb1..2e769f3d 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ (The MIT License) -Copyright (c) 2013 Coderaiser +Copyright (c) 2014 Coderaiser Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the diff --git a/README.md b/README.md index 797f257a..b0147ae6 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -Cloud Commander v0.6.0 [![NPM version][NPMIMGURL]][NPMURL] [![Dependency Status][DependencyStatusIMGURL]][DependencyStatusURL] [![Build Status][BuildStatusIMGURL]][BuildStatusURL] +Cloud Commander v0.7.0 [![NPM version][NPMIMGURL]][NPMURL] [![Dependency Status][DependencyStatusIMGURL]][DependencyStatusURL] [![Build Status][BuildStatusIMGURL]][BuildStatusURL] =============== ###[Main][MainURL] [Blog][BlogURL] Live(![IO][IO_LIVE_IMG] [IO][IOURL], ![JitSu][JitSu_LIVE_IMG] [JitSu][JitSuURL], ![Heroku][Heroku_LIVE_IMG] [Heroku][HerokuURL] ![RunKite][RunKite_LIVE_IMG] [RunKite][RunKiteURL]) [NPMIMGURL]: https://badge.fury.io/js/cloudcmd.png diff --git a/package.json b/package.json index e27a1069..55a97d52 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cloudcmd", - "version": "0.6.0", + "version": "0.7.0", "author": "coderaiser (https://github.com/coderaiser)", "description": "Cloud Commander - file manager with console and editor", "homepage": "http://cloudcmd.io", From f930e4865a1e589260dd98d4a070bd9520e9c8d8 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Mon, 9 Dec 2013 09:07:17 +0000 Subject: [PATCH 315/315] feature(shell) log: rm refactor --- shell/log.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/shell/log.sh b/shell/log.sh index 2f42a8e5..6f0a0f13 100755 --- a/shell/log.sh +++ b/shell/log.sh @@ -3,7 +3,6 @@ if test -z $1 then echo "log.sh " else - git log $1..HEAD --pretty=format:"- %s" --grep feature git log $1..HEAD --pretty=format:"- %s" --grep fix - git log $1..HEAD --pretty=format:"- %s" --grep refactor -fi \ No newline at end of file + git log $1..HEAD --pretty=format:"- %s" --grep feature +fi