Copy alt to clipboard when running natively
This commit is contained in:
parent
f37337f088
commit
708afaf4d3
2 changed files with 56 additions and 9 deletions
19
main.js
19
main.js
|
|
@ -14,6 +14,8 @@ let schedule = {
|
|||
|
||||
const offlineTitle = 'OFFLINE';
|
||||
const offlineSubtitle = 'takin a nap';
|
||||
|
||||
let altText;
|
||||
let copyClipboard;
|
||||
let saveImage;
|
||||
|
||||
|
|
@ -91,7 +93,7 @@ function loadSchedule() {
|
|||
schedule = JSON.parse(atob(saved));
|
||||
}
|
||||
|
||||
function altText() {
|
||||
function generateAltText() {
|
||||
let altText = "ari melody LIVE schedule: ";
|
||||
|
||||
const activeDays = Object.keys(schedule.days)
|
||||
|
|
@ -113,9 +115,11 @@ function altText() {
|
|||
altText += `, `;
|
||||
}
|
||||
|
||||
alert(altText);
|
||||
return altText;
|
||||
}
|
||||
|
||||
altText = () => alert(generateAltText());
|
||||
|
||||
if ('webkit' in window && 'messageHandlers' in window.webkit) {
|
||||
let _promiseId = 0;
|
||||
let _promises = new Map();
|
||||
|
|
@ -136,6 +140,17 @@ if ('webkit' in window && 'messageHandlers' in window.webkit) {
|
|||
reject();
|
||||
});
|
||||
|
||||
altText = () => new Promise((resolve, reject) => {
|
||||
const thisPromiseId = ++_promiseId;
|
||||
|
||||
_promises.set(thisPromiseId, [resolve, reject]);
|
||||
|
||||
window.webkit.messageHandlers.altText.postMessage([
|
||||
thisPromiseId,
|
||||
generateAltText(),
|
||||
]);
|
||||
});
|
||||
|
||||
copyClipboard = () => new Promise((resolve, reject) => {
|
||||
const thisPromiseId = ++_promiseId;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue