Commit 3fb306f7 authored by Leo Iannacone's avatar Leo Iannacone

renamed variable data to view - refactored utils as well

parent d25f6fb6
...@@ -33,8 +33,8 @@ function Page_Generic() ...@@ -33,8 +33,8 @@ function Page_Generic()
$('#distributions ul').append('<li id="distribution-' + name +'"><a href="'+ config.paths.distribution + '#'+ name + '">' + name + '</li>'); $('#distributions ul').append('<li id="distribution-' + name +'"><a href="'+ config.paths.distribution + '#'+ name + '">' + name + '</li>');
}); });
if (window.location.pathname == config.paths.distribution) { if (window.location.pathname == config.paths.distribution) {
data = Utils.from_hash_to_data() var data = Utils.from_hash_to_view()
if (Utils.check_data_distribution(data)) { if (Utils.check_view_distribution(data)) {
$("#distributions li[id='distribution-" + data.distribution.name + "']").addClass('active') $("#distributions li[id='distribution-" + data.distribution.name + "']").addClass('active')
} }
} }
...@@ -98,7 +98,7 @@ function Page_Generic() ...@@ -98,7 +98,7 @@ function Page_Generic()
distributions.set(socket_distributions) distributions.set(socket_distributions)
}); });
socket.on('error', function(data) { consol_e.error(data) }); socket.on('error', function(socket_data_error) { console.error(socket_data_error) });
socket.on(_e.client.status, function(packages_status) { socket.on(_e.client.status, function(packages_status) {
status.set(packages_status) status.set(packages_status)
......
var Utils = { var Utils = {
from_hash_to_data: function (hash) { from_hash_to_view: function (hash) {
if (! hash ) if (! hash )
hash = window.location.hash hash = window.location.hash
hash = hash.replace('#', '') hash = hash.replace('#', '')
info = hash.split('/'); info = hash.split('/');
data = {} var view = {}
if (info.length >= 1) { if (info.length >= 1) {
data.distribution = {} view.distribution = {}
data.distribution.name = info[0]; view.distribution.name = info[0];
} }
if (info.length >= 3){ if (info.length >= 3){
data.package = {} view.package = {}
data.package.name = info[1]; view.package.name = info[1];
data.package.version = info[2]; view.package.version = info[2];
data.package.orig_name = data.package.name + '_' + data.package.version view.package.orig_name = view.package.name + '_' + view.package.version
} }
if (info.length >= 4) { if (info.length >= 4) {
data.file = {} view.file = {}
data.file.name = info[3] view.file.name = info[3]
data.file.orig_name = data.package.orig_name + '.' + data.file.name view.file.orig_name = view.package.orig_name + '.' + view.file.name
} }
return data return view
}, },
from_data_to_hash: function (data) { from_view_to_hash: function (view) {
hash = "#" hash = "#"
if (Utils.check_data_distribution(data)) { if (Utils.check_view_distribution(view)) {
hash = hash + data.distribution.name hash = hash + view.distribution.name
if (Utils.check_data_package(data)) { if (Utils.check_view_package(view)) {
hash = hash + '/' + data.package.name + "/" + data.package.version hash = hash + '/' + view.package.name + "/" + view.package.version
if (Utils.check_data_file(data)) if (Utils.check_view_file(view))
hash = hash + '/' + data.file.name hash = hash + '/' + view.file.name
} }
} }
return hash return hash
}, },
check_data_distribution: function(data) { check_view_distribution: function(view) {
return data && data.distribution && data.distribution.name return view && view.distribution && view.distribution.name
}, },
check_data_package: function(data) { check_view_package: function(view) {
return Utils.check_data_distribution(data) && data.package && data.package.name && data.package.version && data.package.orig_name return Utils.check_view_distribution(view) && view.package && view.package.name && view.package.version && view.package.orig_name
}, },
check_data_file: function(data) { check_view_file: function(view) {
return Utils.check_data_package(data) && data.file && data.file.name return Utils.check_view_package(view) && view.file && view.file.name
}, },
get_status_icon_and_class: function (status_data) { get_status_icon_and_class: function (status_data) {
......
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