I want to make a command line interface with javascript. So that it can search google , wiki & google image simultaneously . Here's the syntax i want to use for google search g_search term. I made a form with a input field with id= text1 . I gave the form an onSubmit=return main() event. And here's the java script in external js file.
Code:
function main(){var inputdata=document.getElementById('text1').value;
var part=inputdata.split('_');
var cmd=part[0];
var arg=part[1];
var enarg=encodeURIComponent(arg);
run();return false;}


function run(){

if(cmd=='g'){g();};

if(cmd=='gi'){gi();};

if(cmd=='wiki'){w();};

if(cmd=='al'){al();};}



function g(){location.href='http://google.com/search/?q='+enarg}


function gi(){location.href='http://googld.com/images/?q='+enarg}

function w(){location.href='http://en.wikipedia.org/wiki/speacial:search/?search='+enarg}

function al(){alert('+arg+')}
but it's not working pls help me out.