-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathset.php
300 lines (241 loc) · 9.61 KB
/
set.php
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
<?php require_once("php/lib.php"); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>test</title>
<link rel="stylesheet" type="text/css" href="php/style.css" /></link>
<script src="php/js/jquery-1.3.2.min.js"></script>
<script src="php/js/jquery.validate.js"></script>
<script src="php/js/jquery.form.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var i = <?php echo time(); ?>;
// start add row
$("#TASKS").hide();
$("#TASKS select,#TASKS input:text, input.submit").each(function(){
$(this).val($(this).attr("val"));
$(this).attr("disabled", "disabled");
});
$("#TASKS").show();
function addRow(type) {
var template = jQuery.format($("#template-"+type, null).val());
$(template(i++)).appendTo("#TASKS tbody");
two_color();
}
function two_color(){
$("#TASKS #task_tr:visible:even").css("backgroundColor",'#e7f3ff');
$("#TASKS #task_tr:visible:odd").css("backgroundColor",'#effbde');
}
// add more rows on click
$("#add").live("click", function(){
addRow($(this).val());
});
$("button, :button").live("click", function(){
$("input.submit").removeAttr("disabled");
});
// Rename TASKS
//<legend><input type="text" value="{0}. 追蹤RSS新消息" size="30"></legend>
$(":input[button=rename]").live("click" ,function(){
$legend = $(this).parent().parent().find("legend");
$text = $legend.html();
$legend.html('<input id="legendBOX" type="text" value="'+$text+'" size="30">');
$(this).parent().parent().find("#op").val("!");
$(this).attr("disabled", "disabled");
});
// DELETE TASKS
$(":input[button=delete]").live("click" ,function(){
$(this).parent().parent().fadeOut(250, function() {
if($(this).find("#op").val()=="+"){
$(this).remove();
} else {
$(this).find("#op").attr("value","-");
}
two_color();
});
});
// Modify TASKS
$(":input[button=modify]").live("click" ,function(){
$(this).parent().parent().find("select, input:text").each(function(){
$(this).removeAttr("disabled");
});
$(this).parent().parent().find("#op").val("!");
});
// AJAX POST framwork
var options = {
target: "#pre", // target element(s) to be updated with server response
beforeSubmit: before, // pre-submit callback
success: showResponse // post-submit callback
};
$("#input_form").ajaxForm(options);
function before(formData, jqForm, options) {
// To access the DOM element for the form do this:
// var formElement = jqForm[0];
while($("#legendBOX").length)
{
$BOX = $("#legendBOX");
$text = $BOX.val();
$BOX.parent().html($text);
}
//var queryString = $.param(formData);
//alert('About to submit: \n\n' + queryString);
return true;
}
// post-submit callback
function showResponse(responseText, statusText) {
//alert('status: ' + statusText + '\n\nresponseText: \n' + responseText +
// '\n\nThe output div should have already been updated with the responseText.');
/* delete */
$("#TASKS tr:hidden").each(function(){$(this).remove();});
/* backup selected to "val" */
$("#TASKS tbody select").each(function(){
$(this).attr("val",$(this).find(":selected").val());
});
/* backup text to "val" */
$("#TASKS tbody input:text").each(function(){
$(this).attr("val",$(this).val());
});
/* lock submit & inputs */
$("#TASKS select, #TASKS input:text, input.submit").each(function(){
$(this).attr("disabled", "disabled");
});
$(":input[button=rename]").removeAttr("disabled");
$("#TASKS").find("#op").each(function(){
$(this).attr("value","=");
});
/* post cache */
$.post('php/cache.php',{ text: $("#TASKS tbody").html() }, function(txt){ });
}
});
</script>
</head>
<body>
<pre id="pre">
<?php
// read cache
//print_r($b);
?>
</pre>
<button id="add" value="cmd">新增 自訂命令</button>
<button id="add" value="rss">新增 RSS訂閱</button>
<button id="add" value="you">新增 youtube訂閱</button>
<form id="input_form" class="cmxform" method="post" action="php/commit.php">
<table id="TASKS">
<tbody>
<?php
$CACHE = @file_get_contents("php/UIcache/cache.html");
if($CACHE != null){
$CACHE = str_replace('\"', '"', $CACHE);//unescape quote
printf($CACHE,FILE_BINARY);
}
?>
</tbody>
<tfoot>
<tr>
<td id="td"><input class="submit" type="submit" value="送出"/></td>
</tr>
</tfoot>
</table>
</form>
<textarea style="display:none" id="template-cmd">
<tr id="task_tr">
<td id="td" class="td_input">
<fieldset>
<legend>{0}. 自訂命令執行</legend>
<!--label>{0}. Item</label-->
<input type="hidden" name="Task{0}[type]" value="CMD" >
<input type="hidden" name="Task{0}[id]" value="{0}" >
<input type="hidden" id="op" name="Task{0}[op]" value="+" >
<SELECT NAME="Task{0}[month]">
<OPTION VALUE ='*'>每月</OPTION>
<?php makeOption(1, 12, null, "月"); ?>
</SELECT>
<SELECT NAME="Task{0}[day]">
<OPTION VALUE ='*'>每日</OPTION>
<?php makeOption(1, 31, null, "號"); ?>
</SELECT>
<SELECT NAME="Task{0}[week]">
<OPTION VALUE ='*'>每日</OPTION>
<?php makeWeekOption();?>
</SELECT>
<SELECT NAME="Task{0}[hour]">
<OPTION VALUE ='*'>每時</OPTION>
<?php makeOption(0, 23, null, "時"); ?>
</SELECT>
<SELECT NAME="Task{0}[minute]">
<OPTION VALUE ='*'>每分</OPTION>
<?php makeOption(0, 59, null, "分"); ?>
</SELECT>
<br>執行指令:<input type="text" autocomplete="off" name="Task{0}[cmd]" size="45" />
</fieldset>
</td>
<td id="td">
<input button="rename" value="改標題" type="button"><br>
<input button="delete" value="刪除" type="button"><br>
<input button="modify" value="重新修改" type="button">
</td>
<td id="td">
<a href="data/{0}" target="data">瀏覽</a>
</td>
</tr>
</textarea>
<textarea style="display:none" id="template-rss">
<tr id="task_tr" >
<td id="td" class="td_input">
<fieldset>
<legend>{0}. 追蹤RSS新消息</legend>
<input type="hidden" name="Task{0}[type]" value="RSS" >
<input type="hidden" name="Task{0}[id]" value="{0}" >
<input type="hidden" id="op" name="Task{0}[op]" value="+" >
更新週期:
<SELECT NAME="Task{0}[circle]">
<OPTION VALUE ="*/30 * * * *">每30分鐘</OPTION>
<OPTION VALUE ="0 * * * *">每1小時</OPTION>
<OPTION VALUE ="0 */3 * * *">每3小時</OPTION>
<OPTION VALUE ="0 */6 * * *">每6小時</OPTION>
<OPTION VALUE ="0 0,12 * * *">每12小時</OPTION>
<OPTION VALUE ="0 0 * * *">每日</OPTION>
<OPTION VALUE ="0 0 * * 1">每周</OPTION>
</SELECT>
<br>RSS網址: <input type="text" autocomplete="off" name="Task{0}[url]" size="45" />
</fieldset>
</td>
<td id="td">
<input button="rename" value="改標題" type="button"><br>
<input button="delete" value="刪除" type="button"><br>
<input button="modify" value="重新修改" type="button">
</td>
<td id="td">
<a href="data/{0}" target="data">瀏覽</a>
</td>
</tr>
</textarea>
<textarea style="display:none" id="template-you">
<tr id="task_tr" >
<td id="td" class="td_input">
<fieldset>
<legend>{0}. 訂閱youtube</legend>
<input type="hidden" name="Task{0}[type]" value="YOU" >
<input type="hidden" name="Task{0}[id]" value="{0}" >
<input type="hidden" id="op" name="Task{0}[op]" value="+" >
訂閱節目:
<SELECT NAME="Task{0}[search]">
<OPTION VALUE ="我愛黑澀會+2009-06-17">我愛黑澀會</OPTION>
<OPTION VALUE ="模范棒棒堂+2009-06-17">模范棒棒堂</OPTION>
<OPTION VALUE ="康熙來了+2009-06-17">康熙來了</OPTION>
<OPTION VALUE ="2009-06-06+我猜我猜我猜猜猜">我猜我猜我猜猜猜</OPTION>
</SELECT>
</fieldset>
</td>
<td id="td">
<input button="rename" value="改標題" type="button"><br>
<input button="delete" value="刪除" type="button"><br>
<input button="modify" value="重新修改" type="button">
</td>
<td id="td">
<a href="data/{0}" target="data">瀏覽</a>
</td>
</tr>
</textarea>
</body>
</html>