-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.ejs
68 lines (65 loc) · 3.04 KB
/
index.ejs
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
<!DOCTYPE html>
<html style="font-size: 13px;">
<head>
<title>SQL Formatter</title>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto+Condensed:400|Fira+Mono">
<link rel="stylesheet" href="css/bundle.css">
<link rel="icon" href="img/favicon.png">
<link rel="apple-touch-icon" href="img/apple-touch-icon.png">
<link rel="apple-touch-icon" sizes="180x180" href="img/apple-touch-icon.png">
<link rel="apple-touch-icon" sizes="192x192" href="img/apple-touch-icon-192.png">
</head>
<body class="d-flex flex-column">
<nav class="py-2 px-3 mb-4">
<div class="container d-flex justify-content-between">
<h1 class="mb-0"><a href="">SQL Formatter</a></h1>
<div class="fit-height">
<div class="h5 mb-0 mr-1 d-inline-block fit-height">Run with:</div>
<select id="languages"></select>
</div>
</div>
</nav>
<div id="main"></div>
<footer class="p-2 text-center text-muted">
<div id="powered-by"></div>
<div>
Built by <a href="http://mattdziuban.com" class="text-muted">Matt Dziuban</a>
•
<a href="https://github.com/mrdziuban/sql-formatter" class="text-muted">Source on GitHub</a>
</div>
</footer>
<script>
var langs = <%= JSON.stringify(htmlWebpackPlugin.options.languages) %>;
var urlMatch = window.location.search.match(/lang=([^&]+)/);
var langKeys = Object.keys(langs);
var langsToPick = (langKeys.length === 1 && langKeys[0] === 'rust') ? langKeys : langKeys.filter(function(l) { return l !== 'rust'; });
var lang = urlMatch && urlMatch[1] && langs[urlMatch[1].toLowerCase()]
? urlMatch[1].toLowerCase()
: langsToPick[Math.floor(Math.random() * langsToPick.length)];
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = 'js/' + lang + '.js';
document.body.appendChild(script);
var langSelect = document.getElementById('languages');
Object.keys(langs).forEach(function(l) {
var opt = document.createElement('option');
opt.value = l;
opt.innerText = langs[l].name;
langSelect.appendChild(opt);
});
langSelect.value = lang;
langSelect.onchange = function() {
window.location = window.location.protocol +
'//' + window.location.hostname +
(window.location.port ? ':' + window.location.port : '') +
window.location.pathname +
'?lang=' + langSelect.value;
};
document.getElementById('powered-by').innerHTML = '<a href="' + langs[lang].link + '" ' +
'class="text-muted" target="_blank">Powered by ' + langs[lang].name + '</a>';
</script>
</body>
</html>