From fdb986251a22f3969a74e997eabaa9752ff0a778 Mon Sep 17 00:00:00 2001 From: kevin Date: Thu, 28 Apr 2016 07:40:57 +0800 Subject: [PATCH 1/6] 0.1.4 --- index.js | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/index.js b/index.js index a2b3d54..8b8b92b 100644 --- a/index.js +++ b/index.js @@ -4,7 +4,10 @@ var str =''; var obj = { challenges: [] }; -console.log("Flucy~v0.1.3"); +console.log("Flucy~ v0.1.4 @KevinHu-1024"); +console.log("bug反馈地址:https://github.com/KevinHu-1024/Flucy/issues"); +console.log("本工具来自FreeCodeCamp中文社区翻译组:https://github.com/huluoyang/freecodecamp.cn/wiki"); +console.log("FreeCodeCamp中文社区:https://freecodecamp.cn"); function a() { try { json = JSON.parse(source.value); @@ -13,29 +16,45 @@ function a() { console.log(error); return } + var main = document.createElement('h3'); + main.innerHTML = json.name; + main.style = "color:red;"; + translate.appendChild(main); + var link = document.createElement('a'); + link.innerHTML = title; + link.href = "https://github.com/KevinHu-1024/Flucy/releases/"; + link.style = "text-align:right;font-size:12px;color:grey;text-decoration:none;"; + translate.appendChild(link); + var frg = document.createDocumentFragment(); for(var i = 0; i < json.challenges.length; i++) { var cur = json.challenges[i]; - str += "

" + (i+1) + "." + cur.title +"

" + var ti = document.createElement('h4'); + ti.style = "color:green;text-decoration:underline"; + ti.innerHTML = (i+1) + "." + cur.title; + frg.appendChild(ti); obj.challenges.push({ dis:[] }) for (var j = 0; j < cur.description.length; j ++) { - str += ""; + var tex = document.createElement('textarea'); + tex.value = cur.description[j]; + tex.rows = 5; + frg.appendChild(tex); + tex = null; obj.challenges[i].dis.push(cur.description[j]); } } console.log(json); console.log(obj); - translate.innerHTML = "

" + json.name +"

" + "" + title + "" + str; + translate.appendChild(frg); } function b() { var collection = translate.getElementsByTagName("textarea"); var i = 0; - // console.log(collection); for (var m = 0; m < obj.challenges.length; m++) { var tar = obj.challenges[m]; for (var j = 0; j < tar.dis.length; j++) { - tar.dis[j] = collection[i].value.replace(/(\)(\s\s)/gi, '$1  ').replace(/(\)(\s\s)/gi, '$1  '); + tar.dis[j] = collection[i].value; i ++; } } @@ -47,7 +66,4 @@ function b() { source.value = JSON.stringify(json, null, 2); } // 提取tests中某项的message: -// /(?:\'message\:)(.+)(?:\))/gi.exec("assert((function(){var testCar = new Car(3,1,2); return testCar.wheels === 3 && testCar.seats === 1 && testCar.engines === 2;})(), 'message: Calling new Car(3,1,2) should produce an object with a wheels property of 3, a seats property of 1, and an engines property of 2.');")[1] -//转义 -//" return valorAnterior - valorActual;".replace(/(\)(\s\s)/gi, '$1  ') -//"
return valorAnterior - valorActual;
".replace(/(\)(\s\s)/gi, '$1  ') \ No newline at end of file +// /(?:\'message\:)(.+)(?:\))/gi.exec("assert((function(){var testCar = new Car(3,1,2); return testCar.wheels === 3 && testCar.seats === 1 && testCar.engines === 2;})(), 'message: Calling new Car(3,1,2) should produce an object with a wheels property of 3, a seats property of 1, and an engines property of 2.');")[1] \ No newline at end of file From 12e00a253b98fbb5b73f31142ad3eca2fd44d5be Mon Sep 17 00:00:00 2001 From: kevin Date: Thu, 28 Apr 2016 08:44:45 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E5=A4=A7=E9=83=A8?= =?UTF-8?q?=E5=88=86json=E7=9A=84tests=E6=88=AA=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.css | 6 ++++++ index.js | 36 +++++++++++++++++++++++++++++------- 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/index.css b/index.css index 2a280ad..ccf0015 100644 --- a/index.css +++ b/index.css @@ -24,4 +24,10 @@ body, section, div { } .container div textarea { width: 100%; +} +.mainText { + color: black; +} +.testsText { + color: blue; } \ No newline at end of file diff --git a/index.js b/index.js index 8b8b92b..ff15a74 100644 --- a/index.js +++ b/index.js @@ -33,37 +33,59 @@ function a() { ti.innerHTML = (i+1) + "." + cur.title; frg.appendChild(ti); obj.challenges.push({ - dis:[] + dis:[], + tes:[] }) for (var j = 0; j < cur.description.length; j ++) { var tex = document.createElement('textarea'); tex.value = cur.description[j]; + tex.className = "mainText"; tex.rows = 5; frg.appendChild(tex); tex = null; obj.challenges[i].dis.push(cur.description[j]); } + for (var n = 0; n < cur.tests.length; n++) { + var tesTex = document.createElement('textarea'); + console.log(n, cur.tests[n]); + tesTex.value = /(?:\'message\:)(.+)(?:\'\))/gi.exec(cur.tests[n])[1]; + //bug: basic js中没有message字段 + tesTex.className = "testsText"; + tesTex.rows = 5; + frg.appendChild(tesTex); + tesTex = null; + obj.challenges[i].tes.push(cur.tests[n]); + } } console.log(json); console.log(obj); translate.appendChild(frg); } function b() { - var collection = translate.getElementsByTagName("textarea"); + var mainTextCollection = translate.getElementsByClassName("mainText"); + var testsTextCollection = translate.getElementsByClassName("testsText"); var i = 0; + var h = 0; for (var m = 0; m < obj.challenges.length; m++) { var tar = obj.challenges[m]; for (var j = 0; j < tar.dis.length; j++) { - tar.dis[j] = collection[i].value; + tar.dis[j] = mainTextCollection[i].value; i ++; } + for (var n = 0; n < tar.tes.length; n++) { + tar.tes[n] = testsTextCollection[h].value + "');"; + h ++; + } } console.log(obj); for (var k = 0; k < obj.challenges.length; k++) { json.challenges[k].description = obj.challenges[k].dis; + // json.challenges[k].tests.replace(/^/gi, obj.challenges[k].tes)//不能直接引用数组过去 + for (var t = 0; t < obj.challenges[k].tes.length; t++) { + obj.challenges[k].tes[t] = /^(assert)(.+)(?:'message:)/gi.exec(json.challenges[k].tests[t])[0] + obj.challenges[k].tes[t]; + json.challenges[k].tests[t] = obj.challenges[k].tes[t]; + } } console.log(json); - source.value = JSON.stringify(json, null, 2); -} -// 提取tests中某项的message: -// /(?:\'message\:)(.+)(?:\))/gi.exec("assert((function(){var testCar = new Car(3,1,2); return testCar.wheels === 3 && testCar.seats === 1 && testCar.engines === 2;})(), 'message: Calling new Car(3,1,2) should produce an object with a wheels property of 3, a seats property of 1, and an engines property of 2.');")[1] \ No newline at end of file + source.value = JSON.stringify(json, null, 2) + "\n"; +} \ No newline at end of file From 29435d855838a4e439196c440835f19730a85370 Mon Sep 17 00:00:00 2001 From: kevin Date: Thu, 28 Apr 2016 08:44:59 +0800 Subject: [PATCH 3/6] bug record --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c999d3e..c63f0d2 100644 --- a/README.md +++ b/README.md @@ -10,4 +10,10 @@ - [ ] 增加tests翻译功能 - [ ] 调整页面按钮文案,避免和新功能混淆 - [ ] 增加翻译提示功能,及语言转换选项 -- [ ] 增加description语言分支选择功能,多语言版本 \ No newline at end of file +- [ ] 增加description语言分支选择功能,多语言版本 + +## 已知bug - 覆盖测试下 + +1. basic-bonfires.json / basic-ziplines.json / front-end-development-certificate.json / gear-up-for-success.json / data-visualization-certificate.json / api-projects.json / back-end-development-certificate.json /里导出或导入错误,它的discription里面还有数组,我把它扁平化了 +2. front-end-development-certificate.json / chromedevtools.json / bigonotation.json / computer-basics.json / dom.json / jslingo.json没用断言,用的别的,上面的有些也是这个原因 +3. basic-js.json 中后几个断言中没有message字段 \ No newline at end of file From 4b790a2f7efad9c40f7034e877c8dcda66845812 Mon Sep 17 00:00:00 2001 From: kevin Date: Tue, 3 May 2016 17:36:06 +0800 Subject: [PATCH 4/6] 0.1.5 --- Flucy.html | 6 +++--- index.js | 53 +++++++++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 50 insertions(+), 9 deletions(-) diff --git a/Flucy.html b/Flucy.html index a22220b..d957372 100644 --- a/Flucy.html +++ b/Flucy.html @@ -13,10 +13,10 @@
+ +
-
- -
+
diff --git a/index.js b/index.js index ff15a74..ce0dc3d 100644 --- a/index.js +++ b/index.js @@ -4,11 +4,47 @@ var str =''; var obj = { challenges: [] }; -console.log("Flucy~ v0.1.4 @KevinHu-1024"); + +String.prototype.markdown2Html = function markdown2Html() { + var parten = { + strong: { + exp: /(?:\*\*)(.+?)(?:\*\*)/gi, + html: [" ", " "] + }, + code: { + exp: /(?:\`)(.+?)(?:\`)/gi, + html: [" ", " "] + } + } + var result = this.toString(); + for (currentParten in parten) { + if (parten.hasOwnProperty(currentParten)) { + result = result.replace(parten[currentParten].exp, function () { + console.log(arguments); + return parten[currentParten].html[0] + arguments[1] + parten[currentParten].html[1]; + }) + } + } + return result +} +console.log("Flucy~ v0.1.5 @KevinHu-1024"); console.log("bug反馈地址:https://github.com/KevinHu-1024/Flucy/issues"); console.log("本工具来自FreeCodeCamp中文社区翻译组:https://github.com/huluoyang/freecodecamp.cn/wiki"); console.log("FreeCodeCamp中文社区:https://freecodecamp.cn"); function a() { + if (translate.innerHTML != '') { + var con = confirm("导入时会重置右侧内容!"); + if (!con) { + return + } + } + source.disabled = 'disabled'; + translate.innerHTML = ''; + json = null; + str =''; + obj = { + challenges: [] + }; try { json = JSON.parse(source.value); } catch (error) { @@ -47,9 +83,8 @@ function a() { } for (var n = 0; n < cur.tests.length; n++) { var tesTex = document.createElement('textarea'); - console.log(n, cur.tests[n]); + // console.log(n, cur.tests[n]); tesTex.value = /(?:\'message\:)(.+)(?:\'\))/gi.exec(cur.tests[n])[1]; - //bug: basic js中没有message字段 tesTex.className = "testsText"; tesTex.rows = 5; frg.appendChild(tesTex); @@ -62,6 +97,13 @@ function a() { translate.appendChild(frg); } function b() { + if (source.value != '') { + var con = confirm("导出时会重置左侧内容!"); + if (!con) { + return + } + } + source.value = ''; var mainTextCollection = translate.getElementsByClassName("mainText"); var testsTextCollection = translate.getElementsByClassName("testsText"); var i = 0; @@ -69,18 +111,17 @@ function b() { for (var m = 0; m < obj.challenges.length; m++) { var tar = obj.challenges[m]; for (var j = 0; j < tar.dis.length; j++) { - tar.dis[j] = mainTextCollection[i].value; + tar.dis[j] = mainTextCollection[i].value.markdown2Html(); i ++; } for (var n = 0; n < tar.tes.length; n++) { - tar.tes[n] = testsTextCollection[h].value + "');"; + tar.tes[n] = testsTextCollection[h].value.markdown2Html() + "');"; h ++; } } console.log(obj); for (var k = 0; k < obj.challenges.length; k++) { json.challenges[k].description = obj.challenges[k].dis; - // json.challenges[k].tests.replace(/^/gi, obj.challenges[k].tes)//不能直接引用数组过去 for (var t = 0; t < obj.challenges[k].tes.length; t++) { obj.challenges[k].tes[t] = /^(assert)(.+)(?:'message:)/gi.exec(json.challenges[k].tests[t])[0] + obj.challenges[k].tes[t]; json.challenges[k].tests[t] = obj.challenges[k].tes[t]; From 1a0e229ae1a7fb29b8457b9036a749daf2d5e755 Mon Sep 17 00:00:00 2001 From: kevin Date: Tue, 3 May 2016 17:36:54 +0800 Subject: [PATCH 5/6] update readme --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index c63f0d2..a37eda3 100644 --- a/README.md +++ b/README.md @@ -2,13 +2,13 @@ - [x] 增加JSON校验错误提示 - [x] 增加控制台版本报告 -- [ ] 增加控制台`issue`提交路径信息 -- [ ] 增加`markdown`格式支持,可能要定制语法,防止`
`标签
+- [x] 增加控制台`issue`提交路径信息
+- [x] 增加`markdown`格式支持,可能要定制语法,防止`
`标签
 - [ ] 增加json文件直接导入功能
 - [ ] 增加json文件直接导出功能,生成前再校验一次
-- [ ] 增加页面重置功能,避免刷新,重置前提示用户
-- [ ] 增加tests翻译功能
-- [ ] 调整页面按钮文案,避免和新功能混淆
+- [x] 增加页面重置功能,避免刷新,重置前提示用户
+- [x] 增加tests翻译功能
+- [x] 调整页面按钮文案,避免和新功能混淆
 - [ ] 增加翻译提示功能,及语言转换选项
 - [ ] 增加description语言分支选择功能,多语言版本
 

From e7ca7c2fc116dd63df73e1083d66898c7094d66f Mon Sep 17 00:00:00 2001
From: kevin 
Date: Thu, 5 May 2016 08:52:54 +0800
Subject: [PATCH 6/6] 0.1.5

---
 Flucy.html | 2 --
 1 file changed, 2 deletions(-)

diff --git a/Flucy.html b/Flucy.html
index d957372..4cd97cc 100644
--- a/Flucy.html
+++ b/Flucy.html
@@ -13,8 +13,6 @@
         
- -