forked from finos/SymphonyElectron
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwin.html
134 lines (120 loc) · 3.71 KB
/
win.html
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
<html>
<head>
<meta charset="UTF-8" />
<title>Test pop-out window</title>
<link rel="stylesheet" href="download-manager.css" />
</head>
Test Window has been opened
<p>
<label for="tag">tag:</label>
<input type="text" id="tag" value="" />
</p>
<button id="open-win">Open a new child window</button>
<br />
<br />
<button id="open-in-browser">Open Symphony in browser</button>
<br />
<br />
<a href="https://symphony.com" target="_blank">Open Symphony</a>
<hr />
<textarea id="text-val" rows="4">Writes some thing to the file</textarea>
<br />
<input type="button" id="download-file1" value="Download" />
<input type="button" id="download-file2" value="Download" />
<div id="footer" class="hidden">
<div id="download-manager-footer" class="download-bar"></div>
</div>
<p>Badge Count:</p>
<p>
<button id="inc-badge">increment badge count</button>
<br />
<script>
var badgeCount = 0;
var incBadgeEl = document.getElementById('inc-badge');
incBadgeEl.addEventListener('click', function () {
badgeCount++;
if (window.ssf) {
ssf.setBadgeCount(badgeCount);
} else {
postMessage(
{ method: 'set-badge-count', data: badgeCount },
window.origin,
);
}
});
var openWinButton = document.getElementById('open-win');
openWinButton.addEventListener('click', function () {
win = window.open(
'childWin.html?x=200&y=200',
'childWin',
'height=500,width=500',
);
});
var openInBrowser = document.getElementById('open-in-browser');
openInBrowser.addEventListener('click', function () {
window.open('https://symphony.com');
});
/**
* Download Manager api handler
*/
const download = (filename, text) => {
const element = document.createElement('a');
element.setAttribute(
'href',
'data:text/plain;charset=utf-8,' + encodeURIComponent(text),
);
element.setAttribute('download', filename);
element.style.display = 'none';
document.body.appendChild(element);
element.click();
document.body.removeChild(element);
};
// Start file download.
document.getElementById('download-file1').addEventListener(
'click',
() => {
const filename = 'hello.txt';
const text = document.getElementById('text-val').value;
download(filename, text);
},
false,
);
document.getElementById('download-file2').addEventListener(
'click',
() => {
const filename = 'bye.txt';
const text = document.getElementById('text-val').value;
download(filename, text);
},
false,
);
</script>
</p>
<hr />
<p>Native Window Handle:</p>
<button id="get-window-handle">Get window handle</button>
<input type="text" id="text-window-handle" />
<script>
document
.getElementById('get-window-handle')
.addEventListener('click', () => {
const resultCallback = (handle) => {
const handleStr = [...handle]
.map((b) => b.toString(16).padStart(2, '0'))
.join('');
document.getElementById('text-window-handle').value = handleStr;
};
if (window.ssf) {
window.ssf.getNativeWindowHandle().then(resultCallback);
} else if (window.manaSSF) {
window.manaSSF.getNativeWindowHandle().then(resultCallback);
} else {
postRequest(apiCmds.getNativeWindowHandle, null, {
successCallback: resultCallback,
});
}
});
</script>
<hr />
<br />
</html>