Skip to content

Commit

Permalink
feat: add extra type libraries to improve typing and apply other sugg…
Browse files Browse the repository at this point in the history
…estions by reviewers
  • Loading branch information
BramDevlaminck committed Sep 2, 2022
1 parent 6a9586c commit 6b15644
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
11 changes: 5 additions & 6 deletions app/assets/javascripts/exercise.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { initTooltips, updateURLParameter } from "util.js";
import { Toast } from "./toast";
import GLightbox from "glightbox";
import {IFrameMessageData, IFrameResizedData} from "iframe-resizer";

function showLightbox(content): void {
const lightbox = new GLightbox(content);
Expand All @@ -17,16 +18,15 @@ function showLightbox(content): void {
document.body.focus();
}

function onFrameMessage(event): void {
function onFrameMessage(event: IFrameMessageData): void {
if (event.message.type === "lightbox") {
showLightbox(event.message.content);
}
}

function initLightboxes(): void {
let index = 0;
const images = [];
document.querySelectorAll<HTMLElement>(".activity-description img, a.dodona-lightbox").forEach(el => {
document.querySelectorAll<HTMLElement>(".activity-description img, a.dodona-lightbox").forEach((el, index) => {
const imagesrc = el.dataset.large || el.getAttribute("src") || el.getAttribute("href");
const altText = el.dataset.caption || el.getAttribute("alt") || imagesrc.split("/").pop();
const imageObject = {
Expand All @@ -36,7 +36,6 @@ function initLightboxes(): void {
images.push(imageObject);

el.dataset.image_index = index.toString();
index++;
});

document.querySelectorAll<HTMLElement>(".activity-description img, a.dodona-lightbox").forEach(el => {
Expand Down Expand Up @@ -117,7 +116,7 @@ function initExerciseDescription(): void {
}

function initExerciseShow(exerciseId: number, programmingLanguage: string, loggedIn: boolean, editorShown: boolean, courseId: number, _deadline: string, baseSubmissionsUrl: string): void {
let editor;
let editor: AceAjax.Editor;
let lastSubmission: string;
let lastTimeout: number;

Expand Down Expand Up @@ -267,7 +266,7 @@ function initExerciseShow(exerciseId: number, programmingLanguage: string, logge
});
}

function feedbackTableLoaded(userId: number, exerciseId: number, courseId: number): void {
function feedbackTableLoaded(userId: number, exerciseId: number, courseId: number | undefined): void {
enableSubmissionTableLinks();
if (lastSubmission) {
const submissionRow = document.getElementById("submission_" + lastSubmission);
Expand Down
3 changes: 0 additions & 3 deletions app/assets/javascripts/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,4 @@ declare interface Window {
parentIFrame: any;
}

// ace editor is globally available
declare var ace;

declare var dodona;
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@
"webpack-cli": "^4.9.2"
},
"devDependencies": {
"@types/ace": "^0.0.48",
"@types/bootstrap": "^5.2.3",
"@types/iframe-resizer": "^3.5.9",
"@types/jest": "^27.5.0",
"@types/serviceworker": "^0.0.51",
"@typescript-eslint/eslint-plugin": "^5.36.1",
Expand Down
10 changes: 10 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1520,6 +1520,11 @@
resolved "https://registry.yarnpkg.com/@tootallnate/once/-/once-1.1.2.tgz#ccb91445360179a04e7fe6aff78c00ffc1eeaf82"
integrity sha512-RbzJvlNzmRq5c3O09UipeuXno4tA1FE6ikOjxZK0tuxVv3412l64l5t1W5pj4+rJq9vpkm/kwiR07aZXnsKPxw==

"@types/ace@^0.0.48":
version "0.0.48"
resolved "https://registry.yarnpkg.com/@types/ace/-/ace-0.0.48.tgz#1cb81872a282da1b49de16976d39e767e5ca435d"
integrity sha512-esV6hOWiDOZ6d7w5S11iLu6LQsPGe/9RPzhri7gNNLdrK1LFpO9/m7IZhQL6dat0JHICJ7l51zvHAiCgnPLLHA==

"@types/babel__core@^7.0.0", "@types/babel__core@^7.1.7":
version "7.1.19"
resolved "https://registry.yarnpkg.com/@types/babel__core/-/babel__core-7.1.19.tgz#7b497495b7d1b4812bdb9d02804d0576f43ee460"
Expand Down Expand Up @@ -1803,6 +1808,11 @@
dependencies:
"@types/node" "*"

"@types/iframe-resizer@^3.5.9":
version "3.5.9"
resolved "https://registry.yarnpkg.com/@types/iframe-resizer/-/iframe-resizer-3.5.9.tgz#75c4cda33cee5f4da4c7693a0d9ad1ccb0c5ee98"
integrity sha512-RQUBI75F+uXruB95BFpC/8V8lPgJg4MQ6HxOCtAZYBB/h0FNCfrFfb4I+u2pZJIV7sKeszZbFqy1UnGeBMrvsA==

"@types/istanbul-lib-coverage@*", "@types/istanbul-lib-coverage@^2.0.0", "@types/istanbul-lib-coverage@^2.0.1":
version "2.0.4"
resolved "https://registry.yarnpkg.com/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.4.tgz#8467d4b3c087805d63580480890791277ce35c44"
Expand Down

0 comments on commit 6b15644

Please sign in to comment.