Last active
December 14, 2015 05:59
-
-
Save derekjohnson/5039415 to your computer and use it in GitHub Desktop.
Add markers to text to easily see line length when prototyping layouts.
This file contains hidden or 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
(function(doc){ | |
if(doc.querySelectorAll) { // This only works in IE 8+ | |
var copy = doc.querySelectorAll('.string') // Element(s) with class="string" need to be in markup | |
, i = 0 | |
, ii = copy.length | |
, replace_at = function(text, index, char) { | |
return text.substr(0, index) + char + text.substr(index + 1); | |
} | |
; | |
for(i; i<ii; i++) { | |
var text = copy[i].textContent; | |
text = replace_at(text, 44, '^'); // Replace 45th char with asterisk | |
text = replace_at(text, 71, '$'); // Replace 72nd char with caret | |
text = replace_at(text, 66, '*'); // Replace 66th char with asterisk | |
copy[i].textContent = text; | |
} | |
} | |
})(document); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment