Commit c1643db6 authored by Leo Iannacone's avatar Leo Iannacone

better select functions and update split in update.page and update.view

parent 05352521
...@@ -45,7 +45,7 @@ function Page_Distrubion() ...@@ -45,7 +45,7 @@ function Page_Distrubion()
tmp.package = p tmp.package = p
$('#packages ul').append('<li id="package-' + p.orig_name + '"><a href="' + Utils.from_data_to_hash(tmp) + '">'+ p.name + ' <span>'+p.version+'</span></a></li>') $('#packages ul').append('<li id="package-' + p.orig_name + '"><a href="' + Utils.from_data_to_hash(tmp) + '">'+ p.name + ' <span>'+p.version+'</span></a></li>')
}) })
select(data) select()
}, },
clean: function () { clean: function () {
...@@ -60,10 +60,8 @@ function Page_Distrubion() ...@@ -60,10 +60,8 @@ function Page_Distrubion()
socket.emit("get_distribution_packages", new_data) socket.emit("get_distribution_packages", new_data)
} }
}, },
select: function(data) { select: function() {
packages.unselect() packages.unselect()
if (! data)
data = Utils.from_hash_to_data()
if (Utils.check_data_package(data)) { if (Utils.check_data_package(data)) {
$("#packages li[id='package-"+ data.package.orig_name + "']").addClass('active') $("#packages li[id='package-"+ data.package.orig_name + "']").addClass('active')
} }
...@@ -125,10 +123,8 @@ function Page_Distrubion() ...@@ -125,10 +123,8 @@ function Page_Distrubion()
socket.emit("get_package_files_list", new_data) socket.emit("get_package_files_list", new_data)
} }
}, },
select: function(data) { select: function() {
files.unselect() files.unselect()
if (! data)
data = Utils.from_hash_to_data()
if (Utils.check_data_file(data)) { if (Utils.check_data_file(data)) {
$("#logs li[id='file-" + data.file.orig_name + "']").addClass('active') $("#logs li[id='file-" + data.file.orig_name + "']").addClass('active')
} }
...@@ -203,15 +199,13 @@ function Page_Distrubion() ...@@ -203,15 +199,13 @@ function Page_Distrubion()
// }) // })
} }
var select = function(data) { var select = function() {
unselect() unselect()
if (! data)
data = Utils.from_hash_to_data()
if (Utils.check_data_distribution(data)) { if (Utils.check_data_distribution(data)) {
$("#distributions li[id='distribution-" + data.distribution.name + "']").addClass('active') $("#distributions li[id='distribution-" + data.distribution.name + "']").addClass('active')
} }
packages.select(data) packages.select()
files.select(data) files.select()
} }
var unselect = function() { var unselect = function() {
...@@ -229,7 +223,8 @@ function Page_Distrubion() ...@@ -229,7 +223,8 @@ function Page_Distrubion()
breadcrumb.update() breadcrumb.update()
} }
var update = function(data, old_data) { var update = {
page: function(data, old_data) {
if (! old_data ) { if (! old_data ) {
if (! data ) if (! data )
populate() populate()
...@@ -244,6 +239,7 @@ function Page_Distrubion() ...@@ -244,6 +239,7 @@ function Page_Distrubion()
{ {
clean() clean()
populate(data) populate(data)
return
} }
else if ( else if (
! Utils.check_data_package(old_data) || ! Utils.check_data_package(old_data) ||
...@@ -266,9 +262,15 @@ function Page_Distrubion() ...@@ -266,9 +262,15 @@ function Page_Distrubion()
{ {
file.get() file.get()
} }
update.view(data)
}
},
view : function(data) {
if (! data )
data = Utils.from_hash_to_data()
title.set(data) title.set(data)
breadcrumb.update() breadcrumb.update()
select(data) select()
sticky() sticky()
} }
} }
...@@ -280,37 +282,34 @@ function Page_Distrubion() ...@@ -280,37 +282,34 @@ function Page_Distrubion()
packages.get(data) packages.get(data)
files.get(data) files.get(data)
file.get(data) file.get(data)
select(data) update.view(data)
breadcrumb.update()
title.set(data)
sticky()
} }
this.init = function (mysocket) { this.init = function (mysocket) {
socket = mysocket socket = mysocket
socket.on('distribution_packages', function(data){ socket.on('distribution_packages', function(socket_data){
packages.set(data) packages.set(socket_data)
}) })
socket.on('package_files_list', function(data){ socket.on('package_files_list', function(socket_data){
files.set(data) files.set(socket_data)
}) })
socket.on('file', function (data) { socket.on('file', function (socket_data) {
file.set(data) file.set(socket_data)
}) })
socket.on('file_newcontent', function(data) { socket.on('file_newcontent', function(socket_data) {
file.append(data) file.append(socket_data)
}) })
$(window).on('hashchange', function() { $(window).on('hashchange', function() {
__check_hash_makes_sense() __check_hash_makes_sense()
new_data = Utils.from_hash_to_data() var old_data = data
update(new_data, data) data = Utils.from_hash_to_data()
data = new_data update.page(data, old_data)
}); });
$(window).on('load', function (){ $(window).on('load', function (){
......
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