Title: [158072] trunk/Source/WebInspectorUI
- Revision
- 158072
- Author
- [email protected]
- Date
- 2013-10-25 16:53:41 -0700 (Fri, 25 Oct 2013)
Log Message
Web Inspector: PrettyPrinting tool should have save button
https://bugs.webkit.org/show_bug.cgi?id=123371
Patch by Joseph Pecoraro <[email protected]> on 2013-10-25
Reviewed by Timothy Hatcher.
Add buttons to save as a URL to share or to save/clear to
localStorage for easier reloads testing local changes.
* Tools/PrettyPrinting/index.html:
Modified Paths
Diff
Modified: trunk/Source/WebInspectorUI/ChangeLog (158071 => 158072)
--- trunk/Source/WebInspectorUI/ChangeLog 2013-10-25 23:46:35 UTC (rev 158071)
+++ trunk/Source/WebInspectorUI/ChangeLog 2013-10-25 23:53:41 UTC (rev 158072)
@@ -1,5 +1,17 @@
2013-10-25 Joseph Pecoraro <[email protected]>
+ Web Inspector: PrettyPrinting tool should have save button
+ https://bugs.webkit.org/show_bug.cgi?id=123371
+
+ Reviewed by Timothy Hatcher.
+
+ Add buttons to save as a URL to share or to save/clear to
+ localStorage for easier reloads testing local changes.
+
+ * Tools/PrettyPrinting/index.html:
+
+2013-10-25 Joseph Pecoraro <[email protected]>
+
Web Inspector: Command+Click on url(…) should go to image not source line
https://bugs.webkit.org/show_bug.cgi?id=123362
Modified: trunk/Source/WebInspectorUI/Tools/PrettyPrinting/index.html (158071 => 158072)
--- trunk/Source/WebInspectorUI/Tools/PrettyPrinting/index.html 2013-10-25 23:46:35 UTC (rev 158071)
+++ trunk/Source/WebInspectorUI/Tools/PrettyPrinting/index.html 2013-10-25 23:53:41 UTC (rev 158072)
@@ -17,8 +17,6 @@
<h1>Debug Pretty Printing</h1>
- <!-- FIXME: There should be a "save" button that saves the mode and content, so reloading will restore that state -->
-
<!-- Controls -->
<select id="mode">
<option selected value="text/_javascript_">_javascript_</option>
@@ -29,6 +27,9 @@
<button id="clear">Clear</button>
<button id="select-output">Select Output</button>
<button id="run-again">Run Again</button>
+ <button id="save-as-url">Save URL</button>
+ <button id="save-local-storage">Save to Storage</button>
+ <button id="clear-local-storage">Clear Storage</button>
<small id="time"></small>
<br><br>
@@ -46,13 +47,47 @@
lineNumbers: true,
});
- // Initial value.
- var str = "(function() { var a=1; return a+1; })();";
- cm.setValue(str);
+ // Initial values from URL.
+ var queryParams = {};
+ if (window.location.search.length > 0) {
+ var searchString = window.location.search.substring(1);
+ var groups = searchString.split("&");
+ for (var i = 0; i < groups.length; ++i) {
+ var pair = groups[i].split("=");
+ queryParams[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]);
+ }
+ }
- // Setup and changing the mode.
- cm.setOption("mode", "text/_javascript_");
+ // Initial mode and string.
+ var mode = "text/_javascript_";
+ var content = "(function() { var a=1; return a+1; })();";
+ var updatePicker = false;
+ if (queryParams.content || queryParams.mode) {
+ content = queryParams.content || "";
+ mode = queryParams.mode || "text/_javascript_";
+ updatePicker = true;
+ } else if (localStorage.content || localStorage.mode) {
+ content = localStorage.content || "";
+ mode = localStorage.mode || "text/_javascript_";
+ updatePicker = true;
+ }
+
+ // Initial mode picker value.
var modePicker = document.getElementById("mode");
+ if (updatePicker) {
+ for (var i = 0; i < modePicker.options.length; ++i) {
+ if (modePicker.options[i]) {
+ modePicker.options[i].selected = true;
+ break;
+ }
+ }
+ }
+
+ // Set on CodeMirror.
+ cm.setValue(content);
+ cm.setOption("mode", mode);
+
+ // Changing the mode.
modePicker.addEventListener("change", function(event) {
cm.setValue("");
cm.setOption("mode", modePicker.value);
@@ -106,6 +141,25 @@
refresh();
});
+ // Save as URL button.
+ document.getElementById("save-as-url").addEventListener("click", function(event) {
+ var mode = modePicker.value;
+ var content = cm.getValue();
+ window.location.search = "?mode=" + window.encodeURIComponent(mode) + "&content=" + window.encodeURIComponent(content);
+ });
+
+ // Save to localStorage.
+ document.getElementById("save-local-storage").addEventListener("click", function(event) {
+ localStorage.mode = modePicker.value;
+ localStorage.content = cm.getValue();
+ });
+
+ // Clear localStorage.
+ document.getElementById("clear-local-storage").addEventListener("click", function(event) {
+ localStorage.removeItem("mode");
+ localStorage.removeItem("content");
+ });
+
// Button helpers.
var buttons = ["mode", "populate", "run-tests", "clear", "select-output", "run-again"];
function disableButtons() {
@@ -170,7 +224,7 @@
setTimeout(refresh);
// Tests.
- function runTests() {
+ function runTests() {
disableButtons();
function completedCallback() {
enableButtons();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes