Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if(this.isRunningCordova()) {
// deviceready may not work, because cordova is already loaded, so try to set it ready after some time
setTimeout(() => this.deviceIsReady = true, 1000);
}
//adding listener for cordova events
document.addEventListener('deviceready', () => {
this.deviceIsReady = true;
}, false);
document.addEventListener('pause', whenDeviceGoesBackground, false);
document.addEventListener('resume', whenDeviceGoesForeground, false);
// just for simulation on forced cordova mode
if ((this.forceCordovaMode) && (!this.isReallyRunningCordova())) {
console.log("SIMULATED deviceready event in FORCED CORDOVA MODE (just use during development)");
setTimeout(this.whenDeviceIsReady,500+Math.random()*1000);
} else if(this.isReallyRunningCordova()) {
this.deviceReadyLoop(1);
}
}
* ignore pauses under 1 minute that appear when going into
* a plugin (camera) or you get a permission request from the OS
*/
if (this.appGoneBackgroundTS==null) return;
if ((Date.now()-this.appGoneBackgroundTS)<(60*1000)) return;
// OK - real pasuse detected
console.log("CordovaService: App comes back from Background");
// call listener if set
if (this.deviceResumeCallback!=null) this.deviceResumeCallback();
};
if(this.isRunningCordova()) {
// deviceready may not work, because cordova is already loaded, so try to set it ready after some time
setTimeout(() => this.deviceIsReady = true, 1000);
}
//adding listener for cordova events
document.addEventListener('deviceready', () => {
this.deviceIsReady = true;
}, false);
document.addEventListener('pause', whenDeviceGoesBackground, false);
document.addEventListener('resume', whenDeviceGoesForeground, false);
// just for simulation on forced cordova mode
if ((this.forceCordovaMode) && (!this.isReallyRunningCordova())) {
console.log("SIMULATED deviceready event in FORCED CORDOVA MODE (just use during development)");
setTimeout(this.whenDeviceIsReady,500+Math.random()*1000);
} else if(this.isReallyRunningCordova()) {
this.deviceReadyLoop(1);
}
let waitLoop = () => {
if (this.serviceIsReady) {
observer.next(null);
observer.complete();
} else {
console.log("Waiting for Device Ready .. waitloop");
setTimeout(waitLoop,200);
}
};
waitLoop();
private deviceReadyLoop(counter:number) : void {
console.log("deviceReadyLoop("+counter+")");
setTimeout(()=>{
if (this.deviceIsReady) {
this.whenDeviceIsReady();
} else {
this.deviceReadyLoop(++counter);
}
},250);
}
it('shows updated state after sucessfull request', (done) => {
mock.onPut().reply(200, {}, {});
const button = document.querySelector('.js-toggle-cluster-list');
button.click();
expect(button.classList).toContain('is-loading');
setTimeout(() => {
expect(button.classList).not.toContain('is-loading');
expect(button.classList).not.toContain('is-checked');
done();
}, 0);
});
data: {}
}
case 'SET_USER_STATUS':
component = action.component;
const checkTimeout = 15;
const ts = component.props.user.timestamp || parseInt(localStorage['userTimestamp'], 10);
if (!localStorage['_jwt']) {
if (ts) {
return { ...state }
}
setTimeout(component.props.userLogOut, 1);
setTimeout(component.props.setUserTimestamp, 1);
return { ...state }
}
now = Math.round(new Date().getTime() / 1000);
if (ts && now - ts < checkTimeout && !action.force) {
return {
...state
}
}
Axios.post(
"http://localhost:5000/auth/status",
{ status: true },
{
headers: {
togglePanel() {
this.sidePanelRef.toggleSidePanel();
setTimeout(() => {
this.datatableWorkitems = [...this.datatableWorkitems];
}, 500);
}
public cycleBackground() {
setTimeout(() => {
this.images.getRandomBackground().subscribe(x => {
this.background = "";
});
}, 10000);
setTimeout(() => {
this.images.getRandomBackground().subscribe(x => {
this.background = this.sanitizer
.bypassSecurityTrustStyle("linear-gradient(-10deg, transparent 20%, rgba(0,0,0,0.7) 20.0%, rgba(0,0,0,0.7) 80.0%, transparent 80%), url(" + x.url + ")");
});
}, 10000);
}
}
public runAnimation() {
this.visible = true;
let positionDiff:Point = new Point(this.to.x - this.from.x, this.to.y - this.from.y);
setTimeout(()=>{
this.transformStyle = 'translate('+ positionDiff.x + 'px,' + positionDiff.y +'px)';
}, 0);
};
fn = f => setTimeout(f, 0)
}