Skip to content

Instantly share code, notes, and snippets.

@derekjohnson
Last active December 14, 2015 05:59
Show Gist options
  • Select an option

  • Save derekjohnson/5039415 to your computer and use it in GitHub Desktop.

Select an option

Save derekjohnson/5039415 to your computer and use it in GitHub Desktop.

Revisions

  1. derekjohnson revised this gist Feb 26, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion markers.js
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    (function(doc){
    if(doc.querySelectorAll) { // This only works in IE 8+
    var copy = doc.querySelectorAll('.string')
    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) {
  2. derekjohnson revised this gist Feb 26, 2013. 1 changed file with 15 additions and 15 deletions.
    30 changes: 15 additions & 15 deletions markers.js
    Original file line number Diff line number Diff line change
    @@ -1,21 +1,21 @@
    (function(doc){
    if(doc.querySelectorAll) { // This only works in IE 8+
    var copy = doc.querySelectorAll('.string')
    , i = 0
    , ii = copy.length
    , replace_at = function(text, index, char) {
    return text.substr(0, index) + char + text.substr(index + 1);
    }
    ;
    if(doc.querySelectorAll) { // This only works in IE 8+
    var copy = doc.querySelectorAll('.string')
    , 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;
    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
    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;
    }
    copy[i].textContent = text;
    }
    }
    })(document);
  3. derekjohnson created this gist Feb 26, 2013.
    21 changes: 21 additions & 0 deletions markers.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    (function(doc){
    if(doc.querySelectorAll) { // This only works in IE 8+
    var copy = doc.querySelectorAll('.string')
    , 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);