forked from mds/readable
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
updated readme to include vanilla instructions, fixed a typo on the d…
…emo index.html file
- Loading branch information
Showing
6 changed files
with
154 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<html> | ||
<head> | ||
<title>Readable - A plugin for creating readable paragraphs</title> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> | ||
<meta name="description" content="Make sure your paragraphs are nice and readable with this simple little plugin. Created by Matt D. Smith" /> | ||
<meta name="HandheldFriendly" content="True" /> | ||
<meta name="MobileOptimized" content="320" /> | ||
</head> | ||
<body> | ||
<a href="javascript:(function(){document.body.appendChild(document.createElement('script')).src='http://mds.sh/readable/bookmarklet/scripts/readable-min.js';})();">Readable</a> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
// | ||
// Readable-bookmarklet.js | ||
// | ||
// Created by Matt D. Smith on 9/17/2015. | ||
// Copyright (c) 2015 Matt D. Smith. All rights reserved. | ||
// | ||
|
||
(function(){ | ||
|
||
function initMyBookmarklet() { | ||
(window.myBookmarklet = function() { | ||
|
||
// start readable | ||
var charCountShowing = false; | ||
|
||
$('span.readable').css({ | ||
"background-color": "#f45b5d", | ||
}); | ||
|
||
function addSpans(){ | ||
$('p').each(function (){ | ||
var $this = $(this); | ||
var ohtml = $(this).html(); | ||
$(this).data('ocontent', ohtml); | ||
$this.html(addReadable); | ||
}); | ||
} | ||
|
||
function addReadable(){ | ||
var text = $(this).text(); | ||
var a = text.substring(0, 45); | ||
var b = text.substring(45, 75); | ||
var c = text.substring(75, text.length); | ||
var d = a + "<span class='readable'>" + b + "</span>" + c; | ||
return d; | ||
} | ||
|
||
function toggleSpans(){ | ||
if( charCountShowing === true ){ | ||
$('p').html(function(){ | ||
var p = $(this).data('ocontent'); | ||
return p; | ||
}); | ||
charCountShowing = false; | ||
}else{ | ||
addSpans(); | ||
charCountShowing = true; | ||
} | ||
} | ||
|
||
function init(){ | ||
charCountShowing = true; | ||
addSpans(); | ||
} | ||
|
||
init(); | ||
|
||
}); | ||
} | ||
|
||
// the minimum version of jQuery we want | ||
var v = "1.3.2"; | ||
|
||
// check prior inclusion and version | ||
if (window.jQuery === undefined || window.jQuery.fn.jquery < v) { | ||
var done = false; | ||
var script = document.createElement("script"); | ||
script.src = "http://ajax.googleapis.com/ajax/libs/jquery/" + v + "/jquery.min.js"; | ||
script.onload = script.onreadystatechange = function(){ | ||
if (!done && (!this.readyState || this.readyState === "loaded" || this.readyState === "complete")) { | ||
done = true; | ||
initMyBookmarklet(); | ||
} | ||
}; | ||
document.getElementsByTagName("head")[0].appendChild(script); | ||
} else { | ||
initMyBookmarklet(); | ||
} | ||
|
||
})(); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters