linterna-magica-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[linterna-magica-commit] [110] Changes for tasks #11216.


From: Ivaylo Valkov
Subject: [linterna-magica-commit] [110] Changes for tasks #11216.
Date: Tue, 05 Jul 2011 12:23:13 +0000

Revision: 110
          
http://svn.sv.gnu.org/viewvc/?view=rev&root=linterna-magica&revision=110
Author:   valkov
Date:     2011-07-05 12:23:13 +0000 (Tue, 05 Jul 2011)
Log Message:
-----------
Changes for tasks #11216. Added rule for (not) installed flash plugin. Sites 
that require this change are using it.

Ticket Links:
------------
    http://savannah.gnu.org/task/?11216

Modified Paths:
--------------
    branches/task-11216/Makefile
    branches/task-11216/src/lm_constructors.js
    branches/task-11216/src/lm_site_dailymotion.js
    branches/task-11216/src/lm_site_myvideode.js
    branches/task-11216/src/lm_site_tedcom.js
    branches/task-11216/src/lm_site_theonion.js
    branches/task-11216/src/lm_sites.js

Modified: branches/task-11216/Makefile
===================================================================
--- branches/task-11216/Makefile        2011-07-05 08:26:14 UTC (rev 109)
+++ branches/task-11216/Makefile        2011-07-05 12:23:13 UTC (rev 110)
@@ -54,7 +54,7 @@
 
 FIRSTJSFILES="$(srcdir)/lm_inject_script_in_page.js            \
 $(srcdir)/lm_init_options.js $(srcdir)/lm_constructors.js      \
-$(srcdir)/lm_config_options.js"
+$(srcdir)/lm_config_options.js $(srcdir)/lm_sites.js"
 
 LASTJSFILES="$(srcdir)/lm_run.js"
 

Modified: branches/task-11216/src/lm_constructors.js
===================================================================
--- branches/task-11216/src/lm_constructors.js  2011-07-05 08:26:14 UTC (rev 
109)
+++ branches/task-11216/src/lm_constructors.js  2011-07-05 12:23:13 UTC (rev 
110)
@@ -82,7 +82,7 @@
     }
 
     var self = this;
-    var val = this.sites.call_site_function_at_position.apply(self,[
+    var val = this.call_site_function_at_position.apply(self,[
        "before_options_init",
        window.location.hostname]);
     if (!val)
@@ -124,21 +124,24 @@
        this.player_timers = new Array();
     }
 
-    if (!this.plugin_is_installed &&
-       /dailymotion\.com/i.test(window.location.hostname))
+    var position_function = null ;
+    if (this.plugin_is_installed)
     {
-       this.request_video_link({video_id: window.location.pathname});
+       position_function = "flash_plugin_installed";
     }
-    // If there is a plugin installed do not search in scripts.
-    else if (!this.plugin_is_installed ||
-            /myvideo\.de/i.test(window.location.hostname) ||
-            /theonion\.com/i.test(window.location.hostname))
+    else
     {
-       this.log("LinternaMagica.constructor:\n"+
-                "Examining scripts.", 4);
+       position_function = "no_flash_plugin_installed";
+    }
 
-       // video.google.* bloats in this function. It takes around 1 min
-       this.extract_objects_from_scripts();
+    var self = this;
+    var val = this.call_site_function_at_position.apply(self,[
+       position_function,
+       window.location.hostname]);
+    
+    if (!val)
+    {
+       return null;
     }
 
     this.log("LinternaMagica.constructor:\n"+

Modified: branches/task-11216/src/lm_site_dailymotion.js
===================================================================
--- branches/task-11216/src/lm_site_dailymotion.js      2011-07-05 08:26:14 UTC 
(rev 109)
+++ branches/task-11216/src/lm_site_dailymotion.js      2011-07-05 12:23:13 UTC 
(rev 110)
@@ -68,3 +68,15 @@
 
     return null;
 }
+
+LinternaMagica.prototype.sites["dailymotion.com"] = new Object();
+
+// Reference
+LinternaMagica.prototype.sites["www.dailymotion.com"] = "dailymotion.com";
+
+LinternaMagica.prototype.sites["dailymotion.com"].no_flash_plugin_installed =
+function()
+{
+    this.request_video_link({video_id: window.location.pathname});
+    return true;
+}

Modified: branches/task-11216/src/lm_site_myvideode.js
===================================================================
--- branches/task-11216/src/lm_site_myvideode.js        2011-07-05 08:26:14 UTC 
(rev 109)
+++ branches/task-11216/src/lm_site_myvideode.js        2011-07-05 12:23:13 UTC 
(rev 110)
@@ -66,3 +66,11 @@
 
     return link;
 }
+
+LinternaMagica.prototype.sites["myvideo.de"] = new Object();
+
+// // Reference
+LinternaMagica.prototype.sites["www.myvideo.de"] = "myvideo.de";
+
+// Function reference
+LinternaMagica.prototype.sites["myvideo.de"].flash_plugin_installed = 
"theonion.com";

Modified: branches/task-11216/src/lm_site_tedcom.js
===================================================================
--- branches/task-11216/src/lm_site_tedcom.js   2011-07-05 08:26:14 UTC (rev 
109)
+++ branches/task-11216/src/lm_site_tedcom.js   2011-07-05 12:23:13 UTC (rev 
110)
@@ -121,7 +121,7 @@
     // (kilo*bytes*) and Firefox and forks block 
     if(!/[A-Za-z0-9]+/i.test(window.location.pathname))
     {  
-          this.log("LinternaMagica.constructor:\n"+
+          this.log("LinternaMagica.sites.before_options_init:\n"+
                    "Skipping TED front page!"+
                    " Blocks Firefox and forks.");
 

Modified: branches/task-11216/src/lm_site_theonion.js
===================================================================
--- branches/task-11216/src/lm_site_theonion.js 2011-07-05 08:26:14 UTC (rev 
109)
+++ branches/task-11216/src/lm_site_theonion.js 2011-07-05 12:23:13 UTC (rev 
110)
@@ -141,3 +141,17 @@
     }
 }
 
+LinternaMagica.prototype.sites["theonion.com"] = new Object();
+
+// Reference
+LinternaMagica.prototype.sites["www.theonion.com"] = "theonion.com";
+
+LinternaMagica.prototype.sites["theonion.com"].flash_plugin_installed =
+function()
+{
+    // Call the default when no plugin is installed. Examine scripts.
+    this.log("LinternaMagica.sites.flash_plugin_installed:\n",
+            "Calling default function to extract scripts");
+    return this.sites.__no_flash_plugin_installed.apply(this, [arguments]);
+}
+

Modified: branches/task-11216/src/lm_sites.js
===================================================================
--- branches/task-11216/src/lm_sites.js 2011-07-05 08:26:14 UTC (rev 109)
+++ branches/task-11216/src/lm_sites.js 2011-07-05 12:23:13 UTC (rev 110)
@@ -32,17 +32,35 @@
 // A function returns false/null, if the calling function should
 // exit/return after this function is executed.  Otherwise it should
 // return true.
+// Take an action before options initialisation. This is the
+// earliest position where site-specific action could be
+// taken. The default config is to keep processing.
+//
+// For example, ted.com requires a different approach.
 LinternaMagica.prototype.sites.__before_options_init = function ()
 {
-    // Take an action before options initialisation. This is the
-    // earliest position where site-specific action could be
-    // taken. The default config is to keep processing.
-    //
-    // For example, ted.com requires a different approach.
     return true;
 }
 
-// LinternaMagica.prototype.sites.__no_flash_plugin_installed
+// Take an action when no flash plugin is installed
+LinternaMagica.prototype.sites.__no_flash_plugin_installed = function()
+{
+    this.log("LinternaMagica.sites.__no_flash_plugin_installed:\n"+
+            "Examining scripts.", 4);
+
+    // video.google.* bloats in this function. It takes around 1 min
+    this.extract_objects_from_scripts();
+
+    return true;
+}
+
+// Take an action when flash plugin is installed. For example
+// myvideo.de and theonion.com have custom function.
+LinternaMagica.prototype.sites.__flash_plugin_installed = function()
+{
+    return true;
+}
+
 // LinternaMagica.prototype.sites.__process_cookies
 // LinternaMagica.prototype.sites.__css_style_fix
 // LinternaMagica.prototype.sites.__detect_flash_ // Useless?
@@ -68,35 +86,53 @@
 // it doesn't, call the general/default function.  A function returns
 // false/null, if the calling function should exit/return after this
 // function is executed. Otherwise it should return true.
-LinternaMagica.prototype.sites.call_site_function_at_position =
+LinternaMagica.prototype.call_site_function_at_position =
 function (position_name, match_site, data)
 {
     var self = this;
 
     if (this.sites[match_site])
     {
-       // All of the following will work when the referenced
-       // object/function is an object/function. A recursion is
-       // required to handle references to strings. 
+       // Recursion is used to handle references to strings.
 
        if (typeof(this.sites[match_site]) == "object" &&
            typeof(this.sites[match_site][position_name]) == "function")
        {
            // Defined site and function
+
+           this.log("LinternaMagica.call_site_function_at_position:\n"+
+                    "Calling function "+position_name+
+                    "for site (both site and function defined)",5);
+
            return this.sites[match_site][position_name].apply(self,[data]);
        }
        else if (typeof(this.sites[match_site]) == "object" &&
                 typeof(this.sites[match_site][position_name]) == "string")
        {
            // Reference to a function of another site
+
            var ref_to = this.sites[match_site][position_name];
-           return this.sites[ref_to][position_name].apply(self,[data]);
+
+           this.log("LinternaMagica.call_site_function_at_position:\n"+
+                    "Calling referenced function "+
+                    position_name+" (site defined,"+
+                    " function reference): "+match_site+" -> "+ref_to,5);
+
+           return this.call_site_function_at_position.apply(self, [
+               position_name, ref_to, data]);
        }
        else if (typeof(this.sites[match_site]) == "string")
        {
            // Reference to a another site
+
            var ref_to = this.sites[match_site];
-           return this.sites[ref_to][position_name].apply(self,[data]);
+
+           this.log("LinternaMagica.call_site_function_at_position:\n"+
+                    "Using another site config (reference) for function "+
+                    position_name+": "+match_site+" -> "+ref_to,5);
+
+           return this.call_site_function_at_position.apply(self, [
+               position_name, ref_to, data]);
        }
     }
     else if ((this.sites[match_site] &&
@@ -104,6 +140,11 @@
             !this.sites[match_site])
     {
        // General-purpose / default function.
+
+       this.log("LinternaMagica.call_site_function_at_position:\n"+
+                "Using default function "+position_name+
+                "(no site specific config)",5);
+
        return this.sites["__"+position_name].apply(self, [data]);
     }
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]