Mailinglist Archive: opensuse-web (64 mails)

< Previous Next >
[opensuse-web] Dynamic counter change according to locale
  • From: Marguerite Su <i@xxxxxxxxxxxxx>
  • Date: Thu, 30 Aug 2012 23:09:38 +0800
  • Message-id: <CAK0PdA=v5-gwRs47jAFDJrT=Ba8CWFTUzd90W6hhDdMQKasvgg@mail.gmail.com>
Hi,

I add a few codes into frontpage.js in landing-page

here they are:

// dynamic change counter
$(document).ready(function() {
var path = $(location).attr('href');
// 24 = http://www.opensuse.org/
if (path.length > 24) {
// should return string like "cn" "ja" "fr"
path = path.substring(path.lastIndexOf("/")-2);
path = path.substring(0,path.length-1);

//test if the counter exists
var counter = new Image();
counter.src = "http://counter.opensuse.org/medium."+path+".png";;
if (counter.width > 0) {

$("h1").css("background-image","http://counter.opensuse.org/medium."+path+".png";);
}
}
});

basically it'll at first detect if default en page, if not, then see
if the local counter exists, if exists, then change the English
counter with the local one.

Enjoy!

Anyone please merge pull request 2 at
https://github.com/openSUSE/landing-page/pulls

Marguerite
--
To unsubscribe, e-mail: opensuse-web+unsubscribe@xxxxxxxxxxxx
To contact the owner, e-mail: opensuse-web+owner@xxxxxxxxxxxx

< Previous Next >
Follow Ups