Note that all the positive and negative integers whose magnitude is no greater than 2^53 are representable in the Number type
Probably fair to say that nearly all the time large 64 bit values are being used, they are being used as unique identifiers (as opposed to an outright measure of some quantity). In this case the usual workaround is to convert the numeric value to a string before converting it to JSON.
I’ve found JSONView to be an extremely useful add-on for FireFox when developing with JSON based APIs. Its like a JSON equivalent of the XML viewing capabilities built into Firefox. Highly recommended.
If you are building an offline capable application, then I would posit that at some level in your client architecture you are going to need a Proxy. On one side of the Proxy will sit your presentation logic, on the other side will sit your business logic. When operating in online mode this Proxy will pass requests on to the remote server, when operating in offline mode the Proxy will redirect requests to some local implementation of business logic that provides a facsimile of the remote server’s behaviour.
For browser based applications, I feel a desirable place to position such a Proxy is at the browser’s HTTP interface. Implementing a Proxy at this level means that all means of initiating HTTP requests from within a browser can be proxied. Indeed Google Gears takes exactly this approach, providing a
ResourceStore into which resources can be cached, Gears then intercepts all HTTP requests made by the browser and if it detects a matching HTTP
GET request for a stored resource, serves the cached version of the resource from the
ResourceStore. This provides a means for an application to provide the static data it needs to ‘read’ when offline, but what about data the application needs to ‘write’ when offline? What about ‘read’ data that is constructed on the fly, for example the results of a query?
ResourceStore, BITSY also specifies a
DataCache to provide offline resource storage.
Change the Registry setting “HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main” and Create a new DWORD key under Main with the name “ShowScriptErrors“. Set dword value of 1
There are (at least) two ways to change registry settings on a Windows Mobile device/emulator. Firstly you can use the Remote Registry Editor (Start|Microsoft Visual Studio 2005|Visual Studio Remote Tools) that comes with Visual Studio. Alternatively you can install a registry editing application on the device, for example PHM Registry Editor.
One thing you can do is leverage XMLHttpRequest (XHR) to log messages to a remote server, sometimes useful when you need to log more information than will easily fit in an alert() dialog box on a cramped Windows Mobile display.
Lately I’ve been trying to get jQuery working on IE Mobile 6.12 (IEm). Best I’ve managed is to mock up IEm versions of the subset of jQuery API methods that I needed for the project I’m working on. Below are my notes on the particular jQuery methods that presented challenges:
There are a couple of challenges with constructing DOM elements from text:
removeChild()etc. on an element it must be first attached to the current document. I used a scratch
<div>element (set to
display:none) to which all elements that were to be manipulated were attached for the duration of the manipulation
$('Hello <i>World</i>'). The
'Hello 'text is not contained within a element node, and so cannot be handled on IEm.
I only built support for a subset of this method’s functionality, namely: find element by id, find element by class name, find element by attribute value, and find elements by tag name. In all cases I could only produce reliable results by walking the DOM (which is known to be inefficient across all browsers).
The only way to traverse the IEm DOM is via the
nextSibling etc. are not supported. Only element nodes are present in this collection, text within an element is accessed via the
innerText property of an element and attributes are accessed via the
getAttribute() method. the class attribute is accessible via the
className property on an element. The tag name is accessible via the
This method is used in two ways:
getAttribute()method to retrieve value
The css for an element be read and written via the element’s
style property. e.g.
e.style['display'] = 'none';
The text of an element can be read and written via the element’s
IEm supports the same ActiveX
XMLHttpRequest (XHR) control as desktop IE, it is instantiated in the usual fashion. Note the IE XHR implementation will only create an XML DOM for responses if the content type is
'text/xml'. To work around this I manually parsed the
responseText property if the XHR did not treat the response as XML. The same MSXML ActiveX object as is present on desktop IE is present on IEm.
onevent attribute in the html. The set of events that are supported on the various HTML elements is very limited, e.g. the
onclick event is not supported for
<span> elements. When event handlers are invoked they do not receive an
event argument, the
window.event property found on desktop IE is not present either; the
this value does point to the element which originated the event.
For static HTML defined in the html file itself you are left with no choice but write explicit event handlers in the HTML code itself, which is at odds with the jQuery’s principle of separating behaviour from presentation. You may not be able to use the full range of events found on other platforms and you will probably end up having to wrap elements in
<div> tags in order to attach event handlers to them.
If you need to bind event handlers to HTML code constructed dynamically – via the
$(...) method – then there is a workaround, its not pretty but it will work. By changing the behaviour of the
jQuery.clean() method (which is responsible for constructing DOM elements from text), elements to which event handlers might be bound can be rewritten to include a unique id (if not already present) and an explicit event handler. So the following code:
$('<a href="#">...</a>') would generate HTML looking something like this:
<a href="#" id="jQuery.id.37" onclick="jQuery.dispatch('click','jQuery.id.37')">
jQuery.dispatch() method is a jQuery extension method I defined. It is passed two arguments: the event type and the id of the element which originated the event.
jQuery.dispatch() uses this information to lookup an internal associative array to find the event handler(s) bound to the particular event type on the element with the specified id and invokes the handler.
The implementation of the
bind() method needs to change to associate the event type and the element’s id with the appropriate event handler in the same associative array that
change() method is used to either set the change event handler for an element or to generate an
onchange event. It should be adapted to either call
jQuery.dispatch() as appropriate.