From c5e3727362ff175de6f9737a6939c7012b2b8b8a Mon Sep 17 00:00:00 2001 From: Vibhu Dujari Date: Tue, 30 Apr 2024 15:28:32 +0530 Subject: [PATCH] disable right click and console if monitorer is enabled --- app/services/monitorer.js | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/app/services/monitorer.js b/app/services/monitorer.js index 0efe951..ff4a777 100644 --- a/app/services/monitorer.js +++ b/app/services/monitorer.js @@ -1,7 +1,6 @@ import Service from '@ember/service'; import { inject as service } from '@ember/service'; import { computed } from '@ember/object'; -// import Monitorer from '@coding-blocks/monitorer'; export default Service.extend({ router: service(), @@ -35,6 +34,10 @@ export default Service.extend({ window.addEventListener('monitorersuccess', this.monitorerSuccessEventHandler) } + if(this.contest.disallowNoFace || contest.disallowTabSwitch || contest.disallowWindowResize) { + await this.enableRightClickMonitorer() + await this.enableKeyboardMonitorer({ console: true }) + } if(this.contest.disallowTabSwitch) { await this.enableTabSwitchMonitorer() @@ -72,20 +75,36 @@ export default Service.extend({ await this.monitorer.enable({ noFace: true }) await this.monitorer.enable({ liveFeed: true }) }, - + + async enableRightClickMonitorer() { + await this.monitorer.enable({ rightClick: true }) + }, + + async enableKeyboardMonitorer(options) { + await this.monitorer.enable({ keyboard: options }) + }, + async disableTabSwitchMonitorer() { await this.monitorer.disable({ tabSwitch: true }) }, - + async disableWindowResizeMonitorer() { await this.monitorer.disable({ windowResize: true }) }, - + async disableNoFaceMonitorer() { await this.monitorer.disable({ noFace: true }) await this.monitorer.disable({ liveFeed: true }) }, + async disableRightClickMonitorer() { + await this.monitorer.disable({ rightClick: true }) + }, + + async disableKeyboardMonitorer(options) { + await this.monitorer.disable({ keyboard: true }) + }, + async monitorerFaultEventHandler(e) { const currentAttempt = await this.contest.currentAttempt if(!!!currentAttempt.id) return