/*----------------------------------------------------------------------------- - File Name: - PayPalShared.js - - Description: - Shared functions for PayPal objects. - - This file contains proprietary and confidential information from WebAssist.com - corporation. Any unauthorized reuse, reproduction, or modification without - the prior written consent of WebAssist.com is strictly prohibited. - - Copyright 2003 WebAssist.com Corporation. All rights reserved. ------------------------------------------------------------------------------*/ var BNVersion = "macromedia.contribute.3_0_0"; // MACR Solution ID var MRB = "R-2K410090UE355584L"; // MACR Program ID var PAL = "A3X7N2U4UM6U8"; // MACR affiliate ID var MRBLINK = "https://www.paypal.com/mrb/mrb="+MRB+"&pal="+PAL; var DWConfigPath = dw.getConfigurationPath(); var PayPalConfigFilePath = WA_getConfigurationPath("/shared/PayPal/PayPalConfig.xml"); var PayPalSIPTempPath = WA_getConfigurationPath("/shared/PayPal/PayPalSIPTemp.txt"); var DocPath = dw.getDocumentPath("document"); var FolderURL = DocPath.substring(0,DocPath.lastIndexOf("/")+1); var FolderPath = MMNotes.localURLToFilePath(FolderURL); var CUSTOM_VC_IMG = "PayPal VC PI.gif"; var CUSTOM_AC_IMG = "PayPal AC PI.gif"; var CUSTOM_SIP_IMG = "PayPal SIP PI.gif"; var CUSTOM_SUB_IMG = "PayPal SUB PI.gif"; var WIZARD_INTERFACE = "Wizard"; var ADVANCED_INTERFACE = "Advanced"; // MAC's only allow filenames up to 32 characters long var MAX_FILE_LENGTH = 32; /**************************** errormessages ****************************/ //--------------- LOCALIZEABLE GLOBALS--------------- var MSG_NoUID = "Debe introducir su cuenta PayPal (p.ej., usuario@miempresa.com)."; var MSG_NoItemName = "Debe introducir un nombre para este artículo (p. ej., 'Mi Widget')"; var MSG_NoItemPrice = "Debe introducir un precio para este artículo (p. ej., 19,99)."; var MSG_NoSubPrice = "Debe introducir una cantidad que se cargará a los clientes por esta suscripción (p. ej., 19,99)."; var MSG_NoSubPriceValidAmount = "Debe introducir una cantidad válida que se cargará a los clientes por esta suscripción (p. ej., 19,99 ó 100)."; var MSG_NoSubTrial1ValidAmount = "Debe introducir una cantidad válida que se facturará por el período de prueba (p. ej., 19,99 ó 100)."; var MSG_InvalidAmount = "Debe introducir una cantidad válida para el precio de este artículo (p. ej., 19,99 ó 100)."; var MSG_AlreadyPayPalInForm = "Este formulario ya contiene funcionalidad de PayPal.\rAsegúrese de que el cursor está fuera del formulario actual o cree un nuevo formulario."; var MSG_AlreadyInForm = "Su selección se encuentra en un formulario existente.\n¿Desea insertar este botón de PayPal después del formulario actual?"; //--------------- END LOCALIZEABLE --------------- /***************************** open broswer windows ********************/ function displayHelp() { displayPPGeneralHelp(""); } //context sensitive help function function displayContextHelp(inputAnchor) { var fileStr = dw.getConfigurationPath(); var tempPath = WA_getConfigurationPath("/Shared/PayPal/ContextTemp.htm"); var browsePath = tempPath; var helpPath = WA_getConfigurationPath("/Shared/PayPal/PayPalHelp.htm"); if (!DWfile.exists(tempPath)) { tempPath = dw.getTempFolderPath(); // force to use local user paths var folderPath = tempPath.substring(0, tempPath.lastIndexOf("/")); tempPath = tempPath.substring(0, tempPath.lastIndexOf("/")) + "/Shared/PayPal/ContextTemp.htm"; browsePath = tempPath; DWfile.createFolder(folderPath+"/Shared"); DWfile.createFolder(folderPath+"/Shared/PayPal"); } scriptTag = "\n\r"; var cfgPath = dw.getConfigurationPath(); var fPath = dw.getTempFolderPath(); fPath = fPath.substring(0, fPath.lastIndexOf("/")); if (DWfile.exists(fPath + "/Shared/PayPal/PayPalHelp.htm")) { cfgPath = fPath; } if (navigator.platform.toLowerCase().indexOf("mac") >= 0) { cfgPath = cfgPath.replace(/file\:\/\/\//i, ""); browsePath = browsePath.replace(/file\:\/\/\//i, ""); if (cfgPath.substring(0, cfgPath.indexOf("/")) == browsePath.substring(0, browsePath.indexOf("/"))) { cfgPath = "file://localhost" + cfgPath.substring(cfgPath.indexOf("/")); } else { cfgPath = "file://localhost/Volumes/" + cfgPath; } scriptTag += "var helpLoc = \"" + escape(cfgPath) + "/Shared/PayPal/PayPalHelp.htm\";\n\r"; browsePath = "file://localhost" + browsePath.substring(browsePath.indexOf("/")); } else { scriptTag += "var helpLoc = \"" + cfgPath + "/Shared/PayPal/PayPalHelp.htm\";\n\r"; } if (inputAnchor && inputAnchor != "") { scriptTag += "helpLoc += \"#" + inputAnchor + "\";\n\r"; } scriptTag += "document.location.href = helpLoc;\n\r"; scriptTag += ""; DWfile.write(tempPath, scriptTag); dreamweaver.browseDocument(browsePath); } function WA_getConfigurationPath(pathFromConfig) { var cPath = dw.getConfigurationPath(); var tPath = dw.getTempFolderPath(); tPath = tPath.substring(0, tPath.lastIndexOf("/")); tPath += pathFromConfig; if (DWfile.exists(tPath)) { return tPath; } return cPath + pathFromConfig; } function displayPPGeneralHelp(inputAnchor) { var fileStr = dw.getConfigurationPath(); var tempPath = WA_getConfigurationPath("/Shared/PayPal/ContextTemp.htm"); var browsePath = tempPath; var helpPath = WA_getConfigurationPath("/Shared/PayPal/ExtensionHelp.htm"); if (!DWfile.exists(tempPath)) { tempPath = dw.getTempFolderPath(); // force to use local user paths var folderPath = tempPath.substring(0, tempPath.lastIndexOf("/")); tempPath = tempPath.substring(0, tempPath.lastIndexOf("/")) + "/Shared/PayPal/ContextTemp.htm"; browsePath = tempPath; DWfile.createFolder(folderPath+"/Shared"); DWfile.createFolder(folderPath+"/Shared/PayPal"); } scriptTag = "\n\r"; var cfgPath = dw.getConfigurationPath(); var fPath = dw.getTempFolderPath(); fPath = fPath.substring(0, fPath.lastIndexOf("/")); if (DWfile.exists(fPath + "/Shared/PayPal/ExtensionHelp.htm")) { cfgPath = fPath; } if (navigator.platform.toLowerCase().indexOf("mac") >= 0) { cfgPath = cfgPath.replace(/file\:\/\/\//i, ""); browsePath = browsePath.replace(/file\:\/\/\//i, ""); if (cfgPath.substring(0, cfgPath.indexOf("/")) == browsePath.substring(0, browsePath.indexOf("/"))) { cfgPath = "file://localhost" + cfgPath.substring(cfgPath.indexOf("/")); } else { cfgPath = "file://localhost/Volumes/" + cfgPath; } scriptTag += "var helpLoc = \"" + escape(cfgPath) + "/Shared/PayPal/ExtensionHelp.htm\";\n\r"; browsePath = "file://localhost" + browsePath.substring(browsePath.indexOf("/")); } else { scriptTag += "var helpLoc = \"" + cfgPath + "/Shared/PayPal/ExtensionHelp.htm\";\n\r"; } if (inputAnchor && inputAnchor != "") { scriptTag += "helpLoc += \"#" + inputAnchor + "\";\n\r"; } scriptTag += "document.location.href = helpLoc;\n\r"; scriptTag += ""; helpPath = tempPath; DWfile.write(tempPath, scriptTag); dreamweaver.browseDocument(browsePath); } function openPPBrowser() { dreamweaver.browseDocument("http://www.paypal.com"); } function openWABrowser() { dreamweaver.browseDocument("http://www.webassist.com"); } function openURLInBrowser(myURL) { dreamweaver.browseDocument(myURL); } function getCurrencyType(inCurrencyCode) { var retCurrencyType = ""; switch (inCurrencyCode) { case "USD": retCurrencyType = MSG_USDollar; break; case "GBP": retCurrencyType = MSG_Pounds; break; case "EUR": retCurrencyType = MSG_Euro; break; case "CAD": retCurrencyType = MSG_CanadianDollar; break; case "AUD": retCurrencyType = MSG_AusDollar; break; case "JPY": retCurrencyType = MSG_Yen; break; } return retCurrencyType; } function getVCUID(theTag) { var idTag = "business="; var idEndTag = "'"; var ppID = ""; var newTag = theTag.toLowerCase(); var ppIDStart = newTag.indexOf(idTag); if (ppIDStart >= 0) { ppIDStart += idTag.length; // take out the 'business=' part out of the UserID string var ppIDLength = newTag.substring(ppIDStart).indexOf(idEndTag); // go to the first single quote var ppIDEnd = ppIDStart + ppIDLength; ppID = theTag.substring(ppIDStart, ppIDEnd); } return ppID; } function getUID(theTag) { var idTag = "business="; var idEndTag = "&"; var ppID = ""; var newTag = theTag.toLowerCase(); var ppIDStart = newTag.indexOf(idTag); if (ppIDStart >= 0) { ppIDStart += idTag.length; // take out the 'business=' part out of the UserID string var ppIDLength = newTag.substring(ppIDStart).indexOf(idEndTag); // go to the first single quote var ppIDEnd = ppIDStart + ppIDLength; ppID = theTag.substring(ppIDStart, ppIDEnd); } return ppID; } function getTranslatedImageURL(theTag) { var theURL = ""; var imageTag = 'img src="'; var imageEndTag = '"'; var theImage = ""; var newTag = theTag.toLowerCase(); var imageStart = newTag.indexOf(imageTag); imageStart += imageTag.length; // take out the 'business=' part out of the UserID string var imageLength = newTag.substring(imageStart).indexOf(imageEndTag); // go to the first single quote var imageEnd = imageStart + imageLength; theURL = theTag.substring(imageStart, imageEnd); theURL = WAURLDecode(theURL); return theURL; } function getTranslatedImage(theTag, theCustomImage) { var theURL = getTranslatedImageURL(theTag).toLowerCase(); var theImage = ""; if (theURL.indexOf("http://images.paypal.com") >= 0) { // stock PayPal image theImage = theURL.substring(theURL.lastIndexOf("/")+1); } else //custom image { theImage = theCustomImage; } return theImage; } function getTranslatedACImage(theURL) { var theImage = ""; var newURL = theURL.toLowerCase(); if (newURL.indexOf("://images.paypal.com") >= 0 || newURL.indexOf("://www.paypal.com/") >= 0) { // stock PayPal image theImage = theURL.substring(theURL.lastIndexOf("/")+1); } else //custom image { theImage = CUSTOM_AC_IMG; } return theImage; } function getTranslatedVCImage(theURL) { var theImage = ""; var newURL = theURL.toLowerCase(); if (newURL.indexOf("http://images.paypal.com") >= 0 || newURL.indexOf("https://images.paypal.com") >= 0) { // stock PayPal image theImage = theURL.substring(theURL.lastIndexOf("/")+1); } else //custom image { theImage = CUSTOM_VC_IMG; } return theImage; } function getTranslatedSIPImage(theURL) { var theImage = ""; var newURL = theURL.toLowerCase(); if (newURL.indexOf("http://images.paypal.com") >= 0 || newURL.indexOf("https://images.paypal.com") >= 0) { // stock PayPal image theImage = theURL.substring(theURL.lastIndexOf("/")+1); } else //custom image { theImage = CUSTOM_SIP_IMG; } return theImage; } function getTranslatedSUBImage(theURL) { var theImage = ""; var newURL = theURL.toLowerCase(); if (newURL.indexOf("http://images.paypal.com") >= 0 || newURL.indexOf("https://images.paypal.com") >= 0) { // stock PayPal image theImage = theURL.substring(theURL.lastIndexOf("/")+1); } else //custom image { theImage = CUSTOM_SUB_IMG; } return theImage; } function getLogoURL(theTag) { var theStartTag = "image_url="; var theEndTag = "&"; var theURL = ""; var newTag = theTag.toLowerCase(); var theStartIndex = newTag.indexOf(theStartTag); if (theStartIndex >= 0) { theStartIndex += theStartTag.length; // take out the 'image_url=' part out of the UserID string var theLength = newTag.substring(theStartIndex).indexOf(theEndTag); // go to the first ampersand var theEndIndex = theStartIndex + theLength; theURL = theTag.substring(theStartIndex, theEndIndex); } return theURL; } function getSuccessURL(theTag) { var theStartTag = "return="; var theEndTag = "&"; var theURL = ""; var newTag = theTag.toLowerCase(); var theStartIndex = newTag.indexOf(theStartTag); if (theStartIndex >= 0) { theStartIndex += theStartTag.length; // take out the 'image_url=' part out of the UserID string var theLength = newTag.substring(theStartIndex).indexOf(theEndTag); // go to the first ampersand var theEndIndex = theStartIndex + theLength; theURL = theTag.substring(theStartIndex, theEndIndex); } return theURL; } function getCancelURL(theTag) { var theStartTag = "cancel_return="; var theEndTag = "&"; var theURL = ""; var newTag = theTag.toLowerCase(); var theStartIndex = newTag.indexOf(theStartTag); if (theStartIndex >= 0) { theStartIndex += theStartTag.length; // take out the 'image_url=' part out of the UserID string var theLength = newTag.substring(theStartIndex).indexOf(theEndTag); // go to the first ampersand var theEndIndex = theStartIndex + theLength; theURL = theTag.substring(theStartIndex, theEndIndex); } return theURL; } function getItemName(theTag) { var theStartTag = "item_name="; var theEndTag = "&"; var retVal = ""; var newTag = theTag.toLowerCase(); var theStartIndex = newTag.indexOf(theStartTag); if (theStartIndex >= 0) { theStartIndex += theStartTag.length; // take out the 'image_url=' part out of the UserID string var theLength = newTag.substring(theStartIndex).indexOf(theEndTag); // go to the first ampersand var theEndIndex = theStartIndex + theLength; retVal = theTag.substring(theStartIndex, theEndIndex); } return retVal; } function getItemNumber(theTag) { var theStartTag = "item_number="; var theEndTag = "&"; var retVal = ""; var newTag = theTag.toLowerCase(); var theStartIndex = newTag.indexOf(theStartTag); if (theStartIndex >= 0) { theStartIndex += theStartTag.length; // take out the 'image_url=' part out of the UserID string var theLength = newTag.substring(theStartIndex).indexOf(theEndTag); // go to the first ampersand var theEndIndex = theStartIndex + theLength; retVal = theTag.substring(theStartIndex, theEndIndex); } return retVal; } function getAmount(theTag) { var theStartTag = "amount="; var theEndTag = "&"; var retVal = ""; var newTag = theTag.toLowerCase(); var theStartIndex = newTag.indexOf(theStartTag); if (theStartIndex >= 0) { theStartIndex += theStartTag.length; // take out the 'image_url=' part out of the UserID string var theLength = newTag.substring(theStartIndex).indexOf(theEndTag); // go to the first ampersand var theEndIndex = theStartIndex + theLength; retVal = theTag.substring(theStartIndex, theEndIndex); } return retVal; } function getQuantityYes(theTag) { var theStartTag = "undefined_quantity="; var theEndTag = "&"; var retVal = ""; var newTag = theTag.toLowerCase(); var theStartIndex = newTag.indexOf(theStartTag); if (theStartIndex >= 0) { theStartIndex += theStartTag.length; // take out the 'image_url=' part out of the UserID string var theLength = newTag.substring(theStartIndex).indexOf(theEndTag); // go to the first ampersand var theEndIndex = theStartIndex + theLength; retVal = theTag.substring(theStartIndex, theEndIndex); } return retVal; } function getShippingNo(theTag) { var theStartTag = "no_shipping="; var theEndTag = "&"; var retVal = ""; var newTag = theTag.toLowerCase(); var theStartIndex = newTag.indexOf(theStartTag); if (theStartIndex >= 0) { theStartIndex += theStartTag.length; // take out the 'image_url=' part out of the UserID string var theLength = newTag.substring(theStartIndex).indexOf(theEndTag); // go to the first ampersand var theEndIndex = theStartIndex + theLength; retVal = theTag.substring(theStartIndex, theEndIndex); } return retVal; } function getIncludeNote(theTag) { var theStartTag = "no_note="; var theEndTag = "'"; // last tag so no more ampersands var retVal = ""; var newTag = theTag.toLowerCase(); var theStartIndex = newTag.indexOf(theStartTag); if (theStartIndex >= 0) { theStartIndex += theStartTag.length; // take out the 'image_url=' part out of the UserID string var theLength = newTag.substring(theStartIndex).indexOf(theEndTag); // go to the first ampersand var theEndIndex = theStartIndex + theLength; retVal = theTag.substring(theStartIndex, theEndIndex); } return retVal; } function enableDisableOtherImage(objType) { var imgObj = "acimage"; var otherImgObj = "otheracimage"; if (objType == "VC") { imgObj = "vcimage"; otherImgObj = "othervcimage"; } else if (objType == "SIP") { imgObj = "sipimage"; otherImgObj = "othersipimage"; } var myImage = findObject(imgObj); for (var n=0; n"; //vcTag += ""; if (!inForm) { vcTag += "
\n\r"; } vcTag += " \n\r"; vcTag += " \n\r"; vcTag += " \n\r"; vcTag += " \n\r"; if (myID) { vcTag += " \n\r"; vcTag += " \n\r"; vcTag += " \n\r"; } vcTag += " \n\r"; if (!inForm) vcTag += "
\n\r"; theDOM.synchronizeDocument(); theDOM.insertHTML(vcTag, false); setLastUID(); theParent = theDOM.getSelectedNode(); while (theParent.parentNode && inForm) { if (theParent.tagName=="FORM") { if (theParent.getAttribute("action")!="https://www.paypal.com/cgi-bin/webscr") theParent.setAttribute("action","https://www.paypal.com/cgi-bin/webscr"); if (theParent.getAttribute("target")!="paypal") theParent.setAttribute("target","paypal"); if (theParent.getAttribute("method")!="post") theParent.setAttribute("method","post"); break; } theParent = theParent.parentNode; } MM.clearBusyCursor(); closeWindow(); return ""; } function generateSIPTag() { MM.setBusyCursor(); var theDOM = dw.getDocumentDOM(); var sipTag = ""; var myID = document.UserIDWP.document.ppUID.value; var myImage = document.ButtonImageWP.document.sipimage; var myImageURL = ""; var myItemName = document.itemWP.document.itemName.value; var myItemID = document.itemWP.document.itemID.value; var myAmount = document.itemWP.document.itemPrice.value; var myCurrency = document.itemWP.document.itemCurrency.options[document.itemWP.document.itemCurrency.selectedIndex].value; var myQuantityYes = document.itemWP.document.quantityYes.checked; var myShipping = document.shippingWP.document.itemShipping.value; var myShipping2 = document.shippingWP.document.itemShipping2.value; var myHandling = document.shippingWP.document.itemHandling.value; var myShippingNo = document.shippingWP.document.shippingNo[1].checked; var myIncludeNote = true; if (document.shippingWP.document.includeNote[1].checked) { myIncludeNote = false; } var myLogoURL = document.logoWP.document.ppLogo.value; var mySuccessURL = document.customWP.document.successURL.value; var myCancelURL = document.customWP.document.cancelURL.value; var inForm = false; var theParent = theDOM.getSelectedNode(); while (theParent.parentNode) { theParent = theParent.parentNode; if (theParent.tagName=="FORM") { if (confirm(MSG_AlreadyInForm)) { theDOM.setSelection(theDOM.nodeToOffsets(theParent)[1]-1,theDOM.nodeToOffsets(theParent)[1]-1); } else { closeWindow(); return ""; } break; } } for (var n=0; n\n\r"; } sipTag += " \n\r"; sipTag += " \n\r"; sipTag += " \n\r"; if (myItemName != "") { sipTag += " \n\r"; } if (myItemID != "") { sipTag += " \n\r"; } if (myAmount != "") { sipTag += " \n\r"; } sipTag += " \n\r"; if (myShipping != "") { sipTag += " \n\r"; } if (myShipping2 != "") { sipTag += " \n\r"; } if (myHandling != "") { sipTag += " \n\r"; } if (isValidURL(myLogoURL)) { sipTag += " \n\r"; } if (isValidURL(mySuccessURL)) { sipTag += " \n\r"; } if (isValidURL(myCancelURL)) { sipTag += " \n\r"; } sipTag += " \n\r"; if (myID) { sipTag += " \n\r"; sipTag += " \n\r"; sipTag += " \n\r"; } // Always insert these three parameters as the last params sipTag += " \n\r"; sipTag += " \n\r"; sipTag += " \n\r"; if (!inForm) sipTag += "\n\r"; theDOM.synchronizeDocument(); theDOM.insertHTML(sipTag, false); setLastUID(); theParent = theDOM.getSelectedNode(); while (theParent.parentNode && inForm) { if (theParent.tagName=="FORM") { if (theParent.getAttribute("action")!="https://www.paypal.com/cgi-bin/webscr") theParent.setAttribute("action","https://www.paypal.com/cgi-bin/webscr"); if (theParent.getAttribute("target")!="paypal") theParent.setAttribute("target","paypal"); if (theParent.getAttribute("method")!="post") theParent.setAttribute("method","post"); break; } theParent = theParent.parentNode; } MM.clearBusyCursor(); closeWindow(); return ""; } function generateACTag() { MM.setBusyCursor(); var theDOM = dw.getDocumentDOM(); var acTag = ""; var myID = document.UserIDWP.document.ppUID.value; var myImage = document.ButtonImageWP.document.acimage; var myImageURL = ""; var myItemName = document.itemWP.document.itemName.value; var myItemID = document.itemWP.document.itemID.value; var myAmount = document.itemWP.document.itemPrice.value; var myCurrency = document.itemWP.document.itemCurrency.options[document.itemWP.document.itemCurrency.selectedIndex].value; var myShippingNo = document.itemWP.document.shippingNo[1].checked; var myIncludeNote = true; var inForm = false; var theParent = theDOM.getSelectedNode(); while (theParent.parentNode) { theParent = theParent.parentNode; if (theParent.tagName=="FORM") { if (confirm(MSG_AlreadyInForm)) { theDOM.setSelection(theDOM.nodeToOffsets(theParent)[1]-1,theDOM.nodeToOffsets(theParent)[1]-1); } else { closeWindow(); return ""; } break; } } if (document.itemWP.document.includeNote[1].checked) { myIncludeNote = false; } var myLogoURL = document.logoWP.document.ppLogo.value; var mySuccessURL = document.customWP.document.successURL.value; var myCancelURL = document.customWP.document.cancelURL.value; for (var n=0; n\n\r"; } acTag += " \n\r"; acTag += " \n\r"; acTag += " \n\r"; acTag += " \n\r"; // acTag += "\n\r"; } if (myItemID != "") { acTag += " \n\r"; } if (myAmount != "") { acTag += " \n\r"; } acTag += " \n\r"; if (isValidURL(myLogoURL)) { acTag += " \n\r"; } if (isValidURL(mySuccessURL)) { acTag += " \n\r"; } if (isValidURL(myCancelURL)) { acTag += " \n\r"; } if (myID) { acTag += " \n\r"; acTag += " \n\r"; acTag += " \n\r"; } acTag += " \n\r"; acTag += " \n\r"; acTag += " \n\r"; if (!inForm) acTag += "\n\r"; theDOM.synchronizeDocument(); theDOM.insertHTML(acTag, false); setLastUID(); theParent = theDOM.getSelectedNode(); while (theParent.parentNode && inForm) { if (theParent.tagName=="FORM") { if (theParent.getAttribute("action")!="https://www.paypal.com/cgi-bin/webscr") theParent.setAttribute("action","https://www.paypal.com/cgi-bin/webscr"); if (theParent.getAttribute("target")!="paypal") theParent.setAttribute("target","paypal"); if (theParent.getAttribute("method")!="post") theParent.setAttribute("method","post"); break; } theParent = theParent.parentNode; } MM.clearBusyCursor(); closeWindow(); return ""; } function generateSUBTag() { MM.setBusyCursor(); var theDOM = dw.getDocumentDOM(); var subTag = ""; var myID = document.UserIDWP.document.ppUID.value; var myImage = document.ButtonImageWP.document.subimage; var myImageURL = ""; var myItemName = document.itemWP.document.subscriptionName.value; var myItemID = document.itemWP.document.subscriptionID.value; var myAmount = document.itemWP.document.subscriptionPrice.value; var myCurrency = document.itemWP.document.itemCurrency.options[document.itemWP.document.itemCurrency.selectedIndex].value; var myTrial1 = document.itemWP.document.trial1Amount.value; var myLogoURL = document.logoWP.document.ppLogo.value; var mySuccessURL = document.customWP.document.successURL.value; var myCancelURL = document.customWP.document.cancelURL.value; var inForm = false; var theParent = theDOM.getSelectedNode(); while (theParent.parentNode) { theParent = theParent.parentNode; if (theParent.tagName=="FORM") { if (confirm(MSG_AlreadyInForm)) { theDOM.setSelection(theDOM.nodeToOffsets(theParent)[1]-1,theDOM.nodeToOffsets(theParent)[1]-1); } else { closeWindow(); return ""; } break; } } for (var n=0; n\n\r"; subTag += " \n\r"; subTag += " \n\r"; subTag += " \n\r"; if (myItemName != "") { subTag += " \n\r"; } if (myItemID != "") { subTag += " \n\r"; } subTag += " \n\r"; if (isValidAmount(myTrial1)) { subTag += " \n\r"; subTag += " \n\r"; subTag += " \n\r"; } subTag += " \n\r"; subTag += " \n\r"; subTag += " \n\r"; if (isValidURL(myLogoURL)) { subTag += " \n\r"; } if (isValidURL(mySuccessURL)) { subTag += " \n\r"; } if (isValidURL(myCancelURL)) { subTag += " \n\r"; } subTag += " \n\r"; if (document.itemWP.document.recurringBilling[1].checked) { subTag += " \n\r"; } subTag += " \n\r"; if (myID) { subTag += " \n\r"; subTag += " \n\r"; subTag += " \n\r"; } subTag += " \n\r"; // no_note is required by the SUB API subTag += " \n\r"; subTag += " \n\r"; if (!inForm) subTag += "\n\r"; theDOM.synchronizeDocument(); theDOM.insertHTML(subTag, false); setLastUID(); theParent = theDOM.getSelectedNode(); while (theParent.parentNode && inForm) { if (theParent.tagName=="FORM") { if (theParent.getAttribute("action")!="https://www.paypal.com/cgi-bin/webscr") theParent.setAttribute("action","https://www.paypal.com/cgi-bin/webscr"); if (theParent.getAttribute("target")!="paypal") theParent.setAttribute("target","paypal"); if (theParent.getAttribute("method")!="post") theParent.setAttribute("method","post"); break; } theParent = theParent.parentNode; } MM.clearBusyCursor(); closeWindow(); return ""; } function generateDTag() { MM.setBusyCursor(); var theDOM = dw.getDocumentDOM(); var sipTag = ""; var myID = document.UserIDWP.document.ppUID.value; var myImage = document.ButtonImageWP.document.sipimage; var myImageURL = ""; var myItemName = document.itemWP.document.itemName.value; var myItemID = document.itemWP.document.itemID.value; var myCurrency = document.itemWP.document.itemCurrency.options[document.itemWP.document.itemCurrency.selectedIndex].value; var myShippingNo = document.itemWP.document.shippingNo[1].checked; var myIncludeNote = true; if (document.itemWP.document.includeNote[1].checked) { myIncludeNote = false; } var myLogoURL = document.logoWP.document.ppLogo.value; var mySuccessURL = document.customWP.document.successURL.value; var myCancelURL = document.customWP.document.cancelURL.value; var inForm = false; var theParent = theDOM.getSelectedNode(); while (theParent.parentNode) { theParent = theParent.parentNode; if (theParent.tagName=="FORM") { inForm = true; break; } } for (var n=0; n\n\r"; } sipTag += " \n\r"; sipTag += " \n\r"; sipTag += " \n\r"; if (myItemName != "") { sipTag += " \n\r"; } if (myItemID != "") { sipTag += " \n\r"; } sipTag += " \n\r"; if (isValidURL(myLogoURL)) { sipTag += " \n\r"; } if (isValidURL(mySuccessURL)) { sipTag += " \n\r"; } if (isValidURL(myCancelURL)) { sipTag += " \n\r"; } if (myID) { sipTag += " \n\r"; sipTag += " \n\r"; sipTag += " \n\r"; } // Always insert these three parameters as the last params sipTag += " \n\r"; sipTag += " \n\r"; sipTag += " \n\r"; if (!inForm) sipTag += "\n\r"; theDOM.synchronizeDocument(); theDOM.insertHTML(sipTag); setLastUID(); theParent = theDOM.getSelectedNode(); while (theParent.parentNode && inForm) { if (theParent.tagName=="FORM") { if (theParent.getAttribute("action")!="https://www.paypal.com/cgi-bin/webscr") theParent.setAttribute("action","https://www.paypal.com/cgi-bin/webscr"); if (theParent.getAttribute("target")!="paypal") theParent.setAttribute("target","paypal"); if (theParent.getAttribute("method")!="post") theParent.setAttribute("method","post"); break; } theParent = theParent.parentNode; } MM.clearBusyCursor(); closeWindow(); return ""; } function validatePPUID() { var errMsg = ""; var ppID = findObject("ppUID").value; if ((ppID == "") || (ppID.indexOf("@") < 0)) { errMsg += "- "+ MSG_NoUID + "\n"; } return errMsg; } function validateSubsDetails() { var retVal = ""; var myPrice = document.itemWP.document.subscriptionPrice.value; var myTrial1 = document.itemWP.document.trial1Amount.value; if (myPrice == "") { retVal += MSG_SubscriptionPrice + MSG_NoSubPrice + "\n"; } else if (!isValidAmount(myPrice) || parseInt(myPrice) <= 0) { retVal += MSG_SubscriptionPrice + MSG_NoSubPriceValidAmount + "\n"; } if (myTrial1 != "") { if (!isValidAmount(myTrial1)) { retVal += MSG_TrialPrice+ MSG_NoSubTrial1ValidAmount + "\n"; } } return retVal; } function validateItemName() { var errMsg = ""; var myItemName = document.itemWP.document.itemName.value; if (myItemName == "") { errMsg += "- "+ MSG_NoItemName + "\n"; } return errMsg; } function validateItemPrice() { var errMsg = ""; var myItemPrice = document.itemWP.document.itemPrice.value; if ((myItemPrice == "") || !isValidAmount(myItemPrice)) { errMsg += "- " + MSG_InvalidAmount + "\n"; } return errMsg; } function validateAmount(theAmount) { var errMsg = ""; if (!isValidAmount(theAmount)) { errMsg = "- " + MSG_InvalidAmount + "\n"; } return errMsg; } function isValidEmail(theEmail) { var retVal = true; if ((theEmail == "") || (theEmail.indexOf("@") < 0)) { retVal = false; } return retVal; } function isValidAmount(thePrice) { var retVal = true; if ( (thePrice == "") || isNaN(thePrice) || (parseInt(thePrice) < 0) ) { retVal = false; } var decimalIndex = thePrice.indexOf("."); if (decimalIndex >= 0) { thePrice = thePrice.substring(decimalIndex+1); if (thePrice.length != 2) retVal = false; } return retVal; } function isValidURL(theURL) { theURL = theURL.toLowerCase(); var retVal = true; if ( (theURL == "") || (theURL == "http://") || (theURL == "https://") ) retVal = false; else if ( (theURL.indexOf("http://") < 0) && (theURL.indexOf("https://") < 0) ) retVal = false; return retVal; } function setLastUID() { var myID = document.UserIDWP.document.ppUID.value; var newTag = '\n'; DWfile.write(PayPalConfigFilePath, newTag); } function getLastUID() { var xmlDOM = dw.getDocumentDOM(PayPalConfigFilePath); var thePayPal = xmlDOM.getElementsByTagName("paypal"); var theUID = thePayPal[0].getAttribute("uid"); document.UserIDWP.document.ppUID.value = WAURLDecode(theUID); } /* ** Full URL Encoding of non-alphanumeric characters (escape() only performs a subset of ** these characters). Just comment out any replace lines for characters you do not want ** to encode for this particular implementation. */ function WAURLEncode(theString) { var re0 = /!/g; var re1 = /"/g; var re2 = /#/g; var re3 = /\$/g; var re4 = /%/g; var re5 = / /g; var re6 = /&/g; var re7 = /'/g; var re8 = /\(/g; var re9 = /\)/g; var re10 = /\*/g; var re11 = /\+/g; var re12 = /,/g; var re13 = /-/g; var re14 = /\./g; var re15 = /:/g; var re16 = /;/g; var re17 = //g; var re20 = /\?/g; var re21 = /@/g; var re22 = /|/g; var re23 = /~/g; theString = theString.replace(re4, "\%25"); // be sure to encode percents first or else it will mess up the rest of the replacements theString = theString.replace(re0, "%21"); theString = theString.replace(re1, "%22"); theString = theString.replace(re2, "%23"); theString = theString.replace(re3, "%24"); theString = theString.replace(re11, "%2B"); //Encode '+' as '%2B' ** must do this before encoding ' ' as '+' theString = theString.replace(re5, "+"); //Encode ' ' as '+' theString = theString.replace(re6, "%26"); theString = theString.replace(re7, "%27"); theString = theString.replace(re8, "%28"); theString = theString.replace(re9, "%29"); theString = theString.replace(re10, "%2A"); theString = theString.replace(re12, "%2C"); //theString = theString.replace(re13, "%2D"); // PayPal doesn't like dashes "-" encoded //theString = theString.replace(re14, "%2E"); // PayPal doesn't like periods "." encoded //theString = theString.replace(re15, "%3A"); // PayPal doesn't like colons ":" encoded theString = theString.replace(re16, "%3B"); theString = theString.replace(re17, "%3C"); theString = theString.replace(re18, "%3D"); theString = theString.replace(re19, "%3E"); theString = theString.replace(re20, "%3F"); //theString = theString.replace(re21, "%40"); // PayPal doesn't like the at symbol "@" encoded //theString = theString.replace(re22, "%7C"); // DW MX doesn't like encoding pipe characters theString = theString.replace(re23, "%7E"); return theString; } /* ** Full URL Encoding of non-alphanumeric characters (escape() only performs a subset of ** these characters). */ function WAURLDecode(theString) { var re0 = /%21/gi; var re1 = /%22/gi; var re2 = /%23/gi; var re3 = /%24/gi; var re4 = /%25/gi; var re5 = /\+/gi; var re6 = /%26/gi; var re7 = /%27/gi; var re8 = /%28/gi; var re9 = /%29/gi; var re10 = /%2A/gi; var re11 = /%2B/gi; var re12 = /%2C/gi; var re13 = /%2D/gi; var re14 = /%2E/gi; var re15 = /%3A/gi; var re16 = /%3B/gi; var re17 = /%3C/gi; var re18 = /%3D/gi; var re19 = /%3E/gi; var re20 = /%3F/gi; var re21 = /%40/gi; var re22 = /%7C/gi; var re23 = /%7E/gi; theString = theString.replace(re0, "!"); theString = theString.replace(re1, "\""); theString = theString.replace(re2, "#"); theString = theString.replace(re3, "$"); theString = theString.replace(re5, " "); // decode '+' to ' ' ** must do this before decoding '%2B' to '+' theString = theString.replace(re6, "&"); theString = theString.replace(re7, "'"); theString = theString.replace(re8, "("); theString = theString.replace(re9, ")"); theString = theString.replace(re10, "*"); theString = theString.replace(re11, "+"); // decode '%2B' to '+' theString = theString.replace(re12, ","); theString = theString.replace(re13, "-"); theString = theString.replace(re14, "."); theString = theString.replace(re15, ":"); theString = theString.replace(re16, ";"); theString = theString.replace(re17, "<"); theString = theString.replace(re18, "="); theString = theString.replace(re19, ">"); theString = theString.replace(re20, "?"); theString = theString.replace(re21, "@"); //theString = theString.replace(re22, "|"); // DW MX doesn't like encoding pipe characters theString = theString.replace(re23, "~"); theString = theString.replace(re4, "%"); // decode percents last return theString; } function getButtonString(inString) { var outPad = " "; if ( (parseInt(dreamweaver.appVersion) >= 6) && dreamweaver.isOSX() ) { // no extra padding for MacOS X outPad = ""; } return (outPad + inString + outPad); } function closeWindow() { window.close(); dreamweaver.forceGarbageCollection(); }