function goCheckOut() { alert('Inside goCheckOut'); document.location.href = "/ejournals/secure/AddressCheckout.do"; } var Issue = { selectAll: function() { $(".select > input") var checkBoxLength = $(".select > input").length; if (document.eJournalMainForm.selectall.checked == true) { for (i=0; i < checkBoxLength; i++) { $(".select > input")[i].checked = true; } } else { for (i=0; i < checkBoxLength; i++) { $(".select > input")[i].checked = false; } } }, emailToFriend: function(actionName, journalId) { var m = document.mail; var sub = document.title; sub = sub.replace(/&/g, " and "); sub = sub.replace(/&/gi,"and"); var tempMail = 'mailto:?subject=' + sub + '&body=' + escape(document.location.href); m.action = tempMail; m.submit(); }, citationDownload: function(format, id, jid) { var journalId = jid; if (!journalId){ journalId = null; } var issue = document.eJournalMainForm.issue.value; var pageType='Issue'; if (!issue){ pageType = 'Online'; } document.downloadCitation.format.value = format; document.downloadCitation.id.value = id; document.downloadCitation.jid.value = journalId; document.downloadCitation.pageType.value = pageType; document.downloadCitation.submit(); }, download: function(type,id,url,pageType) { //alert("Issue.download"); var orderSizeString = document.eJournalMainForm.orderSize.value; var orderSize; // alert ("orderSizeString"+orderSizeString); if (orderSizeString) { orderSize = parseInt(orderSizeString,10) & 255; // alert("size: "+orderSize); } if (!pageType){ pageType = document.eJournalMainForm.pageType.value; } //check order limit code /commenting out if(id) { if (type == 'PDF' && document.eJournalMainForm.hasSubscription.value == 'true') { //download the pdf...may need to change later. document.location.href = "/ejournals/app/ejournaldownload.do?jid=" + document.eJournalMainForm.jid.value + "&pageType=ViewCart&chronid="+id; return; } //check order limit code /commenting out //also go to My downloads page. document.eJournalMainForm.downloadType.value = type; document.eJournalMainForm.pageType.value = pageType; document.eJournalMainForm.pdfChronicleId.value = id; document.eJournalMainForm.chronicleId.value = id; document.eJournalMainForm.submit(); } else { var checkboxNodes = $("#main_content > .item > .select input"); var isChecked = false; if (!checkboxNodes){ alert("No papers are selectable"); return; } var totalChecked = 0; for (i=0; i < checkboxNodes.length; i++) { if (checkboxNodes[i].checked == true) { isChecked = true; totalChecked = totalChecked+1; } } //check order limit code /commenting out if (isChecked) { //make concessions for when published content doesn't have the necessary form values document.eJournalMainForm.downloadType.value = type; document.eJournalMainForm.pageType.value = pageType; document.eJournalMainForm.submit(); } else { alert('Please Select an item(s) to download'); } } } }; var Cart = { checkout: function(journalId) { //alert('Inside Cart.checkOut'); document.location.href = "/ejournals/secure/AddressCheckout.do"; }, goCheckOut: function(journalId, pageType, erightsUrl, orderSize) { if(orderSize >0) { document.location.href = "/ejournals/secure/AddressCheckout.do?jid="+journalId+"&pageType="+pageType; } else { alert("Your cart is empty. Please add items before checkout"); } }, goMemberCheckOut: function(journalId, pageType, erightsUrl, orderSize, targetUrl) { if(orderSize >0) { document.location.href = erightsUrl + encodeURIComponent(targetUrl); } else { alert("Your cart is empty. Please add items before checkout"); } }, becomeMember: function(journalId, pageType, membershipURL, orderSize, targetUrl) { if(orderSize >0) { document.location.href = membershipURL; } else { alert("Your cart is empty. Please add items before checkout"); } }, reloadPage: function(journalId, pageType) { alert('Here'); document.location.href="/ejournals/app/ViewCart.do?jid=" + journalId + "&pageType=ViewCart"; alert('f re'); }, view: function(journalId) { //alert('Inside Cart.view'); document.location.href = "/ejournals/app/ViewCart.do?jid=" + journalId + "&pageType=ViewCart"; } }; var Page = { emailToFriend: function(actionName, journalId) { var m = document.mail; var sub = document.title; sub = sub.replace(/&/g, " and "); sub = sub.replace(/&/gi,"and"); var tempMail = 'mailto:?subject=' + sub + '&body=' + escape(document.location.href); m.action = tempMail; m.submit(); }, printThisPage: function(jid, pageType) { var queryString = window.top.location.search; var reqParam = "?jid=" + jid + "&pageType=" + pageType + "&print=print"+"&" + queryString; //starts with ? ...see if all browsers accept //won't need this. Will load this the Navigation.onload function window.open(reqParam,'_blank','height=400,width=800,status=yes,toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=yes'); }, printCurrentYear: function() { var date=new Date(); year=date.getFullYear(); document.write(year); } }; var Navigation = { gotoPage: function(pageType, jid) { //alert('Inside Navigation.gotoPage. PageType/JID:'+pageType+jid); document.location.href = "/ejournals/jsp/journalapp.jsp?jid="+jid+"&pageType="+pageType; }, login: function(serverName, pageType, jid, reqURL, reqURI, arbitraryTargetUrl) { //alert("login"); var scheme = 'http'; var port = '80'; var targetUrl = null; var browserParams = window.top.location.search; if (browserParams.indexOf("pageType=" + pageType)>=0) { targetUrl = reqURL + browserParams; } else { //if the page type is different then the one passed in has precedence. var parameters = (browserParams).split('?')[1]; targetUrl = reqURL + "?" + "jid=" + jid + "&pageType=" + pageType; if (parameters) { targetUrl = targetUrl + '&' + parameters; } } //some pages end in .do instead of using journalapp.jsp, so we have to account for them if (pageType=='ViewCart') { //alert("accounting for IE & ViewCart"); arbitraryTargetUrl = reqURL.replace(/jsp\/cart\/ViewCart.jsp/gi, "app/ViewCart.do") + "?" + "jid=" + jid + "&pageType=" + pageType; //if the reqURL is missing construct the url if(reqURL.indexOf(serverName)==-1){ arbitraryTargetUrl = scheme+"://" + serverName + ":" + port + "/ejournals/"+"app/ViewCart.do" + "?" + "jid=" + jid + "&pageType=" + pageType; } } if(arbitraryTargetUrl) { targetUrl = arbitraryTargetUrl ; } targetUrl = escape(targetUrl); if (!getCookieValue('sm_constitid')) { var emetaURL = 'https://' + serverName + '/appssecured/login/servlet/ErightsLoginServlet?ERIGHTS_TARGET=' + targetUrl; //var emetaURL = 'http://' + serverName + '/appssecured/servlet/ErightsLoginServlet?ERIGHTS_TARGET=' + targetUrl; document.location.href = emetaURL; } else { alert("Already logged in"); } }, logout: function(serverName, pageType, jid, reqURL, reqURI, arbitraryTargetUrl) { //alert("logout "+arbitraryTargetUrl); var scheme = 'http'; var params = window.top.location.search; if (params=='' || params.indexOf("pageType=")==-1 || params.indexOf("jid=")==-1) { params = '?pageType='+pageType+'&jid='+jid; } //accounting for IE6 wierdness if (navigator.userAgent.indexOf('MSIE') > -1) { if (pageType='ViewCart') { //alert("accounting for IE & ViewCart--will remove next build"); arbitraryTargetUrl = reqURL.replace(/jsp\/cart\/ViewCart.jsp/gi, "app/ViewCart.do") + params; } } var targetUrl = reqURL + params; if(arbitraryTargetUrl) { targetUrl = arbitraryTargetUrl; } targetUrl = escape(targetUrl); var emetaURL = 'https://' + serverName + '/appssecured/login/servlet/ErightsLoginServlet?command=logout&ERIGHTS_TARGET=' + targetUrl; //var emetaURL = 'http://' + serverName + '/appssecured/servlet/ErightsLoginServlet?command=logout&ERIGHTS_TARGET=' + targetUrl; //alert("Logging out with: "+emetaURL); document.location.href = emetaURL; }, updateMainFrame: function(pageType, jid, targetUrl, htmlDivId) { //alert('Inside Navigation.updateMainFrame: function(pageType, jid) {:'+pageType+jid); var lyrisFile = jid + '_lyris.html'; var url = "http://www.spe.org/ejournals/Common/Includes/"+lyrisFile; //alert('url: '+url); $.get(url, { key: "value"}, function(htmlResponse){ //alert("ajax return: " + htmlResponse); if (pageType=='Lyris') { $("#main").hide().html(htmlResponse).show(); } return; }); }, getPanelUrl: function(panelType) { //alert("Navigation.getPanelUrl()"); var extension = ".jsp"; var previewUrl = null; var webcurl = $("#content > form[name='eJournalMainForm'] > input[name='webcurl']").attr("value"); var context = 'http://www.spe.org'; var discussionUrl = context + '/' + document.eJournalMainForm.paperDiscussionUrl.value ; var referencesUrl = context + '/' + document.eJournalMainForm.paperReferencesUrl.value; var citingUrl = context + '/ejournals/app/showCitingArticles.do?targetIncUrl='; var addtionalParams = '?pageType='+document.eJournalMainForm.pageType.value+'&jid='+document.eJournalMainForm.jid.value + '&mid='+document.eJournalMainForm.mid.value; if (panelType=='references') { var fullUrl = encodeURIComponent(referencesUrl+addtionalParams); //alert("fullUrl to reference: "+fullUrl); return fullUrl; } else if (panelType=='discussion') { var fullUrl = encodeURIComponent(discussionUrl+addtionalParams); //alert("fullUrl to discussion: "+fullUrl); return fullUrl; } else if (panelType=='download') { alert('not implemented'); } else if (panelType=='citing') { var fullUrl = '?targetIncUrl='+ encodeURIComponent(citingUrl+addtionalParams); return fullUrl; } else if (panelType=='abstract') { alert('not implemented'); } else if (panelType=='Lyris') { alert('not implemented'); } else { alert("The tab doesnt exist: "+panelType); } }, handleOnload: function(journalId) { //alert("Navigation.handleOnload()"); var queryString = window.top.location.search; //alert("queryString: "+queryString); if (queryString.indexOf("pageType=Preview")>=0) { var newReferenceUrl = ''; var newDiscussionUrl = ''; var newCitingUrl = ''; var newDownloadUrl = ''; $.get("/ejournals/Common/Includes/preview_div_tabs_labels.html", { jid: ""}, function(htmlResponse) { //alert("ajax return: " + htmlResponse); $("#details").prepend(htmlResponse); var useragent = navigator.userAgent; //alert("useragent:"+useragent); //setting anchor list for tabs for each browser type. Tried to do it dynamically but using the anchorList variable below but not always reliable (timing issue) var anchorListHardCode = ''; if (useragent.indexOf('MSIE') > -1) { anchorListHardCode = '#abstract;#ui-tabs-10;#ui-tabs-20;#ui-tabs-22;#ui-tabs-24'; //IE } else { anchorListHardCode = '#abstract;#ui-tabs-6;#ui-tabs-16;#ui-tabs-18;#ui-tabs-20'; //Safari/Firefox/Opera .....Konquerer doesn't work } //manipulating tab labels to put proper urls in the hrefs var addtionalParams = '&pageType='+document.eJournalMainForm.pageType.value+'&jid='+document.eJournalMainForm.jid.value + '&mid='+document.eJournalMainForm.mid.value + '&discussionExists='+document.eJournalMainForm.discussionExists.value + '&hasSubscription='+document.eJournalMainForm.hasSubscription.value + '&pdfChronicleId='+document.eJournalMainForm.pdfChronicleId.value; var newParams = '?pageType='+document.eJournalMainForm.pageType.value+'&jid='+document.eJournalMainForm.jid.value + '&chronicleId=' + document.eJournalMainForm.chronicleId.value + '&mid='+document.eJournalMainForm.mid.value + '&hasSubscription='+document.eJournalMainForm.hasSubscription.value + '&pdfChronicleId='+document.eJournalMainForm.pdfChronicleId.value; newReferenceUrl = $("#details > ul > li > a:contains('References')").attr('href') + Navigation.getPanelUrl('references') + addtionalParams + '&tabAnchors=' + encodeURIComponent(anchorListHardCode.split(";")[2]); $("#details > ul > li > a:contains('References')").attr('href',newReferenceUrl); newDiscussionUrl = $("#details > ul > li > a:contains('Discussion')").attr('href') + Navigation.getPanelUrl('discussion') + addtionalParams + '&tabAnchors=' + encodeURIComponent(anchorListHardCode.split(";")[4]);; $("#details > ul > li > a:contains('Discussion')").attr('href',newDiscussionUrl); newCitingUrl = $("#details > ul > li > a:contains('Citing')").attr('href') + newParams + '&tabAnchors=' + encodeURIComponent(anchorListHardCode.split(";")[3]);; $("#details > ul > li > a:contains('Citing')").attr('href',newCitingUrl); newDownloadUrl = $("#details > ul > li > a:contains('Download')").attr('href') + newParams + '&tabAnchors=' + encodeURIComponent(anchorListHardCode.split(";")[1]);; $("#details > ul > li > a:contains('Download')").attr('href',newDownloadUrl); //enabling jquery tabs $('#details > ul').tabs({ remote: true }); //may need to add caching //adding anchors to request params of all the tabs. Note: these values sometimes differ by browser. Tested in in Konquerer/Opera/IE/Safari/Firefox var hrefTabNodes = $("#details > ul > li > a"); var anchorList = ""; //alert("newReferenceUrl"+newReferenceUrl); //alert("newDiscussionUrl"+newDiscussionUrl); //alert("newCitingUrl"+newCitingUrl); //alert("newDownloadUrl"+newDownloadUrl); for(i=0;i < hrefTabNodes.length; i++) { var anchor = hrefTabNodes.eq(i).attr('href'); //alert("anchor: "+anchor); anchorList=anchorList+anchor+";"; } //after login from the preview tabs ie6 misbehaves; adding hack to display correct panel if (navigator.userAgent.indexOf('MSIE') > -1) { //alert("You are using IE"); //alert("queryString: "+queryString); //unselect all tabs var previewTabs = $(".ui-tabs-nav > li"); //determine which tab was selected and enable if (queryString.indexOf("ui-tabs-20")>=0) { //references previewTabs.eq(2).attr('class','ui-tabs-selected'); //hide all tabs for(i=0;i < previewTabs.length; i++) { if (i==2){continue;} previewTabs.eq(i).attr('class',''); $(".ui-tabs-panel").eq(i).hide(); } previewTabs.eq(2).attr('class','ui-tabs-selected'); //alert("retrieving: "+newReferenceUrl); $.get(newReferenceUrl, { jid: ""}, function(htmlResponse) { //alert("response"+htmlResponse); $(".ui-tabs-panel").eq(2).html(htmlResponse); $(".ui-tabs-panel").eq(2).attr('class','ui-tabs-panel') }); } if (queryString.indexOf("ui-tabs-22")>=0) { //citing articles previewTabs.eq(3).attr('class','ui-tabs-selected'); //hide all tabs for(i=0;i < previewTabs.length; i++) { if (i==3){continue;} previewTabs.eq(i).attr('class',''); $(".ui-tabs-panel").eq(i).hide(); } previewTabs.eq(3).attr('class','ui-tabs-selected'); $.get(newCitingUrl, { jid: ""}, function(htmlResponse) { $(".ui-tabs-panel").eq(3).html(htmlResponse); $(".ui-tabs-panel").eq(3).attr('class','ui-tabs-panel') }); } if (queryString.indexOf("ui-tabs-24")>=0) { //discussion previewTabs.eq(4).attr('class','ui-tabs-selected'); //hide all tabs for(i=0;i < previewTabs.length; i++) { if (i==4){continue;} previewTabs.eq(i).attr('class',''); $(".ui-tabs-panel").eq(i).hide(); } previewTabs.eq(4).attr('class','ui-tabs-selected'); //alert("retrieving: "+newDiscussionUrl); $.get(newDiscussionUrl, { jid: ""}, function(htmlResponse) { //alert("response"+htmlResponse); $(".ui-tabs-panel").eq(4).html(htmlResponse); $(".ui-tabs-panel").eq(4).attr('class','ui-tabs-panel') }); } } //set the anchor list in a hidden attribute to be referenced by the tab panels later document.eJournalMainForm.tabAnchors.value = anchorList; //alert("document.eJournalMainForm.tabAnchors.value"+document.eJournalMainForm.tabAnchors.value); }); $.get("/ejournals/Common/Includes/preview_div_tabs_body.html", { jid: ""}, function(htmlResponse){ //alert("ajax return: " + htmlResponse); $("#abstract").after(htmlResponse); if (queryString.indexOf("print=print")>=0) { //alert("making ajax call for: "+newReferenceUrl); var panelIds = ''; if (navigator.userAgent.indexOf('MSIE') > -1) { panelIds = 'abstract;#ui-tabs-9;#reference;#citing;#discussion'; //IE } else { panelIds = '#abstract;#ui-tabs-5;#ui-tabs-15;#ui-tabs-17;#ui-tabs-19'; //Safari/Firefox/Opera ..... } //alert("making ajax call for: "+newDownloadUrl); $.get(newDownloadUrl, { jid: ""}, function(htmlResponse) { //alert("ajax return(newDownloadUrl): " + htmlResponse); if (navigator.userAgent.indexOf('MSIE') > -1) { $(".ui-tabs-panel").eq(1).html(htmlResponse); } else { ($(panelIds.split(";")[1])).html(htmlResponse); } }); $.get(newReferenceUrl, { jid: ""}, function(htmlResponse) { //alert("ajax return(newReferenceUrl): " + htmlResponse); if (navigator.userAgent.indexOf('MSIE') > -1) { $(".ui-tabs-panel").eq(2).html(htmlResponse); } else { ($(panelIds.split(";")[2])).html(htmlResponse); } }); //alert("making ajax call for: "+newCitingUrl); $.get(newCitingUrl, { jid: ""}, function(htmlResponse) { //alert("ajax return(newCitingUrl): " + htmlResponse); if (navigator.userAgent.indexOf('MSIE') > -1) { $(".ui-tabs-panel").eq(3).html(htmlResponse); } else { ($(panelIds.split(";")[3])).html(htmlResponse); } }); //alert("making ajax call for: "+newDiscussionUrl); $.get(newDiscussionUrl, { jid: ""}, function(htmlResponse) { //alert("ajax return(newDiscussionUrl): " + htmlResponse); if (navigator.userAgent.indexOf('MSIE') > -1) { $(".ui-tabs-panel").eq(4).html(htmlResponse); } else { ($(panelIds.split(";")[4])).html(htmlResponse); } }); } //end if preview & print //Also replace PDF with Add To Cart if checkbox exists and not logged in. if (document.eJournalMainForm.hasSubscription.value=='false') { $(".pdf > a").text("Add To Cart"); //set url & onclick of AddToCart Pages //commenting out order limit check as it doesn't work in ie //var currentAddToCartHref = $(".pdf > a").eq(0).attr("href"); //var newOnclickValue = "Issue.download('','','"+currentAddToCartHref+"');"; //$(".pdf > a").attr("onClick",newOnclickValue); //$(".pdf > a").eq(i).attr("href",""); } }); //set the title document.title = document.title + document.eJournalMainForm.browserTitle.value + document.eJournalMainForm.paperTitle.value; } else if (queryString.indexOf("pageType=Issue")>=0 || queryString.indexOf("pageType=Online")>=0) { // alert("here"); //set the title if (document.eJournalMainForm != null && document.eJournalMainForm.browserTitle != null && document.eJournalMainForm.browserTitle.value != null) document.title = document.eJournalMainForm.browserTitle.value; else document.title = "Journal"; //alert ("title: "+document.title); //set all checkbox names to the one the application expects if not done through publishing var checkboxNodes = $("#main_content > .item > .select input"); if($(checkboxNodes)){ for (i=0; i < checkboxNodes.length; i++) { checkboxNodes.eq(i).attr('name','selectCheckBox');//name . checkboxNodes.eq(i).attr('id','selectCheckBox');//id . //get pdf chronicle Id var pdfChronicleId = $("#main_content > .item > .select input").eq(i).attr("value").split(";")[0]; //add PDF chronicle Id to URL of Preview //first get current url var currentUrl = $("#main_content > .item > .item_title > a").eq(i).attr("href"); var newPreviewUrl = currentUrl+"&pdfChronicleId=" + pdfChronicleId; //set url for each of the 2 preview links per row $("#main_content > .item > .item_title > a").eq(i).attr("href",newPreviewUrl);//title $("#main_content > .item > p .preview> a").eq(i).attr("href",newPreviewUrl);//Preview link //commenting out order limit check as it doesn't work in ie //set url & onclick of AddToCart Pages //var currentAddToCartHref = $(".pdf > a").eq(i).attr("href"); //var newOnclickValue = "Issue.download('','','"+currentAddToCartHref+"');"; //$(".pdf > a").eq(i).attr("onClick",newOnclickValue); //$(".pdf > a").eq(i).attr("href",""); } //Also replace PDF with Add To Cart if hasSubscription hidden attribute is there. // alert("has subs:"+document.eJournalMainForm.hasSubscription.value); if (document.eJournalMainForm != null && document.eJournalMainForm.hasSubscription != null && document.eJournalMainForm.hasSubscription.value != null && document.eJournalMainForm.hasSubscription.value=='false') { $(".pdf > a").text("Add To Cart"); } } //alert("end of if"); } else if (queryString.indexOf("pageType=ViewCart")>=0) { //alert("ViewCart"+journalId); if (getCookieValue('emeta_id')) { //alert("Replacing logout link"); var onClick = $("#login > li > a").eq(0).attr("onClick"); $("#login > li > a").eq(0).attr("onClick","Navigation.logout('www.spe.org','ViewCart','"+journalId+"','','','http://www.spe.org/ejournals/app/ViewCart.do?pageType=ViewCart&jid="+journalId+"');"); } if (!getCookieValue('emeta_id')) { //alert("Replacing login link"); var onClick = $("#login > li > a").eq(0).attr("onClick"); $("#login > li > a").eq(0).attr("onClick","Navigation.login('www.spe.org','ViewCart','"+journalId+"','','','http://www.spe.org/ejournals/app/ViewCart.do?pageType=ViewCart&jid="+journalId+"');"); } } else if (queryString.indexOf("pageType=Archives")>=0) { //set the title document.title = document.eJournalMainForm.browserTitle.value; } else if (queryString.indexOf("pageType=TopDownloads")>=0) { //set the title document.title = document.TopDownloadsForm.browserTitle.value; } else if (queryString.indexOf("pageType=TopicalMeetings")>=0) { //set the title document.title = document.TopicalMeetingsForm.browserTitle.value; } else if (!queryString.indexOf("pageType")>=0) { //alert("No page type found. Changing logout links to go to current issue"); if (queryString.indexOf("webcurl")>=0) { //Articles document.title = document.eJournalMainForm.browserTitle.value; } if (getCookieValue('emeta_id')) { var onClick = $("#login > li > a").eq(0).attr("onClick"); $("#login > li > a").eq(0).attr("onClick","Navigation.logout('www.spe.org','Issue','"+journalId+"','','','http://www.spe.org/ejournals/jsp/journalapp.jsp?pageType=Issue&jid="+journalId+"');"); } //TODO: May need to set login case. } }, handleError: function(errorMessage) { alert("Navigation. handleError: function(errorMessage) : "); //show errors: var errors = $(".error"); if(errors){ errors.show(); } }, handleClick: function(type, insertionDiv) { //alert("Navigation.handleTabClick(panelType): "+panelType); var panelUrl = Navigation.getPanelUrl(type); //alert("panelUrl: "+panelUrl); $.get(panelUrl, { key: "value"}, function(htmlResponse){ //alert("ajax return: " + htmlResponse); }); } };