Commit 9bbe4a18 authored by Leo Iannacone's avatar Leo Iannacone

build hash with a function

parent 9f456fc5
...@@ -19,6 +19,19 @@ function get_path(path) { ...@@ -19,6 +19,19 @@ function get_path(path) {
} }
} }
function build_hash(data) {
hash = "#"
if (data.distribution && data.distribution.name) {
hash = hash + data.distribution.name
if (data.package && data.package.name && data.package.version) {
hash = hash + '/' + data.package.name + "/" + data.package.version
if (data.file && data.file.name)
hash = hash + '/' + data.file.name
}
}
return hash
}
var socket = io.connect('//localhost:3000'); var socket = io.connect('//localhost:3000');
socket.on('distributions', function(distributions) { socket.on('distributions', function(distributions) {
...@@ -30,16 +43,20 @@ socket.on('distributions', function(distributions) { ...@@ -30,16 +43,20 @@ socket.on('distributions', function(distributions) {
socket.on('distribution_packages', function(data){ socket.on('distribution_packages', function(data){
$('#packages ul').html('') $('#packages ul').html('')
tmp = data
tmp.file = null
data.distribution.packages.forEach(function(p){ data.distribution.packages.forEach(function(p){
div = $('#packages ul').append('<li><a href="#' + data.distribution.name + '/' + p.name + '/'+ p.version + '">'+ p.name + ' <span>'+p.version+'</span></a></li>') tmp.package = p
div = $('#packages ul').append('<li><a href="' + build_hash(tmp) + '">'+ p.name + ' <span>'+p.version+'</span></a></li>')
}) })
}) })
socket.on('package_file_list', function(data){ socket.on('package_file_list', function(data){
$('#files ul').html(''); $('#files ul').html('');
tmp = data
data.package.files.forEach(function(f){ data.package.files.forEach(function(f){
p = data.package tmp.file = f
$('#files ul').append('<li><a href="#' + data.distribution.name + '/' + p.name + '/'+ p.version + '/' + f.name + '">' + f.name + '</a></li>') $('#files ul').append('<li><a href="'+ build_hash(tmp) + '">' + f.name + '</a></li>')
}) })
}) })
......
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