Skip to content

Instantly share code, notes, and snippets.

@joelewis
Last active December 11, 2015 04:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joelewis/4547256 to your computer and use it in GitHub Desktop.
Save joelewis/4547256 to your computer and use it in GitHub Desktop.
A javascript bookmarklet for recording your progress with the online book you are going through, and share it in your wordpress for future reference. //In chrome, click bookmark icon, choose edit and place this code in the 'url' space. //Now, you can click the bookmark whenever you want to log your current online book's progress in your wordpres…
javascript: var d=document,w=window,e=w.getSelection,k=d.getSelection,x=d.selection,s=(e?e():(k)?k():(x?x.createRange().text:0));
url=d.location.href, urlsplit=url.split('/'); urlstring="";
function cal(){for(i=1;i<(urlsplit.length-1);i++){ urlstring += urlsplit[i]+' | ';}}
cal();
poc = document.body.scrollTop/(document.body.clientHeight-window.innerHeight)*100;
poc = Math.ceil(poc);
poc = poc.toString();
s=s.toString();
s += "\n"+" I completed "+poc+"% of chapter-"+urlsplit[urlsplit.length-1].split('.')[0]+", in the book, "+"\""+urlstring+"\""+"<i> published via <a href='http://joelewis.github.com/readlog.html'>ReadLog</a></i>";
/*
use this when you distribute this bookmark to serveral people, otherwise just modify the str variable to point to your url.
that's it. */
// uname = prompt("wordpress.com username?","joelevis");
// str='http://'+uname+'.wordpress.com/wp-admin/press-this.php';
str='http://joelevis.wordpress.com/wp-admin/press-this.php'; //otherwise simply edit this line
f=str,l=d.location,e=encodeURIComponent,u=f+'?u='+e(l.href)+'&t='+e(urlstring)+'&s='+e(s)+'&v=4';a=function(){if(!w.open(u,'t','toolbar=0,resizable=1,scrollbars=1,status=1,width=570,height=370'))l.href=u;};if (/Firefox/.test(navigator.userAgent)) setTimeout(a, 0); else a();void(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment