-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #90 from kzahel/serve-local
support serving local folders using web-server-chrome
- Loading branch information
Showing
4 changed files
with
7,029 additions
and
184 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
function AdminDataHandler(request) { | ||
WSC.BaseHandler.prototype.constructor.call(this) | ||
} | ||
_.extend(AdminDataHandler.prototype, { | ||
put: function() { | ||
|
||
var newData = this.request.bodyparams | ||
|
||
chrome.storage.local.get(null, function(data) { | ||
|
||
var saveData = {} | ||
var restart = false; | ||
for(var key in newData){ | ||
var value = newData[key] | ||
if(data.hasOwnProperty(key)){ | ||
data[key] = value; | ||
saveData[key] = value; | ||
if(key == "url"){ | ||
chrome.runtime.sendMessage({url: value}); | ||
} | ||
}else if(key == "restart"){ | ||
restart = true; | ||
} | ||
} | ||
chrome.storage.local.set(saveData); | ||
this.setHeader('content-type','text/json') | ||
var buf = new TextEncoder('utf-8').encode(JSON.stringify(data)).buffer | ||
this.write(buf) | ||
this.finish() | ||
|
||
if(restart) setTimeout( function() { | ||
// allow writing out response first. | ||
chrome.runtime.reload(); | ||
}, 1000 ) | ||
|
||
|
||
}.bind(this)) | ||
|
||
}, | ||
get: function() { | ||
chrome.storage.local.get(null, function(data) { | ||
this.setHeader('content-type','text/json') | ||
var buf = new TextEncoder('utf-8').encode(JSON.stringify(data)).buffer | ||
this.write(buf) | ||
this.finish() | ||
}.bind(this)) | ||
} | ||
}, WSC.BaseHandler.prototype) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.