2018-12-30 23:16:09 +01:00
|
|
|
<template>
|
2019-01-17 22:16:55 +01:00
|
|
|
<div class="popup">
|
2019-01-02 20:36:00 +01:00
|
|
|
<div class="header">
|
|
|
|
<span class="smallcaps">Ultrawidify</span>: <small>Quick settings</small>
|
|
|
|
</div>
|
|
|
|
|
2019-01-17 22:16:55 +01:00
|
|
|
<div class="flex flex-row">
|
|
|
|
<!-- TABS/SIDEBAR -->
|
|
|
|
<div id="tablist" class="flex flex-column flex-nogrow flex-noshrink">
|
|
|
|
<div class="menu-item"
|
|
|
|
:class="{'selected-tab': selectedTab === 'extension'}"
|
|
|
|
@click="selectTab('extension')"
|
|
|
|
>
|
|
|
|
<div class="">
|
|
|
|
Extension settings
|
|
|
|
</div>
|
|
|
|
<div class="">
|
2019-01-03 02:07:16 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
2019-01-17 22:16:55 +01:00
|
|
|
<div class="menu-item"
|
|
|
|
:class="{'selected-tab': selectedTab === 'site'}"
|
|
|
|
@click="selectTab('site')"
|
|
|
|
>
|
|
|
|
<div class="">
|
|
|
|
Site settings
|
|
|
|
</div>
|
|
|
|
<div class="">
|
|
|
|
</div>
|
2019-01-03 02:07:16 +01:00
|
|
|
</div>
|
2019-01-17 22:16:55 +01:00
|
|
|
<div class="menu-item"
|
|
|
|
:class="{'selected-tab': selectedTab === 'video'}"
|
|
|
|
@click="selectTab('video')"
|
|
|
|
>
|
|
|
|
<div class="">
|
2019-01-20 20:36:24 +01:00
|
|
|
Video settings
|
2019-01-17 22:16:55 +01:00
|
|
|
</div>
|
|
|
|
<div class="">
|
|
|
|
</div>
|
|
|
|
<div class="">
|
2019-01-20 20:36:24 +01:00
|
|
|
<div class=""
|
|
|
|
:class="{'tabitem-selected': selectedFrame === frame.id}"
|
|
|
|
v-for="frame of activeFrames"
|
2019-01-18 00:26:15 +01:00
|
|
|
:key="frame.id"
|
2019-01-20 20:36:24 +01:00
|
|
|
@click="selectFrame(frame.id)"
|
2019-01-18 00:26:15 +01:00
|
|
|
>
|
2019-01-20 20:36:24 +01:00
|
|
|
{{frame.label}} {{frame.id}}
|
2019-01-17 22:16:55 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
2019-01-03 02:07:16 +01:00
|
|
|
</div>
|
2019-01-17 22:16:55 +01:00
|
|
|
<div class="menu-item"
|
|
|
|
:class="{'selected-tab': selectedTab === 'about'}"
|
|
|
|
@click="selectTab('about')"
|
|
|
|
>
|
2019-01-03 02:07:16 +01:00
|
|
|
<div class="">
|
2019-01-17 22:16:55 +01:00
|
|
|
About
|
|
|
|
</div>
|
|
|
|
<div class="">
|
|
|
|
</div>
|
2019-01-03 02:07:16 +01:00
|
|
|
</div>
|
2019-01-17 22:16:55 +01:00
|
|
|
<div class="menu-item"
|
|
|
|
:class="{'selected-tab': selectedTab === 'beggathon'}"
|
|
|
|
@click="selectTab('beggathon')"
|
|
|
|
>
|
|
|
|
<div class="">
|
|
|
|
Donate
|
|
|
|
</div>
|
|
|
|
<div class="">
|
|
|
|
</div>
|
2019-01-03 02:07:16 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
2019-01-02 20:36:00 +01:00
|
|
|
|
2019-01-17 22:16:55 +01:00
|
|
|
<!-- PANELS/CONTENT -->
|
|
|
|
<div id="tab-content" class="flex-grow" style="max-width: 480px !important;">
|
|
|
|
<VideoPanel v-if="settings && settings.active && selectedTab === 'video'"
|
|
|
|
class=""
|
|
|
|
:settings="settings"
|
|
|
|
:frame="selectedFrame"
|
|
|
|
:zoom="currentZoom"
|
|
|
|
@zoom-change="updateZoom($event)"
|
|
|
|
>
|
|
|
|
</VideoPanel>
|
|
|
|
</div>
|
2019-01-02 20:36:00 +01:00
|
|
|
</div>
|
2018-12-30 23:16:09 +01:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2019-01-03 02:07:16 +01:00
|
|
|
import Debug from '../ext/conf/Debug';
|
|
|
|
import BrowserDetect from '../ext/conf/BrowserDetect';
|
|
|
|
import Comms from '../ext/lib/comms/Comms';
|
2019-01-02 20:36:00 +01:00
|
|
|
import VideoPanel from './panels/VideoPanel';
|
|
|
|
import Settings from '../ext/lib/Settings';
|
2019-01-17 22:16:55 +01:00
|
|
|
import ExecAction from './js/ExecAction.js';
|
2019-01-02 20:36:00 +01:00
|
|
|
|
2018-12-30 23:16:09 +01:00
|
|
|
export default {
|
|
|
|
data () {
|
2019-01-02 20:36:00 +01:00
|
|
|
return {
|
|
|
|
selectedTab: 'video',
|
|
|
|
selectedFrame: '__all',
|
2019-01-03 02:07:16 +01:00
|
|
|
activeFrames: [],
|
|
|
|
port: BrowserDetect.firefox ? browser.runtime.connect({name: 'popup-port'}) : chrome.runtime.connect({name: 'popup-port'}),
|
|
|
|
comms: new Comms(),
|
|
|
|
frameStore: {},
|
|
|
|
frameStoreCount: 0,
|
|
|
|
site: null,
|
|
|
|
currentZoom: 1,
|
2019-01-17 22:16:55 +01:00
|
|
|
execAction: new ExecAction(),
|
|
|
|
settings: new Settings(undefined, () => this.updateConfig()),
|
2019-01-02 20:36:00 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
async created() {
|
2019-01-17 22:16:55 +01:00
|
|
|
this.settings.init();
|
2019-01-03 02:07:16 +01:00
|
|
|
this.port.onMessage.addListener( (m,p) => this.processReceivedMessage(m,p));
|
2019-01-17 22:16:55 +01:00
|
|
|
this.execAction.setSettings(this.settings);
|
2019-01-18 00:26:15 +01:00
|
|
|
|
|
|
|
// get info about current site from background script
|
|
|
|
while (true) {
|
|
|
|
this.getSite();
|
|
|
|
await this.sleep(5000);
|
|
|
|
}
|
|
|
|
// ensure we'll clean player markings on popup close
|
|
|
|
window.addEventListener("unload", () => {
|
|
|
|
port.postMessage({
|
|
|
|
cmd: 'unmark-player',
|
|
|
|
});
|
|
|
|
});
|
2019-01-02 20:36:00 +01:00
|
|
|
},
|
|
|
|
components: {
|
|
|
|
VideoPanel,
|
2019-01-03 02:07:16 +01:00
|
|
|
},
|
|
|
|
methods: {
|
2019-01-18 00:26:15 +01:00
|
|
|
async sleep(t) {
|
|
|
|
return new Promise( (resolve,reject) => {
|
|
|
|
setTimeout(() => resolve(), t);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
toObject(obj) {
|
|
|
|
return JSON.parse(JSON.stringify(obj));
|
|
|
|
},
|
|
|
|
getSite() {
|
|
|
|
try {
|
|
|
|
if (Debug.debug) {
|
|
|
|
console.log("[popup.js] requesting current site");
|
|
|
|
}
|
|
|
|
this.port.postMessage({cmd: 'get-current-site'});
|
|
|
|
} catch (e) {
|
|
|
|
if (Debug.debug) {
|
|
|
|
console.log("[popup::getSite] sending get-current-site failed for some reason. Reason:", e)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
getRandomColor() {
|
|
|
|
return `rgb(${Math.floor(Math.random() * 128)}, ${Math.floor(Math.random() * 128)}, ${Math.floor(Math.random() * 128)})`;
|
|
|
|
},
|
2019-01-03 02:07:16 +01:00
|
|
|
selectTab(tab) {
|
|
|
|
this.selectedTab = tab;
|
|
|
|
},
|
|
|
|
selectFrame(frame) {
|
|
|
|
this.selectedFrame = frame;
|
2019-01-17 22:16:55 +01:00
|
|
|
},
|
|
|
|
async updateConfig() {
|
|
|
|
|
2019-01-03 02:07:16 +01:00
|
|
|
},
|
|
|
|
processReceivedMessage(message, port) {
|
|
|
|
if (Debug.debug) {
|
2019-01-18 00:26:15 +01:00
|
|
|
console.log("[popup.js] received message set-c", message);
|
2019-01-20 19:58:26 +01:00
|
|
|
console.log("[popup.js] message cloned set-c", JSON.parse(JSON.stringify(message)));
|
2019-01-03 02:07:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if(message.cmd === 'set-current-site'){
|
|
|
|
if (this.site) {
|
|
|
|
if (!site.host) {
|
|
|
|
// dunno why this fix is needed, but sometimes it is
|
|
|
|
this.site.host = site.tabHostname;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!this.site || this.site.host !== message.site.host) {
|
|
|
|
this.port.postMessage({cmd: 'get-current-zoom'});
|
|
|
|
}
|
|
|
|
this.site = message.site;
|
2019-01-18 00:26:15 +01:00
|
|
|
// loadConfig(site.host); TODO
|
|
|
|
this.loadFrames(this.site);
|
2019-01-03 02:07:16 +01:00
|
|
|
} else if (message.cmd === 'set-current-zoom') {
|
2019-01-18 00:26:15 +01:00
|
|
|
this.setCurrentZoom(message.zoom);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
loadFrames(videoTab) {
|
|
|
|
if (videoTab.selected) {
|
|
|
|
this.selectedSubitem = videoTab.selected;
|
|
|
|
// selectedSubitemLoaded = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.activeFrames = [];
|
|
|
|
|
2019-01-20 19:58:26 +01:00
|
|
|
if (videoTab.frames.length < 2 || Object.keys(videoTab.frames).length < 2) {
|
2019-01-18 00:26:15 +01:00
|
|
|
this.selectedFrame = '__all';
|
|
|
|
return;
|
|
|
|
}
|
2019-01-20 20:36:24 +01:00
|
|
|
for (const frame in videoTab.frames) {
|
2019-01-18 00:26:15 +01:00
|
|
|
|
2019-01-20 20:36:24 +01:00
|
|
|
if (frame && !this.frameStore[frame]) {
|
|
|
|
const fs = {
|
|
|
|
name: this.frameStoreCount++,
|
|
|
|
color: this.getRandomColor()
|
|
|
|
}
|
2019-01-18 00:26:15 +01:00
|
|
|
|
2019-01-20 20:36:24 +01:00
|
|
|
this.frameStore[frame] = fs;
|
2019-01-18 00:26:15 +01:00
|
|
|
|
2019-01-20 20:36:24 +01:00
|
|
|
this.port.postMessage({
|
|
|
|
cmd: 'mark-player',
|
|
|
|
targetTab: videoTab.id,
|
|
|
|
targetFrame: frame,
|
|
|
|
name: fs.name,
|
|
|
|
color: fs.color
|
|
|
|
});
|
2019-01-18 00:26:15 +01:00
|
|
|
}
|
2019-01-20 19:58:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
this.activeFrames = [{id: '__all', label: 'All'},{id: '__playing', label: 'Currently playing'}];
|
2019-01-20 20:36:24 +01:00
|
|
|
|
2019-01-20 19:58:26 +01:00
|
|
|
for (const frame in videoTab.frames) {
|
|
|
|
this.activeFrames.push({
|
2019-01-20 20:36:24 +01:00
|
|
|
id: `${this.site.id}-${frame}`,
|
2019-01-20 19:58:26 +01:00
|
|
|
label: videoTab.frames[frame].host,
|
|
|
|
...this.frameStore[frame],
|
|
|
|
})
|
2019-01-03 02:07:16 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
getRandomColor() {
|
|
|
|
return `rgb(${Math.floor(Math.random() * 128)}, ${Math.floor(Math.random() * 128)}, ${Math.floor(Math.random() * 128)})`;
|
|
|
|
},
|
|
|
|
setCurrentZoom(nz) {
|
|
|
|
this.currentZoom = nz;
|
|
|
|
},
|
|
|
|
updateZoom(nz){
|
|
|
|
this.currentZoom = nz;
|
2019-01-20 20:36:24 +01:00
|
|
|
},
|
|
|
|
selectFrame(id){
|
|
|
|
this.selectedFrame = id;
|
2019-01-03 02:07:16 +01:00
|
|
|
}
|
2018-12-30 23:16:09 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
2019-01-03 02:07:16 +01:00
|
|
|
<style src="../res/css/font/overpass.css"></style>
|
|
|
|
<style src="../res/css/font/overpass-mono.css"></style>
|
|
|
|
<style src="../res/css/flex.css"></style>
|
|
|
|
<style src="../res/css/common.scss"></style>
|
|
|
|
|
2018-12-30 23:16:09 +01:00
|
|
|
<style lang="scss" scoped>
|
2019-01-03 02:07:16 +01:00
|
|
|
html, body {
|
2019-01-17 22:16:55 +01:00
|
|
|
width: 800px !important;
|
2019-01-03 02:07:16 +01:00
|
|
|
max-width: 800px !important;
|
|
|
|
padding: 0px;
|
|
|
|
margin: 0px;
|
|
|
|
}
|
|
|
|
|
2019-01-17 22:16:55 +01:00
|
|
|
#tablist {
|
|
|
|
min-width: 275px;
|
|
|
|
}
|
|
|
|
|
2019-01-03 02:07:16 +01:00
|
|
|
.header {
|
2019-01-17 22:16:55 +01:00
|
|
|
overflow: hidden;
|
2019-01-03 02:07:16 +01:00
|
|
|
background-color: #7f1416;
|
|
|
|
color: #fff;
|
|
|
|
margin: 0px;
|
|
|
|
margin-top: 0px;
|
|
|
|
padding-top: 8px;
|
|
|
|
padding-left: 15px;
|
|
|
|
padding-bottom: 1px;
|
|
|
|
font-size: 2.7em;
|
|
|
|
}
|
|
|
|
|
|
|
|
.menu-item-inline-desc{
|
|
|
|
font-size: 0.60em;
|
|
|
|
font-weight: 300;
|
|
|
|
font-variant: normal;
|
|
|
|
}
|
|
|
|
|
|
|
|
.left-side {
|
|
|
|
display: inline-block;
|
|
|
|
width: 39%;
|
|
|
|
float: left;
|
|
|
|
font-size: 1.6em;
|
|
|
|
}
|
|
|
|
|
|
|
|
.right-side {
|
|
|
|
display: inline-block;
|
|
|
|
width: 60%;
|
|
|
|
float: right;
|
|
|
|
}
|
|
|
|
|
|
|
|
.menu-item {
|
|
|
|
padding-left: 15px;
|
|
|
|
padding-top: 5px;
|
|
|
|
padding-bottom: 5px;
|
|
|
|
font-variant: small-caps;
|
|
|
|
border-left: transparent 5px solid;
|
|
|
|
}
|
|
|
|
|
|
|
|
.suboption {
|
|
|
|
display: block;
|
|
|
|
padding-left: 15px;
|
|
|
|
padding-right: 15px;
|
|
|
|
padding-top: 5px;
|
|
|
|
padding-bottom: 20px;
|
|
|
|
min-height: 250px;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#no-videos-display {
|
|
|
|
height: 100%;
|
|
|
|
padding-top: 50px;
|
|
|
|
/* text-align: center; */
|
|
|
|
}
|
|
|
|
|
|
|
|
.tabitem-container {
|
|
|
|
padding-top: 0.5em;
|
|
|
|
}
|
|
|
|
|
|
|
|
.selected-tab {
|
|
|
|
background-color: initial;
|
|
|
|
border-left: #f18810 5px solid;
|
|
|
|
}
|
|
|
|
|
|
|
|
.tabitem {
|
|
|
|
font-variant: normal;
|
|
|
|
font-size: 0.69em;
|
|
|
|
margin-left: 1em;
|
|
|
|
border-left: transparent 3px solid;
|
|
|
|
padding-left: 12px;
|
|
|
|
margin-left: -10px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.tabitem-selected {
|
|
|
|
color: #fff !important;
|
|
|
|
background-color: initial;
|
|
|
|
border-left: #f0c089 3px solid !important;
|
|
|
|
}
|
|
|
|
.tabitem-selected::before {
|
|
|
|
padding-right: 0.5em;
|
|
|
|
}
|
|
|
|
|
|
|
|
.tabitem-iframe::after {
|
|
|
|
content: "</>";
|
|
|
|
padding-left: 0.33em;
|
2018-12-30 23:16:09 +01:00
|
|
|
}
|
2019-01-17 22:16:55 +01:00
|
|
|
|
|
|
|
.popup {
|
|
|
|
max-width: 780px;
|
|
|
|
// width: 800px;
|
|
|
|
height: 600px;
|
|
|
|
}
|
2018-12-30 23:16:09 +01:00
|
|
|
</style>
|