35 lines
691 B
JavaScript
35 lines
691 B
JavaScript
/**
|
|
* {}
|
|
* @author yutent<yutent.io@gmail.com>
|
|
* @date 2023/07/20 14:19:13
|
|
*/
|
|
|
|
import 'es.shim'
|
|
import { $, bind } from 'wkit'
|
|
|
|
async function test1() {
|
|
try {
|
|
var result = await window.webkit.messageHandlers.app.postMessage({
|
|
value: 'Test 1'
|
|
})
|
|
$('#output').innerHTML = 'output: ' + result
|
|
} catch (err) {
|
|
alert(err)
|
|
}
|
|
}
|
|
async function test2() {
|
|
let key = 'cb_' + Math.random().toString().slice(2)
|
|
|
|
window.$on(key, function (v) {
|
|
$('#output').innerHTML = v
|
|
})
|
|
window.webkit.messageHandlers.app.postMessage({
|
|
value: new Date(),
|
|
key
|
|
})
|
|
$('#output').innerHTML = result
|
|
}
|
|
|
|
bind($('.btn1'), 'click', test1)
|
|
bind($('.btn2'), 'click', test2)
|
Python
60.1%
JavaScript
37.6%
HTML
2.3%