Publish Vulpes Preview 15 sources for desktop, Android and Tundra
Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
This commit is contained in:
parent
93e3a48004
commit
b38dea0597
25901 changed files with 9982925 additions and 369 deletions
44
gaia/shared/js/smart-screen/pin_card.js
Executable file
44
gaia/shared/js/smart-screen/pin_card.js
Executable file
|
|
@ -0,0 +1,44 @@
|
|||
/* global evt, CardManager */
|
||||
|
||||
'use strict';
|
||||
|
||||
(function(exports) {
|
||||
function PinCard(options) {
|
||||
options = options || {};
|
||||
this.pinnedChannels = {};
|
||||
this.origin = options.origin || '';
|
||||
this.manifestURL = options.manifestURL || '';
|
||||
this.cardManager = new CardManager();
|
||||
this.cardManager.init('readonly')
|
||||
.then(this.updatePinnedChannels.bind(this));
|
||||
|
||||
// Update pinnedChannels when card-list changed
|
||||
this.cardManager.on(
|
||||
'cardlist-changed', this.updatePinnedChannels.bind(this));
|
||||
}
|
||||
|
||||
var proto = Object.create(new evt());
|
||||
|
||||
/**
|
||||
* Retrieve latest TV card list from card manager and update pin button
|
||||
* information.
|
||||
*/
|
||||
proto.updatePinnedChannels = function pc_updatePinnedChannels() {
|
||||
this.pinnedChannels = {};
|
||||
this.cardManager.getCardList().then(function(cardList) {
|
||||
cardList.forEach(function(card) {
|
||||
var url = card.launchURL;
|
||||
if (url && url.match(new RegExp(this.origin))) {
|
||||
var channelHash = url.substring(url.indexOf('#'));
|
||||
this.pinnedChannels[channelHash] = true;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}.bind(this));
|
||||
this.fire('update-pin-button');
|
||||
}.bind(this));
|
||||
};
|
||||
|
||||
PinCard.prototype = proto;
|
||||
exports.PinCard = PinCard;
|
||||
})(window);
|
||||
Loading…
Reference in a new issue