1 line
2.2 KiB
JavaScript
1 line
2.2 KiB
JavaScript
function error(t){$(t).parent().parent().remove()}$(document).ready(function(){function t(t,e,o){var t=$(t).find("img"),a=$(t).attr("src").replace(e,o);$(t).attr("src",a)}function e(t){$(t).val().length>0?($(".icon").css("display","none"),$("a[data-icon*='"+$(t).val().toLowerCase()+"']").parent().css("display","block"),$('<div class="close-search"></div>').insertAfter(t),$(".close-search").click(function(){o(t)})):o(t)}function o(t){$(".close-search").remove(),$(".icon").css("display","block"),$(t).val("")}var a=["svg","128","32","32@2x"],c=["color","black","icon","white"];$("form .search").on("input",function(){e($(this))}),$("form").submit(function(t){t.preventDefault(),e($("form .search"))}),$.getJSON("manifest.json",function(e){var o="",a=0;$.each(e.icons,function(t,e){o+='<div class="col-6 col-sm-4 col-lg-3 col-xl-2 text-left icon">',o+='<a href="#'+e+'" class="bg-light text-muted text-uppercase d-block p-4" data-toggle="modal" data-target="#infoIcon" data-icon="'+e+'">',o+='<img class="mr-2" src="svg/black/'+e+'.svg" alt="'+e+'" onerror="error(this);">'+e,o+="</a>",o+="</div>",a++}),$(".row.icons").html(o),$(".icon").hover(function(){t($(this),"black","color")}),$(".icon").mouseleave(function(){t($(this),"color","black")}),$(".count-cryptos").text(a)}),$("#infoIcon").on("show.bs.modal",function(t){var e=$(t.relatedTarget),o=$(this),n=e.data("icon"),r="",i=0,l=0;for(r+='<table class="table info-icon mb-0">',r+="<thead>",r+="<tr>",r+='<th class="text-center text-uppercase align-middle"><h5 class="mb-0">'+n+"</h5></th>";c[l];){s=a[i].replace("@","-");r+='<th class="variant-'+c[l]+' text-center font-weight-light text-muted align-middle">'+c[l]+"</th>",l++}for(l=0,r+="</tr>",r+="</thead>",r+="<tbody>";a[i];){var s;if(r+="<tr>",r+='<th class="format-'+(s=a[i].replace("@","-"))+' text-center font-weight-light text-muted align-middle" scope="row">'+a[i]+"</th>","svg"==a[i])d=".svg";else if("32@2x"==a[i])d="@2x.png";else var d=".png";for(;c[l];)r+='<td class="format-'+s+" variant-"+c[l]+' text-center">',r+='<img src="'+a[i]+"/"+c[l]+"/"+n+d+'" alt="'+n+'">',r+="</td>",l++;l=0,i++,r+="</tr>"}r+="</tbody>",r+="</table>",o.find(".modal-title").text(n),o.find(".modal-body").html(r)})}); |