pagepeeker
v1.0.1
Published
the ulitiry to redisplay the web page of other user
Downloads
2
Readme
Pagepeeker
A node.js+express utility can redisplay the web page that was displayed by other user.
dependency
node.js express express-session
Installation
$ npm install pagepeeker
Usage
pagepeeker
exposes two function; One of functions is the filter which can save the page contents of all sessions. The other of funcions is the router which can output the lived session list and the page contents which you want.
Example app.js:
var pagepeeker = require('pagepeeker');
/* "/seslist" is the Page URL(PageURL). */
app.use("/seslist", pagepeeker.seslist);
app.use(pagepeeker());
interface
You can access the Page URL(PageURL) to get the lived session list and the page contents.
the lived session list
The format of the list is JSON.
URL: WebURL/PageURL
the page contents
URL: WebURL/PageURL?sessionid=XXXXXXX
Example example.html:
<HTML>
<HEAD></HEAD>
<BODY>
<script language='javascript'>
function hpfresh(url) {
parent.document.getElementById('hpcon').src = url;
}
</script>
<ul>
<script lanaguage="javascript">
var http_request;
try {
// Opera 8.0+, Firefox, Chrome, Safari
http_request = new XMLHttpRequest();
} catch (e) {
// Internet Explorer Browsers
try {
http_request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
http_request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {
// Something went wrong
alert("Your browser broke!");
}
}
}
http_request.onreadystatechange = function () {
if (http_request.readyState == 4) {
// Javascript function JSON.parse to parse JSON data
var result = JSON.parse(http_request.responseText);
// jsonObj variable now contains the data structure and can
// be accessed as jsonObj.name and jsonObj.country.
for (var i = 0; i < result.length; i++) {
document.writeln("<li><a href=\"\" onclick=\"hpfresh('/seslist?sessionid=" + result[i].id
+ "')\">" + result[i].id + "</a></li>");
}
}
}
http_request.open("GET", "/seslist", true);
http_request.send();
</script>
</ul>
</BODY>
</HTML>
Authors
Hongsheng Zhang
License
(The MIT License)