-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jira Homepage Helper.html
226 lines (193 loc) · 7.77 KB
/
Jira Homepage Helper.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
<!DOCTYPE HTML>
<html>
<head>
<!--
JIRA Helper Homepage
Copyright (C) 2021 Martin Hohenberg <me@martinhohenberg.de>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
//-->
<meta charset="UTF-8">
<title>MaHo's amazing JIRA Project Access System</title>
<script src="https://code.jquery.com/jquery-3.4.0.min.js" crossorigin="anonymous"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"
integrity="sha256-VazP97ZCwtekAsvgPBSUwPFKdrwD3unUfSGVYrahUqU=" crossorigin="anonymous"></script>
<script>
// baseURL is the base URL under which your Jira instance lives
var baseURL = "https://myhost/jira";
// headerLinks are the link texts and links of the buttons.
var headerLinks = [
["Home", "/"],
["Behaviours", "/secure/admin/Behaviours!default.jspa"],
["Custom Fields", "/secure/admin/UserBrowser.jspa"],
["User Management", "/secure/admin/UserBrowser.jspa"],
["SIL Manager", "/plugins/servlet/silmanager?autoSelectTree=sil.scripts"],
["Scriptrunner Base", "/plugins/servlet/scriptrunner/admin/browse"],
["Portfolio", "/secure/PortfolioPortfolioManage.jspa?ref=1"]
]
function getColor(indexpos){
return "hsl(" + 360 * indexpos + ',' +
70 + '%,' +
95 + '%)'
}
var counterForSwitch = 0;
var GlobalTextFromTextInputConverter;
String.prototype.replaceAll = function (search, replacement) {
var target = this;
return target.replace(new RegExp(search, 'g'), replacement);
};
function text_converter() {
counterForSwitch++;
var textBoxInput = $("#textBox").val();
if ((counterForSwitch % 2) === 1) {
GlobalTextFromTextInputConverter = textBoxInput;
var TextForTextBox = textBoxInput;
TextForTextBox = TextForTextBox.replaceAll(/["]/gm, '\\"');
/*Escape " to /" */
TextForTextBox = TextForTextBox.replaceAll(/[“]/gm, '\\“');
/*Escape “ to /“ */
TextForTextBox = TextForTextBox.replaceAll(/\n/g, ' \\n"+\n' + '"');
/* Add the new line with a plus */
TextForTextBox = "lfSet(\"description\",\n" + "\"" + TextForTextBox + "\"" + "\n);";
/*Add the Start and the end */
document.getElementById("textBox").value = TextForTextBox;
/*Set the value of the textarea*/
document.getElementById("switchForConvert").className ="tunerActiv"
$("#switchForConvert").prop('value', 'convert back');
} else {
document.getElementById("textBox").value = GlobalTextFromTextInputConverter;
document.getElementById("switchForConvert").className ="tuner"
$("#switchForConvert").prop('value', 'convert to SIL');
}
}
function setFocusToTextBox() {
$("#project").focus();
}
function matchProjectKeyPattern(pattern, regex) {
return pattern.match(regex);
}
function clearTextBox() {
$("#project").val("");
}
function redirect() {
var projectKey = $("#project").val();
projectKey = projectKey.toUpperCase().trim();
var regex = /^([A-Z]+)$/;
if (matchProjectKeyPattern(projectKey, regex)) {
if ($("#destination").val() == "admin view") {
window.open(baseURL+"/plugins/servlet/project-config/" + projectKey + "/summary");
} else if ($("#destination").val() == "components") {
window.open(baseURL+"/plugins/servlet/project-config/" + projectKey + "/administer-components");
} else if ($("#destination").val() == "users and roles") {
window.open(baseURL+"/plugins/servlet/project-config/" + projectKey + "/roles");
} else if ($("#destination").val() == "workflows") {
window.open(baseURL+"/plugins/servlet/project-config/" + projectKey + "/workflows");
} else if ($("#destination").val() == "screens") {
window.open(baseURL+"/plugins/servlet/project-config/" + projectKey + "/screens");
} else {
window.open(baseURL+"/projects/" + projectKey + "/issues/");
}
} else {
alert("Not a valid project key: " + projectKey);
}
}
</script>
<style type="text/css">
* {
font-family: Helvetica, Verdana, Arial, sans-serif;
color: #AAA;
}
form {
text-align: center;
margin: 0.25em auto 0 auto;
font-size: 4em;
}
input, select {
font-size: 1em;
padding: 0.05em;
color: #333;
border: 1px solid #999;
}
#buttons li {
float: left;
list-style: none;
text-align: center;
background-color: #033;
margin-right: 30px;
width: 150px;
line-height: 60px;
}
#buttons li a {
text-decoration: none;
color: #000;
display: block;
}
#buttons li a:hover {
text-decoration: none;
color: #000000;
background-color: #33B5E5;
border:1px solid #888;
}
textarea {
height: 15em;
width: 60%;
color: black;
font-size: 0.4em;
}
.tuner {
background-color: #33B5E5;
width: 20%;
height: 100px;
font-size: 0.4em;
color: #FFFFFF;
}
.tunerActiv {
background-color: #cb640b;
width: 20%;
height: 100px;
font-size: 0.4em;
color: #FFFFFF;
}
</style>
</head>
<body onload="setFocusToTextBox()">
<ul style="margin:0 auto 0 auto" id="buttons">
</ul>
<div style="clear:both"></div>
<hr> <h2>Go to Project (by key)</h2>
<form>
Go to
<select id="destination">
<option>admin view</option>
<option>components</option>
<option>users and roles</option>
<option>workflows</option>
<option>screens</option>
<option>overview</option>
</select> of
<input type="text" id="project" onfocus="clearTextBox()" onchange="redirect()"/>
<input type="button" style="background-color:#4d243d;color:white;" onclick="redirect()" value="GO!">
</form>
<hr> <h2>SIL Template Converter</h2>
<div class="textconverter">
<form onsubmit="text_converter()">
<textarea id="textBox"></textarea>
<input onclick="text_converter()" style="background-color:#4d243d;color:white;height:1.5em;width:60%;" type="button" class="tuner" value="convert to SIL" id="switchForConvert">
</form>
</div>
<script>
headerLinks.forEach( function (item, index){
var buttoncolor = getColor(index / headerLinks.length);
$( "#buttons" ).append("<li><a style='background-color:"+buttoncolor+"' target='_new' href='"+baseURL+item[1]+"'>"+item[0]+"</a></li>" );
});
</script>
</body>
</html>