Very neat! (A bit ugly perhaps, but neat.)
Not sure where your code got garbled, but I had to change the "at" that 
appeared when I pasted your code into my script:
NB. LABNUMS=:": each <"0 at i.@#LABTITLES_jlab_

Sent from my iPad

On Dec 14, 2012, at 10:26 AM, bob therriault <bobtherria...@mac.com> wrote:

> Yep, Javascript works in view on iPad
> 
> I have been playing around with a different way to view labs (but we still 
> don't have a way to call J from hview yet, do we? :) )
> 
> Here is the script for what I have done so far. Apologies to anyone who 
> actually knows how to code. :)
> 
> cocurrent 'uxjlab'
> require '~addons/ide/ios/labs.ijs'
> require '~addons/labs/labsx/lab.ijs'
> clear ''
> jx 85 NB. out of range to initialize labs
> CATCOLOR=: ;:'OrangeRed LightSalmon Gold Lime DodgerBlue Fuchsia' NB. 
> Category colors
> CATCLASS=:~.LABCATS_jlab_
> LABNAMES=:(([:>:':'i.~])}.])each LABTITLES_jlab_
> LABNUMS=:": each <"0@i.@#LABTITLES_jlab_
> CSS=:JS=:HTML=:''
> 
> CATSTYLE=:;(<'[name='),each CATCLASS,each(<'] { color:'),each 
> CATCOLOR,each(<'; } ')
> BUTTONSTYLE=:;(<'button { display:inline; color:'),each CATCOLOR,each(<'; 
> font-size:1em; text-shadow:1px 1px 2px #000000; } .catButton { 
> font-size:1.3em; opacity:1; display:inline; }')
> GROUPSTYLE=:;(<'div[name='),each CATCLASS ,each(<'] {width:70%; display:none 
> } div[name='),each CATCLASS ,each(<'] .on {width:70%; display:inline } 
> div[name=core] {width:70%; display:inline-block }')
> CSS=:'<style> ',CATSTYLE,GROUPSTYLE,BUTTONSTYLE,' </style>'
> 
> CATBUTTONS=: ;('<button onclick="showLabs(this)" class="catButton" 
> name="',,&'" id="',,&'">',,&'</button>')each CATCLASS
> LABBUTTONS=: (('" id="',,&'" >',,&'</button>') each)  each (LABCATS_jlab_ 
> </.LABNAMES)
> LABBUTTONS=:  (LABCATS_jlab_ </.LABCATS_jlab_)(,each) each LABBUTTONS
> LABBUTTONS=:('<button onclick="labText(this)" width=150px; class="labButton" 
> name="'&,each)each LABBUTTONS
> LABBUTTONS=:((<'">'),,&(<'</div>'))each LABBUTTONS
> LABBUTTONS=:;;(('<div name="'&,)each CATCLASS); each LABBUTTONS
> HTML=: CATBUTTONS,LABBUTTONS
> 
> JS=: ' function showLabs(t) { var dl 
> =document.getElementsByTagName("div").length; for(var i=0;i<dl;i++) { var x= 
> document.getElementsByTagName("div")[i]; 
> if(x.getAttribute("name")===t.getAttribute("name")) { 
> x.style.display="inline-block";} else {x.style.display="none";};};}'
> JS=: JS,' function labText(t){ alert(t.getAttribute("id")+ "\n Enter: jx "+ 
> labNum(t)+ " in text entry.");}'
> JS=: JS,' function labNum(t){ var bl 
> =document.getElementsByTagName("button").length; for(var i=0;i<bl;i++) { var 
> x= document.getElementsByTagName("button")[i]; 
> if(x.getAttribute("id")===t.getAttribute("id")) { return i-6;}};}'NB. 
> subtract 6 to account for 6 category buttons
> JS=:'<script>',JS,'</script>'
> 
> jux=: 3 : 0
> jy '<html><head>',CSS,'</head><body>',JS,HTML,'</body></html>'
> )
> 
> jux_z_=:jux_uxjlab_
> jux ''
> 
> On 2012-12-14, at 6:15 AM, Eric Iverson wrote:
> 
>> I expect javascript is enabled by default for the iPad hview. It would
>> be worthwhile to test this. Having javascript work in that window does
>> open up possibilities.
>> 
>> On Fri, Dec 14, 2012 at 7:03 AM, Brian Schott <schott.br...@gmail.com> wrote:
>>> Eric,
>>> 
>>> Last night I mentioned the html window in J for ipad to Brian LeRoux,
>>> who is a/the developer for phonegap. He said maybe the fix is simply
>>> changing the value of setEnableJavaScript, but only maybe.
>>> 
>>> On Mon, Nov 19, 2012 at 5:46 PM, Eric Iverson <eric.b.iver...@gmail.com> 
>>> wrote:
>>>> I don't think the current release will allow javascript running in the
>>>> html view to call J. This should be possible and opens up interesting
>>>> possibilities. The preliminary step would be to experiment with
>>>> javascript in the html view. I think it should be easy to put html
>>>> controls in the window and have touching them do things. The trick
>>>> would be to have the page do an ajax http request to a server running
>>>> in J. Experiments and feedback welcome.
>>>> 
>>> 
>>> 
>>> --
>>> (B=)
>>> ----------------------------------------------------------------------
>>> For information about J forums see http://www.jsoftware.com/forums.htm
>> ----------------------------------------------------------------------
>> For information about J forums see http://www.jsoftware.com/forums.htm
> 
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to