mirror of
https://github.com/finos/SymphonyElectron.git
synced 2024-12-28 09:51:06 -06:00
105 lines
3.5 KiB
HTML
105 lines
3.5 KiB
HTML
<html>
|
|
<head>
|
|
</head>
|
|
<body>
|
|
<h1>Symphony Electron API Demo</h1>
|
|
<hr>
|
|
<p>Notifications:<p>
|
|
<button id='notf'>show notification</button>
|
|
<p>
|
|
<label for='title'>title:</label>
|
|
<input type='text' id='title' value='Notification Demo'/>
|
|
</p>
|
|
<p>
|
|
<label for='body'>body:</label>
|
|
<input type='text' id='body' value='Some message'/>
|
|
</p>
|
|
<p>
|
|
<label for='image'>image url:</label>
|
|
<input type='text' id='image' value='https://lh3.googleusercontent.com/-s2PXL6wWMCc/AAAAAAAAAAI/AAAAAAAAAAA/AAomvV2gUNMMeFsOijwVVpihfg_anpKWQA/s32-c-mo/photo.jpg'/>
|
|
</p>
|
|
<p>
|
|
<label for='flash'>flash:</label>
|
|
<input type='checkbox' id='flash'/>
|
|
</p>
|
|
<p>
|
|
<label for='color'>color:</label>
|
|
<input type='text' id='color' value='white'/>
|
|
<br>
|
|
<hr>
|
|
<p>Badge Count:<p>
|
|
<button id='inc-badge'>increment badge count</button>
|
|
<br>
|
|
<button id='clear-badge'>clear badge count</button>
|
|
</body>
|
|
<script>
|
|
var notfEl = document.getElementById('notf');
|
|
var num = 0;
|
|
|
|
// note: notification will close when clicked
|
|
notfEl.addEventListener('click', function() {
|
|
var title = document.getElementById('title').value;
|
|
var body = document.getElementById('body').value;
|
|
var imageUrl = document.getElementById('image').value;
|
|
var shouldFlash = document.getElementById('flash').checked;
|
|
var color = document.getElementById('color').value;
|
|
|
|
num++;
|
|
|
|
// notfs with same groupId will replace existing notf.
|
|
var groupId = (num % 2).toString();
|
|
var notf = new SYM_API.Notification(title, {
|
|
body: (body + ' num=' + num + ' groupId=' + groupId),
|
|
image: imageUrl,
|
|
flash: shouldFlash,
|
|
color: color || 'white',
|
|
data: {
|
|
hello: 'hello word'
|
|
},
|
|
groupId: groupId
|
|
});
|
|
|
|
notf.addEventListener('click', onclick);
|
|
function onclick(event) {
|
|
event.target.data.then(function(value) {
|
|
alert('notification clicked: ' + value.hello);
|
|
})
|
|
}
|
|
|
|
notf.addEventListener('close', onclose);
|
|
function onclose() {
|
|
alert('notification closed');
|
|
removeEvents();
|
|
};
|
|
|
|
notf.addEventListener('error', onerror);
|
|
function onerror(event) {
|
|
alert('error=' + event.result);
|
|
};
|
|
|
|
// be sure to remove all events when closed, otherwise leaks
|
|
// will occur.
|
|
function removeEvents() {
|
|
notf.removeEventListener('click', onclick)
|
|
notf.removeEventListener('close', onclose)
|
|
notf.removeEventListener('error', onerror)
|
|
}
|
|
});
|
|
|
|
var badgeCount = 0;
|
|
|
|
var incBadgeEl = document.getElementById('inc-badge');
|
|
incBadgeEl.addEventListener('click', function() {
|
|
badgeCount++;
|
|
SYM_API.setBadgeCount(badgeCount);
|
|
});
|
|
|
|
var incBadgeEl = document.getElementById('clear-badge');
|
|
incBadgeEl.addEventListener('click', function() {
|
|
badgeCount = 0;
|
|
SYM_API.setBadgeCount(0);
|
|
});
|
|
|
|
</script>
|
|
</html>
|