Commit 0be66681 authored by Alexander's avatar Alexander

Add default project option

parent 9c92ca09
......@@ -51,6 +51,12 @@ function removeSkypeFormatting(string) {
return string;
}
function maybeAddProject(string, project) {
if (string.match(/^[0-9]+$/) != null) {
string = project + '-' + string;
}
return string;
}
function openWindow() {
window.open(url + key);
......@@ -60,11 +66,13 @@ function openIssue() {
chrome.storage.sync.get(function (item) {
var urlOption = item.savedUrl;
var projectOption = item.savedProject;
key = document.getElementById('key').value;
setUrl(urlOption);
key = removeSpaces(key);
key = removeSkypeFormatting(key);
key = maybeAddProject(key, projectOption);
if (key === '') {
returnError('Please insert key', 'key');
......@@ -102,4 +110,4 @@ if (window.addEventListener) {
window.attachEvent('onload', listenKeys);
} else {
document.addEventListener('load', listenKeys, false);
}
\ No newline at end of file
}
function save_options() {
var url = document.getElementById('urlOption').value;
var project = document.getElementById('projectOption').value;
var status = document.getElementById('status');
var error = document.getElementById('error');
var border = document.getElementById('urlOption');
......@@ -15,9 +16,10 @@ function save_options() {
border.select();
chrome.storage.sync.set({
savedUrl: url
savedUrl: url,
savedProject: project
}, function () {
status.textContent = 'URL is saved';
status.textContent = 'Options saved';
setTimeout(function () {
status.textContent = '';
}, 2000);
......@@ -27,9 +29,11 @@ function save_options() {
function restore_options() {
chrome.storage.sync.get({
savedUrl: 'https://jira.atlassian.com'
savedUrl: 'https://jira.atlassian.com',
savedProject: 'PROJECT'
}, function (items) {
document.getElementById('urlOption').value = items.savedUrl;
document.getElementById('projectOption').value = items.savedProject;
document.getElementById('urlOption').select();
});
}
......@@ -65,4 +69,4 @@ if (window.addEventListener) {
window.attachEvent('onload', listenURL);
} else {
document.addEventListener('load', listenURL, false);
}
\ No newline at end of file
}
{
"name": "JIRA Issue Opener",
"short_name": "JIRA Issue Opener",
"version": "2.0",
"version": "2.1",
"manifest_version": 2,
"description": "Extension opens JIRA issue in new tab",
"homepage_url": "http://ivanova-irina.blogspot.com/p/jira-issue-opener.html",
......@@ -23,4 +23,4 @@
"name": "Irina Ivanova",
"email": "iriiiina@gmail.com"
}
}
\ No newline at end of file
}
......@@ -2,7 +2,7 @@
<html>
<head>
<title>Options of JIRA Issue Opener 2.0</title>
<title>Options of JIRA Issue Opener 2.1</title>
<link rel='stylesheet' type='text/css' href='css/options.css' />
</head>
......@@ -31,7 +31,16 @@
</label>
</td>
<td>
<input type='text' name='urlOption' id='urlOption' maxlength='255' size='30' autofocus />&nbsp;<code>/browse/KEY</code>
<input type='text' name='urlOption' id='urlOption' maxlength='255' size='30' autofocus />&nbsp;<code>/browse/PROJECT-123</code>
</td>
</tr>
<tr>
<td>
<label for='urlOption'><b>Default project:</b>
</label>
</td>
<td>
<input type='text' name='projectOption' id='projectOption' maxlength='255' size='30' autofocus />
</td>
</tr>
<tr>
......@@ -49,4 +58,4 @@
</body>
</html>
\ No newline at end of file
</html>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment