Create mega repo
Create pirate repo
by Lissandro Dittmar
HTML
<div id="banner-message">
<p>Count for statistic</p>
<button>Do it!</button>
</div>
<ol id="liste">
</ol>
<a id="downloadAnchorElem" style="display:none"></a>
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;
}
.loader {
border: 16px solid #f3f3f3; /* Light grey */
border-top: 16px solid #3498db; /* Blue */
border-radius: 50%;
width: 50px;
height: 50px;
animation: spin 2s linear infinite;
margin-left: 410px;
margin-top: 30px;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
JavaScript
const repos = [];
const apiUrl = 'https://api.github.com/graphql';
const TOKEN_STRING = "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";
const adapterList = [];
let dings = "asc";
const start = async function() {
if(dings === "asc"){
dings = "desc";
}else{
dings = "asc";
}
$.getJSON('https://raw.githubusercontent.com/ioBroker/ioBroker.repositories/master/sources-dist.json', function(data) {
const adapters = [];
$.each(data, function(key, val) {
adapters.push(key.toUpperCase());
});
console.log("Latest: " + (adapters.length - 1));
});
$.getJSON('https://raw.githubusercontent.com/ioBroker/ioBroker.repositories/master/sources-dist-stable.json', function(data) {
const adapters = [];
$.each(data, function(key, val) {
adapters.push(key.toUpperCase());
});
console.log("Stable: " + (adapters.length - 1));
});
let queryBody = `{
search(query: "iobroker sort:updated-$dings", type: REPOSITORY, first: 100) {
repositoryCount
nodes {
... on Repository {
resourcePath
isFork
createdAt
description
primaryLanguage {name}
object(expression: "HEAD:io-package.json") {
... on Tree {
entries {
name
}
}
}
}
}
pageInfo {
endCursor
hasNextPage
}
}
}`;
queryBody = queryBody.replace("$dings", dings);
let data = await (await fetch('https://api.github.com/graphql', {
method: 'POST',
headers: new Headers({
'Content-Type': 'application/json',
'Authorization': 'bearer ' + TOKEN_STRING
}),
body: JSON.stringify({
query: queryBody
})
})).json();
console.log("Repocount: " + data['data']['search']['repositoryCount']);
$.each(data['data']['search']['nodes'], function(i, obj) {
if ($.inArray(obj.resourcePath, adapterList) == -1 && obj.object !== null && !obj.isFork) {
adapterList.push(obj.resourcePath);
const repo...