home *** CD-ROM | disk | FTP | other *** search
/ PC World 2005 March / PCWorld_2005-03_cd.bin / komunikace / kmeleon / kmeleon09.exe / aggreg8.jar / content / getrss.js < prev    next >
Text File  |  2004-11-30  |  2KB  |  76 lines

  1. function httpGet(aURL){
  2.     if(rssLoading){
  3.     httpReq.abort();
  4.     rssLoading = false;
  5.     }
  6.     
  7.     responseXML = null;
  8.     
  9.     httpReq = new XMLHttpRequest();
  10.     httpReq.onload = httpLoaded;    
  11.     httpReq.onerror = httpError;
  12.     httpReq.onreadystatechange = httpReadyStateChange;
  13.     
  14.     
  15.     try{
  16.     httpReq.open("GET" , aURL);
  17.     httpReq.setRequestHeader("User-Agent", USER_AGENT);
  18.     httpReq.overrideMimeType("application/xml");
  19.     }catch(e){
  20.     //httpGetResult(RESULT_ERROR_FAILURE);
  21.     aggreg8dump("RESULT_ERROR_FAILURE");
  22.     Parser(RESULT_ERROR_FAILURE,responseXML);
  23.     }
  24.     
  25.     try{
  26.     httpReq.send(null);
  27.     rssLoading = true;
  28.     }catch(e){
  29.     //httpGetResult(RESULT_ERROR_FAILURE);
  30.     aggreg8dump("RESULT_ERROR_FAILURE");
  31.     Parser(RESULT_ERROR_FAILURE,responseXML);
  32.     }
  33. }
  34.  
  35. function httpError(e){aggreg8dump(e);}
  36. function httpReadyStateChange(){
  37.     
  38.     if(httpReq.readyState == 2){
  39.     try{
  40.         if(httpReq.status == 404){
  41.         aggreg8dump("RESULT_NOT_FOUND");
  42.         Parser(RESULT_NOT_FOUND,responseXML);
  43.         //httpGetResult(RESULT_NOT_FOUND);
  44.         }
  45.     }catch(e){
  46.         aggreg8dump("RESULT_NOT_AVAILABLE");
  47.         Parser(RESULT_NOT_AVAILABLE,responseXML);
  48.         //httpGetResult(RESULT_NOT_AVAILABLE);
  49.         return;
  50.     }
  51.     }else if(httpReq.readyState == 3){}
  52. }
  53.  
  54. function httpLoaded(e){
  55.     responseXML = httpReq.responseXML;
  56.     var rootNodeName = responseXML.documentElement.localName.toLowerCase();
  57.     
  58.     switch(rootNodeName){
  59.     case "parsererror":
  60.         // XML Parse Error
  61.         Parser(RESULT_PARSE_ERROR,responseXML);
  62.         break;
  63.     case "rss":
  64.     case "rdf":
  65.     case "feed":
  66.         aggreg8dump("Sending to Parser" + responseXML);
  67.         Parser(RESULT_OK,responseXML);
  68.        
  69.         break;
  70.     default:
  71.         // Not RSS or ATOM
  72.         Parser(RESULT_NOT_RSS,responseXML);
  73.         break;
  74.     }
  75. }
  76.