-
Notifications
You must be signed in to change notification settings - Fork 1
/
chmod.html
167 lines (166 loc) · 5.95 KB
/
chmod.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>CHMOD ONLINE EMULATOR</title>
<meta content="width=device-width, initial-scale=1.0" name="viewport" />
<meta content="CHMOD ONLINE EMULATOR" name="description" />
<!-- Twitter Bootstrap -->
<link href="http://twitter.github.com/bootstrap/assets/css/bootstrap.css" rel="stylesheet" />
<style type="text/css">
body {
padding-top: 60px;
padding-bottom: 40px;
} </style>
<!--[if lt IE 9]>
<script src="http://cdnjs.cloudflare.com/ajax/libs/html5shiv/r29/html5.js"></script>
<![endif]--><script type="text/javascript">
/*
Jeroen's Chmod Calculator- By Jeroen Vermeulen of Alphamega Hosting <jeroen@alphamegahosting.com>
Visit http://www.javascriptkit.com for this script and more
This notice must stay intact
*/
function octalchange()
{
var val = document.chmod.t_total.value;
var ownerbin = parseInt(val.charAt(0)).toString(2);
while (ownerbin.length<3) { ownerbin="0"+ownerbin; };
var groupbin = parseInt(val.charAt(1)).toString(2);
while (groupbin.length<3) { groupbin="0"+groupbin; };
var otherbin = parseInt(val.charAt(2)).toString(2);
while (otherbin.length<3) { otherbin="0"+otherbin; };
document.chmod.owner4.checked = parseInt(ownerbin.charAt(0));
document.chmod.owner2.checked = parseInt(ownerbin.charAt(1));
document.chmod.owner1.checked = parseInt(ownerbin.charAt(2));
document.chmod.group4.checked = parseInt(groupbin.charAt(0));
document.chmod.group2.checked = parseInt(groupbin.charAt(1));
document.chmod.group1.checked = parseInt(groupbin.charAt(2));
document.chmod.other4.checked = parseInt(otherbin.charAt(0));
document.chmod.other2.checked = parseInt(otherbin.charAt(1));
document.chmod.other1.checked = parseInt(otherbin.charAt(2));
calc_chmod(1);
};
function calc_chmod(nototals)
{
var users = new Array("owner", "group", "other");
var totals = new Array("","","");
var syms = new Array("","","");
for (var i=0; i<users.length; i++)
{
var user=users[i];
var field4 = user + "4";
var field2 = user + "2";
var field1 = user + "1";
//var total = "t_" + user;
var symbolic = "sym_" + user;
var number = 0;
var sym_string = "";
if (document.chmod[field4].checked == true) { number += 4; }
if (document.chmod[field2].checked == true) { number += 2; }
if (document.chmod[field1].checked == true) { number += 1; }
if (document.chmod[field4].checked == true) {
sym_string += "r";
} else {
sym_string += "-";
}
if (document.chmod[field2].checked == true) {
sym_string += "w";
} else {
sym_string += "-";
}
if (document.chmod[field1].checked == true) {
sym_string += "x";
} else {
sym_string += "-";
}
//if (number == 0) { number = ""; }
//document.chmod[total].value =
totals[i] = totals[i]+number;
syms[i] = syms[i]+sym_string;
};
if (!nototals) document.chmod.t_total.value = totals[0] + totals[1] + totals[2];
document.chmod.sym_total.value = "-" + syms[0] + syms[1] + syms[2];
}
window.onload=octalchange
//-->
</script>
</head>
<body>
<div class="container">
<div class="hero-unit">
<h1>
CHMOD ONLINE EMULATOR</h1>
<p>
A nice way to practice chmod</p>
</div>
<div class="row show-grid">
<div class="span8 offset4">
Permissions:
<form name="chmod">
<table>
<tbody>
<tr align="LEFT" valign="MIDDLE">
<td>
</td>
<td>
<input maxlength="3" name="t_total" onkeyup="octalchange()" type="text" value="751" /></td>
<td>
<input name="sym_total" readonly="1" size="12" type="text" value="" /></td>
</tr>
</tbody>
</table>
<br />
<table border="0" cellpadding="2" cellspacing="0">
<tbody>
<tr bgcolor="#333333">
<td align="left" width="60">
</td>
<td align="center" style="color:white" width="55">
<b>owner </b></td>
<td align="center" style="color:white" width="55">
<b>group </b></td>
<td align="center" style="color:white" width="55">
<b>other </b></td>
</tr>
<tr bgcolor="#dddddd">
<td align="left" bgcolor="#FFFFFF" nowrap="nowrap" width="60">
read</td>
<td align="center" bgcolor="#EEEEEE" width="55">
<input name="owner4" onclick="calc_chmod()" type="checkbox" value="4" /></td>
<td align="center" bgcolor="#ffffff" width="55">
<input name="group4" onclick="calc_chmod()" type="checkbox" value="4" /></td>
<td align="center" bgcolor="#EEEEEE" width="55">
<input name="other4" onclick="calc_chmod()" type="checkbox" value="4" /></td>
</tr>
<tr bgcolor="#dddddd">
<td align="left" bgcolor="#FFFFFF" nowrap="nowrap" width="60">
write</td>
<td align="center" bgcolor="#EEEEEE" width="55">
<input name="owner2" onclick="calc_chmod()" type="checkbox" value="2" /></td>
<td align="center" bgcolor="#ffffff" width="55">
<input name="group2" onclick="calc_chmod()" type="checkbox" value="2" /></td>
<td align="center" bgcolor="#EEEEEE" width="55">
<input name="other2" onclick="calc_chmod()" type="checkbox" value="2" /></td>
</tr>
<tr bgcolor="#dddddd">
<td align="left" bgcolor="#FFFFFF" nowrap="nowrap" width="60">
execute</td>
<td align="center" bgcolor="#EEEEEE" width="55">
<input name="owner1" onclick="calc_chmod()" type="checkbox" value="1" /></td>
<td align="center" bgcolor="#ffffff" width="55">
<input name="group1" onclick="calc_chmod()" type="checkbox" value="1" /></td>
<td align="center" bgcolor="#EEEEEE" width="55">
<input name="other1" onclick="calc_chmod()" type="checkbox" value="1" /></td>
</tr>
</tbody>
</table>
</form>
</div>
</div>
<footer>
<p>
© VeneHosting.com 2012</p>
</footer>
</div>
</body>
</html>