-
Notifications
You must be signed in to change notification settings - Fork 4
/
HarmonyExport.js
144 lines (136 loc) · 15.6 KB
/
HarmonyExport.js
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
import { Base64 } from "js-base64";
(function (global, factory) {
typeof exports === "object" && typeof module !== "undefined"
? (module.exports = factory())
: typeof define === "function" && define.amd
? define(factory)
: ((global =
typeof globalThis !== "undefined" ? globalThis : global || self),
(global.HarmonyExport = factory()));
})(this, function () {
"use strict";
const harmonyURL = "https://harmonydata.ac.uk/app/#/";
const createHarmonyUrl = ({ questions, instrument_name }) => {
//
if (
Array.isArray(questions) &&
questions.length &&
questions.every(
(q) =>
typeof q === "string" ||
q instanceof String ||
(q.question_text &&
(typeof q.question_text === "string" ||
q.question_text instanceof String))
)
) {
const qArray = questions.map((q, i) => {
return {
question_no: q.question_no || i,
question_text: q.question_text || q,
};
});
const iArray = { instrument_name: instrument_name, questions: qArray };
return (
harmonyURL + "import/" + Base64.encode(JSON.stringify(iArray), true)
);
} else {
throw new Error(
"questions is not properly formatted - it must be an array of question texts, or an array of objects which each must have a question_text property"
);
}
};
class HarmonyExportComponent extends HTMLElement {
constructor() {
super();
this._questions = [];
this._instrument_name = "Imported Instrument";
this._size = "26px";
this.attachShadow({ mode: "open" });
this.shadowRoot.innerHTML = `
<style>
#harmony-link {
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAALQAAAC0CAYAAAA9zQYyAAAAAXNSR0IArs4c6QAAIABJREFUeF7tnQl4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UbIXNxlpsdlRekSvr3/cvYK20Yx7Mbt2yxQUyMlp0Be1hXUm3D2QEUsxE/9AxITVElZZEinB3TVGSnDRR7t4kAAAA+0lEQVQkEsoYHU6GhQKAAcZVbqfdpZW0oyyPVF1x3oPKKkMAqDpfttsFMte3WCQJ5Pb1FrYjJ0nnSCMQrCPQeRY6WCWUnktUIyABLSp1C19YCWjh61hUEkpAi0rdwhdWAlr4OhaVhBLQolK38IWVgBa+jkUloQS0qNQtfGEloIWvY1FJKAEtKnULX1gJaOHrWFQSSkCLSt3CF1YCWvg6FpWEEtCiUrfwhZWAFr6ORSWhBLSo1C18YSWgha9jUUkoAS0qdQtfWAlo4etYVBJKQItK3cIXVgJa+DoWlYQS0KJSt/CFlYAWvo5FJaEEtKjULXxhJaCFr2NRSfj/erSwqjY+tXwAAAAASUVORK5CYII=");
display: block;
max-height: 180px;
max-width: 180px;
font-size: 0;
background-size: cover;
background-repeat: no-repeat;
background-position: center center;
flex-shrink: 0;
}
.format-error {
display: block;
color: red;
font-size: 2rem!important;
flex-shrink: 0;
}
</style>
<a target="${harmonyURL}" id="harmony-link"></a>
`;
}
get size() {
return this._size;
}
set size(size) {
this._size = size;
}
get questions() {
return this._questions;
}
set questions(questions) {
this._questions = questions;
}
get instrument_name() {
return this._instrument_name;
}
set instrument_name(instrument_name) {
this._instrument_name = instrument_name;
}
connectedCallback() {
let questionsA;
try {
questionsA = JSON.parse(this.getAttribute("questions"));
if (!Array.isArray(questionsA)) {
console.log("Could not parse question attibutes");
questionsA = null;
}
} catch (e) {
console.log("Could not parse question attibutes");
}
const instrument_nameA = this.getAttribute("instrument_name");
const sizeA = this.getAttribute("size");
// attributes app
const size = sizeA || this._size;
const questions = questionsA || this._questions;
const instrument_name = instrument_nameA || this._instrument_name;
try {
console.log("WCquestions", questions);
console.log("WClabel", instrument_name);
const url = createHarmonyUrl({
questions: questions,
instrument_name: instrument_name,
});
console.log("WCurl", instrument_name);
this.shadowRoot.getElementById("harmony-link").href = url;
this.shadowRoot.getElementById("harmony-link").style.width = size;
this.shadowRoot.getElementById("harmony-link").style.height = size;
} catch (e) {
//display an error message in the component to help debugging
this.shadowRoot.getElementById("harmony-link").text = e;
this.shadowRoot.getElementById("harmony-link").classList.add =
"format-error";
}
}
}
// Register the custom element
customElements.define("harmony-export", HarmonyExportComponent);
window.HarmonyExportComponent = HarmonyExportComponent;
window.createHarmonyUrl = createHarmonyUrl;
// Expose functions in the library object
return {
createHarmonyUrl,
HarmonyExportComponent,
};
});