aboutsummaryrefslogblamecommitdiffstats
path: root/docs/html/overview-summary-offline-support.js.html
blob: 7d8ccc7207e3881a4d716988c84d1d5c5a4e330e (plain) (tree)


















































































































































































































































































































                                                                                                                                                                                                                                                                                
<!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>&nbsp;</td>
  <td bgcolor="#FFFFFF" class="NavBarCell1Rev">	&nbsp;<font class="NavBarFont1Rev"><b>File</b></font>&nbsp;</td>
  

  <td bgcolor="#FFFFFF" class="NavBarCell1"> 	<font class="NavBarFont1">Class</font>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a>&nbsp;</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">
&nbsp;PREV&nbsp;
&nbsp;NEXT</font></td>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
  <a href="index.html" target="_top"><b>FRAMES</b></a>  &nbsp;
&nbsp;<a href="overview-summary.html" target="_top"><b>NO FRAMES</b></a>
&nbsp;&nbsp;
<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
 *
 * &lt;form method="post" action="process_bug.cgi" autocomplete="off"&gt;
 *
 * 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 =&gt; 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">"&amp;"</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">"&amp;"</span>);
        }
    }

    serialForm.dataOut = Array.filter(form.elements,<span class="reserved">function</span>(el) {
        <span class="reserved">return</span> !el.disabled &amp;&amp; el.name &amp;&amp;
            <span class="comment">// FIXME shouldn't I just add &amp;&amp; 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">"&amp;"</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 &amp; 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 &gt; 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>&nbsp;</td>
  <td bgcolor="#FFFFFF" class="NavBarCell1Rev">	&nbsp;<font class="NavBarFont1Rev"><b>File</b></font>&nbsp;</td>
  

  <td bgcolor="#FFFFFF" class="NavBarCell1"> <font class="NavBarFont1">Class</font>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a>&nbsp;</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">
&nbsp;PREV&nbsp;
&nbsp;NEXT</font></td>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
  <a href="index.html" target="_top"><b>FRAMES</b></a>  &nbsp;
&nbsp;<a href="overview-summary.html" target="_top"><b>NO FRAMES</b></a>
&nbsp;&nbsp;
<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>