forked from vitotafuni/JSOTTEST
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jsottest.html
112 lines (102 loc) · 4.3 KB
/
jsottest.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
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<!--
Copyright 2011 - Vito Tafuni
This file is part of JSOTTEST.
JSOTTEST is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
JSOTTEST is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with JSOTTEST. If not, see <http://www.gnu.org/licenses/>.
-->
<title>JavaScript Operational Transformation algorithm TEST page</title>
<link rel="stylesheet" href="style.css" type="text/css" media="all" />
<script type="text/javascript">
// some corrections for dependencies from mootools in JSON.js
function Hash(){};
function typeOf(value) {
var s = typeof value;
if (s === 'object') {
if (value) {
if (typeof value.length === 'number' &&
!(value.propertyIsEnumerable('length')) &&
typeof value.splice === 'function') {
s = 'array';
}
} else {
s = 'null';
}
}
return s;
}
Object.prototype.each = function(el,fn){
for (var k in el)
if(el.hasOwnProperty(k))
fn(el[k],k);
}
Array.prototype.clean = function(){
var those = new Array();
for(var i=0; i<this.length; i++)
if(this[i]!=null && this[i]!=undefined)
those[those.length] = this[i];
return those;
}
// IE is the worste browser
if(!Array.prototype.map)
Array.prototype.map = function(fn, scope){
scope = scope || window;
var r = [];
for(var i = 0; i < this.length; i++)
r[r.length] = fn.call(scope, this[i], i, this);
return r;
};
// avoid error if browser doesn't have console.log
if(!window.console) console = {log:function(){}};
</script>
<script type="text/javascript" src="JSON.js"></script>
<script type="text/javascript" src="myOT.js"></script>
<script type="text/javascript" src="cases.js"></script>
<script type="text/javascript" src="cases.execution.js"></script>
<script type="text/javascript" src="ui.js"></script>
</head>
<body>
<div class="case_params">
<div class="buttons">
switch case:
<select id="cases">
</select>
<input type="button" value="Add random case" onclick="javascript: toggleRandomCaseParams()">
<input type="button" value="Add blank case" onclick="javascript: addBlankCase()">
<input type="button" value="Add blank user" onclick="javascript: addBlankUser()">
<input type="button" value="Execute case" onclick="javascript: executeCase(document.getElementById('cases').value)">
<input type="checkbox" onclick="javascript: log_op = this.checked? log_on:log_off" style="border:none;"/>Enable Log
<div id="random_case">
<label for="ops">operations number<input type="text" id="nops"/></label>
<label for="users">users number<input type="text" id="nusers"/></label><br/>
<label for="pinsert">insert percentage<input type="text" id="pinsert"/></label>
<label for="pdelete">delete percentage<input type="text" id="pdelete"/></label><br/>
<input type="button" value="Add case" onclick="javascript: addRandomCase()"/>
</div>
</div>
<div>
<label class="ops_list" for="ops_list">ops list:<br/><textarea id='ops_list'></textarea></label>
<label for="init_text">initial text: <br/><textarea id='init_text'></textarea></label><br/>
<label for="exp_text">expected text: <br/><textarea id='exp_text' onchange="javascript: document.getElementById('recheck').style.display='block'"></textarea></label><br/>
<input id="recheck" type="button" value="re-check" onclick="javascript: recheck(); this.style.display='none'"/><br/>
<label id="gen_time_info">generation time:<input class="time" id="gen_time" type="text"/></label>
<label id="corr_exec_info">correct executions:<input class="time" id="corr_exec" type="text"/></label>
<label id="avg_time_info">average exec time:<input class="time" id="avg_time" type="text"/></label>
</div>
</div>
<div id="users">
</div>
<script type="text/javascript"> uiComplete() </script>
</body>
</html>