Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
139 lines (113 sloc) 3.32 KB
<!DOCTYPE html>
<html>
<head>
<title>MooTools Milk Sprinter</title>
<style>
#iframes iframe {
width: 100%;
height: 300px;
}
#suiteselection {
overflow: hidden;
}
#suiteselection div {
float: left;
margin-right: 20px;
}
#runspecs {
margin: 20px;
}
</style>
</head>
<body>
<div id="suiteselection"></div>
<div><button id="runspecs">Run!</button></div>
<div id="iframes"></div>
<script src="SimpleRequest.js"></script>
<script type="text/javascript">
var suites = {
'Base': [],
'DOM': []
};
var indexOf = function(array, el){
for (var i = 0; i < array.length; i++){
if (array[i] == el) return i;
}
return -1;
};
var stringifyModulesHash = function(){
var parts = [];
for (var suite in suites){
if (suites[suite].length) parts.push(suite + ':' + suites[suite].join(','));
}
return parts.join(';');
};
var parseModulesHash = function(){
var _packages = location.hash.slice(1).split(';');
for (var i = 0; i < _packages.length; i++){
var parts = _packages[i].split(':');
suites[parts[0]] = parts[1] ? parts[1].split(',') : [];
}
};
// loading the iframes
var run = function(){
var iframesWrapper = document.getElementById('iframes');
iframesWrapper.innerHTML = '';
for (var name in suites){
var packagesuites = suites[name];
for (var j = 0; j < packagesuites.length; j++){
var heading = document.createElement('h3');
heading.innerHTML = name;
iframesWrapper.appendChild(heading);
var iframe = document.createElement('iframe');
iframesWrapper.appendChild(iframe);
iframe.src = '../' + name + '/Specs/'
+ packagesuites[j] + '.html?' + +(new Date)
+ '&path=' + encodeURI(location.pathname.match(/(.*\/)\w+\.html$/i)[1]);
}
}
location.hash = '#' + stringifyModulesHash();
};
// load suites.json for the suite selection
var suiteselection = document.getElementById('suiteselection');
for (var module in suites) (function(module){
var wrapper = document.createElement('div');
wrapper.innerHTML = '<h2>' + module + '</h2>loading...';
suiteselection.appendChild(wrapper);
new SimpleRequest().send('../' + module + '/Specs/suites.json', function(json){
var data = window.JSON && JSON.parse ? JSON.parse(json) : eval('(' + json + ')');
var html = '<h2>' + module + '</h2>';
for (var name in data){
var _name = module + ':' + name;
var _id = module + '-' + name;
html += '<input type="checkbox" name="'
+ _name + '" id="' + _id + '"'
+ (suites[module] && (indexOf(suites[module], name) != -1) ? ' checked' : '')
+ '><label for="' + _id + '">'
+ name + '</label><br>';
}
wrapper.innerHTML = html;
});
})(module);
var runButton = document.getElementById('runspecs');
runButton.onclick = function(){
var inputs = suiteselection.getElementsByTagName('input');
for (var i = 0; i < inputs.length; i++){
var input = inputs[i];
var parts = input.name.split(':');
var packagesuites = suites[parts[0]];
var index = indexOf(packagesuites, parts[1]);
if (input.checked && index == -1){
packagesuites.push(parts[1]);
} else if (!input.checked && index != -1){
packagesuites.splice(index, 1);
}
}
run();
};
// do it!
parseModulesHash();
run();
</script>
</body>
</html>