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.
Je suis tombé sur le même problème. window.onload fonctionne s’il est appelé avant </head>, mais pas s’il est appelé plus tard. En raison de cela, document.getElementById échoue (l’ID n’est pas encore défini).
Pourriez-vous me pointer vers un tutoriel/exemple/guide pour créer un initialiseur Ember personnalisé pour quelqu’un qui n’a aucune expérience avec Ember ?
Pour être complet, ce que j’essaie de faire est d’afficher une image de bannière aléatoire à partir d’un tableau d’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;