home *** CD-ROM | disk | FTP | other *** search
Wrap
Text File | 2006-03-28 | 37.6 KB | 1,185 lines
// i8n - Non-Compliant // Error Message var loading_string="Data Loading"; // Construct the list of Choices in the Library Browser - For the Specific Device // Need to verify if these global variables can be used ???? var myPlacesXml, mySitesXml; var updateRequestXml; var storeID, subscriptions_found = 0; var checkingSubscriptionUpdates = 0; var pendingRequests = new Array(); var MyPlace = 1; var MySite = 2; var NoContentSelectedMessage = "No content selected"; var subXml = null; var websiteXml = null; function LoadLibraryPage() { MM_preloadImages('/webaroo/e29f1fe6/images/webaroo_search_f2.gif','/webaroo/e29f1fe6/images/webaroo_contents_f2.gif','/webaroo/e29f1fe6/images/webaroo_prefs_f2.gif','/webaroo/e29f1fe6/images/webaroo_help_f2.gif'); // following lines for rounded corners script if(NiftyCheck()) { Rounded("div#leftMenuDiv","all","#FFAA44","#FFFFFF","smooth");//parameters in order: no. of corners rounded, corner colour, top and bottom colour, type of corner Rounded("div#libraryBannerStatusDiv","all","#FFAA44","#E35201","smooth"); Rounded("div#storeBannerStatusDiv","all","#FFAA44","#E35201","smooth"); Rounded("div#deviceBannerStatusDiv","all","#FFAA44","#E35201","smooth"); Rounded("div#favoriteBannerStatusDiv","all","#FFAA44","#E35201","smooth"); Rounded("div#favoriteViewDiv","all","#FFAA44","#FFFFFF","smooth"); } // initialize the DHTML History framework dhtmlHistory.initialize(); // add ourselves as a DHTML History listener dhtmlHistory.addListener(GetLibraryPage); if(dhtmlHistory.isFirstLoad()) { ShowMyLibrary(0); } } function GetLibraryPage() { var currentLocation = window.location.href.split("#"); if (currentLocation[0].indexOf("/webaroo/e29f1fe6/content") == -1) { return; } if(currentLocation.length >1) { var pageType = currentLocation[1]; if (pageType == "") { ShowMyLibrary(0); } else if(pageType == "mylibrary") ShowMyLibrary(0); else if(pageType == "favorite") ShowAddFavorite(0); else if(pageType == "onlinestore") ShowOnlineStore(0); else { pageType = pageType.split("="); if(pageType[0]=="deviceIndex") { var deviceindex = parseInt(pageType[1]); if(deviceNameList.length > deviceindex) ShowDeviceInfo(0,deviceindex); else // Most likely the device/store is removed ShowMyLibrary(0); } } } else ShowMyLibrary(0); } // Displays My Library view function ShowMyLibrary(addToHistory) { if(addToHistory) { dhtmlHistory.add("mylibrary",""); } currentDeviceIndex = -1; AdjustPageElements("library"); AbortPendingRequests(); subscriptions_found = 0; ConstructDeviceChoiceTable(); showMyLibrarySizeDetails(); } function AbortPendingRequests() { if (pendingRequests != null) { for (var i=0; i < pendingRequests.length; ++i) { if (pendingRequests[i] != null) { pendingRequests[i].abort(); pendingRequests[i] = null; } } } pendingRequests = new Array(); } function AddEmptyRowsInSubscriptionTable() { // Add some empty rows in the left nav var rowkeys = new Array(); var rowvalues = new Array(); var keys = new Array(); var values = new Array(); // Add some empty rows in the Subscription table // find out the current rows in the table var deviceTable = document.getElementById('device_choices_table'); var noOfRowsInSubscriptionTable = deviceTable.rows.length; var limit = 8 - noOfRowsInSubscriptionTable; for (var i =0; i < limit ; i++) { keys[0] = "innerHTML"; values[0] = " "; keys[2] = "height"; values[2]="46"; var newRow = AddRowToTable('device_choices_table', rowkeys,rowvalues,keys, values); // For getting the vertical lines AddCellToRow(newRow, keys, values); AddCellToRow(newRow, keys, values); AddCellToRow(newRow, keys, values); AddCellToRow(newRow, keys, values); } AlternateTableRowStyle('device_choices_table'); } function AddEmptyRowsInLeftMenu() { // Add some empty rows in the left nav var rowkeys = new Array(); var rowvalues = new Array(); var keys = new Array(); var values = new Array(); // First delete all the empty rows from the devicelist legth onwards ClearTable('ExtraRowsInLeftNav'); //adding 5 rows now var limit = 14 - deviceList.length; for (var i =0; i < limit ; i++) { keys[0] = "innerHTML"; values[0] = " "; AddRowToTable('ExtraRowsInLeftNav', rowkeys,rowvalues,keys, values); } } function CheckForSubscriptionUpdates() { if ((checkingSubscriptionUpdates == 0) && (currentView == "library") && (currentDeviceIndex == -1) && (subscriptions_found > 0)) { checkingSubscriptionUpdates = 1; SendAsynchornousRequest("/webaroo/e29f1fe6/updatedsubs", "", ShowUpdatedSubscriptions, ""); } } function ShowUpdatedSubscriptions(xmlStatus, data) { var subIds = new Array(); var rowIndex; var listObject = xmlStatus.getElementsByTagName('ID'); for (var j=0;j<listObject.length;j++) { if (listObject[j].nodeType != 1) continue; subIds.push(listObject[j].firstChild.nodeValue); } if ((currentView == "library") && (currentDeviceIndex == -1) && (subscriptions_found > 0)) { for (var k=0;k < subIds.length; ++k) { rowIndex = GetRowIndex(subIds[k]); if (rowIndex != -1) { var updateImg = document.getElementById('uAval' + (rowIndex-1)); if(updateImg != null) { updateImg.innerHTML = "<img src=\"/webaroo/e29f1fe6/images/webaroo_upd_available.gif\" border=\"0\" onMouseover=\"ddrivetip('Updates available.', 80)\"; onMouseout=\"hideddrivetip()\">"; } } } } checkingSubscriptionUpdates = 0; } function ConstructDeviceChoiceTable() { //On slow systems this should give an intermediate "Loading..." screen. document.getElementById('loading').style.display="block"; //Constructing the table for the given store SendDeviceChoiceTable(-1, "library"); } function AddNoContentTable() { var htmlCode; htmlCode = "<table cellpadding=\"5\" cellspacing=\"0\" border=\"0\" width=\"620\"> \ <tr> \ <td style=\"vertical-align:middle; text-align:center; font:bold 12px verdana; color:#E35201; padding-top:10px; padding-bottom:10px;\" >You currently do not have any content downloaded to your library</td> \ </tr> \ <tr> \ <td style=\"vertical-align:middle; text-align:left; font:normal 12px verdana; color:#003366;\" ><p><b>Add Web Pack</b></p>A Web Pack brings together relevant web content from multiple sources for a specific topic that you can download on your laptop or mobile devices. Currently available Web Packs include popular city destinations, news and sports - more will follow soon. To get started click on \"add web pack\" link as shown below.<br/></td> \ </tr> \ <tr> \ <td style=\"vertical-align:middle; text-align:center;\"><img src=\"images/webaroo_add_packs.gif\" /><br/></td> \ </tr> \ <tr> \ <td style=\"vertical-align:middle; text-align:left; font:normal 12px verdana; color:#003366;\" ><p><b>Add Web Site</b></p>You can also download your favorite web sites to your Library and have access to it all the time. You just need to specify the web URL and depth of pages you want to download. To add a Web Site click the \"add web site\" button as shown below.<br/> </td> \ </tr> \ <tr> \ <td style=\"vertical-align:middle; text-align:center;\"><img src=\"images/webaroo_add_site.gif\" /><br/></td> \ </tr> \ </table>"; return htmlCode; } function renderNoContentDeviceChoiceTableData() { ClearTable('device_choices_table'); AddHeaderRow('device_choices_table'); var keys = new Array(); var values = new Array(); var rowkeys = new Array(); var rowvalues = new Array(); // Need to add table in place of the cell var htmlCode = AddNoContentTable(); keys[0] = "innerHTML"; keys[2] = "colspan"; keys[3] = "align"; values[0] = htmlCode; values[1] = "top"; values[2] = "5"; values[3] = "center"; AddRowToTable('device_choices_table', rowkeys,rowvalues,keys, values); } function SendDeviceChoiceTable(deviceIndex, context) { var cardName; var cardId; var cardType; var url, request=""; var currentContext = new Array(); if (deviceIndex != -1) { cardName = deviceNameList[deviceIndex]; cardId = deviceList[deviceIndex]; cardType = storeTypeList[deviceIndex]; request = "&storeID=" + cardId +"&cardName=" + cardName; } ClearTable('device_choices_table'); // Generate the XMLHTTPRequest to get the XML response file // for the places for the Specific Store url = "/webaroo/e29f1fe6/myplaces?resourceType=storeSubscriptionXml" + request; currentContext[0] = deviceIndex; currentContext[1] = context; // This is asynchronous call SendAsynchornousRequest(url,"",renderXMLDeviceChoiceTableData,currentContext); } //Constructing the table for the given store function renderXMLDeviceChoiceTableData(webPackXml, originalContext) { // Function has I18N issue var htmlData=""; var cardName; var cardId; var cardType; var url, request=""; var deviceIndex = originalContext[0]; var originalView = originalContext[1]; // Make sure we are in same View and device index matches if ((currentView == originalView) && (currentDeviceIndex == deviceIndex)) { if (deviceIndex != -1) { cardName = deviceNameList[deviceIndex]; cardId = deviceList[deviceIndex]; cardType = storeTypeList[deviceIndex]; request = "&storeID=" + cardId +"&cardName=" + cardName; } var currentSubscriptionID; var currentChannelID; var currentSubChannelID; var currentTopic; var currentDescription; var currentSize; var realSize; var currentSizeUnit; var realSizeUnit; var currentImageCopyFlag; var currentSubscriptionType; var currentSiteID; var currentSiteURL; var currentSiteLinkLevel; var currentSubscriptionLastUpdateDate; var newRow, newCell; var keys = new Array(); var values = new Array(); var rowkeys = new Array(); var rowvalues = new Array(); myPlacesXml = webPackXml; subXml = webPackXml; url = "/webaroo/e29f1fe6/mysites?resourceType=xml" + request; // This is also a synchronous call processXMLData(url); mySitesXml = xmlContent; websiteXml = xmlContent; var subListObject = subXml.getElementsByTagName('Subscription'); // Now get the listObject for mysites var mysitesListObject = websiteXml.getElementsByTagName('Favorite'); // Clear the device_choice_table first ClearTable('device_choices_table'); if((deviceIndex==-1)&&(subListObject.length==0)&&(mysitesListObject.length==0)) { AddHeaderRow('device_choices_table'); var updateButton = document.getElementById('updateButton'); updateButton.disabled = true; var deleteButton = document.getElementById('deleteButton'); deleteButton.disabled = true; // also disable the "Copy To.." drop down control var copyToDropDownControl = document.getElementById('copyToDropDown'); copyToDropDownControl.disabled = true; renderNoContentDeviceChoiceTableData(); document.getElementById('loading').style.display="none"; document.getElementById('device_choices').style.display="block"; return; } else if((deviceIndex!=-1)&&(subListObject.length==0)&&(mysitesListObject.length==0)) { var syncDeviceButton = document.getElementById('syncDevice'); syncDeviceButton.disabled = true; var removeButton = document.getElementById('removeDevice'); removeButton.disabled = true; SetOperationStatus('deviceBanner', "No content found. Add content to your mobile device from <a href='javascript:ShowMyLibrary(1)'>my library</a>."); document.getElementById('loading').style.display="none"; document.getElementById('device_choices').style.display="none"; return; } else if((subListObject.length!=0)||(mysitesListObject.length!=0)) { AddHeaderRow('device_choices_table'); if(deviceIndex == -1) // enable the control { var updateButton = document.getElementById('updateButton'); updateButton.disabled = false; var deleteButton = document.getElementById('deleteButton'); deleteButton.disabled = false; // also disable the "Copy To.." drop down control var copyToDropDownControl = document.getElementById('copyToDropDown'); if(deviceList.length>1) // Atlease one device storage is connected copyToDropDownControl.disabled = false; } else // enable the controls for device view { var syncDeviceButton = document.getElementById('syncDevice'); syncDeviceButton.disabled = false; var removeButton = document.getElementById('removeDevice'); removeButton.disabled = false; } } // Increment the count while assigning the id to the checkbox var checkboxindex = 0; for (var j=0;j<subListObject.length;j++) { if (subListObject[j].nodeType != 1) continue; subscriptions_found=1; currentNodeObject=subListObject[j]; for (k=0;k<currentNodeObject.childNodes.length;k++) { if (currentNodeObject.childNodes[k].nodeType != 1) continue; switch(currentNodeObject.childNodes[k].nodeName) { case 'SubscriptionID': currentSubscriptionID=currentNodeObject.childNodes[k].firstChild.nodeValue; break; case 'ChannelID': currentChannelID=currentNodeObject.childNodes[k].firstChild.nodeValue; break; case 'SubChannelID': currentSubChannelID=currentNodeObject.childNodes[k].firstChild.nodeValue; break; case 'Topic': currentTopic=currentNodeObject.childNodes[k].firstChild.nodeValue; break; case 'Description': currentDescription=currentNodeObject.childNodes[k].firstChild.nodeValue; break; case 'Size': currentSize=currentNodeObject.childNodes[k].firstChild.nodeValue; break; case 'RealSize': realSize = currentNodeObject.childNodes[k].firstChild.nodeValue; break; case 'SizeUnit': currentSizeUnit=currentNodeObject.childNodes[k].firstChild.nodeValue; break; case 'RealSizeUnit': realSizeUnit=currentNodeObject.childNodes[k].firstChild.nodeValue; break; case 'ImageCopyFlag': currentImageCopyFlag=currentNodeObject.childNodes[k].firstChild.nodeValue; break; case 'LastUpdate': currentSubscriptionLastUpdateDate = currentNodeObject.childNodes[k].firstChild.nodeValue; break; } } keys[0] = "innerHTML"; keys[1] = "width"; keys[2] = "valign"; keys[3] = "align"; values[0] = "<input id=\"device_choice_checkbox" + checkboxindex +"\" name=\"device_choice_checkbox\" type=\"checkbox\" value=\""+currentSubscriptionID+"\"/>"; values[1] = "20"; values[2] = "top"; values[3] = "center"; newRow = AddRowToTable('device_choices_table', rowkeys,rowvalues,keys, values); keys[3] = ""; if(currentSubscriptionLastUpdateDate.indexOf("Not")==0) values[0] = "<font style=\"font-family:Verdana, 'Times New Roman', Times, serif; font-weight:normal; font-size:12px;\">" + currentTopic + "</font> <br />"; else values[0] = "<font style=\"font-family:Verdana, 'Times New Roman', Times, serif; font-weight:normal; font-size:12px;\"><a href=\"/webaroo/e29f1fe6/search#/webaroo/e29f1fe6/topics?searcherid=" + doubleUrlEncode(currentSubscriptionID) +"&channelId=" + currentChannelID + "\">" + currentTopic + "</a></font> <br />"; values[0] += "<input type=\"hidden\" value=\"" + MyPlace + "\" name=\"subscriptionType\">"; values[0] += "<image src=\"/webaroo/e29f1fe6/images/webaroo_webpack.gif\" /> <font class=\"itemType\">web pack</font> "; values[1] = "165"; AddCellToRow(newRow, keys, values); values[0] = "<font class=\"itemSize\">" + realSize + " " + realSizeUnit + "<br/> (" + currentSize + " " + currentSizeUnit + ")</font><br />" values[1] ="80"; AddCellToRow(newRow, keys, values); // Truncating size of currentTopic to 100 chars var regularExpr = /'/g currentDescription = currentDescription.replace(regularExpr,'\\\''); var intSize = currentDescription.length; var truncatedDescription = currentDescription.substring(0, 100); if(intSize > 100) { truncatedDescription += "..."; } // I18N issue values[0] = "<b onMouseover=\"ddrivetip('" + currentDescription + "', 300)\"; onMouseout=\"hideddrivetip()\">"; values[0] += "<font class=\"itemDes\">" + truncatedDescription + "</font></b>"; values[1] = "270"; AddCellToRow(newRow, keys, values); values[0] = (deviceIndex == -1) ? "<span id=\"uAval" + checkboxindex + "\" name=\"uAval" + checkboxindex + "\"><img name=\"umage" + checkboxindex +"\" src=\"images/webaroo_no_updates.gif\" border=\"0\"></span>" : ""; values[0] += "<font class=\"itemUpdate\">" + currentSubscriptionLastUpdateDate + "</font>"; values[1] ="85"; AddCellToRow(newRow, keys, values); keys[1] = ""; checkboxindex++; } for (j=0;j<mysitesListObject.length;j++) { if (mysitesListObject[j].nodeType != 1) continue; subscriptions_found=1; var currentNodeObject=mysitesListObject[j]; var currentSiteID; var currentSiteName; var currentSiteURL; var currentSiteLinkLevel; var originalSiteURL; var catchedSiteUrl; for (var k=0;k<currentNodeObject.childNodes.length;k++) { if (currentNodeObject.childNodes[k].nodeType != 1) continue; switch(currentNodeObject.childNodes[k].nodeName) { case 'ID': currentSiteID=currentNodeObject.childNodes[k].firstChild.nodeValue; break; case 'SiteName': currentSiteName=currentNodeObject.childNodes[k].firstChild.nodeValue; // if siteURL is more than 20 chracters, trim and append ... to it // The below code is useless because we check for site length when we add a site // but it is kept here to override manual additions -- pravin if(currentSiteName.length > 20) { currentSiteName = currentSiteName.substring(0,19) + "..."; } break; case 'SiteURL': currentSiteURL=currentNodeObject.childNodes[k].firstChild.nodeValue; originalSiteURL = currentSiteURL; // if siteURL is more than 50 chracters, trim and append ... to it if(currentSiteURL.length > 40) { currentSiteURL = currentSiteURL.substring(0,39) + "..."; } break; case 'SiteLinkLevel': currentSiteLinkLevel=currentNodeObject.childNodes[k].firstChild.nodeValue; break; case 'ChannelID': currentChannelID=currentNodeObject.childNodes[k].firstChild.nodeValue; break; case 'SubChannelID': currentSubChannelID=currentNodeObject.childNodes[k].firstChild.nodeValue; break; case 'Size': currentSize=currentNodeObject.childNodes[k].firstChild.nodeValue; break; case 'RealSize': realSize = currentNodeObject.childNodes[k].firstChild.nodeValue; break; case 'SizeUnit': currentSizeUnit=currentNodeObject.childNodes[k].firstChild.nodeValue; break; case 'ImageCopyFlag': currentImageCopyFlag=currentNodeObject.childNodes[k].firstChild.nodeValue; break; case 'LastUpdate': currentSubscriptionLastUpdateDate = currentNodeObject.childNodes[k].firstChild.nodeValue; break; case 'CachedUrl': if(currentNodeObject.childNodes[k].firstChild != null) catchedSiteUrl = currentNodeObject.childNodes[k].firstChild.nodeValue; else catchedSiteUrl = ""; break; } } keys[0] = "innerHTML"; keys[1] = "width"; keys[2] = "valign"; keys[3] = "align"; values[0] = "<input id=\"device_choice_checkbox" + checkboxindex +"\" name=\"device_choice_checkbox\" type=\"checkbox\" value=\""+currentSiteID+"\"/>"; values[1] = "20"; values[2] = "top"; values[3] = "center"; newRow = AddRowToTable('device_choices_table', rowkeys,rowvalues,keys, values); keys[3] = ""; if((currentSubscriptionLastUpdateDate.indexOf("Not")==0)||(catchedSiteUrl=="")) values[0] = "<font style=\"font-family:Verdana, 'Times New Roman', Times, serif; font-weight:normal; font-size:12px;\">" + currentSiteName + "</font><br />"; else values[0] = "<font style=\"font-family:Verdana, 'Times New Roman', Times, serif; font-weight:normal; font-size:12px;\"><a href=\""+ catchedSiteUrl +"\">" + currentSiteName + "</a></font><br />"; values[0] += "<input type=\"hidden\" value=\"" + MySite + "\" name=\"subscriptionType\">"; values[0] += "<image src=\"/webaroo/e29f1fe6/images/webaroo_website.gif\" /> <font class=\"itemType\">web site</font> "; values[1] = "165"; AddCellToRow(newRow, keys, values); values[0] = "<font class=\"itemSize\">" + currentSize + " " + currentSizeUnit + " <br/> </font><br />" values[1] = "80"; AddCellToRow(newRow, keys, values); // I18N issue values[0] = "<font class=\"itemSite\">" + currentSiteURL + "</font><br />"; values[0] += "<font class=\"itemSize\">Link Depth " + currentSiteLinkLevel + "</font>"; values[1] = "270"; AddCellToRow(newRow, keys, values); //keys[1] = "noWrap"; //values[1] = "true"; values[0] = (deviceIndex == -1) ? "<img name=\"umage" + checkboxindex +"\" src=\"images/webaroo_no_updates.gif\" border=\"0\" />" : ""; values[0] += "<font class=\"itemUpdate\">" + currentSubscriptionLastUpdateDate + "</font>"; values[1] = "85"; AddCellToRow(newRow, keys, values); // increment the count checkboxindex++; } AlternateTableRowStyle('device_choices_table'); document.getElementById('loading').style.display="none"; document.getElementById('device_choices').style.display="block"; // Add empty rows here AddEmptyRowsInSubscriptionTable(); CheckForSubscriptionUpdates(); // Asynchronous call to get real pack sizes var packContext = new Array(); packContext[0] = currentDeviceIndex; packContext[1] = currentView; packContext[2] = 'Subscription'; url = "/webaroo/e29f1fe6/myplaces?resourceType=storeSubscriptionXml" + request + "&getRealPackSize=true"; var packRequest = SendAsynchornousRequest(url, "", RenderSizeInfo, packContext); pendingRequests.push(packRequest); // Asynchronous call to get real site sizes var siteContext = new Array(); siteContext[0] = currentDeviceIndex; siteContext[1] = currentView; siteContext[2] = 'Favorite'; url = "/webaroo/e29f1fe6/mysites?resourceType=xml" + request + "&getRealSiteSize=true"; var siteRequest = SendAsynchornousRequest(url, "", RenderSizeInfo, siteContext); pendingRequests.push(siteRequest); } } function RenderSizeInfo(subSizeXml, originalContext) { var deviceIndex = originalContext[0]; var originalView = originalContext[1]; // Make sure we are in same View and device index matches if ((currentView == originalView) && (currentDeviceIndex == deviceIndex)) { var currentSubscriptionID; var currentSize; var realSize; var currentSizeUnit; var realSizeUnit; var rowIndex; var deviceChoiceTable = document.getElementById('device_choices_table'); var sizeXml = subSizeXml; var subListObject = sizeXml.getElementsByTagName(originalContext[2]); for (var j=0; j < subListObject.length; j++) { if (subListObject[j].nodeType != 1) continue; currentNodeObject=subListObject[j]; for (var k=0;k<currentNodeObject.childNodes.length;k++) { if (currentNodeObject.childNodes[k].nodeType != 1) continue; switch(currentNodeObject.childNodes[k].nodeName) { case 'SubscriptionID': currentSubscriptionID=currentNodeObject.childNodes[k].firstChild.nodeValue; break; case 'ID': currentSubscriptionID=currentNodeObject.childNodes[k].firstChild.nodeValue; break; case 'Size': currentSize=currentNodeObject.childNodes[k].firstChild.nodeValue; break; case 'RealSize': realSize = currentNodeObject.childNodes[k].firstChild.nodeValue; break; case 'SizeUnit': currentSizeUnit=currentNodeObject.childNodes[k].firstChild.nodeValue; break; case 'RealSizeUnit': realSizeUnit=currentNodeObject.childNodes[k].firstChild.nodeValue; break; } } rowIndex = GetRowIndex(currentSubscriptionID); if (rowIndex != -1) { if (originalContext[2] == 'Subscription') { deviceChoiceTable.rows[rowIndex].cells[2].innerHTML = "<font class=\"itemSize\">" + realSize + " " + realSizeUnit + "<br/> (" + currentSize + " " + currentSizeUnit + ")</font><br />" } else { deviceChoiceTable.rows[rowIndex].cells[2].innerHTML = "<font class=\"itemSize\">" + currentSize + " " + currentSizeUnit + " <br/> </font><br />" } } } } } function RemoveSubscriptions(deviceIndex ,placeIDs, siteIDs) { var url; var confirmDelete; if(deviceIndex != -1) { confirmDelete = confirm('Are you sure you want to delete the selected content?') } else { confirmDelete = confirm('Are you sure you want to delete the selected content? Please note that the content will also be deleted from your mobile stores if they are connected right now.') } if(confirmDelete) { var status="Processing delete request. Please wait..."; if (deviceIndex == -1) { SetOperationStatus('libraryBanner', status); } else { SetOperationStatus('deviceBanner', status); } var deletedXml = '<XmlData>\n'; if (deviceIndex != -1) { deletedXml += '<storeID>' + deviceList[deviceIndex] + '</storeID>\n'; deletedXml += '<CardName>' + EncodeValue(deviceNameList[deviceIndex]) + '</CardName>\n'; deletedXml += '<CardType>' + storeTypeList[deviceIndex] + '</CardType>\n'; deletedXml += '<DeviceType>' + deviceTypeList[deviceIndex] + '</DeviceType>\n'; } deletedXml += '<Response>\n'; if (placeIDs.length > 0) { deletedXml += CreateSubscriptionsXml(placeIDs, MyPlace); } if (siteIDs.length > 0) { deletedXml += CreateSubscriptionsXml(siteIDs, MySite); } deletedXml += '</Response>\n'; deletedXml += '</XmlData>\n'; url = "/webaroo/e29f1fe6/savemysubs?request=delete"; SendAsynchornousRequest(url, "XMLData=" + deletedXml, ReturnMessageStatus, deviceIndex); } } // Called from My Library and Device view function SendDeleteRequestToServer(deviceIndex, subscriptionID) { var subscriptionType = FindSubscriptionTypeFromID(subscriptionID); if (subscriptionType != -1) { var placeIDs = new Array(); var siteIDs = new Array(); if (subscriptionType == MyPlace) { placeIDs[0] = subscriptionID; } else { siteIDs[0] = subscriptionID; } RemoveSubscriptions(deviceIndex, placeIDs, siteIDs); } else { // TODO: handle error } } function FindSubscriptionTypeFromID(subscriptionID) { var libraryForm = document.device_choices_form; var subscriptionsTable = document.getElementById('device_choices_table'); var j, k; var type = -1; if (subscriptionsTable.rows.length == 2) // Table only has header + one row. { if (subscriptionID == libraryForm.device_choice_checkbox.value) { type = libraryForm.subscriptionType.value; } } else { for (j=0; j < libraryForm.device_choice_checkbox.length; ++j) { if (subscriptionID == libraryForm.device_choice_checkbox[j].value) { type = libraryForm.subscriptionType[j].value; break; } } } return type; } function CreateSubscriptionsXml(subscriptionIDs, subscriptionType) { var subscriptionsXml = ""; if (subscriptionType == MyPlace) { subscriptionsXml += '<Subscriptions>\n'; subscriptionsXml += CreateMyPlacesXml(subscriptionIDs); subscriptionsXml += '</Subscriptions>\n'; } else if (subscriptionType == MySite) { subscriptionsXml += '<Favorites>\n'; subscriptionsXml += CreateMySitesXml(subscriptionIDs); subscriptionsXml += '</Favorites>\n'; } return subscriptionsXml; } function CreateMyPlacesXml(subscriptionIDs) { var subscriptionList = myPlacesXml.getElementsByTagName('Subscription'); var i,j,k; var currentSubscription; var currentSubscriptionID; var currentChannelID; var currentSubChannelID; var currentTopic; var currentSize; var currentImageCopyFlag; var myPlacesXmlString = ""; for (j=0; j < subscriptionList.length; ++j) { if (subscriptionList[j].nodeType != 1) continue; currentSubscription=subscriptionList[j]; for (k=0; k < currentSubscription.childNodes.length; ++k) { if (currentSubscription.childNodes[k].nodeType != 1) continue; switch(currentSubscription.childNodes[k].nodeName) { case 'SubscriptionID': currentSubscriptionID=currentSubscription.childNodes[k].firstChild.nodeValue; break; case 'ChannelID': currentChannelID=currentSubscription.childNodes[k].firstChild.nodeValue; break; case 'SubChannelID': currentSubChannelID=currentSubscription.childNodes[k].firstChild.nodeValue; break; case 'Topic': currentTopic='<![CDATA[' + escape(currentSubscription.childNodes[k].firstChild.nodeValue) + ']]>'; break; case 'OriginalSize': currentSize=currentSubscription.childNodes[k].firstChild.nodeValue; break; case 'ImageCopyFlag': currentImageCopyFlag=currentSubscription.childNodes[k].firstChild.nodeValue; break; } } for (i=0; i < subscriptionIDs.length; ++i) { if (currentSubscriptionID == subscriptionIDs[i]) { myPlacesXmlString += '<Subscription>\n'; myPlacesXmlString += '<SubscriptionID>' + currentSubscriptionID + '</SubscriptionID>\n'; myPlacesXmlString += '<ChannelID>' + currentChannelID + '</ChannelID>\n'; myPlacesXmlString += '<SubChannelID>' + currentSubChannelID + '</SubChannelID>\n'; myPlacesXmlString += '<Topic>' + currentTopic + '</Topic>\n'; myPlacesXmlString += '<Size>' + currentSize + '</Size>\n'; myPlacesXmlString += '<ImageCopyFlag>' + currentImageCopyFlag + '</ImageCopyFlag>\n'; myPlacesXmlString += '</Subscription>\n'; break; } } } return myPlacesXmlString; } function CreateMySitesXml(siteIDs) { var favoriteList = mySitesXml.getElementsByTagName('Favorite'); var i,j,k; var mySitesXmlString = ""; var currentFavorite; var currentSiteID; var currentSiteName; var currentUrl; var currentSiteLinkLevel; var currentChannelID; var currentSubChannelID; var currentSize; var currentImageCopyFlag; for (j=0; j < favoriteList.length; ++j) { if (favoriteList[j].nodeType != 1) continue; currentFavorite=favoriteList[j]; for (k=0; k < currentFavorite.childNodes.length; ++k) { if (currentFavorite.childNodes[k].nodeType != 1) continue; switch(currentFavorite.childNodes[k].nodeName) { case 'ID': currentSiteID=currentFavorite.childNodes[k].firstChild.nodeValue; break; case 'SiteName': currentSiteName='<![CDATA[' + escape(currentFavorite.childNodes[k].firstChild.nodeValue)+ ']]>'; break; case 'SiteURL': currentUrl='<![CDATA[' + doubleUrlEncode(currentFavorite.childNodes[k].firstChild.nodeValue)+ ']]>';; break; case 'SiteLinkLevel': currentSiteLinkLevel=currentFavorite.childNodes[k].firstChild.nodeValue; break; case 'ChannelID': currentChannelID=currentFavorite.childNodes[k].firstChild.nodeValue; break; case 'SubChannelID': currentSubChannelID=currentFavorite.childNodes[k].firstChild.nodeValue; break; case 'Size': currentSize=currentFavorite.childNodes[k].firstChild.nodeValue; break; case 'ImageCopyFlag': currentImageCopyFlag=currentFavorite.childNodes[k].firstChild.nodeValue; break; } } for (i=0; i < siteIDs.length; ++i) { if (currentSiteID == siteIDs[i]) { mySitesXmlString += '<Favorite>\n'; mySitesXmlString += '<ID>' + currentSiteID + '</ID>\n'; mySitesXmlString += '<SiteName>' + currentSiteName + '</SiteName>\n'; mySitesXmlString += '<SiteURL>' + currentUrl + '</SiteURL>\n'; mySitesXmlString += '<SiteLinkLevel>' + currentSiteLinkLevel + '</SiteLinkLevel>\n'; mySitesXmlString += '<ChannelID>' + currentChannelID + '</ChannelID>\n'; mySitesXmlString += '<SubChannelID>' + currentSubChannelID + '</SubChannelID>\n'; mySitesXmlString += '<Size>' + currentSize + '</Size>\n'; mySitesXmlString += '<ImageCopyFlag>' + currentImageCopyFlag + '</ImageCopyFlag>\n'; mySitesXmlString += '</Favorite>\n'; break; } } } return mySitesXmlString; } // Called from My Library and Device view function SendUpdateRequestToServer(subscriptionID) { var subs = new Array(); subs.push(subscriptionID); var xmlData = CreateSyncUpdateSubscriptionsXml(subs, false); // Internally this also follows in sync request url = "/webaroo/e29f1fe6/update"; sendXMLData(url, "XMLData=" + xmlData); //Need to display status status = GetOperationStatus(xmlContent); SetOperationStatus('libraryBanner', status); } function UpdateSelectedSubscriptions() { // find all the subscription ids for which checkboxes are checked var selectedSubscriptions= new Array(); QuerySelectedCheckboxes(selectedSubscriptions) if (selectedSubscriptions.length > 0) { var xmlData = CreateSyncUpdateSubscriptionsXml(selectedSubscriptions, false); url = "/webaroo/e29f1fe6/update"; SendAsynchornousRequest(url, "XMLData=" + xmlData, SetReturnMessageStatus, ""); ClearAllCheckboxes(); } else { SetOperationStatus('libraryBanner', NoContentSelectedMessage); } } function AddSubscriptionsToDevice(deviceIndex, placeIDs, siteIDs) { var status = ""; var url; var cardName = EncodeValue(deviceNameList[deviceIndex]); var cardId = deviceList[deviceIndex]; var cardType = storeTypeList[deviceIndex]; var deviceType = deviceTypeList[deviceIndex]; var copyXml = '<XmlData>\n'; copyXml += '<storeID>' + cardId + '</storeID>\n'; copyXml += '<CardName>' + cardName + '</CardName>\n'; copyXml += '<CardType>' + cardType + '</CardType>\n'; copyXml += '<DeviceType>' + deviceType + '</DeviceType>\n'; copyXml += '<Response>\n'; if (placeIDs.length > 0) { copyXml += CreateSubscriptionsXml(placeIDs, MyPlace); } if (siteIDs.length > 0) { copyXml += CreateSubscriptionsXml(siteIDs, MySite); } copyXml += '</Response>\n'; copyXml += '</XmlData>\n'; url = "/webaroo/e29f1fe6/savemysubs?request=add"; SendAsynchornousRequest(url, "XMLData=" + copyXml, SetCopyToDeviceStatus, deviceIndex); // i18n issue status = "Processing copy request. Check progress on <a href=\"javascript:ShowStatusWindow()\">status window</a>."; return status; } function SetCopyToDeviceStatus(xmlStatus, deviceIndex) { var status = GetOperationStatus(xmlStatus); SetOperationStatus('libraryBanner', status); // Check device storage is Webaroo Storage or not if((deviceIndex >= 0) && (storeTypeList.length > deviceIndex) && (deviceList[deviceIndex] == deviceConfigMessage) && (storeTypeList[deviceIndex]=="nowebaroo")) { ShowSynchornousLeftMenu(); } } // Called from My Library view function SendCopyRequestToServer(deviceIndex, subscriptionID) { var status = ""; if (deviceList[deviceIndex] != deviceConfigMessage) { var subscriptionType = FindSubscriptionTypeFromID(subscriptionID); if (subscriptionType != -1) { var placeIDs = new Array(); var siteIDs = new Array(); if (subscriptionType == MyPlace) { placeIDs[0] = subscriptionID; } else { siteIDs[0] = subscriptionID; } status = AddSubscriptionsToDevice(deviceIndex, placeIDs, siteIDs); SetOperationStatus('libraryBanner', status); // Check device storage is Webaroo Storage or not if(storeTypeList[deviceIndex]=="nowebaroo") { deviceList[deviceIndex] = deviceConfigMessage; } } else { // TODO: handle error } } else { //i18n issue status = "Copy can't be started as device configuration is in progress."; SetOperationStatus('libraryBanner', status); } } // Called from My Library view function CopySelectedSubscriptionsToDevice(deviceIndex) { var status = ""; if (deviceList[deviceIndex] != deviceConfigMessage) { var selected = 0; // find all the subscription ids for which checkboxes are checked var selectedPlaces = new Array(); var selectedSites = new Array(); QuerySelectedCheckboxesBasedOnType(MyPlace, selectedPlaces) QuerySelectedCheckboxesBasedOnType(MySite, selectedSites) if ((selectedPlaces.length > 0) || (selectedSites.length > 0)) { status = AddSubscriptionsToDevice(deviceIndex, selectedPlaces, selectedSites); selected = 1; } else { SetOperationStatus('libraryBanner', NoContentSelectedMessage); } if (selected == 1) { SetOperationStatus('libraryBanner', status); ClearAllCheckboxes(); // Check device storage is Webaroo Storage or not if(storeTypeList[deviceIndex]=="nowebaroo") { deviceList[deviceIndex] = deviceConfigMessage; } } } else { //i18n issue status = "Copy can't be started as device configuration is in progress."; SetOperationStatus('libraryBanner', status); } } function SetReturnMessageStatus(xmlStatus, deviceIndex) { var status = GetOperationStatus(xmlStatus); SetOperationStatus('libraryBanner', status); } function ReturnMessageStatus(xmlStatus,deviceIndex) { var status = GetOperationStatus(xmlStatus); if (deviceIndex == -1) { // CHANGE to delete table row ShowMyLibrary(0); SetOperationStatus('libraryBanner', status); } else { // CHANGE to delete table row ShowDeviceInfo(0,deviceIndex); SetOperationStatus('deviceBanner', status); } }