// // Asterisk -- A telephony toolkit for Linux. // // test.js Example Javascript IVR // // Copyright (C) 2005, Anthony Minessale II // // Anthony Minessale II // // This program is free software, distributed under the terms of // the GNU General Public License // // SPECIAL VARS // // Argv[] : An array of the : (colon) seperated args // argc : The number of args // Chan : The interface to the asterisk channel // // METHODS of Chan // // Chan.GetVar("varname") // Chan.SetVar("varname","val") // Chan.StreamFile("filename") // Chan.RecordFile("filename.format", "silence", "maxduration", "options") // *Chan.Exec("App","Data") // *Chan.ExecFunc("ENV(HOME)") // Chan.Hangup() // Chan.Answer() // Chan.GetDigits("file",maxdigits) // Chan.WaitForDigit(timeout_ms) // Chan.Wait(timeout_ms) // Chan.Up([true]) // Chan.StartMusic([class]) // Chan.StopMusic() // Chan.SetMusic([class]) // // Read-Only Members of Chan // // Chan.name // Chan.context // Chan.exten // Chan.priority // Chan.callerid_num // Chan.callerid_name // Chan.musicclass // // BUILT-IN FUNCTONS // // Verbose(level,"MESSAGE") // Log("LOG_TYPE","MESSAGE") // FetchURL() // *Include("/path/to/js/file") // *GetVar("GLOBALVARNAME") // Die("so long cruel world!") // // (* indicates skipped or impacted when security flag is on.) Chan.Up(true); // make sure channel is up optional 'true' means end the script/call if it's not Chan.Answer() // play music for 5 seconds Chan.StartMusic(); Chan.Wait(5000); Chan.StopMusic(); //pull some data in from a url and put name/value pairs into pre-declared 'myhash' myhash = new Array(); FetchURL("http://some.site.com/url.cgi","myhash"); for ( testKey in myhash ) { Verbose(0,"myhash key " + testKey + " = " + myhash[testKey] + "\n"); } for(x=0;x