Created
September 17, 2015 21:56
-
-
Save geekdinazor/4d4b08afe76fe060a92e to your computer and use it in GitHub Desktop.
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
function replacer (numpost) | |
{ | |
while (numpost>=1) | |
{ | |
if (!document.getElementById(numpost)) | |
{ | |
alert(numpost+"th post is missing! Please contact the webmaster.") | |
numpost-- ; | |
continue; | |
} | |
var post = document.getElementById(numpost).innerHTML ; | |
var index = post.indexOf("@") ; | |
var nums = "0123456789" ; | |
var refnum = "" ; | |
if (index<0) | |
{ | |
numpost-- ; | |
continue ; | |
} | |
else | |
{ | |
var x = index+1 ; //position of the character after @ | |
while (nums.indexOf(post.charAt(x)) >= 0) | |
{ | |
refnum = refnum + post.charAt(x) ; | |
x++ ; | |
} | |
var newpost = '<a href="#' + refnum + '">@' + refnum + '</a>' ; | |
if (refnum) | |
{ | |
var old = "@" + refnum ; | |
document.getElementById(numpost).innerHTML = post.replace(old, newpost) ; | |
} | |
numpost-- ; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment