Warning: this is an htmlized version!
The original is here, and the conversion rules are here. |
// From: // http://angg.twu.net/blogme3/local-videos.js.html // http://angg.twu.net/blogme3/local-videos.js // (find-blogme3 "local-videos.js") // Author: Eduardo Ochs <eduardoochs@gmail.com> // Version: 2013sep26 escape_table = { '&': '&', '<': '<', '>': '>', '"': '"', "'": ''', "\x0f": '<font color="red"><strong>*</strong></font>' } escape_char = function (c) { return escape_table[c] || c; } escape = function (str) { return str.replace(/[\x0f&<>"']/g, escape_char); } youtube_mp4s = {} nonemptylines = function (bigstr) { return bigstr.match(/[!-~]+/g); } add_mp4s = function (bigstr) { var fnames = nonemptylines(bigstr), i; for (i=0; i<fnames.length; ++i) { var fname = fnames[i]; var A = fname.match(/(...........)\.mp4$/); if (A) { youtube_mp4s[A[1]] = fname; } } } get_mp4s_from = function (id) { var elt = document.getElementById(id); // add_mp4s(elt.innerText); add_mp4s(elt.textContent); elt.innerHTML = ""; } youtube_hash_re = /[?&]v=([^ &]+)/ youtube_hash = function (str) { var A = str.match(youtube_hash_re); if (A) { return A[1]; } } youtube_line_re = /^(.*)(https?:\/\/www.youtube[^ ]*)( *)(.*)$/ youtube_line_parse = function (str) { var A = str.match(youtube_line_re); if (A) { var all=A[0], a=A[1], url=A[2], b=A[3], title=A[4]; var hash = youtube_hash(url); if (hash) { return {'all':all, 'a':a, 'url':url, 'b':b, 'title':title, 'hash':hash}; } } } href0 = function (tgt, text) { return '<a href="'+tgt+'">' + text + '</a>'; } href = function (tgt, text) { return tgt ? href0(tgt, text) : text; } url_line_re = /^(.*)(https?:\/\/[!-~]*)( *)(.*)$/ url_line0 = function (str) { var A = str.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); } } youtube_url = function (hash) { return "http://www.youtube.com/watch?v="+hash; } yt_link = function (hash) { return "("+href(youtube_url(hash), "YT")+")"; } title_link = function (h, t) { return href(youtube_mp4s[h], t); } title_link = function (h, t) { return href(youtube_mp4s[h], escape(t)); } youtube_line0 = function (li) { var A = youtube_line_parse(li) if (A) { return A.a + yt_link(A.hash) + A.b + title_link(A.hash, A.title); } } youtube_line = function (li) { return youtube_line0(li) || li; } youtube_line = function (li) { return youtube_line0(li) || url_line0(li) || li; } 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); } // get_mp4s_from("mp4s") // youtube_activate("body")