├── app ├── app01.ijs ├── app02.ijs ├── app03.ijs ├── app04.ijs ├── app05.ijs ├── app06.ijs ├── app07.ijs └── app08.ijs ├── aws ├── aws-sh ├── aws-utils.ijs ├── cloud-bld-sh └── cloud-run-sh ├── chart.ijs ├── config ├── jhs-node.cfg └── jhs.cfg ├── core.ijs ├── d3.ijs ├── demo ├── jdemo01.ijs ├── jdemo02.ijs ├── jdemo03.ijs ├── jdemo04.ijs ├── jdemo05.ijs ├── jdemo06.ijs ├── jdemo07.ijs ├── jdemo08.ijs ├── jdemo09.ijs ├── jdemo10.ijs ├── jdemo11.ijs └── jdemo12.ijs ├── extra ├── man.ijs └── manage.ijs ├── favicon.ico ├── gnuplot.ijs ├── gpdemo.ijs ├── grep.exe ├── guest ├── bad.html ├── create-jguest-sh ├── guest-readme.txt ├── guest-sudo-sh ├── guest.ijs ├── guest.js ├── guest_util.ijs ├── redirect.html ├── survey.ijs ├── user.html └── user.ijs ├── history.txt ├── installer.ijs ├── jbase.ijs ├── jbeacon.ijs ├── jbinfo.ijs ├── jcopy.ijs ├── jdebug.ijs ├── jdoc.ijs ├── jfif.ijs ├── jfile.ijs ├── jfilesrc.ijs ├── jgcp.ijs ├── jhelp.ijs ├── jijs.ijs ├── jijx.ijs ├── jj.ijs ├── jjserver.ijs ├── jlocale.ijs ├── jlogin.ijs ├── jpacman.ijs ├── js ├── chartjs │ ├── chart.js │ ├── defaults.js │ └── source.txt ├── codemirror6 │ ├── autocomplete │ │ ├── .github │ │ │ └── workflows │ │ │ │ └── dispatch.yml │ │ └── dist │ │ │ └── index.js │ ├── commands │ │ ├── .github │ │ │ └── workflows │ │ │ │ └── dispatch.yml │ │ └── dist │ │ │ └── index.js │ ├── language │ │ ├── .github │ │ │ └── workflows │ │ │ │ └── dispatch.yml │ │ └── dist │ │ │ └── index.js │ ├── search │ │ ├── .github │ │ │ └── workflows │ │ │ │ └── dispatch.yml │ │ └── dist │ │ │ └── index.js │ ├── state │ │ ├── .github │ │ │ └── workflows │ │ │ │ └── dispatch.yml │ │ └── dist │ │ │ └── index.js │ └── view │ │ ├── .github │ │ └── workflows │ │ │ └── dispatch.yml │ │ └── dist │ │ └── index.js ├── crelt │ └── index.js ├── d3 │ ├── d3.css │ ├── d3.js │ ├── d3.min.js │ └── license ├── handsontable │ ├── handsontable.full.min.css │ └── handsontable.full.min.js ├── jquery │ ├── jquery-2.0.3.min.js │ ├── jquery-ui.css │ ├── jquery-ui.min.js │ └── smoothness │ │ ├── images │ │ ├── animated-overlay.gif │ │ ├── ui-bg_flat_0_aaaaaa_40x100.png │ │ ├── ui-bg_flat_75_ffffff_40x100.png │ │ ├── ui-bg_glass_55_fbf9ee_1x400.png │ │ ├── ui-bg_glass_65_ffffff_1x400.png │ │ ├── ui-bg_glass_75_dadada_1x400.png │ │ ├── ui-bg_glass_75_e6e6e6_1x400.png │ │ ├── ui-bg_glass_95_fef1ec_1x400.png │ │ ├── ui-bg_highlight-soft_75_cccccc_1x100.png │ │ ├── ui-icons_222222_256x240.png │ │ ├── ui-icons_2e83ff_256x240.png │ │ ├── ui-icons_454545_256x240.png │ │ ├── ui-icons_888888_256x240.png │ │ └── ui-icons_cd0a0a_256x240.png │ │ └── jquery-ui.custom.css ├── jsoftware │ ├── csscore.css │ ├── d3_basic.js │ ├── editor.js │ ├── jijs.js │ ├── jijx.js │ └── jscore.js ├── lezer │ ├── common │ │ └── dist │ │ │ └── index.js │ ├── generator │ │ └── dist │ │ │ └── index.js │ ├── highlight │ │ └── dist │ │ │ └── index.js │ └── lr │ │ └── dist │ │ └── index.js ├── style-mod │ └── src │ │ └── style-mod.js ├── w3c-keyname │ ├── .tern-port │ └── index.js └── webgl │ └── glmatrix-min.js ├── jum.ijs ├── loadx.ijs ├── manifest.ijs ├── node.ijs ├── node ├── cert.pem ├── key.pem ├── server.html └── server.js ├── nopacman ├── app_v2.txt ├── build.ijs ├── dbtest.ijs ├── dev.ijs ├── issues.ijs ├── jdemo09.ijs ├── jfiles.ijs ├── jhsdev.ijs ├── oldmenu.js ├── switch.ijs └── wiki.txt ├── page ├── jcanvas.ijs ├── jcjs.ijs ├── jd3.ijs ├── jhotd3.ijs ├── jtable.ijs ├── jwatch.ijs └── tictactoe.ijs ├── port.ijs ├── react └── tictactoe │ ├── LICENSE.txt │ ├── README.md │ ├── addj │ ├── index.html │ ├── reacttictactoe.ijs │ ├── script.js │ └── style.css │ ├── dist │ ├── index.html │ ├── script.js │ └── style.css │ └── src │ ├── index.html │ ├── script.babel │ └── style.css ├── readme.txt ├── release.txt ├── sp.ijs ├── spfile_template.ijs ├── spx ├── canvas.ijt ├── chart.ijt ├── overview.ijt ├── overview_example.ijs ├── plot.ijt └── spx.ijt ├── src └── gif │ ├── newfile.gif │ └── oldfile.gif ├── test ├── chkrad.ijs ├── handlers.ijs ├── jdemo17.ijs ├── open.ijs ├── raw.ijs ├── select_widget.ijs └── test_select.ijs ├── tool.ijs ├── util.ijs ├── utilh.ijs ├── vocabhelp.ijs └── widget ├── jhot.ijs └── readme.txt /app/app01.ijs: -------------------------------------------------------------------------------- 1 | coclass'app01' 2 | coinsert'jhs' 3 | 4 | manapp=: 'jpage y must be ''''' NB. doc jpage y arg 5 | 6 | NB. J lines run in jhs locale that define html for the page 7 | HBS=: 0 : 0 8 | jhclose '' NB. menu with close 9 | 'title' jhh1 'overview' NB. header size 1 10 | jhijs'' NB. button to edit source script 11 | jhhr NB. horizontal rule 12 | 'b1' jhb 'flip' NB. button 13 | 't1' jhtext '' NB. text field 14 | ) 15 | 16 | NB. jpage (or url) calls to init page for browser 17 | ev_create=: 3 : 0 18 | manapp assert ''-:y 19 | jhcmds 'set t1 *just loaded' NB. browser command when page loads 20 | ) 21 | 22 | NB. click b1 -> ev_b1_click -> jhrcmds returns cmd to browser -> browser runs cmd 23 | ev_b1_click=: {{ jhrcmds 'set t1 *',|.getv't1' }} 24 | 25 | NB. enter in t1 -> ev_t1_enter -> jhrcmds returns cmd to browser -> browser runs cmd 26 | ev_t1_enter=: {{ jhrcmds 'set t1 *enter in t1' }} 27 | -------------------------------------------------------------------------------- /app/app02.ijs: -------------------------------------------------------------------------------- 1 | coclass'app02' 2 | coinsert'jhs' 3 | 4 | 0 : 0 5 | more html elements and event handlers 6 | element id c*c1 has main id e and secondary id c1 7 | clicking e*c1 calls ev_e_click (main id) 8 | event handler can get secondary id with getv'jsid' 9 | ) 10 | 11 | manapp=: 'jpage y must be '''' or similar to ''text1'';''text2''' 12 | 13 | HBS=: 0 : 0 14 | jhclose '' 15 | 'title' jhh1 'html' 16 | jhijs'' NB. button to edit source script 17 | jhhr 18 | 'b1' jhb 'b1 flip t1' 19 | 'b2' jhb 'b2 flip both' 20 | 'b3' jhb 'error' 21 | jhbr NB. jhbr_jhs_ is html '' 22 | 'e*t1' jhtext '' 23 | 'e*t2' jhtext '' 24 | jhbr 25 | 'e*c1' jhchk 'chk1' 26 | 'e*c2' jhchk 'chk2';1 27 | 'e*r1' jhrad 'rad1';0;'rg0' NB. rg0 is radio group 0 28 | 'e*r2' jhrad 'rad2';1;'rg0' 29 | 'd1' jhdiv '' NB. html division (or section) for html elements 30 | ) 31 | 32 | report=: {{ 'mid sid type'=.getvs 'jmid jsid jtype' 33 | t=. 'jmid jtype jsid: ',mid,' ',type,' ',sid,LF,'event: ev_',mid,'_',type 34 | t=. t,LF,'NV has following name value pairs and getv''...'' gets a value' 35 | 'set d1 *','
',jhfroma t,LF,seebox NV }} 36 | 37 | return=: {{ jhrcmds (report'');boxopen y }} 38 | 39 | ev_create=: 3 : 0 40 | y=. y jpagedefault 't1 default';'t2 default' 41 | manapp assert (1=L. y)*.(2=#y)*.2=;3!:0 each y 42 | jhcmds ('set e*t1 *',0{::y);'set e*t2 *',1{::y NB. browser commands when page loads 43 | ) 44 | 45 | ev_b1_click=: {{ return 'set e*t1 *',|.getv'e*t1' }} 46 | 47 | ev_b2_click=: {{ return ('set e*t1 *',|.getv'e*t1');'set e*t2 *',|.getv'e*t2' }} 48 | 49 | ev_b3_click=: {{ return return 'set badid *' }} 50 | 51 | ev_e_click=: {{ return '' }} NB. called for all elements with main id e 52 | ev_e_enter=: ev_e_click -------------------------------------------------------------------------------- /app/app03.ijs: -------------------------------------------------------------------------------- 1 | coclass'app03' 2 | coinsert'jhs' 3 | 4 | 0 : 0 5 | study CSS=: lines to see how they change html look and feel 6 | CSS can be complicated 7 | online validators or visual studio code can help 8 | CSS is powerful - cut/paste can get you a long ways 9 | but serious use requires study of the exensive online resources 10 | ) 11 | 12 | how=: 0 : 0 13 | cautiously change CSS in textarea at bottom and press set (e.g., change first line salmon to red and press set)

14 | 15 | css errors are generally forgiving (perhaps not the desired effect, but not a crash)

16 | 17 | css is a rich language and is well documented on the web

18 | 19 | css statment is:
20 | selector { property : value ;}
21 | selector #abc applys to element with id abc
22 | selector .jhb applys to elements with class jhb

23 | 24 | selector can select more than 1 element and there can be multiple property:value pairs

25 | 26 | try out a few simple changes to get a feel for things
27 | ) 28 | 29 | NB. sentences that define html elements 30 | HBS=: 0 : 0 31 | jhclose'' 32 | 'title' jhh1 'css custmizing look and feel' 33 | jhijs'' NB. button to edit source script 34 | jhhr 35 | 'how' jhdiv how 36 | 'hr' jhline'' 37 | 'e*text' jhtext 'text' 38 | 'e*pswd' jhpassword '' 39 | 'e*b0' jhb'lots of extra text' 40 | 'e*b1' jhb'less text' 41 | jhbr 42 | 'e*bg2' jhb 'first' 43 | 'e*bg3' jhb 'second' 44 | 'set' jhb'set css' 45 | 'ta' jhtextarea '' 46 | ) 47 | 48 | NB. is replaced by: 49 | NB. font-family:"courier new","courier","monospace";font-weight:550;white-space:pre; 50 | 51 | CSS=: 0 : 0 52 | #set{background-color:salmon;} 53 | #set{display:block;margin:auto;width:50%;} 54 | #text{background-color: lightblue;} 55 | #text:focus{background-color: yellow;} 56 | #pswd:hover{background-color: pink;} 57 | /* jhb class with id prefix e*bg */ 58 | .jhb[id^="e*bg"]{width: 20em; color:red;} 59 | #hr{background-color:black;height:1em;} 60 | #ta{} 61 | #ta{width:100%;height:24em;} 62 | #how{background-image: 63 | linear-gradient(pink,plum,aqua);} 64 | ) 65 | 66 | manapp=: 'jpage y must be ''''' 67 | 68 | ev_create=: 3 : 0 NB. called by page or browser to initialize locale 69 | manapp assert ''-:y 70 | jhcmds 'set ta *',CSS 71 | ) 72 | 73 | ev_set_click=: {{ 74 | jhrcmds 'css *',getv'ta' 75 | }} 76 | 77 | ev_e_click=: {{ 78 | 'mid sid type'=. getvs'jmid jsid jtype' 79 | jhrcmds 'set e*text *',mid,'*',sid,' ',type 80 | }} 81 | 82 | ev_e_enter=: ev_e_click 83 | 84 | -------------------------------------------------------------------------------- /app/app04.ijs: -------------------------------------------------------------------------------- 1 | coclass'app04' 2 | coinsert'jhs' 3 | 4 | manapp=: 'jpage y must be ''''' 5 | 6 | 0 : 0 7 | css flex allows dynamic sizing 8 | you can do almost any layout you can imagine 9 | but it can be complicated! 10 | you can do a lot with cut/paste from examples 11 | serious use requires study of extensive online resources 12 | ) 13 | 14 | HBS=: 0 : 0 15 | NB. base div implicitly opened 16 | jhclose'' 17 | 'title' jhh1 'css flex - ta textarea' 18 | jhijs'' NB. button to edit source script 19 | jhhr 20 | 'hbs' jhb'show HBS' 21 | 'css' jhb'show CSS' 22 | 23 | jhdivz NB. base div close - flex active 24 | 'foo'jhb'asdf' 25 | 'ta' jhtextarea '' NB. textarea element is in flex area 26 | 27 | jhdiva'' NB. base div open - flex inactive 28 | 29 | 'footer' jhhn 3;'page footer' 30 | NB. base div implicitly closed 31 | ) 32 | 33 | CSS=: 0 : 0 34 | #ta{font-family:;resize:none;} /* id ta - fixed font - no resize handle */ 35 | #ta{width:100%;height:100%;} /* id ta - fill available space */ 36 | ) 37 | 38 | NB. J code - initialize and handle events 39 | ev_create=: 3 : 0 NB. called by page or browser to initialize locale 40 | manapp assert ''-:y 41 | t=. y jpagedefault ,LF,.~60 20$'silly text ' 42 | 'must be text'assert 2=3!:0 t 43 | jhcmds 'set ta *',t 44 | ) 45 | 46 | ev_hbs_click=: 3 : 0 47 | jhrcmds 'set ta *',HBS 48 | ) 49 | 50 | ev_css_click=: 3 : 0 51 | jhrcmds 'set ta *',CSS 52 | ) 53 | -------------------------------------------------------------------------------- /app/app05.ijs: -------------------------------------------------------------------------------- 1 | coclass'app05' 2 | coinsert'jhs' 3 | 4 | HBS=: 0 : 0 5 | NB. base div implicity opened 6 | jhclose'' 7 | 'title' jhh1 'css flex - ta beside tb' 8 | jhijs'' NB. button to edit source script 9 | jhhr 10 | 'hbs' jhb 'show HBS' 11 | 'css' jhb 'show CSS' 12 | 13 | jhdivz NB. base div close - flex active 14 | 15 | 'jflexrow'jhdiva'' NB. allow side by side resizing 16 | 'ta'jhtextarea'' 17 | 'tb'jhtextarea'' 18 | jhdivz NB. close jflexrow div 19 | 20 | jhdiva'' NB. base div open - flex inactive 21 | 22 | 'footer'jhhn 3;'page footer' 23 | NB. base div implicity closed 24 | ) 25 | 26 | CSS=: 0 : 0 27 | #ta{;resize:none;} /* code font - no resize handle */ 28 | #tb{;resize:none;} /* code font - no resize handle */ 29 | #ta{width: 50%;height:100%;} /* fill available space */ 30 | #tb{width: 50%;height:100%;} 31 | ) 32 | 33 | manapp=: 'jpage y must be ''''' 34 | 35 | ev_create=: {{ 36 | manapp assert ''-:y 37 | t=. y jpagedefault ,LF,.~20 20$'some text ' 38 | jhcmds ('set ta *',t);'set tb *',100}.|.t 39 | }} 40 | 41 | ev_hbs_click=: {{ jhrcmds 'set ta *',HBS }} 42 | ev_css_click=: {{ jhrcmds 'set tb *',CSS }} 43 | -------------------------------------------------------------------------------- /app/app06.ijs: -------------------------------------------------------------------------------- 1 | coclass'app06' 2 | coinsert'jhs' 3 | 4 | HBS=: 0 : 0 5 | NB. base div implicity opened 6 | jhclose'' 7 | 'title' jhh1 'css flex - ta above tb' 8 | jhijs'' NB. button to edit source script 9 | jhhr 10 | 'hbs' jhb'show HBS' 11 | 'css' jhb'show CSS' 12 | 13 | jhdivz NB. base div close - flex active 14 | 15 | NB. elements not in main div share remaining space 16 | 'tatitle'jhtitle'tb textarea' 17 | 'ta'jhtextarea'';10;10 18 | jhdiva'' NB. reopen main div 19 | 20 | 'hr'jhline'' 21 | 22 | jhdivz 23 | 'tbtitle'jhtitle'tb textarea' 24 | 'tb'jhtextarea'';10;10 25 | 26 | jhdiva'' NB. reopen main div 27 | 'footer'jhhn 3;'adsf' 28 | ) 29 | 30 | CSS=: 0 : 0 31 | #ta{;resize:none;} /* code font - no resize handle */ 32 | #tb{;resize:none;} /* code font - no resize handle */ 33 | #ta{width: 100%;height:70%;} /* full height - share width */ 34 | #tb{width: 100%;height:30%;} 35 | #hr{height: 10px; background-color: red;} 36 | ) 37 | 38 | manapp=: 'jpage y must be ''''' 39 | 40 | ev_create=: {{ 41 | manapp assert ''-:y 42 | t=. y jpagedefault ,LF,.~20 20$'some text ' 43 | jhcmds ('set ta *',t);'set tb *',100}.|.t 44 | }} 45 | 46 | ev_hbs_click=: {{ jhrcmds 'set ta *',HBS }} 47 | ev_css_click=: {{ jhrcmds 'set tb *',CSS }} 48 | -------------------------------------------------------------------------------- /app/app07.ijs: -------------------------------------------------------------------------------- 1 | coclass'app07' 2 | coinsert'jhs' 3 | 4 | NB. sentences to create html elements 5 | NB. jhbshtml_jdemoxx_'' shows HBS html 6 | HBS=: 0 : 0 7 | jhclose'' 8 | 'title' jhh1 'chartjs' 9 | jhijs'' NB. button to edit source script 10 | jhhr 11 | 'top' jhdiv'same data - 4 chart types' 12 | jhbr 13 | 'run' jhb'run' 14 | 'sentence'jhtext'' 15 | jhbr 16 | 'cjsa' jhchart'' 17 | 'cjsb' jhchart'' 18 | jhbr 19 | 'cjsc' jhchart'' 20 | 'cjsd' jhchart'' 21 | ) 22 | 23 | NB. style the html elements 24 | CSS=: 0 : 0 25 | #top{text-align:center;font-size:20px;} 26 | #sentence{margin-bottom:5px;} 27 | .jhchart_parent{border:solid;height:200px;width:50%;float:left;} 28 | #cjsd_parent{background-color:pink} 29 | hr{clear:both} /* so it doesn't appear under elements that float */ 30 | ) 31 | 32 | get=: 3 : 0 33 | jcjs'type';y 34 | jcjs'get' 35 | ) 36 | 37 | NB. validate sentence 38 | validate=: 3 : 0 39 | try. 40 | v=. ".y 41 | assert (1=$$v)*.2~:3!:0 v 42 | catch. 43 | echo 'bad sentence: ',y 44 | y=. '5?5' 45 | v=. ".y 46 | end. 47 | y;v 48 | ) 49 | 50 | create=: 3 : 0 51 | 't v'=. validate y 52 | jcjs'reset' 53 | jcjs'labels';#v 54 | jcjs'data';v 55 | jcjs'legend';'mydata' 56 | jcjs'add';'options.animation.duration 2000' 57 | d=. ('set sentence *',t);('chartjs cjsa *',get'line');('chartjs cjsb *',get'bar');('chartjs cjsc *',get'pie');'chartjs cjsd *',get'doughnut' 58 | ) 59 | 60 | ev_create=: 3 : 0 61 | jhcmds create y jpagedefault '5?5' 62 | ) 63 | 64 | ev_run_click=: {{ jhrcmds create getv'sentence' }} 65 | ev_sentence_enter=: ev_run_click 66 | 67 | INC=: INC_chartjs NB. include chart js code 68 | 69 | -------------------------------------------------------------------------------- /app/app08.ijs: -------------------------------------------------------------------------------- 1 | coclass'app08' 2 | coinsert'jhs' 3 | 4 | man=: 'jpage y must be ''''' 5 | 6 | NB. override create, jev_get, saveonclose verbs to customize app 7 | 8 | NB. html form definition 9 | NB. html element id can be one part (pswd) or two parts (gn*up) 10 | NB. gn*up (mid*sid) has gn main id and up secondary id 11 | NB. J event handler is ev_mid_type 12 | NB. easy to have a single handler for different events 13 | HBS=: 0 : 0 14 | jhclose'' NB. menu with close 15 | 'head' jhh1 'password' 16 | jhijs'' NB. button to edit source script 17 | jhhr 18 | 'pswd' jhspan ' ' NB. pswd text - non-breaking space 19 | jhhr NB. html horizonatal rule 20 | 'len' jhspan'length: ',":length 21 | 'gn*up' jhb'▲' NB. button to increase length 22 | 'gn*dn' jhb'▼' 23 | 'epy' jhspan'entropy: ' 24 | jhbr NB. html line break 25 | 'gn*sp' jhchk'%^& etc';0 26 | 'gn*uc' jhchk'uppercase';0 27 | 'gn*di' jhchk'digits';0 28 | jhbr 29 | 'gn' jhb'generate' 30 | 'copy' jhb'copy to clipboard' 31 | jhhr 32 | 'gn*sim'jhrad'simple css';1;'cssset' NB. csset radio button group 33 | 'gn*fan'jhrad'fancy css' ;0;'cssset' 34 | jhbr 35 | desc 36 | ) 37 | 38 | length=: 10 NB. chars in password 39 | 40 | NB. return pswd;entropy 41 | gen=: 3 : 0 42 | 'lc uc di sp'=. (26}.Alpha_j_);(26{.Alpha_j_);'0123456789';'~!@#$%^&*()-=_+' 43 | sud=. ;0".each getvs'gn*sp gn*uc gn*di' NB. sp uc di values from event 44 | a=. lc,;sud#sp;uc;di NB. valid pswd chars 45 | (a {~ ? length##a);<<.length*2^.#a 46 | ) 47 | 48 | NB. jhrcmds finishes event handler with 0 or more commands 49 | NB. that will be run in the browser 50 | ev_gn_click=: 3 : 0 51 | lastevent__=: NV NB. name/value pairs in event 52 | length=: 10>.30<.length+('up'-:getv'jsid')-'dn'-:getv'jsid' 53 | 'p e'=. gen'' 54 | len=. 'set len *length: ',":length 55 | psw=. 'set pswd *',p 56 | epy=. 'set epy *entropy: ',":e 57 | css=. 'css *',(1=0".getv'gn*fan')#fancycss 58 | jhrcmds len;psw;epy;css NB. len;psw;css 59 | ) 60 | 61 | ev_create=: 3 : 0 NB. called by page or browser to initialize locale 62 | man assert ''-:y 63 | jhcmds '' 64 | ) 65 | 66 | ev_copy_click=: 3 : 0 67 | jhrcmds'copy *',getv'pswd' 68 | ) 69 | 70 | desc=: 0 : 0 71 |
Modeled after J602 app documented in 72 | J wiki (User:Andrew_Nikitin/Literate).

73 | All events are passed to J handlers and no javascript code is required.

74 | Tab/browser close does not inform J server. 75 | ) 76 | 77 | NB. html cascading style sheet - document look and feel 78 | CSS=: 0 : 0 79 | form{margin:0px 2px 2px 2px;} 80 | *.jhtext{font-family:"monospace";} 81 | ) 82 | 83 | fancycss=: 0 : 0 84 | form{margin:0px 40px;} 85 | #pswd{background-color:salmon;font-size:20px} 86 | ) 87 | -------------------------------------------------------------------------------- /aws/aws-sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # avoid .sh suffix so pacman preserves eol LF on windows 3 | 4 | how="commands: 5 | ? - how to use this script 6 | clr - remove old entry from known_hosts for new instance 7 | 8 | set a.b.c.d - ip address -> .ssh/jhs_aws_ip.txt 9 | setg - jhs_aws_ip.txt -> jhs_aws_ip_guest.txt 10 | setd - jhs_aws_ip_guest.txt -> jhs_aws_ip.txt 11 | 12 | ssh 13 | 14 | get remote-file local-file (scp) 15 | put local-file remote-file (scp) 16 | 17 | ! rsync local is relative to pwd 18 | getr remote-folder-or-file local-folder-or-file (rsync) 19 | putr local-folder-or-file remote-folder-or-file (rsync) 20 | 21 | run command-to-run-on-remote 22 | 23 | bld key j9.x 24 | serve logon-key 25 | 26 | lets-backup - create letsencrypt tar and copy to local .ssh/jserver 27 | lets-restore - copy backup to server and untar to /etc/ 28 | " 29 | 30 | dipf=~/.ssh/jhs_aws_ip.txt 31 | gipf=~/.ssh/jhs_aws_ip_guest.txt 32 | 33 | pem=~/.ssh/jhs1-kp.pem 34 | 35 | IFS='' 36 | ip=`cat $dipf` 37 | 38 | case $1 in 39 | 40 | clr) 41 | ssh-keygen -f ~/.ssh/known_hosts -R $ip # new instance will not match known_hosts - remove entry - security! 42 | ;; 43 | 44 | set) 45 | ip=$2 46 | re='^(0*(1?[0-9]{1,2}|2([0-4][0-9]|5[0-5]))\.){3}' 47 | re+='0*(1?[0-9]{1,2}|2([‌​0-4][0-9]|5[0-5]))$' 48 | if [[ ! $ip =~ $re ]]; then echo "invalid ip" ; exit 2 ; fi 49 | echo $2 > $dipf 50 | ;; 51 | 52 | setg) 53 | cp $dipf $gipf 54 | echo `cat $dipf` 55 | ;; 56 | 57 | setd) 58 | cp $gipf $dipf 59 | echo `cat $dipf` 60 | ;; 61 | 62 | ssh) 63 | ssh -i $pem ec2-user@$ip 64 | ;; 65 | 66 | get) 67 | scp -i $pem ec2-user@$ip:$2 $3 68 | ;; 69 | 70 | put) 71 | scp -i $pem $2 ec2-user@$ip:$3 72 | ;; 73 | 74 | putr) 75 | rsync --exclude .git -avz -e "ssh -i $pem" $2 ec2-user@$ip:$3 76 | ;; 77 | 78 | getr) 79 | rsync -avz -e "ssh -i $pem" ec2-user@$ip:$2 $3 80 | ;; 81 | 82 | 83 | run) 84 | ssh -i $pem ec2-user@$ip $2 85 | ;; 86 | 87 | bld) 88 | [ "$#" -ne 2 ] && echo "one parameter: j9.x" && exit 1 89 | ./aws-sh put cloud-bld-sh 90 | ./aws-sh put cloud-run-sh 91 | ./aws-sh run "./cloud-bld-sh $2" # build j and nodejs 92 | ;; 93 | 94 | server) 95 | [ "$#" -ne 2 ] && echo "one parameter: logon-key" && exit 1 96 | ./aws-sh run "./cloud-run-sh $2" # start JHS and nodejs 97 | echo "starting JHS and nodejs..." 98 | echo "browse to: https://$ip:65101/jijx" 99 | echo "logon-key: $2" 100 | ;; 101 | 102 | lets-restore) 103 | [ ! -f ~/.ssh/jserver/letsencrypt.tar.gz ] && echo "backup .ssh/jserver/letsencypt.tar.gz does not exist" && exit 1 104 | ./aws-sh put ~/.ssh/jserver/letsencrypt.tar.gz foo 105 | ./aws-sh run "sudo mv foo .ssh/jserver/letsencrypt.tar.gz" 106 | ./aws-sh run "sudo tar zxvf ~/.ssh/jserver/letsencrypt.tar.gz -C /" 107 | ;; 108 | 109 | lets-backup) 110 | ./aws-sh run 'sudo tar zcvf .ssh/jserver/letsencrypt.tar.gz /etc/letsencrypt' 111 | ./aws-sh get .ssh/jserver/letsencrypt.tar.gz ~/.ssh/jserver/letsencrypt.tar.gz.$(date +"%Y-%m-%dT%T") 112 | ;; 113 | 114 | # $2 is path to folder with key.pem and cert.pem files 115 | https) 116 | [ "$#" -ne 2 ] && echo "missing path to key/cert .pem files" && exit 1 117 | [ ! -f $2/cert.pem ] && echo "cert.pem not in path" && exit 1 118 | [ ! -f $2/key.pem ] && echo "key.pem not in path" && exit 1 119 | ./aws-sh run "rm .ssh/key.pem" 120 | ./aws-sh run "rm .ssh/cert.pem" 121 | ./aws-sh put $2/key.pem .ssh/key.pem 122 | ./aws-sh put $2/cert.pem .ssh/cert.pem 123 | ;; 124 | 125 | *) 126 | echo "$how" 127 | ;; 128 | esac 129 | -------------------------------------------------------------------------------- /aws/aws-utils.ijs: -------------------------------------------------------------------------------- 1 | NB. utils for aws instance 2 | coclass'jaws' 3 | 4 | NB. create_swap '1G' 5 | NB. swap 1G required for jdrt'pandas' 6 | NB. https://www.digitalocean.com/community/tutorials/how-to-add-swap-space-on-ubuntu-22-04 7 | create_swap=: 3 : 0 8 | er=. 'arg must be of form: nG for n GiB swap file' 9 | er assert 'G'={:y 10 | 'swap already exists'assert ''-:shell'swapon --show' 11 | shell'sudo fallocate -l ',y,' /swapfile' 12 | shell'sudo chmod 600 /swapfile' 13 | shell'sudo mkswap /swapfile' 14 | shell'sudo swapon /swapfile' 15 | shell'swapon --show' 16 | ) 17 | 18 | NB. install pip3/pandas/pyarrow - python3 already installed 19 | NB. required for jdrt'pandas' 20 | install_python=: 3 : 0 21 | 'python3' fwrite '~config/python3.cfg' 22 | run'sudo yum -y install python3-pip' 23 | run'pip3 install pandas' 24 | run'pip3 install pyarrow' 25 | ) 26 | 27 | install_git=: 3 : 0 28 | run'sudo yum -y install git' 29 | ) 30 | 31 | NB. shutdown args same as for terminal command shutdown 32 | NB. shutdown 'now' or '+30' or '-c' 33 | NB. terminate/stop instance - depending on instance shutdown behavior 34 | shutdown=: 3 : 0 35 | shell'sudo shutdown ',y 36 | ) 37 | 38 | NB. kill JHS/nodejs servers and restart 39 | NB. key rerun key - logon key repeated to try to avoid typos 40 | restart=: 4 : 0 41 | 'x and y must be same'assert x-:y 42 | 'key must not contain blank'assert -.' 'e. y 43 | echo 'JHS/nodejs servers killed and restarted' 44 | shell'./cloud-run.sh ',y,' &' 45 | ) 46 | 47 | NB. see jijx menu jfile>jcopy for put/get services 48 | NB. download 'a.tgz';'~user/temp/1.ijs' 49 | NB. download 'b.tgz';'~user/config' 50 | NB. tar file created on server in ~/uploads 51 | NB. and then downloaded to browser downloads folder 52 | download=: 3 : 0 53 | 'name source'=. y 54 | s=. jpath source 55 | i=. s i: '/' 56 | if. i=#s do. 57 | p=. '' 58 | s=. source 59 | else. 60 | p=. dquote i{.s 61 | s=. }.i}.s 62 | end. 63 | mkdir_j_'~/uploads' 64 | file=. '~/uploads/',name 65 | shell 'cd ',p,' && tar czf ',file,' ',dquote s 66 | jhtml_jhs_ '
download: 'rplc'';file;'';name 67 | ) 68 | 69 | NB. hibernate instance - easy to restart with saved state 70 | NB. requires encrypted storage and hibernate option enabled 71 | NB. eip costs start and it might be better to keep smaller machines running 72 | hibernate=: 3 : 0 73 | shell'sudo /etc/acpi/actions/sleep.sh button/sleep SBTN 00000080 00000000' 74 | ) 75 | 76 | run=: 3 : 0 77 | echo y 78 | echo shell y 79 | echo LF 80 | ) 81 | -------------------------------------------------------------------------------- /aws/cloud-bld-sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # $1 is jversion - j9.4 or j9.5 ... 3 | # avoid .suffix so git/pacman preserve eol lf on windows 4 | 5 | # install j 6 | rm $1_linux64.tar.gz 7 | wget -nv www.jsoftware.com/download/$1/install/$1_linux64.tar.gz 8 | tar -zxf $1_linux64.tar.gz 9 | 10 | # update j - mkdir Desktop so install icons don't fail 11 | ln -s -f $1/bin/jconsole jc 12 | ./jc -js "mkdir_j_'Desktop'" "load'pacman'" "'install'jpkg'*'" "exit''" 13 | ln -s -f $1/addons/ide/jhs/guest/guest_util.ijs guest_util.ijs 14 | 15 | # put default self-signed certificates in .ssh 16 | sudo cp $1/addons/ide/jhs/node/key.pem .ssh 17 | sudo cp $1/addons/ide/jhs/node/cert.pem .ssh 18 | sudo chmod 600 .ssh/key.pem 19 | sudo chown ec2-user:ec2-user .ssh/key.pem 20 | sudo chmod 600 .ssh/cert.pem 21 | sudo chown ec2-user:ec2-user .ssh/cert.pem 22 | 23 | # create .ssh/jserver for letsencrypt 24 | sudo mkdir -p .ssh/jserver 25 | sudo chmod 700 .ssh/jserver 26 | sudo chown $1:$1 .ssh/jserver 27 | 28 | # install nodejs 29 | sudo yum -y install nodejs 30 | echo `which node` > nodebin 31 | 32 | # python3 already installed but we also need pip3 33 | sudo yum -y install python3-pip 34 | 35 | # install certbot - letsencrypt 36 | sudo dnf install -y augeas-libs 37 | sudo python3 -m venv /opt/certbot/ 38 | sudo /opt/certbot/bin/pip install --upgrade pip 39 | sudo /opt/certbot/bin/pip install certbot certbot-apache 40 | sudo ln -s -f /opt/certbot/bin/certbot /usr/bin/certbot 41 | -------------------------------------------------------------------------------- /aws/cloud-run-sh: -------------------------------------------------------------------------------- 1 | #!./jc 2 | # avoid .suffix so git/pacman preserve eol lf on windows 3 | load'~addons/ide/jhs/node.ijs' 4 | startJHS_jhs_ '' 5 | startNODE_jhs_ 65101 ; '.ssh' ; {:ARGV NB. key 6 | exit'' 7 | -------------------------------------------------------------------------------- /config/jhs-node.cfg: -------------------------------------------------------------------------------- 1 | NB. JHS server for node server 2 | config_jhs_=: 3 : 0 3 | PORT=: 65001 NB. work required for other ports 4 | AUTO=: 0 NB. do not start browser 5 | NOEXIT=: 1 NB. jijx red button does not do exit'' 6 | ) 7 | setbreak 'node' NB. break from node server 8 | load'~addons/ide/jhs/core.ijs' 9 | load'~addons/ide/jhs/aws/aws-utils.ijs' 10 | init_jhs_'' 11 | -------------------------------------------------------------------------------- /config/jhs.cfg: -------------------------------------------------------------------------------- 1 | NB. start JHS - run jconsole and load this (or other cfg) script 2 | NB. create other cfg - copy this file, rename, and edit 3 | NB. see configdefault_jhs_ for config options 4 | 5 | config_jhs_=: 3 : 0 6 | NB. add/edit config options here 7 | 8 | PORT=: 65001 NB. serve port 65001 9 | 10 | NB. do not edit after here 11 | ) 12 | load'~addons/ide/jhs/core.ijs' 13 | init_jhs_'' 14 | -------------------------------------------------------------------------------- /d3.ijs: -------------------------------------------------------------------------------- 1 | NB. d3 utils 2 | coclass'jhs' 3 | 4 | NB. jd3 plots 5 | 6 | jd3doc=: 0 : 0 7 | jd3'help' 8 | jd3'options' NB. plot options 9 | jd3'state' NB. current options state 10 | jd3'reset' NB. reset options state 11 | jd3'type bar' NB. add type option 12 | jd3'title TITLE' NB. add title option 13 | 14 | example: 15 | jd3'reset;type line;title My Data;legend "line one","line two","line three"' 16 | 'jd3'jpage jd3x;?3 4$100 17 | 18 | jd3'reset;type bar;label "a","b","c","d"' 19 | 'jd3;0 0;abc'jpage jd3x;?3 4$100 20 | 21 | jd3'reset;type pie' 22 | 'jd3;10 10;ghi'jpage jd3x;?4$100 23 | ) 24 | 25 | jd3docoptions=: 0 : 0 26 | jd3'option arg' - add option to jd3x__ 27 | type line - line or pie or bar 28 | header how now
29 | title Good Data 30 | minh 200 - min height 31 | maxh 600 32 | minw 300 - min width 33 | maxw 700 34 | linewidth 4 35 | barwidth 40 36 | label "s","d","f" 37 | legend "a","b","c" 38 | footer
how now 39 | ) 40 | 41 | jd3=: 3 : 0 42 | if. _1=nc<'jd3x__' do. jd3x__=: '' end. 43 | assert 'literal'-:datatype y 44 | if. ';'e. y do. 45 | t=. jd3 each a:-.~<;._2 y,';' 46 | >(0~:;*/each $each t)#t 47 | return. 48 | end. 49 | i=. y i.' ' 50 | c=. dltb i{.y 51 | a=. dltb i}.y 52 | a=. a rplc '"';'''' 53 | b=. '''',a,'''' 54 | select. c 55 | fcase.'' do. 56 | case.'help' do. jd3doc return. 57 | case.'options' do. jd3docoptions return. 58 | case.'state' do. jd3x__ return. 59 | case.'reset' do. jd3x__=: '' return. 60 | case. ;:'type header title footer' do. 61 | t=. c,'=',b 62 | case. ;:'minh maxh minw maxw barwidth linewidth' do. 63 | t=. c,'=',a 64 | case. ;:'legend label' do. 65 | t=. c,'=[',a,']' 66 | case. do. ('jd3 unknown option: ',y)assert 0 67 | end. 68 | jd3x__=: jd3x__,t,LF 69 | i.0 0 70 | ) 71 | 72 | NB. might be better to use jsfromtable - but _123 not handled 73 | jd3data=: 3 : 0 74 | d=. ":each <"1 y 75 | d=. d rplc each <' ';',' 76 | d=. d rplc each <'_';'-' 77 | d=. ']',~each '[',each d 78 | ']',~'data=[',;d,each',' 79 | ) 80 | -------------------------------------------------------------------------------- /demo/jdemo01.ijs: -------------------------------------------------------------------------------- 1 | coclass'jdemo01' 2 | coinsert'jhs' 3 | 4 | NB. sentences to create html body 5 | NB. jhbshtml_jdemo1_'' shows HBS html 6 | HBS=: 0 : 0 7 | jhclose'' NB. standard menu with close 8 | jhh1'Roll with submit' 9 | 'roll' jhb'rollem' 10 | '' 11 | desc 12 | jhdemo'' 13 | ) 14 | 15 | NB. create html page from HBS CSS JS 16 | NB. HBS body can have TAGS that are replaced 17 | create=: 3 : 0 18 | 'jdemo1'jhr'RESULT';y NB. tag replaced by y 19 | ) 20 | 21 | NB. called when browser gets this page 22 | jev_get=: create 23 | 24 | NB. event handler - called by js handler jsubmit() 25 | NB. 6 numbers replace tag 26 | ev_roll_click=: 3 : 'create >:6?49' 27 | 28 | desc=: 0 : 0 29 |
Pressing rollem button:
30 | calls js function ev_roll_click()
31 | which calls jsubmit()
32 | which calls verb ev_roll_click
33 | which returns a new page

34 | 35 | The browser sends all form data with the submit request 36 | to the server. The server creates a complete new page and 37 | sends it to the browser. There is little form data in this example 38 | and the page is small so there is not much data sloshing. 39 | But in a real app it could be lots and the app could be sluggish, 40 | especially over a network. 41 | ) 42 | 43 | CSS=: '' NB. styles 44 | 45 | JS=: 0 : 0 NB. javascript 46 | function ev_roll_click(){jsubmit();} // submit form - calls J ev_roll_click 47 | ) 48 | -------------------------------------------------------------------------------- /demo/jdemo02.ijs: -------------------------------------------------------------------------------- 1 | coclass'jdemo02' 2 | coinsert'jhs' 3 | 4 | HBS=: 0 : 0 5 | jhclose'' NB. standard menu with close 6 | jhh1'Roll with ajax' 7 | 'roll' jhb'rollem' 8 | 'result' jhspan'' 9 | desc 10 | jhdemo'' 11 | ) 12 | 13 | create=: 3 : 0 14 | 'jdemo2'jhr'' 15 | ) 16 | 17 | ev_roll_click=: 3 : 'jhrajax ":>:6?49' 18 | 19 | jev_get=: create 20 | 21 | desc=: 0 : 0 22 |
Ajax stands for 'asynchronous javascript and xml'.

23 | 24 | An app transaction without ajax waits for all the form 25 | data to be transmitted to the server, waits for the server 26 | to format an entire new page, waits for the new page to be 27 | transmitted to the browser, and waits for the browser to 28 | format and display the page. In a complicated app 29 | this can be a great deal of data sloshing and unnecessary 30 | processing. Non-trivial apps that use submit are sluggish 31 | compared to desktop apps.

32 | 33 | An ajax app transaction sends only required data to the 34 | server, gets back only required data, and updates 35 | the page dynamically in place affecting only the parts 36 | that have changed. With reasonably fast transmission 37 | ajax apps can rival desktop apps. 38 | ) 39 | 40 | CSS=: '' NB. styles 41 | 42 | JS=: 0 : 0 NB. javascript 43 | // event handler - send ajax request to J 44 | // jdoajx args are 45 | // list of form element names to send as name=value 46 | // string to send as jdata= value 47 | // [] is an empty list "" is an empty string 48 | function ev_roll_click(){jdoajax([],"");} 49 | 50 | // framework calls with the jhrajax argument 51 | // ts is list of JASEP delimited strings 52 | // ts[0] is first (and in this example only) string 53 | // sets result element innerHTML with the 6 numbers 54 | function ev_roll_click_ajax(ts){jbyid("result").innerHTML=ts[0];} 55 | ) 56 | -------------------------------------------------------------------------------- /demo/jdemo03.ijs: -------------------------------------------------------------------------------- 1 | coclass'jdemo03' 2 | coinsert'jhs' 3 | 4 | HBS=: 0 : 0 5 | jhclose'' NB. standard menu with close 6 | jhh1'Flip - ajax args and results' 7 | 'flip' jhb'flipem' 8 | 't1' jhtext'some text';10 9 | 't2' jhtext'more text';10 10 | desc 11 | jhdemo'' 12 | ) 13 | 14 | create=: 3 : 0 15 | 'jdemo3'jhr'' 16 | ) 17 | 18 | NB. NV_jhs_ has request name/value pairs 19 | NB. getvs't1 t2' returns values for names t1 and t2 20 | NB. smoutput seebox NV can help debugging 21 | NB. JASEP separates ajax results 22 | ev_flip_click=: 3 : 0 23 | smoutput seebox NV 24 | 't1 t2'=. getvs't1 t2' 25 | jhrajax (8 u:|.7 u: t1),JASEP,(8 u:|.7 u: t2) 26 | ) 27 | 28 | jev_get=: create NB. browser get request 29 | 30 | JS=: 0 : 0 31 | 32 | // send t1 and t2 name/value pairs to J 33 | function ev_flip_click(){jdoajax(["t1","t2"],"");} 34 | 35 | // firefox enter in textarea does not trigger default button event 36 | function ev_t1_enter(){jscdo("flip");} 37 | function ev_t2_enter(){jscdo("flip");} 38 | 39 | // ts is list of JASEP delimited strings 40 | function ajax(ts) 41 | { 42 | if(2!=ts.length)alert("wrong number of ajax results"); 43 | jbyid("t1").value=ts[0]; 44 | jbyid("t2").value=ts[1]; 45 | } 46 | ) 47 | 48 | desc=: 0 : 0 49 |
An ajax request sends only required data to the server. 50 | The JHS framework sends values of html form elements 51 | that have been listed in the jdoajax arg. Hidden text 52 | elements are useful for data that should not be visible to 53 | the user.

54 | 55 | An ajax result can be any string of bytes. The JHS framework 56 | convention is to send strings of data delimited by the byte 57 | value JASEP. 58 | ) 59 | 60 | -------------------------------------------------------------------------------- /demo/jdemo04.ijs: -------------------------------------------------------------------------------- 1 | coclass'jdemo04' 2 | coinsert'jhs' 3 | 4 | HBS=: 0 : 0 5 | jhclose'' NB. standard menu with close 6 | jhh1'Controls with javascript and CSS' 7 | 'javascript:' 8 | 'which' jhspan'this is the which text' 9 | jhbr,jhbr 10 | 'cb0' jhchk 'chb 0';0 11 | 'cb1' jhchk 'chk 1';1 12 | jhbr 13 | 'rad0' jhrad 'rad one';1;'radgroup' 14 | 'rad1' jhrad 'rad two';0;'radgroup' 15 | jhbr 16 | 'sel' jhselect ('zero';'one';'two';'three';'four');1;0 17 | jhbr 18 | text 19 | jhbr 20 | 'blue' jhb'color blue' 21 | 'red' jhb'color red' 22 | jhbr 23 | desc 24 | jhdemo'' 25 | ) 26 | 27 | text=: 0 : 0 28 | Now is the time 29 | for all good 30 | folk to come to the party. 31 | ) 32 | 33 | create=: 3 : 0 34 | 'jdemo4'jhr'' 35 | ) 36 | 37 | jev_get=: create 38 | 39 | desc=: 0 : 0 40 |
This page has a few controls with simple javascript event handlers. 41 | ) 42 | 43 | CSS=: 0 : 0 44 | span.mark{color:green;} 45 | ) 46 | 47 | JS=: 0 : 0 48 | function show(){jbyid("which").innerHTML= JEV;} 49 | 50 | function ev_foo_click(){show();} 51 | function ev_goo_click(){show();} 52 | function ev_moo_click(){show();} 53 | function ev_koo_click(){show();} 54 | 55 | function ev_d_shortcut(){jbyid("which").innerHTML= "ev_d_shortcut";} 56 | 57 | function color(c) 58 | { 59 | show(); 60 | jbyid("one").style.color=c; 61 | jbyid("two").style.color=c; 62 | } 63 | 64 | // set text span elements blue 65 | function ev_blue_click(){color("blue");} 66 | 67 | // set text span elements red 68 | function ev_red_click(){color("red");} 69 | 70 | // radio button handlers 71 | function ev_rad0_click(){show();jsetchk(jform.jid.value,1);} 72 | function ev_rad1_click(){show();jsetchk(jform.jid.value,1);} 73 | 74 | // checkbox button handlers 75 | function ev_cb0_click(){show();jflipchk(jform.jid.value);} 76 | function ev_cb1_click(){show();jflipchk(jform.jid.value);} 77 | 78 | function ev_sel_change() 79 | { 80 | jbyid("which").innerHTML= JEV+" : "+jbyid("sel").selectedIndex; 81 | } 82 | ) 83 | -------------------------------------------------------------------------------- /demo/jdemo05.ijs: -------------------------------------------------------------------------------- 1 | coclass'jdemo05' 2 | coinsert'jhs' 3 | 4 | NB. sentences to create html elements 5 | NB. jhbshtml_jdemoxx_'' shows HBS html 6 | HBS=: 0 : 0 7 | jhclose'' 8 | 'title' jhh1 'chartjs' 9 | 'run'jhb'run' 10 | 'sentence'jhtext'' 11 | jhbr 12 | 'cjsa'jhchart'' 13 | ) 14 | 15 | NB. style the html elements 16 | CSS=: 0 : 0 17 | .jhchart_parent{border:solid;height:200px;width:50%;float:left;} 18 | ) 19 | 20 | get=: 3 : 0 21 | jcjs'type';y 22 | jcjs'get' 23 | ) 24 | 25 | NB. validate sentence 26 | validate=: 3 : 0 27 | try. 28 | v=. ".y 29 | assert (1=$$v)*.2~:3!:0 v 30 | catch. 31 | echo 'bad sentence: ',y 32 | y=. '5?5' 33 | v=. ".y 34 | end. 35 | y;v 36 | ) 37 | 38 | create=: 3 : 0 39 | 't v'=. validate y 40 | jcjs'reset' 41 | jcjs'labels';#v 42 | jcjs'data';v 43 | jcjs'legend';'mydata' 44 | jcjs'add';'options.animation.duration 2000' 45 | ('set sentence *',t);('chartjs cjsa *',get'line') 46 | ) 47 | 48 | ev_create=: 3 : 0 49 | jhcmds create y jpagedefault '5?5' 50 | ) 51 | 52 | ev_run_click=: {{ jhrcmds create getv'sentence' }} 53 | ev_sentence_enter=: ev_run_click 54 | 55 | INC=: INC_chartjs NB. include chart js code 56 | 57 | -------------------------------------------------------------------------------- /demo/jdemo06.ijs: -------------------------------------------------------------------------------- 1 | coclass'jdemo06' 2 | coinsert'jhs' 3 | 4 | HBS=: 0 : 0 5 | jhclose'' NB. standard menu with close 6 | jhh1'Grid Demo' 7 | jhhr 8 | jgridnumedit'g0';'';'';'gdata0__' 9 | jhhr 10 | jgridnumedit'g1';'';'';'gdata1__' 11 | jhhr 12 | desc 13 | jhdemo'' 14 | ) 15 | 16 | create=: 3 : 0 17 | CSS=: jgridnumeditcss'g0';'80px' 18 | CSS=: CSS,jgridnumeditcss'g1';'40px' 19 | 'jdemo6'jhr'' 20 | ) 21 | 22 | jev_get=: create NB. browser get request 23 | 24 | ev_g0_dd_enter=: gup 25 | ev_g1_dd_enter=: gup 26 | 27 | gup=: 3 : 0 28 | mid=. getv'jmid' 29 | sid=. getv'jsid' 30 | gid=. mid{.~mid i.'_' 31 | name=. getv gid,'_hh' 32 | r=. (sid i.'*'){.sid 33 | c=. (>:sid i.'*')}.sid 34 | v=. {.0".getv gid,'_vv' NB. new grid cell value 35 | d=. ".name 36 | d=. v (P=: <(".r);".c)}d 37 | ".name,'=: d' 38 | ctotal=. ":(".c){+/d 39 | rtotal=. ":(".r){+/"1 d 40 | d=. mid,'*',sid,JASEP,(":v),JASEP,gid,'_cf*0*',c,JASEP,ctotal,JASEP,gid,'_rf*',r,'*0',JASEP,rtotal 41 | NB. htmlresponse d,~hajax rplc '';":#d 42 | jhrajax d 43 | ) 44 | 45 | desc=: 0 : 0 46 |
Edit global nouns gdata0__ and gdata1__.

47 | 48 | The grid numeric editor uses ajax. When a cell value is 49 | changed, just 3 numbers (value,row,column) are sent to 50 | to the server. The server updates the noun, calculates 51 | new totals, and sends back 3 numbers 52 | (possibly corrected value,new column total,new row total), 53 | and then javascript updates just the affected cells. 54 | ) 55 | 56 | JS=: 0 : 0 57 | function gup() 58 | { 59 | var t= jform.jmid.value; 60 | var gid= t.substring(0,t.indexOf("_")); 61 | jform.jtype.value= 'enter'; // change becomes enter 62 | jbyid(gid+"_vv").value= jbyid(gid+"_dd*"+jform.jsid.value).value; 63 | jdoajax([gid+"_hh",gid+"_vv"],""); 64 | } 65 | 66 | function ev_g0_dd_enter(){gup();} 67 | function ev_g1_dd_enter(){gup();} 68 | 69 | // leaving changed cell (tab,mouse,...) 70 | // process as enter and return true to continue tab or ... 71 | function ev_g0_dd_change(){gup();return true;} 72 | function ev_g1_dd_change(){gup();return true;} 73 | 74 | function ajax(ts) 75 | { 76 | if(6!=ts.length)alert("wrong number of ajax results"); 77 | jbyid(ts[0]).value=ts[1]; 78 | jbyid(ts[2]).value=ts[3]; 79 | jbyid(ts[4]).value=ts[5]; 80 | } 81 | 82 | ) 83 | 84 | -------------------------------------------------------------------------------- /demo/jdemo07.ijs: -------------------------------------------------------------------------------- 1 | coclass'jdemo07' 2 | coinsert'jhs' 3 | 4 | HBS=: 0 : 0 5 | jhclose'' NB. standard menu with close 6 | jhh1'Table layout' 7 | jhtablea 8 | jhtr 'longer label:';('t00'jhtext'';10);'a:' ;'t01'jhtext'';5 9 | jhtr 'medium:' ;('t10'jhtext'';10);'bbbb:';'t11'jhtext'';5 10 | jhtr 'short:' ;'t20'jhtext'';10 11 | jhtr '' ;'' ;'dd:' ;'t31'jhtext'';5 12 | jhtablez 13 | jhdemo'' 14 | ) 15 | 16 | create=: 3 : 0 17 | 'jdemo7'jhr'' 18 | ) 19 | 20 | jev_get=: create 21 | -------------------------------------------------------------------------------- /demo/jdemo08.ijs: -------------------------------------------------------------------------------- 1 | coclass'jdemo08' 2 | coinsert'jhs' 3 | 4 | NB. do not use

if sizing 5 | NB. FF and IE get extra body background which 6 | NB. throws off calcualations 7 | 8 | NB. giving body and each div a different background color 9 | NB. can be useful in figuring this stuff out 10 | 11 | HBS=: 0 : 0 12 | jhclose'' NB. standard menu with close 13 | 'a' jhdiva '' 14 | 'Dynamic Resize' NB. jhh1'Dynamic Resize' 15 | jhdivz 16 | 'm' jhdiv jhfroma toJ fread jpath'~addons/ide/jhs/demo/jdemo08.ijs' 17 | 'z' jhdiv jhdemo'' 18 | ) 19 | 20 | CSS=: 0 : 0 21 | #m{overflow:scroll;border:solid;border-width:1px;} 22 | ) 23 | 24 | create=: 3 : 0 25 | 'jdemo08'jhr'' 26 | ) 27 | 28 | jev_get=: create 29 | 30 | 0 : 0 31 | Window has 3 divs.
32 | Divs a and z are sized by their contents.
33 | Div m is resized to fill the window. 34 | ) 35 | 36 | JS=: 0 : 0 37 | window.onresize= resize; 38 | 39 | function ev_body_load(){resize();} 40 | 41 | function resize(){ 42 | var a= jgpwindowh();// window height 43 | a-= jgpbodymh(); // body margin h (top+bottom) 44 | a-= jgpdivh("a"); // div a height 45 | a-= jgpdivh("z"); // div z height 46 | a-= 6 // fudge to avoid outside scroll 47 | a= a<0?0:a; // negative causes problems 48 | jbyid("m").style.height= a+"px"; 49 | } 50 | ) 51 | -------------------------------------------------------------------------------- /demo/jdemo09.ijs: -------------------------------------------------------------------------------- 1 | coclass'jdemo09' 2 | coinsert'jhs' 3 | 4 | NB. css/js library files to include 5 | INC=: INC_d3_basic 6 | 7 | NB. J sentences - create html body 8 | HBS=: 0 : 0 9 | jhclose'' NB. standard menu with close 10 | jhh1 'd3 basic' 11 | 'ha'jhdiva'' 12 | desc 13 | jhdemo'' 14 | jhhr 15 | 'data'jhtext'';20 16 | 'plot'jhb'plot' 17 | 'flip'jhb'v/h' 18 | '

' 19 | 'ga'jhd3_basic'' NB. ga,ga_... divs for d3_basic plot 20 | 'gb'jhd3_basic'' NB. gb,gb_... divs for d3_basic plot 21 | ) 22 | 23 | desc=: 'D3 line and bar plots with same data' 24 | 25 | NB. additional CSS - float:left allows side by side plots 26 | CSS=: 0 : 0 27 | #ga_box{float:left;} 28 | #gb_box{float:left;} 29 | ) 30 | 31 | NB. J handlers for app events 32 | 33 | jev_get=: 3 : 0 34 | sentence=. '?2 8$100' 35 | data=. jd3data ".sentence 36 | 'jdemo13'jhrx(getcss''),(getjs'TABDATA';data),gethbs'SENTENCE';sentence 37 | ) 38 | 39 | ev_plot_click=: 3 : 0 40 | d=. getv'data' 41 | jhrajax jd3data".d 42 | ) 43 | 44 | NB. javascript 45 | JS=: 0 : 0 46 | hv= 1; 47 | tabdata=""; // from jev_get 48 | 49 | function ev_plot_click(){jdoajax(["data"]);} // include form data/value in request 50 | 51 | function ev_plot_click_ajax(ts) 52 | { 53 | tabdata=ts[0]; 54 | resize(); 55 | } 56 | 57 | function ev_data_enter(){jscdo("plot");} 58 | 59 | function ev_flip_click(){hv= hv?0:1;resize();} 60 | 61 | function ev_body_load() 62 | { 63 | document.title= window.name; 64 | resize(); 65 | window.onresize= resize; 66 | } 67 | 68 | function resize() 69 | { 70 | w= window.innerWidth-20; 71 | h= window.innerHeight-20; 72 | h= h-jbyid("ha").clientHeight; 73 | if(hv) w= w/2; else h= h/2; 74 | w= w+"px"; 75 | h= h+"px"; 76 | jbyid("ga_box").style.width=w; 77 | jbyid("ga_box").style.height=h; 78 | jbyid("gb_box").style.width=w; 79 | jbyid("gb_box").style.height=h; 80 | plot("ga",'type="line"\n'+tabdata); 81 | plot("gb",'type="bar"\n'+tabdata); 82 | } 83 | -------------------------------------------------------------------------------- /demo/jdemo10.ijs: -------------------------------------------------------------------------------- 1 | coclass'jdemo10' 2 | coinsert'jhs' 3 | 4 | HBS=: 0 : 0 5 | jhclose'' NB. standard menu with close 6 | jhh1'Ajax chunks' 7 | 'run' jhb'get ajax response in 4 chunks with 2 second delays' 8 | jhtablea 9 | jhtr 'chunk:' ; 'chunk' jhtext '';20 10 | jhtr 'chunks:' ; 'chunks' jhtext '';20 11 | jhtablez 12 | desc 13 | jhdemo'' 14 | ) 15 | 16 | desc=: 0 : 0 17 |
18 | J can provide an ajax response in chunks as it comes available.

19 | Intermediate results can be provided in a long running request as soon 20 | as they are ready and Javascript can do incremental and timely page updates.

21 | Typically the chunks for processeing need to be delimited as the data 22 | received boundaries don't necessarily correspond with chunks.

23 | In this demo JASEP is used to delimit chunks. 24 | ) 25 | 26 | create=: 3 : 0 27 | 'jdemo10'jhr'' 28 | ) 29 | 30 | NB. JASEP delimits chunks 31 | ev_run_click=: 3 : 0 32 | jhrajax_a 'a',JASEP NB. first chunk 33 | 6!:3[2 34 | jhrajax_b 'bb',JASEP NB. annother chunk 35 | 6!:3[2 36 | jhrajax_b 'ccc',JASEP NB. another chunk 37 | 6!:3[2 38 | jhrajax_z 'ddd',JASEP NB. last chunk 39 | i.0 0 40 | ) 41 | 42 | jev_get=: create 43 | 44 | CSS=: '' NB. styles 45 | 46 | JS=: 0 : 0 NB. javascript 47 | 48 | function ev_run_click() 49 | { 50 | jbyid("chunk").value= ""; 51 | jbyid("chunks").value= ""; 52 | jdoajax([],"",jevsentence,true); // async 53 | } 54 | 55 | function ev_run_click_ajax(){;} 56 | 57 | // process next chunk 58 | function process(c) 59 | { 60 | jbyid("chunk").value= c; 61 | jbyid("chunks").value+= c; 62 | } 63 | 64 | // framework calls with responseText so far 65 | // next chunk is from rqoffset up to JASEP 66 | function ev_run_click_ajax_chunk() 67 | { 68 | while(1) // there could be 0, 1, or several chunks in the new data 69 | { 70 | var a= rq.responseText.substr(rqoffset); // not yet processed 71 | var i= a.indexOf(JASEP); 72 | if(i==-1) break; // do not have a chunk 73 | rqchunk= a.substr(0,i); 74 | process(rqchunk); 75 | rqoffset= rqoffset+i+1; 76 | } 77 | } 78 | 79 | 80 | ) -------------------------------------------------------------------------------- /demo/jdemo11.ijs: -------------------------------------------------------------------------------- 1 | coclass'jdemo11' 2 | coinsert'jhs' 3 | 4 | HBS=: 0 : 0 5 | jhclose'' NB. standard menu with close 6 | jhh1'Ajax interval timer' 7 | 'start' jhb 'start' 8 | 'stop' jhb 'stop' 9 | 'tf' jhtext '';20 10 | desc 11 | jhdemo '' 12 | ) 13 | 14 | create=: 3 : 0 15 | count=: 0 16 | 'jdemo11'jhr'' 17 | ) 18 | 19 | jev_get=: create 20 | 21 | jev_sys_time=: 3 : 'jhrajax ":count=: >:count' 22 | 23 | desc=: 0 : 0 24 |
Javascript interval timer can trigger J execution. 25 | ) 26 | 27 | CSS=: '' NB. styles 28 | 29 | JS=: 0 : 0 NB. javascript 30 | var interval=null; 31 | 32 | function ev_start_click() 33 | { 34 | if(interval==null) 35 | { 36 | timer_event(); 37 | interval= setInterval(function(){timer_event()},1000); 38 | } 39 | } 40 | 41 | function ev_stop_click() 42 | { 43 | if(interval!=null) clearInterval(interval); 44 | interval= null; 45 | } 46 | 47 | function ajax(){ jbyid("tf").value= rq.responseText;} 48 | 49 | function timer_event() 50 | { 51 | jdoajax([],"","jev_sys_time_"+jform.jlocale.value+"_[0",true); // async 52 | } 53 | 54 | ) -------------------------------------------------------------------------------- /extra/man.ijs: -------------------------------------------------------------------------------- 1 | coclass'jman' 2 | man_z_=: man_jman_ 3 | zloc=: <,'z' 4 | 5 | NB.! perhaps base9 (<500k) should be included in base library 6 | 7 | NB. y is name - abc abc_jd_ abc__c or locale - _jhs_ 8 | NB. display comments before definition in defining script 9 | NB. last defn is used! 10 | NB. if defining script is in ~system it looks for source script in base9 11 | NB. would be nice to support f* to return all matches 12 | man=: 3 : 0 13 | r=. getman y 14 | NB. remove NB.*blank and NB.blank 15 | r=. <;.2 r 16 | b=. ;(<'NB.* ')=5{.each r 17 | r=. (b*5)}.each r 18 | b=. ;(<'NB. ')=4{.each r 19 | r=. (b*4)}.each r 20 | jselect_jhs_ ;r 21 | ) 22 | 23 | getman=: 3 : 0 24 | n=. dltb y 25 | if. '_'={.n do. 26 | t=. ('nl',n)~1 2 3 27 | t=. ;LF,~each(<''''),~each(<' man'''),each t,each0 52 | f=. i{4!:3'' 53 | t=. jpath'~system/' 54 | if. t-: (#t){.;f do. 55 | NB. look for defn in base9 56 | p=. jpath'~Base9x' 57 | if. p-:'~Base9x' do. 58 | '~Base9 not defined. Add ~Base9 to folders.cfg to point at Base9.'assert 0 59 | end. 60 | dt=. {."1 dirtree p,'/*.ijs' 61 | for_f. dt do. 62 | r=. (fread f) manx n 63 | if. -.r-:'not found' do. r break. end. 64 | end. 65 | else. 66 | r=. (fread f) manx n 67 | end. 68 | r=. ' ',n,LF,(' edit''',(;f),''''),LF,(LF={.r)}.r 69 | ) 70 | 71 | manx=: 4 : 0 72 | d=. x 73 | p=. ('_'={:y){::y; ((}:y)i:'_'){.y 74 | nna=. '(^|[^[:alnum:]_])' 75 | nnz=. '($|[^[:alnum:]_])' NB. .: removed 76 | gass=. '[[:space:]]*=:' 77 | p=. nna,p,gass 78 | b=. p rxmatches_jregex_ d 79 | select. #b 80 | case. 0 do. 'not found' return. 81 | case. 1 do. 82 | case. do. 'found: ',":#b 83 | end. 84 | bdx=. <;._2 d,LF 85 | bd=. dltb each bdx 86 | 87 | i=. {.{:{:b 88 | i=. i+LF=i{d 89 | i=. +/LF=i{.d 90 | 91 | t=. i{.bd 92 | a=. (;(<'NB.')=3{.each t)+.0=;#each t 93 | h=. a i: 0 94 | 95 | if. 0*.')'=;h{bd do. NB. back up over one set of 0 : 0 lines 96 | t=. h{.bd 97 | a=. ;+./each (<'0 : 0') E. each t 98 | a=. a+.;+./each (<'0 :0') E. each t 99 | a=. a+.;t=<,')' 100 | a=. a i: 1 101 | h=. h-<:((#t)-a)*a<#t 102 | end. 103 | 104 | r=. (>:h)}.(>:i){.bdx 105 | ;r,each LF 106 | ) 107 | 108 | doin=: 4 : '(.9-#n)#' '),p,LF 121 | d fwrite f 122 | UserFolders_j_=: UserFolders_j_,n;jpath p 123 | ) 124 | -------------------------------------------------------------------------------- /extra/manage.ijs: -------------------------------------------------------------------------------- 1 | NB. validate app/page/demo scripts 2 | validate=: 3 : 0 3 | 'ev_create not found'assert 'ev_create'vsub'app' 4 | 'create found' assert -.'create'vsub'app' 5 | 6 | 'ev_create not found'assert 'ev_create'vsub'page' 7 | 'create found' assert -.'create'vsub'page' 8 | 9 | 'ev_create found'assert -.'ev_create'vsub'demo' 10 | NB. 'create not found' assert 'create'vsub'demo' 11 | 12 | a=. geth1_jijx_'~addons/ide/jhs/demo/jdemo*.ijs' 13 | if. 0~:+/'no header'E.;{."1 a do. 14 | echo 'demo folder has files without jhh1' 15 | end. 16 | if. -.demo_order_jijx_-:/:~{:"1 a do. 17 | echo 'demo folder mistatch with order_demo' 18 | end. 19 | a=. geth1_jijx_'~addons/ide/jhs/app/app*.ijs' 20 | if. 0~:+/'no header'E.;{."1 a do. 21 | echo 'app folder has files without jhh1' 22 | end. 23 | if. -.app_order_jijx_-:/:~{:"1 a do. 24 | echo 'app folder mistatch with order_app' 25 | end. 26 | i.0 0 27 | ) 28 | 29 | vsub=: 4 : 0 30 | d=. 1 dir '~addons/ide/jhs/',y 31 | t=. <;.2 fread each d 32 | (#d)=+/;+/each( 2 | 3 | 4 | 5 | 19 | 20 |

JHS

21 |

your JHS sesssion has closed

22 |

23 | 24 |
25 | 26 | 37 | 38 | -------------------------------------------------------------------------------- /guest/create-jguest-sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # $1 is $USER for chmod 3 | # $2 is path to current J install 4 | 5 | # /jguest is copy of current J install 6 | rm -f -r /jguest 7 | mkdir /jguest 8 | # L option follows jhs symbolic link 9 | cp -Lr $2 /jguest/j 10 | 11 | if [ -d /etc/letsencrypt/live/ ] 12 | then 13 | d=`sudo find /etc/letsencrypt/live/ -name cert.pem` 14 | else 15 | d="" 16 | fi 17 | 18 | if [ -z "$d" ] 19 | then 20 | echo 'unsigned certificate' 21 | cert=/jguest/j/addons/ide/jhs/node/cert.pem 22 | key=/jguest/j/addons/ide/jhs/node/key.pem 23 | else 24 | echo 'letsencrypt certificate' 25 | cert=${d#s} 26 | key=${cert::-8}privkey.pem 27 | fi 28 | 29 | mkdir -p jpersist 30 | mkdir -p .ssh/jserver 31 | chmod 700 .ssh/jserver 32 | chown $1:$1 .ssh/jserver 33 | cp $cert .ssh/jserver/cert.pem 34 | cp $key .ssh/jserver/key.pem 35 | chmod 600 .ssh/jserver/cert.pem 36 | chmod 600 .ssh/jserver/key.pem 37 | chown $1:$1 .ssh/jserver/cert.pem 38 | chown $1:$1 .ssh/jserver/key.pem 39 | 40 | echo $(basename $2) > "/jguest/version.txt" 41 | -------------------------------------------------------------------------------- /guest/guest-sudo-sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # guest port 3 | # user port unused restart 4 | # break port 5 | # restore port name 6 | # clear port 7 | # du 0 8 | 9 | # depends on /j soft link to j install folder 10 | 11 | # can sudo without password 12 | 13 | purge () { 14 | if [ -d /home/$user ]; then 15 | sudo pkill -U $user 16 | 17 | # if jpersist is defined - backup ~temp 18 | if [ -f /home/$user/jpersist.txt ]; then 19 | sudo tar -czf jpersist/`cat /home/$user/jpersist.txt`.tgz -C /home/$user `cat /jguest/version.txt`-user 20 | fi 21 | 22 | sudo userdel -r $user > /dev/null 2>&1 23 | fi 24 | } 25 | 26 | user=p$2 # user for port 27 | if [ "$2" = "65001" ]; then user=$USER; fi # unless port is 65001 28 | 29 | # /home/$user created if required 30 | 31 | case $1 in 32 | guest) 33 | purge 34 | sudo useradd -m -g pgroup $user 35 | sudo chmod 700 /home/$user # ensure 700 in case /etc/login.defs HOME_MODE not set to 700 36 | su -l -c "/jguest/j/bin/jconsole /jguest/j/addons/ide/jhs/guest/guest.ijs $2 &" $user 37 | ;; 38 | 39 | kill) 40 | purge 41 | ;; 42 | 43 | user) 44 | # task to serve port is started if port not active or if $4 is restart 45 | # $3 unused - was $USER 46 | p=`fuser -n tcp $2 2>/dev/null` 47 | if [[ $4 == "true" || ! $p ]]; then 48 | sudo fuser --kill -n tcp $2 49 | su -l -c "/jguest/j/bin/jconsole /jguest/j/addons/ide/jhs/guest/user.ijs $2 &" $3 50 | fi 51 | ;; 52 | 53 | break) 54 | su -l -c "/jguest/j/bin/jconsole -js break\'node\' exit\'\' " $user 55 | ;; 56 | 57 | restore) 58 | sudo echo -n $3 > /home/$user/jpersist.txt 59 | sudo rm -f /home/$user/jpersist.tgz 60 | if [ -f jpersist/$3.tgz ]; then 61 | sudo cp jpersist/$3.tgz /home/$user/jpersist.tgz 62 | sudo chown $user:pgroup /home/$user/jpersist.tgz 63 | fi 64 | ;; 65 | 66 | du) 67 | # echo "..." necessary to preserve \t and \n 68 | echo "`sudo du -s -b /home/p* 2> /dev/null`" # execSync result 69 | ;; 70 | esac 71 | 72 | 73 | -------------------------------------------------------------------------------- /guest/guest.ijs: -------------------------------------------------------------------------------- 1 | NB. start jhs guest on port 2 | load'~addons/ide/jhs/core.ijs' 3 | setbreak'node' 4 | configdefault_jhs_'' 5 | PORT_jhs_=:0".;2{ARGV 6 | AUTO_jhs_=:0 7 | TIPX_jhs_=: 'g' 8 | QRULES_jhs_=: 2 NB. exit without jhrajax 9 | GUEST_jhs_=: 1 10 | 11 | t=. ":each <.each 60 60 1e6%~each 0".each <;._1 ' ',}:fread'/jguest/args' 12 | 13 | tool_guest_rules_jijx_=: 0 : 0 hrplc_jhs_ 'LIMIT IDLE DULIM';t 14 | A guest session runs JHS in your browser as front end to a J task on a linux server. 15 | 16 | A good way to learn about J. Run tutorials and experiment before you take the step of 17 | installing on your own machine. 18 | 19 | A guest session ends when it: 20 | •has run for minutes 21 | •is idle for minutes 22 | •more disk than MB 23 | •uses excessive resources 24 | ) 25 | 26 | tool_guest_files_jijx_=: 0 : 0 27 | ☰.file >jcopy moves files between server and your machine. 28 | 29 | All files created are deleted when the session ends. 30 | 31 | ~temp files can be carried forward to a new guest session. 32 | 33 | Run sentence (... is your private choice of savedname): 34 | jgp'...' 35 | 36 | If savedname exists, then its files are copied to the ~temp folder. 37 | 38 | When the session ends, ~temp files are copied to savedname. 39 | ) 40 | 41 | jgp_jhs_=: 3 : 0 42 | name=. fread'jpersist.txt' 43 | if. (8>#y)+.0~:#y-.AlphaNum_j_ do. NB. enforced in guest.js 44 | ferase'jpersist.txt' 45 | echo'must be at least 8 alphanumerics' 46 | echo LF,'no files copied when this session ends' 47 | return. 48 | end. 49 | 50 | if. 1~:ftype'jpersist.tgz' do. 51 | echo'no files to restore' 52 | else. 53 | r=. <;.2 shell'tar -xzvf jpersist.tgz' 54 | ferase'jpersist.tgz' 55 | echo ;('/'~:;_2{each r)#r 56 | end. 57 | echo LF,'~user copied to saved-name when session ends' 58 | echo 'saved-name required to restore ~user in new session!' 59 | ) 60 | 61 | jgp__=: jgp_jhs_ 62 | 63 | init_jhs_'' 64 | -------------------------------------------------------------------------------- /guest/redirect.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 9 | 10 | -------------------------------------------------------------------------------- /guest/survey.ijs: -------------------------------------------------------------------------------- 1 | coclass'jsurvey' 2 | coinsert'jhs' 3 | 4 | NB. locale jsurvey must match url used in guest.js 5 | 6 | thankyou=: 0 : 0 7 |
Jsoftware 8 | thanks you for submitting this survey. 9 |
10 | ) 11 | 12 | survey=: 0 : 0 13 |
Jsoftware survey - basic

14 | Your answers to these 12 questions will help guide Jsoftware efforts to improve J. A comment area follows each guestion. 15 |
16 | 17 | +How long have you been using J? 18 | *less than 1 year 19 | *1-3 years 20 | *4-10 year 21 | *seems like forever 22 | 23 | +Which platform do you use most with J? 24 | *Windows 25 | *Mac 26 | *Linux 27 | *iOS 28 | *Android 29 | 30 | +What platforms do you use with J? 31 | -Windows 32 | -Mac 33 | -Linux 34 | -iOS 35 | -Android 36 | 37 | +Which J front end do you use the most? 38 | *Jqt 39 | *jconsole 40 | *JHS 41 | 42 | +What J front ends to you use? 43 | *Jqt 44 | *jconsole 45 | *JHS 46 | 47 | +What script editor do you us the most? 48 | *Jqt edit 49 | *JHS edit 50 | *Visual Studio Code 51 | 52 | +What J technologies do you use? 53 | -plot 54 | -viemat 55 | -dissect 56 | -Jd 57 | -Jqt window driver 58 | -JHS apps 59 | 60 | +What use do you make of debug? 61 | *none 62 | *raw (dbr,dbs,...) 63 | *Jqt 64 | *JHS 65 | 66 | +How old are you? 67 | *under 20 68 | *21 to 30 69 | *31 to 40 70 | *41 to 50 71 | *over 50 72 | 73 | +How would you rate Jsoftware support for J? 74 | *poor 75 | *average 76 | *excellent 77 | 78 | +Would you recommend J to a friend or colleague? 79 | *no 80 | *yes 81 | *absolutely 82 | 83 | +Comments please! 84 | ) 85 | 86 | NB. question,item 87 | getid=: 3 : 0 88 | 'q i question item'=. y 89 | questions=: questions,question;item 90 | id=. 'q',(":q),'i',(":i) 91 | ids=: ids,id,LF 92 | jsids=: jsids,',''',id,'''' 93 | '''',id,'''' 94 | ) 95 | 96 | createHBS=: 3 : 0 97 | d=. <;._2 survey 98 | d=. deb each d 99 | i=. d i. <'' 100 | h=. i{.d 101 | d=. i}.d 102 | r=. <'''',(;h),'''' 103 | q=. 0 104 | i=. 1 105 | type=. ' ' 106 | ids=: '' 107 | jsids=: '' 108 | questions=: 0 2$'' 109 | for_n. d do. 110 | t=. deb ;n 111 | s=. {.t 112 | t=. }.t 113 | item=. t 114 | select. s 115 | case.'+' do. 116 | if. q~:0 do. NB. new question 117 | if. type='*' do. 118 | set=. '''','q',(":q),'''' 119 | r=. r,<(getid q;i;question;'na'),' jhrad ',set,';''none of the above''' 120 | i=. >:i 121 | end. 122 | r=. r,<(getid q;i;question;'ta'),' jhtextarea '''';1;20' 123 | type=. ' ' 124 | end. 125 | q=. >:q 126 | i=. 1 127 | r=. r,<'jhhr' 128 | r=. r,<'jhquestion ''',(":q),'. ',t,'''' 129 | question=. t 130 | case.'-' do. 131 | type=. '-' 132 | r=. r,<(getid q;i;question;item),' jhchk''',t,''';0' 133 | i=. >:i 134 | case.'*' do. 135 | type=. '*' 136 | set=. '''','q',(":q),'''' 137 | r=. r,<(getid q;i;question;item),' jhrad ',set,';''',t,'''' 138 | i=. >:i 139 | case.'=' do. 140 | r=. r,<(getid q;i;question;item),' jhtextarea '''';1;20' 141 | i=. >:i 142 | case.' ' do. 143 | end. 144 | end. 145 | if. type='*' do. 146 | set=. '''','q',(":q),'''' 147 | r=. r,<(getid q;i;question;item),' jhrad ',set,';''none of the above''' 148 | i=. >:i 149 | end. 150 | r=. r,<(getid q;i;question;''),' jhtextarea '''';1;20' 151 | r=. r,<'jhhr' 152 | t=. ;r,each LF 153 | t=. t rplc LF;LF,'''
''',LF 154 | t,LF,~'''sub''jhb''submit''' 155 | ) 156 | 157 | createJS=: 3 : 0 158 | JS=: JS rplc '';(}.jsids);'';thankyou-.LF 159 | ) 160 | 161 | jhquestion=: 3 : 0 162 | y 163 | ) 164 | 165 | HBS=: '' 166 | 167 | create_new_survey=: 3 : 0 168 | echo 'create new survey' 169 | p=. 'jsurvey' 170 | mkdir_j_ p 171 | HBS=: createHBS'' 172 | JS=: createJS'' 173 | HBS fwrite p,'/HBS' 174 | ids fwrite p,'/ids' 175 | survey fwrite p,'/survey' 176 | '' fwrite p,'/data' 177 | t=. 'jsurvey' jhrpage (getcss''),(getjs''),gethbs'' 178 | t=. (t i.'<')}.t 179 | t fwrite p,'/survey.html' 180 | ) 181 | 182 | create=: 3 : 0 183 | if. HBS-:'' do. create_new_survey'' end. 184 | 'create_new_survey_jsurvey_ must be run to create HBS'assert -.HBS-:'' 185 | 'survey' jhrx (getcss''),(getjs''),gethbs'' 186 | ) 187 | 188 | NB. called when browser gets this page 189 | jev_get=: create 190 | 191 | ev_sub_click=: 3 : 0 192 | echo'sub click' 193 | echo NV 194 | nv=: NV 195 | b=. 'j'~:;{.each{."1 nv 196 | snv=. b#nv 197 | t=. '1'=;1{. each 1{"1 snv 198 | answers=: (t#{."1 snv),.t#questions_jsurvey_ 199 | echo answers 200 | t=. 1<;#each 1{"1 snv 201 | comments=: (}:"1(t#{."1 snv),.t#questions_jsurvey_),.'*',each t#{:"1 snv 202 | echo comments 203 | jhrajax'' 204 | ) 205 | 206 | NB. jsurvey utils 207 | 208 | NB. \0 terminated survey submissions 209 | NB. start with blank delimited ts ip 210 | surdata=: 3 : 0 211 | d=. <;.2 fread'jsurvey/data' 212 | i=. ;d i.each' ' 213 | ts=. i{.each d 214 | d=. (>:i)}.each d 215 | i=. ;d i.each' ' 216 | ip=. i{.each d 217 | ts,.ip,.(>:i)}.each d 218 | ) 219 | 220 | CSS=: 0 : 0 221 | form{margin:2rem;} 222 | #sub{font-size:2em;padding:5px;} 223 | ) 224 | 225 | NB. *.jhspan:hover{background-color:lightblue;} 226 | 227 | JS=: 0 : 0 228 | //function ev_sub_click(){jdoajax([]);} 229 | function ajax(){document.body.innerHTML="";} 230 | 231 | ) -------------------------------------------------------------------------------- /guest/user.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 19 | 20 | 21 |

JHS user login

22 |
23 |
STATUS
24 |
25 | 26 | key:

27 | 28 |
29 | 30 | 85 | 86 | -------------------------------------------------------------------------------- /guest/user.ijs: -------------------------------------------------------------------------------- 1 | NB. start jhs user on port 2 | load'~addons/ide/jhs/core.ijs' 3 | setbreak'node' 4 | configdefault_jhs_'' 5 | PORT_jhs_=:0".;2{ARGV 6 | AUTO_jhs_=:0 7 | TIPX_jhs_=: 'u' 8 | QRULES_jhs_=: 1 NB. close tabs - no exit 9 | 10 | welcome_jhs_=: 0 : 0 11 |
 JHS - User
12 | ) 13 | 14 | init_jhs_'' 15 | -------------------------------------------------------------------------------- /history.txt: -------------------------------------------------------------------------------- 1 | ide/jhs - change history 2 | 3 | == 1.0.0/1 == 4 | * initial release 5 | -------------------------------------------------------------------------------- /jbase.ijs: -------------------------------------------------------------------------------- 1 | coclass'jbase' 2 | coinsert'jhs' 3 | 4 | NB. browser loads (usually from init) to get jijx in iframe 5 | 6 | title=: 'jterm' 7 | 8 | NB. J lines run in jhs locale that define html for the page 9 | HBS=: 0 : 0 10 | jhdivz 11 | '' 12 | jhdiva'' 13 | ) 14 | -------------------------------------------------------------------------------- /jbeacon.ijs: -------------------------------------------------------------------------------- 1 | NB. jbeacon sendbeacon handler 2 | 3 | coclass'jbeacon' 4 | coinsert'jhs' 5 | 6 | jev_post_raw=: 3 : 0 7 | decho NV_jhs_ 8 | bnv__=: NV_jhs_ 9 | NV_jhs_=: parse NV_jhs_ 10 | op=. getv'op' 11 | if. op-:'close' do. 12 | d=. getv'uri' 13 | c=. <,d}.~>:d i:'/' 14 | echo c 15 | echo names__c'' 16 | end. 17 | ) 18 | 19 | urlresponse=: 3 : 0 20 | shutdownJ_jsocket_ SKSERVER_jhs_ ; 2 21 | sdclose_jsocket_ ::0: SKSERVER_jhs_ 22 | SKSERVER_jhs_=: _1 23 | ) 24 | 25 | NB. jjs_jhs_'navigator.sendBeacon("jbeacon",log.innerHTML);' 26 | NB. jjs_jhs_'w=window.open("","jfif");navigator.sendBeacon("jbeacon",w.document.title+"&state=123");' -------------------------------------------------------------------------------- /jbinfo.ijs: -------------------------------------------------------------------------------- 1 | NB. J HTTP Server - jbinfo app - show browswer info 2 | coclass'jbinfo' 3 | coinsert'jhs' 4 | 5 | jev_get=: 3 : 0 6 | 'jbinfo'jhrx(getcss''),(getjs''),gethbs'' 7 | ) 8 | 9 | JS=: 0 : 0 10 | document.onkeyup= kup; 11 | 12 | function kup(ev) 13 | { 14 | var e=window.event||ev; 15 | var t='key up'; 16 | t+= '\nchar : '+e.charCode; 17 | t+= '\nkey : '+e.keyCode; 18 | t+= '\nctrl : '+e.ctrlKey; 19 | t+= '\nshift: '+e.shiftKey; 20 | alert(t); 21 | return true; 22 | } 23 | 24 | var b= "Browser info:

"; 25 | for(var pn in navigator) 26 | { 27 | b+= pn+": "+navigator[pn]+"
"; 28 | } 29 | b+= "
Javascript info:

"; 30 | b+= "all: "+document.all+"
"; 31 | b+= "getElementById: "+document.getElementById+"
"; 32 | b+= "addEventListener: "+window.addEventListener+"
"; 33 | b+= "attachEvent: "+window.attachEvent+"
"; 34 | b+= "scrollTo: "+window.scrollTo+"
"; 35 | b+= "XMLHttpRequest: "+(new XMLHttpRequest())+'
'; 36 | document.write(b); 37 | ) 38 | -------------------------------------------------------------------------------- /jcopy.ijs: -------------------------------------------------------------------------------- 1 | coclass'jcopy' 2 | coinsert'jhs' 3 | require'~addons/convert/misc/base64.ijs' 4 | 5 | NB.copy files between server and client machines 6 | 7 | mkdir_j_ '~/uploads' 8 | 'test'fwrite'~/uploads/test.txt' 9 | 10 | NB. sentences that define html elements 11 | HBS=: 0 : 0 12 | jhmenu'' 13 | 'menu0' jhmenugroup '' 14 | 'close' jhmenuitem 'close';'q' 15 | jhmenugroupz'' 16 | 17 | 'puttitle' jhtitle 'copy client file xxx to server ~/uploads/xxx' 18 | '' 19 | 'putf' jhhidden'' 20 | 'putrep' jhdiv' ' 21 | 'put' jhb 'put' 22 | '
' 23 | 'gettitle' jhtitle 'copy server file ~/uploads/xxx to client downloads' 24 | 'selspan' jhspan 'getsel'jhselect ((#jpath'~/uploads/')}.each 1 dir'~/uploads/');1;0 25 | 'refresh' jhb'refresh select list' 26 | 'getrep' jhdiv' ' 27 | 'get' jhb 'get' 28 | ) 29 | 30 | create=: 3 : 0 31 | 'jcopy' jhr '' 32 | ) 33 | 34 | jev_get=: 3 : 0 35 | create '' 36 | ) 37 | 38 | ev_put_click=: 3 : 0 39 | d=: frombase64 getv'jdata' 40 | f=. getv'putf' 41 | d fwrite '~/uploads/',f 42 | jhrjson 'put';'OK: ',f 43 | ) 44 | 45 | ev_get_click=: 3 : 0 46 | f=. getv'getsel' 47 | try. 48 | jhrjson d__=: 'rep';('OK: ',f);'data';tobase64 fread '~/uploads/',f 49 | catch. 50 | jhrjson 'rep';'file does not exist: ',f 51 | end. 52 | ) 53 | 54 | ev_refresh_click=: 3 : 0 55 | jhrjson 'list';'getsel'jhselect ((#jpath'~/uploads/')}.each 1 dir'~/uploads/');1;0 56 | ) 57 | 58 | ev_downtar_click=: 3 : 0 59 | echo'downtar' 60 | shell'tar -czf taruser.tgz j9.5-user' 61 | jhrjson d__=: 'rep';('OK: taruser.tgz');'data';tobase64 fread 'taruser.tgz' 62 | ) 63 | 64 | CSS=: 0 : 0 65 | *{font-family:PC_FONTFIXED;} 66 | ) 67 | 68 | NB. javascript code - initialize page and handle events 69 | JS=: 0 : 0 70 | 71 | function ev_put_click(){ 72 | var f=fileupload.files[0]; 73 | if(undefined==f) 74 | jbyid('putrep').innerHTML = "no file selected"; 75 | else 76 | { 77 | jset("putf",fileupload.files[0].name); 78 | read(fileupload.files[0]); 79 | } 80 | } 81 | 82 | function read(file) { 83 | const reader = new FileReader(); 84 | reader.addEventListener('load', (event) => { 85 | s= arrayBufferToBase64(event.target.result); 86 | jdoajax(["putf"],s); 87 | }); 88 | reader.readAsArrayBuffer(file); 89 | } 90 | 91 | function arrayBufferToBase64( buffer ) { 92 | var binary = ''; 93 | var bytes = new Uint8Array( buffer ); 94 | var len = bytes.byteLength; 95 | for (var i = 0; i < len; i++) { 96 | binary += String.fromCharCode( bytes[ i ] ); 97 | } 98 | return window.btoa( binary ); 99 | } 100 | 101 | function ev_put_click_ajax_json(t){ 102 | jbyid('putrep').innerHTML = t.put;} 103 | 104 | 105 | function ev_refresh_click(){jdoajax(['getsel']);} 106 | 107 | function ev_refresh_click_ajax_json(t){jbyid('selspan').innerHTML= t.list;} 108 | 109 | ) 110 | -------------------------------------------------------------------------------- /jdoc.ijs: -------------------------------------------------------------------------------- 1 | coclass'jdoc' 2 | coinsert'jhs' 3 | 4 | HBS=: 0 : 0 5 | jhclose'' 6 | 'title'jhtitle'JHS framework' 7 | 'jhs locale - utils - verbs/nouns/... for working with JHS' 8 | jhbr 9 | mfix '';'general utils';'~addons/ide/jhs/util.ijs' 10 | mfix'html';'html elements';'~addons/ide/jhs/utilh.ijs' 11 | mfix 'js';'javascript utils';'~addons/ide/jhs/utiljs.ijs' 12 | ) 13 | 14 | CSS=: 0 : 0 15 | form{margin:10px;} 16 | div{font-family:;white-space:pre;padding-left:10px} 17 | ) 18 | 19 | fix=: 3 : 0 20 | t=. doc y 21 | t=. t rplc '<';'<' 22 | ''jhdiv t 23 | ) 24 | 25 | mfix=: 3 : 0 26 | 'doc header url'=. y 27 | t=. ''jhline'' 28 | t=. t,''jhhn 3;header 29 | t=. t,fix doc 30 | ) 31 | 32 | jev_get=: 3 : 0 33 | 'jdoc'jhr'' 34 | ) 35 | 36 | -------------------------------------------------------------------------------- /jfilesrc.ijs: -------------------------------------------------------------------------------- 1 | NB. JHS - file source stuff - favicon.ico ... 2 | coclass'jfilesrc' 3 | coinsert'jhs' 4 | 5 | NB. serves .htm .js etc pages from anywhere 6 | NB. possible security issues! careful on allowing other suffixes! 7 | jev_get=: 3 : 0 8 | if. 0=nc<'gets_jhs_' do. gets_jhs_=: gets_jhs_,y,LF end. 9 | if. y-:'favicon.ico' do. favicon 0 return. end. 10 | if. (-.IFWIN)*.'usr/share/'-:10{.y do. y=. '/',y end. NB. gnuplot kludge 11 | y=. jpath y 12 | d=. fread y 13 | if. _1=d do. echo 'get file does not exist: ',y return. end. 14 | NB. Firefox 8 requires a response header 15 | if. ('.htm'-:_4{.y)+.'.html'-:_5{.y do. htmlresponse d,~fsrchead rplc '';'text/html' return. end. 16 | if. (#mimetypes) > i=. ({:"1 mimetypes) i. <@tolower@}.(}.~ i:&'.') y do. 17 | t=. i{:: {."1 mimetypes 18 | else. echo 'will not get file ',y return. end. 19 | t gsrcf d 20 | ) 21 | 22 | NB. common mime types 23 | mimetypes=: <;._1@(' '&,)@deb;._2 (0 : 0) 24 | application/javascript js 25 | application/javascript map 26 | application/msword doc 27 | application/msword docx 28 | application/pdf pdf 29 | application/postscript eps 30 | application/postscript ps 31 | application/rtf rtf 32 | application/vnd.ms-excel xls 33 | application/vnd.ms-excel xlsx 34 | application/x-gnumeric gnumeric 35 | application/x-gtar-compressed tgz 36 | application/x-sc sc 37 | application/zip zip 38 | audio/mp3 mp3 39 | image/gif gif 40 | image/jpeg jpeg 41 | image/jpeg jpg 42 | image/png png 43 | image/tiff tif 44 | image/tiff tiff 45 | image/x-icon ico 46 | image/x-ms-bmp bmp 47 | text/css css 48 | text/csv csv 49 | text/html htm 50 | text/html html 51 | text/plain text 52 | text/plain txt 53 | video/x-ms-wmv wmv 54 | video/x-msvideo avi 55 | 56 | ) 57 | 58 | favicon=: 3 : 0 59 | htmlresponse htmlfav,1!:1 ;} 11 | .jhdiv{white-space:pre;} 12 | a{white-space:pre;text-decoration:none;} 13 | ) 14 | 15 | jev_get=: 3 : 0 16 | 'jhelp'jhr'' 17 | ) 18 | 19 | -------------------------------------------------------------------------------- /jijx.ijs: -------------------------------------------------------------------------------- 1 | NB. J HTTP Server - jijx app 2 | coclass'jijx' 3 | coinsert'jhs' 4 | 5 | termmenu=: 0 : 0 6 | jhmenu'term';'advance'jhb'⇒';'jmenuburger' 7 | 8 | 'menu0' jhmenugroup '' 9 | 'sp' jhmenuitem 'projects';'p' 10 | 'jinputs' jhmenuitem 'inputs';'i' 11 | 'jbreak' jhmenuitem 'break';'c' 12 | 'jhshelp' jhmenuitem 'help';'h' 13 | 'closepages' jhmenuitem 'close pages' 14 | jhmenulink 'jpages';'system pages' 15 | jhmenulink 'options';'options and view' 16 | 'close' jhmenuitem 'quit';'q' 17 | jhmenugroupz'' 18 | 19 | 'jpages' jhmenugroup'' 20 | 'jfile' jhmenuitem 'explore files';'e' 21 | 'jfif' jhmenuitem 'find in files';'f' 22 | 'jdebug' jhmenuitem 'debug';'d' 23 | 'jijs' jhmenuitem 'edit new temp file';'n' 24 | 'jpacman' jhmenuitem 'package manager' 25 | 'jlocale' jhmenuitem 'locale explorer' 26 | 'jcopy' jhmenuitem 'copy files server/client' 27 | 'jhelp' jhmenuitem 'jhshelp texts' 28 | 'jdoc' jhmenuitem 'framework docs' 29 | jhmenugroupz'' 30 | 31 | 'options' jhmenugroup'' 32 | 'wrap' jhmenuitem 'NOWRAP ➜ wrap' 33 | 'spa' jhmenuitem 'TERM ➜ tab' 34 | 'flow' jhmenuitem 'COLUMN ➜ row' 35 | 'cleartemps' jhmenuitem 'remove red boxes';'r' 36 | 'clearwindow' jhmenuitem 'clear window' 37 | 'clearrefresh' jhmenuitem 'clear refresh' 38 | 'clearLS' jhmenuitem 'clear LS' 39 | jhmenugroupz'' 40 | 41 | ) 42 | 43 | HBS=: 0 : 0 rplc '';termmenu 44 | 45 | jhdivz NB. flex active 46 | 'log' jhec'' 47 | 'jframes'jhdiva'' 48 | jhdivz 49 | jhdiva'' NB. flex inactive - reopen main div 50 | ) 51 | 52 | jev_get=: create 53 | 54 | NB. move new transaction(s) to log 55 | uplog=: 3 : 0 56 | LOG_jhs_=: LOG,LOGN 57 | LOGN_jhs_=: '' 58 | ) 59 | 60 | NB. y is J prompt - '' ' ' or ' ' 61 | NB. called at start of input 62 | NB. ff/safari/chrome collapse empty div (hence bull) 63 | NB. empty prompt is • which is removed if present from input 64 | urlresponse=: 3 : 0 65 | if. 0=#y do. 66 | t=. JZWSPU8 67 | PROMPT_jhs_=: JZWSPU8 68 | else. 69 | t=. (6*#y)$' ' 70 | PROMPT_jhs_=: y 71 | end. 72 | t=. '
',t,'
' 73 | d=. LOGN,t 74 | uplog'' 75 | if. METHOD-:'post' do. 76 | if. CHUNKY do. 77 | CHUNKY_jhs_=: 0 78 | jhrajax_z d 79 | else. 80 | jhrajax d 81 | end. 82 | else. 83 | create'' 84 | end. 85 | ) 86 | 87 | NB. refresh response - not jajax 88 | create=: 3 : 0 89 | uplog'' 90 | 'term' jhr 'LOG';LOG 91 | ) 92 | 93 | ev_advance_click=: 3 : 0 94 | select. ADVANCE 95 | case. 'spx' do. spx__'' 96 | case. 'lab' do. lab 0 97 | case. 'wiki'do. wikistep_jsp_'' 98 | case. do. echo 'no open lab/spx to advance' 99 | end. 100 | ) 101 | 102 | jloadnoun_z_=: 0!:100 103 | 104 | ev_clearrefresh_click=: 3 : 'LOG_jhs_=: ''''' 105 | 106 | ev_jhelp_click=: 3 : 0 107 | 'jhelp'jpage'' 108 | ) 109 | 110 | ev_jhshelp_click=: 3 : 0 111 | jhshelp'' 112 | ) 113 | 114 | ev_about_click=: 3 : 0 115 | jhtml'
' 116 | echo JVERSION 117 | echo' ' 118 | echo'Copyright 1994-2025 Jsoftware Inc.' 119 | jhtml'
' 120 | ) 121 | 122 | NB. aws server window.close fails (depends on how started) 123 | ev_close_click=: 3 : 0 124 | select. QRULES 125 | case. 0 do. NB. localhost - close pages, exit server, close jterm 126 | jhrajax'666' 127 | exit'' 128 | case. 1 do. NB.server user - close pages, no exit, window.location=juser 129 | jhrajax 'juser>' NB. causes set of window.location 130 | case. 2 do. NB. server guest - close pages, exit server, window.location=jguest 131 | exit'' NB. no jhrajax triggers jguest page 132 | end. 133 | ) 134 | 135 | ev_sp_click=: 3 : 'sp__''''' 136 | 137 | ev_comma_ctrl =: 3 : 'i.0 0' 138 | ev_dot_ctrl=: ev_advance_click 139 | ev_slash_ctrl =: 3 : 'i.0 0' 140 | ev_less_ctrl =: 3 : 'i.0 0' 141 | ev_larger_ctrl =: 3 : 'i.0 0' 142 | ev_query_ctrl =: 3 : 'i.0 0' 143 | ev_semicolon_ctrl =: 3 : 'loadx__ 0' 144 | ev_colon_ctrl =: 3 : 'echo''colon''' 145 | ev_quote_ctrl_jijx_=: 3 : 'echo''quote''' 146 | ev_doublequote_ctrl =: 3 : 'echo''doublequote''' 147 | 148 | load'~addons/ide/jhs/loadx.ijs' 149 | 150 | CSS=: 0 : 0 151 | 152 | #log{width:100%;height:100%;resize:none;overflow:auto;} 153 | 154 | *{font-family:;font-weight:550;} 155 | form{margin-top:0;margin-bottom:0;} 156 | *.fm {color:;} 157 | *.er {color:;} 158 | *.log {color:;} 159 | *.sys {color:;} 160 | *.file {color:;} 161 | 162 | .jhb#overview{background-color:;font-weight:bold;font-size:1em;margin-left:2em;} 163 | #prompt{background-color:blanchedalmond;border:2px solid black;padding:8px 0 8px 0;} 164 | ) 165 | 166 | INC=: INC_chartjs NB. include chart js code 167 | 168 | JS=: ('var qrules= ',":QRULES),LF,fread JSPATH,'jijx.js' 169 | -------------------------------------------------------------------------------- /jj.ijs: -------------------------------------------------------------------------------- 1 | NB. jj (j to jhs) client code 2 | 3 | require'socket' 4 | require'tar' 5 | 6 | jjset=: jjset_jj_ 7 | jjdo=: jjdo_jj_ 8 | jjget=: jjget_jj_ 9 | jjput=: jjput_jj_ 10 | 11 | coclass'jj' 12 | 13 | URL=: 'jjserver' 14 | TAR=: '~temp/jtoj.tar' 15 | 16 | posttemplate=: _2}.toCRLF 0 : 0 17 | POST / HTTP/1.1 18 | Connection: Keep-Alive 19 | Content-Length: 20 | 21 | 22 | ) 23 | 24 | jjset=: 3 : 0 25 | d=. <;._1 ' ',deb y 26 | 'argument not: ip:port pass'assert 2=#d 27 | 'SERVER PASS'=: d 28 | i.0 0 29 | ) 30 | 31 | jjdo=: 4 : 0 32 | 'jjset required to set ip:port pswd'assert 0=nc<'SERVER' 33 | data=. PASS,({.a.),x,({.a.),3!:1 y 34 | i=. SERVER i. ':' 35 | port=. 0".}.i}.SERVER 36 | server=. i{.SERVER 37 | ip=. >2{sdgethostbyname_jsocket_ server 38 | 39 | try. 40 | sk=. >0{sdcheck_jsocket_ sdsocket_jsocket_'' 41 | sdcheck_jsocket_ sdconnect_jsocket_ sk;AF_INET_jsocket_;ip;port 42 | t=. posttemplate rplc '';URL;'';data;'';":#data 43 | while. #t do. t=.(>sdcheck_jsocket_ t sdsend_jsocket_ sk,0)}.t end. 44 | h=. d=. '' 45 | cl=. 0 46 | while. (0=#h)+.cl>#d do. NB. read until we have header and all data 47 | z=. sdselect_jsocket_ sk;'';'';5000 48 | assert sk e.>1{z NB. timeout 49 | 'c r'=. sdrecv_jsocket_ sk,10000,0 50 | assert 0=c 51 | 52 | if. (0=#r)*.cl=_ do. break. end. NB. no length and no more data 53 | 54 | d=. d,r 55 | if. 0=#h do. NB. get headers 56 | i=. (d E.~ CRLF,CRLF)i.1 NB. headers CRLF delimited with CRLF at end 57 | if. i<#d do. NB. have headers 58 | i=. 4+i 59 | h=. i{.d NB. headers 60 | d=. i}.d 61 | i=. ('Content-Length:'E. h)i.1 62 | 63 | if. i<#h do. 64 | t=. (15+i)}.h 65 | t=. (t i.CR){.t 66 | cl=. _1".t 67 | assert _1~:cl 68 | else. 69 | cl=. _ 70 | end. 71 | end. 72 | end. 73 | end. 74 | catch. 75 | shutdownJ_jsocket_ sk ; 2 76 | sdclose_jsocket_ ::0: sk 77 | (13!:12'') assert 0 78 | end. 79 | shutdownJ_jsocket_ sk ; 2 80 | sdclose_jsocket_ ::0: sk 81 | 82 | if. '|'={.d do. d assert 0 end. NB. error - plain text starting with | 83 | 3!:2 d 84 | ) 85 | 86 | jjget=: 3 : 0 87 | y jjget~ (y i:'/'){.y 88 | : 89 | target=. x [ source=. y 90 | st=. 'ftype y'jjdo source 91 | 'source is not a file or folder'assert 0~:st 92 | mkdir_j_ target 93 | 'target is not a folder'assert 2=ftype target 94 | t=. target,(source i:'/')}.source 95 | if. 1=st do. 96 | d=. 'fread y' jjdo source 97 | 'write to target failed'assert (#d)=d fwrite t 98 | else. 99 | 'tar y'jjdo 'c';TAR;source;'' 100 | d=. 'fread y' jjdo TAR 101 | d fwrite TAR 102 | tar 'x';TAR;t 103 | end. 104 | 'OK' 105 | ) 106 | 107 | jjput=: 3 : 0 108 | y jjput~ (y i:'/'){.y 109 | : 110 | target=. x [ source=. y 111 | st=. ftype source 112 | 'source is not a file or folder'assert 0~:st 113 | 'mkdir_j_ y' jjdo target 114 | 'target is not a folder'assert 2='ftype y'jjdo target 115 | t=. target,(source i:'/')}.source 116 | if. 1=st do. 117 | d=. fread source 118 | ('y fwrite ''',t,'''') jjdo d 119 | else. 120 | tar 'c';TAR;source;'' 121 | '(>{:y) fwrite {.y' jjdo TAR;fread TAR 122 | 'tar y' jjdo 'x';TAR;t 123 | end. 124 | 'OK' 125 | ) 126 | 127 | NB. simple test for jjput/jjget - run on same machine 128 | test=: 3 : 0 129 | mkdir_j_'~temp/jj' 130 | ferase {."1 fdir'~temp/jjx*' 131 | ferase {."1 fdir'~temp/jjy/*' 132 | ferase {."1 fdir'~temp/jjz/*' 133 | 'abc'fwrite'~temp/jjx/a' 134 | '~temp/jj/b'jjput'~temp/jjx/a' 135 | '~temp/jj/c'jjget'~temp/jjx/b' 136 | assert fexist (<'~temp/jjx/'),each ;:'a b c' 137 | 138 | '~temp/jjy'jjput'~temp/jjx' 139 | assert fexist (<'~temp/jjy/'),each ;:'a b c' 140 | '~temp/jjz'jjget'~temp/jjy' 141 | assert fexist (<'~temp/jjz/'),each ;:'a b c' 142 | ) 143 | 144 | echo 0 : 0 145 | jjset 'ip:port pswd' 146 | [target] jjget source 147 | [target] jjput source 148 | '...' jjdo y 149 | 150 | source is .../FILE or .../FOLDER 151 | to put in target folder 152 | 153 | elided target is ... from source 154 | ) 155 | -------------------------------------------------------------------------------- /jjserver.ijs: -------------------------------------------------------------------------------- 1 | NB. j to jhs server 2 | 3 | 0 : 0 4 | JHS jjserver task 5 | load'~addons/ide/jhs/jjserver.ijs' 6 | init_jjserver_ 'pwsd' 7 | 8 | J jj client task 9 | load'~addons/ide/jhs/jj.ijs' 10 | jjset 'ip:port pswd' 11 | '~temp/f.ijs' jhsget '~temp/g.ijs' 12 | ) 13 | 14 | require'tar' 15 | 16 | coclass'jjserver' 17 | coinsert'jhs' 18 | 19 | jev_post_raw=: 3 : 0 20 | 21 | try. 22 | d=. NV 23 | i=. d i. {.a. 24 | p=. i{.d 25 | 'bad password'assert (0~:#PASS)*.p-:PASS 26 | d=. (>:i)}.d 27 | i=. d i. {.a. 28 | s=. i{.d 29 | d=. (>:i)}.d 30 | erase'y' NB. so do will see the global 31 | y__=: 3!:2 d 32 | r=. 3!:1 do__ s 33 | catch. 34 | r=. 13!:12'' 35 | end. 36 | 'jbin' gsrcf r 37 | erase'y__' 38 | i.0 0 39 | ) 40 | 41 | init=: 3 : 0 42 | 'bad password'assert (2=3!:0 y)*.(1=$$y)*.1<#y 43 | PASS=: y 44 | addOKURL_jhs_'jjserver' 45 | 'client access with: jjset ''',(getlanip''),':',(":PORT),' ',PASS,'''' 46 | ) -------------------------------------------------------------------------------- /jlocale.ijs: -------------------------------------------------------------------------------- 1 | NB. browser for jhs 2 | NB. based on Oleg Kobchenko's version for j6 wd 3 | NB. modified to run with Jqt 4 | NB. modified by David Mitchell for JHS with jquery 5 | NB. this modification to run for JHS without javascript 6 | 7 | coclass'jlocale' 8 | coinsert'jhs' 9 | 10 | TITLE=: 'jlocale' 11 | 12 | MAXDEF=: 20000 NB. max size to display in def div 13 | 14 | fx=: 3 : 0 15 | jhref 'jijs';y;y NB. (jpath y);s 16 | ) 17 | 18 | NB. y is exclude 0 or 1 - initialize all 19 | init=: 3 : 0 20 | t=. conl 0 21 | if. y do. t=. ('j'~:;{.each t)#t end. 22 | d=. <'set locsdiv *','locsdiv' jhdiv 'locs' jhselect t;5;0 23 | d=. d,<'set atsdiv *','ats' jhselect (cobinst {.t);5;0 24 | d=. d,<'set namesdiv *', 'names' jhselect (cobnames ({.t);0 1 2 3);5;0 25 | d=. d,<'set rep *undefined' 26 | d=. d,<'set def *' 27 | ) 28 | 29 | cobfmt=: 3 : 0 30 | 'a b c'=.y 31 | a,' ',b,' ',c 32 | ) 33 | 34 | NB. y is loc - return ats contents 35 | cobinst=: 3 : 0 36 | sif=. <'_' 37 | for_ref. inst=. y ((e. copath)"0 # ]) conl 1 do. 38 | if. 0=4!:0 <'COCREATOR__ref' do. 39 | c=. COCREATOR__ref 40 | n=. ":&.>conouns__c ref 41 | else. n=. c=. <'X' end. 42 | sif=. sif,ni{4!:3'' else. sc=. 'defined in session' end. 56 | sp=. 'c'>@(8!:0) 7!:5 name 57 | if. 0=nc name do. 58 | v=. (>name)~ 59 | rep=. datatype v 60 | view=. utf8_from_jboxdraw jhtmlfroma fmt0 ":v 61 | rep=. rep,' shape:',(":$v),' space:',sp 62 | else. 63 | rep=. >(<:nc name){'adverb';'conjunction';'verb' 64 | rep=. rep,' space:',sp 65 | view=. 5!:5 name 66 | end. 67 | if. MAXDEF<7!:5 name do. view=. 'too big...',LF,'...' end. 68 | view;((>name),' ',rep);sc 69 | ) 70 | 71 | 72 | cobdef=: 3 : 0 73 | 'c a n'=. getvs'locs ats names' 74 | if. '_'~:{.a do. c=. <(a i.' '){.a end. 75 | 'view rep sc'=. cobview n;c 76 | a=. (jhtmlfroma rep),' ',sc,'
' 77 | ('set rep *',a);'set def *',jhtmlfroma view 78 | ) 79 | 80 | getnlarg=: 3 : 0 81 | 0 1 2 3#~;0".each getvs'nl*noun nl*adverb nl*conj nl*verb' 82 | ) 83 | 84 | 85 | cobnames=: 3 : 0 86 | 'c a'=. y 87 | '_';nl__c a 88 | ) 89 | 90 | NB. runs as class STATIC instance (no object) 91 | NB. to run as OBJECT - define ev_create and remove jev_get 92 | xev_create=: 3 : 0 93 | jhcmds init 0 94 | ) 95 | 96 | jev_get=: 3 : 0 97 | jhcmds init 0 98 | TITLE jhr'' 99 | ) 100 | 101 | ev_locs_change=: 3 : 0 102 | c=. } 147 | select{min-width:100px;max-width:200px;float:left;min-height:300px;} 148 | hr{clear:both;} 149 | #rep{clear:both;float:left;} 150 | #def{clear:both;float:left;min-width:300px;} 151 | ) 152 | -------------------------------------------------------------------------------- /jlogin.ijs: -------------------------------------------------------------------------------- 1 | coclass'jlogin' 2 | coinsert'jhs' 3 | 4 | GOURL=: 'jijx' 5 | 6 | HBS=: 0 : 0 7 | login 8 | '' 9 | jhtablea 10 | jhtr 'user: ';'user' jhtext'';15 11 | jhtr 'pswd: ';'pass' jhpassword'';15 12 | jhtablez 13 | 'login'jhb'login' 14 | loggedin 15 | ) 16 | 17 | login=: 0 : 0 18 |

J login

19 | ) 20 | 21 | loggedin=: 0 : 0 22 |
23 | SECURITY! logout when finished
24 | close all browser windows or run sentence
25 |    jlogoff_jhs_ 0 26 |
27 | ) 28 | 29 | goto=: 3 : 0 30 | NB. ".'jev_get_',(getv'radg'),'_''''' 31 | ".'jev_get_',GOURL,'_''''' 32 | ) 33 | 34 | NB. login not allowed after LIMIT failures 35 | NB. jum sets to _ (multiple users) 36 | LIMIT=: 10 37 | 38 | CSS=: 0 : 0 39 | form{margin:20px;} 40 | ) 41 | 42 | count=: 0 43 | 44 | jev_get=: create 45 | 46 | ev_login_click=: create 47 | 48 | invalid=: 'Invalid login COUNT.

' 49 | 50 | expires=: 'jcookie=; Mon, 1-Jan-2000 00:00:00 GMT;' 51 | 52 | NB. wierd as it runs through a 1st time with a failure to show the page the 1st time 53 | NB. called from core input if cookie required and not set 54 | NB. valid login - goes to page and does SetCookie 55 | NB. invalid login - shows page with setcookie expires and no-cache 56 | create=: 3 : 0 57 | if. (-.URL-:'jlogin')*.-.URL-:'favicon.ico' do. GOURL=: URL end. 58 | NB.override formtmpl to stay on users desired url 59 | formtmpl=: formtmpl_jhs_ rplc '';GOURL 60 | p=. PASS 61 | u=. ,getv'user' 62 | p=. ,getv'pass' 63 | if. (0~:#PASS)*.(u-:USER)*.p-:PASS do. 64 | count=: 0 65 | SETCOOKIE_jhs_=: 1 66 | PROMPT_jhs_=: ' ' 67 | goto'' 68 | else. 69 | if. count>3 do. 6!:3[3 end. NB. slow down pswd attack 70 | b=. (jhbs HBS)hrplc 'MSG';(count>0)#invalid rplc 'COUNT';":<:count 71 | count=: >:count 72 | t=. hrtemplate rplc (CRLF,CRLF);CRLF,'Cache-Control: no-cache',CRLF,CRLF 73 | t=. t rplc (LF,LF);LF,'Set-Cookie: ',expires,LF,LF 74 | htmlresponse t hrplc'TITLE CSS JS BODY';GOURL;(css CSS);(js JS);b 75 | end. 76 | ) 77 | 78 | JS=: 0 : 0 79 | function ev_body_load() {jform.user.focus();} 80 | function ev_user_enter() {jsubmit();} 81 | function ev_pass_enter() {jsubmit();} 82 | function ev_login_click(){jsubmit();} 83 | ) 84 | -------------------------------------------------------------------------------- /jpacman.ijs: -------------------------------------------------------------------------------- 1 | NB. J HTTP Server - jpacman 2 | coclass'jpacman' 3 | coinsert'jhs' 4 | require'pacman' 5 | 6 | HBS=: 0 : 0 7 | 8 | jhmenu'' 9 | 'menu0' jhmenugroup '' 10 | 'close' jhmenuitem 'close';'q' 11 | jhmenugroupz'' 12 | 13 | 'J Package Manager code.jsoftware.com/wiki/addons' 14 | '
' 15 | 'upable' jhb'Upgradeable' 16 | 'remable'jhb'Removeable' 17 | 'inst' jhb'Installed' 18 | 'notin' jhb'Not Installed' 19 | 'desc' jhb'Descriptions' 20 | 'all' jhb'Upgrade/Install All' 21 | 'buttons'jhdiv'' 22 | jhresize'' 23 | 'result' jhdiv'' 24 | ) 25 | 26 | checkers=: ('check'jhb'Check all'),'uncheck'jhb'Uncheck all' 27 | 28 | maketable=: 3 : 0 29 | b=. ((<'c_'),each{."1 y)jhchk each <'';0;'';'';'~' 30 | NB. b=. ,.(('c'),each ":each <"0 i.#y)jhchk each <'';0 31 | t=. jhtablea 32 | t=. t,,jhtr"1 b,.y 33 | t,jhtablez 34 | ) 35 | 36 | create=: 3 : 0 NB. create - y replaces in body 37 | 'jpacman'jhr'BUTTONS RESULT';y 38 | ) 39 | 40 | jev_get=: 3 : 0 41 | create '';('update'jpkg'')rplc LF;'
' 42 | ) 43 | 44 | ev_all_click=: 3 : 0 45 | 'update'jpkg'' NB. update to make current 46 | 'upgrade'jpkg'' 47 | 'install'jpkg,<'all' 48 | jev_get'' 49 | ) 50 | 51 | ev_upable_click=: 3 : 0 52 | 'update'jpkg'' NB. update to make current 53 | d=. 'showupgrade'jpkg'' 54 | b=. checkers,~'upgrade'jhb'Upgrade Selected' 55 | t=. maketable d 56 | create b;t 57 | ) 58 | 59 | ev_remable_click=: 3 : 0 60 | 'update'jpkg'' NB. update to make current 61 | d=. 'showinstalled'jpkg'' 62 | d=. d#~-.({."1 d) e. 'base library';'ide/jhs' 63 | b=. checkers,~'remove'jhb'Remove Selected' 64 | t=. maketable d 65 | create b;t 66 | ) 67 | 68 | ev_notin_click=: 3 : 0 69 | 'update'jpkg'' NB. update to make current 70 | b=. checkers,~'install'jhb'Install Selected' 71 | t=. maketable'shownotinstalled'jpkg'' 72 | create b;t 73 | ) 74 | 75 | ev_inst_click=: 3 : 0 76 | 'update'jpkg'' NB. update to make current 77 | b=. checkers,~'upgrade'jhb'Upgrade Selected' 78 | t=. maketable'showinstalled'jpkg'' 79 | create b;t 80 | ) 81 | 82 | doselect=: 3 : 0 83 | d=. {."1 NV 84 | b=. (<'c_')=2{.each d 85 | d=. b#{."1 NV 86 | n=. ;0".each b#{:"1 NV 87 | d=. 2}.each n#d 88 | r=. y jpkg d 89 | jhrcmds'set result *',r 90 | ) 91 | 92 | ev_install_click=: 3 : 0 93 | doselect'install' 94 | ) 95 | 96 | ev_upgrade_click=: 3 : 0 97 | doselect'upgrade' 98 | ) 99 | 100 | ev_remove_click=: 3 : 0 101 | doselect'remove' 102 | ) 103 | 104 | descfix=: 3 : 0 105 | i=. y i.LF 106 | '',(i{.y),'',}.i}.y 107 | ) 108 | 109 | ev_desc_click=: 3 : 0 110 | d=. ('showinstalled'jpkg''),'shownotinstalled'jpkg'' 111 | d=. /:~{."1 d 112 | d=. 'show'jpkg d 113 | d=. d rplc '== ';0{a. 114 | d=. <;._1 d 115 | d=. descfix each d 116 | r=. ;d 117 | create '';r rplc LF;'
' 118 | ) 119 | 120 | JS=: 0 : 0 121 | function ev_body_load(){jresize();} 122 | 123 | function ev_upable_click(){jsubmit();} 124 | function ev_remable_click(){jsubmit();} 125 | function ev_inst_click(){jsubmit();} 126 | function ev_notin_click(){jsubmit();} 127 | function ev_desc_click(){jsubmit();} 128 | function ev_all_click() 129 | { 130 | jbyid("result").innerHTML= 'this may take a few minutes ...'; 131 | jsubmit(); 132 | } 133 | 134 | //function ev_remove_click(){jdojax();} 135 | //function ev_upgrade_click(){jsubmit();} 136 | //function ev_install_click(){jsubmit();} 137 | 138 | 139 | function check(v) 140 | { 141 | var marks= "□▣"; 142 | var n=document.getElementsByClassName("jhchk"); 143 | for(var i=0;i */ 7 | *,*::before,*::after {box-sizing: border-box;} 8 | *{font-family:PC_FONTVARIABLE;} 9 | 10 | /* vh/svh/lvh/dvh critical to ipad dynamic size */ 11 | /* https://dev.to/frehner/css-vh-dvh-lvh-svh-and-vw-units-27k4 */ 12 | 13 | html,body,form {width:100svw;height:100svh;margin:0;} 14 | 15 | body{min-height: 100svh;display: flex;flex-flow: column;} /* row */ 16 | form{min-height: 100svh;display: flex;flex-flow: column;} /* row */ 17 | 18 | div{padding-left:2px;} 19 | 20 | #jflexcol{display: flex; flex-flow: column; flex: 1; height:100%;} 21 | #jflexrow{display: flex; flex-flow: row ; flex: 1; width: 100%;} 22 | #jresizeb{overflow:scroll;border:solid;border-width:1px;clear:left;} 23 | 24 | iframe[id^="jifr"]{overflow:auto;flex:1 1 10em;} 25 | iframe[id^="jifr-jijx"]{overflow:auto;flex:3 1 auto;} 26 | 27 | #status-busy{ 28 | position: absolute; top: 0px; left: 70%; border: thick red solid; 29 | margin: 20px; padding: 10px;display: none; background: white;text-align:center; 30 | } 31 | 32 | .jhtitle{margin-left:0px;font-size:2em;} 33 | 34 | .transient{border:1px red solid;} 35 | 36 | /* button elements */ 37 | button{color:black;margin: 2px; padding: 2px; background-color:white;border:0;} 38 | button:hover{cursor:pointer;} 39 | 40 | /* burger menu */ 41 | .jmenugroup{position:fixed;top:0;left:0;visibility:hidden;border:3px solid black; margin:4px; padding:4px; overflow:scroll; 42 | background-color:white;max-height:100svh;overflow-y: auto;overflow-x:hidden;z-index:3;} /* z-index top touch buttons */ 43 | 44 | .jmenuburger,.jmenuitem,.jmenutitle{height:1.5em;} 45 | 46 | .jmenuburger{color:black;background-color:white;margin:0px;font-size:1em;width:1em;border:0;margin-right:1em;} 47 | .jmenuburger:hover{background-color:PC_MENU_HOVER;} 48 | 49 | .jmenutitle{display:inline-block;} 50 | 51 | .jmenuitem {color:black;padding:2px;margin:0px;background-color: white;width:16em;text-decoration:none;border-top:0px solid black; 52 | display:block;text-align:left;} 53 | .jmenuitem:focus{border:2px solid black;} 54 | .jmenuitem:hover{background-color:PC_MENU_HOVER;} 55 | 56 | .jmenuspanleft {font-family:PC_FONTFIXED;pointer-events: none;} 57 | .jmenuspanright {font-family:PC_FONTFIXED;float:right;pointer-events: none;} 58 | 59 | /* see ev_wrap_click() */ 60 | #log{overflow-wrap:normal;white-space:nowrap;} /* jijx log wrap */ 61 | 62 | 63 | 64 | .jhb{background-color:PC_BUTTON;border: 1px solid black;border-radius:6px;height:2em;} 65 | 66 | /* .jhchk{} .jhrad{} .jhab{} */ 67 | .jhchk:hover,.jhrad:hover,.jhab:hover{background-color:PC_BUTTON} 68 | 69 | 70 | /* end of button styles */ 71 | 72 | .jhsel{background-color:buttonface;font-family:PC_FONTFIXED;} 73 | 74 | input[type=text],input[type=password]{ margin: 2px;padding:2px;border: 1px solid black;} 75 | 76 | /* tablet */ 77 | @media screen and (max-device-width: 992px){ 78 | *{font-size:24px;} 79 | .jhab{display:inline-block;min-height:2em;min-width:2em;} 80 | .jhb{min-height:2em;min-width:2em;} 81 | .jmenuburger,.jmenuitem,.jmenutitle{min-height:2.5em;min-width:2.5em;} 82 | input::file-selector-button{font-size:24px;color:green;} 83 | #log{overflow-wrap:break-word;white-space:normal;} /* jijx log wrap */ 84 | } 85 | 86 | /* phone */ 87 | @media screen and (max-device-width: 640px){ 88 | *{font-size:48px} 89 | .jhab{display:inline-block;min-height:2.5em;min-width:2.5em;} 90 | .jhb{min-height:2.5em;min-width:2.5em;} 91 | .jmenuburger,.jmenuitem,.jmenutitle{height:2.5em;} 92 | input::file-selector-button{font-size:48px;color:red;} /*min-height:180px;min-width:180px;*/ 93 | #log{overflow-wrap:break-word;white-space:normal;} /* jijx log wrap */ 94 | 95 | /* phone hamburger menu */ 96 | .jmenuburger {height:2em;} 97 | .jmenuitem {height:2em;} 98 | } 99 | 100 | -------------------------------------------------------------------------------- /js/jsoftware/jijs.js: -------------------------------------------------------------------------------- 1 | var ta, rep, saveasx; 2 | 3 | function ev_body_load() { 4 | ce = jbyid("ijs"); 5 | window.cm6_creat(ce.value, document.getElementById("cm6_editor")); 6 | rep = jbyid("rep"); 7 | ta = jbyid("textarea"); 8 | saveasx = jbyid("saveasx"); 9 | jresize(); 10 | } 11 | 12 | function setdirty() { jbyid("jmenutitle").style.color = "red"; dirty = true; } 13 | function setclean() { jbyid("jmenutitle").style.color = "blue"; dirty = false; } 14 | function setnamed() { jbyid("jmenutitle").innerHTML = jbyid("filename").value; } 15 | 16 | function click() { 17 | t = (dirty ? "dirty" : "clean") + JASEP; 18 | const [anchorLine, anchorCh, headLine, headCh] = window.cm6_getSelectionData(); 19 | t = t + anchorLine + ' ' + anchorCh + ' ' + headLine + ' ' + headCh + JASEP; 20 | ta.value = window.cm6_gettext(); 21 | jdoajax(["filename", "textarea", "saveasx",], t); 22 | } 23 | 24 | function ev_save_click() { click(); } 25 | function ev_runw_click() { click(); } 26 | function ev_runwd_click() { click(); } 27 | function ev_line_click() { click(); } 28 | function ev_lineadv_click() { click(); } 29 | function ev_sel_click() { click(); } 30 | function ev_chelp_click() { click(); } 31 | 32 | function ev_undo_click() { window.cm6_undo(); } 33 | function ev_redo_click() { window.cm6_redo(); } 34 | function ev_find_click() { window.cm6_findAll(); } 35 | function ev_next_click() { window.cm6_findNext(); } 36 | function ev_previous_click() { window.cm6_findPrev(); } 37 | function ev_replace_click() { window.cm6_replaceNext(); } 38 | function ev_repall_click() { window.cm6_replaceAll(); } 39 | 40 | function ev_saveasdo_click() { click(); } 41 | function ev_saveasx_enter() { click(); } 42 | 43 | function ev_saveas_click() { 44 | saveasx.value = jbyid("filename").value; 45 | jdlgshow("saveasdlg", "saveasx"); 46 | jresize(); 47 | } 48 | 49 | function ev_saveasclose_click() { jhide("saveasdlg"); jresize(); } 50 | 51 | function ev_ro_click() { window.cm6_changeReadOnly(); } 52 | function ev_numbers_click() { window.cm6_changeLineNumbers(); } 53 | function ev_theme_click() { window.cm6_changeTheme(); } 54 | 55 | // ajax response - ts[0] error ; ts[1] sentence ; advance_line ts[2] 56 | function ajax(ts) { 57 | rep.innerHTML = ts[0]; 58 | jhide("saveasdlg"); 59 | if (0 != ts[0].length) return; 60 | setclean(); // no report means save was done 61 | switch (jform.jmid.value) { 62 | 63 | case 'close': winclose(); break; 64 | case 'save': break; 65 | case 'saveasx': 66 | case 'saveasdo': 67 | jbyid("filename").value = ts[1]; 68 | setnamed(); 69 | var t = ts[1].split('/'); 70 | document.title = t[t.length - 1]; 71 | break; 72 | case 'lineadv': 73 | var i = parseInt(ts[2]); 74 | window.cm6_setselection(i); 75 | default: 76 | jijxrun(ts[1]); // run sentence in jijx 77 | } 78 | jresize(); 79 | } 80 | 81 | function ev_ijs_enter() { return true; } 82 | 83 | function ev_comma_ctrl() { jscdo("line"); } 84 | function ev_dot_ctrl() { jscdo("lineadv"); } 85 | function ev_slash_ctrl() { jscdo("sel"); } 86 | 87 | function ev_z_shortcut() { } // Handled by cm6. 88 | function ev_y_shortcut() { } 89 | function ev_p_shortcut() { jscdo("chelp"); } 90 | function ev_t_shortcut() { jscdo("ro"); } 91 | function ev_r_shortcut() { jscdo("runw"); } 92 | function ev_s_shortcut() { jscdo("save"); } 93 | function ev_h_shortcut() { jscdo("chelp"); } 94 | 95 | //function ev_2_shortcut(){ce.focus();} 96 | 97 | // override jscore.js defs 98 | function ev_close_click() { if (dirty) click(); else winclose(); } 99 | function ev_close_click_ajax(){ winclose(); } -------------------------------------------------------------------------------- /js/w3c-keyname/.tern-port: -------------------------------------------------------------------------------- 1 | 39679 -------------------------------------------------------------------------------- /js/w3c-keyname/index.js: -------------------------------------------------------------------------------- 1 | export var base = { 2 | 8: "Backspace", 3 | 9: "Tab", 4 | 10: "Enter", 5 | 12: "NumLock", 6 | 13: "Enter", 7 | 16: "Shift", 8 | 17: "Control", 9 | 18: "Alt", 10 | 20: "CapsLock", 11 | 27: "Escape", 12 | 32: " ", 13 | 33: "PageUp", 14 | 34: "PageDown", 15 | 35: "End", 16 | 36: "Home", 17 | 37: "ArrowLeft", 18 | 38: "ArrowUp", 19 | 39: "ArrowRight", 20 | 40: "ArrowDown", 21 | 44: "PrintScreen", 22 | 45: "Insert", 23 | 46: "Delete", 24 | 59: ";", 25 | 61: "=", 26 | 91: "Meta", 27 | 92: "Meta", 28 | 106: "*", 29 | 107: "+", 30 | 108: ",", 31 | 109: "-", 32 | 110: ".", 33 | 111: "/", 34 | 144: "NumLock", 35 | 145: "ScrollLock", 36 | 160: "Shift", 37 | 161: "Shift", 38 | 162: "Control", 39 | 163: "Control", 40 | 164: "Alt", 41 | 165: "Alt", 42 | 173: "-", 43 | 186: ";", 44 | 187: "=", 45 | 188: ",", 46 | 189: "-", 47 | 190: ".", 48 | 191: "/", 49 | 192: "`", 50 | 219: "[", 51 | 220: "\\", 52 | 221: "]", 53 | 222: "'" 54 | } 55 | 56 | export var shift = { 57 | 48: ")", 58 | 49: "!", 59 | 50: "@", 60 | 51: "#", 61 | 52: "$", 62 | 53: "%", 63 | 54: "^", 64 | 55: "&", 65 | 56: "*", 66 | 57: "(", 67 | 59: ":", 68 | 61: "+", 69 | 173: "_", 70 | 186: ":", 71 | 187: "+", 72 | 188: "<", 73 | 189: "_", 74 | 190: ">", 75 | 191: "?", 76 | 192: "~", 77 | 219: "{", 78 | 220: "|", 79 | 221: "}", 80 | 222: "\"" 81 | } 82 | 83 | var mac = typeof navigator != "undefined" && /Mac/.test(navigator.platform) 84 | var ie = typeof navigator != "undefined" && /MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent) 85 | 86 | // Fill in the digit keys 87 | for (var i = 0; i < 10; i++) base[48 + i] = base[96 + i] = String(i) 88 | 89 | // The function keys 90 | for (var i = 1; i <= 24; i++) base[i + 111] = "F" + i 91 | 92 | // And the alphabetic keys 93 | for (var i = 65; i <= 90; i++) { 94 | base[i] = String.fromCharCode(i + 32) 95 | shift[i] = String.fromCharCode(i) 96 | } 97 | 98 | // For each code that doesn't have a shift-equivalent, copy the base name 99 | for (var code in base) if (!shift.hasOwnProperty(code)) shift[code] = base[code] 100 | 101 | export function keyName(event) { 102 | // On macOS, keys held with Shift and Cmd don't reflect the effect of Shift in `.key`. 103 | // On IE, shift effect is never included in `.key`. 104 | var ignoreKey = mac && event.metaKey && event.shiftKey && !event.ctrlKey && !event.altKey || 105 | ie && event.shiftKey && event.key && event.key.length == 1 || 106 | event.key == "Unidentified" 107 | var name = (!ignoreKey && event.key) || 108 | (event.shiftKey ? shift : base)[event.keyCode] || 109 | event.key || "Unidentified" 110 | // Edge sometimes produces wrong names (Issue #3) 111 | if (name == "Esc") name = "Escape" 112 | if (name == "Del") name = "Delete" 113 | // https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/8860571/ 114 | if (name == "Left") name = "ArrowLeft" 115 | if (name == "Up") name = "ArrowUp" 116 | if (name == "Right") name = "ArrowRight" 117 | if (name == "Down") name = "ArrowDown" 118 | return name 119 | } 120 | -------------------------------------------------------------------------------- /loadx.ijs: -------------------------------------------------------------------------------- 1 | 0 : 0 2 | vscode extension ctrl+; shortcut saves file and appends name to ~loadx.txt file 3 | 4 | J session runs: loadx 0 to load scripts as indicated by the editor 5 | 6 | JHS ctrl+; shortcut runs: loadx__ 0 7 | ) 8 | 9 | loadx_z_=: 3 : 0 10 | f=. '~/loadx.txt' 11 | d=. <;._2 fread f 12 | ''fwrite f 13 | d=. ~.d 14 | b=. (<'.ijs')=_4{.each d 15 | if. +/-.b do. echo LF,~;(d#~-.b),each LF end. 16 | d=. b#d 17 | if. 0=#d do. echo 'no scripts to load' return. end. 18 | for_n. d do. 19 | n=. >n 20 | p=. (10{.(>:n i:'/')}.n),' ',n 21 | try. 22 | load n 23 | echo p 24 | catch. echo LF,LF,~p,LF,13!:12'' end. 25 | end. 26 | i.0 0 27 | ) 28 | 29 | NB. gitbuild 'data/jmf' 30 | gitbuild_z_=: 3 : 0 31 | require'~system/util/project.ijs' NB. writesourcex 32 | load'~Addons/',y,'/source/build.ijs' 33 | ) 34 | 35 | -------------------------------------------------------------------------------- /manifest.ijs: -------------------------------------------------------------------------------- 1 | NB. ide/jhs manifest 2 | 3 | CAPTION=: 'JHS IDE' 4 | 5 | DESCRIPTION=: 0 : 0 6 | JHS IDE 7 | ) 8 | 9 | VERSION=: '1.0.395' 10 | 11 | FILES=: 0 : 0 12 | app/ 13 | aws/ 14 | config/ 15 | demo/ 16 | guest/ 17 | js/ 18 | node/ 19 | page/ 20 | react/ 21 | spx/ 22 | extra/ 23 | test/ 24 | widget/ 25 | src/ 26 | core.ijs 27 | chart.ijs 28 | d3.ijs 29 | favicon.ico 30 | gnuplot.ijs 31 | gpdemo.ijs 32 | history.txt 33 | installer.ijs 34 | jbase.ijs 35 | jhelp.ijs 36 | jlocale.ijs 37 | jdoc.ijs 38 | jpacman.ijs 39 | jbeacon.ijs 40 | jbinfo.ijs 41 | jfif.ijs 42 | jfile.ijs 43 | jcopy.ijs 44 | jfilesrc.ijs 45 | jgcp.ijs 46 | jijs.ijs 47 | jijx.ijs 48 | jdebug.ijs 49 | jj.ijs 50 | jjserver.ijs 51 | jlogin.ijs 52 | loadx.ijs 53 | spfile_template.ijs 54 | jum.ijs 55 | manifest.ijs 56 | node.ijs 57 | port.ijs 58 | readme.txt 59 | release.txt 60 | sp.ijs 61 | tool.ijs 62 | util.ijs 63 | utilh.ijs 64 | vocabhelp.ijs 65 | ) 66 | 67 | FILESWIN=: 0 : 0 68 | grep.exe 69 | ) 70 | 71 | RELEASE=: 'j805' 72 | 73 | FOLDER=: 'ide/jhs' 74 | -------------------------------------------------------------------------------- /node/cert.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIDPjCCAiYCCQChs6/LGvY9VjANBgkqhkiG9w0BAQsFADBhMQswCQYDVQQGEwJO 3 | QTELMAkGA1UECAwCTkExCzAJBgNVBAcMAk5BMQswCQYDVQQKDAJOQTELMAkGA1UE 4 | CwwCTkExCzAJBgNVBAMMAk5BMREwDwYJKoZIhvcNAQkBFgJOQTAeFw0yMTAxMTAx 5 | NzIwMzFaFw00ODA1MjcxNzIwMzFaMGExCzAJBgNVBAYTAk5BMQswCQYDVQQIDAJO 6 | QTELMAkGA1UEBwwCTkExCzAJBgNVBAoMAk5BMQswCQYDVQQLDAJOQTELMAkGA1UE 7 | AwwCTkExETAPBgkqhkiG9w0BCQEWAk5BMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A 8 | MIIBCgKCAQEAzwzBm6EG/QYYghbQw+euJEkVIncP82iOJewQEOTx7Pwcm/JR6yD+ 9 | tNSWBNMXWraQaaUBmfdY4oprcllnJg5xflzu318ggt6zRvVPSW95vjm12fUXIJAR 10 | qRg/uJKT9E4WyAQ4K7jGfAwsaWeW68FwZ66QqKbVaXn4QvG8c0DZ6nUYtZ4YL4FR 11 | PmTYfOuN7vd12zY6pSVJzm1861sN+5CeHsgR6qRZtZcVlgawg2Yn9c2lYpUsv9Aj 12 | lfVJy+QzozIyn9LgzpCq/xfqC/gpWohELleXAX1BMBQTEdxZ1F14s5tzXXexTStZ 13 | TdReRG0v+0bhtesDyEuk3tcmghaoo57fpwIDAQABMA0GCSqGSIb3DQEBCwUAA4IB 14 | AQAXd6XD1+3BrkntMJWF9C9kvZjtdl8pma1z9wsZf0KIGDhH6t0Ye5M03WLHNc7v 15 | kPZmYighz/o/azPIqFhOsjH7ci0rBHqwwdNZwWHjn/4KyY1IKewexBp/3a4sG0Lt 16 | t/9fWsoUEClQ6D8XtDvWwE97NxTQ2R7+LMjSArD90pSjE30KjTRbDpGyFjTPR0Fq 17 | PU1cfOYar5tsbndLnhvH4+VeSL9zaykOPF7+esRkyH1WXj8ulAcdNvbGo3xXUrGM 18 | B9vz45WU6kn9Lg3ZTZ8vP3YKqR8CgXrqArFmAL0zCH/Y+PkVGRgs7CDYeTkSTLs/ 19 | 5lu6EdwUxSLwgDhbtkAYSVcN 20 | -----END CERTIFICATE----- 21 | -------------------------------------------------------------------------------- /node/key.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIIEogIBAAKCAQEAzwzBm6EG/QYYghbQw+euJEkVIncP82iOJewQEOTx7Pwcm/JR 3 | 6yD+tNSWBNMXWraQaaUBmfdY4oprcllnJg5xflzu318ggt6zRvVPSW95vjm12fUX 4 | IJARqRg/uJKT9E4WyAQ4K7jGfAwsaWeW68FwZ66QqKbVaXn4QvG8c0DZ6nUYtZ4Y 5 | L4FRPmTYfOuN7vd12zY6pSVJzm1861sN+5CeHsgR6qRZtZcVlgawg2Yn9c2lYpUs 6 | v9AjlfVJy+QzozIyn9LgzpCq/xfqC/gpWohELleXAX1BMBQTEdxZ1F14s5tzXXex 7 | TStZTdReRG0v+0bhtesDyEuk3tcmghaoo57fpwIDAQABAoIBADC/ah4ALasI8mA+ 8 | iux08bUtV8KDkcfXSBB5oda4cJVBTmMRDGR1okJlAuUj5g2/igS1isj7SXwc5utH 9 | TVfScrozmzIQLZFiaYc9XmuFyX4WDFDCua06/k13nhkQubD9abOx+p+go2q1Wwd+ 10 | EjRzmMlwejKbBQgOZXstexcPn77pYhxrPwdLfub6LaLRrEH8D41yHAxtCXcxbhX4 11 | YLdmNn4z+Y70iG9zsml6/5fVlpebO0LrtWlaU2HKRoC0+ssC1lsYT9upUpr9s3fF 12 | Y5mij3w0v+iDSLcsVpL80SDDpuWSc25a0rluWU11GBwovCYkppSS/NtxTZrbCVI5 13 | nC6bsZECgYEA+jjrfvUF0nOXIf7VzRnLUqKb3IUot8m543krI1DYWtzGf9D1ps9K 14 | 0gmcHnE0ToYbw+k2TkzkDaM3ePrauEg2GKfYnxjZb6hz4TGUk1J+MAYFyDVd5EzL 15 | s4kuiFWf8nlVPSzpHZSu3pLRVp2TdDDspWJAfojdiSE/yk0SFW0oiM0CgYEA09Sk 16 | Eu50F6eDV3FBRTOrdwwchC0K1yqDqcgWhV2W0SM9EfgARUQifWYIzFu06WCIlnrh 17 | gFwp5E5L7gigK411/WZlhMV1KWo2jyZcoNTvri0YCS1LCxYZqC5EkBEgeqBz64Q8 18 | 7l61+MrmRKcimKtQXlnx1ppprYHJVFrt+KWXWkMCgYBp8VekNVH1vQMsXZ1gbZ9s 19 | qXScdbS7vCl8an0dQsmYDwnsbCjWK8ZeD7uOGBgxdw6icEeR93RHYefGzU913v0o 20 | i0hodDj70bLekgN6LN9IrgQctJvAYdONfHO7PaWvIDg64p0A7Ubs7fS8W5NnCp/n 21 | liYAbSp/ORitKtyRPdp/sQKBgBg6kim4LH8oIdW2loibyFjtgbV8kWja7ARXZnwK 22 | oF17cljDzQQfLvK44Pi+5IptCDJuC6zq3b/HVNf9FJTmsUAynhn5m9UI2QS2lpGu 23 | yVtavQ0PqS2zcWvTHvR7gQOFpryhe3aoTpgOXRgtJb/gmGiyUP8C2mOGHMkRPXbb 24 | OdyRAoGAd9PRu2epxKNPQyC2DLuLESlh/aJ2IX/vmZOc02PDK1hKx606aFi5SQH6 25 | hL/sQ18gV2PnCAmVT4IXRih0dlRKtjB9teOwi+Q5a4Jp5Z/Y9TUWzZ+1dFgTdaqm 26 | /ajDNO+axg7mxMqgE6VkqW83mktnd3mJjuTW01b+6PGimCtaX5Q= 27 | -----END RSA PRIVATE KEY----- 28 | -------------------------------------------------------------------------------- /node/server.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |

JHS

5 |
STATUS
6 | 7 | key: 8 |
9 | 10 | 52 | 53 | -------------------------------------------------------------------------------- /node/server.js: -------------------------------------------------------------------------------- 1 | /* jhs proxy server 2 | Cookie: handled in node to manage logon 3 | Expect: (chunk) handled in node and complete result passed to client 4 | see: ~addons/ide/jhs/node.ijs 5 | */ 6 | 7 | var args= process.argv.slice(2); 8 | const nodeport=args[0];const key=args[1];const jhsport=args[2];const breakfile=args[3];const pem=args[4] 9 | 10 | const https = require('https'); 11 | const http = require('http'); 12 | const fs = require('fs'); 13 | const crypto = require("crypto"); 14 | 15 | const bind= '0.0.0.0'; // anybody 16 | const jhshost= "localhost"; 17 | const cookiename= "jhs_cookie"; 18 | const token= crypto.randomBytes(16).toString("hex"); 19 | const logonhtml= fs.readFileSync(__dirname+'/server.html', 'utf8'); 20 | 21 | // client reponse with text 22 | function replyx(code,res,p){res.writeHead(code, "OK", {'Content-Type': 'text/html'});res.end(p);} 23 | 24 | // client response with cookkie and text 25 | function replyc(code,res,p,cval) 26 | { 27 | res.writeHead(code, "OK", {'Set-Cookie':cookiename+"="+cval+";Secure;Httponly",'Content-Type': 'text/html'}); 28 | res.end(p); 29 | } 30 | 31 | // client response with headers and body string 32 | function replyhb(code,res,p) 33 | { 34 | res.writeHead(code, "OK", p['headers']); 35 | res.end(Buffer.from(p['body'],'binary')) // must be buffer to avoid utf8 stuff 36 | } 37 | 38 | const options = { 39 | key: fs.readFileSync(pem+'/key.pem'), 40 | cert: fs.readFileSync(pem+'/cert.pem') 41 | }; 42 | 43 | const server = https.createServer(options, (req, res) => { 44 | var c= get_cookies(req)['jhs_cookie']; 45 | var url= decodeURIComponent(req.url); 46 | // var ip = req.connection.remoteAddress; // could avoid logon for localhost 47 | 48 | if(req.method == 'POST') 49 | { 50 | dopost(req, res, function() { 51 | let postdata= decodeURIComponent(req.post) 52 | let i= postdata.indexOf('?') 53 | let cmd= postdata.substring(0,i) 54 | if("jlogon"==cmd) // validate logon key 55 | { 56 | if(key==postdata.substring(7)) replyc(200,res,"logon valid",token); else replyc(200,res,"invalid key",0); 57 | } 58 | else if(c!=token || "jlogoff"==cmd) // jlogoff from jijx menu ide>logoff 59 | { 60 | replyc(403,res,"logon required",0); 61 | } 62 | else if("jbreak"==cmd) 63 | { 64 | let fd= fs.openSync(breakfile, 'r+'); 65 | let b=new Uint8Array([3]) 66 | fs.readSync(fd,b,0,1,0) 67 | b[0]= b[0]+1; 68 | if(b[0]>2)b[0]=2 69 | fs.writeSync(fd,b,0,1,0); // fd,data,offset,bytes,position 70 | fs.closeSync(fd); 71 | replyx(200,res,'break signalled'); 72 | } 73 | else 74 | jhsreq("POST",jhshost,jhsport,url,req.post,req,res); // pass to JHS 75 | }); 76 | return; 77 | } 78 | 79 | // get 80 | if(url=="/favicon.ico") // favicon allowed even if not logged on 81 | jhsreq("GET",jhshost,jhsport,url,"",req,res); 82 | else if(c!=token) 83 | replyx(200,res,logonhtml.replace("STATUS",(c!=token)?"logon required":"logon valid")) 84 | else 85 | jhsreq("GET",jhshost,jhsport,url,"",req,res); 86 | }); 87 | 88 | server.listen(nodeport, bind, () => { 89 | console.log(`JHS node proxy server running at https://${bind}:${nodeport}/`); 90 | }); 91 | 92 | var get_cookies = function(request) { 93 | var cookies = {}; 94 | if (typeof(request.headers.cookie) == "undefined") return cookies; 95 | request.headers && request.headers.cookie.split(';').forEach(function(cookie) { 96 | var parts = cookie.match(/(.*?)=(.*)$/) 97 | cookies[ parts[1].trim() ] = (parts[2] || '').trim(); 98 | }); 99 | return cookies; 100 | }; 101 | 102 | function dopost(req, res, callback) { 103 | var postdata = ""; 104 | req.on('data', function(data) { 105 | postdata += data; 106 | if(postdata.length > 1e6) { 107 | postdata = ""; 108 | res.writeHead(413, {'Content-Type': 'text/plain'}).end(); 109 | req.connection.destroy(); 110 | } 111 | }); 112 | req.on('end', function() { 113 | req.post = postdata; 114 | callback(); 115 | }); 116 | } 117 | 118 | function jhsresponse(res,data){return {'headers': res.headers,'body':data}} 119 | 120 | async function jhsreq(gp,host,port,url,body,req,res) 121 | { 122 | let promise= dorequest(gp,host,port,url,body,req); 123 | promise.then(good,bad); 124 | function good(data){replyhb(200,res,data);} 125 | function bad(data) {replyhb(200,res,data);} 126 | } 127 | 128 | function dorequest(gp,host,port,url,body,req){ 129 | let h= req.headers 130 | h["node-jhs"]= 1 131 | return new Promise(function(resolve, reject) { 132 | let options = {hostname: host,port: port,path: url,method: gp, headers: h 133 | } 134 | http 135 | .request(options, res => { 136 | var data = "" 137 | res.setEncoding('binary') // critical to get binary data uncompressed 138 | res.on("data", d => {data += d;}) 139 | res.on("end", () => {resolve(jhsresponse(res,data))}) 140 | }) 141 | .on("error", (error) => {reject(JSON.stringify(error));}) 142 | .end(body) 143 | }); 144 | } 145 | -------------------------------------------------------------------------------- /nopacman/app_v2.txt: -------------------------------------------------------------------------------- 1 | notes on app version 2 2 | 3 | jhchk2 ... 4 | 5 | javascript event 6 | jev(event) 7 | jevdo() 8 | JEV= "ev_"+jform.jmid.value+"_"+jform.jtype.value; 9 | mid is id or id from id*xxx 10 | if JEV undefined 11 | 12 | // jevdo() 13 | // ev_jid_type(id) 14 | // ev_mid_type(id) 15 | // ev_class.type(id) 16 | //! JEVIDS needs testing -------------------------------------------------------------------------------- /nopacman/build.ijs: -------------------------------------------------------------------------------- 1 | NB. build 2 | 3 | mkdir_j_ jpath '~addons/ide/jhs/config' 4 | mkdir_j_ jpath '~addons/ide/jhs/demo' 5 | mkdir_j_ jpath '~addons/ide/jhs/js' 6 | 7 | 3 : 0'' 8 | T=. jpath '~addons/ide/jhs/' 9 | S=. jpath '~Addons/ide/jhs/' 10 | 11 | mkdir_j_ each T&, each cutopen 'config demo' 12 | 13 | f=. {."1 dirtree S 14 | t=. T&, each (#S) }.each f 15 | empty t fcopynew each f 16 | ) 17 | -------------------------------------------------------------------------------- /nopacman/dbtest.ijs: -------------------------------------------------------------------------------- 1 | dbr 1 2 | dbxsm each 'f *:*';'g *';'h *';'adv *';'con *';'dyad :*';'nrr *' 3 | 4 | dyad=: 3 : 0 5 | : 6 | x+y 7 | ) 8 | 9 | f=: 3 : 0 10 | a=. 2 11 | a+y 12 | : 13 | a=. 3 14 | a+x+y 15 | ) 16 | 17 | g=: {{2+x f y}} 18 | 19 | h=: {{23+2 f y}} 20 | 21 | adv=: {{ 22 | a=. 2 23 | ;@:(<@u) y 24 | }} 25 | 26 | con=: 2 : '(u;.n) y' 27 | 28 | 29 | nrr=: 3 : 0 NB. noun result was required 30 | + 31 | ) 32 | 33 | k=: 1 : 0 34 | + 35 | ) 36 | 37 | k2=: 3 : 0 38 | : 39 | x (2 k) y 40 | ) 41 | -------------------------------------------------------------------------------- /nopacman/dev.ijs: -------------------------------------------------------------------------------- 1 | NB. tools for git to pacman release 2 | 3 | NB. setp 'ide/jhs' 4 | setp=: 3 : 0 5 | t=. jpath'~Addons/',y,'/' 6 | 'not path to git manifest'assert t,'/manifest.ijs' 7 | gitp=: t 8 | ) 9 | 10 | NB. FILESWIN64 etc 11 | specials=: 3 : 0 12 | ns=. }.'FILES'nl 0 13 | r=. '' 14 | for_n. ns do. 15 | r=. r,<;._2 (;n)~ 16 | end. 17 | (:{:n 66 | n=. (":n)rplc' ';'.' 67 | t=. 'VERSION=: ''',n,'''' 68 | echo 'new: ',t 69 | m=. a,t,b 70 | m fwrite f 71 | EMPTY 72 | ) 73 | -------------------------------------------------------------------------------- /nopacman/jdemo09.ijs: -------------------------------------------------------------------------------- 1 | coclass'jdemo09' 2 | coinsert'jhs' 3 | 4 | NB. does not use HBS 5 | NB. does not load jscore so jijx esq-q jscdo fails - window.close() instead 6 | 7 | jev_get=: 3 : 0 8 | t=. html rplc '
';gethv_jhs_ 'Host:' 9 | htmlresponse hrtemplate hrplc 'TITLE CSS JS BODY';'jdemo9';'';'';t 10 | ) 11 | 12 | html=: 0 : 0 13 | 14 | 17 | 18 | 21 | 24 | 25 | 26 | ) 27 | 28 | info=: 0 : 0 29 | The html result has multiple frames. 30 | 31 | Get a similar result by creating file multiple.htm 32 | and loading it in a browser. 33 | 34 | *** multiple.htm *** 35 | multiple 36 | ) 37 | -------------------------------------------------------------------------------- /nopacman/jfiles.ijs: -------------------------------------------------------------------------------- 1 | NB. JHS - recent files 2 | coclass'jfiles' 3 | coinsert'jhs' 4 | 5 | HBS=: 0 : 0 6 | jhfcommon'jfiles' 7 | jhresize'' 8 | files'' 9 | ) 10 | 11 | jev_get=: 3 : 0 12 | 'jfiles'jhr'' 13 | ) 14 | 15 | files=: 3 : 0 16 | addrecent_jsp_'' 17 | 18 | if. 0=#SPFILES_jsp_ do. 19 | '',~'
The recent files list is empty.' 20 | else. 21 | '
',~'
',;fx each SPFILES_jsp_ 22 | end. 23 | ) 24 | 25 | fx=: 3 : 0 26 | s=. ;shorts_jsp_ y 27 | t=. jshortname y 28 | NB.!f=. ;(1>.10-#s)#<' ' 29 | f=. ;(1>.10-#s)#<' ' 30 | (('file*',jurlencode t)jhab s,f,t),jhbr 31 | ) 32 | 33 | CSS=: 0 : 0 34 | *{font-family:PC_FONTFIXED;} 35 | ) 36 | 37 | JS=: jsfcommon,0 : 0 38 | function ev_body_load(){jresize();} 39 | 40 | function ev_file_click(){ 41 | t= 'jijs?jwid='+jsid.value,jsid.value; 42 | pageopen(t,t); //? nocache??? 43 | } 44 | 45 | ) 46 | 47 | 48 | -------------------------------------------------------------------------------- /nopacman/jhsdev.ijs: -------------------------------------------------------------------------------- 1 | jhs_create_symbolic_link=: 3 : 0 2 | 'already linked to ~Addons'assert 0=fexist'~addons/ide/jhs/.git' 3 | rmdir_j_ jpath'~addons/ide/jhs' NB. delete pacman ~addons folder 4 | hostcmd_j_ 'ln -s ',(jpath'~Addons/ide/jhs/'),' ',jpath '~addons/ide/jhs' 5 | 'link to ~Addons did not work'assert 1=fexist'~addons/ide/jhs/.git' 6 | ) 7 | 8 | man=: 0 : 0 9 | JHS development 10 | editing/testing done with git/addons/ide/jhs 11 | JHS runs with git code due to symbolic link set by: jhs_create_symbolic_link'' 12 | ~Addons -> git/addons 13 | ~addons -> j90x/addons -> git/addons 14 | 15 | git manifest version numbers should always increase 16 | so pacman update should never see that pacman update as required 17 | 18 | *** pacman release build (from ~Addons/ide/jhs): 19 | ...$ cd git/addons/ide/jhs 20 | ...$ git pull 21 | ...$ git status - resolve problems 22 | 23 | start J 24 | load'docs/ijs/spfile.ijs' NB. define bupx etc 25 | bupn__=: '~Addons/ide/jhs' NB. folder to backup 26 | bupx'before pacman' NB. defined in p_jhs_jsp_ 27 | load'~Addons/ide/jhs/nopacman/dev.ijs' 28 | setp'ide/jhs' 29 | manifest_status'' NB. edit manifest to resolve problems 30 | bump_version'' 31 | 32 | ...$ git status 33 | ...$ git commit -a -m "pacman release ..." 34 | ...$ git push 35 | 36 | *** test pacman build: 37 | ferase'~addons/ide/jhs' NB. erase ln symbolic link file to git/addons/ide/jhs 38 | esc+q 39 | 40 | start jconsole 41 | load'pacman' 42 | 'install'jpkg'ide/jhs' 43 | 44 | shutdown/start JHS/test 45 | 46 | *** ln to ~Addons for development: 47 | start JHS 48 | jhs_create_symbolic_link'' 49 | ) 50 | -------------------------------------------------------------------------------- /nopacman/oldmenu.js: -------------------------------------------------------------------------------- 1 | //! old menu stuff 2 | 3 | // return menu group node n 4 | function jfindmenu(n) 5 | { 6 | var nodes= document.getElementsByTagName("a"); 7 | var i,node,cnt=0,last,len= nodes.length; 8 | for(i=0;i=0;--n) // back n up to current group 48 | if(1==jmenunavinfo(m,n))break; 49 | for(i=n-1;i>=0;--i) 50 | if(jmenunavfocushmg(m,i))return; 51 | for(i=len-1;i>=0;--i) // focus last hmg 52 | if(jmenunavfocushmg(m,i))return; 53 | } 54 | else if(c==38) // up 55 | { 56 | if("jhmg"==nc) return; 57 | if(jmenunavfocus(m,n-1))return; 58 | else 59 | { 60 | for(i=n;i=0;--i) // back up to hmg then forward 1 78 | if(1==jmenunavinfo(m,i))break; 79 | jmenunavfocus(m,i+1); 80 | return; 81 | } 82 | } 83 | } 84 | 85 | // focus,show if hmg - return 1 if focus is done 86 | function jmenunavfocushmg(m,n) 87 | { 88 | if(1!=jmenunavinfo(m,n))return 0; 89 | m[n].focus();jmenushow(m[n]); 90 | return 1; 91 | } 92 | 93 | // focus if hml/jmab - return 1 if focus is done 94 | function jmenunavfocus(m,n) 95 | { 96 | if(2!=jmenunavinfo(m,n))return 0; 97 | m[n].focus(); 98 | return 1; 99 | } 100 | 101 | // return m[n] info - 0 none, 1 hmg, 2 hml or hmab 102 | function jmenunavinfo(m,n) 103 | { 104 | if(n==m.length)return 0; 105 | return ("jhmg"==m[n].getAttribute("class"))?1:2 106 | } 107 | 108 | // activate menu group n 109 | function jactivatemenu(n) 110 | { 111 | jmenuhide(); 112 | var node= jfindmenu(n); 113 | if('undefined'==typeof node) return; 114 | node.focus(); 115 | } 116 | 117 | var menublock= null; // menu ul element with display:block 118 | var menulast= null; // menu ul element just hidden 119 | 120 | function jmenuclick(ev) 121 | { 122 | jmenuhide(ev); 123 | var e=window.event||ev; 124 | var tar=(typeof e.target=='undefined')?e.srcElement:e.target; 125 | var id=tar.id; 126 | if(id=="adv"){jscdo("advance");return;} 127 | var idul= id+"_ul"; 128 | jbyid(id).focus(); // required on mac 129 | if(jbyid(idul).style.display=="block") 130 | { 131 | menublock= null; 132 | jbyid(idul).style.display= "none"; 133 | } 134 | else 135 | { 136 | if(menulast!=jbyid(idul)) 137 | { 138 | menublock= jbyid(idul); 139 | menublock.style.display= "block"; 140 | } 141 | } 142 | } 143 | 144 | function jmenushow(node) 145 | { 146 | jmenuhide(); 147 | var id=node.id; 148 | var idul= id+"_ul"; 149 | menublock= jbyid(idul); 150 | menublock.style.display= "block"; 151 | } 152 | 153 | function jmenuhide() 154 | { 155 | if(tmenuid!=0) clearTimeout(tmenuid); 156 | tmenuid= 0; 157 | menulast= menublock; 158 | if(menublock!=null) menublock.style.display= "none"; 159 | menublock= null; 160 | return true; 161 | } 162 | 163 | // browser differences 164 | // safari/chrome onblur on mousedown and onfocus on mouseup 165 | // onblur will hide the menu 250 after mousedown (no clear) 166 | // so menu item click needs to be quick 167 | 168 | var tmenuid= 0; 169 | 170 | function jmenublur(ev) 171 | { 172 | if(tmenuid!=0) clearTimeout(tmenuid); 173 | tmenuid= setTimeout(jmenuhide,500) 174 | return true; 175 | } 176 | 177 | function jmenufocus(ev) 178 | { 179 | if(tmenuid!=0) clearTimeout(tmenuid); 180 | tmenuid= 0; 181 | return true; 182 | } 183 | 184 | function jmenukeydown(ev) 185 | { 186 | var e=window.event||ev; 187 | var c=e.keyCode; 188 | return(c>36&&c<41)?false:true; 189 | } 190 | 191 | function jmenukeypress(ev) 192 | { 193 | var e=window.event||ev; 194 | var c=e.keyCode; 195 | return(c>36&&c<41)?false:true; 196 | } 197 | 198 | function jmenukeyup(ev) 199 | { 200 | var e=window.event||ev; 201 | var c=e.keyCode; 202 | if(c<37||c>40)return false; 203 | var tar=(typeof e.target=='undefined')?e.srcElement:e.target; 204 | jmenunav(tar,c); 205 | return true; 206 | } 207 | 208 | 209 | -------------------------------------------------------------------------------- /nopacman/switch.ijs: -------------------------------------------------------------------------------- 1 | load'pacman' 2 | 3 | man=: 0 : 0 4 | manage multiple JHS versions - git / pacman original / tar snapshot 5 | 6 | jhsalt folder has alternate jhs code 7 | jhsalt,'/pac/addons/ide/jhs' - original pacman -set by first which 8 | jhsalt,'/bup/git/addons/ide/jhs' - from tar of git source 9 | 10 | dif'' NB. linux kdiff3 git vs jhsalt/bup 11 | 12 | switch'...' NB. git/pac/bup - jhs link to alternate code 13 | 14 | get'...' NB. path to backup tar of git/addons/ide/jhs 15 | ) 16 | 17 | jhsalt=: 'jhsalt' NB. folder with alternate JHS source 18 | 19 | asserts=: 3 : 0 20 | 'should be run in jconsole' assert -.IFJHS+.IFQT 21 | 'jhsalt must be defined'assert 0=nc<'jhsalt' 22 | 'jhsalt folder must exist' assert fexist jhsalt 23 | '~Addons must be defined in ~config/folders.ijs' assert fexist '~Addons/ide/jhs/core.ijs' 24 | ) 25 | 26 | NB. which JHS code 27 | which=: 3 : 0 28 | asserts'' 29 | r=.shell'ls -l ',jpath'~addons/ide/jhs' 30 | if. 1~:+/r=LF do. 31 | p=. jhsalt,'/pac/addons/ide' 32 | mkdir_j_ p 33 | echo'jhs not a link - assume it is pacman version' 34 | echo'pacman version copied to: ',p 35 | shell 'cp -r ',(jpath'~addons/ide/jhs'),' ',p 36 | jpath'~addons/ide/jhs' 37 | else. 38 | i=. r i:'>' 39 | }:2}.(i}.r) 40 | end. 41 | ) 42 | 43 | NB. set jhs link to run alternate JHS code 44 | switch=: 3 : 0 45 | asserts'' 46 | old=. which'' 47 | echo old 48 | select. y 49 | case. 'git' do. t=. 'git/addons/ide/jhs' 50 | case. 'bup' do. t=. jhsalt,'/bup/git/addons/ide/jhs' 51 | case. 'pac' do. t=. jhsalt,'/pac/addons/ide/jhs' 52 | case. do. 'invalid arg'assert 0 53 | end. 54 | t=. jpath '~/',t 55 | if. t-:old do. 'already set to that link' return. end. 56 | rmdir_j_ jpath'~addons/ide/jhs' NB. delete pacman ~addons folder 57 | shell'ln -s ',t,' ',jpath '~addons/ide/jhs' 58 | which'' 59 | ) 60 | 61 | NB. dif between git and jhsalt/bup 62 | dif=: 3 : 0 63 | shell'kdiff3 git/addons/ide/jhs jhsalt/bup/git/addons/ide/jhs' 64 | ) 65 | 66 | NB. get'pastebuptarfilenamehere' 67 | NB. copy file to jhsalt/bup/ and untar 68 | get=: {{ 69 | asserts'' 70 | fn=. dltb deb 7}.y NB. drop prefix 'file:// 71 | echo fn 72 | 'not tar.gz'assert '.tar.gz'-:_7{.fn 73 | name=. (fn i: '/')}.fn 74 | echo name 75 | t=. 'jhsalt/bup' 76 | rmdir_j_ :: [ t 77 | mkdir_j_ t 78 | (fread fn)fwrite t,name 79 | q=.'tar -xzf ',t,name,' -C ',t 80 | echo q 81 | shell q 82 | }} 83 | -------------------------------------------------------------------------------- /nopacman/wiki.txt: -------------------------------------------------------------------------------- 1 | 13 april 2022 2 | 3 | * onbeforeunload finally works 4 | close page if dirty gives user change to cancel close 5 | kill off ctrl+\ ??? 6 | kill off redbarclose 7 | 8 | * jijs - load/loadd run in jijx window - alert if jijx window is gone 9 | 10 | * more consistent use of window name 11 | 12 | * more consistent use of standard jshortname 13 | 14 | * jijx menu cleanup - edit menu 15 | 16 | * mac cmd key in menu -------------------------------------------------------------------------------- /page/jcjs.ijs: -------------------------------------------------------------------------------- 1 | coclass'jcjs' 2 | coinsert'jhs' 3 | 4 | INC=: INC_chartjs NB. include chart js code 5 | 6 | NB. define html elements (button,...) 7 | HBS=: 0 : 0 8 | jhclose'' 9 | 'dict'jhb'show chart config' 10 | 'defn'jhb'show chart defintion' 11 | jhdivz NB. base div close - flex active 12 | 13 | NB. share remaining vertical space 14 | 'charta'jhchart'' 15 | 'show'jhdiv'' 16 | 17 | jhdiva'' NB. reopen main div 18 | ) 19 | 20 | ev_create=: 3 : 0 21 | if. ''-:y do. 22 | jcjs'reset' 23 | jcjs'data';>:5?20 24 | jcjs'labels';5 25 | end. 26 | jhcmds 'chartjs charta *',cjsdata 27 | ) 28 | 29 | NB. style html elements (color,size,border,..) 30 | CSS=: 0 : 0 31 | #charta_parent{background-color:pink;} 32 | #charta_parent{height:50%;width:100%;} 33 | #show{font-family:monospace;} 34 | ) 35 | 36 | NB. javascript code 37 | JS=: 0 : 0 38 | 39 | function show(t){ 40 | t= t.replace(//g, '>'); 42 | t= t.replace(/\n/g, '
'); 43 | t= t.replace(/ /g, ' '); 44 | t= t.replace(/\"/g, '"'); 45 | t= t.replace(/'/g, '''); 46 | jbyid('show').innerHTML= t; 47 | } 48 | 49 | function ev_dict_click(){ 50 | var c= cjs('charta').config; 51 | show(JSON.stringify(c._config,null,4)); 52 | } 53 | 54 | function ev_defn_click(){show(jsdata['charta']);} 55 | 56 | ) -------------------------------------------------------------------------------- /page/jd3.ijs: -------------------------------------------------------------------------------- 1 | coclass'jd3' 2 | coinsert'jhs' 3 | 4 | NB. css/js library files to include 5 | INC=: INC_d3_basic 6 | 7 | NB. J sentences - create html body 8 | HBS=: 0 : 0 9 | jhclose'' 10 | 'ga'jhd3_basic'' NB. ga,ga_... divs for d3_basic plot 11 | ) 12 | 13 | NB. jpage boilerplate from util.ijs 14 | 15 | ev_create=: 3 : 0 16 | if. ''-: y do. 17 | jd3'reset;type line;title My Data;legend "line one","line two","line three"' 18 | y=. jd3x__;?3 4$100 19 | end. 20 | 21 | try. 22 | 'opt d'=. y 23 | data=: (opt rplc LF;'\n'),jd3data d 24 | catchd. 25 | ('create failed:',LF,13!:12'') assert 0 26 | end. 27 | JS=: JS hrplc 'TABDATA';data NB. adjust JS here! 28 | ) 29 | 30 | NB. javascript 31 | JS=: 0 : 0 32 | 33 | tabdata=""; // set by ev_create 34 | 35 | function ev_body_load() 36 | { 37 | if (window.frameElement){jhide("close");} // demo14.ijs - only 1 close button in iframe set 38 | resize(); 39 | window.onresize= resize; 40 | } 41 | 42 | function resize() 43 | { 44 | jbyid("ga_box").style.width=window.innerWidth-20+"px"; 45 | jbyid("ga_box").style.height=window.innerHeight-20+"px"; 46 | plot("ga",tabdata); 47 | } 48 | 49 | function ajax(ts){;} 50 | 51 | ) -------------------------------------------------------------------------------- /page/jhotd3.ijs: -------------------------------------------------------------------------------- 1 | coclass'jhotd3' 2 | coinsert'jhs' 3 | 4 | man=: 'jpage y must be 5 by 12 integer table' 5 | 6 | HBS=: 0 : 0 7 | jhclose'' 8 | jhh1'Budget' 9 | 'budget 2016' 10 | '
' 11 | '' 12 | '' 13 | '
' 14 | ) 15 | 16 | months=: '"JAN","FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"' 17 | 18 | ev_create=: 3 : 0 19 | y=. y jpagedefault ?5 12$200 20 | man assert (4=3!:0 y)*. 5 12-:$y 21 | temp__=: y 22 | t=. 'temp' 23 | try. 24 | shown=: 1 25 | header=: dltb t 26 | header=: header,>('_'={:header){'__';'' 27 | assert 0=nc
td {background-color: bisque;}' 33 | 34 | NB. sets summary rows to readonly 35 | option__hot1'cells: function(row, col, prop){var cellProperties = {};if(row > 4){cellProperties.readOnly = true;}return cellProperties;}' 36 | 37 | option__hot1'colHeaders:[',months,']' 38 | option__hot1'rowHeaders:["food","car","cell","rent","misc","min","max","avg","sum","tot"]' 39 | option__hot1'minSpareRows:0' 40 | option__hot1'minSpareCols:0' 41 | setdata__hot1 d,calc d 42 | fixjs__hot1'' NB. apply options and data to JS 43 | 44 | jd3'reset' 45 | jd3'label ',months 46 | jd3'legend "foo","car","cell","rent","misc"' 47 | jd3'barwidth 60' 48 | jd3'type bar' 49 | jd3options=: jd3x__ 50 | loc=: 'jd3;_;'jpage jd3options;d 51 | 52 | catch. 53 | ('create failed:',LF,13!:12'') assert 0 54 | end. 55 | jhcmds'' 56 | ) 57 | 58 | destroy=: 3 : 0 59 | if. shown do. close ;coname'' end. 60 | destroy__hot1'' 61 | destroy__loc'' 62 | codestroy'' 63 | ) 64 | 65 | NB. new CSS3 calc will allow better layout control 66 | CSS=: 0 : 0 67 | #title{margin-left:50px;text-align:center;font-size:22pt;} 68 | #hots{height:90vh;overflow:hidden;} 69 | #hot1{width:100%;height:50%;overflow:hidden;} 70 | #jd3 {width:100%;height:50%;overflow:hidden;} 71 | ) 72 | 73 | calc=: 3 : '(<./y),(>./y),(<.(+/%#) y),(+/y),:+/\ +/y' 74 | 75 | NB. gets all the data - could get and apply just changes 76 | jev_change=: 3 : 0 77 | b=. 5{.data__hot1 78 | d=. tablefromjs getv'jdata' NB. data and summary data 79 | for_i. i.#d do. 80 | 'r c z n'=. i{d 81 | b=. n (' 11 | '' 12 | '
' 13 | ) 14 | 15 | NB. jpage boilerplate from util.ijs 16 | 17 | ev_create=: 3 : 0 18 | if. ''-:y do. 19 | temp__=: 2 2$'aa';'b';'c';'dd' 20 | y=. 'temp' 21 | end. 22 | 23 | try. 24 | header=: dltb y 25 | header=: header,>('_'={:header){'__';'' 26 | assert 0=nc
:$$d 29 | assert 2>L.d 30 | (header)=: (,:^:({.2-$$d)) d 31 | hot=: 'jhot;_'jpage'EMPTY_z_' 32 | setdata__hot header~ 33 | JS__hot 34 | fixjs__hot'' NB. apply options and data to JS 35 | JS__hot 36 | NB. show__hot 'tab' 37 | jhcmds 'set head *table: ',header 38 | catchd. 39 | ('create failed:',LF,13!:12'') assert 0 40 | end. 41 | ) 42 | 43 | NB. need better way to destroy embedded objects 44 | ev_close_click=: 3 : 0 45 | destroy__hot'' NB. jhot object 46 | jhrajax'' 47 | shown=: 0 NB. already closed 48 | destroy'' 49 | i.0 0 50 | ) 51 | 52 | NB. currently gets all the data - could get and apply just changes 53 | jev_change=: 3 : 0 54 | (header)=: data__hot=: tablefromjs getv'jdata' 55 | jhrajax'' 56 | ) 57 | 58 | CSS=: 0 : 0 59 | body{margin:5px;} 60 | #hots{height:90vh;} 61 | #hot{width:100%;height:100%;} 62 | ) 63 | 64 | JS=: 0 : 0 NB. javascript 65 | function ev_body_load() 66 | { 67 | window.frames[0].hot.addHook('afterChange', function(change,source) 68 | { 69 | if(source!="edit")return; 70 | var s= "jev_change_"+jform.jlocale.value+"_ 0" 71 | jdoajax([],JSON.stringify(window.frames[0].data),s); 72 | } 73 | ); 74 | jhrcmds(jsdata['jhrcmds']); // must do explicitly 75 | } 76 | 77 | function ajax(ts){;} 78 | 79 | ) 80 | -------------------------------------------------------------------------------- /page/jwatch.ijs: -------------------------------------------------------------------------------- 1 | coclass'jwatch' 2 | coinsert'jhs' 3 | 4 | HBS=: 0 : 0 5 | jhclose'' 6 | 'run'jhb'run' 7 | 'sentence'jhtext'';30 8 | 'display'jhdiv'' 9 | ) 10 | 11 | ev_create=: 3 : 0 12 | t=. y jpagedefault '5?5' 13 | jhcmds ('set sentence *',t);'set display *',calc t 14 | ) 15 | 16 | calc=: 3 : 0 17 | try. r=. ":do__ y catch. r=. 13!:12'' end. 18 | if. 2=$$r do. r=. ,r,.LF end. 19 | utf8_from_jboxdraw jhtmlfroma fmt0 r 20 | ) 21 | 22 | ev_run_click=: {{ jhrcmds 'set display *',calc getv'sentence' }} 23 | 24 | ev_sentence_enter=: ev_run_click 25 | 26 | CSS=: 0 : 0 27 | #sentence,#display{} 28 | ) 29 | -------------------------------------------------------------------------------- /page/tictactoe.ijs: -------------------------------------------------------------------------------- 1 | require'~addons/ide/jhs/react/tictactoe/addj/reacttictactoe.ijs' 2 | 3 | coclass'tictactoe' 4 | coinsert'jhs' 5 | title=: 'tictactoe' 6 | 7 | desc=: 0 : 0 8 | react is a javascript framework for building apps 9 | https://react.dev/ 10 | react/tictactoe has react tictactoe code from codepen 11 | react/tictactoe/addj has changes so J calculates plays 12 | addj code runs in an iframe 13 | ) 14 | 15 | NB. define html for the page 16 | HBS=: 0 : 0 17 | jhclose'react' 18 | 'desc'jhdiv desc 19 | jhdivz 20 | '' 21 | ) 22 | 23 | NB. id desc has variable font and preformatted white space 24 | NB. id react takes all height and has scroll if necessary 25 | CSS=: 0 : 0 26 | #desc{font-family:;white-space:pre;} 27 | #react{height:100%;overflow:scroll;} 28 | ) 29 | 30 | ev_create=: 3 : 0 31 | jhcmds '' NB. browser commands when page loads 32 | ) 33 | -------------------------------------------------------------------------------- /port.ijs: -------------------------------------------------------------------------------- 1 | NB. port utilties - used with Jd/JHS node server 2 | NB. should probably be an addons - for now it can live here 3 | NB. Jd currently loads this script 4 | 5 | coclass'jport' 6 | 7 | killport=: 3 : 0 8 | 'must be single port'assert 1=#y 9 | pid=: pidfromport y 10 | if. _1~:pid do. 11 | select. UNAME 12 | case. 'Win' do. shell_jtask_'taskkill /f /pid ',":pid 13 | case. do. shell_jtask_'kill ',":pid 14 | end. 15 | end. 16 | i.0 0 17 | ) 18 | 19 | NB. pids,.ports 20 | pidport=: 3 : 0 21 | if. UNAME-:'Win' do. 22 | NB.! may have same problem as lsof with multiple pid ports 23 | d=. CR-.~each deb each <;._2 shell'netstat -ano -p tcp' 24 | b=. d#~;(<'TCP')-:each 3{.each d 25 | d=. ><;._2 each d,each' ' 26 | d=. d#~(<'LISTENING')=3{"1 d 27 | a=. 1{"1 d 28 | a=. ;0".each(>:;a i: each':')}.each a 29 | d=. ;0".each 4{"1 d 30 | d,:a 31 | else. 32 | NB. lsof reporting no ports gets interface error 33 | NB. lsof - some always reports f field and some only if requested - always request 34 | NB. p field can be followed by multiple f and n fields 35 | d=. shell_jtask_ :: 0: 'lsof -F pfn -s TCP:LISTEN -i TCP' 36 | if. d-:0 do. i.2 0 return. end. 37 | d=. <;._2 shell_jtask_'lsof -F pfn -s TCP:LISTEN -i TCP' 38 | r=. '' 39 | while. #d do. 40 | if. 'p'={.;{.d do. 41 | p=. {.d 42 | r=. r,3{.d 43 | d=. 3}.d 44 | else. 45 | r=. r,p,2{.d 46 | d=. 2}.d 47 | end. 48 | end. 49 | 'unexpected lsof result'assert 0=3|#r 50 | d=. (3,~<.3%~#r)$r 51 | pids=. ;_1".each}.each{."1 d 52 | a=. {:"1 d 53 | ports=. ;_1".each a}.~each >:;a i: each':' 54 | pids,:ports 55 | end. 56 | ) 57 | 58 | NB. delays to allow task to start 59 | pidfromport=: 3 : 0 60 | 'pid port'=. pidport'' 61 | r=. (port i. y){pid,_1 62 | if. r=_1 do. 63 | 6!:3[0.1 64 | 'pid port'=. pidport'' 65 | r=. (port i. y){pid,_1 66 | if. r=_1 do. 67 | 6!:3[0.4 68 | 'pid port'=. pidport'' 69 | r=. (port i. y){pid,_1 70 | end. 71 | end. 72 | r 73 | ) 74 | -------------------------------------------------------------------------------- /react/tictactoe/LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2022 Dan Abramov (https://codepen.io/gaearon/pen/gWWZgR) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /react/tictactoe/README.md: -------------------------------------------------------------------------------- 1 | # Tic Tac Toe 2 | 3 | A Pen created on CodePen.io. Original URL: [https://codepen.io/gaearon/pen/gWWZgR](https://codepen.io/gaearon/pen/gWWZgR). 4 | 5 | -------------------------------------------------------------------------------- /react/tictactoe/addj/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CodePen - Tic Tac Toe 6 | 7 | 8 | 9 | 10 | 11 | 12 |
20 |
21 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /react/tictactoe/addj/reacttictactoe.ijs: -------------------------------------------------------------------------------- 1 | coclass'reacttictactoe' 2 | coinsert'jhs' 3 | 4 | NB. src - path to find other bits 5 | src=: '~addons/ide/jhs/react/tictactoe/addj/' 6 | 7 | NB. fix css/script path 8 | fixhtml=: 3 : 0 9 | y rplc './';src 10 | ) 11 | 12 | jev_get=: 3 : 0 13 | d=. fixhtml fread src,'index.html' 14 | htmlresponse d,~fsrchead rplc '';'text/html' 15 | ) 16 | 17 | winners=: 0 4 8, 6 4 2, (i. 3 3), (|: i. 3 3) 18 | 19 | NB. x is X or Y ; y is board 20 | getplays=: 4 : 0 21 | c=. +/y='*' 22 | i=. (y='*')#i.9 23 | plays=. <"1 (i.c),.i 24 | x plays } (c,9)$y 25 | ) 26 | 27 | NB. x is X or O ; y is board 28 | getwinner=: 4 : 0 29 | d=. x getplays y 30 | i=. 3 i.~ >./"1 +/"1 x=winners {"_ 1 d 31 | if. i=#d do. 9 return. end. 32 | t=. i{d 33 | (t~:y)i.1 34 | ) 35 | 36 | NB. 'cmd' getval table_from_json 37 | getval=: 4 : 0 38 | i=. ({.y)i.i{{:y 40 | ) 41 | 42 | NB. NV has json of cmd: and board: 43 | NB. return oplay: as O move and winner: as 0/1/2 for no/X/Y winner 44 | jev_post_raw=: 3 : 0 45 | v=. dec_json_jhs_ NV 46 | c=. 'cmd'getval v 47 | s=. {:'squares'getval v 48 | B=: q=. ;s rplc each <'json_null';'*' 49 | a=. 0 NB. assume no winner 50 | 51 | if. 3 e. +/"1 'X'=winners{q do. 52 | i=. 9 53 | a=. 1 NB. X wins 54 | else. 55 | 56 | NB. play to win 57 | i=. 'O' getwinner q 58 | if. i<9 do. 59 | a=. 2 NB. Y wins 60 | else. 61 | NB. play to block 62 | i=. 'X' getwinner q 63 | if. i=9 do. 64 | t=. (q='*')#i.#q 65 | if. 0=#t do. i=. q i.'O' else. i=. (?#t){t end. NB. random play 66 | end. 67 | end. 68 | end. 69 | if. i<#q do. q=. 'O' i}q end. 70 | last=: q 71 | NB. error before here - no jhrajax response - J crash 72 | jhrajax jsencode 'oplay';i;'winner';a{'0XO' 73 | ) 74 | -------------------------------------------------------------------------------- /react/tictactoe/addj/script.js: -------------------------------------------------------------------------------- 1 | //! ebi edits to original react script.js 2 | 3 | // postdata to JHS server and get response 4 | async function postData(url = '', data = {}) { 5 | // Default options are marked with * 6 | const response = await fetch(url, { 7 | method: 'POST', // *GET, POST, PUT, DELETE, etc. 8 | mode: 'cors', // no-cors, *cors, same-origin 9 | cache: 'no-cache', // *default, no-cache, reload, force-cache, only-if-cached 10 | credentials: 'same-origin', // include, *same-origin, omit 11 | headers: { 12 | 'Content-Type': 'application/json' 13 | // 'Content-Type': 'application/x-www-form-urlencoded', 14 | }, 15 | redirect: 'follow', // manual, *follow, error 16 | referrerPolicy: 'no-referrer', // no-referrer, *no-referrer-when-downgrade, origin, origin-when-cross-origin, same-origin, strict-origin, strict-origin-when-cross-origin, unsafe-url 17 | body: JSON.stringify(data) // body data type must match "Content-Type" header 18 | }); 19 | return response.json(); // parses JSON response into native JavaScript objects 20 | } 21 | //! 22 | 23 | function Square(props) { 24 | return /*#__PURE__*/( 25 | React.createElement("button", { className: "square", onClick: props.onClick }, 26 | props.value)); 27 | 28 | 29 | } 30 | 31 | class Board extends React.Component { 32 | renderSquare(i) { 33 | return /*#__PURE__*/( 34 | React.createElement(Square, { 35 | value: this.props.squares[i], 36 | onClick: () => this.props.onClick(i) })); 37 | 38 | 39 | } 40 | 41 | render() { 42 | return /*#__PURE__*/( 43 | React.createElement("div", null, /*#__PURE__*/ 44 | React.createElement("div", { className: "board-row" }, 45 | this.renderSquare(0), 46 | this.renderSquare(1), 47 | this.renderSquare(2)), /*#__PURE__*/ 48 | 49 | React.createElement("div", { className: "board-row" }, 50 | this.renderSquare(3), 51 | this.renderSquare(4), 52 | this.renderSquare(5)), /*#__PURE__*/ 53 | 54 | React.createElement("div", { className: "board-row" }, 55 | this.renderSquare(6), 56 | this.renderSquare(7), 57 | this.renderSquare(8)))); 58 | 59 | 60 | 61 | }} 62 | 63 | 64 | class Game extends React.Component { 65 | constructor(props) { 66 | super(props); 67 | this.state = { 68 | history: [ 69 | { 70 | squares: Array(9).fill(null) }], 71 | 72 | 73 | stepNumber: 0, 74 | xIsNext: true, 75 | winner: 0 }; 76 | 77 | } 78 | 79 | 80 | //! ebi changes 81 | handleClick(i) { 82 | const history = this.state.history.slice(0, this.state.stepNumber + 1); 83 | const current = history[history.length - 1]; 84 | const squares = current.squares.slice(); 85 | 86 | if(squares[i]!=null || this.state.winner!=0) return; 87 | squares[i]= "X"; 88 | 89 | var a= { cmd: 'xplay', squares: Object.assign({}, squares) }; 90 | postData(window.location.href, a ) // return O play and winner (if any) 91 | .then((data) => { 92 | if(data.oplay<9) squares[data.oplay] = "O"; 93 | this.state.xIsNext= 1; 94 | this.setState({ 95 | history: history.concat([{ 96 | squares: squares }]), 97 | stepNumber: history.length, 98 | winner: data.winner 99 | }); 100 | }); 101 | } 102 | 103 | jumpTo(step) { 104 | this.setState({ 105 | stepNumber: step, 106 | xIsNext: step % 2 === 0, 107 | winner: 0 }); 108 | 109 | } 110 | 111 | render() { 112 | const history = this.state.history; 113 | const current = history[this.state.stepNumber]; 114 | const moves = history.map((step, move) => { 115 | const desc = move ? 116 | 'Go to move #' + move : 117 | 'Go to game start'; 118 | return /*#__PURE__*/( 119 | React.createElement("li", { key: move }, /*#__PURE__*/ 120 | React.createElement("button", { onClick: () => this.jumpTo(move) }, desc))); 121 | 122 | 123 | }); 124 | 125 | let status; 126 | if (this.state.winner!=0) { 127 | status = "Winner: " + this.state.winner; 128 | } else { 129 | status = "Next player: " + (this.state.xIsNext ? "X" : "O"); 130 | } 131 | 132 | return /*#__PURE__*/( 133 | React.createElement("div", { className: "game" }, /*#__PURE__*/ 134 | React.createElement("div", { className: "game-board" }, /*#__PURE__*/ 135 | React.createElement(Board, { 136 | squares: current.squares, 137 | onClick: i => this.handleClick(i) })), /*#__PURE__*/ 138 | 139 | React.createElement("div", { className: "game-info" }, /*#__PURE__*/ 140 | React.createElement("div", null, status), /*#__PURE__*/ 141 | React.createElement("ol", null, moves)))); 142 | 143 | 144 | 145 | }} 146 | 147 | 148 | // ======================================== 149 | 150 | const root = ReactDOM.createRoot(document.getElementById("root")); 151 | root.render( /*#__PURE__*/React.createElement(Game, null)); 152 | -------------------------------------------------------------------------------- /react/tictactoe/addj/style.css: -------------------------------------------------------------------------------- 1 | body { 2 | font: 14px "Century Gothic", Futura, sans-serif; 3 | margin: 20px; 4 | } 5 | 6 | ol, ul { 7 | padding-left: 30px; 8 | } 9 | 10 | .board-row:after { 11 | clear: both; 12 | content: ""; 13 | display: table; 14 | } 15 | 16 | .status { 17 | margin-bottom: 10px; 18 | } 19 | 20 | .square { 21 | background: #fff; 22 | border: 1px solid #999; 23 | float: left; 24 | font-size: 24px; 25 | font-weight: bold; 26 | line-height: 34px; 27 | height: 34px; 28 | margin-right: -1px; 29 | margin-top: -1px; 30 | padding: 0; 31 | text-align: center; 32 | width: 34px; 33 | } 34 | 35 | .square:focus { 36 | outline: none; 37 | } 38 | 39 | .kbd-navigation .square:focus { 40 | background: #ddd; 41 | } 42 | 43 | .game { 44 | display: flex; 45 | flex-direction: row; 46 | } 47 | 48 | .game-info { 49 | margin-left: 20px; 50 | } -------------------------------------------------------------------------------- /react/tictactoe/dist/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CodePen - Tic Tac Toe 6 | 7 | 8 | 9 | 10 | 11 | 12 |
20 |
21 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /react/tictactoe/dist/script.js: -------------------------------------------------------------------------------- 1 | function Square(props) { 2 | return /*#__PURE__*/( 3 | React.createElement("button", { className: "square", onClick: props.onClick }, 4 | props.value)); 5 | 6 | 7 | } 8 | 9 | class Board extends React.Component { 10 | renderSquare(i) { 11 | return /*#__PURE__*/( 12 | React.createElement(Square, { 13 | value: this.props.squares[i], 14 | onClick: () => this.props.onClick(i) })); 15 | 16 | 17 | } 18 | 19 | render() { 20 | return /*#__PURE__*/( 21 | React.createElement("div", null, /*#__PURE__*/ 22 | React.createElement("div", { className: "board-row" }, 23 | this.renderSquare(0), 24 | this.renderSquare(1), 25 | this.renderSquare(2)), /*#__PURE__*/ 26 | 27 | React.createElement("div", { className: "board-row" }, 28 | this.renderSquare(3), 29 | this.renderSquare(4), 30 | this.renderSquare(5)), /*#__PURE__*/ 31 | 32 | React.createElement("div", { className: "board-row" }, 33 | this.renderSquare(6), 34 | this.renderSquare(7), 35 | this.renderSquare(8)))); 36 | 37 | 38 | 39 | }} 40 | 41 | 42 | class Game extends React.Component { 43 | constructor(props) { 44 | super(props); 45 | this.state = { 46 | history: [ 47 | { 48 | squares: Array(9).fill(null) }], 49 | 50 | 51 | stepNumber: 0, 52 | xIsNext: true }; 53 | 54 | } 55 | 56 | handleClick(i) { 57 | const history = this.state.history.slice(0, this.state.stepNumber + 1); 58 | const current = history[history.length - 1]; 59 | const squares = current.squares.slice(); 60 | if (calculateWinner(squares) || squares[i]) { 61 | return; 62 | } 63 | squares[i] = this.state.xIsNext ? "X" : "O"; 64 | this.setState({ 65 | history: history.concat([ 66 | { 67 | squares: squares }]), 68 | 69 | 70 | stepNumber: history.length, 71 | xIsNext: !this.state.xIsNext }); 72 | 73 | } 74 | 75 | jumpTo(step) { 76 | this.setState({ 77 | stepNumber: step, 78 | xIsNext: step % 2 === 0 }); 79 | 80 | } 81 | 82 | render() { 83 | const history = this.state.history; 84 | const current = history[this.state.stepNumber]; 85 | const winner = calculateWinner(current.squares); 86 | 87 | const moves = history.map((step, move) => { 88 | const desc = move ? 89 | 'Go to move #' + move : 90 | 'Go to game start'; 91 | return /*#__PURE__*/( 92 | React.createElement("li", { key: move }, /*#__PURE__*/ 93 | React.createElement("button", { onClick: () => this.jumpTo(move) }, desc))); 94 | 95 | 96 | }); 97 | 98 | let status; 99 | if (winner) { 100 | status = "Winner: " + winner; 101 | } else { 102 | status = "Next player: " + (this.state.xIsNext ? "X" : "O"); 103 | } 104 | 105 | return /*#__PURE__*/( 106 | React.createElement("div", { className: "game" }, /*#__PURE__*/ 107 | React.createElement("div", { className: "game-board" }, /*#__PURE__*/ 108 | React.createElement(Board, { 109 | squares: current.squares, 110 | onClick: i => this.handleClick(i) })), /*#__PURE__*/ 111 | 112 | 113 | React.createElement("div", { className: "game-info" }, /*#__PURE__*/ 114 | React.createElement("div", null, status), /*#__PURE__*/ 115 | React.createElement("ol", null, moves)))); 116 | 117 | 118 | 119 | }} 120 | 121 | 122 | // ======================================== 123 | 124 | const root = ReactDOM.createRoot(document.getElementById("root")); 125 | root.render( /*#__PURE__*/React.createElement(Game, null)); 126 | 127 | function calculateWinner(squares) { 128 | const lines = [ 129 | [0, 1, 2], 130 | [3, 4, 5], 131 | [6, 7, 8], 132 | [0, 3, 6], 133 | [1, 4, 7], 134 | [2, 5, 8], 135 | [0, 4, 8], 136 | [2, 4, 6]]; 137 | 138 | for (let i = 0; i < lines.length; i++) { 139 | const [a, b, c] = lines[i]; 140 | if (squares[a] && squares[a] === squares[b] && squares[a] === squares[c]) { 141 | return squares[a]; 142 | } 143 | } 144 | return null; 145 | } -------------------------------------------------------------------------------- /react/tictactoe/dist/style.css: -------------------------------------------------------------------------------- 1 | body { 2 | font: 14px "Century Gothic", Futura, sans-serif; 3 | margin: 20px; 4 | } 5 | 6 | ol, ul { 7 | padding-left: 30px; 8 | } 9 | 10 | .board-row:after { 11 | clear: both; 12 | content: ""; 13 | display: table; 14 | } 15 | 16 | .status { 17 | margin-bottom: 10px; 18 | } 19 | 20 | .square { 21 | background: #fff; 22 | border: 1px solid #999; 23 | float: left; 24 | font-size: 24px; 25 | font-weight: bold; 26 | line-height: 34px; 27 | height: 34px; 28 | margin-right: -1px; 29 | margin-top: -1px; 30 | padding: 0; 31 | text-align: center; 32 | width: 34px; 33 | } 34 | 35 | .square:focus { 36 | outline: none; 37 | } 38 | 39 | .kbd-navigation .square:focus { 40 | background: #ddd; 41 | } 42 | 43 | .game { 44 | display: flex; 45 | flex-direction: row; 46 | } 47 | 48 | .game-info { 49 | margin-left: 20px; 50 | } -------------------------------------------------------------------------------- /react/tictactoe/src/index.html: -------------------------------------------------------------------------------- 1 |
9 |
10 | 39 | -------------------------------------------------------------------------------- /react/tictactoe/src/script.babel: -------------------------------------------------------------------------------- 1 | function Square(props) { 2 | return ( 3 | 6 | ); 7 | } 8 | 9 | class Board extends React.Component { 10 | renderSquare(i) { 11 | return ( 12 | this.props.onClick(i)} 15 | /> 16 | ); 17 | } 18 | 19 | render() { 20 | return ( 21 |
22 |
23 | {this.renderSquare(0)} 24 | {this.renderSquare(1)} 25 | {this.renderSquare(2)} 26 |
27 |
28 | {this.renderSquare(3)} 29 | {this.renderSquare(4)} 30 | {this.renderSquare(5)} 31 |
32 |
33 | {this.renderSquare(6)} 34 | {this.renderSquare(7)} 35 | {this.renderSquare(8)} 36 |
37 |
38 | ); 39 | } 40 | } 41 | 42 | class Game extends React.Component { 43 | constructor(props) { 44 | super(props); 45 | this.state = { 46 | history: [ 47 | { 48 | squares: Array(9).fill(null) 49 | } 50 | ], 51 | stepNumber: 0, 52 | xIsNext: true 53 | }; 54 | } 55 | 56 | handleClick(i) { 57 | const history = this.state.history.slice(0, this.state.stepNumber + 1); 58 | const current = history[history.length - 1]; 59 | const squares = current.squares.slice(); 60 | if (calculateWinner(squares) || squares[i]) { 61 | return; 62 | } 63 | squares[i] = this.state.xIsNext ? "X" : "O"; 64 | this.setState({ 65 | history: history.concat([ 66 | { 67 | squares: squares 68 | } 69 | ]), 70 | stepNumber: history.length, 71 | xIsNext: !this.state.xIsNext 72 | }); 73 | } 74 | 75 | jumpTo(step) { 76 | this.setState({ 77 | stepNumber: step, 78 | xIsNext: (step % 2) === 0 79 | }); 80 | } 81 | 82 | render() { 83 | const history = this.state.history; 84 | const current = history[this.state.stepNumber]; 85 | const winner = calculateWinner(current.squares); 86 | 87 | const moves = history.map((step, move) => { 88 | const desc = move ? 89 | 'Go to move #' + move : 90 | 'Go to game start'; 91 | return ( 92 |
  • 93 | 94 |
  • 95 | ); 96 | }); 97 | 98 | let status; 99 | if (winner) { 100 | status = "Winner: " + winner; 101 | } else { 102 | status = "Next player: " + (this.state.xIsNext ? "X" : "O"); 103 | } 104 | 105 | return ( 106 |
    107 |
    108 | this.handleClick(i)} 111 | /> 112 |
    113 |
    114 |
    {status}
    115 |
      {moves}
    116 |
    117 |
    118 | ); 119 | } 120 | } 121 | 122 | // ======================================== 123 | 124 | const root = ReactDOM.createRoot(document.getElementById("root")); 125 | root.render(); 126 | 127 | function calculateWinner(squares) { 128 | const lines = [ 129 | [0, 1, 2], 130 | [3, 4, 5], 131 | [6, 7, 8], 132 | [0, 3, 6], 133 | [1, 4, 7], 134 | [2, 5, 8], 135 | [0, 4, 8], 136 | [2, 4, 6] 137 | ]; 138 | for (let i = 0; i < lines.length; i++) { 139 | const [a, b, c] = lines[i]; 140 | if (squares[a] && squares[a] === squares[b] && squares[a] === squares[c]) { 141 | return squares[a]; 142 | } 143 | } 144 | return null; 145 | } 146 | -------------------------------------------------------------------------------- /react/tictactoe/src/style.css: -------------------------------------------------------------------------------- 1 | body { 2 | font: 14px "Century Gothic", Futura, sans-serif; 3 | margin: 20px; 4 | } 5 | 6 | ol, ul { 7 | padding-left: 30px; 8 | } 9 | 10 | .board-row:after { 11 | clear: both; 12 | content: ""; 13 | display: table; 14 | } 15 | 16 | .status { 17 | margin-bottom: 10px; 18 | } 19 | 20 | .square { 21 | background: #fff; 22 | border: 1px solid #999; 23 | float: left; 24 | font-size: 24px; 25 | font-weight: bold; 26 | line-height: 34px; 27 | height: 34px; 28 | margin-right: -1px; 29 | margin-top: -1px; 30 | padding: 0; 31 | text-align: center; 32 | width: 34px; 33 | } 34 | 35 | .square:focus { 36 | outline: none; 37 | } 38 | 39 | .kbd-navigation .square:focus { 40 | background: #ddd; 41 | } 42 | 43 | .game { 44 | display: flex; 45 | flex-direction: row; 46 | } 47 | 48 | .game-info { 49 | margin-left: 20px; 50 | } 51 | -------------------------------------------------------------------------------- /readme.txt: -------------------------------------------------------------------------------- 1 | The ide/jhs addon is the JHS IDE for j701 and later releases. 2 | 3 | -------------------------------------------------------------------------------- /release.txt: -------------------------------------------------------------------------------- 1 | release notes 2 | 3 | 1.0.386 ? 4 | jterm esc-z close pages and exit server 5 | jed - opens edit page in jterm 6 | jed newpage - first step for SPA (single-page-app) 7 | jterm esc-1 to jijx page 8 | jterm esc=2 to next page 9 | overview tour further improved 10 | jijx ☰ reorganized 11 | 12 | 1.0.385 ? 13 | click me button 14 | ☰ menu 15 | overview tour improved 16 | guest info 17 | mobile right hand buttons 18 | jterm (jijx) wrap/nowrap 19 | 20 | 1.0.384 21 | ☰ menu 22 | server guest 23 | overview tour 24 | jijx->jterm 25 | wrap/nowrap 26 | mobile right buttons 27 | 28 | 1.0.383 29 | react cleanup 30 | runreact/app/demo moved from z to jhs 31 | jpage/cojhs boilerplate moved from z to jhs 32 | 33 | 1.0.336: 34 | redbox close on most pages - upper right 35 | 36 | border-box sizing everywhere 37 | *,*::before,*::after {box-sizing: border-box;} 38 | 39 | flex - col and row resizing 40 | max height so flex resize will fill available space 41 | html,body,form {height: 100%;margin: 0;} 42 | 43 | tool>react 44 | tool>plot-chart - chartjs 45 | tool>app - completely new - best practice 46 | tool>debug javascript 47 | jijs run>lineadvance line selection 48 | dot_ctrl lab advance for all (advance in new plot page) 49 | help>framework 50 | 51 | 1.0.333: -------------------------------------------------------------------------------- /spfile_template.ijs: -------------------------------------------------------------------------------- 1 | coclass'jsp' 2 | 3 | 0 : 0 4 | define project verbs 5 | 6 | default SPFILE is: ~temp/sp/spfile.ijs 7 | template is: ~addons/ide/jhs/spfile_template.ijs 8 | 9 | man'jhsclosepages' 10 | man'jhsoption' 11 | man'jhsflex' 12 | ) 13 | 14 | p_example=: 3 : 0 15 | jhsclosepages'' 16 | jhsoption'term column' 17 | 'jfile'jpage'' 18 | edit '~Projects/jhs/example/example.ijs' 19 | jhsflex 50 20 | testdata=: i.3 4 21 | ) 22 | 23 | NB. define your p_name verb here 24 | 25 | splist'' NB. echo project sentences -------------------------------------------------------------------------------- /spx/canvas.ijt: -------------------------------------------------------------------------------- 1 | NB. graphics - drawing on an html canvas 2 | require'~addons/ide/jhs/page/jcanvas.ijs' 3 | 'jsxw_z_ jsxh_z_'=: jsxwh_z_=: 300 300 NB. width,height 4 | p=. 'jcanvas;_' cojhs jsxwh NB. create locale - no show 5 | title__p=: 'canvas-tour' 6 | refresh__p=: '' NB. initial and refresh is blank canvas 7 | NB. next step shows graph page in a new window 8 | show__p 1 1 400 400 9 | NB. position canvas-tour page so you can see it and jijx page 10 | 11 | f1=: 3 : 0 12 | jsxnew'' NB. clear jsxbuf buffer 13 | jscbeginPath'' NB. start path that will be painted 14 | jsclineWidth 4 NB. pen width 15 | jscstrokeStyle jsxucp'red' NB. red pen 16 | jscmoveTo 0 0 NB. upper left 17 | jsclineTo jsxwh NB. lower right 18 | jscstroke'' NB. draw line 19 | jsxnew'' NB. return jsxbuf and clear 20 | ) 21 | 22 | run__p b1=: f1'' NB. run commands to draw thick red line 23 | b1 NB. list of ints - command count args ... 24 | NB. 1st int is for command beginPath and it has 0 args 25 | NB. 3rd int is for command lineWidth and it has 1 arg which is 1 26 | 27 | refresh__p=: jsxarg b1 NB. 28 | 29 | NB. common setup: pen width; pen color ; brush color 30 | common=: 3 : 0 31 | 'a b c'=. y 32 | jsxnew'' 33 | jscbeginPath'' 34 | jsclineWidth a 35 | jscstrokeStyle jsxucp b 36 | jscfillStyle jsxucp c 37 | ) 38 | 39 | f2=: 3 : 0 40 | common 2;'blue';'blue' 41 | jscmoveTo 0,jsxh 42 | jsclineTo jsxw,0 43 | jscstroke'' 44 | jsxnew'' 45 | ) 46 | run__p b2=: f2'' NB. draw thin blue line from lower left to upper right 47 | 48 | NB.spxaction: mouse event handlers - click mouse down, move, and mouse up 49 | 50 | f3=: 3 : 0 51 | common 3;'rgb(0,255,0)';'yellow' NB. any css color string is valid 52 | jscrect 20 20 50 20 53 | jscfill'' 54 | jscstroke'' 55 | jsxnew'' 56 | ) 57 | run__p b3=: f3'' NB. draw rectangle 58 | 59 | f4=: 3 : 0 60 | common 4;'pink';'aqua' 61 | jscfont jsxucp '80px Arial' 62 | jscfillText 20 150, jsxucp 'hello Ü' 63 | jsxnew'' 64 | ) 65 | run__p b4=: f4'' NB. draw text 66 | 67 | f5=: 3 : 0 68 | common 3;'orange';'aqua' 69 | jscellipse 150 75 50 75 ,(jsxradian 1 0 ,2*o.1), 1 70 | jscstroke'' 71 | jscbeginPath'' 72 | jscellipse 60 200 50 75 ,(jsxradian 0 0 , o.1),0 73 | jscfill'' 74 | jscstroke'' 75 | jsxnew'' 76 | ) 77 | run__p b5=: f5'' NB. ellipse 78 | 79 | f6=: 3 : 0 80 | jscbeginPath'' 81 | r=. 0 , 0.5*o.1 82 | 83 | jscbeginPath'' 84 | jscmoveTo 200 200 85 | jscarc 200 200 50 ,(jsxradian r),0 86 | jscfillStyle jsxucp 'green' 87 | jscfill'' 88 | 89 | jscbeginPath'' 90 | jscmoveTo 200 200 91 | jscarc 200 200 50 ,(jsxradian r+0.5*o.1),0 92 | jscfillStyle jsxucp 'red' 93 | jscfill'' 94 | 95 | jscbeginPath'' 96 | jscmoveTo 200 200 97 | jscarc 200 200 50 ,(jsxradian r+o.1),0 98 | jscfillStyle jsxucp'yellow' 99 | jscfill'' 100 | 101 | jscbeginPath'' 102 | jscmoveTo 200 200 103 | jscarc 200 200 50 ,(jsxradian r+1.5*o.1),0 104 | jscfillStyle jsxucp'blue' 105 | jscfill'' 106 | 107 | jsxnew'' 108 | ) 109 | run__p b6=: f6'' NB. pie quarters 110 | 111 | f7=: 3 : 0 112 | jscbeginPath'' 113 | jsclineWidth 3 114 | jscstrokeStyle jsxucp'forestgreen' 115 | jsxlines ?20$300 116 | jsxnew'' 117 | ) 118 | run__p b7=: f7'' NB. line connecting random points 119 | 120 | fclear=: 3 : 0 121 | jsxnew'' 122 | jscbeginPath'' 123 | jscclearRect 0 0,jsxwh 124 | jsxnew'' 125 | ) 126 | run__p bclear=: fclear'' 127 | 128 | run__p b1,b2,b3,b4,b5,b6,b7 129 | 130 | f8=: 3 : 0 131 | d=. #:(~:/&.#:@, +:)^:(<32) 1 132 | jsxnew'' 133 | jscclearRect 0 0,jsxwh 134 | jscbeginPath'' 135 | jsxvm d 136 | jsxnew'' 137 | ) 138 | 139 | run__p b8=: f8'' NB. simple viewmat - Sierpinski triangle 140 | -------------------------------------------------------------------------------- /spx/chart.ijt: -------------------------------------------------------------------------------- 1 | jhslinkurl'www.chartjs.org' NB. link to home page 2 | 3 | jcjs'reset' 4 | jcjs'data';>:5?20 5 | jcjs'labels';5 NB. a0,a1,a2,a3,a4 6 | jcjs'plot';10 10 600 600 7 | 8 | jcjs'add';'options.elements.point.radius 10' 9 | jcjs'update' 10 | 11 | jcjs'add';'options.elements.point.radius 1' 12 | jcjs'update' 13 | 14 | jcjs'data';5?5 15 | jcjs'update' 16 | 17 | jcjs'legend';'legend' 18 | jcjs'titles';'xaxis';'yaxis';'top of the chart' 19 | jcjs'update' 20 | 21 | jcjs'type';'bar' 22 | jcjs'update' 23 | 24 | jcjs'type';'pie' 25 | jcjs'update' 26 | 27 | jcjs'type';'doughnut' 28 | jcjs'update' 29 | 30 | jcjs'type';'polarArea' NB. note uppercase A 31 | jcjs'update' 32 | 33 | jcjs'type';'line' 34 | jcjs'update' 35 | 36 | jcjs'data';(<5?15),<5?15 37 | jcjs'update' 38 | 39 | jcjs'add';'data.datasets.1.label "bardata"' 40 | jcjs'add';'data.datasets.1.type "bar"' 41 | jcjs'update' 42 | 43 | jcjs'add';'options.animation.duration 2000' 44 | jcjs'update' 45 | 46 | 47 | 0 : 0 48 | press the 'show chart definition' button 49 | scroll down to the line with "grid" 50 | this line is in the dictionary at options.scales.x.grid 51 | the "grid":"color" value "rgba(0,0,0,0.1)" is not very visible 52 | the next step sets the value to "red" 53 | ) 54 | 55 | jcjs'add';'options.scales.x.grid.color "red"' 56 | jcjs'add';'options.scales.x.grid.lineWidth 5' 57 | jcjs'update' 58 | 59 | 0 : 0 60 | you can inspect the 'show chart config' display 61 | for values you can change 62 | 63 | or you can study the chartjs online documentation 64 | for far more customizations 65 | 66 | most settings are simple values such as a string in "s or a number 67 | you can also use more complicated values (dictionary or array) 68 | 69 | note: values set explicity override those set with a dictionary 70 | ) 71 | 72 | jcjs'add';'options.scales.y.grid {"color":"green","lineWidth":5}' 73 | jcjs'update' 74 | 75 | jcjs'get' NB. chart defition changes 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | jcjs'close' -------------------------------------------------------------------------------- /spx/overview.ijt: -------------------------------------------------------------------------------- 1 | 0 :0 2 | 6 minutes with this lab covers J programming mechanics with the JHS interface 3 | 4 | J coding is covered by other labs and resources referenced at the end 5 | 6 | ctrl+. (ctrl+dot) or menu bar ⇒ 7 | gives J next line from lab file 8 | 9 | do a lab advance now 10 | ) 11 | 12 | i. 5 NB. first 5 ints 13 | +/ i. 5 NB. sum over first 5 ints 14 | *: i. 5 NB. square first 5 ints 15 | 'reset' chart *: i. 100 16 | a=. 0.1 * i. 100 17 | s=. sin a 18 | c=. cos a 19 | sc=. s ,: c NB. sin and cosine values 20 | chart sc 21 | jcjs'legend';'sin';'cos';'+/' 22 | chart sc,+/sc,+/sc 23 | 24 | 0 : 0 25 | next line sets menu options 26 | suitable for this lab 27 | wrap - avoid horizontal scrolling 28 | term - edit frame shares this window 29 | column - window frames in a column 30 | ) 31 | jhsoption'wrap term column' 32 | 33 | 0 : 0 34 | this lab work well on a tablet 35 | especially with a real keyboard 36 | 37 | works on a phone but much 38 | easier if you are already familiar 39 | ) 40 | 41 | 0 : 0 42 | time to try your first input 43 | enter a line in the input box below 44 | e.g. sin 1 and press enter 45 | ) 46 | 47 | 0 : 0 48 | this pattern: 49 | read input 50 | evaluate 51 | print 52 | loop 53 | is a repl (read-eval-print-loop) 54 | 55 | this window is a J repl 56 | ) 57 | 58 | 0 : 0 59 | click ☰ (upper left corner) 60 | click outside menu to dismiss it 61 | ) 62 | 63 | 0 : 0 64 | if you are a J server guest you can learn more: 65 | ☰ then help then guest rules 66 | ☰.help.guest rules 67 | ☰.help.guest files 68 | ) 69 | 70 | 10?20 NB. 10 random from i.20 71 | 72 | 0 : 0 73 | want to run a line again? 74 | 75 | click the line above with 10?20 76 | press return to recall to input area 77 | press return again to run it 78 | ) 79 | 80 | 0 : 0 81 | recall previous inputs with: 82 | ctrl+shift+🠅 and ctrl+shift+🠧 83 | 84 | if you have a keyboard 85 | try it now to recall the 10?20 line 86 | and press enter to run it again 87 | ) 88 | 89 | 0 : 0 90 | ☰.inputs - list recent inputs 91 | lab lines are not treated as inputs 92 | so your list of input lines may be short 93 | (shortcut ☰.i) 94 | click one for and press enter to recall 95 | ) 96 | 97 | 0 : 0 98 | J script files (xxx.ijs) contain J code 99 | ) 100 | 101 | fin=: '~addons/ide/jhs/spx/overview_example.ijs' 102 | jpath fin NB. ~addons expands to J addons folder 103 | data=: fread fin NB. file read 104 | data 105 | fout=: '~temp/ovlab.ijs' NB. J temp folder 106 | data fwrite fout NB. data written to file 107 | load fout NB. load script to define crsum 108 | mat=: ?3 4$10 NB. random numbers from 3 by 4 matrix of 10s 109 | mat 110 | crsum mat NB. crsum adds row and col sums 111 | 112 | crsum NB. display defn 113 | 114 | 0 : 0 115 | name=: ... NB. global assignment 116 | name=. ... NB. local assigment - only for current definition 117 | 118 | crsum sentence: 119 | t=. y,+/y 120 | assigns the local name t 121 | ) 122 | 123 | t=: 123 124 | crsum mat 125 | t NB. global t is not changed by crsum local use 126 | 127 | erase'crsum' 128 | crsum mat NB. error 129 | load fout NB. load script again to define crsum 130 | crsum mat 131 | crsum 'asdf' NB. error 132 | 'reset' chart crsum mat 133 | 134 | 0 : 0 135 | ovlab.ijs also defines verb hypot 136 | ) 137 | 138 | hypot 3 4 139 | hypot NB. square root of sum over squares of arg 140 | 141 | 0 : 0 142 | you can also show latex or html or anything that can show in a browser 143 | ) 144 | jhlatex_jhs_ '\sqrt{y_0^2 + y_1^2}' 145 | jhtml'
    %: +/ *: y
    ' 146 | 147 | names'' NB. list of defined names 148 | 149 | 0 : 0 150 | browsers appropriate most keyboard shortcuts 151 | JHS uses: ctrl+. for lab advance 152 | ctrl+, to show ☰ 153 | 154 | editor uses ctrl+zxcvy and a few more 155 | ) 156 | 157 | 0 : 0 158 | next step opens file ovlab.ijs for editing 159 | 160 | focus will be in the edit frame 161 | click term input area to focus the term frame 162 | ) 163 | 164 | edit fout 165 | 166 | 0 : 0 167 | try the following: 168 | in edit frame: 169 | ☰.readonly - allow changes 170 | add new first line: 171 | d=: %: 5 172 | ☰.load - save and load the script 173 | ) 174 | d 175 | 176 | 0 : 0 177 | in edit frame: 178 | ☰.close 179 | ) 180 | 181 | NB. next advamce will sleep for 3 seconds 182 | jxsleep 3 NB. sleep for 3 seconds 183 | 184 | 0 : 0 185 | what if you asked for a long sleep by mistake or your code had an infinite loop? 186 | 187 | you need to signal break to get back control 188 | ) 189 | 190 | 0 : 0 191 | ☰.break 192 | no effect if nothing is running 193 | 194 | if J is running locally: signal break with 195 | ctrl+c in window that started your server 196 | 197 | it takes 2 breaks to break a sleep 198 | and one to break a loop 199 | 200 | next step will sleep for 15 seconds 201 | use ☰.break twice 202 | or 203 | ctrl+c twice in your JHS server 204 | to break out of the sleep 205 | ) 206 | 207 | 0 : 0 208 | enter the following line in the input area: 209 | jxsleep 15 210 | 211 | and then signal 2 breaks with ☰.break or ctrl+c 212 | ) 213 | 214 | 0 : 0 215 | explore the help docs 216 | ☰.help 217 | ) 218 | 219 | 0 : 0 220 | JHS is a browser interface to J 221 | 222 | A J installation also includes: 223 | Jqt - an interface with Qt 224 | jconsole - terminal repl interface 225 | ) 226 | 227 | 0 : 0 228 | this is the end of the overview 229 | 230 | recall and run lines from the following: 231 | jhshelp'' 232 | 233 | or try one of the tours listed: 234 | jhshelp 'tour' 235 | 236 | or try (following jhshelp'lab'->jhslab'core') 237 | jhsrun'A J Introduction' 238 | 239 | or browse the wiki: 240 | jhshelp'wiki' 241 | ) 242 | -------------------------------------------------------------------------------- /spx/overview_example.ijs: -------------------------------------------------------------------------------- 1 | NB. crsum ?2 3$10 2 | NB. add row and col sums to matrix 3 | crsum=: {{ 4 | t=. y,+/y 5 | t,.+/"1 t 6 | }} 7 | 8 | NB. square root of sum over squares of arg 9 | hypot=: {{ %: +/ *: y }} -------------------------------------------------------------------------------- /spx/plot.ijt: -------------------------------------------------------------------------------- 1 | 0 : 0 2 | there are several ways to visualize data: 3 | viewmat - table values as colors 4 | plot - J native plot 5 | jd3 - javascript 6 | gnuplot - C standalone utility 7 | gc - Google Charts web service 8 | webgl - javascript 3D interactive graphics 9 | 10 | plots can: 11 | show inline in jijx session 12 | show in tabs (new or reused) 13 | show in apps with other html elements 14 | write a file in a common format (png/html/...) 15 | 16 | run next line to open this script 17 | edit'~addons/ide/jhs/spx/plot.ijt' 18 | 19 | there are independent sections - you can skip around 20 | ) 21 | spx':' NB. run a line to skip to corresponding section 22 | 23 | NB.spxsection:viewmat 24 | require'viewmat' 25 | viewmat 50 50$ 1 2 1 26 | viewmat */~ i:9 27 | viewmat #:(~:/&.#:@, +:)^:(<32) 1 28 | jhslinkurl'code.jsoftware.com/wiki/Essays/Base_Spectrum' NB. link to Essay using viewmat 29 | 30 | NB.spxsection:plot 31 | jhslinkurl'code.jsoftware.com/wiki/Plot' NB. link to wiki plot doc 32 | require'plot' 33 | plotdef 'jijx';'plot';200 100 NB. attributes for subsequent plots 34 | plot ?10$100 35 | plot ?2 10$100 36 | plotdef 'jijx';'plot';400 200 37 | plot ?2 10$100 38 | plotdef 'show';'plot';600 400 NB. show in tab named plot 39 | plot ?2 10$100 40 | load '~Demos/wdplot/plotdemos.ijs' NB. more than 50 demos 41 | >5{.PLOTNAMES_jdplot_ NB. names of first 5 demos 42 | plotdef 'jijx';'plot';600 400 43 | plotdemos 0 44 | plotdef 'show';'plot';600 400 NB. show in tab named plot 45 | plotdemos 1 46 | plotdemos 20 47 | plotdemos 30 48 | plotdef 'link';'plot';600 450 NB. link to plot 49 | plotdemos 50 50 | plotdef 'none';'plot';600 300 NB. create ~temp/plot.html 51 | plotdemos 25 52 | 'plot' jhsshow '~temp/plot.html' NB. show plot in window plot 53 | plotdef 'jijx';'';400 200 54 | plotdemos 54 55 | 56 | NB.spxsection:jd3 57 | jhslinkurl'www.d3js.org' NB. link to D3 home page 58 | require'~addons/ide/jhs/page/jd3.ijs' NB. create jd3 locale 59 | jd3'help' 60 | jd3'reset;type line;title My Data;legend "line one","line two","line three"' 61 | 'jd3;10 10'jpage jd3x;?3 4$100 62 | 63 | NB.spxsection:gnuplot 64 | jhslinkurl'www.gnuplot.info' 65 | 0 : 0 66 | these examples fail if gnuplot is not installed 67 | linux installs with something like: 68 | sudo apt-get install gnuplot 69 | see website for info for other systems 70 | 71 | note: tab name (reuse a tab) is not the tab title 72 | ) 73 | require'~addons/ide/jhs/gnuplot.ijs' 74 | 75 | gpd0=: 4 : 0 NB. verb with gnuplot commands 76 | gpinit'' 77 | gpset y 78 | gpset 'grid' 79 | gpset 'title "sin(exp) vs cos(exp)"' 80 | gpset 'xlabel "x-axis"' 81 | gpset 'ylabel "y-axis"' 82 | gpsetwith 'with lines title "sin(exp)", with lines title "cos(exp)"' 83 | x gpplot (;sin@^,:cos@^) steps _1 2 100 84 | ) 85 | 86 | small=: ' size 400,200 ' 87 | big=: ' size 600,400 ' 88 | 89 | 'd0' gpd0 term_png,small NB. create png file 90 | jhspng 'plot' gpd0 term_png,small NB. display in session 91 | 'plot'jhsshow 'plot' gpd0 term_png,small NB. show in tab named plot 92 | jhslink 'plot' gpd0 term_png,small NB. link to file 93 | 94 | 'd0' gpd0 term_canvas,small NB. create html file 95 | 'plot'jhsshow 'd2' gpd0 term_canvas,small NB. show file in tab named plot 96 | jhslink 'd1' gpd0 term_canvas,small NB. link to file 97 | NB. currently gnuplot canvas is standalone and can not be displayed in jijx 98 | 99 | gpd1=: 4 : 0 100 | wiggle=. 4 101 | points=. 200 102 | X=. (3 % <:points) * i.points 103 | fn=. +/@((0.9&^) * cos@((3&^ * (+/&X))))@i. 104 | XY=. fn wiggle 105 | gpinit'' 106 | gpset y 107 | gpsetwith 'with lines' 108 | x gpplot X;XY 109 | ) 110 | jhspng 'plot' gpd1 term_png,small NB. display in session 111 | 112 | gpd2=: 4 : 0 113 | xd=. range _3 3 0.2 114 | yd=. range _3 3 0.2 115 | zd=. sin xd +/ sin yd 116 | CP=. xd;yd;zd 117 | gpinit'' 118 | gpset y 119 | gpset 'title "sin(x+sin(y))"' 120 | gpset 'parametric' 121 | gpsetwith 'with lines' 122 | gpsetsurface 1 123 | x gpplot CP 124 | ) 125 | jhspng 'plot' gpd2 term_png,big NB. display in session 126 | 127 | gpd3=: 4 : 0 128 | xd=. range _3 3 0.1 129 | yd=. range _3 3 0.1 130 | SP=. xd;yd;(sin xd) */ sin yd 131 | gpinit'' 132 | gpset y 133 | gpset 'title "sin(x)*sin(y)) contour plot"' 134 | gpset 'parametric;contour;cntrparam levels 20;view 0,0,1;nosurface' 135 | gpsetwith 'with lines' 136 | gpsetsurface 1 137 | x gpplot SP NB. surface plot 138 | ) 139 | jhspng 'plot' gpd3 term_png,big NB. display in session 140 | 141 | gpd4=: 4 : 0 142 | gpinit'' 143 | gpset y 144 | gpsetwith'with lines' 145 | x gpplot 10?10 146 | ) 147 | jhspng 'plot' gpd4 term_png,small NB. display in session 148 | 149 | NB.spxsection:gc 150 | 0 : 0 151 | Google killed the service used by this facility in 2019 152 | 153 | this could be reworked to use the new Google Charts service 154 | https://en.wikipedia.org/wiki/Google_Charts 155 | 156 | this section is left as a place holder 157 | 158 | http://code.google.com/apis/chart/ 159 | load'~addons/ide/jhs/jgcp.ijs' 160 | jgc'help' NB. plot info 161 | jgcx'' NB. examples 162 | NB. study the code that generates the charts 163 | NB. note how reset clears state and additional commands add to state 164 | ) 165 | 166 | NB.spxsection:webgl 167 | jhsget'demo/jdemo12' 168 | -------------------------------------------------------------------------------- /spx/spx.ijt: -------------------------------------------------------------------------------- 1 | 0 : 0 2 | spx does managed execution of any script 3 | you can step through or jump around 4 | 5 | this script demonstrates spx features 6 | tutorial scripts can use them to advantage 7 | they are not required and spx can manage any script 8 | 9 | next step opens this script - put it in another window 10 | so you can read along as spx steps through 11 | ) 12 | 13 | edit'~addons/ide/jhs/spx/spx.ijt' 14 | 15 | require'plot' 16 | 17 | NB. : to ) lines display in a single advance 18 | f=: 3 : 0 19 | *:y 20 | ) 21 | 22 | 0 : 0 23 | 0 : 0 by itself displays 24 | the lines as comments 25 | ) 26 | 27 | 0 : 0 28 | after any step you can experiment 29 | enter a sentence using verb f 30 | ) 31 | 32 | spx 0 NB. echo spx status 33 | 34 | NB. spx 19 will execute line 19 35 | NB. spx 1 19 will execute lines 1 to 19 36 | 37 | NB.spxaction: this line displays in red as an action required line 38 | 39 | NB.spxhr: 40 | NB. previous line displays as horizontal rule 41 | NB. sequential lines starting with NB. 42 | NB. display in a single advance 43 | 44 | 0 : 0 45 | =: replaces =. so defns are global 46 | next advance is =: although the script line is =. 47 | ) 48 | a=. 5 49 | 50 | NB.spxhtml:
    html, latex, and plots can be included
    51 | 52 | NB.spxlatex:1+sin(x) 53 | 54 | NB.spxlatex:^2+y^2+z^2 55 | 56 | NB.spxlatex:\frac{1+sin(x)}{x^3} 57 | 58 | plot 20?20 59 | 60 | 0 : 0 61 | often scripts need to be stepped through in order 62 | tutorial scripts can have independent sections 63 | and you can jump to a section 64 | ) 65 | 66 | NB.spxsection:aaa 67 | a=. i.5 68 | 69 | NB.spxsection:bbb 70 | a=. i.23 71 | 72 | spx':' NB. display sections 73 | 74 | NB. run 1 of the previous lines to jump to that section 75 | 76 | NB. noun spxhelp has spx info 77 | spxhelp 78 | -------------------------------------------------------------------------------- /src/gif/newfile.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jsoftware/ide_jhs/b329205d2e4c9673164a200e11ca1252c908f3ed/src/gif/newfile.gif -------------------------------------------------------------------------------- /src/gif/oldfile.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jsoftware/ide_jhs/b329205d2e4c9673164a200e11ca1252c908f3ed/src/gif/oldfile.gif -------------------------------------------------------------------------------- /test/chkrad.ijs: -------------------------------------------------------------------------------- 1 | coclass'chkrad' 2 | coinsert'jhs' 3 | 4 | HBS=: 0 : 0 5 | 'get' jhb 'get' 6 | 'abc' jhchk 'ev_abc_click';0 7 | 'def' jhchk 'ev_jhchk_click';0 8 | 'ghi' jhchk 'ev_ghi_click';0 9 | 'jjj' jhchk 'only 1 arg' 10 | 'kkk' jhchk 'kkk';1;'ny' 11 | 'q*12'jhchk 'asdf' 12 | jhbr 13 | 'xr1' jhrad 'a00';0;'r1' 14 | 'xr2' jhrad 'a11';1;'r1' 15 | 'xr3' jhrad 'a22';0;'r1' 16 | jhbr NB. old style that need arg adjust 17 | 'r0' jhrad 'r0 Aa' ;1;'rg1' 18 | 'r1' jhrad 'r1 /...' ;0;'rg1' 19 | 'r2' jhrad 'r2 lines';0;'rg1' 20 | 'getchk' jhb 'get this button';0 21 | 'fubar' jhb 'plain no jdoajax' 22 | ) 23 | 24 | create=: 3 : 0 25 | 'test' jhrx (getcss''),(getjs''),gethbs'' 26 | ) 27 | 28 | NB. called when browser gets this page 29 | jev_get=: create 30 | 31 | ev_get_click=: 3 : 0 32 | echo NV 33 | jhrajax'' 34 | ) 35 | 36 | ev_getchk_click=: 3 : 0 37 | echo NV 38 | jhrajax'' 39 | ) 40 | 41 | CSS=: '' 42 | 43 | JS=: 0 : 0 44 | 45 | function ev_get_click(id){jdoajax(["abc","xr1"]);} 46 | 47 | function ev_get_click_ajax(){;} 48 | 49 | 50 | function ev_abc_click(id){jflipchk(id);} 51 | 52 | function ev_ghi_click(id){jflipchk(id);} // ghi*foo 53 | 54 | function ev_qqq_click(){alert([...document.querySelectorAll('[id]')].map(e => e.id).join(", "));jdoajax([]);} 55 | function ev_qqq_click_ajax(){;}; 56 | 57 | function ev_r0_click(){jsetchk(jform.jid.value,1);} /* jform.jid.value is r0 */ 58 | function ev_r1_click(){jsetchk(jform.jid.value,1);} 59 | function ev_r2_click(){jsetchk(jform.jid.value,1);} 60 | 61 | function ev_getchk_click(){ 62 | id= "r0"; 63 | alert('getchk'); 64 | alert(jbyid(id).getAttribute("data-jhscheck")); 65 | alert(jgetchk(id)); 66 | } 67 | 68 | function ev_getchk_click_ajax(){alert('ajax');} 69 | 70 | function ev_fubar_click(){;} 71 | ) 72 | 73 | -------------------------------------------------------------------------------- /test/handlers.ijs: -------------------------------------------------------------------------------- 1 | coclass'handlers' 2 | coinsert'jhs' 3 | 4 | run__=: 'handlers'&jpage 5 | ld__=: [: load '~addons/ide/jhs/' , ] 6 | 7 | NB. test html jh... event handlers 8 | 9 | section=: 3 : 'jhhr,'''',y,'''',jhbr' 10 | 11 | HBS=: 0 : 0 12 | jhclose'' 13 | 'clr' jhb'clr' 14 | 'jstext' jhtext'';20 15 | 'jtext' jhtext'';20 16 | section'jhb buttons' 17 | 'b01' jhb 'b01 js only' 18 | 'b02' jhb 'b02 js jdoajax jhrajax' 19 | 'b03' jhb 'b03 js jdoajax jhrjson' 20 | 'b04' jhb 'b04 js jdoajax jhrcmds' 21 | 'b05' jhb 'b05 j only jhrcmds' 22 | 'b09' jhb 'b09bbb,def' 23 | 'b10' jhb 'b10cbbbdef';'jhb';'=' 24 | 'b11*1' jhb 'b11*1' 25 | 'b11*2' jhb 'b11*2' 26 | 'b12' jhb 'b12 no js and ~ option';'';'~' 27 | section'jhb with errors' 28 | 'b06' jhb 'b06 jev not defined' 29 | 'b07' jhb 'b07 jev error' 30 | 'b08' jhb 'b08 jev no ajax response' 31 | section'jhchk/jhrad with default js calling j handler' 32 | 'cx01' jhchk 'cx01' 33 | 'cx02' jhchk 'cxo2' 34 | 'rx01' jhrad 'rx01';0;'rd0' 35 | 'rx02' jhrad 'rx02';1;'rd0' 36 | section'jhchk/jhrad without handlers ~ option' 37 | 'c01' jhchk 'c01';0;'';'';'~' NB. 'jhchk';default_marks;'~' 38 | 'c02' jhchk 'co2';0;'';'';'~' 39 | 'r01' jhrad 'rad1';'r01';0;'';'';'~' NB. 'jhrad';default_marks;'~' 40 | 'r02' jhrad 'rad1';'ro2';1;'';'';'~' 41 | section'jhab' 42 | 'a01' jhab 'a01' 43 | 'a02' jhab 'a02' 44 | 'a03' jhab 'abc' 45 | section'jhselect' 46 | jhhr 47 | 's01' jhselect ('s01 abc';'dBc';'ghi');0;0 48 | 's02' jhselect ('s02 123';'456';'789');0;0;'';'~' NB. size;selected;class;options 49 | section'jhtext' 50 | 't01' jhtext 't01 handler' 51 | 't02' jhtext 't02 "';'';'';'~' NB. size;class;'~' 52 | 'b30' jhb'b30' 53 | 'p01' jhpassword '' 54 | 'p02' jhpassword '';'';'';'~' NB. size;class;'~' 55 | section'jhtable' 56 | 'table' jhtable'' 57 | jhtr 'longer label:' ; ('tab00'jhtext'') ; 'a:' ; 'tab01'jhtext'' 58 | jhtr 'medium:' ; 'plain text' ; 'bbbb:' ; 'tab11'jhtext'' 59 | jhtr 'short:' ; 'tab20'jhtext'' 60 | jhtr '' ; '' ; 'dd:' ; 't31'jhb'button' 61 | jhtablez 62 | 63 | 64 | 'xxx'jhb'xxx' 65 | ) 66 | 67 | ev_xxx_click=: 3 : 0 68 | t=. pageopenargs'jijs?jwid=~temp/a.txt' 69 | jhrcmds'pageopen *',}:;t,each',' 70 | ) 71 | 72 | ev_create=: 3 : 0 73 | jhcmds'' 74 | ) 75 | 76 | NB. jev_get=: jpageget NB. called by browser to load page 77 | 78 | cmds=: {{ 79 | q__=:NV 80 | t=. 'set jtext *',getv'jmid' 81 | if. 0~:#getv'jstext' do. t=. t;'set jstext *' end. 82 | jhrcmds t 83 | }} 84 | 85 | ev_b02_click=: {{ jhrajax 'b02 ajax''"x' }} 86 | ev_b03_click=: {{ jhrjson 'text';'b03 json' }} 87 | ev_b04_click=: cmds 88 | ev_b05_click=: cmds 89 | 90 | ev_cx01_click=: cmds 91 | ev_cx02_click=: cmds 92 | ev_rx01_click=: cmds 93 | ev_rx02_click=: cmds 94 | 95 | ev_b07_click=: {{ +a.}} 96 | ev_b08_click=: {{ a=. 5 }} 97 | 98 | ev_s01_change=: cmds 99 | 100 | ev_t01_enter=: cmds 101 | ev_p01_enter=: cmds 102 | 103 | ev_a01_click=: cmds 104 | ev_a02_click=: cmds 105 | ev_a03_click=: cmds 106 | 107 | CSS=: 0 : 0 108 | table, th, td {border: 1px solid;} 109 | ) 110 | 111 | NB. javascript code - initialize page and handle events 112 | JS=: 0 : 0 113 | 114 | function ev_clr_click(){clr();} 115 | 116 | function clr(){jset('jstext','');jset('jtext','');} 117 | function set(){clr();jset('jstext',jform.jid.value);} 118 | function setx(){set();jdoajax([]);} 119 | 120 | function xxxset(){clr();jset('jstext',jform.jid.value);} 121 | 122 | function ev_b01_click(){xxxset();} 123 | 124 | function ev_b02_click(){setx();} 125 | function ev_b02_click_ajax(ts){jset('jtext',ts[0]);} 126 | 127 | function ev_b03_click(){setx();} 128 | function ev_b03_click_ajax_json(t){jset('jtext',t.text);} 129 | 130 | function ev_b04_click(){setx();} // ajaxcmds runs automatically 131 | 132 | function ev_b09_click(){set();} 133 | function ev_b10_click(){set();} 134 | function ev_b11_click(){set();} 135 | 136 | ) 137 | -------------------------------------------------------------------------------- /test/jdemo17.ijs: -------------------------------------------------------------------------------- 1 | coclass'jdemo17' 2 | coinsert'jhs' 3 | NB. play with hamburger menu 4 | 5 | NB. sentences that define html elements 6 | HBS=: 0 : 0 7 | jhmenu'' 8 | 9 | 'menu0' jhmenugroup'' NB. '☰';'' 10 | jhmenulink 'apps';'apps galore' 11 | 'tools' jhmenuitem 'tools run' 12 | jhmenulink 'view';'view stuff' 13 | jhmenulink 'tour';'tour stuff' 14 | jhmenulink 'help';'help stuff' 15 | 16 | 'boo' jhb 'boo' 17 | jhbr 18 | 'coo' jhb 'coo' 19 | jhbr 20 | 'doo' jhb 'doo' 21 | jhbr 22 | 23 | 24 | 'quit' jhmenuitem 'quit' 25 | jhmenugroupz'' 26 | 27 | 'apps' jhmenugroup'' 28 | 'file' jhmenuitem'file' 29 | jhmenugroupz'' 30 | 31 | 'view' jhmenugroup'' 32 | jhmenulink 'foo';'foo above' 33 | 'wclear'jhmenuitem'clear window' 34 | 'rclear'jhmenuitem'clear refresh' 35 | jhmenugroupz'' 36 | 37 | 'foo' jhmenugroup'foo above';'view' 38 | 'funny' jhmenuitem'funny' 39 | jhmenugroupz'' 40 | 41 | ) 42 | 43 | NB. J code - initialize and handle events 44 | create=: 3 : 0 NB. called by page or browser to initialize locale 45 | t=. y jpagedefault 'this is default data' 46 | 'must be text'assert 2=3!:0 t 47 | jsdata=: 'ta';t 48 | ) 49 | 50 | jev_get=: jpageget NB. called by browser to load page 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /test/open.ijs: -------------------------------------------------------------------------------- 1 | NB. test open/jpage tab/window/jterm 2 | 3 | uqs=: uqs_jhs_ 4 | 5 | opentest=: 3 : 0 6 | 'tab' open_jhs_ 'jfile',uqs'' 7 | 10 10 200 200 open_jhs_ 'jfile',uqs'' 8 | 'jterm' open_jhs_ 'jfile',uqs'' 9 | echo'should have opened jfile page as window/tab/jterm' 10 | ) 11 | 12 | load'~addons/ide/jhs/app/app07.ijs' 13 | 14 | jpagetest=: 3 : 0 15 | t=. #conl 1 16 | 'app07;tab' jpage'' 17 | 'app07;jterm' jpage'' 18 | 'app07;10 10' jpage'' 19 | 'did not create 3 objects'assert 3=t-~#conl 1 20 | echo'should have opened app07 3 times' 21 | ) -------------------------------------------------------------------------------- /test/raw.ijs: -------------------------------------------------------------------------------- 1 | coclass'raw' 2 | coinsert'jhs' 3 | 4 | HBS=: 0 : 0 5 | 'get' jhb 'get' 6 | NB. 't1' jhtext 'adsf';20 7 | ' style="color:red;" placeholder="comments" ' jhfix 't1'jhtext 'adsf';20 8 | 't2' jhtext 'qwer';10 9 | ) 10 | 11 | NB. ' style="color:red;" placeholder="comments" ' jhfix 't1'jhtext 'adsf';20 12 | 13 | 14 | create=: 3 : 0 15 | 'raw' jhrx (getcss''),(getjs''),gethbs'' 16 | ) 17 | 18 | NB. called when browser gets this page 19 | jev_get=: create 20 | 21 | ev_get_click=: 3 : 0 22 | echo NV 23 | 't1 t2'=. getvs't1 t2' 24 | jhrcmds ('set t1 value *',8 u:|.7 u: t1);'set t2 value *',8 u:|.7 u: t2 25 | ) 26 | 27 | ev_t1_enter=: ev_t2_enter=: ev_get_click 28 | 29 | jhfix_jhs_=: 4 : 0 30 | i=. y i.'>' 31 | (i{.y),x,i}.y 32 | ) 33 | 34 | CSS=: '' 35 | 36 | JS=: '' 37 | -------------------------------------------------------------------------------- /test/select_widget.ijs: -------------------------------------------------------------------------------- 1 | coclass'testapp01' 2 | coinsert'jhs' 3 | 4 | 0 : 0 5 | app (browser page) with a few hmtl elements and event handlers 6 | ) 7 | 8 | manapp=: 'jpage y must be ''''' NB. doc jpage y arg 9 | 10 | 11 | NB. J lines run in jhs locale that define html for the page 12 | HBS=: 0 : 0 13 | jhclose '' NB. menu with close 14 | 'title' jhh1 'overview' 15 | 'b1' jhb 'button-one' 16 | jhbr 17 | 't1' jhtext '' 18 | jhbr 19 | 20 | '
    ' 21 | 'a1' jhb 'a1' 22 | jhbr 23 | 'a2' jhb 'a2' 24 | jhbr 25 | 'a3' jhb 'a3' 26 | '
    ' 27 | 28 | '
    ' 29 | ) 30 | 31 | NB. jpage (or url) calls to init page for browser 32 | ev_create=: 3 : 0 33 | manapp assert ''-:y 34 | jhcmds '' 35 | ) 36 | 37 | cnt=: 0 38 | 39 | NB. click b1 -> ev_b1_click -> jhrcmds returns cmd to browser -> browser runs cmd 40 | ev_b1_click=: {{ 41 | q__=: NV 42 | jhrcmds 'set t1 *b1 clicked: ',":cnt=: cnt+1 43 | }} 44 | 45 | ev_a1_click=: {{ 46 | q__=: NV 47 | jhrcmds 'set t1 *a1 clicked: ',":cnt=: cnt+1 48 | }} 49 | 50 | 51 | ev_a2_click=: {{ 52 | q__=: NV 53 | jhrcmds 'set t1 *a2 clicked: ',":cnt=: cnt+1 54 | }} 55 | 56 | ev_za1_click=: {{ 57 | q__=: NV 58 | jhrcmds 'set t1 *za1 clicked: ',":cnt=: cnt+1 59 | }} 60 | 61 | ev_za2_click=: {{ 62 | q__=: NV 63 | jhrcmds 'set t1 *za2 clicked: ',":cnt=: cnt+1 64 | }} 65 | 66 | 67 | 68 | CSS=: 0 : 0 69 | .highlight { background-color:#ff0; } 70 | ) 71 | 72 | JS=: 0 : 0 73 | 74 | function ev_body_load(){ 75 | 76 | jbyid('a1').focus(); 77 | 78 | var li= jbyid("select").children; 79 | var liz= []; 80 | for (var i= 0 ; i is selected 88 | var currentLI = 0; 89 | 90 | // Initialize first li as the selected (focused) one: 91 | li[currentLI].classList.add("highlight"); 92 | 93 | 94 | // Set up a key event handler for the document 95 | jbyid("select").addEventListener("keydown", function(event){ 96 | 97 | // Check for up/down key presses 98 | switch(event.keyCode){ 99 | 100 | case 38: // Up arrow 101 | // Remove the highlighting from the previous element 102 | li[currentLI].classList.remove("highlight"); 103 | 104 | currentLI = currentLI > 0 ? --currentLI : 0; // Decrease the counter 105 | li[currentLI].classList.add("highlight"); // Highlight the new element 106 | li[currentLI].focus(); 107 | break; 108 | case 40: // Down arrow 109 | // Remove the highlighting from the previous element 110 | li[currentLI].classList.remove("highlight"); 111 | 112 | currentLI = currentLI < li.length-1 ? ++currentLI : li.length-1; // Increase counter 113 | li[currentLI].classList.add("highlight"); // Highlight the new element 114 | li[currentLI].focus(); 115 | break; 116 | } 117 | // return false; ? 118 | }); 119 | 120 | } 121 | 122 | ) 123 | -------------------------------------------------------------------------------- /test/test_select.ijs: -------------------------------------------------------------------------------- 1 | coclass'testselect' 2 | coinsert'jhs' 3 | 4 | 5 | NB. J lines run in jhs locale that define html for the page 6 | HBS=: 0 : 0 7 | jhclose '' NB. menu with close 8 | 'click' jhselect('abc';'def';'ghi');10;1 9 | 'change' jhselect('123';'234';'345');10;1;'';'~' 10 | 'both' jhselect('b1';'b2';'b3');10;1 11 | 't1' jhtext '' NB. text field 12 | ) 13 | 14 | NB. jpage (or url) calls to init page for browser 15 | ev_create=: 3 : 0 16 | jhcmds '' 17 | ) 18 | 19 | NB. click b1 -> ev_b1_click -> jhrcmds returns cmd to browser -> browser runs cmd 20 | ev_b1_click=: {{ jhrcmds 'set t1 *b1 clicked' }} 21 | 22 | NB. enter in t1 -> ev_t1_enter -> jhrcmds returns cmd to browser -> browser runs cmd 23 | ev_t1_enter=: {{ jhrcmds 'set t1 *enter in t1' }} 24 | -------------------------------------------------------------------------------- /vocabhelp.ijs: -------------------------------------------------------------------------------- 1 | coclass'jhs' 2 | 3 | 0 : 0 4 | jhswiki'voc' NB. NuVoc vocabulary 5 | jhswiki'i.' NB. edit i. for others - click Dyad for x i. y 6 | jhswiki'if.' NB. control words 7 | jhswiki'!:' NB. foreigns 8 | jhswiki'12x' NB. constants 9 | jhswiki'a' NB. ancilliary 10 | jhswiki'std' NB. standard library 11 | jhswiki'rel' NB. J release notes 12 | jhswiki'JHS' NB. JHS info 13 | jhswiki'807' NB. 807 legacy html 14 | jhswiki'main' NB. main page 15 | ) 16 | 17 | NB. add label for each link 18 | wwwlinks=: <;._2 [ 0 : 0 19 | vocabulary https://code.jsoftware.com/wiki/NuVoc 20 | control structures https://code.jsoftware.com/wiki/Vocabulary/ControlStructures 21 | foreigns !: https://code.jsoftware.com/wiki/Vocabulary/Foreigns 22 | constants https://code.jsoftware.com/wiki/Vocabulary/Constants 23 | ancilliary https://code.jsoftware.com/wiki/NuVoc#bottomrefs 24 | standard library https://code.jsoftware.com/wiki/Standard_Library/Overview 25 | release notes https://code.jsoftware.com/wiki/System/ReleaseNotes 26 | JHS https://code.jsoftware.com/wiki/Guides/JHS 27 | 807 legacy html https://www.jsoftware.com/help/index.htm 28 | main page https://code.jsoftware.com/wiki/Main_Page 29 | ) 30 | 31 | links=: 3 : 0 32 | t=. '
    Jsoftware www/wiki links:
    ' 33 | for_n. wwwlinks do. 34 | a=. ;n 35 | i=. a i: ' ' 36 | b=. deb i}.a 37 | a=. deb i{.a 38 | t=. t,LF,'' 39 | end. 40 | t=. t,LF,'
    ' 41 | ) 42 | 43 | NB. borrows from ide/qt/help.ijs 44 | 45 | jhsvocab=: 3 : 0 46 | top=. {.;:y 47 | first=. {.;top 48 | last=. {:;top 49 | b=. 'https://code.jsoftware.com/wiki/Vocabulary' 50 | a=. ;top 51 | if. top e. DICTNV_jhs_ do. t=. b,'/',>DICTNVX {~ DICTNV i.top 52 | elseif. (first e. Alpha_j_) *. '.'=last do. t=. b,'/ControlStructures' 53 | elseif. '!:'-:a do. t=. 'https://code.jsoftware.com/wiki/Vocabulary/Foreigns' 54 | elseif. (first='_')+.first e. Num_j_ do. t=. b,'/Constants' 55 | elseif. 'JHS'-:a do. t=. 'https://code.jsoftware.com/wiki/Guides/JHS' 56 | elseif. a-:,'a' do. t=. 'https://code.jsoftware.com/wiki/NuVoc','#bottomrefs' 57 | elseif. a-:'807' do. t=. 'https://www.jsoftware.com/help/index.htm' 58 | elseif. a-:'std' do. t=. 'https://code.jsoftware.com/wiki/Standard_Library/Overview' 59 | elseif. a-:'rel' do. t=. 'https://code.jsoftware.com/wiki/System/ReleaseNotes' 60 | elseif. a-:'main' do. t=. 'https://code.jsoftware.com/wiki/Main_Page' 61 | elseif. 1 do. t=. b 62 | end. 63 | jjs_jhs_ 'urlopen("',t,'");' 64 | i.0 0 65 | ) 66 | 67 | wiki_z_=: jhsvocab_jhs_ 68 | 69 | NB. banco replaced by !: 70 | j=. <;._2 (0 : 0) 71 | = eq 72 | =. eqdot 73 | =: eqco 74 | < lt 75 | <. ltdot 76 | <: ltco 77 | > gt 78 | >. gtdot 79 | >: gtco 80 | _ under 81 | _. underdot 82 | _: underco 83 | + plus 84 | +. plusdot 85 | +: plusco 86 | * star 87 | *. stardot 88 | *: starco 89 | - minus 90 | -. minusdot 91 | -: minusco 92 | % percent 93 | %. percentdot 94 | %: percentco 95 | ^ hat 96 | ^. hatdot 97 | ^: hatco 98 | $ dollar 99 | $. dollardot 100 | $: dollarco 101 | ~ tilde 102 | ~. tildedot 103 | ~: tildeco 104 | | bar 105 | |. bardot 106 | |: barco 107 | . dot 108 | .. dotdot 109 | .: dotco 110 | : co 111 | :. codot 112 | :: coco 113 | , comma 114 | ,. commadot 115 | ,: commaco 116 | ; semi 117 | ;. semidot 118 | ;: semico 119 | # number 120 | #. numberdot 121 | #: numberco 122 | ! bang 123 | !. bangdot 124 | !: Foreigns 125 | / slash 126 | /. slashdot 127 | /: slashco 128 | \ bslash 129 | \. bslashdot 130 | \: bslashco 131 | [ squarelf 132 | [: squarelfco 133 | ] squarert 134 | { curlylf 135 | {. curlylfdot 136 | {: curlylfco 137 | {:: curlylfcoco 138 | } curlyrt 139 | }. curlyrtdot 140 | }: curlyrtco 141 | " quote 142 | ". quotedot 143 | ": quoteco 144 | ` grave 145 | `: graveco 146 | @ at 147 | @. atdot 148 | @: atco 149 | & ampm 150 | &. ampdot 151 | &.: ampdotco 152 | &: ampco 153 | ? query 154 | ?. querydot 155 | 0: zeroco 156 | 1: zeroco 157 | 2: zeroco 158 | 3: zeroco 159 | 4: zeroco 160 | 5: zeroco 161 | 6: zeroco 162 | 7: zeroco 163 | 8: zeroco 164 | 9: zeroco 165 | _1: zeroco 166 | _2: zeroco 167 | _3: zeroco 168 | _4: zeroco 169 | _5: zeroco 170 | _6: zeroco 171 | _7: zeroco 172 | _8: zeroco 173 | _9: zeroco 174 | a. adot 175 | a: aco 176 | A. acapdot 177 | b. bdot 178 | C. ccapdot 179 | d. ddot 180 | D. dcapdot 181 | D: dcapco 182 | e. edot 183 | E. ecapdot 184 | f. fdot 185 | H. hcapdot 186 | i. idot 187 | i: ico 188 | I. icapdot 189 | j. jdot 190 | L. lcapdot 191 | L: lcapco 192 | M. mcapdot 193 | o. odot 194 | p. pdot 195 | p.. pdotdot 196 | p: pco 197 | q: qco 198 | r. rdot 199 | s: sco 200 | S: scapco 201 | t. tdot 202 | t: tco 203 | T. tcapdot 204 | u: uco 205 | x: xco 206 | ) 207 | 208 | n=. j i.&> ' ' 209 | DICTNV=: n {.each j 210 | DICTNVX=: (n+1) }.each j 211 | -------------------------------------------------------------------------------- /widget/jhot.ijs: -------------------------------------------------------------------------------- 1 | NB. handsontable - minimal 2 | NB. 'jhot'jpage'n__'[n__=: i.3 9 3 | 4 | coclass'jhot' 5 | coinsert'jhs' 6 | 7 | NB. jpage boilerplate from util.ijs 8 | 9 | NB. create=: 3 : 'setdata y~' 10 | ev_create=: 3 : 0 11 | if. y-:'' do. hotdata=: 2 2$'aa';'b';'c';'dd' end. 12 | t=. y jpagedefault 'hotdata' 13 | setdata t~ 14 | NB. fixjs'' should be done after options and data set 15 | ) 16 | 17 | NB. apply options and data to JS 18 | fixjs=: 3 : 0 19 | JS=: JS hrplc 'CUSTOM';CUSTOM hrplc 'OPTIONS DATA';options;jsfromtable data 20 | ) 21 | 22 | options=: 0 : 0 23 | data: data, 24 | minSpareRows: 1, 25 | minSpareCols: 1, 26 | contextMenu: true, 27 | undo: true, 28 | ) 29 | 30 | setdata=: 3 : 0 31 | 'bad data'assert (2=$$y)*.2>L.y 32 | option'type: ',;((0~:L.y)+.2=3!:0 y){'"numeric"';'"text"' 33 | data=: y 34 | ) 35 | 36 | NB. option'type:' - remove option 37 | NB. option'type:"numeric"' - new option 38 | option=: 3 : 0 39 | d=. <;.2 options 40 | a=. (>:;d i.each':'){.each d 41 | i=. >:y i.':' 42 | t=. dltb i{.y 43 | p=. dltb i}.y 44 | 'trailing , not allowed'assert ','~:{:p 45 | d=. ;(a~: 58 | $('#hot').handsontable({}); 59 | hot = $('#hot').handsontable("getInstance"); 60 | // hot.addHook('afterChange', function(){dirty= true;}); 61 | ) 62 | 63 | JS=: 0 : 0 NB. javascript 64 | function ev_body_load(){} 65 | 66 | ) 67 | -------------------------------------------------------------------------------- /widget/readme.txt: -------------------------------------------------------------------------------- 1 | this folder has widgets that can be added to app page 2 | jhot.ijs is handsontable and can be put in an iframe 3 | 4 | future additions will be jd3, chart, canvas 5 | --------------------------------------------------------------------------------