BB10/Screenshot/ext/net.jonwebb.screenshot/index.js
function (success, fail, args) {
		// userargs are encoded and need decoding & parsing into a json object
		var userargs = JSON.parse(decodeURIComponent(args["userargs"]));
		// which window handle should we use?
		var wv = qnx.webplatform.getWebViews();
		for(var i=0;i<wv.length;i++){
			if (wv[i].zOrder==0) {
				// found window handle.
				success(
					template.getInstance().execute(
						{
							handle:wv[i].jsScreenWindowHandle, 
							userargs:userargs
						}
					)
				);
				return;
			}
		}
		fail("error:no window handle");
	}
function (success, fail, args) {
		// userargs are encoded and need decoding & parsing into a json object
		var userargs = JSON.parse(decodeURIComponent(args["userargs"]));
		// which window handle should we use?
		var wv = qnx.webplatform.getWebViews();
		for(var i=0;i<wv.length;i++){
			if (wv[i].zOrder==0) {
				// found window handle.
				success(
					template.getInstance().execute(
						{
							handle:wv[i].jsScreenWindowHandle, 
							userargs:userargs
						}
					)
				);
				return;
			}
		}
		fail("error:no window handle");
	}
execute() finds the window handle, processes userargs then performs the screenshot