Leaflet/build/build.html

234 lines
5.7 KiB
HTML
Raw Normal View History

<!DOCTYPE html>
<html>
<head>
<title>Leaflet Build Helper</title>
<script type="text/javascript" src="deps.js"></script>
<style type="text/css">
body {
font: 12px/1.4 Verdana, sans-serif;
text-align: center;
padding: 2em 0;
}
#container {
text-align: left;
margin: 0 auto;
2011-12-12 20:04:26 +08:00
width: 780px;
}
#deplist {
list-style: none;
padding: 0;
}
#deplist li {
2011-12-12 20:04:26 +08:00
padding-top: 7px;
padding-bottom: 7px;
border-bottom: 1px solid #ddd;
2010-09-30 05:02:54 +08:00
}
#deplist li.heading {
border: none;
2011-12-12 20:04:26 +08:00
background: #ddd;
2010-09-30 05:02:54 +08:00
padding: 5px 10px;
2011-12-12 20:04:26 +08:00
margin-top: 25px;
border-radius: 5px;
}
#deplist input {
float: left;
margin-right: 5px;
display: inline;
}
#deplist label {
float: left;
2011-12-12 20:04:26 +08:00
width: 160px;
font-weight: bold;
}
#deplist div {
display: table-cell;
height: 1%;
}
#deplist .desc {
}
#deplist .deps {
color: #777;
}
#command, #command2 {
width: 100%;
}
2011-12-12 20:04:26 +08:00
#toolbar {
padding-bottom: 10px;
border-bottom: 1px solid #ddd;
}
h2 {
margin-top: 2em;
}
</style>
</head>
<body>
<div id="container">
<h1>Leaflet Build Helper</h1>
2011-12-12 20:04:26 +08:00
<p id="toolbar">
<a id="select-all" href="#all">Select All</a> |
<a id="deselect-all" href="#none">Deselect All</a>
</p>
<ul id="deplist"></ul>
2011-12-12 20:04:26 +08:00
<h2>Building using Node and UglifyJS</h2>
<p>
2011-12-12 20:04:26 +08:00
<a href="http://nodejs.org/#download">Install Node</a>, install Jake & UglifyJS (<code>npm install -g jake</code>; <code>npm install -g uglify-js</code>), then run this in the root Leaflet directory:<br />
<input type="text" id="command2" />
</p>
2011-12-12 20:04:26 +08:00
<h2>Building using Closure Compiler</h2>
<p>
2011-12-12 20:04:26 +08:00
<a href="http://closure-compiler.googlecode.com/files/compiler-latest.zip">Download Closure Compiler</a> and extract it into <code>lib/closure-compiler</code> directory and run this command in the root Leaflet directory:<br />
<input type="text" id="command" />
</p>
</div>
<script type="text/javascript">
var deplist = document.getElementById('deplist'),
commandInput = document.getElementById('command'),
commandInput2 = document.getElementById('command2');
document.getElementById('select-all').onclick = function() {
var checks = deplist.getElementsByTagName('input');
for (var i = 0; i < checks.length; i++) {
checks[i].checked = true;
}
updateCommand();
return false;
};
document.getElementById('deselect-all').onclick = function() {
var checks = deplist.getElementsByTagName('input');
for (var i = 0; i < checks.length; i++) {
if (!checks[i].disabled) {
checks[i].checked = false;
}
}
updateCommand();
return false;
};
function updateCommand() {
var files = {};
var checks = deplist.getElementsByTagName('input');
var compsStr = '';
2011-12-12 20:04:26 +08:00
for (var i = 0, len = checks.length; i < len; i++) {
if (checks[i].checked) {
var srcs = deps[checks[i].id].src;
2011-12-12 20:04:26 +08:00
for (var j = 0, len2 = srcs.length; j < len2; j++) {
files[srcs[j]] = true;
}
compsStr = '1' + compsStr;
} else {
compsStr = '0' + compsStr;
}
}
var command = 'java -jar lib/closure-compiler/compiler.jar ';
for (var src in files) {
command += '--js src/' + src + ' ';
}
command += '--js_output_file dist/leaflet-custom.js';
commandInput.value = command;
commandInput2.value = 'jake build[' + parseInt(compsStr, 2).toString(32) + ']';
}
commandInput.onclick = function() {
commandInput.focus();
commandInput.select();
};
function onCheckboxChange() {
if (this.checked) {
var depDeps = deps[this.id].deps;
if (depDeps) {
for (var i = 0; i < depDeps.length; i++) {
var check = document.getElementById(depDeps[i]);
if (!check.checked) {
check.checked = true;
check.onchange();
}
}
}
} else {
var checks = deplist.getElementsByTagName('input');
for (var i = 0; i < checks.length; i++) {
var dep = deps[checks[i].id];
if (!dep.deps) { continue; }
for (var j = 0; j < dep.deps.length; j++) {
if (dep.deps[j] === this.id) {
if (checks[i].checked) {
checks[i].checked = false;
checks[i].onchange();
}
}
}
}
}
updateCommand();
}
for (var name in deps) {
var li = document.createElement('li');
2010-09-30 05:02:54 +08:00
if (deps[name].heading) {
var heading = document.createElement('li');
heading.className = 'heading';
heading.appendChild(document.createTextNode(deps[name].heading));
deplist.appendChild(heading);
}
var div = document.createElement('div');
var label = document.createElement('label');
var check = document.createElement('input');
check.type = 'checkbox';
check.id = name;
label.appendChild(check);
check.onchange = onCheckboxChange;
if (name == 'Core') {
check.checked = true;
check.disabled = true;
}
label.appendChild(document.createTextNode(name));
label.htmlFor = name;
li.appendChild(label);
var desc = document.createElement('span');
desc.className = 'desc';
desc.appendChild(document.createTextNode(deps[name].desc));
var depText = deps[name].deps && deps[name].deps.join(', ');
if (depText) {
var depspan = document.createElement('span');
depspan.className = 'deps';
depspan.appendChild(document.createTextNode('Deps: ' + depText));
}
div.appendChild(desc);
div.appendChild(document.createElement('br'));
if (depText) { div.appendChild(depspan); }
li.appendChild(div);
deplist.appendChild(li);
}
updateCommand();
</script>
</body>
</html>