home *** CD-ROM | disk | FTP | other *** search
- // i8n - Compliant
- // Constructs the Navigation Systems For the HTML Page
- // The default store
- var default_store_id;
- var linkset=new Array()
-
- // Type of mobile left menu request
- var SyncRequest = -1;
- var AsyncRequest = 0;
- var FirstAsyncRequest = 1;
-
- function InstallWebaroo()
- {
- var url = "/webaroo/e29f1fe6/installwebaroo";
- SendAsynchornousRequest(url, "", IgnoreResponse, "");
- }
-
- function IgnoreResponse(xmlStatus, data)
- {
- }
-
-
- function ShowTopMenu()
- {
- var url = "/webaroo/e29f1fe6/xml?request=topmenu";
- processXMLData(url);
- renderTopMenu(xmlContent);
- }
-
- function renderTopMenu(topMenuXml)
- {
- var htmlData='';
- var menuNames = new Array();
- var menuLinks = new Array();
- var menuImages = new Array();
- var menuOnOverImages = new Array();
- var index = 0;
-
- // Delete the rows after the first top 5 rows
- var topMenuTable = document.getElementById('topMenuTable');
- var listObject = topMenuXml.getElementsByTagName('Menu');
- for (var j=0;j<listObject.length;j++)
- {
- if (listObject[j].nodeType != 1)
- continue;
- menuNames[index] = listObject[j].firstChild.nodeValue;
- menuLinks[index] = listObject[j].getAttributeNode('link').nodeValue;
- menuImages[index] = listObject[j].getAttributeNode('image').nodeValue;
- menuOnOverImages[index] = listObject[j].getAttributeNode('onoverimage').nodeValue;
- index++;
- }
-
- // First Icon is Webaroo Icon
- htmlData = "<a href=\"" + menuLinks[0] + "\" target=\"_top\" ><img src=\"" + menuImages[0] + "\" border=\"0\" alt=\"\"></a>";
- topMenuTable.rows[0].cells[0].innerHTML = htmlData;
-
- for(var i=1; i < index; i++)
- {
- var imageName = "Image" + i ;
- if(topMenuTable.rows[0].cells[i].className == "selected")
- {
- //pick up the other image here: Remove the last 4 character (".gif") from name and
- // append _f2 name there
- var iconImageNamelength = menuImages[i].length;
- var iconImageName = menuImages[i].substring(0,iconImageNamelength-4)+ '_f2.gif';
-
- htmlData = "<a href=\"" + menuLinks[i] + "\" target=\"_top\"><img name=\"" + imageName + "\" src=\"" + iconImageName + "\" border=\"0\" alt=\"\"></a>";
- }
- else
- 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>";
- htmlData += " <a href=\"" + menuLinks[i] + "\" target=\"_top\" style=\"text-decoration:none;\" > <br/>" + menuNames[i] + "</a>";
- topMenuTable.rows[0].cells[i].innerHTML = htmlData;
- }
- }
-
- function ShowMobileLoadingMessage(MessageText)
- {
- var rowkey = new Array();
- var rowvalues = new Array();
- var keys = new Array();
- var values = new Array();
-
- // Delete the rows after the first top 4 rows
- DeleteRowsFromTable('leftMenu', 4 , -1);
-
- keys[0] = "innerHTML";
- values[0] = MessageText;
- keys[1] = "className";
- values[1] = "LeftMenuStatusMessage";
- AddRowToTable('leftMenu',rowkey,rowvalues, keys, values);
- }
-
- function ShowAsynchornousLeftMenu(isAsyncFirstTime)
- {
- if (currentView != "")
- {
- // i18n issue
- // Show message in leftMenuTable itself
- ShowMobileLoadingMessage('Loading available storage cards...');
- }
- var url = "/webaroo/e29f1fe6/xml?request=leftmenu";
- SendAsynchornousRequest(url, "", ShowLeftDeviceMenu, isAsyncFirstTime);
- }
-
- function ShowSynchornousLeftMenu()
- {
- var url = "/webaroo/e29f1fe6/xml?request=leftmenu";
- sendXMLData(url, "");
- ShowLeftDeviceMenu(xmlContent, SyncRequest);
- }
-
- //Constructs the Left Device Menu For Navigating among the Various Stores
- function ShowLeftDeviceMenu(leftmenuXML, data)
- {
- var currentDeviceInfo = new Array();
-
- if ((currentView == "device") && (currentDeviceIndex != -1))
- {
- currentDeviceInfo[0] = deviceList[currentDeviceIndex];
- currentDeviceInfo[1] = deviceNameList[currentDeviceIndex];
- currentDeviceInfo[2] = storeTypeList[currentDeviceIndex];
- currentDeviceInfo[3] = deviceTypeList[currentDeviceIndex];
- currentDeviceInfo[4] = storeTotalSizeList[currentDeviceIndex];
- currentDeviceInfo[5] = storeAvailableSizeList[currentDeviceIndex];
- currentDeviceInfo[6] = storeLibrarySizeList[currentDeviceIndex];
- }
-
- deviceList = new Array();
- deviceNameList = new Array();
- storeTypeList = new Array();
- deviceTypeList = new Array();
- storeTotalSizeList = new Array();
- storeAvailableSizeList = new Array();
- storeLibrarySizeList = new Array();
-
- renderXMLLeftDeviceMenuData(leftmenuXML);
- CreateCopySelectOptions();
-
- if ((currentView == "library") || (currentView == ""))
- {
- showMyLibrarySizeDetails();
- }
- else if ((currentView == "device") && (currentDeviceIndex != -1))
- {
- var nextAction = CheckDeviceInfoAfterRefresh(currentDeviceInfo);
- // always refresh device view to update index passed to actions
- ShowDeviceInfo(0,nextAction[1]);
- }
- }
-
- function CheckDeviceInfoAfterRefresh(currentDeviceInfo)
- {
- var nextAction = new Array();
- nextAction[0] = "nochange";
- nextAction[1] = -1;
-
- if (currentDeviceInfo.length > 0)
- {
- var devicePresent = false;
- var deviceInfoChanged = false;
-
- // ignore the first entry which is for the local store C:
- for(var i=1;i<deviceList.length;i++)
- {
- if ((currentDeviceInfo[1] == deviceNameList[i]) && (currentDeviceInfo[3] == deviceTypeList[i]))
- {
- devicePresent = true;
- nextAction[1] = i;
-
- if ((currentDeviceInfo[0] != deviceList[i]) || (currentDeviceInfo[2] != storeTypeList[i]) || (currentDeviceInfo[4] != storeTotalSizeList[i]) || (currentDeviceInfo[5] != storeAvailableSizeList[i]) || (currentDeviceInfo[6] != storeLibrarySizeList[i]))
- {
- deviceInfoChanged = true;
- }
- else
- {
- currentDeviceIndex = i;
- }
-
- break;
- }
- }
-
- if (devicePresent)
- {
- if (deviceInfoChanged)
- {
- nextAction[0] = "refresh";
- }
- }
- else
- {
- nextAction[0] = "invalid";
- }
- }
-
- return nextAction;
- }
-
- function showMyLibrarySizeDetails()
- {
- // First entry is locatmother store entry
- var cardAvailableSize = storeAvailableSizeList[0];
- var cardTotalSize = storeTotalSizeList[0];
- var cardLibrarySize = storeLibrarySizeList[0];
- var htmlData = "";
-
- if(cardTotalSize)
- {
- htmlData += "<font class=\"StoreSize\">";
- htmlData += "My Library: " + cardLibrarySize + " (" + cardAvailableSize + " Free)";
- //htmlData += "Total/Available: <b>" +cardTotalSize + "/" + cardAvailableSize + "</b> ";
- htmlData += " | <a style=\"color:#114488; text-decoration:underline;\" href=\"javascript:ShowStatusWindow()\">Status Window</a> </font>";
- }
- document.getElementById('librarySize').innerHTML = htmlData;
- //if(NiftyCheck())
- //{
- //Rounded("div#librarySize","all","#FFAA44","#FFCC88","smooth");
- //}
- }
-
- //Function that Renders the Data to Left Device Menu of HTML
- function renderXMLLeftDeviceMenuData(leftmenuXML)
- {
- var cardType;
- var htmlData='';
- var keys = new Array();
- var values = new Array();
- var rowkey = new Array();
- var rowvalues = new Array();
- var index = 0;
-
- // Delete the rows after the first top 4 rows
- DeleteRowsFromTable('leftMenu', 4 , -1);
- var listObject = leftmenuXML.getElementsByTagName('Response');
- if(listObject.length >0)
- {
- for (var j=0;j<listObject[0].childNodes.length;j++)
- {
- if (listObject[0].childNodes[j].nodeType != 1) continue;
-
- var cardName = listObject[0].childNodes[j].getElementsByTagName('Name');
- var cardId = listObject[0].childNodes[j].getElementsByTagName('ID');
- var cardType = listObject[0].childNodes[j].getElementsByTagName('Type');
- var deviceType = listObject[0].childNodes[j].getElementsByTagName('CardType');
- var storeTotalSize = listObject[0].childNodes[j].getElementsByTagName('TotalStorage');
- var storeAvailableSize = listObject[0].childNodes[j].getElementsByTagName('AvailableSpace');
- var storeLibrarySize = listObject[0].childNodes[j].getElementsByTagName('LibrarySize');
-
- var cardNameStr = cardName[0].firstChild.nodeValue;
- var cardIdStr = cardId[0].firstChild.nodeValue;
- var cardTypeStr = cardType[0].firstChild.nodeValue;
- var deviceTypeStr = deviceType[0].firstChild.nodeValue;
- var storeTotalSizestr = storeTotalSize[0].firstChild.nodeValue;;
- var storeAvailableSizestr = storeAvailableSize[0].firstChild.nodeValue;;
- var storeLibrarySizestr = storeLibrarySize[0].firstChild.nodeValue;;
-
- deviceList[index] = cardIdStr;
- deviceNameList[index] = cardNameStr;
- storeTypeList[index] = cardTypeStr;
- deviceTypeList[index] = deviceTypeStr;
- storeTotalSizeList[index] = storeTotalSizestr;
- storeAvailableSizeList[index] = storeAvailableSizestr;
- storeLibrarySizeList[index] = storeLibrarySizestr;
- index++;
- }
- }
-
- if(deviceList.length > 1)
- {
- // ignore the first entry which is for the local store C:
- for(var i=1;i<deviceList.length;i++)
- {
- // GetSpace(2) for indentation level
- //var subMenuIndentationLevel = 2;
- keys[0] = "innerHTML";
- keys[1] = "id";
- values[0] = "<image src=\"/webaroo/e29f1fe6/images/webaroo_mobiledevice.gif\" /><a href=\"javascript:ShowDeviceInfo(1," + i + ")\">" + deviceNameList[i] + "</a>";
- values[1] = "deviceIndexCell" + i;
- AddRowToTable('leftMenu',rowkey,rowvalues, keys, values);
- }
- }
- else
- {
- ShowMobileLoadingMessage('Connect mobile device and click \"refresh\" to view available storage cards');
- }
- AddEmptyRowsInLeftMenu();
- }
-
- function DeleteRowsFromTable(tableId, deleteStart , deleteEnd)
- {
- var leftmenutable = document.getElementById(tableId);
- var curr_row;
- if(deleteEnd == -1)
- deleteEnd = leftmenutable.rows.length-1;
- for (curr_row = deleteEnd; curr_row >=deleteStart ; curr_row--)
- {
- leftmenutable.deleteRow(curr_row);
- }
- }
-
- function RenderPopUpMenu(e, context, deviceIndex)
- {
- if (!document.all&&!document.getElementById)
- return;
-
- if(navigator.appName.indexOf("Microsoft")!=-1) e = window.event;
-
- var imagenode;
- imagenode = (e.target) ? e.target.parentNode:e.srcElement.parentElement;
-
- // Name is also the attribute
- imagenode = imagenode.getAttributeNode("name").nodeValue;
-
- var indexnumber = imagenode.substr(5); // Ripping the "image" from the name to get the index
- // Index of Checkbox and Imagenode would always match
- // i.e. image0 would be associated with device_choice_checkbox0
- var checkboxnodeid = "device_choice_checkbox" + indexnumber;
- var checkboxnode = document.getElementById(checkboxnodeid);
- var subscriptionID = checkboxnode.value;
-
- if(context=="library")
- {
- // Needs to modify the linkset[1] to show the device entries
- linkset[1]="<a href=\"#\" onclick=\"SendUpdateRequestToServer('" + subscriptionID + "')\" >Update</a>";
- // 0 the entry is for my Library
- for(var i =1; i < deviceNameList.length; i++)
- {
- var storename = deviceNameList[i];
- linkset[1] += "<a href=\"#\" onclick=\"SendCopyRequestToServer(" + i + ", '" + subscriptionID + "')\" >Copy to " + storename + "</a>";
- }
- linkset[1] += "---------------";
- linkset[1] += "<a href=\"#\" onclick=\"SendDeleteRequestToServer(" + deviceIndex + ", '" + subscriptionID + "')\">Delete</a>";
- // Now call the ShowMenu function
- showmenu(e, linkset[1]);
- }
- else if(context =="device")
- {
- linkset[2] = "<a href=\"#\" onclick=\"SendSyncRequestToServer('" + subscriptionID + "')\">Sync</a>";
- linkset[2] += "---------------";
- linkset[2] += "<a href=\"#\" onclick=\"SendDeleteRequestToServer(" + deviceIndex + ", '" + subscriptionID + "')\">Delete</a>";
- showmenu(e, linkset[2]);
- }
- }
-
- function MM_preloadImages() { //v3.0
- var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
- var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
- if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
- }
-
- function MM_swapImgRestore() { //v3.0
- var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
- }
-
- function MM_findObj(n, d) { //v4.01
- var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
- d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
- if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
- for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
- if(!x && d.getElementById) x=d.getElementById(n); return x;
- }
-
- function MM_swapImage() { //v3.0
- var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
- if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
- }
-
- function CreateCopySelectOptions()
- {
- var copyOptions = document.TopControlForm.copySelect;
- var copyToDropDownControl = document.getElementById('copyToDropDown');
-
- if(copyOptions)
- {
- // Clear all of the option froms combo box first except the first one
- copyOptions.options.length=1;
- if (deviceList.length > 1)
- {
- for (var i=1; i < deviceList.length; ++i) // 0th entry is for My Library
- {
- copyOptions.options[i] = new Option(deviceNameList[i],i,false,false);
- }
- // Get list Object for MySites and Subscription
- var subListObject = null;
- if(subXml != null)
- {
- subListObject = subXml.getElementsByTagName('Subscription');
- }
- var mysitesListObject = null;
- if(websiteXml != null)
- {
- mysitesListObject = websiteXml.getElementsByTagName('Favorite');
- }
-
- if(((subListObject == null) || (subListObject.length == 0)) && ((mysitesListObject == null) || (mysitesListObject.length == 0)))
- {
- copyToDropDownControl.disabled = true;
- }
- else
- {
- copyToDropDownControl.disabled = false;
- }
- }
- else // Disable the copy To control here
- {
- copyToDropDownControl.disabled = true;
- }
- }
- }
-
- function CopyToStorage()
- {
- var indexDeviceStorage = document.TopControlForm.copySelect.options[document.TopControlForm.copySelect.selectedIndex].value
- CopySelectedSubscriptionsToDevice(indexDeviceStorage);
- // Setting back the selected index to 0
- document.TopControlForm.copySelect.selectedIndex = 0;
- }
-