[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[linterna-magica-commit] [50] Code cleanup
From: |
Ivaylo Valkov |
Subject: |
[linterna-magica-commit] [50] Code cleanup |
Date: |
Wed, 27 Apr 2011 10:21:42 +0000 |
Revision: 50
http://svn.sv.gnu.org/viewvc/?view=rev&root=linterna-magica&revision=50
Author: valkov
Date: 2011-04-27 10:21:41 +0000 (Wed, 27 Apr 2011)
Log Message:
-----------
Code cleanup
Modified Paths:
--------------
trunk/src/lm_check_for_updates.js
trunk/src/lm_create_video_object.js
trunk/src/lm_interface_player_web_buttons.js
trunk/src/lm_interface_toggle_plugin.js
trunk/src/lm_log.js
Modified: trunk/src/lm_check_for_updates.js
===================================================================
--- trunk/src/lm_check_for_updates.js 2011-04-27 09:41:21 UTC (rev 49)
+++ trunk/src/lm_check_for_updates.js 2011-04-27 10:21:41 UTC (rev 50)
@@ -144,7 +144,8 @@
"</script>"+
"</head><body></body></html>";
- checker_frame.setAttribute("data", "data:text/html;charset=UTF-8;base64,"+
+ checker_frame.setAttribute("data",
+ "data:text/html;charset=UTF-8;base64,"+
btoa(frame_data));
checker_frame.setAttribute("width","1px");
@@ -196,7 +197,8 @@
// 0 - day name ; 1 - Month ; 2 - day of month; 3 - year
// 0 - Mon, Tue, Wed, Thu, Fri, Sun, Sat
- // 1 - Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Noe, Dec
+ // 1 - Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct,
+ // Noe, Dec
format_date = format_date.split(" ");
// To be used by other functions
@@ -222,14 +224,16 @@
var notifier = this.create_update_notifier_link(n);
var update_info = this.create_update_info_box(n);
- notifier.
- addEventListener("click", function(ev)
- {
- var el = this;
- self.show_or_hide_update_info.
- apply(self, [ev, el]);
- }, false);
+ var notifier_click_function = function(ev)
+ {
+ var el = this;
+ self.show_or_hide_update_info.apply(self, [ev, el]);
+ };
+ notifier.addEventListener("click",
+ notifier_click_function,
+ false);
+
h.appendChild(notifier);
lm.appendChild(update_info);
}
Modified: trunk/src/lm_create_video_object.js
===================================================================
--- trunk/src/lm_create_video_object.js 2011-04-27 09:41:21 UTC (rev 49)
+++ trunk/src/lm_create_video_object.js 2011-04-27 10:21:41 UTC (rev 50)
@@ -102,10 +102,11 @@
script_name.setAttribute("class", "linterna-magica-logo");
var self = this;
- script_name.addEventListener("click", function(ev){
- var el = this;
- self.about.apply(self, [ev, el]);
- }, false);
+ script_name.addEventListener("click", function(ev)
+ {
+ var el = this;
+ self.about.apply(self, [ev, el]);
+ }, false);
// If the plugin is not installed this is useless
if (this.plugin_is_installed)
@@ -138,13 +139,16 @@
hd_button.textContent = this._("HQ");
hd_button.setAttribute("title", this._("Higher quality"));
hd_button.setAttribute("class", "linterna-magica-switch-hd");
- hd_button.addEventListener("click", function(ev)
- {
- var el = this;
- self.show_or_hide_hd_links.
- apply(self, [ev, el]);
- }, false);
+ var hd_button_click_function = function(ev)
+ {
+ var el = this;
+ self.show_or_hide_hd_links.apply(self, [ev, el]);
+ };
+
+ hd_button.addEventListener("click",
+ hd_button_click_function, false);
+
hd_wrapper.appendChild(hd_button);
var hd_links = document.createElement("div");
@@ -160,13 +164,16 @@
var button = document.createElement("a");
button.setAttribute("href",object_data.hd_links[link].url);
button.textContent = object_data.hd_links[link].label;
- button.addEventListener("click", function(ev)
- {
- var el = this;
- self.switch_to_hd_link.
- apply(self, [ev, el]);
- }, false);
+ var button_click_function = function(ev)
+ {
+ var el = this;
+ self.switch_to_hd_link.apply(self, [ev, el]);
+ };
+
+ button.addEventListener("click",
+ button_click_function , false);
+
// Selected link. Default it is the lowest quality.
if (link == (object_data.hd_links.length-1))
{
@@ -187,13 +194,16 @@
if (this.debug_level && this.log_to == "web")
{
var log_link = this.create_web_log_link(id);
- log_link.addEventListener("click", function(ev)
- {
- var el = this;
- self.show_or_hide_web_log.
- apply(self, [ev, el]);
- }, false);
+ var log_link_click_function = function(ev)
+ {
+ var el = this;
+ self.show_or_hide_web_log.apply(self, [ev, el]);
+ };
+
+ log_link.addEventListener("click",
+ log_link_click_function, false);
+
header.appendChild(log_link);
// Hide the web log, so it accessible only from interface.
var log = document.getElementById("linterna-magica-web-log");
Modified: trunk/src/lm_interface_player_web_buttons.js
===================================================================
--- trunk/src/lm_interface_player_web_buttons.js 2011-04-27 09:41:21 UTC
(rev 49)
+++ trunk/src/lm_interface_player_web_buttons.js 2011-04-27 10:21:41 UTC
(rev 50)
@@ -49,28 +49,25 @@
{
play.style.setProperty("display", "none", "important");
}
+ var play_click_function = function(ev)
+ {
+ ev.preventDefault();
- play.addEventListener("click", function(ev)
- {
- ev.preventDefault();
+ this.style.setProperty("display", "none", "important");
- this.style.
- setProperty("display",
- "none", "important");
+ this.nextSibling.style.removeProperty("display");
- this.nextSibling.style.
- removeProperty("display");
+ self.player.play.apply(self, [id]);
- self.player.play.apply(self, [id]);
+ // Start the time ticker
+ self.player_timers[id] = setInterval(
+ function()
+ {
+ self.ticker.apply(self, [id]);
+ }, 500);
+ };
- // Start the time ticker
- self.player_timers[id] =
- setInterval(
- function()
- {
- self.ticker.apply(self, [id]);
- }, 500);
- }, false);
+ play.addEventListener("click", play_click_function, false);
controls.appendChild(play);
var pause = document.createElement("a");
@@ -85,22 +82,22 @@
pause.style.setProperty("display", "none", "important");
}
- pause.addEventListener("click", function(ev)
- {
- ev.preventDefault();
- this.style.
- setProperty("display",
- "none", "important");
+ var pause_click_function = function(ev)
+ {
+ ev.preventDefault();
+ this.style.
+ setProperty("display", "none", "important");
- this.previousSibling.style.
- removeProperty("display");
+ this.previousSibling.style.removeProperty("display");
- self.player.pause.apply(self, [id]);
+ self.player.pause.apply(self, [id]);
- // Stop the time ticker
- clearInterval(self.player_timers[id]);
- delete self.player_timers[id];
- }, false);
+ // Stop the time ticker
+ clearInterval(self.player_timers[id]);
+ delete self.player_timers[id];
+ };
+
+ pause.addEventListener("click", pause_click_function, false);
controls.appendChild(pause);
var stop = document.createElement("a");
@@ -109,23 +106,25 @@
stop.setAttribute("href", "#");
stop.setAttribute("title", this._("Stop"));
stop.textContent ="St";
- stop.addEventListener("click", function(ev)
- {
- ev.preventDefault();
- // pause
- this.previousSibling.style.
- setProperty("display",
- "none", "important");
- // play
- this.previousSibling.previousSibling.
- style.removeProperty("display");
- self.player.stop.apply(self, [id]);
+ var stop_click_function = function(ev)
+ {
+ ev.preventDefault();
+ // pause
+ this.previousSibling.style.setProperty("display",
+ "none", "important");
+ // play button
+ var play = this.previousSibling.previousSibling;
+ play.style.removeProperty("display");
- // Stop the time ticker
- clearInterval(self.player_timers[id]);
- delete self.player_timers[id];
- }, false);
+ self.player.stop.apply(self, [id]);
+
+ // Stop the time ticker
+ clearInterval(self.player_timers[id]);
+ delete self.player_timers[id];
+ };
+
+ stop.addEventListener("click", stop_click_function, false);
controls.appendChild(stop);
var time_slider = document.createElement("div");
@@ -151,55 +150,51 @@
var mouse_scroll = /WebKit/i.test(navigator.userAgent) ?
"mousewheel" : "DOMMouseScroll";
- time_slider.addEventListener(mouse_scroll, function(ev)
- {
- ev.preventDefault();
- var pos = self.slider_control.
- apply(self, [ev]);
+ var time_slider_scroll_function = function(ev)
+ {
+ ev.preventDefault();
+ var pos = self.slider_control.apply(self, [ev]);
- if (pos.direction > 0)
- {
- self.player.forward.
- apply(self,[id,pos.val])
- }
- else
- {
- self.player.rewind.
- apply(self,[id,pos.val])
- }
+ if (pos.direction > 0)
+ {
+ self.player.forward.apply(self,[id,pos.val]);
+ }
+ else
+ {
+ self.player.rewind.apply(self,[id,pos.val]);
+ }
+ };
- }, false);
+ time_slider.addEventListener(mouse_scroll,
+ time_slider_scroll_function, false);
- time_slider.addEventListener("click", function(ev)
- {
- ev.preventDefault();
- // Stop the time ticker
- clearInterval(self.player_timers[id]);
- delete self.player_timers[id];
+ var time_slider_click_function = function(ev)
+ {
+ ev.preventDefault();
+ // Stop the time ticker
+ clearInterval(self.player_timers[id]);
+ delete self.player_timers[id];
- var pos =
- self.slider_control.
- apply(self, [ev]);
+ var pos = self.slider_control.apply(self, [ev]);
- if (pos.direction > 0)
- {
- self.player.forward.
- apply(self,[id,pos.val])
- }
- else
- {
- self.player.rewind.
- apply(self,[id,pos.val])
- }
+ if (pos.direction > 0)
+ {
+ self.player.forward.apply(self,[id,pos.val]);
+ }
+ else
+ {
+ self.player.rewind.apply(self,[id,pos.val]);
+ }
- self.player_timers[id] =
- setInterval(
- function()
- {
- self.ticker.apply(self,[id]);
- }, 500);
- }, false);
+ self.player_timers[id] = setInterval(
+ function()
+ {
+ self.ticker.apply(self,[id]);
+ }, 500);
+ };
+ time_slider.addEventListener("click", time_slider_click_function, false);
+
var time_knob_move = null;
if (this.languages[this.lang].__direction == "ltr" ||
@@ -266,32 +261,32 @@
volume_width+"px",
"important");
- volume_slider.addEventListener(mouse_scroll, function(ev)
- {
- ev.preventDefault();
- var pos =
- self.slider_control.
- apply(self, [ev]);
+ var volume_slider_scroll_function = function(ev)
+ {
+ ev.preventDefault();
+ var pos = self.slider_control.apply(self, [ev]);
- self.player.set_volume.
- apply(self, [id, pos.val]);
+ self.player.set_volume.apply(self, [id, pos.val]);
- volume_text.textContent = pos.val;
- }, false);
+ volume_text.textContent = pos.val;
+ };
- volume_slider.addEventListener("click", function(ev)
- {
- ev.preventDefault();
- var pos =
- self.slider_control.
- apply(self, [ev]);
+ volume_slider.addEventListener(mouse_scroll,
+ volume_slider_scroll_function, false);
- self.player.set_volume.
- apply(self, [id, pos.val]);
+ var volume_slider_click_function = function(ev)
+ {
+ ev.preventDefault();
+ var pos = self.slider_control.apply(self, [ev]);
- volume_text.textContent = pos.val;
- }, false);
+ self.player.set_volume.apply(self, [id, pos.val]);
+ volume_text.textContent = pos.val;
+ };
+
+ volume_slider.addEventListener("click",
+ volume_slider_click_function, false);
+
var volume_knob_move = null;
if (this.languages[this.lang].__direction == "ltr" ||
@@ -326,7 +321,8 @@
controls.appendChild(volume_slider);
- volume_text.setAttribute("class", "linterna-magica-controls-slider-text");
+ volume_text.setAttribute("class",
+ "linterna-magica-controls-slider-text");
volume_text.style.setProperty("left",
parseInt(volume_width/3)+"px",
@@ -399,11 +395,15 @@
fullscreen.setAttribute("href", "#");
fullscreen.setAttribute("title", this._("Fullscreen"));
fullscreen.textContent ="Fs";
- fullscreen.addEventListener("click", function(ev)
- {
- ev.preventDefault();
- self.player.fullscreen.apply(self, [id]);
- }, false);
+
+ var fullscreen_click_function = function(ev)
+ {
+ ev.preventDefault();
+ self.player.fullscreen.apply(self, [id]);
+ };
+
+ fullscreen.addEventListener("click",
+ fullscreen_click_function, false);
controls.appendChild(fullscreen);
return controls;
Modified: trunk/src/lm_interface_toggle_plugin.js
===================================================================
--- trunk/src/lm_interface_toggle_plugin.js 2011-04-27 09:41:21 UTC (rev 49)
+++ trunk/src/lm_interface_toggle_plugin.js 2011-04-27 10:21:41 UTC (rev 50)
@@ -39,12 +39,16 @@
{
toggle_plugin.setAttribute("class", "linterna-magica-toggle-plugin");
}
- toggle_plugin.addEventListener("click", function(ev)
- {
- var el = this;
- self.toggle_plugin.
- apply(self, [ev, el]);
- }, false);
+
+ var toggle_plugin_click_function = function(ev)
+ {
+ var el = this;
+ self.toggle_plugin.apply(self, [ev, el]);
+ };
+
+ toggle_plugin.addEventListener("click",
+ toggle_plugin_click_function, false);
+
if (plugin_priority)
{
Modified: trunk/src/lm_log.js
===================================================================
--- trunk/src/lm_log.js 2011-04-27 09:41:21 UTC (rev 49)
+++ trunk/src/lm_log.js 2011-04-27 10:21:41 UTC (rev 50)
@@ -130,15 +130,16 @@
close.setAttribute("title", this._("Remove log"));
p.appendChild(close);
- close.addEventListener("click", function(ev)
- {
- ev.preventDefault();
- // The entire web log
- var log = this.parentNode.
- parentNode.parentNode;
- log.parentNode.removeChild(log);
- }, false);
+ var close_click_function = function(ev)
+ {
+ ev.preventDefault();
+ // The entire web log
+ var log = this.parentNode.parentNode.parentNode;
+ log.parentNode.removeChild(log);
+ };
+ close.addEventListener("click", close_click_function, false);
+
var show_hide_log = document.createElement("a");
show_hide_log.textContent="-";
show_hide_log.setAttribute("href", "#");
@@ -146,41 +147,35 @@
show_hide_log.setAttribute("class",
"linterna-magica-web-log-show-hide-body");
p.appendChild(show_hide_log);
- show_hide_log.addEventListener("click", function(ev)
- {
- ev.preventDefault();
- // The body of the log
- var b = this.parentNode.
- parentNode.nextSibling;
- var p = b.parentNode;
- var t =
- parseInt(p.style.getPropertyValue("top"));
+ var show_hide_log_click_function = function(ev)
+ {
+ ev.preventDefault();
+ // The body of the log
+ var b = this.parentNode.
+ parentNode.nextSibling;
+ var p = b.parentNode;
+ var t = parseInt(p.style.getPropertyValue("top"));
- if(b.style.display)
- {
- b.style.removeProperty("display");
- p.style.setProperty("height",
- "250px", "important");
- p.style.setProperty("top", (t-226)+"px",
- "important");
- b.style.setProperty("overflow", "auto",
- "important");
- p.style.setProperty("overflow", "visible",
- "important");
- }
- else
- {
- b.style.setProperty(
- "display","none", "important");
- // Only the header is visible
- p.style.setProperty("height",
- "24px", "important");
- p.style.setProperty("overflow", "hidden",
- "important");
- p.style.setProperty("top", (t+226)+"px",
- "important");
- }
- }, false);
+ if(b.style.display)
+ {
+ b.style.removeProperty("display");
+ p.style.setProperty("height", "250px", "important");
+ p.style.setProperty("top", (t-226)+"px", "important");
+ b.style.setProperty("overflow", "auto", "important");
+ p.style.setProperty("overflow", "visible", "important");
+ }
+ else
+ {
+ b.style.setProperty("display", "none", "important");
+ // Only the header is visible
+ p.style.setProperty("height", "24px", "important");
+ p.style.setProperty("overflow", "hidden", "important");
+ p.style.setProperty("top", (t+226)+"px", "important");
+ }
+ };
+
+ show_hide_log.addEventListener("click",
+ show_hide_log_click_function, false);
logger.appendChild(header);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [linterna-magica-commit] [50] Code cleanup,
Ivaylo Valkov <=