2010-09-29 20:22:49 +08:00
<!DOCTYPE html>
< html >
< head >
< title > Leaflet Build Helper< / title >
2011-12-09 18:40:15 +08:00
2010-09-29 20:22:49 +08:00
< script type = "text/javascript" src = "deps.js" > < / script >
2011-12-09 18:40:15 +08:00
2010-09-29 20:22:49 +08:00
< 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;
2010-09-29 20:22:49 +08:00
}
#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;
2010-09-29 20:22:49 +08:00
}
#deplist input {
float: left;
margin-right: 5px;
display: inline;
}
#deplist label {
float: left;
2011-12-12 20:04:26 +08:00
width: 160px;
2010-09-29 20:22:49 +08:00
font-weight: bold;
}
#deplist div {
display: table-cell;
height: 1%;
}
#deplist .desc {
2011-12-09 18:40:15 +08:00
}
2010-09-29 20:22:49 +08:00
#deplist .deps {
color: #777;
}
2011-12-09 18:40:15 +08:00
2011-12-13 04:37:30 +08:00
#command {
2010-09-29 20:22:49 +08:00
width: 100%;
}
2011-12-13 04:37:30 +08:00
#command2 {
width: 200px;
}
2011-12-12 20:04:26 +08:00
#toolbar {
padding-bottom: 10px;
border-bottom: 1px solid #ddd;
}
h2 {
margin-top: 2em;
}
2010-09-29 20:22:49 +08:00
< / style >
< / head >
< body >
< div id = "container" >
< h1 > Leaflet Build Helper< / h1 >
2011-12-09 18:40:15 +08:00
2011-12-12 20:04:26 +08:00
< p id = "toolbar" >
2011-12-09 18:40:15 +08:00
< a id = "select-all" href = "#all" > Select All< / a > |
2010-09-29 20:22:49 +08:00
< a id = "deselect-all" href = "#none" > Deselect All< / a >
< / p >
2011-12-09 18:40:15 +08:00
2010-09-29 20:22:49 +08:00
< ul id = "deplist" > < / ul >
2011-12-09 18:40:15 +08:00
2011-12-12 20:04:26 +08:00
< h2 > Building using Node and UglifyJS< / h2 >
2011-12-13 04:37:30 +08:00
< ol >
< li > < a href = "http://nodejs.org/#download" > Download and install Node< / a > < / li >
< li > Run this in the command line:< br / >
< pre > < code > npm install -g jake
2012-02-26 00:57:28 +08:00
npm install jshint
npm install uglify-js< / code > < / pre > < / li >
2011-12-13 04:37:30 +08:00
< li > Run this command inside the Leaflet directory: < br / > < input type = "text" id = "command2" / >
< / ol >
2011-12-12 20:04:26 +08:00
< h2 > Building using Closure Compiler< / h2 >
2011-12-13 04:37:30 +08:00
< ol >
2012-02-26 00:57:28 +08:00
< li > < a href = "http://closure-compiler.googlecode.com/files/compiler-latest.zip" > Download Closure Compiler< / a > , extract it into < code > closure-compiler< / code > directory< / li >
2011-12-13 04:37:30 +08:00
< li > Run this command in the root Leaflet directory: < br / > < input type = "text" id = "command" / > < / li >
< / ol >
2010-09-29 20:22:49 +08:00
< / div >
2011-12-09 18:40:15 +08:00
2010-09-29 20:22:49 +08:00
< script type = "text/javascript" >
var deplist = document.getElementById('deplist'),
2011-12-12 17:42:42 +08:00
commandInput = document.getElementById('command'),
commandInput2 = document.getElementById('command2');
2011-12-09 18:40:15 +08:00
2010-09-29 20:22:49 +08:00
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;
};
2011-12-09 18:40:15 +08:00
2010-09-29 20:22:49 +08:00
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;
};
2011-12-09 18:40:15 +08:00
2010-09-29 20:22:49 +08:00
function updateCommand() {
var files = {};
var checks = deplist.getElementsByTagName('input');
2011-12-12 17:42:42 +08:00
var compsStr = '';
2011-12-12 20:04:26 +08:00
for (var i = 0, len = checks.length; i < len ; i + + ) {
2010-09-29 20:22:49 +08:00
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 + + ) {
2010-09-29 20:22:49 +08:00
files[srcs[j]] = true;
}
2011-12-12 17:42:42 +08:00
compsStr = '1' + compsStr;
} else {
compsStr = '0' + compsStr;
2010-09-29 20:22:49 +08:00
}
}
2011-12-09 18:40:15 +08:00
2012-02-26 00:57:28 +08:00
var command = 'java -jar closure-compiler/compiler.jar ';
2010-09-29 20:22:49 +08:00
for (var src in files) {
2011-12-12 17:42:42 +08:00
command += '--js src/' + src + ' ';
2010-09-29 20:22:49 +08:00
}
2011-12-12 17:42:42 +08:00
command += '--js_output_file dist/leaflet-custom.js';
2011-12-09 18:40:15 +08:00
2010-09-29 20:22:49 +08:00
commandInput.value = command;
2011-12-12 17:42:42 +08:00
2011-12-13 04:37:30 +08:00
commandInput2.value = 'jake build[' + parseInt(compsStr, 2).toString(32) + ',custom]';
2010-09-29 20:22:49 +08:00
}
2011-12-09 18:40:15 +08:00
2011-12-13 04:37:30 +08:00
function inputSelect() {
this.focus();
this.select();
2010-09-29 20:22:49 +08:00
};
2012-02-26 00:57:28 +08:00
2011-12-13 04:37:30 +08:00
commandInput.onclick = inputSelect;
commandInput2.onclick = inputSelect;
2011-12-09 18:40:15 +08:00
2010-09-29 20:22:49 +08:00
function onCheckboxChange() {
if (this.checked) {
var depDeps = deps[this.id].deps;
2011-12-12 17:42:42 +08:00
if (depDeps) {
for (var i = 0; i < depDeps.length ; i + + ) {
var check = document.getElementById(depDeps[i]);
if (!check.checked) {
check.checked = true;
check.onchange();
}
2010-09-29 20:22:49 +08:00
}
}
} 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 + + ) {
2011-12-12 17:42:42 +08:00
if (dep.deps[j] === this.id) {
2010-09-29 20:22:49 +08:00
if (checks[i].checked) {
checks[i].checked = false;
checks[i].onchange();
}
}
}
}
}
updateCommand();
}
2011-12-09 18:40:15 +08:00
2010-09-29 20:22:49 +08:00
for (var name in deps) {
var li = document.createElement('li');
2011-12-09 18:40:15 +08:00
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);
}
2011-12-09 18:40:15 +08:00
2010-09-29 20:22:49 +08:00
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;
2011-12-09 18:40:15 +08:00
2010-09-29 20:22:49 +08:00
if (name == 'Core') {
check.checked = true;
check.disabled = true;
}
2011-12-09 18:40:15 +08:00
2010-09-29 20:22:49 +08:00
label.appendChild(document.createTextNode(name));
label.htmlFor = name;
2011-12-09 18:40:15 +08:00
2010-09-29 20:22:49 +08:00
li.appendChild(label);
2011-12-09 18:40:15 +08:00
2010-09-29 20:22:49 +08:00
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));
}
2011-12-09 18:40:15 +08:00
2010-09-29 20:22:49 +08:00
div.appendChild(desc);
div.appendChild(document.createElement('br'));
if (depText) { div.appendChild(depspan); }
2011-12-09 18:40:15 +08:00
2010-09-29 20:22:49 +08:00
li.appendChild(div);
2011-12-09 18:40:15 +08:00
2010-09-29 20:22:49 +08:00
deplist.appendChild(li);
}
updateCommand();
< / script >
< / body >
2011-12-09 18:40:15 +08:00
< / html >