Add ability to import config by pasting in a json blob
This commit is contained in:
parent
fbd552ef4c
commit
a8e07d967b
|
@ -300,13 +300,18 @@ _tabbro_ = function() {
|
|||
// Set the notification color
|
||||
chrome.browserAction.setBadgeBackgroundColor({"color":"#990000"})
|
||||
|
||||
// Set up the data tree
|
||||
this.initializeTree()
|
||||
// Add evnt listeners
|
||||
this.addListeners()
|
||||
//console.log("Tabbro v" + this.__VERSION + " ready!")
|
||||
}
|
||||
|
||||
this.initializeTree = function() {
|
||||
// If any non-sticky windows are in our data from a previous session, remove them
|
||||
this.pruneData();
|
||||
// Add all open windows/tabs to the database tree
|
||||
this.loadInitialTree()
|
||||
// Add evnt listeners
|
||||
this.addListeners()
|
||||
//console.log("Tabbro v" + this.__VERSION + " ready!")
|
||||
}
|
||||
|
||||
this.loadInitialTree = function() {
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
<br />
|
||||
<br />
|
||||
<h1>Load Data</h1>
|
||||
<input type="text" name="dumpin" id="dumpin" value="Paste JSON here (Not functional yet)" />
|
||||
<input type="text" name="dumpin" id="dumpin" value="Paste JSON here" />
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
27
options.js
27
options.js
|
@ -45,6 +45,31 @@ function setup() {
|
|||
this.value = JSON.stringify(tabbro.tree)
|
||||
}
|
||||
|
||||
|
||||
var dumpin = document.getElementById("dumpin")
|
||||
dumpin.onchange=function() {
|
||||
var data = JSON.parse(this.value)
|
||||
var windows = 0;
|
||||
var tabs = 0;
|
||||
for(var w in data) {
|
||||
data[w].sticky = true
|
||||
data[w].id = null
|
||||
windows++
|
||||
for(var t in data[w].tabs) {
|
||||
data[w].tabs[t].sticky = true
|
||||
data[w].tabs[t].id = null
|
||||
tabs++
|
||||
}
|
||||
}
|
||||
if(confirm("Replace all tabbro data?\n\nWindows: "+windows+"\nTabs: "+tabs)) {
|
||||
tabbro.data.tree.splice(0, tabbro.data.tree.length)
|
||||
for(var w in data) {
|
||||
tabbro.data.tree.push(data[w])
|
||||
}
|
||||
tabbro.save()
|
||||
tabbro.loadInitialTree()
|
||||
alert("Done!")
|
||||
this.value="Paste JSON here"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue