blob: 927fabaa80dcff0d62796b695abafce894099473 (
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="persistent-page-mod.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>persistent-page-mod.js</h2>
</center>
<h4>Summary</h4>
<p>
No overview generated for 'persistent-page-mod.js'<BR/><BR/>
</p>
<hr>
<table border="1" cellpadding="3" cellspacing="0" width="100%">
<tr bgcolor="#CCCCFF" class="TableHeadingColor">
<td colspan=2><font size="+2">
<b>Class Summary</b>
</font></td>
</tr>
<tr bgcolor="white" class="TableRowColor">
<td width="15%"><b><a href="PersistentPageMod.html">PersistentPageMod</a></b></td>
<td> </td>
</tr>
</table>
<hr/>
<!-- ========== METHOD SUMMARY =========== -->
<!-- ========== END METHOD SUMMARY =========== -->
<pre class="sourceview">var timer = require(<span class="literal">"timer"</span>);
var self = require(<span class="literal">"self"</span>);
<span class="reserved">function</span> PersistentPageMod(window, callback) {
memory.track(<span class="reserved">this</span>);
<span class="reserved">this</span>.window = window;
<span class="reserved">this</span>.callback = callback;
<span class="reserved">this</span>.window.addEventListener(<span class="literal">"unload"</span>, <span class="reserved">this</span>, false);
<span class="reserved">this</span>.window.addEventListener(<span class="literal">"DOMSubtreeModified"</span>, <span class="reserved">this</span>, false);
<span class="reserved">this</span>.doMod();
require(<span class="literal">"unload-2"</span>).ensure(<span class="reserved">this</span>);
}
PersistentPageMod.<span class="reserved">prototype</span> = {
REPLACE_DELAY: 100,
doMod: <span class="reserved">function</span> doMod() {
try {
<span class="reserved">this</span>.callback.call(undefined, <span class="reserved">this</span>.window);
} catch (e) {
console.exception(e);
}
<span class="reserved">this</span>.timerID = null;
},
handleEvent: <span class="reserved">function</span> handleEvent(event) {
switch (event.type) {
case <span class="literal">"unload"</span>:
<span class="reserved">if</span> (event.target == <span class="reserved">this</span>.window.document)
<span class="reserved">this</span>.unload();
break;
case <span class="literal">"DOMSubtreeModified"</span>:
<span class="reserved">if</span> (<span class="reserved">this</span>.timerID == null) {
<span class="comment">// Wait a bit to do the replacing. Otherwise, we just get called</span>
<span class="comment">// tons of times in a tiny period and end up hanging the browser</span>
<span class="comment">// for a while.</span>
var self = <span class="reserved">this</span>;
<span class="reserved">this</span>.timerID = timer.setTimeout(<span class="reserved">function</span>() {self.doMod();},
<span class="reserved">this</span>.REPLACE_DELAY);
}
break;
}
},
unload: <span class="reserved">function</span> unload() {
<span class="reserved">if</span> (<span class="reserved">this</span>.timerID != null) {
timer.clearTimeout(<span class="reserved">this</span>.timerID);
<span class="reserved">this</span>.timerID = null;
}
<span class="reserved">this</span>.window.removeEventListener(<span class="literal">"DOMSubtreeModified"</span>, <span class="reserved">this</span>, false);
<span class="reserved">this</span>.window.removeEventListener(<span class="literal">"unload"</span>, <span class="reserved">this</span>, false);
}
};
require(<span class="literal">"errors"</span>).catchAndLogProps(PersistentPageMod.<span class="reserved">prototype</span>,
<span class="literal">"handleEvent"</span>);
var register = exports.register = <span class="reserved">function</span> register(window, callback) {
new PersistentPageMod(window, callback);
};
</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>
|