Skip to content

Commit

Permalink
Show explicit tab switch prompt
Browse files Browse the repository at this point in the history
  • Loading branch information
vdvibhu20 committed Mar 9, 2024
1 parent dfb81c0 commit 64624fb
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
2 changes: 2 additions & 0 deletions app/pods/components/full-screen-contest-view/component.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import Component from '@ember/component';
import { inject as service } from '@ember/service';

export default class FullScreenContestView extends Component {
@service monitorer
showSubmitDialog = false
}
6 changes: 5 additions & 1 deletion app/pods/components/full-screen-contest-view/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,8 @@
</div>
</div>
</ModalDialog>
{{/if}}
{{/if}}

<WPulse @class="display-inline" @triggered={{monitorer.tabSwitchTrigger}}>
<div class="bottom-bar t-align-c bg-gradient-pink font-md">You Switched the tab. 10 minutes deducted.</div>
</WPulse>
3 changes: 2 additions & 1 deletion app/services/monitorer.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export default Service.extend({
api: service(),
store: service(),
isEventListenerAdded: false,
tabSwitchTrigger: false,
monitoredRoutes: [
'contests.contest.attempt.content.problem',
'contests.contest.attempt.content.quiz',
Expand Down Expand Up @@ -44,7 +45,7 @@ export default Service.extend({
fault_type: 'tab_switch'
}
})

this.setProperties('tabSwitchTrigger', true)
await this.store.findRecord('contest-attempt', currentAttempt.id)
},

Expand Down
7 changes: 7 additions & 0 deletions app/styles/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,13 @@ body{
animation: pulse-animation-red 2s infinite;
}

.bottom-bar {
position: fixed;
bottom: 0;
padding: 2rem 4rem;
width: 100vw;
}

// Animations

@keyframes dots {
Expand Down

0 comments on commit 64624fb

Please sign in to comment.