index.html 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <!DOCTYPE html>
  2. <html>
  3. <body>
  4. <div>
  5. <button id="log">Call Log API</button>
  6. <button id="request">Call Request (async) API</button>
  7. <button id="event">Send event to Rust</button>
  8. </div>
  9. <div style="margin-top: 24px">
  10. <select id="dir">
  11. <option value="">None</option>
  12. </select>
  13. <input id="path-to-read" placeholder="Type the path to read...">
  14. <button id="read">Read</button>
  15. </div>
  16. <div style="margin-top: 24px">
  17. <input id="url" value="https://tauri.studio">
  18. <button id="open-url">Open URL</button>
  19. </div>
  20. <div style="margin-top: 24px">
  21. <input id="title" value="Awesome Tauri Example!">
  22. <button id="set-title">Set title</button>
  23. </div>
  24. <div style="margin-top: 24px">
  25. <input id="dialog-default-path" placeholder="Default path">
  26. <input id="dialog-filter" placeholder="Extensions filter">
  27. <div>
  28. <input type="checkbox" id="dialog-multiple">
  29. <label>Multiple</label>
  30. </div>
  31. <div>
  32. <input type="checkbox" id="dialog-directory">
  33. <label>Directory</label>
  34. </div>
  35. <button id="open-dialog">Open dialog</button>
  36. <button id="save-dialog">Open save dialog</button>
  37. </div>
  38. <div id="response"></div>
  39. <script>
  40. function registerResponse (response) {
  41. document.getElementById('response').innerHTML = typeof response === 'object'
  42. ? JSON.stringify(response)
  43. : response
  44. }
  45. function addClickEnterHandler (button, input, handler) {
  46. button.addEventListener('click', handler)
  47. input.addEventListener('keyup', function (e) {
  48. if (e.keyCode === 13) {
  49. handler()
  50. }
  51. })
  52. }
  53. window.onTauriInit = function () {
  54. window.tauri.listen('rust-event', function (res) {
  55. document.getElementById('response').innerHTML = JSON.stringify(res)
  56. })
  57. var dirSelect = document.getElementById('dir')
  58. for (var key in window.tauri.Dir) {
  59. var value = window.tauri.Dir[key]
  60. var opt = document.createElement("option")
  61. opt.value = value
  62. opt.innerHTML = key
  63. dirSelect.appendChild(opt)
  64. }
  65. }
  66. </script>
  67. <script src="communication.js"></script>
  68. <script src="fs.js"></script>
  69. <script src="window.js"></script>
  70. <script src="dialog.js"></script>
  71. </body>
  72. </html>