diff options
author | Alexander Sulfrian <alexander@sulfrian.net> | 2010-06-08 08:22:05 +0200 |
---|---|---|
committer | Alexander Sulfrian <alexander@sulfrian.net> | 2010-06-08 08:22:05 +0200 |
commit | d7c5ad7d6263fd1baf9bfdbaa4c50b70ef2fbdb2 (patch) | |
tree | ae0b65da6432f4c26c8d5a7319efbda5d172846c /trunk/etherpad/src/etherpad/control/store/storecontrol.js | |
parent | fa61221dcd89fcd72cba2c97971626f456c86e5d (diff) | |
download | etherpad-d7c5ad7d6263fd1baf9bfdbaa4c50b70ef2fbdb2.tar.gz etherpad-d7c5ad7d6263fd1baf9bfdbaa4c50b70ef2fbdb2.tar.bz2 etherpad-d7c5ad7d6263fd1baf9bfdbaa4c50b70ef2fbdb2.zip |
reverted folder structure change for better mergeing with upstream
Diffstat (limited to 'trunk/etherpad/src/etherpad/control/store/storecontrol.js')
-rw-r--r-- | trunk/etherpad/src/etherpad/control/store/storecontrol.js | 201 |
1 files changed, 201 insertions, 0 deletions
diff --git a/trunk/etherpad/src/etherpad/control/store/storecontrol.js b/trunk/etherpad/src/etherpad/control/store/storecontrol.js new file mode 100644 index 0000000..43569e4 --- /dev/null +++ b/trunk/etherpad/src/etherpad/control/store/storecontrol.js @@ -0,0 +1,201 @@ +/** + * Copyright 2009 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS-IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import("dispatch.{Dispatcher,DirMatcher,forward}"); +import("fastJSON"); +import("funhtml.*"); + +import('etherpad.globals.*'); +import("etherpad.store.eepnet_trial"); +import("etherpad.store.eepnet_checkout"); +import("etherpad.sessions.getSession"); +import("etherpad.utils.*"); + +import("etherpad.control.store.eepnet_checkout_control"); +import("etherpad.control.pro.admin.team_billing_control"); + +jimport("java.lang.System.out.println"); + +//---------------------------------------------------------------- + +function onStartup() {} + +function onRequest() { + var disp = new Dispatcher(); + disp.addLocations([ + [DirMatcher('/ep/store/eepnet-checkout/'), forward(eepnet_checkout_control)], + ]); + return disp.dispatch(); +} + +//---------------------------------------------------------------- + +function render_main() { + response.redirect("/ep/about/pricing"); +} + +//---------------------------------------------------------------- +// Flow goes through these 4 pages in order: +//---------------------------------------------------------------- + +function render_eepnet_eval_signup_get() { + renderFramed("store/eepnet_eval_signup.ejs", { + trialDays: eepnet_trial.getTrialDays(), + oldData: (getSession().pricingContactData || {}), + sfIndustryList: eepnet_trial.getSalesforceIndustryList() + }); + delete getSession().errorMsg; +} + +// function render_eepnet_eval_signup_post() { +// response.setContentType("text/plain; charset=utf-8"); +// var data = {}; +// var fields = ['firstName', 'lastName', 'email', 'orgName', +// 'jobTitle', 'phone', 'estUsers', 'industry']; +// +// if (!getSession().pricingContactData) { +// getSession().pricingContactData = {}; +// } +// +// function _redirectErr(msg) { +// response.write(fastJSON.stringify({error: msg})); +// response.stop(); +// } +// +// fields.forEach(function(f) { +// getSession().pricingContactData[f] = request.params[f]; +// }); +// +// fields.forEach(function(f) { +// data[f] = request.params[f]; +// if (!(data[f] && (data[f].length > 0))) { +// _redirectErr("All fields are required."); +// } +// }); +// +// // validate email +// if (!isValidEmail(data.email)) { +// _redirectErr("That email address doesn't look valid."); +// } +// +// // check that email not already registered. +// if (eepnet_trial.hasEmailAlreadyDownloaded(data.email)) { +// _redirectErr("That email has already downloaded a free trial."+ +// ' <a href="/ep/store/eepnet-recover-license">Recover a lost license key here</a>.'); +// } +// +// // Looks good! Create and email license key... +// eepnet_trial.createAndMailNewLicense(data); +// getSession().message = "A license key has been sent to "+data.email; +// +// // Generate web2lead info and return it +// var web2leadData = eepnet_trial.getWeb2LeadData(data, request.clientAddr, getSession().initialReferer); +// response.write(fastJSON.stringify(web2leadData)); +// } +// +// function render_salesforce_web2lead_ok() { +// renderFramedHtml([ +// '<script>', +// 'top.location.href = "'+request.scheme+'://'+request.host+'/ep/store/eepnet-download";', +// '</script>' +// ].join('\n')); +// } +// +// function render_eepnet_eval_download() { +// // NOTE: keep this URL around for historical reasons? +// response.redirect("/ep/store/eepnet-download"); +// } +// +// function render_eepnet_download() { +// renderFramed("store/eepnet_download.ejs", { +// message: (getSession().message || null), +// versionString: (PNE_RELEASE_VERSION+" ("+PNE_RELEASE_DATE +")") +// }); +// delete getSession().message; +// } +// +// function render_eepnet_download_zip() { +// response.redirect("/static/zip/pne-release/etherpad-pne-"+PNE_RELEASE_VERSION+".zip"); +// } +// +// function render_eepnet_download_nextsteps() { +// renderFramed("store/eepnet_eval_nextsteps.ejs"); +// } + +//---------------------------------------------------------------- +// recover a lost license +//---------------------------------------------------------------- +function render_eepnet_recover_license_get() { + var d = DIV({className: "fpcontent"}); + + d.push(P("Recover your lost license key.")); + + if (getSession().message) { + d.push(DIV({id: "resultmsg", + style: "border: 1px solid #333; padding: 0 1em; background: #efe; margin: 1em 0;"}, getSession().message)); + delete getSession().message; + } + if (getSession().error) { + d.push(DIV({id: "errormsg", + style: "border: 1px solid red; padding: 0 1em; background: #fee; margin: 1em 0;"}, getSession().error)); + delete getSession().error; + } + + d.push(FORM({style: "border: 1px solid #222; padding: 2em; background: #eee;", + action: request.path, method: "post"}, + LABEL({htmlFor: "email"}, + "Your email address:"), + INPUT({type: "text", name: "email", id: "email"}), + INPUT({type: "submit", id: "submit", value: "Submit"}))); + + renderFramedHtml(d); +} + +function render_eepnet_recover_license_post() { + var email = request.params.email; + if (!eepnet_trial.hasEmailAlreadyDownloaded(email) && !eepnet_trialhasEmailAlreadyPurchased(email)) { + getSession().error = P("License not found for email: \"", email, "\"."); + response.redirect(request.path); + } + if (eepnet_checkout.hasEmailAlreadyPurchased(email)) { + eepnet_checkout.mailLostLicense(email); + } else if (eepnet_trial.hasEmailAlreadyDownloaded(email)) { + eepnet_trial.mailLostLicense(email); + } + getSession().message = P("Your license information has been sent to ", email, "."); + response.redirect(request.path); +} + +//---------------------------------------------------------------- +function render_eepnet_purchase_get() { + renderFramed("store/eepnet_purchase.ejs", {}); +} + +//-------------------------------------------------------------------------------- +// csc-help page +//-------------------------------------------------------------------------------- + +function render_csc_help_get() { + response.write(renderTemplateAsString("store/csc-help.ejs")); +} + +//-------------------------------------------------------------------------------- +// paypal notifications for pro +//-------------------------------------------------------------------------------- + +function render_paypalnotify() { + team_billing_control.handlePaypalNotify(); +} |