Akron | 479994e | 2018-07-02 13:21:44 +0200 | [diff] [blame] | 1 | <!DOCTYPE html> |
| 2 | <html> |
| 3 | <head> |
| 4 | <title>Plugin demo</title> |
Akron | e8e2c95 | 2018-07-04 13:43:12 +0200 | [diff] [blame] | 5 | |
Akron | 7f1e07e | 2020-08-24 20:12:14 +0200 | [diff] [blame] | 6 | <link type="text/css" rel="stylesheet" href="/css/kalamar-plugin.css" /> |
Akron | 479994e | 2018-07-02 13:21:44 +0200 | [diff] [blame] | 7 | |
| 8 | <!-- load client javascript library --> |
Akron | a6c32b9 | 2018-07-02 18:39:42 +0200 | [diff] [blame] | 9 | <script src="/js/src/plugin/client.js" data-server="http://localhost:3003/"></script> |
| 10 | <style> |
| 11 | body, html { |
Akron | e8e2c95 | 2018-07-04 13:43:12 +0200 | [diff] [blame] | 12 | padding: 0; |
| 13 | margin: 0; |
| 14 | box-sizing: border-box; |
| 15 | border-width: 0; |
| 16 | height: unset !important; |
| 17 | } |
| 18 | |
| 19 | body { |
| 20 | min-height: unset !important; |
Akron | a6c32b9 | 2018-07-02 18:39:42 +0200 | [diff] [blame] | 21 | } |
| 22 | </style> |
Akron | 479994e | 2018-07-02 13:21:44 +0200 | [diff] [blame] | 23 | </head> |
Akron | 7f1e07e | 2020-08-24 20:12:14 +0200 | [diff] [blame] | 24 | <body class="result-view"> |
Akron | 479994e | 2018-07-02 13:21:44 +0200 | [diff] [blame] | 25 | <h2>Example Widget!</h2> |
Akron | a99315e | 2018-07-03 22:56:45 +0200 | [diff] [blame] | 26 | <script> |
| 27 | function flood () { |
| 28 | var i = 0; |
| 29 | for (; i < 90; i++) { |
Akron | c300364 | 2020-03-30 10:19:14 +0200 | [diff] [blame] | 30 | KorAPlugin.sendMsg({ |
Akron | a99315e | 2018-07-03 22:56:45 +0200 | [diff] [blame] | 31 | 'action' : '-' |
| 32 | }); |
| 33 | }; |
| 34 | }; |
Akron | 22598cd | 2019-12-09 14:59:03 +0100 | [diff] [blame] | 35 | |
| 36 | function pluginit (p) { |
| 37 | p.onMessage = function(msg) { |
Akron | 51ee623 | 2019-12-17 21:00:05 +0100 | [diff] [blame] | 38 | switch (msg.key) { |
| 39 | // console.log("State changed to", msg.key, msg.value); |
| 40 | case 'glemm': |
| 41 | let data = { |
| 42 | 'action' : 'pipe', |
| 43 | 'service' : 'http://glemm/' |
| 44 | }; |
| 45 | |
| 46 | if (!msg.value) { |
| 47 | data['job'] = 'del'; |
| 48 | }; |
| 49 | KorAPlugin.sendMsg(data); |
| 50 | break; |
| 51 | } |
Akron | 22598cd | 2019-12-09 14:59:03 +0100 | [diff] [blame] | 52 | }; |
| 53 | }; |
Akron | ec4bbfa | 2021-09-15 15:00:59 +0200 | [diff] [blame] | 54 | |
| 55 | function redirect() { |
| 56 | |
| 57 | KorAPlugin.requestMsg({ |
| 58 | "action":"get", |
| 59 | "key": 'QueryParam' |
| 60 | }, function (d) { |
| 61 | |
Akron | 4de759f | 2021-10-13 10:46:45 +0200 | [diff] [blame] | 62 | const par = new URLSearchParams(d.value.search); |
Akron | ec4bbfa | 2021-09-15 15:00:59 +0200 | [diff] [blame] | 63 | par.set("q",56); |
| 64 | |
| 65 | KorAPlugin.sendMsg({ |
| 66 | 'action':'redirect', |
| 67 | 'queryParam' : par.toString() |
| 68 | }) |
| 69 | }); |
Akron | ec4bbfa | 2021-09-15 15:00:59 +0200 | [diff] [blame] | 70 | } |
Akron | 4de759f | 2021-10-13 10:46:45 +0200 | [diff] [blame] | 71 | |
| 72 | function getQueryParam() { |
| 73 | KorAPlugin.requestMsg({ |
| 74 | "action":"get", |
| 75 | "key": 'QueryParam' |
| 76 | }, function (d) { |
| 77 | KorAPlugin.log(0, d.value.search); |
| 78 | }); |
| 79 | } |
Akron | ec4bbfa | 2021-09-15 15:00:59 +0200 | [diff] [blame] | 80 | |
Akron | 22598cd | 2019-12-09 14:59:03 +0100 | [diff] [blame] | 81 | </script> |
Akron | a6c32b9 | 2018-07-02 18:39:42 +0200 | [diff] [blame] | 82 | <ul> |
| 83 | <li><a onclick="KorAPlugin.log(333, 'Huhu!')">Send log!</a></li> |
| 84 | <li><a onclick="KorAPlugin.resize()">Resize</a></li> |
Akron | 51ee623 | 2019-12-17 21:00:05 +0100 | [diff] [blame] | 85 | <li><a onclick="KorAPlugin.sendMsg({'action':'pipe','service':'Glemm'})">Add Glemm</a></li> |
Akron | 4de759f | 2021-10-13 10:46:45 +0200 | [diff] [blame] | 86 | <li><a onclick="getQueryParam()">GetQueryParam</a></li> |
Akron | ec4bbfa | 2021-09-15 15:00:59 +0200 | [diff] [blame] | 87 | <li><a onclick="redirect()">Redirect</a></li> |
Akron | a99315e | 2018-07-03 22:56:45 +0200 | [diff] [blame] | 88 | <li><a onclick="flood()">Flood!</a></li> |
Akron | c300364 | 2020-03-30 10:19:14 +0200 | [diff] [blame] | 89 | <li><a onclick="KorAPlugin.requestMsg({'action':'get', 'key':'KQ'}, function (d) { document.write(JSON.stringify(d.value))})">Get KQ</a></li> |
Akron | 338b4d4 | 2022-12-20 13:59:22 +0100 | [diff] [blame] | 90 | <li><a onclick="KorAPlugin.requestMsg({'action':'get', 'key':'textSigle', 'value':'textSigle'}, function (d) { document.write(JSON.stringify(d.value))})">Get textSigle</a></li> |
Akron | 7d18d8e | 2024-11-08 11:08:48 +0100 | [diff] [blame] | 91 | <li><a onclick="KorAPlugin.sendMsg({'action':'set', 'key':'QueryForm', 'value':{'q':'[This][is][a][query]'}})">Set query</a></li> |
Akron | a6c32b9 | 2018-07-02 18:39:42 +0200 | [diff] [blame] | 92 | </ul> |
Akron | 8d646d7 | 2018-07-08 13:45:53 +0200 | [diff] [blame] | 93 | <p style="width: 2000px">------------------------------------------------------------------------------------------------------------------------</p> |
Akron | 479994e | 2018-07-02 13:21:44 +0200 | [diff] [blame] | 94 | </body> |
| 95 | </html> |