Page 285 - Asterisk™: The Future of Telephony
P. 285

Prototype also makes it easy to make XMLHttp requests in an elegant manner. Using
               Prototype’s Ajax object, the submitform() function can be rewritten as:
                   <script language="javascript" type="text/javascript">
                   function submitform(){
                      var url = '/rawman';
                      var pars = 'username=' + escape($F('username')) + '&secret=' + escape($F('password'));

                   var myAjax = new Ajax.Request( url,
                     { method: 'get',
                       parameters: pars,
                       onComplete: dosomething
                     });

                   }
                   </script>
               Not only is this code much shorter, you don’t have to write browser-specific code in
               your web pages; Prototype takes care of the differences between Mozilla/Firefox and
               the various versions of Internet Explorer. Furthermore, it takes care of testing the re-
               quest’s  readyState,  so  you  leave  that  annoying  if  statement  out  of  your  handler.
               Prototype has lots of built-in functions, some of which have been extensively used in
               the Asterisk framework. There’s no room to discuss them here, but for more informa-
               tion,  see  the  Short  Cuts  Prototype  Quick  Reference  by  Scott  Raymond  and
               Prototype and Scriptaculous: Taking the Pain Out of JavaScript by Chris Angus, both
               from O’Reilly.

               Customization of the GUI

               Now that we’ve explored the different pieces that form the foundation of the Asterisk
               GUI, we have what we need to be able to explore the GUI itself and modify it to fit our
               needs. To get to the Asterisk GUI, go to the following address in your browser: http://
               localhost:8088/asterisk/static/config/cfgbasic.html.
               Looking at Figure 11-1 might lead you to conclude that the Asterisk GUI is simply one
               more Asterisk GUI in an already crowded space. Nothing could be further from the
               truth. This GUI doesn’t just allow you to tweak it, it practically begs you to. In this
               section we are going to discuss how you can modify the GUI and use AJAM to build
               your own extensions to the GUI. In order to benefit the most from this information,
               you need some HTML and JavaScript knowledge.
               The GUI home page is named cfgbasic.html. All other pages are loaded into the iframe
               contained within the cfgbasic.html page. By default, cfgbasic.html loads home.html into
               the main frame.

               For most changes to the GUI, you’ll eventually need to modify cfgbasic.html, which is
               the login screen.





                                                                Developing for the Asterisk GUI | 257
   280   281   282   283   284   285   286   287   288   289   290