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
306
307
|
<!doctype html public "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd">
<html>
<head>
<title>
Overview
</title>
<link rel ="stylesheet" type="text/css" href="stylesheet.css" title="Style">
<script>
function asd() {
parent.document.title="offline-support.js Overview";
}
</script>
</head>
<body bgcolor="white" onload="asd();">
<!-- ========== START OF NAVBAR ========== -->
<a name="navbar_top"><!-- --></a>
<table border="0" width="100%" cellpadding="1" cellspacing="0">
<tr>
<td colspan=2 bgcolor="#EEEEFF" class="NavBarCell1">
<a name="navbar_top_firstrow"><!-- --></a>
<table border="0" cellpadding="0" cellspacing="3">
<tr align="center" valign="top">
<td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="overview-summary.html"><font class="NavBarFont1"><b>Overview</b></font></a> </td>
<td bgcolor="#FFFFFF" class="NavBarCell1Rev"> <font class="NavBarFont1Rev"><b>File</b></font> </td>
<td bgcolor="#FFFFFF" class="NavBarCell1"> <font class="NavBarFont1">Class</font> </td>
<td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a> </td>
<td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a> </td>
<td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a> </td>
</tr>
</table>
</td>
<td bgcolor="#EEEEFF" align="right" valign="top">
<em>
<b></b></em>
</td>
</tr>
<tr>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
PREV
NEXT</font></td>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
<a href="index.html" target="_top"><b>FRAMES</b></a>
<a href="overview-summary.html" target="_top"><b>NO FRAMES</b></a>
<script>
<!--
if(window==top) {
document.writeln('<A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>');
}
//-->
</script>
<noscript>
<a href="allclasses-noframe.html" target=""><b>All Classes</b></a>
</noscript>
</font></td>
</tr>
</table>
<!-- =========== END OF NAVBAR =========== -->
<hr>
<center>
<h2>offline-support.js</h2>
</center>
<h4>Summary</h4>
<p>
No overview generated for 'offline-support.js'<BR/><BR/>
</p>
<hr>
<!-- ========== METHOD SUMMARY =========== -->
<!-- ========== END METHOD SUMMARY =========== -->
<pre class="sourceview"><span class="comment">/*jslint onevar: false, browser: true, evil: true, laxbreak: true, undef: true, nomen: true, eqeqeq: true, bitwise: true, maxerr: 1000, immed: false, white: false, plusplus: false, regexp: false, undef: false */</span>
<span class="comment">/*global jetpack */</span>
<span class="comment">// Released under the MIT/X11 license</span>
<span class="comment">// http://www.opensource.org/licenses/mit-license.php</span>
<span class="literal">"use strict"</span>;
<span class="comment">/* Offline supporting functions */</span>
<span class="comment">/**
*
* <span class="attrib">@todo</span> FIXME this probably makes a closure and a memory leak name='changeform'
* investigate
* https://developer.mozilla.org/en/How_to_Turn_Off_Form_Autocompletion
*
* <form method="post" action="process_bug.cgi" autocomplete="off">
*
* Reading
* http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#h-17.13
* random notes: - 17.13.3 provides all steps necessary - enctype !=
* application/x-www-form-urlencoded => SHOULD fails (no further questions
* needed) - http://www.w3.org/MarkUp/html-spec/html-spec_8.html#SEC8.2.1. is
* nice explanation (albeit quite dated) - on multiple values
* http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#h-17.6.1 -
* příliš jednoduché
* http://www.innovation.ch/java/HTTPClient/emulating_forms.html -
*/</span>
RHBugzillaPage.<span class="reserved">prototype</span>.serializeForm = <span class="reserved">function</span>(form) {
var serialForm = {
dataOut : <span class="literal">""</span>,
name : form.name,
method : form.method,
acceptCharset : form.acceptCharset,
action : form.action, <span class="comment">// TODO shouldn't we get a non-relative URL?</span>
enctype : form.enctype,
cookie : <span class="reserved">this</span>.doc.cookie,
autocomplete : form.getAttribute(<span class="literal">"autocomplete"</span>),
bugNo : <span class="reserved">this</span>.bugNo
};
<span class="reserved">function</span> genURIElement(sName, sValue) {
<span class="reserved">return</span> encodeURIComponent(sName) + <span class="literal">"="</span> + encodeURIComponent(sValue);
}
<span class="comment">/**
* <span class="attrib">@param</span> o
* control to be serialized
* <span class="attrib">@return</span> String with the serialized control
*/</span>
<span class="reserved">function</span> serializeControl(element) {
var val = element.value;
<span class="comment">// console.log("val.toSource() = " + val.toSource());</span>
<span class="comment">/*
* on HTMLSelectElement we have an attribute 'type' of type DOMString,
* readonly The type of this form control. This is the string
* "select-multiple" when the multiple attribute is true and the string
* "select-one" when false.
*/</span>
<span class="reserved">if</span> ((val == null) || (val == undefined) || (val == <span class="literal">""</span>)) {
<span class="reserved">return</span>;
} <span class="reserved">else</span> <span class="reserved">if</span> (val instanceof Array) {
<span class="reserved">return</span> val.map(<span class="reserved">function</span>(x) {
<span class="reserved">return</span> genURIElement(element.name, x.value);
}).join(<span class="literal">"&"</span>);
} <span class="reserved">else</span> <span class="reserved">if</span> (val instanceof String) {
<span class="reserved">return</span> genURIElement(element.name, val);
} <span class="reserved">else</span> { <span class="comment">// assume HTMLCollection</span>
<span class="reserved">return</span> Array.map(val, <span class="reserved">function</span>(x) {
<span class="reserved">return</span> genURIElement(element.name, x.value);
}).join(<span class="literal">"&"</span>);
}
}
serialForm.dataOut = Array.filter(form.elements,<span class="reserved">function</span>(el) {
<span class="reserved">return</span> !el.disabled && el.name &&
<span class="comment">// FIXME shouldn't I just add && el.value here?</span>
(el.checked || /select|textarea/i.test(el.nodeName) ||
/text|hidden|password|search/i.test(el.type));
}).map(serializeControl).join(<span class="literal">"&"</span>);
<span class="reserved">return</span> serialForm;
};
<span class="comment">//RHBugzillaPage.prototype.submitCallback = function(evt) {</span>
<span class="comment">// console.log("Submit Callback!");</span>
<span class="comment">// if (jetpack.__parent__.navigator.onLine) {</span>
<span class="comment">// var serForm = this</span>
<span class="comment">// .serializeForm(jetpack.tabs.focused.contentWindow.document.forms</span>
<span class="comment">// .namedItem("changeform"));</span>
<span class="comment">//// console.log("serForm:\n" + serForm.toSource());</span>
<span class="comment">// } else {</span>
<span class="comment">// var serForm = this</span>
<span class="comment">// .serializeForm(jetpack.tabs.focused.contentWindow.document.forms</span>
<span class="comment">// .namedItem("changeform"));</span>
<span class="comment">// myStorage.forms[this.bugNo] = serForm;</span>
<span class="comment">// evt.stopPropagation();</span>
<span class="comment">// evt.preventDefault();</span>
<span class="comment">// }</span>
<span class="comment">//};</span>
<span class="comment">/**
*
*
* Yes, this is correct, this is NOT method of RHBugzillaPage!
*/</span>
<span class="comment">/*function onlineCallback() {
function deserializeAndSend(formData) {
// FIXME notImplemented
// is it enough to just
// run XMLHttpRequest? Probably yes, this is just a form
// and this is just a HTTP request
// it is probably better to get already processed
// application/x-www-form-urlencoded
// see http://htmlhelp.com/reference/html40/forms/form.html for details
// and also https://developer.mozilla.org/en/AJAX/Getting_Started
// what's?
// https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference\
// /Global_Functions/encodeURI & co.
// this seems to be also interesting
// https://developer.mozilla.org/en/Code_snippets/Post_data_to_window
console.error("Sending bugs not implemented yet!");
return ""; // FIXME check other HTTP headers to be set
var bugID = formData.bugNo;
var req = new XMLHttpRequest();
req.open("POST", formData.action, true);
// FIXME co očekávám za odpověď? req.overrideMimeType("text/xml");
// * Accept-Encoding
// * Accept-Language
// * Accept (MIME types)
req.setRequestHeader("Connection", "keep-alive");
req.setRequestHeader("Keep-Alive", 300);
req.setRequestHeader("Content-Type", formData.enctype);
req.setRequestHeader("Referer", bugURL + bugID);
req.setRequestHeader("Accept-Charset", formData.acceptCharset);
req.setRequestHeader("Cookie", formData.cookie);
req.onreadystatechange = function(aEvt) {
if (req.readyState == 4) {
if (req.status == 200) {
console.log("Sent form for bug " + bugID);
delete myStorage.forms[bugID];
} else {
console.error("Sending form for bug " + bugID + "failed!");
}
}
};
req.send(formData.data);
}
if (myStorage.forms.length > 0) {
myStorage.forms.forEach(function(x) {
deserializeAndSend(x);
});
}
}
*/</span>
</pre>
<hr>
<!-- ========== START OF NAVBAR ========== -->
<a name="navbar_top"><!-- --></a>
<table border="0" width="100%" cellpadding="1" cellspacing="0">
<tr>
<td colspan=2 bgcolor="#EEEEFF" class="NavBarCell1">
<a name="navbar_top_firstrow"><!-- --></a>
<table border="0" cellpadding="0" cellspacing="3">
<tr align="center" valign="top">
<td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="overview-summary.html"><font class="NavBarFont1"><b>Overview</b></font></a> </td>
<td bgcolor="#FFFFFF" class="NavBarCell1Rev"> <font class="NavBarFont1Rev"><b>File</b></font> </td>
<td bgcolor="#FFFFFF" class="NavBarCell1"> <font class="NavBarFont1">Class</font> </td>
<td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a> </td>
<td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a> </td>
<td bgcolor="#EEEEFF" class="NavBarCell1"> <a href="help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a> </td>
</tr>
</table>
</td>
<td bgcolor="#EEEEFF" align="right" valign="top"><em>
<b></b></em>
</td>
</tr>
<tr>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
PREV
NEXT</font></td>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
<a href="index.html" target="_top"><b>FRAMES</b></a>
<a href="overview-summary.html" target="_top"><b>NO FRAMES</b></a>
<script>
<!--
if(window==top) {
document.writeln('<A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>');
}
//-->
</script>
<noscript>
<a href="allclasses-noframe.html" target=""><b>All Classes</b></a>
</noscript>
</font></td>
</tr>
</table>
<!-- =========== END OF NAVBAR =========== -->
<hr>
<font size="-1">
</font>
<div class="jsdoc_ctime">Documentation generated by <a href="http://jsdoc.sourceforge.net/" target="_parent">JSDoc</a> on Wed Jun 23 09:33:14 2010</div>
</body>
</html>
|