source: apps/routerconsole/jsp/welcome.jsp @ 6462e2a

Last change on this file since 6462e2a was 6462e2a, checked in by zzz <zzz@…>, 21 months ago

MLab/NDT: Prep for connecting to wizard, fixes, cleanups

  • Property mode set to 100644
File size: 8.5 KB
Line 
1<%@page contentType="text/html"%><%@page pageEncoding="UTF-8"%><jsp:useBean class="net.i2p.router.web.helpers.WizardHelper" id="wizhelper" scope="request" /><%
2    // page ID
3    final int LAST_PAGE = 7;
4    String pg = request.getParameter("page");
5    int ipg;
6    if (pg == null) {
7        ipg = 1;
8    } else {
9        try {
10            ipg = Integer.parseInt(pg);
11            if (request.getParameter("prev") != null) {
12                // previous button handling
13                if (ipg == 6)
14                    ipg = 3;
15                else
16                    ipg -= 2;
17            }
18            if (ipg <= 0 || ipg > LAST_PAGE) {
19                ipg = 1;
20            } else if (ipg == 4 && request.getParameter("skipbw") != null) {
21                ipg++;  // skip bw test
22            }
23        } catch (NumberFormatException nfe) {
24            ipg = 1;
25        }
26    }
27
28    // detect completion
29    boolean done = request.getParameter("done") != null || request.getParameter("skip") != null;
30    if (done) {
31        // tell wizard helper we're done
32        String i2pcontextId = request.getParameter("i2p.contextId");
33        try {
34            if (i2pcontextId != null) {
35                session.setAttribute("i2p.contextId", i2pcontextId);
36            } else {
37                i2pcontextId = (String) session.getAttribute("i2p.contextId");
38            }
39        } catch (IllegalStateException ise) {}
40        wizhelper.setContextId(i2pcontextId);
41        wizhelper.complete();
42
43        // redirect to /home
44        response.setStatus(307);
45        response.setHeader("Cache-Control","no-cache");
46        String req = request.getRequestURL().toString();
47        int slash = req.indexOf("/welcome");
48        if (slash >= 0)
49            req = req.substring(0, slash) + "/home";
50        else // shouldn't happen
51            req = "http://127.0.0.1:7657/home";
52        response.setHeader("Location", req);
53        // force commitment
54        response.getOutputStream().close();
55        return;
56    }
57%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
58<html><head>
59<%@include file="css.jsi" %>
60<%=intl.title("New Install Wizard")%>
61<%
62    if (ipg == 4) {
63%>
64<script src="/js/ajax.js" type="text/javascript"></script>
65<script type="text/javascript">
66  var failMessage = "<hr><b><%=intl._t("Router is down")%><\/b>";
67  function requestAjax1() { ajax("/welcomexhr.jsp", "xhr", "1000"); }
68  function initAjax() { setTimeout(requestAjax1, "1000");  }
69</script>
70<%
71    }
72%>
73</head>
74<%
75    if (ipg == 4) {
76%>
77<body onload="initAjax()">
78<%
79    } else {
80%>
81<body>
82<%
83    }
84%>
85<h2><%=intl._t("New Install Wizard")%> <%=ipg%>/<%=LAST_PAGE%></h2>
86<div id="wizard">
87<%--
88    // note that for the handler we use a session scope, not a page scope,
89    // so that we can access the NDT test results.
90    // The MLabHelper singleton will prevent multiple simultaneous tests, even across sessions.
91--%>
92<jsp:useBean class="net.i2p.router.web.helpers.WizardHandler" id="formhandler" scope="session" />
93<%@include file="formhandler.jsi" %>
94<form action="" method="POST">
95<input type="hidden" name="nonce" value="<%=pageNonce%>">
96<input type="hidden" name="action" value="blah" >
97<input type="hidden" name="page" value="<%=(ipg + 1)%>" >
98<%
99
100    if (ipg == 1) {
101        // language selection
102%>
103<jsp:useBean class="net.i2p.router.web.helpers.ConfigUIHelper" id="uihelper" scope="request" />
104<jsp:setProperty name="uihelper" property="contextId" value="<%=i2pcontextId%>" />
105<%-- needed for CSS: --%><div id="config_ui">
106<%-- needed for lang setting in css.jsi: --%><input type="hidden" name="consoleNonce" value="<%=net.i2p.router.web.CSSHelper.getNonce()%>" >
107<h3 id="langheading"><%=uihelper._t("Router Console Language")%></h3>
108<div id="langsettings">
109<jsp:getProperty name="uihelper" property="langSettings" />
110</div></div>
111<%
112
113    } else if (ipg == 2) {
114        // I2P Philosophy
115        // license info?
116%>
117<h3><%=intl._t("Why I2P?")%></h3>
118<p>TODO</p>
119<%
120
121    } else if (ipg == 3) {
122        // Overview of bandwidth test
123%>
124<h3><%=intl._t("Bandwidth Test")%></h3>
125<p>
126<%=intl._t("I2P will now test your internet connection to identify the optimal speed settings.")%>
127<%=intl._t("Applying these settings will maximize your download speed using the third-party M-Lab service.")%>
128<%=intl._t("M-Lab collects and publishes the IP address of the client that conducted the measurement.")%>
129<%=intl._t("FIXME! This is necessary to understand and describe experimental results, including to identify which Internet service provider the test was conducted from.")%>
130<%=intl._t("Please review the M-Lab privacy policies linked below.")%>
131<%=intl._t("If you do not wish to run the M-Lab bandwidth test, you may skip it by clicking the button below.")%>
132</p><p>
133<a href="https://www.measurementlab.net/privacy/" target="_blank"><%=intl._t("M-Lab Privacy Policy")%></a>
134<br><a href="https://github.com/m-lab/mlab-ns/blob/master/MLAB-NS_PRIVACY_POLICY.md" target="_blank"><%=intl._t("M-Lab Name Server Privacy Policy")%></a>
135</p>
136
137
138<%
139
140    } else if (ipg == 4) {
141        // Bandwidth test in progress (w/ AJAX)
142%>
143<h3><%=intl._t("Bandwidth Test in Progress")%></h3>
144<p>TODO</p>
145<%
146
147    } else if (ipg == 5) {
148        // Bandwidth test results
149        // and/or manual bw entry?
150%>
151<jsp:useBean class="net.i2p.router.web.helpers.ConfigNetHelper" id="nethelper" scope="request" />
152<jsp:setProperty name="nethelper" property="contextId" value="<%=i2pcontextId%>" />
153<h3><%=intl._t("Bandwidth Test Results")%></h3>
154<table class="configtable">
155<tr><td>
156Test results go here
157</td></tr>
158</table>
159<h3><%=intl._t("Bandwidth Configuration")%></h3>
160<table id="bandwidthconfig" class="configtable">
161<tr><td class="infohelp" colspan="2">
162<%=intl._t("I2P will work best if you configure your rates to match the speed of your internet connection.")%>
163</td></tr>
164<tr><td><input style="text-align: right; width: 5em;" name="inboundrate" type="text" size="5" maxlength="5" value="<jsp:getProperty name="nethelper" property="inboundBurstRate" />" >
165<%=intl._t("KBps In")%>
166</td><td>(<jsp:getProperty name="nethelper" property="inboundBurstRateBits" />)</td>
167</tr><tr>
168<%-- display burst, set standard, handler will fix up --%>
169<td><input style="text-align: right; width: 5em;" name="outboundrate" type="text" size="5" maxlength="5" value="<jsp:getProperty name="nethelper" property="outboundBurstRate" />" >
170<%=intl._t("KBps Out")%>
171</td><td>(<jsp:getProperty name="nethelper" property="outboundBurstRateBits" />)</td>
172</tr><tr>
173<td><jsp:getProperty name="nethelper" property="sharePercentageBox" /> <%=intl._t("Share")%></td>
174<td>(<jsp:getProperty name="nethelper" property="shareRateBits" />)
175</td></tr>
176<tr><td class="infohelp" colspan="2">
177<% int share = Math.round(nethelper.getShareBandwidth() * 1.024f);
178    if (share < 12) {
179        out.print("<b>");
180        out.print(intl._t("NOTE"));
181        out.print("</b>: ");
182        out.print(intl._t("You have configured I2P to share only {0} KBps.", share));
183        out.print("\n");
184
185        out.print(intl._t("I2P requires at least 12KBps to enable sharing. "));
186        out.print(intl._t("Please enable sharing (participating in tunnels) by configuring more bandwidth. "));
187        out.print(intl._t("It improves your anonymity by creating cover traffic, and helps the network."));
188    } else {
189        out.print(intl._t("You have configured I2P to share {0} KBps.", share));
190        out.print("\n");
191
192        out.print(intl._t("The higher the share bandwidth the more you improve your anonymity and help the network."));
193    }
194%></td></tr>
195</table>
196<%
197
198    } else if (ipg == 6) {
199        // Browser setup
200%>
201<h3><%=intl._t("Browser Setup")%></h3>
202<p>TODO</p>
203<%
204
205    } else if (ipg == LAST_PAGE) {
206        // Done
207%>
208<h3><%=intl._t("Finished")%></h3>
209<p>TODO</p>
210<%
211
212    } else {
213%>
214<p>unknown wizard page</p>
215<%
216    }
217%>
218<div class="wizardbuttons">
219<table class="configtable"><tr><td class="optionsave">
220<%
221    if (ipg != 1) {
222%>
223<input type="submit" class="go" name="prev" value="<%=intl._t("Previous")%>" >
224<%
225    }
226    if (ipg != LAST_PAGE) {
227%>
228<input type="submit" class="cancel" name="skip" value="<%=intl._t("Skip Setup")%>" >
229<%
230        if (ipg == 3) {
231%>
232<input type="submit" class="cancel" name="skipbw" value="<%=intl._t("Skip Bandwidth Test")%>" >
233<%
234        } else if (ipg == 4) {
235%>
236<input type="submit" class="cancel" name="cancelbw" value="<%=intl._t("Cancel Bandwidth Test")%>" >
237<%
238        }
239%>
240<input type="submit" class="go" name="next" value="<%=intl._t("Next")%>" >
241<%
242    } else {
243%>
244<input type="submit" class="go" name="done" value="<%=intl._t("Finished")%>" >
245<%
246    }
247%>
248</td></tr></table>
249</form>
250</div></body></html>
Note: See TracBrowser for help on using the repository browser.