-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbrutus.js
305 lines (293 loc) · 8.46 KB
/
brutus.js
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
function initialize()
{
if( document.location.href.indexOf("?") > -1 )
{
// user wants to do something interesting.
var argsString = document.location.href.split("?");
argsString = argsString[1];
var args = argsString.split("&");
var driver = {};
for ( var i = 0; i < args.length; i++ ) {
var argsplit = args[i].split("=");
driver[argsplit[0]] = argsplit[1];
}
if( driver['q'] != '' && typeof(driver['q']) != "undefined" && typeof(driver['type']) == "undefined" )
{
document.getElementById("q").value = driver['q'];
submitAjaxSearchForm(document.getElementById("searchform"));
}
if( driver['verb'] != '' )
{
// do nothing, this is handled as a state change of the document.
}
}
var body = $('body');
var termlists = body.select('div.termlist');
var i;
for(i=0;i<termlists.length;i++)
{
termlists[i].style.width = parseInt(100/termlists.length)+"%";
if( i == termlists.length-1 )
{
termlists[i].style.clear = "right";
}
}
//setTimeout("doYourPart()",5000);
}
function doYourPart()
{
window.status = "Doing your part.";
var url = global_url_prefix+"stab.php";
var ajax = new Ajax.Request(url, {method:'get',onFailure:null,asynchronous:true});
var strAjaxResult = ajax.transport.responseText;
window.status = "Done doing your part, thanks a bunch! Have a great day.";
}
function submitAjaxSearchForm( aForm )
{
var url = global_url_prefix+"ajax.php?verb=SearchResults&q="+aForm.q.value;
var ajax = new Ajax.Request(url, {method:'get',
onFailure:null,
asynchronous:false}
);
var strAjaxResult = ajax.transport.responseText;
var body = $("body");
if( body.innerHTML.strip() == "" )
{
body.innerHTML = strAjaxResult;
}
else
{
var items = body.childElements();//body.select('div');
if( items.length > 1 )
{
var i;
for(i=0;i<items.length;i++)
{
Effect.SlideUp(items[i].id, {afterFinish:function(effect){ effect.element.remove(); }} );
}
body.innerHTML = body.innerHTML+strAjaxResult;
}
else if( items.length == 1 )
{
body.innerHTML = body.innerHTML+strAjaxResult;
var firstItem = body.select("div")[0];
if( firstItem )
{
Effect.SlideUp(firstItem,{duration:1,afterFinish:function(effect){ effect.element.remove();}} );
}
}
// zero case already handled by ihtml test.
}
replaceStoredSearches();
return false;
}
function submitAjaxSearchFormExtended( aForm )
{
var url = global_url_prefix+"ajax.php?verb=SearchResults&q="+aForm.q.value+((aForm.type.value!='')?"&type="+aForm.type.value:"")+((aForm.lower.value!='')?"&lower="+aForm.lower.value:"")+((aForm.upper.value!='')?"&upper="+aForm.upper.value:"");
var ajax = new Ajax.Request(url, {method:'get',
onFailure:null,
asynchronous:false}
);
var strAjaxResult = ajax.transport.responseText;
var body = $("body");
if( body.innerHTML.strip() == "" )
{
body.innerHTML = strAjaxResult;
}
else
{
var items = body.childElements();//body.select('div');
if( items.length > 1 )
{
var i;
for(i=0;i<items.length;i++)
{
Effect.SlideUp(items[i].id, {afterFinish:function(effect){ effect.element.remove(); }} );
}
body.innerHTML = body.innerHTML+strAjaxResult;
}
else if( items.length == 1 )
{
body.innerHTML = body.innerHTML+strAjaxResult;
var firstItem = body.select("div")[0];
if( firstItem )
{
Effect.SlideUp(firstItem,{duration:1,afterFinish:function(effect){ effect.element.remove();}} );
}
}
// zero case already handled by ihtml test.
}
replaceStoredSearches();
return false;
}
function submitAjaxAccountForm(aForm)
{
if( aForm.step.value == 1 )
{
var url = global_url_prefix+"ajax.php?verb=Account&step="+aForm.step.value+"&user="+aForm.user.value+"&email="+aForm.email.value+"&reference="+aForm.reference[aForm.reference.selectedIndex].value+"&password="+aForm.password.value;
}
else
{
var url = global_url_prefix+"ajax.php?verb=Account&step="+aForm.step.value+"&confirm="+aForm.confirm.value;
}
var ajax = new Ajax.Request(url, {method:'get',
onFailure:null,
asynchronous:false});
var strAjaxResult = ajax.transport.responseText;
//window.prompt(url,strAjaxResult);
var body = $('body');
if( body.innerHTML.strip() == "" )
{
body.innerHTML = strAjaxResult;
}
else
{
body.innerHTML = body.innerHTML+strAjaxResult;
var firstItem = $("accountFormWrapper"+aForm.step.value);
if( firstItem )
{
Effect.SlideUp(firstItem,{duration:1,afterFinish:function(effect){
effect.element.remove();
}
});
}
}
return false;
}
function submitAjaxLoginForm( aForm )
{
var url = global_url_prefix+"ajax.php?verb=Authenticate";
var params = {"user":aForm.user.value,"password":aForm.password.value};
var ajax = new Ajax.Request(url, {method:'post',
onFailure:null,
parameters:params,
asynchronous:false});
var strAjaxResult = ajax.transport.responseText;
//window.prompt(url,strAjaxResult);
var body = $('loginData');
if( body.innerHTML.strip() == "" )
{
body.innerHTML = strAjaxResult;
}
else
{
body.innerHTML = body.innerHTML+strAjaxResult;
var firstItem = $("loginForm");
if( firstItem )
{
Effect.SwitchOff(firstItem,{duration:1,afterFinish:function(effect){
effect.element.remove();
}
});
}
}
return false;
}
function showDisclosedItem( anItem )
{
var telement = $(anItem);
if( telement.style.display == "none" )
{
Effect.Fade(Element.siblings(telement)[0],{duration:0.25});
Effect.Appear(telement,{duration:1.0});
}
else
{
Effect.Fade(telement,{duration:0.25});
Effect.Appear(Element.siblings(telement)[0],{duration:0.5});
}
}
function replaceStoredSearches()
{
var searches = $('searches');
var url = global_url_prefix+"ajax.php?verb=RecallStoredSearches";
var ajax = new Ajax.Request(url, {method:'get',
onFailure:null,
asynchronous:false}
);
var strAjaxResult = ajax.transport.responseText;
searches.replace(strAjaxResult);
}
function expandMessageRow( rowId )
{
//fetch rows surrounding from the database
//replace the row that we clicked on with the rows from the database.
var id = rowId.split(".");
id = id[1];
var url = global_url_prefix+"ajax.php?verb=SurroundingRows&id="+id;
var ajax = new Ajax.Request(url, {method:'get',
onFailure:null,
asynchronous:false}
);
var strAjaxResult = ajax.transport.responseText;
var element = document.getElementById(rowId);
Element.extend(element);
element.preserve = strAjaxResult;
Effect.Fade(element,{duration:0.25,afterFinish:function(effect){
Element.replace(effect.element,effect.element.preserve);}});
}
function contractMessageRows(lastId)
{
var replaceRow = document.getElementById(lastId);
var table = document.getElementById("searchResultsTable");
Element.extend(table);
var rows = Element.select(table,"tr.append");
rows.each(function(item){
if( item.id != lastId )
{
Effect.Fade(item,{duration:0.5});
//Element.extend(item); Element.remove(item);
}
});
var id = lastId.split(".");
id = id[1];
var url = global_url_prefix+"ajax.php?verb=FetchMessageRow&id="+id;
var ajax = new Ajax.Request(url, {method:'get',
onFailure:null,
asynchronous:false}
);
var strAjaxResult = ajax.transport.responseText;
Effect.Fade(replaceRow,{duration:.5,afterFinish:Element.replace(replaceRow,strAjaxResult)});
}
function submitAjaxImportCookieSearches(id, scriptFunction)
{
var url = global_url_prefix+"ajax.php?verb=ImportCookieSearches&id="+id;
var ajax = new Ajax.Request(url, {method:'get',
onFailure:null,
asynchronous:false}
);
var strAjaxResult = ajax.transport.responseText;
window.alert(strAjaxResult);
eval( scriptFunction );
return false;
}
function submitAjaxModifySearchesForm(aForm, scriptFunction)
{
var i;
var url = "";
var checkboxValuesEnable = new Array();
var checkboxValuesDisable = new Array();
for(i=0;i<aForm.length;i++)
{
if( aForm[i].type == "checkbox" )
{
if( aForm[i].checked )
{
checkboxValuesEnable[checkboxValuesEnable.length] = aForm[i].value;
}
else
{
checkboxValuesDisable[checkboxValuesDisable.length] = aForm[i].value;
}
}
}
url = global_url_prefix+"ajax.php?verb=ModifySearches&enable="+checkboxValuesEnable.join(",")+"&disable="+checkboxValuesDisable.join(",");
var ajax = new Ajax.Request(url, {method:'get',
onFailure:null,
asynchronous:false}
);
var strAjaxResult = ajax.transport.responseText;
window.alert(strAjaxResult);
eval( scriptFunction );
return false;
}