-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
111 lines (108 loc) · 2.16 KB
/
index.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Randomize</title>
<style>
body{
font-family: sans-serif;
font-size:13px;
text-align: center;
}
form{
display:block;
width:203px;
margin:0 auto;
}
select{
display:block;
float: left;
width:100px;
margin:0;
text-align: center;
line-height: 20px;
height: 174px;
overflow: hidden;
border:1px solid #000;
}
option{
padding:0;
line-height: 17px;
height: 17px;
}
#result{
display:block;
float: left;
width:100px;
margin:0;
height: 172px;
overflow: hidden;
border:1px solid #000;
border-left-width:0;
}
#result ul{
display:block;
float: left;
width:100%;
margin:0;
padding:0;
list-style: none;
}
#result ul li{
display:block;
margin:0;
height: 17px;
overflow: hidden;
}
button{
margin-top:10px;
}
</style>
</head>
<body>
<h1>Randomize Array</h1>
<form>
<select multiple>
<option selected value="elt01">elt01</option>
<option selected value="elt02">elt02</option>
<option selected value="elt03">elt03</option>
<option selected value="elt04">elt04</option>
<option selected value="elt05">elt05</option>
<option value="elt06">elt06</option>
<option value="elt07">elt07</option>
<option value="elt08">elt08</option>
<option value="elt09">elt09</option>
<option value="elt10">elt10</option>
</select>
<div id="result"></div>
<button>Randomize selection</button>
</form>
<script src="js/jquery-1.11.1.min.js"></script>
<script src="src/randomize.js"></script>
<script>
function randomVal(elt){
var container = elt || $('select'),
values = container.val(),
result = '';
if(values){
var randomValues = randomize(values),
result = $('<ul />');
for(var i = 0, lgth = randomValues.length; i < lgth; i++){
result.append('<li>'+randomValues[i]+'</li>');
}
$('#result').html(result);
}
}
$(document).ready(function(){
randomVal();
$('select').on('change', function(){
randomVal($(this));
});
$('button').on('click', function(e){
e.preventDefault();
randomVal();
});
});
</script>
</body>
</html>