aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEinar Egilsson <einar@einaregilsson.com>2019-12-12 10:52:54 +0000
committerEinar Egilsson <einar@einaregilsson.com>2019-12-12 10:52:54 +0000
commit31f1b675bf738f5905bf3f9e7dccf9515a471ec2 (patch)
tree36c45ed2dc93c347210884b5b6a46ab6d90d8dc1
parent7161bb3f24f57d0e4f83805f32f615f03d471ff3 (diff)
Fix messages
-rw-r--r--js/background.js8
-rw-r--r--js/redirectorpage.js26
2 files changed, 28 insertions, 6 deletions
diff --git a/js/background.js b/js/background.js
index a3b5da3..89118d0 100644
--- a/js/background.js
+++ b/js/background.js
@@ -290,13 +290,13 @@ chrome.runtime.onMessage.addListener(
// Call setupRedirectListener to setup the redirects
setUpRedirectListener();
sendResponse({
- message: "syncEnabled"
+ message: "sync-enabled"
});
});
} else {
log('No redirects are setup currently in Local, just enabling Sync');
sendResponse({
- message: "syncEnabled"
+ message: "sync-enabled"
});
}
});
@@ -316,12 +316,12 @@ chrome.runtime.onMessage.addListener(
// Call setupRedirectListener to setup the redirects
setUpRedirectListener();
sendResponse({
- message: "syncDisabled"
+ message: "sync-disabled"
});
});
} else {
sendResponse({
- message: "syncDisabled"
+ message: "sync-disabled"
});
}
});
diff --git a/js/redirectorpage.js b/js/redirectorpage.js
index 482838f..ee2eec0 100644
--- a/js/redirectorpage.js
+++ b/js/redirectorpage.js
@@ -14,7 +14,7 @@ function saveChanges() {
// Clean them up so angular $$hash things and stuff don't get serialized.
let arr = REDIRECTS.map(normalize);
- chrome.runtime.sendMessage({type:"saveredirects", redirects:arr}, function(response) {
+ chrome.runtime.sendMessage({type:"save-redirects", redirects:arr}, function(response) {
console.log(response.message);
if(response.message.indexOf("Redirects failed to save") > -1){
showMessage(response.message, false);
@@ -41,7 +41,7 @@ function toggleSyncSetting() {
}
else {
alert(response.message)
- showMessage('Error occured when trying to change Sync settings. Refer logging and raise an issue',false);
+ showMessage('Error occured when trying to change Sync settings. Look at the logs and raise an issue',false);
}
el('#storage-sync-option').checked = options.isSyncEnabled;
});
@@ -146,6 +146,28 @@ function pageLoad() {
for (var i=0; i < response.redirects.length; i++) {
REDIRECTS.push(new Redirect(response.redirects[i]));
}
+
+ if (response.redirects.length === 0) {
+ //Add example redirect for first time users...
+ REDIRECTS.push(new Redirect(
+ {
+ "description": "Example redirect, try going to http://example.com/anywordhere",
+ "exampleUrl": "http://example.com/some-word-that-matches-wildcard",
+ "exampleResult": "https://google.com/search?q=some-word-that-matches-wildcard",
+ "error": null,
+ "includePattern": "http://example.com/*",
+ "excludePattern": "",
+ "patternDesc": "Any word after example.com leads to google search for that word.",
+ "redirectUrl": "https://google.com/search?q=$1",
+ "patternType": "W",
+ "processMatches": "noProcessing",
+ "disabled": false,
+ "appliesTo": [
+ "main_frame"
+ ]
+ }
+ ));
+ }
renderRedirects();
});