{"id":27,"date":"2007-06-12T09:51:43","date_gmt":"2007-06-12T13:51:43","guid":{"rendered":"http:\/\/patorjk.com\/blog\/2007\/06\/12\/more-taag-updates\/"},"modified":"2014-01-25T18:10:59","modified_gmt":"2014-01-25T22:10:59","slug":"more-taag-updates","status":"publish","type":"post","link":"https:\/\/patorjk.com\/blog\/2007\/06\/12\/more-taag-updates\/","title":{"rendered":"More TAAG Updates"},"content":{"rendered":"<p>Last night I made two major updates made to the Text Ascii Art Generator:<\/p>\n<p>&#8211; A whole crap load of fonts were uploaded, probably between 80 and 100.<br \/>\n&#8211; I added some Javascript that converted URLs into hyperlinks in the sections about the FIGlet font authors (the &#8220;Click for Info&#8221; link). I figured this would be a nice gesture toward the font authors since most people, including myself, are usually too lazy to copy and paste a URL. You can see this script in action in the information section for fonts like &#8220;AMC razor 2&#8221; and &#8220;Sub-Zero&#8221;, as well as many others. Alas, after implementing this I discovered most author&#8217;s homepages were long gone. Oh well, I still think it&#8217;s a nice addition.<\/p>\n<p>To those of you curious as to how this was implemented I used regular expressions. This changed what could have been a lot of code, into one simple line of code! Check it out:<\/p>\n<p>String.prototype.urlsToHyperlinks = function()<br \/>\n{<br \/>\n\u00a0  return this.replace(\/\\bhttp:[^ \\)\\n\\&lt;]+\/g, &#8220;&lt;a href=&#8217;$&amp;&#8217; target=&#8217;_new&#8217;&gt;$&amp;&lt;\/a&gt;&#8221;);<br \/>\n}<\/p>\n<p>And then to use it, do this:<\/p>\n<p>var urlText = &#8220;blah blah blah http:\/\/www.patorjk.com\/ blah blah blah http:\/\/www.google.com\/&#8221;;<br \/>\nvar hyperlinkedText = urlText.urlsToHyperlinks();<br \/>\nalert(hyperlinkedText);<\/p>\n<p>Feel free to use this however you want.<\/p>\n<p>If the above code just looked like a bunch of gibberish, don&#8217;t worry, regular expressions are easy to pick up. You just need to get the syntax down. Here are some links that should help you get on your feet pretty quickly:<\/p>\n<p><a href=\"http:\/\/www.webreference.com\/js\/column5\/\">http:\/\/www.webreference.com\/js\/column5\/<\/a><br \/>\n<a href=\"http:\/\/www.javascriptkit.com\/javatutors\/re.shtml\">http:\/\/www.javascriptkit.com\/javatutors\/re.shtml<\/a><br \/>\n<a href=\"http:\/\/www.w3schools.com\/jsref\/jsref_replace.asp\">http:\/\/www.w3schools.com\/jsref\/jsref_replace.asp<\/a> &#8211; Make sure you read example 4. Too many people don&#8217;t realize that about the Javascript replace function.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Last night I made two major updates made to the Text Ascii Art Generator: &#8211; A whole crap load of fonts were uploaded, probably between 80 and 100. &#8211; I added some Javascript that converted URLs into hyperlinks in the sections about the FIGlet font authors (the &#8220;Click for Info&#8221; link). I figured this would &hellip; <a href=\"https:\/\/patorjk.com\/blog\/2007\/06\/12\/more-taag-updates\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">More TAAG Updates<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-27","post","type-post","status-publish","format-standard","hentry","category-software"],"_links":{"self":[{"href":"https:\/\/patorjk.com\/blog\/wp-json\/wp\/v2\/posts\/27","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/patorjk.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/patorjk.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/patorjk.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/patorjk.com\/blog\/wp-json\/wp\/v2\/comments?post=27"}],"version-history":[{"count":1,"href":"https:\/\/patorjk.com\/blog\/wp-json\/wp\/v2\/posts\/27\/revisions"}],"predecessor-version":[{"id":2807,"href":"https:\/\/patorjk.com\/blog\/wp-json\/wp\/v2\/posts\/27\/revisions\/2807"}],"wp:attachment":[{"href":"https:\/\/patorjk.com\/blog\/wp-json\/wp\/v2\/media?parent=27"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/patorjk.com\/blog\/wp-json\/wp\/v2\/categories?post=27"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/patorjk.com\/blog\/wp-json\/wp\/v2\/tags?post=27"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}