OLD | NEW |
---|---|
1 <html> | 1 <html> |
2 <head> | 2 <head> |
3 <title>Cast shell remote debugging</title> | 3 <title>Cast shell remote debugging</title> |
4 <style> | 4 <style> |
5 .local-ui-link { | |
6 background-color: #eee; | |
7 border: 1px solid #ccc; | |
8 color: #333; | |
9 display: block; | |
10 font-family: monospace; | |
11 font-size: 11px; | |
12 margin: 4px; | |
13 padding: 4px; | |
14 width: 100%; | |
15 } | |
16 | |
17 .help { | |
18 font-size: 11px; | |
19 } | |
5 </style> | 20 </style> |
6 | 21 |
7 <script> | 22 <script> |
byungchul
2014/10/29 21:35:52
move script after body to faster loading.
gunsch
2014/10/29 23:02:00
Ha, it's literally loading 2 kilobytes over your l
| |
8 function onLoad() { | 23 window.addEventListener('load', function() { |
9 var tabs_list_request = new XMLHttpRequest(); | 24 var tabs_list_request = new XMLHttpRequest(); |
10 tabs_list_request.open("GET", "/json/list?t=" + new Date().getTime(), true); | 25 tabs_list_request.open("GET", "/json/list?t=" + new Date().getTime(), true); |
11 tabs_list_request.onreadystatechange = onReady; | 26 tabs_list_request.onreadystatechange = function() { |
12 tabs_list_request.send(); | 27 if (this.readyState == 4 && this.status == 200 && this.response) { |
13 } | |
14 | |
15 function onReady() { | |
16 if(this.readyState == 4 && this.status == 200) { | |
17 if(this.response != null) { | |
18 var responseJSON = JSON.parse(this.response); | 28 var responseJSON = JSON.parse(this.response); |
19 for (var i = 0; i < responseJSON.length; ++i) { | 29 for (var i = 0; i < responseJSON.length; ++i) { |
20 appendItem(responseJSON[i]); | 30 appendItem(responseJSON[i]); |
21 } | 31 } |
22 } | 32 } |
23 } | 33 }; |
24 } | 34 tabs_list_request.send(); |
35 }); | |
25 | 36 |
26 function appendItem(item_object) { | 37 function appendItem(metadata) { |
27 var frontend_ref; | 38 var item_container = document.createElement('div'); |
28 if (item_object.devtoolsFrontendUrl) { | 39 var frontend_link = document.createElement('a'); |
29 frontend_ref = document.createElement("a"); | 40 frontend_link.textContent = metadata.title || "(untitled tab)"; |
30 frontend_ref.href = item_object.devtoolsFrontendUrl; | 41 item_container.appendChild(frontend_link); |
byungchul
2014/10/29 21:35:53
I think it would be better to append child after c
gunsch
2014/10/29 23:02:00
That would be an incorrect functionality change: i
| |
31 frontend_ref.title = item_object.title; | 42 |
43 var is_debuggable = Boolean(metadata.devtoolsFrontendUrl); | |
byungchul
2014/10/29 21:35:53
!!metadata.devtoolsFrontendUrl?
gunsch
2014/10/29 23:01:59
Done.
| |
44 | |
45 if (metadata.devtoolsFrontendUrl) { | |
byungchul
2014/10/29 21:35:52
is_debuggable
gunsch
2014/10/29 23:02:00
Done.
| |
46 frontend_link.href = metadata.devtoolsFrontendUrl; | |
47 | |
48 var remote_help_text = document.createElement('div'); | |
49 remote_help_text.className = 'help'; | |
50 remote_help_text.innerHTML = | |
51 'You may have to select the shield icon in the address bar to ' + | |
byungchul
2014/10/29 21:35:53
This is true only for chrome. Explorer might not h
gunsch
2014/10/29 23:02:00
DevRel confirmed this isn't a concern, and that we
| |
52 'establish a connection. See the <a ' + | |
53 'href="https://support.google.com/chrome/answer/1342714?hl=en">help ' + | |
54 'center</a> for more information.'; | |
55 item_container.appendChild(remote_help_text); | |
56 | |
57 var local_ui_help_text = document.createElement('div'); | |
58 local_ui_help_text.className = 'help'; | |
59 local_ui_help_text.textContent = | |
60 'Or, copy/paste the URL below to your address bar.'; | |
61 item_container.appendChild(local_ui_help_text); | |
62 | |
63 var local_ui_link = document.createElement('textarea'); | |
64 local_ui_link.className = 'local-ui-link'; | |
65 local_ui_link.value = metadata.devtoolsFrontendUrl.replace( | |
dgozman
2014/10/29 22:40:14
This is actually not a local ui - it still fetches
gunsch
2014/10/29 23:01:59
Done.
| |
66 "http://chrome-devtools-frontend.appspot.com", | |
67 "chrome-devtools://devtools/remote"); | |
68 // Highlight text when clicked. | |
69 local_ui_link.onclick = function() { this.select(); } | |
70 item_container.appendChild(local_ui_link); | |
byungchul
2014/10/29 21:35:52
Why don't you put these div's in the body and cont
gunsch
2014/10/29 23:02:00
We could have multiple items in the list, if we're
byungchul
2014/10/29 23:19:16
At least, help texts can be static.
gunsch
2014/10/30 00:44:32
Done.
| |
32 } else { | 71 } else { |
33 frontend_ref = document.createElement("div"); | 72 frontend_link.textContent += " (already has active debugging session)"; |
34 frontend_ref.title = "The tab already has active debugging session"; | |
35 } | 73 } |
36 | 74 |
37 var text = document.createElement("div"); | 75 document.getElementById("items").appendChild(item_container); |
38 if (item_object.title) | |
39 text.innerText = item_object.title; | |
40 else | |
41 text.innerText = "(untitled tab)"; | |
42 text.style.cssText = "background-image:url(" + item_object.faviconUrl + ")"; | |
43 frontend_ref.appendChild(text); | |
44 | |
45 var item = document.createElement("p"); | |
46 item.appendChild(frontend_ref); | |
47 | |
48 document.getElementById("items").appendChild(item); | |
49 } | 76 } |
50 </script> | 77 </script> |
51 </head> | 78 </head> |
52 <body onload='onLoad()'> | 79 <body> |
53 <div id='caption'>Inspectable WebContents</div> | 80 <div id='caption'>Inspectable WebContents</div> |
54 <div id='items'></div> | 81 <div id='items'></div> |
55 </body> | 82 </body> |
56 </html> | 83 </html> |
OLD | NEW |