Commit 40d4005b authored by Leo Iannacone's avatar Leo Iannacone

some html tests

parent 5682fd79
...@@ -6,42 +6,68 @@ ...@@ -6,42 +6,68 @@
<script src='//code.jquery.com/jquery-1.7.2.min.js'></script> <script src='//code.jquery.com/jquery-1.7.2.min.js'></script>
<script src='//localhost:3000/socket.io/socket.io.js'></script> <script src='//localhost:3000/socket.io/socket.io.js'></script>
<script> <script>
function get_path(path) { function get_path(path) {
info = path.split('/'); info = path.split('/');
data = {} data = {}
if (info.length >= 1) { if (info.length >= 1) {
data.distribution = {} data.distribution = {}
data.distribution.name = info[0]; data.distribution.name = info[0];
} }
if (info.length >= 3){ if (info.length >= 3){
data.package = {} data.package = {}
data.package.name = info[1]; data.package.name = info[1];
data.package.version = info[2]; data.package.version = info[2];
} }
if (info.length == 4) {
data.file = info[3]
socket.emit('get-file', data)
}
else
socket.emit('get-view', data); socket.emit('get-view', data);
}
function set_up_view(data) {
if (data) {
if (data.distribution) {
if (data.distribution.name && data.distribution.packages) {
$('#packages').html('')
data.distribution.packages.forEach(function(p){
div = $('#packages').append('<li><a href="#' + data.distribution.name + '/' + p.name + '/'+ p.version + '">'+ p.name + ' <span>'+p.version+'</span></a></li>')
})
}
if (data.package) {
$('#files').html('');
data.package.files.forEach(function(f){
p = data.package
$('#files').append('<li><a href="#' + data.distribution.name + '/' + p.name + '/'+ p.version + '/' + f.name + '">' + f.label + '</a></li>')
})
}
}
} }
var socket = io.connect('//localhost:3000'); }
var socket = io.connect('//localhost:3000');
socket.on('distributions', function(distributions) { socket.on('distributions', function(distributions) {
$('#distributions').html(''); $('#distributions').html('');
distributions.forEach(function (name){ distributions.forEach(function (name){
$('#distributions').append('<li><a href="#' + name + '">' + name + '</li>'); $('#distributions').append('<li><a href="#' + name + '">' + name + '</li>');
});
}); });
});
socket.on('view', function(data){ socket.on('view', function(data){
console.log(data) console.log(data)
}); set_up_view(data)
});
socket.on('error', function() { console.error(arguments) });
$(window).on('hashchange', function() { socket.on('error', function() { console.error(arguments) });
get_path(window.location.hash.replace('#',''));
}); $(window).on('hashchange', function() {
get_path(window.location.hash.replace('#',''));
$(window).on('load', function (){ });
get_path(window.location.hash.replace('#',''));
}); $(window).on('load', function (){
get_path(window.location.hash.replace('#',''));
});
</script> </script>
</head> </head>
<body> <body>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment