Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
debomatic-webui
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
debomatic-webui-admins
debomatic-webui
Commits
c0c918ec
Commit
c0c918ec
authored
Jun 04, 2014
by
Leo Iannacone
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jslint client code
parent
08e14f2f
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
912 additions
and
926 deletions
+912
-926
debomatic-webui/public/javascripts/debug.js
debomatic-webui/public/javascripts/debug.js
+21
-20
debomatic-webui/public/javascripts/main.js
debomatic-webui/public/javascripts/main.js
+20
-19
debomatic-webui/public/javascripts/page_distribution.js
debomatic-webui/public/javascripts/page_distribution.js
+563
-577
debomatic-webui/public/javascripts/page_generic.js
debomatic-webui/public/javascripts/page_generic.js
+168
-171
debomatic-webui/public/javascripts/preferences.js
debomatic-webui/public/javascripts/preferences.js
+52
-50
debomatic-webui/public/javascripts/utils.js
debomatic-webui/public/javascripts/utils.js
+88
-89
No files found.
debomatic-webui/public/javascripts/debug.js
View file @
c0c918ec
"
use strict
"
;
/*
General information about debugging:
...
...
@@ -10,18 +11,18 @@
3 - socket emit data
4 - socket received data
*/
var
debug
=
function
()
{
if
(
arguments
.
length
<
2
)
{
return
}
var
level
=
arguments
[
0
]
arguments
[
0
]
=
"
debug [
"
+
level
+
"
]:
"
if
(
level
<=
config
.
preferences
.
debug
)
{
if
(
console
.
debug
)
console
.
debug
.
apply
(
console
,
arguments
)
else
console
.
log
.
apply
(
console
,
arguments
)
}
var
debug
=
function
()
{
if
(
arguments
.
length
<
2
)
{
return
;
}
var
level
=
arguments
[
0
];
arguments
[
0
]
=
"
debug [
"
+
level
+
"
]:
"
;
if
(
level
<=
config
.
preferences
.
debug
)
{
if
(
console
.
debug
)
console
.
debug
.
apply
(
console
,
arguments
);
else
console
.
log
.
apply
(
console
,
arguments
);
}
}
/*
...
...
@@ -30,11 +31,11 @@ var debug = function() {
usage: debug_socket("emit"|"received", event_name, data)
*/
var
debug_socket
=
function
()
{
if
(
arguments
.
length
!=
3
)
return
var
level
=
3
;
if
(
arguments
[
0
]
==
"
received
"
)
level
=
4
debug
(
level
,
"
socket
"
,
arguments
[
0
],
"
event:
"
,
arguments
[
1
],
"
data:
"
,
arguments
[
2
])
}
\ No newline at end of file
var
debug_socket
=
function
()
{
if
(
arguments
.
length
!=
3
)
return
;
var
level
=
3
;
if
(
arguments
[
0
]
==
"
received
"
)
level
=
4
;
debug
(
level
,
"
socket
"
,
arguments
[
0
],
"
event:
"
,
arguments
[
1
],
"
data:
"
,
arguments
[
2
]);
}
debomatic-webui/public/javascripts/main.js
View file @
c0c918ec
// main client javascript
'
use strict
'
;
var
preferences
=
new
Preferences
()
var
preferences
=
new
Preferences
()
;
var
page_generic
=
new
Page_Generic
()
var
page_generic
=
new
Page_Generic
()
;
if
(
window
.
location
.
pathname
==
config
.
paths
.
preferences
)
{
preferences
.
initPage
()
preferences
.
initPage
();
}
if
(
window
.
location
.
pathname
==
'
/
'
)
{
// convert email addresses in the right format
var
emails
=
$
(
"
.email
"
)
$
.
each
(
emails
,
function
()
{
var
subject
=
''
if
(
$
(
this
).
attr
(
'
subject
'
))
{
subject
=
'
?subject=
'
+
$
(
this
).
attr
(
'
subject
'
)
}
var
real_email
=
$
(
this
).
attr
(
'
address
'
).
replace
(
'
AT
'
,
'
@
'
).
replace
(
'
DOT
'
,
'
.
'
).
replace
(
/ /g
,
''
)
var
label
=
real_email
if
(
config
.
debomatic
.
admin
.
name
&&
config
.
debomatic
.
admin
.
name
!=
'
Your Name
'
)
label
=
config
.
debomatic
.
admin
.
name
real_email
=
'
<a href="mailto:
'
+
real_email
+
subject
+
'
">
'
+
label
+
'
</a>
'
$
(
this
).
html
(
real_email
)
})
// convert email addresses in the right format
var
emails
=
$
(
'
.email
'
);
$
.
each
(
emails
,
function
()
{
var
subject
=
''
;
if
(
$
(
this
).
attr
(
'
subject
'
))
{
subject
=
'
?subject=
'
+
$
(
this
).
attr
(
'
subject
'
);
}
var
real_email
=
$
(
this
).
attr
(
'
address
'
).
replace
(
'
AT
'
,
'
@
'
).
replace
(
'
DOT
'
,
'
.
'
).
replace
(
/ /g
,
''
);
var
label
=
real_email
;
if
(
config
.
debomatic
.
admin
.
name
&&
config
.
debomatic
.
admin
.
name
!=
'
Your Name
'
);
label
=
config
.
debomatic
.
admin
.
name
;
real_email
=
'
<a href="mailto:
'
+
real_email
+
subject
+
'
">
'
+
label
+
'
</a>
'
;
$
(
this
).
html
(
real_email
);
})
}
var
socket
=
io
.
connect
(
'
/
'
);
page_generic
.
start
(
socket
)
page_generic
.
start
(
socket
)
;
if
(
window
.
location
.
pathname
==
config
.
paths
.
distribution
)
{
new
Page_Distrubion
(
socket
).
start
()
new
Page_Distrubion
(
socket
).
start
();
}
debomatic-webui/public/javascripts/page_distribution.js
View file @
c0c918ec
'
use strict
'
;
// function to get all files in on click
// event comes from HTML
function
download_all
(
div_id
)
{
frame_id
=
'
downloadAllFrame
'
if
(
$
(
"
#
"
+
frame_id
).
length
>
0
)
frame
=
$
(
$
(
"
#
"
+
frame_id
)[
0
])
else
{
frame
=
$
(
'
<iframe></iframe>
'
)
frame
.
hide
()
frame
.
attr
(
'
id
'
,
frame_id
)
$
(
'
body
'
).
append
(
frame
)
}
files
=
$
(
div_id
).
find
(
'
ul li a
'
)
$
.
each
(
files
,
function
(
index
,
item
)
{
setTimeout
(
function
()
{
frame
.
attr
(
'
src
'
,
item
.
href
)
},
index
*
1000
)
})
function
download_all
(
div_id
)
{
var
frame_id
=
'
downloadAllFrame
'
;
var
frame
=
null
;
if
(
$
(
'
#
'
+
frame_id
).
length
>
0
)
frame
=
$
(
$
(
'
#
'
+
frame_id
)[
0
]);
else
{
frame
=
$
(
'
<iframe></iframe>
'
);
frame
.
hide
();
frame
.
attr
(
'
id
'
,
frame_id
);
$
(
'
body
'
).
append
(
frame
);
}
var
files
=
$
(
div_id
).
find
(
'
ul li a
'
);
$
.
each
(
files
,
function
(
index
,
item
)
{
setTimeout
(
function
()
{
frame
.
attr
(
'
src
'
,
item
.
href
);
},
index
*
1000
);
});
}
function
Page_Distrubion
(
socket
)
{
function
Page_Distrubion
(
socket
)
{
/*
...
...
@@ -60,570 +62,554 @@ function Page_Distrubion(socket)
*/
var
socket
=
socket
var
_e
=
config
.
events
.
client
var
view
=
Utils
.
from_hash_to_view
()
var
sidebarOffset
=
0
var
new_lines
=
[]
var
_e
=
config
.
events
.
client
;
var
view
=
Utils
.
from_hash_to_view
();
var
sidebarOffset
=
0
;
var
new_lines
=
[];
function
__check_hash_makes_sense
()
{
if
(
window
.
location
.
hash
.
indexOf
(
'
..
'
)
>=
0
)
{
error
.
set
(
"
Detected '..' God Is Watching You !
"
)
return
false
}
if
(
!
window
.
location
.
hash
)
{
welcome
.
show
()
return
false
}
var
info
=
window
.
location
.
hash
.
split
(
'
/
'
)
if
(
info
.
length
==
2
)
window
.
location
.
hash
=
info
[
0
]
return
true
}
var
title
=
{
set
:
function
(
label
)
{
if
(
label
)
{
$
(
'
#title
'
).
html
(
label
)
page_generic
.
set_window_title
(
label
)
return
}
var
label
=
''
var
window_title
=
null
if
(
Utils
.
check_view_file
(
view
))
{
var
complete_name
=
view
.
package
.
orig_name
+
'
.
'
+
view
.
file
.
name
window_title
=
complete_name
if
(
!
view
.
file
.
path
)
view
.
file
.
path
=
config
.
paths
.
debomatic
+
'
/
'
+
view
.
distribution
.
name
+
'
/pool/
'
+
view
.
package
.
orig_name
+
'
/
'
+
complete_name
label
=
complete_name
+
'
\
<a class="btn btn-link btn-lg" title="Download" href="
'
+
view
.
file
.
path
+
'
">
\
<span class="glyphicon glyphicon-download-alt"></span>
\
</a>
'
}
else
if
(
Utils
.
check_view_package
(
view
))
label
=
view
.
package
.
orig_name
else
if
(
Utils
.
check_view_distribution
(
view
))
label
=
view
.
distribution
.
name
$
(
'
#title
'
).
html
(
label
)
if
(
window_title
)
label
=
window_title
page_generic
.
set_window_title
(
label
)
},
clean
:
function
()
{
$
(
'
#title
'
).
html
(
''
)
page_generic
.
set_window_title
()
}
}
var
packages
=
{
set
:
function
(
socket_data
)
{
packages
.
clean
()
var
tmp
=
Utils
.
clone
(
socket_data
)
tmp
.
file
=
null
view
.
packages
=
{}
if
(
socket_data
.
distribution
.
packages
&&
socket_data
.
distribution
.
packages
.
length
>
0
)
{
socket_data
.
distribution
.
packages
.
forEach
(
function
(
p
){
tmp
.
package
=
p
// get datestamp if package is clicked
$
(
'
#packages ul
'
).
append
(
'
<li id="package-
'
+
p
.
orig_name
+
'
"><a href="
'
+
Utils
.
from_view_to_hash
(
tmp
)
+
'
/datestamp">
'
+
p
.
name
+
'
<span>
'
+
p
.
version
+
'
</span></a></li>
'
)
view
.
packages
[
p
.
orig_name
]
=
Utils
.
clone
(
p
)
})
packages
.
select
()
}
else
{
$
(
'
#packages ul
'
).
append
(
'
<li class="text-muted">No packages yet</li>
'
)
}
packages
.
show
()
sticky
.
updateOffset
()
},
clean
:
function
()
{
$
(
'
#packages ul
'
).
html
(
''
)
},
get
:
function
()
{
if
(
Utils
.
check_view_distribution
(
view
))
{
var
query_data
=
{}
query_data
.
distribution
=
view
.
distribution
debug_socket
(
"
emit
"
,
_e
.
distribution_packages
.
get
,
query_data
)
socket
.
emit
(
_e
.
distribution_packages
.
get
,
query_data
)
}
},
select
:
function
()
{
packages
.
unselect
()
if
(
Utils
.
check_view_package
(
view
))
{
$
(
"
#packages li[id='package-
"
+
view
.
package
.
orig_name
+
"
']
"
).
addClass
(
'
active
'
)
}
},
unselect
:
function
()
{
$
(
'
#packages li
'
).
removeClass
(
'
active
'
)
},
set_status
:
function
(
status_data
)
{
// set status in view
if
(
view
.
distribution
.
name
==
status_data
.
distribution
&&
view
.
packages
[
status_data
.
package
]
)
{
view
.
packages
[
status_data
.
package
].
status
=
status_data
.
status
if
(
status_data
.
hasOwnProperty
(
'
success
'
))
view
.
packages
[
status_data
.
package
].
success
=
status_data
.
success
else
delete
(
view
.
packages
[
status_data
.
package
].
success
)
}
// and in html
var
p_html
=
$
(
"
#packages li[id='package-
"
+
status_data
.
package
+
"
'] a
"
)
p_html
.
find
(
'
span.icon
'
).
remove
()
p_html
.
append
(
Utils
.
get_status_icon_html
(
status_data
))
if
(
Utils
.
check_view_package
(
view
)
&&
view
.
package
.
orig_name
==
status_data
.
package
&&
view
.
distribution
.
name
==
status_data
.
distribution
)
{
// in case user is watching this package, update also view.package
view
.
package
=
Utils
.
clone
(
view
.
packages
[
status_data
.
package
])
}
},
show
:
function
()
{
$
(
"
#packages
"
).
show
()
},
hide
:
function
()
{
$
(
"
#packages
"
).
hide
()
}
}
var
files
=
{
set
:
function
(
socket_data
)
{
files
.
clean
()
var
tmp
=
Utils
.
clone
(
socket_data
)
if
(
socket_data
.
package
.
files
&&
socket_data
.
package
.
files
.
length
>
0
)
{
// update view
view
.
package
.
files
=
Utils
.
clone
(
socket_data
.
package
.
files
)
// update html
socket_data
.
package
.
files
.
forEach
(
function
(
f
){
tmp
.
file
=
f
var
html_file
=
$
(
'
<li id="file-
'
+
f
.
orig_name
+
'
"><a title="
'
+
f
.
orig_name
+
'
" href="
'
+
Utils
.
from_view_to_hash
(
tmp
)
+
'
">
'
+
f
.
name
+
'
</a></li>
'
)
html_file
.
on
(
"
click
"
,
function
(){
files
.
select
(
this
)
})
$
(
'
#logs ul
'
).
append
(
html_file
)
})
$
(
'
#logs
'
).
show
()
files
.
select
()
}
if
(
socket_data
.
package
.
debs
&&
socket_data
.
package
.
debs
.
length
>
0
)
{
// update view
view
.
package
.
debs
=
Utils
.
clone
(
socket_data
.
package
.
debs
)
// update.html
socket_data
.
package
.
debs
.
forEach
(
function
(
f
){
$
(
'
#debs ul
'
).
append
(
'
<li><a title="
'
+
f
.
orig_name
+
'
" href="
'
+
f
.
path
+
'
">
'
+
f
.
name
+
'
</a> <span>.
'
+
f
.
extension
+
'
</span></li>
'
)
})
$
(
'
#debs
'
).
show
()
}
if
(
socket_data
.
package
.
sources
&&
socket_data
.
package
.
sources
.
length
>
0
)
{
// update view
view
.
package
.
sources
=
Utils
.
clone
(
socket_data
.
package
.
sources
)
// update html
socket_data
.
package
.
sources
.
forEach
(
function
(
f
){
$
(
'
#sources ul
'
).
append
(
'
<li><a title="
'
+
f
.
orig_name
+
'
" href="
'
+
f
.
path
+
'
">
'
+
f
.
name
+
'
</a></li>
'
)
})
$
(
'
#sources
'
).
show
()
}
files
.
show
()
sticky
.
updateOffset
()
},
clean
:
function
()
{
$
(
'
#logs ul
'
).
html
(
''
);
$
(
'
#logs
'
).
hide
()
$
(
'
#debs ul
'
).
html
(
''
);
$
(
'
#debs
'
).
hide
();
$
(
'
#sources ul
'
).
html
(
''
)
$
(
'
#sources
'
).
hide
()
files
.
hide
()
},
get
:
function
()
{
if
(
Utils
.
check_view_package
(
view
))
{
var
query_data
=
{}
query_data
.
distribution
=
view
.
distribution
query_data
.
package
=
view
.
package
debug_socket
(
"
emit
"
,
_e
.
package_files_list
.
get
,
query_data
)
socket
.
emit
(
_e
.
package_files_list
.
get
,
query_data
)
}
},
select
:
function
()
{
files
.
show
()
files
.
unselect
()
if
(
Utils
.
check_view_file
(
view
))
{
$
(
"
#logs li[id='file-
"
+
view
.
file
.
orig_name
+
"
']
"
).
addClass
(
'
active
'
)
}
},
unselect
:
function
()
{
$
(
'
#logs li
'
).
removeClass
(
'
active
'
);
},
hide
:
function
()
{
$
(
'
#files
'
).
hide
()
},
show
:
function
()
{
$
(
'
#files
'
).
show
()
},
}
var
file
=
{
set
:
function
(
socket_data
)
{
view
.
file
=
Utils
.
clone
(
socket_data
.
file
)
$
(
"
#file pre
"
).
html
(
socket_data
.
file
.
content
)
$
(
"
#file
"
).
show
()
},
clean
:
function
()
{
$
(
'
#file pre
'
).
html
(
''
)
$
(
'
#file
'
).
hide
()
},
append
:
function
(
new_content
)
{
var
content
=
$
(
"
#file pre
"
)
content
.
append
(
new_content
)
if
(
config
.
preferences
.
autoscroll
)
{
// scroll down if file is covering footer
var
file_height
=
$
(
"
#fileOffset
"
).
offset
().
top
var
footerOffset
=
$
(
"
footer
"
).
offset
().
top
if
(
file_height
>
footerOffset
)
{
debug
(
2
,
'
scoll down on new content
'
)
$
(
'
html,body
'
).
animate
({
scrollTop
:
file_height
},
0
);
function
__check_hash_makes_sense
()
{
if
(
window
.
location
.
hash
.
indexOf
(
'
..
'
)
>=
0
)
{
error
.
set
(
'
Detected ".." God Is Watching You !
'
);
return
false
;
}
}
},
get
:
function
()
{
if
(
Utils
.
check_view_file
(
view
))
{
var
query_data
=
{}
query_data
.
distribution
=
view
.
distribution
query_data
.
package
=
view
.
package
query_data
.
file
=
view
.
file
query_data
.
file
.
content
=
null
// get a feedback to user while downloading file
$
(
"
#file pre
"
).
html
(
"
Downloading file, please wait a while ...
"
)
$
(
"
#file
"
).
show
()
debug_socket
(
"
emit
"
,
_e
.
file
.
get
,
query_data
)
socket
.
emit
(
_e
.
file
.
get
,
query_data
)
}
}
}
var
breadcrumb
=
{
update
:
function
(
label
)
{
if
(
label
)
{
$
(
'
.breadcrumb
'
).
html
(
'
<li class="active">
'
+
label
+
'
</li>
'
)
return
}
hash
=
window
.
location
.
hash
.
replace
(
'
#
'
,
''
)
var
new_html
=
''
var
new_hash
=
'
#
'
var
info
=
hash
.
split
(
'
/
'
)
for
(
var
i
=
0
;
i
<
info
.
length
;
i
++
)
{
new_hash
+=
info
[
i
]
if
(
i
==
(
info
.
length
-
1
))
new_html
+=
'
<li class="active">
'
+
info
[
i
]
+
'
</li>
'
else
new_html
+=
'
<li><a href="
'
+
new_hash
+
'
">
'
+
info
[
i
]
+
'
</a>
'
new_hash
+=
'
/
'
}
$
(
'
.breadcrumb
'
).
html
(
new_html
)
}
}
// sticky sidebar
var
sticky
=
{
init
:
function
()
{
if
(
sidebarOffset
==
0
)
return
if
(
$
(
window
).
scrollTop
()
>
sidebarOffset
)
{
sticky
.
show
()
}
else
{
sticky
.
hide
()
sticky
.
updateOffset
()
}
},
start
:
function
()
{
$
(
window
).
scroll
(
sticky
.
init
)
},
stop
:
function
()
{
$
(
window
).
off
(
"
scroll
"
)
},
reset
:
function
()
{
sticky
.
stop
()
sticky
.
update
()
sticky
.
init
()
sticky
.
start
()
},
show
:
function
()
{
if
(
config
.
preferences
.
sidebar
)
{
$
(
"
#sticky
"
).
addClass
(
'
fixed
'
)
}
debug
(
2
,
"
showing sticky
"
)
$
(
"
#sticky-package
"
).
fadeIn
()
},
hide
:
function
()
{
$
(
"
#sticky
"
).
removeClass
(
'
fixed
'
)
$
(
"
#sticky-package
"
).
fadeOut
(
150
)
},
update
:
function
()
{
sticky
.
updateOffset
()
if
(
Utils
.
check_view_distribution
(
view
))
$
(
"
#sticky-package .distribution
"
).
html
(
view
.
distribution
.
name
)
if
(
Utils
.
check_view_package
(
view
))
{
$
(
"
#sticky-package .name
"
).
html
(
view
.
package
.
name
)
$
(
"
#sticky-package .version
"
).
html
(
view
.
package
.
version
)
sticky
.
set_status
()
}
},
updateOffset
:
function
()
{
var
sidebar
=
$
(
"
#files
"
)
sidebarOffset
=
sidebar
.
offset
().
top
},
set_status
:
function
(
status_data
)
{
if
(
!
status_data
)
{
status_data
=
{}
status_data
.
distribution
=
view
.
distribution
.
name
status_data
.
package
=
view
.
package
.
orig_name
status_data
.
status
=
view
.
package
.
status
if
(
view
.
package
.
hasOwnProperty
(
'
success
'
))
status_data
.
success
=
view
.
package
.
success
}
if
(
Utils
.
check_view_package
(
view
)
&&
status_data
.
distribution
==
view
.
distribution
.
name
&&
status_data
.
package
==
view
.
package
.
orig_name
)
{
// update html
var
info
=
Utils
.
get_status_icon_and_class
(
status_data
)
var
panel
=
$
(
"
#sticky-package-content
"
)
panel
.
removeClass
()
panel
.
addClass
(
'
panel panel-
'
+
info
.
className
)
var
div
=
$
(
"
#sticky-package .status
"
)
div
.
find
(
'
span.icon
'
).
remove
()
div
.
append
(
Utils
.
get_status_icon_html
(
status_data
))
}
if
(
!
window
.
location
.
hash
)
{
welcome
.
show
();
return
false
;
}
var
info
=
window
.
location
.
hash
.
split
(
'
/
'
);
if
(
info
.
length
==
2
)
window
.
location
.
hash
=
info
[
0
];
return
true
;
}
}
var
error
=
{
set
:
function
(
socket_error
)
{
$
(
"
#error span
"
).
html
(
socket_error
)
error
.
view
()
},
clean
:
function
()
{
$
(
"
#error
"
).
hide
()
$
(
"
#error span
"
).
html
(
''
)
},
view
:
function
()
{
$
(
"
#error
"
).
fadeIn
(
100
)
title
.
set
(
"
Something is wrong ...
"
)
breadcrumb
.
update
(
'
Something is wrong ...
'
)
file
.
clean
()
files
.
hide
()
unselect
()
},
}
var
welcome
=
{
set
:
function
(
distributions
)
{
welcome
.
clean
()
if
(
distributions
.
length
<
1
)
{
$
(
'
#welcome
'
).
append
(
'
<p class="lead text-muted">There is no distribution at the moment</p>
'
)
}
else
{
distributions
.
forEach
(
function
(
name
){
$
(
'
#welcome
'
).
append
(
'
<a class="btn btn-lg btn-primary" href="
'
+
config
.
paths
.
distribution
+
'
#
'
+
name
+
'
">
'
+
name
+
'
</a>
'
);
var
title
=
{
set
:
function
(
label
)
{
if
(
label
)
{
$
(
'
#title
'
).
html
(
label
);
page_generic
.
set_window_title
(
label
);
return
;
}
label
=
''
;
var
window_title
=
null
;
if
(
Utils
.
check_view_file
(
view
))
{
var
complete_name
=
view
.
package
.
orig_name
+
'
.
'
+
view
.
file
.
name
;
window_title
=
complete_name
;
if
(
!
view
.
file
.
path
);
view
.
file
.
path
=
config
.
paths
.
debomatic
+
'
/
'
+
view
.
distribution
.
name
+
'
/pool/
'
+
view
.
package
.
orig_name
+
'
/
'
+
complete_name
;
label
=
complete_name
+
'
<a class="btn btn-link btn-lg" title="Download" href="
'
+
view
.
file
.
path
+
'
">
'
+
'
<span class="glyphicon glyphicon-download-alt"></span></a>
'
;
}
else
if
(
Utils
.
check_view_package
(
view
))
label
=
view
.
package
.
orig_name
;
else
if
(
Utils
.
check_view_distribution
(
view
))
label
=
view
.
distribution
.
name
;
$
(
'
#title
'
).
html
(
label
);
if
(
window_title
)
label
=
window_title
;
page_generic
.
set_window_title
(
label
);
},
clean
:
function
()
{
$
(
'
#title
'
).
html
(
''
);
page_generic
.
set_window_title
();
}
};
var
packages
=
{
set
:
function
(
socket_data
)
{
packages
.
clean
();
var
tmp
=
Utils
.
clone
(
socket_data
);
tmp
.
file
=
null
;
view
.
packages
=
{};
if
(
socket_data
.
distribution
.
packages
&&
socket_data
.
distribution
.
packages
.
length
>
0
)
{
socket_data
.
distribution
.
packages
.
forEach
(
function
(
p
)
{
tmp
.
package
=
p
;
// get datestamp if package is clicked
$
(
'
#packages ul
'
).
append
(
'
<li id="package-
'
+
p
.
orig_name
+
'
"><a href="
'
+
Utils
.
from_view_to_hash
(
tmp
)
+
'
/datestamp">
'
+
p
.
name
+
'
<span>
'
+
p
.
version
+
'
</span></a></li>
'
);
view
.
packages
[
p
.
orig_name
]
=
Utils
.
clone
(
p
);
});
packages
.
select
();
}
else
{
$
(
'
#packages ul
'
).
append
(
'
<li class="text-muted">No packages yet</li>
'
);
}
packages
.
show
();
sticky
.
updateOffset
();
},
clean
:
function
()
{
$
(
'
#packages ul
'
).
html
(
''
);
},
get
:
function
()
{
if
(
Utils
.
check_view_distribution
(
view
))
{
var
query_data
=
{};
query_data
.
distribution
=
view
.
distribution
;
debug_socket
(
'
emit
'
,
_e
.
distribution_packages
.
get
,
query_data
);
socket
.
emit
(
_e
.
distribution_packages
.
get
,
query_data
);
}
},
select
:
function
()
{
packages
.
unselect
();
if
(
Utils
.
check_view_package
(
view
))
{
$
(
'
#packages li[id="package-
'
+
view
.
package
.
orig_name
+
'
"]
'
).
addClass
(
'
active
'
);
}
},
unselect
:
function
()
{
$
(
'
#packages li
'
).
removeClass
(
'
active
'
);
},
set_status
:
function
(
status_data
)
{
// set status in view
if
(
view
.
distribution
.
name
==
status_data
.
distribution
&&
view
.
packages
[
status_data
.
package
])
{
view
.
packages
[
status_data
.
package
].
status
=
status_data
.
status
;
if
(
status_data
.
hasOwnProperty
(
'
success
'
))
view
.
packages
[
status_data
.
package
].
success
=
status_data
.
success
;
else
delete
(
view
.
packages
[
status_data
.
package
].
success
);
}
// and in html
var
p_html
=
$
(
'
#packages li[id="package-
'
+
status_data
.
package
+
'
"] a
'
);
p_html
.
find
(
'
span.icon
'
).
remove
();
p_html
.
append
(
Utils
.
get_status_icon_html
(
status_data
));
if
(
Utils
.
check_view_package
(
view
)
&&
view
.
package
.
orig_name
==
status_data
.
package
&&
view
.
distribution
.
name
==
status_data
.
distribution
)
{
// in case user is watching this package, update also view.package
view
.
package
=
Utils
.
clone
(
view
.
packages
[
status_data
.
package
]);
}
},
show
:
function
()
{
$
(
'
#packages
'
).
show
();
},
hide
:
function
()
{
$
(
'
#packages
'
).
hide
();
}
};
var
files
=
{
set
:
function
(
socket_data
)
{
files
.
clean
();
var
tmp
=
Utils
.
clone
(
socket_data
);
if
(
socket_data
.
package
.
files
&&
socket_data
.
package
.
files
.
length
>
0
)
{
// update view
view
.
package
.
files
=
Utils
.
clone
(
socket_data
.
package
.
files
);
// update html
socket_data
.
package
.
files
.
forEach
(
function
(
f
)
{
tmp
.
file
=
f
;
var
html_file
=
$
(
'
<li id="file-
'
+
f
.
orig_name
+
'
"><a title="
'
+
f
.
orig_name
+
'
" href="
'
+
Utils
.
from_view_to_hash
(
tmp
)
+
'
">
'
+
f
.
name
+
'
</a></li>
'
);
html_file
.
on
(
'
click
'
,
function
()
{
files
.
select
(
this
);
});
$
(
'
#logs ul
'
).
append
(
html_file
);
});
$
(
'
#logs
'
).
show
();
files
.
select
();
}
if
(
socket_data
.
package
.
debs
&&
socket_data
.
package
.
debs
.
length
>
0
)
{
// update view
view
.
package
.
debs
=
Utils
.
clone
(
socket_data
.
package
.
debs
);
// update.html
socket_data
.
package
.
debs
.
forEach
(
function
(
f
)
{
$
(
'
#debs ul
'
).
append
(
'
<li><a title="
'
+
f
.
orig_name
+
'
" href="
'
+
f
.
path
+
'
">
'
+
f
.
name
+
'
</a> <span>.
'
+
f
.
extension
+
'
</span></li>
'
);
});
$
(
'
#debs
'
).
show
();
}
if
(
socket_data
.
package
.
sources
&&
socket_data
.
package
.
sources
.
length
>
0
)
{
// update view
view
.
package
.
sources
=
Utils
.
clone
(
socket_data
.
package
.
sources
);
// update html
socket_data
.
package
.
sources
.
forEach
(
function
(
f
)
{
$
(
'
#sources ul
'
).
append
(
'
<li><a title="
'
+
f
.
orig_name
+
'
" href="
'
+
f
.
path
+
'
">
'
+
f
.
name
+
'
</a></li>
'
);
})
$
(
'
#sources
'
).
show
();
}
files
.
show
();
sticky
.
updateOffset
();
},
clean
:
function
()
{
$
(
'
#logs ul
'
).
html
(
''
);
$
(
'
#logs
'
).
hide
();
$
(
'
#debs ul
'
).
html
(
''
);
$
(
'
#debs
'
).
hide
();
$
(
'
#sources ul
'
).
html
(
''
);
$
(
'
#sources
'
).
hide
();
files
.
hide
();
},
get
:
function
()
{
if
(
Utils
.
check_view_package
(
view
))
{
var
query_data
=
{};
query_data
.
distribution
=
view
.
distribution
;
query_data
.
package
=
view
.
package
;
debug_socket
(
'
emit
'
,
_e
.
package_files_list
.
get
,
query_data
);
socket
.
emit
(
_e
.
package_files_list
.
get
,
query_data
);
}
},
select
:
function
()
{
files
.
show
();
files
.
unselect
();
if
(
Utils
.
check_view_file
(
view
))
{
$
(
'
#logs li[id="file-
'
+
view
.
file
.
orig_name
+
'
"]
'
).
addClass
(
'
active
'
);
}
},
unselect
:
function
()
{
$
(
'
#logs li
'
).
removeClass
(
'
active
'
);
},
hide
:
function
()
{
$
(
'
#files
'
).
hide
();
},
show
:
function
()
{
$
(
'
#files
'
).
show
();
},
};
var
file
=
{
set
:
function
(
socket_data
)
{
view
.
file
=
Utils
.
clone
(
socket_data
.
file
);
$
(
'
#file pre
'
).
html
(
socket_data
.
file
.
content
);
$
(
'
#file
'
).
show
();
},
clean
:
function
()
{
$
(
'
#file pre
'
).
html
(
''
);
$
(
'
#file
'
).
hide
();
},
append
:
function
(
new_content
)
{
var
content
=
$
(
'
#file pre
'
);
content
.
append
(
new_content
);
if
(
config
.
preferences
.
autoscroll
)
{
// scroll down if file is covering footer
var
file_height
=
$
(
'
#fileOffset
'
).
offset
().
top
;
var
footerOffset
=
$
(
'
footer
'
).
offset
().
top
;
if
(
file_height
>
footerOffset
)
{
debug
(
2
,
'
scoll down on new content
'
);
$
(
'
html,body
'
).
animate
({
scrollTop
:
file_height
},
0
);
}
}
},
get
:
function
()
{
if
(
Utils
.
check_view_file
(
view
))
{
var
query_data
=
{};
query_data
.
distribution
=
view
.
distribution
;
query_data
.
package
=
view
.
package
;
query_data
.
file
=
view
.
file
;
query_data
.
file
.
content
=
null
;
// get a feedback to user while downloading file
$
(
'
#file pre
'
).
html
(
'
Downloading file, please wait a while ...
'
);
$
(
'
#file
'
).
show
();
debug_socket
(
'
emit
'
,
_e
.
file
.
get
,
query_data
);
socket
.
emit
(
_e
.
file
.
get
,
query_data
);
}
}
};
var
breadcrumb
=
{
update
:
function
(
label
)
{
if
(
label
)
{
$
(
'
.breadcrumb
'
).
html
(
'
<li class="active">
'
+
label
+
'
</li>
'
);
return
;
}
var
hash
=
window
.
location
.
hash
.
replace
(
'
#
'
,
''
);
var
new_html
=
''
;
var
new_hash
=
'
#
'
;
var
info
=
hash
.
split
(
'
/
'
);
for
(
var
i
=
0
;
i
<
info
.
length
;
i
++
)
{
new_hash
+=
info
[
i
];
if
(
i
==
(
info
.
length
-
1
))
new_html
+=
'
<li class="active">
'
+
info
[
i
]
+
'
</li>
'
;
else
new_html
+=
'
<li><a href="
'
+
new_hash
+
'
">
'
+
info
[
i
]
+
'
</a>
'
;
new_hash
+=
'
/
'
;
}
$
(
'
.breadcrumb
'
).
html
(
new_html
);
}
};
// sticky sidebar
var
sticky
=
{
init
:
function
()
{
if
(
sidebarOffset
===
0
)
return
;
if
(
$
(
window
).
scrollTop
()
>
sidebarOffset
)
{
sticky
.
show
();
}
else
{
sticky
.
hide
();
sticky
.
updateOffset
();
}
},
start
:
function
()
{
$
(
window
).
scroll
(
sticky
.
init
);
},
stop
:
function
()
{
$
(
window
).
off
(
'
scroll
'
);
},
reset
:
function
()
{
sticky
.
stop
();
sticky
.
update
();
sticky
.
init
();
sticky
.
start
();
},
show
:
function
()
{
if
(
config
.
preferences
.
sidebar
)
{
$
(
'
#sticky
'
).
addClass
(
'
fixed
'
);
}
debug
(
2
,
'
showing sticky
'
);
$
(
'
#sticky-package
'
).
fadeIn
();
},
hide
:
function
()
{
$
(
'
#sticky
'
).
removeClass
(
'
fixed
'
);
$
(
'
#sticky-package
'
).
fadeOut
(
150
);
},
update
:
function
()
{
sticky
.
updateOffset
();
if
(
Utils
.
check_view_distribution
(
view
))
$
(
'
#sticky-package .distribution
'
).
html
(
view
.
distribution
.
name
);
if
(
Utils
.
check_view_package
(
view
))
{
$
(
'
#sticky-package .name
'
).
html
(
view
.
package
.
name
);
$
(
'
#sticky-package .version
'
).
html
(
view
.
package
.
version
);
sticky
.
set_status
();
}
},
updateOffset
:
function
()
{
var
sidebar
=
$
(
'
#files
'
);
sidebarOffset
=
sidebar
.
offset
().
top
;
},
set_status
:
function
(
status_data
)
{
if
(
!
status_data
)
{
status_data
=
{};
status_data
.
distribution
=
view
.
distribution
.
name
;
status_data
.
package
=
view
.
package
.
orig_name
;
status_data
.
status
=
view
.
package
.
status
;
if
(
view
.
package
.
hasOwnProperty
(
'
success
'
))
status_data
.
success
=
view
.
package
.
success
;
}
if
(
Utils
.
check_view_package
(
view
)
&&
status_data
.
distribution
==
view
.
distribution
.
name
&&
status_data
.
package
==
view
.
package
.
orig_name
)
{
// update html
var
info
=
Utils
.
get_status_icon_and_class
(
status_data
);
var
panel
=
$
(
'
#sticky-package-content
'
);
panel
.
removeClass
();
panel
.
addClass
(
'
panel panel-
'
+
info
.
className
);
var
div
=
$
(
'
#sticky-package .status
'
);
div
.
find
(
'
span.icon
'
).
remove
();
div
.
append
(
Utils
.
get_status_icon_html
(
status_data
));
}
}
};
var
error
=
{
set
:
function
(
socket_error
)
{
$
(
'
#error span
'
).
html
(
socket_error
);
error
.
view
();
},
clean
:
function
()
{
$
(
'
#error
'
).
hide
();
$
(
'
#error span
'
).
html
(
''
);
},
view
:
function
()
{
$
(
'
#error
'
).
fadeIn
(
100
);
title
.
set
(
'
Something is wrong ...
'
);
breadcrumb
.
update
(
'
Something is wrong ...
'
);
file
.
clean
();
files
.
hide
();
unselect
();
},
};
var
welcome
=
{
set
:
function
(
distributions
)
{
welcome
.
clean
();
if
(
distributions
.
length
<
1
)
{
$
(
'
#welcome
'
).
append
(
'
<p class="lead text-muted">There is no distribution at the moment</p>
'
);
}
else
{
distributions
.
forEach
(
function
(
name
)
{
$
(
'
#welcome
'
).
append
(
'
<a class="btn btn-lg btn-primary" href="
'
+
config
.
paths
.
distribution
+
'
#
'
+
name
+
'
">
'
+
name
+
'
</a>
'
);
});
}
},
show
:
function
()
{
title
.
set
(
'
Please select a distribution
'
);
breadcrumb
.
update
(
'
Select a distribution
'
);
packages
.
hide
();
file
.
clean
();
files
.
hide
();
unselect
();
$
(
'
#welcome
'
).
show
();
},
clean
:
function
()
{
$
(
'
#welcome
'
).
html
(
''
);
},
hide
:
function
()
{
$
(
'
#welcome
'
).
hide
();
}
};
var
preferences
=
function
()
{
if
(
!
config
.
preferences
.
sidebar
)
{
debug
(
2
,
'
no sidebar - updating html
'
);
$
(
'
#sidebar
'
).
removeClass
();
$
(
'
#sidebar
'
).
addClass
(
'
col-md-12 row
'
);
$
(
'
#packages
'
).
addClass
(
'
col-md-4
'
);
$
(
'
#logs
'
).
addClass
(
'
col-md-4
'
);
$
(
'
#files .others
'
).
addClass
(
'
col-md-4
'
);
$
(
'
#main
'
).
removeClass
().
addClass
(
'
col-md-12
'
);
$
(
'
#sticky-package
'
).
addClass
(
'
on-top
'
);
}
if
(
!
config
.
preferences
.
file_background
)
{
$
(
'
#file pre
'
).
addClass
(
'
no-background
'
);
}
$
(
'
#file pre
'
).
css
(
'
font-size
'
,
config
.
preferences
.
file_fontsize
);
};
var
select
=
function
()
{
unselect
();
if
(
Utils
.
check_view_distribution
(
view
))
{
$
(
'
#distributions li[id="distribution-
'
+
view
.
distribution
.
name
+
'
"]
'
).
addClass
(
'
active
'
);
}
packages
.
select
();
files
.
select
();
};
var
unselect
=
function
()
{
$
(
'
#distributions li
'
).
removeClass
(
'
active
'
);
files
.
unselect
();
packages
.
unselect
();
};
var
clean
=
function
()
{
welcome
.
hide
();
title
.
clean
();
packages
.
clean
();
files
.
clean
();
file
.
clean
();
unselect
();
breadcrumb
.
update
();
error
.
clean
();
};
var
update
=
{
page
:
function
(
old_view
)
{
if
(
!
old_view
||
!
Utils
.
check_view_distribution
(
old_view
)
||
!
Utils
.
check_view_distribution
(
view
)
||
view
.
distribution
.
name
!=
old_view
.
distribution
.
name
||
!
view
.
package
.
orig_name
)
{
// new distribution view
populate
();
return
;
}
else
if
(
!
Utils
.
check_view_package
(
old_view
)
||
!
Utils
.
check_view_package
(
view
)
||
view
.
package
.
orig_name
!=
old_view
.
package
.
orig_name
)
{
// new package view
files
.
get
();
file
.
get
();
}
else
if
(
!
Utils
.
check_view_file
(
old_view
)
||
!
Utils
.
check_view_file
(
view
)
||
view
.
file
.
name
!=
old_view
.
file
.
name
)
{
// new file view
file
.
get
();
}
update
.
view
(
view
);
},
view
:
function
()
{
error
.
clean
();
title
.
set
();
breadcrumb
.
update
();
select
();
sticky
.
reset
();
}
};
var
populate
=
function
()
{
clean
();
packages
.
get
();
files
.
get
();
file
.
get
();
update
.
view
();
};
this
.
start
=
function
()
{
socket
.
on
(
config
.
events
.
error
,
function
(
socket_error
)
{
debug_socket
(
'
received
'
,
config
.
events
.
error
,
socket_error
);
error
.
set
(
socket_error
);
});
}
},
show
:
function
()
{
title
.
set
(
"
Please select a distribution
"
)
breadcrumb
.
update
(
"
Select a distribution
"
)
packages
.
hide
()
file
.
clean
()
files
.
hide
()
unselect
()
$
(
"
#welcome
"
).
show
()
},
clean
:
function
()
{
$
(
"
#welcome
"
).
html
(
''
)
},
hide
:
function
()
{
$
(
"
#welcome
"
).
hide
()
}
}
var
preferences
=
function
()
{
if
(
!
config
.
preferences
.
sidebar
)
{
debug
(
2
,
"
no sidebar - updating html
"
)
$
(
"
#sidebar
"
).
removeClass
()
$
(
"
#sidebar
"
).
addClass
(
"
col-md-12 row
"
)
$
(
"
#packages
"
).
addClass
(
"
col-md-4
"
)
$
(
"
#logs
"
).
addClass
(
"
col-md-4
"
)
$
(
"
#files .others
"
).
addClass
(
"
col-md-4
"
)
$
(
"
#main
"
).
removeClass
().
addClass
(
"
col-md-12
"
)
$
(
"
#sticky-package
"
).
addClass
(
"
on-top
"
)
}
if
(
!
config
.
preferences
.
file_background
)
{
$
(
"
#file pre
"
).
addClass
(
"
no-background
"
)
}
$
(
"
#file pre
"
).
css
(
'
font-size
'
,
config
.
preferences
.
file_fontsize
)
}
var
select
=
function
()
{
unselect
()
if
(
Utils
.
check_view_distribution
(
view
))
{
$
(
"
#distributions li[id='distribution-
"
+
view
.
distribution
.
name
+
"
']
"
).
addClass
(
'
active
'
)
}
packages
.
select
()
files
.
select
()
}
var
unselect
=
function
()
{
$
(
'
#distributions li
'
).
removeClass
(
'
active
'
)
files
.
unselect
()
packages
.
unselect
()
}
var
clean
=
function
()
{
welcome
.
hide
()
title
.
clean
()
packages
.
clean
()
files
.
clean
()
file
.
clean
()
unselect
()
breadcrumb
.
update
()
error
.
clean
()
}
var
update
=
{
page
:
function
(
old_view
)
{
if
(
!
old_view
||
!
Utils
.
check_view_distribution
(
old_view
)
||
!
Utils
.
check_view_distribution
(
view
)
||
view
.
distribution
.
name
!=
old_view
.
distribution
.
name
||
!
view
.
package
.
orig_name
)
{
// new distribution view
populate
()
return
}
else
if
(
!
Utils
.
check_view_package
(
old_view
)
||
!
Utils
.
check_view_package
(
view
)
||
view
.
package
.
orig_name
!=
old_view
.
package
.
orig_name
)
{
// new package view
files
.
get
()
file
.
get
()
}
else
if
(
!
Utils
.
check_view_file
(
old_view
)
||
!
Utils
.
check_view_file
(
view
)
||
view
.
file
.
name
!=
old_view
.
file
.
name
)
{
// new file view
file
.
get
()
}
update
.
view
(
view
)
},
view
:
function
()
{
error
.
clean
()
title
.
set
()
breadcrumb
.
update
()
select
()
sticky
.
reset
()
}
}
var
populate
=
function
()
{
clean
()
packages
.
get
()
files
.
get
()
file
.
get
()
update
.
view
()
}
this
.
start
=
function
()
{
socket
.
on
(
config
.
events
.
error
,
function
(
socket_error
)
{
debug_socket
(
"
received
"
,
config
.
events
.
error
,
socket_error
)
error
.
set
(
socket_error
)
})
socket
.
on
(
config
.
events
.
broadcast
.
distributions
,
function
(
socket_data
)
{
debug_socket
(
"
received
"
,
config
.
events
.
broadcast
.
distributions
,
socket_data
)
welcome
.
set
(
socket_data
)
})
socket
.
on
(
_e
.
distribution_packages
.
set
,
function
(
socket_data
){
debug_socket
(
"
received
"
,
_e
.
distribution_packages
.
set
,
socket_data
)
packages
.
set
(
socket_data
)
})
socket
.
on
(
_e
.
distribution_packages
.
status
,
function
(
socket_data
){
debug_socket
(
"
received
"
,
_e
.
distribution_packages
.
set
,
socket_data
)
packages
.
set_status
(
socket_data
)
sticky
.
set_status
(
socket_data
)
})
socket
.
on
(
config
.
events
.
broadcast
.
status_update
,
function
(
socket_data
){
packages
.
set_status
(
socket_data
)
sticky
.
set_status
(
socket_data
)
})
socket
.
on
(
_e
.
package_files_list
.
set
,
function
(
socket_data
){
debug_socket
(
"
received
"
,
_e
.
package_files_list
.
set
,
socket_data
)
files
.
set
(
socket_data
)
})
socket
.
on
(
_e
.
file
.
set
,
function
(
socket_data
)
{
debug_socket
(
"
received
"
,
_e
.
file
.
set
,
socket_data
)
file
.
set
(
socket_data
)
})
socket
.
on
(
_e
.
file_newcontent
,
function
(
socket_data
)
{
debug_socket
(
"
received
"
,
_e
.
file_newcontent
,
socket_data
)
new_lines
.
push
(
socket_data
.
file
.
new_content
)
})
$
(
window
).
on
(
'
hashchange
'
,
function
()
{
if
(
!
__check_hash_makes_sense
())
return
var
old_view
=
Utils
.
clone
(
view
)
var
new_view
=
Utils
.
from_hash_to_view
()
// reset current view
view
.
distribution
=
Utils
.
clone
(
new_view
.
distribution
)
view
.
package
=
Utils
.
clone
(
new_view
.
package
)
if
(
view
.
packages
[
new_view
.
package
.
orig_name
])
view
.
package
=
Utils
.
clone
(
view
.
packages
[
new_view
.
package
.
orig_name
])
view
.
file
=
Utils
.
clone
(
new_view
.
file
)
update
.
page
(
old_view
)
$
(
'
html,body
'
).
animate
({
scrollTop
:
0
},
0
);
debug
(
1
,
"
changing view
"
,
"
old:
"
,
old_view
,
"
new:
"
,
view
)
});
if
(
!
__check_hash_makes_sense
())
return
populate
()
// Init sticky-package back_on_top on click
$
(
"
#sticky-package
"
).
on
(
"
click
"
,
function
(){
$
(
'
html,body
'
).
animate
({
scrollTop
:
0
},
100
);
})
// WORKAROUND:
// when page is loaded sidebar has offset().top
// equals 0. This is because html is loaded on socket
// events. Sleep a while and call stiky.reset()
setTimeout
(
sticky
.
reset
,
500
);
// WORKAROUND:
// On incoming hundred of lines browser goes crazy.
// Append lines every 200 mills.
function
watch_for_new_lines
()
{
if
(
new_lines
.
length
>
0
)
{
file
.
append
(
new_lines
.
join
(
''
))
new_lines
=
[]
}
setTimeout
(
watch_for_new_lines
,
200
);
}
watch_for_new_lines
()
socket
.
on
(
config
.
events
.
broadcast
.
distributions
,
function
(
socket_data
)
{
debug_socket
(
'
received
'
,
config
.
events
.
broadcast
.
distributions
,
socket_data
);
welcome
.
set
(
socket_data
);
});
socket
.
on
(
_e
.
distribution_packages
.
set
,
function
(
socket_data
)
{
debug_socket
(
'
received
'
,
_e
.
distribution_packages
.
set
,
socket_data
);
packages
.
set
(
socket_data
);
});
socket
.
on
(
_e
.
distribution_packages
.
status
,
function
(
socket_data
)
{
debug_socket
(
'
received
'
,
_e
.
distribution_packages
.
set
,
socket_data
);
packages
.
set_status
(
socket_data
);
sticky
.
set_status
(
socket_data
);
});
socket
.
on
(
config
.
events
.
broadcast
.
status_update
,
function
(
socket_data
)
{
packages
.
set_status
(
socket_data
);
sticky
.
set_status
(
socket_data
);
});
socket
.
on
(
_e
.
package_files_list
.
set
,
function
(
socket_data
)
{
debug_socket
(
'
received
'
,
_e
.
package_files_list
.
set
,
socket_data
);
files
.
set
(
socket_data
);
});
socket
.
on
(
_e
.
file
.
set
,
function
(
socket_data
)
{
debug_socket
(
'
received
'
,
_e
.
file
.
set
,
socket_data
);
file
.
set
(
socket_data
);
});
socket
.
on
(
_e
.
file_newcontent
,
function
(
socket_data
)
{
debug_socket
(
'
received
'
,
_e
.
file_newcontent
,
socket_data
);
new_lines
.
push
(
socket_data
.
file
.
new_content
);
});
$
(
window
).
on
(
'
hashchange
'
,
function
()
{
if
(
!
__check_hash_makes_sense
())
return
;
var
old_view
=
Utils
.
clone
(
view
);
var
new_view
=
Utils
.
from_hash_to_view
();
// reset current view
view
.
distribution
=
Utils
.
clone
(
new_view
.
distribution
);
view
.
package
=
Utils
.
clone
(
new_view
.
package
);
if
(
view
.
packages
[
new_view
.
package
.
orig_name
])
view
.
package
=
Utils
.
clone
(
view
.
packages
[
new_view
.
package
.
orig_name
]);
view
.
file
=
Utils
.
clone
(
new_view
.
file
);
update
.
page
(
old_view
);
$
(
'
html,body
'
).
animate
({
scrollTop
:
0
},
0
);
debug
(
1
,
'
changing view
'
,
'
old:
'
,
old_view
,
'
new:
'
,
view
);
});
if
(
!
__check_hash_makes_sense
())
return
;
populate
();
// Init sticky-package back_on_top on click
$
(
'
#sticky-package
'
).
on
(
'
click
'
,
function
()
{
$
(
'
html,body
'
).
animate
({
scrollTop
:
0
},
100
);
});
// WORKAROUND:
// when page is loaded sidebar has offset().top
// equals 0. This is because html is loaded on socket
// events. Sleep a while and call stiky.reset()
setTimeout
(
sticky
.
reset
,
500
);
// WORKAROUND:
// On incoming hundred of lines browser goes crazy.
// Append lines every 200 mills.
function
watch_for_new_lines
()
{
if
(
new_lines
.
length
>
0
)
{
file
.
append
(
new_lines
.
join
(
''
));
new_lines
=
[];
}
setTimeout
(
watch_for_new_lines
,
200
);
}
watch_for_new_lines
();
// Update html according with preferences
preferences
()
// Update html according with preferences
preferences
();
}
};
}
debomatic-webui/public/javascripts/page_generic.js
View file @
c0c918ec
function
Page_Generic
()
{
var
_e
=
config
.
events
function
__get_status_html_id
(
status_data
)
{
var
result
=
'
status-
'
+
status_data
.
status
+
'
-
'
+
status_data
.
distribution
if
(
status_data
.
hasOwnProperty
(
'
package
'
))
result
+=
'
-
'
+
status_data
.
package
return
result
}
function
__get_status_html_href
(
status_data
)
{
result
=
config
.
paths
.
distribution
+
'
#
'
+
status_data
.
distribution
if
(
status_data
.
hasOwnProperty
(
'
package
'
))
result
+=
'
/
'
+
status_data
.
package
.
replace
(
'
_
'
,
'
/
'
)
+
'
/datestamp
'
return
result
}
function
__get_status_html_title
(
status_data
)
{
result
=
status_data
.
status
+
'
:
'
+
status_data
.
distribution
if
(
status_data
.
hasOwnProperty
(
'
package
'
))
result
+=
'
>
'
+
status_data
.
package
if
(
status_data
.
hasOwnProperty
(
'
uploader
'
)
&&
status_data
.
uploader
.
length
>
0
)
result
+=
'
by
'
+
status_data
.
uploader
return
result
}
function
__get_status_html_inner
(
status_data
)
{
if
(
status_data
.
hasOwnProperty
(
'
package
'
))
return
status_data
.
package
;
return
status_data
.
distribution
}
function
__get_status_html
(
status_data
)
{
var
_s
=
status_data
var
li
=
$
(
'
<li></li>
'
)
li
.
attr
(
'
id
'
,
__get_status_html_id
(
status_data
))
var
button
=
$
(
'
<a></a>
'
)
button
.
addClass
(
'
btn btn-xs
'
)
button
.
addClass
(
_s
.
status
)
button
.
attr
(
'
title
'
,
__get_status_html_title
(
_s
))
button
.
attr
(
'
href
'
,
__get_status_html_href
(
_s
))
button
.
html
(
__get_status_html_inner
(
_s
))
var
info
=
Utils
.
get_status_icon_and_class
(
_s
)
button
.
addClass
(
'
btn-
'
+
info
.
className
)
// add icon
button
.
html
(
button
.
html
()
+
'
'
+
Utils
.
get_status_icon_html
(
_s
))
li
.
html
(
button
)
var
result
=
$
(
'
<div></div>
'
)
result
.
html
(
li
)
return
result
.
html
()
}
var
distributions
=
{
set
:
function
(
distributions
)
{
$
(
'
#distributions ul
'
).
html
(
''
);
if
(
distributions
.
length
<
1
)
{
$
(
'
#distributions ul
'
).
append
(
'
<li><a title="There is no distribution at the moment" onclick="return false">None</li>
'
)
}
else
{
distributions
.
forEach
(
function
(
name
){
$
(
'
#distributions ul
'
).
append
(
'
<li id="distribution-
'
+
name
+
'
"><a href="
'
+
config
.
paths
.
distribution
+
'
#
'
+
name
+
'
">
'
+
name
+
'
</a></li>
'
);
});
if
(
window
.
location
.
pathname
==
config
.
paths
.
distribution
)
{
var
data
=
Utils
.
from_hash_to_view
()
if
(
Utils
.
check_view_distribution
(
data
))
{
$
(
"
#distributions li[id='distribution-
"
+
data
.
distribution
.
name
+
"
']
"
).
addClass
(
'
active
'
)
}
}
}
},
}
var
status
=
{
set
:
function
(
data_status
)
{
$
(
"
#status ul
"
).
html
(
''
)
if
(
data_status
.
length
>
0
)
{
data_status
.
forEach
(
function
(
s
){
status
.
append
(
s
)
})
}
},
append
:
function
(
status_data
)
{
$
(
'
#status .idle
'
).
hide
()
$
(
"
#status ul
"
).
append
(
__get_status_html
(
status_data
))
},
update
:
function
(
status_data
)
{
var
li
=
$
(
"
#status li[id='
"
+
__get_status_html_id
(
status_data
)
+
"
']
"
)
if
(
li
.
length
>
0
&&
status_data
.
hasOwnProperty
(
'
success
'
))
{
// Update color and icon
li
=
$
(
li
[
0
])
li
.
html
(
$
(
__get_status_html
(
status_data
)).
children
())
li
.
attr
(
'
id
'
,
''
)
// This is a chain to have a fadeOut and correctly
// delete status li from list.
// The first timemout fades out the status element.
setTimeout
(
function
()
{
li
.
children
().
fadeOut
(
config
.
status
.
delay
.
fadeOut
)
// Then resize list.
setTimeout
(
function
()
{
li
.
animate
({
width
:
'
toggle
'
})
},
config
.
status
.
delay
.
fadeOut
)
// Finally remove status html
// and show idle label if necessary.
setTimeout
(
function
()
{
li
.
remove
()
if
(
$
(
'
#status li
'
).
length
==
0
)
$
(
'
#status .idle
'
).
show
()
},
config
.
status
.
delay
.
remove
+
2000
)
// more delay on remove html
},
config
.
status
.
delay
.
remove
)
}
else
if
(
!
status_data
.
hasOwnProperty
(
'
success
'
))
{
status
.
append
(
status_data
)
}
},
}
this
.
preferences
=
function
()
{
if
(
config
.
preferences
.
header
)
{
$
(
"
#pageheader
"
).
show
()
$
(
"
.navbar .home-link
"
).
hide
()
'
use strict
'
;
function
Page_Generic
()
{
var
_e
=
config
.
events
;
function
__get_status_html_id
(
status_data
)
{
var
result
=
'
status-
'
+
status_data
.
status
+
'
-
'
+
status_data
.
distribution
;
if
(
status_data
.
hasOwnProperty
(
'
package
'
))
result
+=
'
-
'
+
status_data
.
package
;
return
result
;
}
function
__get_status_html_href
(
status_data
)
{
result
=
config
.
paths
.
distribution
+
'
#
'
+
status_data
.
distribution
;
if
(
status_data
.
hasOwnProperty
(
'
package
'
))
result
+=
'
/
'
+
status_data
.
package
.
replace
(
'
_
'
,
'
/
'
)
+
'
/datestamp
'
;
return
result
;
}
else
{
$
(
"
#pageheader
"
).
hide
()
$
(
"
.navbar .home-link
"
).
show
()
function
__get_status_html_title
(
status_data
)
{
result
=
status_data
.
status
+
'
:
'
+
status_data
.
distribution
;
if
(
status_data
.
hasOwnProperty
(
'
package
'
))
result
+=
'
>
'
+
status_data
.
package
;
if
(
status_data
.
hasOwnProperty
(
'
uploader
'
)
&&
status_data
.
uploader
.
length
>
0
)
result
+=
'
by
'
+
status_data
.
uploader
;
return
result
;
}
function
__get_status_html_inner
(
status_data
)
{
if
(
status_data
.
hasOwnProperty
(
'
package
'
))
return
status_data
.
package
;
return
status_data
.
distribution
;
}
if
(
config
.
preferences
.
glossy_theme
)
{
if
(
$
(
"
head
"
).
find
(
"
link[href='/external_libs/bootstrap-3.1.1-dist/css/bootstrap-theme.min.css']
"
).
length
==
0
)
$
(
"
head
"
).
append
(
'
<link rel="stylesheet" href="/external_libs/bootstrap-3.1.1-dist/css/bootstrap-theme.min.css">
'
)
function
__get_status_html
(
status_data
)
{
var
_s
=
status_data
;
var
li
=
$
(
'
<li></li>
'
);
li
.
attr
(
'
id
'
,
__get_status_html_id
(
status_data
));
var
button
=
$
(
'
<a></a>
'
);
button
.
addClass
(
'
btn btn-xs
'
);
button
.
addClass
(
_s
.
status
);
button
.
attr
(
'
title
'
,
__get_status_html_title
(
_s
));
button
.
attr
(
'
href
'
,
__get_status_html_href
(
_s
));
button
.
html
(
__get_status_html_inner
(
_s
));
var
info
=
Utils
.
get_status_icon_and_class
(
_s
);
button
.
addClass
(
'
btn-
'
+
info
.
className
);
// add icon
button
.
html
(
button
.
html
()
+
'
'
+
Utils
.
get_status_icon_html
(
_s
));
li
.
html
(
button
);
var
result
=
$
(
'
<div></div>
'
);
result
.
html
(
li
);
return
result
.
html
();
}
else
{
$
(
"
head
"
).
find
(
"
link[href='/external_libs/bootstrap-3.1.1-dist/css/bootstrap-theme.min.css']
"
).
remove
()
var
distributions
=
{
set
:
function
(
distributions
)
{
$
(
'
#distributions ul
'
).
html
(
''
);
if
(
distributions
.
length
<
1
)
{
$
(
'
#distributions ul
'
).
append
(
'
<li><a title="There is no distribution at the moment" onclick="return false">None</li>
'
);
}
else
{
distributions
.
forEach
(
function
(
name
)
{
$
(
'
#distributions ul
'
).
append
(
'
<li id="distribution-
'
+
name
+
'
"><a href="
'
+
config
.
paths
.
distribution
+
'
#
'
+
name
+
'
">
'
+
name
+
'
</a></li>
'
);
});
if
(
window
.
location
.
pathname
==
config
.
paths
.
distribution
)
{
var
data
=
Utils
.
from_hash_to_view
();
if
(
Utils
.
check_view_distribution
(
data
))
{
$
(
'
#distributions li[id="distribution-
'
+
data
.
distribution
.
name
+
'
"]
'
).
addClass
(
'
active
'
);
}
}
}
},
}
var
status
=
{
set
:
function
(
data_status
)
{
$
(
"
#status ul
"
).
html
(
''
);
if
(
data_status
.
length
>
0
)
{
data_status
.
forEach
(
function
(
s
)
{
status
.
append
(
s
);
})
}
},
append
:
function
(
status_data
)
{
$
(
'
#status .idle
'
).
hide
();
$
(
"
#status ul
"
).
append
(
__get_status_html
(
status_data
));
},
update
:
function
(
status_data
)
{
var
li
=
$
(
'
#status li[id="
'
+
__get_status_html_id
(
status_data
)
+
'
"]
'
);
if
(
li
.
length
>
0
&&
status_data
.
hasOwnProperty
(
'
success
'
))
{
// Update color and icon
li
=
$
(
li
[
0
]);
li
.
html
(
$
(
__get_status_html
(
status_data
)).
children
());
li
.
attr
(
'
id
'
,
''
);
// This is a chain to have a fadeOut and correctly
// delete status li from list.
// The first timemout fades out the status element.
setTimeout
(
function
()
{
li
.
children
().
fadeOut
(
config
.
status
.
delay
.
fadeOut
);
// Then resize list.
setTimeout
(
function
()
{
li
.
animate
({
width
:
'
toggle
'
});
},
config
.
status
.
delay
.
fadeOut
);
// Finally remove status html
// and show idle label if necessary.
setTimeout
(
function
()
{
li
.
remove
();
if
(
$
(
'
#status li
'
).
length
===
0
);
$
(
'
#status .idle
'
).
show
();
},
config
.
status
.
delay
.
remove
+
2000
);
// more delay on remove html
},
config
.
status
.
delay
.
remove
);
}
else
if
(
!
status_data
.
hasOwnProperty
(
'
success
'
))
{
status
.
append
(
status_data
);
}
},
};
this
.
preferences
=
function
()
{
if
(
config
.
preferences
.
header
)
{
$
(
'
#pageheader
'
).
show
();
$
(
'
.navbar .home-link
'
).
hide
();
}
else
{
$
(
'
#pageheader
'
).
hide
();
$
(
'
.navbar .home-link
'
).
show
();
}
if
(
config
.
preferences
.
glossy_theme
)
{
if
(
$
(
'
head
'
).
find
(
'
link[href="/external_libs/bootstrap-3.1.1-dist/css/bootstrap-theme.min.css"]
'
).
length
===
0
)
$
(
'
head
'
).
append
(
'
<link rel="stylesheet" href="/external_libs/bootstrap-3.1.1-dist/css/bootstrap-theme.min.css">
'
);
}
else
{
$
(
'
head
'
).
find
(
'
link[href="/external_libs/bootstrap-3.1.1-dist/css/bootstrap-theme.min.css"]
'
).
remove
();
}
};
this
.
set_window_title
=
function
(
label
)
{
var
window_title_separator
=
'
\
u00ab
'
;
if
(
label
)
window
.
document
.
title
=
label
+
window_title_separator
+
config
.
title
;
else
window
.
document
.
title
=
config
.
title
;
};
this
.
start
=
function
(
socket
)
{
// update distributions
socket
.
on
(
_e
.
broadcast
.
distributions
,
function
(
socket_distributions
)
{
debug_socket
(
'
received
'
,
_e
.
broadcast
.
distributions
,
socket_distributions
);
distributions
.
set
(
socket_distributions
);
});
socket
.
on
(
_e
.
client
.
status
,
function
(
socket_status
)
{
debug_socket
(
'
received
'
,
_e
.
client
.
status
,
socket_status
);
status
.
set
(
socket_status
);
});
socket
.
on
(
_e
.
broadcast
.
status_update
,
function
(
package_status
)
{
debug_socket
(
'
received
'
,
_e
.
broadcast
.
status_update
,
package_status
);
status
.
update
(
package_status
);
});
socket
.
on
(
_e
.
error
,
function
(
error
)
{
console
.
error
(
'
socket >
'
+
error
);
});
};
// select current page in navbar
if
(
window
.
location
.
pathname
!=
config
.
paths
.
distribution
)
{
$
(
'
.navbar li a[href="
'
+
window
.
location
.
pathname
+
'
"]
'
).
parent
().
addClass
(
'
active
'
);
}
}
this
.
set_window_title
=
function
(
label
)
{
var
window_title_separator
=
'
\
u00ab
'
if
(
label
)
window
.
document
.
title
=
label
+
window_title_separator
+
config
.
title
else
window
.
document
.
title
=
config
.
title
}
this
.
start
=
function
(
socket
)
{
// update distributions
socket
.
on
(
_e
.
broadcast
.
distributions
,
function
(
socket_distributions
)
{
debug_socket
(
"
received
"
,
_e
.
broadcast
.
distributions
,
socket_distributions
)
distributions
.
set
(
socket_distributions
)
});
socket
.
on
(
_e
.
client
.
status
,
function
(
socket_status
)
{
debug_socket
(
"
received
"
,
_e
.
client
.
status
,
socket_status
)
status
.
set
(
socket_status
)
})
socket
.
on
(
_e
.
broadcast
.
status_update
,
function
(
package_status
)
{
debug_socket
(
"
received
"
,
_e
.
broadcast
.
status_update
,
package_status
)
status
.
update
(
package_status
)
})
socket
.
on
(
_e
.
error
,
function
(
error
)
{
console
.
error
(
"
socket >
"
+
error
)
})
}
// select current page in navbar
if
(
window
.
location
.
pathname
!=
config
.
paths
.
distribution
)
{
$
(
"
.navbar li a[href='
"
+
window
.
location
.
pathname
+
"
']
"
).
parent
().
addClass
(
"
active
"
)
}
// update html according with preferences
this
.
preferences
()
// update html according with preferences
this
.
preferences
();
}
debomatic-webui/public/javascripts/preferences.js
View file @
c0c918ec
'
use strict
'
;
function
Preferences
()
{
// update config.preferences according with user choices
var
load
=
function
()
{
for
(
key
in
config
.
preferences
)
{
if
((
value
=
localStorage
.
getItem
(
key
)))
{
debug
(
2
,
'
loading preference
'
,
key
,
value
)
config
.
preferences
[
key
]
=
JSON
.
parse
(
value
)
}
}
}
// set prefence
var
set
=
function
(
key
,
value
)
{
if
(
config
.
preferences
.
hasOwnProperty
(
key
))
{
debug
(
1
,
'
setting preference
'
,
key
,
value
)
localStorage
.
setItem
(
key
,
value
)
config
.
preferences
[
key
]
=
JSON
.
parse
(
value
)
}
}
// init prefence page
this
.
initPage
=
function
()
{
page_generic
.
set_window_title
(
"
Preferences
"
)
// set view according with config.preferences
for
(
key
in
config
.
preferences
)
{
var
element
=
$
(
"
#preferences #
"
+
key
)
if
(
element
.
attr
(
'
type
'
)
==
"
checkbox
"
)
{
element
.
prop
(
'
checked
'
,
config
.
preferences
[
key
])
}
else
{
element
.
val
(
config
.
preferences
[
key
])
}
}
// on input change, set prefence
$
(
"
#preferences input, #preferences select
"
).
change
(
function
()
{
var
key
=
$
(
this
).
attr
(
'
id
'
)
var
value
=
$
(
this
).
val
()
if
(
$
(
this
).
attr
(
'
type
'
)
==
'
checkbox
'
)
value
=
$
(
this
).
is
(
'
:checked
'
)
set
(
key
,
value
)
// give to user an immediate feedback changing preferences
page_generic
.
preferences
()
})
}
load
()
}
\ No newline at end of file
// update config.preferences according with user choices
var
load
=
function
()
{
for
(
var
key
in
config
.
preferences
)
{
var
value
=
localStorage
.
getItem
(
key
);
if
(
value
)
{
debug
(
2
,
'
loading preference
'
,
key
,
value
);
config
.
preferences
[
key
]
=
JSON
.
parse
(
value
);
}
}
};
// set prefence
var
set
=
function
(
key
,
value
)
{
if
(
config
.
preferences
.
hasOwnProperty
(
key
))
{
debug
(
1
,
'
setting preference
'
,
key
,
value
);
localStorage
.
setItem
(
key
,
value
);
config
.
preferences
[
key
]
=
JSON
.
parse
(
value
);
}
};
// init prefence page
this
.
initPage
=
function
()
{
page_generic
.
set_window_title
(
'
Preferences
'
);
// set view according with config.preferences
for
(
var
key
in
config
.
preferences
)
{
var
element
=
$
(
'
#preferences #
'
+
key
);
if
(
element
.
attr
(
'
type
'
)
==
'
checkbox
'
)
{
element
.
prop
(
'
checked
'
,
config
.
preferences
[
key
]);
}
else
{
element
.
val
(
config
.
preferences
[
key
]);
}
}
// on input change, set prefence
$
(
'
#preferences input, #preferences select
'
).
change
(
function
()
{
var
key
=
$
(
this
).
attr
(
'
id
'
);
var
value
=
$
(
this
).
val
();
if
(
$
(
this
).
attr
(
'
type
'
)
==
'
checkbox
'
)
value
=
$
(
this
).
is
(
'
:checked
'
);
set
(
key
,
value
);
// give to user an immediate feedback changing preferences
page_generic
.
preferences
();
});
};
load
();
}
debomatic-webui/public/javascripts/utils.js
View file @
c0c918ec
'
use strict
'
;
var
Utils
=
{
from_hash_to_view
:
function
(
hash
)
{
if
(
!
hash
)
hash
=
window
.
location
.
hash
hash
=
hash
.
replace
(
'
#
'
,
''
)
info
=
hash
.
split
(
'
/
'
);
var
view
=
{}
view
.
distribution
=
{}
view
.
packages
=
{}
view
.
package
=
{}
view
.
file
=
{}
from_hash_to_view
:
function
(
hash
)
{
if
(
!
hash
)
hash
=
window
.
location
.
hash
;
hash
=
hash
.
replace
(
'
#
'
,
''
);
var
info
=
hash
.
split
(
'
/
'
);
var
view
=
{};
view
.
distribution
=
{};
view
.
packages
=
{};
view
.
package
=
{};
view
.
file
=
{};
if
(
info
.
length
>=
1
)
{
view
.
distribution
.
name
=
info
[
0
];
}
if
(
info
.
length
>=
3
){
view
.
package
.
name
=
info
[
1
];
view
.
package
.
version
=
info
[
2
];
view
.
package
.
orig_name
=
view
.
package
.
name
+
'
_
'
+
view
.
package
.
version
}
if
(
info
.
length
>=
4
)
{
view
.
file
.
name
=
info
[
3
]
view
.
file
.
orig_name
=
view
.
package
.
orig_name
+
'
.
'
+
view
.
file
.
name
}
return
view
},
from_view_to_hash
:
function
(
view
)
{
hash
=
"
#
"
if
(
Utils
.
check_view_distribution
(
view
))
{
hash
=
hash
+
view
.
distribution
.
name
if
(
Utils
.
check_view_package
(
view
))
{
hash
=
hash
+
'
/
'
+
view
.
package
.
name
+
"
/
"
+
view
.
package
.
version
if
(
Utils
.
check_view_file
(
view
))
hash
=
hash
+
'
/
'
+
view
.
file
.
name
}
}
return
hash
},
check_view_distribution
:
function
(
view
)
{
return
view
&&
view
.
distribution
&&
view
.
distribution
.
name
},
check_view_package
:
function
(
view
)
{
return
Utils
.
check_view_distribution
(
view
)
&&
view
.
package
&&
view
.
package
.
name
&&
view
.
package
.
version
&&
view
.
package
.
orig_name
},
check_view_file
:
function
(
view
)
{
return
Utils
.
check_view_package
(
view
)
&&
view
.
file
&&
view
.
file
.
name
},
if
(
info
.
length
>=
1
)
{
view
.
distribution
.
name
=
info
[
0
];
}
if
(
info
.
length
>=
3
)
{
view
.
package
.
name
=
info
[
1
];
view
.
package
.
version
=
info
[
2
];
view
.
package
.
orig_name
=
view
.
package
.
name
+
'
_
'
+
view
.
package
.
version
;
}
if
(
info
.
length
>=
4
)
{
view
.
file
.
name
=
info
[
3
];
view
.
file
.
orig_name
=
view
.
package
.
orig_name
+
'
.
'
+
view
.
file
.
name
;
}
return
view
;
},
get_status_icon_and_class
:
function
(
status_data
)
{
var
_c
=
config
.
status
.
className
var
_i
=
config
.
status
.
icons
var
_s
=
status_data
var
className
=
null
var
icon
=
null
if
(
_s
.
hasOwnProperty
(
'
success
'
))
{
if
(
_s
.
success
==
true
)
{
className
=
_c
.
success
icon
=
_i
.
success
}
else
{
className
=
_c
.
fail
icon
=
_i
.
fail
}
}
else
{
className
=
_c
[
_s
.
status
]
icon
=
_i
[
_s
.
status
]
}
from_view_to_hash
:
function
(
view
)
{
var
hash
=
'
#
'
;
if
(
Utils
.
check_view_distribution
(
view
))
{
hash
=
hash
+
view
.
distribution
.
name
;
if
(
Utils
.
check_view_package
(
view
))
{
hash
=
hash
+
'
/
'
+
view
.
package
.
name
+
'
/
'
+
view
.
package
.
version
;
if
(
Utils
.
check_view_file
(
view
))
hash
=
hash
+
'
/
'
+
view
.
file
.
name
;
}
}
return
hash
;
},
// do not change color if update or create and successed
if
(
_s
.
success
==
true
&&
_s
.
status
!=
config
.
status
.
build
)
{
className
=
_c
[
_s
.
status
]
}
check_view_distribution
:
function
(
view
)
{
return
view
&&
view
.
distribution
&&
view
.
distribution
.
name
;
},
return
{
className
:
className
,
icon
:
icon
}
},
check_view_package
:
function
(
view
)
{
return
Utils
.
check_view_distribution
(
view
)
&&
view
.
package
&&
view
.
package
.
name
&&
view
.
package
.
version
&&
view
.
package
.
orig_name
;
},
check_view_file
:
function
(
view
)
{
return
Utils
.
check_view_package
(
view
)
&&
view
.
file
&&
view
.
file
.
name
;
},
get_status_icon_and_class
:
function
(
status_data
)
{
var
_c
=
config
.
status
.
className
;
var
_i
=
config
.
status
.
icons
;
var
_s
=
status_data
;
var
className
=
null
;
var
icon
=
null
;
if
(
_s
.
hasOwnProperty
(
'
success
'
))
{
if
(
_s
.
success
===
true
)
{
className
=
_c
.
success
;
icon
=
_i
.
success
;
}
else
{
className
=
_c
.
fail
;
icon
=
_i
.
fail
;
}
}
else
{
className
=
_c
[
_s
.
status
];
icon
=
_i
[
_s
.
status
];
}
get_status_icon_html
:
function
(
status_data
)
{
info
=
Utils
.
get_status_icon_and_class
(
status_data
)
return
'
<span class="icon glyphicon glyphicon-
'
+
info
.
icon
+
'
"></span>
'
},
// do not change color if update or create and successed
if
(
_s
.
success
===
true
&&
_s
.
status
!=
config
.
status
.
build
)
{
className
=
_c
[
_s
.
status
];
}
// clone an object via JSON
clone
:
function
(
object
)
{
return
JSON
.
parse
(
JSON
.
stringify
(
object
));
}
}
return
{
className
:
className
,
icon
:
icon
};
},
get_status_icon_html
:
function
(
status_data
)
{
var
info
=
Utils
.
get_status_icon_and_class
(
status_data
);
return
'
<span class="icon glyphicon glyphicon-
'
+
info
.
icon
+
'
"></span>
'
;
},
// clone an object via JSON
clone
:
function
(
object
)
{
return
JSON
.
parse
(
JSON
.
stringify
(
object
));
}
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment