-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathservlet-picker.html
59 lines (52 loc) · 1.9 KB
/
servlet-picker.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Bookmarklet: CQ5/AEM6 Server Picker</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
</head>
<body class="container">
<h1>Bookmarklet: CQ5/AEM6 Server Picker</h1>
Select a server and an action and voila.
<h3>Installation</h3>
Drag the following link to your bookmarks bar:
<a id="bookmarklet" href="javascript:">Servers</a>
<h3>Source</h3>
<pre id="source" style="-moz-tab-size: 4; -o-tab-size: 4; tab-size: 4;"></pre>
<script>
(function () {
'use strict';
var code = function () {
// --- the bookmarklet code START ---
var url = location.protocol === 'file:' ? 'server-picker.js' :
'https://rawgit.com/byterider/server-picker/master/server-picker.js',
head = document.getElementsByTagName('head')[0],
script = document.createElement('script');
if (head && script) {
script.src = url;
head.appendChild(script);//test
}
// --- the bookmarklet code END ---
};
function stripComments(s) {
return s.replace(/\n?( |\t)*([^:])\/{2}[^\n]*$/mg, '$2');
}
function extractBody(s) {
return s.substring(s.indexOf('{') + 2, s.lastIndexOf('}')).replace(/^([ \t]*\n)+/m, '').replace(/(\n\t*)+$/, '');
}
function collapseWhiteSpace(s) {
return s.replace(/([^}{;,\s])\s*\n/mg, '$1\n').replace(/^\s+|\s+$|\n/mg, '');
}
function outdent(s) {
var indentLevel = s.match(/^ |\t+/)[0].length;
return s.replace(new RegExp('^ |\\t{' + indentLevel + '}', 'mg'), '');
}
var source = '' + code,
bookmarklet = collapseWhiteSpace(extractBody(stripComments(source))),
preview = outdent(extractBody(stripComments(source)));
document.getElementById('bookmarklet').href += bookmarklet;
document.getElementById('source').innerText = preview;
}());
</script>
</body>
</html>