8 callback.init = function() {
10 callback.type = 'browser';
11 document.getElementById("heading").style.display="";
13 callback.type = 'iphone';
15 var searchdiv = document.getElementById("searchdiv");
16 if (this.type != 'iphone') {
17 searchdiv.style.display = '';
18 document.search.onsubmit = onFormSubmit;
21 searchdiv.style.display = 'none';
24 String.prototype.replaceAll = function(stringToFind,stringToReplace) {
26 var index = temp.indexOf(stringToFind);
28 temp = temp.replace(stringToFind,stringToReplace);
29 index = temp.indexOf(stringToFind);
34 callback.send = function()
36 var args = [].splice.call(arguments,0);
37 for (var i = 0; i < args.length; i++) {
39 args[i] = args[i].replaceAll(':','_');
41 alert("args was null: " + i);
43 var message = "myapp:" + args.join(":");
44 if (this.type == 'iphone')
45 document.location = message;
47 document.getElementById("log").innerHTML = message;
50 // implement JSON.stringify serialization
51 JSON.stringify = JSON.stringify || function(obj) {
53 if (t != "object" || obj === null) {
56 obj = '"' + obj + '"';
59 // recurse array or object
60 var n, v, json = [], arr = (obj && obj.constructor == Array);
66 else if (t == "object" && v !== null)
67 v = JSON.stringify(v);
68 json.push((arr ? "" : '"' + n + '":') + String(v));
70 return (arr ? "[" : "{") + String(json) + (arr ? "]" : "}");
74 function search(message) {
75 document.search.query.value = message;
76 onFormSubmitEventHandler();
84 function onFormSubmit() {
85 return search(document.search.query.value);