Icon hinzugefügt

This commit is contained in:
silas
2018-10-06 17:17:38 +02:00
parent da2252fc11
commit 07ec39b1a1
18 changed files with 229 additions and 100 deletions

View File

@@ -18,7 +18,7 @@ import "./lib/pwa-user-management"
import {SettingsManager, SettingsSite} from "./lib/pwa-core";
import {Matomo, SoundManager} from "./lib/pwa-assets";
import {InstallManager, Matomo, SoundManager} from "./lib/pwa-assets";
import {MenuSite} from "../module/Application/pwa/js/site/MenuSite";
import {WordRotatorSettingFragment} from "../module/Application/pwa/js/Fragment/WordRotatorSettingFragment";
@@ -70,7 +70,7 @@ InitPromise.resolve(app).then(async function(){
app.start(MenuSite);
Translator.setLanguage("de");
// let matomo = new Matomo();
// console.log(await matomo._askIsTracking());
InstallManager.setCanInstallListener(e => {
console.log("can install!", e);
});
});

View File

@@ -8,6 +8,31 @@ class DelayPromise extends Promise {
}
}
class InstallManager{
static init(){
console.log("init");
window.addEventListener('beforeinstallprompt', e => {
console.log("beforeinstallprompt", e);
this.deferredPromt = e;
if (this.canInstallListener){
this.canInstallListener(this.deferredPromt);
}
});
}
static setCanInstallListener(listener, callIfCanInstall){
this.canInstallListener = listener;
callIfCanInstall = Helper.nonNull(callIfCanInstall, true);
if (callIfCanInstall && Helper.nonNull(this.deferredPromt)){
this.canInstallListener(this.deferredPromt);
}
}
}
InstallManager.init();
window.addEventListener("load", () => {
console.log("loaded");
});
class Matomo {
static init() {
@@ -246,6 +271,8 @@ class AudioChain {
this.startTime = null;
this.pauseTime = null;
this.source = null;
this.running = false;
}
setBuffer(buffer) {
@@ -263,8 +290,7 @@ class AudioChain {
}
}
async start(delay, offset, duration)
{
async start(delay, offset, duration) {
let source = this.context.createBufferSource();
source.loop = this.shouldLoop;
@@ -280,48 +306,24 @@ class AudioChain {
source.start(delay, offset, duration);
this.startTime = (new Date()).getTime();
this.source = source;
this.running = true;
}
async stop(delay){
if (Helper.isNotNull(this.source)){
this.pauseTime = ((new Date()).getTime())-this.startTime;
async stop(delay) {
if (Helper.isNotNull(this.source)) {
this.pauseTime = ((new Date()).getTime()) - this.startTime;
return this.source.stop(delay);
}
this.running = false;
return null;
}
async resume(){
console.log("resume-Time:", Helper.nonNull(this.pauseTime, 0)/1000.0);
return this.start(null, Helper.nonNull(this.pauseTime, 0)/1000.0);
}
}
class InitPromise$1
{
static addPromise(promise)
{
if (typeof promise === 'function')
{
let func = promise;
promise = InitPromise$1.mainPromise.then(function(app){
return (func(app));
});
async resume() {
if (!this.running) {
return this.start(null, Helper.nonNull(this.pauseTime, 0) / 1000.0);
}
InitPromise$1.promises.push(promise);
}
static resolve(app)
{
InitPromise$1.mainResolver(app);
return InitPromise$1.mainPromise.then(function(){
return Promise.all(InitPromise$1.promises);
});
}
}
InitPromise$1.promises = [];
InitPromise$1.mainPromise = new Promise(function(resolver){
InitPromise$1.mainResolver = resolver;
});
class SoundManager {
static getInstance() {
@@ -359,7 +361,7 @@ class SoundManager {
audioObject.timeOffset = Helper.nonNull(options.timeOffset, audioObject.timeOffset, 0);
this.channels[channel] = audioObject;
if (audioObject.muted){
if (audioObject.muted) {
this.stop(channel);
}
@@ -393,7 +395,7 @@ class SoundManager {
source.setBuffer(buffer);
//to prevent gap in mp3-files
source.setLooping(this.channels[channel].loop, 0.3, buffer.duration-0.3);
source.setLooping(this.channels[channel].loop, 0.3, buffer.duration - 0.3);
source.start();
@@ -410,21 +412,31 @@ class SoundManager {
oldAudio.source.stop();
}
}
get(channel) {
channel = Helper.nonNull(channel, SoundManager.CHANNELS.DEFAULT);
return this.channels[channel];
}
async resume(channel){
channel = Helper.nonNull(channel, SoundManager.CHANNELS.DEFAULT);
if (!this.channels[channel].muted && Helper.isNotNull(this.channels[channel].source)) {
return this.channels[channel].source.resume();
}
}
handleVisibilityChange() {
if (document.hidden){
for (let k in this.channels){
this.channels[k].source.stop();
if (document.hidden) {
for (let k in this.channels) {
if (Helper.isNotNull(this.channels[k].source)) {
this.channels[k].source.stop();
}
}
}
else{
for (let k in this.channels){
if (!this.channels[k].muted){
this.channels[k].source.resume();
else {
for (let k in this.channels) {
if (!this.channels[k].muted && Helper.isNotNull(this.channels[k].source)) {
this.channels[k].source.resume();
}
}
}
@@ -502,4 +514,4 @@ class TabbedFragment extends Fragment {
}
}
export { DelayPromise, Matomo, RotateHelper, ScaleHelper, AudioChain, SoundManager, TabbedFragment };
export { DelayPromise, InstallManager, Matomo, RotateHelper, ScaleHelper, AudioChain, SoundManager, TabbedFragment };

View File

@@ -44,6 +44,8 @@ export class LevelSite extends WordRotatorBaseSite {
volume: 0.7
}, SoundManager.CHANNELS.SOUND);
soundManager.resume(SoundManager.CHANNELS.MUSIC);
return super.onConstruct(args);
}

View File

@@ -90,7 +90,7 @@ body {
}
}
label{
font-size: 1em;
font-size: 1em !important;
}
.setting-row{