Skip to content

Commit

Permalink
disable right click and console if monitorer is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
vdvibhu20 committed Apr 30, 2024
1 parent 8982d09 commit c5e3727
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions app/services/monitorer.js
Original file line number Diff line number Diff line change
@@ -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(),
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit c5e3727

Please sign in to comment.