Skip to content

Commit

Permalink
Add option for opening custom page instead of new tab (Resolves #3)
Browse files Browse the repository at this point in the history
  • Loading branch information
livibetter committed Jun 18, 2012
1 parent bba99a3 commit 600e757
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGES.mkd
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ CHANGES

## Development

## Version 0.5

* Add opening custom page instead of new tab (#3)

## Version 0.4.1 (2012-02-02T12:21:35Z)

Expand Down
11 changes: 7 additions & 4 deletions background.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,13 @@
creating_tab = true;
var select_new_created = localStorage["select_new_created"] == 1;
var auto_pin = localStorage["auto_pin"] == 1;
chrome.tabs.create({
selected: select_new_created,
pinned: (auto_pin && !w.tabs[0].pinned)
}, function(tab){
var create_options = {
selected: select_new_created,
pinned: (auto_pin && !w.tabs[0].pinned)
};
if (localStorage["open_custom_page"] == 1)
create_options['url'] = localStorage["custom_page_url"];
chrome.tabs.create(create_options, function(tab){
// save this tab id in case of Close Tabs to The Right.
// Chrome will close this tab if that is the case even it's just being
// added.
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Keep Last Two Tabs",
"version": "0.4.1",
"version": "0.5",
"description": "This extension keep last two tabs to prevent Chrome quits when last tab is closed.",
"icons": { "16": "icon16.png",
"48": "icon48.png",
Expand Down
20 changes: 20 additions & 0 deletions options.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@
else
localStorage["auto_pin"] = 0;

var open_custom_page = document.getElementById("open_custom_page");
if (open_custom_page.checked)
localStorage["open_custom_page"] = 1;
else
localStorage["open_custom_page"] = 0;
localStorage["custom_page_url"] = document.getElementById("custom_page_url").value;

// Update status to let user know options were saved.
var status = document.getElementById("status");
status.innerHTML = "Options Saved.";
Expand All @@ -59,6 +66,11 @@
if (auto_pin == 1) {
document.getElementById("auto_pin").checked = true;
}
var open_custom_page = localStorage["open_custom_page"];
if (open_custom_page == 1) {
document.getElementById("open_custom_page").checked = true;
}
document.getElementById("custom_page_url").value = localStorage["custom_page_url"] || '';
}

</script>
Expand Down Expand Up @@ -87,6 +99,14 @@ <h1>Keep Last Two Tabs: Options</h1>
</label>
</div>

<div>
<label>
<input type="checkbox" id="open_custom_page" name="open_custom_page" value="true"/>
Open custom page
<input type="input" id="custom_page_url" name="custom_page_url"/>
</label>
</div>

<hr/>

<div>
Expand Down

0 comments on commit 600e757

Please sign in to comment.