From 2c89e4881f3c4adad862a8b51cee050b332ef7b4 Mon Sep 17 00:00:00 2001 From: Mechtel <mechtel@iqb.hu-berlin.de> Date: Fri, 12 Apr 2019 21:51:13 +0200 Subject: [PATCH] v1.3 costumtexts, booklet buttons wrap introducing srcdoc polyfill for edge --- src/app/about/about.component.ts | 4 +- src/app/start/start.component.ts | 10 +- .../unithost/unithost.component.ts | 5 +- src/environments/environment.build.ts | 2 +- src/environments/environment.prod.ts | 2 +- src/index.html | 118 +++++++++++++++++- 6 files changed, 134 insertions(+), 7 deletions(-) diff --git a/src/app/about/about.component.ts b/src/app/about/about.component.ts index c3e67665..db504334 100644 --- a/src/app/about/about.component.ts +++ b/src/app/about/about.component.ts @@ -1,3 +1,4 @@ +import { MainDataService } from 'src/app/maindata.service'; import { Component, Inject } from '@angular/core'; @Component({ @@ -8,6 +9,7 @@ export class AboutComponent { constructor( @Inject('APP_NAME') public appName: string, @Inject('APP_PUBLISHER') public appPublisher: string, - @Inject('APP_VERSION') public appVersion: string + @Inject('APP_VERSION') public appVersion: string, + public mds: MainDataService ) { } } diff --git a/src/app/start/start.component.ts b/src/app/start/start.component.ts index b1a9607d..f19c7361 100644 --- a/src/app/start/start.component.ts +++ b/src/app/start/start.component.ts @@ -60,9 +60,15 @@ export class StartComponent implements OnInit, OnDestroy { this.loginStatusText.push('Gruppe: ' + logindata.groupname); if (logindata.mode === 'trial') { - this.loginStatusText.push(this.mds.getCostumText('login_trialmodeText')); + const tmt = this.mds.getCostumText('login_trialmodeText'); + if (tmt.length > 0) { + this.loginStatusText.push(tmt); + } } else if (logindata.mode === 'review') { - this.loginStatusText.push(this.mds.getCostumText('login_reviewmodeText')); + const tmt = this.mds.getCostumText('login_reviewmodeText'); + if (tmt.length > 0) { + this.loginStatusText.push(tmt); + } } this.showLoginForm = false; diff --git a/src/app/test-controller/unithost/unithost.component.ts b/src/app/test-controller/unithost/unithost.component.ts index 0cb355c1..4db1f268 100644 --- a/src/app/test-controller/unithost/unithost.component.ts +++ b/src/app/test-controller/unithost/unithost.component.ts @@ -8,6 +8,8 @@ import { OnDestroy } from '@angular/core/src/metadata/lifecycle_hooks'; import { Location } from '@angular/common'; import { TaggedString, PageData, LastStateKey, LogEntryKey } from '../test-controller.interfaces'; +declare var srcDoc: any; + @Component({ templateUrl: './unithost.component.html', styleUrls: ['./unithost.component.css'] @@ -187,7 +189,7 @@ export class UnithostComponent implements OnInit, OnDestroy { this.setPageList([], ''); this.iFrameItemplayer = <HTMLIFrameElement>document.createElement('iframe'); - this.iFrameItemplayer.setAttribute('srcdoc', this.tcs.getPlayer(currentUnit.unitDef.playerId)); + // this.iFrameItemplayer.setAttribute('srcdoc', this.tcs.getPlayer(currentUnit.unitDef.playerId)); this.iFrameItemplayer.setAttribute('sandbox', 'allow-forms allow-scripts allow-same-origin'); this.iFrameItemplayer.setAttribute('class', 'unitHost'); this.iFrameItemplayer.setAttribute('height', String(this.iFrameHostElement.clientHeight)); @@ -209,6 +211,7 @@ export class UnithostComponent implements OnInit, OnDestroy { this.pendingUnitDefinition = null; } this.iFrameHostElement.appendChild(this.iFrameItemplayer); + srcDoc.set(this.iFrameItemplayer, this.tcs.getPlayer(currentUnit.unitDef.playerId)); } }); } diff --git a/src/environments/environment.build.ts b/src/environments/environment.build.ts index f6143522..9324f99b 100644 --- a/src/environments/environment.build.ts +++ b/src/environments/environment.build.ts @@ -5,5 +5,5 @@ export const environment = { testcenterUrl: '/', appName: 'IQB-Testcenter', appPublisher: 'IQB - Institut zur Qualitätsentwicklung im Bildungswesen', - appVersion: '1.2 - 7.4.2019' + appVersion: '1.3 - 12.4.2019' }; diff --git a/src/environments/environment.prod.ts b/src/environments/environment.prod.ts index c17f9a3b..a254c8c2 100644 --- a/src/environments/environment.prod.ts +++ b/src/environments/environment.prod.ts @@ -5,5 +5,5 @@ export const environment = { testcenterUrl: '/', appName: 'IQB-Testcenter', appPublisher: 'IQB - Institut zur Qualitätsentwicklung im Bildungswesen', - appVersion: '1.2 - 7.4.2019' + appVersion: '1.3 - 12.4.2019' }; diff --git a/src/index.html b/src/index.html index c8289e5e..c24fbf31 100644 --- a/src/index.html +++ b/src/index.html @@ -24,6 +24,122 @@ <tc-root> <p style="margin: 20px; color: white;">IQB-Testcenter: laden...</p> </tc-root> -</body> + <script> + (function(root, factory) { + // `root` does not resolve to the global window object in a Browserified + // bundle, so a direct reference to that object is used instead. + var _srcDoc = window.srcDoc; + + if (typeof define === "function" && define.amd) { + define(['exports'], function(exports) { + factory(exports, _srcDoc); + root.srcDoc = exports; + }); + } else if (typeof exports === "object") { + factory(exports, _srcDoc); + } else { + root.srcDoc = {}; + factory(root.srcDoc, _srcDoc); + } + })(this, function(exports, _srcDoc) { + var idx, iframes; + var isCompliant = !!("srcdoc" in document.createElement("iframe")); + var sandboxMsg = "Polyfill may not function in the presence of the " + + "`sandbox` attribute. Consider using the `force` option."; + var sandboxAllow = /\ballow-same-origin\b/; + /** + * Determine if the operation may be blocked by the `sandbox` attribute in + * some environments, and optionally issue a warning or remove the + * attribute. + */ + var validate = function( iframe, options ) { + var sandbox = iframe.getAttribute("sandbox"); + if (typeof sandbox === "string" && !sandboxAllow.test(sandbox)) { + if (options && options.force) { + iframe.removeAttribute("sandbox"); + } else if (!options || options.force !== false) { + logError(sandboxMsg); + iframe.setAttribute("data-srcdoc-polyfill", sandboxMsg); + } + } + }; + var implementations = { + compliant: function( iframe, content, options ) { + + if (content) { + validate(iframe, options); + iframe.setAttribute("srcdoc", content); + } + }, + legacy: function( iframe, content, options ) { + + var jsUrl; + + if (!iframe || !iframe.getAttribute) { + return; + } + + if (!content) { + content = iframe.getAttribute("srcdoc"); + } else { + iframe.setAttribute("srcdoc", content); + } + + if (content) { + validate(iframe, options); + + // The value returned by a script-targeted URL will be used as + // the iFrame's content. Create such a URL which returns the + // iFrame element's `srcdoc` attribute. + jsUrl = "javascript: window.frameElement.getAttribute('srcdoc');"; + + // Explicitly set the iFrame's window.location for + // compatability with IE9, which does not react to changes in + // the `src` attribute when it is a `javascript:` URL, for + // some reason + if (iframe.contentWindow) { + iframe.contentWindow.location = jsUrl; + } + + iframe.setAttribute("src", jsUrl); + } + } + }; + var srcDoc = exports; + var logError; + + if (window.console && window.console.error) { + logError = function(msg) { + window.console.error("[srcdoc-polyfill] " + msg); + }; + } else { + logError = function() {}; + } + + // Assume the best + srcDoc.set = implementations.compliant; + srcDoc.noConflict = function() { + window.srcDoc = _srcDoc; + return srcDoc; + }; + + // If the browser supports srcdoc, no shimming is necessary + if (isCompliant) { + return; + } + + srcDoc.set = implementations.legacy; + + // Automatically shim any iframes already present in the document + iframes = document.getElementsByTagName("iframe"); + idx = iframes.length; + console.log(idx.length); + while (idx--) { + srcDoc.set( iframes[idx] ); + } + + }); + </script> + </body> </html> <!-- class="mat-app-background"--> -- GitLab