Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 <html> | 1 <html> |
| 2 <head> | 2 <head> |
| 3 <title>Inspectable pages</title> | 3 <title>Inspectable pages</title> |
| 4 <style> | 4 <style> |
| 5 body { | 5 body { |
| 6 color: #222; | 6 color: #222; |
| 7 font-family: Helvetica, Arial, sans-serif; | 7 font-family: Helvetica, Arial, sans-serif; |
| 8 margin: 0; | 8 margin: 0; |
| 9 text-shadow: rgba(255, 255, 255, 0.496094) 0px 1px 0px; | 9 text-shadow: rgba(255, 255, 255, 0.496094) 0px 1px 0px; |
| 10 } | 10 } |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 78 function onReady() { | 78 function onReady() { |
| 79 if(this.readyState == 4 && this.status == 200) { | 79 if(this.readyState == 4 && this.status == 200) { |
| 80 if(this.response != null) | 80 if(this.response != null) |
| 81 var responseJSON = JSON.parse(this.response); | 81 var responseJSON = JSON.parse(this.response); |
| 82 for (var i = 0; i < responseJSON.length; ++i) | 82 for (var i = 0; i < responseJSON.length; ++i) |
| 83 appendItem(responseJSON[i]); | 83 appendItem(responseJSON[i]); |
| 84 } | 84 } |
| 85 } | 85 } |
| 86 | 86 |
| 87 function overrideFrontendUrl(item) { | 87 function overrideFrontendUrl(item) { |
| 88 if (window.location.hash) { | 88 if (!window.location.hash) |
| 89 var overridden_url = window.location.hash.substr(1); | 89 return item.devtoolsFrontendUrl; |
| 90 var ws_suffix = item.webSocketDebuggerUrl.replace('ws://', 'ws='); | 90 |
| 91 if (overridden_url.indexOf('?') == -1) | 91 var hashParams = new URLSearchParams(location.hash.substring(1)); |
| 92 return overridden_url + '?' + ws_suffix; | 92 if (!hashParams.get("custom")) |
| 93 else | 93 return item.devtoolsFrontendUrl; |
| 94 return overridden_url + '&' + ws_suffix; | 94 |
| 95 } | 95 var searchIndex = item.devtoolsFrontendUrl.indexOf("?"); |
| 96 return item.devtoolsFrontendUrl; | 96 if (searchIndex === -1) |
| 97 return item.devtoolsFrontendUrl; | |
| 98 originalParams = new URLSearchParams(item.devtoolsFrontendUrl.substring(search Index + 1)); | |
| 99 if (hashParams.get("experiments")) | |
| 100 originalParams.set("experiments", true); | |
| 101 | |
| 102 return "chrome-devtools://devtools/custom/inspector.html?" + originalParams.to String(); | |
| 97 } | 103 } |
| 98 | 104 |
| 99 function appendItem(item_object) { | 105 function appendItem(item_object) { |
| 100 var item_element; | 106 var item_element; |
| 101 if (item_object.devtoolsFrontendUrl) { | 107 if (item_object.devtoolsFrontendUrl) { |
| 102 item_element = document.createElement('a'); | 108 item_element = document.createElement('a'); |
| 103 item_element.href = overrideFrontendUrl(item_object); | 109 item_element.href = overrideFrontendUrl(item_object); |
| 104 item_element.title = item_object.title; | 110 item_element.title = item_object.title; |
| 111 item_element.addEventListener('click', maybeHandleClick.bind(null, item_elem ent)); | |
| 105 } else { | 112 } else { |
| 106 item_element = document.createElement('div'); | 113 item_element = document.createElement('div'); |
| 107 item_element.className = 'connected'; | 114 item_element.className = 'connected'; |
| 108 item_element.title = 'The tab already has an active debug session'; | 115 item_element.title = 'The tab already has an active debug session'; |
| 109 } | 116 } |
| 110 item_element.classList.add('item'); | 117 item_element.classList.add('item'); |
| 111 | 118 |
| 112 var description = document.createElement('div'); | 119 var description = document.createElement('div'); |
| 113 description.className = 'description'; | 120 description.className = 'description'; |
| 114 | 121 |
| 115 var title = document.createElement('div'); | 122 var title = document.createElement('div'); |
| 116 title.className = 'title'; | 123 title.className = 'title'; |
| 117 title.textContent = item_object.description || item_object.title; | 124 title.textContent = item_object.description || item_object.title; |
| 118 title.style.cssText = 'background-image:url(' + | 125 title.style.cssText = 'background-image:url(' + |
| 119 item_object.faviconUrl + ')'; | 126 item_object.faviconUrl + ')'; |
| 120 description.appendChild(title); | 127 description.appendChild(title); |
| 121 | 128 |
| 122 var subtitle = document.createElement('div'); | 129 var subtitle = document.createElement('div'); |
| 123 subtitle.className = 'subtitle'; | 130 subtitle.className = 'subtitle'; |
| 124 subtitle.textContent = (item_object.url || '').substring(0, 300); | 131 subtitle.textContent = (item_object.url || '').substring(0, 300); |
| 125 description.appendChild(subtitle); | 132 description.appendChild(subtitle); |
| 126 | 133 |
| 127 item_element.appendChild(description); | 134 item_element.appendChild(description); |
| 128 | 135 |
| 129 document.getElementById('items').appendChild(item_element); | 136 document.getElementById('items').appendChild(item_element); |
| 130 } | 137 } |
| 138 | |
| 139 function maybeHandleClick(anchor, event) | |
| 140 { | |
| 141 if (!anchor.href.startsWith("chrome-devtools://")) | |
| 142 return; | |
| 143 fetch("/json/new?" + anchor.href); | |
|
dgozman
2016/10/31 23:11:32
Just do a preselected copy-paste.
lushnikov
2016/11/01 00:19:39
Done. Screenshot: https://goo.gl/Xx4kdr
| |
| 144 event.preventDefault(); | |
| 145 event.stopPropagation(); | |
| 146 } | |
| 131 </script> | 147 </script> |
| 132 </head> | 148 </head> |
| 133 <body onload='onLoad()'> | 149 <body onload='onLoad()'> |
| 134 <div id='caption'>Inspectable pages</div> | 150 <div id='caption'>Inspectable pages</div> |
| 135 <hr> | 151 <hr> |
| 136 <div id='items'> | 152 <div id='items'> |
| 137 </div> | 153 </div> |
| 138 </body> | 154 </body> |
| 139 </html> | 155 </html> |
| OLD | NEW |