developer sign in
where » create » reference » choice

variables


Similar to JavaScript, variables are references to underlying type specific values. Variables can be cast and converted implicitly. A variable can point to another variable.


Object Types

Array

An array of variables.

Constructor: new Array(size)
                    { var1, var2, ... , varN }

Methods Description JIN
length() length of the array 2.0
Examples:
 
  <script>
    var items = new Array(3); 
    items[0] = 'one'; 
    items[1] = 1; 
    items[2] = foo; 
    // alerts 'one' 
    alert(items[0]); 
                  
    var list = { 'one', 1, foo }; 
    // alerts 1 
    alert(list[1]); 
  </script> 
      

Attribute

An attribute object represents the string value of an attribute in an element.

Methods Description JIN
n/a n/a 2.0
Examples:
 
  <script>
    // alerts "Press Me"
    alert(document.button.value);     
  </script>
    ...
  <pr>
    <input type="button" id="button" value="Press Me"/>
  </pr>
    

Boolean

A Boolean literal.

Methods Description JIN
n/a n/a 2.0
Examples:
 
  <script>
    var test = false;
    // alerts 'false'
    if (test) { alert('true'); }
    else { alert('false'); } 
  </script> 
    

Document

A document object represents the JIN element and is the top level DOM object.

Methods Description JIN
getNodeById(nodeId) Returns the node in the document with attribute id equal to "nodeId" 2.0
redraw() Redraws the document 2.0
reset() Given the current DOM, the underlying Document is re-built to construct a new screen representing the current DOM. If any removal or addition of a node is made, the change will not be reflected until a call is made to this function 2.0
removeNodeById(nodeId) Removes the first occurence (highest order) of the element in the DOM tree with the id attribute "nodeId" 2.0
setFocus(nodeId) Sets the focus of the page to element with id attribute "nodeId" 2.0
document.body
REFERENCE
Direct referece to the body element 2.0
Examples:
 
  <script>
    var theBody = document.body;
    document.removeNodeById('listNode');
    document.reset();
    document.textNode.text = 'new message';
    document.redraw();
    document.setFocus('buttonId');
    var theButton = document.getNodeById('buttonId');                   
  </script>
    

Form

A form element.

Methods Description JIN
submit() Submits this form and sets a new screen based on the response. 2.0
fetch() Submits this form and returns a trimmed string representing the response. 2.0
Examples:
  <script>
    // fetch a new list and replace old list                 
    var updateForm = document.updateObj;
    var newList = updateForm.fetch();
    if (newList.startsWith('<list')) {
      document.removeNodeById('list');
      document.prNode.insertNodeAt(newList, 3);
    }
  </script>  
  
  <script>  
    // submit a form                   
    var formObj = document.formObj;
    formObj.lat.value = load('pos_lat');
    formObj.lng.value = load('pos_lng');
    formObj.submit();                    
  </script>    
    

Integer

An integer literal that must be expressed in decimal (base 10).

Methods Description JIN
n/a n/a 2.0
Examples:
  <script>
    var foo = 3;
    foo++;
    foo = (3 + 4) + (foo - (10 - 5));
  </script>    
    

List

A list object represents a choice, list, or option element.

Methods Description JIN
getFocus() Returns the index in the list with focus (not the index that is selected in the case of a radio or check choice group). 2.0
size() Returns the length of the list. 2.0
isSelected(index) Returns true/false for whether this index is selected (applies to choice groups only) 2.0
setFocus(index) Sets the focus of the list to the specified index. 2.0
setSelected(index) Sets the specified index of the choice group to be selected. For a radio choice group, this "un-selects" the other radio buttons. 2.0
Examples:
  <script>
    // get list item with focus                  
    var sel = document.list.getFocus();
    // get the selected option 
    var list = document.list;
    var sel = 0;
    for (var i = 0; i < list.size(); i++) {
      if (list.isSelected(i)) { 
        sel = i; 
      } 
    }
    // set list focus to specified index
    document.list.setFocus(3);
    // sets the selected index of this choice group
    document.list.setSelected(3);
  </script>                 
    

Node

A node object represents any element within the document.

Methods Description JIN
nodeAt(N) Gets the Node at N depth in the Node's tree. 2.0
insertNode(JIN) Inserts the JIN to the end of this Node's tree. 2.0
insertNodeAt(JIN, index) Inserts the JIN at position index in the Node's tree. 2.0
removeNode() Removes the last Node from this Node's tree. 2.0
removeNodeAt(index) Removes the Node at position index from this Node's tree. 2.0
removeAllNodes() Removes every Node from this Node's tree. 2.0
hasFocus() Returns true/false if this element has focus. 2.0
setFocus(nodeId) Sets the page focus to nodeId within the referenced node. 2.0
Examples:
Using a script to change the text labels of a list. See full source: www.where.com/create/samples/domJin.jin.txt

List Before DJIN:
<list id="alist" bgfocus="0xFF0000"> 
  <listitem> 
    <text>List Item 1</text> 
  </listitem> 
  <listitem> 
    <text>List Item 2</text> 
  </listitem> 
  <listitem> 
    <text>List Item 3</text> 
  </listitem> 
  <listitem> 
    <text>List Item 4</text> 
  </listitem>                     
</list>

Now Some Scripting:
                
<script>
  function changeList() { 
    // grab the list node 
    var aList = document.alist;  
    // change text in node with index 1 
    aList.nodeAt(1).nodeAt(0).text = 'New List Item 2'; 
    // insert new list item to bottom of list 
    aList.insertNode('<listitem><text>List Item 5<$/text><$/listitem>'); 
    // insert new list item to top of list 
    aList.insertNodeAt('<listitem><text>New List Item 1<$/text><$/listitem>', 0); 
    // remove 'List Item 3' 
    aList.removeNodeAt(3); 
    // must call document.reset() to alter DOM 
    document.reset(); 
    // set focus to bottom list item 
    aList.setFocus(4); 
  } 
</script> 

List After DJIN:
<list id="alist" bgfocus="0xFF0000"> 
  <listitem> 
    <text>New List Item 1</text> 
  </listitem> 
  <listitem> 
    <text>List Item 1</text> 
  </listitem> 
  <listitem> 
    <text>New List Item 2</text> 
  </listitem> 
  <listitem> 
    <text>List Item 4</text> 
  </listitem>  
  <listitem> 
    <text>List Item 5</text> 
  </listitem>                     
</list> 
                    
                    

Null

A null value literal.

Methods Description JIN
n/a n/a 2.0
Examples:
<script>
  var aNullVal = null; 
  // alerts "it's null" 
  if (aNullVal == null) { alert("it's null"); } 
  else { alert("it's NOT null"); }  
</script> 
    

String

A string value literal.

Methods Description JIN
substring(startIndex, endIndex) Returns the substring of the string from startIndex to endIndex. 2.0
length() Returns the length of the string. 2.0
charAt(index) Returns the character (as a string) at the specified index. 2.0
indexOf(char) Returns the index of the character in this string. 2.0
trim() Removes whitespace from the start and end of this string. 2.0
startsWith(string) Returns true/false whether this string starts with "string" 2.0
Examples:
  <script>
    var hiString = 'hi'; 
    var thereString = "there"; 
    // alerts "the"; 
    alert(thereString.substring(0,3)); 
    // alerts '2' 
    alert(hiString.length()); 
    var hiThereString = hiString + ' ' + thereString; 
    // alerts 'i' 
    alert(hiThereString.charAt(1)); 
    // alerts '5' 
    alert(hiThereString.indexOf('e')); 
    // alerts 'true' 
    alert(hiThereString.startsWith('hi')); 
  </script> 

Text

The text or CDATA section of an element.

Methods Description JIN
n/a n/a 2.0
Examples:
    
  <script>
    // alerts "Some text to be displayed" 
    alert(document.someText.text); 
    document.someText.text = 'This is some different text'; 
    document.redraw(); 
  </script> 
   ... 
  <pr> 
    <text id="someText">Some text to be displayed</text> 
  </pr> 
    

Thread

A thread of execution that runs currently with multiple threads including the main thread of execution. A Thread's life is contained in the creating page. Thread clean up when exiting a page is handled by the JIN browser (stop() explicity kills a Thread).

Constructor: new Thread(JinScript, sleepInMillis)

Note: It is not advisable to have more then 3 Threads running concurrently in a page.

Methods Description JIN
start() Starts this THread's execution 2.0
stop() Stops this THread's execution 2.0
Examples:
  <script>
    // create a Thread to call a function every 10 secs 
    var t = new Thread('doSomething()', 10000); 
    t.start(); 
    // create a Thead to call a function every 20 secs and increment counter 
    var t2 = new Thread('doSomethingElse(); foo++', 20000); 
    t2.start(); 
    // stop Thread t; 
    t.stop(); 
    // clean up of Thread t2 is handled by Browser with a new page 
  </script>        
    
terms of use | privacy policy | about | FAQ | blog | jobs | contact us
For 24/7 support email support@where.com or call 888-262-1150
WHERE™ is a product from uLocate Communications, Inc. ©2007 All Rights Reserved.