fix: [contrib] Hide broken organisation images - Fix #110

pull/121/head
mokaddem 2019-08-29 10:25:57 +02:00
parent fb1332be6a
commit 0dbaa034fb
2 changed files with 14 additions and 9 deletions

View File

@ -152,6 +152,7 @@ function getMonthlyRankIcon(rank, size, header) {
img.width = size; img.width = size;
} }
} }
img.setAttribute('onerror', "this.style.display='none'");
return img.outerHTML; return img.outerHTML;
} }
@ -167,7 +168,8 @@ function getOrgRankIcon(rank, size) {
obj.src = rankLogoPath; obj.src = rankLogoPath;
obj.type = "image/svg" obj.type = "image/svg"
obj.title = org_rank_obj[rank]; obj.title = org_rank_obj[rank];
obj.classList.add('orgRankClass') obj.classList.add('orgRankClass');
obj.setAttribute('onerror', "this.style.display='none'");
return obj.outerHTML; return obj.outerHTML;
} }
@ -177,8 +179,9 @@ function createImg(source, size) {
obj.width = size; obj.width = size;
obj.style.margin = 'auto'; obj.style.margin = 'auto';
obj.src = source; obj.src = source;
obj.type = "image/png" obj.type = "image/png";
obj.alt = "" obj.alt = "";
obj.setAttribute('onerror', "this.style.display='none'");
return obj.outerHTML; return obj.outerHTML;
} }
@ -187,10 +190,11 @@ function createTrophyImg(rank, size, categ) {
obj.height = size; obj.height = size;
obj.width = size; obj.width = size;
obj.style.margin = 'auto'; obj.style.margin = 'auto';
obj.src = url_baseTrophyLogo+rank+'.png';; obj.src = url_baseTrophyLogo+rank+'.png';
obj.title = trophy_title[rank] + " in " + categ; obj.title = trophy_title[rank] + " in " + categ;
obj.type = "image/png" obj.type = "image/png";
obj.alt = "" obj.alt = "";
obj.setAttribute('onerror', "this.style.display='none'");
return obj.outerHTML; return obj.outerHTML;
} }
@ -208,6 +212,7 @@ function createHonorImg(array, size) {
obj.style.margin = 'auto'; obj.style.margin = 'auto';
obj.title = org_honor_badge_title[badgeNum]; obj.title = org_honor_badge_title[badgeNum];
obj.src = url_baseHonorLogo+badgeNum+'.svg'; obj.src = url_baseHonorLogo+badgeNum+'.svg';
obj.setAttribute('onerror', "this.style.display='none'");
div.appendChild(obj); div.appendChild(obj);
} }
div.style.width = 32*array.length+'px'; div.style.width = 32*array.length+'px';
@ -563,7 +568,7 @@ function generate_table_ranking_on_category(categ) {
var rank = arr[2]; var rank = arr[2];
var tr = $('<tr></tr>'); var tr = $('<tr></tr>');
tr.append($('<td style="width: 100px;">'+i+'</td>')); tr.append($('<td style="width: 100px;">'+i+'</td>'));
tr.append($('<td style="width: 100px;"><img src="'+url_baseTrophyLogo+rank+'.png" width="30" height="30"></td>')); tr.append($('<td style="width: 100px;"><img src="'+url_baseTrophyLogo+rank+'.png" width="30" height="30" onerror="this.style.display=\'none\'"></td>'));
tr.append($('<td style="width: 200px;">'+points+'</td>')); tr.append($('<td style="width: 200px;">'+points+'</td>'));
tr.append($('<td><a href="?org='+org+'">'+org+'</a></td>')); tr.append($('<td><a href="?org='+org+'">'+org+'</a></td>'));
if (currOrg == org) { if (currOrg == org) {

View File

@ -120,7 +120,7 @@
<tbody id='bodyTablerankingModal'> <tbody id='bodyTablerankingModal'>
{% for item in org_rank_list %} {% for item in org_rank_list %}
<tr data-rank={{ loop.index }}> <tr data-rank={{ loop.index }}>
<td style='padding: 0px; text-align: right;'><img height='35px' width='70px' style="margin-right: 20px;" src="{{ url_for('static', filename='pics/rankingMISPOrg/1.svg')[:-5]}}{{ item[0] }}.svg" type='image/svg' style="margin: auto;"</img></td> <td style='padding: 0px; text-align: right;'><img height='35px' width='70px' style="margin-right: 20px;" src="{{ url_for('static', filename='pics/rankingMISPOrg/1.svg')[:-5]}}{{ item[0] }}.svg" type='image/svg' style="margin: auto;" onerror="this.style.display='none'"</img></td>
<td>{{ item[1] }}</td> <td>{{ item[1] }}</td>
<td>{{ item[2] }}</td> <td>{{ item[2] }}</td>
<td>{{ item[3] }}</td> <td>{{ item[3] }}</td>
@ -172,7 +172,7 @@
<tr> <tr>
<td> <td>
<div id="divBadge_{{ loop.index }}" class="circleBadgeSmall circlBadgeNotAcquired"> <div id="divBadge_{{ loop.index }}" class="circleBadgeSmall circlBadgeNotAcquired">
<img height='48px' width='48' class="" style="margin-top: 3px;" src="{{ url_for('static', filename='pics/MISPHonorableIcons/1.svg')[:-5]}}{{ item[0] }}.svg" type='image/svg' style="margin: auto;"</img> <img height='48px' width='48' class="" style="margin-top: 3px;" src="{{ url_for('static', filename='pics/MISPHonorableIcons/1.svg')[:-5]}}{{ item[0] }}.svg" type='image/svg' style="margin: auto;" onerror="this.style.display='none'"</img>
</div> </div>
</td> </td>
<td style="padding-left: 15px;">{{ item[1] }}</td> <td style="padding-left: 15px;">{{ item[1] }}</td>