Permalink
Browse files

Configure TravisCI

  • Loading branch information...
kyleladd committed Oct 2, 2015
1 parent 8d8bf71 commit edcef86f390832e73dff85aa6c17f399a10f8f43
Showing with 70 additions and 41 deletions.
  1. +2 −0 .gitignore
  2. +5 −0 .travis.yml
  3. +18 −16 Chrometana/js/bootstrap.js
  4. +22 −25 Chrometana/js/options.js
  5. +11 −0 README.md
  6. +12 −0 package.json
View
@@ -1 +1,3 @@
Chrometana.zip
+# Dependencies
+node_modules/
View
@@ -0,0 +1,5 @@
+language: node_js
+node_js:
+ - "0.12"
+ - "0.11"
+ - "0.10"
View
@@ -5,11 +5,11 @@ function convertURL(url){
log(url);
url = url.replace(/%20/g,"+");
var uri = /\?q\=([0-9a-zA-Z-._~:\/?#[\]@!$'()*+,;=%]*)($|(\&))/.exec(url)[1];
- log(url);
- log(uri);
- log(storageChange);
- var match = /^((go\+to\+)|(open\+)|())([0-9a-zA-Z-._~:\/?#[\]@!$'()*+,;=%]*\.[a-z]+)/i.exec(uri)
- log(match)
+ log("url: " + url);
+ log("uri: " + uri);
+ log("StorageChange: " + storageChange);
+ var match = /^((go\+to\+)|(open\+)|())([0-9a-zA-Z-._~:\/?#[\]@!$'()*+,;=%]*\.[a-z]+)/i.exec(uri);
+ log(match);
if(match){
return "http://" + match[5];
}
@@ -31,30 +31,32 @@ function convertURL(url){
return "https://www.google.com/search?q=" + uri;
}
chrome.storage.sync.get(['search_engine','custom_engine'], function (obj) {
- log('myKey', obj);
- storageChange = obj['search_engine'];
+ log("obj: " + obj);
+ storageChange = obj.search_engine;
if(storageChange == "Custom"){
- custom_engine = obj['custom_engine'];
+ custom_engine = obj.custom_engine;
}
});
chrome.storage.onChanged.addListener(function(changes, namespace) {
+ log("changes: ");
log(changes);
- if(typeof changes['search_engine'] !== "undefined"){
- storageChange = changes['search_engine']['newValue'];
+ if(typeof changes.search_engine !== "undefined"){
+ storageChange = changes.search_engine.newValue;
}
if(storageChange == "Custom"){
- if(typeof changes['custom_engine'] !== "undefined"){
- custom_engine = changes['custom_engine']['newValue'];
+ if(typeof changes.custom_engine !== "undefined"){
+ custom_engine = changes.custom_engine.newValue;
}
}
- log(storageChange);
- log(custom_engine);
+ log("storageChange: " + storageChange);
+ log("custom_engine: " + custom_engine);
});
chrome.webRequest.onBeforeRequest.addListener(function(details) {
- log(storageChange);
-
+ log("storageChange: " + storageChange);
+ log("details:");
+ log(details);
return { redirectUrl: convertURL(details.url)};
}, {urls: ["*://*.bing.com/search*"]}, ["blocking"]);
View
@@ -2,7 +2,7 @@ function save_options(key, element, value) {
var options = {};
options[key] = value;
if(key == "custom_engine"){
- options['search_engine'] = "Custom";
+ options.search_engine = "Custom";
}
chrome.storage.sync.set(options, function() {
restore_options();
@@ -23,7 +23,6 @@ function updateDisplay(items){
if (selectorList[i].getAttribute('value') == items.search_engine) {
addClass(selectorList[i], 'selected');
document.getElementById("webpage_diagram_placeholder").className = selectorList[i].getAttribute("data-icon-class");
-
}
else {
removeClass(selectorList[i], 'selected');
@@ -53,22 +52,33 @@ var selectorList = document.getElementsByClassName('selector');
document.addEventListener('DOMContentLoaded', restore_options);
+var optionCaller = function() {
+ save_options('search_engine',this, this.getAttribute('value'));
+};
+
+var handleMouseover = function() {
+ selectedElements = document.getElementsByClassName('selected');
+ for (i = 0; i < selectedElements.length; i++) {
+ removeClass(selectedElements[i], 'selected');
+ }
+ addClass(this, 'selected');
+};
+
+var handleMouseout = function() {
+ removeClass(this, 'selected');
+ restore_options();
+};
+
if (getURLVariable("newinstall") == "yes"){
var installadvice = document.getElementById('installadvice');
addClass(installadvice, 'visible');
}
for (i = 0; i < selectorList.length; i++) {
- selectorList[i].addEventListener('click', function() {
- save_options('search_engine',this, this.getAttribute('value'))
- });
- selectorList[i].addEventListener('mouseover', function() {
- handleMouseover(this);
- });
- selectorList[i].addEventListener('mouseleave', function() {
- handleMouseout(this);
- })
+ selectorList[i].addEventListener('click', optionCaller,false);
+ selectorList[i].addEventListener('mouseover', handleMouseover, false);
+ selectorList[i].addEventListener('mouseleave', handleMouseout, false);
}
document.getElementById('custom_engine_update').addEventListener('click', function() {
@@ -88,20 +98,7 @@ document.getElementById('additional-settings-toggle').addEventListener('click',
} else {
addClass(settingsPane, 'open');
}
-})
-
-function handleMouseover(element) {
- selectedElements = document.getElementsByClassName('selected');
- for (i = 0; i < selectedElements.length; i++) {
- removeClass(selectedElements[i], 'selected');
- }
- addClass(element, 'selected');
-}
-
-function handleMouseout(element) {
- removeClass(element, 'selected');
- restore_options();
-}
+});
function addClass(element, classNameToAdd) {
if (!element.className.includes(classNameToAdd)) {
View
@@ -6,6 +6,8 @@ Chrometana
[Link to the Chrometana blog](http://Chrometana.Theo.li)
+![Travis](https://travis-ci.org/kyleladd/Chrometana.svg?branch=master)
+
INTRODUCTION
------------
With the introduction of Windows 10 to the general public, Bing use is growing rampant. Many aren't using Bing by choice, especially Cortana users. Chrometana aims to force all Bing searches made in Chrome to be redirected to a search engine of the user's choice
@@ -50,6 +52,15 @@ HOW TO CONTRIBUTE
------------
Want to contribute to Chrometana? Awesome! Feel free to make pull requests directly to the dev branch, or contact Theo with any questions at all at <theo@theobrowne.com>
+ 1. Install dependencies
+ ```
+ npm install
+ ```
+ 2. Run jshint for linting tests
+ ```
+ node_modules/jshint/bin/jshint --exclude ./node_modules .
+ ```
+
CREDITS
------------
Lead by [Theo Browne](http://www.theo.li)
View
@@ -0,0 +1,12 @@
+{
+ "name": "Chrometana",
+ "description": "Redirect Bing Somewhere Better http://Chrometana.Theo.li",
+ "author": "Theo Browne",
+ "version": "1.1.2",
+ "devDependencies": {
+ "jshint": "^2.6.0"
+ },
+ "scripts": {
+ "test": "jshint --exclude ./node_modules ."
+ }
+}

0 comments on commit edcef86

Please sign in to comment.