• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<html>
2<head>
3<title>Dialog Test</title>
4<script>
5function show_alert() {
6  alert("I am an alert box!");
7}
8
9function show_confirm() {
10  var r = confirm("Press a button");
11  var msg = r ? "You pressed OK!" : "You pressed Cancel!";
12  document.getElementById('cm').innerText = msg;
13}
14
15function show_prompt() {
16  var name = prompt("Please enter your name" ,"Harry Potter");
17  if (name != null && name != "")
18    document.getElementById('pm').innerText = "Hello " + name + "!";
19}
20
21window.onbeforeunload = function() {
22  return 'This is an onbeforeunload message.';
23}
24
25function update_time() {
26  document.getElementById('time').innerText = new Date().toLocaleString();
27}
28
29function setup() {
30  update_time();
31  setInterval(update_time, 1000);
32
33  if (location.hostname != 'tests' && location.hostname != 'localhost') {
34    alert('Parts of this page can only be run from tests or localhost.');
35    return;
36  }
37
38  // Enable all elements.
39  var elements = document.getElementById("form").elements;
40  for (var i = 0, element; element = elements[i++]; ) {
41    element.disabled = false;
42  }
43}
44
45function show_file_dialog(element, test) {
46  var message = 'DialogTest.' + test;
47  var target = document.getElementById(element);
48
49  // Results in a call to the OnQuery method in dialog_test.cpp
50  window.cefQuery({
51    request: message,
52    onSuccess: function(response) {
53      target.innerText = response;
54    },
55    onFailure: function(error_code, error_message) {}
56  });
57}
58
59window.addEventListener('load', setup, false);
60</script>
61</head>
62<body bgcolor="white">
63<form id="form">
64Click a button to show the associated dialog type.
65<br/><input type="button" onclick="show_alert();" value="Show Alert">
66<br/><input type="button" onclick="show_confirm();" value="Show Confirm"> <span id="cm"></span>
67<br/><input type="button" onclick="show_prompt();" value="Show Prompt"> <span id="pm"></span>
68<br/>input type="file": <input type="file" name="pic" accept="text/*,.js,.css,image/*">
69<br/>input type="file" (directory): <input type="file" webkitdirectory  accept="text/*,.js,.css,image/*">
70<br/><input type="button" onclick="show_file_dialog('fo', 'FileOpen');" value="Show File Open" disabled="true"> <span id="fo"></span>
71<br/><input type="button" onclick="show_file_dialog('fom', 'FileOpenMultiple');" value="Show File Open Multiple" disabled="true"> <span id="fom"></span>
72<br/><input type="button" onclick="show_file_dialog('fof', 'FileOpenFolder');" value="Show File Open Folder" disabled="true"> <span id="fof"></span>
73<br/><input type="button" onclick="show_file_dialog('fs', 'FileSave');" value="Show File Save" disabled="true"> <span id="fs"></span>
74<p id="time"></p>
75</form>
76</body>
77</html>
78