Skip to content

Commit

Permalink
fix(player): load jQuery to support passing player configuration of m…
Browse files Browse the repository at this point in the history
…ore than 2083 characters (optional, feature flagged) PSVAMB-22008 (#417)

* fix(player): load jQuery to support passing player configuration of more than 2083 characters (optional, feature flagged) PSVAMB-22008

* load jQuery from local assets folder for on-prem with no Internet access PSVAMB-22008
  • Loading branch information
amirch1 authored Mar 3, 2021
1 parent 4548020 commit dbd590b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/app/shared/services/app.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,17 @@ export class AppService implements OnDestroy {
this._initAppError(error.message);
}
);

// Load jQuery to support player loading long configuration string (more than 2083 characters)
if (analyticsConfig.previewPlayer.loadJquery && document.getElementById("jquery") === null) {
let jq = document.createElement('script');
jq.src = 'assets/jquery-3.5.1.min.js';
jq.id = "jquery";
jq.integrity = "sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=";
jq.crossOrigin = "anonymous";
jq.async = false;
document.head.appendChild(jq);
}
}

private _initAppError(errorMsg: string): void {
Expand Down
2 changes: 2 additions & 0 deletions src/assets/jquery-3.5.1.min.js

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions src/configuration/analytics-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ export interface AnalyticsConfig {
viewsConfig?: {
[key: string]: ViewConfig;
};
previewPlayer?: {
loadJquery: boolean;
};
live?: {
pollInterval?: PollInterval;
healthNotificationsCount?: number;
Expand Down Expand Up @@ -118,6 +121,7 @@ export function setConfig(config: AnalyticsConfig, hosted = false): void {
analyticsConfig.viewsConfig = config.viewsConfig || { ...viewsConfig };
analyticsConfig.customData = config.customData || { };
analyticsConfig.multiAccount = config.multiAccount || false;
analyticsConfig.previewPlayer = config.previewPlayer || { loadJquery: true };
setLiveEntryUsersReports(config.liveEntryUsersReports);
if (config.customStyle) {
setCustomStyle(config.customStyle);
Expand Down

0 comments on commit dbd590b

Please sign in to comment.