Warning: this is an htmlized version!
The original is here, and the conversion rules are here. |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>$TITLE</title> </head> <body> <h3>$TITLE</h3> <script> // _ _ _ // __ _(_) __| | ___ ___ (_)___ // \ \ / / |/ _` |/ _ \/ _ \ | / __| // \ V /| | (_| | __/ (_) | | \__ \ // \_/ |_|\__,_|\___|\___/ _/ |___/ // |__/ // // JavaScript code for handling indexes of videos, // possibly with links to local copies in MP4 format // From: http://angg.twu.net/blogme3/local-videos-mini.js.html // (find-blogme3 "local-videos-mini.js") // See: http://angg.twu.net/ferramentas-para-ativistas.html // (find-TH "ferramentas-para-ativistas") // http://angg.twu.net/linkdasruas.html // Author: Eduardo Ochs <eduardoochs@gmail.com> // Version: 2014jul13 // eltbyid = function (id) { return document.getElementById(id); } from_textarea = function (id) { return eltbyid(id).value; } from_pre = function (id) { return eltbyid(id).innerHTML; } to_textarea = function (id, txt) { eltbyid(id).innerHTML = txt; } to_pre = function (id, txt) { eltbyid(id).innerHTML = txt; } function href0 (tgt, text) { return '<a href="'+tgt+'">' + text + '</a>'; } function href (tgt, text) { return tgt ? href0(tgt, text) : text; } // escape_re = /[\x0f&<>"']/g; // escape_table = { // '&': '&', // '<': '<', // '>': '>', // '"': '"', // "'": ''', // "\x0f": '<font color="red"><strong>*</strong></font>' // } escape_re = /[\x0f]/g; escape_table = { "\x0f": '<font color="red"><strong>*</strong></font>' } escape = function (str) { return str.replace(escape_re, function (c) { return escape_table[c] || c; }); } yt_mp4s = {} yt_mp4_re = /(...........)\.mp4$/ yt_hash_re = /[?&]v=([^ &]+)/ yt_line_re = /^(.*)(https?:\/\/www.youtube[^ ]*)( *)(.*)$/ function yt_extract_mp4s(bigstr) { // process and remove the mp4 lines from str var f = function (line) { line = line.replace(/\n/g, ""); var A = line.match(yt_mp4_re); if (A) { yt_mp4s[A[1]] = line; // put in yt_mp4a return ""; } else { return line + "\n"; } } // f = function (s) { var p = "("+s+")"; alert(p); return p; } return bigstr.replace(/([^\n]+)\n/g, f); } function yt_hash (str) { var A = str.match(yt_hash_re); if (A) { return A[1]; } } function yt_line_parse (str) { var A = str.match(yt_line_re); if (A) { var all=A[0], a=A[1], url=A[2], b=A[3], title=A[4]; var hash = yt_hash(url); if (hash) { return {'all':all, 'a':a, 'url':url, 'b':b, 'title':title, 'hash':hash}; } } } function yt_url (hash) { return "http://www.youtube.com/watch?v="+hash; } function yt_ytlink_html (hash) { return "("+href(yt_url(hash), "YT")+")"; } function yt_title_html (h, t) { return href(yt_mp4s[h], escape(t)); } function yt_line_html (line) { var A = yt_line_parse(line) if (A) { return A.a + yt_ytlink_html(A.hash) + A.b + yt_title_html(A.hash, A.title); } } url_line_re = /^(.*)(https?:\/\/[!-~]*)(.*)$/ url_line_html = function (line) { var A = line.match(url_line_re); if (A) { var all=A[0], a=A[1], url=A[2], b=A[3]; return escape(a)+href(url, url)+escape(b); } } yt_htmlize0 = function (bigstr) { var f = function (li) { return yt_line_html(li) || url_line_html(li) || li; } return yt_extract_mp4s(bigstr).replace(/[^\n]+/g, f); } yt_htmlize = function (bigstr) { yt_mp4s={}; return yt_htmlize0(bigstr); } yt_htmlize_pre = function (pre_id) { to_pre(pre_id, yt_htmlize(from_pre(pre_id))); } // Typical uses: // to_pre('output_a',yt_htmlize(from_textarea('input_a'))); // to_pre('my_pre_a',yt_htmlize(from_pre('my_pre_a'))); // youtube_activate0 = function (bigstr, f) { // return bigstr.replace(/[^\n]+/g, (f || youtube_line)); // } // youtube_activate = function (id, f) { // var elt = document.getElementById(id); // // elt.innerHTML = youtube_activate0(elt.innerText, f); // elt.innerHTML = youtube_activate0(elt.textContent, f); // } </script> <!-- ! _ _ ! __ _(_) __| | ___ ___ ___ ! \ \ / / |/ _` |/ _ \/ _ \/ __| ! \ V /| | (_| | __/ (_) \__ \ ! \_/ |_|\__,_|\___|\___/|___/ ! !--> <pre id="link_das_ruas"> $TXT $LST </pre> <script> yt_htmlize_pre("link_das_ruas") </script> </body> </html>