├── README ├── ajax └── ajax.js ├── config └── config.js ├── goosh.js ├── gui └── gui.js ├── index.html ├── lang └── lang.js ├── lib ├── chop.js ├── cookie.js ├── dump.js ├── get.js ├── in_array.js ├── keyboard.js └── namespace.js ├── module-exp ├── gmail.js ├── login.js └── logout.js ├── module ├── addengine.js ├── blogs.js ├── calc.js ├── cd.js ├── clear.js ├── feed.js ├── go.js ├── help.js ├── images.js ├── inurl.js ├── load.js ├── ls.js ├── lucky.js ├── more.js ├── news.js ├── open.js ├── place.js ├── read.js ├── settings.js ├── translate.js ├── video.js ├── web.js └── wiki.js ├── modules └── modules.js ├── searchers └── lang.js ├── set └── set.js └── style.css /README: -------------------------------------------------------------------------------- 1 | Just open the index.html web page. 2 | 3 | -------------------------------------------------------------------------------- /ajax/ajax.js: -------------------------------------------------------------------------------- 1 | goosh.lib.namespace("goosh.ajax"); 2 | 3 | goosh.ajax.contexts = new Array(); 4 | goosh.ajax.lastcontext = false; 5 | 6 | goosh.ajax.stopall = function(){ 7 | 8 | for(key in goosh.ajax.contexts){ 9 | goosh.ajax.iscontext(key); 10 | } 11 | 12 | } 13 | 14 | goosh.ajax.deletecontext = function(context){ 15 | goosh.gui.outln('Error: Operation timed out. '+context); 16 | if(!document.all) goosh.gui.outln(goosh.gui.less('If you use the noscript firefox-extension, add "ajax.googleapis.com" to the whitelist.')); 17 | goosh.gui.outln(''); 18 | goosh.ajax.contexts[context]=false; 19 | 20 | var d = document.getElementById(context); 21 | if(d) document.body.removeChild(d); 22 | 23 | goosh.gui.showinput(); 24 | goosh.gui.focusinput(); 25 | goosh.gui.scroll(); 26 | if(!document.all) stop(); 27 | 28 | } 29 | 30 | goosh.ajax.iscontext = function(name){ 31 | 32 | if(goosh.ajax.contexts[name]){ 33 | 34 | clearTimeout(goosh.ajax.contexts[name]); 35 | goosh.ajax.contexts[name] =false; 36 | 37 | var d = document.getElementById(name); 38 | if(d) document.body.removeChild(d); 39 | 40 | 41 | return true; 42 | } 43 | else return false; 44 | 45 | } 46 | 47 | goosh.ajax.getcontext = function(name){ 48 | var d = new Date(); 49 | var context = d.getTime(); 50 | if(name) context = name; 51 | 52 | goosh.ajax.contexts[context] = setTimeout("goosh.ajax.deletecontext('"+context+"');",1000*goosh.config.timeout); 53 | 54 | return context; 55 | } 56 | 57 | goosh.ajax.query = function(url,nohide){ 58 | var context = "none"; 59 | if(!nohide){ 60 | context = goosh.ajax.getcontext(); 61 | goosh.ajax.lastcontext = context; // more elegant with return, but doesnt work in opera 62 | goosh.gui.hideinput(); 63 | } 64 | 65 | 66 | var script = document.createElement("script"); 67 | document.body.appendChild(script); 68 | script.src = url+'&context='+context+'&'; 69 | script.id = context; 70 | 71 | } 72 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /config/config.js: -------------------------------------------------------------------------------- 1 | goosh.lib.namespace("goosh.config"); 2 | 3 | goosh.config.apikey = "ABQIAAAA0cXSEVCNSwf_x74KTtPJMRShYK5vgJfK0afUKMRqjECszDItkhTOIyZ74499O_ys5nJIQuP4sq4nZg"; 4 | 5 | goosh.config.user = "guest"; 6 | goosh.config.host = "goosh.org"; 7 | goosh.config.mode = "web"; 8 | goosh.config.pend = "> "; 9 | 10 | goosh.config.numres = 4; 11 | goosh.config.timeout = 4; 12 | 13 | goosh.config.start=0; 14 | goosh.config.moreobj; 15 | 16 | goosh.config.lang = "en"; 17 | goosh.config.urls = new Array(); 18 | goosh.config.cmdlines = new Array(); 19 | goosh.config.cmdqueue = new Array(); 20 | -------------------------------------------------------------------------------- /goosh.js: -------------------------------------------------------------------------------- 1 | goosh.command = function() { 2 | 3 | var cmdpar = goosh.gui.inputfield.value; 4 | var tokens = cmdpar.split(" "); 5 | var args = new Array(); 6 | 7 | for (i = 0; i < tokens.length; i++) 8 | { 9 | if (tokens[i] != "") 10 | { 11 | if (tokens[0] != "set" && tokens[0] != "settings") 12 | { 13 | var j = 1; 14 | 15 | while (goosh.config.urls[j]) // replace search result numbers 16 | { 17 | if (tokens[i] == j) 18 | { 19 | tokens[i] = goosh.config.urls[j]; 20 | 21 | if (i == 0) 22 | args.push("open"); // number shortcut 23 | } 24 | 25 | j++; 26 | } 27 | } 28 | 29 | args.push(tokens[i]); 30 | } 31 | } 32 | 33 | var searcher; 34 | 35 | for (key in goosh.modules.list) 36 | { 37 | if (goosh.lib.in_array(goosh.modules.list[key].aliases, args[0])) 38 | { 39 | searcher = goosh.modules.list[key]; 40 | args[0] = searcher.name; 41 | break; 42 | } 43 | } 44 | 45 | if (args.length == 0 && goosh.config.moreobj && goosh.config.moreobj.hasmore) 46 | { 47 | searcher = goosh.modules.list["more"]; 48 | args[0] = "more"; 49 | } 50 | 51 | // output.innerHTML += searcher.aliases; 52 | // output.innerHTML += "COMMAND:"+delim+"/"+cmdstr+"/"+args+".
"; // debug 53 | 54 | var cmdstrnew = args.join(" "); 55 | 56 | if (encodeURIComponent(cmdstrnew) != goosh.lib.get("q") && cmdstrnew != "more" && cmdstrnew != "logout") 57 | window.location.hash = "#"+encodeURIComponent(cmdstrnew); 58 | 59 | goosh.gui.out("
" + goosh.gui.prompt + "" + cmdstrnew.replace(/"); 60 | 61 | if(cmdstrnew != "") 62 | { 63 | goosh.keyboard.hist[goosh.keyboard.hist.length] = cmdstrnew; 64 | goosh.keyboard.histpos = goosh.keyboard.hist.length; 65 | } 66 | 67 | var cmd = ""; 68 | 69 | if(!searcher) 70 | { 71 | searcher = goosh.modules.list[goosh.config.mode]; // default searcher = mode 72 | } 73 | else 74 | { 75 | for (i = 0; i < args.length - 1; i++) 76 | args[i] = args[i+1]; 77 | 78 | args.pop(); 79 | } 80 | 81 | // more 82 | if (searcher.more && args.length>0) 83 | this.config.moreobj = searcher; 84 | 85 | if(args.length == 0 && searcher.mode) 86 | { 87 | goosh.config.mode = searcher.name; 88 | goosh.gui.updateprompt(); 89 | } 90 | else 91 | { 92 | searcher.call(args); 93 | } 94 | 95 | goosh.gui.scroll(); 96 | goosh.gui.inputfield.value = ''; 97 | goosh.gui.focusinput(); 98 | 99 | return false; 100 | } 101 | 102 | goosh.onload = function(e,username) { 103 | 104 | var ifrlogin = false; 105 | 106 | try 107 | { 108 | if (parent.goosh != goosh) 109 | { 110 | var bodyel = document.getElementById('body'); 111 | 112 | bodyel.innerHTML = ""; 113 | goosh = parent.goosh; 114 | ifrlogin = true; 115 | } 116 | } 117 | catch (e) 118 | { 119 | } 120 | 121 | goosh.gui.init(); 122 | 123 | if (!username && (ifrlogin || document.cookie.indexOf("loggedin") != -1)) 124 | { 125 | goosh.ajax.query("http://goosh.appspot.com/status?callback=goosh.onload"); 126 | return; 127 | } 128 | else 129 | { 130 | if (goosh.ajax.iscontext(e)) 131 | { 132 | goosh.config.user = username; 133 | 134 | //try { 135 | var d = goosh.gui.el("gooshlogin"); 136 | var p = goosh.gui.el("gooshloginparent"); 137 | 138 | if (d && p) 139 | { 140 | goosh.gui.outputel.removeChild(goosh.gui.outputel.lastChild); 141 | } 142 | // } 143 | // catch(e){} 144 | } 145 | } 146 | 147 | if (username && username != "guest") 148 | goosh.lib.cookie.set("loggedin", "1", 365); 149 | 150 | goosh.set.init(); 151 | } 152 | 153 | goosh.getquery = function() { 154 | 155 | var query = "" 156 | 157 | if (goosh.lib.get("q")) 158 | { 159 | query = goosh.lib.get("q"); 160 | } 161 | 162 | //{window.location.href="http://gshell.grothkopp.com/#"+goosh.lib.get("q"); return;} //query = decodeURI(goosh.lib.get("q")); 163 | 164 | if (window.location.hash) 165 | query = decodeURIComponent(window.location.hash.substr(1)); 166 | 167 | query += " "; 168 | 169 | if (query != " " && query.substr(0,6) != "login " && query.substr(0,4) != "set " && query.substr(0,9) != "settings ") 170 | goosh.gui.inputfield.value = query.substr(0,query.length); //.replace(/
"); 46 | goosh.gui.showinput(); 47 | goosh.gui.focusinput(); 48 | goosh.gui.scroll(); 49 | } 50 | 51 | 52 | 53 | goosh.gui.outln = function(text){ 54 | goosh.gui.out(text+"
"); 55 | } 56 | 57 | goosh.gui.out = function(text){ 58 | //goosh.gui.outputel.innerHTML += text; 59 | var div = document.createElement("div"); 60 | div.innerHTML = text; 61 | goosh.gui.outputel.appendChild(div); 62 | 63 | } 64 | 65 | goosh.gui.less = function(text){ 66 | return ""+text+""; 67 | } 68 | 69 | goosh.gui.info = function(text){ 70 | return ""+text+""; 71 | } 72 | 73 | goosh.gui.clear = function(){ 74 | goosh.gui.outputel.innerHTML = ""; 75 | } 76 | 77 | goosh.gui.showinput = function(){ 78 | goosh.gui.inputel.style['display'] = 'block'; 79 | } 80 | 81 | goosh.gui.hideinput = function(){ 82 | goosh.gui.inputel.style['display'] = 'none'; 83 | } 84 | 85 | goosh.gui.focusinput = function(){ 86 | var txt = ""; 87 | //if (document.getSelection) txt = document.getSelection(); 88 | if (document.selection) txt = document.selection.createRange().text; 89 | else if (window.getSelection) txt = window.getSelection().toString(); 90 | 91 | if(txt.length == 0){ 92 | 93 | document.f.q.value = document.f.q.value; // for safari 94 | if(goosh.gui.inputel.style['display'] != 'none') document.f.q.focus(); 95 | } 96 | } 97 | 98 | goosh.gui.updateprompt = function(){ 99 | goosh.gui.prompt = goosh.config.user+"@"+goosh.config.host+":/"+goosh.config.mode+goosh.config.pend; 100 | goosh.gui.promptel.innerHTML = goosh.gui.prompt; 101 | } 102 | 103 | goosh.gui.scroll = function(){ 104 | window.scrollBy(0, 122500); 105 | } 106 | 107 | goosh.gui.setstyle = function(ele,prop,val){ 108 | try{ 109 | var el = goosh.gui.el(ele); 110 | el.style[prop] = val; 111 | return true; 112 | } 113 | catch(e){ 114 | return false; 115 | } 116 | 117 | } 118 | 119 | goosh.gui.setstyleclass = function(classname,style){ 120 | //goosh.gui.outputel.innerHTML += text; 121 | var div = document.createElement("div"); 122 | var out = "
"; 123 | div.innerHTML = out; 124 | goosh.gui.bodyel.appendChild(div); 125 | 126 | } 127 | 128 | 129 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | goosh.org - the unofficial google shell 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 |
84 |
85 | 86 |
87 |
88 | 89 | 90 | 93 | 96 | 97 |
91 |
92 |
94 | 95 |
98 |
99 |
100 | 101 | 102 | 103 | -------------------------------------------------------------------------------- /lang/lang.js: -------------------------------------------------------------------------------- 1 | goosh.lib.namespace("goosh.lang"); 2 | 3 | goosh.lang.list = { 4 | 'arabic' : 'ar', 5 | 'bulgarian' : 'bg', 6 | 'catalan' : 'ca', 7 | 'chinese' : 'zh', 8 | 'chinese_simplified' : 'zh-cn', 9 | 'chinese_traditional' : 'zh-tw', 10 | 'croatian' : 'hr', 11 | 'czech' : 'cs', 12 | 'danish' : 'da', 13 | 'dutch': 'nl', 14 | 'english' : 'en', 15 | 'estonian' : 'et', 16 | 'filipino' : 'tl', 17 | 'finnish' : 'fi', 18 | 'french' : 'fr', 19 | 'german' : 'de', 20 | 'greek' : 'el', 21 | 'hebrew' : 'iw', 22 | 'hindi' : 'hi', 23 | 'hungarian' : 'hu', 24 | 'indonesian' : 'id', 25 | 'italian' : 'it', 26 | 'japanese' : 'ja', 27 | 'korean' : 'ko', 28 | 'latvian' : 'lv', 29 | 'lithuanian' : 'lt', 30 | 'norwegian' : 'no', 31 | 'persian' : 'fa', 32 | 'polish' : 'pl', 33 | 'portuguese' : 'pt', 34 | 'romanian' : 'ro', 35 | 'russian' : 'ru', 36 | 'serbian' : 'sr', 37 | 'slovak' : 'sk', 38 | 'slovenian' : 'sl', 39 | 'spanish' : 'es', 40 | 'swedish' : 'sv', 41 | 'thai' : 'th', 42 | 'turkish' : 'tr', 43 | 'ukrainian' : 'uk', 44 | 'vietnamese' : 'vi' 45 | }; 46 | 47 | goosh.lang.reverse = new Object(); 48 | for(key in goosh.lang.list) goosh.lang.reverse[goosh.lang.list[key]] =key; 49 | -------------------------------------------------------------------------------- /lib/chop.js: -------------------------------------------------------------------------------- 1 | goosh.lib.chop = function(text){ 2 | 3 | if(text) 4 | while(text.charAt(0) == " ") text = text.substr(1); 5 | 6 | return text; 7 | } 8 | -------------------------------------------------------------------------------- /lib/cookie.js: -------------------------------------------------------------------------------- 1 | goosh.lib.namespace("goosh.lib.cookie"); 2 | 3 | goosh.lib.cookie.list = new Object(); 4 | 5 | /* 6 | goosh.lib.cookie.fetch = function(context,result){ 7 | 8 | goosh.lib.cookie.getfromstr(document.cookie); 9 | 10 | if(goosh.config.user != "guest") { 11 | if(!context) { 12 | goosh.ajax.query("http://goosh.appspot.com/cookie?callback=goosh.lib.cookie.fetch"); 13 | } 14 | else if(goosh.ajax.iscontext(context)){ 15 | 16 | //alert(result); 17 | 18 | goosh.lib.cookie.getfromstr(result,true); 19 | 20 | } 21 | 22 | } 23 | return goosh.lib.cookie.list; 24 | } 25 | */ 26 | 27 | goosh.lib.cookie.getfromstr = function(str,update){ 28 | var ca = str.split(';'); 29 | 30 | for(var i=0;i < ca.length;i++) { 31 | var pair = ca[i].split("="); 32 | var key = goosh.lib.chop(pair[0]); 33 | var val = goosh.lib.chop(pair[1]); 34 | if(update && goosh.lib.cookie.list[key] != val){ 35 | goosh.lib.cookie.set(key,val,365); 36 | } 37 | goosh.lib.cookie.list[key] = val; 38 | } 39 | } 40 | 41 | 42 | goosh.lib.cookie.get = function(name) { 43 | return goosh.lib.cookie.list[name]; 44 | } 45 | 46 | 47 | 48 | goosh.lib.cookie.set = function(name,val,days) { 49 | 50 | var duration = new Date(); 51 | var timespan = duration.getTime() + (days * 24 * 60 * 60 * 1000); 52 | duration.setTime(timespan); 53 | 54 | document.cookie = name+"="+val+"; expires=" + duration.toGMTString(); 55 | 56 | if(goosh.config.user != "guest" && name != "loggedin") { 57 | var del = ""; 58 | if(days<0) {del= "&del=1"; } 59 | goosh.ajax.query("http://goosh.appspot.com/cookie?key="+encodeURIComponent(name)+"&val="+encodeURIComponent(val)+"&callback=goosh.lib.cookie.fetch"+del,true); 60 | } 61 | 62 | goosh.lib.cookie.list[name] = val; 63 | return val; 64 | } 65 | 66 | 67 | goosh.lib.cookie.del = function(name) { 68 | 69 | goosh.lib.cookie.set(name,"",-100); 70 | 71 | goosh.lib.cookie.list[name] = null; 72 | 73 | } 74 | 75 | 76 | goosh.lib.cookie.getall = function(){ 77 | return goosh.lib.cookie.list; 78 | } 79 | -------------------------------------------------------------------------------- /lib/dump.js: -------------------------------------------------------------------------------- 1 | function dump(arr,level) { 2 | var dumped_text = ""; 3 | if(!level) level = 0; 4 | 5 | //The padding given at the beginning of the line. 6 | var level_padding = ""; 7 | for(var j=0;j \"" + value + "\"\n"; 18 | } 19 | } 20 | } else { //Stings/Chars/Numbers etc. 21 | dumped_text = "===>"+arr+"<===("+typeof(arr)+")"; 22 | } 23 | return dumped_text; 24 | } 25 | 26 | 27 | -------------------------------------------------------------------------------- /lib/get.js: -------------------------------------------------------------------------------- 1 | goosh.lib.namespace("goosh.lib"); 2 | 3 | goosh.lib.get = function(name){ 4 | name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]"); 5 | var regexS = "[\\?&]"+name+"=([^&#]*)"; 6 | var regex = new RegExp( regexS ); 7 | var results = regex.exec( window.location.href ); 8 | if( results == null ) 9 | return ""; 10 | else 11 | return decodeURIComponent(results[1]).replace(/\+/g," "); 12 | } 13 | -------------------------------------------------------------------------------- /lib/in_array.js: -------------------------------------------------------------------------------- 1 | goosh.lib.in_array = function (arr,elem) { 2 | var i; 3 | for (i = 0; i < arr.length; i++) { 4 | if (arr[i] == elem) { 5 | return true; 6 | } 7 | } 8 | return false; 9 | }; 10 | 11 | -------------------------------------------------------------------------------- /lib/keyboard.js: -------------------------------------------------------------------------------- 1 | goosh.lib.namespace("goosh.keyboard"); 2 | 3 | goosh.keyboard.suggestions = new Array(); 4 | goosh.keyboard.suggpos = 1; 5 | goosh.keyboard.suggword =""; 6 | 7 | goosh.keyboard.hist = new Array(); 8 | goosh.keyboard.histpos = 0; 9 | goosh.keyboard.histtemp = 0; 10 | 11 | 12 | goosh.keyboard.suggest = function(word){ 13 | 14 | if(goosh.keyboard.suggpos > goosh.keyboard.suggestions[word].length) goosh.keyboard.suggpos =1; 15 | 16 | if(goosh.keyboard.suggestions[word][goosh.keyboard.suggpos]) 17 | goosh.gui.inputfield.value = goosh.keyboard.suggestions[word][goosh.keyboard.suggpos]; 18 | 19 | var d= goosh.gui.inputfield; 20 | if(d.createTextRange){ 21 | var t=d.createTextRange(); 22 | t.moveStart("character",word.length); 23 | t.select() 24 | } else if (d.setSelectionRange){ 25 | d.setSelectionRange(word.length,d.value.length) 26 | } 27 | 28 | } 29 | 30 | 31 | // evil hack for suggest 32 | goosh.keyboard.dummyac = function() { 33 | 34 | this.Suggest_apply = function(el,text,sug,temp){ 35 | 36 | goosh.keyboard.suggestions[text] = sug; 37 | goosh.keyboard.suggest(text); 38 | return true; 39 | } 40 | 41 | }; 42 | 43 | window.google = new Array(); 44 | 45 | window.google.ac = new goosh.keyboard.dummyac(); 46 | 47 | 48 | goosh.keyboard.keyDownHandler = function(event){ 49 | if(!event&&window.event) { 50 | event=window.event; 51 | } 52 | if(event) { 53 | _lastKeyCode=event.keyCode; 54 | } 55 | 56 | // We are backspacing here... 57 | if(event&&event.keyCode==9){ 58 | event.cancelBubble=true; 59 | event.returnValue=false; 60 | // tab = 9, backsp = 8, ctrl =17, r = 82 61 | //output.innerHTML += event.keyCode+"
"; 62 | 63 | var word = goosh.keyboard.suggword; 64 | 65 | if(word !=""){ 66 | if(!goosh.keyboard.suggestions[word]){ 67 | goosh.keyboard.suggpos = 1; 68 | // output.innerHTML += "query
"; 69 | var script = document.createElement('script'); 70 | document.body.appendChild(script); 71 | script.src = "http://www.google.com/complete/search?hl="+goosh.config.lang+"&js=true&qu="+encodeURIComponent(word); 72 | } 73 | else{ 74 | goosh.keyboard.suggpos +=2; 75 | goosh.keyboard.suggest(word); 76 | } 77 | } 78 | return false 79 | } 80 | } 81 | 82 | 83 | 84 | goosh.keyboard.mcursor = function(e){ 85 | var keycode=e.keyCode; 86 | 87 | 88 | if(goosh.keyboard.hist.length>0){ 89 | if(keycode==38 || keycode==40){ 90 | 91 | if(goosh.keyboard.hist[goosh.keyboard.histpos]) { 92 | goosh.keyboard.hist[goosh.keyboard.histpos] = goosh.gui.inputfield.value; 93 | } 94 | else 95 | goosh.keyboard.histtemp = goosh.gui.inputfield.value; 96 | } 97 | 98 | if(keycode==38){ // up 99 | goosh.keyboard.histpos--; 100 | if(goosh.keyboard.histpos<0) goosh.keyboard.histpos =0; 101 | 102 | } 103 | else if(keycode==40){ //down 104 | 105 | goosh.keyboard.histpos++; 106 | if(goosh.keyboard.histpos > goosh.keyboard.hist.length) 107 | goosh.keyboard.histpos = goosh.keyboard.hist.length; 108 | } 109 | 110 | if(keycode==38 || keycode==40){ 111 | 112 | if(goosh.keyboard.hist[goosh.keyboard.histpos]) 113 | goosh.gui.inputfield.value = goosh.keyboard.hist[goosh.keyboard.histpos]; 114 | else 115 | goosh.gui.inputfield.value = goosh.keyboard.histtemp; 116 | 117 | } 118 | 119 | } 120 | 121 | if(keycode!=9 && keycode !=13) 122 | goosh.keyboard.suggword = goosh.gui.inputfield.value; 123 | 124 | if(keycode==13){ 125 | goosh.command(); 126 | } 127 | } 128 | 129 | 130 | -------------------------------------------------------------------------------- /lib/namespace.js: -------------------------------------------------------------------------------- 1 | 2 | // thanks to Michael Schwarz for this function 3 | goosh.lib.namespace = function (ns) 4 | { 5 | var parts = ns.split("."); 6 | var root = window; 7 | 8 | for(var i=0; i"); 13 | goosh.gui.out(""); 14 | //goosh.gui.out(""); 15 | else 16 | goosh.gui.out(""); 17 | 18 | 19 | } 20 | 21 | } 22 | goosh.modules.register("gmail"); 23 | 24 | 25 | -------------------------------------------------------------------------------- /module-exp/login.js: -------------------------------------------------------------------------------- 1 | 2 | goosh.module.login = function(){ 3 | this.name = "login"; 4 | this.aliases = new Array("login"); 5 | 6 | this.help = "login with your google account *"; 7 | this.helptext = "goosh sees only your username"; 8 | this.parameters = ""; 9 | 10 | 11 | this.cb = function(context,username){ 12 | if(goosh.ajax.iscontext(context)){ 13 | if(username && username != "guest") goosh.lib.cookie.set("loggedin","1",365); 14 | 15 | goosh.config.user = username; 16 | if(goosh.config.user != "guest"){ 17 | goosh.gui.outln("You're logged in as: "+goosh.config.user+"
"); 18 | goosh.set.init(); 19 | 20 | goosh.gui.updateprompt(); 21 | goosh.gui.showinput(); 22 | goosh.gui.focusinput(); 23 | goosh.gui.scroll(); 24 | 25 | } 26 | else 27 | goosh.ajax.query("http://goosh.appspot.com/dologin?"); 28 | 29 | 30 | goosh.gui.showinput(); 31 | goosh.gui.focusinput(); 32 | goosh.gui.scroll(); 33 | 34 | 35 | } 36 | } 37 | 38 | this.call = function(args){ 39 | 40 | goosh.ajax.query("http://goosh.appspot.com/status?callback=goosh.modobj.login.cb"); 41 | 42 | } 43 | 44 | } 45 | goosh.modules.register("login"); 46 | 47 | 48 | -------------------------------------------------------------------------------- /module-exp/logout.js: -------------------------------------------------------------------------------- 1 | 2 | goosh.module.logout = function(){ 3 | this.name = "logout"; 4 | this.aliases = new Array("logout"); 5 | 6 | this.help = "log out of goosh *"; 7 | this.helptext = ""; 8 | 9 | this.call = function(args){ 10 | goosh.ajax.query("http://goosh.appspot.com/dologout?"); 11 | if(goosh.ajax.iscontext(goosh.ajax.lastcontext)){ 12 | goosh.config.user = "guest"; 13 | goosh.lib.cookie.del("loggedin"); 14 | goosh.gui.updateprompt(); 15 | goosh.gui.showinput(); 16 | goosh.gui.focusinput(); 17 | goosh.gui.scroll(); 18 | 19 | } 20 | 21 | } 22 | 23 | } 24 | goosh.modules.register("logout"); 25 | 26 | 27 | -------------------------------------------------------------------------------- /module/addengine.js: -------------------------------------------------------------------------------- 1 | 2 | goosh.module.addengine = function(){ 3 | this.name = "addengine"; 4 | this.aliases = new Array("addengine"); 5 | this.help = "add goosh to firefox search box"; 6 | 7 | this.call = function(args){ 8 | engineURL ="http://gshell.grothkopp.com/goosh.xml"; 9 | if (!document.all && window.external && ("AddSearchProvider" in window.external)) { 10 | window.external.AddSearchProvider(engineURL); 11 | } else { 12 | goosh.gui.error("addengine will only work in Firefox-Browsers."); 13 | } 14 | } 15 | 16 | 17 | } 18 | goosh.modules.register("addengine"); 19 | 20 | 21 | -------------------------------------------------------------------------------- /module/blogs.js: -------------------------------------------------------------------------------- 1 | 2 | goosh.module.blogs = function(){ 3 | this.name = "blogs"; 4 | this.aliases = new Array("blogs","blog","b"); 5 | this.mode = true; 6 | 7 | this.parameters = "[keywords]"; 8 | this.help = "google blog search"; 9 | this.helptext = "examples:
"+ 10 | "blog foo bar - searches for "foo bar" blogs
"; 11 | 12 | } 13 | 14 | goosh.modules.register("blogs","web"); 15 | 16 | 17 | -------------------------------------------------------------------------------- /module/calc.js: -------------------------------------------------------------------------------- 1 | 2 | goosh.module.calculate = function(){ 3 | this.name = "calculate"; 4 | this.aliases = new Array("calculate","calc"); 5 | 6 | this.help = "evaluate a mathematical expression"; 7 | this.parameters = "[mathematical expression]"; 8 | 9 | this.call = function(args){ 10 | 11 | var out =""; 12 | 13 | var exp = args.join(" "); 14 | var expin = exp; 15 | 16 | if(exp.match(/^[0-9\+\-\/\*\. \^\(\)]+$/)){ 17 | 18 | exp = exp.replace(/([0-9]+)\^([0-9]+)/g, "Math.pow($1,$2)"); 19 | 20 | goosh.gui.outln(expin+" = "+eval(exp)); 21 | } 22 | else{ 23 | goosh.gui.error("could not calculate that."); 24 | return false; 25 | } 26 | 27 | } 28 | 29 | } 30 | goosh.modules.register("calculate"); 31 | 32 | 33 | -------------------------------------------------------------------------------- /module/cd.js: -------------------------------------------------------------------------------- 1 | 2 | goosh.module.cd = function(){ 3 | this.name = "cd"; 4 | this.aliases = new Array("cd"); 5 | this.parameters = "<command>"; 6 | this.help = "change mode"; 7 | this.helptext = "This exists just for convenience. Use <command> without parameters instead.
"; 8 | 9 | this.call = function(args){ 10 | if(!args[0]) args[0] = goosh.config.mode; 11 | if(args[0] && args[0] =="..") args[0] = "web"; 12 | 13 | if(args[0] && goosh.modules.list[args[0]] && goosh.modules.list[args[0]].mode){ 14 | var searcher = goosh.modules.list[args[0]]; 15 | 16 | goosh.config.mode = searcher.name; 17 | goosh.gui.updateprompt(); 18 | 19 | } 20 | else{ 21 | goosh.gui.error("command not found or command is not a mode."); 22 | } 23 | } 24 | 25 | 26 | } 27 | goosh.modules.register("cd"); 28 | 29 | 30 | -------------------------------------------------------------------------------- /module/clear.js: -------------------------------------------------------------------------------- 1 | 2 | goosh.module.clear = function(){ 3 | this.name = "clear"; 4 | this.aliases = new Array("clear","c"); 5 | this.help = "clear the screen"; 6 | 7 | this.call = function(args){ 8 | goosh.gui.clear(); 9 | } 10 | 11 | 12 | } 13 | goosh.modules.register("clear"); 14 | 15 | 16 | -------------------------------------------------------------------------------- /module/feed.js: -------------------------------------------------------------------------------- 1 | 2 | goosh.module.feeds = function(){ 3 | this.name = "feeds"; 4 | this.aliases = new Array("feeds","feed","f"); 5 | this.mode = true; 6 | this.start = 0; 7 | this.args =""; 8 | 9 | this.parameters = "[keywords]"; 10 | this.help = "google feed search"; 11 | this.helptext = "examples:
"+ 12 | "feed foo bar - searches for "foo bar" feeds
"+ 13 | "read 2 - reads second result
"; 14 | 15 | this.query = function(cmdstr,query) { 16 | 17 | //output.innerHTML += "COMMAND:"+cmdstr+"/"+query+"/"+this.name+".
"; // debug 18 | 19 | 20 | goosh.ajax.query("http://ajax.googleapis.com/ajax/services/feed/find?v=1.0&hl="+goosh.config.lang+"&callback=goosh.modobj."+this.name+".render&q="+encodeURIComponent(query)+'&num=100&key'+goosh.config.apikey+"&"); 21 | } 22 | 23 | 24 | 25 | this.call = function(args){ 26 | if(args.length > 0) 27 | this.start = 0; 28 | this.results = new Array(); 29 | this.args = args.join(" "); 30 | this.query(this.name,args.join(" ")); 31 | } 32 | 33 | 34 | this.render = function(context, results, status, details, unused){ 35 | if(goosh.ajax.iscontext(context)){ 36 | 37 | if(results && results.entries && results.entries.length>0){ 38 | results.results = new Array(); 39 | 40 | for(i=0;i"; 36 | if(module.aliases.length >1){ 37 | out += "("; 38 | for(i=0;iimages foo bar - searches for "foo bar" images
"; 9 | 10 | } 11 | goosh.modules.register("images","web"); 12 | 13 | -------------------------------------------------------------------------------- /module/inurl.js: -------------------------------------------------------------------------------- 1 | goosh.module.site = function(){ 2 | this.name = "site"; 3 | this.aliases = new Array("site","in"); 4 | this.parameters = "<url> <keywords>"; 5 | this.help = "search in a specific website"; 6 | this.mode = false; 7 | 8 | 9 | } 10 | goosh.modules.register("site","web"); 11 | 12 | 13 | -------------------------------------------------------------------------------- /module/load.js: -------------------------------------------------------------------------------- 1 | 2 | goosh.module.load = function(){ 3 | this.name = "load"; 4 | this.aliases = new Array("load"); 5 | this.help = "load an extension"; 6 | this.parameters = "<extension_url>"; 7 | 8 | this.call = function(args){ 9 | if(args[0]){ 10 | var url = args[0]; 11 | if(url.indexOf("http://")==-1 && url.indexOf("https://")) url = "http://gshell.grothkopp.com/ext/"+url+".js"; 12 | var script = document.createElement('script'); 13 | document.body.appendChild(script); 14 | script.src = url; 15 | 16 | } 17 | 18 | } 19 | 20 | 21 | } 22 | goosh.modules.register("load"); 23 | 24 | 25 | -------------------------------------------------------------------------------- /module/ls.js: -------------------------------------------------------------------------------- 1 | 2 | goosh.module.ls = function(){ 3 | this.name = "ls"; 4 | this.aliases = new Array("ls"); 5 | 6 | this.help = "lists commands"; 7 | this.helptext = "this exists just for convenience. Use help for help.
"; 8 | this.parameters = "[command]"; 9 | 10 | this.call = function(args){ 11 | 12 | var out =""; 13 | 14 | if(args[0] && !goosh.modules.list[args[0]]) { 15 | goosh.gui.error("command ""+args[0]+"" not found."); 16 | return false; 17 | } 18 | 19 | out += ""; 20 | 21 | var module; 22 | var i =0; 23 | 24 | for(key in goosh.modules.list){ 25 | if(args.length ==0 || key == args[0]){ 26 | module = goosh.modules.list[key]; 27 | 28 | out += "';} 32 | i++; 33 | } 34 | } 35 | 36 | out += "
"; 31 | if(i==5){ i=0; out += '
"; 37 | 38 | 39 | goosh.gui.outln(out); 40 | } 41 | 42 | } 43 | goosh.modules.register("ls"); 44 | 45 | 46 | -------------------------------------------------------------------------------- /module/lucky.js: -------------------------------------------------------------------------------- 1 | 2 | goosh.module.lucky = function(){ 3 | this.name = "lucky"; 4 | this.aliases = new Array("lucky","l"); 5 | this.mode = false; 6 | 7 | this.parameters = "[keywords]"; 8 | this.help = "go directly to first result"; 9 | this.helptext = "examples:
"+ 10 | "lucky foo bar - goes to first "foo bar" result
"; 11 | 12 | this.call = function(args){ 13 | this.qstart = 0; 14 | if(args.length > 0) 15 | this.query("web",args.join(" ")); 16 | } 17 | 18 | this.render = function(context, results, status, details, unused){ 19 | 20 | if(goosh.ajax.iscontext(context)){ 21 | this.renderResult(context); 22 | 23 | if(results.results[0].unescapedUrl){ 24 | setTimeout('window.location.href = "'+results.results[0].unescapedUrl+'"',0); 25 | } 26 | goosh.gui.showinput(); 27 | goosh.gui.focusinput(); 28 | goosh.gui.scroll(); 29 | 30 | } 31 | } 32 | 33 | } 34 | goosh.modules.register("lucky","web"); 35 | 36 | -------------------------------------------------------------------------------- /module/more.js: -------------------------------------------------------------------------------- 1 | 2 | goosh.module.more = function(){ 3 | this.name = "more"; 4 | this.aliases = new Array("more","m"); 5 | this.help = "get more results"; 6 | 7 | this.call = function(args){ 8 | if(goosh.config.moreobj && goosh.config.moreobj.hasmore){ 9 | goosh.config.moreobj.more(); 10 | } 11 | } 12 | 13 | 14 | } 15 | goosh.modules.register("more"); 16 | 17 | 18 | -------------------------------------------------------------------------------- /module/news.js: -------------------------------------------------------------------------------- 1 | 2 | goosh.module.news = function(){ 3 | this.name = "news"; 4 | this.aliases = new Array("news","n"); 5 | this.mode = true; 6 | 7 | this.parameters = "[keywords]"; 8 | this.help = "google news search"; 9 | this.helptext = "examples:
"+ 10 | "blog foo bar - searches for "foo bar" news
"; 11 | 12 | 13 | } 14 | goosh.modules.register("news","web"); 15 | 16 | 17 | -------------------------------------------------------------------------------- /module/open.js: -------------------------------------------------------------------------------- 1 | 2 | goosh.module.open = function(){ 3 | this.name = "open"; 4 | this.aliases = new Array("open","o"); 5 | this.parameters = "<url>"; 6 | this.help = "open url in new window"; 7 | this.helptext = "examples:
"+ 8 | "open 1 3 - open first and third result from last search
"; 9 | 10 | 11 | this.call = function(args){ 12 | for(i=0;iplace New York - show new york in a map
"; 13 | 14 | this.query = function(cmdstr,query) { 15 | 16 | //output.innerHTML += "COMMAND:"+cmdstr+"/"+query+"/"+this.name+".
"; // debug 17 | 18 | goosh.ajax.query("http://maps.google.com/maps/geo?q="+encodeURIComponent(query)+"&output=json&callback=goosh.modobj."+this.name+".render&key="+goosh.config.apikey+"&lang="+goosh.config.lang); 19 | 20 | } 21 | 22 | 23 | 24 | this.call = function(args){ 25 | if(args.length > 0) 26 | this.start = 0; 27 | this.results = new Array(); 28 | this.args = args.join(" "); 29 | this.query(this.name,args.join(" ")); 30 | } 31 | 32 | 33 | this.render = function(results){ 34 | if(goosh.ajax.iscontext(goosh.ajax.lastcontext)){ 35 | 36 | if(results && results.Placemark){ 37 | results.results = new Array(); 38 | 39 | for(i=0;i= 4) detail = 10; 47 | if(acc >= 6) detail = 14; 48 | results.results[i] = new Array(); 49 | results.results[i].title = r.address; 50 | results.results[i].unescapedUrl = "http://maps.google.com/maps?f=q&hl="+goosh.config.lang+"&q="+encodeURIComponent(r.address)+"¢er="+r.Point.coordinates[1]+","+r.Point.coordinates[0]+"&zoom="+(detail); 51 | results.results[i].content = ""; 52 | results.results[i].thumb = ""; 53 | } 54 | 55 | 56 | } 57 | 58 | this.hasmore = true; 59 | this.results = results.results; 60 | this.renderResult(goosh.ajax.lastcontext, results); 61 | } 62 | else { 63 | goosh.gui.error("Place ""+this.args+"" not found."); 64 | } 65 | 66 | if(this.results.length <= this.start+ parseInt(goosh.config.numres)){ 67 | this.hasmore = false; 68 | moreobj = false; 69 | 70 | } 71 | 72 | 73 | goosh.gui.showinput(); 74 | goosh.gui.focusinput(); 75 | goosh.gui.scroll(); 76 | } 77 | 78 | return true; 79 | } 80 | 81 | this.more = function(){ 82 | if(this.args){ 83 | this.start += parseInt(goosh.config.numres); 84 | //this.query(this.name,this.args); 85 | 86 | if(this.results.length <= this.start+ parseInt(goosh.config.numres)){ 87 | this.hasmore = false; 88 | moreobj = false; 89 | 90 | } 91 | this.renderResult(); 92 | 93 | } 94 | 95 | } 96 | 97 | 98 | } 99 | goosh.modules.register("place","web"); 100 | 101 | 102 | -------------------------------------------------------------------------------- /module/read.js: -------------------------------------------------------------------------------- 1 | 2 | goosh.module.read = function(){ 3 | this.name = "read"; 4 | this.aliases = new Array("read","rss","r"); 5 | this.mode = false; 6 | this.start = 0; 7 | 8 | this.parameters = "<url>"; 9 | this.help = "read feed of url"; 10 | this.helptext = "examples:
"+ 11 | "read reddit.com - read reddit.com-feed
"; 12 | 13 | this.query = function(cmdstr,query) { 14 | 15 | // output.innerHTML += "COMMAND:"+cmdstr+"/"+query+"/"+this.name+".
"; // debug 16 | 17 | goosh.ajax.query("http://ajax.googleapis.com/ajax/services/feed/load?v=1.0&hl="+goosh.config.lang+"&callback=goosh.modobj."+this.name+".render&num=100&scoring=h&q="+encodeURIComponent(query)+"&key="+goosh.config.apikey); 18 | } 19 | 20 | this.lookup = function(cmdstr,query) { 21 | 22 | // output.innerHTML += "lookup:"+cmdstr+"/"+query+"/"+this.name+".
"; // debug 23 | 24 | 25 | goosh.ajax.query("http://ajax.googleapis.com/ajax/services/feed/lookup?v=1.0&hl="+goosh.config.lang+"&callback=goosh.modobj."+this.name+".lookupdone&q="+encodeURIComponent(query)+"&key="+goosh.config.apikey); 26 | } 27 | 28 | 29 | this.lookupdone = function(context, results, status, details, unused){ 30 | if(results){ 31 | if(results.url){ 32 | if(goosh.ajax.iscontext(context)) 33 | this.query(this.name,results.url); 34 | } 35 | } 36 | else { 37 | goosh.gui.error("feed ""+this.args+"" not found.
Try the "feed"-command to find feeds."); 38 | } 39 | } 40 | 41 | this.call = function(args){ 42 | if(args.length > 0){ 43 | this.start =0; 44 | this.results = new Array(); 45 | this.args = args.join(" "); 46 | this.lookup(this.name,args.join(" ")); 47 | 48 | } 49 | } 50 | 51 | 52 | 53 | this.render = function(context, results, status, details, unused){ 54 | if(goosh.ajax.iscontext(context)){ 55 | 56 | if(results){ 57 | results.results = new Array(); 58 | 59 | for(i=0;i Try the "feed"-command to find feeds."); 84 | } 85 | } 86 | } 87 | 88 | this.more = function(){ 89 | 90 | if(this.args){ 91 | this.start += parseInt(goosh.config.numres); 92 | 93 | if(this.results.length <= this.start + parseInt(goosh.config.numres)){ 94 | this.hasmore = false; 95 | moreobj = false; 96 | 97 | } 98 | 99 | 100 | 101 | this.renderResult(); 102 | 103 | } 104 | 105 | 106 | } 107 | 108 | } 109 | goosh.modules.register("read","web"); 110 | 111 | 112 | -------------------------------------------------------------------------------- /module/settings.js: -------------------------------------------------------------------------------- 1 | 2 | goosh.module.settings = function(){ 3 | this.name = "settings"; 4 | this.aliases = new Array("settings","set"); 5 | 6 | this.help = "edit settings"; 7 | this.parameters = "[name] [value]"; 8 | 9 | this.helptext = "examples:
"+ 10 | "set lang de - sets language to german
"+ 11 | "set lang - displays value of lang-setting
"+ 12 | "settings - displays all settings
"+ 13 | "settings reset - reset all settings to default values
"; 14 | 15 | 16 | this.call = function(args){ 17 | 18 | var out =""; 19 | 20 | if(args[0] && args[1]){ 21 | if(goosh.set.list[args[0]] && goosh.set.list[args[0]].set(args[1])){ 22 | 23 | if(goosh.set.list[args[0]].get() == goosh.set.list[args[0]].def) 24 | goosh.lib.cookie.del(args[0]); 25 | else 26 | goosh.lib.cookie.set(args[0],goosh.set.list[args[0]].get(),365); 27 | 28 | args[1] =false; 29 | } 30 | else { 31 | goosh.gui.error("Could not set "+args[0]+" to ""+args[1]+"""); 32 | return false; 33 | } 34 | } 35 | 36 | if(args[0] && !args[1]) { 37 | if(args[0] == "reset"){ 38 | for(key in goosh.set.list){ 39 | goosh.set.list[key].set(goosh.set.list[key].def); 40 | goosh.lib.cookie.del(key); 41 | } 42 | out += "Settings where set to default values."; 43 | } 44 | else if(goosh.set.list[args[0]]){ 45 | out += args[0]+" is set to ""+goosh.set.list[args[0]].get()+"".
"; 46 | } 47 | else 48 | goosh.gui.error("No setting with that name."); 49 | } 50 | else{ 51 | out += ""; 52 | out += "" 53 | 54 | for(key in goosh.set.list){ 55 | out += ""; 58 | out += "" 59 | out += "" 60 | out += "" 61 | out += ''; 62 | } 63 | 64 | out += "
namevaluedefaulthelp
"+goosh.set.list[key].get()+""+goosh.set.list[key].def+""+goosh.set.list[key].txt+"
"; 65 | 66 | } 67 | goosh.gui.outln(out); 68 | //alert(document.cookie); 69 | } 70 | 71 | } 72 | goosh.modules.register("settings"); 73 | 74 | 75 | -------------------------------------------------------------------------------- /module/translate.js: -------------------------------------------------------------------------------- 1 | 2 | goosh.module.translate = function(){ 3 | this.name = "translate"; 4 | this.aliases = new Array("translate","trans","t"); 5 | this.mode = true; 6 | this.args =""; 7 | 8 | this.parameters = "[lang1] [lang2] <words>"; 9 | this.help = "google translation"; 10 | this.helptext = "examples:
"+ 11 | "translate en de What time is it? - translate "What time is it?" from english to german
"+ 12 | "translate fr What time is it? - translate "What time is it?" to french
"+ 13 | "translate Wie spät ist es? - translates "Wie spät ist es?" to your default language. language of text will be guessed.
"; 14 | 15 | this.query = function(cmdstr,args) { 16 | 17 | goosh.ajax.query("http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q="+encodeURIComponent(this.text)+"&langpair="+this.lang1+"%7C"+this.lang2+"&callback=goosh.modobj."+this.name+".render"+'&key='+goosh.config.apikey); 18 | } 19 | 20 | this.guess = function(text) { 21 | 22 | goosh.ajax.query("http://ajax.googleapis.com/ajax/services/language/detect?v=1.0&q="+encodeURIComponent(text)+"&callback=goosh.modobj."+this.name+".guessresult"+'&key='+goosh.config.apikey); 23 | } 24 | 25 | 26 | this.guessresult = function(context, results, status, details, unused){ 27 | if(goosh.ajax.iscontext(context)){ 28 | if(results){ 29 | if(results.language){ 30 | this.lang1 = results.language; 31 | if(!this.lang2) this.lang2 = goosh.config.lang; 32 | 33 | this.query(); 34 | 35 | }else{ 36 | goosh.gui.error("could not guess language."); 37 | } 38 | } 39 | } 40 | 41 | 42 | 43 | } 44 | 45 | this.renderResult = function(context, results, status, details, unused){ 46 | var out = ""; 47 | var rnum = this.start; 48 | if(goosh.ajax.iscontext(context)){ 49 | if(results){ 50 | if(results.translatedText){ 51 | goosh.gui.outln("translating ""+this.text+"" from "+goosh.gui.info(goosh.lang.reverse[this.lang1])+" to "+goosh.gui.info(goosh.lang.reverse[this.lang2])+":"); 52 | goosh.gui.outln(''); 53 | goosh.gui.outln(goosh.gui.info("""+results.translatedText+""")); 54 | goosh.gui.outln(''); 55 | }else{ 56 | goosh.gui.error("no translation found."); 57 | } 58 | } 59 | 60 | 61 | goosh.gui.showinput(); 62 | goosh.gui.focusinput(); 63 | goosh.gui.scroll(); 64 | } 65 | } 66 | 67 | 68 | 69 | this.call = function(args){ 70 | this.args = args; 71 | this.lang1 = false; 72 | this.lang2 = false; 73 | 74 | if(args.length > 2 && (goosh.lang.list[args[0]] || goosh.lang.reverse[args[0]]) && (goosh.lang.list[args[1]] || goosh.lang.reverse[args[1]])){ 75 | 76 | if(goosh.lang.list[args[0]]) 77 | this.lang1 = goosh.lang.list[args[0]]; 78 | else 79 | this.lang1 = args[0]; 80 | 81 | if(goosh.lang.list[args[1]]) 82 | this.lang2 = goosh.lang.list[args[1]]; 83 | else 84 | this.lang2 = args[1]; 85 | 86 | this.text = args[2]; 87 | for(i=3;ivideo foo bar - searches for "foo bar" videos
"; 11 | 12 | 13 | } 14 | goosh.modules.register("video","web"); 15 | 16 | 17 | -------------------------------------------------------------------------------- /module/web.js: -------------------------------------------------------------------------------- 1 | //google.load("search", "1"); 2 | 3 | goosh.module.web = function(){ 4 | this.name = "web"; 5 | this.aliases = new Array("web","search","s","w"); 6 | this.mode = true; 7 | this.start = 0; 8 | this.args =""; 9 | 10 | this.parameters = "[keywords]"; 11 | this.help = "google web search"; 12 | this.helptext = "examples:
"+ 13 | "web foo bar - searches the web for "foo bar"
"; 14 | 15 | this.query = function(cmdstr,query) { 16 | 17 | // goosh.gui.outln("COMMAND:"+cmdstr+"/"+query+"/"+this.name+".
"); 18 | 19 | goosh.ajax.query("http://ajax.googleapis.com/ajax/services/search/"+cmdstr+"?v=1.0&start="+this.qstart+"&hl="+goosh.config.lang+"&callback=goosh.modobj."+this.name+".render&q="+encodeURIComponent(query)+'&key='+goosh.config.apikey+"&rsz=large"); 20 | } 21 | 22 | 23 | this.renderResult = function(context, results, status, details, unused){ 24 | var out = ""; 25 | var rnum = this.start; 26 | 27 | //out += this.start+","+goosh.config.numres+","+this.results.length+ 28 | out += ""; 29 | 30 | for (i = this.start; i < (this.start + parseInt(goosh.config.numres)); i++) 31 | if(this.results[i]) 32 | { 33 | var r = this.results[i]; 34 | 35 | rnum++; 36 | goosh.config.urls[rnum] = r.unescapedUrl; 37 | r.unescapedUrl = r.unescapedUrl.replace(/"/g,"""); 38 | 39 | out += ""; 40 | out += "" 41 | out += ""; 50 | } 51 | 52 | goosh.gui.out(out + "
  "+rnum+") "; 42 | out += ''+r.title+""; 43 | out += "
"; 44 | out += r.content; 45 | out += "
"; 46 | out += ''+r.unescapedUrl+""; 47 | out += "
"; 48 | if(r.thumb) out += ''+r.thumb+"
"; 49 | out += " 
"); 53 | //yield(); 54 | } 55 | 56 | 57 | 58 | this.call = function(args){ 59 | if(args.length > 0){ 60 | this.start = 0; 61 | this.qstart = 0; 62 | this.results = new Array(); 63 | this.args = args.join(" "); 64 | if(args.length>1 && this.name=="site") { 65 | //this.name = "web"; 66 | this.args = "site:"+this.args; 67 | this.cmd = "web"; 68 | } 69 | else if( this.name=="wiki") { 70 | //this.name = "web"; 71 | this.args = "site:"+goosh.config.lang+".wikipedia.org "+this.args; 72 | this.cmd = "web"; 73 | } 74 | else this.cmd = this.name; 75 | 76 | this.query(this.cmd,this.args); 77 | } 78 | } 79 | 80 | this.more = function(){ 81 | if(this.args){ 82 | this.start += parseInt(goosh.config.numres); 83 | this.qstart = this.results.length; 84 | //this.qstart += parseInt(goosh.config.numres); 85 | if(this.results.length < this.start + parseInt(goosh.config.numres)) 86 | this.query(this.cmd,this.args); 87 | else 88 | this.renderResult(); 89 | 90 | } 91 | } 92 | 93 | 94 | this.render = function(context, results, status, details, unused){ 95 | if(goosh.ajax.iscontext(context)){ 96 | if(results && results.results){ 97 | 98 | for(i=0;i"; 105 | else if(this.name =="video"){ 106 | results.results[i].thumb = "";; 107 | results.results[i].unescapedUrl = r.playUrl; 108 | 109 | } 110 | 111 | this.results.push(results.results[i]); 112 | } 113 | 114 | this.hasmore = true; 115 | 116 | if(results.results.length < 8){ 117 | this.hasmore = false; 118 | moreobj = false; 119 | } 120 | } 121 | else{ 122 | this.hasmore = false; 123 | moreobj = false; 124 | } 125 | 126 | if(this.hasmore && this.results.length < this.start + parseInt(goosh.config.numres)){ 127 | this.qstart = this.results.length; 128 | this.query(this.cmd,this.args); 129 | return 130 | } 131 | 132 | if(results && results.cursor && results.cursor["moreResultsUrl"]) 133 | this.moreresurl = results.cursor["moreResultsUrl"]; 134 | 135 | if(!this.hasmore && this.moreresurl){ 136 | r = new Object(); 137 | 138 | // goosh.gui.outln("EWEWR"); 139 | r.title = "More results at google"; 140 | r.unescapedUrl = unescape(this.moreresurl); 141 | r.content = ""; 142 | this.results.push(r); 143 | 144 | } 145 | 146 | this.renderResult(context, results, status, details, unused); 147 | 148 | 149 | goosh.gui.showinput(); 150 | goosh.gui.focusinput(); 151 | goosh.gui.scroll(); 152 | } 153 | } 154 | 155 | } 156 | goosh.modules.register("web"); 157 | 158 | 159 | -------------------------------------------------------------------------------- /module/wiki.js: -------------------------------------------------------------------------------- 1 | goosh.module.wiki = function(){ 2 | this.name = "wiki"; 3 | this.aliases = new Array("wikipedia","wiki"); 4 | this.mode = true; 5 | this.help = "wikipedia search"; 6 | this.helptext = "examples:
"+ 7 | "wiki foo bar - searches "foo bar" in wikipedia
"; 8 | 9 | 10 | } 11 | goosh.modules.register("wiki","web"); 12 | 13 | 14 | -------------------------------------------------------------------------------- /modules/modules.js: -------------------------------------------------------------------------------- 1 | goosh.lib.namespace("goosh.modules"); 2 | goosh.lib.namespace("goosh.module"); 3 | goosh.lib.namespace("goosh.modobj"); 4 | 5 | //function yield(){ 6 | // if(cmdqueue.length >0) command(cmdqueue.pop()); 7 | //} 8 | 9 | 10 | goosh.modules.list = new Array(); 11 | 12 | 13 | goosh.module.base = function(){ 14 | 15 | this.mode = false; 16 | // this.more = false; 17 | this.parameters = ""; 18 | this.help = "no helptext yet."; 19 | this.helptext = ""; 20 | this.hasmore = false; 21 | this.results = new Array(); 22 | 23 | } 24 | 25 | goosh.modules.register = function(name,base){ 26 | if(!base) base = "base"; 27 | eval(//"search_"+name+".prototype = new search_"+base+"();"+ 28 | //"searchers_"+name+" = new search_"+name+"();"+ 29 | 'goosh.module.'+name+'.prototype = new goosh.module.'+base+';'+ 30 | 'goosh.modobj.'+name+' = new goosh.module.'+name+';'+ 31 | 'goosh.modules.list["'+name+'"] = goosh.modobj.'+name+";"); 32 | } 33 | 34 | /* 35 | include("goosh/module/web.js"); 36 | 37 | if ($handle = opendir('goosh/module')) { 38 | while (false !== ($file = readdir($handle))) { 39 | if($file[0] != "." && $file != "web.js") include("goosh/module/".$file); //echo "$file\n"; 40 | } 41 | 42 | closedir($handle); 43 | } 44 | 45 | if ($handle = opendir('goosh/module-exp')) { 46 | while (false !== ($file = readdir($handle))) { 47 | if($file[0] != "." && $file != "web.js") include("goosh/module-exp/".$file); //echo "$file\n"; 48 | } 49 | 50 | closedir($handle); 51 | } 52 | */ 53 | -------------------------------------------------------------------------------- /searchers/lang.js: -------------------------------------------------------------------------------- 1 | 2 | function search_lang(){ 3 | this.name = "lang"; 4 | this.aliases = new Array("lang"); 5 | this.parameters = "<language>"; 6 | this.help = "change language"; 7 | this.helptext = "use the two-letter language codes used by google.
"; 8 | 9 | this.call = function(args){ 10 | if(args[0]){ 11 | if(languages[args[0]]) args[0] =languages[args[0]]; 12 | 13 | if(langreverse[args[0]]){ 14 | 15 | var url = "http://gshell.grothkopp.com/?lang="+args[0]; 16 | document.location = url; 17 | 18 | } 19 | else { 20 | 21 | output.innerHTML += "language ""+args[0]+"" not found.

"; 22 | } 23 | } 24 | else{ 25 | output.innerHTML += "language is: "+langreverse[lang]+" ("+lang+")

"; 26 | } 27 | } 28 | 29 | 30 | } 31 | register_searcher("lang"); 32 | 33 | 34 | -------------------------------------------------------------------------------- /set/set.js: -------------------------------------------------------------------------------- 1 | goosh.lib.namespace("goosh.set"); 2 | 3 | goosh.set.base = function(name,def,txt,min,max){ 4 | this.name = name; 5 | this.txt = txt; 6 | this.def = def; 7 | (max) ? this.max = max : this.max = 2000; 8 | (min) ? this.min = min : this.min = 0; 9 | 10 | if(min && max) this.txt += " ("+min+".."+max+")"; 11 | 12 | this.get = function() { return eval (""+this.name+";"); }; 13 | this.set = function(val) { if(val >= this.min && val <= this.max) eval (""+this.name+" = '"+val+"';"); return true; }; 14 | 15 | } 16 | 17 | goosh.set.list = new Object(); 18 | goosh.set.list['lang'] = new goosh.set.base("goosh.config.lang","en","google default language"); 19 | goosh.set.list['lang'].set = function(val) { 20 | if (goosh.lang.reverse[val]) goosh.config.lang = val; 21 | else if (goosh.lang.list[val]) goosh.config.lang = goosh.lang.list[val]; 22 | else return false; 23 | return true; 24 | }; 25 | 26 | goosh.set.list['results'] = new goosh.set.base("goosh.config.numres","4","number of results for google-searches",1,100); 27 | goosh.set.list['timeout'] = new goosh.set.base("goosh.config.timeout","4","timeout for ajax requests in seconds",1,100); 28 | 29 | goosh.set.list['style.bg'] = new goosh.set.base("goosh.config.bgcolor","#FFFFFF","goosh background color"); 30 | goosh.set.list['style.bg'].set = function(val){ 31 | if( goosh.gui.setstyle("body","backgroundColor",val) && 32 | goosh.gui.setstyle("inputfield","backgroundColor",val)){ 33 | goosh.config.bgcolor = val; 34 | return true; 35 | } 36 | else return false; 37 | } 38 | 39 | goosh.set.list['style.fg'] = new goosh.set.base("goosh.config.fgcolor","#000000","goosh font color"); 40 | goosh.set.list['style.fg'].set = function(val){ 41 | if( goosh.gui.setstyle("body","color",val) && 42 | goosh.gui.setstyle("inputfield","color",val)){ 43 | goosh.config.fgcolor = val; 44 | return true; 45 | } 46 | else return false; 47 | } 48 | 49 | goosh.set.list['style.hl'] = new goosh.set.base("goosh.config.hlcolor","#009900","goosh highlight color"); 50 | goosh.set.list['style.hl'].set = function(val){ 51 | goosh.gui.setstyleclass(".info","color: "+val); 52 | goosh.gui.setstyleclass("a:visited.info","color: "+val); 53 | goosh.config.hlcolor = val; 54 | return true; 55 | } 56 | 57 | goosh.set.list['style.sh'] = new goosh.set.base("goosh.config.shcolor","#666666","goosh 'shaded' color"); 58 | goosh.set.list['style.sh'].set = function(val){ 59 | goosh.gui.setstyleclass(".less","color: "+val); 60 | goosh.config.shcolor = val; 61 | return true; 62 | } 63 | 64 | 65 | goosh.set.list['style.link'] = new goosh.set.base("goosh.config.linkcolor","#0000CC","goosh link color"); 66 | goosh.set.list['style.link'].set = function(val){ 67 | goosh.gui.setstyleclass("a","color: "+val); 68 | goosh.config.linkcolor = val; 69 | return true; 70 | } 71 | 72 | 73 | goosh.set.list['style.vlink'] = new goosh.set.base("goosh.config.vlinkcolor","#551a8b","goosh visited link color"); 74 | goosh.set.list['style.vlink'].set = function(val){ 75 | goosh.gui.setstyleclass("a:visited","color: "+val); 76 | goosh.config.vlinkcolor = val; 77 | return true; 78 | } 79 | 80 | 81 | // #551a8b 82 | 83 | //goosh.gui.setstyleclass 84 | 85 | 86 | 87 | goosh.set.list['place.width'] = new goosh.set.base("goosh.config.mapwidth","300","width of map image",20,600); 88 | goosh.set.list['place.height'] = new goosh.set.base("goosh.config.mapheight","150","height of map image",20,500); 89 | 90 | goosh.set.init = function(context,result){ 91 | 92 | if(goosh.config.user != "guest") { 93 | if(!context) { 94 | goosh.ajax.query("http://goosh.appspot.com/cookie?callback=goosh.set.init"); 95 | return; 96 | } 97 | else if(goosh.ajax.iscontext(context)){ 98 | 99 | goosh.gui.outln("Loading remote settings..."); 100 | //alert(result); 101 | goosh.lib.cookie.getfromstr(document.cookie); 102 | goosh.lib.cookie.getfromstr(result,true); 103 | 104 | } 105 | 106 | } 107 | else { 108 | goosh.gui.outln("Loading local settings..."); 109 | goosh.lib.cookie.getfromstr(document.cookie); 110 | } 111 | 112 | var cookies = goosh.lib.cookie.getall(); 113 | 114 | for(key in goosh.set.list){ 115 | var c = false; 116 | if(cookies[key]) c = cookies[key]; 117 | if(c && goosh.set.list[key].set(c)) { 118 | goosh.gui.outln(" "+key+" => ""+c+""."); 119 | } 120 | else{ 121 | goosh.set.list[key].set(goosh.set.list[key].def); 122 | // goosh.gui.outln(key+" = ""+goosh.set.list[key].get()+""."); 123 | } 124 | } 125 | 126 | goosh.gui.outln(""); 127 | // goosh.gui.updateprompt(); 128 | // goosh.gui.showinput(); 129 | // goosh.gui.focusinput(); 130 | goosh.getquery(); 131 | 132 | } 133 | 134 | 135 | -------------------------------------------------------------------------------- /style.css: -------------------------------------------------------------------------------- 1 | html 2 | { 3 | height: 100%; 4 | } 5 | 6 | body 7 | { 8 | font-size: 12px; 9 | font-family: monospace; 10 | height: 99%; 11 | margin:0px; 12 | padding: 0px; 13 | } 14 | 15 | form 16 | { 17 | padding: 0px; 18 | margin: 0px; 19 | } 20 | 21 | pre 22 | { 23 | font-size: 12px; 24 | } 25 | 26 | br 27 | { 28 | clear: both; 29 | } 30 | 31 | :focus 32 | { 33 | outline: 0; 34 | } 35 | 36 | input.cmdline 37 | { 38 | border: none; 39 | border: 0px; 40 | font-size: 12px; 41 | font-family: monospace; 42 | padding: 0px; 43 | margin:0px; 44 | width:100%; 45 | } 46 | 47 | table.inputtable 48 | { 49 | width:100%; 50 | vertical-align:top; 51 | } 52 | 53 | td.inputtd 54 | { 55 | width:100%; 56 | } 57 | 58 | #input 59 | { 60 | margin-left: 8px; 61 | color: #666; 62 | overflow: hidden; 63 | } 64 | 65 | #output 66 | { 67 | margin-left: 8px; 68 | margin-top: 8px; 69 | } 70 | 71 | .less 72 | { 73 | color: #666; 74 | } 75 | 76 | .info 77 | { 78 | color: #090; 79 | } 80 | 81 | table 82 | { 83 | padding: 0px; 84 | margin: 0px; 85 | border-collapse: collapse; 86 | border-spacing: 0px; 87 | } 88 | 89 | td 90 | { 91 | padding: 0px; 92 | margin: 0px; 93 | vertical-align: top; 94 | font-size: 12px; 95 | font-family: monospace; 96 | } 97 | 98 | .help td 99 | { 100 | padding-right: 25px; 101 | font-size: 12px; 102 | } 103 | 104 | div#prompt 105 | { 106 | display: inline; 107 | white-space:nowrap; 108 | padding:0px; 109 | margin:0px; 110 | } 111 | 112 | img 113 | { 114 | border: none; 115 | } 116 | --------------------------------------------------------------------------------