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

  1. // List of stores by their ID
  2. var deviceList=new Array();
  3. // List of stores by their Name
  4. var deviceNameList=new Array();
  5. // store types
  6. var storeTypeList=new Array();
  7. // List of stores by their device type
  8. var deviceTypeList=new Array();
  9. // List of stores containing their Total size
  10. var storeTotalSizeList = new Array();
  11. // List of stores containing their available size
  12. var storeAvailableSizeList = new Array();
  13. // List of stores containing their library size
  14. var storeLibrarySizeList = new Array();
  15. // Current device whose information is displayed in device view
  16. var currentDeviceIndex = -1;
  17. // Device id while device is in process of conversion to webaroo store
  18. var deviceConfigMessage = "_config_started_";
  19.  
  20. function ShowDeviceInfo(addToHistory,deviceIndex)
  21. {
  22.     if(addToHistory)
  23.     {
  24.         dhtmlHistory.add("deviceIndex=" + deviceIndex ,"");
  25.     }
  26.     
  27.     AdjustPageElements("device");
  28.     currentDeviceIndex = deviceIndex;
  29.     AbortPendingRequests();
  30.     subscriptions_found = 0;
  31.     
  32.     // Set the Left Menu Context
  33.     var leftmenutable = document.getElementById('leftMenu');
  34.     // Add 3 to device index to set the offset correctly
  35.     // depending upon the number of menus
  36.     leftmenutable.rows[deviceIndex + 3].cells[0].className = "selected";
  37.     
  38.     if (currentDeviceIndex != -1)
  39.     {
  40.         ConstructDeviceTable(deviceIndex);
  41.     }
  42.     else
  43.     {
  44.         ShowInvalidDeviceMessage();
  45.     }
  46. }
  47.  
  48. function ShowInvalidDeviceMessage()
  49. {
  50.     var devicebuttons = document.getElementById('deviceactionbuttons');
  51.     devicebuttons.innerHTML = "";
  52.  
  53.     var devicelinks = document.getElementById('deviceactionlinks');
  54.     devicelinks.innerHTML = "";
  55.  
  56.     // i18n issue
  57.     SetOperationStatus('deviceBanner', "Mobile device not connected. ");
  58. }
  59.  
  60. function ConstructDeviceTable(deviceIndex)
  61. {
  62.     var url;
  63.     var htmlData = "";
  64.     
  65.     //On slow systems this should give an intermediate "Loading..." screen.
  66.     document.getElementById('loading').style.display="block";
  67.  
  68.     var cardName = deviceNameList[deviceIndex];
  69.     var cardId = deviceList[deviceIndex];
  70.     var cardType = storeTypeList[deviceIndex];
  71.     var cardAvailableSize = storeAvailableSizeList[deviceIndex];
  72.     var cardTotalSize = storeTotalSizeList[deviceIndex];
  73.     var cardLibrarySize = storeLibrarySizeList[deviceIndex];
  74.     
  75.     var devicebuttons = document.getElementById('deviceactionbuttons');
  76.     
  77.     var devicelinks = document.getElementById('deviceactionlinks');
  78.     htmlData = "<a href=\"javascript:ShowMyLibrary(1)\"><img style=\"display:inline\" src=\"images/webaroo_add.gif\" border=\"0\"/></a>";
  79.     htmlData += "<a href=\"javascript:ShowMyLibrary(1) \" style=\"color:#114488;\"> add from my library  </a>";
  80.     devicelinks.innerHTML = htmlData;
  81.     var devicesize = document.getElementById('deviceactionsize');
  82.     htmlData = "<div id=\"storeSize\"><font class=\"StoreSize\">";
  83.     htmlData += "Webaroo content: " + cardLibrarySize + " (" + cardAvailableSize + " Free)";
  84.     //htmlData += "Total/Available: <b>" + cardTotalSize + "/" + cardAvailableSize + "</b> ";
  85.     htmlData += " | <a style=\"color:#114488; text-decoration:underline;\" href=\"javascript:ShowStatusWindow()\">Status Window</a>  </font></div>";
  86.     devicesize.innerHTML = htmlData;
  87.     //if(NiftyCheck())
  88.     //{
  89.         //Rounded("div#storeSize","all","#FFAA44","#FFCC88","smooth");
  90.     //}
  91.     document.getElementById('loading').style.display="none";
  92.  
  93.     htmlData = " <button type=\"button\" id=\"syncDevice\" name=\"syncDevice\" title=\"Synchronizes content from My Library to mobile devices.\" onclick=\"SyncSelectedSubscriptions(" +deviceIndex + ")\">Sync</button>";
  94.     htmlData += " <button type=\"button\" id=\"removeDevice\" name=\"removeDevice\" title=\"Deletes content from your mobile devices.\" onclick=\"RemoveSelectedSubscriptions(" +deviceIndex + ")\">Delete</button>";
  95.     devicebuttons.innerHTML = htmlData;
  96.  
  97.     if (cardType == "webaroo")
  98.     {
  99.         SendDeviceChoiceTable(deviceIndex, "device");
  100.     }
  101.     else if (cardType == "nowebaroo")
  102.     {
  103.         var syncDeviceButton = document.getElementById('syncDevice');
  104.         syncDeviceButton.disabled = true;
  105.         var removeButton = document.getElementById('removeDevice');
  106.         removeButton.disabled = true;    
  107.         SetOperationStatus('deviceBanner', "No content found. Add content to your mobile device from <a href='javascript:ShowMyLibrary(1)'>my library</a>.");
  108.     }
  109. }
  110.  
  111. // called from device View
  112. function SendSyncRequestToServer(subscriptionID)
  113. {
  114.     var subs = new Array();
  115.     subs.push(subscriptionID);
  116.     var xmlData = CreateSyncUpdateSubscriptionsXml(subs, true);
  117.     // Hide the menu
  118.     hidemenu();
  119.     // Once the subscription specific sync API is implemented
  120.     // we would use that API to sync only that subscription
  121.     url = "/webaroo/e29f1fe6/sync";
  122.     sendXMLData(url, "XMLData=" + xmlData);
  123.     
  124.     var syncStatus = GetOperationStatus(xmlContent);
  125.     SetOperationStatus('deviceBanner',syncStatus);
  126. }
  127.  
  128. function CreateSyncUpdateSubscriptionsXml(subscriptionIDs, isSync)
  129. {
  130.     var subscriptionsXml = "";
  131.     subscriptionsXml = '<XmlData>\n';
  132.  
  133.     if (isSync && (currentDeviceIndex != -1))
  134.     {
  135.         var cardName = EncodeValue(deviceNameList[currentDeviceIndex]);
  136.         var cardId = deviceList[currentDeviceIndex];
  137.         var cardType = storeTypeList[currentDeviceIndex];
  138.         var deviceType = deviceTypeList[currentDeviceIndex];
  139.  
  140.         subscriptionsXml += '<storeID>' + cardId + '</storeID>\n';
  141.         subscriptionsXml += '<CardName>' + cardName + '</CardName>\n';
  142.         subscriptionsXml += '<CardType>' + cardType + '</CardType>\n';
  143.         subscriptionsXml += '<DeviceType>' + deviceType + '</DeviceType>\n';
  144.     }
  145.  
  146.     subscriptionsXml += '<Response>\n';
  147.     for (i=0; i < subscriptionIDs.length; ++i)
  148.     {
  149.         subscriptionsXml += '<ID>';
  150.         subscriptionsXml += subscriptionIDs[i];
  151.         subscriptionsXml += '</ID>';
  152.     }
  153.     subscriptionsXml += '</Response>\n';
  154.     subscriptionsXml += '</XmlData>\n';
  155.     return subscriptionsXml;
  156. }
  157.  
  158. function SyncSelectedSubscriptions(deviceIndex)
  159. {
  160.     // find all the subscription ids for which checkboxes are checked
  161.     var selectedSubscriptions= new Array();
  162.     QuerySelectedCheckboxes(selectedSubscriptions)
  163.  
  164.     if (selectedSubscriptions.length > 0)
  165.     {
  166.         // TO DO : Once the specific sync code is available
  167.         // The following code would change    
  168.         var xmlData = CreateSyncUpdateSubscriptionsXml(selectedSubscriptions, true);
  169.         url = "/webaroo/e29f1fe6/sync";
  170.         sendXMLData(url, "XMLData=" + xmlData)
  171.         
  172.         var syncStatus = GetOperationStatus(xmlContent);
  173.         SetOperationStatus('deviceBanner',syncStatus);
  174.         ClearAllCheckboxes();
  175.     }
  176.     else
  177.     {
  178.         SetOperationStatus('deviceBanner', NoContentSelectedMessage);
  179.     }
  180. }
  181.  
  182. function RemoveSelectedSubscriptions(deviceIndex)
  183. {
  184.     var status="";
  185.  
  186.     // find all the subscription ids for which checkboxes are checked
  187.     var selectedPlaces = new Array();
  188.     var selectedSites = new Array();
  189.  
  190.     QuerySelectedCheckboxesBasedOnType(MyPlace, selectedPlaces)
  191.     QuerySelectedCheckboxesBasedOnType(MySite, selectedSites)
  192.  
  193.     if ((selectedPlaces.length > 0) || (selectedSites.length > 0))
  194.     { 
  195.         RemoveSubscriptions(deviceIndex ,selectedPlaces, selectedSites);
  196.     }
  197.     else
  198.     {
  199.         SetOperationStatus((deviceIndex == -1) ? 'libraryBanner' : 'deviceBanner', NoContentSelectedMessage);
  200.     }
  201. }
  202.