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

  1. // i8n - Compliant
  2. // Constructs the Navigation Systems For the HTML Page
  3. // The default store
  4. var default_store_id;
  5. var linkset=new Array()
  6.  
  7. // Type of mobile left menu request
  8. var SyncRequest = -1;
  9. var AsyncRequest = 0;
  10. var FirstAsyncRequest = 1;
  11.  
  12. function InstallWebaroo()
  13. {
  14.     var url = "/webaroo/e29f1fe6/installwebaroo";
  15.     SendAsynchornousRequest(url, "", IgnoreResponse, "");
  16. }
  17.  
  18. function IgnoreResponse(xmlStatus, data)
  19. {    
  20. }
  21.  
  22.  
  23. function ShowTopMenu()
  24. {
  25.     var url = "/webaroo/e29f1fe6/xml?request=topmenu";
  26.     processXMLData(url);
  27.     renderTopMenu(xmlContent);
  28. }
  29.  
  30. function renderTopMenu(topMenuXml)
  31. {
  32.     var htmlData='';
  33.     var menuNames = new Array();
  34.     var menuLinks = new Array();
  35.     var menuImages = new Array();
  36.     var menuOnOverImages = new Array();
  37.     var index = 0;
  38.     
  39.     // Delete the rows after the first top 5 rows
  40.     var topMenuTable = document.getElementById('topMenuTable');
  41.     var listObject = topMenuXml.getElementsByTagName('Menu');
  42.     for (var j=0;j<listObject.length;j++)
  43.     {
  44.         if (listObject[j].nodeType != 1) 
  45.             continue;
  46.         menuNames[index] = listObject[j].firstChild.nodeValue;
  47.         menuLinks[index] = listObject[j].getAttributeNode('link').nodeValue;
  48.         menuImages[index] = listObject[j].getAttributeNode('image').nodeValue;
  49.         menuOnOverImages[index] = listObject[j].getAttributeNode('onoverimage').nodeValue;
  50.         index++;
  51.     }
  52.     
  53.     // First Icon is Webaroo Icon
  54.     htmlData = "<a href=\"" + menuLinks[0] + "\" target=\"_top\" ><img src=\"" + menuImages[0] + "\"  border=\"0\" alt=\"\"></a>";
  55.     topMenuTable.rows[0].cells[0].innerHTML = htmlData;
  56.  
  57.     for(var i=1; i < index; i++)
  58.     {
  59.         var imageName = "Image" + i ;
  60.         if(topMenuTable.rows[0].cells[i].className == "selected")
  61.         {
  62.             //pick up the other image here: Remove the last 4 character (".gif") from name and 
  63.             // append _f2 name there
  64.             var iconImageNamelength = menuImages[i].length;
  65.             var iconImageName = menuImages[i].substring(0,iconImageNamelength-4)+ '_f2.gif';
  66.             
  67.             htmlData = "<a href=\"" + menuLinks[i] + "\" target=\"_top\"><img name=\"" + imageName + "\" src=\"" + iconImageName + "\" border=\"0\" alt=\"\"></a>";
  68.         }
  69.         else
  70.             htmlData = "<a onmouseover=\"MM_swapImage('" + imageName + "','','"+menuOnOverImages[i]+"'," + i + ")\" onmouseout=\"MM_swapImgRestore()\" href=\"" + menuLinks[i] + "\" target=\"_top\"><img name=\"" + imageName + "\" src=\"" + menuImages[i] + "\" border=\"0\" alt=\"\"></a>";        
  71.         htmlData += " <a href=\"" + menuLinks[i] + "\" target=\"_top\" style=\"text-decoration:none;\" > <br/>" + menuNames[i] + "</a>";
  72.         topMenuTable.rows[0].cells[i].innerHTML = htmlData;
  73.     }
  74. }
  75.  
  76. function ShowMobileLoadingMessage(MessageText)
  77. {
  78.     var rowkey = new Array();
  79.     var rowvalues = new Array();
  80.     var keys = new Array();
  81.     var values = new Array();
  82.     
  83.     // Delete the rows after the first top 4 rows
  84.     DeleteRowsFromTable('leftMenu', 4 , -1);
  85.     
  86.     keys[0] = "innerHTML";
  87.     values[0] = MessageText;
  88.     keys[1] = "className";
  89.     values[1] = "LeftMenuStatusMessage";
  90.     AddRowToTable('leftMenu',rowkey,rowvalues, keys, values);
  91. }
  92.  
  93. function ShowAsynchornousLeftMenu(isAsyncFirstTime)
  94. {
  95.     if (currentView != "")
  96.     {
  97.         // i18n issue
  98.         // Show message in leftMenuTable itself
  99.         ShowMobileLoadingMessage('Loading available storage cards...');
  100.     }
  101.     var url = "/webaroo/e29f1fe6/xml?request=leftmenu";
  102.     SendAsynchornousRequest(url, "", ShowLeftDeviceMenu, isAsyncFirstTime);
  103. }
  104.  
  105. function ShowSynchornousLeftMenu()
  106. {
  107.     var url = "/webaroo/e29f1fe6/xml?request=leftmenu";
  108.     sendXMLData(url, "");
  109.     ShowLeftDeviceMenu(xmlContent, SyncRequest);
  110. }
  111.  
  112. //Constructs the Left Device Menu For Navigating among the Various Stores
  113. function ShowLeftDeviceMenu(leftmenuXML, data)
  114. {    
  115.     var currentDeviceInfo = new Array();
  116.  
  117.     if ((currentView == "device") && (currentDeviceIndex != -1))
  118.     {
  119.         currentDeviceInfo[0] = deviceList[currentDeviceIndex];
  120.         currentDeviceInfo[1] = deviceNameList[currentDeviceIndex];
  121.         currentDeviceInfo[2] = storeTypeList[currentDeviceIndex];
  122.         currentDeviceInfo[3] = deviceTypeList[currentDeviceIndex];
  123.         currentDeviceInfo[4] = storeTotalSizeList[currentDeviceIndex];
  124.         currentDeviceInfo[5] = storeAvailableSizeList[currentDeviceIndex];
  125.         currentDeviceInfo[6] = storeLibrarySizeList[currentDeviceIndex];
  126.     }
  127.     
  128.     deviceList = new Array();
  129.     deviceNameList = new Array();
  130.     storeTypeList = new Array();
  131.     deviceTypeList = new Array();
  132.     storeTotalSizeList = new Array();
  133.     storeAvailableSizeList = new Array();
  134.     storeLibrarySizeList = new Array();
  135.     
  136.     renderXMLLeftDeviceMenuData(leftmenuXML);
  137.     CreateCopySelectOptions();
  138.     
  139.     if ((currentView == "library") || (currentView == ""))
  140.     {
  141.         showMyLibrarySizeDetails();
  142.     }
  143.     else if ((currentView == "device") && (currentDeviceIndex != -1))
  144.     {
  145.         var nextAction = CheckDeviceInfoAfterRefresh(currentDeviceInfo);
  146.         // always refresh device view to update index passed to actions
  147.         ShowDeviceInfo(0,nextAction[1]);
  148.     }
  149. }
  150.  
  151. function CheckDeviceInfoAfterRefresh(currentDeviceInfo)
  152. {
  153.     var nextAction = new Array();
  154.     nextAction[0] = "nochange";
  155.     nextAction[1] = -1;
  156.     
  157.     if (currentDeviceInfo.length > 0)
  158.     {
  159.         var devicePresent = false;
  160.         var deviceInfoChanged = false;
  161.         
  162.         // ignore the first entry which is for the local store C:
  163.         for(var i=1;i<deviceList.length;i++)
  164.         {
  165.             if ((currentDeviceInfo[1] == deviceNameList[i]) && (currentDeviceInfo[3] == deviceTypeList[i]))    
  166.             {
  167.                 devicePresent = true;
  168.                 nextAction[1] = i;
  169.                 
  170.                 if ((currentDeviceInfo[0] != deviceList[i]) || (currentDeviceInfo[2] != storeTypeList[i]) || (currentDeviceInfo[4] != storeTotalSizeList[i]) || (currentDeviceInfo[5] != storeAvailableSizeList[i]) || (currentDeviceInfo[6] != storeLibrarySizeList[i]))
  171.                 {
  172.                     deviceInfoChanged = true;
  173.                 }
  174.                 else
  175.                 {
  176.                     currentDeviceIndex = i;
  177.                 }
  178.                 
  179.                 break;
  180.             }
  181.         }
  182.         
  183.         if (devicePresent)
  184.         {
  185.             if (deviceInfoChanged)
  186.             {
  187.                 nextAction[0] = "refresh";
  188.             }
  189.         }
  190.         else
  191.         {
  192.             nextAction[0] = "invalid";
  193.         }
  194.     }
  195.     
  196.     return nextAction;    
  197. }
  198.  
  199. function showMyLibrarySizeDetails()
  200. {
  201.     // First entry is locatmother store entry
  202.     var cardAvailableSize = storeAvailableSizeList[0];
  203.     var cardTotalSize = storeTotalSizeList[0];
  204.     var cardLibrarySize = storeLibrarySizeList[0];
  205.     var htmlData = "";
  206.  
  207.     if(cardTotalSize)
  208.     {
  209.         htmlData += "<font class=\"StoreSize\">";
  210.         htmlData += "My Library: " + cardLibrarySize + " (" + cardAvailableSize + " Free)";
  211.         //htmlData += "Total/Available: <b>" +cardTotalSize  + "/" + cardAvailableSize + "</b> ";
  212.         htmlData += " | <a style=\"color:#114488; text-decoration:underline;\" href=\"javascript:ShowStatusWindow()\">Status Window</a>  </font>";
  213.     }
  214.     document.getElementById('librarySize').innerHTML = htmlData;
  215.     //if(NiftyCheck())
  216.     //{
  217.         //Rounded("div#librarySize","all","#FFAA44","#FFCC88","smooth");
  218.     //}
  219. }
  220.  
  221. //Function that Renders the Data to Left Device Menu of HTML
  222. function renderXMLLeftDeviceMenuData(leftmenuXML)
  223. {
  224.     var cardType;
  225.     var htmlData='';
  226.     var keys = new Array();
  227.     var values = new Array();
  228.     var rowkey = new Array();
  229.     var rowvalues = new Array();
  230.     var index = 0;
  231.     
  232.     // Delete the rows after the first top 4 rows
  233.     DeleteRowsFromTable('leftMenu', 4 , -1);
  234.     var listObject = leftmenuXML.getElementsByTagName('Response');
  235.     if(listObject.length >0)
  236.     {
  237.         for (var j=0;j<listObject[0].childNodes.length;j++)
  238.         {
  239.             if (listObject[0].childNodes[j].nodeType != 1) continue;
  240.             
  241.             var cardName = listObject[0].childNodes[j].getElementsByTagName('Name');
  242.             var cardId = listObject[0].childNodes[j].getElementsByTagName('ID');
  243.             var cardType = listObject[0].childNodes[j].getElementsByTagName('Type');
  244.             var deviceType = listObject[0].childNodes[j].getElementsByTagName('CardType');
  245.             var storeTotalSize = listObject[0].childNodes[j].getElementsByTagName('TotalStorage');
  246.             var storeAvailableSize = listObject[0].childNodes[j].getElementsByTagName('AvailableSpace');
  247.             var storeLibrarySize = listObject[0].childNodes[j].getElementsByTagName('LibrarySize');
  248.             
  249.             var cardNameStr = cardName[0].firstChild.nodeValue;
  250.             var cardIdStr = cardId[0].firstChild.nodeValue;
  251.             var cardTypeStr = cardType[0].firstChild.nodeValue;
  252.             var deviceTypeStr = deviceType[0].firstChild.nodeValue;
  253.             var storeTotalSizestr = storeTotalSize[0].firstChild.nodeValue;;
  254.             var storeAvailableSizestr = storeAvailableSize[0].firstChild.nodeValue;;
  255.             var storeLibrarySizestr = storeLibrarySize[0].firstChild.nodeValue;;
  256.             
  257.             deviceList[index] = cardIdStr;
  258.             deviceNameList[index] = cardNameStr;
  259.             storeTypeList[index] = cardTypeStr;
  260.             deviceTypeList[index] = deviceTypeStr;
  261.             storeTotalSizeList[index] = storeTotalSizestr;
  262.             storeAvailableSizeList[index] = storeAvailableSizestr;
  263.             storeLibrarySizeList[index] = storeLibrarySizestr;
  264.             index++;
  265.         }
  266.     }
  267.     
  268.     if(deviceList.length > 1)
  269.     {
  270.         // ignore the first entry which is for the local store C:
  271.         for(var i=1;i<deviceList.length;i++)
  272.         {    
  273.             // GetSpace(2) for indentation level
  274.             //var subMenuIndentationLevel = 2;
  275.             keys[0] = "innerHTML";
  276.             keys[1] = "id";
  277.             values[0] = "<image src=\"/webaroo/e29f1fe6/images/webaroo_mobiledevice.gif\" /><a href=\"javascript:ShowDeviceInfo(1," + i + ")\">" + deviceNameList[i] + "</a>";
  278.             values[1] = "deviceIndexCell" + i;
  279.             AddRowToTable('leftMenu',rowkey,rowvalues, keys, values);
  280.         }
  281.     }
  282.     else
  283.     {
  284.         ShowMobileLoadingMessage('Connect mobile device and click \"refresh\" to view available storage cards');
  285.     }
  286.     AddEmptyRowsInLeftMenu();
  287. }
  288.  
  289. function DeleteRowsFromTable(tableId, deleteStart , deleteEnd)
  290. {
  291.     var leftmenutable = document.getElementById(tableId);
  292.     var curr_row;
  293.     if(deleteEnd == -1)
  294.         deleteEnd = leftmenutable.rows.length-1;
  295.     for (curr_row = deleteEnd; curr_row >=deleteStart ; curr_row--)
  296.     {
  297.         leftmenutable.deleteRow(curr_row);
  298.     }    
  299. }
  300.  
  301. function RenderPopUpMenu(e, context, deviceIndex)
  302. {
  303.     if (!document.all&&!document.getElementById)
  304.     return;
  305.     
  306.     if(navigator.appName.indexOf("Microsoft")!=-1) e = window.event;
  307.  
  308.     var imagenode;
  309.     imagenode = (e.target) ? e.target.parentNode:e.srcElement.parentElement;
  310.     
  311.     // Name is also the attribute
  312.     imagenode = imagenode.getAttributeNode("name").nodeValue;
  313.     
  314.     var indexnumber = imagenode.substr(5); // Ripping the "image" from the name to get the index
  315.     // Index of Checkbox and Imagenode would always match
  316.     // i.e. image0 would be associated with device_choice_checkbox0
  317.     var checkboxnodeid = "device_choice_checkbox" + indexnumber;
  318.     var checkboxnode = document.getElementById(checkboxnodeid);
  319.     var subscriptionID = checkboxnode.value;
  320.     
  321.     if(context=="library")
  322.     {
  323.         // Needs to modify the linkset[1] to show the device entries
  324.         linkset[1]="<a href=\"#\" onclick=\"SendUpdateRequestToServer('" + subscriptionID + "')\" >Update</a>";
  325.         // 0 the entry is for my Library
  326.         for(var i =1; i < deviceNameList.length; i++)
  327.         {
  328.             var storename = deviceNameList[i];
  329.             linkset[1] += "<a href=\"#\" onclick=\"SendCopyRequestToServer(" + i + ", '" + subscriptionID + "')\" >Copy to " + storename + "</a>";
  330.         }
  331.         linkset[1] += "---------------";
  332.         linkset[1] += "<a href=\"#\" onclick=\"SendDeleteRequestToServer(" + deviceIndex + ", '" + subscriptionID + "')\">Delete</a>";
  333.         // Now call the ShowMenu function
  334.         showmenu(e, linkset[1]);
  335.     }
  336.     else if(context =="device")
  337.     {
  338.         linkset[2] = "<a href=\"#\" onclick=\"SendSyncRequestToServer('" + subscriptionID + "')\">Sync</a>";
  339.         linkset[2] += "---------------";
  340.         linkset[2] += "<a href=\"#\" onclick=\"SendDeleteRequestToServer(" + deviceIndex + ", '" + subscriptionID + "')\">Delete</a>";
  341.         showmenu(e, linkset[2]);
  342.     }
  343. }
  344.  
  345. function MM_preloadImages() { //v3.0
  346.   var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
  347.     var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
  348.     if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
  349. }
  350.  
  351. function MM_swapImgRestore() { //v3.0
  352.   var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
  353. }
  354.  
  355. function MM_findObj(n, d) { //v4.01
  356.   var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
  357.     d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  358.   if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  359.   for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  360.   if(!x && d.getElementById) x=d.getElementById(n); return x;
  361. }
  362.  
  363. function MM_swapImage() { //v3.0
  364.   var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
  365.    if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
  366. }
  367.  
  368. function CreateCopySelectOptions()
  369. {
  370.     var copyOptions =     document.TopControlForm.copySelect;
  371.     var copyToDropDownControl = document.getElementById('copyToDropDown');
  372.             
  373.     if(copyOptions)
  374.     {
  375.         // Clear all of the option froms combo box first except the first one
  376.         copyOptions.options.length=1;
  377.         if (deviceList.length > 1)
  378.         {
  379.             for (var i=1; i < deviceList.length; ++i)    // 0th entry is for My Library
  380.             {
  381.                 copyOptions.options[i] = new Option(deviceNameList[i],i,false,false);
  382.             }
  383.             // Get list Object for MySites and Subscription
  384.             var subListObject = null;
  385.             if(subXml != null)
  386.             {
  387.                 subListObject = subXml.getElementsByTagName('Subscription');
  388.             }
  389.             var mysitesListObject = null;
  390.             if(websiteXml != null)
  391.             {
  392.                 mysitesListObject = websiteXml.getElementsByTagName('Favorite');
  393.             }
  394.             
  395.             if(((subListObject == null) || (subListObject.length == 0)) && ((mysitesListObject == null) || (mysitesListObject.length == 0)))
  396.             {
  397.                 copyToDropDownControl.disabled = true;
  398.             }
  399.             else
  400.             {
  401.                 copyToDropDownControl.disabled = false;
  402.             }
  403.         }
  404.         else // Disable the copy To control here
  405.         {
  406.             copyToDropDownControl.disabled = true;
  407.         }
  408.     }
  409. }
  410.  
  411. function CopyToStorage()
  412. {
  413.     var indexDeviceStorage = document.TopControlForm.copySelect.options[document.TopControlForm.copySelect.selectedIndex].value
  414.     CopySelectedSubscriptionsToDevice(indexDeviceStorage);
  415.     // Setting back the selected index to 0
  416.     document.TopControlForm.copySelect.selectedIndex = 0;
  417. }
  418.