8 callback.init = function() {
10 callback.type = 'browser';
12 callback.type = 'iphone';
16 String.prototype.replaceAll = function(stringToFind,stringToReplace) {
18 var index = temp.indexOf(stringToFind);
20 temp = temp.replace(stringToFind,stringToReplace);
21 index = temp.indexOf(stringToFind);
26 callback.send = function()
28 var args = [].splice.call(arguments,0);
29 for (var i = 0; i < args.length; i++) {
31 args[i] = args[i].replaceAll(':','_');
33 alert("args was null: " + i);
35 var message = "myapp:" + args.join(":");
36 if (this.type == 'iphone')
37 document.location = message;
39 document.getElementById("log").innerHTML = message;
42 // implement JSON.stringify serialization
43 JSON.stringify = JSON.stringify || function(obj) {
45 if (t != "object" || obj === null) {
48 obj = '"' + obj + '"';
51 // recurse array or object
52 var n, v, json = [], arr = (obj && obj.constructor == Array);
58 else if (t == "object" && v !== null)
59 v = JSON.stringify(v);
60 json.push((arr ? "" : '"' + n + '":') + String(v));
62 return (arr ? "[" : "{") + String(json) + (arr ? "]" : "}");
66 function search(message) {
67 document.search.query.value = message;
68 onFormSubmitEventHandler();
76 function onFormSubmit() {
77 return search(document.search.query.value);