-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconsole.php
More file actions
44 lines (34 loc) · 976 Bytes
/
console.php
File metadata and controls
44 lines (34 loc) · 976 Bytes
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
<?php
if(! class_exists('Webview')) {
require_once __DIR__ .'/webview.stub.php';
}
$html = <<<EOD
EOD;
$webview = new Webview();
$webview->set_title("Hello World");
$webview->set_size(600, 450);
$webview->set_html("
<h2>Time: <span id='hour'>HH</span>:<span id='minute'>mm</span>:<span id='second'>ii</span> </h2>
");
// redirect the console log to the PHP console
$webview->init("
window.console = {
log: function(data){
window.console_log(JSON.stringify(data));
}
}
window.onload = function(){
setInterval(function() {
var date = new Date();
hour.innerText = date.getHours();
minute.innerText = date.getMinutes();
second.innerText = date.getSeconds();
console.log('Date: ' + date);
}, 1000);
}
");
$webview->bind('console_log', function($data){
echo print_r(json_decode($data), true). PHP_EOL;
});
$webview->run();
unset($webview);