-
Notifications
You must be signed in to change notification settings - Fork 6
/
jdoc.ijs
81 lines (63 loc) · 2.24 KB
/
jdoc.ijs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
coclass'jdoc'
coinsert'jhs'
HBS=: 0 : 0
jhclose''
'title'jhtitle'JHS framework'
'jhs locale - utils - verbs/nouns/... for working with JHS'
jhbr
mfix '';'general utils';'~addons/ide/jhs/util.ijs'
mfix'html';'html elements';'~addons/ide/jhs/utilh.ijs'
mfix 'js';'javascript utils';'~addons/ide/jhs/utiljs.ijs'
)
CSS=: 0 : 0
form{margin:10px;}
div{font-family:<PC_FONTFIXED>;white-space:pre;padding-left:10px}
)
intro=: 0 : 0
An app (browser page using a JHS server) is started by:
'appname' jpage args
or
browse to url JHS-server:port/appname
A new temp (numbered) locale is created for the browser page.
Script that defines locale appname must be run first.
An app is defined by a script that defines nouns HBS, CSS, JS and event handler verbs.
HBS is a set of J lines that create html and the result of each line is added together
to create the html for the page.
HBS line: 'id' jhb 'click me'
runs in the jhs locale and you can see the html by running:
'id' jhb_jhs_ 'click me'
You can see the entire html result with:
gethbs_jhs_'...' NB. where ... is the locale wtih the app defintions
You do not need to do any javascript programming to build an app. Advanced apps can benefit from
javascript programming, but that is beyond the scope of this document.
This document covers apps that do not require any javascript programming.
Event handler example:
user clicks button with id 'one'
-> browser calls j verb ev_one_click
-> ev_one_click calls jhrcmds with list of browser commands
-> browser runs commands
best practice for building JHS app (page)
page is numbered locale with class in its path
meny has close )esc-q) to close page and free locale
app has 4 parts: HBS, CSS, J code, JS javascript code
HBS (html build sentences) definess app elements (buttons etc)
CSS (cascading style sheet) defines how elements look
J code defines event handlers (what happens when a button is clicked)
JS (javascript code) is not required except in advanced apps
browser passes event data to J in a dictionary (accessed by getv)
J passes cmds back to javascript as a JSON string
)
fix=: 3 : 0
t=. doc y
t=. t rplc '<';'<'
''jhdiv t
)
mfix=: 3 : 0
'doc header url'=. y
t=. ''jhline''
t=. t,''jhhn 3;header
t=. t,fix doc
)
jev_get=: 3 : 0
'jdoc'jhr''
)