-
Notifications
You must be signed in to change notification settings - Fork 2
/
tpl.footer.php
67 lines (56 loc) · 1.79 KB
/
tpl.footer.php
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
<hr />
<details>
<summary>Jira requests</summary>
<pre style="white-space: pre-line; margin: 0"><?= implode('<br />', $jira_history) ?></pre>
</details>
<pre><?= number_format(microtime(1) - $_start, 3) ?> s</pre>
<script>
function makeUpKey(field) {
var key = field.value.trim(); // issue 17 | issue17
key = key.replace(/\s+/, '-').toUpperCase(); // ISSUE-17 | ISSUE17
key = key.replace(/^([A-Z_]+)(\d+)$/, '$1-$2'); // ISSUE-17
// Jira's keys are very simple. If it's not that, no need to redirect.
if ( !/^[A-Z_]+\-\d+$/.test(key) ) {
alert('Invalid key: ' + key);
setTimeout(function() {
field.focus();
}, 1);
return;
}
return key;
}
$$('a[data-confirm]').on('click', function(e) {
if ( !confirm(this.data('confirm')) ) {
e.preventDefault();
e.stopPropagation();
e.stopImmediatePropagation();
}
});
$$('button[data-preview]').on('click', function(e) {
e.preventDefault();
var btn = this;
var text = $(btn.data('preview'), true).value;
document.body.addClass('loading');
$.post('new.php', 'issue=<?= urlencode($_GET['key'] ?? '') ?>&preview=' + encodeURIComponent(text)).on('success', function(e, html) {
document.el('div', {"class": 'markup', "style": 'position: relative; outline: solid 2px blue'})
.setHTML('<button type="button" onclick="return this.parentNode.remove(), false" style="position: absolute; top: 10px; right: 10px">x</button>' + html)
.injectAfter(btn.selfOrAncestor('p'));
document.body.removeClass('loading');
});
});
$$('a.ajax:not(.ajaxed)').on('click', function(e) {
e.preventDefault();
document.body.addClass('loading');
$.get(this.href).on('done', function(e, rsp) {
if ( rsp.substr(0, 2) == 'OK' ) {
location.reload();
}
else {
document.body.removeClass('loading');
alert(rsp);
}
});
}).addClass('ajaxed');
</script>
</body>
</html>