Skip to content

Commit

Permalink
Add files from first version.
Browse files Browse the repository at this point in the history
  • Loading branch information
Amaury Rodriguez committed Mar 8, 2015
1 parent 0afa77f commit 9236e7a
Show file tree
Hide file tree
Showing 16 changed files with 589 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
@@ -1,7 +1,7 @@
Faster Redmine
==============

Change the Status of a Redmine Issue without having to click first on the Edit link, change the Status, and then click on the Submit button. This extension puts a dropdown right on the main Issue view, and changing the selection immediately updates the Issue. You can choose to refresh the page on each Issue update in the extension's settings.
Chrome extension that allows you to change the Status of a Redmine Issue without having to first: click on the Edit link, change the Status, and then click on the Submit button. This extension puts a dropdown right on the main Issue view, and changing the selection immediately updates the Issue. You can choose to refresh the page on each Issue update in the extension's settings.

Features:
---------
Expand Down
Binary file added icons/fast-redmine-128.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/fast-redmine-16.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/fast-redmine-48.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/fast-redmine-bw-19.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/fast-redmine-bw-38.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/fast-redmine-bw-blocked-19.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/fast-redmine-bw-blocked-38.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
45 changes: 45 additions & 0 deletions manifest.json
@@ -0,0 +1,45 @@
{
"manifest_version": 2,

"name": "Faster Redmine",
"description": "Makes updating Redmine Issues much faster.",
"version": "1.0",

"icons": {
"16": "icons/fast-redmine-16.png",
"48": "icons/fast-redmine-48.png",
"128": "icons/fast-redmine-128.png"
},

"permissions": [
"tabs",
"storage",
"contentSettings"
],

"optional_permissions": [
"http://*/*",
"https://*/*"
],

"background": {
"scripts": ["scripts/background.js"],
"persistent": false
},

"page_action": {
"default_icon": {
"19": "icons/fast-redmine-bw-19.png",
"38": "icons/fast-redmine-bw-38.png"
},
"default_title": "Faster Redmine",
"default_popup": "popup.html"
},

"options_ui": {
"page": "options.html",
"chrome_style": true,
"open_in_tab": false
}

}
61 changes: 61 additions & 0 deletions options.html
@@ -0,0 +1,61 @@
<!DOCTYPE html>
<html>
<head>
<title>Faster Redmine Options</title>
<style>
body: { padding: 10px; }

div.box {
box-sizing: border-box;
width: 100%;
border: 0 solid;
border-color: white;
}

div.box_left {
float: left;
}

div.box_right {
float: right;
}
</style>
</head>

<body>
<label>
Redmine application root URL:
<br>
<input type="text" id="redmineUrl" size=40 placeholder="https://regmine.mycompany.com/">
</label>
<br><br>
<label>
Redmine API Key: <span style="font-style:italic;color:#F45C13">(For security reasons, value is not synched.)</span>
<br>
<input type="text" id="key" size=40 placeholder="Go to My Account -> API access Key -> Show">
</label>
<br><br>
<label>
<input type="checkbox" id="propagate">
Propagate status changes to parent issue.
</label>
<br><br>
<label>
<input type="checkbox" id="reload">
Reload page on each update.
</label>
<br>
<div id="status" style="color:green"><br></div>

<div class="box">
<div class="box_left">
<button id="save">Save</button>
</div>
<div class="box_right">
<button id="clear">Clear Permissions</button>
</div>
</div>

<script src="scripts/options.js"></script>
</body>
</html>
15 changes: 15 additions & 0 deletions popup.html
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<title>Fast Redmine</title>
</head>

<body style="width: 150px;">

<div id="header" style="text-align: center;font-weight: bold;padding: 5px 5px 20px 20px;" >Faster Redmine</div>
<div id="message" style="text-align: center;padding: 0px 5px 10px 5px;" ></div>
<div style="text-align: center;"><button id="button">Options</button></div>

<script type="text/javascript" src="scripts/popup.js"></script>
</body>
</html>
199 changes: 199 additions & 0 deletions scripts/background.js
@@ -0,0 +1,199 @@

chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {

var options = "chrome-extension://" + chrome.runtime.id + "/options.html";
var popup = "chrome-extension://" + chrome.runtime.id + "/popup.html";

if (sender.tab || sender.url == options || sender.url == popup){

if (request.reload) {
chrome.storage.sync.get({
reload: true
}, function(items) {
if (items.reload) {
reloadTab(sender.tab.id);
}
});

} else if (request.requestPermission && request.origins) {
requestPermission(request.origins, sendResponse);

} else if (request.removePermission && request.origins) {
removePermission(request.origins, sendResponse);

} else if (request.hasPermission && request.origin) {
hasPermission(request.origin, sendResponse );

} else if (request.requestRefreshPageActionAllTabs) {
refreshPageActionIconAllTabs();

}
}

// Must return true to send multiple responses, else only first response will be sent.
return true;
});

chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {

if (changeInfo.status === 'complete') {
refreshPageActionIcon(tab);
}

// chrome.storage.sync.get({
// redmineUrl: "^$"
// }, function(items){
// re = RegExp(items.redmineUrl);

// if (changeInfo.status === 'complete') {
// var url = tab.url.split('#')[0]; // Exclude URL fragments

// if (re.test(url) && url !== "chrome://extensions") {

// refreshPageActionIcon(tab);

// hasPermission(url, function(granted){

// if (granted) {
// var paths = {"19": "icons/fast-redmine-bw-19.png", "38": "icons/fast-redmine-bw-38.png"};

// chrome.pageAction.setIcon({tabId: tabId, path: paths});
// chrome.pageAction.show(tabId);
// injectScripts(tabId);

// } else {
// var paths = {"19": "icons/fast-redmine-bw-blocked-19.png", "38": "icons/fast-redmine-bw-blocked-38.png"};

// chrome.pageAction.setIcon({tabId: tabId, path: paths});
// chrome.pageAction.show(tabId);
// }

// });
// }
// }
// });
});

function refreshPageActionIconAllTabs() {
chrome.tabs.query({}, function(arrayOfTabs) {
for (var i = 0; i < arrayOfTabs.length; i++) {
if (arrayOfTabs[i].status == "complete") {
refreshPageActionIcon(arrayOfTabs[i]);
}
}
});
}

function refreshPageActionIcon (tab) {

var url = tab.url.split('#')[0]; // Exclude URL fragments

hasPermission(url, function(granted){

chrome.storage.sync.get({
redmineUrl: "^$"
}, function(items){
re = RegExp(items.redmineUrl);

if (!(re.test(url) && url !== "chrome://extensions")) {
return;
}

if (granted) {
var paths = {"19": "icons/fast-redmine-bw-19.png", "38": "icons/fast-redmine-bw-38.png"};

chrome.pageAction.setIcon({tabId: tab.id, path: paths});
chrome.pageAction.show(tab.id);
injectScripts(tab.id);

} else {
var paths = {"19": "icons/fast-redmine-bw-blocked-19.png", "38": "icons/fast-redmine-bw-blocked-38.png"};

chrome.pageAction.setIcon({tabId: tab.id, path: paths});
chrome.pageAction.show(tab.id);
}
});
});
}

chrome.runtime.onInstalled.addListener(function(details){
if(details.reason == "install"){
chrome.tabs.create({ url: "chrome://extensions/?options=" + chrome.runtime.id });
}else if(details.reason == "update"){
//var thisVersion = chrome.runtime.getManifest().version;
//console.log("Updated from " + details.previousVersion + " to " + thisVersion + "!");
}
});

function reloadTab(tabId){
chrome.tabs.query({active: true, currentWindow: true}, function (arrayOfTabs) {
chrome.tabs.reload(tabId);
});
}

function requestPermission(urls, callback) {
// Permissions must be requested from inside a user gesture, like a button's
// click handler.

if (urls.constructor !== Array) {
urls = [urls]
}

chrome.permissions.request({
permissions: [],
origins: urls
}, function(granted) {
// The callback argument will be true if the user granted the permissions.
if (granted) {
callback({granted: true});
} else {
callback({granted: false});
}
});
}

function removePermission(urls, callback) {

if (urls.constructor !== Array) {
urls = [urls]
}

chrome.permissions.remove({
permissions: [],
origins: urls
}, function(removed) {
if (removed) {
callback({removed: true});
} else {
callback({removed: false});
}
});

}

function hasPermission(url, callback){

chrome.permissions.contains({
permissions: ['contentSettings'],
origins: [url]
}, function(result) {
if (result) {
callback(true);
} else {
callback(false);
}
});
}

function injectScripts(tabId) {

chrome.tabs.executeScript(tabId, {
file: "scripts/jquery-1.11.2.min.js",
runAt: "document_end"
}, function(){
chrome.tabs.executeScript(tabId, {
file: "scripts/inject.js",
runAt: "document_end"
});
});
}

0 comments on commit 9236e7a

Please sign in to comment.