Is it possible to (via a plug-in if necessary) randomly choose a logo (and small logo) from a set of 3 every time someone starts a new session (or until their browser refreshes the assets for the logo)?
The Ruby code is trivial - but how can we incorporate that into Discourse?
This is doable in a theme component, the method by @Alankrit_Choudh can work but I would recommend adding a custom ember initializer instead that overrides the URL in discourse instead of relying on window.onload here.
Ho incontrato lo stesso problema. window.onload funziona se chiamato prima di </head>, ma non se chiamato successivamente. A causa di ciò, document.getElementById fallisce (l’ID non è ancora definito).
Potresti indicarmi una guida/esempio/come fare per creare un inizializzatore Ember personalizzato per chi non ha esperienza con Ember?
Per completezza, ciò che sto cercando di fare è visualizzare un’immagine banner casuale da un array di URL:
var jlmyPix = new Array(
'/img/pic0.jpeg',
[ ... ]
'/img/picN.jpeg'
);
function jlchoosePic() {
var jlrandomPicNum = Math.floor(Math.random() * jlmyPix.length);
document.getElementById("jlmyPicture").src = jlmyPix[jlrandomPicNum];
};
window.onload = jlchoosePic;