forked from TFNS/CTFNote
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathTask.vue
58 lines (52 loc) · 1.43 KB
/
Task.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<template>
<q-page class="page">
<iframe v-if="task" :src="task.padUrl" />
<p v-else>Unable to load task</p>
</q-page>
</template>
<script lang="ts">
import { Ctf, Id, Task } from 'src/ctfnote/models';
import { computed, defineComponent, onMounted, watch } from 'vue';
export default defineComponent({
props: {
ctf: { type: Object as () => Ctf, required: true },
taskId: { type: Number as unknown as () => Id<Task>, required: true },
},
setup(props) {
const task = computed(
() => props.ctf.tasks.find((t) => t.id == props.taskId) ?? null
);
watch(
task,
(task) => {
if (task) {
document.title = `CTFNote - ${task.title}`;
}
},
{ immediate: true }
);
onMounted(() => {
const taskFrame = window.frames[0];
taskFrame.addEventListener('DOMContentLoaded', () => {
// inject hotkey script with some CTFNote code to catch hotkey for search dialog
// and communicate that with the parent window
const hotkeyScript = taskFrame.document.createElement('script');
hotkeyScript.src = '/pad/js/hotkeys-iframe.js'; // this won't exist in development but will in production
taskFrame.document.body.appendChild(hotkeyScript);
});
});
return { task };
},
});
</script>
<style scoped>
iframe {
width: 100%;
height: 100%;
border: none;
}
.page {
display: grid;
grid-template-rows: 1fr;
}
</style>