-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaccount.html
364 lines (330 loc) · 8.88 KB
/
account.html
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
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
<!DOCTYPE HTML>
<html>
<head>
<title>Cyclo Account</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no,width=device-width">
<script src="https://code.jquery.com/jquery-latest.min.js"></script>
<script src="js/jquery-ui-latest.min.js"></script>
<script src="js/jquery.layout-latest.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
//$('body').layout({ applyDemoStyles: true });
initPage();
});
function getUrlVars()
{
var vars = [], hash;
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for(var i = 0; i < hashes.length; i++)
{
hash = hashes[i].split('=');
vars.push(hash[0]);
vars[hash[0]] = hash[1];
}
return vars;
}
var params = getUrlVars();
function setCookie(cname,cvalue,exdays)
{
var d = new Date();
d.setTime(d.getTime()+(exdays*24*60*60*1000));
var expires = "expires="+d.toGMTString();
document.cookie = cname + "=" + cvalue + "; " + expires;
}
function getCookie(cname)
{
var name = cname + "=";
var ca = document.cookie.split(';');
for(var i=0; i<ca.length; i++)
{
var c = ca[i].trim();
if (c.indexOf(name)==0) return c.substring(name.length,c.length);
}
return "";
}
var options = {
email:"",
id:""
}
function setOption(name,value)
{
var ex = 365;
options[name] = value;
setCookie(name,value,ex);
}
function getOption(name,editName,overrideValue,f)
{
var edit = $("#"+editName);
options[name] = getCookie(name);
if ( overrideValue !==undefined ) options[name] = overrideValue;
if (options[name]!="")
edit.val(options[name]); //document.getElementById(edit).value = options[name];
edit.on("change", function(event) {
var s = this.value;
if ( f !== undefined ) s = f(s);
this.value = s;
setOption(name,s);
} );
}
function checkCookies()
{
// options.email=getCookie("email"); if (email!="") document.getElementById('editEmail').value = email;
getOption("email","editEmail",params["e"]);
getOption("id","editId",params["id"],cleanNumbers);
}
function initPage()
{
$("body").layout({
applyDemoStyles: true,
defaults: {
fxName: "slide",
fxSpeed: "slow",
spacing_closed: 14,
initClosed: false
},
west: {
size: 120
},
north: {
//togglerLength_closed: "10%"
},
south: {
//togglerLength_closed: "50%"
}
});
checkCookies();
$("#getId").on("click", function(event) { sendCyclo({order:1},function(d){ $("#idMsg").text(d) });} );
$("#getActiveLogname").on("click",getActiveLogName);
$("#moveName").on("click",moveLogName);
getActiveLogName(function() { initGrant("OneLog"); }); // muuten ei ehdi alustua oikein
initGrant("Active");
initGrant("Default");
initGrant("Trust");
$("#getLogs").on("click",getLogs);
getLogs();
$("#result").on("change",moveLogName);
}
function getLogs()
{
var mask = $("#editLoglistMask").val();
if ( mask == "" ) mask = "*";
sendCyclo({dir:mask},function(d){
// $("#result").text(d); }
var lines = d.split("\n");
var listbox = $("#result");
listbox.empty();
//$("#result> option").each(function(i, option){
// $(option).remove();
//}
//);
lines.sort();
for(var i=0; i<lines.length; i++)
{
var line = lines[i].trim();
if ( line == "" ) continue;
var item = '<option value="'+line+'">'+line+'</option>';
listbox.append(item);
}
}
);
}
function moveLogName()
{
var selectedOpts = $("#result").val();
if ( selectedOpts == "" ) return;
var edit = $("#editOneLog");
edit.val(selectedOpts);
getGrant("OneLog",$("#resultOneLog"));
}
function initGrant(logName)
{
var ln = logName.toLowerCase();
$("#get"+logName).on("click", function(event) { getGrant(ln,$("#result"+logName)); } );
$("#set"+logName).on("click", function(event) { setGrant(ln,$("#result"+logName).val()); } );
getGrant(ln,$("#result"+logName));
}
function setGrant(logName,grant)
{
grant = grant.trim();
grant = grant.replace(/\n/g,',');
grant = grant.trim();
if ( grant == "" ) grant = "-";
sendCyclo({log:checkLogName(logName),g:grant},function(d){$("#idMsg").text(d); });
}
function getGrant(logName,grantRes)
{
sendCyclo({log:checkLogName(logName),qg:1},function(d){
d = d.replace(/,/g,'\n');
grantRes.val(d);
});
}
function Sort(elementId) {
// Convert the listbox options to a javascript array and sort (ascending)
var sortedList = $.makeArray($("#" + elementId + " option"))
.sort(function(a, b) {
return $(a).text() < $(b).text() ? -1 : 1;
});
// Clear the options and add the sorted ones
$("#" + elementId).empty().html(sortedList);
}
function getActiveLogName(f)
{
sendCyclo({},function(d){
var edit = $("#editOneLog");
d = d.replace(/.*\/(.*)=.*/,'$1').trim();
edit.val(d);
if ( typeof f == 'function' ) f();
});
}
function checkLogName(logName)
{
var ln = logName.toLowerCase();
if ( ln == "onelog" )
ln = $("#editOneLog").val().toLowerCase();
return ln;
}
function cleanNumbers(s)
{
return s.replace(/[^0-9]/g,'').trim();
}
function sendCyclo(command,f)
{
/*
$.ajax({
type: 'POST',
url: "https://www.mit.jyu.fi/demowww/cyclo/",
contentType: 'text/plain',
xhrFields: { withCredentials: false },
success: function() {
},
});
*/
clearError();
options.id = cleanNumbers(options.id);
var params = $.extend({}, command, { id: options.id, e: options.email });
$.post( "index.php", params )
.done(function( data ) {
f(data)
} );
}
function setError(s)
{
var e = document.getElementById('errorMsg');
e.innerHTML += " " + s;
return s;
}
function clearError()
{
var e = document.getElementById('errorMsg');
e.innerHTML = "";
return "";
}
// var selectedOpts = $('#source-listbox').val();
</script>
<style>
html, body
{
/* background-color:#b0c4de; */
height: 100%;
}
.errorClass {
color:#ff0000;
font-weight: bold;
}
div#mapDiv {
}
div#accountDiv {
border-top:2px solid blue;
margin-top: 10px;
margin-bottom: 10px;
}
.setlog {
border-top:2px solid blue;
}
.loglistarea {
height: 85%;
}
</style>
</head>
<body>
</div>
<!--
<div class="ui-layout-north">North</div>
<div class="ui-layout-west">west</div>
-->
<div class="ui-layout-north">
<h1>Hallitse CycloLite -tiliäsi</h1>
</div>
<div class="ui-layout-west">
<input type="text" id="editLoglistMask" value="*" size="10" />
<button id="getLogs">Hae logilista</button></br>
<!--
<textarea class="loglistarea" id="result" rows="10", cols="30">
</textarea>
-->
<select class="loglistarea" id="result" size="20">
<option value="1">1</option>
</select><br />
<button id="moveName">Siirrä nimi</button></br>
</div>
<div class="ui-layout-center">
<div class="idMsg" id = "idMsg"></div>
<div id="accountDiv">
<p>
<strong>Omat tunnukset:</strong>
email: <input type="text" id="editEmail" value="" size="25" /> id: <input type="text" id="editId" value="" size="10" /> <button id="getId">Hae uusi ID</button>
<span class="errorClass" id="errorMsg"></span>
</p>
</div>
<div id="activeDiv" class="setlog">
<p>
Kuka saa katsoa aktiivisen login nimen? (kirjoita all, jos haluat että kaikki)<br />
<textarea id="resultActive" rows="3", cols="25">
</textarea>
<button id="getActive">Hae</button>
<button id="setActive">Aseta</button>
</p>
</div>
<div id="defaultDiv" class="setlog">
<p>
Kuka saa katsoa oletuksena mitä tahansa logia? <br />
<textarea id="resultDefault" rows="3", cols="25">
</textarea>
<button id="getDefault">Hae</button>
<button id="setDefault">Aseta</button>
</p>
</div>
<div id="trustDiv" class="setlog">
<p>
Kehen luotat niin, ettei tarvitse koskaan antaa oikeuksia erikseen? <br />
Yleensä tähän tulee vain omat eri postiosoitteet, joita käytetään CycloLitessä. <br />
<textarea id="resultTrust" rows="3", cols="25">
</textarea>
<button id="getTrust">Hae</button>
<button id="setTrust">Aseta</button>
</p>
</div>
<div id="oneLogDiv" class="setlog">
<p>
Login <input type="text" id="editOneLog" value="" size="25" />
oikeudet.
<button id="getActiveLogname">Hae</button> aktiivisen login nimi.
<br />
<textarea id="resultOneLog" rows="3", cols="25">
</textarea>
<button id="getOneLog">Hae</button>
<button id="setOneLog">Aseta</button>
</p>
</div>
</div>
<div class="ui-layout-south">
<div id='instructions'>
<p>Dataa voit lähettää/katsoa <a href="https://trac.cc.jyu.fi/projects/dotnet/wiki/CycloLite">CycloLite</a>llä.
Samalla sivulla on lisäohjeita tunnuksista.
Logeja voit seurata <a href="k.html">kartalta</a>.
</p>
</div>
</div>
</body>
</html>