-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathimg.ts
More file actions
44 lines (39 loc) · 1.24 KB
/
img.ts
File metadata and controls
44 lines (39 loc) · 1.24 KB
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
/* MoMath Math Square Behavior
*
* Title: Image
* Description: Display a static image
* Scheduler ID: multiple (see scheduler.ts)
* Framework: none
* Author: Dylan Simon <dylan@dylex.net>
* Created: 2017-03, generalized from existing images
* Updated: 2017-04 for SDK by dylan
* Status: works
*/
import {Behavior} from 'behavior';
import {params, form} from 'main';
import * as Display from 'display';
import {imgtoken} from 'prod';
function init(container: HTMLDivElement) {
var src = params.src;
const img = document.createElement('img');
img.width = Display.width;
img.height = Display.height;
(document.getElementById('src') as HTMLLabelElement).style['visibility'] = 'visible';
if (src) {
(form.elements.namedItem('src') as HTMLInputElement).value = src;
if (src.indexOf("/") == -1) {
src = "http://api.momath.org/api/v1/content/exhibit-blob/MASQ.OD.Graphics/00000000-0000-0000-0000-000000000000/" + src;
if (imgtoken)
src += "?tok=" + imgtoken;
}
img.src = src;
}
container.appendChild(img);
}
export const behavior: Behavior = {
title: "Static Image: " + params.src,
maxUsers: null, /* disable sensors */
init: init
/* no rendering */
};
export default behavior