From ab3b3fc231ece8a77a2332a47a4df1b6a1057d6e Mon Sep 17 00:00:00 2001 From: "H.C. Chen" Date: Thu, 18 May 2017 17:17:58 +0800 Subject: [PATCH 01/16] new develop branch after the master release --- LOG/log.txt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/LOG/log.txt b/LOG/log.txt index 6cf995d..73105ca 100644 --- a/LOG/log.txt +++ b/LOG/log.txt @@ -5901,7 +5901,7 @@ [ ] 錄製 12choc.f 的說明影片。 [ ] Make a master release and update the issue https://github.com/hcchengithub/jeforth.3we/issues/5 -[ ] 準備 release master 新版 release 新版 master +[x] 準備 release master 新版 release 新版 master [x] jeforth.3we\js\version.js --> jeforth3we_minor_version = 303; o selftest them all [x] setup.bat @@ -5918,13 +5918,15 @@ [x] box2dweb-arrow.f , [x] calc.f , [x] chipmunk-js-pyramidstack.f , [x] flot-demo.f , [x] h2o.f , [x] many-clocks.f , [x] numeric-demo.f , alarm.f [x] solar-system.f - [ ] commit develop -> 將 develop 分支發佈到 Master 分支的命令 : + [x] commit develop -> 將 develop 分支發佈到 Master 分支的命令 : 切換到Master分支 : git checkout master 合併 develop 分支進 master 來 : git merge --no-ff develop - [ ] Test the master all over again ... ignored, lazy. - [ ] Master 到回 develop + [/] Test the master all over again ... ignored, lazy. + [x] Upload master to GitHub : git push + [x] Master 到回 develop 切換到Master分支 : git checkout develop 合併 develop 分支進 master 來 : git merge --no-ff master + [x] Complete this log.txt [ ] release note \ No newline at end of file From 78c388fdad5488efb5c2ef97a71c12070c0c5675 Mon Sep 17 00:00:00 2001 From: "H.C. Chen" Date: Mon, 26 Jun 2017 20:19:41 +0800 Subject: [PATCH 02/16] new command getNIC to disable/enable NIC --- 3hta/f/wmi.f | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 3hta/f/wsh.f | 3 +-- 2 files changed, 49 insertions(+), 2 deletions(-) diff --git a/3hta/f/wmi.f b/3hta/f/wmi.f index 7754d8c..8b05a2e 100644 --- a/3hta/f/wmi.f +++ b/3hta/f/wmi.f @@ -39,6 +39,7 @@ ) ; + \ Iterate all network cards (NIC) in this computer list all Network adapters' IP address : printIPAddress ( -- ) \ Print (all) IP Addresses @@ -74,6 +75,53 @@ \ -%-%-%-%-%- \ +\ WMI Win32_NetworkAdapter class +\ https://msdn.microsoft.com/en-us/library/aa394216(v=vs.85).aspx +: objEnumWin32_NetworkAdapter + ( "where-clause" -- objEnumWin32_NetworkAdapter ) \ Get Win32_NetworkAdapter object onto TOS. + + new Enumerator( + vm.objWMIService.ExecQuery("Select * from Win32_NetworkAdapter "+pop()) + ) + ; + + + ." List all NIC" cr + "" objEnumWin32_NetworkAdapter >r \ No where clause, + [begin] + r@ js> pop().atEnd() [if] r> drop true [else] + r@ js> pop().item().caption . ." / DeviceID: " + r@ js> pop().item().DeviceID . cr + r@ js: pop().moveNext() + false + [then] + [until] + ." List specific NIC through identifying its caption" cr + s" where caption like '%Intel(R) Ethernet Connection%'" objEnumWin32_NetworkAdapter >r + [begin] + r@ js> pop().atEnd() [if] r> drop true [else] + r@ js> pop().item().caption . ." / DeviceID: " + r@ js> pop().item().DeviceID . cr + r@ js: pop().moveNext() + false + [then] + [until] + + +: getNIC ( "caption" -- objNIC ) \ Get NIC object so I can disable or enable it + s" where caption like '" swap + char ' + objEnumWin32_NetworkAdapter >r + begin + r@ js> pop().atEnd() if r> drop true else + r@ js> pop().item() \ get the last one if there are many + r@ js: pop().moveNext() + false + then + until ; + /// Usage: Run jeforth.hta as administrator (through administrator DOS box is a way) + /// s" %Intel(R) Ethernet Connection%" getNIC :> disable() \ return 5 is failed when not an administrator + /// s" %Intel(R) Ethernet Connection%" getNIC :> enable() \ return 5 is failed when not an administrator + + \ 利用 jeforth for WSH 與其 JavaScript console 手動來操作 WMI 很有用,沒必要寫一大堆人機介面。 \ 跑一下 objEnumWin32_OperatingSystem 準備好 Win32_OperatingSystem object 放在 TOS,此後用 console 進 js console, \ var os = pop(), 即可用 os 來 access 所有 Win32_OperatingSystem 的東西。例如: diff --git a/3hta/f/wsh.f b/3hta/f/wsh.f index 1fe2982..8db15b8 100644 --- a/3hta/f/wsh.f +++ b/3hta/f/wsh.f @@ -166,11 +166,10 @@ \ 以下這個測試示範看得人眼花撩亂,但不要低估它。 \ jeforth.3hta 能夠這樣玩弄 DOS 等於是大大地增強了 DOS 的能力。 - *** fork append time stamp into selftest.log ... s" fork and dos test " js> Date().toString() + \ ( pattern ) s" fork cmd /c echo " over + s" >> selftest.log - " + tib.insert + " + tib.insert 100 nap \ 7:03 PM 6/26/2017 I found a delay is needed sometimes s' dos find "' swap + s' " selftest.log & exit ' + tib.insert [d 0 d] [p 'dos','(dos)','fork','(fork)' p] From 5bb6b7d88424a0c1104d990be99ba874f7779fb5 Mon Sep 17 00:00:00 2001 From: "H.C. Chen" Date: Mon, 26 Jun 2017 20:24:29 +0800 Subject: [PATCH 03/16] todos --- LOG/log.txt | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/LOG/log.txt b/LOG/log.txt index 73105ca..2d3180d 100644 --- a/LOG/log.txt +++ b/LOG/log.txt @@ -5903,6 +5903,7 @@ [ ] Make a master release and update the issue https://github.com/hcchengithub/jeforth.3we/issues/5 [x] 準備 release master 新版 release 新版 master [x] jeforth.3we\js\version.js --> jeforth3we_minor_version = 303; + [ ] Check the date stamp at the bottom of README.md o selftest them all [x] setup.bat [x] 3nw use 3hta to fork cmd /c start nw ../jeforth.3we @@ -5917,7 +5918,7 @@ [x] 12choc.f , [x] alarm.f , [x] ball.f(non-selftest mode) , [x] blowing-in-the-wind.f , [x] box2dweb-arrow.f , [x] calc.f , [x] chipmunk-js-pyramidstack.f , [x] flot-demo.f , [x] h2o.f , [x] many-clocks.f , [x] numeric-demo.f , alarm.f - [x] solar-system.f + [x] solar-system.f, [ ] tutor-cloth.f [x] commit develop -> 將 develop 分支發佈到 Master 分支的命令 : 切換到Master分支 : git checkout master 合併 develop 分支進 master 來 : git merge --no-ff develop @@ -5928,5 +5929,7 @@ 合併 develop 分支進 master 來 : git merge --no-ff master [x] Complete this log.txt [ ] release note - +[ ] README.md to include + http://cdn.rawgit.com/hcchengithub/jeforth.3we/r2/index.html?cls_include_tutor-cloth.f +[ ] Try to use Ubuntu NW.js or Node.js to try jeforth.3nw, 3nd on Ubuntu. \ No newline at end of file From 8464f5cbcded97dc043cd6610bc3a3cceb934c30 Mon Sep 17 00:00:00 2001 From: "H.C. Chen" Date: Tue, 27 Jun 2017 18:06:46 +0800 Subject: [PATCH 04/16] nic.bat to allow running as an administrator wmi.f add new words to access NIC --- 3hta/NIC.bat | 77 ++++++++++++++++++++++++++++++++++++++++++ 3hta/f/wmi.f | 95 +++++++++++++++++++++++++++++++++++++++------------- 2 files changed, 149 insertions(+), 23 deletions(-) create mode 100644 3hta/NIC.bat diff --git a/3hta/NIC.bat b/3hta/NIC.bat new file mode 100644 index 0000000..bbea5e7 --- /dev/null +++ b/3hta/NIC.bat @@ -0,0 +1,77 @@ +: @rem ; ' \ aliases echo @echo @echo. @goto :end jeforth.hta @rem cd call @if :ERR pause :END +cd %~dp0 +@rem +@rem N I C . b a t +@rem +@rem +@rem H.C. Chen 3:29 PM 6/27/2017 +@rem + +@echo. +@echo Executing %~nx0 . . . +@goto batch +\ --------------- start jeforth code ---------------------- + +." List all NIC" cr +"" getNIC ( nic nic ... ) \ No where clause, get all of them +#nic ?dup [if] [for] + >r r@ :> caption . cr + ." / NetConnectionStatus: " r@ :> NetConnectionStatus . cr + ." / NetEnabled: " r@ :> NetEnabled . cr + ." / NetworkAddresses: " r@ :> NetworkAddresses . cr + ." / PermanentAddress: " r@ :> PermanentAddress . cr + ." / Status: " r@ :> Status . cr + r> drop +[next] [then] + +." List active NIC" cr +activeNIC ( nic nic ... ) \ assume there are many active NICs +#nic ?dup [if] [for] + >r r@ :> caption . cr + ." / NetConnectionStatus: " r@ :> NetConnectionStatus . cr + ." / NetEnabled: " r@ :> NetEnabled . cr + ." / NetworkAddresses: " r@ :> NetworkAddresses . cr + ." / PermanentAddress: " r@ :> PermanentAddress . cr + ." / Status: " r@ :> Status . cr + r> drop +[next] [then] + +: nicoff ( -- ) \ Turn off the NIC + s" where deviceid = 19" getNIC :> disable() + dup if + ." Failed! Error code " . ." . Make sure to run as an administrator." cr + else + drop ." NIC device turned off sucessfully." cr + then ; + /// return 5 is failed when not an administrator + +: nicon ( -- ) \ Turn on the NIC + s" where deviceid = 19" getNIC :> enable() + dup if + ." Failed! Error code " . ." . Make sure to run as an administrator." cr + else + drop ." NIC device turned on sucessfully." cr + then ; +\ Usage guide +

nicoff or nicon

drop cr + stop + +\ ---------------- end jeforth code ----------------------- + +:batch +call admin.bat +@rem ---------- start batch code --------------------------- +start jeforth.hta include %~nx0 \ include the batch program itself +@if %errorlevel% GEQ 1 goto ERR +@rem ------------ end batch code --------------------------- + +@goto END +:ERR +@echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +@echo errorlevel : %errorlevel% +@echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +pause +:END + + + diff --git a/3hta/f/wmi.f b/3hta/f/wmi.f index 8b05a2e..cc223db 100644 --- a/3hta/f/wmi.f +++ b/3hta/f/wmi.f @@ -84,43 +84,92 @@ vm.objWMIService.ExecQuery("Select * from Win32_NetworkAdapter "+pop()) ) ; - + +0 value #nic // ( -- n ) NIC count. A result of activeNIC or getNIC command. +: getNIC ( "where clause" -- objNIC[,objNIC] ) \ Get NIC objects screened by "where clause" + objEnumWin32_NetworkAdapter >r + 0 to #nic + begin + r@ js> pop().atEnd() if r> drop true else + #nic 1+ to #nic + r@ js> pop().item() \ get all of them if there are many + r@ js: pop().moveNext() + false + then + until ; +: activeNIC ( -- objNIC[,objNIC] ) \ Get the wroking NIC object so I can disable or enable it + s" where NetEnabled='True'" objEnumWin32_NetworkAdapter >r + 0 to #nic + begin + r@ js> pop().atEnd() if r> drop true else + #nic 1+ to #nic + r@ js> pop().item() \ get all of them if there are many + r@ js: pop().moveNext() + false + then + until ; + /// Usage: Run jeforth.hta as administrator (through administrator DOS box is a way) + /// activeNIC :> disable() \ return 5 is failed when not an administrator + /// activeNIC :> enable() \ return 5 is failed when not an administrator + /// check #nic for the active NIC count if there are many. + ." List all NIC" cr - "" objEnumWin32_NetworkAdapter >r \ No where clause, + "" getNIC ( nic nic ... ) \ No where clause, get all of them + #nic ?dup [if] [for] + >r r@ :> caption . cr + ." / NetConnectionStatus: " r@ :> NetConnectionStatus . cr + ." / NetEnabled: " r@ :> NetEnabled . cr + ." / NetworkAddresses: " r@ :> NetworkAddresses . cr + ." / PermanentAddress: " r@ :> PermanentAddress . cr + ." / Status: " r@ :> Status . cr + r> drop + [next] [then] + + ." List active NIC" cr + activeNIC ( nic nic ... ) \ assume there are many active NICs + #nic ?dup [if] [for] + >r r@ :> caption . cr + ." / NetConnectionStatus: " r@ :> NetConnectionStatus . cr + ." / NetEnabled: " r@ :> NetEnabled . cr + ." / NetworkAddresses: " r@ :> NetworkAddresses . cr + ." / PermanentAddress: " r@ :> PermanentAddress . cr + ." / Status: " r@ :> Status . cr + r> drop + [next] [then] + + + \ Obsoleted methods still good for reference + ." List all NIC" cr + "" objEnumWin32_NetworkAdapter >r \ No where clause, get all of them [begin] r@ js> pop().atEnd() [if] r> drop true [else] - r@ js> pop().item().caption . ." / DeviceID: " - r@ js> pop().item().DeviceID . cr + r@ js> pop().item().caption . cr + ." / NetConnectionStatus: " r@ js> pop().item().NetConnectionStatus . cr + ." / NetEnabled: " r@ js> pop().item().NetEnabled . cr + ." / NetworkAddresses: " r@ js> pop().item().NetworkAddresses . cr + ." / PermanentAddress: " r@ js> pop().item().PermanentAddress . cr + ." / Status: " r@ js> pop().item().Status . cr r@ js: pop().moveNext() false [then] [until] - ." List specific NIC through identifying its caption" cr - s" where caption like '%Intel(R) Ethernet Connection%'" objEnumWin32_NetworkAdapter >r + ." List specific NIC through identifying its properties" cr + \ s" where caption like '%Intel(R) Ethernet Connection%'" objEnumWin32_NetworkAdapter >r + s" where NetEnabled='True'" objEnumWin32_NetworkAdapter >r [begin] r@ js> pop().atEnd() [if] r> drop true [else] - r@ js> pop().item().caption . ." / DeviceID: " - r@ js> pop().item().DeviceID . cr + r@ js> pop().item().caption . cr + ." / NetConnectionStatus: " r@ js> pop().item().NetConnectionStatus . cr + ." / NetEnabled: " r@ js> pop().item().NetEnabled . cr + ." / NetworkAddresses: " r@ js> pop().item().NetworkAddresses . cr + ." / PermanentAddress: " r@ js> pop().item().PermanentAddress . cr + ." / Status: " r@ js> pop().item().Status . cr r@ js: pop().moveNext() false [then] [until] -
- -: getNIC ( "caption" -- objNIC ) \ Get NIC object so I can disable or enable it - s" where caption like '" swap + char ' + objEnumWin32_NetworkAdapter >r - begin - r@ js> pop().atEnd() if r> drop true else - r@ js> pop().item() \ get the last one if there are many - r@ js: pop().moveNext() - false - then - until ; - /// Usage: Run jeforth.hta as administrator (through administrator DOS box is a way) - /// s" %Intel(R) Ethernet Connection%" getNIC :> disable() \ return 5 is failed when not an administrator - /// s" %Intel(R) Ethernet Connection%" getNIC :> enable() \ return 5 is failed when not an administrator - + \ 利用 jeforth for WSH 與其 JavaScript console 手動來操作 WMI 很有用,沒必要寫一大堆人機介面。 \ 跑一下 objEnumWin32_OperatingSystem 準備好 Win32_OperatingSystem object 放在 TOS,此後用 console 進 js console, From 30c0d06e0f79df210388d6d9f450a31fabcca945 Mon Sep 17 00:00:00 2001 From: "H.C. Chen" Date: Fri, 30 Jun 2017 14:51:19 +0800 Subject: [PATCH 05/16] Add Microsoft Azure Face API exercises --- playground/NIC.bat | 77 ++++++++++++++++++++++++++++++++++++++++++++ playground/faceapi.f | 72 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 149 insertions(+) create mode 100644 playground/NIC.bat create mode 100644 playground/faceapi.f diff --git a/playground/NIC.bat b/playground/NIC.bat new file mode 100644 index 0000000..bbea5e7 --- /dev/null +++ b/playground/NIC.bat @@ -0,0 +1,77 @@ +: @rem ; ' \ aliases echo @echo @echo. @goto :end jeforth.hta @rem cd call @if :ERR pause :END +cd %~dp0 +@rem +@rem N I C . b a t +@rem +@rem +@rem H.C. Chen 3:29 PM 6/27/2017 +@rem + +@echo. +@echo Executing %~nx0 . . . +@goto batch +\ --------------- start jeforth code ---------------------- + +." List all NIC" cr +"" getNIC ( nic nic ... ) \ No where clause, get all of them +#nic ?dup [if] [for] + >r r@ :> caption . cr + ." / NetConnectionStatus: " r@ :> NetConnectionStatus . cr + ." / NetEnabled: " r@ :> NetEnabled . cr + ." / NetworkAddresses: " r@ :> NetworkAddresses . cr + ." / PermanentAddress: " r@ :> PermanentAddress . cr + ." / Status: " r@ :> Status . cr + r> drop +[next] [then] + +." List active NIC" cr +activeNIC ( nic nic ... ) \ assume there are many active NICs +#nic ?dup [if] [for] + >r r@ :> caption . cr + ." / NetConnectionStatus: " r@ :> NetConnectionStatus . cr + ." / NetEnabled: " r@ :> NetEnabled . cr + ." / NetworkAddresses: " r@ :> NetworkAddresses . cr + ." / PermanentAddress: " r@ :> PermanentAddress . cr + ." / Status: " r@ :> Status . cr + r> drop +[next] [then] + +: nicoff ( -- ) \ Turn off the NIC + s" where deviceid = 19" getNIC :> disable() + dup if + ." Failed! Error code " . ." . Make sure to run as an administrator." cr + else + drop ." NIC device turned off sucessfully." cr + then ; + /// return 5 is failed when not an administrator + +: nicon ( -- ) \ Turn on the NIC + s" where deviceid = 19" getNIC :> enable() + dup if + ." Failed! Error code " . ." . Make sure to run as an administrator." cr + else + drop ." NIC device turned on sucessfully." cr + then ; +\ Usage guide +

nicoff or nicon

drop cr + stop + +\ ---------------- end jeforth code ----------------------- + +:batch +call admin.bat +@rem ---------- start batch code --------------------------- +start jeforth.hta include %~nx0 \ include the batch program itself +@if %errorlevel% GEQ 1 goto ERR +@rem ------------ end batch code --------------------------- + +@goto END +:ERR +@echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +@echo errorlevel : %errorlevel% +@echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +pause +:END + + + diff --git a/playground/faceapi.f b/playground/faceapi.f new file mode 100644 index 0000000..159b1f5 --- /dev/null +++ b/playground/faceapi.f @@ -0,0 +1,72 @@ +--- marker --- cls +\ ==== All you need to provide are here ==== + + \ Request parameters + + ({ + "returnFaceId": "true", + "returnFaceLandmarks": "false", + "returnFaceAttributes": "age,gender,headPose,smile,facialHair,glasses,emotion,hair,makeup,accessories" + }) + value parameters-on-Request-URL // ( -- hashTable ) + + \ Picture URL + s" https://upload.wikimedia.org/wikipedia/en/d/d0/Hippolyta_%28DC_Comics%29_as_WW_-_from_WW_v2_i130.png" + value picture-url // ( -- "url" ) + + \ show the picture + + :> replace(/_pic_/,vm[context]["picture-url"]) + drop cr + + \ Azure resource subscription-key (paied account to call the service) + + char 5f5f04717cb641e0aa54ca03c9a5dfe0 value subscription-key // ( -- "key") hcchen's Azure cognitive services resource subscription-key + +\ ==== Now prepare to send the request to Azure server ==== + + \ Request URL + parameters-on-Request-URL + "https://southeastasia.api.cognitive.microsoft.com/face/v1.0/detect?" + $.param(pop()) + value request-url // ( -- "url" ) + + \ Request body + + picture-url + ('{"url":"__url__"}').replace(/__url__/,pop()) + value request-body // ( -- "object" ) + + \ Send the request to Azure server + + + $.ajax({ + url: vm[context]["request-url"], + beforeSend: function(xhrObj){ + // Request headers + xhrObj.setRequestHeader("Content-Type","application/json"); + xhrObj.setRequestHeader("Ocp-Apim-Subscription-Key",vm[context]["subscription-key"]); + }, + type: "POST", + data: vm[context]["request-body"] + }) + .done(function(response) { + alert("success"); + push(response); + execute('(see)'); // see the result + }) + .fail(function(error) { + alert("error"); + push(error); + execute('(see)'); // see the error message + }); + + + + + Face API - V1.0 reference + https://southeastasia.dev.cognitive.microsoft.com/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395236/console + My key : 5f5f04717cb641e0aa54ca03c9a5dfe0 + returnFaceAttributes=age,gender,headPose,smile,facialHair,glasses,emotion,hair,makeup,occlusion,accessories,blur,exposure,noise" + 大頭照 + data = '{"url":"https://upload.wikimedia.org/wikipedia/en/d/d0/Hippolyta_%28DC_Comics%29_as_WW_-_from_WW_v2_i130.png"}' + From bf38624d89ff15615297a2723d083db7f0845430 Mon Sep 17 00:00:00 2001 From: "H.C. Chen" Date: Mon, 3 Jul 2017 21:08:42 +0800 Subject: [PATCH 06/16] study LUIS and HTA issue --- LOG/log.txt | 8578 ++++++++++++++++++++++++++------------------------- 1 file changed, 4313 insertions(+), 4265 deletions(-) diff --git a/LOG/log.txt b/LOG/log.txt index 2d3180d..42f7f1c 100644 --- a/LOG/log.txt +++ b/LOG/log.txt @@ -1,544 +1,544 @@ - ~%~%~%~%~%~%~%~ j e f o r t h . 3 w e ~%~%~%~%~%~%~%~ - The jeforth with a three words engine - Same kernel - jeforth.js, jeforth.f, voc.f - for - all applications - HTA, HTM, Node.js - and more? - http://github.com/hcchengithub/jeforth.3we + ~%~%~%~%~%~%~%~ j e f o r t h . 3 w e ~%~%~%~%~%~%~%~ + The jeforth with a three words engine + Same kernel - jeforth.js, jeforth.f, voc.f - for + all applications - HTA, HTM, Node.js - and more? + http://github.com/hcchengithub/jeforth.3we ---------- developping log -------------------------------------------------------------- -[x] first line of jeforth.f is strange. I skip it now. Need to find out the reason someday. hcchen5600 2014/01/28 11:39:49 - ==> fso does not support utf-8, ado does. +[x] first line of jeforth.f is strange. I skip it now. Need to find out the reason someday. hcchen5600 2014/01/28 11:39:49 + ==> fso does not support utf-8, ado does. [x] why UTF-8 chinese characters are not shown correctly? ==> big5 is ok! - ==> fso does not support utf-8, ado does. + ==> fso does not support utf-8, ado does. [X] jquery.terminal-0.7.7.js ==> I give up jQuery-terminal when it comes to HTA. - > 552 var data = $.Storage.get(name + 'commands'); - > alert(name+"==>"+data); - > 553 data = data ? new Function('return ' + data + ';')() : []; - > 554 var pos = data.length-1; + > 552 var data = $.Storage.get(name + 'commands'); + > alert(name+"==>"+data); + > 553 data = data ? new Function('return ' + data + ';')() : []; + > 554 var pos = data.length-1; - How to make a Terminal (comamnd line, shell like) U/I on Web page? - See this answer ==> evernote:///view/2472143/s22/bf00c410-9727-401f-98a7-221c8fc00558/bf00c410-9727-401f-98a7-221c8fc00558/ + How to make a Terminal (comamnd line, shell like) U/I on Web page? + See this answer ==> evernote:///view/2472143/s22/bf00c410-9727-401f-98a7-221c8fc00558/bf00c410-9727-401f-98a7-221c8fc00558/ [x] the screen output is a little strange, messy. Find a SRP. - ==> print() probably is the root cause, it wrap around long lines. Looks like the jQuery-terminal - thinks of the right-edge with a wrong number. - ==> When use 'body' instead of a DIV component, the jQuery-terminal can not scroll up and the - bottom line can not see! - ==> So, give up using jQuery-terminal? Sure, ok this is it! - ==> [/] simplify the SRP and report to the jQuery-terminal author. - ==> [/] also consider to use termlib.js @ evernote:///view/2472143/s22/6df50a24-f3b8-4ae4-afc5-45d7e180b3dc/6df50a24-f3b8-4ae4-afc5-45d7e180b3dc/ - ==> [x] Try normal HTML terminal first - ------ http://jsfiddle.net/hcchen/9Kr5E/ hcchen/jsfiddle ------------------ - << HTML section >> - -
恭喜發財!
-
- root@host  - -
- - << JavaScript section >> - - $("#command").keyup(function (e) { - if (e.keyCode == 13) { - submit(); - } - }); - - var submit = function () { - var command = document.getElementById("command").value; - var outputel = document.getElementById("screenoutput"); - var div = document.createElement("div"); - div.innerHTML = "root@host " + command; - outputel.appendChild(div); - document.getElementById("command").value = ""; - }; - ==> I give up jQuery-terminal when it comes to HTA. + ==> print() probably is the root cause, it wrap around long lines. Looks like the jQuery-terminal + thinks of the right-edge with a wrong number. + ==> When use 'body' instead of a DIV component, the jQuery-terminal can not scroll up and the + bottom line can not see! + ==> So, give up using jQuery-terminal? Sure, ok this is it! + ==> [/] simplify the SRP and report to the jQuery-terminal author. + ==> [/] also consider to use termlib.js @ evernote:///view/2472143/s22/6df50a24-f3b8-4ae4-afc5-45d7e180b3dc/6df50a24-f3b8-4ae4-afc5-45d7e180b3dc/ + ==> [x] Try normal HTML terminal first + ------ http://jsfiddle.net/hcchen/9Kr5E/ hcchen/jsfiddle ------------------ + << HTML section >> + +
恭喜發財!
+
+ root@host  + +
+ + << JavaScript section >> + + $("#command").keyup(function (e) { + if (e.keyCode == 13) { + submit(); + } + }); + + var submit = function () { + var command = document.getElementById("command").value; + var outputel = document.getElementById("screenoutput"); + var div = document.createElement("div"); + div.innerHTML = "root@host " + command; + outputel.appendChild(div); + document.getElementById("command").value = ""; + }; + ==> I give up jQuery-terminal when it comes to HTA. [x] In .3nw jsEvalRaw's return value spec was quirky, it was ( data errormsg ), make it simpler - ( data, errormsg, flag) ? - jsEvalRaw is a very useful word. By using jsEvalRaw, we don't need to try{}catch{} every - system call. E.g. readTextFile() and writeTextFile() become much easier. + ( data, errormsg, flag) ? + jsEvalRaw is a very useful word. By using jsEvalRaw, we don't need to try{}catch{} every + system call. E.g. readTextFile() and writeTextFile() become much easier. [x] Now start to port wsh.f (wmi.f excel.f ... ) [x] Make .... <=== 研究 WSC 就是為了要 support 這組有趣的命令 - Study how to combine VBscipt and JScript - HTC http://msdn.microsoft.com/en-us/library/ms532146(v=vs.85).aspx - WSC or WSH gui interface with IE or HTA http://computer-programming-forum.com/61-wsh/9dad42d8c1e3a878.htm + Study how to combine VBscipt and JScript + HTC http://msdn.microsoft.com/en-us/library/ms532146(v=vs.85).aspx + WSC or WSH gui interface with IE or HTA http://computer-programming-forum.com/61-wsh/9dad42d8c1e3a878.htm - hcchen5600 2014/07/01 08:44:41 It's very easy. See below hcchen5600 2014/06/30 17:22:40 + hcchen5600 2014/07/01 08:44:41 It's very easy. See below hcchen5600 2014/06/30 17:22:40 [/] WSC can be used in VBScript even wthout registered. - Ask Michael Harris, if same thing can be done in JScript? ==> Now I realized, even if it - would turn out that only VBscript can GetObject(..wsc..) is good enough. jeforth.hta uses - that VBScript to launch jeforth.js would be fine. - [x] Put the jeforth.js into jeforth.wsc, Open jeforth.WSC in jeforth.hta - ==> use to include jeforth.js in WSC is ok. - [/] we can publicate properties and methods but how to publicate objects? - - - - - - ==> If you are thinking of a tag, see this http://msdn.microsoft.com/en-us/library/thwwf7y9(v=vs.84).aspx - But it's wrong anyway. An object is simply a property I guess. - [*] Note! Only define things in WSC, don't try to run anything in WSC. - [/] By the experiments of Dropbox\learnings\JavaScript\WSC , if run 2.vbs then - JS section in 2.wsc doesn't know about WScript.echo but MsgBox of VBS works fine. - why? WSC do not have any I/O? unless that are VBS built-in, right? This is great! - VBScript has many built-in U/I functions. + Ask Michael Harris, if same thing can be done in JScript? ==> Now I realized, even if it + would turn out that only VBscript can GetObject(..wsc..) is good enough. jeforth.hta uses + that VBScript to launch jeforth.js would be fine. + [x] Put the jeforth.js into jeforth.wsc, Open jeforth.WSC in jeforth.hta + ==> use to include jeforth.js in WSC is ok. + [/] we can publicate properties and methods but how to publicate objects? + + + + + + ==> If you are thinking of a tag, see this http://msdn.microsoft.com/en-us/library/thwwf7y9(v=vs.84).aspx + But it's wrong anyway. An object is simply a property I guess. + [*] Note! Only define things in WSC, don't try to run anything in WSC. + [/] By the experiments of Dropbox\learnings\JavaScript\WSC , if run 2.vbs then + JS section in 2.wsc doesn't know about WScript.echo but MsgBox of VBS works fine. + why? WSC do not have any I/O? unless that are VBS built-in, right? This is great! + VBScript has many built-in U/I functions. [x] Recent jeforth.3hta on Github is v1.00, it prints to a
immediately but they - do not appear on the web page immediately! <=== Note, because jeforth for-next loop is a blocking - process. Thus, "print" and "accept" need to refer to plateform.f in jeforth.3nw which is my best - practice dealing with none-blocking programming. + do not appear on the web page immediately! <=== Note, because jeforth for-next loop is a blocking + process. Thus, "print" and "accept" need to refer to plateform.f in jeforth.3nw which is my best + practice dealing with none-blocking programming. - \ By using 'sleep' command introduced since jeforth.3nw, I can make KVM none-blocking. See below - \ example, it works fine on jeforth.3hta v1.00 too. - : test for r@ . space 1 sleep next ; - cls 1000 last execute + \ By using 'sleep' command introduced since jeforth.3nw, I can make KVM none-blocking. See below + \ example, it works fine on jeforth.3hta v1.00 too. + : test for r@ . space 1 sleep next ; + cls 1000 last execute - \ But I find another way without using 'sleep' and it's much mush faster, - : test for r@ . space js> scrollToElement($('#endofpage')) next ; - cls 1000 last execute + \ But I find another way without using 'sleep' and it's much mush faster, + : test for r@ . space js> scrollToElement($('#endofpage')) next ; + cls 1000 last execute [/] 承上, I should designe a word to scroll to end of the display area. - Calling the scrolling system call gives the browser some time to breathe. - ==> scrollToElement() is good enough. If you are thinking about jeforth's example, it's, - - var o = document.getElementById('outputbox'); - o.scrollTop = o.scrollHeight; - + Calling the scrolling system call gives the browser some time to breathe. + ==> scrollToElement() is good enough. If you are thinking about jeforth's example, it's, + + var o = document.getElementById('outputbox'); + o.scrollTop = o.scrollHeight; + [x] Now by utilizing WSC, I think that I can combine jeforth.3wsh and jeforth.3hta or even jeforth.3wsf - Because they all based on the same jeforth.wsc. - HTA is really a sinking boat http://social.technet.microsoft.com/Forums/scriptcenter/en-US/c21b847c-35b4-46ab-a609-17e7fd47638e/how-to-open-the-f12-key-debugger-in-hta-like-ie?forum=ITCG#c21b847c-35b4-46ab-a609-17e7fd47638e - ==> No need to complicate wsc this way, see 2014/02/07 13:48:05 + Because they all based on the same jeforth.wsc. + HTA is really a sinking boat http://social.technet.microsoft.com/Forums/scriptcenter/en-US/c21b847c-35b4-46ab-a609-17e7fd47638e/how-to-open-the-f12-key-debugger-in-hta-like-ie?forum=ITCG#c21b847c-35b4-46ab-a609-17e7fd47638e + ==> No need to complicate wsc this way, see 2014/02/07 13:48:05 [x] hcchen5600 2014/02/07 13:48:05 - WSC's purpose is letting jeforth to support commands then we don't need to - bring entire jeforth.js into the wsc file!! - ==> Yeah! True. My .wsc has only a vbscript section that exports properties and methods. - then they can be accessed from jeforth by wsc.propertyname and wsc.methodname(). - - - ' Disk.vbs - ' Sample VBS WMI - ' Author Guy Thomas http://computerperformance.co.uk/ - ' http://www.computerperformance.co.uk/vbscript/wmi_basics.htm - ' Version 1.5 - November 2010 - ' -----------------------------------------------' - Option Explicit - Dim objWMIService, objItem, colItems, strComputer, intDrive - - ' On Error Resume Next - strComputer = "." - intDrive = 0 - - ' WMI connection to Root CIM - Set objWMIService = GetObject("winmgmts:\\" _ - & strComputer & "\root\cimv2") - Set colItems = objWMIService.ExecQuery(_ - "Select * from Win32_DiskDrive") - - ' Classic For Next Loop - For Each objItem in colItems - intDrive = intDrive + 1 - print "DiskDrive " & intDrive & vbCrLf & _ - "Caption: " & objItem.Caption & vbCrLf & _ - "Description: " & objItem.Description & vbCrLf & _ - "Manufacturer: " & objItem.Manufacturer & vbCrLf & _ - "Model: " & objItem.Model & vbCrLf & _ - "Name: " & objItem.Name & vbCrLf & _ - "Partitions: " & objItem.Partitions & vbCrLf & _ - "Size: " & objItem.Size & vbCrLf & _ - "Status: " & objItem.Status & vbCrLf & _ - "SystemName: " & objItem.SystemName & vbCrLf & _ - "TotalCylinders: " & objItem.TotalCylinders & vbCrLf & _ - "TotalHeads: " & objItem.TotalHeads & vbCrLf & _ - "TotalSectors: " & objItem.TotalSectors & vbCrLf & _ - "TotalTracks: " & objItem.TotalTracks & vbCrLf & _ - "TracksPerCylinder: " & objItem.TracksPerCylinder - Next - - ' End of Sample Disk VBScript - js> vbs.displayBuffer="";vbs.exec(pop());vbs.displayBuffer cls . - - ------------------------------------------------------------------------------- - W/O using WSC works fine too - ------------------------------------------------------------------------------- - - ' Disk.vbs - ' Sample VBS WMI - ' Author Guy Thomas http://computerperformance.co.uk/ - ' http://www.computerperformance.co.uk/vbscript/wmi_basics.htm - ' Version 1.5 - November 2010 - ' -----------------------------------------------' - Option Explicit - Dim objWMIService, objItem, colItems, strComputer, intDrive - - ' On Error Resume Next - strComputer = "." - intDrive = 0 - - ' WMI connection to Root CIM - Set objWMIService = GetObject("winmgmts:\\" _ - & strComputer & "\root\cimv2") - Set colItems = objWMIService.ExecQuery(_ - "Select * from Win32_DiskDrive") - - ' Classic For Next Loop - For Each objItem in colItems - intDrive = intDrive + 1 - print "DiskDrive " & intDrive & vbCrLf & _ - "Caption: " & objItem.Caption & vbCrLf & _ - "Description: " & objItem.Description & vbCrLf & _ - "Manufacturer: " & objItem.Manufacturer & vbCrLf & _ - "Model: " & objItem.Model & vbCrLf & _ - "Name: " & objItem.Name & vbCrLf & _ - "Partitions: " & objItem.Partitions & vbCrLf & _ - "Size: " & objItem.Size & vbCrLf & _ - "Status: " & objItem.Status & vbCrLf & _ - "SystemName: " & objItem.SystemName & vbCrLf & _ - "TotalCylinders: " & objItem.TotalCylinders & vbCrLf & _ - "TotalHeads: " & objItem.TotalHeads & vbCrLf & _ - "TotalSectors: " & objItem.TotalSectors & vbCrLf & _ - "TotalTracks: " & objItem.TotalTracks & vbCrLf & _ - "TracksPerCylinder: " & objItem.TracksPerCylinder - Next - - ' End of Sample Disk VBScript - js> vbExecute(pop()) + WSC's purpose is letting jeforth to support commands then we don't need to + bring entire jeforth.js into the wsc file!! + ==> Yeah! True. My .wsc has only a vbscript section that exports properties and methods. + then they can be accessed from jeforth by wsc.propertyname and wsc.methodname(). + + + ' Disk.vbs + ' Sample VBS WMI + ' Author Guy Thomas http://computerperformance.co.uk/ + ' http://www.computerperformance.co.uk/vbscript/wmi_basics.htm + ' Version 1.5 - November 2010 + ' -----------------------------------------------' + Option Explicit + Dim objWMIService, objItem, colItems, strComputer, intDrive + + ' On Error Resume Next + strComputer = "." + intDrive = 0 + + ' WMI connection to Root CIM + Set objWMIService = GetObject("winmgmts:\\" _ + & strComputer & "\root\cimv2") + Set colItems = objWMIService.ExecQuery(_ + "Select * from Win32_DiskDrive") + + ' Classic For Next Loop + For Each objItem in colItems + intDrive = intDrive + 1 + print "DiskDrive " & intDrive & vbCrLf & _ + "Caption: " & objItem.Caption & vbCrLf & _ + "Description: " & objItem.Description & vbCrLf & _ + "Manufacturer: " & objItem.Manufacturer & vbCrLf & _ + "Model: " & objItem.Model & vbCrLf & _ + "Name: " & objItem.Name & vbCrLf & _ + "Partitions: " & objItem.Partitions & vbCrLf & _ + "Size: " & objItem.Size & vbCrLf & _ + "Status: " & objItem.Status & vbCrLf & _ + "SystemName: " & objItem.SystemName & vbCrLf & _ + "TotalCylinders: " & objItem.TotalCylinders & vbCrLf & _ + "TotalHeads: " & objItem.TotalHeads & vbCrLf & _ + "TotalSectors: " & objItem.TotalSectors & vbCrLf & _ + "TotalTracks: " & objItem.TotalTracks & vbCrLf & _ + "TracksPerCylinder: " & objItem.TracksPerCylinder + Next + + ' End of Sample Disk VBScript + js> vbs.displayBuffer="";vbs.exec(pop());vbs.displayBuffer cls . + + ------------------------------------------------------------------------------- + W/O using WSC works fine too + ------------------------------------------------------------------------------- + + ' Disk.vbs + ' Sample VBS WMI + ' Author Guy Thomas http://computerperformance.co.uk/ + ' http://www.computerperformance.co.uk/vbscript/wmi_basics.htm + ' Version 1.5 - November 2010 + ' -----------------------------------------------' + Option Explicit + Dim objWMIService, objItem, colItems, strComputer, intDrive + + ' On Error Resume Next + strComputer = "." + intDrive = 0 + + ' WMI connection to Root CIM + Set objWMIService = GetObject("winmgmts:\\" _ + & strComputer & "\root\cimv2") + Set colItems = objWMIService.ExecQuery(_ + "Select * from Win32_DiskDrive") + + ' Classic For Next Loop + For Each objItem in colItems + intDrive = intDrive + 1 + print "DiskDrive " & intDrive & vbCrLf & _ + "Caption: " & objItem.Caption & vbCrLf & _ + "Description: " & objItem.Description & vbCrLf & _ + "Manufacturer: " & objItem.Manufacturer & vbCrLf & _ + "Model: " & objItem.Model & vbCrLf & _ + "Name: " & objItem.Name & vbCrLf & _ + "Partitions: " & objItem.Partitions & vbCrLf & _ + "Size: " & objItem.Size & vbCrLf & _ + "Status: " & objItem.Status & vbCrLf & _ + "SystemName: " & objItem.SystemName & vbCrLf & _ + "TotalCylinders: " & objItem.TotalCylinders & vbCrLf & _ + "TotalHeads: " & objItem.TotalHeads & vbCrLf & _ + "TotalSectors: " & objItem.TotalSectors & vbCrLf & _ + "TotalTracks: " & objItem.TotalTracks & vbCrLf & _ + "TracksPerCylinder: " & objItem.TracksPerCylinder + Next + + ' End of Sample Disk VBScript + js> vbExecute(pop()) [x] We totally don't need WSC if the purpose is letting jeforth to support commands. - HTA allows different language sections to reference each other! Shit, I didn't know. + HTA allows different language sections to reference each other! Shit, I didn't know. [x] wsh.f Try to support the 'include' command to auto-search the given file. - done! hcchen5600 2014/07/13 15:38:04 + done! hcchen5600 2014/07/13 15:38:04 [x] http://www.104case.com.tw/memberp/member_seek_qa.cfm?seekno=815367042306027563&mode=2 - 黃嘉祥 - 服務的金額這確實是令人頭痛的問題,有時候只是”江湖一點訣”根本沒什麼,要收費我也收的很不好意思,像 - 您104貼的那個問題,只要加上浮動設定就可以解決了 - <div id=”keyboardinput” style=”position:absolute; bottom:0;”> - 除非您有更進一步的需求再做調整。 我目前的配合方式:1.單件報價 - 次月或累積到一定的金額($5000)時 - 再付款。 2.月聘維護 - 依公司維護需求/等級定價(這部分可能要詳談)。 我通常都建議初期採用單件,除非 - 很確定需求和內容,不然採用月聘容易產生誤會(ex:錢付了,結果整個月只處理兩件小事,或一個月內超過20 - 件複雜案,超過維護門檻)如果是像104那個小問題,沒有時間壓力要馬上解決的話...我看我們就交個朋友,透 - 過mail處理掉就ok了 - 2014/02/12 04:49 + 黃嘉祥 + 服務的金額這確實是令人頭痛的問題,有時候只是”江湖一點訣”根本沒什麼,要收費我也收的很不好意思,像 + 您104貼的那個問題,只要加上浮動設定就可以解決了 + <div id=”keyboardinput” style=”position:absolute; bottom:0;”> + 除非您有更進一步的需求再做調整。 我目前的配合方式:1.單件報價 - 次月或累積到一定的金額($5000)時 + 再付款。 2.月聘維護 - 依公司維護需求/等級定價(這部分可能要詳談)。 我通常都建議初期採用單件,除非 + 很確定需求和內容,不然採用月聘容易產生誤會(ex:錢付了,結果整個月只處理兩件小事,或一個月內超過20 + 件複雜案,超過維護門檻)如果是像104那個小問題,沒有時間壓力要馬上解決的話...我看我們就交個朋友,透 + 過mail處理掉就ok了 + 2014/02/12 04:49 [x] Wrtie a debug console, 'jsc' command. - See jeforth.js function panic(msg,severity) when severity!=false. - Consider to use VBScript's MsgBox and InpubBox. - No need to use VB, JavaScript has similar built-in functions: - js: alert('msg') js> confirm('msg') js> prompt('msg') - [x] hcchen5600 2014/07/16 10:09:47 利用 eval() 會認得 local variable 的特性。 - ==> Bingo!! - kvm.jsc.prompt = "111";eval(kvm.jsc.xt); + See jeforth.js function panic(msg,severity) when severity!=false. + Consider to use VBScript's MsgBox and InpubBox. + No need to use VB, JavaScript has similar built-in functions: + js: alert('msg') js> confirm('msg') js> prompt('msg') + [x] hcchen5600 2014/07/16 10:09:47 利用 eval() 會認得 local variable 的特性。 + ==> Bingo!! + kvm.jsc.prompt = "111";eval(kvm.jsc.xt); [x] 目前 gitHub 上有一版基本版 voc.f ready -- hcchen5600 2014/02/28 15:25:14 [x] hcchen5600 2014/06/30 14:08:56 還在搞 ... 的準備。在 Github 上弄了個 Develop branch 方便 backup 用。 - jeforth.3hta\playground\vb.f 有些進展。 - 先把本來 jeforth.hta 裡的 vbs section 整個弄走,放進 vbs/basic.vbs ----> - vb.f 裡實驗用 vbExecute(pop()) 來定義 vbs function or subroutine 有成功!但只能在同一個 block 裡存在。如何把 - 它 assign 給一個 name ? - If not doable, then being able to include ~.vbs is good enough. - hcchen5600 2014/06/30 17:22:40 ... is ok now at playground/vb.f. + jeforth.3hta\playground\vb.f 有些進展。 + 先把本來 jeforth.hta 裡的 vbs section 整個弄走,放進 vbs/basic.vbs ----> + vb.f 裡實驗用 vbExecute(pop()) 來定義 vbs function or subroutine 有成功!但只能在同一個 block 裡存在。如何把 + 它 assign 給一個 name ? + If not doable, then being able to include ~.vbs is good enough. + hcchen5600 2014/06/30 17:22:40 ... is ok now at playground/vb.f. [x] hcchen5600 2014/06/30 17:23:43 - kvm.something can be accessed in section. - js> kvm obj>keys . - I got ===> init,reset,panic,*fortheval*,see,suspendForthVM,resumeForthVM,stack,words OK - many of kvm export functions are not used at all, and we need push() and pop(). ===> done! - All kvm memvers can be used in section happily. - Example: - kvm.push(kvm.tos()) <------- this works like 'DUP' command. - vb: vb> are done too. Commit it. + kvm.something can be accessed in section. + js> kvm obj>keys . + I got ===> init,reset,panic,*fortheval*,see,suspendForthVM,resumeForthVM,stack,words OK + many of kvm export functions are not used at all, and we need push() and pop(). ===> done! + All kvm memvers can be used in section happily. + Example: + kvm.push(kvm.tos()) <------- this works like 'DUP' command. + vb: vb> are done too. Commit it. [x] Many useful VBS examples are here - http://msdn.microsoft.com/en-us/library/aa394599(v=vs.85).aspx - http://technet.microsoft.com/en-us/library/ee692768.aspx + http://msdn.microsoft.com/en-us/library/aa394599(v=vs.85).aspx + http://technet.microsoft.com/en-us/library/ee692768.aspx [x] tos(),pop(),push() can be used in forth code directly but not VBS code. - Unless jeforth.hta introduces them to global. Let's do it ..... done! - Now we can use them directly in sections. + Unless jeforth.hta introduces them to global. Let's do it ..... done! + Now we can use them directly in sections. [x] 玩 self 或 window object 時,發現新大陸! window.prompt() 本來就有,可以用來 - 收 input line !! 所以 prompt = 'OK ' 要改名成 kvmPrompt. ==> 3hta, 3nw both done. hcchen5600 2014/07/03 10:41:56 - - 在 jeforth console 下,用 JavaScript 的 self 就可以看到這些東西。我覺得這時 - 的 self 應該是 kvm 但其實是 window。搞不懂! - - OK js> self obj>keys . \ ----- 3HTA ----- - Refer to MSDN @ http://msdn.microsoft.com/en-us/library/ie/ms535873(v=vs.85).aspx - - $, jQuery, kvm, WshShell, document, styleMedia, clientInformation, - clipboardData, closed, defaultStatus, event, external, - maxConnectionsPerServer, offscreenBuffering, onfocusin, onfocusout, - onhelp, onmouseenter, onmouseleave, screenLeft, screenTop, status, - innerHeight, innerWidth, outerHeight, outerWidth, pageXOf fset, - pageYOffset, screen, screenX, screenY, frameElement, frames, history, - leng th, location, name, navigator, onabort, onafterprint, - onbeforeprint, onbeforeun load, onblur, oncanplay, oncanplaythrough, - onchange, onclick, oncontextmenu, on dblclick, ondrag, ondragend, - ondragenter, ondragleave, ondragover, ondragstart , ondrop, - ondurationchange, onemptied, onended, onerror, onfocus, onhashchange, - oninput, onkeydown, onkeypress, onkeyup, onload, onloadeddata, - onloadedmetadat a, onloadstart, onmessage, onmousedown, onmousemove, - onmouseout, onmouseover, o nmouseup, onmousewheel, onoffline, ononline, - onpause, onplay, onplaying, onprog ress, onratechange, - onreadystatechange, onreset, onresize, onscroll, onseeked, onseeking, - onselect, onstalled, onstorage, onsubmit, onsuspend, ontimeupdate, o - nunload, onvolumechange, onwaiting, opener, parent, self, top, window, - localStor age, performance, sessionStorage, addEventListener, - dispatchEvent, removeEven tListener, attachEvent, detachEvent, - createPopup, execScript, item, moveBy, mov eTo, msWriteProfilerMark, - navigate, resizeBy, resizeTo, showHelp, showModeless Dialog, - toStaticHTML, scroll, scrollBy, scrollTo, getComputedStyle, alert, blur - , close, confirm, focus, getSelection, open, postMessage, print, prompt, - showModa lDialog, toString, clearInterval, clearTimeout, setInterval, - setTimeout OK - - OK js> self .s - 0: [object Window] (object) <------------ 果然是 window object ! - - 用 ~.3nw 也看看 . . . - - OK js> self . - [object Window] <------------ 確定是 window object ! - OK js> self js> window = . - true <------------ 再次確定是 window object ! ~.3hta 結果也一樣。 - - OK js> self obj>keys . \ ----- 3nw ----- - top, window, location, nwDispatcher, Intl, v8Intl, document, global, - process, Buffer, root, require, $, jQuery, kvm, gui, revision, debug, - ... snip ... - - js> document obj>keys . \ -------- 3HTA ---------------- - doctype, documentElement, implementation, inputEncoding, xmlEncoding, - xmlStandalone, xmlVersion, styleSheets, defaultView, URL, activeElement, - ... snip ... - - js: document.onmouseout=function(){alert(222)} \ 靠!真的會在 mouse 移開時打 alert() - js: document.onmouseout=null - js: document.onmouseout=function(){fortheval('hi')} \ It works!! - : test begin 80 for char * . 100 sleep next cr again ; \ 弄一個印 * 的 long run 程式。 - - 用 forth colon word 當 event handler, interrupt service routine 的要領: - o jeforth.hta inputbox 本身就是個最兇的 event 他會改 stack. 別的 event handler 都得 - balance data stack and return stack. - o 所有的 event handler 都要【接地】也就是直接回到 JavaScript host 也就是 idle state 去。 - 不能在 dictate() 或 execute() 之後放別的 JavaScript code 還以為是前面做好了才下來的, - 錯! dictate() 或 execute() 裡面很可能有 nap 或 sleep 那時候它就衝下來了! sleep 才可 - 以 stopSleeping 所以應該是它。 + 收 input line !! 所以 prompt = 'OK ' 要改名成 kvmPrompt. ==> 3hta, 3nw both done. hcchen5600 2014/07/03 10:41:56 + + 在 jeforth console 下,用 JavaScript 的 self 就可以看到這些東西。我覺得這時 + 的 self 應該是 kvm 但其實是 window。搞不懂! + + OK js> self obj>keys . \ ----- 3HTA ----- + Refer to MSDN @ http://msdn.microsoft.com/en-us/library/ie/ms535873(v=vs.85).aspx + + $, jQuery, kvm, WshShell, document, styleMedia, clientInformation, + clipboardData, closed, defaultStatus, event, external, + maxConnectionsPerServer, offscreenBuffering, onfocusin, onfocusout, + onhelp, onmouseenter, onmouseleave, screenLeft, screenTop, status, + innerHeight, innerWidth, outerHeight, outerWidth, pageXOf fset, + pageYOffset, screen, screenX, screenY, frameElement, frames, history, + leng th, location, name, navigator, onabort, onafterprint, + onbeforeprint, onbeforeun load, onblur, oncanplay, oncanplaythrough, + onchange, onclick, oncontextmenu, on dblclick, ondrag, ondragend, + ondragenter, ondragleave, ondragover, ondragstart , ondrop, + ondurationchange, onemptied, onended, onerror, onfocus, onhashchange, + oninput, onkeydown, onkeypress, onkeyup, onload, onloadeddata, + onloadedmetadat a, onloadstart, onmessage, onmousedown, onmousemove, + onmouseout, onmouseover, o nmouseup, onmousewheel, onoffline, ononline, + onpause, onplay, onplaying, onprog ress, onratechange, + onreadystatechange, onreset, onresize, onscroll, onseeked, onseeking, + onselect, onstalled, onstorage, onsubmit, onsuspend, ontimeupdate, o + nunload, onvolumechange, onwaiting, opener, parent, self, top, window, + localStor age, performance, sessionStorage, addEventListener, + dispatchEvent, removeEven tListener, attachEvent, detachEvent, + createPopup, execScript, item, moveBy, mov eTo, msWriteProfilerMark, + navigate, resizeBy, resizeTo, showHelp, showModeless Dialog, + toStaticHTML, scroll, scrollBy, scrollTo, getComputedStyle, alert, blur + , close, confirm, focus, getSelection, open, postMessage, print, prompt, + showModa lDialog, toString, clearInterval, clearTimeout, setInterval, + setTimeout OK + + OK js> self .s + 0: [object Window] (object) <------------ 果然是 window object ! + + 用 ~.3nw 也看看 . . . + + OK js> self . + [object Window] <------------ 確定是 window object ! + OK js> self js> window = . + true <------------ 再次確定是 window object ! ~.3hta 結果也一樣。 + + OK js> self obj>keys . \ ----- 3nw ----- + top, window, location, nwDispatcher, Intl, v8Intl, document, global, + process, Buffer, root, require, $, jQuery, kvm, gui, revision, debug, + ... snip ... + + js> document obj>keys . \ -------- 3HTA ---------------- + doctype, documentElement, implementation, inputEncoding, xmlEncoding, + xmlStandalone, xmlVersion, styleSheets, defaultView, URL, activeElement, + ... snip ... + + js: document.onmouseout=function(){alert(222)} \ 靠!真的會在 mouse 移開時打 alert() + js: document.onmouseout=null + js: document.onmouseout=function(){fortheval('hi')} \ It works!! + : test begin 80 for char * . 100 sleep next cr again ; \ 弄一個印 * 的 long run 程式。 + + 用 forth colon word 當 event handler, interrupt service routine 的要領: + o jeforth.hta inputbox 本身就是個最兇的 event 他會改 stack. 別的 event handler 都得 + balance data stack and return stack. + o 所有的 event handler 都要【接地】也就是直接回到 JavaScript host 也就是 idle state 去。 + 不能在 dictate() 或 execute() 之後放別的 JavaScript code 還以為是前面做好了才下來的, + 錯! dictate() 或 execute() 裡面很可能有 nap 或 sleep 那時候它就衝下來了! sleep 才可 + 以 stopSleeping 所以應該是它。 [/] Found a bug!! This bug is still in ~.3wsh and ~.3nw - wsh.f run command reads the whole line as a command line. The old definition + wsh.f run command reads the whole line as a command line. The old definition - 10 ASCII>char ( \n ) word (run) + 10 ASCII>char ( \n ) word (run) - was a mistake. It should be + was a mistake. It should be - char \n|\r word (run) ; interpret-only + char \n|\r word (run) ; interpret-only - The first match of either \r or \n terminates the command line. This is important - otherwise the extra \n may pollute the command line. + The first match of either \r or \n terminates the command line. This is important + otherwise the extra \n may pollute the command line. [x] To test 'run' command and siblings, I need to run command line therefore the parser is needed. - Copy from ~.3nw, it's easy but not so easy. Recent approach is not good. I need to impove it. - argv should neat at beginning. - ===> done! but there's a unexpected thing in stack [x] UI, tib.insert 吃到 empty stack 時會留下 - undefined at TOS. This is a mistake. 解法是在原來 pop() 處改成 (pop()||"") 就不會在 stack - empty 時 pop() 成 'undefined'. - ==> Ok now, include wsh.f then "run jeforth.hta 123 bye" you get 123 at TOS, bingo!!! + Copy from ~.3nw, it's easy but not so easy. Recent approach is not good. I need to impove it. + argv should neat at beginning. + ===> done! but there's a unexpected thing in stack [x] UI, tib.insert 吃到 empty stack 時會留下 + undefined at TOS. This is a mistake. 解法是在原來 pop() 處改成 (pop()||"") 就不會在 stack + empty 時 pop() 成 'undefined'. + ==> Ok now, include wsh.f then "run jeforth.hta 123 bye" you get 123 at TOS, bingo!!! [x] textarea cmd input has a problem. Press at middle of a string cuts the string <=== should not! - then pass the string to fortheval. I guess keydown/keyup needs fine tune <=== Yes! done. - Keycode 13 (Enter) handled in Keydown has fixed the problem. + then pass the string to fortheval. I guess keydown/keyup needs fine tune <=== Yes! done. + Keycode 13 (Enter) handled in Keydown has fixed the problem. [x] Now I am working on wsh.f and html5.f, the element can be drop on jeforth.display - so how about other HTML elements? - ==> Now I have or , Bingo!! + so how about other HTML elements? + ==> Now I have or , Bingo!! [x] wsh.f (dir) selftest's print outs should be redirected to selftest.log if printing is necessary. [x] docode() 裡面的 local variables 可以被 js> 看見!因為 JavaScript eval() 時,看得見。故 eval() 的 - 時機不能再 docode() 裡面。有機會嗎?==> done!! hcchen5600 2014/07/12 20:51:19 + 時機不能再 docode() 裡面。有機會嗎?==> done!! hcchen5600 2014/07/12 20:51:19 [x] 用 sendkey 時,不能是中文輸入法,如何禁用? 似乎有解 http://bbs.csdn.net/topics/80079918 - js> $('#cmd').hide() 1000 sleep js> $('#cmd').show() 果然是他 - document.myform.text1.style.imeMode="disabled"; 禁用輸入法的方法 - js> $('#cmd')[0].style.imeMode="disabled"; - js> $('#cmd')[0].style.imeMode="auto"; - js> $('#cmd')[0].style.imeMode="active"; - js> $('#cmd')[0].style.imeMode="inactive"; - - $('#cmd')[0].style.imeMode="disabled"; 成功!!! - 能不能連 keyboard 都禁掉? - ==> 改用 clipboard 已經成功,不怕中文輸入模式。 hcchen5600 2014/07/12 20:27:46 + js> $('#cmd').hide() 1000 sleep js> $('#cmd').show() 果然是他 + document.myform.text1.style.imeMode="disabled"; 禁用輸入法的方法 + js> $('#cmd')[0].style.imeMode="disabled"; + js> $('#cmd')[0].style.imeMode="auto"; + js> $('#cmd')[0].style.imeMode="active"; + js> $('#cmd')[0].style.imeMode="inactive"; + + $('#cmd')[0].style.imeMode="disabled"; 成功!!! + 能不能連 keyboard 都禁掉? + ==> 改用 clipboard 已經成功,不怕中文輸入模式。 hcchen5600 2014/07/12 20:27:46 [x] jeforth.3hta 因為 input textarea 本身就是 multiple line 的,word 就是跨行的了!故我把 3nw 具有的 - text command 拿掉了。然而,還是有些 word 具有原始 forth 的跨行特性,例如 : ... ; 定義就是。但 - code ... end-code 不跨行。相較之下, jeforth.3nw 的 code ... end-code 是可跨行的。 - ==> 就這樣吧!不管他了。 + text command 拿掉了。然而,還是有些 word 具有原始 forth 的跨行特性,例如 : ... ; 定義就是。但 + code ... end-code 不跨行。相較之下, jeforth.3nw 的 code ... end-code 是可跨行的。 + ==> 就這樣吧!不管他了。 [x] 又抓到一個 bug, jeforth.3nw still has the problem - // keyboard.waiting = false; // jeforth.3nw 的 jeforth.js 裡有這種 platform dependent 的東西!不應該啊 [] - // term.set_prompt(prompt); // restore default jQuery-terminal prompt constant - ==> jeforth.3we common kernel should have resolved these problems. But in jeforth.3nw stand - alone version, well ... forget it. hcchen5600 2014/10/29 08:35:43 + // keyboard.waiting = false; // jeforth.3nw 的 jeforth.js 裡有這種 platform dependent 的東西!不應該啊 [] + // term.set_prompt(prompt); // restore default jQuery-terminal prompt constant + ==> jeforth.3we common kernel should have resolved these problems. But in jeforth.3nw stand + alone version, well ... forget it. hcchen5600 2014/10/29 08:35:43 [/] Bug found: - keycode 13 時,keyup 清除 textarea 不對,當 EditMode=true 時就糗了。hcchen5600 2014/07/13 17:48:07 - 正在幫 vb.f 寫 selftest, 構想每個 word command 該怎麼測試。。。 + keycode 13 時,keyup 清除 textarea 不對,當 EditMode=true 時就糗了。hcchen5600 2014/07/13 17:48:07 + 正在幫 vb.f 寫 selftest, 構想每個 word command 該怎麼測試。。。 [x] Shift-keys seem to be locked at start up. Back-space doesn't work. Check it out ... - js> ShiftKeyDown . cr false - js> CtrlKeyDown . cr false - js> AltKeyDown . cr true <---------- I felt that too! Now why? - ==> 這是測 wsh.f selftest 用到 alt-F4 關 calc.exe 時留下來的。多 sendkeys 按一下 Alt key 即解。 + js> ShiftKeyDown . cr false + js> CtrlKeyDown . cr false + js> AltKeyDown . cr true <---------- I felt that too! Now why? + ==> 這是測 wsh.f selftest 用到 alt-F4 關 calc.exe 時留下來的。多 sendkeys 按一下 Alt key 即解。 [x] 玩一玩 HTA 下的 elements. 確定 name attribute 的用法,真的可以用點的,但很長。要攔腰命名以縮短之。 - js> document.body obj>keys . - bgColor, background, noWrap, onafterprint, onbeforeprint, onbeforeunload, onblur,onerror, ... snip ... - - js> document.body.children.jeforth obj>keys . - windowState,borderStyle,version,maximizeButton, ... snip ... - - js> $('outputbox') obj>keys . - length, prevObject, context, selector, jquery, ... snip ... - - js> $('#outputbox').parent() . \ 查看我寫的東西掛哪裡? - [object Object] OK - js> $('#outputbox').parent()[0] . \ 這個 element 是 jeforth - [object HTMLUnknownElement] OK - - js> $('#outputbox').parent()[0].id . \ 整個頁面都屬 jeforth element - jeforth OK - - char Hello!!! . - js> document.body.children.jeforth.children.outputbox.textContent . \ outputbox 是 name attribute - - : jeforth js> document.body.children.jeforth.children ; \ 攔腰給個名字,縮短 object chain. - jeforth js: pop().outputbox.textContent="1111" \ 真的可以! - - OK - js> $('#outputbox')[0] - js> document.body.children.jeforth.children.outputbox \ name attribute 可以這樣用,直接點。 - = . - true OK - - OK - js> $('outputbox')[0] \ 誤會了!此處的 name 不是 name='foo' 之類的 attribute 而是 tag name, like 'p' of

. - js> document.body.children.jeforth.children.outputbox - = . - false OK - - - js: $('textarea')[0].textContent=123 \ 真的在輸入區中置入了 '123' - - true OK js> $("#outputbox")[0].id . \ 這個參考法對 id 有效, id 要小寫。如下,對 name 無效。 - outputbox OK - js> $("#outputbox")[0].getAttribute("ID") . \ 這樣也可以。 - outputbox OK - - jeforth OK js> $('#outputbox').parent()[0].getAttribute("id") - js> $('#outputbox').parent()[0].id = . - true OK - - OK js> $("#outputbox")[0].name . \ name 不能用點的,只有 id 可以。 - undefined - OK js> $("#outputbox")[0].getAttribute("name") . \ 要用 getAttribute() - outputbox - OK js> $("#outputbox")[0].getAttribute("name") . - outputbox OK - js> $("#outputbox")[0].name . - undefined OK - - js> $("#outputbox")[0].name . cr \ undefined - js> $("#outputbox")[0].getAttribute("name") . cr \ outputbox - js> $("#outputbox")[0].class . cr \ undefined 看來只有 id 可以直接點 - js> $("#outputbox")[0].getAttribute("class") . cr \ outputbox - - 用 jeforth.3nw 的 F12 debugger 輕易就把這玩意兒搞懂了 - OK sdfsdfsd - OK js> document.body.children.outputbox.lastChild . ===> [object Text] - OK js> document.body.children.outputbox.lastChild.data . ===> sdfsdfsd - OK js> document.body.children.outputbox.lastChild.baseURI . ===> file:///D:/hcchen/Dropbox/learnings/github/jeforth.3nw/index.html - OK js> document.body.children.outputbox.lastChild.nodeName . ===> #text - OK js> document.body.children.outputbox.lastChild.nodeType . ===> 3 - OK js> document.body.children.outputbox.lastChild.nodeValue . ===> sdfsdfsd - - js: document.body.children.outputbox.lastChild.data="11223344" - js> document.body.children.outputbox.lastChild.data . ===> 11223344 - - 看來是 jeforth.3hta 的問題,~.3nw 下 lastChild 跟 lastElementChild 是一樣的 - OK - OK js> document.body.children.outputbox.lastChild.nodeName . ===> INPUT - OK js> document.body.children.outputbox.lastElementChild.nodeName . ===> INPUT - - js> document.body.children.jeforth.children.outputbox.lastChild.nodeName . - js> document.body.children.jeforth.children.outputbox.lastChild.nodeValue . - js> document.body.children.jeforth.children.outputbox.childNodes .s - js> document.body.children.jeforth.children.outputbox.childNodes[1].nodeName . - js> document.body.children.jeforth.children.outputbox.childNodes[1].nodeValue . - - 來看看 jeforth.3hta 的 outputbox element 有哪些 members ? - js> document.body.children.jeforth.children.outputbox obj>keys . - align, noWrap, dataFld, dataFormatAs, dataSrc, currentStyle, runtimeStyle, - ... snip ... - replaceNode, - http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_node_replacechild - swapNode, clientHeight, clientLeft, clientTop, clientWidth, scrollHeight, - ... snip ... - ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE OK + js> document.body obj>keys . + bgColor, background, noWrap, onafterprint, onbeforeprint, onbeforeunload, onblur,onerror, ... snip ... + + js> document.body.children.jeforth obj>keys . + windowState,borderStyle,version,maximizeButton, ... snip ... + + js> $('outputbox') obj>keys . + length, prevObject, context, selector, jquery, ... snip ... + + js> $('#outputbox').parent() . \ 查看我寫的東西掛哪裡? + [object Object] OK + js> $('#outputbox').parent()[0] . \ 這個 element 是 jeforth + [object HTMLUnknownElement] OK + + js> $('#outputbox').parent()[0].id . \ 整個頁面都屬 jeforth element + jeforth OK + + char Hello!!! . + js> document.body.children.jeforth.children.outputbox.textContent . \ outputbox 是 name attribute + + : jeforth js> document.body.children.jeforth.children ; \ 攔腰給個名字,縮短 object chain. + jeforth js: pop().outputbox.textContent="1111" \ 真的可以! + + OK + js> $('#outputbox')[0] + js> document.body.children.jeforth.children.outputbox \ name attribute 可以這樣用,直接點。 + = . + true OK + + OK + js> $('outputbox')[0] \ 誤會了!此處的 name 不是 name='foo' 之類的 attribute 而是 tag name, like 'p' of

. + js> document.body.children.jeforth.children.outputbox + = . + false OK + + + js: $('textarea')[0].textContent=123 \ 真的在輸入區中置入了 '123' + + true OK js> $("#outputbox")[0].id . \ 這個參考法對 id 有效, id 要小寫。如下,對 name 無效。 + outputbox OK + js> $("#outputbox")[0].getAttribute("ID") . \ 這樣也可以。 + outputbox OK + + jeforth OK js> $('#outputbox').parent()[0].getAttribute("id") + js> $('#outputbox').parent()[0].id = . + true OK + + OK js> $("#outputbox")[0].name . \ name 不能用點的,只有 id 可以。 + undefined + OK js> $("#outputbox")[0].getAttribute("name") . \ 要用 getAttribute() + outputbox + OK js> $("#outputbox")[0].getAttribute("name") . + outputbox OK + js> $("#outputbox")[0].name . + undefined OK + + js> $("#outputbox")[0].name . cr \ undefined + js> $("#outputbox")[0].getAttribute("name") . cr \ outputbox + js> $("#outputbox")[0].class . cr \ undefined 看來只有 id 可以直接點 + js> $("#outputbox")[0].getAttribute("class") . cr \ outputbox + + 用 jeforth.3nw 的 F12 debugger 輕易就把這玩意兒搞懂了 + OK sdfsdfsd + OK js> document.body.children.outputbox.lastChild . ===> [object Text] + OK js> document.body.children.outputbox.lastChild.data . ===> sdfsdfsd + OK js> document.body.children.outputbox.lastChild.baseURI . ===> file:///D:/hcchen/Dropbox/learnings/github/jeforth.3nw/index.html + OK js> document.body.children.outputbox.lastChild.nodeName . ===> #text + OK js> document.body.children.outputbox.lastChild.nodeType . ===> 3 + OK js> document.body.children.outputbox.lastChild.nodeValue . ===> sdfsdfsd + + js: document.body.children.outputbox.lastChild.data="11223344" + js> document.body.children.outputbox.lastChild.data . ===> 11223344 + + 看來是 jeforth.3hta 的問題,~.3nw 下 lastChild 跟 lastElementChild 是一樣的 + OK + OK js> document.body.children.outputbox.lastChild.nodeName . ===> INPUT + OK js> document.body.children.outputbox.lastElementChild.nodeName . ===> INPUT + + js> document.body.children.jeforth.children.outputbox.lastChild.nodeName . + js> document.body.children.jeforth.children.outputbox.lastChild.nodeValue . + js> document.body.children.jeforth.children.outputbox.childNodes .s + js> document.body.children.jeforth.children.outputbox.childNodes[1].nodeName . + js> document.body.children.jeforth.children.outputbox.childNodes[1].nodeValue . + + 來看看 jeforth.3hta 的 outputbox element 有哪些 members ? + js> document.body.children.jeforth.children.outputbox obj>keys . + align, noWrap, dataFld, dataFormatAs, dataSrc, currentStyle, runtimeStyle, + ... snip ... + replaceNode, + http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_node_replacechild + swapNode, clientHeight, clientLeft, clientTop, clientWidth, scrollHeight, + ... snip ... + ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE OK [x] 亂定一堆 global variable 很令人不安,例如 kernelfso 等。 乾脆全部掛給 kvm 好過掛給 window ? - jeforth.hta 裡就要做 closure 才對。 <=== 目前已經是 jeforth.3we 裡所有 application 的慣例。 - ( ^ hcchen5600 2014/10/22 11:23:57 ) - ==> 本來在 jeforth.hta 裡的東西都是 global, 加上 closure 之後都不是了!這樣對,但如何修改? - 在 index.htm (即 jeforth.hta) 中變個 global object 出來,把所有屬 global 的東西都往裡倒。 - kvm.init() 時把 global 傳進去即可。 ====> Done!!! commit 一版。 - - [17:18:26] h.c.chen: 請教問題。jeforth 最上層是 index.html , 裡頭 script include 進 jeforth.js . - 我想把 index.html 裡的程式都 closure,以避免 global。這麼一來,要讓 jeforth.js - 看得到 index.html 定義的東西有何建議? - 我現在想的是在 index.html 裡弄一個 global object 把要用到的東西全放裡面。 - kvm.init(global) 傳過去給 jeforth.js ,這樣 ok? - [17:23:24] yap @ Forth: 建議用 browersify.js 或component.js - [17:24:02] h.c.chen: 有幾分鐘可以接電話嗎? - [17:25:39] h.c.chen: 我先看看 browserify.js 或component.js 謝謝! + jeforth.hta 裡就要做 closure 才對。 <=== 目前已經是 jeforth.3we 裡所有 application 的慣例。 + ( ^ hcchen5600 2014/10/22 11:23:57 ) + ==> 本來在 jeforth.hta 裡的東西都是 global, 加上 closure 之後都不是了!這樣對,但如何修改? + 在 index.htm (即 jeforth.hta) 中變個 global object 出來,把所有屬 global 的東西都往裡倒。 + kvm.init() 時把 global 傳進去即可。 ====> Done!!! commit 一版。 + + [17:18:26] h.c.chen: 請教問題。jeforth 最上層是 index.html , 裡頭 script include 進 jeforth.js . + 我想把 index.html 裡的程式都 closure,以避免 global。這麼一來,要讓 jeforth.js + 看得到 index.html 定義的東西有何建議? + 我現在想的是在 index.html 裡弄一個 global object 把要用到的東西全放裡面。 + kvm.init(global) 傳過去給 jeforth.js ,這樣 ok? + [17:23:24] yap @ Forth: 建議用 browersify.js 或component.js + [17:24:02] h.c.chen: 有幾分鐘可以接電話嗎? + [17:25:39] h.c.chen: 我先看看 browserify.js 或component.js 謝謝! [x] js> window obj>keys . ==> kvm,tos,pop,push,base,stackwas,htaProcess,WshShell,f,document, ... - 應該只有 kvm 其他都不要! - [x] base ==> kvm.base 才對 - [x] stackwas 要仔細檢討 - [x] tos, pop, push 改 call kvm.tos(), 等. - [x] htaProcess 改放 kvm.process, WshShell 保留在 window 裡。 - [x] f 根本是個錯誤,哪來的? ==> 用到時忘了用 var f; 先定義成 local 所造成。 - 最終,只有 kvm 與 WshShell 兩個 window global. - ==> *** hcchen5600 2014/10/22 11:11:45 Now, after jeforth.3we released with HTA, HTML, Node.js - support. The kvm object is now the only root. Different application's index.html or the likes - are to define kvm.properties and kvm.methods for the specific environment of the special - application. kvm.things are always accessable which is good when you were in F12 debugger or - in the jsc traps. + 應該只有 kvm 其他都不要! + [x] base ==> kvm.base 才對 + [x] stackwas 要仔細檢討 + [x] tos, pop, push 改 call kvm.tos(), 等. + [x] htaProcess 改放 kvm.process, WshShell 保留在 window 裡。 + [x] f 根本是個錯誤,哪來的? ==> 用到時忘了用 var f; 先定義成 local 所造成。 + 最終,只有 kvm 與 WshShell 兩個 window global. + ==> *** hcchen5600 2014/10/22 11:11:45 Now, after jeforth.3we released with HTA, HTML, Node.js + support. The kvm object is now the only root. Different application's index.html or the likes + are to define kvm.properties and kvm.methods for the specific environment of the special + application. kvm.things are always accessable which is good when you were in F12 debugger or + in the jsc traps. [x] something wrong on voc.f .... yeah, it's kernel. Well I will clarify it out. - ==> 抓 \uedit-backup\ 舊版回來就好了。我想錯了, voc.f 不可能比照 vocabulary 慣例。 + ==> 抓 \uedit-backup\ 舊版回來就好了。我想錯了, voc.f 不可能比照 vocabulary 慣例。 [x] 要不要改良 selftest.f 裡的 **** ==>judge 讓 'pass', 'failed' 自動找到對的位置顯示? [x] ." 是 compile-only 有必要嗎? wmi.f 裡用了一堆 ==> 變成 dual mode 了 [x] 拿到的 element 是 [object Text] 好像不對。 - 拿到的

element 也是 [object Text],不能用。 - ==> 原因找到了!哈哈題。 之前如果有空格就會傳回這個空格的 element 也就是 [object Text] - 這沒錯,錯在
之間不該留空格。 或者該自動把 之前的空 - 格消除! ===> 123 456 --> 123456 Bingo!!! + 拿到的
element 也是 [object Text],不能用。 + ==> 原因找到了!哈哈題。 之前如果有空格就會傳回這個空格的 element 也就是 [object Text] + 這沒錯,錯在
之間不該留空格。 或者該自動把 之前的空 + 格消除! ===> 123 456 --> 123456 Bingo!!! [x] char excel.exe kill-them 殺不掉,大小寫? ==> input must be a leagal where clause. @@ -547,77 +547,77 @@ [x] selftest.log 也不全面,只有 jeforth.f 有在 save log 應該全面都 save log. [x] Selftest 很長很長,怎麼樣知道已經做完了?應該自動 jump 到 inputbox. - js: kvm.scrollToElement($('#header')); 3000 sleep \ this doesn't work - js: kvm.scrollToElement($('#header')); 3000 freeze \ this works + js: kvm.scrollToElement($('#header')); 3000 sleep \ this doesn't work + js: kvm.scrollToElement($('#header')); 3000 freeze \ this works [x] 輸出叫做 outputbox 吧!(was outputscreen) - 輸入叫做 inputbox 吧! (was cmd) + 輸入叫做 inputbox 吧! (was cmd) [x] ... are interpret-only [x] forth macro 可以用 tib.insert 來做 <==== Yes! source-code-header is an example. [x] include 可以自動幫 ~.f 檔加上 \ --EOF-- 結尾。 So ~.f file's header can be further simplified. - 看到 \s 或 \ --EOF-- 就自動把該處當成 EOF 切掉之後的部份。 - 定義 source-code-header 為 - - ?skip2 --EOF-- \ skip it if already included - dup .( Including ) . cr char -- over over + + - js: tick('').masterMarker=tos()+"selftest--"; - also forth definitions (marker) (vocabulary) - last execute definitions - - js> tick('').masterMarker (marker) - include kernel/selftest.f - - constant source-code-header - tib.insert - ==> 一次成功! - 尾巴要自動完成。由 header 去找第一個 \\\s+--EOF-- , 後面切除,加上以下 - - js> tick('').masterMarker tib.insert - js> kvm.screenbuffer char selftest.log writeTextFile \ save selftest log file - - js> tick('').enabled [if] js> tick('').buffer tib.insert [then] - js: tick('').buffer="" \ recycle the memory - \ --EOF-- - - 試驗: - tib.slice(ntib); ntib = 0; - start-here kvm.screenbuffer.indexOf("thernet",pop())!=-1 \ true Ethernet - ("aabbcc\tddeeff\n\\--EOF-- gg\\shhii").search(/\\\s*--EOF--|\\s/) . - - var ss = "aabbcc\tddee\nff\\--EOF-- gg\\shhii"; - ss = (ss+" ").slice(0,ss.search(/\\\s*--EOF--|\\s/)); // 一開始多加一個 space 讓 search 結果 -1 時吃掉。 - . - 試驗成功,以下動作要在 include 裡做。 ss 是讀進來的整個 ~.f source code. - - ss = (ss+'x').slice(0,ss.search(/\\\s*--EOF--|\s\\s\s/)); // 一開始多加一個 'x' 讓 search 結果 -1 時吃掉。 - ss += "\\ --EOF--\n"; - - debug 的技巧 - kvm.jsc.prompt="111";eval(kvm.jsc.xt); \ jsc breakpoint - js: clipboardData.setData("text",tib.slice(ntib)) \ 利用 clipboard+notepad 來查看常內容 - - if(tos().indexOf("wmi.f")!=-1) window.xx=true; - js> window.xx [if] *debug* jjj>>> [then] + 看到 \s 或 \ --EOF-- 就自動把該處當成 EOF 切掉之後的部份。 + 定義 source-code-header 為 + + ?skip2 --EOF-- \ skip it if already included + dup .( Including ) . cr char -- over over + + + js: tick('').masterMarker=tos()+"selftest--"; + also forth definitions (marker) (vocabulary) + last execute definitions + + js> tick('').masterMarker (marker) + include kernel/selftest.f + + constant source-code-header + tib.insert + ==> 一次成功! + 尾巴要自動完成。由 header 去找第一個 \\\s+--EOF-- , 後面切除,加上以下 + + js> tick('').masterMarker tib.insert + js> kvm.screenbuffer char selftest.log writeTextFile \ save selftest log file + + js> tick('').enabled [if] js> tick('').buffer tib.insert [then] + js: tick('').buffer="" \ recycle the memory + \ --EOF-- + + 試驗: + tib.slice(ntib); ntib = 0; + start-here kvm.screenbuffer.indexOf("thernet",pop())!=-1 \ true Ethernet + ("aabbcc\tddeeff\n\\--EOF-- gg\\shhii").search(/\\\s*--EOF--|\\s/) . + + var ss = "aabbcc\tddee\nff\\--EOF-- gg\\shhii"; + ss = (ss+" ").slice(0,ss.search(/\\\s*--EOF--|\\s/)); // 一開始多加一個 space 讓 search 結果 -1 時吃掉。 + . + 試驗成功,以下動作要在 include 裡做。 ss 是讀進來的整個 ~.f source code. + + ss = (ss+'x').slice(0,ss.search(/\\\s*--EOF--|\s\\s\s/)); // 一開始多加一個 'x' 讓 search 結果 -1 時吃掉。 + ss += "\\ --EOF--\n"; + + debug 的技巧 + kvm.jsc.prompt="111";eval(kvm.jsc.xt); \ jsc breakpoint + js: clipboardData.setData("text",tib.slice(ntib)) \ 利用 clipboard+notepad 來查看常內容 + + if(tos().indexOf("wmi.f")!=-1) window.xx=true; + js> window.xx [if] *debug* jjj>>> [then] [x] writeTextFile 用來 save selftest.log 有時候會有問題,改用 writeBinaryFile 看看。。。 - ==> modify ok, [x] test my desktop at home. + ==> modify ok, [x] test my desktop at home. [x] jsc has been used in panic(). I need jsc for experiments. So, make it a command word. [X] excle.f selftest not completed yet - Including excel.f - *** excel... pass - *** excel.visible excel.invisible ... pass - *** new... pass - *** excel... pass - *** excel... pass - reDef WORKBOOK - *** get-sheet gets worksheet object ... pass - *** get-sheet gets worksheet object ... pass - *** get-cell gets cell object ... pass - *** cell@ cell! ... pass + Including excel.f + *** excel... pass + *** excel.visible excel.invisible ... pass + *** new... pass + *** excel... pass + *** excel... pass + reDef WORKBOOK + *** get-sheet gets worksheet object ... pass + *** get-sheet gets worksheet object ... pass + *** get-cell gets cell object ... pass + *** cell@ cell! ... pass [X] Bug found! selftest ***** treats any . as the end of the description! should be \.$ [x] jeforth.3hta starting greeting 看久了有一點煩,太干擾。簡化之。。。 @@ -626,119 +626,119 @@ [x] beeps when moves cmdhistory over the top or under the bottom. [x] voc.f help is very poor. Improve it. Better not to show empty - vocabularies, pattern should accept white spaces. + vocabularies, pattern should accept white spaces. [x] help shows word.comment but very poor. Use RegEx to indent comments. - js> ("aaa\nbbb\nccc").replace(/^\s*/gm,"\t") . + js> ("aaa\nbbb\nccc").replace(/^\s*/gm,"\t") . [ ] 已經開著的 excel 如何控制? - Try open some excel, try to see them then control them.... - ==> int hwnd = (int)Process.GetProcessById(excelId).MainWindowHandle http://stackoverflow.com/questions/770173/how-to-get-excel-instance-or-excel-instance-clsid-using-the-process-id - This is for .NET not JavaScript. + Try open some excel, try to see them then control them.... + ==> int hwnd = (int)Process.GetProcessById(excelId).MainWindowHandle http://stackoverflow.com/questions/770173/how-to-get-excel-instance-or-excel-instance-clsid-using-the-process-id + This is for .NET not JavaScript. [x] Tab auto-complete [ ] Tab auto-complete don't be case sensitive -[X] F2 toggle EditMode - F9 shrink input box - F10 enlarge input box - F4 copy marked text into inputbox. - - study IE9 window.getSelection() - : test - ." Get 3 selections " cr - 1000 sleep 1 . 1000 sleep 2 . 1000 sleep 3 . 1000 sleep 4 . 1000 sleep 5 . js> getSelection().anchorNode cr - 1000 sleep 1 . 1000 sleep 2 . 1000 sleep 3 . 1000 sleep 4 . 1000 sleep 5 . js> getSelection().anchorNode cr - 1000 sleep 1 . 1000 sleep 2 . 1000 sleep 3 . 1000 sleep 4 . 1000 sleep 5 . js> getSelection().anchorNode cr - ." done !!" cr - ; last execute - 發現 getSelection() 取得的 object 只存在於 selection 還在時。 - - Property Description - anchorNode Returns the element or node that contains the start of the selection. - anchorOffset Retrieves the starting position of a selection that is relative to the anchorNode. - focusNode Retrieves the element or node that contains the end of a selection. - focusOffset Retrieves the end position of a selection that is relative to the focusNode. - isCollapsed Retrieves whether a selection is collapsed or empty. - It's null when "true". - rangeCount Returns the number of ranges in a selection - It's always 1. I don't understand. - - variable selection - 1000 sleep 1 . beep - 1000 sleep 2 . beep - 1000 sleep 3 . beep - 1000 sleep 4 . beep - 1000 sleep 5 . beep cr - js> getSelection() selection ! - selection @ js> pop().anchorNode constant anchorNode - selection @ js> pop().anchorOffset constant anchorOffset - selection @ js> pop().focusNode constant focusNode - selection @ js> pop().focusOffset constant focusOffset - selection @ js> pop().isCollapsed constant isCollapsed - selection @ js> pop().rangeCount constant rangeCount -

Done!!

drop beep - - Mark 區域是 - code {F4} ( -- ) \ Copy marked string into inputbox - var selection = getSelection(); - var start, end; - if (selection.isCollapsed) return; // Nothing selected - if (selection.anchorNode==selection.focusNode) { - start = Math.min(selection.anchorOffset,selection.focusOffset); - end = Math.max(selection.anchorOffset,selection.focusOffset); - } else { - start = selection.anchorOffset; - end = selection.anchorNode.data.length; - } - var ss = selection.anchorNode.data.slice(start,end); - document.getElementById("inputbox").value += ss; - $('#inputbox').focus(); - end-code +[X] F2 toggle EditMode + F9 shrink input box + F10 enlarge input box + F4 copy marked text into inputbox. + + study IE9 window.getSelection() + : test + ." Get 3 selections " cr + 1000 sleep 1 . 1000 sleep 2 . 1000 sleep 3 . 1000 sleep 4 . 1000 sleep 5 . js> getSelection().anchorNode cr + 1000 sleep 1 . 1000 sleep 2 . 1000 sleep 3 . 1000 sleep 4 . 1000 sleep 5 . js> getSelection().anchorNode cr + 1000 sleep 1 . 1000 sleep 2 . 1000 sleep 3 . 1000 sleep 4 . 1000 sleep 5 . js> getSelection().anchorNode cr + ." done !!" cr + ; last execute + 發現 getSelection() 取得的 object 只存在於 selection 還在時。 + + Property Description + anchorNode Returns the element or node that contains the start of the selection. + anchorOffset Retrieves the starting position of a selection that is relative to the anchorNode. + focusNode Retrieves the element or node that contains the end of a selection. + focusOffset Retrieves the end position of a selection that is relative to the focusNode. + isCollapsed Retrieves whether a selection is collapsed or empty. + It's null when "true". + rangeCount Returns the number of ranges in a selection + It's always 1. I don't understand. + + variable selection + 1000 sleep 1 . beep + 1000 sleep 2 . beep + 1000 sleep 3 . beep + 1000 sleep 4 . beep + 1000 sleep 5 . beep cr + js> getSelection() selection ! + selection @ js> pop().anchorNode constant anchorNode + selection @ js> pop().anchorOffset constant anchorOffset + selection @ js> pop().focusNode constant focusNode + selection @ js> pop().focusOffset constant focusOffset + selection @ js> pop().isCollapsed constant isCollapsed + selection @ js> pop().rangeCount constant rangeCount +

Done!!

drop beep + + Mark 區域是 + code {F4} ( -- ) \ Copy marked string into inputbox + var selection = getSelection(); + var start, end; + if (selection.isCollapsed) return; // Nothing selected + if (selection.anchorNode==selection.focusNode) { + start = Math.min(selection.anchorOffset,selection.focusOffset); + end = Math.max(selection.anchorOffset,selection.focusOffset); + } else { + start = selection.anchorOffset; + end = selection.anchorNode.data.length; + } + var ss = selection.anchorNode.data.slice(start,end); + document.getElementById("inputbox").value += ss; + $('#inputbox').focus(); + end-code [x] dot . prints things, some objects are not printable that triggers an error: - Error msg: JavaScript error on word "." : Object doesn't support this property or method - 從 dot . 下手有成功,但是不完整。應該要從 print() and see() 下手才會完整。 - ===> much better now! - try : s" where name like 'chrome%'" get-them .s + Error msg: JavaScript error on word "." : Object doesn't support this property or method + 從 dot . 下手有成功,但是不完整。應該要從 print() and see() 下手才會完整。 + ===> much better now! + try : s" where name like 'chrome%'" get-them .s [x] "save" command to save definitions to jeforth.JSON to speed up the starting up time. - ==> They may be objects in dictionary, so no way!! + ==> They may be objects in dictionary, so no way!! [x] remove ^\s* from cmdhistory. [x] include , sinclude redefined in wsh.f so as to auto-search the source code file. - if forth gets the higher priority over wsh.f in vocabulary order then older definitions - will be taking the effects. The correct solution is not bringing wsh.f into kernel but - simply to use the 'definition' vocabulary command to redefine special words into the 'forth' - vocabulary. Thus even the forth word-list has higher priority than wsh.f the older - include/sinclude commands won't be unexpectedly used. - ==> Test, what happen after forget to --wsh.f-- marker? .... new words will be forgotten. + if forth gets the higher priority over wsh.f in vocabulary order then older definitions + will be taking the effects. The correct solution is not bringing wsh.f into kernel but + simply to use the 'definition' vocabulary command to redefine special words into the 'forth' + vocabulary. Thus even the forth word-list has higher priority than wsh.f the older + include/sinclude commands won't be unexpectedly used. + ==> Test, what happen after forget to --wsh.f-- marker? .... new words will be forgotten. [x] Hotkey F10 needs two press to make one effect. Try to print 'F10' at beginning of the handler - sees the same thing <==== check again. - ==> Now I am sure, root cause is the focus has gone to HTA's menu bar due to F10. - Under a condition, F10 can disable by this way ==> (https://www.evernote.com/shard/s22/sh/205fe9d0-4c7f-41db-a33a-98aacbc91a01/39cc5075538a71b51d150c24af8b9663) - , must be document.onkeydown not .onkeypress. So as to take over the control. + sees the same thing <==== check again. + ==> Now I am sure, root cause is the focus has gone to HTA's menu bar due to F10. + Under a condition, F10 can disable by this way ==> (https://www.evernote.com/shard/s22/sh/205fe9d0-4c7f-41db-a33a-98aacbc91a01/39cc5075538a71b51d150c24af8b9663) + , must be document.onkeydown not .onkeypress. So as to take over the control. [x] Hotkey handler should not be in input box. Because input box will be hide when rows <= 0 therefore - no way to get focus and then no way to get it back. + no way to get focus and then no way to get it back. [x] Source code file should not use "UTF-8 file with BOM" format, - jsc>stack[0].charCodeAt(0) ==> 22172 (number) - jsc>stack[0].charCodeAt(1) ==> 29854 (number) - As shown above, leading bytes become problem. + jsc>stack[0].charCodeAt(0) ==> 22172 (number) + jsc>stack[0].charCodeAt(1) ==> 29854 (number) + As shown above, leading bytes become problem. [x] jsc support Esc as the 'q' command equivlant. [x] see kvm.fso ==> JavaScript error on word "(see)" : Object doesn't support this property or method - ==> RI: print(tab + dictionary[i] + ...) 時,某些 object 沒有 .toString() 無法做 + operation. - ==> 應該幫所有不具 toString() method 的 object 都加上 toString()。 <=== Not allowed! - e.g. kvm.fso.FolderExists() is a method in fso. 但用 jsc 去檢查 kvm.fso.FolderExists 結果是 undefined! - 所有未知的 object 真不知道該怎麼 see ??? [x] <=== Node.js 的 console.log() 很好! + ==> RI: print(tab + dictionary[i] + ...) 時,某些 object 沒有 .toString() 無法做 + operation. + ==> 應該幫所有不具 toString() method 的 object 都加上 toString()。 <=== Not allowed! + e.g. kvm.fso.FolderExists() is a method in fso. 但用 jsc 去檢查 kvm.fso.FolderExists 結果是 undefined! + 所有未知的 object 真不知道該怎麼 see ??? [x] <=== Node.js 的 console.log() 很好! [x] Constant() 能不能也屬於 Word()? 一致,且 see() 較簡單。 ==> 不 merge, 但一併考慮。 [x] dump, see, dot, print 功能重複,疊床架屋 ==> 慢慢適應吧! [x] subFolders helps redefine sinclude and include ... failed! - ha ha bug. + ha ha bug. [x] help without pattern prints hotkey helps. @@ -751,255 +751,255 @@ [ ] Output box 2 and input box 2, dual pannel like Norton commander. [x] List elements of outputbox. - []nodes ( ele n -- array ) Beginning n nodes of the element - nodes[] ( ele n -- array ) Ending n nodes of the element + []nodes ( ele n -- array ) Beginning n nodes of the element + nodes[] ( ele n -- array ) Ending n nodes of the element [x] mimic processing.js, setup an environment. Say canvas.f, setup{} and draw{} - So that we'll be familiar with canvas programming and go on completing the clock. - Study clock.f first... Done! see p5.f, clock3.f + So that we'll be familiar with canvas programming and go on completing the clock. + Study clock.f first... Done! see p5.f, clock3.f [x] 用了那麼多 kvm.var 能不能利用 eval() & arguments.callee 來隨時增加 vm 內部的 global variable? - ==> No way. + ==> No way. [ ] {backSpace} 的 bottom up 跟 top down 程式都類似,可以再簡化。 - [x] 用來清理 outputbox 畫面,在 Node-webkit jsc 裡無效。 - 記得在以前也碰過同樣問題,原因是判斷 inputbox 是否 empty 時它並非 empty 而是有個 0x0A 留在 - 裡面。<==== 不該多個 LF,處理 inputbox 的程式有問題。不要妥協! - --> 可能是 Node-webkit 的問題 $('#inputbox').focus(); 有嫌疑 <=== 捅不出來,可能不是。 - 進 jsc 一律把 inputbox.value="" 也是簡單的辦法。 <==== 就這麼用補的治好了。 + [x] 用來清理 outputbox 畫面,在 Node-webkit jsc 裡無效。 + 記得在以前也碰過同樣問題,原因是判斷 inputbox 是否 empty 時它並非 empty 而是有個 0x0A 留在 + 裡面。<==== 不該多個 LF,處理 inputbox 的程式有問題。不要妥協! + --> 可能是 Node-webkit 的問題 $('#inputbox').focus(); 有嫌疑 <=== 捅不出來,可能不是。 + 進 jsc 一律把 inputbox.value="" 也是簡單的辦法。 <==== 就這麼用補的治好了。 [x] Now jeforth.3hta default is float instead of integer. Try input 123.456 .s and 0x7fffff .s - This is for HTML5 canvas. + This is for HTML5 canvas. [x] words and help need options, - -n for matching only name pattern, case insensitive. - -N for exactly name only, case sensitive. - -v for matching vocabulary, case insensitive. - ===> jeforth.f (words) [x] debug version, Add one more input 'option' to (words) - ===> modify voc.f to distinguish options. + -n for matching only name pattern, case insensitive. + -N for exactly name only, case sensitive. + -v for matching vocabulary, case insensitive. + ===> jeforth.f (words) [x] debug version, Add one more input 'option' to (words) + ===> modify voc.f to distinguish options. [x] Other than we need a command to generate header element. - ==> for ouputbox, for head, element append to the element - ==> done! now go back to complete the clock.f improvement. + ==> for ouputbox, for head, element append to the element + ==> done! now go back to complete the clock.f improvement. [x] Stop F2 hotkey to change the textarea size [x] canvas.f better to put the canvas below the inputbox textarea, easier to see it all the time. [x] Re-write clock2.f with an strong arm of canvas.f [x] Different textarea background color for different EditModes. Modify the style in jeforth.hta - ==> review how do I modify canvas style in canvas.f --> simply modify ele.innerHTML - ==> try to view jeforth.hta style --> id=style ok --> js> style obj>keys . ok - ==> style element is just like other elements having all those object members. - The problem is all 3 sections (body, textarea:focus, and textarea) are in the same style element. - If I only want to modify one, how to do that? - [x] Create a new style in may work. ==> No. - [x] Try modify 'style' itself. --> Bingo!! - - body { - font-family: courier new; - font-size: 20px; - padding:20px; - word-wrap:break-word; - border: 1px ridge; - background:#F0F0F0; - } - textarea { - font-family: courier new; - color:black; - font-size: 20px; - width:100%; - border: 0px solid; - background:#BBBBBB; - } - textarea:focus { - border: 0px solid; - background:#FFE0E0; Pink or #F0E0E0; Gray - } - js> style.innerHTML=pop() - [x] Try to make a new style to modify only textarea:focus --> Failed - drop - - textarea:focus { - border: 0px solid; - background:#E0F0E0; - } - js> newStyle.innerHTML=pop() - [x] A separate style in jeforth.hta for textarea:focus --> ok! + ==> review how do I modify canvas style in canvas.f --> simply modify ele.innerHTML + ==> try to view jeforth.hta style --> id=style ok --> js> style obj>keys . ok + ==> style element is just like other elements having all those object members. + The problem is all 3 sections (body, textarea:focus, and textarea) are in the same style element. + If I only want to modify one, how to do that? + [x] Create a new style in may work. ==> No. + [x] Try modify 'style' itself. --> Bingo!! + + body { + font-family: courier new; + font-size: 20px; + padding:20px; + word-wrap:break-word; + border: 1px ridge; + background:#F0F0F0; + } + textarea { + font-family: courier new; + color:black; + font-size: 20px; + width:100%; + border: 0px solid; + background:#BBBBBB; + } + textarea:focus { + border: 0px solid; + background:#FFE0E0; Pink or #F0E0E0; Gray + } + js> style.innerHTML=pop() + [x] Try to make a new style to modify only textarea:focus --> Failed + drop + + textarea:focus { + border: 0px solid; + background:#E0F0E0; + } + js> newStyle.innerHTML=pop() + [x] A separate style in jeforth.hta for textarea:focus --> ok! [x] 應該把 jeforth.3wsh jeforth.3hta jeforth.3nd jeforth.3nw jeforth.3htm 五套融合成一套,共享所有的 .f 檔。 - ==> jeforth.3we + ==> jeforth.3we [x] canvas.f works on kvm.cv is good, so we can work on many CV's. - But it needs an assignment process, instead of being the default only one. - ==> 3htm/canvas/canvas.f done + But it needs an assignment process, instead of being the default only one. + ==> 3htm/canvas/canvas.f done [ ] Reviewed Processing.js, try to go through "~\Dropbox\learnings\processing\Pomax's guide to Processing.js.pdf" - practice on jeforth.hta --> working on playground\p5.f + practice on jeforth.hta --> working on playground\p5.f [ ] html5.f does not have self-test yet. was wrong when in compiling mode, now fixed. [x] To support multiple canvas, clock2.f timeout() needs fine tune. [x] see 把 canvas object 都鑽進去印出來,太多了當掉。 - ==> js> window (see) 即可複製該問題。 - ==> Simplify function see() in jeforth.js + ==> js> window (see) 即可複製該問題。 + ==> Simplify function see() in jeforth.js [x] clock3.f seems ok, but only the last clock can run. - By my debugging logic, make a simplified case to try. - : hi me ." Hello " js> setTimeout(pop().xt,1000) . space ; last execute - Hello 141 OK Hello 142 Hello 143 Hello 144 Hello 145 \ 這個OK - : wo me ." world!" js> setTimeout(pop().xt,1000) . space ; \ 才剛定義好新的 word 不論 colon word 或 code word - world!376 world!377 world!378 world!379 world!380 . . . \ 都會變成下一個 timeout 被執行的對象! - ' wo ' hi js> pop().xt=pop().xt \ 如果以為是 xt 的問題,錯! colon word 的 xt 即使是同一個一切依然 - 連新定義出來的 code word 也會被 timeout 到,這就是線索了! - 不要懷疑 timeout 收到的 function. 成功過就對了。 奇怪的是,為何總是執行最後一個 word 的 xt ? - 直接定義一個 ' hi timeout(pop().xt,1000) 來試呀! 果然複製出問題了。 - - 結論是 colon word 的 xt 如果這樣執行 ' hi js> pop().xt() 就沒問題,因為參考到的正是 colon word object 本身無誤。 - 如果 ' hi js> pop().xt execute 這樣執行就令人困惑了。困惑不如實測證實, - code tt11 print("he he he 112233") end-code \ 故意弄一個 code word 當成 last - js> inner(this.cfa) \ 直接執行 colon word 之 xt 裡的這行 - he he he 112233 OK \ 果然就是這樣! - - 結論是 colon word 的 xt 不能用來當 call back function 用。這下問題來了,colon word 有 recentcolonword - 可以取得本身的 object 那麼 code word 呢?抄 recentcolonword 的定義即可,這表示 code word 的自身 object - 就是 this. 實驗看看: - code ttestt push(this) end-code ttestt . ==> 果然無誤 Bingo! - 進一步弄成利用 timeout 重複執行的 code word, - code rr print(Date()); setTimeout(this.xt,1000) end-code 執行後,第一個 timeout 有印出 Date() 但是 - 隨後的 setTimeout() 造成 run time error 'invalid argument'. 我怕是其中的 this 到時候變成別的東西,沒 - 有 xt 造成 error 凸顯問題反而是好事。嘗試從 JavaScript 的 recursive 裡找答案 ==> arguments.callee - code rr print(Date()); setTimeout(arguments.callee,1000) end-code ==> 徹底成功了!!! - - [x] ==> 這下子,clock3.f 的 '時鐘' 產生的 colon word 要如何包裝成 function() 來當 call back function? - ==> colon words can be executed by inner(cfa), thus - code t inner(2730);setTimeout(arguments.callee,1000) end-code last execute - can launch the clock correctly. Where 2730 is Taipei's cfa. - ==> 取得 colon word 本身的 cfa 有兩法 - 1)colon word 裡一見面 me/recentcolonword js> pop().cfa 即是 - 2)colon word 裡一見面 js> ip 2- 也是 - 前者若是由 call-back-function 透過 inner() 發動的,就會出錯!!! - [x] 實驗看看。可能 recentcolonword 要另想更好的辦法。 - ==> -1 時鐘 tokyo - ' tokyo js> pop().cfa dump - 02739: 2693 (number) - 02740: -3600000 (number) - ... snip ... - code t2 inner(2739);setTimeout(arguments.callee,1000) end-code last execute - 成功地 run 出第二個時鐘了! + By my debugging logic, make a simplified case to try. + : hi me ." Hello " js> setTimeout(pop().xt,1000) . space ; last execute + Hello 141 OK Hello 142 Hello 143 Hello 144 Hello 145 \ 這個OK + : wo me ." world!" js> setTimeout(pop().xt,1000) . space ; \ 才剛定義好新的 word 不論 colon word 或 code word + world!376 world!377 world!378 world!379 world!380 . . . \ 都會變成下一個 timeout 被執行的對象! + ' wo ' hi js> pop().xt=pop().xt \ 如果以為是 xt 的問題,錯! colon word 的 xt 即使是同一個一切依然 + 連新定義出來的 code word 也會被 timeout 到,這就是線索了! + 不要懷疑 timeout 收到的 function. 成功過就對了。 奇怪的是,為何總是執行最後一個 word 的 xt ? + 直接定義一個 ' hi timeout(pop().xt,1000) 來試呀! 果然複製出問題了。 + + 結論是 colon word 的 xt 如果這樣執行 ' hi js> pop().xt() 就沒問題,因為參考到的正是 colon word object 本身無誤。 + 如果 ' hi js> pop().xt execute 這樣執行就令人困惑了。困惑不如實測證實, + code tt11 print("he he he 112233") end-code \ 故意弄一個 code word 當成 last + js> inner(this.cfa) \ 直接執行 colon word 之 xt 裡的這行 + he he he 112233 OK \ 果然就是這樣! + + 結論是 colon word 的 xt 不能用來當 call back function 用。這下問題來了,colon word 有 recentcolonword + 可以取得本身的 object 那麼 code word 呢?抄 recentcolonword 的定義即可,這表示 code word 的自身 object + 就是 this. 實驗看看: + code ttestt push(this) end-code ttestt . ==> 果然無誤 Bingo! + 進一步弄成利用 timeout 重複執行的 code word, + code rr print(Date()); setTimeout(this.xt,1000) end-code 執行後,第一個 timeout 有印出 Date() 但是 + 隨後的 setTimeout() 造成 run time error 'invalid argument'. 我怕是其中的 this 到時候變成別的東西,沒 + 有 xt 造成 error 凸顯問題反而是好事。嘗試從 JavaScript 的 recursive 裡找答案 ==> arguments.callee + code rr print(Date()); setTimeout(arguments.callee,1000) end-code ==> 徹底成功了!!! + + [x] ==> 這下子,clock3.f 的 '時鐘' 產生的 colon word 要如何包裝成 function() 來當 call back function? + ==> colon words can be executed by inner(cfa), thus + code t inner(2730);setTimeout(arguments.callee,1000) end-code last execute + can launch the clock correctly. Where 2730 is Taipei's cfa. + ==> 取得 colon word 本身的 cfa 有兩法 + 1)colon word 裡一見面 me/recentcolonword js> pop().cfa 即是 + 2)colon word 裡一見面 js> ip 2- 也是 + 前者若是由 call-back-function 透過 inner() 發動的,就會出錯!!! + [x] 實驗看看。可能 recentcolonword 要另想更好的辦法。 + ==> -1 時鐘 tokyo + ' tokyo js> pop().cfa dump + 02739: 2693 (number) + 02740: -3600000 (number) + ... snip ... + code t2 inner(2739);setTimeout(arguments.callee,1000) end-code last execute + 成功地 run 出第二個時鐘了! [ ] The jeforth.js global variable 'context' is useless. When no vocabulary, context is 'forth'. - When with vocabulary, forth get-context command replaces the old context command. So why do we - have the 'context' command? ===> ask FigTaiwan + When with vocabulary, forth get-context command replaces the old context command. So why do we + have the 'context' command? ===> ask FigTaiwan [ ] current_word_list() defined in jeforth.js 應該是為了嫌 words[current] 有點 proprietary 而設。 - 實際上 words[current] 還是有在用,那何必有 current_word_list()? 乾脆取消。 + 實際上 words[current] 還是有在用,那何必有 current_word_list()? 乾脆取消。 [x] new Word() 馬上會把 new word 加進 wordhash{},這無可厚非沒什麼不對。萬一 colon definition 失敗 - words[current].pop() 把 last 丟掉之後,只能 rescan-word-hash 才能恢復 reDef 被蓋掉的 original. + words[current].pop() 把 last 丟掉之後,只能 rescan-word-hash 才能恢復 reDef 被蓋掉的 original. [x] 取得 colon word 本身的 cfa 有兩法 - 1)colon word 裡一見面 me/recentcolonword js> pop().cfa 即是 - 2)colon word 裡一見面 js> ip 2- 也是 - 前者若是由 call-back-function 透過 inner() 發動的,就會出錯!!! - [x] 實驗看看。可能 recentcolonword 要另想更好的辦法。==> the two statements - push(newname); execute("(create)"); - in ';' definition should be moved to ':' , so we have last() in colon definition. - To drop the last use words[current].pop() when something wrong. words[current].pop() - 把 last 丟掉之後,只能 rescan-word-hash 才能恢復 reDef 被蓋掉的 original. - --> try :: and ;; - ==> 要用 last 取得 colon word 自身時,要注意 last 必須 immediate! - 正確寫法是 :: myself [ last ] literal ;; - ==> [x] 基本上 ok 但是過不了 selftest, selftest 好耶! - 問題出在 sinclude 的定義裡會用到原來的 sinclude, 此時新定義的 sinclude 已經在 wordhash - 裡取代了,故造成無窮迴路。 - ==> 所以,一直以來 new Word() 直接把 newword 加進 wordhash 的作法有問題。要讓 ; 來做此事。 - See ebook <> @ https://www.evernote.com/shard/s22/nl/2472143/e572d6b8-8e2c-44bf-8d9b-e916ac0f9a2c - 有提到此事,果然就是用舊版 word 定義新版時、或者 recurse 時會碰到的問題。傳統 forth 用 hide - reveal 這一對開關來解決。我的 jeforth 不直接從 words[] 裡找 word 而是用 wordhash hash table, - 故控制 new word 加進 wordhash 的時機也是一樣的效果。 - ==> 改掉 Word() 不要自動加 newname 進 wordhash, 增加新 command 'reveal' 用來把 newname 加進 - wordhash. ==> done! - ==> 原來用到 recentcolonword 的地方都找出來改掉 + 1)colon word 裡一見面 me/recentcolonword js> pop().cfa 即是 + 2)colon word 裡一見面 js> ip 2- 也是 + 前者若是由 call-back-function 透過 inner() 發動的,就會出錯!!! + [x] 實驗看看。可能 recentcolonword 要另想更好的辦法。==> the two statements + push(newname); execute("(create)"); + in ';' definition should be moved to ':' , so we have last() in colon definition. + To drop the last use words[current].pop() when something wrong. words[current].pop() + 把 last 丟掉之後,只能 rescan-word-hash 才能恢復 reDef 被蓋掉的 original. + --> try :: and ;; + ==> 要用 last 取得 colon word 自身時,要注意 last 必須 immediate! + 正確寫法是 :: myself [ last ] literal ;; + ==> [x] 基本上 ok 但是過不了 selftest, selftest 好耶! + 問題出在 sinclude 的定義裡會用到原來的 sinclude, 此時新定義的 sinclude 已經在 wordhash + 裡取代了,故造成無窮迴路。 + ==> 所以,一直以來 new Word() 直接把 newword 加進 wordhash 的作法有問題。要讓 ; 來做此事。 + See ebook <> @ https://www.evernote.com/shard/s22/nl/2472143/e572d6b8-8e2c-44bf-8d9b-e916ac0f9a2c + 有提到此事,果然就是用舊版 word 定義新版時、或者 recurse 時會碰到的問題。傳統 forth 用 hide + reveal 這一對開關來解決。我的 jeforth 不直接從 words[] 裡找 word 而是用 wordhash hash table, + 故控制 new word 加進 wordhash 的時機也是一樣的效果。 + ==> 改掉 Word() 不要自動加 newname 進 wordhash, 增加新 command 'reveal' 用來把 newname 加進 + wordhash. ==> done! + ==> 原來用到 recentcolonword 的地方都找出來改掉 [x] jeforth.f has a problem "如果不 writeBinaryFile [x] 好像 wmi.f 會有 error ????" - that made me to use writeBinaryFile command which is not defined yet in jeforth.f - ==> jeforth.hta used to use fso, but fso doesn't support utf-8, ANSI only. My souce code and - actual printed strings were having utf-8. bla bla bla, that's the problem. - Fixed by using ADO that supports utf-8. + that made me to use writeBinaryFile command which is not defined yet in jeforth.f + ==> jeforth.hta used to use fso, but fso doesn't support utf-8, ANSI only. My souce code and + actual printed strings were having utf-8. bla bla bla, that's the problem. + Fixed by using ADO that supports utf-8. [x] 大目標!改寫 jsEval jsEvalNo ([x] jsEvalRaw is useless) 讓他們在 compiling mode 時直接 compile 成 - function("jsEvalNo") 或 function(jsEval;push(lastStatement))。靈感來自 p5.f 裡的 call back function. - : processing ( -- ) \ Processing main loop - [ s" push(function(){inner(" js> last().cfa + s" )})" + jsEvalNo ] literal ( -- callBackFunction ) - frameInterval [ s" push(function(){setTimeout(pop(1),pop())})" jsEvalNo , ] - frameCount 1+ to frameCount draw - ; last execute - 其中有取得 call back function 放在 TOS 的範例,以及直接 compile 一個 function 的範例。 - ==> This regEx works fine : s" aaaaa;bbbb;ccc" js> pop().match(/^(.*;)(.*)$/) . - Returns [entire string,fore part,last statement] - Note 1. when there's no ';' the result is NULL. - 2. Nothing or only \s after the last ';' the result is [entire string,entire - string w/o ending \s,NULL] 此時用 - 3. normal "aaa;bbb;ccc" - 這樣狀況有種嫌太多了。 - ==> 先把尾部的 ";\s*$" 消除。統一狀況。 - s" aaaaa;bbbb;ccc;;; " js> "\n\t\r" + js> pop().replace(/;*(\s+)$/,'') . \ the end - ==> 整合起來,最後只剩兩種狀況 - s" aaa;bbb;ccc" js> "\n\t\r" + js> pop().replace(/;*(\s+)$/,'') js> pop().match(/^(.*;)(.*)$/) . - Note 1. when there's no previous ';' the result is NULL. ==> 整行抓去用 - 2. otherwise the result is [entire string,fore part,last statement] - 這樣簡單多了。 - - : jsFunc ( "statements" -- function ) \ Compile JavaScript to a function() that returns last statement - js> pop().replace(/^\s*/,'') - js> pop().replace(/;*\s*$/,'') dup - js> pop().match(/^(.*;)(.*)$/) ?dup \ statement [entire string,fore part,last statement]|NULL - if \ statement [entire string,fore part,last statement] - nip - s" push(function(){" js> tos(1)[1] + - s" push(" + js> pop(1)[2] + s" )" + - s" })" + - jsEvalNo - else \ statement - s" push(function(){push(" swap + s" )})" + - jsEvalNo - then ; - - : jsFuncNo ( "statements" -- function ) \ Compile JavaScript to a function() - s" push(function(){" swap + s" })" + jsEvalNo ; - - [x] jsEval jsEvalNo 保留不改,新增命令 jsFunc jsFuncNo。 先完成 jsFuncNo - ( "js statements" -- function ) + function("jsEvalNo") 或 function(jsEval;push(lastStatement))。靈感來自 p5.f 裡的 call back function. + : processing ( -- ) \ Processing main loop + [ s" push(function(){inner(" js> last().cfa + s" )})" + jsEvalNo ] literal ( -- callBackFunction ) + frameInterval [ s" push(function(){setTimeout(pop(1),pop())})" jsEvalNo , ] + frameCount 1+ to frameCount draw + ; last execute + 其中有取得 call back function 放在 TOS 的範例,以及直接 compile 一個 function 的範例。 + ==> This regEx works fine : s" aaaaa;bbbb;ccc" js> pop().match(/^(.*;)(.*)$/) . + Returns [entire string,fore part,last statement] + Note 1. when there's no ';' the result is NULL. + 2. Nothing or only \s after the last ';' the result is [entire string,entire + string w/o ending \s,NULL] 此時用 + 3. normal "aaa;bbb;ccc" + 這樣狀況有種嫌太多了。 + ==> 先把尾部的 ";\s*$" 消除。統一狀況。 + s" aaaaa;bbbb;ccc;;; " js> "\n\t\r" + js> pop().replace(/;*(\s+)$/,'') . \ the end + ==> 整合起來,最後只剩兩種狀況 + s" aaa;bbb;ccc" js> "\n\t\r" + js> pop().replace(/;*(\s+)$/,'') js> pop().match(/^(.*;)(.*)$/) . + Note 1. when there's no previous ';' the result is NULL. ==> 整行抓去用 + 2. otherwise the result is [entire string,fore part,last statement] + 這樣簡單多了。 + + : jsFunc ( "statements" -- function ) \ Compile JavaScript to a function() that returns last statement + js> pop().replace(/^\s*/,'') + js> pop().replace(/;*\s*$/,'') dup + js> pop().match(/^(.*;)(.*)$/) ?dup \ statement [entire string,fore part,last statement]|NULL + if \ statement [entire string,fore part,last statement] + nip + s" push(function(){" js> tos(1)[1] + + s" push(" + js> pop(1)[2] + s" )" + + s" })" + + jsEvalNo + else \ statement + s" push(function(){push(" swap + s" )})" + + jsEvalNo + then ; + + : jsFuncNo ( "statements" -- function ) \ Compile JavaScript to a function() + s" push(function(){" swap + s" })" + jsEvalNo ; + + [x] jsEval jsEvalNo 保留不改,新增命令 jsFunc jsFuncNo。 先完成 jsFuncNo + ( "js statements" -- function ) [x] objRet in jeforth.f 還有用嗎? ==> 有用。 [ ] 當 marker 是個 vocabulary 時,順便 previous 把多出來的 forth drop 掉。 - ==> 改 voc.f (marker) 應該很簡單。Selftest 的測法可能造成問題。 - ==> 改 --filename.f-- 的定義才對。只有 --filename.f-- 這類 marker 才可以做 previous。 + ==> 改 voc.f (marker) 應該很簡單。Selftest 的測法可能造成問題。 + ==> 改 --filename.f-- 的定義才對。只有 --filename.f-- 這類 marker 才可以做 previous。 [x] merge.f 的「對話表」可以一次全部印出來。HTML 可以回頭補任意位置的內容,只要在 - 資料不全時把 [Go!] 灰掉即可。 + 資料不全時把 [Go!] 灰掉即可。 [x] Working on playground/merge2.f ==> Done!! [x] Merge.f 很好用。其他 excel 的程式也該 port 到 jeforth.3hta 來! - ==> 拆分混合個部門的總表成多個 Excel 檔。===> split.f done!! + ==> 拆分混合個部門的總表成多個 Excel 檔。===> split.f done!! [ ] Very very strange thing: - jsc>kvm.dictionary - Oooops! Object doesn't support this property or method - jsc>kvm.stack - Oooops! Object doesn't support this property or method - ===> 又是 see 的問題,嘗試顯示出來時失敗的現象。 + jsc>kvm.dictionary + Oooops! Object doesn't support this property or method + jsc>kvm.stack + Oooops! Object doesn't support this property or method + ===> 又是 see 的問題,嘗試顯示出來時失敗的現象。 -------------- jeforth for node.js console mode ---------------------- [x] jeforth.3we 就是這樣來的! - 我計畫讓 Windows 下所有的 jeforth.3xxx 都共享同樣的 source code , 如 jeforth.js, jeforth.f 等。 - node.js 版的 jeforth.js 有這行, - exports.constructor = KsanaVm; - 到時候是用 require() 讀進去的,希望 require 接受 string。我就可以用加的把這行加進去。 - ==> 爽哥的 ~\multitaskjavascripteforth-master\jeForthVM.js 似乎有解, + 我計畫讓 Windows 下所有的 jeforth.3xxx 都共享同樣的 source code , 如 jeforth.js, jeforth.f 等。 + node.js 版的 jeforth.js 有這行, + exports.constructor = KsanaVm; + 到時候是用 require() 讀進去的,希望 require 接受 string。我就可以用加的把這行加進去。 + ==> 爽哥的 ~\multitaskjavascripteforth-master\jeForthVM.js 似乎有解, - if (typeof exports==='undefined') window .jeForthVM=jeForthVM // export for web cliend APP - else exports.jeForthVM=jeForthVM // export for node.js APP + if (typeof exports==='undefined') window .jeForthVM=jeForthVM // export for web cliend APP + else exports.jeForthVM=jeForthVM // export for node.js APP - As shown above, node.js 'exports' is a system object not a 宣告指令。 + As shown above, node.js 'exports' is a system object not a 宣告指令。 [x] readTextFile is from jeforth.hta, needs to be defined in index.js [x] bye is platform dependent. Needs kvm.bye() - code bye ( ERRORLEVEL -- ) \ Exit to shell with TOS as the ERRORLEVEL. - var errorlevel = pop(); - errorlevel = typeof(errorlevel)=='number' ? errorlevel : 0; - kvm.bye(errorlevel); - end-code + code bye ( ERRORLEVEL -- ) \ Exit to shell with TOS as the ERRORLEVEL. + var errorlevel = pop(); + errorlevel = typeof(errorlevel)=='number' ? errorlevel : 0; + kvm.bye(errorlevel); + end-code jeforth.hta can return ERRORLEVEL to its caller batch program, but not DOS box. I repeat, TOS as errorlevel only works in batch program. This is the experiment: @@ -1014,518 +1014,518 @@ 77 [x] 這個要想一想。定樣在 jeforth.hta 中的 kvm 是個 global 可以反過來在 jeforth.js 裡看得見。 - 但是定義在 node.js 的 index.js 裡的 kvm, fs 等則不然。既然 kvm 跟 KsanaVm() 裡面參考自己的 - vm 是同一個,何不在 jeforth.js 裡直接就稱為 kvm?如果還是照以前稱為 vm 就得像下面這般繁複地 - 補救。 - function KsanaVm() { - var vm = this; // "this" is very confusing to me. Now I am sure 'vm' is 'kvm'. - if(typeof(kvm)=="undefined"){var kvm=vm} // kvm defined in jeforth.hta is visible but not node.js index.js - ...snip.... - 稱為 vm 目的可能是想跑 multiple VM. 這點我看是不會發生了。但讓 global 的 kvm 跟 closure 裡的 kvm - 同名,也有點令人不安。繁複就繁複吧! + 但是定義在 node.js 的 index.js 裡的 kvm, fs 等則不然。既然 kvm 跟 KsanaVm() 裡面參考自己的 + vm 是同一個,何不在 jeforth.js 裡直接就稱為 kvm?如果還是照以前稱為 vm 就得像下面這般繁複地 + 補救。 + function KsanaVm() { + var vm = this; // "this" is very confusing to me. Now I am sure 'vm' is 'kvm'. + if(typeof(kvm)=="undefined"){var kvm=vm} // kvm defined in jeforth.hta is visible but not node.js index.js + ...snip.... + 稱為 vm 目的可能是想跑 multiple VM. 這點我看是不會發生了。但讓 global 的 kvm 跟 closure 裡的 kvm + 同名,也有點令人不安。繁複就繁複吧! [x] Word.help 尾巴都有個 \r\n 要拿掉。 - OK ' + js> pop().help - OK .s - 0: + ( a b -- a+b) Add two numbers or concatenate two strings. - (string) <=== This is the clue of that there's something like \r\n at the end - > dup binary-string>array <=== defined in 80286asm.f, useful here. - OK .s - 0: + ( a b -- a+b) Add two numbers or concatenate two strings. - (string) - 1: 43,32,40,32,97,32,98,32,45,45,32,97,43,98,41,32,65,100,100,32,116,119,111,32,110,117,109,98,101,114,115,32,111, - 114,32,99,111,110,99,97,116,101,110,97,116,101,32,116,119,111,32,115,116,114,105,110,103,115,46,13 (array) - OK - ==> The ending is a \r (13) , remove it ! jeforth.js I guess. + OK ' + js> pop().help + OK .s + 0: + ( a b -- a+b) Add two numbers or concatenate two strings. + (string) <=== This is the clue of that there's something like \r\n at the end + > dup binary-string>array <=== defined in 80286asm.f, useful here. + OK .s + 0: + ( a b -- a+b) Add two numbers or concatenate two strings. + (string) + 1: 43,32,40,32,97,32,98,32,45,45,32,97,43,98,41,32,65,100,100,32,116,119,111,32,110,117,109,98,101,114,115,32,111, + 114,32,99,111,110,99,97,116,101,110,97,116,101,32,116,119,111,32,115,116,114,105,110,103,115,46,13 (array) + OK + ==> The ending is a \r (13) , remove it ! jeforth.js I guess. [x] nexttoken('RegEx string') escape string and RegEd work together can be a little strange. - Sometimes simply JS escape string works fine like : nexttoken('\r|\n') - Sometimes we need to double the back slash like : nexttoken('\\)\\)') - Because what we want from the front one is '#13','|','#10' and it works fine. - Yet we want from the rear one is literally '\)\)' which can not be - nexttoken('))') nor nexttoken('\)\)'). + Sometimes simply JS escape string works fine like : nexttoken('\r|\n') + Sometimes we need to double the back slash like : nexttoken('\\)\\)') + Because what we want from the front one is '#13','|','#10' and it works fine. + Yet we want from the rear one is literally '\)\)' which can not be + nexttoken('))') nor nexttoken('\)\)'). [ ] vb.f 有了現在的 html5.f 可以改寫得更好。 [x] 讓 include 自動找目錄,不用等到 wsh.f ==> readTextFileAuto ( "pathname" -- file ) \ Search and read - ==> Use kvm.path=[...] to specify path space and the order. + ==> Use kvm.path=[...] to specify path space and the order. [ ] Ask FigTaiwan 請教先進。 jeforth 有這個問題。 - 發現一個 jeforth 的大大大問題。 exit 用來結束一個 colon word, 但是 exit 用在 for..next 裡面時 - 就不一樣了!要先 r> drop 才行吧?! ==> Yes!!! + 發現一個 jeforth 的大大大問題。 exit 用來結束一個 colon word, 但是 exit 用在 for..next 裡面時 + 就不一樣了!要先 r> drop 才行吧?! ==> Yes!!! [x] execute ( cmd -- ... ) command 針對 cmd==string 時,要順便把前後的 \s 去掉。 [x] ~\jeforth.3hta\playground\86ef202.f compile 出來,跑不起來。要重視原因! - ==> 懷疑是用 writeTextFile 有問題,checksum 其實一樣。 - d:\hcchen\Dropbox\learnings\github\jeforth.3hta>d:\Download\BATCH\SUM.EXE eforth.com - This program was written by Eddy Chuang 1991. - -- The checksum of file:eforth.com is '20633D' on base 16 -- - d:\hcchen\Dropbox\LEARNI~1\github\JEFORT~1.3HT> - - target-space 0x100 DICSIZE array-slice - var sum=0; for( var i=0; i<12032; i++) {sum+=tos()[i]}; sum - 1: 2122557 20633dh (number) - ==> 接下來用 symdeb.exe 檢查了。。。 --> COLD1: entry should be 1097h ( "see COLD1:" command ) - but symdeb traced it's 1200h - ==> 看到原因了!本來 (create) 現在要改成 (create) reveal !!! + ==> 懷疑是用 writeTextFile 有問題,checksum 其實一樣。 + d:\hcchen\Dropbox\learnings\github\jeforth.3hta>d:\Download\BATCH\SUM.EXE eforth.com + This program was written by Eddy Chuang 1991. + -- The checksum of file:eforth.com is '20633D' on base 16 -- + d:\hcchen\Dropbox\LEARNI~1\github\JEFORT~1.3HT> + + target-space 0x100 DICSIZE array-slice + var sum=0; for( var i=0; i<12032; i++) {sum+=tos()[i]}; sum + 1: 2122557 20633dh (number) + ==> 接下來用 symdeb.exe 檢查了。。。 --> COLD1: entry should be 1097h ( "see COLD1:" command ) + but symdeb traced it's 1200h + ==> 看到原因了!本來 (create) 現在要改成 (create) reveal !!! [x] include 80286asm.f 很奇怪,新舊版會夾雜的感覺。Source code 怎麼改都無效。總是 include 到舊版的! - ==> Run jeforth.hta new session then OK. + ==> Run jeforth.hta new session then OK. [x] The method 86ef202.f writes file to eforth.com needs think twice. - Node.js and nw can use writeTextFile, but I guess not on HTA. - ==> The reason why 3nd can use it is Node.js' global class Buffer(). It handles binary data. - So this project is 3nd and 3nw dependent! + Node.js and nw can use writeTextFile, but I guess not on HTA. + ==> The reason why 3nd can use it is Node.js' global class Buffer(). It handles binary data. + So this project is 3nd and 3nw dependent! [x] Many other .f files should be moved to hta/ They are all HTA dependent. - ==> Every platform has its own kvm.path space now. + ==> Every platform has its own kvm.path space now. [x] readTextFileAuto 自帶 platform dependent 的 path array, 不好。 - 應該有個 kvm.path 在 jeforth.3nd.js jeforth.html jeforth.hta 中定義好來,這樣才對。 - ==> 3hta, 3nw, 3nd, 3wsh, 3htm 意外的好處是這些 platform folder 都是 3 開頭,自然會聚在一起。 + 應該有個 kvm.path 在 jeforth.3nd.js jeforth.html jeforth.hta 中定義好來,這樣才對。 + ==> 3hta, 3nw, 3nd, 3wsh, 3htm 意外的好處是這些 platform folder 都是 3 開頭,自然會聚在一起。 [x] include 吃掉一整行,這樣並不好。 check the reason. - ==> RI, 因為 include test.f dsdf sfds 的 test.f 當中最後一行是 \ comment , 在 tib.insert - 之後,這個 comment 延續到之後去,造成這個結果。 - ==> 只要在 sinclude 裡,去掉 --EOF-- 之後,加一個 \n 到 file 最後即可。 + ==> RI, 因為 include test.f dsdf sfds 的 test.f 當中最後一行是 \ comment , 在 tib.insert + 之後,這個 comment 延續到之後去,造成這個結果。 + ==> 只要在 sinclude 裡,去掉 --EOF-- 之後,加一個 \n 到 file 最後即可。 [ ] The leading two lines in jeforth.3nd.js, FigTaiwan acadamic topic. - var z = require('./kernel/jeforth.js') - var kvm = z.kvm; - this means: the 'kvm' virtual machine object is and will be the only one. Older code was, - var z = require('./kernel/jeforth.js') - var kvm = new z.KsanaVm() // get the jeForth VM - which means KsanaVm() constructor can be used multiple times, I don't think so. + var z = require('./kernel/jeforth.js') + var kvm = z.kvm; + this means: the 'kvm' virtual machine object is and will be the only one. Older code was, + var z = require('./kernel/jeforth.js') + var kvm = new z.KsanaVm() // get the jeForth VM + which means KsanaVm() constructor can be used multiple times, I don't think so. [x] With selftest, 3nd can't show things after jeforth.f in the main .js - ==> Not "selftest-invisible" ---> try 1/2 sort.... Wow! strange. Post jeforth.f - instructions are executed when at the first *** command in selftest ! - ==> RI, because selftest '***' command uses 'sleep' command, that's why. Wow, jeforth - is amazing. The 'sleep' command really suspend the VM. - 當初 1 sleep 是為了要讓 selftest message 一行行地印出來,不要突然一下全倒出來。 - ==> 既然有 sleep, 表示我的 jeforth 裡 fortheval(jeforth.f) 這一行必須是最後一行。 - 很重要的大發現!否則,它後面的東西會被意外執行到。 - ==> So, the first OK prompt must be printed by jeforth.f not jeforth.3nd.js + ==> Not "selftest-invisible" ---> try 1/2 sort.... Wow! strange. Post jeforth.f + instructions are executed when at the first *** command in selftest ! + ==> RI, because selftest '***' command uses 'sleep' command, that's why. Wow, jeforth + is amazing. The 'sleep' command really suspend the VM. + 當初 1 sleep 是為了要讓 selftest message 一行行地印出來,不要突然一下全倒出來。 + ==> 既然有 sleep, 表示我的 jeforth 裡 fortheval(jeforth.f) 這一行必須是最後一行。 + 很重要的大發現!否則,它後面的東西會被意外執行到。 + ==> So, the first OK prompt must be printed by jeforth.f not jeforth.3nd.js [x] jsc for 3node. ( demo to FigTaiwan ) - How to switch Node.js readline.on() ? - ==> 應該可以,但非置入式地(也必定是 blocking 的)方式,光切換 forth / jsc 也沒啥用了。 - jeforth.hta has alert(), prompt(), confirm() that are blocking functions. - ==> 利用 kvm.stdio.question() 做成 macro kvm.jsc.xt 置入式地應用可以了。但 readline - is none-blocking, 結果還是沒有用。 - ==> 找到辦法了! http://stackoverflow.com/questions/3430939/node-js-readsync-from-stdin - So now I have kvm.gets() which is a blocking function. + How to switch Node.js readline.on() ? + ==> 應該可以,但非置入式地(也必定是 blocking 的)方式,光切換 forth / jsc 也沒啥用了。 + jeforth.hta has alert(), prompt(), confirm() that are blocking functions. + ==> 利用 kvm.stdio.question() 做成 macro kvm.jsc.xt 置入式地應用可以了。但 readline + is none-blocking, 結果還是沒有用。 + ==> 找到辦法了! http://stackoverflow.com/questions/3430939/node-js-readsync-from-stdin + So now I have kvm.gets() which is a blocking function. [/] jeforth.3nd can use kvm.gets() to support multiple line input! [x] These two files, - 2014/10/15 17:01 448 jsc.hlp - 2014/10/15 17:00 733 jsc.js - are not defined in jeforth.3nd.js directly because it's not convenient to define multiple - line string, as far as I know. jsc.js will go to kvm.jsc.xt in text form so it will be a - string too. + 2014/10/15 17:01 448 jsc.hlp + 2014/10/15 17:00 733 jsc.js + are not defined in jeforth.3nd.js directly because it's not convenient to define multiple + line string, as far as I know. jsc.js will go to kvm.jsc.xt in text form so it will be a + string too. - If use ... to define kvm.jsc.help and kvm.jsc.xt then sure it's easy but - then platform.f is supposed to do that. Then kvm.jsc life cycle will be delaied. I want - jsc to be available earlier before jeforth.f. + If use ... to define kvm.jsc.help and kvm.jsc.xt then sure it's easy but + then platform.f is supposed to do that. Then kvm.jsc life cycle will be delaied. I want + jsc to be available earlier before jeforth.f. [x] Node.js 本身的 REPL 可以 'see' object 效果超好,怎麼應用? - ==> 那是 console.log() 的效果。 考慮 3nd 的 print() 裡面應該就用 console.log() - ==> 找到了!用 util.inspect() or sys.inspect() for older Node.js systems. + ==> 那是 console.log() 的效果。 考慮 3nd 的 print() 裡面應該就用 console.log() + ==> 找到了!用 util.inspect() or sys.inspect() for older Node.js systems. [ ] FigTaiwan academic topic: - o jeforth can compile all function() into dictionary, instead of Word()'s. Hard to read the dictionary - tho'. - o jeforth can drop the inner() interpreter. Use functions unnest() next() like eforth.com - instead. + o jeforth can compile all function() into dictionary, instead of Word()'s. Hard to read the dictionary + tho'. + o jeforth can drop the inner() interpreter. Use functions unnest() next() like eforth.com + instead. [x] jeforth.3nd how to clear screen? - kvm.clearScreen = function(){console.log('\033c')} - '\033c' or '\033[2J' - http://stackoverflow.com/questions/9006988/node-js-on-windows-how-to-clear-console + kvm.clearScreen = function(){console.log('\033c')} + '\033c' or '\033[2J' + http://stackoverflow.com/questions/9006988/node-js-on-windows-how-to-clear-console [x] jeforth.hta (jeforth.commandLine + " ").split(/\s+/).slice(0,-1); // An array, 這麼麻煩是為了要自動把行尾的 white spaces 去掉。 - should use .replace() <=== No! the result is expected to be an array. The above method is smart. + should use .replace() <=== No! the result is expected to be an array. The above method is smart. --------------- jeforth for HTML ---------------------- hcchen5600 2014/10/16 10:45:41 +-------------- jeforth for HTML ---------------------- hcchen5600 2014/10/16 10:45:41 [x] 一開始寫 jeforth.3htm 馬上發現當初 jeforth.3hta 的網頁結構可以更合理。 - [x] kvm.platform = "3hta"; 直接改成 ==> kvm.appname = "jeforth.3hta" 因為本來就有用到。 - [x] HTA:APPLICATION 設定裡的 ID 稱為 jeforth 並不好用。應該成為 hta 更好懂。 + [x] kvm.platform = "3hta"; 直接改成 ==> kvm.appname = "jeforth.3hta" 因為本來就有用到。 + [x] HTA:APPLICATION 設定裡的 ID 稱為 jeforth 並不好用。應該成為 hta 更好懂。 [ ] jeforth.hta 執行時的 working directory 當成 root folder. 這限制了它的用法。 - c:\>node64 c:\Users\8304018.WKSCN\Dropbox\learnings\github\jeforth.3hta\jeforth.3nd.js - fs.js:427 - return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode); - ^ - Error: ENOENT, no such file or directory 'c:\3nd\jsc.hlp' <========== Problem! - at Object.fs.openSync (fs.js:427:18) - .... snip ..... + c:\>node64 c:\Users\8304018.WKSCN\Dropbox\learnings\github\jeforth.3hta\jeforth.3nd.js + fs.js:427 + return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode); + ^ + Error: ENOENT, no such file or directory 'c:\3nd\jsc.hlp' <========== Problem! + at Object.fs.openSync (fs.js:427:18) + .... snip ..... - 我的舊 jeforth.3nw 有解決過這個問題。 + 我的舊 jeforth.3nw 有解決過這個問題。 [ ] 有兩種 run jeforth.htm 的方法,透過 web server、從 local 直接 run. 看能不能兩種都 support? - 從 local 直接 run - 要解決 read data file 的問題,已經有解了。缺點是必須人工操作。 - https://www.evernote.com/shard/s22/nl/2472143/62b103ca-c162-48eb-99b3-eeecef88e2db + 從 local 直接 run + 要解決 read data file 的問題,已經有解了。缺點是必須人工操作。 + https://www.evernote.com/shard/s22/nl/2472143/62b103ca-c162-48eb-99b3-eeecef88e2db - 透過 web server 可能最合理。可用 Python one liner 當 server 很簡單。 - set path=c:\Program Files (x86)\OpenOffice 4\program; <== python.exe v2.7.5 is there - python -m SimpleHTTPServer 8888 - "Anonymous Person" provided the iframe solution, as URL below. I tried, it works fine. - http://stackoverflow.com/questions/12760852/how-to-access-plain-text-content-retrieved-via-script-type-text-plain-src - https://www.evernote.com/shard/s22/nl/2472143/f8a48817-933d-4681-a6bb-90eb10649fcd + 透過 web server 可能最合理。可用 Python one liner 當 server 很簡單。 + set path=c:\Program Files (x86)\OpenOffice 4\program; <== python.exe v2.7.5 is there + python -m SimpleHTTPServer 8888 + "Anonymous Person" provided the iframe solution, as URL below. I tried, it works fine. + http://stackoverflow.com/questions/12760852/how-to-access-plain-text-content-retrieved-via-script-type-text-plain-src + https://www.evernote.com/shard/s22/nl/2472143/f8a48817-933d-4681-a6bb-90eb10649fcd [x] 用 iframe 的方式 include text file, extended filename can not be .f or it will be saved to - local disk directly. 暫時改名 jeforth.f==>jeforth.txt, voc.f==>voc.txt - Study ... + local disk directly. 暫時改名 jeforth.f==>jeforth.txt, voc.f==>voc.txt + Study ... - The problem is similar to this page, - "Bug 235363 - When opening a .php file inside of an " + ( -- iframe ) - js: $(tos()).load(function(){execute('stopSleeping')}) 10000 sleep - js> tos().contentDocument.body.lastChild.innerText - swap removeElement ( -- string ) - js> tos().indexOf('404')!=-1 ( -- string 404? ) - tos(1).toLowerCase().indexOf('not found')!=-1 ( -- string 404? notFound? ) - js> tos(2).length<100 ( -- string 404? notFound? length<100 ) - and and if drop "" then - ; + : readTextFile ( "pathname" -- string ) \ "" if file not found + js> pop().replace(/^\s*|\s*$/g,'') \ remove white spaces + s" " + ( -- iframe ) + js: $(tos()).load(function(){execute('stopSleeping')}) 10000 sleep + js> tos().contentDocument.body.lastChild.innerText + swap removeElement ( -- string ) + js> tos().indexOf('404')!=-1 ( -- string 404? ) + tos(1).toLowerCase().indexOf('not found')!=-1 ( -- string 404? notFound? ) + js> tos(2).length<100 ( -- string 404? notFound? length<100 ) + and and if drop "" then + ; [x] char f/mytools.f readTextFile <=== failed, still run to the old one!! - cfa, creater, don't foget to replace xt too!! + cfa, creater, don't foget to replace xt too!! [x] improve the jeforth.htm iframe ready sequence. This is the recent working version, - // System initialization - jQuery(document).ready( - // jQuery convention, learned from W3School, make sure web page is ready. - function() { - jQuery('#readtextfilef').load( - // for iframes, use load() instead of ready(). http://stackoverflow.com/questions/205087/jquery-ready-in-a-dynamically-inserted-iframe - function() { - $('#rev').html(kvm.version); // also .commandLine, .applicationName, ... - $('#location').html(window.location.toString()); // it's built-in in DOM - $('.appname').html(kvm.appname); - document.onkeydown = hotKeyHandler; // Must be using onkeydown so as to grab the control. - kvm.init(); // setup platform related I/O - var kernel = jeforthf.contentDocument.body.lastChild.innerText; - jeforthf.parentElement.removeChild(jeforthf); // suicide - // jeforthf.contentDocument.body.lastChild.innerText=""; // 否則會不斷累積!不知是前後端哪一端的問題。 - kvm.fortheval(kernel); // Run jeforth.f once. - // fortheval() 之後不能再有任何東西,否則因為有 sleep/suspend/resume 之故,會被意外執行到。 - } - ) - } - ); - 下面這個方法 Chrome 下有時候會等不到! - // System initialization - jQuery(document).ready( - // jQuery convention, learned from W3School, make sure web page is ready. - function() { - $('#rev').html(kvm.version); // also .commandLine, .applicationName, ... - $('#location').html(window.location.toString()); // it's built-in in DOM - $('.appname').html(kvm.appname); - document.onkeydown = hotKeyHandler; // Must be using onkeydown so as to grab the control. - kvm.init(); - jQuery('#jeforthf').load( // for iframes, use load() instead of ready(). http://stackoverflow.com/questions/205087/jquery-ready-in-a-dynamically-inserted-iframe - function(){jQuery('#vocf').load(function(){jQuery('#selftestf').load( - function(){jQuery('#html5f').load(function(){jQuery('#readtextfilef').load( - function() { - var jef = jeforthf.contentDocument.body.lastChild.innerText; - var voc = vocf.contentDocument.body.lastChild.innerText; - var rea = readtextfilef.contentDocument.body.lastChild.innerText; - var htm = html5f.contentDocument.body.lastChild.innerText; - jeforthf.parentElement.removeChild(jeforthf); // suicide 否則會不斷累積! - vocf.parentElement.removeChild(vocf); // suicide - readtextfilef.parentElement.removeChild(readtextfilef); // suicide - html5f.parentElement.removeChild(html5f); // suicide - kvm.fortheval(jef+voc+rea+htm); // Run jeforth.f once. - // 之後不能再有任何東西,否則因為有 sleep/suspend/resume 之故,會被意外執行到。 - } - )})})})} - ) - } - ); - 改成這樣,還是會漏接: - // System initialization - var jef,voc,rea,htm,sel; jef=voc=rea=htm=sel=""; - jQuery('#jeforthf').load( - function() { - jef = jeforthf.contentDocument.body.lastChild.innerText; - jeforthf.parentElement.removeChild(jeforthf); // suicide 否則會不斷累積! - } - ); - jQuery('#vocf').load( - function() { - voc = vocf.contentDocument.body.lastChild.innerText; - vocf.parentElement.removeChild(vocf); // suicide 否則會不斷累積! - } - ); - jQuery('#selftestf').load( - function() { - sel = selftestf.contentDocument.body.lastChild.innerText; - selftestf.parentElement.removeChild(selftestf); // suicide 否則會不斷累積! - } - ); - jQuery('#html5f').load( - function() { - htm = html5f.contentDocument.body.lastChild.innerText; - html5f.parentElement.removeChild(html5f); // suicide 否則會不斷累積! - } - ); - jQuery('#readtextfilef').load( - function() { - rea = readtextfilef.contentDocument.body.lastChild.innerText; - readtextfilef.parentElement.removeChild(readtextfilef); // suicide 否則會不斷累積! - } - ); - jQuery(document).ready( - // jQuery convention, learned from W3School, make sure web page is ready. - function() { - $('#rev').html(kvm.version); // also .commandLine, .applicationName, ... - $('#location').html(window.location.toString()); // it's built-in in DOM - $('.appname').html(kvm.appname); - document.onkeydown = hotKeyHandler; // Must be using onkeydown so as to grab the control. - kvm.init(); - (function run(){ - if(sel&&jef&&voc&&htm&&rea){ - kvm.fortheval(jef+voc+htm+rea); - // 之後放東西要很小心,因為有 sleep 之故,會被意外執行到。 - } else setTimeout(run,100); - })(); - } - ); + // System initialization + jQuery(document).ready( + // jQuery convention, learned from W3School, make sure web page is ready. + function() { + jQuery('#readtextfilef').load( + // for iframes, use load() instead of ready(). http://stackoverflow.com/questions/205087/jquery-ready-in-a-dynamically-inserted-iframe + function() { + $('#rev').html(kvm.version); // also .commandLine, .applicationName, ... + $('#location').html(window.location.toString()); // it's built-in in DOM + $('.appname').html(kvm.appname); + document.onkeydown = hotKeyHandler; // Must be using onkeydown so as to grab the control. + kvm.init(); // setup platform related I/O + var kernel = jeforthf.contentDocument.body.lastChild.innerText; + jeforthf.parentElement.removeChild(jeforthf); // suicide + // jeforthf.contentDocument.body.lastChild.innerText=""; // 否則會不斷累積!不知是前後端哪一端的問題。 + kvm.fortheval(kernel); // Run jeforth.f once. + // fortheval() 之後不能再有任何東西,否則因為有 sleep/suspend/resume 之故,會被意外執行到。 + } + ) + } + ); + 下面這個方法 Chrome 下有時候會等不到! + // System initialization + jQuery(document).ready( + // jQuery convention, learned from W3School, make sure web page is ready. + function() { + $('#rev').html(kvm.version); // also .commandLine, .applicationName, ... + $('#location').html(window.location.toString()); // it's built-in in DOM + $('.appname').html(kvm.appname); + document.onkeydown = hotKeyHandler; // Must be using onkeydown so as to grab the control. + kvm.init(); + jQuery('#jeforthf').load( // for iframes, use load() instead of ready(). http://stackoverflow.com/questions/205087/jquery-ready-in-a-dynamically-inserted-iframe + function(){jQuery('#vocf').load(function(){jQuery('#selftestf').load( + function(){jQuery('#html5f').load(function(){jQuery('#readtextfilef').load( + function() { + var jef = jeforthf.contentDocument.body.lastChild.innerText; + var voc = vocf.contentDocument.body.lastChild.innerText; + var rea = readtextfilef.contentDocument.body.lastChild.innerText; + var htm = html5f.contentDocument.body.lastChild.innerText; + jeforthf.parentElement.removeChild(jeforthf); // suicide 否則會不斷累積! + vocf.parentElement.removeChild(vocf); // suicide + readtextfilef.parentElement.removeChild(readtextfilef); // suicide + html5f.parentElement.removeChild(html5f); // suicide + kvm.fortheval(jef+voc+rea+htm); // Run jeforth.f once. + // 之後不能再有任何東西,否則因為有 sleep/suspend/resume 之故,會被意外執行到。 + } + )})})})} + ) + } + ); + 改成這樣,還是會漏接: + // System initialization + var jef,voc,rea,htm,sel; jef=voc=rea=htm=sel=""; + jQuery('#jeforthf').load( + function() { + jef = jeforthf.contentDocument.body.lastChild.innerText; + jeforthf.parentElement.removeChild(jeforthf); // suicide 否則會不斷累積! + } + ); + jQuery('#vocf').load( + function() { + voc = vocf.contentDocument.body.lastChild.innerText; + vocf.parentElement.removeChild(vocf); // suicide 否則會不斷累積! + } + ); + jQuery('#selftestf').load( + function() { + sel = selftestf.contentDocument.body.lastChild.innerText; + selftestf.parentElement.removeChild(selftestf); // suicide 否則會不斷累積! + } + ); + jQuery('#html5f').load( + function() { + htm = html5f.contentDocument.body.lastChild.innerText; + html5f.parentElement.removeChild(html5f); // suicide 否則會不斷累積! + } + ); + jQuery('#readtextfilef').load( + function() { + rea = readtextfilef.contentDocument.body.lastChild.innerText; + readtextfilef.parentElement.removeChild(readtextfilef); // suicide 否則會不斷累積! + } + ); + jQuery(document).ready( + // jQuery convention, learned from W3School, make sure web page is ready. + function() { + $('#rev').html(kvm.version); // also .commandLine, .applicationName, ... + $('#location').html(window.location.toString()); // it's built-in in DOM + $('.appname').html(kvm.appname); + document.onkeydown = hotKeyHandler; // Must be using onkeydown so as to grab the control. + kvm.init(); + (function run(){ + if(sel&&jef&&voc&&htm&&rea){ + kvm.fortheval(jef+voc+htm+rea); + // 之後放東西要很小心,因為有 sleep 之故,會被意外執行到。 + } else setTimeout(run,100); + })(); + } + ); [x] 想到一個技巧。JavaScript 常常撞上 Cannot read property 'x' of undefined ( or null ) - 造成程式中斷。這可以用 && || 的特性來避免。 - : test js> kvm.a.b . space js> kvm.a.b . space ; - 執行 test ==> P A N I C ! JavaScript error on word "test" : Cannot read property 'b' of undefined - 改成以下寫法,run TSR 不會出錯終止程式, - : TSR 100 for js> kvm.a&&kvm.a.b . space 1000 sleep next ; - 隨後再根據失敗的線索,回頭去定義 kvm.a 而非一失敗就終止程式。 - jeforth.hta 裡,讀取 iframe 很容易失敗,造成程式中止, - jef = jeforthf.contentDocument.body.lastChild.innerText; - 改成 - jef = (jef=jeforthf.contentDocument.body.lastChild||"")&&jef.innerText; - 即可。 + 造成程式中斷。這可以用 && || 的特性來避免。 + : test js> kvm.a.b . space js> kvm.a.b . space ; + 執行 test ==> P A N I C ! JavaScript error on word "test" : Cannot read property 'b' of undefined + 改成以下寫法,run TSR 不會出錯終止程式, + : TSR 100 for js> kvm.a&&kvm.a.b . space 1000 sleep next ; + 隨後再根據失敗的線索,回頭去定義 kvm.a 而非一失敗就終止程式。 + jeforth.hta 裡,讀取 iframe 很容易失敗,造成程式中止, + jef = jeforthf.contentDocument.body.lastChild.innerText; + 改成 + jef = (jef=jeforthf.contentDocument.body.lastChild||"")&&jef.innerText; + 即可。 [x] iframe is a 旁門左道。好好的去讀 server 端的資料就好了呀!怎麼做? - $.get('1.htm',"text") ==> The result is an object {readyState,getResponseHeader,getAllResponseHeaders, - setRequestHeader,overrideMimeType,statusCode,abort,state,always,then,promise,pipe,done,fail,progress, - complete,success,error,responseText,status,statusText} - ==> tos().responseText is the data - ==> tos().status ==> 200(c8h) or 404(194h) number, HTML status code - Shit! so easy. - ==> It returns the object immediately. But the obj.status will be 'undefined' at first and become - 200 or 404 later. - ==> use $.get('1.htm',callback,"text") to get called back - ==> Shit! tos().status is not always there! - Try f js> pop().state() . "resolved" or "pending" - See this experiment, - - var f = $.get("1.htm",'text'); - f - constant ff - ff js> pop().state() . space 1 sleep - ff js> pop().state() . space 1 sleep - ff js> pop().state() . space 1 sleep - ff js> pop().state() . space 1 sleep - ff js> pop().state() . space 1 sleep - ff js> pop().state() . space 1 sleep - ==> pending OK pending resolved resolved resolved resolved - [x] $.get() 有 cache 的問題,在 IE 特別嚴重,根本不去讀新版! - http://stackoverflow.com/questions/367786/prevent-caching-of-ajax-call - http://stackoverflow.com/questions/10610034/jquery-get-caching-working-too-well - I choose the global setting as my solution : $.ajaxSetup({cache:false}) - This issue is jeforth.3htm 特有的問題。改 3htm/readTextFile.f。 + $.get('1.htm',"text") ==> The result is an object {readyState,getResponseHeader,getAllResponseHeaders, + setRequestHeader,overrideMimeType,statusCode,abort,state,always,then,promise,pipe,done,fail,progress, + complete,success,error,responseText,status,statusText} + ==> tos().responseText is the data + ==> tos().status ==> 200(c8h) or 404(194h) number, HTML status code + Shit! so easy. + ==> It returns the object immediately. But the obj.status will be 'undefined' at first and become + 200 or 404 later. + ==> use $.get('1.htm',callback,"text") to get called back + ==> Shit! tos().status is not always there! + Try f js> pop().state() . "resolved" or "pending" + See this experiment, + + var f = $.get("1.htm",'text'); + f + constant ff + ff js> pop().state() . space 1 sleep + ff js> pop().state() . space 1 sleep + ff js> pop().state() . space 1 sleep + ff js> pop().state() . space 1 sleep + ff js> pop().state() . space 1 sleep + ff js> pop().state() . space 1 sleep + ==> pending OK pending resolved resolved resolved resolved + [x] $.get() 有 cache 的問題,在 IE 特別嚴重,根本不去讀新版! + http://stackoverflow.com/questions/367786/prevent-caching-of-ajax-call + http://stackoverflow.com/questions/10610034/jquery-get-caching-working-too-well + I choose the global setting as my solution : $.ajaxSetup({cache:false}) + This issue is jeforth.3htm 特有的問題。改 3htm/readTextFile.f。 [ ] The whole project's name jeforth.3WE three words engine [x] ==> Root cause 出在用 fso 讀text不support utf-8, 所以 kernel jeforth.f 是用 ANSI Big5, IE 又出問題。 - 改用 utf-8, jeforth.hta 不用 fso 改用 ADO 即可讀 utf-8, 皆大歡喜。 - jeforth.3htm has bug on IE 10.0.9. I should also try FF and Linux. - ==> IE's debugger easily finds the growing words.forth stop at 'create'. Strange thing is - tick('create') => 0 ! The last 3 words have the same problem. - roll . space compile create - the . is dispeared, and tick later three gets 0. <=== problem. - ==> first colon word : space ... ; would replace the previous word . dot. - The bug is in ; colon or ; semi-colon or reveal. - ==> IE debugger F12 is as good as Chrome's. - if(kvm.debug&&(kvm.debug=333)) debugger; - But you need to enable by click the [Start Debugging] - button. Instruction 'debugger' is also supported. --> something wrong in (create) , after - (create) words.forth is still same <--- new word 'test' created by : test [ is expected. - so everything supposed to go to last() goes to '.' !! <=== Cause !! - ==> Why current_word_list().push(new Word([newname,function(){}])) does not work? - --> current_word_list().push(123) --> OK - --> current_word_list().push(new Word(['tteesstt'])) --> OK - --> single step trace : test 112233 ; ---> OK! strange??? - --> bp in ';' --> Proved the wrong last() happened before ';' <-- shoooo! good progress. - should have created words.forth[109] for the new word : tst 112233 ; but didn't <--- problem! - --> move bp earlier to where the new word is supposed to be created. - yeah, it has happened after (create) --> move bp earlier into (create) --> very very strange - finding! see below, the entire line before bp.11 is missing!!!!! because the previous comment - is ended with chinese characters and thus it *eat* the next line, as shown below, - - newxt=function(){ /* (create) */ - if(!(newname=pop())) panic("Create what?\n", tib.length-ntib>100); - if(isReDef(newname)) print("reDef "+newname+"\n"); // ?Y??tick(newname) ?N?? current_word_list().push(new Word([newname,function(){}])); - if(kvm.debug&&(kvm.debug=11)) debugger; - last().vid = current; // vocabulary ID - last().wid = current_word_list().length-1; // word ID - last().creater = ["code"]; - last().creater.push(this.name); // this.name is "(create)" - last().help = newname + " " + packhelp(); // help messages packed - - Add space after the ending chinese character '了' can fix the problem. But I don't like it. - - My jeforth.f is ANSI Big5. I use Big5 because jeforth.hta has problem with UTF-8. - Now I guess that was "utf-8 with BOM" (3 bytes: EF BB BF) leading marks that caused - the jeforth.hta problem. <== YES!! - If use 'utf-8 without BOM' then jeforth.hta become ok with utf-8, *AND* if IE were ok <== YES!! - with utf-8 even comment with chinese character at the end of line, <=== YES!! - then let's switch to use utf-8 without BOM encoding for source code. <==== YES! - - By the way, jeforth.f encoded in utf-8 with BOM works fine on 3htm+IE and 3nd. So, only - 3hta has problem. So, Microsoft's HTA does not work with utf-8 with BOM and IE does not work - with Big5, so Microsoft engineers only work on utf-8 without BOM. - - [x] 3HTA has big problem with utf-8! clock3.f does not work because it contains Chinese - named words! Those words become garbage and are not working correctly. <==== problem!! - ==> Root cause 出在用 fso 讀text不support utf-8, 改用 ADO 即可。 - - [x] I have this line, ==> Root cause 出在用 fso 讀text不support utf-8, 改用 ADO 即可。 - - in jeforth.hta. But it shows utf-8 chineses as garbage while Big5 good. Why? <=== HTA is wrong! - The funny thing is, in jeforth.htm the situation is reversed: Big5 garbage and utf-8 OK. <== Correct. - ==> Change to something else to reverse 3htm behavior. Make sure this line - is the key. --> Failed!! modify jeforth.htm to - ==> How to use codes instead of string? So as to control characters. - - [x] I found, under DOS box running jeforth.3nd. js> "\377" . prints HTML code ÿ, a y with - strange looking <==== Surprise, ASCII 255h is blank !!!!!! - 往下看!我後來發現在 Window 8 DOS box 下 jeforth.3nd 可以同時顯示正、簡體的中文!取決於 - print() 所用的 function。 - [x] Similar situaion in jeforth.hta, after OK prompt, type char ÿ - it shows char y <== strange y. But it's "ÿ" at TOS. - - [x] jsc is now in trouble under jeforth.htm !!! - OK jsc - - J a v a S c r i p t C o n s o l e - Usage: js: kvm.jsc.prompt='messsage';eval(kvm.jsc.xt) - - ------------------- P A N I C ! ------------------------- - JavaScript error on word "jsc" : Cannot set property 'prompt' of undefined - abortexec: false - compiling: false .... snip ...... - ===> 靠!忘了 jsc in jeforth.f is for 3hta only 啦! 有替 3nd 寫好了 jsc, 3htm 還沒有啦! - [x] 嘗試把 jeforth.f 裡的 jsc 定義拉出來,各個 application 放在前面一點的地方。 - - [x] jeforth.htm selftest failed so far on IE. (Chrome ok) - ==> 因為 voc.f 又是 Big5 coded !! - ==> 改成 utf-8 .... still failed. tick ' undefined! <==== - ==> cache 搞鬼 voc.f 怎麼改都無效。 - --> char kernel/voc.f readTextFile . <==== 改過了,還是讀到舊資料。 - 竟然又真的是 cache 的問題,voc.f 讀到 cache 版了。 - --> Ctrl-F5 無效,必須把 IE 整個關掉重開才行。 - ==> 確定 voc.f 本來是 Big5 改成 utf-8 encoding 就好了。 + 改用 utf-8, jeforth.hta 不用 fso 改用 ADO 即可讀 utf-8, 皆大歡喜。 + jeforth.3htm has bug on IE 10.0.9. I should also try FF and Linux. + ==> IE's debugger easily finds the growing words.forth stop at 'create'. Strange thing is + tick('create') => 0 ! The last 3 words have the same problem. + roll . space compile create + the . is dispeared, and tick later three gets 0. <=== problem. + ==> first colon word : space ... ; would replace the previous word . dot. + The bug is in ; colon or ; semi-colon or reveal. + ==> IE debugger F12 is as good as Chrome's. + if(kvm.debug&&(kvm.debug=333)) debugger; + But you need to enable by click the [Start Debugging] + button. Instruction 'debugger' is also supported. --> something wrong in (create) , after + (create) words.forth is still same <--- new word 'test' created by : test [ is expected. + so everything supposed to go to last() goes to '.' !! <=== Cause !! + ==> Why current_word_list().push(new Word([newname,function(){}])) does not work? + --> current_word_list().push(123) --> OK + --> current_word_list().push(new Word(['tteesstt'])) --> OK + --> single step trace : test 112233 ; ---> OK! strange??? + --> bp in ';' --> Proved the wrong last() happened before ';' <-- shoooo! good progress. + should have created words.forth[109] for the new word : tst 112233 ; but didn't <--- problem! + --> move bp earlier to where the new word is supposed to be created. + yeah, it has happened after (create) --> move bp earlier into (create) --> very very strange + finding! see below, the entire line before bp.11 is missing!!!!! because the previous comment + is ended with chinese characters and thus it *eat* the next line, as shown below, + + newxt=function(){ /* (create) */ + if(!(newname=pop())) panic("Create what?\n", tib.length-ntib>100); + if(isReDef(newname)) print("reDef "+newname+"\n"); // ?Y??tick(newname) ?N?? current_word_list().push(new Word([newname,function(){}])); + if(kvm.debug&&(kvm.debug=11)) debugger; + last().vid = current; // vocabulary ID + last().wid = current_word_list().length-1; // word ID + last().creater = ["code"]; + last().creater.push(this.name); // this.name is "(create)" + last().help = newname + " " + packhelp(); // help messages packed + + Add space after the ending chinese character '了' can fix the problem. But I don't like it. + + My jeforth.f is ANSI Big5. I use Big5 because jeforth.hta has problem with UTF-8. + Now I guess that was "utf-8 with BOM" (3 bytes: EF BB BF) leading marks that caused + the jeforth.hta problem. <== YES!! + If use 'utf-8 without BOM' then jeforth.hta become ok with utf-8, *AND* if IE were ok <== YES!! + with utf-8 even comment with chinese character at the end of line, <=== YES!! + then let's switch to use utf-8 without BOM encoding for source code. <==== YES! + + By the way, jeforth.f encoded in utf-8 with BOM works fine on 3htm+IE and 3nd. So, only + 3hta has problem. So, Microsoft's HTA does not work with utf-8 with BOM and IE does not work + with Big5, so Microsoft engineers only work on utf-8 without BOM. + + [x] 3HTA has big problem with utf-8! clock3.f does not work because it contains Chinese + named words! Those words become garbage and are not working correctly. <==== problem!! + ==> Root cause 出在用 fso 讀text不support utf-8, 改用 ADO 即可。 + + [x] I have this line, ==> Root cause 出在用 fso 讀text不support utf-8, 改用 ADO 即可。 + + in jeforth.hta. But it shows utf-8 chineses as garbage while Big5 good. Why? <=== HTA is wrong! + The funny thing is, in jeforth.htm the situation is reversed: Big5 garbage and utf-8 OK. <== Correct. + ==> Change to something else to reverse 3htm behavior. Make sure this line + is the key. --> Failed!! modify jeforth.htm to + ==> How to use codes instead of string? So as to control characters. + + [x] I found, under DOS box running jeforth.3nd. js> "\377" . prints HTML code ÿ, a y with + strange looking <==== Surprise, ASCII 255h is blank !!!!!! + 往下看!我後來發現在 Window 8 DOS box 下 jeforth.3nd 可以同時顯示正、簡體的中文!取決於 + print() 所用的 function。 + [x] Similar situaion in jeforth.hta, after OK prompt, type char ÿ + it shows char y <== strange y. But it's "ÿ" at TOS. + + [x] jsc is now in trouble under jeforth.htm !!! + OK jsc + + J a v a S c r i p t C o n s o l e + Usage: js: kvm.jsc.prompt='messsage';eval(kvm.jsc.xt) + + ------------------- P A N I C ! ------------------------- + JavaScript error on word "jsc" : Cannot set property 'prompt' of undefined + abortexec: false + compiling: false .... snip ...... + ===> 靠!忘了 jsc in jeforth.f is for 3hta only 啦! 有替 3nd 寫好了 jsc, 3htm 還沒有啦! + [x] 嘗試把 jeforth.f 裡的 jsc 定義拉出來,各個 application 放在前面一點的地方。 + + [x] jeforth.htm selftest failed so far on IE. (Chrome ok) + ==> 因為 voc.f 又是 Big5 coded !! + ==> 改成 utf-8 .... still failed. tick ' undefined! <==== + ==> cache 搞鬼 voc.f 怎麼改都無效。 + --> char kernel/voc.f readTextFile . <==== 改過了,還是讀到舊資料。 + 竟然又真的是 cache 的問題,voc.f 讀到 cache 版了。 + --> Ctrl-F5 無效,必須把 IE 整個關掉重開才行。 + ==> 確定 voc.f 本來是 Big5 改成 utf-8 encoding 就好了。 [x] HTA 其實可以顯示中文。手動輸入 - : test ; /// 中文注视 - /// 繁體也型 - ,即可見得。js> tick('test').comment binary-string>array 得 - 0: 9,20013,25991,27880,35270,10,9,32321,39636,20063,22411,10 (array) - --- chinese.f ----- - : chinese ; /// 中文注视 - /// 繁體也型 - ------------------- - include chinese.f 來看,help -n chinese 顯示亂碼! - js> tick('chinese').comment binary-string>array 得 - 1: 9,37533,21084,63,30236,21051,63,10,9,34652,61247,63,37515,60929,63,10 (array) - ==> 試 char chinese.f readTextFile . 印出來就是亂碼 - ==> 查 readTextFile 的寫法。。。var data = kvm.readTextFile(pop()); - var txtFile = kvm.fso.OpenTextFile( - pathname, - 1, // ForReading - false, - 0 // TristateFalse <==== 問題出在這裡, 只能放 0, -1 並不是 utf-8 ! - ); - TristateUseDefault –2 使用系统缺省打开文件。 - TristateTrue –1 以 Unicode 格式打开文件。 UCS-2 Big Endian 或 UCS-2 Little Endian 都不是 utf-8!! - TristateFalse 0 以 ASCII 格式打开文件。 - ==> This is the answer http://stackoverflow.com/questions/13851473/read-utf-8-text-file-in-vbscript - Dim objStream, strData - Set objStream = CreateObject("ADODB.Stream") - objStream.CharSet = "utf-8" - objStream.Open - objStream.LoadFromFile("C:\Users\admin\Desktop\ArtistCG\folder.txt") - strData = objStream.ReadText() - objStream.Close - - kvm.readTextFile = function(pathname) { - var strData, objStream = CreateObject("ADODB.Stream"); - objStream.CharSet = "utf-8"; - objStream.Open(); - objStream.LoadFromFile(pathname); - strData = objStream.ReadText(); - objStream.Close(); - return(strData); - } - Bingo!!! - ==> Try how to saveToFile - The below experiment works fine, Bingo!! - new ActiveXObject("ADODB.Stream") value objStream - objStream js: pop().CharSet="utf-8" - objStream js: pop().Open(); - objStream js: pop().LoadFromFile("readme.txt") - objStream js: pop().SaveToFile("3.txt",2) \ adSaveCreateOverWrite=2, adSaveCreateNotExist=1(can't overwite) - objStream js: pop().Close() - Try to write my string, it works fine, Bingo!! - new ActiveXObject("ADODB.Stream") value objStream - objStream js: pop().CharSet="utf-8" - objStream js: pop().Open(); - objStream js: pop().WriteText("11"); \ option: adWriteChar =0(default), adWriteLine =1(\r\n) - objStream js: pop().WriteText("22"); \ option: adWriteChar =0(default), adWriteLine =1(\r\n) - objStream js: pop().SaveToFile("3.txt",2) \ adSaveCreateOverWrite=2, adSaveCreateNotExist=1(can't overwite) - objStream js: pop().Close() - [x] 改寫 kvm.writeTextFile + : test ; /// 中文注视 + /// 繁體也型 + ,即可見得。js> tick('test').comment binary-string>array 得 + 0: 9,20013,25991,27880,35270,10,9,32321,39636,20063,22411,10 (array) + --- chinese.f ----- + : chinese ; /// 中文注视 + /// 繁體也型 + ------------------- + include chinese.f 來看,help -n chinese 顯示亂碼! + js> tick('chinese').comment binary-string>array 得 + 1: 9,37533,21084,63,30236,21051,63,10,9,34652,61247,63,37515,60929,63,10 (array) + ==> 試 char chinese.f readTextFile . 印出來就是亂碼 + ==> 查 readTextFile 的寫法。。。var data = kvm.readTextFile(pop()); + var txtFile = kvm.fso.OpenTextFile( + pathname, + 1, // ForReading + false, + 0 // TristateFalse <==== 問題出在這裡, 只能放 0, -1 並不是 utf-8 ! + ); + TristateUseDefault –2 使用系统缺省打开文件。 + TristateTrue –1 以 Unicode 格式打开文件。 UCS-2 Big Endian 或 UCS-2 Little Endian 都不是 utf-8!! + TristateFalse 0 以 ASCII 格式打开文件。 + ==> This is the answer http://stackoverflow.com/questions/13851473/read-utf-8-text-file-in-vbscript + Dim objStream, strData + Set objStream = CreateObject("ADODB.Stream") + objStream.CharSet = "utf-8" + objStream.Open + objStream.LoadFromFile("C:\Users\admin\Desktop\ArtistCG\folder.txt") + strData = objStream.ReadText() + objStream.Close + + kvm.readTextFile = function(pathname) { + var strData, objStream = CreateObject("ADODB.Stream"); + objStream.CharSet = "utf-8"; + objStream.Open(); + objStream.LoadFromFile(pathname); + strData = objStream.ReadText(); + objStream.Close(); + return(strData); + } + Bingo!!! + ==> Try how to saveToFile + The below experiment works fine, Bingo!! + new ActiveXObject("ADODB.Stream") value objStream + objStream js: pop().CharSet="utf-8" + objStream js: pop().Open(); + objStream js: pop().LoadFromFile("readme.txt") + objStream js: pop().SaveToFile("3.txt",2) \ adSaveCreateOverWrite=2, adSaveCreateNotExist=1(can't overwite) + objStream js: pop().Close() + Try to write my string, it works fine, Bingo!! + new ActiveXObject("ADODB.Stream") value objStream + objStream js: pop().CharSet="utf-8" + objStream js: pop().Open(); + objStream js: pop().WriteText("11"); \ option: adWriteChar =0(default), adWriteLine =1(\r\n) + objStream js: pop().WriteText("22"); \ option: adWriteChar =0(default), adWriteLine =1(\r\n) + objStream js: pop().SaveToFile("3.txt",2) \ adSaveCreateOverWrite=2, adSaveCreateNotExist=1(can't overwite) + objStream js: pop().Close() + [x] 改寫 kvm.writeTextFile [ ] binary.f does not need VB module, use new ActiveXObject("ADODB.Stream"); [x] Make utf-8 with BOM leading EF BB BF a nop word : EFBBBF ; - ==> No need I guess. 3HTA was a bug of using the incorrect fso module which does not support utf-8. + ==> No need I guess. 3HTA was a bug of using the incorrect fso module which does not support utf-8. [x] Node.js DOS box 顯示 utf-8 可能有妙用 <=== 確認可以! - 正體中文顯示在 DOS box 之下本來是得注意 chcp 950 Code Page 的設定。而且簡中系統也不好切 chcp 950. - 跑 jeforth.3nd source code 都是 utf-8 顯示中文倒是都正常。試試簡中系統。。。。 - 这几个自是简体中文,在正体 DOS 下显示正常否? - Ha! 兩種字體同時在 Window 8 DOS box 下正常顯示! + 正體中文顯示在 DOS box 之下本來是得注意 chcp 950 Code Page 的設定。而且簡中系統也不好切 chcp 950. + 跑 jeforth.3nd source code 都是 utf-8 顯示中文倒是都正常。試試簡中系統。。。。 + 这几个自是简体中文,在正体 DOS 下显示正常否? + Ha! 兩種字體同時在 Window 8 DOS box 下正常顯示! [ ] 所以,將來弄 jeforth.3dos 時,print() 的寫法要講究,有機會也能顯示 utf-8 中文正、簡通用! @@ -1535,211 +1535,211 @@ [ ] improve html5.f self-test, was too rough for such an important module. [x] 在 include source.f 裡面 skip 到 --EOF-- 的方法: - js> confirm("要執行 canvas.f self-test 嗎?") [if] [else] - push("--E"+"OF--");execute("word"); // 如果不用 JavaScript code, 到這裡檔尾的 "--EOF--" 將成為下一個指令! - pop();execute("BL");execute("word");pop(); - execute("--canvas.f--selftest--") - [then] + js> confirm("要執行 canvas.f self-test 嗎?") [if] [else] + push("--E"+"OF--");execute("word"); // 如果不用 JavaScript code, 到這裡檔尾的 "--EOF--" 將成為下一個指令! + pop();execute("BL");execute("word");pop(); + execute("--canvas.f--selftest--") + [then] [x] jeforth.3we has released to FigTaiwan google groups last night. hcchen5600 2014/10/22 11:06:14 - ==> start to port jeforth.3nw to under jeforth.3we + ==> start to port jeforth.3nw to under jeforth.3we [x] hcchen5600 2014/10/22 11:01:47 porting to jeforth.3we, modify jeforth.3we/3nw/index.html to - obey jeforth.3we conventions. - o first of all, jeforth.3we/3nw/index.html - js> window obj>keys . \ ==> 果然有 ... Box2D,Vector,Vector_a2j_Number, ... + c:\Users\8304018.WKSCN\Dropbox\learnings\github\jeforth.3we\js\box2dweb\Box2dWeb-2.1.a.3.min.js + + js> window obj>keys . \ ==> 果然有 ... Box2D,Vector,Vector_a2j_Number, ... [x] 在 jeforth.3we 中操作 object 以 solar-system.f 為典範,有了突破。 - 1、透過 istar 讓 property 既是 forth 的 global 又可以 access 各自的 object instance 不亂。 - 2、Function Overloading 在 to 命令上的嘗試,成功。 See solar-system.f + 1、透過 istar 讓 property 既是 forth 的 global 又可以 access 各自的 object instance 不亂。 + 2、Function Overloading 在 to 命令上的嘗試,成功。 See solar-system.f [x] jeforth.js 要再簡化,只留必要的東西。所以 help 相關的都要移除。 ( ) \ 可以改良,在 TIB 中回朔到 - 同一行中有 last().name 就知道自己是 stack diagram 以及 help message, 故不必放在 kernel 裡也可以 - 做得到。 - 錯!能移出來早就移出來了。為了 code word 也能有 help message 只好繼續保留。 + 同一行中有 last().name 就知道自己是 stack diagram 以及 help message, 故不必放在 kernel 裡也可以 + 做得到。 + 錯!能移出來早就移出來了。為了 code word 也能有 help message 只好繼續保留。 [x] I need a new js function : previoustoken() for 'rewind' to idiot-proof there's a nap in front of it. -[x] ("h" + " aa bb cc dd " + " ").split(/\s+/).slice(0,-1) // An array, 這麼麻煩是為了要自動把行尾的 white spaces 去掉。 - ("h" + " aa bb cc dd " + " t").split(/\s+/).slice(0,-1) - split the TIB at ntib , the previous is just used, the next is what 'word' will return. - so the previous returns an array of tokens - : -word ( -- token[] ) \ Get used tokens in the TIB. - var a=('h '+tib.substr(0,ntib)+' t').split(/\s+/); // 加上 dummy 頭尾再 split 以統一所有狀況。 - a.pop(); a.shift(); /* 丟掉 dummy 頭尾巴 */ a ; +[x] ("h" + " aa bb cc dd " + " ").split(/\s+/).slice(0,-1) // An array, 這麼麻煩是為了要自動把行尾的 white spaces 去掉。 + ("h" + " aa bb cc dd " + " t").split(/\s+/).slice(0,-1) + split the TIB at ntib , the previous is just used, the next is what 'word' will return. + so the previous returns an array of tokens + : -word ( -- token[] ) \ Get used tokens in the TIB. + var a=('h '+tib.substr(0,ntib)+' t').split(/\s+/); // 加上 dummy 頭尾再 split 以統一所有狀況。 + a.pop(); a.shift(); /* 丟掉 dummy 頭尾巴 */ a ; [x] need a jeforth new word to launch multiple TIB tasks - s' ." * " 100 nap rewind' js: fortheval(pop()) - s' ." $ " 150 nap rewind' js: fortheval(pop()) - ==> ." * " 100 nap rewind ." $ " 100 nap rewind + s' ." * " 100 nap rewind' js: fortheval(pop()) + s' ." $ " 150 nap rewind' js: fortheval(pop()) + ==> ." * " 100 nap rewind ." $ " 100 nap rewind [x] jeforth.3htm press {backSpace} become changing the web page to previous. Avoid that! - hcchen5600 2015/04/03 21:47:24 Done! + hcchen5600 2015/04/03 21:47:24 Done! [x] pull down menu for command history and words auto completion - See jQuery 'Popup selections - Tryit Editor v2.3' @ http://www.w3schools.com/jquerymobile/tryit.asp?filename=tryjqmob_forms_select_popup - - + See jQuery 'Popup selections - Tryit Editor v2.3' @ http://www.w3schools.com/jquerymobile/tryit.asp?filename=tryjqmob_forms_select_popup + + [x] 用 jeforth.hta 來管理 github - 先複習怎樣由 jeforth.hta 來下 dos box command . . . - 1. use Github for Windows to open the dos shell through the [setting] button at the upper right corner. - 2. title demo <-- change the dos box title - 3. WshShell.AppActivate "demo" \ activate the dos box - WshShell.SendKeys "dir{enter}" - - js> clipboardData.getData("text") ?dup not [if] "" [then] \ SAVE-restore. Clipboard can be null, so be careful. - js: clipboardData.setData("text","1+2=*3=") - WshShell.SendKeys "^c" 100 sleep \ Ctrl-c - WshShell.SendKeys "%{F4}" 100 sleep \ Alt-f4 - js> clipboardData.getData("text") - js: clipboardData.setData("text",pop(1)) \ save-RESTORE - 9 = ==>judge [if] ['ActiveXObject','WshShell'] all-pass [then] - WshShell.SendKeys "%" \ Release Alt key, some how other wise it got locked. - - \ 改用 clipboard 已經成功,不怕中文輸入模式。以下留作紀念。 - \ js: document.body.style.imeMode='disabled'; \ [x] 懸案,想要避免中文輸入法干擾,無效! - \ WshShell.SendKeys "1{+}" 100 sleep \ Pad plus - \ js: document.body.style.imeMode='auto'; - + 先複習怎樣由 jeforth.hta 來下 dos box command . . . + 1. use Github for Windows to open the dos shell through the [setting] button at the upper right corner. + 2. title demo <-- change the dos box title + 3. WshShell.AppActivate "demo" \ activate the dos box + WshShell.SendKeys "dir{enter}" + + js> clipboardData.getData("text") ?dup not [if] "" [then] \ SAVE-restore. Clipboard can be null, so be careful. + js: clipboardData.setData("text","1+2=*3=") + WshShell.SendKeys "^c" 100 sleep \ Ctrl-c + WshShell.SendKeys "%{F4}" 100 sleep \ Alt-f4 + js> clipboardData.getData("text") + js: clipboardData.setData("text",pop(1)) \ save-RESTORE + 9 = ==>judge [if] ['ActiveXObject','WshShell'] all-pass [then] + WshShell.SendKeys "%" \ Release Alt key, some how other wise it got locked. + + \ 改用 clipboard 已經成功,不怕中文輸入模式。以下留作紀念。 + \ js: document.body.style.imeMode='disabled'; \ [x] 懸案,想要避免中文輸入法干擾,無效! + \ WshShell.SendKeys "1{+}" 100 sleep \ Pad plus + \ js: document.body.style.imeMode='auto'; + [x] jsc interface changed, see hta's guit.f - 1. jump2endofinptbox.click() every time. - 2. remove the jsc> prompt in the confirm box. + 1. jump2endofinptbox.click() every time. + 2. remove the jsc> prompt in the confirm box. [x] words and help to support a new switch "-V vocabulary-name" to show only the specified vocabulary - words or help -V- to disable + words or help -V- to disable [x] 為了 forthtranspiler 自稱 vm 怕混淆 jeforth.3we 還是自稱 kvm 好了。 [x] 成功了, forthtranspiler 可以直接在 jeforth.3we 底下加掛! - - - ==> 把唯一的 console.log 改成 print 即可。 + + + ==> 把唯一的 console.log 改成 print 即可。 [/] HTML5 textarea (inputbox) 有 autocomplete, autofocus(對咱無效) 等功能! @@ -3198,48 +3198,48 @@ [ ] 現在有了 er 不妨在 outputbox 設定上限,超過就把最上面得 text br 刪掉一部分,免得太長 browser 受不了。 [ ] 爽哥遇到兩個問題 1)jeforth.3nd.bat 路徑沒改,run 不起來。 2)jeforth.3hta 因為 Same origin policy - run 不起來。為了降低 user 遇到挫折的機會,[ ] 要防呆。為了要幫助 user 抓出問題,或當場有事做可以幫忙抓 - 問題,[ ] 要提供 safe mode。 + run 不起來。為了降低 user 遇到挫折的機會,[ ] 要防呆。為了要幫助 user 抓出問題,或當場有事做可以幫忙抓 + 問題,[ ] 要提供 safe mode。 [ ] 最精簡的 jsforth.js 包含的 words 只有 - code end-code 如何使用 wordhash words dictionary ip stack - rstack tos pop push tip ntip overhauling protocal 共筆機制 版本週期 - jsforth.f - inner loop - outer loop - word + code end-code 如何使用 wordhash words dictionary ip stack + rstack tos pop push tip ntip overhauling protocal 共筆機制 版本週期 + jsforth.f + inner loop + outer loop + word [ ] 爽哥的 https://github.com/samsuanchen/multitaskjavascripteforth 應該盡量多引用。先看他的 inner loop [ ] 仿 jsForth 把 print() 改成 printLine() printChar() 或 sprint() 避開與 window.print() 相撞的機會。 [ ] function dictcompile(n), function compilecode(word) 這兩個在 jeforth.js 裡的 function 很累贅。改 - 成 comma() 一個就好了。原 compilecode(word) 用 comma(tick('wordName')) 就可以了,不必多一個 function() + 成 comma() 一個就好了。原 compilecode(word) 用 comma(tick('wordName')) 就可以了,不必多一個 function() [ ] 利用 solar-system.f 開發出來的方法來管理 canvas 也可以有多個 canvas。或者用個 icanvas 來指定某一個 - ,因此有修改到 icanvas 的人都得 save-restore icanvas。 - 如果規定 value cv 當做默認的 canvas 就不必用 kvm.cv 了,但這樣會使 canvas.f 經常因為 cv 是 undefined - 而出錯。 + ,因此有修改到 icanvas 的人都得 save-restore icanvas。 + 如果規定 value cv 當做默認的 canvas 就不必用 kvm.cv 了,但這樣會使 canvas.f 經常因為 cv 是 undefined + 而出錯。 [x] jeforth.3we README.md 改良 [ ] How to play with arrow.js - 1. add three lines only to arrow.js - push(world); // [ ] + 1. add three lines only to arrow.js + push(world); // [ ] [x] sync words -V vocabulary-name and help -V vocabulary-name also -V- - 改寫,合併、簡化 + 改寫,合併、簡化 [x] echo command line 要先 cr 一下,除非沒有東西。 - [x]index.htm [x]index.html [x]jeforth.hta [ ]jeforth.3nd.js + [x]index.htm [x]index.html [x]jeforth.hta [ ]jeforth.3nd.js [x] alias' help should show the correct word name [x] Tab change to 4 spaces - [x]jeforth.hta [x]index.html [x]jeforth.3nw.html + [x]jeforth.hta [x]index.html [x]jeforth.3nw.html [x] key doesn't work when in EditMode !!! Bug. - ==> EditMode 當中 enter 不適合用來跳進 inputbox, 會嚴重干擾 editing。 - 但是有 Esc, Tab, F4 等替代辦法。 + ==> EditMode 當中 enter 不適合用來跳進 inputbox, 會嚴重干擾 editing。 + 但是有 Esc, Tab, F4 等替代辦法。 [x] Tab-autocomplete don't let it return 'undefind' @@ -3248,307 +3248,307 @@ [ ] Separate git.f and shell.f [ ] inputbox 之前放個 prompt 很重要 - [ ]3hta, [ ]3htm, [ ]3nw + [ ]3hta, [ ]3htm, [ ]3nw [ ] 把文章都整理進 jeforth.3we/Wiki - o jeforth for WSH 也可以拿來玩 tiny forth / tiny assembly-disassembly + o jeforth for WSH 也可以拿來玩 tiny forth / tiny assembly-disassembly [x] 改成 up/down 不要直接 recall command line history ,只有 Ctrl-up/Ctrl-down do that。 [ ] Sam Suan Chen's definition is interesting. code function x() { .... } end-code defines - vm.x() function. I wish this is the way to add variables and functions into KVM. But, don't know - if it's a good idea. + vm.x() function. I wish this is the way to add variables and functions into KVM. But, don't know + if it's a good idea. [x] 比較 jeforth.3we 與 。。。 的速度 - : speed-test 0 swap for 1+ next ; - // ( count -- sount ) 1 + 1 + ... count times - code precise-time function(){dStk.push((new Date()).getTime())} end-code + : speed-test 0 swap for 1+ next ; + // ( count -- sount ) 1 + 1 + ... count times + code precise-time function(){dStk.push((new Date()).getTime())} end-code [ ] hcchen5600 2015/05/17 07:15:30 - 改用 project-k 的 jeforth.js 有幾個問題, - [ ] 原來的 forth vocabulary 改成 root 大地震! - [ ] kvm 不要動或也改名。 + 改用 project-k 的 jeforth.js 有幾個問題, + [ ] 原來的 forth vocabulary 改成 root 大地震! + [ ] kvm 不要動或也改名。 [ ] Branch project-k 來改吧! [ ] Working on Dropbox\Stock2015.xls need to automation - Excel data from Fubon e01 is already dynamic <-------- Bingo! everything rely on it. - [ ] Then I'd like to add stock to the excel file with formula that gets the data dynamically. - [ ] Then I'd like to read data from Web page directly http://www.yuanta.com.tw/pages/content/Frame.aspx?Node=47f739da-b7c5-4d16-accc-7175d8dcf583 - to update and check new info. - [/] I have opened many excel file, use "list-processes" or "see-process" can see - how many excel process are running. There can be many excel processes. - Use "list-workbooks" command can list all excel files under the application - object. 想要 study "how to get Application object using process id" and "How - To Get Excel Object From Process?", "how to get excel object through processID - through javascript", "Attaching to Running Instance of Office Application" - 還是放棄了。 - [x] 最簡單的方法是,透過 jeforth.3we 把 excel run 起來,然後用 excel 去 open 要 - 工作的 excel files。讓 jeforth.3we 透過選單來指定哪個 file 是哪個 file。 - [x] 用 notepad++ 把 "2062橋椿" --> "2062 橋椿": - Replace "(\d)(\D)" to "\1 \2" - ==> 用不著。 money.f 寫好了,自動轉換 formula 而已。搭配元大的除息表看,漏的、新的 - 很清楚。 - 這張表從 http://www.yuanta.com.tw/pages/content/Frame.aspx?Node=47f739da-b7c5-4d16-accc-7175d8dcf583 copy 來的 + Excel data from Fubon e01 is already dynamic <-------- Bingo! everything rely on it. + [ ] Then I'd like to add stock to the excel file with formula that gets the data dynamically. + [ ] Then I'd like to read data from Web page directly http://www.yuanta.com.tw/pages/content/Frame.aspx?Node=47f739da-b7c5-4d16-accc-7175d8dcf583 + to update and check new info. + [/] I have opened many excel file, use "list-processes" or "see-process" can see + how many excel process are running. There can be many excel processes. + Use "list-workbooks" command can list all excel files under the application + object. 想要 study "how to get Application object using process id" and "How + To Get Excel Object From Process?", "how to get excel object through processID + through javascript", "Attaching to Running Instance of Office Application" + 還是放棄了。 + [x] 最簡單的方法是,透過 jeforth.3we 把 excel run 起來,然後用 excel 去 open 要 + 工作的 excel files。讓 jeforth.3we 透過選單來指定哪個 file 是哪個 file。 + [x] 用 notepad++ 把 "2062橋椿" --> "2062 橋椿": + Replace "(\d)(\D)" to "\1 \2" + ==> 用不著。 money.f 寫好了,自動轉換 formula 而已。搭配元大的除息表看,漏的、新的 + 很清楚。 + 這張表從 http://www.yuanta.com.tw/pages/content/Frame.aspx?Node=47f739da-b7c5-4d16-accc-7175d8dcf583 copy 來的 [ ] 改用 project-k 的 kernel 有幾個問題要討論。 - 1. Virtual machine 的 instance 之命名 - 2. Virtual machine 裡的 with(){} default name space. - 3. global variable 要不要加 _ prefix? 避免撞名。或者用一個 function 來管理 新增、刪除? + 1. Virtual machine 的 instance 之命名 + 2. Virtual machine 裡的 with(){} default name space. + 3. global variable 要不要加 _ prefix? 避免撞名。或者用一個 function 來管理 新增、刪除? [ ] 研究 3hta 的 localStorage 看能不能用來存 excel 的 application object (或 workbook object 也可以) - ==> js> window.localStorage \ ==> undefined (undefined) - ==> HTA 只 support 到 IE7 幹! 沒有 localStorage。 - http://note.youdao.com/share/?id=a3be4afcc542a1f5d106528f1f3ae5ab&type=note - ==> 嘗試用 excel 的一格來存放 myWorkbook object 也不行。 - activeCell :: value=g.myWorkbook ==> -- P A N I C ! -- JavaScript error : Expected ';' + ==> js> window.localStorage \ ==> undefined (undefined) + ==> HTA 只 support 到 IE7 幹! 沒有 localStorage。 + http://note.youdao.com/share/?id=a3be4afcc542a1f5d106528f1f3ae5ab&type=note + ==> 嘗試用 excel 的一格來存放 myWorkbook object 也不行。 + activeCell :: value=g.myWorkbook ==> -- P A N I C ! -- JavaScript error : Expected ';' [ ] WSH 的 sendkeys 不太靈光,對 excel、有道云笔记,都無效。 - char 有道云笔记 activate - js: clipboardData.setData("text","abc") - char ^v{TAB} sendkeys - [ ] 有空用 excel 的 sendkeys 試試。 + char 有道云笔记 activate + js: clipboardData.setData("text","abc") + char ^v{TAB} sendkeys + [ ] 有空用 excel 的 sendkeys 試試。 [ ] 使用 jQuery 的結果在 Win7 之下跑不起來了。因為 jQuery + JScript + HTA 版本的關係。 - ==> 首先要把 jQuery(document).ready() 改成用 document.onload = function(){} 或者 - 用 更簡單。 - ==> 在舊的 jeforth.3hta 上改了一半,可以不靠 jQuery 跑起來了。--> 把現在的 3we commit 起來,開 - 始直接在上面修改。 - --> 靠!當前的 3we 是 [namespace-test +1 ~8 -1 !] branch,忘了本來是在幹嘛了! 還改了一堆 - excel 的東西。先用 GitHub for Windows 瞧瞧. . . . 可以合併回 marker so just do it . . . - --> git merge namespace-test ... 成功! 平生第一次做 merge。 - --> 現在回到 master 了, - [x] Microsoft JScript runtime error: 'keyCode' is null or not an object - --> Windows 7, Top on JScript v5.8.16385 而且是 IE8 結果他的 document.onkeydown 收到的不是 - handler(e) 而是 handler(void)! keyCode 要另外從 event.keyCode 取得. - --> 所以網友建議的 pattern 是: - function alertKeycode(e) { - e = (e) ? e : event; - var keycode = (e.keyCode) ? e.keyCode : (e.which) ? e.which : false; - alert(keycode) - } - => OK! - [ ] Win7 的 IE 是 IE8 而 HTA 裡的這的一行設定: - - 顯得令人擔憂。 - [x] 當初用 jquery 的原因是它的 .append("test string or HTML tag") 很好用,而我當時也搞不懂 - .appendChild(obj) 裡的 obj 怎麼來。其實很簡單: - outputbox.appendChild(document.createTextNode("string")) - 這樣就可以了: - var aa = (kvm.plain(ss)+'\n').split('\n').slice(0,-1); // [aaa,bbb,] - for(i=0; i 都靠 jQuery 才好做。所以還是在 html5.f 裡把 jquery 給抓進來了。 - [ ] 目前的 cr 好像不 work? - [ ] HTML 一類的 greeting 上有 Program path file:///C:/.../jeforth.3we/jeforth.hta#endofinputbox - 尾巴上的 #endofinputbox 應該想辦法把它拿掉。 - - [ ] 想通了 jQuery 還是要把它 include 進來。適當時機是 html5.f, Win7 經過 windows upgrade 之後 - JScript 也到了 v11 了, Winxp 放棄或晚點再看看。 - - [x] Try AutoItX3 - push(new ActiveXObject("AutoItX3.Control")) constant au3 // ( -- AutoItX3 ) Get AutoItX3 object - au3 :: run("notepad.exe") - ==> Bingo!! - [ ] So, let's go for the autoit.f - - [x] https://msdn.microsoft.com/en-us/library/office/gg251785(v=office.15).aspx - If the pathname argument is omitted, GetObject returns a currently active object of the specified type. - If no object of the specified type exists, an error occurs. <== 這就是 jeforth.3hta 裡 excel.f 該用的辦 - 法了! 先用 see-excel 查看有幾個 excel 在 running? 如果是一個就用它, 如果超過一個就警告, 如果沒有就開一個。 - Set xl=GetObject(,"excel.application"):kvm.push(xl) - it works!! - ==> 終於解決 multiple Excel.Application object 的問題了! - [ ] ?abort" error message " 能不能弄成 dual state 通用? - - [ ] 開始研究透過 AutoIt 抓網頁 data - 研究 ie.au3 很可能跟 excel 依樣發現又是 GetObject() 就能解決? - --> 果然發現 IE Window Object, _IEAttach()'s return value. - --> 原來他是透過 shell.application access windows object, 其實 windows 就是 IE 的 tab 頁面。 - [ ] shell.application 應改簡化成 shell.app 類似 excel.app - https://msdn.microsoft.com/en-us/library/windows/desktop/bb774063(v=vs.85).aspx - shell.application :> windows() constant ShellWindows // ( -- obj ) shell.application windows object - /// ShellWindows object https://msdn.microsoft.com/en-us/library/windows/desktop/bb773974(v=vs.85).aspx - ShellWindows :> count \ ==> 3 (number) 根本就是看 IE 開了幾個 tab 亦即 windows。 - ShellWindows :> item(0) \ ==> Windows Internet Explorer (object) https://msdn.microsoft.com/library/aa752084(v=vs.85).aspx - ShellWindows :> item(3) \ ==> null (null) 超過了就變成 null。 - ShellWindows :> item(0) :> LocationName \ ==> 星巴克华东 (string) Bingo!!! 真的碰到了! - ShellWindows :> item(0) :> LoCaTiOnUrL \ ==> http://www.president-starbucks.com.cn/index.html (string) - ShellWindows :> item(0) :> application \ ==> Windows Internet Explorer (object) 就是 item(0) 自己。 - [x] 其實 IE object 也可以這樣直接取得: - Set IE = CreateObject("InternetExplorer.Application"):kvm.push(IE) constant IE // ( -- obj ) Internet Explorer object - 然後透過 IE :> parent 應該也是回到 ShellWindows --> [ ] try try see .... 非也, 這個 IE.parent 還是它 - 自己。 - [x] 同上,改用 GetObject 看看, - Set ie = GetObject(,"InternetExplorer.Application"):kvm.push(ie) constant ie // ( -- obj ) Internet Explorer object - --> VBscript error : ActiveX component can't create object: 'GetObject' - --> 這是因為 IE 應該是個 single-instance object - [ ] 同上,改用 GetObject 的另一方式看看, - Set ie = GetObject("","InternetExplorer.Application"):kvm.push(ie) constant ie // ( -- obj ) Internet Explorer object - --> 成功了! 但它的 parent 還是自己。 - --> 每多開一個 tab 用 s" where name = 'iexplore.exe'" see-process . 來看就會多一個 process. - [x] 被 stop 停掉的 TIB 應該馬上 stop=false 以便只 stop 本 . - --> 改了 outer() 若無誤,記得連 project-k 也要修正。 - --> 錯! stop 必須 stop 全部工作。後續還有工作的情形用 ?rewind。 - [x] Need a ?rewind command - - [x] Have many bugs now. On excel.f and on ie.f/money.f. This bug happens on S7 when starting - ieforth.3we. First time said there are multiple excel and stoped including excel. So I close - visible excel workbooks. F5 reload and the below error happened. Retry can't fix it. Close - jeforth.3we and run again, still same problem. - ------------------- P A N I C ! ------------------------- - VBscript error : ActiveX component can't create object: 'GetObject' - stop: false - compiling: false - stack.length: 0 - rstack.length: 1 - ip: 1286 - ntib: 279 - tib.length: 65609 - tib: (,"excel.application"):kvm.push(xl)
- [else] char Excel.Application ActiveXObject [then] to (excel.app) - ==> I guess this is again the "single-instance object" issue ... - ==> Bingo!! 不要用 ActiveXObject(), 用 CreateObject() or GetObject()。 - 而且 IE and Excel 都是 "single-instance object" 只要看到有多個 application object - 就可以當作是問題。 - - [ ] ie.f ok now, money.f 需要改寫 with new knowledge of ie.f. - [x] 如何取得 the active IE window? ==> 讓 user 自己從 list-ie-winsows 裡選。 + ==> 首先要把 jQuery(document).ready() 改成用 document.onload = function(){} 或者 + 用 更簡單。 + ==> 在舊的 jeforth.3hta 上改了一半,可以不靠 jQuery 跑起來了。--> 把現在的 3we commit 起來,開 + 始直接在上面修改。 + --> 靠!當前的 3we 是 [namespace-test +1 ~8 -1 !] branch,忘了本來是在幹嘛了! 還改了一堆 + excel 的東西。先用 GitHub for Windows 瞧瞧. . . . 可以合併回 marker so just do it . . . + --> git merge namespace-test ... 成功! 平生第一次做 merge。 + --> 現在回到 master 了, + [x] Microsoft JScript runtime error: 'keyCode' is null or not an object + --> Windows 7, Top on JScript v5.8.16385 而且是 IE8 結果他的 document.onkeydown 收到的不是 + handler(e) 而是 handler(void)! keyCode 要另外從 event.keyCode 取得. + --> 所以網友建議的 pattern 是: + function alertKeycode(e) { + e = (e) ? e : event; + var keycode = (e.keyCode) ? e.keyCode : (e.which) ? e.which : false; + alert(keycode) + } + => OK! + [ ] Win7 的 IE 是 IE8 而 HTA 裡的這的一行設定: + + 顯得令人擔憂。 + [x] 當初用 jquery 的原因是它的 .append("test string or HTML tag") 很好用,而我當時也搞不懂 + .appendChild(obj) 裡的 obj 怎麼來。其實很簡單: + outputbox.appendChild(document.createTextNode("string")) + 這樣就可以了: + var aa = (kvm.plain(ss)+'\n').split('\n').slice(0,-1); // [aaa,bbb,] + for(i=0; i 都靠 jQuery 才好做。所以還是在 html5.f 裡把 jquery 給抓進來了。 + [ ] 目前的 cr 好像不 work? + [ ] HTML 一類的 greeting 上有 Program path file:///C:/.../jeforth.3we/jeforth.hta#endofinputbox + 尾巴上的 #endofinputbox 應該想辦法把它拿掉。 + + [ ] 想通了 jQuery 還是要把它 include 進來。適當時機是 html5.f, Win7 經過 windows upgrade 之後 + JScript 也到了 v11 了, Winxp 放棄或晚點再看看。 + + [x] Try AutoItX3 + push(new ActiveXObject("AutoItX3.Control")) constant au3 // ( -- AutoItX3 ) Get AutoItX3 object + au3 :: run("notepad.exe") + ==> Bingo!! + [ ] So, let's go for the autoit.f + + [x] https://msdn.microsoft.com/en-us/library/office/gg251785(v=office.15).aspx + If the pathname argument is omitted, GetObject returns a currently active object of the specified type. + If no object of the specified type exists, an error occurs. <== 這就是 jeforth.3hta 裡 excel.f 該用的辦 + 法了! 先用 see-excel 查看有幾個 excel 在 running? 如果是一個就用它, 如果超過一個就警告, 如果沒有就開一個。 + Set xl=GetObject(,"excel.application"):kvm.push(xl) + it works!! + ==> 終於解決 multiple Excel.Application object 的問題了! + [ ] ?abort" error message " 能不能弄成 dual state 通用? + + [ ] 開始研究透過 AutoIt 抓網頁 data + 研究 ie.au3 很可能跟 excel 依樣發現又是 GetObject() 就能解決? + --> 果然發現 IE Window Object, _IEAttach()'s return value. + --> 原來他是透過 shell.application access windows object, 其實 windows 就是 IE 的 tab 頁面。 + [ ] shell.application 應改簡化成 shell.app 類似 excel.app + https://msdn.microsoft.com/en-us/library/windows/desktop/bb774063(v=vs.85).aspx + shell.application :> windows() constant ShellWindows // ( -- obj ) shell.application windows object + /// ShellWindows object https://msdn.microsoft.com/en-us/library/windows/desktop/bb773974(v=vs.85).aspx + ShellWindows :> count \ ==> 3 (number) 根本就是看 IE 開了幾個 tab 亦即 windows。 + ShellWindows :> item(0) \ ==> Windows Internet Explorer (object) https://msdn.microsoft.com/library/aa752084(v=vs.85).aspx + ShellWindows :> item(3) \ ==> null (null) 超過了就變成 null。 + ShellWindows :> item(0) :> LocationName \ ==> 星巴克华东 (string) Bingo!!! 真的碰到了! + ShellWindows :> item(0) :> LoCaTiOnUrL \ ==> http://www.president-starbucks.com.cn/index.html (string) + ShellWindows :> item(0) :> application \ ==> Windows Internet Explorer (object) 就是 item(0) 自己。 + [x] 其實 IE object 也可以這樣直接取得: + Set IE = CreateObject("InternetExplorer.Application"):kvm.push(IE) constant IE // ( -- obj ) Internet Explorer object + 然後透過 IE :> parent 應該也是回到 ShellWindows --> [ ] try try see .... 非也, 這個 IE.parent 還是它 + 自己。 + [x] 同上,改用 GetObject 看看, + Set ie = GetObject(,"InternetExplorer.Application"):kvm.push(ie) constant ie // ( -- obj ) Internet Explorer object + --> VBscript error : ActiveX component can't create object: 'GetObject' + --> 這是因為 IE 應該是個 single-instance object + [ ] 同上,改用 GetObject 的另一方式看看, + Set ie = GetObject("","InternetExplorer.Application"):kvm.push(ie) constant ie // ( -- obj ) Internet Explorer object + --> 成功了! 但它的 parent 還是自己。 + --> 每多開一個 tab 用 s" where name = 'iexplore.exe'" see-process . 來看就會多一個 process. + [x] 被 stop 停掉的 TIB 應該馬上 stop=false 以便只 stop 本 . + --> 改了 outer() 若無誤,記得連 project-k 也要修正。 + --> 錯! stop 必須 stop 全部工作。後續還有工作的情形用 ?rewind。 + [x] Need a ?rewind command + + [x] Have many bugs now. On excel.f and on ie.f/money.f. This bug happens on S7 when starting + ieforth.3we. First time said there are multiple excel and stoped including excel. So I close + visible excel workbooks. F5 reload and the below error happened. Retry can't fix it. Close + jeforth.3we and run again, still same problem. + ------------------- P A N I C ! ------------------------- + VBscript error : ActiveX component can't create object: 'GetObject' + stop: false + compiling: false + stack.length: 0 + rstack.length: 1 + ip: 1286 + ntib: 279 + tib.length: 65609 + tib: (,"excel.application"):kvm.push(xl)
+ [else] char Excel.Application ActiveXObject [then] to (excel.app) + ==> I guess this is again the "single-instance object" issue ... + ==> Bingo!! 不要用 ActiveXObject(), 用 CreateObject() or GetObject()。 + 而且 IE and Excel 都是 "single-instance object" 只要看到有多個 application object + 就可以當作是問題。 + + [ ] ie.f ok now, money.f 需要改寫 with new knowledge of ie.f. + [x] 如何取得 the active IE window? ==> 讓 user 自己從 list-ie-winsows 裡選。 [ ] 如何 用 jquery 去 query 用 ie.f attach 到的 web pabe? [ ] 改 hotkey.au3, 增加功能每周三中午前把 router 切好位置。 [ ] ie(i) 的 alias ie 有問題, run 不起來。 - ieWindow 也一樣問題。 + ieWindow 也一樣問題。 [x] JavaScript "Table to JSON" http://lightswitch05.github.io/table-to-json/ - works fine. - See YNote "Js Tutorial - Table to JSON _table_to_JSON_" + works fine. + See YNote "Js Tutorial - Table to JSON _table_to_JSON_" [x] 希望能把整個網頁都抓進來 jquery 搜尋/控制 其中的東西 - http://stackoverflow.com/questions/18145273/how-to-load-an-external-webpage-into-a-div-of-a-html-page -
- - -
- 真的可以 open 小網頁! -
- - -
+ http://stackoverflow.com/questions/18145273/how-to-load-an-external-webpage-into-a-div-of-a-html-page +
+ + +
+ 真的可以 open 小網頁! +
+ + +
[x] My Asus desktop rolled back to IE8 意外發現 (er) was not defined well. - ==> fixed. 分辨 HTML Tag 要用 ce@ :> nodeName 不是用 '[object Text]' 不可靠。 - 其實當時我就覺得用 elementObject.toString()=='[object Text]' 有點太過神奇。 + ==> fixed. 分辨 HTML Tag 要用 ce@ :> nodeName 不是用 '[object Text]' 不可靠。 + 其實當時我就覺得用 elementObject.toString()=='[object Text]' 有點太過神奇。 [x] autoit.f 不必寫甚麼在包裝過一層的命令, 給 au3 的使用例子就好了。 - 直接查 autoitx.hlp 看其他命令。多半是 keyboard / mouse 的命令。 + 直接查 autoitx.hlp 看其他命令。多半是 keyboard / mouse 的命令。 [ ] ie.f 裡 ready not-busy 常常等很久, 有時 readyStatus 卡在 1 不變 4, 配合收 event 可能較好。 [x] hcchen5600 2015/06/29 14:08:57 - 想用 jQuery 去 access jeforth 去 attach 的 IE object 網頁, 成功! 太棒了! - Fortunately the $() function has a second argument, the context, that has to be used here, like: - $('p', $(ht).context) ==> 去 study 這個 2nd argument 的玄機。 - -- - jQuery 2nd argument, see http://api.jquery.com/jQuery/ Categories: Core - jQuery 有很多種形式, jQuery("selector") 形式是原型 jQuery( selector [, context ] ) - 的簡略式, jQuery(element) 也很常用。鑽進 IE 去控制網頁用的是有 2nd argument - context object 的形式。 其中 context 實例 ShellWindows.item(theIE).document 即是。 - jQuery 的各種形式, - 1, jQuery(selector [,context]) - 2, jQuery(element) - 3, jQuery(elementArray) - 4, jQuery(object) - 5, jQuery(selection) <--- 猜想是第一式的結果 - 6, jQuery() - 7, jQuery( html [, ownerDocument ] ) - 8, jQuery( html, attributes ) - 9, jQuery( callback ) - -- - document js> $('div',pop()) 在 S7 會跑出 : JavaScript error : Permission denied - 可能又是 same origin policy issue。靠,這要怎麼避免? 關鍵是, 拿得到 IE document 可 - 讀是應該的, 要可寫才有得談 Same origin policy 算不算是個問題。 - ==> Surprise! 可以修改 Yahoo.com 在本地 DOH7 網頁上的內容。然後又發 - 現 document js> $("div",pop()) 也可以! 只是換了一部電腦而已。 - > document :> links[0].outerHTML="

hiiiii!!

" - > document :> links[1].outerHTML="

Loooooo!!

" - > document js> $("div",pop()) - OK - > .s - 3:

hi!!

(string) - 4:

Loooooo!!

(string) - 5: [object Object] (object) - ==> 回頭查 S7 上失敗時的網頁是 WKS eform http://wkseform.wistron.com/P00/FM_MyPage.aspx - --> 看能不能改 local 網頁? --> 也可以。 - --> 再試一遍 document js> $("div",pop()) 還是一樣 JavaScript error : Permission denied - --> 試別的網頁 --> 果然就好了! 原來是需要登入的網頁, jQuery 進去亂鑽,當然要 Permission denied - shit! 虛驚一場。 + 想用 jQuery 去 access jeforth 去 attach 的 IE object 網頁, 成功! 太棒了! + Fortunately the $() function has a second argument, the context, that has to be used here, like: + $('p', $(ht).context) ==> 去 study 這個 2nd argument 的玄機。 + -- + jQuery 2nd argument, see http://api.jquery.com/jQuery/ Categories: Core + jQuery 有很多種形式, jQuery("selector") 形式是原型 jQuery( selector [, context ] ) + 的簡略式, jQuery(element) 也很常用。鑽進 IE 去控制網頁用的是有 2nd argument + context object 的形式。 其中 context 實例 ShellWindows.item(theIE).document 即是。 + jQuery 的各種形式, + 1, jQuery(selector [,context]) + 2, jQuery(element) + 3, jQuery(elementArray) + 4, jQuery(object) + 5, jQuery(selection) <--- 猜想是第一式的結果 + 6, jQuery() + 7, jQuery( html [, ownerDocument ] ) + 8, jQuery( html, attributes ) + 9, jQuery( callback ) + -- + document js> $('div',pop()) 在 S7 會跑出 : JavaScript error : Permission denied + 可能又是 same origin policy issue。靠,這要怎麼避免? 關鍵是, 拿得到 IE document 可 + 讀是應該的, 要可寫才有得談 Same origin policy 算不算是個問題。 + ==> Surprise! 可以修改 Yahoo.com 在本地 DOH7 網頁上的內容。然後又發 + 現 document js> $("div",pop()) 也可以! 只是換了一部電腦而已。 + > document :> links[0].outerHTML="

hiiiii!!

" + > document :> links[1].outerHTML="

Loooooo!!

" + > document js> $("div",pop()) + OK + > .s + 3:

hi!!

(string) + 4:

Loooooo!!

(string) + 5: [object Object] (object) + ==> 回頭查 S7 上失敗時的網頁是 WKS eform http://wkseform.wistron.com/P00/FM_MyPage.aspx + --> 看能不能改 local 網頁? --> 也可以。 + --> 再試一遍 document js> $("div",pop()) 還是一樣 JavaScript error : Permission denied + --> 試別的網頁 --> 果然就好了! 原來是需要登入的網頁, jQuery 進去亂鑽,當然要 Permission denied + shit! 虛驚一場。 [x] jQuery 鑽進去了, 我在期待甚麼? 如果是個 iframe 則手動用 element.f 的 ce 也甚麼都看不到。 - 希望 jQuery 能有所不同。因為 F12 debugger 可以看得進去。 - ==> 真的成功了! - fubon js> $("iframe",g.fubon).length \ ==> 1 - fubon js> $("iframe",g.fubon)[0] obj>keys . \ ==> 有 src - fubon js> $("iframe",g.fubon)[0].src . \ ==> http://fubon-ebrokerdj.fbs.com.tw/SmartNavi3.asp?A=$^$^B$^BA$^BA]DJHTM&B=1 OK ^1 - ==> id=SysJustIFRAMEDIV 是用 Chrome F12 進去查出來的, document :> getElementById() 找得到嗎? - --> document :> getElementById("SysJustIFRAMEDIV") \ ==> null (null) - ==> 用 jQuery 看看 js> $("#SysJustIFRAMEDIV",g.fubon).length . \ ==> 0 - 也是沒找到, 改找所有的 table 看看。 - --> js> $("table",g.fubon).length . \ ==> 0 - 我可能是給錯參數了, 絕對有 table 的, 但指定 fubon 之下, 沒有, 很自然。用 jQuery 也是這個邏輯。 - [x] iframe 只有一個, 又有 src, 直接 browse ==> 可以。 + 希望 jQuery 能有所不同。因為 F12 debugger 可以看得進去。 + ==> 真的成功了! + fubon js> $("iframe",g.fubon).length \ ==> 1 + fubon js> $("iframe",g.fubon)[0] obj>keys . \ ==> 有 src + fubon js> $("iframe",g.fubon)[0].src . \ ==> http://fubon-ebrokerdj.fbs.com.tw/SmartNavi3.asp?A=$^$^B$^BA$^BA]DJHTM&B=1 OK ^1 + ==> id=SysJustIFRAMEDIV 是用 Chrome F12 進去查出來的, document :> getElementById() 找得到嗎? + --> document :> getElementById("SysJustIFRAMEDIV") \ ==> null (null) + ==> 用 jQuery 看看 js> $("#SysJustIFRAMEDIV",g.fubon).length . \ ==> 0 + 也是沒找到, 改找所有的 table 看看。 + --> js> $("table",g.fubon).length . \ ==> 0 + 我可能是給錯參數了, 絕對有 table 的, 但指定 fubon 之下, 沒有, 很自然。用 jQuery 也是這個邏輯。 + [x] iframe 只有一個, 又有 src, 直接 browse ==> 可以。 [/] hcchen5600 2015/06/29 15:38:58 - 以上 Fubon 這個 iframe 頁面 ^1 沒有 倒有 竟然可用 .body 來 access: - > document :> body . \ ==> [object HTMLFrameSetElement] OK - ==> 這是常識! http://www.cnblogs.com/yinluhui0229/archive/2011/04/27/2030822.html - YoudaoNote "frame,iframe,frameset用法和区别" - 每個 frame 都有自己的 ... document。 + 以上 Fubon 這個 iframe 頁面 ^1 沒有 倒有 竟然可用 .body 來 access: + > document :> body . \ ==> [object HTMLFrameSetElement] OK + ==> 這是常識! http://www.cnblogs.com/yinluhui0229/archive/2011/04/27/2030822.html + YoudaoNote "frame,iframe,frameset用法和区别" + 每個 frame 都有自己的 ... document。 [/] frame (等於是另一個網頁) 要怎麼 access - --> document :> getElementsByTagName("frame").length . \ ==> 3 OK the ^1 fubon page - --> document :> getElementsByTagName("frame")[2] obj>keys . \ ==> 列出 members - 有 getElementsBy TagName,ClassName 但是沒有 ById 想想好像也有道理。 - --> 想把 frame 顯示在 jeforth.3we outputbox 可能做不到: - cls document :> getElementsByTagName("frame")[0].outerHTML . - \ ==> OK - --> 看進去的入口猜是 contentDocument - document :> getElementsByTagName("frame")[2].contentDocument . \ ==> [object Document] 對了! - --> 試幾下就發現輸入股號的 frame 是 1 號, - document :> getElementsByTagName("frame")[1].contentDocument.getElementsByTagName("input").length . \ ==> 2 - document :> getElementsByTagName("frame")[1].contentDocument.getElementsByTagName("input") value inputs - inputs :> [0].outerHTML \ ==> - inputs :> [1].outerHTML \ ==> - --> inputs :: [1].value=5490 --> 成功! - 對應的 button 是下一格 裡的 裏頭有 onclick。如何定位到這個 image 方法很多。 - 取 inputs :: [1] 的 siblings 找到 TagName = img 的就是了。 - --> inputs :> [1].nextElementSibling \ ==> null OK 此法不通,要看它的結構,隔一個 就不行了。 - --> 在該 table 裡找 TagName = img - inputs :> [1].parentElement . \ ==> [object HTMLTableDataCellElement] - inputs :> [1].parentElement.parentElement . \ ==> [object HTMLTableRowElement] - inputs :> [1].parentElement.parentElement.getElementsByTagName("img").length . \ ==> 2 OK 成功! - --> 改用該 frame 的 document 來找 TagName = img: - document :> getElementsByTagName("frame")[1].contentDocument constant theFrame or SysJustHead, name of the frame. - theFrame :> getElementsByTagName("img").length \ ==> 5 (number) - theFrame :> getElementsByTagName("img")[0].getAttribute("src") \ ==> /images/TransDot.gif (string) - theFrame :> getElementsByTagName("img")[1].getAttribute("src") \ ==> /images/TransDot.gif (string) - theFrame :> getElementsByTagName("img")[2].getAttribute("src") \ ==> /images/TransDot.gif (string) - theFrame :> getElementsByTagName("img")[3].getAttribute("src") \ ==> /images/btn_ok.gif (string) - theFrame :> getElementsByTagName("img")[4].getAttribute("src") \ ==> /images/TransDot.gif (string) - --> theFrame :> getElementsByTagName("img")[3].click() 成功! 網頁開始 load 5490 了。 - --> 其實這些 frame 都是有 name 的 - ==> 這個是輸入股號的 frame: - document :> getElementsByName("SysJustHead").length \ ==> 1 OK - document :> getElementsByName("SysJustHead")[0].getAttribute("name") \ ==> SysJustHead (string) OK - ==> 這個是 SysJustBody 左右兩半的部分. - document :> getElementsByName("SysJustBody").length \ ==> 1 (number) OK - document :> getElementsByName("SysJustBody")[0].getAttribute("name") \ ==> SysJustBody (string) OK - ==> 所有要 click 的 link 都在裡面 - document :> getElementsByName("SysJustBody")[0] constant SysJustBody - SysJustBody :> contentDocument list-links - 0 所屬產業 11 補充揭露事項 22 產銷組合 33 資產負債季表 - ... snip ... - --> SysJustBody :> contentDocument.links[17].click() 成功! - --> 17 經營績效 的 table id oMainTable 裏頭還有 select 在 tr id=oScrollHead 裡。 + --> document :> getElementsByTagName("frame").length . \ ==> 3 OK the ^1 fubon page + --> document :> getElementsByTagName("frame")[2] obj>keys . \ ==> 列出 members + 有 getElementsBy TagName,ClassName 但是沒有 ById 想想好像也有道理。 + --> 想把 frame 顯示在 jeforth.3we outputbox 可能做不到: + cls document :> getElementsByTagName("frame")[0].outerHTML . + \ ==> OK + --> 看進去的入口猜是 contentDocument + document :> getElementsByTagName("frame")[2].contentDocument . \ ==> [object Document] 對了! + --> 試幾下就發現輸入股號的 frame 是 1 號, + document :> getElementsByTagName("frame")[1].contentDocument.getElementsByTagName("input").length . \ ==> 2 + document :> getElementsByTagName("frame")[1].contentDocument.getElementsByTagName("input") value inputs + inputs :> [0].outerHTML \ ==> + inputs :> [1].outerHTML \ ==> + --> inputs :: [1].value=5490 --> 成功! + 對應的 button 是下一格 裡的 裏頭有 onclick。如何定位到這個 image 方法很多。 + 取 inputs :: [1] 的 siblings 找到 TagName = img 的就是了。 + --> inputs :> [1].nextElementSibling \ ==> null OK 此法不通,要看它的結構,隔一個 就不行了。 + --> 在該 table 裡找 TagName = img + inputs :> [1].parentElement . \ ==> [object HTMLTableDataCellElement] + inputs :> [1].parentElement.parentElement . \ ==> [object HTMLTableRowElement] + inputs :> [1].parentElement.parentElement.getElementsByTagName("img").length . \ ==> 2 OK 成功! + --> 改用該 frame 的 document 來找 TagName = img: + document :> getElementsByTagName("frame")[1].contentDocument constant theFrame or SysJustHead, name of the frame. + theFrame :> getElementsByTagName("img").length \ ==> 5 (number) + theFrame :> getElementsByTagName("img")[0].getAttribute("src") \ ==> /images/TransDot.gif (string) + theFrame :> getElementsByTagName("img")[1].getAttribute("src") \ ==> /images/TransDot.gif (string) + theFrame :> getElementsByTagName("img")[2].getAttribute("src") \ ==> /images/TransDot.gif (string) + theFrame :> getElementsByTagName("img")[3].getAttribute("src") \ ==> /images/btn_ok.gif (string) + theFrame :> getElementsByTagName("img")[4].getAttribute("src") \ ==> /images/TransDot.gif (string) + --> theFrame :> getElementsByTagName("img")[3].click() 成功! 網頁開始 load 5490 了。 + --> 其實這些 frame 都是有 name 的 + ==> 這個是輸入股號的 frame: + document :> getElementsByName("SysJustHead").length \ ==> 1 OK + document :> getElementsByName("SysJustHead")[0].getAttribute("name") \ ==> SysJustHead (string) OK + ==> 這個是 SysJustBody 左右兩半的部分. + document :> getElementsByName("SysJustBody").length \ ==> 1 (number) OK + document :> getElementsByName("SysJustBody")[0].getAttribute("name") \ ==> SysJustBody (string) OK + ==> 所有要 click 的 link 都在裡面 + document :> getElementsByName("SysJustBody")[0] constant SysJustBody + SysJustBody :> contentDocument list-links + 0 所屬產業 11 補充揭露事項 22 產銷組合 33 資產負債季表 + ... snip ... + --> SysJustBody :> contentDocument.links[17].click() 成功! + --> 17 經營績效 的 table id oMainTable 裏頭還有 select 在 tr id=oScrollHead 裡。 [/] Win7, jeforth.3we inputbox 怪怪的, back-space 倒不回去。 [/] Win7, jeforth.3we Alt-Up 之後, 上下鍵一跳兩行! @@ -3558,1230 +3558,1230 @@ [x] Excel 的時間 相容於 vb> CDate("2015/1/1 1:23:45") 與 JavaScript 的時間不相容。 [x] 大驚奇! excel time 值屬 (Date) type 其 boolean 有可能是 false !! - See work.f hcchen5600 2015/07/15 15:49:42 + See work.f hcchen5600 2015/07/15 15:49:42 [x] jeforth.3we element.f or ie.f hover mouse cursor on the page turns objects with red frame - line. So I can copy its outer or inner HTML to jeforth.hta outputbox and then use element.f - to trim them up. - ===> moved to ie.f + line. So I can copy its outer or inner HTML to jeforth.hta outputbox and then use element.f + to trim them up. + ===> moved to ie.f [x] 用部門代碼查表 departmentcode.json - // key(i).value 就是本表的 key 或 index 值, 要查 hash 表, 得重複嘗試。 - // 如果失敗就從最後少一個字母再試,直到兩個字母也失敗為止才放棄。 - // 失敗時傳回 undefined 正好。這個 function 稱為 lookup 即可。 - code lookup ( hash key -- ) \ Lookup the hash table that has partial keys with the full key - (function(hash,index){ // 查表 return hash[index] or undefined - for(var i=index; i.length>=2; i=i.slice(0,-1)){ - var v = hash[i]; - if(typeof(v)!="undefined") break; - } - push(v); - })(pop(1),pop()); end-code - : query-dept ( hash dept -- ) \ See the department info - char BG dup . char : . space js> tos(2)[pop()] over lookup . cr - char BD dup . char : . space js> tos(2)[pop()] over lookup . cr - char DEPT dup . char : . space js> tos(2)[pop()] over lookup . cr - char DEPT2 dup . char : . space js> tos(2)[pop()] over lookup . cr - char JamesYu dup . char : . space js> tos(2)[pop()] over lookup . cr - char Payroll dup . char : . space js> tos(2)[pop()] over lookup . cr - char Site dup . char : . space js> tos(2)[pop()] over lookup . cr - char Boss dup . char : . space js> tos(2)[pop()] over lookup . cr - char Assistant dup . char : . space js> tos(2)[pop()] over lookup . cr - char WKSRD dup . char : . space js> tos(2)[pop()] over lookup . cr - 2drop ; + // key(i).value 就是本表的 key 或 index 值, 要查 hash 表, 得重複嘗試。 + // 如果失敗就從最後少一個字母再試,直到兩個字母也失敗為止才放棄。 + // 失敗時傳回 undefined 正好。這個 function 稱為 lookup 即可。 + code lookup ( hash key -- ) \ Lookup the hash table that has partial keys with the full key + (function(hash,index){ // 查表 return hash[index] or undefined + for(var i=index; i.length>=2; i=i.slice(0,-1)){ + var v = hash[i]; + if(typeof(v)!="undefined") break; + } + push(v); + })(pop(1),pop()); end-code + : query-dept ( hash dept -- ) \ See the department info + char BG dup . char : . space js> tos(2)[pop()] over lookup . cr + char BD dup . char : . space js> tos(2)[pop()] over lookup . cr + char DEPT dup . char : . space js> tos(2)[pop()] over lookup . cr + char DEPT2 dup . char : . space js> tos(2)[pop()] over lookup . cr + char JamesYu dup . char : . space js> tos(2)[pop()] over lookup . cr + char Payroll dup . char : . space js> tos(2)[pop()] over lookup . cr + char Site dup . char : . space js> tos(2)[pop()] over lookup . cr + char Boss dup . char : . space js> tos(2)[pop()] over lookup . cr + char Assistant dup . char : . space js> tos(2)[pop()] over lookup . cr + char WKSRD dup . char : . space js> tos(2)[pop()] over lookup . cr + 2drop ; [x] excel.f 在有 excel 的 S7 OA 上也被跳過了, 原因是下面這段 code 出乎意料地傳回 'undefined' , - - On Error Resume Next - Set xl=GetObject(,"excel.application") - kvm.push(xl) - - --> 去掉 "On Error Resume Next" 後即見原因: - VBscript error : ActiveX component can't create object: 'GetObject' - 我猜這個 excel process 是有問題了。把它 kill 掉看看 --> 果然好了。 - ==> 加上這種情形的警告。 + + On Error Resume Next + Set xl=GetObject(,"excel.application") + kvm.push(xl) + + --> 去掉 "On Error Resume Next" 後即見原因: + VBscript error : ActiveX component can't create object: 'GetObject' + 我猜這個 excel process 是有問題了。把它 kill 掉看看 --> 果然好了。 + ==> 加上這種情形的警告。 [x] Improve see-dept , list all possible departments - hash 的 key 有很多是部門代碼的開頭幾個字母, lookup 會自動把 i 縮短來嘗試。 - 原來的 lookup 是用 v = hash[i]; 查表, 所以 i 怎麼縮必須是 hash 有的 key。 - 如果 i 已經比 hash 的 key 短, 就查不到了。 - ==> 如果 input 很長, 沒有 hash 吻合。把 i 截短 重試, 直到有吻合的為止。--> 現有的 algorithm, 精確。 - ==> 如果以上失敗,就拿所有的 key 來跟 i 比。比 i 短的就不對了, - 比 i 長的 key 截短來比 --> 結果可以一 key 多 value 都列出來。 - ==> 做成另一組 lookup2 跟 see-dept2 吧 - ==> see-departments 1s1k + hash 的 key 有很多是部門代碼的開頭幾個字母, lookup 會自動把 i 縮短來嘗試。 + 原來的 lookup 是用 v = hash[i]; 查表, 所以 i 怎麼縮必須是 hash 有的 key。 + 如果 i 已經比 hash 的 key 短, 就查不到了。 + ==> 如果 input 很長, 沒有 hash 吻合。把 i 截短 重試, 直到有吻合的為止。--> 現有的 algorithm, 精確。 + ==> 如果以上失敗,就拿所有的 key 來跟 i 比。比 i 短的就不對了, + 比 i 長的 key 截短來比 --> 結果可以一 key 多 value 都列出來。 + ==> 做成另一組 lookup2 跟 see-dept2 吧 + ==> see-departments 1s1k [x] hcchen5600 2015/08/21 17:40:12 - 完成 [begin][again] [begin][until] [for][next] interpret mode 的重要 flow control 命令 - 以後不用 cut .. rewind 了。 + 完成 [begin][again] [begin][until] [for][next] interpret mode 的重要 flow control 命令 + 以後不用 cut .. rewind 了。 [x] Use this line to setup Fubon e01 association in excel - ==> [begin] DDE-formula down @?stop 10 nap [again] + ==> [begin] DDE-formula down @?stop 10 nap [again] [x] study meney.f against the recent decline. [x] work on project-k jeforth.f [x] 新增 private folder 放 work.f money.f departmentcode.json 等。 - --> 看怎麼把 project-k-kernel merge 回 master? + --> 看怎麼把 project-k-kernel merge 回 master? [x] 把 jeforth.3we 的 kernel 換成 project-k. project-k 的 cub.html 已經成功把 - pack-help 獨立出來, vm/kvm 的問題也搞懂了. 應該從 jeforth.f 改好就好了。 - jeforth.3we 還是可以自稱 kvm 噓~~~ ===> 不要直接改, 先用 cub.html debug。 - 或者用帶入新 vm 的手法直接在 jeforth.3we 裡 debug。 + pack-help 獨立出來, vm/kvm 的問題也搞懂了. 應該從 jeforth.f 改好就好了。 + jeforth.3we 還是可以自稱 kvm 噓~~~ ===> 不要直接改, 先用 cub.html debug。 + 或者用帶入新 vm 的手法直接在 jeforth.3we 裡 debug。 [x] cub.f 直接在 jeforth.3we 裡試驗 project-k-kernel 很成功。一下就把 cub.f - run 起來了。cub.f 沒有 selftest 所以不可靠, jeforth.3we 穩是基本要求。準備 - 改用 3we/kernel/jeforth.f + run 起來了。cub.f 沒有 selftest 所以不可靠, jeforth.3we 穩是基本要求。準備 + 改用 3we/kernel/jeforth.f [x] 用了很久的 packhelp() 傳回 "( foo ) bar" 或者 "( ?? ) No help message. Use // to add one." - 等於是從 tib 抽 help 出來。用新的 "parse-help" 取代,方法如下: - push(nexttoken('\n|\r')); // rest of the first line - execute("parse-help"); // ( "helpmsg" "rests" ) - tib = pop() + " " + tib.slice(ntib); ntib = 0; // "rests" + tib(ntib) - newhelp = pop(); + 等於是從 tib 抽 help 出來。用新的 "parse-help" 取代,方法如下: + push(nexttoken('\n|\r')); // rest of the first line + execute("parse-help"); // ( "helpmsg" "rests" ) + tib = pop() + " " + tib.slice(ntib); ntib = 0; // "rests" + tib(ntib) + newhelp = pop(); [x] project-k 的 panic 要表明身分,否則搞搞不清楚. [x] 從 jeforth.3we 下命令給 project-k VM 用 hotkey f8: - code {F8} ( "command line" -- ) \ Let project-k VM to run the inputbox - var cmd = inputbox.value; - inputbox.value=""; - g.k.dictate(cmd) ; - jump2endofinputbox.click(); - inputbox.focus(); - end-code + code {F8} ( "command line" -- ) \ Let project-k VM to run the inputbox + var cmd = inputbox.value; + inputbox.value=""; + g.k.dictate(cmd) ; + jump2endofinputbox.click(); + inputbox.focus(); + end-code [x] cub.f 好了,攻 selftest, 改良。 [x] Original (words) in jeforth.f is very powerful but without -v and -V. - While words and help was poor, because they were rely on voc.f unnecessarily. - So we need to improve words and help. --> 規定好 input 格式, 有助化簡程式。 - words/help [pattern [switch [argument]]] + While words and help was poor, because they were rely on voc.f unnecessarily. + So we need to improve words and help. --> 規定好 input 格式, 有助化簡程式。 + words/help [pattern [switch [argument]]] [x] 老經驗 - nexttoken('\n|\r'); // if use only '\n' then we get an unexpected ending '\r'. + nexttoken('\n|\r'); // if use only '\n' then we get an unexpected ending '\r'. [x] see ~(create)~ - JavaScript error on word ".0r" : Cannot read property 'length' of undefined - ==> RI,FP: 產生一個 colon word 方法很多,不一定已經有 cfa。 + JavaScript error on word ".0r" : Cannot read property 'length' of undefined + ==> RI,FP: 產生一個 colon word 方法很多,不一定已經有 cfa。 [x] 用 vm.init() 來設定 type() or print() function 多此一舉。已經有 vm.clearScreen 等 - 乾脆就不要 init() 了。projct-k 根本不知道也不用知道你需要 print() !! - ==> jeforth.js 有用到 type() 這樣一來 project-k 就認為自己在有 display 的地方執行?! - 雖然可以從 type() 的定義解決,總是不太理想。 - ==> 用到 type() 的地方 - 1. docode() 的 reDef warning ==> 改 call panic(state-object). - 2. panic() ==> 所有 error/warning 都 call panic() 如前。但 panic() 裡面先檢查有 - 沒有 vm.panic() 然後 call vm.panic(state)。 - 3. reset() 的 message 沒啥意義 - ==> 已經都用 k :: type=function..., k :: prompt=.. 的方式。 + 乾脆就不要 init() 了。projct-k 根本不知道也不用知道你需要 print() !! + ==> jeforth.js 有用到 type() 這樣一來 project-k 就認為自己在有 display 的地方執行?! + 雖然可以從 type() 的定義解決,總是不太理想。 + ==> 用到 type() 的地方 + 1. docode() 的 reDef warning ==> 改 call panic(state-object). + 2. panic() ==> 所有 error/warning 都 call panic() 如前。但 panic() 裡面先檢查有 + 沒有 vm.panic() 然後 call vm.panic(state)。 + 3. reset() 的 message 沒啥意義 + ==> 已經都用 k :: type=function..., k :: prompt=.. 的方式。 [x] Javascript 的 string 有 trim() method 可以去頭尾 white spaces, 從來不知。 - ==> 小心用! Windows XP 的 JScript v5.6 未 support. 故 project-k jeforth.f 裡都不能用。 + ==> 小心用! Windows XP 的 JScript v5.6 未 support. 故 project-k jeforth.f 裡都不能用。 [x] stackwas 放在 jeforth.js kernel 裏頭有必要嗎? --> 改成 tick(':').stackwas 了。 [x] 要參考 code word 自身,用 tick('name') 是可以考慮。有更好的辦法嗎? - ==> 現在 _me 直接就是該 word object 本身。 + ==> 現在 _me 直接就是該 word object 本身。 [x] working on db bp *debug* for cub.f - ==> resume function needs a static variable. - --> see processing.f, "JavaScript Module Pattern: In-Depth" in YouDao Notebook. - ==> I only want to get the code word object in its xt(), it's the argument! So, - simply call w.xt(w) passes w over, this simple! This is done in the inner(). - also "newxt=function(_me){..." in docode() of kernel jeforth.js. - ==> 經由 "newxt=function(_me){..." in docode() of kernel jeforth.js, and - simply call w.xt(w) in the inner() loop, we have _me in any code word - that indicates the code word itself. + ==> resume function needs a static variable. + --> see processing.f, "JavaScript Module Pattern: In-Depth" in YouDao Notebook. + ==> I only want to get the code word object in its xt(), it's the argument! So, + simply call w.xt(w) passes w over, this simple! This is done in the inner(). + also "newxt=function(_me){..." in docode() of kernel jeforth.js. + ==> 經由 "newxt=function(_me){..." in docode() of kernel jeforth.js, and + simply call w.xt(w) in the inner() loop, we have _me in any code word + that indicates the code word itself. [x] root word-list 還是叫 'forth' 好了, 當初想的是讓 project-k 盡量中性,先有 root 然 - 後再加上 forth voc 等。但因為 kernel jeforth.f 本身不 support vocabulary, 故以上 - 已經落空,根本分不出 root 跟 forth 不如就用 forth。還是可以在 voc.f 進來了以後再 - 拆分 root 跟 forth。但這麼做有何意義? 既無意義就表示都是 forth 即可。 - 所以 forth 變成永遠都在的部分,不想讓 words help 太雜亂時,盡量用 only work.f, - only git.f 等來讓輸出清爽。故 words 的 -v -V -V- option 都不必了,好耶。 + 後再加上 forth voc 等。但因為 kernel jeforth.f 本身不 support vocabulary, 故以上 + 已經落空,根本分不出 root 跟 forth 不如就用 forth。還是可以在 voc.f 進來了以後再 + 拆分 root 跟 forth。但這麼做有何意義? 既無意義就表示都是 forth 即可。 + 所以 forth 變成永遠都在的部分,不想讓 words help 太雜亂時,盡量用 only work.f, + only git.f 等來讓輸出清爽。故 words 的 -v -V -V- option 都不必了,好耶。 [x] should be moved to voc.f - : temp ( -- ) \ The source-code-file.f header macro - - ?skip2 --EOF-- \ skip it if already included - dup .( Including ) . cr char -- over over + + - js: tick('').masterMarker=tos()+"selftest--"; - also forth definitions (marker) (vocabulary) - last execute definitions - - js> tick('').masterMarker (marker) - include kernel/selftest.f - - tib.insert ; - js: last().name="source-code"+"-header" - /// skip including if the module has been included. - /// setup the self-test module - /// initiate vocabulary for the including module + : temp ( -- ) \ The source-code-file.f header macro + + ?skip2 --EOF-- \ skip it if already included + dup .( Including ) . cr char -- over over + + + js: tick('').masterMarker=tos()+"selftest--"; + also forth definitions (marker) (vocabulary) + last execute definitions + + js> tick('').masterMarker (marker) + include kernel/selftest.f + + tib.insert ; + js: last().name="source-code"+"-header" + /// skip including if the module has been included. + /// setup the self-test module + /// initiate vocabulary for the including module [x] cub.f 寫好了以後要併回 cub.html, project-k 保持單純。 [x] 大改寫, - [x] voc.f help calls (help) but origianl (help)/help 的 系統 help 要重新調配. - (help) 不該負責印系統 help --> (words) words , voc.f words help ok - o get jeForth() from jeforth.js > kvm = new jeForth() - o kernel/jeforth.f --> f/jeforth.f - o fortheval --> dictate - o print --> type - o 所有 g.sth 改成 vm.g.sth, 否則 g 本身要在哪裡定義? - --> 如果是在 init module (index.html, jeforth.hta, etc) 的 global - 可以考慮,但我不想跑出一個不是掛在 vm 下的例外來降低 porting project-k 的一致性。 - --> 如果在 kernel jeforth.js 裡,不好!多出個人色彩。 - --> 必須 HTA 下 .. vm.g.name .. 也能看得見。 - 本來看不見 vm 只看得見 kvm 但死認 kvm 當然不行,所以後來引進 - var jeforth_project_k_virtual_machine_object = new jeForth() - 把 vm 的本名弄到絕對不會有人來衝突,然後再介紹給 內部自己的 global vm。 - --> 所以 g hash 目前是掛在 vm.g 暫無他法。 - o internel kvm --> vm - o 去掉 kernel kvm.path = ["dummy", "f", "3nd/f", "3nd", "3nd/eforth.com", "playground"]; - o kvm.selftest_visible = true; - o kvm.minor_version = 1; // minor version specified by application, major version is from jeforth.js kernel. - var version = parseFloat(kvm.major_version+"."+kvm.minor_version); - kvm.greeting = function(){ - type("j e f o r t h . 3 h t m -- v"+version+'\n'); - type("source code http://github.com/hcchengithub/jeforth.3we\n"); - type("Program path " + window.location.toString()); - return(version); - } - o vm.base 改用 value -> vm.g.base [x]jeforth.f []3htm []3nd []3nw []3hta - o vm.editMode 改用 ({F2}).EditMode - o 改寫 vm.panic() + [x] voc.f help calls (help) but origianl (help)/help 的 系統 help 要重新調配. + (help) 不該負責印系統 help --> (words) words , voc.f words help ok + o get jeForth() from jeforth.js > kvm = new jeForth() + o kernel/jeforth.f --> f/jeforth.f + o fortheval --> dictate + o print --> type + o 所有 g.sth 改成 vm.g.sth, 否則 g 本身要在哪裡定義? + --> 如果是在 init module (index.html, jeforth.hta, etc) 的 global + 可以考慮,但我不想跑出一個不是掛在 vm 下的例外來降低 porting project-k 的一致性。 + --> 如果在 kernel jeforth.js 裡,不好!多出個人色彩。 + --> 必須 HTA 下 .. vm.g.name .. 也能看得見。 + 本來看不見 vm 只看得見 kvm 但死認 kvm 當然不行,所以後來引進 + var jeforth_project_k_virtual_machine_object = new jeForth() + 把 vm 的本名弄到絕對不會有人來衝突,然後再介紹給 內部自己的 global vm。 + --> 所以 g hash 目前是掛在 vm.g 暫無他法。 + o internel kvm --> vm + o 去掉 kernel kvm.path = ["dummy", "f", "3nd/f", "3nd", "3nd/eforth.com", "playground"]; + o kvm.selftest_visible = true; + o kvm.minor_version = 1; // minor version specified by application, major version is from jeforth.js kernel. + var version = parseFloat(kvm.major_version+"."+kvm.minor_version); + kvm.greeting = function(){ + type("j e f o r t h . 3 h t m -- v"+version+'\n'); + type("source code http://github.com/hcchengithub/jeforth.3we\n"); + type("Program path " + window.location.toString()); + return(version); + } + o vm.base 改用 value -> vm.g.base [x]jeforth.f []3htm []3nd []3nw []3hta + o vm.editMode 改用 ({F2}).EditMode + o 改寫 vm.panic() [ ] html5.f , element.f 的 selftest 都很欠缺,無聊寫寫。 [x] 3htm 的 platform.f 裡又有 (help) help 用來超漂亮的 help .... 也得改寫. - ---> keyboard events 有問題,回家繼續 debug + ---> keyboard events 有問題,回家繼續 debug [x] Error! source-code-header unknown. [x] jeforth.3we 的 'kernel' directory 直接就是 project-k 以免搞不清楚. - 本來認為是 kernel 的 jeforth.f 跟 voc.f 則搬到 f 裡去。不當作 kernel 了。 - [x] 這個要把 kernel 拿掉, 以 3htm 為例, - kvm.path = ["dummy","f", "3htm/f", "3htm/canvas", "3htm", "playground"]; + 本來認為是 kernel 的 jeforth.f 跟 voc.f 則搬到 f 裡去。不當作 kernel 了。 + [x] 這個要把 kernel 拿掉, 以 3htm 為例, + kvm.path = ["dummy","f", "3htm/f", "3htm/canvas", "3htm", "playground"]; [x] 這兩個不必佔用 vm.member , 應該直接放進 *debug* 的 members。 - 因為掛在 vm 下的 properties 都要有關聯 vm 內外的目的,如 vm.type(), vm.prompt, - 等. bp 跟 continue 或 resume 純粹是 jeforth.f 內部的東西, 應該屬於 value 放 - 在 vm.g 下才對. 宣告成 value 就對了。 - // debug - vm.bp = 0 // breakpoint <---- tick("*debug*").breakpoint=0 - vm.continue = 0 // *debug* resume point <---- tick("*debug*").resume=null - [x] index.html [x] cub.html [ ] 3nw [ ] 3nd + 因為掛在 vm 下的 properties 都要有關聯 vm 內外的目的,如 vm.type(), vm.prompt, + 等. bp 跟 continue 或 resume 純粹是 jeforth.f 內部的東西, 應該屬於 value 放 + 在 vm.g 下才對. 宣告成 value 就對了。 + // debug + vm.bp = 0 // breakpoint <---- tick("*debug*").breakpoint=0 + vm.continue = 0 // *debug* resume point <---- tick("*debug*").resume=null + [x] index.html [x] cub.html [ ] 3nw [ ] 3nd [x] some application didn't use this trick - e = (e) ? e : event; var keycode = (e.keyCode) ? e.keyCode : (e.which) ? e.which : false; - [x] index.html of 3HTML, [x] baby.html of project-k, [x] cub.html of project-k + e = (e) ? e : event; var keycode = (e.keyCode) ? e.keyCode : (e.which) ? e.which : false; + [x] index.html of 3HTML, [x] baby.html of project-k, [x] cub.html of project-k [x] chrome f12 跑出一個 message : - cub.html:6 Resource interpreted as Stylesheet but transferred with MIME type text/plain: "http://localhost:8888/common.css". - 我不喜歡這個解釋 http://stackoverflow.com/questions/12003107/resource-interpreted-as-script-but-transferred-with-mime-type-text-plain-for-l - 用 Win8 ie10 也一樣有問題 SEC7113: CSS was ignored due to mime type mismatch - --> utf-8 改成 ANSI 也沒用 - ==> 改直接執行 cub.html 就好了 (不透過 localhost:8888) --> 可能是 webserver.f 的問題. - ==> 果然是 webserver.f 的問題! https://msdn.microsoft.com/en-us/library/hh180764(v=vs.85).aspx - RI : An imported style sheet was not used due to the wrong MIME type in the HTTP header. - FP : Ensure style sheet file is delivered with the proper HTTP response header, which includes - a content type of text\css. See MIME-Handling Changes in Internet Explorer for more information. + cub.html:6 Resource interpreted as Stylesheet but transferred with MIME type text/plain: "http://localhost:8888/common.css". + 我不喜歡這個解釋 http://stackoverflow.com/questions/12003107/resource-interpreted-as-script-but-transferred-with-mime-type-text-plain-for-l + 用 Win8 ie10 也一樣有問題 SEC7113: CSS was ignored due to mime type mismatch + --> utf-8 改成 ANSI 也沒用 + ==> 改直接執行 cub.html 就好了 (不透過 localhost:8888) --> 可能是 webserver.f 的問題. + ==> 果然是 webserver.f 的問題! https://msdn.microsoft.com/en-us/library/hh180764(v=vs.85).aspx + RI : An imported style sheet was not used due to the wrong MIME type in the HTTP header. + FP : Ensure style sheet file is delivered with the proper HTTP response header, which includes + a content type of text\css. See MIME-Handling Changes in Internet Explorer for more information. [x] ie10 還抓到 cub.html 好多別的問題 - HTML1402: Character reference is missing an ending semicolon ";". - cub.html, line 243 character 22 - HTML1402: Character reference is missing an ending semicolon ";". - cub.html, line 707 character 62 - HTML1402: Character reference is missing an ending semicolon ";". - cub.html, line 707 character 124 - HTML1402: Character reference is missing an ending semicolon ";". - cub.html, line 710 character 34 - HTML1402: Character reference is missing an ending semicolon ";". - cub.html, line 712 character 103 - 在 chrome 都沒問題,而且所列之處根本就是 forth code ! 別管他。 + HTML1402: Character reference is missing an ending semicolon ";". + cub.html, line 243 character 22 + HTML1402: Character reference is missing an ending semicolon ";". + cub.html, line 707 character 62 + HTML1402: Character reference is missing an ending semicolon ";". + cub.html, line 707 character 124 + HTML1402: Character reference is missing an ending semicolon ";". + cub.html, line 710 character 34 + HTML1402: Character reference is missing an ending semicolon ";". + cub.html, line 712 character 103 + 在 chrome 都沒問題,而且所列之處根本就是 forth code ! 別管他。 [ ] review project-k GitHub wiki 的文件、linkage 等。 - 文章寫多了,動不動就有斷鏈、command 已經改名等問題。 + 文章寫多了,動不動就有斷鏈、command 已經改名等問題。 [/] 檢查 browser 是否 Chrome, alert 用 chrome 比較好。cub.html 在 Win 10 Edge 直接跑,慢得要命。 [x] 3htm jsc 裡 erase 無效 ... 感謝我自己! 以前已經發現在 jsc console 時 - inputbox.value 是 \10 因為 \r\n (Chrome & IE) 只吃掉 \r 故留下 \n 使得 inputbox 非 empty 因此 - {backspace} 不工作。修改判斷條件為 inputbox.value==""||inputbox.value=="\n" 即可 - * 3nw 也解過這個問題, 方法是在 jsc.xt 裡一見面就把 inputbox.value 清成 "" 也可以。 + inputbox.value 是 \10 因為 \r\n (Chrome & IE) 只吃掉 \r 故留下 \n 使得 inputbox 非 empty 因此 + {backspace} 不工作。修改判斷條件為 inputbox.value==""||inputbox.value=="\n" 即可 + * 3nw 也解過這個問題, 方法是在 jsc.xt 裡一見面就把 inputbox.value 清成 "" 也可以。 [x] tweak cub.html on going . . . so as to make a project-k release - rename to sample.html. project-k released. [ ] make it a release on github. + rename to sample.html. project-k released. [ ] make it a release on github. [x] webserver.f ok now. working on 3nd . . . - [x] no panic !!!! in jeforth.3nd.js <---- master kvm.panic() was missing. - in 3htm level doesn't work either <----- it works, it launchs F12 debugger. - [x] vm.gets() very poor, needs improvement. - --> e command tips ctrl-z at least - [x] fs.f has some self-test, they need to upgrade - [x] jsc.hlp, jsc.js - [ ] eforth.com + [x] no panic !!!! in jeforth.3nd.js <---- master kvm.panic() was missing. + in 3htm level doesn't work either <----- it works, it launchs F12 debugger. + [x] vm.gets() very poor, needs improvement. + --> e command tips ctrl-z at least + [x] fs.f has some self-test, they need to upgrade + [x] jsc.hlp, jsc.js + [ ] eforth.com [ ] jsc 能不能在 exit "", ret null 處停下來, 目前不會, 故看不到 ret / exit 就突然結束了。 [x] porting to project-k 大改寫 apply to 3HTA (3htm and 3nd are done) - [x] kernel/jeforth.js --> project-k/jeforth.js - [x] get jeForth() from jeforth.js > kvm = new jeForth() - [x] 去掉 kernel kvm.path = ["dummy", "f", "3nd/f", "3nd", "3nd/eforth.com", "playground"]; - [x] kernel/jeforth.f --> f/jeforth.f - [x] kvm.selftest_visible = true; // type() needs to check it - [x] kvm.minor_version = 1; // minor version specified by application, major version is from jeforth.js kernel. - var version = parseFloat(kvm.major_version+"."+kvm.minor_version); - kvm.greeting = function(){ - type("j e f o r t h . 3 h t m -- v"+version+'\n'); - type("source code http://github.com/hcchengithub/jeforth.3we\n"); - type("Program path " + window.location.toString()); - return(version); - } - [x] vm.base 改用 value -> vm.g.base [x]jeforth.f []3htm [x]3nd []3nw [x]3hta - [x] apply to all *.f files - [x] fortheval --> dictate [ ] apply to all *.f files - [x] print --> type [ ] apply to all *.f files - [x] 所有 g.sth 改成 vm.g.sth [ ] apply to all *.f files - [x] internel kvm --> vm - [x] js: vm.selftest_visible=true - [x] -->judge 改用 [d d] [p p] - [x] vm.editMode, in platform.f, 改用 {F2}.EditMode [x]3htm []3nd []3nw [x]3hta - [x]3htm [x]3nw [x]3hta all are in 3htm/f/platform.f - [x]3nd - [x] 改寫 vm.panic() - [x] 照理說 "kvm" 只應出現在 jeforth.hta 裡, 其他都用 "vm"。但是 vb.f 裡似乎免不了要用一次 "kvm" 讓 - VBscript 認得 "vm"。若 "kvm" 之名改了,vb.f 也得跟著改。<==== FP, use a very long VM name in global. + [x] kernel/jeforth.js --> project-k/jeforth.js + [x] get jeForth() from jeforth.js > kvm = new jeForth() + [x] 去掉 kernel kvm.path = ["dummy", "f", "3nd/f", "3nd", "3nd/eforth.com", "playground"]; + [x] kernel/jeforth.f --> f/jeforth.f + [x] kvm.selftest_visible = true; // type() needs to check it + [x] kvm.minor_version = 1; // minor version specified by application, major version is from jeforth.js kernel. + var version = parseFloat(kvm.major_version+"."+kvm.minor_version); + kvm.greeting = function(){ + type("j e f o r t h . 3 h t m -- v"+version+'\n'); + type("source code http://github.com/hcchengithub/jeforth.3we\n"); + type("Program path " + window.location.toString()); + return(version); + } + [x] vm.base 改用 value -> vm.g.base [x]jeforth.f []3htm [x]3nd []3nw [x]3hta + [x] apply to all *.f files + [x] fortheval --> dictate [ ] apply to all *.f files + [x] print --> type [ ] apply to all *.f files + [x] 所有 g.sth 改成 vm.g.sth [ ] apply to all *.f files + [x] internel kvm --> vm + [x] js: vm.selftest_visible=true + [x] -->judge 改用 [d d] [p p] + [x] vm.editMode, in platform.f, 改用 {F2}.EditMode [x]3htm []3nd []3nw [x]3hta + [x]3htm [x]3nw [x]3hta all are in 3htm/f/platform.f + [x]3nd + [x] 改寫 vm.panic() + [x] 照理說 "kvm" 只應出現在 jeforth.hta 裡, 其他都用 "vm"。但是 vb.f 裡似乎免不了要用一次 "kvm" 讓 + VBscript 認得 "vm"。若 "kvm" 之名改了,vb.f 也得跟著改。<==== FP, use a very long VM name in global. [x] working on improving 3nd jsc . . . done,it's very good now. - [x] 3htm [x] 3hta [ ] 3nw + [x] 3htm [x] 3hta [ ] 3nw [x] *debug* should print the prompt at entering *debug* mode. [x] include jQuery is done in html5.f , no good. Because html5.f is shared by 3hta, 3htm, and 3nw. - --> move include jQuery out of html5.f, jquery.f stand alone for 3hta. - --> type should be redefined in jquery.f but didn't --> fixed, but still pringing >>>
> js> - --> RI: multiple \t only first \t processed, because plain=function...; function vm.type=function... - something wrong. --> try newPlain() then ok. So which plain() is used? I know vm.plain() - --> 乾脆不要有 type() plain(), 都用 vm.type() vm.plain() 免生疑惑。 ==> Bingo! and shit 自找麻煩。 + --> move include jQuery out of html5.f, jquery.f stand alone for 3hta. + --> type should be redefined in jquery.f but didn't --> fixed, but still pringing >>>
> js> + --> RI: multiple \t only first \t processed, because plain=function...; function vm.type=function... + something wrong. --> try newPlain() then ok. So which plain() is used? I know vm.plain() + --> 乾脆不要有 type() plain(), 都用 vm.type() vm.plain() 免生疑惑。 ==> Bingo! and shit 自找麻煩。 [x] working on wsh.f selftest improvements [x] 半路發動 selftest 的方法,必須用 include 的才會自動幫 .f 檔加東西執行 selftest。 - ' :: enabled=true dropall cls --wmi.f-- include wmi.f - ' :: enabled=true dropall cls --excel.f-- include excel.f - ' :: enabled=true dropall cls --canvas.f-- include canvas.f - ' :: enabled=true dropall cls --ie.f-- include ie.f + ' :: enabled=true dropall cls --wmi.f-- include wmi.f + ' :: enabled=true dropall cls --excel.f-- include excel.f + ' :: enabled=true dropall cls --canvas.f-- include canvas.f + ' :: enabled=true dropall cls --ie.f-- include ie.f [x] ie.f 已知 ShellWindows 包括 fe ie . ie(i) ie 等不該以 ie 為名。 [x] fe/ie 其實是 sw 才對,ShellWindows.item(i) [x] ie.f 最嚴重的問題是這個, ShellWindows.item(index) 不能收 argument !!?? - \ [x] 不能直接用變數,很奇怪? <-- RI: 需 parseInt() cast 一下。 - \ theIE s" vm.g.ShellWindows.item(_i_)" :> replace(/_i_/,pop()) jsEval ; - > : sw var index=vm.g.theIE; var oo = vm.g.ShellWindows.item(index); oo; ; - > sw . - > JavaScript error on word "sw" : Invalid procedure call or argument - ==> 改用 code word - code sw2 - var index=vm.g.theIE; - var oo = vm.g.ShellWindows.item(index); - push(oo); - end-code - --> 結果一樣 - ==> 改用 .js 發現用 parseInt() cast 一下就好了 - var sa = new ActiveXObject("Shell.Application"); - var sw = sa.windows(); - var index = vm.g.theIE; - type(sw.item(index)); // 還是有問題 - --> - var sa = new ActiveXObject("Shell.Application"); - var sw = sa.windows(); - type(sw.item(parseInt(vm.g.theIE))); // parseInt() cast 一下就好了。 - - ==> : sw js> vm.g.ShellWindows.item(parseInt(vm.g.theIE)) ; <--- OK !! -[x] 在 wsh.f 裡會自動切中文? 如何避免? ---> 乾脆讓它 "Let me set a different input method for - each app window" @ Control Panel>Clock, Language, and Region > Language > Advanced settings. - 因為不讓它切它總是要切乾脆由它去吧! + \ [x] 不能直接用變數,很奇怪? <-- RI: 需 parseInt() cast 一下。 + \ theIE s" vm.g.ShellWindows.item(_i_)" :> replace(/_i_/,pop()) jsEval ; + > : sw var index=vm.g.theIE; var oo = vm.g.ShellWindows.item(index); oo; ; + > sw . + > JavaScript error on word "sw" : Invalid procedure call or argument + ==> 改用 code word + code sw2 + var index=vm.g.theIE; + var oo = vm.g.ShellWindows.item(index); + push(oo); + end-code + --> 結果一樣 + ==> 改用 .js 發現用 parseInt() cast 一下就好了 + var sa = new ActiveXObject("Shell.Application"); + var sw = sa.windows(); + var index = vm.g.theIE; + type(sw.item(index)); // 還是有問題 + --> + var sa = new ActiveXObject("Shell.Application"); + var sw = sa.windows(); + type(sw.item(parseInt(vm.g.theIE))); // parseInt() cast 一下就好了。 + + ==> : sw js> vm.g.ShellWindows.item(parseInt(vm.g.theIE)) ; <--- OK !! +[x] 在 wsh.f 裡會自動切中文? 如何避免? ---> 乾脆讓它 "Let me set a different input method for + each app window" @ Control Panel>Clock, Language, and Region > Language > Advanced settings. + 因為不讓它切它總是要切乾脆由它去吧! [x] Consider the proper .f for [stringify] and [parse] , according to 3hta's quit.f, - include voc.f \ voc.f is basic of forth language - ==> include html5.f \ HTML5 is HTA's plateform feature - include jquery.f \ Avoid Windows XP, Windows 7 HTA problems from happening immediately - include element.f \ HTML element manipulation - include platform.f \ Hotkey handlers and platform features - include vb.f \ Being able to run VBS is what HTA is for. - include wsh.f \ Windows Shell Host + include voc.f \ voc.f is basic of forth language + ==> include html5.f \ HTML5 is HTA's plateform feature + include jquery.f \ Avoid Windows XP, Windows 7 HTA problems from happening immediately + include element.f \ HTML element manipulation + include platform.f \ Hotkey handlers and platform features + include vb.f \ Being able to run VBS is what HTA is for. + include wsh.f \ Windows Shell Host [x] 在 panic() 裡面用 ' :> enabled 來判斷是否 free run mode。 - panic() 是 application dependent, 以 3hta 為例,如果是 free run mode ,碰到 severe panic - 通通要進 jsc 停下來; 如果是 interactive mode 則進 F12 debugger. - 看來 定義好之後要改寫 panic() 但是又不方便放進 jeforth.f 成為 common code, - 因此應該在 quit.f 裡面改寫。 - ------------- ^^^^ 以上不對 ^^^^ ------------------------------- - 實際上 panic() 要不要進 jsc 只跟 severity 有關, 沒機會管 .enabled. - [x] 3hta [x]3nd [x]3nw [x]3htm + panic() 是 application dependent, 以 3hta 為例,如果是 free run mode ,碰到 severe panic + 通通要進 jsc 停下來; 如果是 interactive mode 則進 F12 debugger. + 看來 定義好之後要改寫 panic() 但是又不方便放進 jeforth.f 成為 common code, + 因此應該在 quit.f 裡面改寫。 + ------------- ^^^^ 以上不對 ^^^^ ------------------------------- + 實際上 panic() 要不要進 jsc 只跟 severity 有關, 沒機會管 .enabled. + [x] 3hta [x]3nd [x]3nw [x]3htm [x] jsc.hlp , jsc.js 都該像 3nd 一樣獨立。 <--- jeforth.f 之後馬上就是 quit.f 不 - 能更早了! 所以放在 quit.f 裡面沒問題。===> ok, but 問題是重複寫了好幾份, 能不能在 quit.f - 裡面都參考同一份 jsc source code? - ==> done, 統一成只有兩分 jsc.f : 3hta,3htm,3nw and 3nd. - [x] 晚點把 3nd 裡的 jsc.hlp jsc.js delete 掉,已經沒有用了。 + 能更早了! 所以放在 quit.f 裡面沒問題。===> ok, but 問題是重複寫了好幾份, 能不能在 quit.f + 裡面都參考同一份 jsc source code? + ==> done, 統一成只有兩分 jsc.f : 3hta,3htm,3nw and 3nd. + [x] 晚點把 3nd 裡的 jsc.hlp jsc.js delete 掉,已經沒有用了。 [ ] T550 常常突然停下來, 造成 Multiplicity 斷線. 寫程式觀察這個情形。 [x] install nw.js 就是把 zip 解壓, 然後整個 folder copy 到 nodejs\ 的 path folder. - 因為 node.js 有 installer, nw.js 沒有. 正好目錄結構不衝突, 應該可以 ==> Yes, OK. + 因為 node.js 有 installer, nw.js 沒有. 正好目錄結構不衝突, 應該可以 ==> Yes, OK. [x] porting to project-k 大改寫 apply to 3nw (3htm 3nd 3hta are done) - ---- modify jeforth.3nw.html -------------------- - [x] kernel/jeforth.js --> project-k/jeforth.js - [x] get jeForth() from jeforth.js > kvm = new jeForth() - [x] 去掉 kernel kvm.path = ["dummy", "f", "3nd/f", "3nd", "3nd/eforth.com", "playground"]; - [x] kernel/jeforth.f --> f/jeforth.f - [x] kvm.selftest_visible = true; // type() needs to check it - [x] kvm.minor_version = 1; // minor version specified by application, major version is from jeforth.js kernel. - var version = parseFloat(kvm.major_version+"."+kvm.minor_version); - kvm.greeting = function(){ - type("j e f o r t h . 3 h t m -- v"+version+'\n'); - type("source code http://github.com/hcchengithub/jeforth.3we\n"); - type("Program path " + window.location.toString()); - return(version); - } - [x] vm.base 改用 value -> vm.g.base [x]jeforth.f [x]3htm [x]3nd [x]3nw [x]3hta - [x] drop kvm.init - [x] apply to all *.f files - [x] fortheval --> dictate [ ] apply to all *.f files - [x] print --> type [ ] apply to all *.f files - [x] 所有 g.sth 改成 vm.g.sth [ ] apply to all *.f files - [x] internel kvm --> vm - [x] js: vm.selftest_visible=true - [x] -->judge 改用 [d d] [p p] - [x] vm.editMode, in platform.f, 改用 {F2}.EditMode - [x]3htm [x]3nw [x]3hta - [x]3nd 另外 review <---- gets is different thing. - [x] 改寫 vm.panic() - [x] 照理說 "kvm" 只應出現在 jeforth.hta 裡, 其他都用 "vm"。但是 vb.f 裡似乎免不了要用一次 "kvm" 讓 - VBscript 認得 "vm"。若 "kvm" 之名改了,vb.f 也得跟著改。 - [x] jsc is now defined in quit.f - [x]3htm [x]3nw [x]3hta <---------- same 3htm/f/jsc.f - [x]3nd 另外 review <--------- 3nd/f/jsc.f + ---- modify jeforth.3nw.html -------------------- + [x] kernel/jeforth.js --> project-k/jeforth.js + [x] get jeForth() from jeforth.js > kvm = new jeForth() + [x] 去掉 kernel kvm.path = ["dummy", "f", "3nd/f", "3nd", "3nd/eforth.com", "playground"]; + [x] kernel/jeforth.f --> f/jeforth.f + [x] kvm.selftest_visible = true; // type() needs to check it + [x] kvm.minor_version = 1; // minor version specified by application, major version is from jeforth.js kernel. + var version = parseFloat(kvm.major_version+"."+kvm.minor_version); + kvm.greeting = function(){ + type("j e f o r t h . 3 h t m -- v"+version+'\n'); + type("source code http://github.com/hcchengithub/jeforth.3we\n"); + type("Program path " + window.location.toString()); + return(version); + } + [x] vm.base 改用 value -> vm.g.base [x]jeforth.f [x]3htm [x]3nd [x]3nw [x]3hta + [x] drop kvm.init + [x] apply to all *.f files + [x] fortheval --> dictate [ ] apply to all *.f files + [x] print --> type [ ] apply to all *.f files + [x] 所有 g.sth 改成 vm.g.sth [ ] apply to all *.f files + [x] internel kvm --> vm + [x] js: vm.selftest_visible=true + [x] -->judge 改用 [d d] [p p] + [x] vm.editMode, in platform.f, 改用 {F2}.EditMode + [x]3htm [x]3nw [x]3hta + [x]3nd 另外 review <---- gets is different thing. + [x] 改寫 vm.panic() + [x] 照理說 "kvm" 只應出現在 jeforth.hta 裡, 其他都用 "vm"。但是 vb.f 裡似乎免不了要用一次 "kvm" 讓 + VBscript 認得 "vm"。若 "kvm" 之名改了,vb.f 也得跟著改。 + [x] jsc is now defined in quit.f + [x]3htm [x]3nw [x]3hta <---------- same 3htm/f/jsc.f + [x]3nd 另外 review <--------- 3nd/f/jsc.f [x] 3nw 的 jsc 直接 copy 用 3hta 的是可以用的。有機會把 3hta 3htm 3nw 三個 jsc 統一起來。 - [x] 乾脆寫成一個 jsc.f 統一起來。 - [x] jsc.f 可以自給自足 vm.jsc 不需要 initial module 定義。 [x]3hta [x]3htm [x]3nw + [x] 乾脆寫成一個 jsc.f 統一起來。 + [x] jsc.f 可以自給自足 vm.jsc 不需要 initial module 定義。 [x]3hta [x]3htm [x]3nw [x] 3nw jsc 目前有下列問題: - [x] initializing of vm.jsc.cmd, vm.jsc.enable should be done in 3nw.html <=== 這兩個根本不用 init - jsc.cmd 用到前有給值的動作, vm.jsc.enable undefined 時正好是 fault。 - [x] Replace the arguments.callee.show by vm.jsc.statusToggle, that switches the status - prompt, by 't' command. - [x] exit/q/quit 光 return 好像不夠, 下 debugger; instruction 會卡在 jsc 裡出不來。--> restart 後消失了。 - [x] erase 有時無效,且 rstack 一直堆積同一個回返地址 - RI ==> 因為 single step 會 break 所有的動作, 連 {backSpace} 也被 break 到了!! - [x] 以後再想想辦法。jsc 裡面用到的 words 都會有這個問題 ==> jsc.enable is the solution. - [!] jsc help shows only a few lines <---- nw.js' problem + [x] initializing of vm.jsc.cmd, vm.jsc.enable should be done in 3nw.html <=== 這兩個根本不用 init + jsc.cmd 用到前有給值的動作, vm.jsc.enable undefined 時正好是 fault。 + [x] Replace the arguments.callee.show by vm.jsc.statusToggle, that switches the status + prompt, by 't' command. + [x] exit/q/quit 光 return 好像不夠, 下 debugger; instruction 會卡在 jsc 裡出不來。--> restart 後消失了。 + [x] erase 有時無效,且 rstack 一直堆積同一個回返地址 + RI ==> 因為 single step 會 break 所有的動作, 連 {backSpace} 也被 break 到了!! + [x] 以後再想想辦法。jsc 裡面用到的 words 都會有這個問題 ==> jsc.enable is the solution. + [!] jsc help shows only a few lines <---- nw.js' problem [x] vm.panic redefine was in 3hta/quit.f , move to 3htm/f/jsc.f - [x]3hta [x]3htm [x]3nw - [x]3nd + [x]3hta [x]3htm [x]3nw + [x]3nd [x] the --- save selftest.log --- thing in all quit.f can be removed - [x]3hta [x]3htm [x]3nw - [x]3nd + [x]3hta [x]3htm [x]3nw + [x]3nd [x] playground 裡面的 project-k things 可以清除了 [x] panic()'s state.level should be state.serious because it's used as a boolean. [x] needs a global name for the jeforthVM, so let it be - var jeforth_project_k_virtual_machine_object = new jeForth() - var kvm = jeforth_project_k_virtual_machine_object; - 裡要重新取得 vm through jeforth_project_k_virtual_machine_object - 全部都叫 vm 感覺也不好, init module 裡維持作 kvm, 因為 vm 聽起來是一個自稱, 事 - 實亦然。 - [x]3hta [x]3htm [x]3nw <----- 目前只 3hta 有用到。 - [x]3nd <-------- global.kvm = global.jeforth_project_k... = new jeForth(); + var jeforth_project_k_virtual_machine_object = new jeForth() + var kvm = jeforth_project_k_virtual_machine_object; + 裡要重新取得 vm through jeforth_project_k_virtual_machine_object + 全部都叫 vm 感覺也不好, init module 裡維持作 kvm, 因為 vm 聽起來是一個自稱, 事 + 實亦然。 + [x]3hta [x]3htm [x]3nw <----- 目前只 3hta 有用到。 + [x]3nd <-------- global.kvm = global.jeforth_project_k... = new jeForth(); [ ] vm 在 initial module (index.html) 裡只用來加掛 jeforth.f 需要的東西,主要是 I/O。 - 此外的東西都不該出現在 vm 下的第一層, 但在 vm.g 以下則 OK. [ ] 畫圖說明 - 這是為求整套系統 building blocks 之間的簡單明了。 - [ ] 手工 js> vm obj>keys . 列出所有 members 一一檢討。 - 3nw: > js> vm obj>keys . - major_version,execute,dictate,stack,rstack,words,dictionary,gui,appname, - selftest_visible,minor_version,host,path,screenbuffer,type,greeting,panic, - debug,fso,readTextFile,writeTextFile,prompt,argv,bye,clearScreen,plain,g, - [ ] --> inputbox - [ ] --> jsc - [ ] --> cmdhistory - [ ] --> forthConsoleHandler - 3hta: > js> vm obj>keys . - major_version,execute,dictate,stack,rstack,words,dictionary,appname,host,path, - selftest_visible,plain,type,greeting,debug,screenbuffer,prompt,ado,argv,bye, - clearScreen,panic,writeTextFile,readTextFile,g,process,fso,BinaryStream, - [ ] --> push,pop, - [ ] --> BinaryFile,objWMIService - [ ] --> vbscript, - [ ] --> jsc,cmdhistory, - [ ] --> forthConsoleHandler, - [ ] --> inputbox,EditMode, - 3nd: - major_version,execute,dictate,stack,rstack,words,dictionary,host,appname,path, - screenbuffer,selftest_visible,type,clearScreen,panic,greeting,fso,readTextFile, - writeTextFile,bye,gets,debug,prompt,argv,exec,stdio,g - [ ] --> jsc, - [ ] --> forthConsoleHandler, + 此外的東西都不該出現在 vm 下的第一層, 但在 vm.g 以下則 OK. [ ] 畫圖說明 + 這是為求整套系統 building blocks 之間的簡單明了。 + [ ] 手工 js> vm obj>keys . 列出所有 members 一一檢討。 + 3nw: > js> vm obj>keys . + major_version,execute,dictate,stack,rstack,words,dictionary,gui,appname, + selftest_visible,minor_version,host,path,screenbuffer,type,greeting,panic, + debug,fso,readTextFile,writeTextFile,prompt,argv,bye,clearScreen,plain,g, + [ ] --> inputbox + [ ] --> jsc + [ ] --> cmdhistory + [ ] --> forthConsoleHandler + 3hta: > js> vm obj>keys . + major_version,execute,dictate,stack,rstack,words,dictionary,appname,host,path, + selftest_visible,plain,type,greeting,debug,screenbuffer,prompt,ado,argv,bye, + clearScreen,panic,writeTextFile,readTextFile,g,process,fso,BinaryStream, + [ ] --> push,pop, + [ ] --> BinaryFile,objWMIService + [ ] --> vbscript, + [ ] --> jsc,cmdhistory, + [ ] --> forthConsoleHandler, + [ ] --> inputbox,EditMode, + 3nd: + major_version,execute,dictate,stack,rstack,words,dictionary,host,appname,path, + screenbuffer,selftest_visible,type,clearScreen,panic,greeting,fso,readTextFile, + writeTextFile,bye,gets,debug,prompt,argv,exec,stdio,g + [ ] --> jsc, + [ ] --> forthConsoleHandler, [x] jsc.prompt are "undefined" when it was from panic [x] project-k kernel porting done. Merge to jeforth.3we master. - --> Click "Pull" on "GitHub for Windows" --> "Pull request created" --> - 一頓亂搞解決 git merge 的問題 --> 好像是先切到 master, 然後 git merge the-working-branch。 - 會在 local 產生一個特別的版本, 其中如果有問題必須在 local 解決, 否則無法 push 上雲端。 + --> Click "Pull" on "GitHub for Windows" --> "Pull request created" --> + 一頓亂搞解決 git merge 的問題 --> 好像是先切到 master, 然後 git merge the-working-branch。 + 會在 local 產生一個特別的版本, 其中如果有問題必須在 local 解決, 否則無法 push 上雲端。 [x] 3nd 的 version 顯示沒有照新 style. - j e f o r t h . 3 n d -- r2 <============== should be major.minor - Node.js v0.12.4 ... snip .... - --> refer to 3htm's index.html + j e f o r t h . 3 n d -- r2 <============== should be major.minor + Node.js v0.12.4 ... snip .... + --> refer to 3htm's index.html [ ] ie.f shell.application.f 這種大題目要另外深入探討。 [x] inputbox arrow keys can be smarter. When it's empty, recall commands, otherwise - it moves cursor. <--- for [x]3hta, [x]3htm, [x]3nw they share the same platform.f - --> redefine 3htm/f/platform.f {up} {down} - --> 想錯了! 第一下可以 recall older command, 再一下因為 inputbox 已非 empty 就不行了。 - 故 up down 應該 launch alt-up history-selector 而非 ctrl-up ctrl-down recall。 - [x] ctrl-up,down 不會整理跨行的 textarea, alt-up history-selector 則會。兩者還是有一點 - 差別。故保留 ctrl-up ctrl-down 仍有效。 - [!] Chrome 3htm inputbox ^m 無效! 3hta ok,任其自然。 - [x] case 77: /* m */ ^m 在 HTA textarea 裡本來就有效。在 Chrome 無效也無法簒改 - e.keyCode。仿 excel 用 Alt-Enter 也不成功。難道只能切 EditMode? 但為什麼 EditMode - 有效? 因為 Alt-Enter 被 Chrome textarea 處裡掉了所以無效。 - --> 那就改用 shift-Enter 呀! ==> B i n g o ! ! - non-EditMode 想換行用 Shift-Enter 避免把命令發出去 - EditMode 用 Ctrl-Enter 發出命令 - [x] 下過命令自動取消 EditMode。 + it moves cursor. <--- for [x]3hta, [x]3htm, [x]3nw they share the same platform.f + --> redefine 3htm/f/platform.f {up} {down} + --> 想錯了! 第一下可以 recall older command, 再一下因為 inputbox 已非 empty 就不行了。 + 故 up down 應該 launch alt-up history-selector 而非 ctrl-up ctrl-down recall。 + [x] ctrl-up,down 不會整理跨行的 textarea, alt-up history-selector 則會。兩者還是有一點 + 差別。故保留 ctrl-up ctrl-down 仍有效。 + [!] Chrome 3htm inputbox ^m 無效! 3hta ok,任其自然。 + [x] case 77: /* m */ ^m 在 HTA textarea 裡本來就有效。在 Chrome 無效也無法簒改 + e.keyCode。仿 excel 用 Alt-Enter 也不成功。難道只能切 EditMode? 但為什麼 EditMode + 有效? 因為 Alt-Enter 被 Chrome textarea 處裡掉了所以無效。 + --> 那就改用 shift-Enter 呀! ==> B i n g o ! ! + non-EditMode 想換行用 Shift-Enter 避免把命令發出去 + EditMode 用 Ctrl-Enter 發出命令 + [x] 下過命令自動取消 EditMode。 [/] rename ntib to itib ok? think about it. --> forget it. [ ] 要不要突破第一行的限制? - --> In a code word definition, the ( foo ) \ baa must be at the first line with 'code' or - it's an error for JavaScript. + --> In a code word definition, the ( foo ) \ baa must be at the first line with 'code' or + it's an error for JavaScript. [x] HTA's vm.beep 本來在 platform.f 有用到, 改成 execute("beep") 把 vm.beep 取消。 - beep 也算是 I/O 定義成 vm.beep() 似乎有理。但既然可以用 execute("beep"), 還是不要的好。 - [x]3hta, [n/a]3htm, [ ]3nw, [ ]3nd + beep 也算是 I/O 定義成 vm.beep() 似乎有理。但既然可以用 execute("beep"), 還是不要的好。 + [x]3hta, [n/a]3htm, [ ]3nw, [ ]3nd [ ] Thinking of how to improve the user experience on http://www.figtaiwan.org/project/jeforth/jeforth.3we-master/, - I found a wonderful web page design helper called contentBuilder.js http://www.online-html-editor.org/. - It's beautiful and it can help us to convert a picture into base64 embeded HTML code. Good for jeforth - to have embeded pictures. - [ ] Use contentBuilder.js' online editor to design what I want to show on jeforth.3htm online. Then pay - some money to find a front end designer to translate into HTML. - http://www.online-html-editor.org/ + I found a wonderful web page design helper called contentBuilder.js http://www.online-html-editor.org/. + It's beautiful and it can help us to convert a picture into base64 embeded HTML code. Good for jeforth + to have embeded pictures. + [ ] Use contentBuilder.js' online editor to design what I want to show on jeforth.3htm online. Then pay + some money to find a front end designer to translate into HTML. + http://www.online-html-editor.org/ [x] 3hta to support both ado and fso switch - --> What happened if use fso? <--- see "HTA does not work with utf-8 with BOM" above - git.f 讀一半就會出錯, 因為有用到中文 word name。 - --> What happened if use ado? - "Safety Settings on this computer prohibit accessing a data source on another domain" - https://www.evernote.com/shard/s22/nl/2472143/db532ac2-04d1-4618-9fc9-e81dc3ed1d0a - [x] 2. HTA 版用 fso 開始, 看到 Windows 8 以上自動改用 ADO (file system) + --> What happened if use fso? <--- see "HTA does not work with utf-8 with BOM" above + git.f 讀一半就會出錯, 因為有用到中文 word name。 + --> What happened if use ado? + "Safety Settings on this computer prohibit accessing a data source on another domain" + https://www.evernote.com/shard/s22/nl/2472143/db532ac2-04d1-4618-9fc9-e81dc3ed1d0a + [x] 2. HTA 版用 fso 開始, 看到 Windows 8 以上自動改用 ADO (file system) [x] project-k can't use string.trim(), Windows XP JScript does not support that. - String.replace(/(^( |\t)*)|(( |\t)*$)/mg,''); // remove 頭尾 whitespaces. .trim() 舊 JScript v5.6 未 support + String.replace(/(^( |\t)*)|(( |\t)*$)/mg,''); // remove 頭尾 whitespaces. .trim() 舊 JScript v5.6 未 support [x] Windows XP can run jeforth.hta now. But can't readTextFile due to the error of : - "JavaScript error : Safety settings on this computer prohibit accessing a data - source on another domain." ===> 放棄 Windows XP. + "JavaScript error : Safety settings on this computer prohibit accessing a data + source on another domain." ===> 放棄 Windows XP. [/] Try Windows 7. ==> Windows 7 不一定可以順利執行, 乾脆偵測到發個警告。 - [/] 偵測 OS version needs objWMIService which is too late and is used, too late. - I wish HTA supports something to tell OS version? - --> jeforth.hta uses the below method to distinguish Windows version: - if(document.getElementsByClassName){ - document.getElementsByClassName('appname')[0].innerHTML=kvm.appname; - document.getElementsByClassName('appname')[1].innerHTML=kvm.appname; - } else{ - alert("Warning: Your system is old, IE10 or newer preferred. Try Windows upgrade."); - } + [/] 偵測 OS version needs objWMIService which is too late and is used, too late. + I wish HTA supports something to tell OS version? + --> jeforth.hta uses the below method to distinguish Windows version: + if(document.getElementsByClassName){ + document.getElementsByClassName('appname')[0].innerHTML=kvm.appname; + document.getElementsByClassName('appname')[1].innerHTML=kvm.appname; + } else{ + alert("Warning: Your system is old, IE10 or newer preferred. Try Windows upgrade."); + } ==> Give up Windows 7 [x] How to tell Windows version? - > objEnumWin32_OperatingSystem :> item().Version . - 6.2.9200 Win 8, 6.1.7601 Win 7, 10.0.10240 Win 10 + > objEnumWin32_OperatingSystem :> item().Version . + 6.2.9200 Win 8, 6.1.7601 Win 7, 10.0.10240 Win 10 [x] 自動判斷, Windows 8 以上就自動切 ado 否則續用 fso。 [x] Windows 7 compatibliity - [x] wmi.f Win32_OperatingSystem selftest memory 本來要求 > 2G 改成 > 128M - [x] skip html5.f appendChild selftest if IE/HTA too old. Check document.getElementsByClassName existance. - [x] html5.f selftest createElement aaa will become AAA on newer IE/HTA but Win7 older IE/HTA will not. + [x] wmi.f Win32_OperatingSystem selftest memory 本來要求 > 2G 改成 > 128M + [x] skip html5.f appendChild selftest if IE/HTA too old. Check document.getElementsByClassName existance. + [x] html5.f selftest createElement aaa will become AAA on newer IE/HTA but Win7 older IE/HTA will not. [x] ~.bat 的 path 設定使 jeforth.3we 對別人很難用。統一 install 方法,去個人化。 - 要求 node.js 先裝好, node.exe 入 path, nw.js 整個 copy 到 node.js home folder 因此 - nw.exe 也入了 path。 - [x] 修改文件, how to run 要改良說明。 + 要求 node.js 先裝好, node.exe 入 path, nw.js 整個 copy 到 node.js home folder 因此 + nw.exe 也入了 path。 + [x] 修改文件, how to run 要改良說明。 [x] 3nw's quit.f needs a jump focus at the end. [x] eforth.com selftest needs a rewrite --> Done. [x] bug - > help ShellWindows <--- also all other constants!! - JavaScript error on word "(words)" : Object doesn't support property or method 'toLowerCase' - JavaScript error on word "(help)" : Object doesn't support this property or method - JavaScript error on word "help" : Object doesn't support this property or method - --> check help calls (help) calls (words) <--- only one, see (help) shit!! - help and (help) are : Modified by platform.f for HTML table. - --> platform.f is common among 3htm too, so it's easy to debug --> try 3nw --> but 3nw is ok on help - --> include ie.f makes the problem? No. - --> not the experiment, - --> the problem has gone after restart jeforth.hta. + > help ShellWindows <--- also all other constants!! + JavaScript error on word "(words)" : Object doesn't support property or method 'toLowerCase' + JavaScript error on word "(help)" : Object doesn't support this property or method + JavaScript error on word "help" : Object doesn't support this property or method + --> check help calls (help) calls (words) <--- only one, see (help) shit!! + help and (help) are : Modified by platform.f for HTML table. + --> platform.f is common among 3htm too, so it's easy to debug --> try 3nw --> but 3nw is ok on help + --> include ie.f makes the problem? No. + --> not the experiment, + --> the problem has gone after restart jeforth.hta. [x] element.f 的 ce@ 有防呆,會自動剔除非 element objects 回復到前一個有效的 element。 - 但沒有警告, 今加上。 2015/10/5 14:14 + 但沒有警告, 今加上。 2015/10/5 14:14 [x] ie.f 裡寫出 - : remove-script-from-element ( element -- ) \ Through jQuery, the element will be modified. - js> $("script",pop()) ( jqObject ) - - for (var i=0; i - ( jqObject ) drop ; - /// The given element 可以是某個 IE 頁面不一定在本地。 - /// document js> $("*",pop())[0] ( the web page ) - /// remove-script-from-element \ document is trimed now - /// document :> body.innerHTML \ No script trouble + : remove-script-from-element ( element -- ) \ Through jQuery, the element will be modified. + js> $("script",pop()) ( jqObject ) + + for (var i=0; i + ( jqObject ) drop ; + /// The given element 可以是某個 IE 頁面不一定在本地。 + /// document js> $("*",pop())[0] ( the web page ) + /// remove-script-from-element \ document is trimed now + /// document :> body.innerHTML \ No script trouble [/] Strange, Windows 10 T550 makes an unknown JavaScript error by, - shell.application :> windows().item(0).document . - jsc: vm.g.ShellWindows.item(parseInt(vm.g.theIE)).document - --> try older version --> master is old, same problem on the T550. --> cold boot --> same problem. --> Windows update ... - --> try S7 Win8 --> OK no such problem. - --> !!! try other Windows 10 computer --> an UUD in the lab 10.0.10546 is ok!! so it's T550's problem. - --> but it appears like [object HTMLDocument] while S7 Win8 appears [object Document], different! - --> try Windows 10 at home --> it's ok. + shell.application :> windows().item(0).document . + jsc: vm.g.ShellWindows.item(parseInt(vm.g.theIE)).document + --> try older version --> master is old, same problem on the T550. --> cold boot --> same problem. --> Windows update ... + --> try S7 Win8 --> OK no such problem. + --> !!! try other Windows 10 computer --> an UUD in the lab 10.0.10546 is ok!! so it's T550's problem. + --> but it appears like [object HTMLDocument] while S7 Win8 appears [object Document], different! + --> try Windows 10 at home --> it's ok. [x] box2dweb-arrow.f 在 arrow.js 裡為了要把物理引擎的 world 傳出來給 jeforth 必須要 - 用到 vm.push 而vm 裡偏偏沒有 push, 從 kernel jeforth.js 裡把它們 export 出來吧! - --> 修改 project-k jeforth.js. - --> vb.f 也要簡化, 先前是它自己定義 vm.push vm.pop 可以拿掉了。 - [x] 同時, arrow.js 裡看不見 vm 因為 vm 是 project-k kernel jeforth.js 裡的自稱,外面 - 看不見. 而 kvm 是 jeforth.hta 給的 instance name 是個 global 所以 arrow.js 裡可 - 以看見。但是 arrow.js 不要用 kvm 而用 jeforth_project_k_virtual_machine_object - 來取得 vm。 + 用到 vm.push 而vm 裡偏偏沒有 push, 從 kernel jeforth.js 裡把它們 export 出來吧! + --> 修改 project-k jeforth.js. + --> vb.f 也要簡化, 先前是它自己定義 vm.push vm.pop 可以拿掉了。 + [x] 同時, arrow.js 裡看不見 vm 因為 vm 是 project-k kernel jeforth.js 裡的自稱,外面 + 看不見. 而 kvm 是 jeforth.hta 給的 instance name 是個 global 所以 arrow.js 裡可 + 以看見。但是 arrow.js 不要用 kvm 而用 jeforth_project_k_virtual_machine_object + 來取得 vm。 [x] 昨天忘了 push proejct-k, 在辦公室 vm.push vm.pop 還是沒有, 先用 quit.f 應急. 回家記得 push & 拿掉。 - working on branch release-3.1 <--- done + working on branch release-3.1 <--- done [x] release 3.1 之後 master == develop 如何複查? - --> S7 checkout to develop, T550 checkout to master - --> compare the two folders via Total Commander > menu : Commands > Synchronize Dirs... - 依內容 compare 只看 != 者, 忽略 .git folders. 證實無誤。 + --> S7 checkout to develop, T550 checkout to master + --> compare the two folders via Total Commander > menu : Commands > Synchronize Dirs... + 依內容 compare 只看 != 者, 忽略 .git folders. 證實無誤。 [x] User suffering problem, jeforth.3we and project-k are separated they don't know, release new README.md - immediately!!! ---> README.md improved - [x] but an even better arrangement is expected. --> Simply : git add -f project-k/jeforth.js + immediately!!! ---> README.md improved + [x] but an even better arrangement is expected. --> Simply : git add -f project-k/jeforth.js [x] Test downlaod jeforth.3we.zip from GitHub, run it, failed !!! <== unix2dos.exe is the solution - reDef code - JavaScript error on word "code" : Expected '}' - reDef code - JavaScript error on word "code" : Invalid character - Error! ; is compile-only. - Error! ; is compile-only. - Error! ; is compile-only. - Error! word is compile-only. - reDef \s - --> stop in quit.f no work. problem in jeforth.f - --> Stop right after reDef code, copy-paste the entire remaining jeforth.f ... PASS! - so what's the matter? - --> Strange, when defining init, the error message appears. But copy-pase ok. - JavaScript error on word "code" : Expected '}' - --> define init-debug which is mirror of init before init. stop before init, Binary search the problem. - --> gotcha ! vm.g.isSameArray = function (a,b) - --> RI! 竟然是中文 comment 的問題, 因為程式一開始是用 fso 而問題直接就發生在 jeforth.f 裡。 - ==> 中文 comment 之後加幾個 space 即可避免。<---- 誤導了!這是個已知的問題, 有 config setting 可以設定. - clone 下來的沒問題, 但是 [Download Zip] 下來的有問題因為 push 上去時 CRLF 被換成 LF, pull 下來時會自動 - 又把 LF 換回 CRLF, clone 下來時也無誤. 我猜 [Download Zip] 直接把雲端的 repo 打包下來時沒有做轉換, 所 - 以都是 LF 因而出問題。 - See http://www.cnblogs.com/flying_bat/archive/2013/09/16/3324769.html - --> 試過了, 只有 3hta 會這樣。3nw, 3nd, 3htm 都 ok. 所以要從 jeforth.hta 下手自己解決這個問題。 - --> 整個 project 已經 run 很久了, cloud 端都被轉換成 LF 了, 這至少對 project-k 是好事. 因為號稱它在所有 - 有 JavaScript 的地方都能用, 一見面就卡在 CRLF(MS), CR(Apple), LF(Linux) 的問題上不好。 - [x] 值得研究!! jeforth.hta should recover this problem in readTextFile and writeTextFile. - ==> jeforth.3we-develop.zip 就應該先處理好, 執行 jeforth.hta 時若未處裡已經太晚了, unix2dos.exe is the solution - [x] make sure Chinese text files HTA created, Big5, utf-8, and GB2312 are all 0D0A/CRLF conflict free - --> Write a Chinese or pure English string from HTA to a file, check the file, ---> it's utf-8/BOM that - has a EF BB BF at beginning. Always. Because my method is ado I guess --> Yes. New line is only LF 0A - --> switch to fso and try again --> Yes! switch to fso then there's no BOM so it's not utf-8 but a plain - text if it's English and Big5 for Chinese. New line is also only LF 0A. - --> '想' charCodeAt() is unicode 60-f3, Big5 is B7-51, utf-8 is E6-83-B3, GBK is CF-EB (saved from notepad++) - Online character code lookup http://bianma.supfree.net/sos.asp?id=12054 - --> GB2312 coded file readTextFile 結果 HTA 會把每個不認得的 code 逐 byte 用 65533 (0xfffd) 取代。 - 所以 '義' C1-78 讀進來變成 2 個 character [65533][120] (0x78 == 120)。讀進不認得的編碼沒救,因 - 為一堆都被 65533 替換掉了。 - --> 本來是 0A 或 0D 0A 皆保留 fso ado 都不會動他們。 <==== 錯! - [@] 解法就是, 先把所有的 charCodeAt(i) == 13 的都刪掉, 然後把所有的 charCodeAt(i) == 10 的都 - insert 13 改成 13 10. - binary-string>array - var aa=[11,22,33,44]; aa.splice(2,1); aa \ ==> 11,22,44 (array) - binary-array>string - ==> 無效, fso 一讀進 utf-8 就已經亂了。亂了再處理已經來不及。 - <無效取消> - [@] guaranteeCRLF (ss) // return a new string with new lines be CRLF - ok now, but read -> write file test still failed. --> device a way to see the actual file read by readTextFile - code remove-all-CR ( string -- string' ) \ Remove all CR 13 from the string - var aa = pop(), bb = ""; - for(var i=0; i write it to a file - code test - var ff = readTextFile_fso("f/jeforth.f"); - writeTextFile_fso ("ff.f", ff); - end-code - - --> 總之, 用 charCodeAt() 不用擔心會看錯, 0d 0a 看到了就是 CR LF 不會錯。 <=== 錯! - --> 錯了! - --> 看到問題了, 中文 comment 之後的 CRLF 真的有問題,把下行的 } 給吃上來了! - --> 因為 fso 不認得 utf-8 中文 - utf-8 中文行尾用 fso 讀進來會被搞亂, 行尾的 0A 不見了!!! <--- root cause - --> 隨便用個中文檔 fso 去讀應該可以複製現象... Bingo!! ... shit! 上面的實驗不夠周延。 - --> 實際上隨便一個 utf-8 中文檔, 用 fso 讀近來都會有 LF 或 CRLF 被吃掉的現象! - 解法曾考慮加強成 20 0D 0A 而非單 0D 0A, 但 fso 一讀進來就已經亂了!來不及做任何補救。 - --> 如果來源是 0D 0A 可能真的有助於避免 fso 把 0A 吃掉? ==> Bingo!! 完全正確。 - [x] 這下子 GitHub 的 CRLF 問題又陷入膠著了... 因為 fso 一讀進來單 LF 0A 的檔案就已經亂了。 - ( ) 看來 jeforth.f quit.f 等, 用 fso 讀進來的 module 都不能用 utf-8 而必須用 Big5 - (x) 主要檔案不要用中文。<---- 寫個程式來檢查 "string".charCodeAt(i) > 128 的就可能 - 是問題。 - code ansi? ( string -- T/F ) \ The string is all ANSI characters? (code < 128) - var ss = pop(), flag = true; - for (var i=0; i 128) { - flag = false; - type(ss.slice(i,i+20+'\n')); - i += 20; - } - } - push(flag); - end-code - ( ) 自動挑選正確編碼的 jeforth.js e.g. jeforth-big5.js, jeforth-utf8.js 跟相關檔案。 - ( ) 乾脆不 support Windows 7 以前的版本, 就可以不用 fso 直接都用 ado。 - [x] [Download Zip] extract 之後用轉碼程式先處理過, 很簡單: - ~\jeforth.3we>for /R %G in (*.*) do c:\your-path\bin\unix2dos.exe "%G" + reDef code + JavaScript error on word "code" : Expected '}' + reDef code + JavaScript error on word "code" : Invalid character + Error! ; is compile-only. + Error! ; is compile-only. + Error! ; is compile-only. + Error! word is compile-only. + reDef \s + --> stop in quit.f no work. problem in jeforth.f + --> Stop right after reDef code, copy-paste the entire remaining jeforth.f ... PASS! + so what's the matter? + --> Strange, when defining init, the error message appears. But copy-pase ok. + JavaScript error on word "code" : Expected '}' + --> define init-debug which is mirror of init before init. stop before init, Binary search the problem. + --> gotcha ! vm.g.isSameArray = function (a,b) + --> RI! 竟然是中文 comment 的問題, 因為程式一開始是用 fso 而問題直接就發生在 jeforth.f 裡。 + ==> 中文 comment 之後加幾個 space 即可避免。<---- 誤導了!這是個已知的問題, 有 config setting 可以設定. + clone 下來的沒問題, 但是 [Download Zip] 下來的有問題因為 push 上去時 CRLF 被換成 LF, pull 下來時會自動 + 又把 LF 換回 CRLF, clone 下來時也無誤. 我猜 [Download Zip] 直接把雲端的 repo 打包下來時沒有做轉換, 所 + 以都是 LF 因而出問題。 + See http://www.cnblogs.com/flying_bat/archive/2013/09/16/3324769.html + --> 試過了, 只有 3hta 會這樣。3nw, 3nd, 3htm 都 ok. 所以要從 jeforth.hta 下手自己解決這個問題。 + --> 整個 project 已經 run 很久了, cloud 端都被轉換成 LF 了, 這至少對 project-k 是好事. 因為號稱它在所有 + 有 JavaScript 的地方都能用, 一見面就卡在 CRLF(MS), CR(Apple), LF(Linux) 的問題上不好。 + [x] 值得研究!! jeforth.hta should recover this problem in readTextFile and writeTextFile. + ==> jeforth.3we-develop.zip 就應該先處理好, 執行 jeforth.hta 時若未處裡已經太晚了, unix2dos.exe is the solution + [x] make sure Chinese text files HTA created, Big5, utf-8, and GB2312 are all 0D0A/CRLF conflict free + --> Write a Chinese or pure English string from HTA to a file, check the file, ---> it's utf-8/BOM that + has a EF BB BF at beginning. Always. Because my method is ado I guess --> Yes. New line is only LF 0A + --> switch to fso and try again --> Yes! switch to fso then there's no BOM so it's not utf-8 but a plain + text if it's English and Big5 for Chinese. New line is also only LF 0A. + --> '想' charCodeAt() is unicode 60-f3, Big5 is B7-51, utf-8 is E6-83-B3, GBK is CF-EB (saved from notepad++) + Online character code lookup http://bianma.supfree.net/sos.asp?id=12054 + --> GB2312 coded file readTextFile 結果 HTA 會把每個不認得的 code 逐 byte 用 65533 (0xfffd) 取代。 + 所以 '義' C1-78 讀進來變成 2 個 character [65533][120] (0x78 == 120)。讀進不認得的編碼沒救,因 + 為一堆都被 65533 替換掉了。 + --> 本來是 0A 或 0D 0A 皆保留 fso ado 都不會動他們。 <==== 錯! + [@] 解法就是, 先把所有的 charCodeAt(i) == 13 的都刪掉, 然後把所有的 charCodeAt(i) == 10 的都 + insert 13 改成 13 10. + binary-string>array + var aa=[11,22,33,44]; aa.splice(2,1); aa \ ==> 11,22,44 (array) + binary-array>string + ==> 無效, fso 一讀進 utf-8 就已經亂了。亂了再處理已經來不及。 + <無效取消> + [@] guaranteeCRLF (ss) // return a new string with new lines be CRLF + ok now, but read -> write file test still failed. --> device a way to see the actual file read by readTextFile + code remove-all-CR ( string -- string' ) \ Remove all CR 13 from the string + var aa = pop(), bb = ""; + for(var i=0; i write it to a file + code test + var ff = readTextFile_fso("f/jeforth.f"); + writeTextFile_fso ("ff.f", ff); + end-code + + --> 總之, 用 charCodeAt() 不用擔心會看錯, 0d 0a 看到了就是 CR LF 不會錯。 <=== 錯! + --> 錯了! + --> 看到問題了, 中文 comment 之後的 CRLF 真的有問題,把下行的 } 給吃上來了! + --> 因為 fso 不認得 utf-8 中文 + utf-8 中文行尾用 fso 讀進來會被搞亂, 行尾的 0A 不見了!!! <--- root cause + --> 隨便用個中文檔 fso 去讀應該可以複製現象... Bingo!! ... shit! 上面的實驗不夠周延。 + --> 實際上隨便一個 utf-8 中文檔, 用 fso 讀近來都會有 LF 或 CRLF 被吃掉的現象! + 解法曾考慮加強成 20 0D 0A 而非單 0D 0A, 但 fso 一讀進來就已經亂了!來不及做任何補救。 + --> 如果來源是 0D 0A 可能真的有助於避免 fso 把 0A 吃掉? ==> Bingo!! 完全正確。 + [x] 這下子 GitHub 的 CRLF 問題又陷入膠著了... 因為 fso 一讀進來單 LF 0A 的檔案就已經亂了。 + ( ) 看來 jeforth.f quit.f 等, 用 fso 讀進來的 module 都不能用 utf-8 而必須用 Big5 + (x) 主要檔案不要用中文。<---- 寫個程式來檢查 "string".charCodeAt(i) > 128 的就可能 + 是問題。 + code ansi? ( string -- T/F ) \ The string is all ANSI characters? (code < 128) + var ss = pop(), flag = true; + for (var i=0; i 128) { + flag = false; + type(ss.slice(i,i+20+'\n')); + i += 20; + } + } + push(flag); + end-code + ( ) 自動挑選正確編碼的 jeforth.js e.g. jeforth-big5.js, jeforth-utf8.js 跟相關檔案。 + ( ) 乾脆不 support Windows 7 以前的版本, 就可以不用 fso 直接都用 ado。 + [x] [Download Zip] extract 之後用轉碼程式先處理過, 很簡單: + ~\jeforth.3we>for /R %G in (*.*) do c:\your-path\bin\unix2dos.exe "%G" [ ] jeforth.3hta 從 DOS box 下執行當然沒問題, 但是從 PowerShell 下執行就會有些 wsh.f 的 selftest 會過不了。 - 值得研究。 + 值得研究。 [ ] ie.f , Windows 10 , observed vm.g.ShellWindows.count==2 but both are null. [ ] Jump into jsc due to error then ESC is to go on the ongoing process, ok fine but - how to terminate the entire system? We need a jsc abort command? + how to terminate the entire system? We need a jsc abort command? [ ] A gh-pages branch which was created via GitHub .... don't know what it is for? - --> Ah! it's the project's web page!! I should use it. + --> Ah! it's the project's web page!! I should use it. [ ] project-k/jeforth.js >> vm.major_version = 2; // major version, jeforth.js kernel version. - --> 應該如實稱作 kernel_version 才對。 + --> 應該如實稱作 kernel_version 才對。 [ ] 'document' command 經常觸發 JavaScript 無名 error. 即使不用 ShellWindows 而直接取得 IE - object 如下, 經實驗證實這個 object 跟 sw.item(i) 是同一個,所以對這個無名 error 無助。 - var ie = new ActiveXObject('InternetExplorer.Application'); ie onstant InternetExplorer.Application - ==> 先嘗試 Chrome automation - ==> Try autoit - ==> Try jeforth.3wsh + object 如下, 經實驗證實這個 object 跟 sw.item(i) 是同一個,所以對這個無名 error 無助。 + var ie = new ActiveXObject('InternetExplorer.Application'); ie onstant InternetExplorer.Application + ==> 先嘗試 Chrome automation + ==> Try autoit + ==> Try jeforth.3wsh [x] 16:36 2015-11-09 Study how to publish jeforth.3htm directly from GitHub through rawgit.com. - 16:43 2015-11-09 It really works! Both baby.html and sample.html - http://rawgit.com/hcchengithub/project-k/master/baby.html - http://rawgit.com/hcchengithub/project-k/master/sample.html - [x] How to make a release, so as to try rawgit - Releases 有專門一群說明點 https://help.github.com/categories/releases/ - 原來 release 是從 GitHub.com 網頁上執行的,所以可以提供 binary 檔。 - ** rawgit 使用方法 ** - 到了 rawgit.com home page 它直接讓你輸入[Paste a GitHub file or Gist URL here]. - 如果輸入的位址是錯的,它不會有反應; 必須輸入對了,底下的測試版、production 版 URL - 才會自動反映出來。正確的輸入內容是從 GitHub.com 網址列抄過來的 - https://github.com/hcchengithub/project-k + '/master/' + 'filename' - 所組成。我把 project-k release 了一版 1.0 而 1.0 就是這版的 release_name 也就是 - branch name. - 輸入: - "https://github.com/hcchengithub/project-k/master/1.0/baby.html" - 得到: - "http://cdn.rawgit.com/hcchengithub/project-k/master/1.0/baby.html" - 但是這個不能用,要把 master 刪掉才可以, 變成: - "https://cdn.rawgit.com/hcchengithub/project-k/1.0/baby.html" - 就好了! + 16:43 2015-11-09 It really works! Both baby.html and sample.html + http://rawgit.com/hcchengithub/project-k/master/baby.html + http://rawgit.com/hcchengithub/project-k/master/sample.html + [x] How to make a release, so as to try rawgit + Releases 有專門一群說明點 https://help.github.com/categories/releases/ + 原來 release 是從 GitHub.com 網頁上執行的,所以可以提供 binary 檔。 + ** rawgit 使用方法 ** + 到了 rawgit.com home page 它直接讓你輸入[Paste a GitHub file or Gist URL here]. + 如果輸入的位址是錯的,它不會有反應; 必須輸入對了,底下的測試版、production 版 URL + 才會自動反映出來。正確的輸入內容是從 GitHub.com 網址列抄過來的 + https://github.com/hcchengithub/project-k + '/master/' + 'filename' + 所組成。我把 project-k release 了一版 1.0 而 1.0 就是這版的 release_name 也就是 + branch name. + 輸入: + "https://github.com/hcchengithub/project-k/master/1.0/baby.html" + 得到: + "http://cdn.rawgit.com/hcchengithub/project-k/master/1.0/baby.html" + 但是這個不能用,要把 master 刪掉才可以, 變成: + "https://cdn.rawgit.com/hcchengithub/project-k/1.0/baby.html" + 就好了! [ ] 問題是從 rawgit.com 或 cdn.rawgit.com 上執行都很容易出現 jquery loading 失敗。 - Ctrl-Enter 無效時,進 F12 debugger 即見該 error message。Refresh 幾次就會成功。 - [ ] 想讓 index.html 檢查看 jquery 有沒有 load 成功。 - [ ] 研究為何有這種情形? - ==> 寫一個簡單的 index.html 裡面就是 include jquery 跟檢查。看能不能複製問題出來。 - ==> https://rawgit.com/hcchengithub/jeforth.3we/develop/index.html?nop - run 得很好。 + Ctrl-Enter 無效時,進 F12 debugger 即見該 error message。Refresh 幾次就會成功。 + [ ] 想讓 index.html 檢查看 jquery 有沒有 load 成功。 + [ ] 研究為何有這種情形? + ==> 寫一個簡單的 index.html 裡面就是 include jquery 跟檢查。看能不能複製問題出來。 + ==> https://rawgit.com/hcchengithub/jeforth.3we/develop/index.html?nop + run 得很好。 [x] 試跑 solar-system.f 剪貼上去的 code 好像內碼有問題。 [x] only cloth.f 的時候, words, help 等只列出 cloth.f。但是 forth words 總是常駐在 - order 裡面。為了避免礙眼。 - [x] re-design rescan-word-hash, let it always read 'forth' first even when it's - not in the 'order' list. - [x] 執行 code 的時候觸發 js error, 這時候 compiling 的質居然是 "code" - reDef code - JavaScript error on word "code" : Unexpected token ] - reDef cr - *** Start self-test - ==> 我猜是 bb 裡面有問題。把 bb 拿掉部分看 error msg 還在不在? - ==> 果然就是這行的問題。 - wordhash[words[v][i].name] = words[v]][i]; - 靠! 多了個 ] ------------------------^ - 結論是, code word 裡面要是有 typo 會有 error on word "code" 症狀會變成 - 定義中的 word 的 xt 變成前一個 word 的,而且該 error 觸發 Chrome F12 debugger 時, - compiling 的值是個字串 "code"。 + order 裡面。為了避免礙眼。 + [x] re-design rescan-word-hash, let it always read 'forth' first even when it's + not in the 'order' list. + [x] 執行 code 的時候觸發 js error, 這時候 compiling 的質居然是 "code" + reDef code + JavaScript error on word "code" : Unexpected token ] + reDef cr + *** Start self-test + ==> 我猜是 bb 裡面有問題。把 bb 拿掉部分看 error msg 還在不在? + ==> 果然就是這行的問題。 + wordhash[words[v][i].name] = words[v]][i]; + 靠! 多了個 ] ------------------------^ + 結論是, code word 裡面要是有 typo 會有 error on word "code" 症狀會變成 + 定義中的 word 的 xt 變成前一個 word 的,而且該 error 觸發 Chrome F12 debugger 時, + compiling 的值是個字串 "code"。 [x] hcchen5600 2015/11/13 10:46:37 - [solar-system.f] cloth.f 改寫,變成教材。 + [solar-system.f] cloth.f 改寫,變成教材。 [x] backspace, Esc, Enter, arrow keys 等這些 hotkey 都應該只侷限在 inputbox 裡面, - 以避免干擾其他操作。 + 以避免干擾其他操作。 [x] 撰寫 cloth.md / cloth.html ==> tutor-cloth.f is better !! [x] up/down 直接 recall history 有點煩, 改成 default disabled。 [x] 合併 [if][else][then][begin][again][until][for][next] 成對應的 if else ... etc - 想想挺困難。不如設計一個 run: 來假裝它可以 run interpret mode 而其實 - 只是把 if else then begin .. etc 等改成對應的 [if][else][then][begin] 再 - 交給 interpreter 執行。 - ==> run: and (run:) + 想想挺困難。不如設計一個 run: 來假裝它可以 run interpret mode 而其實 + 只是把 if else then begin .. etc 等改成對應的 [if][else][then][begin] 再 + 交給 interpreter 執行。 + ==> run: and (run:) [x] recall all vocabulary after only - get-vocs js> tos().length [for] js> tos().shift() . cr [next] drop - get-vocs js> tos().length [for] js: order.push(tos().shift()) [next] drop rescan-word-hash - ==> "not-only" command recalls all loaded vocabularies. - + get-vocs js> tos().length [for] js> tos().shift() . cr [next] drop + get-vocs js> tos().length [for] js: order.push(tos().shift()) [next] drop rescan-word-hash + ==> "not-only" command recalls all loaded vocabularies. + [x] vm.cv <--- is an inappropriate thing, should be vm.g.cv if it has to be - a global, and it is. - So cv will be a value, a global too. - ==> this is a bigger effort to modify all existing .f files. Done. + a global, and it is. + So cv will be a value, a global too. + ==> this is a bigger effort to modify all existing .f files. Done. [ ] This info seems a better way for ie.f to modify a web page - https://msdn.microsoft.com/en-us/library/jj733572.aspx#Date + https://msdn.microsoft.com/en-us/library/jj733572.aspx#Date [x] 寫個 word 來 escape ... 裡的 HTML tag signs. - o 規定 ... 不能 nested, 而且要依序出現。 - o ... 是最裡面的, 即
..
要包在外面。 - ==> code escape ( "raw string" -- "cooked string" ) \ Escape '<','>' in tag. - ==> In unindent.f now + o 規定 ... 不能 nested, 而且要依序出現。 + o ... 是最裡面的, 即
..
要包在外面。 + ==> code escape ( "raw string" -- "cooked string" ) \ Escape '<','>' in tag. + ==> In unindent.f now [x] tutor-cloth.f source code 本身的美感略顯不足,因為
 區段不能 indent。
-    構想是:設計一個 ... tag 用來把其中的整段落往左 shift 到有某一行
-    撞到左邊了為止。Tab \t 要先換成 spaces 幾個? 可調。
-    ==> unindent.f done
+	構想是:設計一個 ... tag 用來把其中的整段落往左 shift 到有某一行
+	撞到左邊了為止。Tab \t 要先換成 spaces 幾個? 可調。
+	==> unindent.f done
 
 [x] 發現 HTA Regular Expression 一個問題 (Windows 10 !!)
-    :> replace(/\/\*(.|\r|\n)*?\*\//mg,"") \ 清除註解。這樣寫在 Chrom OK, 在 HTA 不行。
-    :> replace(/[/]\*(.|\r|\n)*?\*[/]/mg,"") \ 要改成 "[/]" 來表達 "/" 不能用 "\/"。
-    [x] Test tutor-cloth.f on Chrome and IE after modification --> [/] works fine.
+	:> replace(/\/\*(.|\r|\n)*?\*\//mg,"") \ 清除註解。這樣寫在 Chrom OK, 在 HTA 不行。
+	:> replace(/[/]\*(.|\r|\n)*?\*[/]/mg,"") \ 要改成 "[/]" 來表達 "/" 不能用 "\/"。
+	[x] Test tutor-cloth.f on Chrome and IE after modification --> [/] works fine.
 
 [x] contentEditable 這麼好用, 真希望 jeforth.3htm 可以在 local 直接跑,而不必再透過 local server。
-    複習一下,Chrome 卡在這裡:
-    XMLHttpRequest cannot load file:///C:/Users/hcche/Documents/GitHub/jeforth.3we/f/jeforth.f?text.
-    Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension,
-    https, chrome-extension-resource.
-    ---
-    問 Yap ,
-    [17:14:05] h.c.chen 陳厚成: jeforth 不透過 local server 真的就不能跑嗎? 卡在 XMLHttpRequest cannot load file ... ; Cross origin requests are only supported for protocol schemes ... ,
-    [17:16:20] h.c.chen 陳厚成: 因為用 JQuery 的 $.get 讀檔案, 例如 jeforth.f 就不行了。
-    [17:18:16] h.c.chen 陳厚成: ( 在網頁上跑的 jeforth )
-    [17:36:12] h.c.chen 陳厚成: 可能找到答案了
-    http://stackoverflow.com/questions/8449716/cross-origin-requests-are-only-supported-for-http-but-its-not-cross-domain
-    http://chrome-allow-file-access-from-file.com/
-    http://joshuamcginnis.com/2011/02/28/how-to-disable-same-origin-policy-in-chrome/
-    我試試看. . . . .
-    [17:39:26] h.c.chen 陳厚成: 哈! 真的可以。 Chrome 有 command line switch :  --allow-file-access-from-files
-    --
-    Answered
-    [18:04:40] yap @ Forth: file:// protocol 只能讀  .js  html, 圖片及聲音
-    [18:05:07] yap @ Forth: 除非透過 html file api ,但多了一個開檔的動作
-    [18:05:21] yap @ Forth: 選檔必須使用者手動
-    --
-    先把 執行中的 chrome process 清乾淨,然後用
-        chrome.exe --allow-file-access-from-files
-    執行, 如此 $.get 可以讀 local files. 我試了讀 .js 檔可以。
-    Windows 10, Chrome 版本 46.0.2490.86 m
-    --
-    MS Edge seems has the same switch : https://social.technet.microsoft.com/Forums/en-US/8128064a-9bad-4cb3-aedc-b8a183e344f8/microsoft-edge-how-to-allowfileaccessfromfiles?forum=win10itprogeneral
-    But it doesn't work on my desk at home:
-    C:\Windows\SystemApps\Microsoft.MicrosoftEdge_8wekyb3d8bbwe>MicrosoftEdge.exe --allow-file-access-from-files file:///c:/Users/hcche/Documents/GitHub/jeforth.3we/index.html
-    --
+	複習一下,Chrome 卡在這裡:
+	XMLHttpRequest cannot load file:///C:/Users/hcche/Documents/GitHub/jeforth.3we/f/jeforth.f?text.
+	Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension,
+	https, chrome-extension-resource.
+	---
+	問 Yap ,
+	[17:14:05] h.c.chen 陳厚成: jeforth 不透過 local server 真的就不能跑嗎? 卡在 XMLHttpRequest cannot load file ... ; Cross origin requests are only supported for protocol schemes ... ,
+	[17:16:20] h.c.chen 陳厚成: 因為用 JQuery 的 $.get 讀檔案, 例如 jeforth.f 就不行了。
+	[17:18:16] h.c.chen 陳厚成: ( 在網頁上跑的 jeforth )
+	[17:36:12] h.c.chen 陳厚成: 可能找到答案了
+	http://stackoverflow.com/questions/8449716/cross-origin-requests-are-only-supported-for-http-but-its-not-cross-domain
+	http://chrome-allow-file-access-from-file.com/
+	http://joshuamcginnis.com/2011/02/28/how-to-disable-same-origin-policy-in-chrome/
+	我試試看. . . . .
+	[17:39:26] h.c.chen 陳厚成: 哈! 真的可以。 Chrome 有 command line switch :  --allow-file-access-from-files
+	--
+	Answered
+	[18:04:40] yap @ Forth: file:// protocol 只能讀  .js  html, 圖片及聲音
+	[18:05:07] yap @ Forth: 除非透過 html file api ,但多了一個開檔的動作
+	[18:05:21] yap @ Forth: 選檔必須使用者手動
+	--
+	先把 執行中的 chrome process 清乾淨,然後用
+		chrome.exe --allow-file-access-from-files
+	執行, 如此 $.get 可以讀 local files. 我試了讀 .js 檔可以。
+	Windows 10, Chrome 版本 46.0.2490.86 m
+	--
+	MS Edge seems has the same switch : https://social.technet.microsoft.com/Forums/en-US/8128064a-9bad-4cb3-aedc-b8a183e344f8/microsoft-edge-how-to-allowfileaccessfromfiles?forum=win10itprogeneral
+	But it doesn't work on my desk at home:
+	C:\Windows\SystemApps\Microsoft.MicrosoftEdge_8wekyb3d8bbwe>MicrosoftEdge.exe --allow-file-access-from-files file:///c:/Users/hcche/Documents/GitHub/jeforth.3we/index.html
+	--
 [x] 爽哥 的 cloth_sam.f 革除原版不像 forth 的缺點。
 [x] shift-F2 in trouble on 3hta. --> fixed
 
 [x] Bug ! both HTA and Chrome, why I didn't find this before?
-    ==> : test  /*aabbcc*/  ;
-        : test s" /*aabbcc*/" ;
-        JavaScript error on word "literal" : Invalid regular expression: missing /
-    ==> 簡化到用 F12 debugger 即可複製:
-        ntib=0;tib=" /*aabbcc*/ ";nexttoken("") --> "/*aabbcc*/ " correct
-        ntib=0;tib=" /*aabbcc*/ ";nexttoken("") --> 也沒錯呀!
-    ==> Strange, happened on 3htm Chrome.
-    ==> 表示  在 compiling state 有問題, and it's nothing in  because s" also
-        has the problem.
-    -->
-        : s"  (  -- str ) \ Get string down to the next delimiter.
-            char " word js: debugger compiling if literal then BL word drop ; immediate
-        : test ( [ js: debugger ] ) s" /*aabbcc*/" ;
-    --> @ bp, stack=["/*aabbcc*/"]
-        tib = s" /*aabbcc*/" ; '
-        ntib ----------------^
-        compiling : true
-    --> 看到問題了! literal 會把常數用 /* */ 表達在該 function 裡,該常數
-        又是 /*...*/ 則結尾的 */ 就會被認走!! 結果出問題了!
-        > : test s" /*aabbcc*" ;
-        > see test
-        -------- Definition in dictionary --------
-        01529: function (){push(literal)/*(string)/*aabbcc* */} (function)
-        01530: RET (null)
-        ---------- End of the definition -----------
-    --> 只有當含有 */ 的 string constant 被 literal compile 進 dictionary 時才有這個問題。
-    [x] 考慮 string constant 可能很長, literal 用 /*...*/ 顯示的方式還要再考慮周詳一點。
-        例如長字串要截斷,碰到 */ 要改成 *_/ 即可避免 .. Bingo!!
+	==> : test  /*aabbcc*/  ;
+		: test s" /*aabbcc*/" ;
+		JavaScript error on word "literal" : Invalid regular expression: missing /
+	==> 簡化到用 F12 debugger 即可複製:
+		ntib=0;tib=" /*aabbcc*/ ";nexttoken("") --> "/*aabbcc*/ " correct
+		ntib=0;tib=" /*aabbcc*/ ";nexttoken("") --> 也沒錯呀!
+	==> Strange, happened on 3htm Chrome.
+	==> 表示  在 compiling state 有問題, and it's nothing in  because s" also
+		has the problem.
+	-->
+		: s"  (  -- str ) \ Get string down to the next delimiter.
+			char " word js: debugger compiling if literal then BL word drop ; immediate
+		: test ( [ js: debugger ] ) s" /*aabbcc*/" ;
+	--> @ bp, stack=["/*aabbcc*/"]
+		tib = s" /*aabbcc*/" ; '
+		ntib ----------------^
+		compiling : true
+	--> 看到問題了! literal 會把常數用 /* */ 表達在該 function 裡,該常數
+		又是 /*...*/ 則結尾的 */ 就會被認走!! 結果出問題了!
+		> : test s" /*aabbcc*" ;
+		> see test
+		-------- Definition in dictionary --------
+		01529: function (){push(literal)/*(string)/*aabbcc* */} (function)
+		01530: RET (null)
+		---------- End of the definition -----------
+	--> 只有當含有 */ 的 string constant 被 literal compile 進 dictionary 時才有這個問題。
+	[x] 考慮 string constant 可能很長, literal 用 /*...*/ 顯示的方式還要再考慮周詳一點。
+		例如長字串要截斷,碰到 */ 要改成 *_/ 即可避免 .. Bingo!!
 
 [x] I was working on git.f, trying to make the article section more sexy.
-    Now at the 5.5 section.
-    --> fix shift-F2 hang issue on 3HTA first.
-        js: document.designMode="on" <=== 3HTA 一下就出問題, 合理。
-        js: outputbox.contentEditable="true" <== 3HTA 真的只針對 outputbox, Chrome 全部都 editable!
-    --> 3hta 反而好!!
+	Now at the 5.5 section.
+	--> fix shift-F2 hang issue on 3HTA first.
+		js: document.designMode="on" <=== 3HTA 一下就出問題, 合理。
+		js: outputbox.contentEditable="true" <== 3HTA 真的只針對 outputbox, Chrome 全部都 editable!
+	--> 3hta 反而好!!
 
 [x] 照 爽哥 建議增加 tutor-cloth.f 畫線的例子。
-    hcchen5600 2015/12/03 17:09:31
+	hcchen5600 2015/12/03 17:09:31
 
 [x] This help message is wrong now?
-    execute ( Word|"name"|address|empty -- ... ) Execute the given word or the last() if stack is empty. (object)
-    ==> 9/16'16 done
-    
+	execute ( Word|"name"|address|empty -- ... ) Execute the given word or the last() if stack is empty. (object)
+	==> 9/16'16 done
+	
 [x] Many older forth basic words appear stupied after having pop() tos() ...etc.
 
 [x] 用 rawgit.com 直接跑 GitHub repo 只有 Chrome and Android built-in browser 能 run, 
 	IE/Edge, and Firefox are facing the Access-Control-Allow-xxxxx 的問題。
-    可能是因為透過 rawgit.com 去跑 GitHub repo 觸動跨境 access 的安全機制之故。
-    ==> study https://pages.github.com/
-    --> 9/16'16 tried https://rawgit.com/hcchengithub/jeforth.3we/develop/index.html on 
-        IE 11/Windows 10, really failed, as shown below:
-        --- jeforth.3htm error message at beginning --- 
-        Error! Failed to read f/jeforth.f
-        --- F12 error messages ---
-        Navigation Event Separator
-        DOM7011: The code on this page disabled back and forward caching. For more information, see: http://go.microsoft.com/fwlink/?LinkID=291337
-        index.html
-        HTML1300: Navigation occurred.
-        index.html
-        SCRIPT7002: XMLHttpRequest: Network Error 0x80070005, Access is denied.
-        index.html
-        SCRIPT7002: XMLHttpRequest: Network Error 0x80070005, Access is denied.
-        index.html
-        SCRIPT7002: XMLHttpRequest: Network Error 0x80070005, Access is denied.
-        index.html
+	可能是因為透過 rawgit.com 去跑 GitHub repo 觸動跨境 access 的安全機制之故。
+	==> study https://pages.github.com/
+	--> 9/16'16 tried https://rawgit.com/hcchengithub/jeforth.3we/develop/index.html on 
+		IE 11/Windows 10, really failed, as shown below:
+		--- jeforth.3htm error message at beginning --- 
+		Error! Failed to read f/jeforth.f
+		--- F12 error messages ---
+		Navigation Event Separator
+		DOM7011: The code on this page disabled back and forward caching. For more information, see: http://go.microsoft.com/fwlink/?LinkID=291337
+		index.html
+		HTML1300: Navigation occurred.
+		index.html
+		SCRIPT7002: XMLHttpRequest: Network Error 0x80070005, Access is denied.
+		index.html
+		SCRIPT7002: XMLHttpRequest: Network Error 0x80070005, Access is denied.
+		index.html
+		SCRIPT7002: XMLHttpRequest: Network Error 0x80070005, Access is denied.
+		index.html
 	--> 13:35 2016-11-26 Firefox's error messages
 		Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://raw.githubusercontent.com/hcchengithub/jeforth.3we/develop/3htm/f/readtextfile.f?text. (Reason: CORS preflight channel did not succeed).(unknown)
 		Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://raw.githubusercontent.com/hcchengithub/jeforth.3we/develop/f/jeforth.f?text. (Reason: CORS preflight channel did not succeed).(unknown)
 		Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://raw.githubusercontent.com/hcchengithub/jeforth.3we/develop/3htm/f/quit.f?text. (Reason: CORS preflight channel did not succeed).(unknown)
-	==> use http://cdn.rawgit.com/... 	is the solution. 13:11 2017-01-08
+	==> use http://cdn.rawgit.com/...	is the solution. 13:11 2017-01-08
 	
 [x] jeforth.3we 可以直接當成 editor 用, 寫筆記, 寫文章皆可。
-    --> See YNote: "在 Web browser 上直接編輯網頁內容"
-    --> Edit by Chrome, press Ctrl-S and save as "完整的網頁" is profect.
-        IE and Edge can only save the original content like Chrome's "僅限網頁的HTML部分"。
-    --> jeforth.3htm 下這一行即可單獨弄出一塊 editable 的 
區域。 - s" body"
--edit me--
- --> 更妙的是 - js> outputbox.contentEditable \ ==> inherit (string) - [x] js: outputbox.contentEditable=true <-- 不妨加入 shift + {F2} editMode ... Done! - --> 曾有過用 project-k 做成獨立的 template.html 實現此構想。直接執行: - chrome --allow-file-access-from-files - 應該更好。有充分的資源可用。 - ==> now, ls.f Edit Box - + --> See YNote: "在 Web browser 上直接編輯網頁內容" + --> Edit by Chrome, press Ctrl-S and save as "完整的網頁" is profect. + IE and Edge can only save the original content like Chrome's "僅限網頁的HTML部分"。 + --> jeforth.3htm 下這一行即可單獨弄出一塊 editable 的
區域。 + s" body"
--edit me--
+ --> 更妙的是 + js> outputbox.contentEditable \ ==> inherit (string) + [x] js: outputbox.contentEditable=true <-- 不妨加入 shift + {F2} editMode ... Done! + --> 曾有過用 project-k 做成獨立的 template.html 實現此構想。直接執行: + chrome --allow-file-access-from-files + 應該更好。有充分的資源可用。 + ==> now, ls.f Edit Box + [x] 應用 chrome --allow-file-access-from-files 之前要把所有執行中的 chrome.exe 都停掉。 - 不如來寫一個命令叫做 powoer-chrome (引用 power user 的用法) 來一口氣完成。 - : power-chrome ( -- ) \ Run chrome that + 不如來寫一個命令叫做 powoer-chrome (引用 power user 的用法) 來一口氣完成。 + : power-chrome ( -- ) \ Run chrome that [x] Alt-Up/Down should not recall multiple-line. - hcchen5600 2015/12/04 10:34:22 + hcchen5600 2015/12/04 10:34:22 [x] bug, constant name 若出現 " 就會出問題, 連帶使 value 也依樣。Variable 倒是 OK 的。 - 這個問題在 constant 的 help 裡早就提過了! 我一點印象也沒有。 - 解法應該是: replace(/"/g,"\\\"") ---> Bingo!! - to command 也有同樣的問題 --> Yes. + 這個問題在 constant 的 help 裡早就提過了! 我一點印象也沒有。 + 解法應該是: replace(/"/g,"\\\"") ---> Bingo!! + to command 也有同樣的問題 --> Yes. [/] vm.g.variable 應該是 vm.g.voc.variable 才對, - 或者各自掛到 vocabulary object 底下去才對。 - --> 這個問題跟 forth 本身把所有的 variable constant value 都當成 global 所造成的 - 隱憂差不多,頂多多一點。 - [/] 讓 value constant 檢查 the name 是否已經存在。 - [/] 當 selftest 時,把 ReDef 當作 big warning 看待,需要 user confirm。 + 或者各自掛到 vocabulary object 底下去才對。 + --> 這個問題跟 forth 本身把所有的 variable constant value 都當成 global 所造成的 + 隱憂差不多,頂多多一點。 + [/] 讓 value constant 檢查 the name 是否已經存在。 + [/] 當 selftest 時,把 ReDef 當作 big warning 看待,需要 user confirm。 ==> automatically no longer a question after private supported. [ ] The template.f project ==> modify.f [x] Bug found!! 這個難解的問題已經解了, 但留有較罕見的情況仍有問題,如下。 - > : test js> "123;" ; - JavaScript error on word "jsFunc" : Expected ';' - --> ok with js: "123;", only js> has the problem. - --> jsFunc is for js> that push the value of the last statement. - Problem is that the last statement can be a string literal that - includes ';' which is not an end of a statement! - So, how to isolate *the last statement* is the challange. My recent jsFunc is - not good enough for this case. -- hcchen5600 2015/12/04 20:40:13 - --> Not only in string but also in RegEx like this, - js> tos(1)[2].replace(/;/,"__SeMiCoLoN__") - the /;/ makes the same problem!! - [x] Idea of the solution - 研究如何把出現在 jeforth code word definition 裡面的 - JavaScript source code 當中的 "..;.." 分號都置換成 __SeMiCoLoN__ - 以避免干擾最後一條 statement 的判斷。 - --> Find all ['"/].;.;.['"/] literals, replace ';' to __semicolon__ - --> Do the existing process to isolate the last statement. - --> Replace __semicolon__ back to ';' for both portion. - ==> Bingo!! - [ ] Escape characters are still a problem. - "ab\"cd" is ab"cd - Also /...\/.../ or /...[/].../ too. + > : test js> "123;" ; + JavaScript error on word "jsFunc" : Expected ';' + --> ok with js: "123;", only js> has the problem. + --> jsFunc is for js> that push the value of the last statement. + Problem is that the last statement can be a string literal that + includes ';' which is not an end of a statement! + So, how to isolate *the last statement* is the challange. My recent jsFunc is + not good enough for this case. -- hcchen5600 2015/12/04 20:40:13 + --> Not only in string but also in RegEx like this, + js> tos(1)[2].replace(/;/,"__SeMiCoLoN__") + the /;/ makes the same problem!! + [x] Idea of the solution + 研究如何把出現在 jeforth code word definition 裡面的 + JavaScript source code 當中的 "..;.." 分號都置換成 __SeMiCoLoN__ + 以避免干擾最後一條 statement 的判斷。 + --> Find all ['"/].;.;.['"/] literals, replace ';' to __semicolon__ + --> Do the existing process to isolate the last statement. + --> Replace __semicolon__ back to ';' for both portion. + ==> Bingo!! + [ ] Escape characters are still a problem. + "ab\"cd" is ab"cd + Also /...\/.../ or /...[/].../ too. [x] 重新考慮要不要這個東西 js: jump2endofinputbox.click(); contentEditable 之後很煩。 - --> Done. + --> Done. [x] 立志要用 jeforth 來編輯 log.txt - js> vm.plain(vm.g["log.txt"]) js: article.innerHTML=pop() - [x] CSS tab-size IE/Edge 皆無效, 3hta either . . . - 證實: char log.html readTextFile js: article.innerHTML=pop() - ==> ls.f Edit Box is now good enough - + js> vm.plain(vm.g["log.txt"]) js: article.innerHTML=pop() + [x] CSS tab-size IE/Edge 皆無效, 3hta either . . . + 證實: char log.html readTextFile js: article.innerHTML=pop() + ==> ls.f Edit Box is now good enough + [x] Ctrl-F2 之後,把 caret cursor 所在的 element 改成 command-line style. - \ caret at the target position - \ press Ctrl-F2 - \ you get a #text node ce (current element) - - [object Text] bla bla bla... - - > The #text node's parentNode ==> char .. (ce) - > ce - [object HTMLParagraphElement] innerHTML=bla bla bla - 0 : [object Text] bla bla bla... - --> In this case, it's a P node. - - \ Now we have the target element. - \ Then let's create a table node. 我需要取得最內層之 的 ID 希望可以用 - \ 暫時的 mytemp 用完就把它取消掉,能這樣做就簡單了。應該用 removeAttribute() 可 - \ 以做到。 - - \ 試試看 element ID 可不可以拿掉? 答案是可以的。 - \ element :: removeAttribute("id") 即可。 - - >

xxx

constant xxx - > xxx :> outerHTML ==>

xxx

- > xxx :: removeAttribute("id") - > xxx :> outerHTML ==>

xxx

- - 動手了: - - -
- -
-
( from ) - ce@ :> nodeValue js: tempid.innerText=pop() - js: tempid.removeAttribute("id") - ce@ :> parentNode replaceNode - - : change-to-code-style ( -- ) \ Change the ce@ to code style -
- -
( from ) - ce@ :> nodeValue js: tempid.innerText=pop() - js: tempid.removeAttribute("id") - ce@ :> parentNode replaceNode ; - + \ caret at the target position + \ press Ctrl-F2 + \ you get a #text node ce (current element) + + [object Text] bla bla bla... + + > The #text node's parentNode ==> char .. (ce) + > ce + [object HTMLParagraphElement] innerHTML=bla bla bla + 0 : [object Text] bla bla bla... + --> In this case, it's a P node. + + \ Now we have the target element. + \ Then let's create a table node. 我需要取得最內層之 的 ID 希望可以用 + \ 暫時的 mytemp 用完就把它取消掉,能這樣做就簡單了。應該用 removeAttribute() 可 + \ 以做到。 + + \ 試試看 element ID 可不可以拿掉? 答案是可以的。 + \ element :: removeAttribute("id") 即可。 + + >

xxx

constant xxx + > xxx :> outerHTML ==>

xxx

+ > xxx :: removeAttribute("id") + > xxx :> outerHTML ==>

xxx

+ + 動手了: + + +
+ +
+
( from ) + ce@ :> nodeValue js: tempid.innerText=pop() + js: tempid.removeAttribute("id") + ce@ :> parentNode replaceNode + + : change-to-code-style ( -- ) \ Change the ce@ to code style +
+ +
( from ) + ce@ :> nodeValue js: tempid.innerText=pop() + js: tempid.removeAttribute("id") + ce@ :> parentNode replaceNode ; + [x] jeforth 分析 考勤 刷卡紀錄 上班時數 分析 [x] private folder is a new project - --> GitHub is not for private use unless pay the money. Use and Dropbox Yun.Baidu instead. - + --> GitHub is not for private use unless pay the money. Use and Dropbox Yun.Baidu instead. + [x] 昨天忘了 sync GitHub at home. Today, in my office, I don't edit log.json and 3ce folder - so as to remain easy-to-sync of the project. Like maintained by two different people on - different topics. - --> 照這樣安排只 click 一下 [Sync] 按鈕, 兩邊這樣都成功了。 - + so as to remain easy-to-sync of the project. Like maintained by two different people on + different topics. + --> 照這樣安排只 click 一下 [Sync] 按鈕, 兩邊這樣都成功了。 + [x] 如何把很大的檔案收一部分起來,以方便操作? --> log.json 需要擴充。log.json 不能被 edit-zone - 取代,因為 outputbox 只接 log 起來太正點了 (ls.f has "snapshot" command now)。保留現有 - log.json 的 stack 架構, 但是擴充 random access 的功能。讓它跟 outputbox 結合地更自然、更好用。 - ==> Done, ls.f Edit Box. + 取代,因為 outputbox 只接 log 起來太正點了 (ls.f has "snapshot" command now)。保留現有 + log.json 的 stack 架構, 但是擴充 random access 的功能。讓它跟 outputbox 結合地更自然、更好用。 + ==> Done, ls.f Edit Box. [x] words and help will list the exactly same word multiple times - depends on the order list. Try not. Simply check the recent i and the order - list if [i] appear earlier then skip it. + depends on the order list. Try not. Simply check the recent i and the order + list if [i] appear earlier then skip it. [x] words , help 取消 -N 把 -N 變成 default, 改用 -f 代表 fuzzy search 取代本來的 default。 - --> modify (words) in jeforth.f , 同時讓 -N (now default) 只列出最高 priority 的一個 word。 - --> Modified jeforth.f, easy. Try on 3ce host page ... fail at selftest. Skip it. - --> 連 comments 都改好了. (words), (help), help in jeforth.f, voc.f, and platform.f. + --> modify (words) in jeforth.f , 同時讓 -N (now default) 只列出最高 priority 的一個 word。 + --> Modified jeforth.f, easy. Try on 3ce host page ... fail at selftest. Skip it. + --> 連 comments 都改好了. (words), (help), help in jeforth.f, voc.f, and platform.f. [x] 寫 S7 方便改 keyboard registry 的命令。 - ==> registry.f , autoit.f 都可以 access registry, 但是要改 REG_BINARY for s7 keyboard - re-layout 還是用 reg.exe 配合 export -> edit -> import 的方法, 3hta dos command can help. - 因為 REG_BINARY 問題太多。 - [x] Review registry.f, notes of S7 keyboard remapping. If only I can read registry through - 3hta then it's convenient enough. - Conclusion is : run the 1 key and 5 key ~.reg files (attached below on this page) to remap - the Acer S7 keyboard. 1 key is the Caps Lock changed to be Mute toggle. 5 keys are Caps Lock - become 'delete', AltGr/Del become Home/End, Fn-Home/Fn-End become Pad-/Pad+ for Windows 10 - Zoom in and Zoom out. Refer to my Youdao YNote. + ==> registry.f , autoit.f 都可以 access registry, 但是要改 REG_BINARY for s7 keyboard + re-layout 還是用 reg.exe 配合 export -> edit -> import 的方法, 3hta dos command can help. + 因為 REG_BINARY 問題太多。 + [x] Review registry.f, notes of S7 keyboard remapping. If only I can read registry through + 3hta then it's convenient enough. + Conclusion is : run the 1 key and 5 key ~.reg files (attached below on this page) to remap + the Acer S7 keyboard. 1 key is the Caps Lock changed to be Mute toggle. 5 keys are Caps Lock + become 'delete', AltGr/Del become Home/End, Fn-Home/Fn-End become Pad-/Pad+ for Windows 10 + Zoom in and Zoom out. Refer to my Youdao YNote. [x] 3ce Improve readTextFile - : readTextFileAuto ( "pathname" -- "text" ) \ Read text file from jeforth.3ce host page. - s" s' " swap + s" ' readTextFileAuto " + \ command line 以下讓 Extention page (the host page) 執行 - s" {} js: tos().forth='stopSleeping' js: tos().tos=pop() " + \ host side packing the message object - s" " \ host commands after resume from file I/O - - chrome.runtime.sendMessage({isCommand:true,text:pop()}, - function(result){push(result);execute('stopSleeping')}) - 10000 sleep ; -[x] 3nw.bat js> 1000*60*60*2 nap include hibernatin.f + : readTextFileAuto ( "pathname" -- "text" ) \ Read text file from jeforth.3ce host page. + s" s' " swap + s" ' readTextFileAuto " + \ command line 以下讓 Extention page (the host page) 執行 + s" {} js: tos().forth='stopSleeping' js: tos().tos=pop() " + \ host side packing the message object + s" " \ host commands after resume from file I/O + + chrome.runtime.sendMessage({isCommand:true,text:pop()}, + function(result){push(result);execute('stopSleeping')}) + 10000 sleep ; +[x] 3nw.bat js> 1000*60*60*2 nap include hibernatin.f [x] Popup page can attach 3ce to target page now, so 3ce default tabid should be the 'active' tab. - js: push({active:true}) tabs.query js> tos().length \ ==> 1 (number) must be only one - js: push({active:true}) tabs.query :> [0] (see) - --> modiyf ce.f tabid command --> ok now! + js: push({active:true}) tabs.query js> tos().length \ ==> 1 (number) must be only one + js: push({active:true}) tabs.query :> [0] (see) + --> modiyf ce.f tabid command --> ok now! [x] 3ce attach works fine, but it has to check if the target page has been loaded! - Experiment: 0 [begin] active-tab :> status . space 500 nap 1+ dup 100 > [until] - --> Correct, get 3 complete in a row to make sure it's really completed. I saw a complete - among "loading" that's why. - --> works fine now. - + Experiment: 0 [begin] active-tab :> status . space 500 nap 1+ dup 100 > [until] + --> Correct, get 3 complete in a row to make sure it's really completed. I saw a complete + among "loading" that's why. + --> works fine now. + [x] This line does not print 50 stars, unless remove the 'cr' Bug!! - run: 50 for char * . cr next - This is ok --> 0 [begin] char * . cr 500 nap 1+ dup 10 > [until] - so [for] ... [next] in trouble? or run: for ... next in trouble? - --> try 50 [for] char * . cr 50 nap [next] ----> it works fine! - --> 50 for char * . cr next (run:) <--- works fine too! - --> So, run: for ... next in trouble! - ==> (run:) uses 'dictate()' to run the string, change to use 'tib.insert'. - - 利用別的軟體來畫表格, 例如 excel 可能是最好的辦法。可以 copy-paste 給 3hta - 然後用 js> $('table')[0].outerHTML . 取得 HTML 放到 Notepad++ 去整理。 + run: 50 for char * . cr next + This is ok --> 0 [begin] char * . cr 500 nap 1+ dup 10 > [until] + so [for] ... [next] in trouble? or run: for ... next in trouble? + --> try 50 [for] char * . cr 50 nap [next] ----> it works fine! + --> 50 for char * . cr next (run:) <--- works fine too! + --> So, run: for ... next in trouble! + ==> (run:) uses 'dictate()' to run the string, change to use 'tib.insert'. + + 利用別的軟體來畫表格, 例如 excel 可能是最好的辦法。可以 copy-paste 給 3hta + 然後用 js> $('table')[0].outerHTML . 取得 HTML 放到 Notepad++ 去整理。 [x] forget to sync, now I have to use log.txt -- 15:02 2016/02/20 [x] Try Ctrl-Enter application, I already know textarea does not return correct element for - anchorNode, how about other things? Try 3ce directly.... - 返回本站首页hao123网址之家www.hao123.com - To study - > js> getSelection() tib. <--------- Alt-F2 gets the same result. - js> getSelection() \ ==> (object) inputbox, null - OK - > js> getSelection() tib. - js> getSelection() \ ==> (object) textarea, null - OK + anchorNode, how about other things? Try 3ce directly.... + 返回本站首页hao123网址之家www.hao123.com + To study + > js> getSelection() tib. <--------- Alt-F2 gets the same result. + js> getSelection() \ ==> (object) inputbox, null + OK + > js> getSelection() tib. + js> getSelection() \ ==> (object) textarea, null + OK - textarea 內不管在哪裡 getSelection() 都是拿到最近的 div parent - js> getSelection() js> getSelection()==pop() \ ==> true (boolean) - js> getSelection().length . - js> getSelection().anchorNode.outerHTML \ ==>
... + textarea 內不管在哪裡 getSelection() 都是拿到最近的 div parent + js> getSelection() js> getSelection()==pop() \ ==> true (boolean) + js> getSelection().length . + js> getSelection().anchorNode.outerHTML \ ==>
... - Drag and drop a picture to 3ce outputbox ==> -
返回本站首页hao123网址之家www.hao123.com
+ Drag and drop a picture to 3ce outputbox ==> +
返回本站首页hao123网址之家www.hao123.com
[x] Now I hope that I can use some script in tr.table. So I can click and run scripts. - That requires a Security Policy: - Refused to execute inline event handler because it violates the following Content - Security Policy directive: "script-src 'self' 'unsafe-eval'". Either the 'unsafe-inline' - keyword, a hash ('sha256-...'), or a nonce ('nonce-...') is required to enable inline - execution. - But after added 'unsafe-inline' into "content_security_policy", reload manifest.json gets - this error : - 嘗試安裝這項擴充功能時顯示警告訊息: - Ignored insecure CSP value "'unsafe-inline'" in directive 'script-src'. - So, the only way is to use a function directly. - --> 奇怪了, 那 jeforth.3ce 已經在用的 script 是怎麼能跑的? - --> inputbox 是收 element.onkeydown , defined in jeforth.3htm.js and platform.f - 只要不是 inline 形式的 onclick="blabla" 就可以了。(嗎) - --> 那對 jeforth 很簡單哪! 先取得 element 再幫他掛上 element.onxxxx=function 即可。 - element.onxxxx=debugger; <--- Failed, 'degugger' unknown. - element.onxxxx="dictate('blabla')" <--- no error, but element.onxxxx will be null. - element.onxxxx=function(){debugger} <--- OK!! 'this' is the element. - h1 :: onclick=function(e){dictate('.s')} <--- OK!!! it works fine. - ==> 結論就是不要寫成 inline script 就行了, 那沒問題呀! - --> See Ynote: jeforth.3ce let tr.table to have script, do-able! - + That requires a Security Policy: + Refused to execute inline event handler because it violates the following Content + Security Policy directive: "script-src 'self' 'unsafe-eval'". Either the 'unsafe-inline' + keyword, a hash ('sha256-...'), or a nonce ('nonce-...') is required to enable inline + execution. + But after added 'unsafe-inline' into "content_security_policy", reload manifest.json gets + this error : + 嘗試安裝這項擴充功能時顯示警告訊息: + Ignored insecure CSP value "'unsafe-inline'" in directive 'script-src'. + So, the only way is to use a function directly. + --> 奇怪了, 那 jeforth.3ce 已經在用的 script 是怎麼能跑的? + --> inputbox 是收 element.onkeydown , defined in jeforth.3htm.js and platform.f + 只要不是 inline 形式的 onclick="blabla" 就可以了。(嗎) + --> 那對 jeforth 很簡單哪! 先取得 element 再幫他掛上 element.onxxxx=function 即可。 + element.onxxxx=debugger; <--- Failed, 'degugger' unknown. + element.onxxxx="dictate('blabla')" <--- no error, but element.onxxxx will be null. + element.onxxxx=function(){debugger} <--- OK!! 'this' is the element. + h1 :: onclick=function(e){dictate('.s')} <--- OK!!! it works fine. + ==> 結論就是不要寫成 inline script 就行了, 那沒問題呀! + --> See Ynote: jeforth.3ce let tr.table to have script, do-able! + [x] is#text? paste-string erase-#text-anchorNode - ==> See Ynote: jeforth.3ce window.getSelection() 得到的 Selection object 是揮發性 - 的!不能留下來以後用。 - + ==> See Ynote: jeforth.3ce window.getSelection() 得到的 Selection object 是揮發性 + 的!不能留下來以後用。 + [x] project-k baby.html, sample.html 突然 run 起來之後 Ctrl-enter 沒有作用, F12 debugger 才看得見 - 問題, 原來是 jQuery 掛不起來: - Failed to load resource: net::ERR_NAME_NOT_RESOLVED http://ajax.microsoft.com/ajax/jQuery/jquery-1.11.2.js - baby.html:48 Uncaught ReferenceError: jQuery is not defined - 這常有, 應該要有警告。 - 這是 GFW 的問題, 透過 VPN 就好了。中國境內有沒有 jQuery 的 mirror? - + 問題, 原來是 jQuery 掛不起來: + Failed to load resource: net::ERR_NAME_NOT_RESOLVED http://ajax.microsoft.com/ajax/jQuery/jquery-1.11.2.js + baby.html:48 Uncaught ReferenceError: jQuery is not defined + 這常有, 應該要有警告。 + 這是 GFW 的問題, 透過 VPN 就好了。中國境內有沒有 jQuery 的 mirror? + [x] 14:21 2016-04-12 jeforth.3ce startup page to advertise itself. Use YNote directly. - cls er + cls er [x] tutor-cloth.f console3we strange. - [x] Improve the scrollto position. - [x] Font size not consistant either. + [x] Improve the scrollto position. + [x] Font size not consistant either. [x] 'Edit box style' 這種東西實在太煩了, 到底為什麼 font size 怎麼都調不好。 - [x] RI: don't use absolute font-size like the 20px in common.css, it is exactly - the root cause of this problem. - --> js> $("style").length \ ==> 3 - --> js> $("style")[0].innerHTML - --> The below study shows me the idea that a stand along style setting for font-size - may be the solution. - - js> $("style")[0].outerHTML \ ==> (string) - - js> $("style")[1].outerHTML - \ ==> (string) - - js> $("style")[2].outerHTML - \ ==> (string) - - js> $("style")[3].outerHTML - \ ==> (string) - *** If want to modify existing style tag, I have done that before! - See flot.f "remove-backgroundColor-style" command that modifies common.css - background color due to that flot.js does not work well with background color. - - [x] 乾脆把 font-size remove from the above [0] style section. The question of "what - is the "1.1em" font size refer to - [x] remove font-size from jeforth.3we/common.css - [x] also change font-size in 3htm/ls.f, which is now refer to default font-size, - to 1.1em that works fine now. - --> it works!! - --> so the default font-size is good enough. <=== True !!! - + [x] RI: don't use absolute font-size like the 20px in common.css, it is exactly + the root cause of this problem. + --> js> $("style").length \ ==> 3 + --> js> $("style")[0].innerHTML + --> The below study shows me the idea that a stand along style setting for font-size + may be the solution. + + js> $("style")[0].outerHTML \ ==> (string) + + js> $("style")[1].outerHTML + \ ==> (string) + + js> $("style")[2].outerHTML + \ ==> (string) + + js> $("style")[3].outerHTML + \ ==> (string) + *** If want to modify existing style tag, I have done that before! + See flot.f "remove-backgroundColor-style" command that modifies common.css + background color due to that flot.js does not work well with background color. + + [x] 乾脆把 font-size remove from the above [0] style section. The question of "what + is the "1.1em" font size refer to + [x] remove font-size from jeforth.3we/common.css + [x] also change font-size in 3htm/ls.f, which is now refer to default font-size, + to 1.1em that works fine now. + --> it works!! + --> so the default font-size is good enough. <=== True !!! + [x] 3nw's Ctrl-{+}, Ctrl-{-} font size control does not work. - 1) the two colon words' logic were wrong!! --> fixed - 2) {pad +} and {pad -} and their normal equivlants are of different keycode, so - 3htm/platform.f needs to add two more keys to allow notebooks (w/o numeric pad) - to press Ctrl-plus and Ctrl-Minus. - Sh**t! this problem has been there for a long time !!! + 1) the two colon words' logic were wrong!! --> fixed + 2) {pad +} and {pad -} and their normal equivlants are of different keycode, so + 3htm/platform.f needs to add two more keys to allow notebooks (w/o numeric pad) + to press Ctrl-plus and Ctrl-Minus. + Sh**t! this problem has been there for a long time !!! [x] Working on jeforth.3we\3hta\1.bat to leverage jeforth.hta for install.bat automation for all applications. @@ -4815,7 +4815,7 @@ --> done! jeforth.3we/setup.bat setup all applications. [x] setup.bat should include the private folder [x] include command may do nothing if the ~.f module was existing. This causes problem - if word reDef is expected. For example, many-clocks.f uses 'save' command which is + if word reDef is expected. For example, many-clocks.f uses 'save' command which is defined in canvas.f module. When include many-clocks.f the 'save' command has been reDef by ls.f and therefore running many-clocks.f will be a mess of failures. The solution is that 'include' command should move the target module to the top instead @@ -4825,13 +4825,13 @@ included already. It's not NOP anymore. 13:10 2017-01-08 [x] ls.f autoexec has a problem. If it include ~.f which uses source-code-header - that will cause a self-test nested structre problem. Because autoexec is added to - the end of tib by tib.insert. But included ~.f's are spposed to be completed before - the ending self-test structure to balance the nested self-test structure. - To avoid the problem, ~.f inclded in autoexec should not use source-code-header. - How to debug this issue? Use this line: - "" value tib-at-the-point js: vm.g.tib=tib.slice(ntib) - and check tib-at-the-point + that will cause a self-test nested structre problem. Because autoexec is added to + the end of tib by tib.insert. But included ~.f's are spposed to be completed before + the ending self-test structure to balance the nested self-test structure. + To avoid the problem, ~.f inclded in autoexec should not use source-code-header. + How to debug this issue? Use this line: + "" value tib-at-the-point js: vm.g.tib=tib.slice(ntib) + and check tib-at-the-point [x] Change the self-test design of jeforth.3we. No command line do nothing. --> Yuan-Yuan Teng's experience made me considered this modification. But actually @@ -4840,221 +4840,221 @@ 13:07 2017-01-08 [x] support 'private' command to hide private words in the vocabulary - Forth 好用, 但是所有的 word 都是 global 令人想念有 local 的環境。應用 jeforth 用久了, 這 - 個念頭越來越鮮明。要定義一個新的 word 時總覺得有點沉重,怕與過去或未來的 word 撞名。 - - 希望 word 都是 private 只見於同一個 context 之內, 這樣寫起程式來就可以放心地重複定義新 word - 不怕撞名。偶而要用到某個 vocabulary 裡的 private word 時,切 context 即可,或把它 export 出來。 - - jeforth 的 word 都是 object, 屬 private 或 global 似乎加一個 property 標註一下即可。 - - jeforth 的 interpret state 以及 compiling 時搜尋參考到的 word 是透過一個 hash table 去找的。 - 要不要讓它進這個 hash table 應該就是這個 word 是否 global 了。每次重整 hash table 時看看 - 每個 word 的 exported property 以及當時的 context 兩點即可決定。就怕會不會捅出更難收拾 - 的複雜結果? - - 應該有人做過了? - - 請問像 Win32forth 這麼龐大,他對撞名有何對策? - - vocabulary 是目前習見的辦法。然而有了 vocabulary 還是很想念 private (或 local) 環境。 - 我會把 private 在 jeforth 上實現出來, private 是個 word, 動詞, 意思是把 last word 設 - 定成 private。實作上就是在這個 word object 的 private property 打成 true。那麼當它所 - 屬的 vocabulary 不是 context 時就看不見它。不是完全看不到, 而是要把它所屬的 vocabulary - 切成 context 才看得到,即使其 vocabulary 已經在 order 裡也還是看不到。相較於沒有 - private 觀念的 forth 系統—只要是名列 order 內的 vocabulary 他們所有的 word 都看得到— - 有所不同。private 是針對個別 word 的設定, 類似 immediate, compile-only 之類。我們還可 - 以加上個系統層面的 variable 用來當總開關—稱作 private-support 吧 — 當關掉不 support 時 - , 就等於是平常的 forth 系統—通通都是 global。如此就不怕引進 private 會引起甚麼想不到的 - 問題了。 - - code private ( -- ) \ Make the last new word invisible out of the vocabulary - last().private=true - end-code - - code rescan-word-hash ( -- ) \ Rescan all word-lists in the order[] to rebuild wordhash{} - wordhash = {}; - scan_vocabulary("forth"); // words in "forth" always available - for (var j=0; j tos().indexOf("-=e"+"Of=-")!=-1 if ( pathname file ) *debug* 111> - \ \ EOF is not allowed in ~.f module - \ s" Abort! EOF mark '-=eOf=-' is reserved but found in " + js> tos(2) + "msg"abort - \ then ( pathname file ) *debug* 222> - ("\n\\ -=pathname[" + pop(1) + "]pathname=-\n" + pop()) ( file' ) - \ - \ \ 跟 source_code_header 成對的尾部 - \ - \ js> tick('').masterMarker tib.insert - \ - \ js> tick('').enabled [if] js> tick('').buffer tib.insert [then] - \ js: tick('').buffer="" \ recycle the memory - \ s" \ --E" + s" OF--" + - \ swap ( -- code file ) - \ // 把 - - EOF - - 之後先切除再加回,為往後的 source code header, selftest 等準備。 - \ var ss = pop(); - \ ss = (ss+'x').slice(0,ss.search(/\\\s*-=eOf=-/)); // 一開始多加一個 'x' 讓 search 結果 -1 時吃掉。 - \ ss += pop(); // Now ss becomes the TOS - \ *debug* 444> - var ss=pop();(ss+'x').slice(0,ss.search(/-=eOf=-/))+'\n\\ -=eOf=-\n' \ The last \n 避免最後是 \ comment 時吃到後面來 - tib.insert ; - /// Add -=pathname[pathname]pathname=- and cut after -=eof=- - - \ developing new include and friends - - char -=EOF=- ( eof ) (new RegExp(tos())) ( eof /eof/ ) - js> ({regex:pop(),pattern:pop()}) constant EOF // ( -- {regex,pattern} ) End of file pattern and RegExp - - : sinclude ( "pathname" -- ... ) \ Lodad the given forth source file. - dup readTextFileAuto ( pathname file ) - ("\n\\ -=pathname[" + pop(1) + "]pathname=-\n" + pop()) ( file' ) - var ss=pop();(ss+'x').slice(0,ss.search(vm.g.EOF.regex))+'\n\\ '+vm.g.EOF.pattern+'\n' - \ The last \n 避免最後是 \ comment 時吃到後面來 - tib.insert ; - /// Add -=pathname[pathname]pathname=- and cut after -=EOF=- - - : include ( -- ... ) \ Load the source file if it's not included yet. - BL word sinclude ; interpret-only - - "" value TIB - 0 value nTIB - : source~ - js> tib.slice(ntib).indexOf(vm.g.EOF.pattern) ( ieof ) - dup -1 = ?abort" Error! EOF mark not found." ( ieof ) - js> ntib + ( ieof ) \ insert selftest section tail here - js> tib.slice(ntib,pop()) ( tib[ntib ~ before EOF] ) \ cut after EOF - - \ 跟 source_code_header 成對的尾部 - - js> tick('').masterMarker tib.insert - - js> tick('').enabled [if] js> tick('').buffer tib.insert [then] - js: tick('').buffer="" \ recycle the memory - ( tib[ntib ~ before EOF] code ) + ( tib[ntib ~ before EOF]+code ) - s" \ " EOF :> pattern + js> '\n' + + ( tib[ntib~beforeEof+code+EOF] ) \ EOF mark appended back - js> tib.slice(0,ntib)+'\n' swap + js: tib=pop() ; - - - ?skip2 -=EOF=- \ skip it if already included - dup .( Including ) . cr char -- over over + + - js: tick('').masterMarker=tos()+"selftest--"; - also forth definitions (marker) (vocabulary) - last execute definitions - - \ setup marker of this module, run this marker to forget everything back to here. - js> tick('').masterMarker (marker) - - swap + ( tib_a' ) - js> tib to TIB js> ntib to nTIB *debug* 11> - lastIndexOf() - - find the eof index, - 11 33 44 -=eOf=- 44 55 66 :> slice(3).indexOf("-=eOf=-") tib. - new RegExp(pattern, attributes); - (new RegExp("pattern","img")) \ ==> /pattern/gim (object) - - : source-code-header ( -- ) \ The source-code-file.f header macro - - ?skip2 -=EOF=- \ skip it if already included - dup .( Including ) . cr char -- over over + + - js: tick('').masterMarker=tos()+"selftest--"; - also forth definitions (marker) (vocabulary) - last execute definitions - - js> tick('').masterMarker (marker) - - tib.insert ; - /// skip including if the module has been included. - /// setup the self-test module - /// initiate vocabulary for the including module - - \ developing new include and friends - - char -=EOF=- ( eof ) (new RegExp(tos())) ( eof /eof/ ) - js> ({regex:pop(),pattern:pop()}) constant EOF // ( -- {regex,pattern} ) End of file pattern and RegExp - - : sinclude ( "pathname" -- ... ) \ Lodad the given forth source file. - dup readTextFileAuto ( pathname file ) - ("\n\\ -=pathname[" + pop(1) + "]pathname=-\n" + pop()) ( file' ) - var ss=pop();(ss+'x').slice(0,ss.search(vm.g.EOF.regex))+'\n\\ '+vm.g.EOF.pattern+'\n' - \ The last \n 避免最後是 \ comment 時吃到後面來 - tib.insert ; - /// Add -=pathname[pathname]pathname=- and cut after -=EOF=- - - : include ( -- ... ) \ Load the source file if it's not included yet. - BL word sinclude ; interpret-only - - : prioritize ( vid -- ) \ Make the vocabulary first priority - js> order.indexOf(tos()) ( vid i ) - js> tos()==-1 ?abort" Error! unknown vocabulary." ( vid i ) - js> order.splice(pop(),1);order.push(pop()) ; - /// works fine! - - \ Get .f module file name left by include command - : get-module-name ( -- "name" ) \ include command inserts it before ntib - char -=pathname[ js> tib.slice(0,ntib).lastIndexOf(tos()) ( pattern i ) - dup -1 = ?abort" Error! ~.f pathname start mark not found." ( pattern i ) - swap :> length + ( i0 ) char ]pathname=- ( i0 pattern ) - js> tib.slice(0,ntib).lastIndexOf(pop()) ( i0 i ) - dup -1 = ?abort" Error! ~.f pathname end mark not found." ( i0 i ) - js> tib.substring(pop(1),pop()) ; - - : header ( -- 'head' ) \ ~.f common header - EOF :> pattern - \ ~.f common header - ?skip2 _eof_ \ skip it if already included - dup .( Including ) . cr char -- over over + + - js: tick('').masterMarker=tos()+"selftest--"; - also forth definitions (marker) (vocabulary) - last execute definitions - - js> tick('').masterMarker (marker) - - :> replace("_eof_",pop()) ; private - - : tailer ( -- 'tailer' ) \ ~.f common tailer - - \ ~.f common tailer - - js> tick('').masterMarker tib.insert - - js> tick('').enabled [if] js> tick('').buffer tib.insert [then] - js: tick('').buffer="" \ recycle the memory - ; private - - : source~ - \ Check if the module is included already - get-module-name ( fname ) dup (') ( fname w ) - if \ already included ( fname ) - *debug* 456> prioritize - else - \ not included yet ( fname ) - drop - \ cut after EOF - js> tib.slice(ntib).indexOf(vm.g.EOF.pattern) ( ieof ) - dup -1 = ?abort" Error! EOF mark not found." ( ieof ) - js> ntib + ( ieof ) \ insert selftest section tail here - js> tib.slice(ntib,pop()) ( tib[ntib ~ before EOF] ) - \ append the tailer - tailer + ( tib[ntib ~ before EOF]+tailer ) - \ append the EOF - s" \ " EOF :> pattern + js> '\n' + + ( tib[ntib~beforeEof+tailer+EOF] ) - \ wrap up the tib - js> tib.slice(0,ntib) swap + js: tib=pop() - header tib.insert - then ; + : sinclude ( "pathname" -- ... ) \ Lodad the given forth source file. + dup readTextFileAuto ( pathname file ) + \ js> tos().indexOf("-=e"+"Of=-")!=-1 if ( pathname file ) *debug* 111> + \ \ EOF is not allowed in ~.f module + \ s" Abort! EOF mark '-=eOf=-' is reserved but found in " + js> tos(2) + "msg"abort + \ then ( pathname file ) *debug* 222> + ("\n\\ -=pathname[" + pop(1) + "]pathname=-\n" + pop()) ( file' ) + \ + \ \ 跟 source_code_header 成對的尾部 + \ + \ js> tick('').masterMarker tib.insert + \ + \ js> tick('').enabled [if] js> tick('').buffer tib.insert [then] + \ js: tick('').buffer="" \ recycle the memory + \ s" \ --E" + s" OF--" + + \ swap ( -- code file ) + \ // 把 - - EOF - - 之後先切除再加回,為往後的 source code header, selftest 等準備。 + \ var ss = pop(); + \ ss = (ss+'x').slice(0,ss.search(/\\\s*-=eOf=-/)); // 一開始多加一個 'x' 讓 search 結果 -1 時吃掉。 + \ ss += pop(); // Now ss becomes the TOS + \ *debug* 444> + var ss=pop();(ss+'x').slice(0,ss.search(/-=eOf=-/))+'\n\\ -=eOf=-\n' \ The last \n 避免最後是 \ comment 時吃到後面來 + tib.insert ; + /// Add -=pathname[pathname]pathname=- and cut after -=eof=- + + \ developing new include and friends + + char -=EOF=- ( eof ) (new RegExp(tos())) ( eof /eof/ ) + js> ({regex:pop(),pattern:pop()}) constant EOF // ( -- {regex,pattern} ) End of file pattern and RegExp + + : sinclude ( "pathname" -- ... ) \ Lodad the given forth source file. + dup readTextFileAuto ( pathname file ) + ("\n\\ -=pathname[" + pop(1) + "]pathname=-\n" + pop()) ( file' ) + var ss=pop();(ss+'x').slice(0,ss.search(vm.g.EOF.regex))+'\n\\ '+vm.g.EOF.pattern+'\n' + \ The last \n 避免最後是 \ comment 時吃到後面來 + tib.insert ; + /// Add -=pathname[pathname]pathname=- and cut after -=EOF=- + + : include ( -- ... ) \ Load the source file if it's not included yet. + BL word sinclude ; interpret-only + + "" value TIB + 0 value nTIB + : source~ + js> tib.slice(ntib).indexOf(vm.g.EOF.pattern) ( ieof ) + dup -1 = ?abort" Error! EOF mark not found." ( ieof ) + js> ntib + ( ieof ) \ insert selftest section tail here + js> tib.slice(ntib,pop()) ( tib[ntib ~ before EOF] ) \ cut after EOF + + \ 跟 source_code_header 成對的尾部 + + js> tick('').masterMarker tib.insert + + js> tick('').enabled [if] js> tick('').buffer tib.insert [then] + js: tick('').buffer="" \ recycle the memory + ( tib[ntib ~ before EOF] code ) + ( tib[ntib ~ before EOF]+code ) + s" \ " EOF :> pattern + js> '\n' + + ( tib[ntib~beforeEof+code+EOF] ) \ EOF mark appended back + js> tib.slice(0,ntib)+'\n' swap + js: tib=pop() ; + + + ?skip2 -=EOF=- \ skip it if already included + dup .( Including ) . cr char -- over over + + + js: tick('').masterMarker=tos()+"selftest--"; + also forth definitions (marker) (vocabulary) + last execute definitions + + \ setup marker of this module, run this marker to forget everything back to here. + js> tick('').masterMarker (marker) + + swap + ( tib_a' ) + js> tib to TIB js> ntib to nTIB *debug* 11> + lastIndexOf() + + find the eof index, + 11 33 44 -=eOf=- 44 55 66 :> slice(3).indexOf("-=eOf=-") tib. + new RegExp(pattern, attributes); + (new RegExp("pattern","img")) \ ==> /pattern/gim (object) + + : source-code-header ( -- ) \ The source-code-file.f header macro + + ?skip2 -=EOF=- \ skip it if already included + dup .( Including ) . cr char -- over over + + + js: tick('').masterMarker=tos()+"selftest--"; + also forth definitions (marker) (vocabulary) + last execute definitions + + js> tick('').masterMarker (marker) + + tib.insert ; + /// skip including if the module has been included. + /// setup the self-test module + /// initiate vocabulary for the including module + + \ developing new include and friends + + char -=EOF=- ( eof ) (new RegExp(tos())) ( eof /eof/ ) + js> ({regex:pop(),pattern:pop()}) constant EOF // ( -- {regex,pattern} ) End of file pattern and RegExp + + : sinclude ( "pathname" -- ... ) \ Lodad the given forth source file. + dup readTextFileAuto ( pathname file ) + ("\n\\ -=pathname[" + pop(1) + "]pathname=-\n" + pop()) ( file' ) + var ss=pop();(ss+'x').slice(0,ss.search(vm.g.EOF.regex))+'\n\\ '+vm.g.EOF.pattern+'\n' + \ The last \n 避免最後是 \ comment 時吃到後面來 + tib.insert ; + /// Add -=pathname[pathname]pathname=- and cut after -=EOF=- + + : include ( -- ... ) \ Load the source file if it's not included yet. + BL word sinclude ; interpret-only + + : prioritize ( vid -- ) \ Make the vocabulary first priority + js> order.indexOf(tos()) ( vid i ) + js> tos()==-1 ?abort" Error! unknown vocabulary." ( vid i ) + js> order.splice(pop(),1);order.push(pop()) ; + /// works fine! + + \ Get .f module file name left by include command + : get-module-name ( -- "name" ) \ include command inserts it before ntib + char -=pathname[ js> tib.slice(0,ntib).lastIndexOf(tos()) ( pattern i ) + dup -1 = ?abort" Error! ~.f pathname start mark not found." ( pattern i ) + swap :> length + ( i0 ) char ]pathname=- ( i0 pattern ) + js> tib.slice(0,ntib).lastIndexOf(pop()) ( i0 i ) + dup -1 = ?abort" Error! ~.f pathname end mark not found." ( i0 i ) + js> tib.substring(pop(1),pop()) ; + + : header ( -- 'head' ) \ ~.f common header + EOF :> pattern + \ ~.f common header + ?skip2 _eof_ \ skip it if already included + dup .( Including ) . cr char -- over over + + + js: tick('').masterMarker=tos()+"selftest--"; + also forth definitions (marker) (vocabulary) + last execute definitions + + js> tick('').masterMarker (marker) + + :> replace("_eof_",pop()) ; private + + : tailer ( -- 'tailer' ) \ ~.f common tailer + + \ ~.f common tailer + + js> tick('').masterMarker tib.insert + + js> tick('').enabled [if] js> tick('').buffer tib.insert [then] + js: tick('').buffer="" \ recycle the memory + ; private + + : source~ + \ Check if the module is included already + get-module-name ( fname ) dup (') ( fname w ) + if \ already included ( fname ) + *debug* 456> prioritize + else + \ not included yet ( fname ) + drop + \ cut after EOF + js> tib.slice(ntib).indexOf(vm.g.EOF.pattern) ( ieof ) + dup -1 = ?abort" Error! EOF mark not found." ( ieof ) + js> ntib + ( ieof ) \ insert selftest section tail here + js> tib.slice(ntib,pop()) ( tib[ntib ~ before EOF] ) + \ append the tailer + tailer + ( tib[ntib ~ before EOF]+tailer ) + \ append the EOF + s" \ " EOF :> pattern + js> '\n' + + ( tib[ntib~beforeEof+tailer+EOF] ) + \ wrap up the tib + js> tib.slice(0,ntib) swap + js: tib=pop() + header tib.insert + then ; [x] Used tib is not reliable, the -=pathname[name.f]pathname=- mark left by include command is not reliable either. So, sinclude command should save the pathname @@ -5062,7 +5062,7 @@ name.f given explicitly. [x] I am warrying about the nested ~.f modules. An included module is to be tib.inserted - to the position of ntib. The process should not hurt the original tib. + to the position of ntib. The process should not hurt the original tib. My sinclude command does it well. <--- OK. [/] But source~ should insert the header and tailer into the right place or split tib into 3 pices [used][ntib~EOF][after EOF] is also a method candidate. @@ -5115,7 +5115,7 @@ now they should be under vm.g.vid.name if they are private word. This is difficult because definiton doesn't know if it's a private word. So, all of them are to be hooked under their definition vid not only private words. - --> This is easy, modify 'constant' would be enough. + --> This is easy, modify 'constant' would be enough. --> ok now! Much much easier than I anticipated. 3hta and 3htm passed self-test already. [x] context is a jeforth.js global variable. It should always be a copy of order[order.length-1]. I guess rescan-word-hash is the right place to do this. @@ -5124,21 +5124,21 @@ : test3 also hte.f one previous ; although the above example looks verbose, but 'one' in hte.f is a private word and test3 defined in a different context can use it. --> they work fine. - [x] See setup.bat (was vm.v[context]) vm[context] is not correct! Should be vm.[current]. - --> vm.v[current] was a mistake. context = current then still use vm[context] is correct. - [x] setup.bat uses value and vm.g.flag and vm.g._a thus is now not working because they should be - (was vm.v[]) vm.[context].flag and vm[context]._a - [x] Am I going to modify all vm.g to vm[context] ? very annoying and I am afraid it's a bad - idea and I'll have to modify again. - --> See Ynote: "jeforth.3we private support value vm.g.name become vm.vid.name" discussion. - 1. For code word, vm[_me.vid].name - 2. For ... in tib, vm[context].name or vid js> vm[pop()].name - 3. vid forth word is a private command, code vid push(_me.vid) end-code private - so vid command can be used in colon words for js: statements - 4. for in module applications , everything is in the ~.f module. Thus js> current and js> - context are the same vid. This is important and is done by source-code-header. Thus - vm[context].name is the easist way. - [x] check all vm.g.name and vm.g[name] values and constants + [x] See setup.bat (was vm.v[context]) vm[context] is not correct! Should be vm.[current]. + --> vm.v[current] was a mistake. context = current then still use vm[context] is correct. + [x] setup.bat uses value and vm.g.flag and vm.g._a thus is now not working because they should be + (was vm.v[]) vm.[context].flag and vm[context]._a + [x] Am I going to modify all vm.g to vm[context] ? very annoying and I am afraid it's a bad + idea and I'll have to modify again. + --> See Ynote: "jeforth.3we private support value vm.g.name become vm.vid.name" discussion. + 1. For code word, vm[_me.vid].name + 2. For ... in tib, vm[context].name or vid js> vm[pop()].name + 3. vid forth word is a private command, code vid push(_me.vid) end-code private + so vid command can be used in colon words for js: statements + 4. for in module applications , everything is in the ~.f module. Thus js> current and js> + context are the same vid. This is important and is done by source-code-header. Thus + vm[context].name is the easist way. + [x] check all vm.g.name and vm.g[name] values and constants Total commander or Notepad++ RegEx : \s?vm\.g(\.|\[) xx c:\Users\hcche\Documents\GitHub\jeforth.3we\demo\ball.f xx c:\Users\hcche\Documents\GitHub\jeforth.3we\demo\blowing-in-the-wind.f @@ -5162,40 +5162,40 @@ xx c:\Users\hcche\Documents\GitHub\jeforth.3we\3ce\target.f [x] attach 3ce to target page does not work, yet the F7 command is fine. > js> document.title . \ ==> hao123网址之家-在线繁体字转换 OK - [x] I guess the readTextFile on target page does not work , because include & + [x] I guess the readTextFile on target page does not work , because include & sinclude have been modified recently. --> actually readTextFile does not work - at all. it's good to have F7 enter so I know. - [x] Also, target.f no exist either. --> simply because not read - [x] Some older note recalled from jeforth.3we/log/Log of TR.html - o 當 host page 都不存在時, readTextFile 也不 work 了! 已證實。--> So we need background page (to readTextFile) - o Google 已經建議用 Event page 取代 background page 了 --> no much difference. - o 檢驗 background-page pop().vm.dictate("11 22 33 .s js: debugger") - o 由 3ce extenstion page 對 background page 下令的公式: - background-page tos().bvm.dictate("cr see readTextFile");pop().bvm.screenbuffer . - o 對 background page jeforth 下令的範本: - background-page pop().bvm.dictate(".s") - background-page :> bvm.screenbuffer . - o 若要重複 init background page 只要 - background-page :: jeforth_project_k_virtual_machine_object=null - 然後 refresh 3ce extension page 即可。 - --> er background-page :> document.head.outerHTML . - er background-page :> document.body.outerHTML . - both empty, so I guess the background page is not init'ed - --> use chrome://extensions/ > Inspect views: jeforth.3ce.background.html to check - background page --> no body, no head - --> incorrect! We have jeforth.3ce.background.html - --> do the same inspect on the 3ce from Google Play --> the background page is correct - body and head are all as jeforth.3ce.background.html - which is not empty, title is jeforth.3ce background page besides - [x] I guess jeforth.3ce.background.html is a symbolic link instead of a hard link - in setup.bat is the root cause! --> Yeah!! - [x] Now check the background page title - > background-page :> document.title . \ ==> jeforth.3ce background page OK - Bingo! so easy, run from 3ce page. - [x] Now, Bug fixed! Root cause is in setup.bat, jeforth.3ce.background.html should be hard link - should not be symbolic link. symbolic link jeforth.3ce.background.html causes no error - in manifest.json but it become an empty nothing like a null jeforth.3ce.background.html. - + at all. it's good to have F7 enter so I know. + [x] Also, target.f no exist either. --> simply because not read + [x] Some older note recalled from jeforth.3we/log/Log of TR.html + o 當 host page 都不存在時, readTextFile 也不 work 了! 已證實。--> So we need background page (to readTextFile) + o Google 已經建議用 Event page 取代 background page 了 --> no much difference. + o 檢驗 background-page pop().vm.dictate("11 22 33 .s js: debugger") + o 由 3ce extenstion page 對 background page 下令的公式: + background-page tos().bvm.dictate("cr see readTextFile");pop().bvm.screenbuffer . + o 對 background page jeforth 下令的範本: + background-page pop().bvm.dictate(".s") + background-page :> bvm.screenbuffer . + o 若要重複 init background page 只要 + background-page :: jeforth_project_k_virtual_machine_object=null + 然後 refresh 3ce extension page 即可。 + --> er background-page :> document.head.outerHTML . + er background-page :> document.body.outerHTML . + both empty, so I guess the background page is not init'ed + --> use chrome://extensions/ > Inspect views: jeforth.3ce.background.html to check + background page --> no body, no head + --> incorrect! We have jeforth.3ce.background.html + --> do the same inspect on the 3ce from Google Play --> the background page is correct + body and head are all as jeforth.3ce.background.html + which is not empty, title is jeforth.3ce background page besides + [x] I guess jeforth.3ce.background.html is a symbolic link instead of a hard link + in setup.bat is the root cause! --> Yeah!! + [x] Now check the background page title + > background-page :> document.title . \ ==> jeforth.3ce background page OK + Bingo! so easy, run from 3ce page. + [x] Now, Bug fixed! Root cause is in setup.bat, jeforth.3ce.background.html should be hard link + should not be symbolic link. symbolic link jeforth.3ce.background.html causes no error + in manifest.json but it become an empty nothing like a null jeforth.3ce.background.html. + xx c:\Users\hcche\Documents\GitHub\jeforth.3we\demo\solar-system.f [x] 2016/12/27 15:48 This command line : '[begin] ." *" 100 nap [again]' stops the solar system! @@ -5240,7 +5240,7 @@ --> failed! --> commit 4c009ce7a1e5aec19513b1fc66e7d651ba404b20 Author: H.C. Chen - Date: Sun Jun 12 00:08:57 2016 +0800 + Date: Sun Jun 12 00:08:57 2016 +0800 new nap sleep [begin][for] and [[for]] @@ -5377,18 +5377,18 @@ c:\Users\hcche\Documents\GitHub\jeforth.3we\playground\123.f [x] recently, only foo will crash the system , previous rescan-wordhash is better. - Done, now: - only work.f help * - works fine. + Done, now: + only work.f help * + works fine. [x] 3hta, include work.f, all words are private but not lookup, why? It's the only code word - Ha, this line in definition of 'code' is a mistake: - execute("privacy");last().private = Boolean(pop()); - should be in 'end-code's definition because last() is not this word when in code. - re-define end-code like what I did to code does not work, although the experiment of - code end-code alert(1234) end-code - works fine. However, modify end-code.xt directly can be an solution --> Bingo! + Ha, this line in definition of 'code' is a mistake: + execute("privacy");last().private = Boolean(pop()); + should be in 'end-code's definition because last() is not this word when in code. + re-define end-code like what I did to code does not work, although the experiment of + code end-code alert(1234) end-code + works fine. However, modify end-code.xt directly can be an solution --> Bingo! [x] 3hta has a new problem. 1. include foo.f <-- file not found - then F5 and ctrl-up are all triggering jsc error! <== Problem! + then F5 and ctrl-up are all triggering jsc error! <== Problem! --> 3ce is fine. Only 3HTA has this problem. So, 3hta's jsc is suspected. debugging sinclude . . . --> no need to include foo.f, run jsc then the problem begins --> run any command (cr, words) or trigger any event (single-click) @@ -5419,23 +5419,23 @@ [x]base [x]breakPoint [x]args [x]up/down-recall-needs-alt-key? [x] 準備 release master 新版 release 新版 master - o search "kvm.minor_version" increase 版號。 - [x] jeforth.3nd.js --> version 203 - [x] 3nw, jeforth.3we/package.json version 223 - [x] jeforth.3htm.js --> to be version 203 - [x] jeforth.3ce.js(3ce extension pages)-> 203 - [x] jeforth.3ce, ce.f(Target page) -> vm.minor_version = 203 - [x] jeforth.3ce, background.js vm.minor_version = 203 - [x] jeforth.hta --> tag. VERSION="204" - [/] jeforth.3ca, also jeforth.3htm.js above - o selftest them all - [x] setup.bat - [x] 3hta - [x] 3nw use 3hta to fork cmd /c start nw ../jeforth.3we - [x] 3htm use 3nw or 3nd to include webserver.f and then localhost:8888 - [x] 3nd - [x] 3ce - [x] 3ca + o search "kvm.minor_version" increase 版號。 + [x] jeforth.3nd.js --> version 203 + [x] 3nw, jeforth.3we/package.json version 223 + [x] jeforth.3htm.js --> to be version 203 + [x] jeforth.3ce.js(3ce extension pages)-> 203 + [x] jeforth.3ce, ce.f(Target page) -> vm.minor_version = 203 + [x] jeforth.3ce, background.js vm.minor_version = 203 + [x] jeforth.hta --> tag. VERSION="204" + [/] jeforth.3ca, also jeforth.3htm.js above + o selftest them all + [x] setup.bat + [x] 3hta + [x] 3nw use 3hta to fork cmd /c start nw ../jeforth.3we + [x] 3htm use 3nw or 3nd to include webserver.f and then localhost:8888 + [x] 3nd + [x] 3ce + [x] 3ca [x] Testing all demo, calc.f does not work in 3ca due to the inline permission. Try to rewrite event handlers of those buttons. Search "Refused to execute inline event handler" there's a solution above (in log.txt). Solution is very viable. Avoid using onclick=anything @@ -5445,56 +5445,56 @@ [x] setup.bat screen flashs badly, try not but beautiful progress info instead on the 3hta window. [x] done with (run) (fork) and (dos) <--- they are now silently run. [x] Simplify setup.bat to use (dos) instead of (run) - [x] commit develop -> 將 develop 分支發佈到 Master 分支的命令 : - 切換到Master分支 : git checkout master - 合併 develop 分支進 master 來 : git merge --no-ff develop - Merge branch 'develop' - # Conflicts: - # 3ca/fig.tw128x128.png - # 3ca/fig.tw16x16.png - # 3hta/localstorage.json - # 3nw/localstorage.json - # - # It looks like you may be committing a merge. - # If this is not correct, please remove the file - # .git/MERGE_HEAD - # and try again. - I plan to rm them all and copy them back from develop, and commit again. - 他說我有問題的,很多不知何故,連 .png 都說是 conflict!? 解法是乾脆把它們都殺掉,因為確信 develop - 版是沒問題的。先 git rm <所有 conflicts> 然後 commit 成功, 把這些檔案 copy 回來再 commit 一次 - 就可以解決。 - [x] Test the master all over again ... pass - [x] Master 到回 develop - 切換到Master分支 : git checkout develop - 合併 develop 分支進 master 來 : git merge --no-ff master - [x] release note - + [x] commit develop -> 將 develop 分支發佈到 Master 分支的命令 : + 切換到Master分支 : git checkout master + 合併 develop 分支進 master 來 : git merge --no-ff develop + Merge branch 'develop' + # Conflicts: + # 3ca/fig.tw128x128.png + # 3ca/fig.tw16x16.png + # 3hta/localstorage.json + # 3nw/localstorage.json + # + # It looks like you may be committing a merge. + # If this is not correct, please remove the file + # .git/MERGE_HEAD + # and try again. + I plan to rm them all and copy them back from develop, and commit again. + 他說我有問題的,很多不知何故,連 .png 都說是 conflict!? 解法是乾脆把它們都殺掉,因為確信 develop + 版是沒問題的。先 git rm <所有 conflicts> 然後 commit 成功, 把這些檔案 copy 回來再 commit 一次 + 就可以解決。 + [x] Test the master all over again ... pass + [x] Master 到回 develop + 切換到Master分支 : git checkout develop + 合併 develop 分支進 master 來 : git merge --no-ff master + [x] release note + [/] Change the startup rule: Selftest to be run by selftest command instead of an empty command line. --> js: tick('').enabled=false in every quit.f - --> 算了麻煩 + --> 算了麻煩 [/] Do we need a command to inhibit any new tib commands during nap / sleep ? - --> to avoid stack/rstack or whatever system things to be changed during napping in waiting - I/O. Sounds necessary, but how? --> where to add this line? - if(kvm.tick("sleep").timeoutId) return; // sleep if for I/O, avoid - --> Add a 'sleeping' variable to project-k jeforth.js kernel to replace using - kvm.tick("sleep").timeoutId if outer() and dictate() are the right places to inhibit - executing during sleeping. - Let it be, abort, no actual reason so far. - + --> to avoid stack/rstack or whatever system things to be changed during napping in waiting + I/O. Sounds necessary, but how? --> where to add this line? + if(kvm.tick("sleep").timeoutId) return; // sleep if for I/O, avoid + --> Add a 'sleeping' variable to project-k jeforth.js kernel to replace using + kvm.tick("sleep").timeoutId if outer() and dictate() are the right places to inhibit + executing during sleeping. + Let it be, abort, no actual reason so far. + [ ] setup.bat to build simplest working directories, e.g. jeforth.3hta/, jeforth.3htm, .. etc without log/ demo/ background/ doc/ ... etc. According to Degn,Yuan-Yuan's request. [x] private support is good, but there are many event handlers like examples in ls.f - $(".ebreadonly",tos())[0].onclick =function(e){push(this);execute("eb.readonly");return(false)} - will be not working because "call by name" and the name will be invisible after being not - the context. My idea is to have a word, say 'word>handler' that output a handler function. So, - code word>handler ( word -- handler() ) \ Pack the word into an event handler + $(".ebreadonly",tos())[0].onclick =function(e){push(this);execute("eb.readonly");return(false)} + will be not working because "call by name" and the name will be invisible after being not + the context. My idea is to have a word, say 'word>handler' that output a handler function. So, + code word>handler ( word -- handler() ) \ Pack the word into an event handler ... snip ... - end-code - and the line will become: - ['] eb.readonly word>handler js: $(".ebreadonly",tos(n))[0].onclick=pop() - [x] call by name must be reviewed especially utility vocabularies. + end-code + and the line will become: + ['] eb.readonly word>handler js: $(".ebreadonly",tos(n))[0].onclick=pop() + [x] call by name must be reviewed especially utility vocabularies. --> tick() and execute() have run-time-warning in selftest mode - [x] ls.f privacy is true now. + [x] ls.f privacy is true now. [ ] ... does not work as expected. Remove them. : ( -- "task" ) \ Invoke a dictate() to run the words. char word ; immediate @@ -5566,11 +5566,11 @@ Warning! private word [all-pass] referenced by name in tick()! [x] These private words are only used in the same module, make them be private at the end of the module : - ' description :: private=true + ' description :: private=true ' expected_rstack :: private=true ' expected_stack :: private=true - ' test-result :: private=true - ' [all-pass] :: private=true + ' test-result :: private=true + ' [all-pass] :: private=true --> this is annoying, because then we can't make the word private when define it. Use this idea when in jeforth.f to avoid warnings is fine. ==> Done, default only warning when in selftest mode. @@ -5590,7 +5590,7 @@ --> F7 or (dictate) both need attach the target tab first, try them: --> both work!!! --> readTextFile suspected again ... yes it is the criminal due to: > char manifest.json readTextFileAuto . \ {F7} - dummy,doc,f,3htm/f,3htm/canvas,3htm,3ce,playground OK <--- problem! the file is not read correctly + dummy,doc,f,3htm/f,3htm/canvas,3htm,3ce,playground OK <--- problem! the file is not read correctly --> trace back develop versions... all failed --> re-start Chrome then OK! Shit [x] Redefine (words) to support 'all' command. Rename to word_select. @@ -5598,25 +5598,25 @@ \ it works now! see you tomorrow with my Metamoji note on X1 Yoga. --> Test [x] 3htm (help) [x] 準備 release master 新版 release 新版 master : af266a3f8c4fefafc04947e9ba0b89d9f3601eed - o search "kvm.minor_version" increase 版號。 - [x] jeforth.3nd.js --> kvm.minor_version = 203 -> 204 - [x] 3nw, jeforth.3we/package.json version 223 -> 224 - [x] jeforth.3htm.js --> kvm.minor_version = 203 -> 204 - [x] jeforth.3ce.js(3ce extension pages)-> 203 kvm.minor_version = 204 - [x] jeforth.3ce, ce.f(Target page) -> vm.minor_version = 203 -> vm.minor_version = 204 - [x] jeforth.3ce, background.js vm.minor_version = 203 -> vm.minor_version = 204 - [x] jeforth.hta --> tag. VERSION="204" -> VERSION="205" - [/] jeforth.3ca, also jeforth.3htm.js above - o selftest them all - [x] setup.bat - [x] 3nw use 3hta to fork cmd /c start nw ../jeforth.3we - [x] 3nd + o search "kvm.minor_version" increase 版號。 + [x] jeforth.3nd.js --> kvm.minor_version = 203 -> 204 + [x] 3nw, jeforth.3we/package.json version 223 -> 224 + [x] jeforth.3htm.js --> kvm.minor_version = 203 -> 204 + [x] jeforth.3ce.js(3ce extension pages)-> 203 kvm.minor_version = 204 + [x] jeforth.3ce, ce.f(Target page) -> vm.minor_version = 203 -> vm.minor_version = 204 + [x] jeforth.3ce, background.js vm.minor_version = 203 -> vm.minor_version = 204 + [x] jeforth.hta --> tag. VERSION="204" -> VERSION="205" + [/] jeforth.3ca, also jeforth.3htm.js above + o selftest them all + [x] setup.bat + [x] 3nw use 3hta to fork cmd /c start nw ../jeforth.3we + [x] 3nd [x] run webserver.f - [x] 3htm use 3nw or 3nd to include webserver.f and then localhost:8888 - [x] 3hta - [x] 3ce + [x] 3htm use 3nw or 3nd to include webserver.f and then localhost:8888 + [x] 3hta + [x] 3ce [x] attach to target pages - [x] 3ca + [x] 3ca [x] Testing all demo [x] 12choc.f , [x] alarm.f , [x] ball.f(non-selftest mode) , [x] blowing-in-the-wind.f , [x] box2dweb-arrow.f , [x] calc.f , [x] chipmunk-js-pyramidstack.f , @@ -5661,22 +5661,22 @@ [ ] webserver.bat 要避免重複跑,multiple instance 搶著當 localHost server 不可能。 [ ] hcchen5600 2015/11/13 10:46:32 - hash>column2 改寫成好用的介面。 + hash>column2 改寫成好用的介面。 [x] How to make a release on GitHub? Not only a master commit, but an official release. ==> Ynote: GitHub Creating Releases.note [x] Unify the version. See above log of a master release, it takes a lot of efforts to modify the version code of each application. - --> ./js/version.js minor_version all 301 - [x] jeforth.3nd.js - [x] 3nw, jeforth.3we\jeforth.3nw.html - [x] 3htm, 3ca, jeforth.3we\3htm\js\jeforth.3htm.js - [x] 3ca, also jeforth.3htm.js above - [x] 3ce.js(3ce extension pages) - [x] 3ce, ce.f (Target page) - [x] 3ce, jeforth.3ce.background.html, background.js vm.minor_version=jeforth3we_minor_version - [x] 3hta, --> tag. VERSION="204" -> VERSION="205" + --> ./js/version.js minor_version all 301 + [x] jeforth.3nd.js + [x] 3nw, jeforth.3we\jeforth.3nw.html + [x] 3htm, 3ca, jeforth.3we\3htm\js\jeforth.3htm.js + [x] 3ca, also jeforth.3htm.js above + [x] 3ce.js(3ce extension pages) + [x] 3ce, ce.f (Target page) + [x] 3ce, jeforth.3ce.background.html, background.js vm.minor_version=jeforth3we_minor_version + [x] 3hta, --> tag. VERSION="204" -> VERSION="205" [x] Remove the : @@ -5715,7 +5715,7 @@ how to arrange a FTP server now. While, jeforth.3nd or 3nw webserver + wget is a solution I like. Therefore, I am now interested to study webserver.f and try to improve it. - I was studying this : "Build Your First HTTP Server in Node.js" https://www.diigo.com/user/hcchen/b/373115646 + I was studying this : "Build Your First HTTP Server in Node.js" https://www.diigo.com/user/hcchen/b/373115646 yesterday. See ~\jeforth.3we\playground\build_your_http_server.f I studied how to use node.js to build a web site before, see Yun.baidu.com "ebook NODE.js" @@ -5752,29 +5752,29 @@
drop getFiles js: myfiles.onchange=pop() \ 3ce doesn't accept inline event handler - [ ] The upload form example from ipad "USB Disk Pro" http://192.168.0.196:8080/ HFS: -
- - <----------- add multiple see see - -
- --> It really works in 3ce attached console. So how to do the samething through - JavaScript for automation? - [x] Post是将表单中的数据放在form的数据体中,按照变量和值相对应的方式,传递到action所指向URL。 - --> So I don't need to attach to the real target page. Just letting above form's - action="192.168.0.196:8080" <--- no it doesn't work. The page must be connected. - [x] 強行添加 multiple to --> it doesn't work. - only one file transfered still. - [x] Try to assign pathname directly @ 3ce attached console - $("input")[1].value="c:\Users\hcche\Downloads\1.au3" - JavaScript error : Failed to set the 'value' property on 'HTMLInputElement': This input - element accepts a filename, which may only be programmatically set to the empty string. - --> is this to the "USB Disk Pro" page only? - --> all input type=file do not accept value to be set to non-empty. - [x] Get filename though my input type=file but submit them manually - --> all input type=file do not accept value to be set to non-empty. - [ ] I also tried to use FTP server on my computer hoping iPad can then download files from it. - But cesarFTP does not work now! and Filezilla needs to learn how to use. + [ ] The upload form example from ipad "USB Disk Pro" http://192.168.0.196:8080/ HFS: +
+ + <----------- add multiple see see + +
+ --> It really works in 3ce attached console. So how to do the samething through + JavaScript for automation? + [x] Post是将表单中的数据放在form的数据体中,按照变量和值相对应的方式,传递到action所指向URL。 + --> So I don't need to attach to the real target page. Just letting above form's + action="192.168.0.196:8080" <--- no it doesn't work. The page must be connected. + [x] 強行添加 multiple to --> it doesn't work. + only one file transfered still. + [x] Try to assign pathname directly @ 3ce attached console + $("input")[1].value="c:\Users\hcche\Downloads\1.au3" + JavaScript error : Failed to set the 'value' property on 'HTMLInputElement': This input + element accepts a filename, which may only be programmatically set to the empty string. + --> is this to the "USB Disk Pro" page only? + --> all input type=file do not accept value to be set to non-empty. + [x] Get filename though my input type=file but submit them manually + --> all input type=file do not accept value to be set to non-empty. + [ ] I also tried to use FTP server on my computer hoping iPad can then download files from it. + But cesarFTP does not work now! and Filezilla needs to learn how to use. [ ] 17:17 2017-03-01 RStudio Source box is a very good example to learn. ls.f ed [run] button needs improvement. Running throught he entire field is not good for exercise. Run only one line and a way to run multiple lines and also the entire field is an interesting @@ -5845,13 +5845,13 @@ > : comment CR word drop ; > comment ." Hello" - OK <-------------- Indeed! the next line is eaten by 'comment' unexpectedly + OK <-------------- Indeed! the next line is eaten by 'comment' unexpectedly > comment <--- add a space ." Hello" Hello OK <--------- then OK [x] So, nexttoken() to always eat the next character is not very good. Should not when delimiter is : case '\\n': case '\\r': case '\\n|\\r': case '\\r|\\n': - case '\n': case '\r': case '\n|\r': case '\r|\n': + case '\n': case '\r': case '\n|\r': case '\r|\n': Where '\n' and '\\n' are same or not depends on nextstring(RegEx), I think they are same. Because a real '\n' and a symble '\\n' is same to String.search() I guess. The following experiment has proved this: > @@ -5872,7 +5872,7 @@ But \s \w \d are RegEx symbole, they must be \\s \\w \\d if appear in a delimiter. aa 123 - bb cc + bb cc :> search("\\d") \ ==> 3 (number) , if "\d" instead then result will be -1. [x] 19:21 May 15, 2017 @@ -5881,10 +5881,10 @@ ~\Documents\GitHub> git clone https://github.com/hcchengithub/jeforth.3we/wiki <------------ Wrong URL !!! Cloning into 'wiki'... fatal: https://github.com/hcchengithub/jeforth.3we/wiki/info/refs not valid: is this a git repository? - ~\Documents\GitHub> git clone https://github.com/hcchengithub/jeforth.3we.wiki <----------- Corect URL !!! + ~\Documents\GitHub> git clone https://github.com/hcchengithub/jeforth.3we.wiki <----------- Corect URL !!! Cloning into 'jeforth.3we.wiki'... remote: Counting objects: 199, done. - remote: Total 199 (delta 0), reused 0 (delta 0), pack-reused 199Receiving objects: 64% (129/199), 580.01 KiB | 63.00 Ki + remote: Total 199 (delta 0), reused 0 (delta 0), pack-reused 199Receiving objects: 64% (129/199), 580.01 KiB | 63.00 Ki Receiving objects: 100% (199/199), 629.37 KiB | 68.00 KiB/s, done. Resolving deltas: 100% (97/97), done. @@ -5902,18 +5902,18 @@ [ ] Make a master release and update the issue https://github.com/hcchengithub/jeforth.3we/issues/5 [x] 準備 release master 新版 release 新版 master - [x] jeforth.3we\js\version.js --> jeforth3we_minor_version = 303; + [x] jeforth.3we\js\version.js --> jeforth3we_minor_version = 303; [ ] Check the date stamp at the bottom of README.md - o selftest them all - [x] setup.bat - [x] 3nw use 3hta to fork cmd /c start nw ../jeforth.3we - [x] 3nd + o selftest them all + [x] setup.bat + [x] 3nw use 3hta to fork cmd /c start nw ../jeforth.3we + [x] 3nd [x] run webserver.f - [x] 3htm use 3nw or 3nd to include webserver.f and then localhost:8888 - [x] 3hta - [x] 3ce + [x] 3htm use 3nw or 3nd to include webserver.f and then localhost:8888 + [x] 3hta + [x] 3ce [x] attach to target pages - [x] 3ca + [x] 3ca [x] Testing all demo [x] 12choc.f , [x] alarm.f , [x] ball.f(non-selftest mode) , [x] blowing-in-the-wind.f , [x] box2dweb-arrow.f , [x] calc.f , [x] chipmunk-js-pyramidstack.f , @@ -5932,4 +5932,52 @@ [ ] README.md to include http://cdn.rawgit.com/hcchengithub/jeforth.3we/r2/index.html?cls_include_tutor-cloth.f [ ] Try to use Ubuntu NW.js or Node.js to try jeforth.3nw, 3nd on Ubuntu. - \ No newline at end of file +[ ] 10:34 2017/07/01 faceapi.f does not work on 3ha. The error object returned from $.ajax() is + { + "readyState": 0, + "status": 0, + "statusText": "No Transport" + } OK + --> Has $.ajax ever been working in 3hta? search ajax see see . . . No, not used before. --> Check + HTA and ajax on the net ... + http://3fwork.com/b402/003425MYM028859/ + 我最先定位到的是ajax方法返回status=0,statusText=No Transport。然后开始了我的查找问题之旅,我在 + 网上所查出的资料都说这个是由于跨域 cross Domain 造成的。 + [x] 試試別的 ajax function --> Good! 成功複製出了問題!--> [ ] 趁現在問 Microsoft 的論壇 + js> $.ajax({url:"http://example.com/",async:false}).responseText tib. + --> 在 3ca 很成功地讀回該網頁的整個 HTML + --> 在 3hta 就失敗了 + + $.ajax({url:"http://example.com/",async:false}) + .done(function(response) { + alert("success"); + }) + .fail(function(error) { + alert("error"); + push(error); + execute('(see)'); // see the error message + }); + + { + "readyState": 0, + "status": 0, + "statusText": "No Transport" + } + --> But it fail in repro.htm too. So, jeforth.3htm has enabled something. what's that? + [x] Try project-k file:///C:/Users/hcche/Documents/GitHub/jeforth.3we/project-k/sample.html + Yes, same problem reproduced + status : 0 + statusText : NetworkError: Failed to execute 'send' on 'XMLHttpRequest': + Failed to load 'http://example.com/' + [x] 果然, jeforth.3htm web 也不行 --> 所以 3ce 3ca 都是特權, 3hta 不行是對的! + "readyState": 0, + "status": 0, + "statusText": "NetworkError: Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'http://example.com/?_=1498901836169'." + --> 然而 faceapi.f 在 project-k sample.html and 3htm web are both working fine ! + So, Azure server side is ok with cross domain. HTA really has problem. + [ ] Try faceapi.htm rename to ~.hta . . . + + [ ] 可以 trace 進 jquery 去查。 + [ ] 不用 ajax 能不能 POST ? + [ ] 別的 ajax POST 去處 + \ No newline at end of file From 6fb1e6da16bf3ecb206dd59f450df8430ef1bef8 Mon Sep 17 00:00:00 2001 From: "H.C. Chen" Date: Wed, 5 Jul 2017 10:11:16 +0800 Subject: [PATCH 07/16] Remove nic.bat Not a good idea, right click to run 3hta.bat can get admin privilege --- 3hta/NIC.bat | 77 --------------- 3hta/f/wmi.f | 17 ++++ 3hta/install.bat | 43 --------- 3hta/localstorage.json | 2 +- 3hta/setup_3hta.bat | 43 +++++++++ playground/NIC.bat | 1 - playground/faceapi.f | 112 ++++++++++++---------- playground/luis.f | 42 +++++++++ setup.bat | 208 +++++++++++++++++++++-------------------- 9 files changed, 273 insertions(+), 272 deletions(-) delete mode 100644 3hta/NIC.bat delete mode 100644 3hta/install.bat create mode 100644 3hta/setup_3hta.bat create mode 100644 playground/luis.f diff --git a/3hta/NIC.bat b/3hta/NIC.bat deleted file mode 100644 index bbea5e7..0000000 --- a/3hta/NIC.bat +++ /dev/null @@ -1,77 +0,0 @@ -: @rem ; ' \ aliases echo @echo @echo. @goto :end jeforth.hta @rem cd call @if :ERR pause :END -cd %~dp0 -@rem -@rem N I C . b a t -@rem -@rem -@rem H.C. Chen 3:29 PM 6/27/2017 -@rem - -@echo. -@echo Executing %~nx0 . . . -@goto batch -\ --------------- start jeforth code ---------------------- - -." List all NIC" cr -"" getNIC ( nic nic ... ) \ No where clause, get all of them -#nic ?dup [if] [for] - >r r@ :> caption . cr - ." / NetConnectionStatus: " r@ :> NetConnectionStatus . cr - ." / NetEnabled: " r@ :> NetEnabled . cr - ." / NetworkAddresses: " r@ :> NetworkAddresses . cr - ." / PermanentAddress: " r@ :> PermanentAddress . cr - ." / Status: " r@ :> Status . cr - r> drop -[next] [then] - -." List active NIC" cr -activeNIC ( nic nic ... ) \ assume there are many active NICs -#nic ?dup [if] [for] - >r r@ :> caption . cr - ." / NetConnectionStatus: " r@ :> NetConnectionStatus . cr - ." / NetEnabled: " r@ :> NetEnabled . cr - ." / NetworkAddresses: " r@ :> NetworkAddresses . cr - ." / PermanentAddress: " r@ :> PermanentAddress . cr - ." / Status: " r@ :> Status . cr - r> drop -[next] [then] - -: nicoff ( -- ) \ Turn off the NIC - s" where deviceid = 19" getNIC :> disable() - dup if - ." Failed! Error code " . ." . Make sure to run as an administrator." cr - else - drop ." NIC device turned off sucessfully." cr - then ; - /// return 5 is failed when not an administrator - -: nicon ( -- ) \ Turn on the NIC - s" where deviceid = 19" getNIC :> enable() - dup if - ." Failed! Error code " . ." . Make sure to run as an administrator." cr - else - drop ." NIC device turned on sucessfully." cr - then ; -\ Usage guide -

nicoff or nicon

drop cr - stop - -\ ---------------- end jeforth code ----------------------- - -:batch -call admin.bat -@rem ---------- start batch code --------------------------- -start jeforth.hta include %~nx0 \ include the batch program itself -@if %errorlevel% GEQ 1 goto ERR -@rem ------------ end batch code --------------------------- - -@goto END -:ERR -@echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -@echo errorlevel : %errorlevel% -@echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -pause -:END - - - diff --git a/3hta/f/wmi.f b/3hta/f/wmi.f index cc223db..ab45f41 100644 --- a/3hta/f/wmi.f +++ b/3hta/f/wmi.f @@ -170,6 +170,23 @@ [then] [until] + +: nicoff ( -- ) \ Turn off the NIC (the certain where clause is for my LRV2 only) + s" where deviceid = 19" getNIC :> disable() + dup if + ." Failed! Error code " . ." . Make sure to run as an administrator." cr + else + drop ." NIC device turned off sucessfully." cr + then ; + /// return 5 is failed when not an administrator + +: nicon ( -- ) \ Turn on the NIC (the certain where clause is for my LRV2 only) + s" where deviceid = 19" getNIC :> enable() + dup if + ." Failed! Error code " . ." . Make sure to run as an administrator." cr + else + drop ." NIC device turned on sucessfully." cr + then ; \ 利用 jeforth for WSH 與其 JavaScript console 手動來操作 WMI 很有用,沒必要寫一大堆人機介面。 \ 跑一下 objEnumWin32_OperatingSystem 準備好 Win32_OperatingSystem object 放在 TOS,此後用 console 進 js console, diff --git a/3hta/install.bat b/3hta/install.bat deleted file mode 100644 index f62e9ef..0000000 --- a/3hta/install.bat +++ /dev/null @@ -1,43 +0,0 @@ - -@rem -@rem jeforth for Microsoft HTML Applications (HTA) -@rem -@rem This batch program creates a mirror directory for jeforth.3hta while the root is still -@rem jeforth.3we that are under the GitHub version contorl. -@rem -@rem Hard links are real file headers that share the same file pathname. Many hard links -@rem can be sharing the same file or directory and all of them are equal, no master. While -@rem symbolic link is a virtual file pathname that points to the real file or directory. For -@rem cloud safety, I guess, symblic links may not be acceptable to web browsers. In that cases, -@rem use hard link instead. -@rem -@rem H.C. Chen 14:01 November 17, 2016 -@rem - -cd %~dp0 -@rem mklink.exe and fsutil.exe need administrator priviledges, check it. -call admin.bat - -md ..\..\jeforth.3hta -cd ..\..\jeforth.3hta - -@rem Symbolic File Links -mklink log.txt ..\jeforth.3we\log\log.txt -@rem mklink jeforth.hta ..\jeforth.3we\jeforth.hta - -@rem Symbolic Directory Links -mklink /d log ..\jeforth.3we\log -mklink /d 3hta ..\jeforth.3we\3hta -mklink /d 3htm ..\jeforth.3we\3htm -mklink /d demo ..\jeforth.3we\demo -mklink /d external-modules ..\jeforth.3we\external-modules -mklink /d f ..\jeforth.3we\f -mklink /d js ..\jeforth.3we\js -mklink /d playground ..\jeforth.3we\playground -mklink /d project-k ..\jeforth.3we\project-k - -@rem Hard Links -fsutil hardlink create common.css ..\jeforth.3we\common.css -fsutil hardlink create jeforth.hta ..\jeforth.3we\jeforth.hta - -pause diff --git a/3hta/localstorage.json b/3hta/localstorage.json index 5fed781..b993c58 100644 --- a/3hta/localstorage.json +++ b/3hta/localstorage.json @@ -1 +1 @@ -{"autoexec":"{\"name\":\"autoexec\",\"readonly\":false,\"codemode\":\"true\",\"doc\":\"\\n\\\\ js> vm.appname==\\\"jeforth.3hta\\\" [if] s\\\" Style for 3HTA on different computers with auto detect\\\" (run) [then]\\n\\n\\njs: outputbox.style.fontSize=\\\"1.5em\\\"\\ncr .( Launch the briefing ) cr\\n drop\\ncr cr \\n.( execute the 'list' command ) cr\\nlist\\n\",\"mode\":true}","Play with numeric.js":"{\"doc\":\"\\ncls \\n\\\\ Linear algebra example. We start with a matrix.\\n\\nvar A = [[1,2,3],\\n [4,5,6],\\n [7,3,9]]; A value A\\n\\n\\\\ Let's also make a vector.\\n var x = [3,1,2]; x value x\\n\\n\\\\ Matrix-vector product. b = A (.) x\\n var b = numeric.dot(vm.g.A,vm.g.x); b value b b (see)\\n\\n\\\\ Matrix inverse. ~A \\n var Ainv = numeric.inv(vm.g.A); Ainv value Ainv \\nAinv (see)\\n\\n\\\\ Let's check it: ~A (.) b = x Bingo!!!!\\n numeric.dot(vm.g.Ainv,vm.g.b); (see)\\n\\n\\\\ Determinant\\n numeric.det(vm.g.A); cr tib. \\n\\n\\\\ Sin wave\\n var x = numeric.linspace(0,6.3,25); x to x x (see)\\n\\n var y = numeric.sin(vm.g.x); y value y y (see)\\n\\n\\n\\n\\nstop\\njs> numeric tib.\\n\\nstop\\njs> vm.appname==\\\"jeforth.3hta\\\" [if] char js/numeric-1.2.6.js\\n[else] char http://www.numericjs.com/lib/numeric-1.2.6.js [then]\\nreadTextFile \\\\ 先讀取 .js 檔, 但不能直接用\\n \\nwindow.numeric = numeric; // 先對 source 做一點必要的加工, 把 numeric 掛上 global \\n + \\\\ 然後才執行\\t\\n\\nstop\\n\\\\ Also hosted on BootCDN.cn\\n\\\\ http://cdn.bootcss.com/numeric/1.2.6/numeric.js\\n\\n\\\\ These lines works fine! Test ok on 3ce, 3hta ADO reads only local files\\n\\\\ so the path should be only \\\"js/numeric-1.2.6.js\\\",\\n\\nchar http://localhost:8888/js/numeric-1.2.6.js readTextFile tib.\\nchar http://www.numericjs.com/lib/numeric-1.2.6.js readTextFile tib.\\nchar http://www.numericjs.com/lib/numeric-1.2.6.min.js readTextFile tib.\\n\\n\\n\",\"mode\":true,\"readonly\":false}","lab":"{\"name\":\"lab\",\"readonly\":false,\"mode\":true,\"doc\":\"\"}","Style for 3HTA on different computers with auto detect":"{\"doc\":\"char %computername% env@ char DESKTOP-Q4DUVFG === [if] ( is my desktop at home )\\n

Style for desktop at home 3HTA

drop\\n js: outputbox.style.fontSize=\\\"1.5em\\\"\\n js: inputbox.style.fontSize=\\\"1.5em\\\"\\n editbox-style \\n .eb .box { width:90%; font-size:1.1em; /* filename */ } \\n .eb .box, .eb .ebhtmlarea { border:1px solid black; }\\n .eb .ebtextarea { font-size:1.2em }\\n .eb input { font-size:0.7em /* buttons */ }\\n .eb p { display:inline; }\\n .eb .ebname { font-size: 1em; } /* field name */\\n js: $(\\\"#ebstyle\\\")[0].innerHTML=pop() \\\\ 直接修改 ebstyle \\n[then]\\n\\nchar %computername% env@ char WKS-31ENA852 === [if] ( X1 Yoga OA notebook )\\n

Style for OA X1 Yoga

drop\\n js: outputbox.style.fontSize=\\\"1.1em\\\"\\n js: inputbox.style.fontSize=\\\"1.1em\\\"\\n editbox-style \\n .eb .box { width:90%; font-size:1.1em; /* filename */ } \\n .eb .box, .eb .ebhtmlarea { border:1px solid black; }\\n .eb .ebtextarea { font-size:1.1em }\\n .eb input { font-size:0.7em /* buttons */ }\\n .eb p { display:inline; }\\n .eb .ebname { font-size: 1em; } /* field name */\\n js: $(\\\"#ebstyle\\\")[0].innerHTML=pop() \\\\ 直接修改 ebstyle \\n[then]\\n\\nchar %computername% env@ char WKS-4AEN0404 === [if] ( T550 OA notebook )\\n

Style for OA T550

drop\\n js: outputbox.style.fontSize=\\\"1.5em\\\"\\n js: inputbox.style.fontSize=\\\"1.5em\\\"\\n editbox-style \\n .eb .box { width:90%; font-size:1.2em; /* filename */ } \\n .eb .box, .eb .ebhtmlarea { border:1px solid black; }\\n .eb .ebtextarea { font-size:1.2em }\\n .eb input { font-size:0.7em /* buttons */ }\\n .eb p { display:inline; }\\n .eb .ebname { font-size: 0.8em; } /* field name */\\n js: $(\\\"#ebstyle\\\")[0].innerHTML=pop() \\\\ 直接修改 ebstyle \\n[then]\\n\\ncr\\n\",\"mode\":true,\"readonly\":false}","3HTA Log 2016-08-31":"{\"doc\":\"[x] Solar-system.f 再改良, 畫面精簡, 指向文章去解釋。\\n[x] 準備 release master 新版, search \\\"kvm.minor_version\\\"\\n 全部加 200 代表 GitHub master release 的版號。\\n [x] jeforth.3nd.js --> version 2 -> 202\\n [x] jeforth.3nw.html, /package.json -> version 22 -> 222\\n [x] jeforth.3htm.js --> to be version 2 now -> 202\\n [x] jeforth.3ce.js(3ce extension pages)-> 202\\n [x] jeforth.3ce, ce.f(Target page) -> 202\\n [x] jeforth.3ce, background.js -> 202\\n [x] jeforth.hta --> tag. to be version 3 now -> 203 \\n [x] GitHub read me should feature the published 3ce Chrome extension.\\n --> feature the Wiki page would be even better. Ynote\\n is in trouble of censorship.\\n [x] README.md 上的 demo 也要改寫好一點。最好能有浮動 console3we 框。\\n --> 先把結構改好, link 出去的內容先弄成 under constructing. 日起有功,穩步推進。\\n [x] excel.f introduction add to wiki and link to readme.md\\n --> done\\n\\n[x] 3nw.bat can't run when the root folder is \\\"jeforth.3we-master\\\" instead of\\n \\\"jeforth.3we\\\" \\n start nw ../jeforth.3we %1 %2 %3 %4 %5 %6 %7 %8 %9\\n --> folder name must be jeforth.3we can't be ~-master or ~-develop.\\n because 3nw.bat command line must be \\\"start nw ../jeforth.3we ...\\\"\\n\\n[x] excel.app.count not correct some times. see-excel is good. \\n --> excel.app.count redesigned, it's now dynamic.\\n[x] ls.f autoexec should not be run when having argv.\\n [x] We need 'args' to know if there were jobs to do from command line\\n [x] 3hta [x] 3htm [x] 3ce [x] 3nd [x] 3nw\\n[x] arrow works but there are error messages flashes before\\n the arrow box.\\n[x] nested puts master tutor-cloth.f in trouble\\n --> fixed in develop already, waiting to relase new master.\\n[ ] 檔案擺放的 rule 應該要寫成專文放在 wiki 下。\\n Also Ynote \\\"jeforth.3we master release 目錄結構的構想\\\"\\n[ ] 以下整頓的理由是:方便 user 要砍乾淨只留必要的東西的場合。 -- 2016-09-06 18:35:00\\n o 像 3htm/f/hte.f, 3htm/f/ls.f 是很多人 (3hta, 3nw, 3ce, 3ca, ...) 共用的也都是放在\\n 3htm/f 之下, 這樣對嗎? --> 對, 只要不是全體通用的就一定要有一個代表的 application.\\n 因為 3htm 是大家的基礎, 所以 path 都含 3htm。\\n o 例如 quit.f 這種各自都有的 module 只要放在自己的 sub-directory 之下藉由 path 定義\\n 的優先順序就可以運作無誤。當 3htm/f 正式版存在時, 在 3htm/ 實驗新版即可取代正式版,\\n 這也是 path 的作用。\\n o 完全與 platform 無關的就放在 f/ 之下, 因為 hibernation.f 只能用在 3nw 3nd 或 3hta\\n 因此要從 f/ 移到 3nw/ 3nw/f 3nd/ 3nd/f 3hta/ 或 3hta/f 其中之一去。讓某一 application \\n 當 hibernation.f 的家可能比不同版本分放各處要好一點點,因為可以集中維護。適合分開放的\\n 也有,如 quit.f platform.f 之類。 --> 所以我把 hibernation.f 移到了 3hta/。hte.f 以及\\n ls.f 留在 3htm/f;但是 mde.f 卻放在 3htm/ 因為 mde.f 可以刪除而前兩者則因為用得多而視\\n 為 application 的成分。\\n o 因此,放在 3htm/f 或 3htm/ 的差別是【成熟與否】,以及【是否可以移除】。\\n [x] 像 box2dweb-arrow.f 就遇到問題了,這個 demo 又要 include jeforth.3we\\\\js\\\\box2dweb\\\\Box2dWeb-2.1.a.3.js \\n 又要 include arrow.f 三個 module 到處散落。Box2dWeb-2.1.a.3.js 出現在 jeforth.3we\\\\js\\\\ \\n 裡也不對。jeforth.3we 怎麼會含有這東西? 我清楚,user 可不清楚。\\n [x] 所以,以上這些都移進 demo 裡去才對。Demo 程式都應該放進 demo directory\\n 只有需要永久保存在 project 裡面的才放進各 application 裡去。\\n [x] demo\\\\box2dweb.js\\\\ <---- working on arrow.js debugging -> - + diff --git a/3ce/jeforth.3ce.html b/3ce/jeforth.3ce.html index dc42b7a..49d28cc 100644 --- a/3ce/jeforth.3ce.html +++ b/3ce/jeforth.3ce.html @@ -17,7 +17,7 @@ } - + diff --git a/3ce/jeforth.3ce.js b/3ce/jeforth.3ce.js index f47b129..6818060 100644 --- a/3ce/jeforth.3ce.js +++ b/3ce/jeforth.3ce.js @@ -18,8 +18,8 @@ kvm.selftest_visible = true; // type() refers to it. // kvm.type() is the master typing or printing function. - // The type() called in code ... end-code is defined in the kernel jeforth.js. - // We need to use type() below, and we can't see the jeforth.js' type() so one + // The type() called in code ... end-code is defined in the kernel projectk.js. + // We need to use type() below, and we can't see the projectk.js' type() so one // is also defined here, even just for a few convenience. The two type() functions // are both calling the same kvm.type(). var type = kvm.type = function (s) { @@ -33,12 +33,12 @@ } // kvm.panic() is the master panic handler. The panic() function defined in - // project-k kernel jeforth.js is the one called in code ... end-code. + // project-k kernel projectk.js is the one called in code ... end-code. kvm.panic = function(state){ type(state.msg); if (state.serious) debugger; } - // We need the panic() function below but we can't see the one in jeforth.js + // We need the panic() function below but we can't see the one in projectk.js // so one is defined here for convenience. function panic(msg,level) { var state = { diff --git a/3ce/target.f b/3ce/target.f index 34e6fbb..e4eefb8 100644 --- a/3ce/target.f +++ b/3ce/target.f @@ -97,7 +97,7 @@ Program path location
// js: $(".console3we")[0].style.visibility="hidden" // vm.type() is the master typing or printing function. - // The type() called in code ... end-code is defined in the kernel jeforth.js. + // The type() called in code ... end-code is defined in the kernel projectk.js. // target_type(s) types to the target page outputbox, instead of to the host page // that may be the popup page or a 3ce extension page. function target_type(s) { diff --git a/3hta/f/wmi.f b/3hta/f/wmi.f index 6659857..afaacab 100644 --- a/3hta/f/wmi.f +++ b/3hta/f/wmi.f @@ -14,7 +14,7 @@ \ "localhost" by default. Define t/c before include wmi.f in command line if your target computer is not localhost. \ 如果在 include wmi.f 之前先設定 t/c 之值,則整套 wmi.f 都 refer to the specified t/c. 所以你可以去 access 別的機器. -\ 例如 "cscript jeforth.js s' 10.34.98.76' constant t/c include wmi.f list-some-OS-properties" 可以去看遠端機器的內容。 +\ 例如 "cscript projectk.js s' 10.34.98.76' constant t/c include wmi.f list-some-OS-properties" 可以去看遠端機器的內容。 \ 若不先給定 t/c 則以下這段程式會把 t/c 設成 localhost 所以是對本地電腦工作。我不想每次都得指定 target computer 因此 \ 如此安排。 @@ -341,7 +341,7 @@ ; \ this is a one liner to list all devices. %errorlevel% is the count of devices. - \ cscript jeforth.js include wmi.f cr list-all-PnP-devices bye + \ cscript projectk.js include wmi.f cr list-all-PnP-devices bye *** Demo how to use objEnumWin32_PnPEntity object @@ -381,7 +381,7 @@ ; \ This is a one liner that lists yellow marks and red marks in Device Manager, leaving %errorlevel% with the abnormal item count. - \ cscript jeforth.js include wmi.f cr list-abnormal-items-in-device-manager bye + \ cscript projectk.js include wmi.f cr list-abnormal-items-in-device-manager bye *** Let's see if there's any abnormal items in device manager @@ -427,7 +427,7 @@ ; \ This is a one liner to show CD/DVD drives, leaving %errorlevel% with the count. - \ cscript jeforth.js include wmi.f list-CD/DVD-drives bye + \ cscript projectk.js include wmi.f list-CD/DVD-drives bye *** Demo objEnumWin32_CDROMDrive object @@ -498,13 +498,13 @@ ; \ This is a one liner to show processors, leaving %errorlevel% with the physical processor count. - \ cscript jeforth.js include wmi.f list-all-processors bye + \ cscript projectk.js include wmi.f list-all-processors bye \ This is a one liner to show processors, leaving %errorlevel% with the logical processor count. - \ cscript jeforth.js include wmi.f list-all-processors drop bye + \ cscript projectk.js include wmi.f list-all-processors drop bye \ This is a one liner to show processors, leaving %errorlevel% with the processor core count. - \ cscript jeforth.js include wmi.f list-all-processors drop drop bye + \ cscript projectk.js include wmi.f list-all-processors drop drop bye *** Demo objEnumWin32_Processor object @@ -570,7 +570,7 @@ \ This is a one liner to show BIOS things. - \ cscript jeforth.js list-Win32_BIOS-properties bye /f0:wmi.f //nologo + \ cscript projectk.js list-Win32_BIOS-properties bye /f0:wmi.f //nologo \ View Battery info \ http://msdn.microsoft.com/en-us/library/windows/desktop/aa394074(v=vs.85).aspx @@ -580,7 +580,7 @@ end-code \ This is a one liner to show battery things. - \ cscript jeforth.js list-Win32_Battery-properties bye /f0:wmi.f //nologo + \ cscript projectk.js list-Win32_Battery-properties bye /f0:wmi.f //nologo *** Demo how to use objEnumWin32_Battery, list Win32_Battery properties diff --git a/3htm/f/jsc.f b/3htm/f/jsc.f index 0e13b06..152a9b2 100644 --- a/3htm/f/jsc.f +++ b/3htm/f/jsc.f @@ -186,7 +186,7 @@ \ function test (input) { // vm.panic() is the master panic handler. The panic() function defined in - // project-k kernel jeforth.js is the one called in code ... end-code. That + // project-k kernel projectk.js is the one called in code ... end-code. That // panic() is actually calling vm.panic(). We redefine vm.panic() because jsc // is ready now while F12 debugger can be called from jsc still. diff --git a/3htm/js/jeforth.3htm.js b/3htm/js/jeforth.3htm.js index bd621ef..503870d 100644 --- a/3htm/js/jeforth.3htm.js +++ b/3htm/js/jeforth.3htm.js @@ -10,8 +10,8 @@ kvm.selftest_visible = true; // type() refers to it. // kvm.type() is the master typing or printing function. - // The type() called in code ... end-code is defined in the kernel jeforth.js. - // We need to use type() below, and we can't see the jeforth.js' type() so one + // The type() called in code ... end-code is defined in the kernel projectk.js. + // We need to use type() below, and we can't see the projectk.js' type() so one // is also defined here, even just for a few convenience. The two type() functions // are both calling the same kvm.type(). var type = kvm.type = function (s) { @@ -25,12 +25,12 @@ } // kvm.panic() is the master panic handler. The panic() function defined in - // project-k kernel jeforth.js is the one called in code ... end-code. + // project-k kernel projectk.js is the one called in code ... end-code. kvm.panic = function(state){ type(state.msg); if (state.serious) debugger; } - // We need the panic() function below but we can't see the one in jeforth.js + // We need the panic() function below but we can't see the one in projectk.js // so one is defined here for convenience. function panic(msg,level) { var state = { diff --git a/3nd/f/jsc.f b/3nd/f/jsc.f index 27ff8f8..23647db 100644 --- a/3nd/f/jsc.f +++ b/3nd/f/jsc.f @@ -122,7 +122,7 @@ \ function test (input) { // vm.panic() is the master panic handler. The panic() function defined in - // project-k kernel jeforth.js is the one called in code ... end-code. That + // project-k kernel projectk.js is the one called in code ... end-code. That // panic() is actually calling vm.panic(). We redefine vm.panic() because jsc // is ready now while F12 debugger can be called from jsc still. diff --git a/3nw/Getting-Started.f b/3nw/Getting-Started.f index fe64b05..6c7d475 100644 --- a/3nw/Getting-Started.f +++ b/3nw/Getting-Started.f @@ -161,7 +161,7 @@ \ function Window(routing_id, nobind) {
js> win.width . \ 876 js: win.width=800 \ it works - js> win.title . \ jeforth.3nw -- 3 words jeforth.js for node-webkit with jQuery-terminal + js> win.title . \ jeforth.3nw -- 3 words projectk.js for node-webkit with jQuery-terminal js: win.title="hahaha" \ it really changes the nw window's title js> win.zoomLevel . \ 0 this is the font size of the forth console js: win.zoomLevel=1 diff --git a/3nw/localstorage.json b/3nw/localstorage.json index 5825f84..3933e1a 100644 --- a/3nw/localstorage.json +++ b/3nw/localstorage.json @@ -1 +1 @@ -{"3nw working on simpleMDE":"{\"doc\":\"\\n[x] Now ^2016-05-06 14:29:46 developing SimpleMDE on 3nw \\n[x] pickFile can work on 3htm, 3nw, 3hta but only 3hta gets the pathname string, \\n others are \\\"\\\" due to security restrictions I believe. Is there a workaround?\\n [x] try answers on Stackoverflow.com \\n 1. http://jsfiddle.net/dwebexperts/4FGg8/1/\\n http://stackoverflow.com/questions/15201071/how-to-get-full-path-of-selected-file-on-change-of-input-type-file-using-jav\\n Introduces a temp_path , which is interesting but not good enough for my MDE because\\n [Save] button needs the real pathname.\\n\\n-----------------\\n\\n\\\\ Word does not work, mde-include not ok yet, but interpret mode works fine\\n\\n\\n.( Include SimpleMDE.js )\\n\\n\\tjs> typeof(SimpleMDE)!=\\\"function\\\" [if]\\n\\t\\t\\n\\t\\t \\n\\t\\t\\n\\t\\t drop \\n\\t[then]\\n\\tfalse ( assume include failed ) \\n\\t30 ( seconds ) [for] \\n\\t\\tjs> typeof(SimpleMDE)==\\\"function\\\" [if] \\n\\t\\t\\tr> drop 0 >r \\\\ break the loop\\n\\t\\t\\tdrop true ( include OK )\\n\\t\\t[else] \\n\\t\\t\\t20 nap .\\\" .\\\" \\\\ wait a while\\n\\t\\t[then] \\n\\t[next] \\n\\t[if] .\\\" Done. \\\" [else] .\\\" Error! Failed to include SimpleMDE! [then] cr\\n\\n.( Create the required textarea for SimpleMDE ) cr\\n\\n \\n js> $(\\\".console3we\\\")[0] insertBefore\\n\\n.( Launch SimpleMDE on the above textarea ) cr\\n\\n \\n var simplemde = new SimpleMDE({element: document.getElementById(\\\"simplemde\\\")}); \\n simplemde \\n \\n constant simplemde\\n\\n.( Load README.md ) cr\\n\\n char README.md readTextFile\\n simplemde :: value(pop())\\n\\t\\n\\\\ Above interpret procedure works fine.\\n\\n\\n\\\\ [x] mde ( -- ) \\\\ open Markdown editor \\n\\n: mde-include ( -- ok? ) \\\\ Inclde MDE editor \\n\\tjs> typeof(SimpleMDE)!=\\\"function\\\" if\\n\\t\\t\\n\\t\\t \\n\\t\\t\\n\\t\\t drop \\n\\tthen\\n\\tfalse ( assume include failed ) \\n\\t30 ( seconds ) for \\n\\t\\tjs> typeof(SimpleMDE)==\\\"function\\\" if \\n\\t\\t\\tr> drop 0 >r \\\\ break the loop\\n\\t\\t\\tdrop true ( include OK )\\n\\t\\telse \\n\\t\\t\\t1000 nap \\\\ wait a while\\n\\t\\tthen \\n\\tnext ;\\n\\n\\\\ execute the word does not work. But run on interpret mode always ok. Why?\\n\\\\ Even when it's not work, check the elements of link and script, they are existing:\\n\\tjs> $(\\\"head\\\")[0] ce! ce 09 ce@ :> outerHTML .\\n\\tjs> $(\\\"head\\\")[0] ce! ce 10 ce@ :> outerHTML .\\n\\nstop \\n---------------\\n[x] 所有在 .console3we 範圍內的 textarea 都會在 F2 edit mode focused 時變成粉紅色。 ed 的亦然。\\n 把 ed 移出 .console3we 之外 (而非光 outputbox 之外) 就會失去所有的 .console3we style. 如下,\\n > js> $(\\\".eb\\\")[0] js> $(\\\".console3we\\\")[0] insertBefore\\n ==> 所以, SimpleMDE init textarea 要移出 .console3we 之上才行. \\n[x] Go on use the knowledge to fine tune 3we's style settings.\\n --> study common.css first \\n --> but I already use .console3we to constraint the range!\\n ==> 所以, SimpleMDE init textarea 要移出 .console3we 之上才行. \\n\\n\\\\ ^^2016-05-04 11:57:32^^ \\n\\\\ (@ 3nw) 改照抄 official demo page 上的 resource 也行, 但是問題還是一樣。\\n\\\\ 可見是 jeforth 的 style 造成的問題。 \\n\\\\ [x] 下一步, 3nw 的 style 反璞歸真, 或限制範圍。 ==> Bingo!! See Ynote \\n\\\\ \\\"SimpleMDE works fine on jeforth.3nw now\\\" \\n\\n\\n\\\\ Include SimpleMDE\\n\\n \\n < link rel=\\\"stylesheet\\\" href=\\\"https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.css\\\"> \\n < script src=\\\"https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.js\\\">\\n drop\\n js> typeof(SimpleMDE) tib. \\\\ ==> function (string) so it has been installed\\n\\n\\\\ Create a textarea\\n\\n \\n js> $(\\\".console3we\\\")[0] insertBefore\\n\\n\\\\ Launch SimpleMDE on the above textarea\\n\\n \\n var simplemde = new SimpleMDE({element: document.getElementById(\\\"simplemde\\\")}); \\n simplemde \\n \\n constant simplemde\\n\\n\\\\ Test, set the content\\n\\n simplemde pop().value(\\\"This text will appear in the editor\\\"); \\n\\n\\\\ Test, get the content\\n\\n simplemde :> value() \\\\ ==> # This text will appear in the editor (string)\\n\\n-----------------------------\\nStudy https://simplemde.com/ so as to copy the usage\\n\\n\\\\ 瞧瞧 body\\n > js> $(\\\"body\\\")[0] ce! ce\\n [object HTMLBodyElement] innerHTML=

SimpleMDE ...\\n 0 : [object HTMLElement] class='page-header'; innerHTML=

SimpleMDE Markdown Edi...\\n 1 : [object HTMLElement] class='main-content'; innerHTML=

.console3we { color:black; word-wrap:...\\n\\n\\\\ 瞧瞧 header\\n > js> $(\\\"body\\\")[0] ce! ce\\n [object HTMLHeadElement] innerHTML=JavaScript Markdown Editor - SimpleM...\\n 0 : [object HTMLMetaElement] \\n 1 : [object HTMLTitleElement] innerHTML=JavaScript Markdown Editor - SimpleMDE...\\n 2 : [object HTMLMetaElement] name='viewport'; \\n 3 : [object HTMLLinkElement] \\n 4 : [object HTMLLinkElement] \\n 5 : [object HTMLLinkElement] \\n 6 : [object HTMLLinkElement] \\n 7 : [object HTMLLinkElement] \\n 8 : [object HTMLScriptElement] <=========== 這裡面是空的\\n 9 : [object HTMLScriptElement] innerHTML= if(window.location.href.indexOf(\\\"nextstepwebs.github.io\\\") !== ...\\n 10 : [object HTMLStyleElement] innerHTML= .editor-preview h1, .editor-preview h2, .editor-preview h3, .ed...\\n 11 : [object HTMLStyleElement] id='style-1-cropbar-clipper'; innerHTML=/* Copyright 2014 Evernote Corpora...\\n 12 : [object HTMLStyleElement] innerHTML= .tr table, .tr td { border:0.075em solid gray; } ...\\n\\n \\\\ ce 8 ce@ :> outerHTML 看來好像在修整網址, 總之 SimpleMDE 不是在 header 裡 include 的。\\n <script>\\n if(window.location.href.indexOf(\\\"nextstepwebs.github.io\\\") !== -1) {\\n window.location.href = \\\"https://simplemde.com/\\\";\\n }\\n \\n if(window.location.protocol != \\\"https:\\\")\\n window.location.href = \\\"https:\\\"+window.location.href.substring(window.location.protocol.length);\\n </script> OK \\n\\n\\\\ Now look into the source code of the demo page\\n\\n\\n> cr cr cr js> $(\\\"body\\\")[0] ce! ce 2 ce@ :> outerHTML .\\n[object HTMLLinkElement] \\n<link rel=\\\"stylesheet\\\" href=\\\"https://maxcdn.bootstrapcdn.com/font-awesome/latest/css/font-awesome.min.css\\\"> OK \\n\\n> cr cr cr js> $(\\\"body\\\")[0] ce! ce 3 ce@ :> outerHTML .\\n[object HTMLLinkElement] \\n<link rel=\\\"stylesheet\\\" href=\\\"https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.css\\\"> OK \\n\\n> cr cr cr js> $(\\\"body\\\")[0] ce! ce 4 ce@ :> outerHTML .\\n[object HTMLScriptElement] \\n<script src=\\\"https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.js\\\"></script> OK \\n\\n> cls js> $(\\\"body\\\")[0] ce! ce 5 ce@ :> outerHTML .\\n[object HTMLScriptElement] innerHTML= new SimpleMDE({ element: document.getElementById(\\\"demo1\\\"), spe...\\n 0 : [object Text] new SimpleMDE({ element: document.getElementById(\\\"demo1\\\"), spellChecker: false, }); n...\\n<script>\\n new SimpleMDE({\\n element: document.getElementById(\\\"demo1\\\"),\\n spellChecker: false,\\n });\\n \\n new SimpleMDE({\\n element: document.getElementById(\\\"demo2\\\"),\\n spellChecker: false,\\n autosave: {\\n enabled: true,\\n unique_id: \\\"demo2\\\",\\n },\\n });\\n \\n new SimpleMDE({\\n element: document.getElementById(\\\"demo3\\\"),\\n status: false,\\n toolbar: false,\\n });\\n </script> OK \\n\\n> cr cr cr js> $(\\\"body\\\")[0] ce! ce 6 ce@ :> outerHTML .\\n[object HTMLScriptElement] innerHTML= (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r...\\n 0 : [object Text] (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=...\\n<script>\\n (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){\\n (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),\\n m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)\\n })(window,document,'script','//www.google-analytics.com/analytics.js','ga');\\n \\n ga('create', 'UA-5808021-18', 'auto');\\n ga('send', 'pageview');\\n \\n </script> OK \\n\\n\\n-----------------------\\n[!] Try 3htm with localhost , the Error is : \\\"require is not defined\\\"\\n (1) Run local host : webserver.bat\\n (2) Run jeforth.3htm through http://localhost:8888 or http://localhost:8888/index.html \\n (3) Run \\n <h>\\n <link rel=\\\"stylesheet\\\" href=\\\"http://localhost:8888/src/css/simplemde.css\\\">\\n <script src=\\\"http://localhost:8888/src/js/simplemde.js\\\"></script>\\n </h>\\n ---> JavaScript error on word \\\"doElement\\\" : require is not defined\\n[!] jeforth.3ce can not do this: (Due to Content Security Policy violation)\\n <h>\\n < link rel=\\\"stylesheet\\\" href=\\\"http://localhost:8888/src/css/simplemde.css\\\">\\n < script src=\\\"http://localhost:8888/src/js/simplemde.js\\\"></script>\\n </h>\\n \\\\s\\n jquery-1.11.2.js:9831 Refused to load the script \\n 'http://localhost:8888/src/js/simplemde.js?_=1462251960943' \\n because it violates the following Content Security Policy directive: \\n \\\"script-src 'self' 'unsafe-eval'\\\".\\n \\\\s\\n \\\\ webserver.bat cd root at c:\\\\program files\\\\nodejs\\\\node_modules\\\\simplemde\\n char http://localhost:8888/src/js/simplemde.js readTextFile . \\\\ ==> works fine\\n[!] Try super chrome \\n --> worse then jeforth.3htm through http://localhost:8888 \\n[x] Trying to include but failed.\\n char ../simplemde-markdown-editor/src/css/simplemde.css readTextFile .\\n char ../simplemde-markdown-editor/src/js/simplemde.js readTextFile .\\n <h>\\n < link rel=\\\"stylesheet\\\" href=\\\"../simplemde-markdown-editor/src/css/simplemde.css\\\">\\n < script src=\\\"../simplemde-markdown-editor/src/js/simplemde.js\\\"></script>\\n </h>\\n --> (on 3HTA) 'require' not defined ==> So, try 3nw !!\\n --> and JavaScript error on word \\\"doElement\\\" : 發生錯誤,無法完成操作 80020101。\\n --> try 3nw, but: JavaScript error on word \\\"doElement\\\" : Cannot find module 'codemirror'\\n --> So, let's, as homepage said, use npm install. I am using 3nw anyway.\\n --> See ^> 2016-05-03 00:07:17 error message\\n C:\\\\Users\\\\hcche\\\\Documents\\\\GitHub> npm install simplemde --save\\n Failed again, npm install wants to use 'git' but which is unknown unless in a \\n gitShell that I can open through GitHub I guess.\\n --> Yes! GitShell is better, on installating now, stop at load codemirror\\n seems working ... I thought it's dead but now continoued. Wow, what a huge\\n installation. ok!\\n [x] I run the install from C:\\\\Users\\\\hcche\\\\Documents\\\\GitHub> is not good.\\n The result is a 10MByte size of mudules! at \\n c:\\\\Users\\\\hcche\\\\Documents\\\\GitHub\\\\node_modules <-- all dated 5/3'16 which is today\\n I should move it to : \\\"c:\\\\Program Files\\\\nodejs\\\\node_modules\\\" <--- all done.\\n * Should run npm install at c:\\\\Program Files\\\\nodejs> ... <== wrong! still failed.\\n [x] (@ Home) 10M of modules installed. What's next? Ah! all the modules are for server side.\\n See examples on http://simplemde.com and think.\\n [x] (@ T550) * Should run npm install at c:\\\\Program Files\\\\nodejs> ... <== wrong! still failed.\\n c:\\\\Program Files\\\\nodejs and sub-directories are not write-able, I guess. Because\\n tried to do the install at ~\\\\downloads\\\\simplemde then OK! See ^> 2016-05-03 09:28:01\\n [x] Holyshit! Totally different result from ^> 2016-05-03 09:28:01 !!!\\n 我想要把所有的 node_modules 都集中到 c:\\\\Program Files\\\\nodejs\\\\node_modules\\\\ 也是錯誤觀念。\\n SimpleMDE 的 node_modules 就放在自己個別的目錄下。\\n[x] I should reinstall Node.js and NW.js at home? Because installing SimpleMDE has totally\\n messed up the node_modules folder.\\n --> ok at home. \\n[x] @ T550 after installed SimpleMDE by npm, Also have made NODE_PATH env correctly points\\n to c:\\\\Program Files\\\\nodejs\\\\node_modules run 3nw.bat and try . . . \\n s\\\" c:\\\\Program Files\\\\nodejs\\\\node_modules\\\\simplemde\\\\src\\\\css\\\\simplemde.css\\\" readTextFile .\\n s\\\" c:\\\\Program Files\\\\nodejs\\\\node_modules\\\\simplemde\\\\src\\\\js\\\\simplemde.js\\\" readTextFile .\\n <h>\\n < link rel=\\\"stylesheet\\\" href=\\\"c:/Program Files/nodejs/node_modules/simplemde/src/css/simplemde.css\\\">\\n < script src=\\\"c:/Program Files/nodejs/node_modules/simplemde/src/js/simplemde.js\\\"></script>\\n </h>\\n --> Now I realized that dealing with npm is needed for Web Server side only\\n[x] (@ 3nw) require('codemirror') not found, add %NODEJSHOME%\\\\node_modules\\\\simplemde\\\\node_modules\\n to NODE_PATH as below can resolve this.\\n ---- 3nw.bat ----\\n if a%COMPUTERNAME%==aWKS-38EN3476 set NODEJSHOME=C:\\\\Program Files\\\\nodejs\\n if a%COMPUTERNAME%==aWKS-4AEN0404 set NODEJSHOME=C:\\\\Program Files\\\\nodejs\\n set NODE_PATH=%NODEJSHOME%\\\\node_modules;%NODEJSHOME%\\\\node_modules\\\\simplemde\\\\node_modules\\n start nw ../jeforth.3we %1 %2 %3 %4 %5 %6 %7 %8 %9\\n -----------------\\n[x] (@ 3nw) But after resolved require('codemirror') not found, new problem appear: \\n JavaScript error on word \\\"doElement\\\" : navigator is not defined\\n --> js> navigator \\\\ ==> [object Navigator] (object) 明明 3nw 有啊!\\n js> window.navigator \\\\ ==> [object Navigator] (object) \\n --> 從 simplemde.js 裡查出是 require(\\\"codemirror\\\") 出錯\\n console.log(111);debugger; // @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\\n var CodeMirror = require(\\\"codemirror\\\");\\n console.log(222);debugger; // @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\\n --> Only server side needs to deal with npm things.\\n[x] (@ 3htm localhost ) 算了, 直接用 BootCDN include 看看: <---- Yes, correct way!! I don't \\n need to deal with server side issues.\\n <h>\\n < link href=\\\"http://cdn.bootcss.com/simplemde/1.10.0/simplemde.min.css\\\" rel=\\\"stylesheet\\\">\\n < script src=\\\"http://cdn.bootcss.com/simplemde/1.10.0/simplemde.min.js\\\"></script>\\n </h>\\n --> cls <js> typeof SimpleMDE </jsV> \\\\ ==> function (string)\\n It works !! \\n --> So, how about 3hta 不成功. 3htm on localhost and 3nw works with the below method.\\n[x] 3htm on localhost installed ok, so go on using it . . . \\n See http://simplemde.com --> Bingo!! it works now. But appearance has something wrong\\n that needs fine tuning.\\n\\n\\\\ 以下 3htm 3nw OK, 3hta 有掛上 simplemde 但是沒有效果。\\n\\\\ Include SimpleMDE\\n\\n <h>\\n < link href=\\\"http://cdn.bootcss.com/simplemde/1.10.0/simplemde.min.css\\\" rel=\\\"stylesheet\\\">\\n < script src=\\\"http://cdn.bootcss.com/simplemde/1.10.0/simplemde.min.js\\\"></script>\\n </h> drop\\n js> typeof(SimpleMDE) tib. \\\\ ==> function (string) so it has been installed\\n\\n\\\\ Create a textarea\\n\\n cls <o> <textarea id=simplemde ></textarea></o> js> outputbox insertBefore\\n\\n\\\\ Launch SimpleMDE on the above textarea\\n\\n <js> \\n var simplemde = new SimpleMDE({element: document.getElementById(\\\"simplemde\\\")}); \\n simplemde \\n </jsV> \\n constant simplemde\\n\\n\\\\ Test, set the content\\n\\n simplemde <js> pop().value(\\\"This text will appear in the editor\\\"); </js>\\n\\n\\\\ Test, get the content\\n\\n simplemde :> value() \\\\ ==> # This text will appear in the editor (string)\\n\\n[x] 不要用 bootCDN 改用別家的試試看... Same problem, see <^2016-05-04 11:57:32\\n\\nstop\\njs> vm.appname==\\\"jeforth.3hta\\\" [if] char js/numeric-1.2.6.js\\n[else] char http://www.numericjs.com/lib/numeric-1.2.6.js [then]\\nreadTextFile \\\\ 先讀取 .js 檔, 但不能直接用\\n<text> \\nwindow.numeric = numeric; // 先對 source 做一點必要的加工, 把 numeric 掛上 global \\n</text> + </js> \\\\ 然後才執行\\t\\n-------------\\n2016-05-03 00:07:17 error message\\n\\t\\tc:\\\\Users\\\\hcche\\\\Documents\\\\GitHub\\\\jeforth.3we>npm install simplemde --save\\n\\t\\tnpm ERR! git clone --template=C:\\\\Users\\\\hcche\\\\AppData\\\\Roaming\\\\npm-cache\\\\_git-remotes\\\\_templates ...\\n\\t\\tc:\\\\Users\\\\hcche\\\\Documents\\\\GitHub\\\\jeforth.3we>git\\n\\t\\t'git' 不是內部或外部命令、可執行的程式或批次檔。\\n\\n^^^^^ 2016-05-03 09:28:01 ^^^^^^^^^^^\\nC:\\\\users\\\\hcche\\\\Downloads> cd .\\\\simplemde\\nC:\\\\users\\\\hcche\\\\Downloads\\\\simplemde> npm install simplemde --save\\nnpm WARN deprecated gulp-minify-css@1.2.4: Please use gulp-clean-css\\nnpm WARN deprecated graceful-fs@3.0.8: graceful-fs v3.0.0 and before will fail on node releases >= v6.0. Please update to graceful-fs@^4.0.0 as soon as possible. Use 'npm ls graceful-fs' to find it in the tree.\\nnpm WARN deprecated lodash@1.0.2: lodash@<3.0.0 is no longer maintained. Upgrade to lodash@^4.0.0.\\nnpm WARN deprecated graceful-fs@1.2.3: graceful-fs v3.0.0 and before will fail on node releases >= v6.0. Please update to graceful-fs@^4.0.0 as soon as possible. Use 'npm ls graceful-fs' to find it in the tree.\\nsimplemde@1.10.1 node_modules\\\\simplemde\\n├── marked@0.3.5\\n├── codemirror@5.14.3\\n└── codemirror-spell-checker@1.0.6 (gulp-minify-css@1.2.4, gulp-header@1.7.1, gulp-concat@2.6.0, gulp-uglify@1.5.3, gulp@3.9.1)\\nC:\\\\users\\\\hcche\\\\Downloads\\\\simplemde>\\n\\nNote! The result is totally different to what happened last night at home.\\nSee Ynote \\\"SimpleMDE Install\\\" for pictures of the correct results.\\n\\n-------------------\\n\\n \\n\\n \",\"mode\":true,\"readonly\":false}","Play flot on 3nw":"{\"doc\":\"\\n \\\\ Flot.js demo GitHub\\\\flot\\\\examples\\\\basic-usage\\\\index.html\\n\\n \\\\ Prepare the Flot ploting zone\\n\\n ' flotzone [if] [else] \\n <o> <div class=flotzone></div></o> constant flotzone // ( -- DIV ) Place for Flot plotings avoid CSS conflict.\\n flotzone js> $(\\\".console3we\\\")[0] insertBefore\\n [then]\\n\\n \\\\ Include CSS and Flot.js\\n \\n js> typeof($.plot)!=\\\"function\\\" [if] \\n <h> \\n <--!link id=flotcss href=\\\"../flot/examples/examples.css\\\" rel=\\\"stylesheet\\\" type=\\\"text/css\\\"-->\\n <script id=flotjs language=\\\"javascript\\\" type=\\\"text/javascript\\\" src=\\\"../flot/jquery.flot.js\\\"></script>\\n </h> drop\\n\\n \\\\ Wait a while, make sure Flot.js is ready\\n .( $.plot readiness check .)\\n ( seconds * 1000 / nap ) js> 60*1000/200 [for] \\n js> typeof($.plot)==\\\"function\\\" [if] \\n r> drop 0 >r \\\\ break the loop\\n [else] \\n 200 nap .\\\" .\\\" \\\\ wait a while\\n [then] \\n [next] cr\\n [then]\\n \\n \\\\ Demo #1\\n \\\\ Create the placeholder\\n\\n flotzone\\n <o> <div id=\\\"placeholder1\\\" style=\\\"width:600px;height:300px\\\"></div></o> ( placeholer1 )\\n appendChild\\n\\n \\\\ Plot a line \\n \\n js: $.plot($(\\\"#placeholder1\\\"),[[[0,0],[1,1]]],{yaxis:{max:1}})\\n\\n \\\\ Demo #2\\n \\\\ Create the placeholder\\n\\n flotzone\\n <o> <div id=\\\"placeholder2\\\" style=\\\"width:600px;height:300px\\\"></div></o> ( placeholer2 )\\n appendChild\\n\\n \\\\ Plot some lines\\n \\n <js>\\n $(function() {\\n\\n var d1 = [];\\n for (var i = 0; i < 14; i += 0.5) {\\n d1.push([i, Math.sin(i)]);\\n }\\n\\n var d2 = [[0, 3], [4, 8], [8, 5], [9, 13]];\\n\\n // A null signifies separate line segments\\n\\n var d3 = [[0, 12], [7, 12], null, [7, 2.5], [12, 2.5]];\\n\\n $.plot(\\\"#placeholder2\\\", [ d1, d2, d3 ]);\\n\\n // Add the Flot version string to the footer\\n\\n $(\\\"#footer\\\").prepend(\\\"Flot \\\" + $.plot.version + \\\" – \\\");\\n });\\n </js>\\n<comment>\\n[ ] flotzone 目前必須放在 .console3we 之外才行, 希望能放在 outputbox 裡面, 做實驗方便。\\n[/] How to clear inherited CSS style for the flotzone element?\\n See 3hta local storage field \\\"Study remove CSS style for an element\\\"\\n --> 不成功, 用 Yahoo CSS reset 也不行。 甚至把 jeforth.3we 本身的 common.css 取消了也不行。\\n[x] 在 outputbox 裡一片白的 flotzone 經 insertBefore 到 .console3we 之上, 還是一片白。\\n[x] 那反過來呢? **在外成功之後** 搬進來如何? --> still failed. But then move out will be ok!\\n flotzone js> inputbox insertBefore \\\\ failed\\n flotzone js> header insertBefore \\\\ ok\\n js> body flotzone appendChild \\\\ ok 只要搬出 .console3we 都 ok\\n\\n[ ] 研究如何 dump 整個 style of an element 來查看\\n js> header.style obj>keys .\\n js> $(\\\".console3we\\\")[0].style obj>keys .\\n\\n[ ] 用 xjeforth.hta <--- 改過, 試試看到底為何 進 console3we 就不行\\n --> 上面說本來不行的搬出去也不行, 現在用 xjeforth.hta, 可能是因為經過簡化, 本來在 outputbox 裡不行的\\n 變成搬出去就可以了。\\n --> 繼續簡化...把 inputbox, outputbox 搬出 .console3we 之外, 終於可以成功地把 flot charts 放進\\n outputbox 了!\\n[ ] Flot.js 於 style.background 有細微的問題。我報了 bug on Flot.js GitHub Issue : \\n https://github.com/flot/flot/issues/1497\\n Or refer to YNote: \\\"Flot bug of graph disappear reproduced. How to fix it\\\"\\n 試圖研究在用到 flot.js 時把 .console3we 的 style 重新定義, 例如把 background 去掉, 就\\n 可以在 outputbox 裡正常運作了。\\n flotzone js> outputbox insertBefore \\\\ 搬到 outputbox 之前仍在 .console3we 裡複製出問題.\\n 查看 style tags 找到 console3we 的 background\\n 把它改成 transparent 試試看.\\n[x] > js> $(\\\"style\\\").length . \\\\ ==> 4 OK \\n 這 4 個裡面不含 common.css 的定義! 所以我以前就說 inputbox 要變粉紅色得分開弄一個 style 原因\\n 可能就是這個。 \\n\\n > js> $(\\\"style\\\")[0].outerHTML .\\n <style type=\\\"text/css\\\">canvas{border:solid 1px #CCC}</style> OK \\n\\n > js> $(\\\"style\\\")[1].outerHTML .\\n <style>\\n .tr table, .tr td { \\n border:0.075em solid gray; \\n }\\n </style> OK \\n\\n > js> $(\\\"style\\\")[2].outerHTML .\\n <style id=\\\"styleTextareaFocus\\\" type=\\\"text/css\\\"> \\n .console3we textarea:focus {\\n background:#E0E0E0;\\n }\\n </style> OK \\n\\n > js> $(\\\"style\\\")[3].outerHTML .\\n <style type=\\\"text/css\\\">\\n .eb .box { width:90%; }\\n .eb .box, .eb .ebhtmlarea { border:1px solid black; }\\n .eb p { display:inline; } \\n .eb .ebname { font-size: 1.1em; }\\n </style> OK \\n\\n[ ] 蓋過去行不行?\\n js> $(\\\".console3we\\\").length .\\n\\n\\n</comment>\",\"mode\":true,\"readonly\":false}","Study XMLHttpRequest object 2016-07-06":"{\"doc\":\"[ ] Study how to *write* files to local disk on super-chrome jeforth.3htm\\n --> 先前有找到過一個例子, 可以把網頁上的 pictures drag-drop 一下就 save 成 local file\\n Ynote: \\\"jeforth 研究 Chrome extension 存檔到本地 disk 的方法\\\" the thing is \\\"XMLHttpRequest\\\" \\n --> Study XMLHttpRequest @ http://www.w3school.com.cn/xml/xml_http.asp\\n<js> var x =new XMLHttpRequest(); x </jsV> constant xmlhttp // ( -- obj ) XMLHttpRequest object\\nxmlhttp :: open(\\\"GET\\\",\\\"a.html\\\",true)\\nxmlhttp :: send(null)\\ntry on 3hta ... error : access denied\\ntry on jeforth.3nw --> it works! \\n\\n\\nStudy XMLHttpRequest object \\nhttp://www.w3school.com.cn/xml/xml_http.asp\\n\\n> <js> var x =new XMLHttpRequest(); x </jsV> constant xmlhttp // ( -- obj ) XMLHttpRequest object\\n> xmlhttp . ==> [object XMLHttpRequest] \\\\ this is how it looks like\\n> xmlhttp :: open(\\\"GET\\\",\\\"a.html\\\",true) \\\\ try to read something from the server, a.html is not existing.\\n> xmlhttp :: send(null) \\\\ arm the instruction.\\n> xmlhttp :> readyState . ==> 4 \\\\ 4 is \\\"loaded\\\" or \\\"complete\\\"\\n> xmlhttp :> status \\\\ ==> 0 (number) \\\\ 0 is \\\"uninitialized\\\", a.html is not existing remember?\\n\\n\\\\ Try again\\n> xmlhttp :: open(\\\"GET\\\",\\\"index.html\\\",true) \\\\ now index.html is jeforth.3htm's main page\\n \\\\ the 3'rd argument Async = True 表示脚本会在 send() 方法之后继续执行,而不等待来自服务器的响应。\\n> xmlhttp :: send(null)\\n\\n\\\\ 照理說這時候要等 event xmlhttp.onreadystatechange=state_Change_event_handler; \\\\ or false if event not used\\n\\n> xmlhttp :> readyState \\\\ ==> 4 OK \\n> xmlhttp :> status \\\\ ==> 200 (number) \\\\ Bingo!! 200 is OK\\n> xmlhttp :> statusText \\\\ ==> OK (string)\\n> xmlhttp :> responseText \\\\ ==> 真的把檔案讀進來了!! Bingo !! 3nw, 3htm (super_chrome and webserver).\\n <!DOCTYPE html>\\n <html>\\n <head id=head>\\n <title class=appname>appname \\n \\n \\n \\n\\n\\\\ 3htm/f/readtextfile.f 裡面用的是 $.get 裡面可能就是用 XMLHttpRequest.\\n\\n> xmlhttp :: open(\\\"POST\\\",\\\"222\\\",false) \\\\ 沒有 error \\n> xmlhttp :: send(\\\"1234bsdfsd\\\") \\\\ 沒有 error 但也沒效果\\n\\n\\\\ 以上 post 無效是 3nw, 3htm(super_chrome) \\n\\\\ --> 改用 3htm + webserver.f 試試看 -- same result :-(\\n\\\\ 我不瞭解 POST command 的真正意義。Server 端應該要有人把收到的 data 存成檔案。\\n\\n[ ] Server 端應該要有人把收到的 data 存成檔案。這就有點麻煩了, 還不如直接用 3nw。\\n 我以前研究過 Web server 端的程式 on 3nd, it's time to review.\\n\",\"mode\":true,\"readonly\":false}","Style for 3nw":"{\"doc\":\"

Style for 3nw

drop\\n js: outputbox.style.fontSize=\\\"1.5em\\\"\\n js: inputbox.style.fontSize=\\\"1.5em\\\"\\n editbox-style \\n .eb .box { width:90%; font-size:1.1em; /* filename */ } \\n .eb .box, .eb .ebhtmlarea { border:1px solid black; }\\n .eb .ebtextarea { font-size:1.2em }\\n .eb input { font-size:0.7em /* buttons */ }\\n .eb p { display:inline; }\\n .eb .ebname { font-size: 1em; } /* field name */\\n js: $(\\\"#ebstyle\\\")[0].innerHTML=pop() \\\\ 直接修改 ebstyle \\ncr\\n\",\"mode\":true,\"readonly\":false}","ad":"{\"doc\":\"\\n\\\\ Remove all annoying floating ad boxes. 刪除所有惱人的廣告框。\\nactive-tab :> id tabid! \\nvar divs = document.getElementsByTagName(\\\"div\\\");\\nfor (var i=divs.length-1; i>=0; i--){\\n if(divs[i].style.position){\\n divs[i].parentNode.removeChild(divs[i]);\\n }\\n}\\nfor (var i=divs.length-1; i>=0; i--){\\n if(parseInt(divs[i].style.width)<600){ // <---- 任意修改\\n divs[i].parentNode.removeChild(divs[i]);\\n }\\n}\\n\\n\",\"readonly\":true,\"mode\":true}","autoexec":"{\"doc\":\"\\njs: outputbox.style.fontSize=\\\"1.5em\\\"\\njs: inputbox.style.fontSize=\\\"1.5em\\\"\\n\",\"mode\":true,\"readonly\":false}","log of 3nw":"{\"doc\":\"[x] file input 若被 user cancel 則 sleep 得不到 stopsleeping 在那裏苦等 <--- problem!\\n> constant ff\\n> ff :> value . \\\\ ==> OK it's null string by default\\n> ff :> value . \\\\ after picking a file, it becomes a pathname\\nC:\\\\Users\\\\hcche\\\\Documents\\\\GitHub\\\\chrome-app-samples\\\\tryitnowbutton_small.png OK \\n> ff :> value . \\\\ try again but click cancel, it becomes a null string as anticipated, good!\\n> \\\\ click [cancel] clears ff.value <--- good!!\\n> ff :: onchange=function(){alert(\\\"onchange\\\")} \\\\ Add event handler, it works!\\n> \\\\ click [cancel] does not fire onchange() event unless due to the above reason that has actually been changed.\\n> ff :: oncancel=function(){alert(\\\"onCancel\\\")} <--- click [cancel] does not fire this event at all. But onchange() event got fired sometimes.\\n> ff :: onchange=function(){alert(\\\"onBigChange\\\")} \\\\ Handler can be changed and it works fine.\\n> ff :> oncancel . \\\\ ==> function (){alert(\\\"onCancel\\\")} OK check, it's there\\n> ff :> onchange . \\\\ ==> function (){alert(\\\"onBigChange\\\")} check, it's there\\n> \\\\ ff :: onabort=function(){alert(\\\"onAbort\\\")} \\\\ ==> Click cancel does not fire this either.\\n> \\\\ ff :> onabort . \\\\ ==> ff :: onabort=function(){alert(\\\"onAbort\\\")}\\n> \\\\ No, click [cancel] does not fire onabort() \\n\\n\\\\ 企圖故意製造 onchange 100% 發生的努力, 失敗了:\\n> ff :> value=\\\"dummy\\\" <--- Not allowed, see err message:\\nJavaScript error : Failed to set the 'value' property on 'HTMLInputElement': \\nThis input element accepts a filename, which may only be programmatically set \\nto the empty string.\\n\\n\\\\ 機會 : 每個 file input 都是新的, 用完馬上 remove 掉, 有機會讓所有的 cancel 都 fire \\n\\\\ onchange() event? --> 一上來馬上 cancel 因為 file.value 都是 null string 沒有變故\\n\\\\ 不會 fire onchange() event. --> 試試為 file.value 給訂初值 --> No way, see:\\n\\\\ 为安全起见,file-upload 元素不允许 HTML 作者或 JavaScript 程序员指定一个默认的文件名。\\n\\nff :> defaultValue \\\\ ==> null string.\\n constant fff\\nff :: onbeforedeactivate=function(){alert(\\\"beforeDeActivate\\\")} \\\\ <== fire when blur, 不適合.\\n\\nff :: onblur=function(){alert(\\\"onblur\\\")} <-- fired when both clicking [瀏覽] and \\nclick desk top but not clicking [cancel], shit!!!\\n\\n[x] 解決了! 3nw 會 fire oncancel() when [cancel] clicked!! Bingo!!\\nff :: onemptied=function(){type(\\\"onemptied\\\")}\\nff :: onended=function(){type(\\\"onended\\\")}\\nff :: onerror=function(){type(\\\"onerror\\\")}\\nff :: onerrorupdate=function(){type(\\\"onerrorupdate\\\")}\\nff :: onfilterchange=function(){type(\\\"onfilterchange\\\")}\\nff :: onfocus=function(){type(\\\"onfocus\\\")}\\nff :: onfocusin=function(){type(\\\"onfocusin\\\")}\\nff :: onfocusout=function(){type(\\\"onfocusout\\\")}\\nff :: onhelp=function(){type(\\\"onhelp\\\")}\\nff :: oninput=function(){type(\\\"oninput\\\")}\\nff :: onchange=function(){type(\\\"onChange\\\")}\\nff :: oncancel=function(){type(\\\"oncancel\\\")}\\n\\n3hta\\nonfocusin onfocus onfocusout \\nonfocusin onfocus onfocusout\\n\\n3nw\\nonfocus \\nonfocus oncancel\\nonfocus \\nonfocus oncancel\\n\\n[x] Answer to stackoverflow with my finding of oncancel() works!\\n http://stackoverflow.com/questions/10127492/capturing-cancel-event-on-input-type-file\\n\\n I have the same question, the solution is surprisingly very \\n easy ... at least in my case NW.js (Node-Webkit) fires oncancel \\n event if user click the [cancel] button in the file chooser \\n dialogue. You use this simple and native way if you're also on \\n NW.js (process.version is v5.11.0).\\n\\n I also tried Microsoft HTA on Windows 10, it does not fire the \\n oncancel event.\\n\\n' --- [if] --- [then] marker --- \\n\\n \\n \\n\\n\\n\\nThe above sample code, modified for jeforth, from \\nhttp://stackoverflow.com/questions/29705135/node-webkit-read-full-path-of-files-from-directory\\nworks fine, very well. No problem at all getting the full pathname on 3nw, but not on 3ce. So, \\nNW.js is really provides super power.\\n\\n\\\\ Works fine on 3nw,\\n> js> $(\\\"#fileDialog\\\").length \\\\ ==> 1 OK \\n> js> $(\\\"#fileDialog\\\")[0].value . \\\\ ==> C:\\\\Users\\\\hcche\\\\Downloads\\\\download OK \\n> js> document.getElementById(\\\"fileDialog\\\") . \\\\ ==> [object HTMLInputElement] OK \\n> js> document.getElementById(\\\"fileDialog\\\").value . \\\\ ==> C:\\\\Users\\\\hcche\\\\Downloads\\\\download OK \\n> pickFile \\n> .s\\n 0: (string) \\\\ <--- My original pickFile does not work on 3nw. Needs debug.\\n\\n\\\\ On jeforth.3ce, failed as anticipated\\n\\n > js> document.getElementById(\\\"fileDialog\\\").value .\\n C:\\\\fakepath\\\\__865.jpg OK <---- \\\"fakepath\\\" as anticipated.\\n\\n\\\\ Works fine on 3HTA.\\n\\n > js> document.getElementById(\\\"fileDialog\\\").value .\\n C:\\\\Users\\\\hcche\\\\Downloads\\\\魏月梅 全民健保核退申請書.PDF OK \\n\\n\\\\ So, pickFile can be improved by this solution from Stackoverflow.\\n\\n: pickFile ( -- \\\"pathname\\\" ) \\\\ Pick a file through web browser's GUI\\nchar input createElement ( element )\\ndup char type char file setAttribute ( element )\\ndup char id char pickfile setAttribute ( element )\\neleBody over appendChild \\\\ 要 append 才有作用。\\n( element ) js> tos().click();tos().value ( element pathname ) ;\\n\\n\\\\ 照上面這個 pickFile 實驗, 還是不行。確定傳回的 pathname 是個 \\\"\\\". 然而手動觀察 element.value 卻是\\n\\\\ 正確的 pathname. [x] 猜想, 最後一行手動看應該會是 expected pathname 無誤。\\n\\n> .s \\n 0: [object HTMLInputElement] (object) \\\\ backup\\n 1: C:\\\\Users\\\\hcche\\\\Downloads\\\\jeforth.3ce.p4.jpg (string)\\n 2: [object HTMLInputElement] (object) \\\\ to be removed\\n> removeElement\\n> js> tos(1).value . \\\\ 查看 element 的 value \\nC:\\\\Users\\\\hcche\\\\Downloads\\\\jeforth.3ce.p4.jpg OK \\\\ 竟然是對的。此時 element id 確定已經不存在了。\\n\\n\\n[x] 嘗試手動作最後一行\\n: pickFile ( -- \\\"pathname\\\" ) \\\\ Pick a file through web browser's GUI\\nchar input createElement ( element )\\ndup char type char file setAttribute ( element )\\ndup char id char pickfile setAttribute ( element )\\neleBody over appendChild \\\\ 要 append 才有作用。\\n; \\n\\n\\\\ 果然, 這行一起做, 傳回 \\\"\\\"\\n( element ) js> tos().click();tos().value ( element pathname ) ;\\n\\n\\\\ 手動分開做, 就 OK 了!!\\n( element ) js: tos().click()\\njs> tos().value ( element pathname ) ;\\n\\n[x] click() 之後, 加上一點 nap 看看, --> \\n\\n: pickFile ( -- \\\"pathname\\\" ) \\\\ Pick a file through web browser's GUI\\nchar input createElement ( element )\\ndup char type char file setAttribute ( element )\\ndup char class char pick_file setAttribute ( element )\\njs> body over appendChild \\\\ 要 append 才有作用。\\njs: tos().click() ( element ) \\\\ 回來就表示 user 已經完成操作\\n( seconds * 1000 / nap ) js> 60*1000/200 for ( element ) \\n\\tjs> tos().value if \\n\\t\\tr> drop 0 >r \\\\ break the loop\\n\\telse \\n\\t\\t200 nap .\\\" .\\\" \\\\ wait a while\\n\\tthen \\nnext ( element ) \\njs> tos().value \\\\ 即使 timeout 也不管了 ( element path ) \\nswap removeElement ; ( path ) \\n\\n\\\\ Ultimate version\\n\\n: pickFile ( -- \\\"pathname\\\" ) \\\\ Pick a file through web browser's GUI\\n\\tchar input createElement ( element )\\n\\tdup char type char file setAttribute ( element )\\n\\tdup char class char pick_file setAttribute ( element ) \\\\ for debug, clue of the element\\n\\tjs: tos().onchange=function(){execute('stopSleeping')} ( element )\\n\\tjs> body over appendChild \\\\ 要 append 才有作用。 ( element )\\n js: tos().click() ( element ) \\\\ @ HTA 回來就表示 user 已經完成操作, @ NW.js 則馬上回來。\\n\\t( minutes*60*1000 ) js> 5*60*1000 sleep ( element )\\n\\tjs> tos().value \\\\ 即使 timeout 也不管了 ( element path ) \\n\\tswap removeElement ; ( path ) \\n\\n: pickFile \\t\\t( -- \\\"pathname\\\" ) \\\\ Pick a file through web browser's GUI\\nchar input createElement ( element )\\ndup char type char file setAttribute ( element )\\ndup char class char pick_file setAttribute ( element ) \\\\ for debug, clue of the element\\n\\\\ For none 3hta only, setup the event handler\\njs> vm.appname!=\\\"jeforth.3hta\\\" if\\n\\tjs: tos().onchange=function(){execute('stopSleeping')} ( element ) then\\njs> body over appendChild \\\\ 要 append 才有作用。 ( element )\\njs: tos().click() ( element ) \\\\ @ HTA 回來就表示 user 已經完成操作, @ NW.js 則馬上回來。\\n\\\\ For none 3hta only, wait for the onchange event\\njs> vm.appname!=\\\"jeforth.3hta\\\" if\\n\\t( minutes*60*1000 ) js> 5*60*1000 sleep ( element ) then\\njs> tos().value \\\\ 即使 timeout 也不管了 ( element path ) \\nswap removeElement ; ( path ) \\n/// Works fine on 3hta and 3nw. The dialog works but returns Null string on 3htm \\n/// or C:\\\\fakepath\\\\__865.jpg on 3ce.\\n/// Through excel app's GetOpenFilename method can do the same thing:\\n/// excel.app js> pop().GETopenFILENAME <== with or w/o () both fine\\n/// Excel's GetSaveAsFilename method too.\\n\\n\\n\\n\\n[x] 3nw's js: storage.save(pathname) and js: storage.restore(pathname) work fine now.\\n[/] How about 3hta? <--- 3hta works fine already, forget it.\\n[x] 3nw should auto save and restore local storage. restore when start up, save when\\n any field is saved. So I don't need corresponding words for them.\\n\",\"mode\":true,\"readonly\":false}","node.js HTTP server":"{\"doc\":\"\\n\\\\ ~@~@~@~@~@~@~@~@~ Build Your First HTTP Server in Node.js ~@~@~@~@~@~@~@~@~\\n\\\\\\n\\\\ https://www.diigo.com/user/hcchen/b/373115646\\n\\\\ jeforth.3nw localsotrage field \\\"node.js HTTP server\\\"\\n\\\\ ~\\\\jeforth.3we\\\\3nd\\\\build_your_http_server.f \\n\\\\\\n\\n\\\\ Lets require/import the HTTP module and choose a port to listen\\n js> require('http') constant http // ( -- HTTP-object ) Get node.js http module\\n\\n\\\\ Lets define a port we want to listen to\\n 8080 constant PORT // ( -- port# ) Port number HTTP server listen to\\n\\n\\\\ We need a function which handles requests and send response\\n \\n \\n var f = function handleRequest(request, response){\\n response.end('It Works!! Path Hit: ' + request.url);\\n };f\\n constant handleRequest // ( -- func ) Request handler\\n \\n\\n\\\\ Callback triggered when server is successfully listening. Hurray!\\n \\n var f = function callback(){\\n type(\\\"Server listening on: http://localhost:\\\"+vm[context].PORT);\\n }; f\\n constant server-callback // ( -- func ) Call back function of the HTTP server\\n\\n\\\\ Create a server\\n http :> createServer(vm[context].handleRequest)\\n constant server // ( -- obj ) HTTP server object\\n\\n\\\\ Lets start our server\\n server :> listen(vm[context].PORT,vm[context][\\\"server-callback\\\"])\\n\\n\\\\ Your server should respond differently to different URL \\n\\\\ paths. This means we need a dispatcher. Dispatcher is kind \\n\\\\ of router which helps in calling the desired request handler \\n\\\\ code for each particular URL path. Now lets add a dispatcher \\n\\\\ to our program. First we will install a dispatcher module, \\n\\\\ in our case httpdispatcher. There are many modules available \\n\\\\ but lets install a basic one for demo purposes\\n\\n js> require('httpdispatcher') constant dispatcher // ( -- obj ) HTTP dispatcher\\n\\n\\n//Lets use our dispatcher\\nfunction handleRequest(request, response){\\n try {\\n //log the request on console\\n console.log(request.url);\\n //Disptach\\n dispatcher.dispatch(request, response);\\n } catch(err) {\\n console.log(err);\\n }\\n}\",\"mode\":true,\"readonly\":false}","pruning":"{\"doc\":\"\\n\\\\ Make the target page editable for pruning. 把 target page 搞成 editable 以便修剪。\\nactive-tab :> id tabid! document.getElementsByTagName(\\\"body\\\")[0].contentEditable=true \\n\",\"readonly\":true,\"mode\":true}","smde_MyUniqueID":"j e f o r t h . 3 w e\n==============\n**Forth** is the simplest programming language ever. The jeforth.**3we** project is an implementation based on a **3 Words Engine** from [project-k](http://github.com/hcchengithub/project-k) for many applications: *HTA (jeforth.3hta)*, *HTML (jeforth.3htm)*, *Chrome Extension (jeforth.3ca)*, *Node.js (jeforth.3nd)*, *Node-webkit or NW.js (jeforth.3nw)*, and probably more in the future. All of them have been tested on Windows 8 or Windows 10.\n\nPlay now\n===========\nAmong the many applications, jeforth for web page (jeforth.3htm) can run on your web browser right now thus is good for demonstration. \n\n#### [Solar system](http://rawgit.com/hcchengithub/jeforth.3we/master/index.html?cls_include_solar-system.f)\n[簡介](http://note.youdao.com/yws/public/redirect/share?id=94764cf57ba4365e2997f4a268ff7716&type=false)
\n![enter image description here](https://github.com/hcchengithub/jeforth.3we/wiki/pictures/solar-system.png)\n\n#### [H2O](http://rawgit.com/hcchengithub/jeforth.3we/master/index.html?cls_include_h2o.f)\n![enter image description here](https://github.com/hcchengithub/jeforth.3we/wiki/pictures/h2o.png)\n\n#### [Alarm clock](http://rawgit.com/hcchengithub/jeforth.3we/master/index.html?cls_include_alarm.f_er)\n ![enter image description here](https://github.com/hcchengithub/jeforth.3we/wiki/pictures/demo-alarm.png)\n \n#### [Box2Dweb Physics Engine demo - Arrows](http://rawgit.com/hcchengithub/jeforth.3we/master/index.html?cls_include_box2dweb-arrow.f)\n![enter image description here](https://github.com/hcchengithub/jeforth.3we/wiki/pictures/demo-arrow.png)\n\n#### [Chipmunk Physics Engine demo - Pyramid Stack](http://rawgit.com/hcchengithub/jeforth.3we/master/index.html?cls_include_chipmunk-js-pyramidstack.f)\n![enter image description here](https://github.com/hcchengithub/jeforth.3we/wiki/pictures/demo-pyramidstack.png)\n\n\nWhat else can you do with jeforth.3we?\n=============\n\n#### [Markdown editor](http://note.youdao.com/yws/public/redirect/share?id=1a8a342f3a9c1e0622a6050480af28b7&type=false)\n\nNW.js can access files in your local computer and also have all abilities like the Chrome browser, that allows jeforth.3nw to include JavaScript modules from the Internet. For example, [SimpleMDE](https://simplemde.com) is a Markdown Editor that works fine on jeofrth.3nw. \n\n![enter image description here](https://github.com/hcchengithub/jeforth.3we/wiki/pictures/demo 3nw mde editor.JPG)\n\n\nGet source code, unzip, and start running\n=============\n\n| Item | Address |\n----------------|----------------------------------------------\n| jeforth.3we high level source code | *http://github.com/hcchengithub/jeforth.3we* |\n| Kernel, jeforth.js 3-words-engine| *http://github.com/hcchengithub/project-k* |\n\n
\nClick the [Download ZIP] button of both projects [jeforth.3we](https://github.com/hcchengithub/jeforth.3we) and [project-k](https://github.com/hcchengithub/project-k) on their GitHub web page to get them. Unzip jeforth.3we first and then unzip project-k to under the jeforth.3we directory, as shown in the below directory listing. Then you can run 3hta.bat without installing anything else if your computer is Windows 8 or Windows 10; or run 3nd.bat and 3nw.bat, if you have installed node.js and nw.js.\n\nMy jeforth.3we/ directory listing for example,\n\n![jeforth3we-dir.png](https://github.com/hcchengithub/jeforth.3we/wiki/pictures/jeforth3we-dir.png)\n\n\n**Note:** Only for jeforth.3hta and only when you were **Download Zip** jeforth.3we from GitHub, It's necessary to use GNU tool [unix2dos](http://waterlan.home.xs4all.nl/dos2unix.html) to convert the new line characters of all text files [from Unix's LF to Windows' CRLF](https://en.wikipedia.org/wiki/Unix2dos). This is an example command line of the usage:\n\n d:\\jeforth.3we>for /R %G in (*.*) do d:\\bin\\unix2dos.exe \"%G\"\n\n
\n\nIf you were **git clone https://github.com/hcchengithub/jeforth.3we** instead of **Download Zip** then forget this step, GitHub shell for Windows already converts new line characters to CRLF correctly. \n\nPresentation videos\n======\n\n| No. | Mandarin | English |\n--------|----------|---------\n| 1 | [Opening](http://www.camdemy.com/media/19253)| n/a |\n| 2 | [Run the HTML version online](http://www.camdemy.com/media/19254)| n/a |\n| 3 | [Run the HTML version on local computer](http://www.camdemy.com/media/19255)| n/a |\n| 4 | [Run the HTA version](http://www.camdemy.com/media/19256)| n/a |\n| 5 | [Run Node.js and Node-Webkit version](http://www.camdemy.com/media/19257)| n/a |\n| 6 | [F2 inputbox edit mode](http://www.camdemy.com/media/19258)| n/a |\n| 7 | [F4 Copy marked string to inputbox](http://www.camdemy.com/media/19259)| n/a |\n| 8 | [F5 Restart](http://www.camdemy.com/media/19260)| n/a |\n| 9 | [Bigger/Smaller input box](http://www.camdemy.com/media/19261)| n/a |\n| 10 | [Esc clear input box](http://www.camdemy.com/media/19262)| n/a |\n| 11 | [Tab auto-complete](http://www.camdemy.com/media/19263)| n/a |\n| 12 | [Enter jump into the input box](http://www.camdemy.com/media/19264)| n/a |\n| 13 | [Up/Down recall command history](http://www.camdemy.com/media/19265)| n/a |\n| 14 | [Alt-Up Reuse used commands](http://www.camdemy.com/media/19266)| n/a |\n| 15 | [Crtl- / Ctrl+ Zoom in/ Zoom out](http://www.camdemy.com/media/19267)| n/a |\n| 16 | [Ctrl-Break stop all tasks](http://www.camdemy.com/media/19268)| n/a |\n| 17 | [BackSpace trims the output box](http://www.camdemy.com/media/19269)| n/a |\n| 18 | [Help is helpful](http://www.camdemy.com/media/19270)| n/a |\n| 19 | [jsc JavaScript Console](http://www.camdemy.com/media/19271)| n/a |\n\nWhat to play in further depth\n========================\nDownload and setup the jeforth.3we directory and project-k directory as mentioned above.\n\n#### **HTA** / jeforth.3hta\nDouble click the **jeforth.3we/jeforth.hta** or execute the below DOS command line in a DOS box,\n```\njeforth.hta cls .' Hello world' cr 3000 sleep bye\n```\n![3htahello-world.png](https://github.com/hcchengithub/jeforth.3we/wiki/pictures/3htahello-world.png)\n\nThe prior method runs self-test because there's no given task to do. The 2'nd method is expected to print 'Hello world' (as shown above) and return to DOS box after 3 seconds.\n\n\nNote! If you see the Windows error message : [\"Safety Settings on this computer prohibit accessing a data source on another domain\"](https://social.msdn.microsoft.com/Forums/en-US/becc982a-b693-49bb-8fb0-95847a3e96c7/hta-safety-settings-on-this-computer-prohibit-accessing-a-data-source-on-another-domain?forum=scripting) that I heard may happen on some Windows 7 computers. Sorry, [I have no solution yet](http://stackoverflow.com/questions/32177060/hta-safety-settings-on-this-computer-prohibit-accessing-a-data-source-on-anot), It didn't happen on those Windows 7 computers that I could reach. Please upgrade to Windows 8 or 10 to avoid from the problem.\n\n#### **Node.js** / jeforth.3nd\nMake sure you can run node.exe in a DOS box so you have setup the path. Make the jeforth.3we/ folder be your working directory. Execute one of the below demo command lines:\n```\nnode jeforth.3nd.js\nnode jeforth.3nd.js cls .' Hello world' cr bye\n```\nAgain, like the above HTA case, the prior command line does the self-test, and the 2'nd is expected to print 'Hello world'.\n\nWe have a local Web server written by jeforth.3nd itself. See jeforth.3we/Webserver.bat. Having a local Web server is necessary to run jeforth.3htm. \n\n#### **HTML** / jeforth.3htm\nSetup your local Web server by running jeforth.3we/Webserver.bat, \n\n![webserver.png](https://github.com/hcchengithub/jeforth.3we/wiki/pictures/webserver.png)\n\nthen try to visit below URLs:\n```\nhttp://localhost:8888\nhttp://localhost:8888/index.html\nhttp://localhost:8888/index.html? cr .\" hello world\" cr cr \nhttp://localhost:8888/index.html?_cr_.\"_hello_world\"_cr_cr \nhttp://localhost:8888/index.html? .\" 8-) \" 100 nap rewind\nhttp://localhost:8888/index.html?_.\"_8-)_\"_100_nap_rewind\n```\nI have tested IE10 , IE11 and Chrome. Firefox or other web browsers are not tested yet. As shown above, we can put any forth words in the URL. That will be the task jeforth.3htm will do after start up and the self-test will be skipped when having a task to do.\n\n#### **Node-webkit** / jeforth.3nw\nSetup your Node.js and Node-Webkit path in prior. Refer to 3nw.bat as an example. Make jeforth.3we/ be your working directory, run either one of below command lines:\n```\nnw ../jeforth.3we\nnw ../jeforth.3we cls .' Hello World' 3000 sleep bye\n```\nThe prior runs self-test because there's no given task to do. The 2'nd is expected to print 'Hello world' and return to DOS box after 3 seconds.\n\t\nCompile eforth.com\n--------------------------\n\nJeforth.3nd for Node.js can be a handy x86 CPU assembler (any other CPU too). We have an example to compile the legendary eforth.com executable for 16 bits PC under MS-DOS by Bill Muench and C. H. Ting, 1990.\n\n 1. Install node.js correctly so you can run node.exe in a DOX box. Working directory at jeforth.3we/. \n 2. Run: node.exe jeforth.3nd.js include 86ef202.f bye\n 3. You got jeforth.3we/eforth.com\n 4. I have a 32bits windows 8, so I can run eforth.com directly. If your Windows system is 64 bits, you'll need a DOS virtual machine like vmware, virtual box, or I recommend DOSBox, to run the created eforth.com.\n\nExcel automation\n---------------------\nUse jeforth.3hta to manipulate excel spread sheets. This example gets a column from a reference excel file to your target excel file.\n\n 1. Double click on jeforth.3we/jeforth.hta to start it. After the self-test type the command line \"include merge2.f\" into the input box.\n 2. Or run the below command line directory for the same thing:\n```\njeforth.hta include merge2.f\n```\n\n#### The End\n\n - FigTaiwan [http://figtaiwan.org](http://figtaiwan.org) \n - H.C. Chen [hcchen5600@gmail.com](hcchen5600@gmail.com) \n - Written with [StackEdit](https://stackedit.io/)\n\n\n "} \ No newline at end of file +{"3nw working on simpleMDE":"{\"doc\":\"\\n[x] Now ^2016-05-06 14:29:46 developing SimpleMDE on 3nw \\n[x] pickFile can work on 3htm, 3nw, 3hta but only 3hta gets the pathname string, \\n others are \\\"\\\" due to security restrictions I believe. Is there a workaround?\\n [x] try answers on Stackoverflow.com \\n 1. http://jsfiddle.net/dwebexperts/4FGg8/1/\\n http://stackoverflow.com/questions/15201071/how-to-get-full-path-of-selected-file-on-change-of-input-type-file-using-jav\\n Introduces a temp_path , which is interesting but not good enough for my MDE because\\n [Save] button needs the real pathname.\\n\\n-----------------\\n\\n\\\\ Word does not work, mde-include not ok yet, but interpret mode works fine\\n\\n\\n.( Include SimpleMDE.js )\\n\\n\\tjs> typeof(SimpleMDE)!=\\\"function\\\" [if]\\n\\t\\t\\n\\t\\t \\n\\t\\t\\n\\t\\t drop \\n\\t[then]\\n\\tfalse ( assume include failed ) \\n\\t30 ( seconds ) [for] \\n\\t\\tjs> typeof(SimpleMDE)==\\\"function\\\" [if] \\n\\t\\t\\tr> drop 0 >r \\\\ break the loop\\n\\t\\t\\tdrop true ( include OK )\\n\\t\\t[else] \\n\\t\\t\\t20 nap .\\\" .\\\" \\\\ wait a while\\n\\t\\t[then] \\n\\t[next] \\n\\t[if] .\\\" Done. \\\" [else] .\\\" Error! Failed to include SimpleMDE! [then] cr\\n\\n.( Create the required textarea for SimpleMDE ) cr\\n\\n \\n js> $(\\\".console3we\\\")[0] insertBefore\\n\\n.( Launch SimpleMDE on the above textarea ) cr\\n\\n \\n var simplemde = new SimpleMDE({element: document.getElementById(\\\"simplemde\\\")}); \\n simplemde \\n \\n constant simplemde\\n\\n.( Load README.md ) cr\\n\\n char README.md readTextFile\\n simplemde :: value(pop())\\n\\t\\n\\\\ Above interpret procedure works fine.\\n\\n\\n\\\\ [x] mde ( -- ) \\\\ open Markdown editor \\n\\n: mde-include ( -- ok? ) \\\\ Inclde MDE editor \\n\\tjs> typeof(SimpleMDE)!=\\\"function\\\" if\\n\\t\\t\\n\\t\\t \\n\\t\\t\\n\\t\\t drop \\n\\tthen\\n\\tfalse ( assume include failed ) \\n\\t30 ( seconds ) for \\n\\t\\tjs> typeof(SimpleMDE)==\\\"function\\\" if \\n\\t\\t\\tr> drop 0 >r \\\\ break the loop\\n\\t\\t\\tdrop true ( include OK )\\n\\t\\telse \\n\\t\\t\\t1000 nap \\\\ wait a while\\n\\t\\tthen \\n\\tnext ;\\n\\n\\\\ execute the word does not work. But run on interpret mode always ok. Why?\\n\\\\ Even when it's not work, check the elements of link and script, they are existing:\\n\\tjs> $(\\\"head\\\")[0] ce! ce 09 ce@ :> outerHTML .\\n\\tjs> $(\\\"head\\\")[0] ce! ce 10 ce@ :> outerHTML .\\n\\nstop \\n---------------\\n[x] 所有在 .console3we 範圍內的 textarea 都會在 F2 edit mode focused 時變成粉紅色。 ed 的亦然。\\n 把 ed 移出 .console3we 之外 (而非光 outputbox 之外) 就會失去所有的 .console3we style. 如下,\\n > js> $(\\\".eb\\\")[0] js> $(\\\".console3we\\\")[0] insertBefore\\n ==> 所以, SimpleMDE init textarea 要移出 .console3we 之上才行. \\n[x] Go on use the knowledge to fine tune 3we's style settings.\\n --> study common.css first \\n --> but I already use .console3we to constraint the range!\\n ==> 所以, SimpleMDE init textarea 要移出 .console3we 之上才行. \\n\\n\\\\ ^^2016-05-04 11:57:32^^ \\n\\\\ (@ 3nw) 改照抄 official demo page 上的 resource 也行, 但是問題還是一樣。\\n\\\\ 可見是 jeforth 的 style 造成的問題。 \\n\\\\ [x] 下一步, 3nw 的 style 反璞歸真, 或限制範圍。 ==> Bingo!! See Ynote \\n\\\\ \\\"SimpleMDE works fine on jeforth.3nw now\\\" \\n\\n\\n\\\\ Include SimpleMDE\\n\\n \\n < link rel=\\\"stylesheet\\\" href=\\\"https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.css\\\"> \\n < script src=\\\"https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.js\\\">\\n drop\\n js> typeof(SimpleMDE) tib. \\\\ ==> function (string) so it has been installed\\n\\n\\\\ Create a textarea\\n\\n \\n js> $(\\\".console3we\\\")[0] insertBefore\\n\\n\\\\ Launch SimpleMDE on the above textarea\\n\\n \\n var simplemde = new SimpleMDE({element: document.getElementById(\\\"simplemde\\\")}); \\n simplemde \\n \\n constant simplemde\\n\\n\\\\ Test, set the content\\n\\n simplemde pop().value(\\\"This text will appear in the editor\\\"); \\n\\n\\\\ Test, get the content\\n\\n simplemde :> value() \\\\ ==> # This text will appear in the editor (string)\\n\\n-----------------------------\\nStudy https://simplemde.com/ so as to copy the usage\\n\\n\\\\ 瞧瞧 body\\n > js> $(\\\"body\\\")[0] ce! ce\\n [object HTMLBodyElement] innerHTML=

SimpleMDE ...\\n 0 : [object HTMLElement] class='page-header'; innerHTML=

SimpleMDE Markdown Edi...\\n 1 : [object HTMLElement] class='main-content'; innerHTML=

.console3we { color:black; word-wrap:...\\n\\n\\\\ 瞧瞧 header\\n > js> $(\\\"body\\\")[0] ce! ce\\n [object HTMLHeadElement] innerHTML=JavaScript Markdown Editor - SimpleM...\\n 0 : [object HTMLMetaElement] \\n 1 : [object HTMLTitleElement] innerHTML=JavaScript Markdown Editor - SimpleMDE...\\n 2 : [object HTMLMetaElement] name='viewport'; \\n 3 : [object HTMLLinkElement] \\n 4 : [object HTMLLinkElement] \\n 5 : [object HTMLLinkElement] \\n 6 : [object HTMLLinkElement] \\n 7 : [object HTMLLinkElement] \\n 8 : [object HTMLScriptElement] <=========== 這裡面是空的\\n 9 : [object HTMLScriptElement] innerHTML= if(window.location.href.indexOf(\\\"nextstepwebs.github.io\\\") !== ...\\n 10 : [object HTMLStyleElement] innerHTML= .editor-preview h1, .editor-preview h2, .editor-preview h3, .ed...\\n 11 : [object HTMLStyleElement] id='style-1-cropbar-clipper'; innerHTML=/* Copyright 2014 Evernote Corpora...\\n 12 : [object HTMLStyleElement] innerHTML= .tr table, .tr td { border:0.075em solid gray; } ...\\n\\n \\\\ ce 8 ce@ :> outerHTML 看來好像在修整網址, 總之 SimpleMDE 不是在 header 裡 include 的。\\n <script>\\n if(window.location.href.indexOf(\\\"nextstepwebs.github.io\\\") !== -1) {\\n window.location.href = \\\"https://simplemde.com/\\\";\\n }\\n \\n if(window.location.protocol != \\\"https:\\\")\\n window.location.href = \\\"https:\\\"+window.location.href.substring(window.location.protocol.length);\\n </script> OK \\n\\n\\\\ Now look into the source code of the demo page\\n\\n\\n> cr cr cr js> $(\\\"body\\\")[0] ce! ce 2 ce@ :> outerHTML .\\n[object HTMLLinkElement] \\n<link rel=\\\"stylesheet\\\" href=\\\"https://maxcdn.bootstrapcdn.com/font-awesome/latest/css/font-awesome.min.css\\\"> OK \\n\\n> cr cr cr js> $(\\\"body\\\")[0] ce! ce 3 ce@ :> outerHTML .\\n[object HTMLLinkElement] \\n<link rel=\\\"stylesheet\\\" href=\\\"https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.css\\\"> OK \\n\\n> cr cr cr js> $(\\\"body\\\")[0] ce! ce 4 ce@ :> outerHTML .\\n[object HTMLScriptElement] \\n<script src=\\\"https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.js\\\"></script> OK \\n\\n> cls js> $(\\\"body\\\")[0] ce! ce 5 ce@ :> outerHTML .\\n[object HTMLScriptElement] innerHTML= new SimpleMDE({ element: document.getElementById(\\\"demo1\\\"), spe...\\n 0 : [object Text] new SimpleMDE({ element: document.getElementById(\\\"demo1\\\"), spellChecker: false, }); n...\\n<script>\\n new SimpleMDE({\\n element: document.getElementById(\\\"demo1\\\"),\\n spellChecker: false,\\n });\\n \\n new SimpleMDE({\\n element: document.getElementById(\\\"demo2\\\"),\\n spellChecker: false,\\n autosave: {\\n enabled: true,\\n unique_id: \\\"demo2\\\",\\n },\\n });\\n \\n new SimpleMDE({\\n element: document.getElementById(\\\"demo3\\\"),\\n status: false,\\n toolbar: false,\\n });\\n </script> OK \\n\\n> cr cr cr js> $(\\\"body\\\")[0] ce! ce 6 ce@ :> outerHTML .\\n[object HTMLScriptElement] innerHTML= (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r...\\n 0 : [object Text] (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=...\\n<script>\\n (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){\\n (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),\\n m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)\\n })(window,document,'script','//www.google-analytics.com/analytics.js','ga');\\n \\n ga('create', 'UA-5808021-18', 'auto');\\n ga('send', 'pageview');\\n \\n </script> OK \\n\\n\\n-----------------------\\n[!] Try 3htm with localhost , the Error is : \\\"require is not defined\\\"\\n (1) Run local host : webserver.bat\\n (2) Run jeforth.3htm through http://localhost:8888 or http://localhost:8888/index.html \\n (3) Run \\n <h>\\n <link rel=\\\"stylesheet\\\" href=\\\"http://localhost:8888/src/css/simplemde.css\\\">\\n <script src=\\\"http://localhost:8888/src/js/simplemde.js\\\"></script>\\n </h>\\n ---> JavaScript error on word \\\"doElement\\\" : require is not defined\\n[!] jeforth.3ce can not do this: (Due to Content Security Policy violation)\\n <h>\\n < link rel=\\\"stylesheet\\\" href=\\\"http://localhost:8888/src/css/simplemde.css\\\">\\n < script src=\\\"http://localhost:8888/src/js/simplemde.js\\\"></script>\\n </h>\\n \\\\s\\n jquery-1.11.2.js:9831 Refused to load the script \\n 'http://localhost:8888/src/js/simplemde.js?_=1462251960943' \\n because it violates the following Content Security Policy directive: \\n \\\"script-src 'self' 'unsafe-eval'\\\".\\n \\\\s\\n \\\\ webserver.bat cd root at c:\\\\program files\\\\nodejs\\\\node_modules\\\\simplemde\\n char http://localhost:8888/src/js/simplemde.js readTextFile . \\\\ ==> works fine\\n[!] Try super chrome \\n --> worse then jeforth.3htm through http://localhost:8888 \\n[x] Trying to include but failed.\\n char ../simplemde-markdown-editor/src/css/simplemde.css readTextFile .\\n char ../simplemde-markdown-editor/src/js/simplemde.js readTextFile .\\n <h>\\n < link rel=\\\"stylesheet\\\" href=\\\"../simplemde-markdown-editor/src/css/simplemde.css\\\">\\n < script src=\\\"../simplemde-markdown-editor/src/js/simplemde.js\\\"></script>\\n </h>\\n --> (on 3HTA) 'require' not defined ==> So, try 3nw !!\\n --> and JavaScript error on word \\\"doElement\\\" : 發生錯誤,無法完成操作 80020101。\\n --> try 3nw, but: JavaScript error on word \\\"doElement\\\" : Cannot find module 'codemirror'\\n --> So, let's, as homepage said, use npm install. I am using 3nw anyway.\\n --> See ^> 2016-05-03 00:07:17 error message\\n C:\\\\Users\\\\hcche\\\\Documents\\\\GitHub> npm install simplemde --save\\n Failed again, npm install wants to use 'git' but which is unknown unless in a \\n gitShell that I can open through GitHub I guess.\\n --> Yes! GitShell is better, on installating now, stop at load codemirror\\n seems working ... I thought it's dead but now continoued. Wow, what a huge\\n installation. ok!\\n [x] I run the install from C:\\\\Users\\\\hcche\\\\Documents\\\\GitHub> is not good.\\n The result is a 10MByte size of mudules! at \\n c:\\\\Users\\\\hcche\\\\Documents\\\\GitHub\\\\node_modules <-- all dated 5/3'16 which is today\\n I should move it to : \\\"c:\\\\Program Files\\\\nodejs\\\\node_modules\\\" <--- all done.\\n * Should run npm install at c:\\\\Program Files\\\\nodejs> ... <== wrong! still failed.\\n [x] (@ Home) 10M of modules installed. What's next? Ah! all the modules are for server side.\\n See examples on http://simplemde.com and think.\\n [x] (@ T550) * Should run npm install at c:\\\\Program Files\\\\nodejs> ... <== wrong! still failed.\\n c:\\\\Program Files\\\\nodejs and sub-directories are not write-able, I guess. Because\\n tried to do the install at ~\\\\downloads\\\\simplemde then OK! See ^> 2016-05-03 09:28:01\\n [x] Holyshit! Totally different result from ^> 2016-05-03 09:28:01 !!!\\n 我想要把所有的 node_modules 都集中到 c:\\\\Program Files\\\\nodejs\\\\node_modules\\\\ 也是錯誤觀念。\\n SimpleMDE 的 node_modules 就放在自己個別的目錄下。\\n[x] I should reinstall Node.js and NW.js at home? Because installing SimpleMDE has totally\\n messed up the node_modules folder.\\n --> ok at home. \\n[x] @ T550 after installed SimpleMDE by npm, Also have made NODE_PATH env correctly points\\n to c:\\\\Program Files\\\\nodejs\\\\node_modules run 3nw.bat and try . . . \\n s\\\" c:\\\\Program Files\\\\nodejs\\\\node_modules\\\\simplemde\\\\src\\\\css\\\\simplemde.css\\\" readTextFile .\\n s\\\" c:\\\\Program Files\\\\nodejs\\\\node_modules\\\\simplemde\\\\src\\\\js\\\\simplemde.js\\\" readTextFile .\\n <h>\\n < link rel=\\\"stylesheet\\\" href=\\\"c:/Program Files/nodejs/node_modules/simplemde/src/css/simplemde.css\\\">\\n < script src=\\\"c:/Program Files/nodejs/node_modules/simplemde/src/js/simplemde.js\\\"></script>\\n </h>\\n --> Now I realized that dealing with npm is needed for Web Server side only\\n[x] (@ 3nw) require('codemirror') not found, add %NODEJSHOME%\\\\node_modules\\\\simplemde\\\\node_modules\\n to NODE_PATH as below can resolve this.\\n ---- 3nw.bat ----\\n if a%COMPUTERNAME%==aWKS-38EN3476 set NODEJSHOME=C:\\\\Program Files\\\\nodejs\\n if a%COMPUTERNAME%==aWKS-4AEN0404 set NODEJSHOME=C:\\\\Program Files\\\\nodejs\\n set NODE_PATH=%NODEJSHOME%\\\\node_modules;%NODEJSHOME%\\\\node_modules\\\\simplemde\\\\node_modules\\n start nw ../jeforth.3we %1 %2 %3 %4 %5 %6 %7 %8 %9\\n -----------------\\n[x] (@ 3nw) But after resolved require('codemirror') not found, new problem appear: \\n JavaScript error on word \\\"doElement\\\" : navigator is not defined\\n --> js> navigator \\\\ ==> [object Navigator] (object) 明明 3nw 有啊!\\n js> window.navigator \\\\ ==> [object Navigator] (object) \\n --> 從 simplemde.js 裡查出是 require(\\\"codemirror\\\") 出錯\\n console.log(111);debugger; // @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\\n var CodeMirror = require(\\\"codemirror\\\");\\n console.log(222);debugger; // @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\\n --> Only server side needs to deal with npm things.\\n[x] (@ 3htm localhost ) 算了, 直接用 BootCDN include 看看: <---- Yes, correct way!! I don't \\n need to deal with server side issues.\\n <h>\\n < link href=\\\"http://cdn.bootcss.com/simplemde/1.10.0/simplemde.min.css\\\" rel=\\\"stylesheet\\\">\\n < script src=\\\"http://cdn.bootcss.com/simplemde/1.10.0/simplemde.min.js\\\"></script>\\n </h>\\n --> cls <js> typeof SimpleMDE </jsV> \\\\ ==> function (string)\\n It works !! \\n --> So, how about 3hta 不成功. 3htm on localhost and 3nw works with the below method.\\n[x] 3htm on localhost installed ok, so go on using it . . . \\n See http://simplemde.com --> Bingo!! it works now. But appearance has something wrong\\n that needs fine tuning.\\n\\n\\\\ 以下 3htm 3nw OK, 3hta 有掛上 simplemde 但是沒有效果。\\n\\\\ Include SimpleMDE\\n\\n <h>\\n < link href=\\\"http://cdn.bootcss.com/simplemde/1.10.0/simplemde.min.css\\\" rel=\\\"stylesheet\\\">\\n < script src=\\\"http://cdn.bootcss.com/simplemde/1.10.0/simplemde.min.js\\\"></script>\\n </h> drop\\n js> typeof(SimpleMDE) tib. \\\\ ==> function (string) so it has been installed\\n\\n\\\\ Create a textarea\\n\\n cls <o> <textarea id=simplemde ></textarea></o> js> outputbox insertBefore\\n\\n\\\\ Launch SimpleMDE on the above textarea\\n\\n <js> \\n var simplemde = new SimpleMDE({element: document.getElementById(\\\"simplemde\\\")}); \\n simplemde \\n </jsV> \\n constant simplemde\\n\\n\\\\ Test, set the content\\n\\n simplemde <js> pop().value(\\\"This text will appear in the editor\\\"); </js>\\n\\n\\\\ Test, get the content\\n\\n simplemde :> value() \\\\ ==> # This text will appear in the editor (string)\\n\\n[x] 不要用 bootCDN 改用別家的試試看... Same problem, see <^2016-05-04 11:57:32\\n\\nstop\\njs> vm.appname==\\\"jeforth.3hta\\\" [if] char js/numeric-1.2.6.js\\n[else] char http://www.numericjs.com/lib/numeric-1.2.6.js [then]\\nreadTextFile \\\\ 先讀取 .js 檔, 但不能直接用\\n<text> \\nwindow.numeric = numeric; // 先對 source 做一點必要的加工, 把 numeric 掛上 global \\n</text> + </js> \\\\ 然後才執行\\t\\n-------------\\n2016-05-03 00:07:17 error message\\n\\t\\tc:\\\\Users\\\\hcche\\\\Documents\\\\GitHub\\\\jeforth.3we>npm install simplemde --save\\n\\t\\tnpm ERR! git clone --template=C:\\\\Users\\\\hcche\\\\AppData\\\\Roaming\\\\npm-cache\\\\_git-remotes\\\\_templates ...\\n\\t\\tc:\\\\Users\\\\hcche\\\\Documents\\\\GitHub\\\\jeforth.3we>git\\n\\t\\t'git' 不是內部或外部命令、可執行的程式或批次檔。\\n\\n^^^^^ 2016-05-03 09:28:01 ^^^^^^^^^^^\\nC:\\\\users\\\\hcche\\\\Downloads> cd .\\\\simplemde\\nC:\\\\users\\\\hcche\\\\Downloads\\\\simplemde> npm install simplemde --save\\nnpm WARN deprecated gulp-minify-css@1.2.4: Please use gulp-clean-css\\nnpm WARN deprecated graceful-fs@3.0.8: graceful-fs v3.0.0 and before will fail on node releases >= v6.0. Please update to graceful-fs@^4.0.0 as soon as possible. Use 'npm ls graceful-fs' to find it in the tree.\\nnpm WARN deprecated lodash@1.0.2: lodash@<3.0.0 is no longer maintained. Upgrade to lodash@^4.0.0.\\nnpm WARN deprecated graceful-fs@1.2.3: graceful-fs v3.0.0 and before will fail on node releases >= v6.0. Please update to graceful-fs@^4.0.0 as soon as possible. Use 'npm ls graceful-fs' to find it in the tree.\\nsimplemde@1.10.1 node_modules\\\\simplemde\\n├── marked@0.3.5\\n├── codemirror@5.14.3\\n└── codemirror-spell-checker@1.0.6 (gulp-minify-css@1.2.4, gulp-header@1.7.1, gulp-concat@2.6.0, gulp-uglify@1.5.3, gulp@3.9.1)\\nC:\\\\users\\\\hcche\\\\Downloads\\\\simplemde>\\n\\nNote! The result is totally different to what happened last night at home.\\nSee Ynote \\\"SimpleMDE Install\\\" for pictures of the correct results.\\n\\n-------------------\\n\\n \\n\\n \",\"mode\":true,\"readonly\":false}","Play flot on 3nw":"{\"doc\":\"\\n \\\\ Flot.js demo GitHub\\\\flot\\\\examples\\\\basic-usage\\\\index.html\\n\\n \\\\ Prepare the Flot ploting zone\\n\\n ' flotzone [if] [else] \\n <o> <div class=flotzone></div></o> constant flotzone // ( -- DIV ) Place for Flot plotings avoid CSS conflict.\\n flotzone js> $(\\\".console3we\\\")[0] insertBefore\\n [then]\\n\\n \\\\ Include CSS and Flot.js\\n \\n js> typeof($.plot)!=\\\"function\\\" [if] \\n <h> \\n <--!link id=flotcss href=\\\"../flot/examples/examples.css\\\" rel=\\\"stylesheet\\\" type=\\\"text/css\\\"-->\\n <script id=flotjs language=\\\"javascript\\\" type=\\\"text/javascript\\\" src=\\\"../flot/jquery.flot.js\\\"></script>\\n </h> drop\\n\\n \\\\ Wait a while, make sure Flot.js is ready\\n .( $.plot readiness check .)\\n ( seconds * 1000 / nap ) js> 60*1000/200 [for] \\n js> typeof($.plot)==\\\"function\\\" [if] \\n r> drop 0 >r \\\\ break the loop\\n [else] \\n 200 nap .\\\" .\\\" \\\\ wait a while\\n [then] \\n [next] cr\\n [then]\\n \\n \\\\ Demo #1\\n \\\\ Create the placeholder\\n\\n flotzone\\n <o> <div id=\\\"placeholder1\\\" style=\\\"width:600px;height:300px\\\"></div></o> ( placeholer1 )\\n appendChild\\n\\n \\\\ Plot a line \\n \\n js: $.plot($(\\\"#placeholder1\\\"),[[[0,0],[1,1]]],{yaxis:{max:1}})\\n\\n \\\\ Demo #2\\n \\\\ Create the placeholder\\n\\n flotzone\\n <o> <div id=\\\"placeholder2\\\" style=\\\"width:600px;height:300px\\\"></div></o> ( placeholer2 )\\n appendChild\\n\\n \\\\ Plot some lines\\n \\n <js>\\n $(function() {\\n\\n var d1 = [];\\n for (var i = 0; i < 14; i += 0.5) {\\n d1.push([i, Math.sin(i)]);\\n }\\n\\n var d2 = [[0, 3], [4, 8], [8, 5], [9, 13]];\\n\\n // A null signifies separate line segments\\n\\n var d3 = [[0, 12], [7, 12], null, [7, 2.5], [12, 2.5]];\\n\\n $.plot(\\\"#placeholder2\\\", [ d1, d2, d3 ]);\\n\\n // Add the Flot version string to the footer\\n\\n $(\\\"#footer\\\").prepend(\\\"Flot \\\" + $.plot.version + \\\" – \\\");\\n });\\n </js>\\n<comment>\\n[ ] flotzone 目前必須放在 .console3we 之外才行, 希望能放在 outputbox 裡面, 做實驗方便。\\n[/] How to clear inherited CSS style for the flotzone element?\\n See 3hta local storage field \\\"Study remove CSS style for an element\\\"\\n --> 不成功, 用 Yahoo CSS reset 也不行。 甚至把 jeforth.3we 本身的 common.css 取消了也不行。\\n[x] 在 outputbox 裡一片白的 flotzone 經 insertBefore 到 .console3we 之上, 還是一片白。\\n[x] 那反過來呢? **在外成功之後** 搬進來如何? --> still failed. But then move out will be ok!\\n flotzone js> inputbox insertBefore \\\\ failed\\n flotzone js> header insertBefore \\\\ ok\\n js> body flotzone appendChild \\\\ ok 只要搬出 .console3we 都 ok\\n\\n[ ] 研究如何 dump 整個 style of an element 來查看\\n js> header.style obj>keys .\\n js> $(\\\".console3we\\\")[0].style obj>keys .\\n\\n[ ] 用 xjeforth.hta <--- 改過, 試試看到底為何 進 console3we 就不行\\n --> 上面說本來不行的搬出去也不行, 現在用 xjeforth.hta, 可能是因為經過簡化, 本來在 outputbox 裡不行的\\n 變成搬出去就可以了。\\n --> 繼續簡化...把 inputbox, outputbox 搬出 .console3we 之外, 終於可以成功地把 flot charts 放進\\n outputbox 了!\\n[ ] Flot.js 於 style.background 有細微的問題。我報了 bug on Flot.js GitHub Issue : \\n https://github.com/flot/flot/issues/1497\\n Or refer to YNote: \\\"Flot bug of graph disappear reproduced. How to fix it\\\"\\n 試圖研究在用到 flot.js 時把 .console3we 的 style 重新定義, 例如把 background 去掉, 就\\n 可以在 outputbox 裡正常運作了。\\n flotzone js> outputbox insertBefore \\\\ 搬到 outputbox 之前仍在 .console3we 裡複製出問題.\\n 查看 style tags 找到 console3we 的 background\\n 把它改成 transparent 試試看.\\n[x] > js> $(\\\"style\\\").length . \\\\ ==> 4 OK \\n 這 4 個裡面不含 common.css 的定義! 所以我以前就說 inputbox 要變粉紅色得分開弄一個 style 原因\\n 可能就是這個。 \\n\\n > js> $(\\\"style\\\")[0].outerHTML .\\n <style type=\\\"text/css\\\">canvas{border:solid 1px #CCC}</style> OK \\n\\n > js> $(\\\"style\\\")[1].outerHTML .\\n <style>\\n .tr table, .tr td { \\n border:0.075em solid gray; \\n }\\n </style> OK \\n\\n > js> $(\\\"style\\\")[2].outerHTML .\\n <style id=\\\"styleTextareaFocus\\\" type=\\\"text/css\\\"> \\n .console3we textarea:focus {\\n background:#E0E0E0;\\n }\\n </style> OK \\n\\n > js> $(\\\"style\\\")[3].outerHTML .\\n <style type=\\\"text/css\\\">\\n .eb .box { width:90%; }\\n .eb .box, .eb .ebhtmlarea { border:1px solid black; }\\n .eb p { display:inline; } \\n .eb .ebname { font-size: 1.1em; }\\n </style> OK \\n\\n[ ] 蓋過去行不行?\\n js> $(\\\".console3we\\\").length .\\n\\n\\n</comment>\",\"mode\":true,\"readonly\":false}","Study XMLHttpRequest object 2016-07-06":"{\"doc\":\"[ ] Study how to *write* files to local disk on super-chrome jeforth.3htm\\n --> 先前有找到過一個例子, 可以把網頁上的 pictures drag-drop 一下就 save 成 local file\\n Ynote: \\\"jeforth 研究 Chrome extension 存檔到本地 disk 的方法\\\" the thing is \\\"XMLHttpRequest\\\" \\n --> Study XMLHttpRequest @ http://www.w3school.com.cn/xml/xml_http.asp\\n<js> var x =new XMLHttpRequest(); x </jsV> constant xmlhttp // ( -- obj ) XMLHttpRequest object\\nxmlhttp :: open(\\\"GET\\\",\\\"a.html\\\",true)\\nxmlhttp :: send(null)\\ntry on 3hta ... error : access denied\\ntry on jeforth.3nw --> it works! \\n\\n\\nStudy XMLHttpRequest object \\nhttp://www.w3school.com.cn/xml/xml_http.asp\\n\\n> <js> var x =new XMLHttpRequest(); x </jsV> constant xmlhttp // ( -- obj ) XMLHttpRequest object\\n> xmlhttp . ==> [object XMLHttpRequest] \\\\ this is how it looks like\\n> xmlhttp :: open(\\\"GET\\\",\\\"a.html\\\",true) \\\\ try to read something from the server, a.html is not existing.\\n> xmlhttp :: send(null) \\\\ arm the instruction.\\n> xmlhttp :> readyState . ==> 4 \\\\ 4 is \\\"loaded\\\" or \\\"complete\\\"\\n> xmlhttp :> status \\\\ ==> 0 (number) \\\\ 0 is \\\"uninitialized\\\", a.html is not existing remember?\\n\\n\\\\ Try again\\n> xmlhttp :: open(\\\"GET\\\",\\\"index.html\\\",true) \\\\ now index.html is jeforth.3htm's main page\\n \\\\ the 3'rd argument Async = True 表示脚本会在 send() 方法之后继续执行,而不等待来自服务器的响应。\\n> xmlhttp :: send(null)\\n\\n\\\\ 照理說這時候要等 event xmlhttp.onreadystatechange=state_Change_event_handler; \\\\ or false if event not used\\n\\n> xmlhttp :> readyState \\\\ ==> 4 OK \\n> xmlhttp :> status \\\\ ==> 200 (number) \\\\ Bingo!! 200 is OK\\n> xmlhttp :> statusText \\\\ ==> OK (string)\\n> xmlhttp :> responseText \\\\ ==> 真的把檔案讀進來了!! Bingo !! 3nw, 3htm (super_chrome and webserver).\\n <!DOCTYPE html>\\n <html>\\n <head id=head>\\n <title class=appname>appname \\n \\n \\n \\n\\n\\\\ 3htm/f/readtextfile.f 裡面用的是 $.get 裡面可能就是用 XMLHttpRequest.\\n\\n> xmlhttp :: open(\\\"POST\\\",\\\"222\\\",false) \\\\ 沒有 error \\n> xmlhttp :: send(\\\"1234bsdfsd\\\") \\\\ 沒有 error 但也沒效果\\n\\n\\\\ 以上 post 無效是 3nw, 3htm(super_chrome) \\n\\\\ --> 改用 3htm + webserver.f 試試看 -- same result :-(\\n\\\\ 我不瞭解 POST command 的真正意義。Server 端應該要有人把收到的 data 存成檔案。\\n\\n[ ] Server 端應該要有人把收到的 data 存成檔案。這就有點麻煩了, 還不如直接用 3nw。\\n 我以前研究過 Web server 端的程式 on 3nd, it's time to review.\\n\",\"mode\":true,\"readonly\":false}","Style for 3nw":"{\"doc\":\"

Style for 3nw

drop\\n js: outputbox.style.fontSize=\\\"1.5em\\\"\\n js: inputbox.style.fontSize=\\\"1.5em\\\"\\n editbox-style \\n .eb .box { width:90%; font-size:1.1em; /* filename */ } \\n .eb .box, .eb .ebhtmlarea { border:1px solid black; }\\n .eb .ebtextarea { font-size:1.2em }\\n .eb input { font-size:0.7em /* buttons */ }\\n .eb p { display:inline; }\\n .eb .ebname { font-size: 1em; } /* field name */\\n js: $(\\\"#ebstyle\\\")[0].innerHTML=pop() \\\\ 直接修改 ebstyle \\ncr\\n\",\"mode\":true,\"readonly\":false}","ad":"{\"doc\":\"\\n\\\\ Remove all annoying floating ad boxes. 刪除所有惱人的廣告框。\\nactive-tab :> id tabid! \\nvar divs = document.getElementsByTagName(\\\"div\\\");\\nfor (var i=divs.length-1; i>=0; i--){\\n if(divs[i].style.position){\\n divs[i].parentNode.removeChild(divs[i]);\\n }\\n}\\nfor (var i=divs.length-1; i>=0; i--){\\n if(parseInt(divs[i].style.width)<600){ // <---- 任意修改\\n divs[i].parentNode.removeChild(divs[i]);\\n }\\n}\\n\\n\",\"readonly\":true,\"mode\":true}","autoexec":"{\"doc\":\"\\njs: outputbox.style.fontSize=\\\"1.5em\\\"\\njs: inputbox.style.fontSize=\\\"1.5em\\\"\\n\",\"mode\":true,\"readonly\":false}","log of 3nw":"{\"doc\":\"[x] file input 若被 user cancel 則 sleep 得不到 stopsleeping 在那裏苦等 <--- problem!\\n> constant ff\\n> ff :> value . \\\\ ==> OK it's null string by default\\n> ff :> value . \\\\ after picking a file, it becomes a pathname\\nC:\\\\Users\\\\hcche\\\\Documents\\\\GitHub\\\\chrome-app-samples\\\\tryitnowbutton_small.png OK \\n> ff :> value . \\\\ try again but click cancel, it becomes a null string as anticipated, good!\\n> \\\\ click [cancel] clears ff.value <--- good!!\\n> ff :: onchange=function(){alert(\\\"onchange\\\")} \\\\ Add event handler, it works!\\n> \\\\ click [cancel] does not fire onchange() event unless due to the above reason that has actually been changed.\\n> ff :: oncancel=function(){alert(\\\"onCancel\\\")} <--- click [cancel] does not fire this event at all. But onchange() event got fired sometimes.\\n> ff :: onchange=function(){alert(\\\"onBigChange\\\")} \\\\ Handler can be changed and it works fine.\\n> ff :> oncancel . \\\\ ==> function (){alert(\\\"onCancel\\\")} OK check, it's there\\n> ff :> onchange . \\\\ ==> function (){alert(\\\"onBigChange\\\")} check, it's there\\n> \\\\ ff :: onabort=function(){alert(\\\"onAbort\\\")} \\\\ ==> Click cancel does not fire this either.\\n> \\\\ ff :> onabort . \\\\ ==> ff :: onabort=function(){alert(\\\"onAbort\\\")}\\n> \\\\ No, click [cancel] does not fire onabort() \\n\\n\\\\ 企圖故意製造 onchange 100% 發生的努力, 失敗了:\\n> ff :> value=\\\"dummy\\\" <--- Not allowed, see err message:\\nJavaScript error : Failed to set the 'value' property on 'HTMLInputElement': \\nThis input element accepts a filename, which may only be programmatically set \\nto the empty string.\\n\\n\\\\ 機會 : 每個 file input 都是新的, 用完馬上 remove 掉, 有機會讓所有的 cancel 都 fire \\n\\\\ onchange() event? --> 一上來馬上 cancel 因為 file.value 都是 null string 沒有變故\\n\\\\ 不會 fire onchange() event. --> 試試為 file.value 給訂初值 --> No way, see:\\n\\\\ 为安全起见,file-upload 元素不允许 HTML 作者或 JavaScript 程序员指定一个默认的文件名。\\n\\nff :> defaultValue \\\\ ==> null string.\\n constant fff\\nff :: onbeforedeactivate=function(){alert(\\\"beforeDeActivate\\\")} \\\\ <== fire when blur, 不適合.\\n\\nff :: onblur=function(){alert(\\\"onblur\\\")} <-- fired when both clicking [瀏覽] and \\nclick desk top but not clicking [cancel], shit!!!\\n\\n[x] 解決了! 3nw 會 fire oncancel() when [cancel] clicked!! Bingo!!\\nff :: onemptied=function(){type(\\\"onemptied\\\")}\\nff :: onended=function(){type(\\\"onended\\\")}\\nff :: onerror=function(){type(\\\"onerror\\\")}\\nff :: onerrorupdate=function(){type(\\\"onerrorupdate\\\")}\\nff :: onfilterchange=function(){type(\\\"onfilterchange\\\")}\\nff :: onfocus=function(){type(\\\"onfocus\\\")}\\nff :: onfocusin=function(){type(\\\"onfocusin\\\")}\\nff :: onfocusout=function(){type(\\\"onfocusout\\\")}\\nff :: onhelp=function(){type(\\\"onhelp\\\")}\\nff :: oninput=function(){type(\\\"oninput\\\")}\\nff :: onchange=function(){type(\\\"onChange\\\")}\\nff :: oncancel=function(){type(\\\"oncancel\\\")}\\n\\n3hta\\nonfocusin onfocus onfocusout \\nonfocusin onfocus onfocusout\\n\\n3nw\\nonfocus \\nonfocus oncancel\\nonfocus \\nonfocus oncancel\\n\\n[x] Answer to stackoverflow with my finding of oncancel() works!\\n http://stackoverflow.com/questions/10127492/capturing-cancel-event-on-input-type-file\\n\\n I have the same question, the solution is surprisingly very \\n easy ... at least in my case NW.js (Node-Webkit) fires oncancel \\n event if user click the [cancel] button in the file chooser \\n dialogue. You use this simple and native way if you're also on \\n NW.js (process.version is v5.11.0).\\n\\n I also tried Microsoft HTA on Windows 10, it does not fire the \\n oncancel event.\\n\\n' --- [if] --- [then] marker --- \\n\\n \\n \\n\\n\\n\\nThe above sample code, modified for jeforth, from \\nhttp://stackoverflow.com/questions/29705135/node-webkit-read-full-path-of-files-from-directory\\nworks fine, very well. No problem at all getting the full pathname on 3nw, but not on 3ce. So, \\nNW.js is really provides super power.\\n\\n\\\\ Works fine on 3nw,\\n> js> $(\\\"#fileDialog\\\").length \\\\ ==> 1 OK \\n> js> $(\\\"#fileDialog\\\")[0].value . \\\\ ==> C:\\\\Users\\\\hcche\\\\Downloads\\\\download OK \\n> js> document.getElementById(\\\"fileDialog\\\") . \\\\ ==> [object HTMLInputElement] OK \\n> js> document.getElementById(\\\"fileDialog\\\").value . \\\\ ==> C:\\\\Users\\\\hcche\\\\Downloads\\\\download OK \\n> pickFile \\n> .s\\n 0: (string) \\\\ <--- My original pickFile does not work on 3nw. Needs debug.\\n\\n\\\\ On jeforth.3ce, failed as anticipated\\n\\n > js> document.getElementById(\\\"fileDialog\\\").value .\\n C:\\\\fakepath\\\\__865.jpg OK <---- \\\"fakepath\\\" as anticipated.\\n\\n\\\\ Works fine on 3HTA.\\n\\n > js> document.getElementById(\\\"fileDialog\\\").value .\\n C:\\\\Users\\\\hcche\\\\Downloads\\\\魏月梅 全民健保核退申請書.PDF OK \\n\\n\\\\ So, pickFile can be improved by this solution from Stackoverflow.\\n\\n: pickFile ( -- \\\"pathname\\\" ) \\\\ Pick a file through web browser's GUI\\nchar input createElement ( element )\\ndup char type char file setAttribute ( element )\\ndup char id char pickfile setAttribute ( element )\\neleBody over appendChild \\\\ 要 append 才有作用。\\n( element ) js> tos().click();tos().value ( element pathname ) ;\\n\\n\\\\ 照上面這個 pickFile 實驗, 還是不行。確定傳回的 pathname 是個 \\\"\\\". 然而手動觀察 element.value 卻是\\n\\\\ 正確的 pathname. [x] 猜想, 最後一行手動看應該會是 expected pathname 無誤。\\n\\n> .s \\n 0: [object HTMLInputElement] (object) \\\\ backup\\n 1: C:\\\\Users\\\\hcche\\\\Downloads\\\\jeforth.3ce.p4.jpg (string)\\n 2: [object HTMLInputElement] (object) \\\\ to be removed\\n> removeElement\\n> js> tos(1).value . \\\\ 查看 element 的 value \\nC:\\\\Users\\\\hcche\\\\Downloads\\\\jeforth.3ce.p4.jpg OK \\\\ 竟然是對的。此時 element id 確定已經不存在了。\\n\\n\\n[x] 嘗試手動作最後一行\\n: pickFile ( -- \\\"pathname\\\" ) \\\\ Pick a file through web browser's GUI\\nchar input createElement ( element )\\ndup char type char file setAttribute ( element )\\ndup char id char pickfile setAttribute ( element )\\neleBody over appendChild \\\\ 要 append 才有作用。\\n; \\n\\n\\\\ 果然, 這行一起做, 傳回 \\\"\\\"\\n( element ) js> tos().click();tos().value ( element pathname ) ;\\n\\n\\\\ 手動分開做, 就 OK 了!!\\n( element ) js: tos().click()\\njs> tos().value ( element pathname ) ;\\n\\n[x] click() 之後, 加上一點 nap 看看, --> \\n\\n: pickFile ( -- \\\"pathname\\\" ) \\\\ Pick a file through web browser's GUI\\nchar input createElement ( element )\\ndup char type char file setAttribute ( element )\\ndup char class char pick_file setAttribute ( element )\\njs> body over appendChild \\\\ 要 append 才有作用。\\njs: tos().click() ( element ) \\\\ 回來就表示 user 已經完成操作\\n( seconds * 1000 / nap ) js> 60*1000/200 for ( element ) \\n\\tjs> tos().value if \\n\\t\\tr> drop 0 >r \\\\ break the loop\\n\\telse \\n\\t\\t200 nap .\\\" .\\\" \\\\ wait a while\\n\\tthen \\nnext ( element ) \\njs> tos().value \\\\ 即使 timeout 也不管了 ( element path ) \\nswap removeElement ; ( path ) \\n\\n\\\\ Ultimate version\\n\\n: pickFile ( -- \\\"pathname\\\" ) \\\\ Pick a file through web browser's GUI\\n\\tchar input createElement ( element )\\n\\tdup char type char file setAttribute ( element )\\n\\tdup char class char pick_file setAttribute ( element ) \\\\ for debug, clue of the element\\n\\tjs: tos().onchange=function(){execute('stopSleeping')} ( element )\\n\\tjs> body over appendChild \\\\ 要 append 才有作用。 ( element )\\n js: tos().click() ( element ) \\\\ @ HTA 回來就表示 user 已經完成操作, @ NW.js 則馬上回來。\\n\\t( minutes*60*1000 ) js> 5*60*1000 sleep ( element )\\n\\tjs> tos().value \\\\ 即使 timeout 也不管了 ( element path ) \\n\\tswap removeElement ; ( path ) \\n\\n: pickFile \\t\\t( -- \\\"pathname\\\" ) \\\\ Pick a file through web browser's GUI\\nchar input createElement ( element )\\ndup char type char file setAttribute ( element )\\ndup char class char pick_file setAttribute ( element ) \\\\ for debug, clue of the element\\n\\\\ For none 3hta only, setup the event handler\\njs> vm.appname!=\\\"jeforth.3hta\\\" if\\n\\tjs: tos().onchange=function(){execute('stopSleeping')} ( element ) then\\njs> body over appendChild \\\\ 要 append 才有作用。 ( element )\\njs: tos().click() ( element ) \\\\ @ HTA 回來就表示 user 已經完成操作, @ NW.js 則馬上回來。\\n\\\\ For none 3hta only, wait for the onchange event\\njs> vm.appname!=\\\"jeforth.3hta\\\" if\\n\\t( minutes*60*1000 ) js> 5*60*1000 sleep ( element ) then\\njs> tos().value \\\\ 即使 timeout 也不管了 ( element path ) \\nswap removeElement ; ( path ) \\n/// Works fine on 3hta and 3nw. The dialog works but returns Null string on 3htm \\n/// or C:\\\\fakepath\\\\__865.jpg on 3ce.\\n/// Through excel app's GetOpenFilename method can do the same thing:\\n/// excel.app js> pop().GETopenFILENAME <== with or w/o () both fine\\n/// Excel's GetSaveAsFilename method too.\\n\\n\\n\\n\\n[x] 3nw's js: storage.save(pathname) and js: storage.restore(pathname) work fine now.\\n[/] How about 3hta? <--- 3hta works fine already, forget it.\\n[x] 3nw should auto save and restore local storage. restore when start up, save when\\n any field is saved. So I don't need corresponding words for them.\\n\",\"mode\":true,\"readonly\":false}","node.js HTTP server":"{\"doc\":\"\\n\\\\ ~@~@~@~@~@~@~@~@~ Build Your First HTTP Server in Node.js ~@~@~@~@~@~@~@~@~\\n\\\\\\n\\\\ https://www.diigo.com/user/hcchen/b/373115646\\n\\\\ jeforth.3nw localsotrage field \\\"node.js HTTP server\\\"\\n\\\\ ~\\\\jeforth.3we\\\\3nd\\\\build_your_http_server.f \\n\\\\\\n\\n\\\\ Lets require/import the HTTP module and choose a port to listen\\n js> require('http') constant http // ( -- HTTP-object ) Get node.js http module\\n\\n\\\\ Lets define a port we want to listen to\\n 8080 constant PORT // ( -- port# ) Port number HTTP server listen to\\n\\n\\\\ We need a function which handles requests and send response\\n \\n \\n var f = function handleRequest(request, response){\\n response.end('It Works!! Path Hit: ' + request.url);\\n };f\\n constant handleRequest // ( -- func ) Request handler\\n \\n\\n\\\\ Callback triggered when server is successfully listening. Hurray!\\n \\n var f = function callback(){\\n type(\\\"Server listening on: http://localhost:\\\"+vm[context].PORT);\\n }; f\\n constant server-callback // ( -- func ) Call back function of the HTTP server\\n\\n\\\\ Create a server\\n http :> createServer(vm[context].handleRequest)\\n constant server // ( -- obj ) HTTP server object\\n\\n\\\\ Lets start our server\\n server :> listen(vm[context].PORT,vm[context][\\\"server-callback\\\"])\\n\\n\\\\ Your server should respond differently to different URL \\n\\\\ paths. This means we need a dispatcher. Dispatcher is kind \\n\\\\ of router which helps in calling the desired request handler \\n\\\\ code for each particular URL path. Now lets add a dispatcher \\n\\\\ to our program. First we will install a dispatcher module, \\n\\\\ in our case httpdispatcher. There are many modules available \\n\\\\ but lets install a basic one for demo purposes\\n\\n js> require('httpdispatcher') constant dispatcher // ( -- obj ) HTTP dispatcher\\n\\n\\n//Lets use our dispatcher\\nfunction handleRequest(request, response){\\n try {\\n //log the request on console\\n console.log(request.url);\\n //Disptach\\n dispatcher.dispatch(request, response);\\n } catch(err) {\\n console.log(err);\\n }\\n}\",\"mode\":true,\"readonly\":false}","pruning":"{\"doc\":\"\\n\\\\ Make the target page editable for pruning. 把 target page 搞成 editable 以便修剪。\\nactive-tab :> id tabid! document.getElementsByTagName(\\\"body\\\")[0].contentEditable=true \\n\",\"readonly\":true,\"mode\":true}","smde_MyUniqueID":"j e f o r t h . 3 w e\n==============\n**Forth** is the simplest programming language ever. The jeforth.**3we** project is an implementation based on a **3 Words Engine** from [project-k](http://github.com/hcchengithub/project-k) for many applications: *HTA (jeforth.3hta)*, *HTML (jeforth.3htm)*, *Chrome Extension (jeforth.3ca)*, *Node.js (jeforth.3nd)*, *Node-webkit or NW.js (jeforth.3nw)*, and probably more in the future. All of them have been tested on Windows 8 or Windows 10.\n\nPlay now\n===========\nAmong the many applications, jeforth for web page (jeforth.3htm) can run on your web browser right now thus is good for demonstration. \n\n#### [Solar system](http://rawgit.com/hcchengithub/jeforth.3we/master/index.html?cls_include_solar-system.f)\n[簡介](http://note.youdao.com/yws/public/redirect/share?id=94764cf57ba4365e2997f4a268ff7716&type=false)
\n![enter image description here](https://github.com/hcchengithub/jeforth.3we/wiki/pictures/solar-system.png)\n\n#### [H2O](http://rawgit.com/hcchengithub/jeforth.3we/master/index.html?cls_include_h2o.f)\n![enter image description here](https://github.com/hcchengithub/jeforth.3we/wiki/pictures/h2o.png)\n\n#### [Alarm clock](http://rawgit.com/hcchengithub/jeforth.3we/master/index.html?cls_include_alarm.f_er)\n ![enter image description here](https://github.com/hcchengithub/jeforth.3we/wiki/pictures/demo-alarm.png)\n \n#### [Box2Dweb Physics Engine demo - Arrows](http://rawgit.com/hcchengithub/jeforth.3we/master/index.html?cls_include_box2dweb-arrow.f)\n![enter image description here](https://github.com/hcchengithub/jeforth.3we/wiki/pictures/demo-arrow.png)\n\n#### [Chipmunk Physics Engine demo - Pyramid Stack](http://rawgit.com/hcchengithub/jeforth.3we/master/index.html?cls_include_chipmunk-js-pyramidstack.f)\n![enter image description here](https://github.com/hcchengithub/jeforth.3we/wiki/pictures/demo-pyramidstack.png)\n\n\nWhat else can you do with jeforth.3we?\n=============\n\n#### [Markdown editor](http://note.youdao.com/yws/public/redirect/share?id=1a8a342f3a9c1e0622a6050480af28b7&type=false)\n\nNW.js can access files in your local computer and also have all abilities like the Chrome browser, that allows jeforth.3nw to include JavaScript modules from the Internet. For example, [SimpleMDE](https://simplemde.com) is a Markdown Editor that works fine on jeofrth.3nw. \n\n![enter image description here](https://github.com/hcchengithub/jeforth.3we/wiki/pictures/demo 3nw mde editor.JPG)\n\n\nGet source code, unzip, and start running\n=============\n\n| Item | Address |\n----------------|----------------------------------------------\n| jeforth.3we high level source code | *http://github.com/hcchengithub/jeforth.3we* |\n| Kernel, projectk.js 3-words-engine| *http://github.com/hcchengithub/project-k* |\n\n
\nClick the [Download ZIP] button of both projects [jeforth.3we](https://github.com/hcchengithub/jeforth.3we) and [project-k](https://github.com/hcchengithub/project-k) on their GitHub web page to get them. Unzip jeforth.3we first and then unzip project-k to under the jeforth.3we directory, as shown in the below directory listing. Then you can run 3hta.bat without installing anything else if your computer is Windows 8 or Windows 10; or run 3nd.bat and 3nw.bat, if you have installed node.js and nw.js.\n\nMy jeforth.3we/ directory listing for example,\n\n![jeforth3we-dir.png](https://github.com/hcchengithub/jeforth.3we/wiki/pictures/jeforth3we-dir.png)\n\n\n**Note:** Only for jeforth.3hta and only when you were **Download Zip** jeforth.3we from GitHub, It's necessary to use GNU tool [unix2dos](http://waterlan.home.xs4all.nl/dos2unix.html) to convert the new line characters of all text files [from Unix's LF to Windows' CRLF](https://en.wikipedia.org/wiki/Unix2dos). This is an example command line of the usage:\n\n d:\\jeforth.3we>for /R %G in (*.*) do d:\\bin\\unix2dos.exe \"%G\"\n\n
\n\nIf you were **git clone https://github.com/hcchengithub/jeforth.3we** instead of **Download Zip** then forget this step, GitHub shell for Windows already converts new line characters to CRLF correctly. \n\nPresentation videos\n======\n\n| No. | Mandarin | English |\n--------|----------|---------\n| 1 | [Opening](http://www.camdemy.com/media/19253)| n/a |\n| 2 | [Run the HTML version online](http://www.camdemy.com/media/19254)| n/a |\n| 3 | [Run the HTML version on local computer](http://www.camdemy.com/media/19255)| n/a |\n| 4 | [Run the HTA version](http://www.camdemy.com/media/19256)| n/a |\n| 5 | [Run Node.js and Node-Webkit version](http://www.camdemy.com/media/19257)| n/a |\n| 6 | [F2 inputbox edit mode](http://www.camdemy.com/media/19258)| n/a |\n| 7 | [F4 Copy marked string to inputbox](http://www.camdemy.com/media/19259)| n/a |\n| 8 | [F5 Restart](http://www.camdemy.com/media/19260)| n/a |\n| 9 | [Bigger/Smaller input box](http://www.camdemy.com/media/19261)| n/a |\n| 10 | [Esc clear input box](http://www.camdemy.com/media/19262)| n/a |\n| 11 | [Tab auto-complete](http://www.camdemy.com/media/19263)| n/a |\n| 12 | [Enter jump into the input box](http://www.camdemy.com/media/19264)| n/a |\n| 13 | [Up/Down recall command history](http://www.camdemy.com/media/19265)| n/a |\n| 14 | [Alt-Up Reuse used commands](http://www.camdemy.com/media/19266)| n/a |\n| 15 | [Crtl- / Ctrl+ Zoom in/ Zoom out](http://www.camdemy.com/media/19267)| n/a |\n| 16 | [Ctrl-Break stop all tasks](http://www.camdemy.com/media/19268)| n/a |\n| 17 | [BackSpace trims the output box](http://www.camdemy.com/media/19269)| n/a |\n| 18 | [Help is helpful](http://www.camdemy.com/media/19270)| n/a |\n| 19 | [jsc JavaScript Console](http://www.camdemy.com/media/19271)| n/a |\n\nWhat to play in further depth\n========================\nDownload and setup the jeforth.3we directory and project-k directory as mentioned above.\n\n#### **HTA** / jeforth.3hta\nDouble click the **jeforth.3we/jeforth.hta** or execute the below DOS command line in a DOS box,\n```\njeforth.hta cls .' Hello world' cr 3000 sleep bye\n```\n![3htahello-world.png](https://github.com/hcchengithub/jeforth.3we/wiki/pictures/3htahello-world.png)\n\nThe prior method runs self-test because there's no given task to do. The 2'nd method is expected to print 'Hello world' (as shown above) and return to DOS box after 3 seconds.\n\n\nNote! If you see the Windows error message : [\"Safety Settings on this computer prohibit accessing a data source on another domain\"](https://social.msdn.microsoft.com/Forums/en-US/becc982a-b693-49bb-8fb0-95847a3e96c7/hta-safety-settings-on-this-computer-prohibit-accessing-a-data-source-on-another-domain?forum=scripting) that I heard may happen on some Windows 7 computers. Sorry, [I have no solution yet](http://stackoverflow.com/questions/32177060/hta-safety-settings-on-this-computer-prohibit-accessing-a-data-source-on-anot), It didn't happen on those Windows 7 computers that I could reach. Please upgrade to Windows 8 or 10 to avoid from the problem.\n\n#### **Node.js** / jeforth.3nd\nMake sure you can run node.exe in a DOS box so you have setup the path. Make the jeforth.3we/ folder be your working directory. Execute one of the below demo command lines:\n```\nnode jeforth.3nd.js\nnode jeforth.3nd.js cls .' Hello world' cr bye\n```\nAgain, like the above HTA case, the prior command line does the self-test, and the 2'nd is expected to print 'Hello world'.\n\nWe have a local Web server written by jeforth.3nd itself. See jeforth.3we/Webserver.bat. Having a local Web server is necessary to run jeforth.3htm. \n\n#### **HTML** / jeforth.3htm\nSetup your local Web server by running jeforth.3we/Webserver.bat, \n\n![webserver.png](https://github.com/hcchengithub/jeforth.3we/wiki/pictures/webserver.png)\n\nthen try to visit below URLs:\n```\nhttp://localhost:8888\nhttp://localhost:8888/index.html\nhttp://localhost:8888/index.html? cr .\" hello world\" cr cr \nhttp://localhost:8888/index.html?_cr_.\"_hello_world\"_cr_cr \nhttp://localhost:8888/index.html? .\" 8-) \" 100 nap rewind\nhttp://localhost:8888/index.html?_.\"_8-)_\"_100_nap_rewind\n```\nI have tested IE10 , IE11 and Chrome. Firefox or other web browsers are not tested yet. As shown above, we can put any forth words in the URL. That will be the task jeforth.3htm will do after start up and the self-test will be skipped when having a task to do.\n\n#### **Node-webkit** / jeforth.3nw\nSetup your Node.js and Node-Webkit path in prior. Refer to 3nw.bat as an example. Make jeforth.3we/ be your working directory, run either one of below command lines:\n```\nnw ../jeforth.3we\nnw ../jeforth.3we cls .' Hello World' 3000 sleep bye\n```\nThe prior runs self-test because there's no given task to do. The 2'nd is expected to print 'Hello world' and return to DOS box after 3 seconds.\n\t\nCompile eforth.com\n--------------------------\n\nJeforth.3nd for Node.js can be a handy x86 CPU assembler (any other CPU too). We have an example to compile the legendary eforth.com executable for 16 bits PC under MS-DOS by Bill Muench and C. H. Ting, 1990.\n\n 1. Install node.js correctly so you can run node.exe in a DOX box. Working directory at jeforth.3we/. \n 2. Run: node.exe jeforth.3nd.js include 86ef202.f bye\n 3. You got jeforth.3we/eforth.com\n 4. I have a 32bits windows 8, so I can run eforth.com directly. If your Windows system is 64 bits, you'll need a DOS virtual machine like vmware, virtual box, or I recommend DOSBox, to run the created eforth.com.\n\nExcel automation\n---------------------\nUse jeforth.3hta to manipulate excel spread sheets. This example gets a column from a reference excel file to your target excel file.\n\n 1. Double click on jeforth.3we/jeforth.hta to start it. After the self-test type the command line \"include merge2.f\" into the input box.\n 2. Or run the below command line directory for the same thing:\n```\njeforth.hta include merge2.f\n```\n\n#### The End\n\n - FigTaiwan [http://figtaiwan.org](http://figtaiwan.org) \n - H.C. Chen [hcchen5600@gmail.com](hcchen5600@gmail.com) \n - Written with [StackEdit](https://stackedit.io/)\n\n\n "} \ No newline at end of file diff --git a/3nw/oklai.f b/3nw/oklai.f index d8cb287..eed69a3 100644 --- a/3nw/oklai.f +++ b/3nw/oklai.f @@ -53,12 +53,12 @@
.(( Now 'win' is the nw.exe main program DOM window object )) - win js> pop().title . \ jeforth.3nw -- 3 words jeforth.js for node-webkit with jQuery-terminal + win js> pop().title . \ jeforth.3nw -- 3 words projectk.js for node-webkit with jQuery-terminal \ [ ] the 'window' seen in debugger and the 'win' (gui.Window.get()) are different things. \ jeforth global variables are window.variables, e.g. window.debug, window.stackwas, window.screenbuffer, etc. \ Whild window.title is "undefined", but gui.Window.get().title is - \ "jeforth.3nw -- 3 words jeforth.js for node-webkit with jQuery-terminal" + \ "jeforth.3nw -- 3 words projectk.js for node-webkit with jQuery-terminal" \ This is not so difficult to understand. i.e. gui.Window.get().minimize() ==> works fine and \ window.minimize() ==> TypeError: Object [object global] has no method 'minimize' diff --git a/LOG/3ca.log.txt b/LOG/3ca.log.txt index b5094aa..8cce778 100644 --- a/LOG/3ca.log.txt +++ b/LOG/3ca.log.txt @@ -128,9 +128,9 @@ c:\Users\hcche\Downloads\jeforth.3we\jeforth.3chrome.html \ from jeforth.3we-59858c0208 --> As shown above it's the .js file that is suspected --> compared, can't find any suspect. - so try to use jeforth.3chrome.js . . . still failed. --> Now I believe the jeforth.js - is different. Because it's blocked at jeforth.js --> Nope, jeforth.js is the same. - --> so try to use the jeforth.3chrome.html .. no work -> use the jeforth.js too ... + so try to use jeforth.3chrome.js . . . still failed. --> Now I believe the projectk.js + is different. Because it's blocked at projectk.js --> Nope, projectk.js is the same. + --> so try to use the jeforth.3chrome.html .. no work -> use the projectk.js too ... failed --> use the manifest.json it self ... OK !! ------------ was -------------------------------------------- diff --git a/LOG/Log of TR.html b/LOG/Log of TR.html index 38e19ea..2d9f937 100644 --- a/LOG/Log of TR.html +++ b/LOG/Log of TR.html @@ -9,7 +9,7 @@ border: 0px solid; background:##E0E0E0; } - + \n\t\t

I am a H3 tag

\n\t\t

I am a P tag of green and A-size

\n\t\t bold italiy sdfsdfsdf B-size in the entire B tab \n\t\t bold italiy sdfsdfsdf B-size in the entire SPAN tag \n\t\t bold italiy sdfsdfsdf B-size in the entire SPAN tag \n\n\t

\n\t\t
\n\t\t\n\t\t

I am a H3 tag

\n\t\t

I am blue P tag A-size

\n\t\t bold italiy sdfsdfsdf B tag with B-size\n\t\t bold italiy sdfsdfsdf B-size in the entire SPAN tag \n\t\t bold italiy sdfsdfsdf B-size in the entire SPAN tag \n\t
\n

OK
> \\ How , how to make this happen on a target Tab of 3ce ????????? --> if chrome.extension.getBackgroundPage()\n also gets the window object of the background page in contecnt-script then this is easy. But, no, it doesn't appear in any content script's isolated world. See below experiment:

> <ce> typeof(chrome.extension.getBackgroundPage)</ceV> . \\ ==> undefined OK when in target tab
> <js> typeof(chrome.extension.getBackgroundPage)</jsV> . \\ ==> function OK when in 3ce

[x] 我稱作 target tab 者, Google 稱作 content script; 我稱作 background page 者, 他稱作 extension page。
[x] study RTFS .. use message to communicate target page content script and extension page. work on ce.f
[x] ce.f 成功了! {F7} 執行 jeforth command on the target tab now. Fri Jan 22 11:03:37 UTC+0800 2016
[x] log.x needs Ctrl-s hotkey to save log.save. (inputbox and outputbox) share the same event handler
    {ios} that fired onkeydown(). Other edit-zone(s) can have their own Ctrl-S handler too.
[x] ' log.recall :: lastrecalled 防呆機制。
[x] cls 要清除 ' log.recall :: lastrecalled
[x] Ctrl-S 要有一點視覺效果, 用現成的 toggle outputbox edit mode 來回即可。


> log.push
"," OK
> --- marker ---
<o>
 <canvas id=\"myCanvas\" width=\"300\" height=\"200\">
   你的瀏覽器不支援Canvas標籤, 請改用Chrome,Opera,Firefox,IE9或Safari
 </canvas>
</o> drop
js> document.getElementById('myCanvas') value canvas
js> vm.g.canvas.getContext('2d') value flag
js> vm.g.canvas.width value flag_w  
js> vm.g.canvas.height value flag_h
js> vm.g.flag_w/4 value circle_x
js> vm.g.flag_h/4 value circle_y
\\ 滿地紅
js: vm.g.flag.fillStyle='rgb(254,0,0)'
js: vm.g.flag.fillRect(0,0,vm.g.flag_w,vm.g.flag_h)
\\ 青天
js: vm.g.flag.fillStyle='rgb(0,0,149)'
js: vm.g.flag.fillRect(0,0,vm.g.flag_w/2,vm.g.flag_h/2)
\\ 白日:星芒
js: vm.g.flag.beginPath();
js> vm.g.flag_w/8 value star_radius
<js>
var angle = 0;
for (var i = 0; i < 24; i++) { // 12道星芒,24條線
   angle += 5 * Math.PI * 2 / 12;
   var toX = vm.g.circle_x + Math.cos(angle) * vm.g.star_radius;
   var toY = vm.g.circle_y + Math.sin(angle) * vm.g.star_radius;
   if (i) vm.g.flag.lineTo(toX, toY);
   else vm.g.flag.moveTo(toX, toY);
}
</js>
js: vm.g.flag.closePath(); \\ 可忽略
js: vm.g.flag.fillStyle='#fff';
js: vm.g.flag.fill();
\\ 白日:藍圈
js: vm.g.flag.beginPath()
js: vm.g.flag.arc(vm.g.circle_x,vm.g.circle_y,vm.g.flag_w*17/240,0,Math.PI*2,true)
js: vm.g.flag.closePath();
js: vm.g.flag.fillStyle='rgb(0,0,149)';
js: vm.g.flag.fill();
\\ 白日:白心
js: vm.g.flag.beginPath();
js: vm.g.flag.arc(vm.g.circle_x,vm.g.circle_y,vm.g.flag_w/16,0,Math.PI*2,true);
js: vm.g.flag.closePath();
js: vm.g.flag.fillStyle='#fff';
js: vm.g.flag.fill();


\n \n 你的瀏覽器不支援Canvas標籤, 請改用Chrome,Opera,Firefox,IE9或Safari\n OK
> log.save
","

研究 Chrome extension 存檔到本地 disk 的方法


This stackoverflow page gives the answer :
http://stackoverflow.com/questions/2153979/chrome-extension-how-to-save-a-file-on-disk 

And this is an example in the answers,

Google Webstore 
Github

I made an extension that does something like this, if anyone here is still interested. It uses an XMLHTTPRequest to grab the object, which in this case is presumed to be an image, then makes an ObjectURL to it, a link to that ObjectUrl, and clicks on the imaginary link.

answered Aug 10 '12 at 4:14
\"\"

--

(function() {

 function saveImage(e) {
  var filename = this /* 就是那個被 drag 的圖 */ .src.substring(this.src.lastIndexOf(\"/\") + 1);
  // 從 src 裡剪切出 最後面的 filename 部分. 作者用 grab 很有趣, 似乎 grab 正好只對 images 有效!!
  e = e ? e : window.event;
  var xhr = new XMLHttpRequest();
  xhr.responseType = 'blob';
  xhr.onload = function() {
   // xhr.response is a Blob
   var url = webkitURL.createObjectURL(xhr.response);
   var a = document.createElement('a');
   a.href = url;
   a.download = filename;
   var e = document.createEvent('MouseEvents');
   e.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
   a.dispatchEvent(e);
   window.webkitURL.revokeObjectURL(url);
  };
  xhr.open('GET', this.src);
  xhr.send();
  return false;
 }

 var documentImages = document.images;
 for ( i = 0; i < documentImages.length; ++i)
  documentImages[i].ondragend = saveImage;
})()

--

this
<img class=​\"currentImg\" onload=​\"alog && alog('speed.set', 'c_firstPageComplete', +new Date)​;​ alog.fire && alog.fire('mark')​;​\" src=​\"http:​/​/​www.itokoo.com/​attachment/​Mon_1409/​21_3_36be70c14afa54b.jpg?46\" width=​\"910\" height=​\"606\" log-rightclick=​\"p=5.102\" title=​\"点击查看源网页\" style=​\"cursor:​ pointer;​ width:​ 490px;​ height:​ 248.5px;​ top:​ 215.25px;​ left:​ 0px;​ display:​ block;​\">​

[ ] 3ce Program path http://...... <--- can be very long that corrupts the outputbox, click to change
[x] New word run> to run through the entire, rest of the, inputbox.value, not only one line.
[ ] This 3ce one liner lists all images in the webpage:
    js> document.images <js> for (var i in tos()) { type(tos()[i].src+\"\\n\") } </js> drop
[ ] How about their actual linkage? Bigger pic anticipated. 
[x] How to make a copy of an element -->  it works!
       <o> <p id=pp> this is an element</p></o> drop
       js: $(pp).clone().insertAfter(pp)
    Also this sample code:
       js: $(document.images.item(2)).clone().insertBefore(inputbox)
log.saved :)
","

在 target page 上安裝 jeforth.3ce inputbox outputbox

[x] 像這樣的東西 event.shiftKey 在 hotkey handler 裡面還是可以用的,例如:
\n        : {F6} js: alert(event.shiftKey) false ;
\n    works fine. Try press F6 with and without shift key.
\n[x] 3 log.roll moves log stack item up to the top so as to be log.drop works fine now.
\n[x] js> outputbox needs border-toggle ok now
\n[x] {F7} command line need to be added to command line history. --> very easy. One line only.
\n[x] {F7} needs idiot-proof to make a warning when target page is not attached yet. --> 算了,每次都檢查,浪費時間。
\n[x] Target tabid refresh 過後就得重新 attach, 即可。
\n[x] attach 應該自動 inject jQuery 到 tabid
\n    char js/jquery-1.11.2.js inject drop
[x] 發現! Extension page refresh 過後, 原來已經 attached 過的 target page 還是 attached,
    似乎只要 Extension page 
的 tabid 對的就可以。
\n



\n[x] 都好了, 可以來寫 target tab 上的 inputbox outputbox 了...
\n    [x] 1. attach \\ {Enter}, target page refresh 過就要重新 attach。
\n    [x] 2. char js/jquery-1.11.2.js inject drop \\ {Enter}
\n    [x] 3. char body <e> <textarea id=inputbox>I am the inputbox id is inputbox</textarea></e> drop \\ {F7}
\n\n    \\ 照這樣在 tabid target tab 上使用是 ok 的,
\n    > char body <e> <h3>I am a h3</h3></e> .s \\ ==> 0: [object Object] (object)
\n    > dup :> nodeName . \\ ==> H3 OK
\n    \\ 為何這樣不行?
\n    >  char body <e> <textarea id=inputbox>I am the inputbox id is inputbox</textarea></e> drop \\ {F7}
\n    [x] 看起來不像不表示不行,不能進這個 textarea 去 edit 的確很奇怪。簡化實驗看看 . . . OK
\n    char body <e> <textarea>in a textarea </textarea></e> .s \\ F7
\n    [x] 那試試原來的. . . . ok now.
\n    [x] 進一步改成 outputbox
\n        char body <e> <div id=outputbox>this is the outputbox</div></e> drop \\ {F7}
\n    [x] 合併起來
\n        char body <e>
\n            <div id=console3ce class=ce3>
\n            <style>
\n                .ce3 {
\n                    color:black;
\n                    font: 20px \"courier new\";
\n                    padding:20px;
\n                    word-wrap:break-word;
\n                    border: 1px ridge;
\n                    background:#F0F0F0;
\n                }
\n                .ce3 textarea {
\n                    width:100%;
\n                    padding:4px;
\n                    border: 0px solid;
\n                    background:#BBBBBB;
\n                }
\n            </style>
\n
            <div id=outputbox>this is the outputbox</div>
\n            <textarea id=inputbox>I am the inputbox id is inputbox</textarea>
\n            </div>
\n        </e> drop \\ {F7}
\n        ---> it works!! 本來 CSS has a
\n

\n
\nCSS style font 照順序提供以下 items 至少要有 font size 跟 font family:  
normal默认值。浏览器显示一个标准的字体样式。
italic浏览器会显示一个斜体的字体样式。
oblique浏览器会显示一个倾斜的字体样式。
inherit
normal默认值。浏览器会显示一个标准的字体。
small-caps浏览器会显示小型大写字母的字体。
inherit规定应该从父元素继承 font-variant 属性的值。
描述
normal默认值。定义标准的字符。
bold定义粗体字符。
bolder定义更粗的字符。
lighter定义更细的字符。
  • 100
  • 200
  • 300
  • 400
  • 500
  • 600
  • 700
  • 800
  • 900
定义由粗到细的字符。400 等同于 normal,而 700 等同于 bold。
inherit规定应该从父元素继承字体的粗细。
font-size/line-height规定字体尺寸和行高。参阅:font-size  line-height 中可能的值。
font: 40px \"courier new\"; <--------- Works fine.
\nfont: 40px courier new; <---------- it works too, the quote is not necessary.
\nfont: 40px courier news; <---- Typo, become 'Times new roman' as the result
\nfont: 40px courier-new; <---- Failed, become 'times new roman' too.
\nfont: 40px \"courier-new\"; <-------- Failed! become 'Times new roman'.
\n\n
\n[x] [CSS style experiment] 改改看, 能不能用 .ce3 (div,textarea) { ... } 這樣的形式? <---- 不行。\n
\n[x] [CSS style experiment] 先讓笨寫法成功  .ce3 div, .ce3 textarea { ... } <------ 這樣寫成功了。
\n    意思是 class=ce3 最外圍這個 DIV 之內的所有 DIV 跟 TEXTAREA 的 style 要如此這般。

\n\n


\\ 故意讓 target page 的 stack TOS 放 {aa:111,bb:222} 且安排讓它的 message callBack 傳回整個
\\ target page 的 stack 這樣做成功。
> tabid js: chrome.tabs.sendMessage(pop(1),\"depth\",function(r){push(r)})
 OK 
> depth
 OK 
> .s
      0:      112233       1b669h (number)
      1: [object Object] (object)
      2:           2           2h (number)
 OK 
> .s
      0:         228          e4h (number)
      1:         228          e4h (number)
      2: 112233,[object Object],2 (array) <==== callBack 傳回的 target page stack
 OK 
> dup :> [1] (see) <=== 果然可以傳回 object 
{
    \"aa\": 111,
    \"bb\": 222
} OK 


\\ 但是當 target page stack TOS 是它的 document object 時同樣的指令就會出錯:

> tabid js: chrome.tabs.sendMessage(pop(1),\"depth\",function(r){push(r)})
JavaScript error : Invocation of form tabs.sendMessage(array, string, function) doesn't match definition tabs.sendMessage(integer tabId, any message, optional object options, optional function responseCallback)

\\ 這個訊息沒有指出真正的問題,然而在 target page 的 F12 debugger 上顯示的是:
Error in event handler for runtime.onMessage: Error: Attempting to use a disconnected port object
\\ 似乎比較貼近,問題是不准傳送被禁止傳送的 object (window or document)。

> .s <--- 用 {F7} 執行, 看 target page 的 stack: 
      0:      112233       1b669h (number)
      1: [object Object] (object) <---------- {aa:111,bb:222}
      2:           2           2h (number)
      3: [object Object] (object) <---------- document object
\\ 結論是, target page 的 message 可以用來傳 object 回 host page。但只能是非 DOM 的東西。

[x] Target page 端 see word 的結果沒有印出 word.help 而是 [object Object] 之類.
    --> <ce> jQuery</ceV> 傳回 [null] array. 可能只能傳 text 回來。
[x] help 的結果顯示他是最舊版的。
[/] 希望可以在 FireFox 上執行, 啊不行 \"Chrome extension\"!
    因為 FireFox 有 Scrapbook 可以把整夜都抓起來,似乎有甚麼獨門秘訣。
[x] 3ce should have its own 3ce/platform.f to redefine the I/O.  --> ce.f + 3ce/quit.f that's all
[x] ce.f attach is very big. what it does are : 1.pick tabid, 2.inject project-k 3.setup platform
    dependent interfaces, 4. Start listening jeforth commands.--> ce.f + 3ce/quit.f that's all
[x] working on 3ce's quit.f. 應該先利用 Chrome extension 的 API 儘快做出 readTextFile 即可化簡 attach。

修改從 Target page Content Script 發回 Extension page 的 messaging protocal. 本來只是 string
現在改成 hash {isCommand:boolean,text:string} 其中 isCommand 是 optional 如果 ommit 就當作是 string message 如前 (because .isCommand is undefined which is a logical false)。經實驗成功,如下:

\\ 下令從 Target page 端發回命令讓 Extension page 執行 version 命令。
> <text> js: chrome.runtime.sendMessage({isCommand:true,text:\"version\"}); </text> (dictate)

\\ 收到的回覆:
> js: chrome.runtime.sendMessage({isCommand:true,text:\"version\"}); \\ <-------- 在 Target 端執行的命令。
j e f o r t h . 3 h t m -- v3.1 \\ <------------------ 在 Extension page 執行 'version' command 的結果。
source code http://github.com/hcchengithub/jeforth.3we
Program path chrome-extension://khjienijgaapbcofpbbogdlcclhbmjoa/index.html OK 

有了這套機制,就可以從 target page 下命令回 Extension page 幫忙讀取檔案。
\n


: readTextFileAuto ( \"pathname\" -- \"text\" ) \\ Read text file from jeforth.3ce package.
    s\" <text> \" swap + s\" </text> readTextFileAuto\" + \\ command line 以下讓 Extention page 執行
   
js: chrome.runtime.sendMessage({isCommand:true,text:pop()},function(){execute('stopSleeping')}) 
    10000 sleep ;

[x] {F7} 應該是 call (dictate) 來做事才對, 不該自己發 chrome.tabs.sendMessage(pop(1),pop())。

[x] 雙向都用 .sendMessage({isCommand:true,text:\"version\"}) 協定。


FigTaiwan
[x] This word partially already works fine on reading the file to Extension page's TOS.
    But the result didn't pass to target page. 可能只是因為 Extension page 要 update 一下剛寫好的程式?
    : readTextFileAuto ( \"pathname\" -- \"text\" ) \\ Read text file from jeforth.3ce package.
        s\" <text> \" swap + s\" </text> readTextFileAuto\" + \\ command line 以下讓 Extention page 執行
        <js> chrome.runtime.sendMessage({isCommand:true,text:pop()},
        function(result){push(result);execute('stopSleeping')}) </js>

        10000 sleep ;

[x] 手寫的筆記 http://note.youdao.com/share/?id=dc2af7872280a434c32475e858ef045b&type=note 實驗出
    來, sendMessage() 可以來回用 callBack。
[x] bug, attach leaves 7 false on host stack. 
    --> char f/jeforth.f (install) leaves the first false. Not caused by jeforth.f, so it's (install)
    --> (dictate) shoul not return a false to terminate event bubbling.

[x] message callBack to return something, it is supposed anything. ---> Yes!
[x] Can't attach js> window.open(\"playground/anual.htm\"), why? It really returns a window object and 7 false.
    [x] <ce> can't work on views (3ce's pages) <ce> window</ceV> or anything else returns an undefined.
        log 裡 executeScript section 早就發現了, F12 有 error message。
 

\n


Step 1. Restart tartet page and Host page, Attach, and run F7 on host
: readTextFileAuto ( \"pathname\" -- \"text\" ) \\ Read text file from jeforth.3ce host page.
s\" <text> \" swap + s\" </text> readTextFileAuto\" + \\ command line 以下讓 Extention page 執行
<js> chrome.runtime.sendMessage({isCommand:true,text:pop()},
function(result){push(result);execute('stopSleeping')}) </js>
10000 sleep ;

step 2. words F7 on host, check readTextFileAuto exists on target page.

Step 3. s\" 3nd.bat\" readTextFileAuto F7 on host page.

Step 4. .s F7 on host page. ---> expect the 3nd.bat file but it's not.


\\ Read the file on host side, it works.
> s\" 3nd.bat\" readTextFile .

@REM set NODE_PATH=%NODEJSHOME%\\node_modules
node jeforth.3nd.js %1 %2 %3 %4 %5 %6 %7 %8 %9
 OK 

\\ Run F7 to define this word on target page.
> : readTextFileAuto ( \"pathname\" -- \"text\" ) \\ Read text file from jeforth.3ce host page.
        s\" <text> \" swap + s\" </text> readTextFileAuto\" + \\ command line 以下讓 Extention page 執行
        <js> chrome.runtime.sendMessage({isCommand:true,text:pop()},
        function(result){push(result);execute('stopSleeping')}) </js>
        10000 sleep ;   
\\ execute by F7

 OK 

\\ Check the new word is really appeared on target page,
> words  \\ F7 to execute

... snip ...
-------- element.f (13 words) --------
ce-history ce! ce@ <>escape jump-to-ce@ se (ce) ce ce< (er) er list-links readTextFileAuto 
 OK 


> s\" 3nd.bat\" readTextFileAuto  \\ execute by F7 
 OK 
> .s
empty
 OK 
> .s
      0: dummy,3ce,doc,f,3htm/f,3htm/canvas,3htm,playground (array) <---- The result is strange!!
 OK 



> \\ check if the result is really from the host? is really what the host replied through message callBack?
> \\ debugger break-point at end of the message when isCommand

message.text
\"<text> 3nd.bat</text> readTextFileAuto\"
stack
[\"3nd.bat\", Array[8]0: \"dummy\"1: \"3ce\"2: \"doc\"3: \"f\"4: \"3htm/f\"5: \"3htm/canvas\"6: \"3htm\"7: \"playground\"length: 8__proto__: Array[0]]

結果真的是這樣。 我很懷疑 host side 的 onMessage event handler 裡面可以使用 dictate() 來處理事情。以前有討論過。複習複習....


\\ jeforth.hta inputbox 本身就是個最兇的 event 他會改 stack. 別的 event handler 都得負責恢復 stack.
\\ The correct implementation of the handler is,
\\   : handler char . . js> rstack.length if 0 >r then ;
\\ Push 0 to rstack due to the assumption of that all handlers are started from the waiting state,
\\ 0 brings the handler back to waiting sate, instead of popping up rstack and return to a unknown forth VM
\\ state!!

用 forth colon word 當 event handler, interrupt service routine 的要領:
 o  jeforth.hta inputbox 本身就是個最兇的 event 他會改 stack. 別的 event handler 都得
    balance data stack and return stack.
 o  所有的 event handler 都要【接地】也就是直接回到 JavaScript host 也就是 idle state 去。
    不能在 dictate() 或 execute() 之後放別的 JavaScript code 還以為是前面做好了才下來的,
    錯! dictate() 或 execute() 裡面很可能有 nap 或 sleep 那時候它就衝下來了! sleep 才可
    以 stopSleeping 所以應該是它。

[x] Repeat the SRP above, but intentionally push some 0's into the rstack. Count the 0's after the
    SRP to prove my theory. --> I add 3 0's on rstack of the target page 3ce VM. After the above procedure,
    that did reproduced the problem, then use debugger instruction to trigger F12 of the target page, check
    rstack, still 3 0's in its rstack.

\n當 host 能夠收 target page messaging 來的 readTextFileAuto command, 表示 host 當時在 idle state 如以前討論出來的結果。這時候它的 rstack 應該是空的或者 RTOS 是 0, 後者是在 napping or sleeping 的情形。[x] 首先, 既然是個類似 interrupt 進來的 dictate() -- 要負責 balance data stack and rstack, 而且還是個 I/O command -- 離開時檔案還沒讀好, 這個 dictate() 一下來一定要【接地】也就是要回到 JavaScript host 的 idle state 去。 總之, host 端的 message handler 不能以為 dictate() 回來就是整串 forth command 都做完了,實際上只是在 nap 或 sleep 等 I/O 時就會衝下來, 此時打 callBack 是不行的。這樣看來, host message handler 裡面打 callBack 已經不可行了。

由 event handler 裡的 dictate() 或 colon word 知道 I/O 已經完成之後打個 message 給 target page. 這時候當初 target 打過來的 message 已經結束了, 所以如果有多 target 的話就不知道是誰了, event handler 一上手在 sleep 等 I/O 之前就要把 sender 存下來放在 [x] ?????(這真是個問題)。只有一個 target page 就不怕這個顧慮了。 --> tabid 變數只有一個 ....

\n


想要用 background page 來跟 target page 傳資料行, background page 是 extension pages 自己內部用的。以下的實驗簡單就把用 background page 來跟 target page 交換資料的意圖打消了。

[x] When I review ce.f trying to recall my memory about how to pass an object to target page, getBackgroundPage() caught my eyes. Use it to get background page window object maybe a good idea to transfer data through it. But, that good idea is not allowed.

> js> chrome.runtime obj>keys . \\ F7, run in a target page
PlatformOs,PlatformArch,PlatformNaclArch,RequestUpdateCheckStatus,OnInstalledReason,OnRestartRequiredReason,getManifest,getURL,connect,sendMessage,onConnect,onMessage,id OK 
> js> chrome.runtime obj>keys . \\ Enter, run in the host page
PlatformOs,PlatformArch,PlatformNaclArch,RequestUpdateCheckStatus,OnInstalledReason,OnRestartRequiredReason,getBackgroundPage,openOptionsPage,getManifest,getURL,setUninstallURL,reload,requestUpdateCheck,restart,connect,sendMessage,getPlatformInfo,getPackageDirectoryEntry,onStartup,onInstalled,onSuspend,onSuspendCanceled,onUpdateAvailable,onBrowserUpdateAvailable,onConnect,onConnectExternal,onMessage,onMessageExternal,onRestartRequired,id OK 


> js> chrome.extension obj>keys . \\ F7, run in a target page
ViewType,sendRequest,getURL,onRequest,inIncognitoContext,connect,sendMessage,onConnect,onMessage OK 
> js> chrome.extension obj>keys . \\ Enter, run in the host page
ViewType,sendRequest,getURL,getViews,getBackgroundPage,isAllowedIncognitoAccess,isAllowedFileSchemeAccess,setUpdateUrlData,onRequest,onRequestExternal,inIncognitoContext,connect,sendMessage,onConnect,onConnectExternal,onMessage,onMessageExternal OK 
\n 
想要用 chrome.tabs.executeScript(integer tabId, object details, function callback)
也不行, 不能從 host 送東西過去給 target。看來還是只有 message 了。

有結論了, 就用 message, interface 仿 Chrome 的 argument --> http://note.youdao.com/share/?id=4aeeaf6fafc45e08056a771faf9e167e&type=note\n\n 

New protocal, which can pass the self-test, is : 3ce SPEC of sendMessage({forth:\".s\",type:\"hello world!\",tos:anything})
\nBut the readTextFileAuto in 3ce/quit.f does not leave anything in target stack but there are many tabid left in host stack. 

After the following experiments, finally works! 


 : readTextFileAuto ( \"pathname\" -- \"text\" ) \\ Read text file from jeforth.3ce host page.
  s\" s' \" swap + s\" ' readTextFileAuto \" + \\ command line 以下讓 Extention page (the host page) 執行
  s\" {} js: tos().forth='stopSleeping' js: tos().tos=pop() \" + \\ host side packing the message object
  s\" message->tabid \" + \\ host commands after resume from file I/O
  js: chrome.runtime.sendMessage({forth:pop()})
  10000 sleep ;   

 : test1 ( -- \"text\" ) \\ experiment : Read text file from jeforth.3ce host page.
  s\" s' 3hta.bat' readTextFileAuto {} js: tos().forth='version' message->tabid \"
  js: chrome.runtime.sendMessage({forth:pop()})
  10000 sleep ;  
  /// ok, 'version' really run on target page. Next step try to send something to target page.
  
 : test2 ( -- \"text\" ) \\ experiment : Read text file from jeforth.3ce host page.
  s\" s' 3hta.bat' readTextFileAuto {} js: tos().forth='version' js: tos().tos=1122334455 message->tabid\"
  js: chrome.runtime.sendMessage({forth:pop()})
  10000 sleep ;  
  /// Ok! Target page stack become [1122334455, 3.1 (TOS)] as anticipated.
  /// the file has read too. But a 239 appear in host stack unexpectedly.
  /// try manual do the same thing on host.
  
 s' 3hta.bat' readTextFileAuto {} js: tos().tos=5566 <js> tos().forth='version .s' </js>  message->tabid  
 \\ This line works fine 

\\ This is the workable final version   
 : readTextFileAuto ( \"pathname\" -- \"text\" ) \\ Read text file from jeforth.3ce host page.
  s\" s' \" swap + s\" ' readTextFileAuto .s \" + \\ command line 以下讓 Extention page (the host page) 執行
  s\" {} js: tos().forth='stopSleeping' js: tos().tos=pop(1) \" + \\ host side packing the message object
  s\" message->tabid \" + \\ host commands after resume from file I/O
  js: chrome.runtime.sendMessage({forth:pop()})
  10000 sleep ;   

 這下有了 readTextFileAuto 之後, attach 就可以大大地簡化了!

Everything went fine, next step is to complete the input/outputbox things,

Including editor.f
JavaScript error : body is not defined
JavaScript error on word \"jsEvalNo\" : endofinputbox is not defined
JavaScript error on word \"</js>\" : endofinputbox is not defined
JavaScript error on word \"stopSleeping\" : endofinputbox is not defined

[x] We have readTextFile, we can hand the control to the target page earlier.
[x] vm.inputbox is not used ever. use local variable instead
[x] Error happens when executing 'attach' from popup page while an extension page is opened.
what appear in the popup page is: 這個問題自動消失了
Error! <e> unknown.
JavaScript error on word \"stopSleeping\" : inputbox is not defined
 OK  OK  OK  OK 

> \\ and what appear in the target page F12 :
Error in event handler for runtime.onMessage: ReferenceError: inputbox is not definedhandler @ extensions::uncaught_exception_handler:8(anonymous function) @ extensions::uncaught_exception_handler:100EventImpl.dispatch_ @ extensions::event_bindings:376EventImpl.dispatch @ extensions::event_bindings:393target.(anonymous function) @ extensions::SafeBuiltins:19publicClass.(anonymous function) @ extensions::utils:94messageListener @ extensions::messaging:179target.(anonymous function) @ extensions::SafeBuiltins:19EventImpl.dispatchToListener @ extensions::event_bindings:387target.(anonymous function) @ extensions::SafeBuiltins:19publicClass.(anonymous function) @ extensions::utils:94EventImpl.dispatch_ @ extensions::event_bindings:371EventImpl.dispatch @ extensions::event_bindings:393target.(anonymous function) @ extensions::SafeBuiltins:19publicClass.(anonymous function) @ extensions::utils:94dispatchOnMessage @ extensions::messaging:310
\n



[x] h2o.f does not work on attached page. Canvas disappeared too in Extension page after, guess a cls but that's normal.
[x] 3ce target page, include math.f failed
[x] char playground/math.f readTextFileAuto . <-- works fine. w/o path failed. So why vm.path does not work? --> readTextFile should return a \"\" if failed. --> when failed, there's no message.tos, how about message.forth? --> no either, no message from host at all. See experiments below,

This experiment worked,
> \\ char aaa readTextFile

{} js: tos().forth='shooo!stopSleeping' js: tos().tos=\"112233\"
message->tabid

This experiment does not trigger message.tos nor message.forth on target id side.
> \\ char aaa readTextFile
{} js: tos().forth='shooo!stopSleeping' js: tos().tos=\"\"
message->tabid

More test --> try breakpoint before both of them .. RI! target page message handler if(message.tos) was a mistake, readTextFile failed return \"\" will then be skipped that's a mistake. if(message.tos!=undefined) then ok.

\n


[x] project-k baby.html does not accept commands now!!! sample.html either. 可能是把 kvm 都改成 vm 造成的。 為什麼要這樣改? 因為 3ce 很多動作都變成是 event handler 裡完成, 跟其他的 jeforth 版本不同了。人家用 vm 的 3ce 要改成 kvm 才行因為 event handler 裡只看得見 kvm。所以都改成 vm 3ce 就好了。但是同名會怎樣? 這是誰優先的問題。既然是同一個東西, 應該不會有問題。

--> 現在又好了, 不知道初三那天 T550 怎麼了。

\n


[ ] 改革 log.commands 用 stack 的方式之外, 也要有直接 access 的方式,更實用。log.roll 之外再加強 log.list 用第一行來
    random access 所有的 sections。
[ ] attach works fine from popup, so I don't need extra page. That means that I don't need to use index 0 as the default tabid. Click FigTW icon and attach to the page underneath.
[ ] 可以用 mouse 在 target tab 上 *點指* 出要操作的東西,
    jeforth baby>  js> window.getSelection().anchorNode.nodeValue .
    hi there!!! OK
    jeforth baby> <js> window.getSelection().anchorNode.nodeValue=\"Hello,I've got changed!\"</js>
    [ ] 希望可以 hover onmousexxxx 更好, 方便在 target page 上操作其上的 hyperlinks 不受干擾。
[ ] 由 event handler 裡的 dictate() 或 colon word 知道 I/O 已經完成之後打個 message 給 target page. 這時候當初 target 打過來的 message 已經結束了, 所以如果有多 target 的話就不知道是誰了, event handler 一上手在 sleep 等 I/O 之前就要把 sender 存下來放在 [x] ?????(這真是個問題)。只有一個 target page 就不怕這個顧慮了。 --> tabid 變數只有一個 ....
[ ] 透過 rawgit 讓 users install 3ce !!

","

This is sample code to create Tracking System section before the outputbox
> <o> <div id=ts class=tr>....</div></o> js> outputbox insertBefore

This problem was known because there are some unexpected white spaces between the wanted <tag> and </h> and </h> returns the last node which in this case is a white space text node. My solution is to improve </o> </h> </e> letting them remove the leading and ending white space from the given string.
rstack[0]:1  stack[[object Text]]:1 <========== Why TEXT NODE? why not the style element in <head> ??

> js> head.outerHTML .            \\ 查看 <head> 整個
> js> $('style').length .         \\ 看看有多少 <style> in or not in the <head>
> js> $('style')[1].innerHTML .   \\ 查看某個 <style> element, 好像不一定照先後順序。
> js> $('style')[1] removeElement \\ 殺掉某個 <style> element

>  js> $('style').length . 
3 OK
>  js> $('style')[1] .
[object HTMLStyleElement] OK
> js> $('style')[1] (see)  <------------ <style> element object 不能用 (see) 的? 對,不能。
{} OK

","

[Closed] Sticky Notes always on top, A closed TR is tr.table=disabled


[x] TR ticket to have a time stamp of the last modified time. If the copy in log.json is newer then warning when save.

[x] Design a table for TR --> see tutor-cloth.f
[x] When working on a new log item which has just pushed to log. Got error:
       log.save canceled, lastrecalled and log.length-1 mismatch!
    this is a bug.

2016-02-24 10:56:03簡化 3hta, platform.f, {ios} 不該寫多套 event handler。
[2016-02-24 16:12:30 ]
{ios} is for Ctrl-s, when 's' pressed when in (I)nputbox or (O)utputbox. Ctrl-s 要 save 存檔, 有了 console3we 之後, 可以把它簡化,不用兩處都各寫一套 handler。

--
   \t\t\t\t\t \t\t\t\t\t

--

\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t
2016-02-25 21:00:58Compare HTA <> Chrome to see what are unique attributes?[2016-02-25 22:39:36 ]

Chrome's <table> obj>keys:

HTA's <table> obj>keys:

[x] I need to design a showdup.exe (my old tool) equivalent command.

Use showdup to find unique properties. These are unique <table> properties of either HTA or Chrome:

Results:
Not appear in Chrome, these are HTA only <table> properties:

Chrome only <table> properties:
大家都有一缸子獨特的東西。

\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n \t\t\t\t\t \t\t\t\t\t     \t

--
\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t
2016-02-25 22:41:44Ctrl-Enter that executes inputbox -- don't scroll to inputbox after execution, remain at where it was.[ 2016-02-26 16:25:54]
Description

Attachments
\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n \t\t\t\t\t \t\t\t\t\t     \t

--
\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t
2016-02-26 09:35:45How to track back to a certain ancester parent?[2016-02-26 09:52:39 ]
有答案:


\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n \t\t\t\t\t \t\t\t\t\t     \t


--

2016-02-25 17:30:06tr.table to have more buttons2016-02-28 17:12:19
Description

Attachments
\t\t\t\t\t \t\t\t\t\t  \t\t\t\t\t \t\t\t\t\t     

 

2016-02-24 11:04:47Make Windows \"StickyNote.exe\" always on top
2016-02-28 17:12:03
Description

   \t\t\t\t\t \t\t\t\t\t
","[x] I tried to automate re-maping Acer S7 OA's keybaord. It was not successful. Target is to
    be able to switch to original for using an external keybaord, and switch to the remaped layout
    for when using the internal keyboard. ---> Done! See below. Very easy.
[x] Read my older log.txt and Ever note, Ynote \"map any key to any key\". I found that T550 Caps Lock
    has actually been changed. That means the registry is still working for Windows 10.

> include registry.f
OK
> s\" HKLM\\SYSTEM\\CurrentControlSet\\Control\\Keyboard Layout\\Scancode Map\" regRead constant regkey
> regkey :> ubound() tib.
regkey :> ubound() \\ ==> 19 (number)

> <js>
for(var i=0; i<=vm.g.regkey.ubound(); i++){
push(vm.g.regkey.getItem(i));
dictate(\".b space\");
}
</js>

00 00 00 00 00 00 00 00 02 00 00 00 20 e0 3a 00 00 00 00 00 OK

00 00 00 00 header

00 00 00 00 header

02 00 00 00 modified 1 key, What? this is T550, what modified?

20 e0 (new ) 3a 00 (target )

00 00 00 00 ending
 
See YNote \"jeforth.3we keyboard remapping\" for the conclusion: run ~.reg files and re-login, that Ynote page has the two .reg files attached.
 

","

Study Chrome extension, Chrome App

實驗 Chrome extensions 的功能


js> chrome.runtime.id . \\ ==> khjienijgaapbcofpbbogdlcclhbmjoa OK
PlatformOs,PlatformArch,PlatformNaclArch,RequestUpdateCheckStatus,OnInstalledReason,OnRestartRequiredReason,getBackgroundPage,openOptionsPage,getManifest,getURL,setUninstallURL,reload,requestUpdateCheck,restart,connect,sendMessage,getPlatformInfo,getPackageDirectoryEntry,onStartup,onInstalled,onSuspend,onSuspendCanceled,onUpdateAvailable,onBrowserUpdateAvailable,onConnect,onConnectExternal,onMessage,onMessageExternal,onRestartRequired,id 

chrome.browserAction.getTitle({},function(result){alert(result)})
js: chrome.browserAction.getTitle({},function(result){type(result)})
[ ] 實際上就是去查看 manifest.json 裡面的 browserAction field 填甚麼。

\n

browserAction.getBadgeText browserAction.setBadgeText

js: chrome.browserAction.getBadgeText({},function(result){type(result)})

js: chrome.browserAction.setBadgeText({text:\"ABCD\"})

[x] 這個非常好玩又有用。


> js> chrome obj>keys .
loadTimes,csi,Event,app,browserAction,extension,i18n,management,permissions,runtime,tabs,windows OK 

有辦法取得所有的 Tab 了! 先用 query 全部都抓成 array 取得 tabid 然後就好辦了。

<js> chrome.tabs.getCurrent(function(tab){push(tab);dictate('(see) .\" Done!!\" cr')})</js>

\\ 上面這行在 popup page 中執行, 得到 undefined。 在正常的 jeforth.3htm tab 中執行得到該 Tab 的 
\\ Chrome extension Tab object. jeforth 可以用來分辨目前的 page 是否 popup page, Bingo !!!
\\ (要考慮 asynchronous behavior)
\\ See also getViews()


> .s

      0: [object Object] (object)
 OK 
> dup (see)
[object Object]
  active :   true
  audible :   [object Boolean]
  height :   775
  highlighted :   true
   id :   198 <------------- ID is not 0,1,2...
  incognito :   [object Boolean]
  index :   1
  mutedInfo :   [object Object]
  pinned :   [object Boolean]
  selected :   true
  status :   complete
  width :   1440
  windowId :   1
 OK 

\\ tabs.getCurrent 在 popup page, background page 用拿到 undefined, getSelected 要作廢了。改用 tabs.query 試試,
\\
tabs.query <js>
 for(var i in tos()){
  if(tos()[i].active){
   push(pop()[i].id);
   break; // <---------------- 有多個 window 就有多個 active tabs. 如何知道有幾個 Chrome window ? 答案還是 tabs.query.
  }
 }
</js>

--

tabs.query 真的有 query 的功能:

<js> chrome.tabs.query({title:\"*anual*\"},function(tabs){
push(tabs);
execute('stopSleeping')
})</js> 10000 sleep er (see)

* tabs.query 只列出看得見的 tabs, 含 chrome://extensions/ , chrome://history/ , 但不含 popup , background
Command line: {} tabs.query (see)



> js: chrome.tabs.get(0,function(tab){push(tab)}) .s <---- Id is not 0,1,2,...
      0: [object Object] (object)
 OK 
> .s
      0: [object Object] (object)
      1: undefined (undefined)
 OK 
> js: chrome.tabs.get(1,function(tab){push(tab)}) .s
      0: [object Object] (object)
      1: undefined (undefined)
 OK 
> .s
      0: [object Object] (object)
      1: undefined (undefined)
      2: undefined (undefined)
 OK 


<js> chrome.tabs.query({},function(tabs){push(tabs);dictate('dup (see) .\" Done!!\" cr constant tabs')})</js>
 OK 
> .s
      3: [object Object],[object Object],[object Object],[object Object] (array)
 OK 
> constant tabs  
 OK 
> tabs (see)
[object Object],[object Object],[object Object],[object Object]
  0 :   [object Object]
  1 :   [object Object]
  2 :   [object Object]
  3 :   [object Object]
 OK 
> tabs :> [0] (see)
[object Object]
  active :   [object Boolean]
  audible :   [object Boolean]
  favIconUrl :   chrome://theme/IDR_EXTENSIONS_FAVICON@2x
  height :   775
  highlighted :   [object Boolean]
  id :   2
  incognito :   [object Boolean]
  index :   0
  mutedInfo :   [object Object]
  pinned :   [object Boolean]
  selected :   [object Boolean]
  status :   complete
  title :   擴充功能
  url :   chrome://extensions/
  width :   1440
  windowId :   1
 OK 
> tabs :> [1] (see)
[object Object]
  active :   true
  audible :   [object Boolean]
  height :   775
  highlighted :   true
  id :   198
  incognito :   [object Boolean]
  index :   1
  mutedInfo :   [object Object]
  pinned :   [object Boolean]
  selected :   true
  status :   complete
  width :   1440
  windowId :   1
 OK 
> tabs :> [2] (see)
[object Object]
  active :   [object Boolean]
  audible :   [object Boolean]
  height :   775
  highlighted :   [object Boolean]
  id :   178
  incognito :   [object Boolean]
  index :   2
  mutedInfo :   [object Object]
  pinned :   [object Boolean]
  selected :   [object Boolean]
  status :   complete
  width :   1440
  windowId :   1
 OK 
> tabs :> [3] (see)
[object Object]
  active :   [object Boolean]
  audible :   [object Boolean]
  height :   775
  highlighted :   [object Boolean]
  id :   182
  incognito :   [object Boolean]
  index :   3
  mutedInfo :   [object Object]
  pinned :   [object Boolean]
  selected :   [object Boolean]
  status :   complete
  width :   1440
  windowId :   1
 OK 
> tabs :> [4] (see)
undefined (undefined)

用對了 tabid 就成功了!

> js: chrome.tabs.get(198,function(tab){push(tab)})
 OK 
> .s
      0: [object Object] (object)
      1: undefined (undefined)
      2: undefined (undefined)
      3: [object Object] (object)
 OK 
> (see)
[object Object]
  active :   true
  audible :   [object Boolean]
  height :   775
  highlighted :   true
  id :   198
  incognito :   [object Boolean]
  index :   1
  mutedInfo :   [object Object]
  pinned :   [object Boolean]
  selected :   true
  status :   complete
  width :   1440
  windowId :   1
 OK 



360's online document in Chinese
 is the best resource for Chrome extension.
I am trying available functions. 



> js: chrome.tabs.query({},function(tabs){push(tabs)})
      3: [object Object],[object Object],[object Object],[object Object],[object Object] (array)

> value tabs
> .s
      0: [object Object] (object)
      1: undefined (undefined)
      2: undefined (undefined)
 OK 
> dropall
 OK 
> tabs :> [0] (see)
[object Object]
  active :   [object Boolean]
  audible :   [object Boolean]
  height :   775
  highlighted :   [object Boolean]
  id :   238 <================================= get the ID of Diigle My libaray page
  incognito :   [object Boolean]
  index :   0
  mutedInfo :   [object Object]
  pinned :   [object Boolean]
  selected :   [object Boolean]
  status :   complete
  width :   1440
  windowId :   1
 OK 
> tabs :> [0] (see)
[object Object]
  active :   [object Boolean]
  audible :   [object Boolean]
  height :   775
  highlighted :   [object Boolean]
  id :   238
  incognito :   [object Boolean]
  index :   0
  mutedInfo :   [object Object]
  pinned :   [object Boolean]
  selected :   [object Boolean]
  status :   complete
  width :   1440
  windowId :   1
 OK 

List again, after I pull out the jeforth.3ce tab to a separated window. Then the tabs are still the same. So tabs are cross window and it's more useful then window.
 
> js: chrome.tabs.query({},function(tabs){push(tabs)})

 OK 
> .s
      0: [object Object],[object Object],[object Object],[object Object],[object Object] (array)
 OK 
[x] We can use  {} tabs.query (see)  now.

tabs.detectLanguage

http://open.chrome.360.cn/extension_dev/tabs.html
Try chrome.tabs.detectLanguage(integer tabId, function callback) <======== Bingo !!
> dropall <js> 
chrome.tabs.detectLanguage(238,function(arg){
push(arg);
dictate(\".' Done' .s\")})
</js>
 OK Done      0: en (string)
\n > dropall 
chrome.tabs.detectLanguage(function(arg){
push(arg);
dictate(\".' Done' .s\")})
</js>
 OK Done      0: en (string)

getSelected   <------ Try Eliminating deprecated chrome.tabs.getSelected from your code and use chrome.tabs.queryinstead.

chrome.tabs.getSelected(integer windowId, function callback)

获取特定窗口指定的标签。

 OK 
dropall <js>
chrome.tabs.getSelected( function(w){
push(w);
dictate(\".' Done' .s\")})
</js>
// chrome.tabs.getSelected(integer windowId, function callback)
 OK Done      0: [object Object] (object)

> (see)
[object Object]
  active :   true
  audible :   [object Boolean]
  height :   513
  highlighted :   true
  id :   198 <========= the recent jeforth.3ce Tab.
  incognito :   [object Boolean]
  index :   0
  mutedInfo :   [object Object]
  pinned :   [object Boolean]
  selected :   true
  status :   complete
  width :   1022
  windowId :   246 <=== I pull out the jeforth.3ce tab to a separated window, this is it.


tab.getCurrent

To try request and messaging, I opened another jeforth.3ce window and get the info

\n<js> chrome.tabs.getCurrent(function(tab){  \\ <-- 同樣是 jeforth 得知自己是 popup, background, 或其他。
    push(tab);
    dictate(' .\" done!!\" cr (see)')
})</js>

 OK done!!
[object Object]
  active :   true
  audible :   [object Boolean]
  height :   513
  highlighted :   true
  id :   248 <======================= this is the new jeforth.3ce tabid, so can 248 talk to 198 ?
  incognito :   [object Boolean]
  index :   1
  mutedInfo :   [object Object]
  openerTabId :   198 <------------- Look at this! tabid 198 opened this tab.
  pinned :   [object Boolean]
  selected :   true
  status :   complete
  width :   1022
  windowId :   246 <=== yeah, the same window.


\n

How to change the title of a tab

For multiple instance, I'll need to change the title of the jeforth.3ce tab,

> js> $(\"title\")[0].innerHTML .
jeforth.3htm OK 


\n

[ ] captureVisibleTab

\\ chrome.tabs.captureVisibleTab(integer windowId, object options, function callback)
\\ 在特定窗口中,抓取当前选中标签的可视区域。 这要求必须在 host permission 中指定对标签URL的访问权限。
<js> chrome.tabs.captureVisibleTab(1,function(x){push(x);dictate('(see) .\" Done!!\" cr')})</js>
 OK undefined (undefined) <---------- I guess, selected is not made yet.
Done!!

dropall <js>
chrome.tabs.getSelected( function(w){
push(w);
dictate(\"(see) .' Done!!' cr\")})
</js>
> (see)
[object Object]
  active :   true
  audible :   [object Boolean]
  height :   598
  highlighted :   true
  id :   199 <------------------- aleady selected, actually which is the active tab.
  incognito :   [object Boolean]
  index :   2
  mutedInfo :   [object Object]
  pinned :   [object Boolean]
  selected :   true
  status :   complete
  width :   1280
  windowId :   1
 OK 

\n

see-manifest

[x] I want to check the recent Manifest.json

see https://developer.chrome.com/extensions/runtime#method-getManifest getManifest object chrome.runtime.getManifest()

dropall js> chrome.runtime.getManifest() (see) <---------- Bingo!!!
[x] Now we have see-manifest
--

--


Google engineers/designers already covered this case. Ha ha! Can't close() a window unless . . > dropall <js> chrome.tabs.executeScript(
    207,
    {code:'window.close()'},
    function(result){push(result)}
)</js>
Error message : Scripts may close only the windows that were opened by it.


getViews

http://open.chrome.360.cn/extension_dev/extension.html#method-getViews
array of global chrome.extension.getViews(object fetchProperties)
以 array 的形式返回当前扩展运行的所有页面(由 3ce 所 create 的 tabs, 而非人家的 tabs)的JavaScript “window”对象。 <------------- No, this is NOT what I am looking for!

> js> chrome.extension.getViews() <------------ It works!!
> .s
      0: [object Window] (array) <---- returned an array
> value windows
> windows :> length . 
1 OK  <--------------------------------- which is the current Tab, the jeforth.3ce tab itself.
> windows :> [0] obj>keys .
external,chrome,document,$,jQuery,jeForth,jeforth_project_k_virtual_machine_object,kvm,AppView,ExtensionOptions,ExtensionView,WebView,f,colonxt,speechSynthesis,caches,localStorage,sessionStorage,webkitStorageInfo,indexedDB,webkitIndexedDB,ondeviceorientation,ondevicemotion,crypto,postMessage,blur,focus,cl... snip ... OK 
> windows :> [0].document.title .
jeforth.3htm OK 

js> chrome.extension.getViews({type: 'popup'}) <--- 從 3ce tab 執行抓不到東西, correct.
<js> chrome.extension.getViews({type:null,windowId:null})</jsV> :> length . <--- 總是 1 即 3ce tab 自己。
[x] 並非抓回所有的 tabs' window object !! why? <--- it gets 3ce's own tabs only. RTFS!

[x] 想要抓某個 Tab 的 Window object window.open() 就是了! --> strange, I remember it worked, but now it returns [object global] which is an empty object.


content script

http://www.cnblogs.com/cart55free99/archive/2014/05/26/3753722.html

[x] modify my manifest.json to have a content_script field. <--- This is to inject Tabs by default automatically, that's not the case jeforth.3ce wants to use.
看起來 jeforth.3ce 不用 content scripts 這種東西, 我們一定是臨時 injects 所以只要用已經試過的 chrome.tabs.executeScript(integer tabId, object details, function callback) 就對了。


 

[x] 若想讓 tabs.executeScript 跑東西把該 tab 的 window object 傳回來, 就得先有辦法傳資料...允許嗎? <--- No, it'll be an empty window object.




executeScript

http://stackoverflow.com/questions/13166293/about-chrome-tabs-executescript-id-details-callback
chrome.tabs.executeScript(integer tabId, object details, function callback)
向页面注入JavaScript 脚本执行。要了解详情,请查阅内容脚本文档的 programmatic injection 部分。

一旦设置好了权限,就可以通过调用 executeScript()来注入 javascript 脚本。如果要注入 css, 可以调用 insertCSS()
http://open.chrome.360.cn/extension_dev/content_scripts.html

<js> chrome.tabs.executeScript(
    203, <-------------------------------- 不能是 Chrome extension 自己的頁面, 否則觸發 error 只有 F12 看得見。
    {code:'alert(\"ABCDE\")'},
    function(x){
        opush(x);
        dictate('(see) .\"done!!!\" cr ')
    }
</js>

這裡有 executeScript 的 sample 但是我試不行,問題如上。
http://stackoverflow.com/questions/13166293/about-chrome-tabs-executescript-id-details-callback

<js> chrome.tabs.executeScript(
203,
{code:'var x=123;x'}, <----------------------- 沒有執行到, 觸發 error 了。
function(result){push(result)}
)</js>

> .s
      6: undefined (undefined)
--

<js> chrome.tabs.executeScript(
null,  <------------------------------------------------ this tab 本身還是不行。
{code:'var x=123;x'}, <---- leaves x as the return value, 執行不到。
function(result){push(result)} <---- nothing in result.
)</js>

> .s
      7: undefined (undefined)
--
哈! 用 debuger 一看嚇一跳,問題一大堆。可見要隨時打開 debugger 來看才行。

> <js> chrome.tabs.executeScript(
199,
{code:'var x=123;x'},
function(result){push(result)}
)</js>

Unchecked runtime.lastError while running tabs.executeScript: Cannot access contents of url \"chrome-extension://facnlnflcdhbelabokalhfenlhknknnh/index.html\". Extension manifest must request permission to access this host. ---> http://stackoverflow.com/questions/14361061/extension-manifest-must-request-permission-to-access-this-host
    at eval (eval at <anonymous> (eval at docode (chrome-extension://facnlnflcdhbelabokalhfenlhknknnh/project-k/jeforth.js:1:0)), <anonymous>:1:13)
    at Word.newxt [as xt] (eval at docode (chrome-extension://facnlnflcdhbelabokalhfenlhknknnh/project-k/jeforth.js:1:0), <anonymous>:4:7)
... snip ...

--> [x] Use the stackoverflow article's manifestjson still failed. I guess extension page are not allowed to executeScript even by jeforth.3ce which is its own script. <== Yes!
Try to specify another tab then ok.

--

Bingo!! Ok now

dropall <js> chrome.tabs.executeScript(
207, // <-------------------------------------------- Can not be a jeforth.3ce Tab.
{code:'console.log(\"hello I am jeforth.3ce\")'},
function(result){push(result)}
)</js>

Where 207 is a Tabid which is NOT any jeforth.3ce tab. And I found every Chrome tab has its own F12 debugger instance simultaneously. I can see the message appear in that Tab's debugger console now. The root cause was really the permission issue. jeforth.3ce tab can not be executeScript'ed which is a good thing.

--
\nThis snippet really returns the number 112233 through an array:

<js> chrome.tabs.executeScript(
225,
{code:'112233'},
function(result){push(result)}
)</js>

 OK 
> .s
      0: 112233 (array)

\nAnd this snippet really returns an object that looks like a window object,

<js> chrome.tabs.executeScript(
225,
{code:'window'},
function(result){push(result)}
)</js>

But that object does not contains a real DOM window.

Can add TabId to the page's title,

<js> chrome.tabs.executeScript(
225,
{code:'document.title+=\"#225\";document.title'},
function(result){push(result)}
)</js>
--

So, how about to inject jeforth.js?

<js> chrome.tabs.executeScript(
225,
{code:'alert(\"hi!\");jeForth',file:'project-k/jeforth.js'},
function(result){push(result)}
)</js>

---> No, the error essage is : Unchecked runtime.lastError while running tabs.executeScript: Code and file should not be specified at the same time in the second argument.  

--
> <js> chrome.tabs.executeScript(
225,
{file:'project-k/jeforth.js'}, <--- So, jeForth() is existing in that tab? Check by F12 ... Nope! 其實這就已經成功了! 只是因為它所處的 thread 是獨立的 extension thread 所以這樣看不見。
function(result){push(result)}
)</js> .

undefined OK  <----- this is correct. jeforth.js does not leave any value.
--
> <js> chrome.tabs.executeScript(
225,
{file:'project-k/jeforth.jssss'}, <--- \"failed to load file\"
function(result){push(result)}
)</js> .
So, it really worked but as mentioned __________ it's a separated environment. ---> [x] Try a separated jeforth.js kernel that does something ... 以下成功了!
--

> <js> chrome.tabs.executeScript(
225,
{file:'3ce/jeforth.js'},  <--- the special jeforth.js really alerts a message. So this works. But after that, check by F12 debuger, window.vm is not existing. So it's really a separated environment. The previous experiment tried to return a window object that can be done but the window object will become empty after the executeScript life cycle. 以後用不著這樣, 用 project-k 的應該就可以了。
function(result){push(result)}
)</js> .

Note!!! try this again,
<js> chrome.tabs.executeScript(
225,
{code:'vm.dictate(\"hi\")'},
function(result){push(result)}
)</js> .
and it works !!! So the above injected jeforth kernel is really existing in that page already. How about to run debugger?

<js> chrome.tabs.executeScript(
225,
{code:'vm.dictate(\"hi\");debugger'}, <---- Yes, bingo!! it closed existing F12 and opened a new instance that works correctly with vm acknowledge. So debug is not a problem then. Another way to see objects in the separated thread is running console.log(object) command. That shows the object in F12 debugger but can't really USE it. To really use them, issue debugger command to switch to the separated thread. In that case, the thread is paused.
function(result){push(result)}
)</js> .

so, ok, only message is allowed. let's try messaging.... actually, all jeforth versions are using text message as the UI. So it's not so bad at all. I can't save a window object to disk neither even when using 3hta or 3nw. so the situation is actually the same.


Sending and receiving message

--
\\ This is my first successful experiment
<text>
chrome.runtime.onMessage.addListener( // 設定 target 端的 message handler
function(request, sender, sendResponse) {  // 收到 message 就顯示其中 info。
console.log(request);
console.log(sender);
console.log(sendResponse);
})
</text>

<js>
chrome.tabs.executeScript (   // 從 host 端透過 executeScript 在 target 端佈署 onMessage listener
 225,{
  \"code\": pop()
 },
 function(result){push(result)} // executeScript 執行完之後傳回最後 statement 的 value。
) </js> .

\\ try to send a message over
js: chrome.tabs.sendMessage(225,\"something\")

\\ this is the console.log results in F12 debugger,
something <---------------------------------------- the message
Object {id: \"khjienijgaapbcofpbbogdlcclhbmjoa\"} <--- the sender object
function (response) { <-------------------------- the sendResponse() function
        if (port) {
          port.postMessage(response);
          privates(port).impl.destroy_();
          port = null;
        } else {
          // We nulled out port when s…

--


\\ Now try to get a response message from the content script:\t

\\ This is the content script:

<text>
chrome.runtime.onMessage.addListener(
    function(request, sender, sendResponse) {
        console.log(request);
        console.log(sender);
        sendResponse(\"This is my response\"); // <----- make a response string.
    }
)
</text> <js> 
chrome.tabs.executeScript (
    225,{
        \"code\": pop()
    },
    function(result){push(result)}
) </js> . // <----- See result

undefined OK  <------------ the code has no return value
> js: chrome.tabs.sendMessage(225,\"something\",function(response){push(response);type(\"responed\\n\")})

 OK responed <--------- it worked

> .s
      0:  (array)
      1: This is my response (string) <----------- Bingo!!!
   
--

\\ Try again, but response an object

>     <text>
    chrome.runtime.onMessage.addListener(
        function(request, sender, sendResponse) {
            console.log(request);
            console.log(sender);
            sendResponse({aa:11,bb:22});
        }
    )
    </text>
    <js> 
    chrome.tabs.executeScript (
        225,{
            \"code\": pop()
        },
        function(result){push(result)}
    ) </js> .

undefined OK 
> js: chrome.tabs.sendMessage(225,\"expecting-an-object\",function(response){push(response);type(\"responed\\n\")})
 OK responed

> .s
      0:  (array)
      1: [object Object] (object)
 OK 
> dup (see)
{
    \"aa\": 11,
    \"bb\": 22
} OK 


The above messaging system is actually very annoying. Now I'd like to use window.open() to get the window object directly! ---> failed. it returned [object global] not [object Window] and the global object is empty. I don't remember what I see when I said window.open() could be a solution, however, it's not. ==> if the opened tab is under 3ce's root folder then window object is [object Window]; if is out of the root folder then it's not accessable [object global].

* 想要取得 target page 的 window object 是來自 Microsoft IE ShellWindows 的 idea。在 Chrome extension 是用 content script 來取代的,更好、更安全。也就是把 code 送進 target page 用 isolated world 來執行,中間用 message 來回傳遞命令與資料——而非把 window object 交給 host。

> list-tabs
283 My Library <--------------------- get the tabid
233 jeforth.3htm
229 chrome extension overview - cart55free99 - 博客园
241 标签--扩展开发文档
237 分类索引--扩展开发文档
267 br711 - Google 搜尋
263 Freebord - Snowboard the Streets
245 Gartner Magic Quadrant - App. Sec. Testing - hcchen5600@gmail.com - Gmail
2 MSN.com - Hotmail, Outlook, Skype, Bing, Latest News, Photos & Videos
 OK 
> <js> chrome.tabs.executeScript(  <------------- inject jeforth kernel 
283,
{file:'project-k/jeforth.js'}, 
function(){dictate(\".' project-k kernel has injected to the specified Tab.' cr \")}
)</js>
 OK project-k kernel has injected to the specified Tab.

> <js> chrome.tabs.executeScript(
283,
{code:'window.vm = new jeForth();'}, <--------------- create the jeforth vm 
function(result){push(result);dictate(\".' Done!! TOS is the result.' cr \")} <--- result 不含 methods
)</js>
 OK Done!! TOS is the result.

> .s
      0: [object Object] (array) <---- jeforth vm but w/o any method!
 OK 
> dup (see)
[
    {
        \"dictionary\": [
            0
        ],
        \"major_version\": 3,
        \"words\": []
    }
] OK 
> .s
      0: [object Object] (array)
 OK 
> <js> for(var i in tos()[0]) type(i+\" (\"+ typeof(tos()[0][i])+\"), \") </js>
dictionary (object), major_version (number), words (object),  OK  <----- See, no method. 



background page


為了要有個 workingTab 系統變數, 以簡化程式避免每個動作都得指定 tabid, 引申出需要 background page 用來放 global variable 之用。 --> Use background.html to include project-k and background.js

\\ 只要在 manifest.json 裡這樣設定, 啟動時就會照 background field 的指示把 script files include 進看不見的 background page.
{
 \"manifest_version\" : 2,
 \"name\" : \"jeforth.3ce\",
 \"description\" : \"jeforth for Chrome Extension\",
 \"version\" : \"1.0\",
 \"browser_action\" : {
  \"default_title\": \"Popup of jeforth.3ce\",
  \"default_icon\" : \"3ce/fig.tw16x16.png\",
  \"default_popup\" : \"index.html\"
 },
 \"background\": {
  \"scripts\": [\"project-k/jeforth.js\", \"3ce/background.js\"]
 }, 
 \"content_security_policy\" : \"script-src 'self' 'unsafe-eval'; object-src 'self'\",
 \"permissions\" : [
  \"tabs\", \"notifications\", \"http://*/*\", \"https://*/*\"
 ]
}

\\ background.js
    chrome.runtime.onMessage.addListener(
        function(request, sender, sendResponse) {
            alert(\"The background page received a message: \" + request);
            alert(\"I think jeForth is \" + jeForth)
        }
    )

\\ 要看 background page 有沒有作用, 發個 message 過去即知:
\njs: chrome.runtime.sendMessage({greeting:\"hello\"}) \\ <--- 打過去就真的馬上彈出事先安排好的 alert. 而且看到 project-k kernel 真的存在了。

\\ runtime.sendMessage() to background page.
\\ tabs.sendMessage() to content script of the specific tab.

[/] background.js 應該定義 dictate() 轉發跟 type() 回覆當作其中的 jeforth vm 的 I/O. 先寫出 type() 來。
    --> 不用這麼複雜。
[x] js> chrome.extension.getBackgroundPage() .s 就可以拿到 background page 的 window object 所以根本不需要
\n\n    background.js, 可能連 project-k 都不必 include 只要宣告一個空的 packground page 就可以了。--> 全空的不行
[x] background.js 裡面只要一行就夠了, 連這行都沒有也不行。
\n    var isBackgroundPage = true;

    js> chrome.extension.getBackgroundPage() .s
          0: [object Window] (object)
    > dup :> isBackgroundPage .
    true OK 


    這樣就可以用 background page 來存放 global data 了。   


","

Improve log system to support TR tickets

[x] improve common.css, it has to be more specific, not covers all body and all textarea.
    Only .jeforthconsole (class) is expected. I still need common.css file, I have many
    platforms besides.
    --> modify common.css first.
\n

<div class=console3we> 
 <div id=\"outputbox\"></div>
 <textarea id=\"inputbox\" cols=100 rows=1></textarea>
\n <a id=jump2endofinputbox href=\"#endofinputbox\"></a><div id=endofinputbox></div>
 <spam id=endofinputbox></spam>
</div>
--
.console3we { 要改成\n.console3we div , .console3we textarea { 才對 textarea 有效 [ ] 不懂何故!!
  color:black;
  font-family: courier new;
  font-size: 20px;
  padding:20px;
  word-wrap:break-word;
  border: 1px ridge;
  background:#F0F0F0;
 }
 .console3we textarea {
  width:100%;
  padding:4px;
  border: 0px solid;
  background:#BBBBBB;
 } 

    --> 3htm 外觀就變了 -> 修改 index.html 用 <div class=console3we> 把 inputbox outputbox 都包起來
    --> ok! But font size in inputbox is very small --> ok now, as above green bold.
        [x] 3htm, [x]3hta, [x]3nw, [x]3ce
[x] after common.css improved, I can specify textarea's width freely, example:
    <o> <textarea style=\"width:50%\"></textarea></o> drop where style field is
    necessary (can't be width field) and also nn% is must.
    --> this is for tr.table command

ID Severity Canceled Move *this* to *here* 移動 element 可以用打樁的方式標示要移甚麼到哪裡. <-- was for tr.table, use Shift-F2 to edit the entire console3we is good enough. [Create] \t\t\t\t\t\t\t [Save] \t\t\t\t\t\t\t [Modify] \t\t\t\t\t\t
[ ]Subject

Attachments
\t\t\t\t\t \t\t\t\t\t \t\t\t\t\t \t\t\t\t\t \t\t\t\t\t
\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t \n\t\t\t\t\t\n\t\t\t\t
[x] {F9} {F10} to adjust any textarea rows, but inputbox is specially tacke cared.[][][]
[x]

構想



[x]

如何抓 current focused 的 textarea object 要研究研究。===> 3htm/f/platform.f modified and new {F9}/{F10} works fine now!!



\t\t\t\t\t \t\t\t\t\t \t\t\t\t\t \t\t\t\t\t \t\t\t\t\t
\n   
\n\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t \n\t\t\t\t\t\n\t\t\t\t
IDClosedTR table 外觀, ID, Abstrace, and 日期欄 improvement. A status is also needed.Created[]Saved[]Changed[]
[x]
--
\t\t\t\t\t \t\t\t\t\t \t\t\t\t\t \t\t\t\t\t \t\t\t\t\t
\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\t \n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t
ID XClosed

Ctrl-Enter 擴充功能, inputbox 非 active 時仍然執行 statements in the inputbox。因為可以區分不同狀況因此可以有不同的效果,例如把 tr.table 插入 cursor 所在之處而非 outputbox 最底下。

\n        \n\t\t\t\t\t\t
[x]

先寫出可以 Ctrl-Enter 打上 time stamp 的命令 e.g. \"now t.dateTime paste\" 就有進展了。



Ctrl-Enter 已經可以用來執行 inputbox 而毋需先 focus 在裡面, 因此可以用來保持 anchorNode 只在某處, 然後對該處執行動作。

\t\t\t\t\t \t\t\t\t\t \t\t\t\t\t \t\t\t\t\t \t\t\t\t\t

\n\t\t
\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\t \n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t
ID X Closed tr.table can have JS. Go on developing is#text? paste-string erase-#text-anchorNode\n         \n          \n   \n\t\t\t\t\t\t
[x]

Subject

Attachments

\t\t\t\t\t \t\t\t\t\t \t\t\t\t\t \t\t\t\t\t \t\t\t\t\t

\n \t
ID X Closed Textarea can be read-only by .disable=true, how to use that?  
[x]OK
<textarea> 可以設定 attribute disabled=true 變成 read only 就不會老是被誤觸,此時 cursor 不會跑進去。
> <o> <textarea id=ttt></textarea></o>

> js> ttt.disabled \\ ==> false OK 
> js> ttt.disabled=true
> js> ttt.disabled=false
> js> ttt.disabled=true


List all <textarea>.isDisabled
> run: .\" <textarea> isDisabled?\" cr js> $('textarea').length for r@ 1- . space r@ js> $('textarea')[pop()-1].isDisabled . cr next
<textarea> isDisabled?
14 false
13 false
...snip ...
0 false

Disable all <textarea> except inputbox and Enable all <textarea>, status remained after log.save.
> run: .\" Disable all <textarea> except inputbox\" cr js> $('textarea').length for r@ js> $('textarea')[pop()-1].disabled=true next js: inputbox.disabled=false
> run: .\" Enable all <textarea>\" cr js> $('textarea').length for r@ js> $('textarea')[pop()-1].disabled=false next

Note! Can't receive oncontextmenu event if the textarea is disabled.

\t\t\t\t\t \t\t\t\t\t \t\t\t\t\t \t\t\t\t\t \t\t\t\t\t

[x] trbody++ should add an entire <tr> or the existing textarea will be erased. Save the original entire innerHTML and then add appended HTML then assign back to the element.innerHTML=pop() then OK. 

[x] words {F7} lists only partial words on popup page when extension page is opened. <-- was a bug.

\n\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t
2016-02-29 12:55:253ce does not work well with target page when a 3ce extension page is opened.[2016-03-09 20:30:36 ]

Description

複習 3ce 的使用
    因為又是 popup page, 又是 target page, 又是 extension page, 命令是誰發給誰執行的, {F7}、<ce>、(dictate),已經胡里胡塗了。
    > attach3 \\ start experiment.
    > ---- Entering *debug* ---- > 555>>> > q > ---- Leaving *debug* ---- > 666>>>  OK 
    這時候 jeforth.f 已經 included,
    > words (dictate) <------------------ 錯! s\" words\" (dictate) 才對。
    {F7} 與 (dictate) 都可以用了。

New problem after changed to use /ceV:
Uncaught ReferenceError: target_f7_handler is not defined(anonymous function) @ VM1538:21(anonymous function) @ VM1538:126
hao123.js?st=-16863:1 Uncaught TypeError: Cannot read property 'error' of undefinedw @ hao123.js?st=-16863:1u @ hao123.js?st=-16863:1w @ hao123.js?st=-16863:1
3extensions::uncaught_exception_handler:8 Error in event handler for runtime.onMessage: TypeError: vm.forthConsoleHandler is not a function

Javascript object member 不能直接 get 到他們的 parent 要轉個彎:
    http://stackoverflow.com/questions/2980763/javascript-objects-get-parent
    > <js> var f = function(){ type(arguments.callee.value)}; f</jsV> constant f

    > f :: () \\ ==> undefined OK 
    > f :: value=123
    > f :: () \\ ==> 123 OK  Bingo!!
    Background page 的 vm.type() 藉此得到 background window object.

[x] 對 background page jeforth 下令的範本:   
    background-page <js> pop().bvm.dictate(\".s\")</js>
    background-page :> bvm.screenbuffer .

[x] How to refresh/reset background page ? <-- forget this, 已經改用 manifest.json
    不能重複 init background page
    因為 background page 一直都在, popup & 3ce extension page can have multiple instances.
    如果每個 instance 都來 init background page 會怎樣?
    若要重複 init 只要 background-page :: jeforth_project_k_virtual_machine_object=null
    然後 refresh 3ce extension page or popup page 即可 (include ce.f 就會 init background page)。


\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t
\n\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t
2016-03-02 17:41:43Switch 3ce target page type() prints to local console3we or extension pages[2016-03-11 10:08:38]

Done,
Defined in target.f

\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t


[x] 從 3ce extension page 去查 background page 的 tabs.getCurrent() 啥結果: 
background-page <js> pop().bvm.dictate(\"js: chrome.tabs.getCurrent(function(tab){push(tab)}) .s\")</js>
background-page :> bvm.screenbuffer . \\ ==> undefined 跟 popup page 一樣。

\n\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t
2016-03-08 17:50:04\n3ce message SPEC 增加 \"addr\" field 或者 host pages 自行過濾  [2016-03-10 16:55:59 ]

Description
See Ynote: http://note.youdao.com/share/?id=6759efb1877ba5c5f2ab149879d9707a&type=note
Attachments

\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t
\n\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t
2016-03-10 13:20:243ce SPEC of chrome.[tabs|runtime].[sendMessage()|onMessage.addListener()][2016-03-10 16:56:47]

The discussion:3ce SPEC of message:
chrome.[tabs|runtime].sendMessage({
    forth: \".s\", /* forth statements */
    type : \"hello world!\", /* for all 3ce pages include the popup and the background */
    tos  : anything, /* Sender passes TOS to receiver */
    addr : \"background\" | (tabs.getcurrent :> id) /* host tabid, given by host himself I guess */
})

Real example of chrome.runtime.onMessage.addListener(function(message, sender, sendResponse){}) arguments:
The message is {
    \"type\": \" OK \"
}
The sender is {
    \"id\": \"khjienijgaapbcofpbbogdlcclhbmjoa\",
    \"url\": \"http://www.hao123.com/haoserver/jianfanzh.htm\",
    \"tab\": {
        \"active\": false,
        \"audible\": false,
        \"favIconUrl\": \"http://www.hao123.com/favicon.ico\",
        \"height\": 775,
        \"highlighted\": false,
        \"id\": 222,
        \"incognito\": false,
        \"index\": 2,
        \"mutedInfo\": {
            \"muted\": false
        },
        \"pinned\": false,
        \"selected\": false,
        \"status\": \"complete\",
        \"title\": \"hao123网址之家-在线繁体字转换\",
        \"url\": \"http://www.hao123.com/haoserver/jianfanzh.htm\",
        \"width\": 1440,
        \"windowId\": 1
    },
    \"frameId\": 0
}
The sendResponse is undefined <--- [ ] the function that calls the callBack, I remember or I guess so.

\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t
\n\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t
2016-04-04 18:14:05Let HTML5 Local Storage be a jeforth.3htm/3ce source code directory2016-04-08 17:24:16

已經成功完成 localstorage.f 供 3ce, 3htm, 3nw 使用。 

[x] 3ce 內 popup page, extension page, 連 background page 都共享同一個 local storage localStorage,
    查看 background page 的 localStorage :
    background-page <js> pop().bvm.dictate(\"js> localStorage (see)\")</js>
    background-page :> bvm.screenbuffer .
[x] Target page 有自己的 localStorage, 不必先 attach 3ce extension page & popup 都可以直接查看 tibid page :
    > <ce> localStorage.sourcecode </ceV> .
    I am in target page Bing.comdisplay->host OK 

Chrome, NW.js 抓 innerHTML of textarea element 只會抓到當初 <textarea> foo bar </textarea> 當中的 value, 有就有、沒有就沒有,不會因為 edit 而變動。HTA textarea 的 innerHTML 則是動態的, 只有 3HTA 很方便可以用來當 editor。 

\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t
\n\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t
2016-04-05 16:00:09Study 用 3ce 自動抓除權除息表  [ ]

Description

直接用 jQuery 就好了, 根本用不著 table_to_json.js 之類東西 

祭出 table to json , 學問來了! Target page 上的 root URL 是 Target page 的, 要 include 東西得寫上完整的網址, 以 3ce 而言, 如下:<h> <script src=\"js/jquery.tabletojson.js\"></script> </h> drop <---- failed,  GET http : // jdata . yuanta . com . tw/z/ze/zeb/js/jquery.tabletojson.js?_=1459926197825 404 (Not Found)

要改成: <h> <script src=\"chrome-extension://khjienijgaapbcofpbbogdlcclhbmjoa/js/jquery.tabletojson.js\"></script> </h> drop

結果又是: Denying load of chrome-extension : // khjienijgaapbcofpbbogdlcclhbmjoa / js/jquery.tabletojson.js  Resources must be listed in the web_accessible_resources manifest key in order to be loaded by pages outside the extension. --> See http : // open.chrome . 360 . cn / extension_dev / manifest.html#web_accessible_resources or my YNote for the manifast.json field \"web_accessible_resources\" that is supposed for this issue. --> 加上這個 solution 好了! 用 <h><script> 動態灌進 target page 網頁的 ~.js code 都要先在 manifast.json 登記。[x] 怎麼 jquety 沒有先登記?

直接用 jQuery 就好了:

js> $(\"tr\")[6] :> innerText . \\ 查看某 row, 不顧 table 的界線!真有彈性。

js> $(\"td\",$(\"tr\")[6/*row*/])[0/*column*/] :> innerText . \\ 查看某 cell

 

HTML5 < tr > a row of a table can be used alone without being in a < table >

Like this : <o> <tr><td>11</td><td>22</td></tr></o>, so can be < td >

[x] 這個寫法居然也可以!!!! Hash 的內容宣告時就直接裝配 instead of using assignment statements.
16 <js> var hh = {a:$(\"td\")[tos()].innerText,b:$(\"td\")[tos()+1].innerText}; hh</jsV> (see)
Refer to 'all-company' also, wonderful ability of JavaScript!

用 next sibling of <td> 可以推進 access 下一個 <td>, 到 row 底就變成 null <td>

      3: [object HTMLTableCellElement] (object) <----------- a <td> element
> js> pop().nextElementSibling dup :> innerText . \\ ==> 105/04/13 OK
> js> pop().nextElementSibling dup :> innerText . \\ ==> 81.89020477 OK
> js> pop().nextElementSibling dup :> innerText . \\ ==> OK
> js> pop().nextElementSibling dup :> innerText . \\
> js> pop().nextElementSibling dup :> innerText . \\ ==> JavaScript error
                                                    : Cannot read property 'innerText' of null

HTML element ID 可以重複使用,但是只有第一個生效, 很合理。
js> $(\"#oAddCheckbox\").length . cr \\ ==> 1 只有第一個生效, 之後的都無實效。
js> $(\"#oAddCheckbox\")[0].innerText . cr / <== the 1st instance 01004T富邦R2 OK
js> $(\"#oAddCheckbox\")[1].innerText . cr / <== Error! over the upper bound.
js> document.getElementById(\"oAddCheckbox\").innerText \\ ==> 01004T富邦R2 OK

Again, cr or nap and sleep can't be used in event handler
\"save\" command of local storage ls.f was not in any event handler and it uses \"cr\"
to print messages. Then I wrote {s} to support Ctrl-s that utilizes save command and
then strange problem happened. {s} is supposed to leave a false to stop event bubbling
but that doesn't

\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t
\n\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t
2016-04-06 13:59:343ce 還是 local 好用, 但與其用 3ce 限制重重(不能 include javascript), 還不如直接用 3htm <-- 錯了! 要控制別人的網頁就必須用 3ce. 2016-04-06 14:03:24

DescriptionAttachments

\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t


[x] 3ce target page console3we was once become too narrow due to the CSS
    setting of that target page I guess. The solution is simply
    js: $(\".console3we\").width(\"1200px\")  

 

 


> log.save
","
2016-03-08 15:26:04Review project-k kernel interface, something need to be removed and 3ce background page can be simplified further.[ ]

Experience of 3ce background page. It needs vm.type vm.prompt vm.panic vm.greeting vm.readTextFile vm.clearScreen ... that are too many! Attachments

\t\t\t\t\t \t\t\t\t\t \t\t\t\t\t \t\t\t\t\t \t\t\t\t\t \t\t\t\t

--

[x] 改革 log.commands 用 stack 的方式之外, 也要有直接 access 的方式,更實用。log.roll 之外再加強
    log.list 用第一行來 random access 所有的 sections。
    --> See Ynote, http://note.youdao.com/share/?id=3c77701beda7d9c037155f2d37bb0b2a&type=note 
    --> leave log along, create new tr interface and use the same database log.json.
    --> Local Storage is the solution.

[x] log.recall to show extra title of the section. but log.save should remove the title.
    --> local storage + ed is the solution
[x] editbox's bigger/smaller can be removed. We have F9/F10 new function already.
    --> local storage + ed is the solution
[x] EditBox --> HTMLbox
    --> local storage + ed has supported both
[x] 3hta [add] button does not work in many cases
    --> local storage + ed overed that 
[x] 3ce attach to target page plus command line of forth commands
[x] Improve EditBox failed cases, idiot-proof or provide more helpful info like 'border-on'.
    --> local storage + ed overed that 

\n\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t
2016-03-21 11:13:24改革 log.{commands} 用 stack 的方式之外, 也要有直接 access 的方式,更實用。2016-04-29 09:41:36

local storage + ed has covered this issue.Attachments

\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t
--
\n\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t
2016-03-21 15:15:263ce should have its own jeforth.3ce.html at root directory. ( also jeforth.3ce.background.html ) --> 3ce should briefing itself at the beginning page!!
2016-04-06 14:06:42

3ce popup page and extension pages were using /index.html as their home page. That requires none 3ce application, i.e. jeforth.3htm to also include ce.f that's buggy. ce.f has to judge whether it is running in Chrome extension environment too, very annoying.

Youtube 上的簡介
\"jeforth.3ce\" (jeforth for Chrome Extension)  has just been published to Chrome web store (2016/03/29). But can't find it by searching \"jeforth\" nor \"jeforth.3ce\". It's too young and having too few population I guess. However, pleaes use the link below to the installation page.
https://chrome.google.com/webstore/detail/jeforth3ce/npgnnakjbggncblfdpaihigcljehmmdd?hl=en-US&gl=TW

\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t

> log.save
"] \ No newline at end of file +["
 

1. jeforth 範例

做習題:jQuery, w3schools, ... etc.

1. https://groups.google.com/forum/?hl=zh-TW#!searchin/figtaiwan/from$3Ame/figtaiwan/yDme4LWg2BA/rmj7qvro0V4J

http://www.w3schools.com/html/html_youtube.asp

2. <o> <iframe width=\"420\" height=\"315\"
src=\"http://www.youtube.com/embed/XGSy3_Czz8k?autoplay=1\">
</iframe></o>

寫筆記:outputbox, log.html, jeforth HTML editor.

Tips

fork chrome --allow-file-access-from-files

2. 研討: jeforth kernel(s)

「Kernel 能抽換」如果有意義,FigTaiwan 就應該來定協議。 

好像只是定義一些 global variables, functions 而已,這篇最下方有表列。
https://github.com/hcchengithub/project-k/wiki/Play-with-the-Forth-kernel

> log.push
","

kvm --> kvm is not defined(…)(anonymous function) @

vm --> vm is not defined(…)(anonymous function) @

var elescript=document.createElement('script')
undefined
elescript.setAttribute(\"src\",\"project-k/projectk.js\")
elescript.setAttribute(\"src\",\"projectk.js\")
undefined
elescript.setAttribute('type',\"text/javascript\")
undefined
document.getElementsByTagName(\"head\")
[<head>​…​</head>​]
document.getElementsByTagName(\"head\")[0]
<head>​…​</head>​
document.getElementsByTagName(\"head\")[0].appendChild(elescript)
<script src=​\"project-k/​projectk.js\" type=​\"text/​javascript\">​</script>​

// 只用 F12 debugger 就可以把 projectk.js 抓進來:
elescript=document.createElement('script')
elescript.setAttribute(\"src\",\"projectk.js\")
elescript.setAttribute('type',\"text/javascript\")
document.getElementsByTagName(\"head\")[0].appendChild(elescript)
// 天上仙女下凡塵
vm = new jeForth()
// 查看 jeforth VM
JSON.stringify(vm,\"\\n\",\"\\t\")
for(var i in vm) console.log(i+\" (\"+ typeof(vm[i])+\"), \")


 


> log.save
OK
> log.save
","

Wed Jan 20 11:38:22 UTC+0800 2016

Chrome extension 的研究已有成果, 開始朝向在 target 頁面 inject jeforth.3htm 的方向研究。

\n

直接在 target 網頁上跑 jeforth.3htm 應該是最方便的辦法。背後有 jeforth.3ce 當後盾,可以取得需要的支援。

\\ Chrome extension code 在 global name space.

> <ce> var x=123</ce>
> <ce> x </ceV> .
123 OK 

\\ We have inject command to include any JavaScript 
\\ code to the target tab.

char project-k/projectk.js inject


\\ Make vm be the jeforth VM.
> <ce> var vm = new jeForth() </ceV> .s

\\ Test jeforth VM
> <ce> vm.stack().length </ceV> .
0 OK 
> <ce> vm.dictate(\"11 22 33\") </ceV> .
> <ce> vm.stack().length </ceV> .
3 OK 
> <ce> debugger </ceV> -- triggers F12 debugger
> <ce> var e=document.createElement(\"div\")</ce>
> <ce> e.setAttribute('id','outputbox')</ce>
> <ce> document.body.appendChild(e) </ceV> .s
      1: [object Object] (array)
> <ce> e.innerHTML=\"<h1>I am a DIV!!!</h1>\" </ceV> .
<h1>I am a DIV!!!</h1> OK 

<ce> 
  // outputbox
  var e=document.createElement(\"div\");
  e.setAttribute('id','outputbox');
  document.body.appendChild(e);
  e.innerHTML=\"<h3>jeforth.3htm is here to serve you.</h3>\"
  // inputbox
  var e=document.createElement(\"textarea\");
  e.setAttribute('id','inputbox');
  document.body.appendChild(e);
  e.value=\"type command here\"
</ce>

aaaabbbb


aaaabbbb


aaaabbbb


aaaabbbb


aaaabbbb



> log.save
","> <o> <div>
   <div class=green>
       <style>
           .green { color: green;}
           .green .asize {font-size:2em;}
           .green .bsize {font-size:0.8em;}
       </style>
       <h3> I am a H3 tag</h3>
       <p class=asize> I am a P tag of green and A-size</p>
       <b class=bsize> bold <i>italiy</i> sdfsdfsdf B-size in the entire B tab </b>
       <span class=bsize> bold <i>italiy</i> sdfsdfsdf B-size in the entire SPAN tag </span>
       <span> bold <i>italiy</i> sdfsdfsdf B-size in the entire SPAN tag </span>

   </div>
       <div class=blue>
       <style>  
           .blue { color: blue;}
           .blue .asize {font-size:0.8em;}
           .blue .bsize {font-size:2em;}
       </style>
       <h3> I am a H3 tag</h3>
       <p class=asize> I am blue P tag A-size</p>
       <b class=bsize> bold <i>italiy</i> sdfsdfsdf B tag with B-size</b>
       <span class=bsize> bold <i>italiy</i> sdfsdfsdf B-size in the entire SPAN tag </span>
       <span> bold <i>italiy</i> sdfsdfsdf B-size in the entire SPAN tag </span>
   </div>
</div></o>

\n\t
\n\t\t\n\t\t

I am a H3 tag

\n\t\t

I am a P tag of green and A-size

\n\t\t bold italiy sdfsdfsdf B-size in the entire B tab \n\t\t bold italiy sdfsdfsdf B-size in the entire SPAN tag \n\t\t bold italiy sdfsdfsdf B-size in the entire SPAN tag \n\n\t
\n\t\t
\n\t\t\n\t\t

I am a H3 tag

\n\t\t

I am blue P tag A-size

\n\t\t bold italiy sdfsdfsdf B tag with B-size\n\t\t bold italiy sdfsdfsdf B-size in the entire SPAN tag \n\t\t bold italiy sdfsdfsdf B-size in the entire SPAN tag \n\t
\n

OK
> \\ How , how to make this happen on a target Tab of 3ce ????????? --> if chrome.extension.getBackgroundPage()\n also gets the window object of the background page in contecnt-script then this is easy. But, no, it doesn't appear in any content script's isolated world. See below experiment:

> <ce> typeof(chrome.extension.getBackgroundPage)</ceV> . \\ ==> undefined OK when in target tab
> <js> typeof(chrome.extension.getBackgroundPage)</jsV> . \\ ==> function OK when in 3ce

[x] 我稱作 target tab 者, Google 稱作 content script; 我稱作 background page 者, 他稱作 extension page。
[x] study RTFS .. use message to communicate target page content script and extension page. work on ce.f
[x] ce.f 成功了! {F7} 執行 jeforth command on the target tab now. Fri Jan 22 11:03:37 UTC+0800 2016
[x] log.x needs Ctrl-s hotkey to save log.save. (inputbox and outputbox) share the same event handler
    {ios} that fired onkeydown(). Other edit-zone(s) can have their own Ctrl-S handler too.
[x] ' log.recall :: lastrecalled 防呆機制。
[x] cls 要清除 ' log.recall :: lastrecalled
[x] Ctrl-S 要有一點視覺效果, 用現成的 toggle outputbox edit mode 來回即可。


> log.push
"," OK
> --- marker ---
<o>
 <canvas id=\"myCanvas\" width=\"300\" height=\"200\">
   你的瀏覽器不支援Canvas標籤, 請改用Chrome,Opera,Firefox,IE9或Safari
 </canvas>
</o> drop
js> document.getElementById('myCanvas') value canvas
js> vm.g.canvas.getContext('2d') value flag
js> vm.g.canvas.width value flag_w  
js> vm.g.canvas.height value flag_h
js> vm.g.flag_w/4 value circle_x
js> vm.g.flag_h/4 value circle_y
\\ 滿地紅
js: vm.g.flag.fillStyle='rgb(254,0,0)'
js: vm.g.flag.fillRect(0,0,vm.g.flag_w,vm.g.flag_h)
\\ 青天
js: vm.g.flag.fillStyle='rgb(0,0,149)'
js: vm.g.flag.fillRect(0,0,vm.g.flag_w/2,vm.g.flag_h/2)
\\ 白日:星芒
js: vm.g.flag.beginPath();
js> vm.g.flag_w/8 value star_radius
<js>
var angle = 0;
for (var i = 0; i < 24; i++) { // 12道星芒,24條線
   angle += 5 * Math.PI * 2 / 12;
   var toX = vm.g.circle_x + Math.cos(angle) * vm.g.star_radius;
   var toY = vm.g.circle_y + Math.sin(angle) * vm.g.star_radius;
   if (i) vm.g.flag.lineTo(toX, toY);
   else vm.g.flag.moveTo(toX, toY);
}
</js>
js: vm.g.flag.closePath(); \\ 可忽略
js: vm.g.flag.fillStyle='#fff';
js: vm.g.flag.fill();
\\ 白日:藍圈
js: vm.g.flag.beginPath()
js: vm.g.flag.arc(vm.g.circle_x,vm.g.circle_y,vm.g.flag_w*17/240,0,Math.PI*2,true)
js: vm.g.flag.closePath();
js: vm.g.flag.fillStyle='rgb(0,0,149)';
js: vm.g.flag.fill();
\\ 白日:白心
js: vm.g.flag.beginPath();
js: vm.g.flag.arc(vm.g.circle_x,vm.g.circle_y,vm.g.flag_w/16,0,Math.PI*2,true);
js: vm.g.flag.closePath();
js: vm.g.flag.fillStyle='#fff';
js: vm.g.flag.fill();


\n \n 你的瀏覽器不支援Canvas標籤, 請改用Chrome,Opera,Firefox,IE9或Safari\n OK
> log.save
","

研究 Chrome extension 存檔到本地 disk 的方法


This stackoverflow page gives the answer : http://stackoverflow.com/questions/2153979/chrome-extension-how-to-save-a-file-on-disk 

And this is an example in the answers,

Google Webstore 
Github

I made an extension that does something like this, if anyone here is still interested. It uses an XMLHTTPRequest to grab the object, which in this case is presumed to be an image, then makes an ObjectURL to it, a link to that ObjectUrl, and clicks on the imaginary link.

answered Aug 10 '12 at 4:14
\"\"

--

(function() {

 function saveImage(e) {
  var filename = this /* 就是那個被 drag 的圖 */ .src.substring(this.src.lastIndexOf(\"/\") + 1);
  // 從 src 裡剪切出 最後面的 filename 部分. 作者用 grab 很有趣, 似乎 grab 正好只對 images 有效!!
  e = e ? e : window.event;
  var xhr = new XMLHttpRequest();
  xhr.responseType = 'blob';
  xhr.onload = function() {
   // xhr.response is a Blob
   var url = webkitURL.createObjectURL(xhr.response);
   var a = document.createElement('a');
   a.href = url;
   a.download = filename;
   var e = document.createEvent('MouseEvents');
   e.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
   a.dispatchEvent(e);
   window.webkitURL.revokeObjectURL(url);
  };
  xhr.open('GET', this.src);
  xhr.send();
  return false;
 }

 var documentImages = document.images;
 for ( i = 0; i < documentImages.length; ++i)
  documentImages[i].ondragend = saveImage;
})()

--

this
<img class=​\"currentImg\" onload=​\"alog && alog('speed.set', 'c_firstPageComplete', +new Date)​;​ alog.fire && alog.fire('mark')​;​\" src=​\"http:​/​/​www.itokoo.com/​attachment/​Mon_1409/​21_3_36be70c14afa54b.jpg?46\" width=​\"910\" height=​\"606\" log-rightclick=​\"p=5.102\" title=​\"点击查看源网页\" style=​\"cursor:​ pointer;​ width:​ 490px;​ height:​ 248.5px;​ top:​ 215.25px;​ left:​ 0px;​ display:​ block;​\">​

[ ] 3ce Program path http://...... <--- can be very long that corrupts the outputbox, click to change
[x] New word run> to run through the entire, rest of the, inputbox.value, not only one line.
[ ] This 3ce one liner lists all images in the webpage:
    js> document.images <js> for (var i in tos()) { type(tos()[i].src+\"\\n\") } </js> drop
[ ] How about their actual linkage? Bigger pic anticipated. 
[x] How to make a copy of an element -->  it works!
       <o> <p id=pp> this is an element</p></o> drop
       js: $(pp).clone().insertAfter(pp)
    Also this sample code:
       js: $(document.images.item(2)).clone().insertBefore(inputbox)
log.saved :)
","

在 target page 上安裝 jeforth.3ce inputbox outputbox

[x] 像這樣的東西 event.shiftKey 在 hotkey handler 裡面還是可以用的,例如:
\n        : {F6} js: alert(event.shiftKey) false ;
\n    works fine. Try press F6 with and without shift key.
\n[x] 3 log.roll moves log stack item up to the top so as to be log.drop works fine now.
\n[x] js> outputbox needs border-toggle ok now
\n[x] {F7} command line need to be added to command line history. --> very easy. One line only.
\n[x] {F7} needs idiot-proof to make a warning when target page is not attached yet. --> 算了,每次都檢查,浪費時間。
\n[x] Target tabid refresh 過後就得重新 attach, 即可。
\n[x] attach 應該自動 inject jQuery 到 tabid
\n    char js/jquery-1.11.2.js inject drop
[x] 發現! Extension page refresh 過後, 原來已經 attached 過的 target page 還是 attached,
    似乎只要 Extension page 
的 tabid 對的就可以。
\n



\n[x] 都好了, 可以來寫 target tab 上的 inputbox outputbox 了...
\n    [x] 1. attach \\ {Enter}, target page refresh 過就要重新 attach。
\n    [x] 2. char js/jquery-1.11.2.js inject drop \\ {Enter}
\n    [x] 3. char body <e> <textarea id=inputbox>I am the inputbox id is inputbox</textarea></e> drop \\ {F7}
\n\n    \\ 照這樣在 tabid target tab 上使用是 ok 的,
\n    > char body <e> <h3>I am a h3</h3></e> .s \\ ==> 0: [object Object] (object)
\n    > dup :> nodeName . \\ ==> H3 OK
\n    \\ 為何這樣不行?
\n    >  char body <e> <textarea id=inputbox>I am the inputbox id is inputbox</textarea></e> drop \\ {F7}
\n    [x] 看起來不像不表示不行,不能進這個 textarea 去 edit 的確很奇怪。簡化實驗看看 . . . OK
\n    char body <e> <textarea>in a textarea </textarea></e> .s \\ F7
\n    [x] 那試試原來的. . . . ok now.
\n    [x] 進一步改成 outputbox
\n        char body <e> <div id=outputbox>this is the outputbox</div></e> drop \\ {F7}
\n    [x] 合併起來
\n        char body <e>
\n            <div id=console3ce class=ce3>
\n            <style>
\n                .ce3 {
\n                    color:black;
\n                    font: 20px \"courier new\";
\n                    padding:20px;
\n                    word-wrap:break-word;
\n                    border: 1px ridge;
\n                    background:#F0F0F0;
\n                }
\n                .ce3 textarea {
\n                    width:100%;
\n                    padding:4px;
\n                    border: 0px solid;
\n                    background:#BBBBBB;
\n                }
\n            </style>
\n
            <div id=outputbox>this is the outputbox</div>
\n            <textarea id=inputbox>I am the inputbox id is inputbox</textarea>
\n            </div>
\n        </e> drop \\ {F7}
\n        ---> it works!! 本來 CSS has a
\n

\n
\nCSS style font 照順序提供以下 items 至少要有 font size 跟 font family:  
normal默认值。浏览器显示一个标准的字体样式。
italic浏览器会显示一个斜体的字体样式。
oblique浏览器会显示一个倾斜的字体样式。
inherit
normal默认值。浏览器会显示一个标准的字体。
small-caps浏览器会显示小型大写字母的字体。
inherit规定应该从父元素继承 font-variant 属性的值。
描述
normal默认值。定义标准的字符。
bold定义粗体字符。
bolder定义更粗的字符。
lighter定义更细的字符。
  • 100
  • 200
  • 300
  • 400
  • 500
  • 600
  • 700
  • 800
  • 900
定义由粗到细的字符。400 等同于 normal,而 700 等同于 bold。
inherit规定应该从父元素继承字体的粗细。
font-size/line-height规定字体尺寸和行高。参阅:font-size  line-height 中可能的值。
font: 40px \"courier new\"; <--------- Works fine.
\nfont: 40px courier new; <---------- it works too, the quote is not necessary.
\nfont: 40px courier news; <---- Typo, become 'Times new roman' as the result
\nfont: 40px courier-new; <---- Failed, become 'times new roman' too.
\nfont: 40px \"courier-new\"; <-------- Failed! become 'Times new roman'.
\n\n
\n[x] [CSS style experiment] 改改看, 能不能用 .ce3 (div,textarea) { ... } 這樣的形式? <---- 不行。\n
\n[x] [CSS style experiment] 先讓笨寫法成功  .ce3 div, .ce3 textarea { ... } <------ 這樣寫成功了。
\n    意思是 class=ce3 最外圍這個 DIV 之內的所有 DIV 跟 TEXTAREA 的 style 要如此這般。

\n\n


\\ 故意讓 target page 的 stack TOS 放 {aa:111,bb:222} 且安排讓它的 message callBack 傳回整個
\\ target page 的 stack 這樣做成功。
> tabid js: chrome.tabs.sendMessage(pop(1),\"depth\",function(r){push(r)})
 OK 
> depth
 OK 
> .s
      0:      112233       1b669h (number)
      1: [object Object] (object)
      2:           2           2h (number)
 OK 
> .s
      0:         228          e4h (number)
      1:         228          e4h (number)
      2: 112233,[object Object],2 (array) <==== callBack 傳回的 target page stack
 OK 
> dup :> [1] (see) <=== 果然可以傳回 object 
{
    \"aa\": 111,
    \"bb\": 222
} OK 


\\ 但是當 target page stack TOS 是它的 document object 時同樣的指令就會出錯:

> tabid js: chrome.tabs.sendMessage(pop(1),\"depth\",function(r){push(r)})
JavaScript error : Invocation of form tabs.sendMessage(array, string, function) doesn't match definition tabs.sendMessage(integer tabId, any message, optional object options, optional function responseCallback)

\\ 這個訊息沒有指出真正的問題,然而在 target page 的 F12 debugger 上顯示的是:
Error in event handler for runtime.onMessage: Error: Attempting to use a disconnected port object
\\ 似乎比較貼近,問題是不准傳送被禁止傳送的 object (window or document)。

> .s <--- 用 {F7} 執行, 看 target page 的 stack: 
      0:      112233       1b669h (number)
      1: [object Object] (object) <---------- {aa:111,bb:222}
      2:           2           2h (number)
      3: [object Object] (object) <---------- document object
\\ 結論是, target page 的 message 可以用來傳 object 回 host page。但只能是非 DOM 的東西。

[x] Target page 端 see word 的結果沒有印出 word.help 而是 [object Object] 之類.
    --> <ce> jQuery</ceV> 傳回 [null] array. 可能只能傳 text 回來。
[x] help 的結果顯示他是最舊版的。
[/] 希望可以在 FireFox 上執行, 啊不行 \"Chrome extension\"!
    因為 FireFox 有 Scrapbook 可以把整夜都抓起來,似乎有甚麼獨門秘訣。
[x] 3ce should have its own 3ce/platform.f to redefine the I/O.  --> ce.f + 3ce/quit.f that's all
[x] ce.f attach is very big. what it does are : 1.pick tabid, 2.inject project-k 3.setup platform
    dependent interfaces, 4. Start listening jeforth commands.--> ce.f + 3ce/quit.f that's all
[x] working on 3ce's quit.f. 應該先利用 Chrome extension 的 API 儘快做出 readTextFile 即可化簡 attach。

修改從 Target page Content Script 發回 Extension page 的 messaging protocal. 本來只是 string
現在改成 hash {isCommand:boolean,text:string} 其中 isCommand 是 optional 如果 ommit 就當作是 string message 如前 (because .isCommand is undefined which is a logical false)。經實驗成功,如下:

\\ 下令從 Target page 端發回命令讓 Extension page 執行 version 命令。
> <text> js: chrome.runtime.sendMessage({isCommand:true,text:\"version\"}); </text> (dictate)

\\ 收到的回覆:
> js: chrome.runtime.sendMessage({isCommand:true,text:\"version\"}); \\ <-------- 在 Target 端執行的命令。
j e f o r t h . 3 h t m -- v3.1 \\ <------------------ 在 Extension page 執行 'version' command 的結果。
source code http://github.com/hcchengithub/jeforth.3we
Program path chrome-extension://khjienijgaapbcofpbbogdlcclhbmjoa/index.html OK 

有了這套機制,就可以從 target page 下命令回 Extension page 幫忙讀取檔案。
\n


: readTextFileAuto ( \"pathname\" -- \"text\" ) \\ Read text file from jeforth.3ce package.
    s\" <text> \" swap + s\" </text> readTextFileAuto\" + \\ command line 以下讓 Extention page 執行
   
js: chrome.runtime.sendMessage({isCommand:true,text:pop()},function(){execute('stopSleeping')}) 
    10000 sleep ;

[x] {F7} 應該是 call (dictate) 來做事才對, 不該自己發 chrome.tabs.sendMessage(pop(1),pop())。

[x] 雙向都用 .sendMessage({isCommand:true,text:\"version\"}) 協定。


FigTaiwan
[x] This word partially already works fine on reading the file to Extension page's TOS.
    But the result didn't pass to target page. 可能只是因為 Extension page 要 update 一下剛寫好的程式?
    : readTextFileAuto ( \"pathname\" -- \"text\" ) \\ Read text file from jeforth.3ce package.
        s\" <text> \" swap + s\" </text> readTextFileAuto\" + \\ command line 以下讓 Extention page 執行
        <js> chrome.runtime.sendMessage({isCommand:true,text:pop()},
        function(result){push(result);execute('stopSleeping')}) </js>

        10000 sleep ;

[x] 手寫的筆記 http://note.youdao.com/share/?id=dc2af7872280a434c32475e858ef045b&type=note 實驗出
    來, sendMessage() 可以來回用 callBack。
[x] bug, attach leaves 7 false on host stack. 
    --> char f/jeforth.f (install) leaves the first false. Not caused by jeforth.f, so it's (install)
    --> (dictate) shoul not return a false to terminate event bubbling.

[x] message callBack to return something, it is supposed anything. ---> Yes!
[x] Can't attach js> window.open(\"playground/anual.htm\"), why? It really returns a window object and 7 false.
    [x] <ce> can't work on views (3ce's pages) <ce> window</ceV> or anything else returns an undefined.
        log 裡 executeScript section 早就發現了, F12 有 error message。
 

\n


Step 1. Restart tartet page and Host page, Attach, and run F7 on host
: readTextFileAuto ( \"pathname\" -- \"text\" ) \\ Read text file from jeforth.3ce host page.
s\" <text> \" swap + s\" </text> readTextFileAuto\" + \\ command line 以下讓 Extention page 執行
<js> chrome.runtime.sendMessage({isCommand:true,text:pop()},
function(result){push(result);execute('stopSleeping')}) </js>
10000 sleep ;

step 2. words F7 on host, check readTextFileAuto exists on target page.

Step 3. s\" 3nd.bat\" readTextFileAuto F7 on host page.

Step 4. .s F7 on host page. ---> expect the 3nd.bat file but it's not.


\\ Read the file on host side, it works.
> s\" 3nd.bat\" readTextFile .

@REM set NODE_PATH=%NODEJSHOME%\\node_modules
node jeforth.3nd.js %1 %2 %3 %4 %5 %6 %7 %8 %9
 OK 

\\ Run F7 to define this word on target page.
> : readTextFileAuto ( \"pathname\" -- \"text\" ) \\ Read text file from jeforth.3ce host page.
        s\" <text> \" swap + s\" </text> readTextFileAuto\" + \\ command line 以下讓 Extention page 執行
        <js> chrome.runtime.sendMessage({isCommand:true,text:pop()},
        function(result){push(result);execute('stopSleeping')}) </js>
        10000 sleep ;   
\\ execute by F7

 OK 

\\ Check the new word is really appeared on target page,
> words  \\ F7 to execute

... snip ...
-------- element.f (13 words) --------
ce-history ce! ce@ <>escape jump-to-ce@ se (ce) ce ce< (er) er list-links readTextFileAuto 
 OK 


> s\" 3nd.bat\" readTextFileAuto  \\ execute by F7 
 OK 
> .s
empty
 OK 
> .s
      0: dummy,3ce,doc,f,3htm/f,3htm/canvas,3htm,playground (array) <---- The result is strange!!
 OK 



> \\ check if the result is really from the host? is really what the host replied through message callBack?
> \\ debugger break-point at end of the message when isCommand

message.text
\"<text> 3nd.bat</text> readTextFileAuto\"
stack
[\"3nd.bat\", Array[8]0: \"dummy\"1: \"3ce\"2: \"doc\"3: \"f\"4: \"3htm/f\"5: \"3htm/canvas\"6: \"3htm\"7: \"playground\"length: 8__proto__: Array[0]]

結果真的是這樣。 我很懷疑 host side 的 onMessage event handler 裡面可以使用 dictate() 來處理事情。以前有討論過。複習複習....


\\ jeforth.hta inputbox 本身就是個最兇的 event 他會改 stack. 別的 event handler 都得負責恢復 stack.
\\ The correct implementation of the handler is,
\\   : handler char . . js> rstack.length if 0 >r then ;
\\ Push 0 to rstack due to the assumption of that all handlers are started from the waiting state,
\\ 0 brings the handler back to waiting sate, instead of popping up rstack and return to a unknown forth VM
\\ state!!

用 forth colon word 當 event handler, interrupt service routine 的要領:
 o  jeforth.hta inputbox 本身就是個最兇的 event 他會改 stack. 別的 event handler 都得
    balance data stack and return stack.
 o  所有的 event handler 都要【接地】也就是直接回到 JavaScript host 也就是 idle state 去。
    不能在 dictate() 或 execute() 之後放別的 JavaScript code 還以為是前面做好了才下來的,
    錯! dictate() 或 execute() 裡面很可能有 nap 或 sleep 那時候它就衝下來了! sleep 才可
    以 stopSleeping 所以應該是它。

[x] Repeat the SRP above, but intentionally push some 0's into the rstack. Count the 0's after the
    SRP to prove my theory. --> I add 3 0's on rstack of the target page 3ce VM. After the above procedure,
    that did reproduced the problem, then use debugger instruction to trigger F12 of the target page, check
    rstack, still 3 0's in its rstack.

\n當 host 能夠收 target page messaging 來的 readTextFileAuto command, 表示 host 當時在 idle state 如以前討論出來的結果。這時候它的 rstack 應該是空的或者 RTOS 是 0, 後者是在 napping or sleeping 的情形。[x] 首先, 既然是個類似 interrupt 進來的 dictate() -- 要負責 balance data stack and rstack, 而且還是個 I/O command -- 離開時檔案還沒讀好, 這個 dictate() 一下來一定要【接地】也就是要回到 JavaScript host 的 idle state 去。 總之, host 端的 message handler 不能以為 dictate() 回來就是整串 forth command 都做完了,實際上只是在 nap 或 sleep 等 I/O 時就會衝下來, 此時打 callBack 是不行的。這樣看來, host message handler 裡面打 callBack 已經不可行了。

由 event handler 裡的 dictate() 或 colon word 知道 I/O 已經完成之後打個 message 給 target page. 這時候當初 target 打過來的 message 已經結束了, 所以如果有多 target 的話就不知道是誰了, event handler 一上手在 sleep 等 I/O 之前就要把 sender 存下來放在 [x] ?????(這真是個問題)。只有一個 target page 就不怕這個顧慮了。 --> tabid 變數只有一個 ....

\n


想要用 background page 來跟 target page 傳資料行, background page 是 extension pages 自己內部用的。以下的實驗簡單就把用 background page 來跟 target page 交換資料的意圖打消了。

[x] When I review ce.f trying to recall my memory about how to pass an object to target page, getBackgroundPage() caught my eyes. Use it to get background page window object maybe a good idea to transfer data through it. But, that good idea is not allowed.

> js> chrome.runtime obj>keys . \\ F7, run in a target page
PlatformOs,PlatformArch,PlatformNaclArch,RequestUpdateCheckStatus,OnInstalledReason,OnRestartRequiredReason,getManifest,getURL,connect,sendMessage,onConnect,onMessage,id OK 
> js> chrome.runtime obj>keys . \\ Enter, run in the host page
PlatformOs,PlatformArch,PlatformNaclArch,RequestUpdateCheckStatus,OnInstalledReason,OnRestartRequiredReason,getBackgroundPage,openOptionsPage,getManifest,getURL,setUninstallURL,reload,requestUpdateCheck,restart,connect,sendMessage,getPlatformInfo,getPackageDirectoryEntry,onStartup,onInstalled,onSuspend,onSuspendCanceled,onUpdateAvailable,onBrowserUpdateAvailable,onConnect,onConnectExternal,onMessage,onMessageExternal,onRestartRequired,id OK 


> js> chrome.extension obj>keys . \\ F7, run in a target page
ViewType,sendRequest,getURL,onRequest,inIncognitoContext,connect,sendMessage,onConnect,onMessage OK 
> js> chrome.extension obj>keys . \\ Enter, run in the host page
ViewType,sendRequest,getURL,getViews,getBackgroundPage,isAllowedIncognitoAccess,isAllowedFileSchemeAccess,setUpdateUrlData,onRequest,onRequestExternal,inIncognitoContext,connect,sendMessage,onConnect,onConnectExternal,onMessage,onMessageExternal OK 
\n 
想要用 chrome.tabs.executeScript(integer tabId, object details, function callback)
也不行, 不能從 host 送東西過去給 target。看來還是只有 message 了。

有結論了, 就用 message, interface 仿 Chrome 的 argument --> http://note.youdao.com/share/?id=4aeeaf6fafc45e08056a771faf9e167e&type=note\n\n 

New protocal, which can pass the self-test, is : 3ce SPEC of sendMessage({forth:\".s\",type:\"hello world!\",tos:anything})
\nBut the readTextFileAuto in 3ce/quit.f does not leave anything in target stack but there are many tabid left in host stack. 

After the following experiments, finally works! 


 : readTextFileAuto ( \"pathname\" -- \"text\" ) \\ Read text file from jeforth.3ce host page.
  s\" s' \" swap + s\" ' readTextFileAuto \" + \\ command line 以下讓 Extention page (the host page) 執行
  s\" {} js: tos().forth='stopSleeping' js: tos().tos=pop() \" + \\ host side packing the message object
  s\" message->tabid \" + \\ host commands after resume from file I/O
  js: chrome.runtime.sendMessage({forth:pop()})
  10000 sleep ;   

 : test1 ( -- \"text\" ) \\ experiment : Read text file from jeforth.3ce host page.
  s\" s' 3hta.bat' readTextFileAuto {} js: tos().forth='version' message->tabid \"
  js: chrome.runtime.sendMessage({forth:pop()})
  10000 sleep ;  
  /// ok, 'version' really run on target page. Next step try to send something to target page.
  
 : test2 ( -- \"text\" ) \\ experiment : Read text file from jeforth.3ce host page.
  s\" s' 3hta.bat' readTextFileAuto {} js: tos().forth='version' js: tos().tos=1122334455 message->tabid\"
  js: chrome.runtime.sendMessage({forth:pop()})
  10000 sleep ;  
  /// Ok! Target page stack become [1122334455, 3.1 (TOS)] as anticipated.
  /// the file has read too. But a 239 appear in host stack unexpectedly.
  /// try manual do the same thing on host.
  
 s' 3hta.bat' readTextFileAuto {} js: tos().tos=5566 <js> tos().forth='version .s' </js>  message->tabid  
 \\ This line works fine 

\\ This is the workable final version   
 : readTextFileAuto ( \"pathname\" -- \"text\" ) \\ Read text file from jeforth.3ce host page.
  s\" s' \" swap + s\" ' readTextFileAuto .s \" + \\ command line 以下讓 Extention page (the host page) 執行
  s\" {} js: tos().forth='stopSleeping' js: tos().tos=pop(1) \" + \\ host side packing the message object
  s\" message->tabid \" + \\ host commands after resume from file I/O
  js: chrome.runtime.sendMessage({forth:pop()})
  10000 sleep ;   

 這下有了 readTextFileAuto 之後, attach 就可以大大地簡化了!

Everything went fine, next step is to complete the input/outputbox things,

Including editor.f
JavaScript error : body is not defined
JavaScript error on word \"jsEvalNo\" : endofinputbox is not defined
JavaScript error on word \"</js>\" : endofinputbox is not defined
JavaScript error on word \"stopSleeping\" : endofinputbox is not defined

[x] We have readTextFile, we can hand the control to the target page earlier.
[x] vm.inputbox is not used ever. use local variable instead
[x] Error happens when executing 'attach' from popup page while an extension page is opened.
what appear in the popup page is: 這個問題自動消失了
Error! <e> unknown.
JavaScript error on word \"stopSleeping\" : inputbox is not defined
 OK  OK  OK  OK 

> \\ and what appear in the target page F12 :
Error in event handler for runtime.onMessage: ReferenceError: inputbox is not definedhandler @ extensions::uncaught_exception_handler:8(anonymous function) @ extensions::uncaught_exception_handler:100EventImpl.dispatch_ @ extensions::event_bindings:376EventImpl.dispatch @ extensions::event_bindings:393target.(anonymous function) @ extensions::SafeBuiltins:19publicClass.(anonymous function) @ extensions::utils:94messageListener @ extensions::messaging:179target.(anonymous function) @ extensions::SafeBuiltins:19EventImpl.dispatchToListener @ extensions::event_bindings:387target.(anonymous function) @ extensions::SafeBuiltins:19publicClass.(anonymous function) @ extensions::utils:94EventImpl.dispatch_ @ extensions::event_bindings:371EventImpl.dispatch @ extensions::event_bindings:393target.(anonymous function) @ extensions::SafeBuiltins:19publicClass.(anonymous function) @ extensions::utils:94dispatchOnMessage @ extensions::messaging:310
\n



[x] h2o.f does not work on attached page. Canvas disappeared too in Extension page after, guess a cls but that's normal.
[x] 3ce target page, include math.f failed
[x] char playground/math.f readTextFileAuto . <-- works fine. w/o path failed. So why vm.path does not work? --> readTextFile should return a \"\" if failed. --> when failed, there's no message.tos, how about message.forth? --> no either, no message from host at all. See experiments below,

This experiment worked,
> \\ char aaa readTextFile

{} js: tos().forth='shooo!stopSleeping' js: tos().tos=\"112233\"
message->tabid

This experiment does not trigger message.tos nor message.forth on target id side.
> \\ char aaa readTextFile
{} js: tos().forth='shooo!stopSleeping' js: tos().tos=\"\"
message->tabid

More test --> try breakpoint before both of them .. RI! target page message handler if(message.tos) was a mistake, readTextFile failed return \"\" will then be skipped that's a mistake. if(message.tos!=undefined) then ok.

\n


[x] project-k baby.html does not accept commands now!!! sample.html either. 可能是把 kvm 都改成 vm 造成的。 為什麼要這樣改? 因為 3ce 很多動作都變成是 event handler 裡完成, 跟其他的 jeforth 版本不同了。人家用 vm 的 3ce 要改成 kvm 才行因為 event handler 裡只看得見 kvm。所以都改成 vm 3ce 就好了。但是同名會怎樣? 這是誰優先的問題。既然是同一個東西, 應該不會有問題。

--> 現在又好了, 不知道初三那天 T550 怎麼了。

\n


[ ] 改革 log.commands 用 stack 的方式之外, 也要有直接 access 的方式,更實用。log.roll 之外再加強 log.list 用第一行來
    random access 所有的 sections。
[ ] attach works fine from popup, so I don't need extra page. That means that I don't need to use index 0 as the default tabid. Click FigTW icon and attach to the page underneath.
[ ] 可以用 mouse 在 target tab 上 *點指* 出要操作的東西,
    jeforth baby>  js> window.getSelection().anchorNode.nodeValue .
    hi there!!! OK
    jeforth baby> <js> window.getSelection().anchorNode.nodeValue=\"Hello,I've got changed!\"</js>
    [ ] 希望可以 hover onmousexxxx 更好, 方便在 target page 上操作其上的 hyperlinks 不受干擾。
[ ] 由 event handler 裡的 dictate() 或 colon word 知道 I/O 已經完成之後打個 message 給 target page. 這時候當初 target 打過來的 message 已經結束了, 所以如果有多 target 的話就不知道是誰了, event handler 一上手在 sleep 等 I/O 之前就要把 sender 存下來放在 [x] ?????(這真是個問題)。只有一個 target page 就不怕這個顧慮了。 --> tabid 變數只有一個 ....
[ ] 透過 rawgit 讓 users install 3ce !!

","

This is sample code to create Tracking System section before the outputbox
> <o> <div id=ts class=tr>....</div></o> js> outputbox insertBefore

This problem was known because there are some unexpected white spaces between the wanted <tag> and </h> and </h> returns the last node which in this case is a white space text node. My solution is to improve </o> </h> </e> letting them remove the leading and ending white space from the given string.
rstack[0]:1  stack[[object Text]]:1 <========== Why TEXT NODE? why not the style element in <head> ??

> js> head.outerHTML .            \\ 查看 <head> 整個
> js> $('style').length .         \\ 看看有多少 <style> in or not in the <head>
> js> $('style')[1].innerHTML .   \\ 查看某個 <style> element, 好像不一定照先後順序。
> js> $('style')[1] removeElement \\ 殺掉某個 <style> element

>  js> $('style').length . 
3 OK
>  js> $('style')[1] .
[object HTMLStyleElement] OK
> js> $('style')[1] (see)  <------------ <style> element object 不能用 (see) 的? 對,不能。
{} OK

","

[Closed] Sticky Notes always on top, A closed TR is tr.table=disabled


[x] TR ticket to have a time stamp of the last modified time. If the copy in log.json is newer then warning when save.

[x] Design a table for TR --> see tutor-cloth.f
[x] When working on a new log item which has just pushed to log. Got error:
       log.save canceled, lastrecalled and log.length-1 mismatch!
    this is a bug.

2016-02-24 10:56:03簡化 3hta, platform.f, {ios} 不該寫多套 event handler。
[2016-02-24 16:12:30 ]
{ios} is for Ctrl-s, when 's' pressed when in (I)nputbox or (O)utputbox. Ctrl-s 要 save 存檔, 有了 console3we 之後, 可以把它簡化,不用兩處都各寫一套 handler。

--
   \t\t\t\t\t \t\t\t\t\t

--

\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t
2016-02-25 21:00:58Compare HTA <> Chrome to see what are unique attributes?[2016-02-25 22:39:36 ]

Chrome's <table> obj>keys:

HTA's <table> obj>keys:

[x] I need to design a showdup.exe (my old tool) equivalent command.

Use showdup to find unique properties. These are unique <table> properties of either HTA or Chrome:

Results:
Not appear in Chrome, these are HTA only <table> properties:

Chrome only <table> properties:
大家都有一缸子獨特的東西。

\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n \t\t\t\t\t \t\t\t\t\t     \t

--
\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t
2016-02-25 22:41:44Ctrl-Enter that executes inputbox -- don't scroll to inputbox after execution, remain at where it was.[ 2016-02-26 16:25:54]
Description

Attachments
\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n \t\t\t\t\t \t\t\t\t\t     \t

--
\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t
2016-02-26 09:35:45How to track back to a certain ancester parent?[2016-02-26 09:52:39 ]
有答案:


\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n \t\t\t\t\t \t\t\t\t\t     \t


--

2016-02-25 17:30:06tr.table to have more buttons2016-02-28 17:12:19
Description

Attachments
\t\t\t\t\t \t\t\t\t\t  \t\t\t\t\t \t\t\t\t\t     

 

2016-02-24 11:04:47Make Windows \"StickyNote.exe\" always on top
2016-02-28 17:12:03
Description

   \t\t\t\t\t \t\t\t\t\t
","[x] I tried to automate re-maping Acer S7 OA's keybaord. It was not successful. Target is to
    be able to switch to original for using an external keybaord, and switch to the remaped layout
    for when using the internal keyboard. ---> Done! See below. Very easy.
[x] Read my older log.txt and Ever note, Ynote \"map any key to any key\". I found that T550 Caps Lock
    has actually been changed. That means the registry is still working for Windows 10.

> include registry.f
OK
> s\" HKLM\\SYSTEM\\CurrentControlSet\\Control\\Keyboard Layout\\Scancode Map\" regRead constant regkey
> regkey :> ubound() tib.
regkey :> ubound() \\ ==> 19 (number)

> <js>
for(var i=0; i<=vm.g.regkey.ubound(); i++){
push(vm.g.regkey.getItem(i));
dictate(\".b space\");
}
</js>

00 00 00 00 00 00 00 00 02 00 00 00 20 e0 3a 00 00 00 00 00 OK

00 00 00 00 header

00 00 00 00 header

02 00 00 00 modified 1 key, What? this is T550, what modified?

20 e0 (new ) 3a 00 (target )

00 00 00 00 ending
 
See YNote \"jeforth.3we keyboard remapping\" for the conclusion: run ~.reg files and re-login, that Ynote page has the two .reg files attached.
 

","

Study Chrome extension, Chrome App

實驗 Chrome extensions 的功能


js> chrome.runtime.id . \\ ==> khjienijgaapbcofpbbogdlcclhbmjoa OK
PlatformOs,PlatformArch,PlatformNaclArch,RequestUpdateCheckStatus,OnInstalledReason,OnRestartRequiredReason,getBackgroundPage,openOptionsPage,getManifest,getURL,setUninstallURL,reload,requestUpdateCheck,restart,connect,sendMessage,getPlatformInfo,getPackageDirectoryEntry,onStartup,onInstalled,onSuspend,onSuspendCanceled,onUpdateAvailable,onBrowserUpdateAvailable,onConnect,onConnectExternal,onMessage,onMessageExternal,onRestartRequired,id 

chrome.browserAction.getTitle({},function(result){alert(result)})
js: chrome.browserAction.getTitle({},function(result){type(result)})
[ ] 實際上就是去查看 manifest.json 裡面的 browserAction field 填甚麼。

\n

browserAction.getBadgeText browserAction.setBadgeText

js: chrome.browserAction.getBadgeText({},function(result){type(result)})

js: chrome.browserAction.setBadgeText({text:\"ABCD\"})

[x] 這個非常好玩又有用。


> js> chrome obj>keys .
loadTimes,csi,Event,app,browserAction,extension,i18n,management,permissions,runtime,tabs,windows OK 

有辦法取得所有的 Tab 了! 先用 query 全部都抓成 array 取得 tabid 然後就好辦了。

<js> chrome.tabs.getCurrent(function(tab){push(tab);dictate('(see) .\" Done!!\" cr')})</js>

\\ 上面這行在 popup page 中執行, 得到 undefined。 在正常的 jeforth.3htm tab 中執行得到該 Tab 的 
\\ Chrome extension Tab object. jeforth 可以用來分辨目前的 page 是否 popup page, Bingo !!!
\\ (要考慮 asynchronous behavior)
\\ See also getViews()


> .s

      0: [object Object] (object)
 OK 
> dup (see)
[object Object]
  active :   true
  audible :   [object Boolean]
  height :   775
  highlighted :   true
   id :   198 <------------- ID is not 0,1,2...
  incognito :   [object Boolean]
  index :   1
  mutedInfo :   [object Object]
  pinned :   [object Boolean]
  selected :   true
  status :   complete
  width :   1440
  windowId :   1
 OK 

\\ tabs.getCurrent 在 popup page, background page 用拿到 undefined, getSelected 要作廢了。改用 tabs.query 試試,
\\
tabs.query <js>
 for(var i in tos()){
  if(tos()[i].active){
   push(pop()[i].id);
   break; // <---------------- 有多個 window 就有多個 active tabs. 如何知道有幾個 Chrome window ? 答案還是 tabs.query.
  }
 }
</js>

--

tabs.query 真的有 query 的功能:

<js> chrome.tabs.query({title:\"*anual*\"},function(tabs){
push(tabs);
execute('stopSleeping')
})</js> 10000 sleep er (see)

* tabs.query 只列出看得見的 tabs, 含 chrome://extensions/ , chrome://history/ , 但不含 popup , background
Command line: {} tabs.query (see)



> js: chrome.tabs.get(0,function(tab){push(tab)}) .s <---- Id is not 0,1,2,...
      0: [object Object] (object)
 OK 
> .s
      0: [object Object] (object)
      1: undefined (undefined)
 OK 
> js: chrome.tabs.get(1,function(tab){push(tab)}) .s
      0: [object Object] (object)
      1: undefined (undefined)
 OK 
> .s
      0: [object Object] (object)
      1: undefined (undefined)
      2: undefined (undefined)
 OK 


<js> chrome.tabs.query({},function(tabs){push(tabs);dictate('dup (see) .\" Done!!\" cr constant tabs')})</js>
 OK 
> .s
      3: [object Object],[object Object],[object Object],[object Object] (array)
 OK 
> constant tabs  
 OK 
> tabs (see)
[object Object],[object Object],[object Object],[object Object]
  0 :   [object Object]
  1 :   [object Object]
  2 :   [object Object]
  3 :   [object Object]
 OK 
> tabs :> [0] (see)
[object Object]
  active :   [object Boolean]
  audible :   [object Boolean]
  favIconUrl :   chrome://theme/IDR_EXTENSIONS_FAVICON@2x
  height :   775
  highlighted :   [object Boolean]
  id :   2
  incognito :   [object Boolean]
  index :   0
  mutedInfo :   [object Object]
  pinned :   [object Boolean]
  selected :   [object Boolean]
  status :   complete
  title :   擴充功能
  url :   chrome://extensions/
  width :   1440
  windowId :   1
 OK 
> tabs :> [1] (see)
[object Object]
  active :   true
  audible :   [object Boolean]
  height :   775
  highlighted :   true
  id :   198
  incognito :   [object Boolean]
  index :   1
  mutedInfo :   [object Object]
  pinned :   [object Boolean]
  selected :   true
  status :   complete
  width :   1440
  windowId :   1
 OK 
> tabs :> [2] (see)
[object Object]
  active :   [object Boolean]
  audible :   [object Boolean]
  height :   775
  highlighted :   [object Boolean]
  id :   178
  incognito :   [object Boolean]
  index :   2
  mutedInfo :   [object Object]
  pinned :   [object Boolean]
  selected :   [object Boolean]
  status :   complete
  width :   1440
  windowId :   1
 OK 
> tabs :> [3] (see)
[object Object]
  active :   [object Boolean]
  audible :   [object Boolean]
  height :   775
  highlighted :   [object Boolean]
  id :   182
  incognito :   [object Boolean]
  index :   3
  mutedInfo :   [object Object]
  pinned :   [object Boolean]
  selected :   [object Boolean]
  status :   complete
  width :   1440
  windowId :   1
 OK 
> tabs :> [4] (see)
undefined (undefined)

用對了 tabid 就成功了!

> js: chrome.tabs.get(198,function(tab){push(tab)})
 OK 
> .s
      0: [object Object] (object)
      1: undefined (undefined)
      2: undefined (undefined)
      3: [object Object] (object)
 OK 
> (see)
[object Object]
  active :   true
  audible :   [object Boolean]
  height :   775
  highlighted :   true
  id :   198
  incognito :   [object Boolean]
  index :   1
  mutedInfo :   [object Object]
  pinned :   [object Boolean]
  selected :   true
  status :   complete
  width :   1440
  windowId :   1
 OK 



360's online document in Chinese
 is the best resource for Chrome extension.
I am trying available functions. 



> js: chrome.tabs.query({},function(tabs){push(tabs)})
      3: [object Object],[object Object],[object Object],[object Object],[object Object] (array)

> value tabs
> .s
      0: [object Object] (object)
      1: undefined (undefined)
      2: undefined (undefined)
 OK 
> dropall
 OK 
> tabs :> [0] (see)
[object Object]
  active :   [object Boolean]
  audible :   [object Boolean]
  height :   775
  highlighted :   [object Boolean]
  id :   238 <================================= get the ID of Diigle My libaray page
  incognito :   [object Boolean]
  index :   0
  mutedInfo :   [object Object]
  pinned :   [object Boolean]
  selected :   [object Boolean]
  status :   complete
  width :   1440
  windowId :   1
 OK 
> tabs :> [0] (see)
[object Object]
  active :   [object Boolean]
  audible :   [object Boolean]
  height :   775
  highlighted :   [object Boolean]
  id :   238
  incognito :   [object Boolean]
  index :   0
  mutedInfo :   [object Object]
  pinned :   [object Boolean]
  selected :   [object Boolean]
  status :   complete
  width :   1440
  windowId :   1
 OK 

List again, after I pull out the jeforth.3ce tab to a separated window. Then the tabs are still the same. So tabs are cross window and it's more useful then window.
 
> js: chrome.tabs.query({},function(tabs){push(tabs)})

 OK 
> .s
      0: [object Object],[object Object],[object Object],[object Object],[object Object] (array)
 OK 
[x] We can use  {} tabs.query (see)  now.

tabs.detectLanguage

http://open.chrome.360.cn/extension_dev/tabs.html
Try chrome.tabs.detectLanguage(integer tabId, function callback) <======== Bingo !!
> dropall <js> 
chrome.tabs.detectLanguage(238,function(arg){
push(arg);
dictate(\".' Done' .s\")})
</js>
 OK Done      0: en (string)
\n > dropall 
chrome.tabs.detectLanguage(function(arg){
push(arg);
dictate(\".' Done' .s\")})
</js>
 OK Done      0: en (string)

getSelected   <------ Try Eliminating deprecated chrome.tabs.getSelected from your code and use chrome.tabs.queryinstead.

chrome.tabs.getSelected(integer windowId, function callback)

获取特定窗口指定的标签。

 OK 
dropall <js>
chrome.tabs.getSelected( function(w){
push(w);
dictate(\".' Done' .s\")})
</js>
// chrome.tabs.getSelected(integer windowId, function callback)
 OK Done      0: [object Object] (object)

> (see)
[object Object]
  active :   true
  audible :   [object Boolean]
  height :   513
  highlighted :   true
  id :   198 <========= the recent jeforth.3ce Tab.
  incognito :   [object Boolean]
  index :   0
  mutedInfo :   [object Object]
  pinned :   [object Boolean]
  selected :   true
  status :   complete
  width :   1022
  windowId :   246 <=== I pull out the jeforth.3ce tab to a separated window, this is it.


tab.getCurrent

To try request and messaging, I opened another jeforth.3ce window and get the info

\n<js> chrome.tabs.getCurrent(function(tab){  \\ <-- 同樣是 jeforth 得知自己是 popup, background, 或其他。
    push(tab);
    dictate(' .\" done!!\" cr (see)')
})</js>

 OK done!!
[object Object]
  active :   true
  audible :   [object Boolean]
  height :   513
  highlighted :   true
  id :   248 <======================= this is the new jeforth.3ce tabid, so can 248 talk to 198 ?
  incognito :   [object Boolean]
  index :   1
  mutedInfo :   [object Object]
  openerTabId :   198 <------------- Look at this! tabid 198 opened this tab.
  pinned :   [object Boolean]
  selected :   true
  status :   complete
  width :   1022
  windowId :   246 <=== yeah, the same window.


\n

How to change the title of a tab

For multiple instance, I'll need to change the title of the jeforth.3ce tab,

> js> $(\"title\")[0].innerHTML .
jeforth.3htm OK 


\n

[ ] captureVisibleTab

\\ chrome.tabs.captureVisibleTab(integer windowId, object options, function callback)
\\ 在特定窗口中,抓取当前选中标签的可视区域。 这要求必须在 host permission 中指定对标签URL的访问权限。
<js> chrome.tabs.captureVisibleTab(1,function(x){push(x);dictate('(see) .\" Done!!\" cr')})</js>
 OK undefined (undefined) <---------- I guess, selected is not made yet.
Done!!

dropall <js>
chrome.tabs.getSelected( function(w){
push(w);
dictate(\"(see) .' Done!!' cr\")})
</js>
> (see)
[object Object]
  active :   true
  audible :   [object Boolean]
  height :   598
  highlighted :   true
  id :   199 <------------------- aleady selected, actually which is the active tab.
  incognito :   [object Boolean]
  index :   2
  mutedInfo :   [object Object]
  pinned :   [object Boolean]
  selected :   true
  status :   complete
  width :   1280
  windowId :   1
 OK 

\n

see-manifest

[x] I want to check the recent Manifest.json

see https://developer.chrome.com/extensions/runtime#method-getManifest getManifest object chrome.runtime.getManifest()

dropall js> chrome.runtime.getManifest() (see) <---------- Bingo!!!
[x] Now we have see-manifest
--

--


Google engineers/designers already covered this case. Ha ha! Can't close() a window unless . . > dropall <js> chrome.tabs.executeScript(
    207,
    {code:'window.close()'},
    function(result){push(result)}
)</js>
Error message : Scripts may close only the windows that were opened by it.


getViews

http://open.chrome.360.cn/extension_dev/extension.html#method-getViews
array of global chrome.extension.getViews(object fetchProperties)
以 array 的形式返回当前扩展运行的所有页面(由 3ce 所 create 的 tabs, 而非人家的 tabs)的JavaScript “window”对象。 <------------- No, this is NOT what I am looking for!

> js> chrome.extension.getViews() <------------ It works!!
> .s
      0: [object Window] (array) <---- returned an array
> value windows
> windows :> length . 
1 OK  <--------------------------------- which is the current Tab, the jeforth.3ce tab itself.
> windows :> [0] obj>keys .
external,chrome,document,$,jQuery,jeForth,jeforth_project_k_virtual_machine_object,kvm,AppView,ExtensionOptions,ExtensionView,WebView,f,colonxt,speechSynthesis,caches,localStorage,sessionStorage,webkitStorageInfo,indexedDB,webkitIndexedDB,ondeviceorientation,ondevicemotion,crypto,postMessage,blur,focus,cl... snip ... OK 
> windows :> [0].document.title .
jeforth.3htm OK 

js> chrome.extension.getViews({type: 'popup'}) <--- 從 3ce tab 執行抓不到東西, correct.
<js> chrome.extension.getViews({type:null,windowId:null})</jsV> :> length . <--- 總是 1 即 3ce tab 自己。
[x] 並非抓回所有的 tabs' window object !! why? <--- it gets 3ce's own tabs only. RTFS!

[x] 想要抓某個 Tab 的 Window object window.open() 就是了! --> strange, I remember it worked, but now it returns [object global] which is an empty object.


content script

http://www.cnblogs.com/cart55free99/archive/2014/05/26/3753722.html

[x] modify my manifest.json to have a content_script field. <--- This is to inject Tabs by default automatically, that's not the case jeforth.3ce wants to use.
看起來 jeforth.3ce 不用 content scripts 這種東西, 我們一定是臨時 injects 所以只要用已經試過的 chrome.tabs.executeScript(integer tabId, object details, function callback) 就對了。


 

[x] 若想讓 tabs.executeScript 跑東西把該 tab 的 window object 傳回來, 就得先有辦法傳資料...允許嗎? <--- No, it'll be an empty window object.




executeScript

http://stackoverflow.com/questions/13166293/about-chrome-tabs-executescript-id-details-callback
chrome.tabs.executeScript(integer tabId, object details, function callback)
向页面注入JavaScript 脚本执行。要了解详情,请查阅内容脚本文档的 programmatic injection 部分。

一旦设置好了权限,就可以通过调用 executeScript()来注入 javascript 脚本。如果要注入 css, 可以调用 insertCSS()
http://open.chrome.360.cn/extension_dev/content_scripts.html

<js> chrome.tabs.executeScript(
    203, <-------------------------------- 不能是 Chrome extension 自己的頁面, 否則觸發 error 只有 F12 看得見。
    {code:'alert(\"ABCDE\")'},
    function(x){
        opush(x);
        dictate('(see) .\"done!!!\" cr ')
    }
</js>

這裡有 executeScript 的 sample 但是我試不行,問題如上。
http://stackoverflow.com/questions/13166293/about-chrome-tabs-executescript-id-details-callback

<js> chrome.tabs.executeScript(
203,
{code:'var x=123;x'}, <----------------------- 沒有執行到, 觸發 error 了。
function(result){push(result)}
)</js>

> .s
      6: undefined (undefined)
--

<js> chrome.tabs.executeScript(
null,  <------------------------------------------------ this tab 本身還是不行。
{code:'var x=123;x'}, <---- leaves x as the return value, 執行不到。
function(result){push(result)} <---- nothing in result.
)</js>

> .s
      7: undefined (undefined)
--
哈! 用 debuger 一看嚇一跳,問題一大堆。可見要隨時打開 debugger 來看才行。

> <js> chrome.tabs.executeScript(
199,
{code:'var x=123;x'},
function(result){push(result)}
)</js>

Unchecked runtime.lastError while running tabs.executeScript: Cannot access contents of url \"chrome-extension://facnlnflcdhbelabokalhfenlhknknnh/index.html\". Extension manifest must request permission to access this host. ---> http://stackoverflow.com/questions/14361061/extension-manifest-must-request-permission-to-access-this-host
    at eval (eval at <anonymous> (eval at docode (chrome-extension://facnlnflcdhbelabokalhfenlhknknnh/project-k/projectk.js:1:0)), <anonymous>:1:13)
    at Word.newxt [as xt] (eval at docode (chrome-extension://facnlnflcdhbelabokalhfenlhknknnh/project-k/projectk.js:1:0), <anonymous>:4:7)
... snip ...

--> [x] Use the stackoverflow article's manifestjson still failed. I guess extension page are not allowed to executeScript even by jeforth.3ce which is its own script. <== Yes!
Try to specify another tab then ok.

--

Bingo!! Ok now

dropall <js> chrome.tabs.executeScript(
207, // <-------------------------------------------- Can not be a jeforth.3ce Tab.
{code:'console.log(\"hello I am jeforth.3ce\")'},
function(result){push(result)}
)</js>

Where 207 is a Tabid which is NOT any jeforth.3ce tab. And I found every Chrome tab has its own F12 debugger instance simultaneously. I can see the message appear in that Tab's debugger console now. The root cause was really the permission issue. jeforth.3ce tab can not be executeScript'ed which is a good thing.

--
\nThis snippet really returns the number 112233 through an array:

<js> chrome.tabs.executeScript(
225,
{code:'112233'},
function(result){push(result)}
)</js>

 OK 
> .s
      0: 112233 (array)

\nAnd this snippet really returns an object that looks like a window object,

<js> chrome.tabs.executeScript(
225,
{code:'window'},
function(result){push(result)}
)</js>

But that object does not contains a real DOM window.

Can add TabId to the page's title,

<js> chrome.tabs.executeScript(
225,
{code:'document.title+=\"#225\";document.title'},
function(result){push(result)}
)</js>
--

So, how about to inject projectk.js?

<js> chrome.tabs.executeScript(
225,
{code:'alert(\"hi!\");jeForth',file:'project-k/projectk.js'},
function(result){push(result)}
)</js>

---> No, the error essage is : Unchecked runtime.lastError while running tabs.executeScript: Code and file should not be specified at the same time in the second argument.  

--
> <js> chrome.tabs.executeScript(
225,
{file:'project-k/projectk.js'}, <--- So, jeForth() is existing in that tab? Check by F12 ... Nope! 其實這就已經成功了! 只是因為它所處的 thread 是獨立的 extension thread 所以這樣看不見。
function(result){push(result)}
)</js> .

undefined OK  <----- this is correct. projectk.js does not leave any value.
--
> <js> chrome.tabs.executeScript(
225,
{file:'project-k/projectk.jssss'}, <--- \"failed to load file\"
function(result){push(result)}
)</js> .
So, it really worked but as mentioned __________ it's a separated environment. ---> [x] Try a separated projectk.js kernel that does something ... 以下成功了!
--

> <js> chrome.tabs.executeScript(
225,
{file:'3ce/projectk.js'},  <--- the special projectk.js really alerts a message. So this works. But after that, check by F12 debuger, window.vm is not existing. So it's really a separated environment. The previous experiment tried to return a window object that can be done but the window object will become empty after the executeScript life cycle. 以後用不著這樣, 用 project-k 的應該就可以了。
function(result){push(result)}
)</js> .

Note!!! try this again,
<js> chrome.tabs.executeScript(
225,
{code:'vm.dictate(\"hi\")'},
function(result){push(result)}
)</js> .
and it works !!! So the above injected jeforth kernel is really existing in that page already. How about to run debugger?

<js> chrome.tabs.executeScript(
225,
{code:'vm.dictate(\"hi\");debugger'}, <---- Yes, bingo!! it closed existing F12 and opened a new instance that works correctly with vm acknowledge. So debug is not a problem then. Another way to see objects in the separated thread is running console.log(object) command. That shows the object in F12 debugger but can't really USE it. To really use them, issue debugger command to switch to the separated thread. In that case, the thread is paused.
function(result){push(result)}
)</js> .

so, ok, only message is allowed. let's try messaging.... actually, all jeforth versions are using text message as the UI. So it's not so bad at all. I can't save a window object to disk neither even when using 3hta or 3nw. so the situation is actually the same.


Sending and receiving message

--
\\ This is my first successful experiment
<text>
chrome.runtime.onMessage.addListener( // 設定 target 端的 message handler
function(request, sender, sendResponse) {  // 收到 message 就顯示其中 info。
console.log(request);
console.log(sender);
console.log(sendResponse);
})
</text>

<js>
chrome.tabs.executeScript (   // 從 host 端透過 executeScript 在 target 端佈署 onMessage listener
 225,{
  \"code\": pop()
 },
 function(result){push(result)} // executeScript 執行完之後傳回最後 statement 的 value。
) </js> .

\\ try to send a message over
js: chrome.tabs.sendMessage(225,\"something\")

\\ this is the console.log results in F12 debugger,
something <---------------------------------------- the message
Object {id: \"khjienijgaapbcofpbbogdlcclhbmjoa\"} <--- the sender object
function (response) { <-------------------------- the sendResponse() function
        if (port) {
          port.postMessage(response);
          privates(port).impl.destroy_();
          port = null;
        } else {
          // We nulled out port when s…

--


\\ Now try to get a response message from the content script:\t

\\ This is the content script:

<text>
chrome.runtime.onMessage.addListener(
    function(request, sender, sendResponse) {
        console.log(request);
        console.log(sender);
        sendResponse(\"This is my response\"); // <----- make a response string.
    }
)
</text> <js> 
chrome.tabs.executeScript (
    225,{
        \"code\": pop()
    },
    function(result){push(result)}
) </js> . // <----- See result

undefined OK  <------------ the code has no return value
> js: chrome.tabs.sendMessage(225,\"something\",function(response){push(response);type(\"responed\\n\")})

 OK responed <--------- it worked

> .s
      0:  (array)
      1: This is my response (string) <----------- Bingo!!!
   
--

\\ Try again, but response an object

>     <text>
    chrome.runtime.onMessage.addListener(
        function(request, sender, sendResponse) {
            console.log(request);
            console.log(sender);
            sendResponse({aa:11,bb:22});
        }
    )
    </text>
    <js> 
    chrome.tabs.executeScript (
        225,{
            \"code\": pop()
        },
        function(result){push(result)}
    ) </js> .

undefined OK 
> js: chrome.tabs.sendMessage(225,\"expecting-an-object\",function(response){push(response);type(\"responed\\n\")})
 OK responed

> .s
      0:  (array)
      1: [object Object] (object)
 OK 
> dup (see)
{
    \"aa\": 11,
    \"bb\": 22
} OK 


The above messaging system is actually very annoying. Now I'd like to use window.open() to get the window object directly! ---> failed. it returned [object global] not [object Window] and the global object is empty. I don't remember what I see when I said window.open() could be a solution, however, it's not. ==> if the opened tab is under 3ce's root folder then window object is [object Window]; if is out of the root folder then it's not accessable [object global].

* 想要取得 target page 的 window object 是來自 Microsoft IE ShellWindows 的 idea。在 Chrome extension 是用 content script 來取代的,更好、更安全。也就是把 code 送進 target page 用 isolated world 來執行,中間用 message 來回傳遞命令與資料——而非把 window object 交給 host。

> list-tabs
283 My Library <--------------------- get the tabid
233 jeforth.3htm
229 chrome extension overview - cart55free99 - 博客园
241 标签--扩展开发文档
237 分类索引--扩展开发文档
267 br711 - Google 搜尋
263 Freebord - Snowboard the Streets
245 Gartner Magic Quadrant - App. Sec. Testing - hcchen5600@gmail.com - Gmail
2 MSN.com - Hotmail, Outlook, Skype, Bing, Latest News, Photos & Videos
 OK 
> <js> chrome.tabs.executeScript(  <------------- inject jeforth kernel 
283,
{file:'project-k/projectk.js'}, 
function(){dictate(\".' project-k kernel has injected to the specified Tab.' cr \")}
)</js>
 OK project-k kernel has injected to the specified Tab.

> <js> chrome.tabs.executeScript(
283,
{code:'window.vm = new jeForth();'}, <--------------- create the jeforth vm 
function(result){push(result);dictate(\".' Done!! TOS is the result.' cr \")} <--- result 不含 methods
)</js>
 OK Done!! TOS is the result.

> .s
      0: [object Object] (array) <---- jeforth vm but w/o any method!
 OK 
> dup (see)
[
    {
        \"dictionary\": [
            0
        ],
        \"major_version\": 3,
        \"words\": []
    }
] OK 
> .s
      0: [object Object] (array)
 OK 
> <js> for(var i in tos()[0]) type(i+\" (\"+ typeof(tos()[0][i])+\"), \") </js>
dictionary (object), major_version (number), words (object),  OK  <----- See, no method. 



background page


為了要有個 workingTab 系統變數, 以簡化程式避免每個動作都得指定 tabid, 引申出需要 background page 用來放 global variable 之用。 --> Use background.html to include project-k and background.js

\\ 只要在 manifest.json 裡這樣設定, 啟動時就會照 background field 的指示把 script files include 進看不見的 background page.
{
 \"manifest_version\" : 2,
 \"name\" : \"jeforth.3ce\",
 \"description\" : \"jeforth for Chrome Extension\",
 \"version\" : \"1.0\",
 \"browser_action\" : {
  \"default_title\": \"Popup of jeforth.3ce\",
  \"default_icon\" : \"3ce/fig.tw16x16.png\",
  \"default_popup\" : \"index.html\"
 },
 \"background\": {
  \"scripts\": [\"project-k/projectk.js\", \"3ce/background.js\"]
 }, 
 \"content_security_policy\" : \"script-src 'self' 'unsafe-eval'; object-src 'self'\",
 \"permissions\" : [
  \"tabs\", \"notifications\", \"http://*/*\", \"https://*/*\"
 ]
}

\\ background.js
    chrome.runtime.onMessage.addListener(
        function(request, sender, sendResponse) {
            alert(\"The background page received a message: \" + request);
            alert(\"I think jeForth is \" + jeForth)
        }
    )

\\ 要看 background page 有沒有作用, 發個 message 過去即知:
\njs: chrome.runtime.sendMessage({greeting:\"hello\"}) \\ <--- 打過去就真的馬上彈出事先安排好的 alert. 而且看到 project-k kernel 真的存在了。

\\ runtime.sendMessage() to background page.
\\ tabs.sendMessage() to content script of the specific tab.

[/] background.js 應該定義 dictate() 轉發跟 type() 回覆當作其中的 jeforth vm 的 I/O. 先寫出 type() 來。
    --> 不用這麼複雜。
[x] js> chrome.extension.getBackgroundPage() .s 就可以拿到 background page 的 window object 所以根本不需要
\n\n    background.js, 可能連 project-k 都不必 include 只要宣告一個空的 packground page 就可以了。--> 全空的不行
[x] background.js 裡面只要一行就夠了, 連這行都沒有也不行。
\n    var isBackgroundPage = true;

    js> chrome.extension.getBackgroundPage() .s
          0: [object Window] (object)
    > dup :> isBackgroundPage .
    true OK 


    這樣就可以用 background page 來存放 global data 了。   


","

Improve log system to support TR tickets

[x] improve common.css, it has to be more specific, not covers all body and all textarea.
    Only .jeforthconsole (class) is expected. I still need common.css file, I have many
    platforms besides.
    --> modify common.css first.
\n

<div class=console3we> 
 <div id=\"outputbox\"></div>
 <textarea id=\"inputbox\" cols=100 rows=1></textarea>
\n <a id=jump2endofinputbox href=\"#endofinputbox\"></a><div id=endofinputbox></div>
 <spam id=endofinputbox></spam>
</div>
--
.console3we { 要改成\n.console3we div , .console3we textarea { 才對 textarea 有效 [ ] 不懂何故!!
  color:black;
  font-family: courier new;
  font-size: 20px;
  padding:20px;
  word-wrap:break-word;
  border: 1px ridge;
  background:#F0F0F0;
 }
 .console3we textarea {
  width:100%;
  padding:4px;
  border: 0px solid;
  background:#BBBBBB;
 } 

    --> 3htm 外觀就變了 -> 修改 index.html 用 <div class=console3we> 把 inputbox outputbox 都包起來
    --> ok! But font size in inputbox is very small --> ok now, as above green bold.
        [x] 3htm, [x]3hta, [x]3nw, [x]3ce
[x] after common.css improved, I can specify textarea's width freely, example:
    <o> <textarea style=\"width:50%\"></textarea></o> drop where style field is
    necessary (can't be width field) and also nn% is must.
    --> this is for tr.table command

ID Severity Canceled Move *this* to *here* 移動 element 可以用打樁的方式標示要移甚麼到哪裡. <-- was for tr.table, use Shift-F2 to edit the entire console3we is good enough. [Create] \t\t\t\t\t\t\t [Save] \t\t\t\t\t\t\t [Modify] \t\t\t\t\t\t
[ ]Subject

Attachments
\t\t\t\t\t \t\t\t\t\t \t\t\t\t\t \t\t\t\t\t \t\t\t\t\t
\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t \n\t\t\t\t\t\n\t\t\t\t
[x] {F9} {F10} to adjust any textarea rows, but inputbox is specially tacke cared.[][][]
[x]

構想



[x]

如何抓 current focused 的 textarea object 要研究研究。===> 3htm/f/platform.f modified and new {F9}/{F10} works fine now!!



\t\t\t\t\t \t\t\t\t\t \t\t\t\t\t \t\t\t\t\t \t\t\t\t\t
\n   
\n\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t \n\t\t\t\t\t\n\t\t\t\t
IDClosedTR table 外觀, ID, Abstrace, and 日期欄 improvement. A status is also needed.Created[]Saved[]Changed[]
[x]
--
\t\t\t\t\t \t\t\t\t\t \t\t\t\t\t \t\t\t\t\t \t\t\t\t\t
\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\t \n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t
ID XClosed

Ctrl-Enter 擴充功能, inputbox 非 active 時仍然執行 statements in the inputbox。因為可以區分不同狀況因此可以有不同的效果,例如把 tr.table 插入 cursor 所在之處而非 outputbox 最底下。

\n        \n\t\t\t\t\t\t
[x]

先寫出可以 Ctrl-Enter 打上 time stamp 的命令 e.g. \"now t.dateTime paste\" 就有進展了。



Ctrl-Enter 已經可以用來執行 inputbox 而毋需先 focus 在裡面, 因此可以用來保持 anchorNode 只在某處, 然後對該處執行動作。

\t\t\t\t\t \t\t\t\t\t \t\t\t\t\t \t\t\t\t\t \t\t\t\t\t

\n\t\t
\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\t \n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t
ID X Closed tr.table can have JS. Go on developing is#text? paste-string erase-#text-anchorNode\n         \n          \n   \n\t\t\t\t\t\t
[x]

Subject

Attachments

\t\t\t\t\t \t\t\t\t\t \t\t\t\t\t \t\t\t\t\t \t\t\t\t\t

\n \t
ID X Closed Textarea can be read-only by .disable=true, how to use that?  
[x]OK
<textarea> 可以設定 attribute disabled=true 變成 read only 就不會老是被誤觸,此時 cursor 不會跑進去。
> <o> <textarea id=ttt></textarea></o>

> js> ttt.disabled \\ ==> false OK 
> js> ttt.disabled=true
> js> ttt.disabled=false
> js> ttt.disabled=true


List all <textarea>.isDisabled
> run: .\" <textarea> isDisabled?\" cr js> $('textarea').length for r@ 1- . space r@ js> $('textarea')[pop()-1].isDisabled . cr next
<textarea> isDisabled?
14 false
13 false
...snip ...
0 false

Disable all <textarea> except inputbox and Enable all <textarea>, status remained after log.save.
> run: .\" Disable all <textarea> except inputbox\" cr js> $('textarea').length for r@ js> $('textarea')[pop()-1].disabled=true next js: inputbox.disabled=false
> run: .\" Enable all <textarea>\" cr js> $('textarea').length for r@ js> $('textarea')[pop()-1].disabled=false next

Note! Can't receive oncontextmenu event if the textarea is disabled.

\t\t\t\t\t \t\t\t\t\t \t\t\t\t\t \t\t\t\t\t \t\t\t\t\t

[x] trbody++ should add an entire <tr> or the existing textarea will be erased. Save the original entire innerHTML and then add appended HTML then assign back to the element.innerHTML=pop() then OK. 

[x] words {F7} lists only partial words on popup page when extension page is opened. <-- was a bug.

\n\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t
2016-02-29 12:55:253ce does not work well with target page when a 3ce extension page is opened.[2016-03-09 20:30:36 ]

Description

複習 3ce 的使用
    因為又是 popup page, 又是 target page, 又是 extension page, 命令是誰發給誰執行的, {F7}、<ce>、(dictate),已經胡里胡塗了。
    > attach3 \\ start experiment.
    > ---- Entering *debug* ---- > 555>>> > q > ---- Leaving *debug* ---- > 666>>>  OK 
    這時候 jeforth.f 已經 included,
    > words (dictate) <------------------ 錯! s\" words\" (dictate) 才對。
    {F7} 與 (dictate) 都可以用了。

New problem after changed to use /ceV:
Uncaught ReferenceError: target_f7_handler is not defined(anonymous function) @ VM1538:21(anonymous function) @ VM1538:126
hao123.js?st=-16863:1 Uncaught TypeError: Cannot read property 'error' of undefinedw @ hao123.js?st=-16863:1u @ hao123.js?st=-16863:1w @ hao123.js?st=-16863:1
3extensions::uncaught_exception_handler:8 Error in event handler for runtime.onMessage: TypeError: vm.forthConsoleHandler is not a function

Javascript object member 不能直接 get 到他們的 parent 要轉個彎:
    http://stackoverflow.com/questions/2980763/javascript-objects-get-parent
    > <js> var f = function(){ type(arguments.callee.value)}; f</jsV> constant f

    > f :: () \\ ==> undefined OK 
    > f :: value=123
    > f :: () \\ ==> 123 OK  Bingo!!
    Background page 的 vm.type() 藉此得到 background window object.

[x] 對 background page jeforth 下令的範本:   
    background-page <js> pop().bvm.dictate(\".s\")</js>
    background-page :> bvm.screenbuffer .

[x] How to refresh/reset background page ? <-- forget this, 已經改用 manifest.json
    不能重複 init background page
    因為 background page 一直都在, popup & 3ce extension page can have multiple instances.
    如果每個 instance 都來 init background page 會怎樣?
    若要重複 init 只要 background-page :: jeforth_project_k_virtual_machine_object=null
    然後 refresh 3ce extension page or popup page 即可 (include ce.f 就會 init background page)。


\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t
\n\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t
2016-03-02 17:41:43Switch 3ce target page type() prints to local console3we or extension pages[2016-03-11 10:08:38]

Done,
Defined in target.f

\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t


[x] 從 3ce extension page 去查 background page 的 tabs.getCurrent() 啥結果: 
background-page <js> pop().bvm.dictate(\"js: chrome.tabs.getCurrent(function(tab){push(tab)}) .s\")</js>
background-page :> bvm.screenbuffer . \\ ==> undefined 跟 popup page 一樣。

\n\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t
2016-03-08 17:50:04\n3ce message SPEC 增加 \"addr\" field 或者 host pages 自行過濾  [2016-03-10 16:55:59 ]

Description
See Ynote: http://note.youdao.com/share/?id=6759efb1877ba5c5f2ab149879d9707a&type=note
Attachments

\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t
\n\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t
2016-03-10 13:20:243ce SPEC of chrome.[tabs|runtime].[sendMessage()|onMessage.addListener()][2016-03-10 16:56:47]

The discussion:3ce SPEC of message:
chrome.[tabs|runtime].sendMessage({
    forth: \".s\", /* forth statements */
    type : \"hello world!\", /* for all 3ce pages include the popup and the background */
    tos  : anything, /* Sender passes TOS to receiver */
    addr : \"background\" | (tabs.getcurrent :> id) /* host tabid, given by host himself I guess */
})

Real example of chrome.runtime.onMessage.addListener(function(message, sender, sendResponse){}) arguments:
The message is {
    \"type\": \" OK \"
}
The sender is {
    \"id\": \"khjienijgaapbcofpbbogdlcclhbmjoa\",
    \"url\": \"http://www.hao123.com/haoserver/jianfanzh.htm\",
    \"tab\": {
        \"active\": false,
        \"audible\": false,
        \"favIconUrl\": \"http://www.hao123.com/favicon.ico\",
        \"height\": 775,
        \"highlighted\": false,
        \"id\": 222,
        \"incognito\": false,
        \"index\": 2,
        \"mutedInfo\": {
            \"muted\": false
        },
        \"pinned\": false,
        \"selected\": false,
        \"status\": \"complete\",
        \"title\": \"hao123网址之家-在线繁体字转换\",
        \"url\": \"http://www.hao123.com/haoserver/jianfanzh.htm\",
        \"width\": 1440,
        \"windowId\": 1
    },
    \"frameId\": 0
}
The sendResponse is undefined <--- [ ] the function that calls the callBack, I remember or I guess so.

\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t
\n\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t
2016-04-04 18:14:05Let HTML5 Local Storage be a jeforth.3htm/3ce source code directory2016-04-08 17:24:16

已經成功完成 localstorage.f 供 3ce, 3htm, 3nw 使用。 

[x] 3ce 內 popup page, extension page, 連 background page 都共享同一個 local storage localStorage,
    查看 background page 的 localStorage :
    background-page <js> pop().bvm.dictate(\"js> localStorage (see)\")</js>
    background-page :> bvm.screenbuffer .
[x] Target page 有自己的 localStorage, 不必先 attach 3ce extension page & popup 都可以直接查看 tibid page :
    > <ce> localStorage.sourcecode </ceV> .
    I am in target page Bing.comdisplay->host OK 

Chrome, NW.js 抓 innerHTML of textarea element 只會抓到當初 <textarea> foo bar </textarea> 當中的 value, 有就有、沒有就沒有,不會因為 edit 而變動。HTA textarea 的 innerHTML 則是動態的, 只有 3HTA 很方便可以用來當 editor。 

\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t
\n\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t
2016-04-05 16:00:09Study 用 3ce 自動抓除權除息表  [ ]

Description

直接用 jQuery 就好了, 根本用不著 table_to_json.js 之類東西 

祭出 table to json , 學問來了! Target page 上的 root URL 是 Target page 的, 要 include 東西得寫上完整的網址, 以 3ce 而言, 如下:<h> <script src=\"js/jquery.tabletojson.js\"></script> </h> drop <---- failed,  GET http : // jdata . yuanta . com . tw/z/ze/zeb/js/jquery.tabletojson.js?_=1459926197825 404 (Not Found)

要改成: <h> <script src=\"chrome-extension://khjienijgaapbcofpbbogdlcclhbmjoa/js/jquery.tabletojson.js\"></script> </h> drop

結果又是: Denying load of chrome-extension : // khjienijgaapbcofpbbogdlcclhbmjoa / js/jquery.tabletojson.js  Resources must be listed in the web_accessible_resources manifest key in order to be loaded by pages outside the extension. --> See http : // open.chrome . 360 . cn / extension_dev / manifest.html#web_accessible_resources or my YNote for the manifast.json field \"web_accessible_resources\" that is supposed for this issue. --> 加上這個 solution 好了! 用 <h><script> 動態灌進 target page 網頁的 ~.js code 都要先在 manifast.json 登記。[x] 怎麼 jquety 沒有先登記?

直接用 jQuery 就好了:

js> $(\"tr\")[6] :> innerText . \\ 查看某 row, 不顧 table 的界線!真有彈性。

js> $(\"td\",$(\"tr\")[6/*row*/])[0/*column*/] :> innerText . \\ 查看某 cell

 

HTML5 < tr > a row of a table can be used alone without being in a < table >

Like this : <o> <tr><td>11</td><td>22</td></tr></o>, so can be < td >

[x] 這個寫法居然也可以!!!! Hash 的內容宣告時就直接裝配 instead of using assignment statements.
16 <js> var hh = {a:$(\"td\")[tos()].innerText,b:$(\"td\")[tos()+1].innerText}; hh</jsV> (see)
Refer to 'all-company' also, wonderful ability of JavaScript!

用 next sibling of <td> 可以推進 access 下一個 <td>, 到 row 底就變成 null <td>

      3: [object HTMLTableCellElement] (object) <----------- a <td> element
> js> pop().nextElementSibling dup :> innerText . \\ ==> 105/04/13 OK
> js> pop().nextElementSibling dup :> innerText . \\ ==> 81.89020477 OK
> js> pop().nextElementSibling dup :> innerText . \\ ==> OK
> js> pop().nextElementSibling dup :> innerText . \\
> js> pop().nextElementSibling dup :> innerText . \\ ==> JavaScript error
                                                    : Cannot read property 'innerText' of null

HTML element ID 可以重複使用,但是只有第一個生效, 很合理。
js> $(\"#oAddCheckbox\").length . cr \\ ==> 1 只有第一個生效, 之後的都無實效。
js> $(\"#oAddCheckbox\")[0].innerText . cr / <== the 1st instance 01004T富邦R2 OK
js> $(\"#oAddCheckbox\")[1].innerText . cr / <== Error! over the upper bound.
js> document.getElementById(\"oAddCheckbox\").innerText \\ ==> 01004T富邦R2 OK

Again, cr or nap and sleep can't be used in event handler
\"save\" command of local storage ls.f was not in any event handler and it uses \"cr\"
to print messages. Then I wrote {s} to support Ctrl-s that utilizes save command and
then strange problem happened. {s} is supposed to leave a false to stop event bubbling
but that doesn't

\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t
\n\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t
2016-04-06 13:59:343ce 還是 local 好用, 但與其用 3ce 限制重重(不能 include javascript), 還不如直接用 3htm <-- 錯了! 要控制別人的網頁就必須用 3ce. 2016-04-06 14:03:24

DescriptionAttachments

\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t


[x] 3ce target page console3we was once become too narrow due to the CSS
    setting of that target page I guess. The solution is simply
    js: $(\".console3we\").width(\"1200px\")  

 

 


> log.save
","
2016-03-08 15:26:04Review project-k kernel interface, something need to be removed and 3ce background page can be simplified further.[ ]

Experience of 3ce background page. It needs vm.type vm.prompt vm.panic vm.greeting vm.readTextFile vm.clearScreen ... that are too many! Attachments

\t\t\t\t\t \t\t\t\t\t \t\t\t\t\t \t\t\t\t\t \t\t\t\t\t \t\t\t\t

--

[x] 改革 log.commands 用 stack 的方式之外, 也要有直接 access 的方式,更實用。log.roll 之外再加強
    log.list 用第一行來 random access 所有的 sections。
    --> See Ynote, http://note.youdao.com/share/?id=3c77701beda7d9c037155f2d37bb0b2a&type=note 
    --> leave log along, create new tr interface and use the same database log.json.
    --> Local Storage is the solution.

[x] log.recall to show extra title of the section. but log.save should remove the title.
    --> local storage + ed is the solution
[x] editbox's bigger/smaller can be removed. We have F9/F10 new function already.
    --> local storage + ed is the solution
[x] EditBox --> HTMLbox
    --> local storage + ed has supported both
[x] 3hta [add] button does not work in many cases
    --> local storage + ed overed that 
[x] 3ce attach to target page plus command line of forth commands
[x] Improve EditBox failed cases, idiot-proof or provide more helpful info like 'border-on'.
    --> local storage + ed overed that 

\n\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t
2016-03-21 11:13:24改革 log.{commands} 用 stack 的方式之外, 也要有直接 access 的方式,更實用。2016-04-29 09:41:36

local storage + ed has covered this issue.Attachments

\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t
--
\n\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t\t\t\n\t\t\t\n\t\t\t\n\t\t
2016-03-21 15:15:263ce should have its own jeforth.3ce.html at root directory. ( also jeforth.3ce.background.html ) --> 3ce should briefing itself at the beginning page!!
2016-04-06 14:06:42

3ce popup page and extension pages were using /index.html as their home page. That requires none 3ce application, i.e. jeforth.3htm to also include ce.f that's buggy. ce.f has to judge whether it is running in Chrome extension environment too, very annoying.

Youtube 上的簡介
\"jeforth.3ce\" (jeforth for Chrome Extension)  has just been published to Chrome web store (2016/03/29). But can't find it by searching \"jeforth\" nor \"jeforth.3ce\". It's too young and having too few population I guess. However, pleaes use the link below to the installation page.
https://chrome.google.com/webstore/detail/jeforth3ce/npgnnakjbggncblfdpaihigcljehmmdd?hl=en-US&gl=TW

\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t

> log.save
"] \ No newline at end of file diff --git a/README.md b/README.md index bab0e11..67ec222 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ Get the project | Item | Address | ----------------|---------------------------------------------- | jeforth.3we high level source code | *http://github.com/hcchengithub/jeforth.3we* | -| Kernel, jeforth.js 3-words-engine| *http://github.com/hcchengithub/project-k* | +| Kernel, projectk.js 3-words-engine| *http://github.com/hcchengithub/project-k* | Get source code from GitHub dwon to your computer through 'git clone' or Download Zip, either way. diff --git a/f/jeforth.f b/f/jeforth.f index 1215f17..93465d4 100644 --- a/f/jeforth.f +++ b/f/jeforth.f @@ -38,11 +38,11 @@ end-code // ( -- ) Start composing a code word. -code _init_ ( -- ) \ Initialize vm.g.members that are moved out from jeforth.js which is thus kept pure. +code _init_ ( -- ) \ Initialize vm.g.members that are moved out from projectk.js which is thus kept pure. // To support private word, END-CODE needs one more line words.forth[2].xt = function(){ - // was from project-k jeforth.js, modified by jeforth.3we jeforth.f _init_ + // was from project-k projectk.js, modified by jeforth.3we jeforth.f _init_ if(compiling!="code"){ panic("Error! 'END-CODE' to a none code word.\n"); return}; current_word_list().push(new Word([newname,newxt])); last().vid = current; @@ -233,7 +233,7 @@ execute = vm.g.selftest_execute = function execute(entry) { 我嘗試了種種的 self-test 寫法。有的很醜,混在正常程式裡面相當有礙視線;不醜的很 累,佔很大 source code 篇幅。 - 以下是發展到目前最好的方法,jeforth.js kernel 裡只有 code end-code 兩個基本 + 以下是發展到目前最好的方法,projectk.js kernel 裡只有 code end-code 兩個基本 words, 剛進到 jeforth.f 只憑這兩個基本 words 就馬上要為每個 word 都做 self-test 原本是很困難的。 然而,jeforth.f 是整個檔案一次讀進來成為大大的一個 TIB 的, 所 以其中已經含有 jeforth.f 的全部功能。如果 self-test 安排在所有的 words 都 load diff --git a/index.html b/index.html index b613a2f..756b8e4 100644 --- a/index.html +++ b/index.html @@ -11,7 +11,7 @@ } - + diff --git a/jeforth.3nd.js b/jeforth.3nd.js index 2dc4ef9..d29a9da 100644 --- a/jeforth.3nd.js +++ b/jeforth.3nd.js @@ -5,7 +5,7 @@ // Usage: node.exe jeofrth.3nd.js cr .' Hello World!!' cr bye // -var jeForth = require('./project-k/jeforth.js').jeForth; +var jeForth = require('./project-k/projectk.js').jeForth; global.kvm = global.jeforth_project_k_virtual_machine_object = new jeForth() kvm.minor_version = require("./js/version.js").jeforth3we_minor_version; kvm.host = global; // global 掛那裡的根據。 @@ -15,8 +15,8 @@ kvm.screenbuffer = ""; // used by both inside and outside vm. kvm.selftest_visible = true; // used by both inside and outside vm. // kvm.type() is the master typing or printing function. -// The type() called in code ... end-code is defined in the kernel jeforth.js. -// We need to use type() below, and we can't see the jeforth.js' type() so one +// The type() called in code ... end-code is defined in the kernel projectk.js. +// We need to use type() below, and we can't see the projectk.js' type() so one // is also defined here, even just for a few convenience. The two type() functions // are both calling the same kvm.type(). var type = kvm.type = function (s) { @@ -35,12 +35,12 @@ kvm.clearScreen = // '\033c' or '\033[2J' http://stackoverflow.com/questions/9006988/node-js-on-windows-how-to-clear-console // kvm.panic() is the master panic handler. The panic() function defined in -// project-k kernel jeforth.js is the one called in code ... end-code. +// project-k kernel projectk.js is the one called in code ... end-code. kvm.panic = function (state) { type(state.msg); if (state.serious) debugger; } -// We need the panic() function below but we can't see the one in jeforth.js +// We need the panic() function below but we can't see the one in projectk.js // so one is defined here for convenience. function panic(msg,level) { var state = { diff --git a/jeforth.3nw.html b/jeforth.3nw.html index 14abe71..169049a 100644 --- a/jeforth.3nw.html +++ b/jeforth.3nw.html @@ -12,7 +12,7 @@ - + - +