I have recently started using code contracts in one of my .net projects and I came to think that since most of the code I produce these days are in Javascript, why don’t I try it there to!
Well, easier said than done – there just is no decent frameworks for this.
During my searching I found some references to libraries such as Cerny.js and ecmaDebug, but these just didn’t make the cut - they all required heavy (and hard to follow) restructuring of your code to make them work.
So what did I do? Well I made jsContract, a library that is clean and .. wait for it .. extremely easy to use! Read the rest of this entry »
Posted by oyvind.kinsey on February 3rd, 2010 under jsContract, programmingTags: code contracts, design by contract, instrumentation, Javascript • 4 Comments
To accommodate older browsers that does not implement the postMessage interface, easyXDM is able to fall back to using the URI fragment trick, and until now this has meant that the provided hash.html file had to be uploaded to the local domain (the ‘calling’ domain).
This seems to be a dealbreaker for many as they are unable to upload files to the server, either due to special systems, or because they just want to present an API in the form of ‘just include this javascript file’ etc..
With the new 1.5.5 release, this has all changed.
For scenarios where you do not want to upload the hash.html file, you can now point the local attribute to any file present on the local domain, like robots.txt or favicon.ico, and supply a readyAfter attribute with the number of milliseconds to wait before assuming the local file to be loaded and the library to be ready for interaction.
{
local: "/robots.txt",
readyAfter: 1000,
remote: "http://.........",
...
}
Update: Just released 1.6.0 which makes it possible to utilize the current document instead of loading a new one from the local domain. This makes it very easy to integrate, but does mean that you will be modifying the documents location when falling back to the HashTransport – and this might interfere with for instance history managers etc.
{
local: window,
remote: "http://.........",
...
}
The hash.html file is still the recommended approach for stable
implementations as it is unobtrusive and it guarantees that the library is indeed ready
when transitioning into a ready state.
Using hash.html also shortens the time needed to initialize easyXDM
as there is no need for the delay to give the local file time to
properly load.
All the different ways to set up easyXDM can now be viewed at http://easyxdm.net/wiki/Documentation.ashx
Posted by oyvind.kinsey on January 2nd, 2010 under easyXDM, programmingTags: easyxdm • No Comments
In an earlier post I showed you how to use binary operators to store multiple privileges/settings in a single integer field. Now I will present to you a simple control for visualizing and modifying such a value.
Read the rest of this entry »
Posted by oyvind.kinsey on November 17th, 2009 under programmingTags: binary, bitwise, extjs, Javascript, privileges • No Comments
In many applications you have the need to set users privileges , and while there are many ways to do so, I prefer to using a single integer value to store a users privileges on any single entity.
This has many advantages,
- you only have a single value representing all privileges
- you can add and remove available privileges without altering the schema/entity model/storage logic
- checking for privileges are very simple
Read the rest of this entry »
Posted by oyvind.kinsey on November 17th, 2009 under programmingTags: binary, bitwise, Javascript, privileges • 3 Comments
When building complex web applications it is often necessarry to restrict the user to keeping only a single instance open, and to do this you need to check for the precense of an existing instance, either directly or indirectly.
Read the rest of this entry »
Posted by oyvind.kinsey on November 15th, 2009 under programmingTags: Javascript, Single instance • No Comments
The nice people at Packt Publishing has asked me to do a book review of Jorge Ramons “Ext JS 3.0 Cookbook“.
According to the book description the following subjects will be covered
- Work with different browsers, platforms, and the DOM, as well as determine and understand the different ExtJS data types
- Create your own custom Ext JS data types as you extend their functionality
- Build great-looking and friendly forms by using client and server-side field validation, form loading, submission, field customization, and layout techniques
- Explore the different layouts provided by the Ext JS library as well as create your own, and understand their common uses
- Display, edit, and group tabular data generated by the server using Grid Panels
- Explore the advantages and the efficiency tradeoffs of widgets such as Combo boxes
- Use the drag and drop features of the grid component, data editing with the new RowEditor Class, and the new lightweight ListView component
- Explore multiple ways of displaying master-details relationships
- Group components or information under the same container to build hierarchical views of information by using TabPanel components
- Use patterns to build a solid and flexible application architecture and implement additional design patterns such as auto-saving form elements, component state management, and code modules to build robust and flexible applications with Ext JS
- Build your own custom components on top of the Ext framework and enhance the custom components created by the Ext JS users’ community
I’m looking forward to this as Ext and JavaScript are two things that I am quite passionate about
Posted by oyvind.kinsey on November 11th, 2009 under programmingTags: book review, extjs, Javascript • No Comments
Most of my web based projects consist of WCF driven webservices at the backend and a javascript UI using ExtJS, and for access to the WCF webservice I like to use its automatically generated proxies as this abstracts away the feeling of working with XMLHttpRequests, actually it abstracts it to a level where you can call the server side method ‘directly’, specifying only a callback function that should receive the response. These proxies are dynamically generated and will always reflect the serverside methods signature.
Read the rest of this entry »
Posted by oyvind.kinsey on October 28th, 2009 under UncategorizedTags: asp.net ajax, Ext Js, Javascript, proxy, svc, wcf, webservices • No Comments
Today I needed to upgrade the software on my Nokia N97, and was prompted by the Nokia software to download and run NokiaSoftwareUpdaterSetup_en.exe.
The only thing was, this just exited with a message saying unsupported platform or something. I quickly tested if the exe file was an archive and discovered I could unpack it with 7-Zip. Inside the resulting directory, in a folder named Installer, I found a file called Configuration.icf, and in this a line with the string
TargetOSs=winXP,winVista
I added ‘,win7′ on a hunch and ran Installer.exe, and what do you know, it worked
Posted by oyvind.kinsey on October 27th, 2009 under UncategorizedTags: hack, n97, nokia • 9 Comments
The newest version of easyXDM (v1.5.3) now includes two new classes, the easyXDM.WidgetManager, and easyXDM.Widget.
These make it extremely easy to make mashups based on the subscribe/publish architecture.
Read the rest of this entry »
Posted by oyvind.kinsey on September 6th, 2009 under easyXDM, programmingTags: easyxdm, Javascript, widgets • No Comments
easyXDM is a javascript library that uses available techniques to provide a means of transporting messages and/or method calls between windows in different domains, in short, by-passing the same-origin policy and letting you call methods across the domain boundry.
This is perfect if you plan to provide a client-side API (e.g Facebook Connect) on your web site as you can expose a method in as little as 7 lines of code.
var remote = new easyXDM.Interface({}, {
local: {
doMagic:{
method: _privateMethod
}
}
});
This can be consumed by a client by using
var remote = new easyXDM.Interface({
local: "../hash.html",
remote: "http://apiprovidersdomain.com/api.html"
},{
remote: {
doMagic: {}
}
});
and can then be called by using
remote.doMagic('argument1',2,function(result){
alert(result)
}
In this CodeProject article I present an example on how easy it is to do this, and in the extensive documentation there are links to several demos showing everything from sending simple strings to letting two applications from different domains send arbitrary objects back and forth, even using older browsers like IE6.
The demos are repeated here
Read the rest of this entry »
Posted by oyvind.kinsey on August 20th, 2009 under easyXDM, programmingTags: AJAX, cross-domain, easyxdm, easyxss, Javascript, xss • 43 Comments