Skip to content

Commit

Permalink
code format
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] authored and [email protected] committed Aug 8, 2017
1 parent 52026ef commit bcc43f9
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 54 deletions.
15 changes: 8 additions & 7 deletions demo/javascript/scripts/demo4.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,21 @@ var EPGList = {
+ ' <a href="javascript:EPGList.handlePlayClick(\'{{startTime}}\');">Play</a>'
+ '</li>',
onPlayClick: null,

init: function (domId, options)
{
this.domId = domId;
this.feed = options.feed;
this.onPlayClick = options.onPlayCallback;

this.loadFeed();
},

loadFeed: function()
loadFeed: function ()
{
var self = this;
window.getJSONPFeed(window.addTimestamp(this.feed), "handleEPGCallback", function(data){
window.getJSONPFeed(window.addTimestamp(this.feed), "handleEPGCallback", function (data)
{
self.handleData(data);
});
},
Expand All @@ -43,7 +44,7 @@ var EPGList = {
var container = document.getElementById(this.domId);
container.innerHTML = epgDom;
},
setActiveProgram: function(index)
setActiveProgram: function (index)
{
var container = document.getElementById(this.domId);
var prevSelectedEl = container.querySelectorAll(".selected");
Expand All @@ -57,12 +58,12 @@ var EPGList = {
window.addClass(elements[index], "selected");
}
},
getProgramLength: function()
getProgramLength: function ()
{
var container = document.getElementById(this.domId);
return container.querySelectorAll(".item").length;
},
handlePlayClick: function(startTime)
handlePlayClick: function (startTime)
{
if (this.onPlayClick)
{
Expand Down
16 changes: 9 additions & 7 deletions demo/javascript/scripts/demo4_1.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// EPG Component
(function(){
(function ()
{
var EPGList = {
domId: null,
template: '<li class="item">'
Expand All @@ -17,10 +18,11 @@
this.loadFeed();
},

loadFeed: function()
loadFeed: function ()
{
var self = this;
window.getJSONPFeed(window.addTimestamp(this.feed), "handleEPGCallback", function(data){
window.getJSONPFeed(window.addTimestamp(this.feed), "handleEPGCallback", function (data)
{
self.handleData(data);
});
},
Expand All @@ -44,7 +46,7 @@
var container = document.getElementById(this.domId);
container.innerHTML = epgDom;
},
setActiveProgram: function(index)
setActiveProgram: function (index)
{
var container = document.getElementById(this.domId);
var prevSelectedEl = container.querySelectorAll(".selected");
Expand All @@ -58,12 +60,12 @@
window.addClass(elements[index], "selected");
}
},
getProgramLength: function()
getProgramLength: function ()
{
var container = document.getElementById(this.domId);
return container.querySelectorAll(".item").length;
},
handlePlayClick: function(startTime)
handlePlayClick: function (startTime)
{
if (this.onPlayClick)
{
Expand All @@ -89,7 +91,7 @@
{
return EPGList.getProgramLength();
},
handlePlayClick: function(startTime)
handlePlayClick: function (startTime)
{
EPGList.handlePlayClick(startTime);
}
Expand Down
25 changes: 16 additions & 9 deletions demo/javascript/scripts/demo4_2.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
(function(){
(function ()
{
// EPG List
var EPGList = function (domId, options)
{
Expand Down Expand Up @@ -26,7 +27,8 @@
var self = this;

var epgFeed = this.options.feed.replace("{date}", window.formatDate(new Date()));
window.getJSONPFeed(window.addTimestamp(epgFeed), "handleEPGCallback", function(data){
window.getJSONPFeed(window.addTimestamp(epgFeed), "handleEPGCallback", function (data)
{
self.handleEPGData(data);
});
};
Expand Down Expand Up @@ -59,8 +61,10 @@
var anchors = document.getElementById(self.domId).querySelectorAll(".play");
for (var i = 0; i < anchors.length; i++)
{
(function(i){
anchors[i].onclick = function() {
(function (i)
{
anchors[i].onclick = function ()
{
self.options.onPlayCallback({startTime: anchors[i].getAttribute('data-starttime')})
};
})(i);
Expand All @@ -84,14 +88,16 @@
}
};

EPGList.prototype.getProgramLength = function()
EPGList.prototype.getProgramLength = function ()
{
var container = document.getElementById(this.domId);
return container.querySelectorAll(".item").length;
};

window.EPGListUI = function(){
return function (domId, options) {

window.EPGListUI = function ()
{
return function (domId, options)
{
var epgList = new EPGList(domId, options);
this.setActiveProgram = function (index)
{
Expand All @@ -105,7 +111,8 @@
}();
})(window);

(function(){
(function ()
{
window.EPGListFactory = (function ()
{
var instance;
Expand Down
16 changes: 9 additions & 7 deletions demo/javascript/scripts/demo5.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function EPGList(domId, options)
+ '</li>';

init();

function init()
{
loadEPGFeed();
Expand Down Expand Up @@ -45,15 +45,17 @@ function EPGList(domId, options)
var anchors = document.getElementById(domId).querySelectorAll(".play");
for (var i = 0; i < anchors.length; i++)
{
(function(i){
anchors[i].onclick = function() {
(function (i)
{
anchors[i].onclick = function ()
{
options.onPlayCallback({startTime: anchors[i].getAttribute('data-starttime')})
};
})(i);
}
}
}

// Public APIs
this.setActiveProgram = function (index)
{
Expand All @@ -69,13 +71,13 @@ function EPGList(domId, options)
window.addClass(elements[index], "selected");
}
};
this.getProgramLength = function()

this.getProgramLength = function ()
{
var container = document.getElementById(domId);
return container.querySelectorAll(".item").length;
};

// Utils
// yyyy/MM/dd
function formatDate(date)
Expand Down
15 changes: 9 additions & 6 deletions demo/javascript/scripts/demo5_1.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ EPGList.prototype._init = function ()
EPGList.prototype._loadEPGFeed = function ()
{
var self = this;

var epgFeed = this.options.epgFeed.replace("{date}", window.formatDate(new Date()));
window.getJSONPFeed(window.addTimestamp(epgFeed), "handleEPGCallback", function(data){
window.getJSONPFeed(window.addTimestamp(epgFeed), "handleEPGCallback", function (data)
{
self._handleEPGData(data);
});
};
Expand All @@ -43,7 +44,7 @@ EPGList.prototype._handleEPGData = function (data)
EPGList.prototype._renderEPGUI = function (epgArr)
{
var self = this;

var epgDom = "<ul>";
for (var i = 0; i < epgArr.length; i++)
{
Expand All @@ -58,8 +59,10 @@ EPGList.prototype._renderEPGUI = function (epgArr)
var anchors = document.getElementById(self.domId).querySelectorAll(".play");
for (var i = 0; i < anchors.length; i++)
{
(function(i){
anchors[i].onclick = function() {
(function (i)
{
anchors[i].onclick = function ()
{
self.options.onPlayCallback({startTime: anchors[i].getAttribute('data-starttime')})
};
})(i);
Expand All @@ -83,7 +86,7 @@ EPGList.prototype.setActiveProgram = function (index)
}
};

EPGList.prototype.getProgramLength = function()
EPGList.prototype.getProgramLength = function ()
{
var container = document.getElementById(this.domId);
return container.querySelectorAll(".item").length;
Expand Down
22 changes: 14 additions & 8 deletions demo/javascript/scripts/demo5_2.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
(function(){
(function ()
{
// EPG List
var EPGList = function (domId, options)
{
Expand Down Expand Up @@ -26,7 +27,8 @@
var self = this;

var epgFeed = this.options.epgFeed.replace("{date}", window.formatDate(new Date()));
window.getJSONPFeed(window.addTimestamp(epgFeed), "handleEPGCallback", function(data){
window.getJSONPFeed(window.addTimestamp(epgFeed), "handleEPGCallback", function (data)
{
self.handleEPGData(data);
});
};
Expand Down Expand Up @@ -59,8 +61,10 @@
var anchors = document.getElementById(self.domId).querySelectorAll(".play");
for (var i = 0; i < anchors.length; i++)
{
(function(i){
anchors[i].onclick = function() {
(function (i)
{
anchors[i].onclick = function ()
{
self.options.onPlayCallback({startTime: anchors[i].getAttribute('data-starttime')})
};
})(i);
Expand All @@ -84,14 +88,16 @@
}
};

EPGList.prototype.getProgramLength = function()
EPGList.prototype.getProgramLength = function ()
{
var container = document.getElementById(this.domId);
return container.querySelectorAll(".item").length;
};

window.EPGList = function(){
return function (domId, options) {

window.EPGList = function ()
{
return function (domId, options)
{
var epgList = new EPGList(domId, options);
this.setActiveProgram = function (index)
{
Expand Down
21 changes: 13 additions & 8 deletions demo/javascript/scripts/demo6.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
(function( $ ) {
(function ($)
{

// EPG List
function EPGList($elem, options)
Expand Down Expand Up @@ -41,24 +42,28 @@
var anchors = $elem[0].querySelectorAll(".play");
for (var i = 0; i < anchors.length; i++)
{
(function(i){
anchors[i].onclick = function() {
(function (i)
{
anchors[i].onclick = function ()
{
options.onPlayCallback({startTime: anchors[i].getAttribute('data-starttime')})
};
})(i);
}
}
}
}

$.fn.epgList = function(options) {

$.fn.epgList = function (options)
{

// Iterate and reformat each matched element.
return this.each(function() {
var elem = $( this );
return this.each(function ()
{
var elem = $(this);
var epgList = new EPGList(elem, options);
elem.data("epgList", epgList);
});
};

}( jQuery ));
}(jQuery));
4 changes: 2 additions & 2 deletions demo/javascript/scripts/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,15 @@ function addClass(el, className)
if (el.classList)
el.classList.add(className);
else
el.className += ' ' + className;
el.className += ' ' + className;
}

function removeClass(el, className)
{
if (el.classList)
el.classList.remove(className);
else
el.className = el.className.replace(new RegExp('(^|\\b)' + className.split(' ').join('|') + '(\\b|$)', 'gi'), ' ');
el.className = el.className.replace(new RegExp('(^|\\b)' + className.split(' ').join('|') + '(\\b|$)', 'gi'), ' ');
}

/* Date functions */
Expand Down

0 comments on commit bcc43f9

Please sign in to comment.