[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[linterna-magica-commit] [85] Closes support #107708.
From: |
Ivaylo Valkov |
Subject: |
[linterna-magica-commit] [85] Closes support #107708. |
Date: |
Sun, 12 Jun 2011 13:19:49 +0000 |
Revision: 85
http://svn.sv.gnu.org/viewvc/?view=rev&root=linterna-magica&revision=85
Author: valkov
Date: 2011-06-12 13:19:49 +0000 (Sun, 12 Jun 2011)
Log Message:
-----------
Closes support #107708. Adds support for The Onion dot com.
Ticket Links:
------------
http://savannah.gnu.org/support/?107708
Modified Paths:
--------------
trunk/data/style/template.css
trunk/src/lm_constructors.js
trunk/src/lm_extract_js_scripts.js
trunk/src/lm_extract_video_link.js
trunk/src/lm_xhr.js
Added Paths:
-----------
trunk/src/lm_site_theonion.js
Modified: trunk/data/style/template.css
===================================================================
--- trunk/data/style/template.css 2011-06-12 12:53:42 UTC (rev 84)
+++ trunk/data/style/template.css 2011-06-12 13:19:49 UTC (rev 85)
@@ -220,6 +220,8 @@
top: 1px !important;
line-height: 22px !important;
float: left !important;
+ /* Fix for The Onion dot com */
+ clear: none !important;
height: 22px !important;
position: relative !important;
color: #ffffff !important;
Modified: trunk/src/lm_constructors.js
===================================================================
--- trunk/src/lm_constructors.js 2011-06-12 12:53:42 UTC (rev 84)
+++ trunk/src/lm_constructors.js 2011-06-12 13:19:49 UTC (rev 85)
@@ -136,8 +136,9 @@
// Exception for blip.tv. This is the easiesy way to
// support it with installed plugin.
else if (!this.plugin_is_installed ||
- /blip\.tv/i.test(window.location.hostname) ||
- /myvideo\.de/i.test(window.location.hostname))
+ /blip\.tv/i.test(window.location.hostname) ||
+ /myvideo\.de/i.test(window.location.hostname) ||
+ /theonion\.com/i.test(window.location.hostname))
{
this.log("LinternaMagica.constructor:\n"+
"Examining scripts.", 4);
Modified: trunk/src/lm_extract_js_scripts.js
===================================================================
--- trunk/src/lm_extract_js_scripts.js 2011-06-12 12:53:42 UTC (rev 84)
+++ trunk/src/lm_extract_js_scripts.js 2011-06-12 13:19:49 UTC (rev 85)
@@ -69,6 +69,18 @@
continue;
}
+ if (/theonion\.com/i.test(window.location.hostname))
+ {
+ object_data = this.extract_object_from_script_theonion();
+
+ if (!object_data)
+ {
+ // No other method of extraction is useful. Skip to
+ // next script.
+ continue;
+ }
+ }
+
if (/youtube\.com/i.test(window.location.hostname) ||
(/youtube-nocookie\.com/i.test(window.location.hostname)))
{
Modified: trunk/src/lm_extract_video_link.js
===================================================================
--- trunk/src/lm_extract_video_link.js 2011-06-12 12:53:42 UTC (rev 84)
+++ trunk/src/lm_extract_video_link.js 2011-06-12 13:19:49 UTC (rev 85)
@@ -240,10 +240,12 @@
// 12.02.2011 Update for myvideo.de. php&ID and \\\. This migth break
// 25.02.2011 Update for videoclipsdump.com
// player_config\\\.php\\\ must be after vid|
+ // 11.06.2011 Update for theonion.com
+ // \\\/video_embed\\\/...
var video_id_re = new RegExp (
"(\\\"|\\\'|\\\&|\\\?|\\\;|\\\/|\\\.|\\\=)(itemid|clip_id|video_id|"+
"vid|player_config\\\.php\\\?v|"+
- "videoid|media_id|vkey|video3|_videoid|vimeo_clip_|php&ID)"+
+
"videoid|media_id|vkey|video3|_videoid|vimeo_clip_|php&ID|\\\/video_embed\\\/\\\?id)"+
"(\\\"|\\\')*(\\\=|\\\:|,|\\\/)\\\s*(\\\"|\\\')*"+
"([a-zA-Z0-9\\\-\\\_]+)",
"i");
Added: trunk/src/lm_site_theonion.js
===================================================================
--- trunk/src/lm_site_theonion.js (rev 0)
+++ trunk/src/lm_site_theonion.js 2011-06-12 13:19:49 UTC (rev 85)
@@ -0,0 +1,143 @@
+// @licstart The following is the entire license notice for the
+// JavaScript code in this page (or file).
+//
+// This file is part of Linterna Mágica
+//
+// Copyright (C) 2011 Ivaylo Valkov <address@hidden>
+//
+// The JavaScript code in this page (or file) is free software: you
+// can redistribute it and/or modify it under the terms of the GNU
+// General Public License (GNU GPL) as published by the Free Software
+// Foundation, either version 3 of the License, or (at your option)
+// any later version. The code is distributed WITHOUT ANY WARRANTY
+// without even the implied warranty of MERCHANTABILITY or FITNESS
+// FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
+//
+// As additional permission under GNU GPL version 3 section 7, you
+// may distribute non-source (e.g., minimized or compacted) forms of
+// that code without the copy of the GNU GPL normally required by
+// section 4, provided you include this license notice and a URL
+// through which recipients can access the Corresponding Source.
+//
+// @licend The above is the entire license notice for the JavaScript
+// code in this page (or file).
+//
+// @source http://e-valkov.org/linterna-magica
+
+// END OF LICENSE HEADER
+
+// Support for The Onion dot com
+
+// Extracts data for the flash object in The Onion dot com from a script
+LinternaMagica.prototype.extract_object_from_script_theonion = function()
+{
+ var player_container = document.getElementById("player_container");
+
+ if (!player_container)
+ {
+ return null;
+ }
+
+ var data = this.script_data;
+ var video_id_re = new RegExp (
+ "var\\\s*afns_video_id\\\s*="+
+ "\\\s*(\\\"|\\\')([0-9]+)(\\\"|\\\')");
+
+ var video_id = data.match(video_id_re);
+
+ if (!video_id)
+ {
+ return null;
+ }
+
+ video_id = video_id[video_id.length-2];
+
+ var width = player_container.clientWidth;
+ var height = player_container.clientHeight;
+
+ if (!width || !height)
+ {
+ return null;
+ }
+
+ var flash_object = document.getElementById("player_container_api");
+
+ var object_data = new Object();
+
+ object_data.video_id = video_id;
+ object_data.width = width;
+ object_data.height = height;
+ object_data.parent = player_container;
+
+ if (flash_object)
+ {
+ object_data.linterna_magica_id =
+ this.mark_flash_object(flash_object);
+ }
+ else
+ {
+ object_data.linterna_magica_id =
+ this.mark_flash_object("extracted-from-script");
+ }
+
+ return object_data;
+}
+
+// Add custom click event listeners to the buttons that change the
+// clips. This is active only on the front page.
+LinternaMagica.prototype.capture_theonion_clip_change = function(object_data)
+{
+ var list = document.getElementById("onn_recent");
+
+ if (!list || !/HTMLUListElement/i.test(list))
+ {
+ return null;
+ }
+
+ var self = this;
+ var click_function = function(ev)
+ {
+ var el = this;
+ var od = object_data;
+
+ self.theonion_clip_change_click_function.apply(self,[ev,el,od]);
+ };
+
+ var buttons = list.getElementsByTagName("li");
+
+ for (var i=0,l=buttons.length; i<l; i++)
+ {
+ var li = buttons[i];
+ li.addEventListener("click", click_function, true);
+ }
+}
+
+// Event listener for click on <li> elements, that change the iframe
+// src.
+LinternaMagica.prototype.theonion_clip_change_click_function =
+function(event,element,object_data)
+{
+ var p = element.getElementsByTagName("p");
+
+ for (var i=0, l=p.length; i<l; i++)
+ {
+ if (p[i].hasAttribute("rel") &&
+ p[i].hasAttribute("class") &&
+ /title/i.test(p[i].getAttribute("class")))
+ {
+ object_data.video_id = p[i].getAttribute("rel");
+ this.request_video_link(object_data);
+
+ var lm = this.get_video_object(object_data.linterna_magica_id);
+ // The whole LM wrapper
+ lm = lm.parentNode;
+
+ // Remove the object, because the XHR will call
+ // create_video_object and will make new one.
+ object_data.parent.removeChild(lm);
+
+ break;
+ }
+ }
+}
+
Modified: trunk/src/lm_xhr.js
===================================================================
--- trunk/src/lm_xhr.js 2011-06-12 12:53:42 UTC (rev 84)
+++ trunk/src/lm_xhr.js 2011-06-12 13:19:49 UTC (rev 85)
@@ -163,6 +163,11 @@
address = "/player/cbplayer/settings.php?vid="+video_id;
}
+ if (/theonion\.com/i.test(host))
+ {
+ address = "/ajax/onn/embed/"+video_id+".json";
+ }
+
var self = this;
client.onreadystatechange = function() {
var client = this;
@@ -416,6 +421,13 @@
}
}
+ if (/theonion\.com/i.test(host))
+ {
+ var onion_data = eval("("+client.responseText+")");
+ url = onion_data.video_url;
+ this.capture_theonion_clip_change(object_data);
+ }
+
if (!url)
{
return;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [linterna-magica-commit] [85] Closes support #107708.,
Ivaylo Valkov <=