Functionality that lists embedded videos has been restored. TODO: css, make it work

This commit is contained in:
Tamius Han 2019-01-20 19:58:26 +01:00
parent e1467cd6d7
commit b49f8c6d26
2 changed files with 54 additions and 32 deletions

View File

@ -9,7 +9,7 @@ class CommsServer {
var ths = this;
console.log("[CommsServer::ctor] INIT! are we in ff?", BrowserDetect.firefox, "BrowserDetect says ...", BrowserDetect)
// console.log("[CommsServer::ctor] INIT! are we in ff?", BrowserDetect.firefox, "BrowserDetect says ...", BrowserDetect)
if (BrowserDetect.firefox) {
browser.runtime.onConnect.addListener(p => ths.onConnect(p));
@ -21,14 +21,14 @@ class CommsServer {
}
async toObject(obj) {
console.log("CLONING OBJECT", obj);
try {
const r = JSON.parse(JSON.stringify(obj));
return r;
} catch (e) {
console.log("ERROR WHILE CLONING", obj);
// console.log("(not actually) CLONING OBJECT", obj);
// try {
// const r = JSON.parse(JSON.stringify(obj));
// return r;
// } catch (e) {
// console.log("ERROR WHILE CLONING", obj);
return obj;
}
// }
}
async getCurrentTabHostname() {
@ -166,7 +166,7 @@ class CommsServer {
if (message.cmd === 'announce-zoom') {
// forward off to the popup, no use for this here
try {
this.popupPort.postMessage(this.toObject({cmd: 'set-current-zoom', zoom: message.zoom}));
this.popupPort.postMessage({cmd: 'set-current-zoom', zoom: message.zoom});
} catch (e) {
// can't forward stuff to popup if it isn't open
}
@ -177,11 +177,11 @@ class CommsServer {
if (message.cmd === 'get-current-site') {
console.log("CCCCC - ss");
console.log("[find server] set-current-site — getting site", this.server.getVideoTab(), this.toObject(this.server.getVideoTab()))
port.postMessage(this.toObject({
port.postMessage({
cmd: 'set-current-site',
site: this.server.getVideoTab(),
tabHostname: await this.getCurrentTabHostname()
}));
});
console.log("CCCCC -s as")
}
if (message.cmd === 'popup-set-selected-tab') {
@ -194,9 +194,9 @@ class CommsServer {
if(Debug.debug) {
console.log("CommsServer: received get-config. Active settings?", this.settings.active, "\n(settings:", this.settings, ")")
}
port.postMessage(this.toObject(
port.postMessage(
{cmd: "set-config", conf: this.settings.active, site: this.server.currentSite}
));
);
} else if (message.cmd === 'has-video') {
this.server.registerVideo(port.sender);
} else if (message.cmd === 'noVideo') {

View File

@ -161,6 +161,7 @@ export default {
processReceivedMessage(message, port) {
if (Debug.debug) {
console.log("[popup.js] received message set-c", message);
console.log("[popup.js] message cloned set-c", JSON.parse(JSON.stringify(message)));
}
if(message.cmd === 'set-current-site'){
@ -179,9 +180,13 @@ export default {
} else if (message.cmd === 'set-current-zoom') {
this.setCurrentZoom(message.zoom);
}
console.log("this?", this, "this.site:", JSON.parse(JSON.stringify(this.site)));
},
loadFrames(videoTab) {
console.log('set-c loading frames', videoTab)
console.log("set-c loading frames \n\n\n------------------------------------------------------------------\n\n\n1\n\n")
console.log('set-c loading frames', videoTab, JSON.parse(JSON.stringify(videoTab)))
if (videoTab.selected) {
this.selectedSubitem = videoTab.selected;
// selectedSubitemLoaded = true;
@ -189,32 +194,49 @@ export default {
this.activeFrames = [];
if (site.frames.length < 2) {
if (videoTab.frames.length < 2 || Object.keys(videoTab.frames).length < 2) {
this.selectedFrame = '__all';
console.log("set-c NOT ENOUGH FRAMES ______________________________________\n", videoTab.frames.length, Object.keys(videoTab.frames), Object.keys(videoTab.frames).length )
return;
}
console.log("set-c loading frames \n\n\n------------------------------------------------------------------\n\n\n2\n\n")
for (const frame in videoTab.frames) {
try {
for (const frame in videoTab.frames) {
if (frame && !this.frameStore[frame]) {
const fs = {
name: this.frameStoreCount++,
color: this.getRandomColor()
if (frame && !this.frameStore[frame]) {
const fs = {
name: this.frameStoreCount++,
color: this.getRandomColor()
}
this.frameStore[frame] = fs;
this.port.postMessage(this.toObject({
cmd: 'mark-player',
targetTab: videoTab.id,
targetFrame: frame,
name: fs.name,
color: fs.color
}));
}
this.frameStore[frame] = fs;
port.postMessage(this.toObject({
cmd: 'mark-player',
targetTab: videoTab.id,
targetFrame: frame,
name: fs.name,
color: fs.color
}));
console.log("set-c loading frames \n\n\n------------------------------------------------------------------\n\n\n22\n\n")
}
} catch (e) {
console.log("set-c loading frames \n\n\n------------------------------------------------------------------\n\n\ne", e, "\n\n")
}
this.activeFrames = [{id: '__all', label: 'All'},{id: '__playing', label: 'Currently playing'}].concat(videoTab.frames);
console.log("set-c", this.activeFrames)
console.log("set-c loading frames \n\n\n------------------------------------------------------------------\n\n\n3\n\n")
this.activeFrames = [{id: '__all', label: 'All'},{id: '__playing', label: 'Currently playing'}];
for (const frame in videoTab.frames) {
this.activeFrames.push({
label: videoTab.frames[frame].host,
...this.frameStore[frame],
})
}
console.log("set-c active frmaes", this.activeFrames, JSON.parse(JSON.stringify(this.activeFrames)))
},
getRandomColor() {
return `rgb(${Math.floor(Math.random() * 128)}, ${Math.floor(Math.random() * 128)}, ${Math.floor(Math.random() * 128)})`;