home *** CD-ROM | disk | FTP | other *** search
/ Mundo do CD-ROM 118 / cdrom118.iso / internet / webaroo / WebarooSetup.exe / Webaroo.msi / _3A558235DF5A47B2AFE014741014F2D5 < prev    next >
Encoding:
Text File  |  2006-03-20  |  11.8 KB  |  377 lines

  1. // JavaScript Document
  2.  
  3. var packs_found = 0;
  4. var serverSubscriptionXml;
  5.  
  6. function ShowOnlineStore(addToHistory)
  7. {
  8.     if(addToHistory)
  9.     {
  10.         dhtmlHistory.add("onlinestore","");
  11.     }
  12.     AdjustPageElements("store");
  13.     AbortPendingRequests();
  14.     packs_found = 0;
  15.     ConstructStoreTable();
  16. }
  17.  
  18. // Construct the list of Choices in the Library Browser
  19. function ConstructStoreTable()
  20. {    
  21.     SetStoreBannerTopRow(false);
  22.     // i18n issue
  23.     SetOperationStatus('storeBanner', "Accessing Web Packs Collection ...");
  24.  
  25.     //On slow systems this should give an intermediate "Loading..." screen.
  26.     document.getElementById('loading').style.display="block";
  27.  
  28.     // Generate the XMLHTTPRequest to get the XML response file 
  29.     var url = "/webaroo/e29f1fe6/myplaces?resourceType=serverSubscriptionListXml";
  30.     SendAsynchornousRequest(url, "", ShowStoreTable, "");
  31. }
  32.  
  33. function ShowStoreTable(storeXml, data)
  34. {
  35.     if (currentView == "store")
  36.     {
  37.         SetOperationStatus('storeBanner', "");
  38.         
  39.         serverSubscriptionXml = storeXml;
  40.         if(CheckForError()==false)
  41.         {
  42.             renderXMLStoreTableData();
  43.             
  44.             if(packs_found != 0)
  45.             {
  46.                 document.getElementById('device_choices').style.display="block";
  47.             }
  48.         }
  49.         
  50.         document.getElementById('loading').style.display="none";
  51.     }
  52. }
  53.  
  54. function SetStoreBannerTopRow(setInfo)
  55. {
  56.     var storebuttons = document.getElementById('storeButton');
  57.     var storeinfo = document.getElementById('storeInfo');
  58.     if (setInfo)
  59.     {
  60.         storebuttons.innerHTML = "<button type=\"button\" id=\"update\" name=\"update\" title=\"Subscribe to the Store content\" onClick=\"AddContentSelection()\">Add To My Library</button>  ";
  61.         
  62.         var htmlData = "";
  63.         if (storeTotalSizeList.length > 0)
  64.         {
  65.             htmlData = "<div id=\"onlineStoreSize\"><font class=\"StoreSize\">";
  66.             htmlData += "My Library: " + storeLibrarySizeList[0] + " " + "(" + storeAvailableSizeList[0] + " Free)";
  67.             //htmlData += "Available/Total: <b>" + storeAvailableSizeList[0] + "/" + storeTotalSizeList[0] +"</b> ";
  68.             htmlData += "</font></div>";
  69.         }
  70.         storeinfo.innerHTML = htmlData;
  71.         // Call the rounded corner function
  72.         //if(NiftyCheck())
  73.         //{
  74.             //Rounded("div#onlineStoreSize","all","#FFAA44","#FFCC88","smooth");
  75.         //}
  76.     }
  77.     else
  78.     {
  79.         storebuttons.innerHTML = "";
  80.         storeinfo.innerHTML = "";
  81.     }
  82. }
  83.  
  84. function CheckForError()
  85. {
  86.     var errormessageobject = serverSubscriptionXml.getElementsByTagName('ErrorMessage');
  87.     var detailerrormessageobject=serverSubscriptionXml.getElementsByTagName('DetailedMessage');
  88.     
  89.     if(errormessageobject.length > 0)
  90.     {
  91.         var errormessage;
  92.         for (var j=0;j<errormessageobject.length;j++)
  93.         {
  94.             if (errormessageobject[j].nodeType != 1) continue;
  95.             errormessage=errormessageobject[j].firstChild.nodeValue;
  96.         }
  97.         //var detailederrormessage;
  98.         //for (var j=0;j<detailerrormessageobject.length;j++)
  99.         //{
  100.         //    if (detailerrormessageobject[j].nodeType != 1) continue;
  101.         //    detailederrormessage =detailerrormessageobject[j].firstChild.nodeValue;
  102.         //}    
  103.         SetStoreBannerTopRow(false);
  104.         SetOperationStatus('storeBanner', errormessage);
  105.         return true;
  106.     }    
  107.     else
  108.     {
  109.         SetStoreBannerTopRow(true);
  110.         return false;
  111.     }
  112. }
  113.  
  114. //Construct the specific list of Choices for the Browser
  115. function renderXMLStoreTableData()
  116. {
  117.     var tempObject = serverSubscriptionXml.getElementsByTagName('Subscriptions');
  118.     var listObject = serverSubscriptionXml.getElementsByTagName('Subscription');
  119.     var storeTable = document.getElementById('device_choices_table');
  120.  
  121.     ClearTable('device_choices_table');
  122.     AddHeaderRow('device_choices_table','store_view');
  123.  
  124.     var htmlData="";
  125.     var newRow, newCell;
  126.     var keys = new Array();
  127.     var values = new Array();
  128.     var rowkeys = new Array();
  129.     var rowvalues = new Array();
  130.     var i=0;
  131.  
  132.     for (var j=0;j<listObject.length;j++)
  133.     {
  134.         if (listObject[j].nodeType != 1) continue;
  135.  
  136.         var currentNodeObject=listObject[j];
  137.         var currentSubChannelID;
  138.         var currentTopic;
  139.         var currentSize;
  140.         var currentSizeUnit;
  141.         var currentLastUpdate;
  142.         var currentDescription;
  143.         var currentLanguage;
  144.         var currentImageCopyFlag;
  145.         var currentSubscriptionID;
  146.         
  147.         for (var k=0;k<currentNodeObject.childNodes.length;k++)
  148.         {
  149.             if (currentNodeObject.childNodes[k].nodeType != 1) continue;
  150.             switch(currentNodeObject.childNodes[k].nodeName)
  151.             {
  152.                 case 'SubChannelID':
  153.                     currentSubChannelID=currentNodeObject.childNodes[k].firstChild.nodeValue;
  154.                     break;
  155.                 case 'Topic':
  156.                     currentTopic=currentNodeObject.childNodes[k].firstChild.nodeValue;
  157.                     break;
  158.                 case 'DisplaySize':
  159.                     currentSize=currentNodeObject.childNodes[k].firstChild.nodeValue;
  160.                     break;
  161.                 case 'DisplaySizeUnit':
  162.                     currentSizeUnit=currentNodeObject.childNodes[k].firstChild.nodeValue;
  163.                     break;
  164.                 case 'LastUpdate':
  165.                     currentLastUpdate=currentNodeObject.childNodes[k].firstChild.nodeValue;
  166.                     break;
  167.                 case 'Description':
  168.                     currentDescription=currentNodeObject.childNodes[k].firstChild.nodeValue;
  169.                     break;
  170.                 case 'Language':
  171.                     currentLanguage=currentNodeObject.childNodes[k].firstChild.nodeValue;
  172.                     break;
  173.                 case 'ImageCopyFlag':
  174.                     currentImageCopyFlag=currentNodeObject.childNodes[k].firstChild.nodeValue;
  175.                     break;
  176.                 case 'SubscriptionID':
  177.                     currentSubscriptionID=currentNodeObject.childNodes[k].firstChild.nodeValue;
  178.                     break;
  179.             }
  180.         }
  181.         
  182.         keys[0] = "innerHTML";
  183.         keys[1] = "width";
  184.         keys[2] = "valign";
  185.         keys[3] = "align";
  186.         
  187.         values[0] = "<input name=\"device_choice_checkbox\" type=\"checkbox\" value=\""+ (i++) +"\" />";
  188.         values[1] = "20";
  189.         values[2] = "top";
  190.         values[3] = "center";
  191.         newRow = AddRowToTable('device_choices_table', rowkeys,rowvalues,keys, values);
  192.  
  193.  
  194.         keys[3] = "";
  195.         
  196.         values[0] = "<font class=\"ContentName\">" + currentTopic + "</font> <br />";
  197.         values[0] += "<image src=\"/webaroo/e29f1fe6/images/webaroo_webpack.gif\" />  <font class=\"itemType\">web pack</font>   ";
  198.         values[1] = "165";
  199.         AddCellToRow(newRow, keys, values);
  200.  
  201.         values[0] = "<font class=\"itemSize\">" + currentSize + " " + currentSizeUnit + "</font><br />"
  202.         values[1] = "80";
  203.         AddCellToRow(newRow, keys, values);
  204.  
  205.         // Truncating size of currentTopic to 100 chars
  206.         var regularExpr = /'/g
  207.         currentDescription = currentDescription.replace(regularExpr,'\\\'');
  208.         var intSize = currentDescription.length;
  209.         var truncatedTopic = currentDescription.substring(0, 100);
  210.         if(intSize > 100)
  211.         {
  212.             truncatedTopic += "...";
  213.         }
  214.  
  215.         // I18N issue
  216.         values[0] = "<b onMouseover=\"ddrivetip('" + currentDescription + "', 300);\" onMouseout=\"hideddrivetip()\">";
  217.         values[0] += "<font class=\"itemDes\">" + truncatedTopic + "</font></b>";
  218.         values[1] = "270";
  219.         AddCellToRow(newRow, keys, values);
  220.  
  221.  
  222.         keys[3] = "noWrap";
  223.         values[3] = "true";
  224.  
  225.         values[0] = "<font class=\"itemUpdate\">" + currentLastUpdate + "</font>";
  226.         values[1] = "85";
  227.         AddCellToRow(newRow, keys, values);
  228.     }
  229.     
  230.     if(listObject.length!=0)
  231.     {
  232.         packs_found = 1;
  233.         AlternateTableRowStyle('device_choices_table');
  234.     }
  235.     else
  236.     {
  237.         packs_found = 0;
  238.         SetOperationStatus('storeBanner', "No content found.");
  239.     }
  240. }
  241.  
  242. function AddContentSelection()
  243. {
  244.     // No subscriptions
  245.     if (packs_found == 0)
  246.     {
  247.       return;
  248.     }  
  249.  
  250.     var selectedSubscriptions = new Array();
  251.     QuerySelectedCheckboxes(selectedSubscriptions);
  252.     
  253.     if (selectedSubscriptions.length > 0)
  254.     { 
  255.         SendSelectedSubscriptionsToServer(selectedSubscriptions);
  256.         
  257.         ShowAddtionStatus();
  258.     }
  259.     else
  260.     {
  261.         SetOperationStatus('storeBanner', NoContentSelectedMessage);
  262.     }
  263. }
  264.  
  265. function SendSelectedSubscriptionsToServer(selectedSubscriptions)
  266. {
  267.     var selectedSubscriptionsXml = CreateSelectedSubscriptionsXml(selectedSubscriptions);
  268.     var url = "/webaroo/e29f1fe6/savemysubs?request=add";
  269.     sendXMLData(url, "XMLData=" + selectedSubscriptionsXml);
  270. }
  271.  
  272. // Form XML string based on Selected Subscriptions
  273. function CreateSelectedSubscriptionsXml(selectedSubscriptions)
  274. {
  275.     var indentLevel = 0;
  276.     var subsObject = serverSubscriptionXml.getElementsByTagName('Subscriptions');
  277.     var currentChannel,currentChannelID ;
  278.     var currentSubChannel, currentSubChannelID;
  279.     var j,k,l;
  280.     var currentIndex=0;
  281.     
  282.     var selectedSubscriptionsXml = '<XmlData>\n';
  283.     //selectedSubscriptionsXml += GetSpace(++indentLevel) + '<storeID>' + storeID + '</storeID>\n';
  284.     selectedSubscriptionsXml += GetSpace(indentLevel) + '<Response>\n';
  285.     selectedSubscriptionsXml += GetSpace(++indentLevel) + '<Subscriptions>\n';
  286.     
  287.     for (j=0; j < subsObject.length; ++j)
  288.     {
  289.         if (subsObject[j].nodeType != 1) continue;
  290.     
  291.         var subscriptionList = subsObject[j].getElementsByTagName('Subscription');
  292.     
  293.         for(k=0;k<subscriptionList.length;k++)
  294.         {    
  295.             currentSubscription=subscriptionList[k];
  296.             //var parentCurrentSubscription = currentSubscription.
  297.             currentChannelID = subsObject[j].getAttributeNode('ChannelID').nodeValue;
  298.             currentSubChannel = currentSubscription.getElementsByTagName('SubChannelID');
  299.             currentSubChannelID = currentSubChannel[0].firstChild.nodeValue;
  300.             
  301.             selected = 0;
  302.             for (l=0; l < selectedSubscriptions.length; ++l)
  303.             {
  304.                 if (currentIndex == selectedSubscriptions[l])
  305.                 {
  306.                     selected = 1;
  307.                     break;
  308.                 }
  309.             }
  310.         
  311.             ++currentIndex;
  312.             if (selected == 0)  continue;
  313.         
  314.             selectedSubscriptionsXml += GetSpace(++indentLevel) + '<Subscription>\n';
  315.             selectedSubscriptionsXml += GetSpace(++indentLevel) + '<ChannelID>' + currentChannelID + '</ChannelID>\n';
  316.             selectedSubscriptionsXml += GetSpace(indentLevel) + '<SubChannelID>' + currentSubChannelID + '</SubChannelID>\n';
  317.             --indentLevel;
  318.  
  319.             for (l=0; l < currentSubscription.childNodes.length; ++l)
  320.             {
  321.                 if (currentSubscription.childNodes[l].nodeType != 1) continue;
  322.                 
  323.                 switch(currentSubscription.childNodes[l].nodeName)
  324.                 {
  325.                     case 'SubscriptionID':
  326.                         currentSubscriptionID=currentSubscription.childNodes[l].firstChild.nodeValue;
  327.                         selectedSubscriptionsXml += GetSpace(++indentLevel) + '<SubscriptionID>' + currentSubscriptionID + '</SubscriptionID>\n';
  328.                         --indentLevel;
  329.                         break;
  330.                     case 'Topic':
  331.                         currentTopic=currentSubscription.childNodes[l].firstChild.nodeValue;
  332.                         selectedSubscriptionsXml += GetSpace(++indentLevel) + '<Topic><![CDATA[' + escape(currentTopic) + ']]></Topic>\n';
  333.                         --indentLevel;
  334.                         break;
  335.                     case 'Size':
  336.                         currentSize=currentSubscription.childNodes[l].firstChild.nodeValue;
  337.                         selectedSubscriptionsXml += GetSpace(++indentLevel) + '<Size>' + currentSize + '</Size>\n';
  338.                         --indentLevel;
  339.                         break;
  340.                     case 'Language':
  341.                         currentLanguage=currentSubscription.childNodes[l].firstChild.nodeValue;
  342.                         selectedSubscriptionsXml += GetSpace(++indentLevel) + '<Language><![CDATA[' + escape(currentLanguage) + ']]></Language>\n';
  343.                         --indentLevel;
  344.                         break;
  345.                     case 'Description':
  346.                         currentDescription=currentSubscription.childNodes[l].firstChild.nodeValue;
  347.                         selectedSubscriptionsXml += GetSpace(++indentLevel) + '<Description><![CDATA[' + escape(currentDescription) + ']]></Description>\n';
  348.                         --indentLevel;
  349.                         break;
  350.                     case 'ImageCopyFlag':
  351.                         currentImageCopyFlag=currentSubscription.childNodes[l].firstChild.nodeValue;
  352.                         selectedSubscriptionsXml += GetSpace(++indentLevel) + '<ImageCopyFlag>' + currentImageCopyFlag + '</ImageCopyFlag>\n';
  353.                         --indentLevel;
  354.                         break;
  355.                 }
  356.             }
  357.             selectedSubscriptionsXml += GetSpace(indentLevel--) + '</Subscription>\n';
  358.         }
  359.     }
  360.  
  361.     selectedSubscriptionsXml += GetSpace(indentLevel--) + '</Subscriptions>\n';
  362.     selectedSubscriptionsXml += GetSpace(indentLevel--) + '</Response>\n';
  363.     selectedSubscriptionsXml += '</XmlData>\n';
  364.  
  365.     return selectedSubscriptionsXml;
  366. }
  367.  
  368. function ShowAddtionStatus()
  369. {
  370.     var listObject = xmlContent.getElementsByTagName('Status');
  371.     var status = listObject[0].firstChild.nodeValue;
  372.     
  373.     SetOperationStatus('storeBanner', status);
  374.     ClearAllCheckboxes();
  375. }
  376.  
  377.