Check io-packages

Check io-packages

by Lissandro Dittmar

HTML

<div id="banner-message">
  <p>Check for io-packages</p>
  <button>Start check</button>
</div>

<div style="background-color: white;">
  <ol id="liste">
  
  </ol>
</div>

CSS

i {
  color: #669FAB;
}

body {
  background: #20262E;
  padding: 20px;
  font-family: Helvetica;
}

#banner-message {
  background: #fff;
  border-radius: 4px;
  padding: 20px;
  font-size: 25px;
  text-align: center;
  transition: all 0.2s;
  margin: 0 auto;
  width: 300px;
}

button {
  background: #0084ff;
  border: none;
  border-radius: 5px;
  padding: 8px 14px;
  font-size: 15px;
  color: #fff;
}

#banner-message.alt {
  background: #0084ff;
  color: #fff;
  margin-top: 40px;
  width: 200px;
}

#banner-message.alt button {
  background: #fff;
  color: #000;
}

JavaScript

var adapterList = [];

const start = function(){

	for(i=0;i<7;i++){
    $.getJSON( "https://api.github.com/search/repositories?q=iobroker&sort=updated&page=" + i + "&per_page=100", function( data ) {
      $.each( data.items, function( key, val ) {
      	var full_name = val.full_name;
         var link = "https://raw.githubusercontent.com/" + val.full_name + "/master/io-package.json";
         $.getJSON( link, function(res) {
         	if($.inArray(full_name, adapterList) == -1 && res && res.common){
            	adapterList.push(full_name);
               for (let key of Object.keys(res.common)) {
                   if($("#commonLi" + key).length ){
                   	$('#span' + key).text(parseInt($('#span' + key).text()) + 1);
                   }else{
                   	$('#liste').append( "<li id='commonLi" + key + "'>" + key + " - <span id='span" + key +"'>1</span></li>");
                   }
                   
                   if(key !== "news" && key !== "desc" && key !== "docs" && key !== "titleLang" && typeof res.common[key] === 'object' && !Array.isArray(res.common[key])){
                   	for (let key2 of Object.keys(res.common[key])) {
                     	if($("#commonLi" + key + key2).length ){
                        	$('#span' + key + key2).text(parseInt($('#span' + key + key2).text()) + 1);
                      	}else{
                        	$('#liste').append( "<li id='commonLi" + key + key2 + "'>" + key + "." + key2 +" - <span id='span" + key + key2 +"'>1</span></li>");
                     	}                     
                   	}
               	}            	
            	}
            }
         });
      	
      });
      });
    };
    
}

$("button").on("click", function(){
  start();
});