Javascript on NMT
From NMTWiki
Placeholder for future user discovered Javacript specs as they pertain to the NMT devices.
Contents |
Known Limitations
The limit of inline script is 23360 bytes in total size per script (between a <script> ...</script>. (You can have multiple scripts of this size in one html)
External files have no such limit, but have another limit of no more than 2048 characters per line of code (separated by a new line).
Dynamic loading of files/scripts is currently not available
Setting images via appendChild(document.createElement('img')); does not work since disable_image_src_set appears to be turned on in the inbuilt NMT browser (verification needed)
Working
Element properties:
- .attribute[]
- .firstChild
- .nextSibling
- .childNodes[]
- .setAttribute('attribute to change','what the attribute should now be')
Element methods (can be used with properties above):
- .nodeValue
- .appendChild
Document creation methods:
- .createTextNode("Text here...") works
- .createElement() works, but img tags don't display in the final render
Examples:
- document.getElementById('XXX').setAttribute('href','new-destination.html') (best way to change attributes within the html)
- document.getElementById('XXX').attribute[?].nodeValue="".
- document.getElementById('xxx').firstChild.nodeValue="" (best way to change text descriptions and such).
How to change stylesheet properties with javascript
- 1. You can change any property setting in your CSS, but it must be listed in the CSS already.
- 2. You must know the index number of your CSS (this is the <style> and its order in your html)
- 3. You must know the index number of your element within the CSS
- document.styleSheets[XXX].cssRules[XXX].style.visibility='hidden' (this is how you change visibility)
- document.styleSheets[XXX].cssRules[XXX].style.left='150'
Example
- <html>
- <head>
- <link rel="StyleSheet" type="text/css" href="exportindex_item_pch.css"></link> NOTE: this would be styleSheets[0]
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
- <style> Note: this would be styleSheets[1]
- image1 {visibility:visible;left:50;top:100} Note: this would be cssRules[0]
- image2 {visibility:visible;left:150;top:100} Note: this would be cssRules[1]
- image3 {visibility:visible;left:250;top:100} Note: this would be cssRules[2]
- image4 {visibility:visible;left:350;top:100} Note: this would be cssRules[3]
- image5 {visibility:visible;left:450;top:100} Note: this would be cssRules[4]
- </style>
Not Working
- .innerHTML does not work
- .deleteRow does not work
- password prompts do not function properly.
- document.write() does not work (update: seems to work as of 01-17-091202-15-POP-402-000)
- display: none does not work, but NMT will respect visibility: hidden. Not exactly, but almost the same.
Tests
User dundanox (german NMT-Forum Link to article on http://www.popcornforum.de) created a testpage, just to see what is supported and what is not.
data types
* [y] integer (number) * [n] float (number) * [y] string * [y] boolean * [y] array * [y] object * [y] function
Arithmetic operations
* [y] Addition (+) * [y] Subtraction (-) * [y] Multiplication (*) * [y] Division (/) * [y] Modulo (%) * [y] Increment (++) * [y] Decrement (--)
Usage
* [y] if ... * [y] if ... else * [y] [...] ? [...] : [...] (like if/else) * [y] switch/case/break/default
Loops
* [y] for * [y] for...in (for objects and arrays) * [y] while * [y] do...while
additionally
* [y] prototype
* [?] regular expressions (RegExp) - may be y, cause of string.match
Global Objects and Functions
* [y] window * [y] document * [y] location * [y] Array * [y] Boolean * [y] Date (since 01-17-090116-15-POP-402) * [y] Function * [y] Math * [y] navigator * [y] Number * [y] RegExp * [n] screen * [y] String
* [n] decodeURI() * [y] decodeURIComponent() * [y] encodeURI() * [y] encodeURIComponent() * [y] eval() (Note: This will crash the c200 as of Jan 27, 2010...did not test on A1XX yet -excal) * [y] escape() * [y] isFinite() * [y] isNaN() * [y] parseFloat() - output is Integer, decimal places truncated * [y] parseInt() * [y] String() * [y] unescape()
window-Object
* [y] document * [n] frames * [y] history * [y] location * [n] closed * [n] defaultStatus * [n] innerHeight * [n] innerWidth * [n] name * [n] opener * [n] parent * [n] self * [n] top * [y] window * [n] outerHeight * [n] outerWidth * [n] pageXOffset * [n] pageYOffset * [n] status * [n] locationbar * [n] menubar * [n] personalbar * [n] scrollbars * [n] statusbar * [n] toolbar
* [y] alert() * [n] back() * [n] blur() * [n] captureEvents() * [y] clearInterval() * [y] clearTimeout() * [n] close() * [y] confirm() * [n] disableExternalCapture() * [n] enableExternalCapture() * [n] find() * [y] focus() * [n] forward() * [n] handleEvent() * [n] home() * [n] moveBy() * [n] moveTo() * [n] open() * [n] print() * [y] prompt() * [n] releaseEvents() * [n] resizeBy() * [n] resizeTo() * [n] routeEvent() * [n] scrollBy() * [n] scrollTo() * [y] setInterval() * [y] setTimeout() * [n] stop()
document-Object
* [y] all * [n] anchors * [n] applets * [n] embeds * [y] forms * [n] images * [n] links * [n] plugins * [y] styleSheets * [n] alinkColor * [n] bgColor * [n] charset * [n] cookie * [n] domain * [n] defaultCharset * [n] fgColor * [n] filesize * [n] readyState * [n] lastModified * [n] linkColor * [n] referrer * [n] title * [n] URL * [n] vlinkColor
* [n] captureEvents() * [n] close() * [y] createAttribute() * [y] createElement() * [y] createTextNode() * [y] getElementById() * [y] getElementsByName() * [y] getElementsByTagName() * [n] getSelection() * [n] handleEvent() * [n] open() * [n] releaseEvents() * [n] routeEvent() * [n] write() * [n] writeln()
location-Object
* [y] hash * [y] host * [y] hostname * [y] href * [y] pathname * [y] port * [y] protocol * [y] search
* [y] reload() * [y] replace()
Array-Object
* [y] length
* [y] concat() * [n] every() * [n] filter() * [n] foreach() * [n] indexOf() * [y] join() * [n] lastIndexOf() * [n] map() * [y] pop() * [y] push() * [y] reverse() * [y] shift() * [y] slice() * [y] splice() * [n] some() * [y] sort() * [y] toSource() * [y] toString() * [y] unshift() * [y] valueOf()
Function-Object
* [y] arguments * [n] arity * [n] caller
Date-Object
* [y] getFullYear() * [y] getYear() * [y] getMonth() * [y] getDate() * [y] getDay() * [y] getHours() * [y] getMinutes() * [y] getSeconds() * [y] getMilliseconds() * [y] getTime() * [y] getTimezoneOffset() * [y] getUTCFullYear() * [y] getUTCMonth() * [y] getUTCDate() * [y] getUTCDay() * [y] getUTCHours() * [y] getUTCMinutes() * [y] getUTCSeconds() * [y] getUTCMilliseconds() * [y] setFullYear() * [y] setYear() * [y] setMonth() * [y] setDate() * [y] setHours() * [y] setMinutes() * [y] setSeconds() * [y] setMilliseconds() * [y] setTime() * [y] setUTCFullYear() * [y] setUTCMonth() * [y] setUTCDate() * [y] setUTCHours() * [y] setUTCMinutes() * [y] setUTCSeconds() * [y] setUTCMilliseconds() * [y] toGMTString() * [y] toLocaleString() * [y] toLocaleDateString() * [y] toLocaleTimeString() * [y] toString() * [y] toUTCString() * [y] parse() * [y] UTC() * [y] valueOf()
Math-Object
* [n] E * [n] LN2 * [n] LN10 * [n] LOG2E * [n] LOG10E * [n] PI * [n] SQRT1_2 * [n] SQRT2
* [y] abs() * [n] acos() * [n] asin() * [n] atan() * [n] atan2() * [n] ceil() * [n] cos() * [n] exp() * [y] floor() * [n] log() * [y] max() * [y] min() * [n] pow() * [y] random() * [y] round() * [n] sin() * [n] sqrt() * [n] tan()
Number-Object
* [y] MAX_VALUE * [y] MIN_VALUE * [y] NaN * [y] NEGATIVE_INFINITY * [y] POSITIVE_INFINITY
* [n] toExponential() * [n] toFixed() * [n] toPrecision() * [y] toString()
String-Object
* [y] length
* [y] charAt() * [y] charCodeAt() * [y] concat() * [n] fromCharCode() * [y] indexOf() * [y] lastIndexOf() * [y] match() * [y] replace() * [y] search() * [y] slice() * [y] split() * [y] substr() * [y] substring() * [y] toLowerCase() * [y] toUpperCase() * [n] anchor() * [n] big() * [n] blink() * [n] bold() * [n] fixed() * [n] fontcolor() * [n] fontsize() * [n] italics() * [n] link() * [n] small() * [n] strike() * [n] sub() * [n] sup()
navigator-Object
* [y] appCodeName * [y] appName * [y] appVersion * [n] cookieEnabled * [n] language * [n] platform * [y] useragent
* [n] yvaEnabled()
Node-Object
* [y] attributes * [y] childNodes * [n] data * [y] firstChild * [y] lastChild * [y] nextSibling * [y] nodeName * [y] nodeType * [y] nodeValue * [y] parentNode * [y] previousSibling
* [n] addEventListener() * [y] appendChild() * [n] appendData() * [y] cloneNode() * [n] deleteData() * [y] getAttribute() * [y] getAttributeNode() * [n] getElementsByTagName() * [y] hasChildNodes() * [y] insertBefore() * [n] insertData() * [y] removeAttribute() * [y] removeAttributeNode() * [y] removeChild() * [y] replaceChild() * [y] setAttribute() * [y] setAttributeNode()
styleSheets-Object
* [y] cssRules * [n] cssText * [y] disabled * [y] href * [y] media * [y] ownerNode * [n] ownerRule * [n] owningElement * [n] parentStylesheet * [n] rules * [y] title * [y] type
* [n] addRule() * [n] removeRule() * [n] deleteRule() * [n] insertRule()
cssRules-Object
* [y] cssText * [y] parentStyleSheet * [y] selectorText * [y] style
