Add PHPStan and other quality checks
Similar to FreshRSS core Contributes to https://github.com/FreshRSS/Extensions/issues/184
This commit is contained in:
parent
a86467db48
commit
b49596818c
59 changed files with 1173 additions and 404 deletions
|
|
@ -1,8 +1,11 @@
|
|||
# FreshRSS Colorful List
|
||||
|
||||
Generate light different background color for article list rows (relying on the feed name)
|
||||
|
||||
# Installation
|
||||
## Installation
|
||||
|
||||
To use it, upload the *xExtension-ColorfulList* folder in your ./extensions directory and enable it on the extension panel in FreshRSS.
|
||||
|
||||
# Preview
|
||||
## Preview
|
||||
|
||||

|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
<?php
|
||||
|
||||
class ColorfulListExtension extends Minz_Extension {
|
||||
declare(strict_types=1);
|
||||
|
||||
public function init():void {
|
||||
Minz_View::appendScript($this->getFileUrl('script.js', 'js'),'','','');
|
||||
}
|
||||
class ColorfulListExtension extends Minz_Extension
|
||||
{
|
||||
public function init(): void {
|
||||
Minz_View::appendScript($this->getFileUrl('script.js', 'js'));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,40 +1,38 @@
|
|||
document.addEventListener('DOMContentLoaded', function(){
|
||||
function monitorEntry(monitorCallback) {
|
||||
const targetNode = document.getElementById('stream');
|
||||
const config = { attributes: false, childList: true, subtree: false};
|
||||
const callback = function(mutationsList, observer) {
|
||||
for(let mutation of mutationsList) {
|
||||
if (mutation.type === 'childList') {
|
||||
monitorCallback(mutationsList);
|
||||
}
|
||||
}
|
||||
};
|
||||
const observer = new MutationObserver(callback);
|
||||
observer.observe(targetNode, config);
|
||||
//observer.disconnect();
|
||||
};
|
||||
monitorEntry(colorize);
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
function monitorEntry(monitorCallback) {
|
||||
const targetNode = document.getElementById('stream');
|
||||
const config = { attributes: false, childList: true, subtree: false };
|
||||
const callback = function (mutationsList, observer) {
|
||||
for (const mutation of mutationsList) {
|
||||
if (mutation.type === 'childList') {
|
||||
monitorCallback(mutationsList);
|
||||
}
|
||||
}
|
||||
};
|
||||
const observer = new MutationObserver(callback);
|
||||
observer.observe(targetNode, config);
|
||||
// observer.disconnect();
|
||||
}
|
||||
monitorEntry(colorize);
|
||||
});
|
||||
|
||||
|
||||
function colorize(entries){
|
||||
let entry = document.querySelectorAll('.flux_header');
|
||||
entry.forEach((e,i)=>{
|
||||
let cl = stringToColour(e.querySelector('.website').textContent)+'12';
|
||||
e.style.background=cl;
|
||||
});
|
||||
};
|
||||
|
||||
function colorize(entries) {
|
||||
const entry = document.querySelectorAll('.flux_header');
|
||||
entry.forEach((e, i) => {
|
||||
const cl = stringToColour(e.querySelector('.website').textContent) + '12';
|
||||
e.style.background = cl;
|
||||
});
|
||||
}
|
||||
|
||||
const stringToColour = (str) => {
|
||||
let hash = 0;
|
||||
str.split('').forEach(char => {
|
||||
hash = char.charCodeAt(0) + ((hash << 5) - hash)
|
||||
})
|
||||
let color = '#';
|
||||
for (let i = 0; i < 3; i++) {
|
||||
const value = (hash >> (i * 8)) & 0xff
|
||||
color += value.toString(16).padStart(2, '0')
|
||||
}
|
||||
return color;
|
||||
let hash = 0;
|
||||
str.split('').forEach(char => {
|
||||
hash = char.charCodeAt(0) + ((hash << 5) - hash);
|
||||
});
|
||||
let color = '#';
|
||||
for (let i = 0; i < 3; i++) {
|
||||
const value = (hash >> (i * 8)) & 0xff;
|
||||
color += value.toString(16).padStart(2, '0');
|
||||
}
|
||||
return color;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue