aboutsummaryrefslogtreecommitdiffstats
path: root/etherpad/src/etherpad/control/aboutcontrol.js
blob: 9d771428645c497563619db788ce5bf206cd3fac (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
/**
 * 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("email.sendEmail");
import("funhtml.*", "stringutils.*");
import("netutils");
import("execution");

import("etherpad.utils.*");
import("etherpad.log");
import("etherpad.globals.*");
import("etherpad.quotas");
import("etherpad.sessions.getSession");
import("etherpad.store.eepnet_trial");
import("etherpad.store.checkout");
import("etherpad.store.eepnet_checkout");

jimport("java.lang.System.out.println");

//----------------------------------------------------------------

function render_product() {
  if (request.params.from) { response.redirect(request.path); }
  renderFramed("about/product_body.ejs");
}

function render_faq() {
  renderFramed("about/faq_body.ejs", {
    LI: LI,
    H2: H2,
    A: A,
    html: html
  });
}

function render_pne_faq() {
  renderFramed("about/pne-faq.ejs");
}

function render_company() {
  renderFramed("about/company_body.ejs");
}

function render_contact() {
  renderFramed("about/contact_body.ejs");
}

function render_privacy() {
  renderFramed("about/privacy_body.ejs");
}

function render_tos() {
  renderFramed("about/tos_body.ejs");
}

function render_testimonials() {
  renderFramed("about/testimonials.ejs");
}

function render_appjet() {
  response.redirect("/ep/blog/posts/etherpad-and-appjet");
//  renderFramed("about/appjet_body.ejs");
}

function render_screencast() {
  if (request.params.from) { response.redirect(request.path); }
  var screencastUrl;
//  if (isProduction()) {
    screencastUrl = encodeURIComponent("http://etherpad.s3.amazonaws.com/epscreencast800x600.flv");
//  } else {
//    screencastUrl = encodeURIComponent("/static/flv/epscreencast800x600.flv");
//  }
  renderFramed("about/screencast_body.ejs", {screencastUrl: screencastUrl});
}

function render_forums() {
  renderFramed("about/forums_body.ejs");
}

function render_blog() {
  renderFramed("about/blog_body.ejs");
}

function render_really_real_time() {
  renderFramed("about/simultaneously.ejs");
}
  
function render_simultaneously() {
  renderFramed("about/simultaneously.ejs");
}

//----------------------------------------------------------------
// pricing
//----------------------------------------------------------------

function render_pricing() {
  renderFramed("about/pricing.ejs", {
    trialDays: eepnet_trial.getTrialDays(),
    costPerUser: checkout.dollars(eepnet_checkout.COST_PER_USER)
  });
}

function render_pricing_free() {
  renderFramed("about/pricing_free.ejs", {
    maxUsersPerPad: quotas.getMaxSimultaneousPadEditors()
  });
}

function render_pricing_eepnet() {
  renderFramed("about/pricing_eepnet.ejs", {
    trialDays: eepnet_trial.getTrialDays(),
    costPerUser: checkout.dollars(eepnet_checkout.COST_PER_USER)
  });
}

function render_pricing_pro() {
  renderFramed("about/pricing_pro.ejs", {});
}

function render_eepnet_pricing_contact_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 err(m) {
    response.write(m);
    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))) {
       err("All fields are required.");
    }
  });
  
  if (!isValidEmail(data.email)) {
    err("Error: Invalid Email");
  }

  // log this data to a file
  fields.ip = request.clientAddr;
  fields.sessionReferer = getSession().initialReferer;
  log.custom("eepnet_pricing_inquiry", fields);

  // submit web2lead
  var ref = getSession().initialReferer;
  var googleQuery = extractGoogleQuery(ref);
  var wlparams = {
    oid: "00D80000000b7ey",
    first_name: data.firstName,
    last_name: data.lastName,
    email: data.email,
    company: data.orgName,
    title: data.jobTitle,
    phone: data.phone,
    '00N80000003FYtG': data.estUsers,
    '00N80000003FYto': ref,
    '00N80000003FYuI': googleQuery,
    lead_source: 'EEPNET Pricing Inquiry',
    industry: data.industry,
    retURL: 'http://'+request.host+'/ep/store/salesforce-web2lead-ok'
  };

  var result = netutils.urlPost(
    "http://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8",
    wlparams, {});

  // now send an email sales notification
  var hostname = ipToHostname(request.clientAddr) || "unknown";
  var subject = 'EEPNET Pricing Inquiry: '+data.email+' / '+hostname;
  var body = [
    "", "This is an automated email.", "",
    data.firstName+" "+data.lastName+" ("+data.orgName+") has inquired about EEPNET pricing.",
    "",
    "This record has automatically been added to SalesForce.  See the salesforce lead page for more details.",
    "", "Session Referer: "+ref, ""
  ].join("\n");
  var toAddr = 'sales@pad.spline.inf.fu-berlin.de';
  if (isTestEmail(data.email)) {
    toAddr = 'blackhole@appjet.com';
  }
  sendEmail(toAddr, 'sales@pad.spline.inf.fu-berlin.de', subject, {}, body);

  // all done!
  response.write("OK");
}

function render_pricing_interest_signup() {
  response.setContentType('text/plain; charset=utf-8');

  var email = request.params.email;
  var interestedNet = request.params.interested_net;
  var interestedHosted = request.params.interested_hosted;

  if (!isValidEmail(email)) {
    response.write("Error: Invalid Email");
    response.stop();
  }

  log.custom("pricing_interest", 
    {email: email, 
     net: interestedNet,
     hosted: interestedHosted});

  response.write('OK');
}

function render_pricing_eepnet_users() {
  renderFramed('about/pricing_eepnet_users.ejs', {});
}

function render_pricing_eepnet_support() {
  renderFramed('about/pricing_eepnet_support.ejs', {});
}


//------------------------------------------------------------
// survey

function render_survey() {
  var id = request.params.id;
  log.custom("pro-user-survey", { surveyProAccountId: (id || "unknown") });
  response.redirect("http://www.surveymonkey.com/s.aspx?sm=yT3ALP0pb_2fP_2bHtcfzvpkXQ_3d_3d");
}


//------------------------------------------------------------

import("etherpad.billing.billing");

function render_testbillingnotify() {
  var ret = billing.handlePaypalNotification();
  if (ret.status == 'completion') {
    // do something with purchase ret.purchaseInfo
  } else if (ret.status != 'redundant') {
    java.lang.System.out.println("Whoa error: "+ret.toSource());
  }
  response.write("ok");
}