summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authordavehauenstein <davehauenstein@d4e419ec-0920-11de-bbfd-a7c1bc4c261e>2009-04-15 22:06:42 +0000
committerdavehauenstein <davehauenstein@d4e419ec-0920-11de-bbfd-a7c1bc4c261e>2009-04-15 22:06:42 +0000
commitc53d8d026021f97075fb2f4940ba22793c38fb6e (patch)
treec5d7865bc0fd226ecc7525d7de8a1d0b0c5c89fd /js
parenta414fcee8e7dc733443c6a971162d0dd9d0e723f (diff)
downloadreadability-simple-c53d8d026021f97075fb2f4940ba22793c38fb6e.tar.bz2
readability-simple-c53d8d026021f97075fb2f4940ba22793c38fb6e.zip
added toolbar; functionality includes refresh button to get back to original page, print article, email a link to the article with a personal note
git-svn-id: http://arc90labs-readability.googlecode.com/svn/trunk@31 d4e419ec-0920-11de-bbfd-a7c1bc4c261e
Diffstat (limited to 'js')
-rwxr-xr-xjs/readability.js56
1 files changed, 49 insertions, 7 deletions
diff --git a/js/readability.js b/js/readability.js
index 934ffb8..97cd2bb 100755
--- a/js/readability.js
+++ b/js/readability.js
@@ -1,9 +1,12 @@
-var readabilityVersion = "0.3";
+var readabilityVersion = "0.4";
+var emailSrc = 'http://lab.arc90.com/experiments/readability/email.php';
+var iframeLoads = 0;
(function(){
var objOverlay = document.createElement("div");
var objinnerDiv = document.createElement("div");
-
+ var articleTools = document.createElement("DIV");
+
objOverlay.id = "readOverlay";
objinnerDiv.id = "readInner";
@@ -12,7 +15,20 @@ var readabilityVersion = "0.3";
objOverlay.className = readStyle;
objinnerDiv.className = readMargin + " " + readSize;
+ // Set up tools widget
+
+ // NOTE THE IMAGE URL'S HERE !!!!!!!!!!!!!!!!!
+ // NOTE THE IMAGE URL'S HERE !!!!!!!!!!!!!!!!!
+ // NOTE THE IMAGE URL'S HERE !!!!!!!!!!!!!!!!!
+ articleTools.id = "readTools";
+ articleTools.innerHTML = "\
+ <a href='#' onclick='return window.location.reload()'><img src='http://lab.arc90.com/experiments/readability/images/read-refresh.png' title='Reload original page'></a>\
+ <a href='#' onclick='javascript:window.print();'><img src='http://lab.arc90.com/experiments/readability/images/read-print.png' title='Print page'></a>\
+ <a href='#' onclick='emailBox(); return false;'><img src='http://lab.arc90.com/experiments/readability/images/read-email.png' title='Email page'></a>\
+ ";
+
objinnerDiv.appendChild(grabArticle()); // Get the article and place it inside the inner Div
+ objOverlay.appendChild(articleTools);
objOverlay.appendChild(objinnerDiv); // Insert the inner div into the overlay
// For totally hosed HTML, add body node that can't be found because of bad HTML or something.
@@ -113,25 +129,24 @@ function grabArticle() {
topDiv = clean(topDiv, "h2");
topDiv = clean(topDiv, "iframe");
+
// Add the footer and contents:
articleFooter.id = "readFooter";
articleFooter.innerHTML = "\
<a href='http://www.arc90.com'><img src='http://lab.arc90.com/experiments/readability/images/footer.png'></a>\
<div class='footer-right' >\
- <a href='#' onclick='return window.location.reload()'>Reload Page &raquo;</a>\
<span class='version'>Readability version " + readabilityVersion + "</span>\
</div>\
";
-
+
articleContent.appendChild(topDiv);
articleContent.appendChild(articleFooter);
-
+
return articleContent;
}
// Get the inner text of a node - cross browser compatibly.
-function getInnerText(e)
-{
+function getInnerText(e) {
if (navigator.appName == "Microsoft Internet Explorer")
return e.innerText;
else
@@ -210,3 +225,30 @@ function clean(e, tags, minWords) {
return e;
}
+function emailBox() {
+ var emailContainer = document.getElementById('email-container');
+ if(null != emailContainer)
+ {
+ return;
+ }
+
+ var emailContainer = document.createElement('div');
+ emailContainer.setAttribute('id', 'email-container');
+ emailContainer.innerHTML = '<iframe src="'+emailSrc + '?pageUrl='+escape(window.location)+'&pageTitle='+escape(document.title)+'" scrolling="no" onload="removeFrame()" style="width:480px; height: 460px; border: 0;"></iframe>';
+
+ document.body.appendChild(emailContainer);
+}
+
+function removeFrame()
+{
+ ++iframeLoads;
+ if(iframeLoads >= 6)
+ {
+ var emailContainer = document.getElementById('email-container');
+ if(null != emailContainer) {
+ emailContainer.parentNode.removeChild(emailContainer);
+ }
+ // reset the count
+ iframeLoads = 0;
+ }
+} \ No newline at end of file