store app settings in localStorage and implemented liveedit

This commit is contained in:
Danny Coates 2010-10-27 20:45:05 -06:00
Родитель 102a207ae3
Коммит 54b3f67c1b
4 изменённых файлов: 39 добавлений и 10 удалений

Просмотреть файл

@ -8,10 +8,8 @@
WebInspector.InspectorBackendStub = function()
{
this._registerDelegate('{"seq": 0, "domain": "Controller", "command": "populateScriptObjects", "arguments": {}}');
this._registerDelegate('{"seq": 0, "domain": "Controller", "command": "getSettings", "arguments": {}}');
this._registerDelegate('{"seq": 0, "domain": "Controller", "command": "getInspectorState", "arguments": {}}');
this._registerDelegate('{"seq": 0, "domain": "Controller", "command": "storeLastActivePanel", "arguments": {"panelName": "string"}}');
this._registerDelegate('{"seq": 0, "domain": "Controller", "command": "saveApplicationSettings", "arguments": {"settings": "string"}}');
this._registerDelegate('{"seq": 0, "domain": "Controller", "command": "saveSessionSettings", "arguments": {"settings": "string"}}');
this._registerDelegate('{"seq": 0, "domain": "Controller", "command": "setSearchingForNode", "arguments": {"enabled": "boolean"}}');
this._registerDelegate('{"seq": 0, "domain": "Controller", "command": "setMonitoringXHREnabled", "arguments": {"enable": "boolean"}}');
@ -101,6 +99,21 @@ WebInspector.InspectorBackendStub.prototype = {
this[commandObject.command] = this.sendMessageToBackend.bind(this, commandInfo);
},
saveApplicationSettings: function(settings)
{
localStorage.setItem('appSettings', settings);
},
getSettings: function(callback)
{
var defaults = "{\"scripts-sidebar-width\":230,\"event-listeners-filter\":\"all\",\"color-format\":\"hex\",\"resources-large-rows\":true,\"watch-expressions\":[],\"last-viewed-script-file\":\"file:///home/danny/research/test.html\",\"show-inherited-computed-style-properties\":false,\"show-user-agent-styles\":true,\"resource-view-tab\":\"content\",\"console-history\":[],\"resources-sort-options\":{\"timeOption\":\"responseTime\",\"sizeOption\":\"transferSize\"}}",
settings = {
application: localStorage.getItem('appSettings') || defaults,
session: "{}"
};
callback.apply(null, [settings]);
},
sendMessageToBackend: function()
{
var args = Array.prototype.slice.call(arguments);

Просмотреть файл

@ -8,6 +8,8 @@ WebInspector.loaded = function() {
}
return;
};
Preferences.canEditScriptSource = true;
/*
(function() {
window.addEventListener("load", function() {

Просмотреть файл

@ -40,6 +40,7 @@ exports.attachDebugger = function (port) {
debugr.emit('break', obj);
}
else {
//TODO exception
debugr.emit('data', obj);
}
}

Просмотреть файл

@ -344,11 +344,7 @@ exports.createSession = function (conn, debuggerPort) {
},
getSettings: {
value: function(seq) {
sendResponse(seq, true, {
settings:{
application:"{\"scripts-sidebar-width\":230,\"event-listeners-filter\":\"all\",\"color-format\":\"hex\",\"resources-large-rows\":true,\"watch-expressions\":[],\"last-viewed-script-file\":\"\",\"show-inherited-computed-style-properties\":false,\"show-user-agent-styles\":true,\"resource-view-tab\":\"content\",\"console-history\":[],\"resources-sort-options\":{\"timeOption\":\"responseTime\",\"sizeOption\":\"transferSize\"}}",
session:"{}"
}});
// handled by localStorage
}
},
getInspectorState: {
@ -367,7 +363,7 @@ exports.createSession = function (conn, debuggerPort) {
},
saveApplicationSettings: {
value: function(settings) {
// handled by localStorage
}
},
saveSessionSettings: {
@ -630,8 +626,25 @@ exports.createSession = function (conn, debuggerPort) {
}
},
editScriptSource: {
value: function(sourceID, newContent) {
value: function(sourceID, newContent, seq) {
var args = {
script_id: sourceID,
preview_only: false,
new_source: newContent
};
debug.request(
'changelive',
{arguments: args},
function(msg) {
sendResponse(
seq,
msg.success,
{
success: msg.success,
newBodyOrErrorMessage: msg.message || newContent
});
//TODO: new callframes?
});
}
},
getScriptSource: {