fix javascript

Signed-off-by: Jess Frazelle <acidburn@google.com>
This commit is contained in:
Jess Frazelle 2017-04-24 15:03:03 -04:00
parent 1d006c17ef
commit e1d409fefd
No known key found for this signature in database
GPG key ID: 18F3685C0022BFF3
4 changed files with 4 additions and 15 deletions

View file

@ -6,6 +6,7 @@ import (
"net/http"
"os"
"path/filepath"
"strings"
"time"
"github.com/Sirupsen/logrus"
@ -255,7 +256,7 @@ func (rc *registryController) vulnerabilitiesHandler(w http.ResponseWriter, r *h
}
}
if r.Header.Get("Accept-Encoding") == "application/json" {
if strings.HasSuffix(r.URL.String(), ".json") {
js, err := json.Marshal(result)
if err != nil {
logrus.WithFields(logrus.Fields{

View file

@ -216,6 +216,7 @@ func main() {
mux.HandleFunc("/repo/{repo}/{tag}/", rc.vulnerabilitiesHandler)
mux.HandleFunc("/repo/{repo}/{tag}/vulns", rc.vulnerabilitiesHandler)
mux.HandleFunc("/repo/{repo}/{tag}/vulns/", rc.vulnerabilitiesHandler)
mux.HandleFunc("/repo/{repo}/{tag}/vulns.json", rc.vulnerabilitiesHandler)
mux.PathPrefix("/static/").Handler(http.StripPrefix("/static/", staticHandler))
mux.Handle("/", staticHandler)

View file

@ -38,7 +38,6 @@ function search(search_val){
function loadVulnerabilityCount(url){
var xhr = new XMLHttpRequest();
xhr.open('GET', url);
xhr.setRequestHeader("Accept-Encoding", "text/json")
xhr.onload = function() {
if (xhr.status === 200) {
var report = JSON.parse(xhr.responseText);
@ -65,18 +64,6 @@ if (el.textContent == 'Parent Directory'){
}
}
/*
var rows = document.querySelectorAll('tr:not(.parent)');
Array.prototype.forEach.call(rows, function(item, index){
if (index !== 0) {
var date_holder = item.querySelectorAll('td:nth-child(3)')[0];
var date = date_holder.textContent;
date = prettyDate(date);
date_holder.innerHTML = date;
}
});
*/
var cells = document.querySelectorAll('td a');
Array.prototype.forEach.call(cells, function(item, index){
var link = item.getAttribute('href');

View file

@ -54,7 +54,7 @@
<script type="text/javascript">
var ajaxCalls = [
{{ range $key, $value := .Repositories }}
'/repo/{{ $value.Name | urlquery }}/{{ $value.Tag }}/vulns',
'/repo/{{ $value.Name | urlquery }}/{{ $value.Tag }}/vulns.json',
{{ end }}
];
window.onload = function() {