Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions _locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@



"headers_description": {
"message": "Description"
},
"headers_header": {
"message": "Header"
},
"headers_value": {
"message": "Value"
},
"headers_active": {
"message": "Active"
},
"headers_description": {
"message": "Description"
},
"headers_active": {
"message": "Active"
},
"headers_add": {
"message": "Add"
},
Expand Down
4 changes: 2 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"manifest_version": 3,
"manifest_version": 4,
"name": "Header-Editor",
"description": "Alter your HTTP request headers on the fly",
"version": "2.2.0",
"version": "2.3.0",
"default_locale": "en",

"options_page": "/src/html/options.html",
Expand Down
8 changes: 4 additions & 4 deletions src/html/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,18 @@ <h2 data-text="request_title"></h2>
<table class="options-headers-table">
<thead>
<tr>
<th data-text="headers_description"></th>
<th data-text="headers_header"></th>
<th data-text="headers_value"></th>
<th data-text="headers_description"></th>
<th data-text="headers_active"></th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td><label><input type="text" class="options-headers-create-description" /></label></td>
<td><label><input type="text" class="options-headers-create-header" /></label></td>
<td><label><input type="text" class="options-headers-create-value" /></label></td>
<td><label><input type="text" class="options-headers-create-description" /></label></td>
<td><label><input type="checkbox" class="options-headers-create-active" checked="true" /></label></td>
<td><button class="options-headers-create-add" data-text="headers_add"></button></td>
</tr>
Expand All @@ -62,18 +62,18 @@ <h2 data-text="response_title"></h2>
<table class="options-headers-table">
<thead>
<tr>
<th data-text="headers_description"></th>
<th data-text="headers_header"></th>
<th data-text="headers_value"></th>
<th data-text="headers_active"></th>
<th data-text="headers_description"></th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td><label><input type="text" class="options-headers-create-description" /></label></td>
<td><label><input type="text" class="options-headers-create-header" /></label></td>
<td><label><input type="text" class="options-headers-create-value" /></label></td>
<td><label><input type="text" class="options-headers-create-description" /></label></td>
<td><label><input type="checkbox" class="options-headers-create-active" checked="true" /></label></td>
<td><button class="options-headers-create-add" data-text="headers_add"></button></td> </tr>
<tr><td colspan="5"><hr /></td></tr>
Expand Down
6 changes: 3 additions & 3 deletions src/js/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@
this.headers = options.headers;
this.headers.fetch();

this.$createDescription = this.$el.find(".options-headers-create-description");
this.$createHeader = this.$el.find(".options-headers-create-header");
this.$createValue = this.$el.find(".options-headers-create-value");
this.$createDescription = this.$el.find(".options-headers-create-description");
this.$createActive = this.$el.find(".options-headers-create-active");

this.listenTo(this.headers, "add", this.renderSingle);
Expand All @@ -71,15 +71,15 @@

createHeader: function() {
this.headers.create({
description: this.$createDescription.val(),
header: this.$createHeader.val(),
value: this.$createValue.val(),
description: this.$createDescription.val(),
active: this.$createActive.is(":checked")
});

this.$createDescription.val("");
this.$createHeader.val("");
this.$createValue.val("");
this.$createDescription.val("");
this.$createActive.prop("checked", true);
}
});
Expand Down
46 changes: 4 additions & 42 deletions src/js/upgrade.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,46 +45,8 @@
return 0;
};

// Methods for updating user data
function update_2_1_0() {
function getHeaders(key) {
var json = localStorage.getItem(key);
return (!!json) ? JSON.parse(json) : {};
}

var requestHeaders = getHeaders("headers");
var responseHeaders = getHeaders("response-headers");

// Since we don't want to include Backbone and all of the dependencies, we'll manually create and serialize the JSON
function convertHeaders(headers, headerKey) {
var headersList = [];

for (var key in headers) {
if (headers.hasOwnProperty(key)) {
var header = headers[key];
var headerId = uuid();
headersList.push(headerId);

localStorage.setItem(headerKey + headerId, JSON.stringify({
id: headerId,
header: header.header || "",
value: header.value || "",
// Only set as inactive if explicitly false
active: (header.active === false) ? false : true
}));
}
}

// Format is <UUID>[,<UUID>]
return headersList.join(",");
}

localStorage.setItem("backbone.requestHeaders", convertHeaders(requestHeaders, "backbone.requestHeaders-"));
localStorage.setItem("backbone.responseHeaders", convertHeaders(responseHeaders, "backbone.responseHeaders-"));
}

// Methods for updating user data to include descriptions
function update_2_2_0() {
function update_2_3_0() {
function getHeaders(key) {
var json = localStorage.getItem(key);
return (!!json) ? JSON.parse(json) : {};
Expand All @@ -105,9 +67,9 @@

localStorage.setItem(headerKey + headerId, JSON.stringify({
id: headerId,
description: header.description || "",
header: header.header || "",
value: header.value || "",
description: header.description || "",
// Only set as inactive if explicitly false
active: (header.active === false) ? false : true
}));
Expand All @@ -127,8 +89,8 @@
var currentVersion = chrome.app.getDetails().version;

if (0 > compareVersions(previousVersion, currentVersion)) {
if (0 > compareVersions(previousVersion, "2.2.0")) {
update_2_2_0();
if (0 > compareVersions(previousVersion, "2.3.0")) {
update_2_3_0();
}
}
});
Expand Down