HEX
Server: Apache
System: Linux vps.mmtprep.com 4.18.0-477.21.1.el8_8.x86_64 #1 SMP Thu Aug 10 13:51:50 EDT 2023 x86_64
User: mmtprep (1001)
PHP: 8.1.34
Disabled: exec,passthru,shell_exec,system
Upload Files
File: /home/mmtprep/public_html/mathzen.mmtprep.com/assets/_ExternalApp-RWK_ScaT.js.map
{"version":3,"file":"_ExternalApp-RWK_ScaT.js","sources":["../../src/exercices/apps/_ExternalApp.ts"],"sourcesContent":["import { get } from 'svelte/store'\nimport { globalOptions, resultsByExercice, exercicesParams } from '../../lib/stores/generalStore'\nimport { sendToCapytaleSaveStudentAssignment } from '../../lib/handleCapytale'\n\nconst titre = 'Application externe'\n\nclass ExternalApp {\n  typeExercice: string\n  numeroExercice!: number\n  sup!: string\n  titre: string\n  container: HTMLDivElement\n  iframe: HTMLIFrameElement\n  url: URL\n  state: 'done' | ''\n  type = 'app'\n  constructor (url: string) {\n    this.url = new URL(url)\n    this.titre = titre\n    this.typeExercice = 'html'\n    this.state = ''\n    this.container = document.createElement('div')\n    this.iframe = document.createElement('iframe')\n    this.iframe.setAttribute('width', '400px')\n    this.iframe.setAttribute('height', '300px')\n    this.iframe.classList.add('my-10')\n    this.iframe.setAttribute('allowfullscreen', '')\n    this.container.appendChild(this.iframe)\n    const updateIframeSize = () => {\n      if (window.innerWidth > window.innerHeight) {\n        this.iframe.setAttribute('width', '100%')\n        this.iframe.setAttribute('height', (document.body.offsetWidth * 0.75).toString())\n      } else {\n        this.iframe.setAttribute('width', '100%')\n        this.iframe.setAttribute('height', (document.body.offsetWidth * 1.5).toString())\n      }\n    }\n    window.addEventListener('resize', updateIframeSize)\n    window.addEventListener('orientationchange', updateIframeSize)\n    this.container.addEventListener('addedToDom', updateIframeSize)\n    window.addEventListener('message', (event) => {\n      if (event.data?.type === 'mathaleaSettings' && event.data?.numeroExercice === this.numeroExercice) {\n        this.sup = event.data.urlParams\n        exercicesParams.update((l) => {\n          l[this.numeroExercice].sup = event.data.urlParams\n          return l\n        })\n      }\n    })\n  }\n\n  get html () {\n    exercicesParams.update((l) => {\n      l[this.numeroExercice].type = 'app'\n      return l\n    })\n    this.handleScore()\n    if (this.sup !== undefined) {\n      const searchParams = new URLSearchParams(this.sup)\n      for (const [key, value] of searchParams.entries()) {\n        this.url.searchParams.append(key, value)\n      }\n    }\n    if (get(globalOptions).v === 'eleve') {\n      this.url.searchParams.append('v', 'eleve')\n    }\n    this.url.searchParams.append('numeroExercice', this.numeroExercice.toString())\n    this.iframe.setAttribute('src', this.url.toString())\n    return this.container\n  }\n\n  handleScore () {\n    window.addEventListener('message', (event) => {\n      if (event.data?.numeroExercice !== this.numeroExercice) return\n      if (event.data?.type === 'mathaleaSendScore') {\n        this.state = 'done'\n        const numberOfPoints = parseInt(event.data.score)\n        const indice = parseInt(event.data.numeroExercice)\n        const numberOfQuestions = parseInt(event.data.numberOfQuestions)\n        const answers = Array.isArray(event.data.finalState) ? event.data.finalState : [event.data.finalState]\n        const type = 'app'\n        resultsByExercice.update((l) => {\n          l[indice] = { numberOfPoints, numberOfQuestions, indice, answers, type }\n          return l\n        })\n        if (get(globalOptions).recorder === 'capytale') {\n          sendToCapytaleSaveStudentAssignment({ indiceExercice: this.numeroExercice })\n        }\n      } else if (event.data?.type === 'mathaleaHasScore') {\n        const numberOfPoints = parseInt(event.data.score)\n        const indice = parseInt(event.data.numeroExercice)\n        const numberOfQuestions = parseInt(event.data.numberOfQuestions)\n        const answers = Array.isArray(event.data.finalState) ? event.data.finalState : [event.data.finalState]\n        resultsByExercice.update((l) => {\n          l[indice] = { numberOfPoints, numberOfQuestions, indice, answers }\n          return l\n        })\n        const message = { type: 'mathaleaHasScore', score: numberOfPoints, numeroExercice: indice, numberOfQuestions, finalState: answers }\n        if (this.iframe !== null && this.iframe.contentWindow !== null) {\n          this.iframe.contentWindow.postMessage(message, '*')\n        }\n      }\n    })\n  }\n}\n\nexport default ExternalApp\n"],"names":["titre","ExternalApp","url","__publicField","updateIframeSize","event","_a","_b","exercicesParams","l","searchParams","key","value","get","globalOptions","numberOfPoints","indice","numberOfQuestions","answers","type","resultsByExercice","sendToCapytaleSaveStudentAssignment","_c","message"],"mappings":"iPAIA,MAAMA,EAAQ,sBAEd,MAAMC,CAAY,CAUhB,YAAaC,EAAa,CAT1BC,EAAA,qBACAA,EAAA,uBACAA,EAAA,YACAA,EAAA,cACAA,EAAA,kBACAA,EAAA,eACAA,EAAA,YACAA,EAAA,cACAA,EAAA,YAAO,OAEA,KAAA,IAAM,IAAI,IAAID,CAAG,EACtB,KAAK,MAAQF,EACb,KAAK,aAAe,OACpB,KAAK,MAAQ,GACR,KAAA,UAAY,SAAS,cAAc,KAAK,EACxC,KAAA,OAAS,SAAS,cAAc,QAAQ,EACxC,KAAA,OAAO,aAAa,QAAS,OAAO,EACpC,KAAA,OAAO,aAAa,SAAU,OAAO,EACrC,KAAA,OAAO,UAAU,IAAI,OAAO,EAC5B,KAAA,OAAO,aAAa,kBAAmB,EAAE,EACzC,KAAA,UAAU,YAAY,KAAK,MAAM,EACtC,MAAMI,EAAmB,IAAM,CACzB,OAAO,WAAa,OAAO,aACxB,KAAA,OAAO,aAAa,QAAS,MAAM,EACnC,KAAA,OAAO,aAAa,UAAW,SAAS,KAAK,YAAc,KAAM,UAAU,IAE3E,KAAA,OAAO,aAAa,QAAS,MAAM,EACnC,KAAA,OAAO,aAAa,UAAW,SAAS,KAAK,YAAc,KAAK,UAAU,EACjF,EAEK,OAAA,iBAAiB,SAAUA,CAAgB,EAC3C,OAAA,iBAAiB,oBAAqBA,CAAgB,EACxD,KAAA,UAAU,iBAAiB,aAAcA,CAAgB,EACvD,OAAA,iBAAiB,UAAYC,GAAU,WACxCC,EAAAD,EAAM,OAAN,YAAAC,EAAY,QAAS,sBAAsBC,EAAAF,EAAM,OAAN,YAAAE,EAAY,kBAAmB,KAAK,iBAC5E,KAAA,IAAMF,EAAM,KAAK,UACNG,EAAA,OAAQC,IACtBA,EAAE,KAAK,cAAc,EAAE,IAAMJ,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