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: 2013dec09 // // (find-2a '(find-fline "local-videos.js") '(find-fline "local-videos-mini.js")) // (find-tkdiff "local-videos.js" "local-videos-mini.js") // (find-tkdiff "local-videos.js" "~/local-videos.js") // http://angg.twu.net/2013-petropolis.html // http://angg.twu.net/local-videos.html // (find-TH "linkdasruas") // (find-TH "2013-irina") // (find-blogme3file "local-videos-mini.js") // // See: // http://angg.twu.net/blogme3/local-videos.js.html 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; } 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); } // New: // youtube_activate = function (id, f) { // to_pre(id, youtube_activate0(from_pre(id), f)); // } // get_mp4s_from("mp4s") // youtube_activate("body")