1
0
mirror of https://github.com/php/web-php.git synced 2026-03-31 19:52:29 +02:00
Files
archived-web-php/userprefs.js
Gabor Hojtsy ec5a78f5e9 Adding client side JS to make events in the user's
country bold. This JS file will be expanded in the future
to add features like last search keyword / last selected
search option remembering

This JS was tested in Mozilla, Galeon and Konqueror
with success and the code was human checked against
MSDN for Internet Explorer questions. It also includes
a BC check for browsers without DOM support.
2003-05-15 13:27:40 +00:00

37 lines
1.2 KiB
JavaScript

// Get a value of one cookie set by it's name
// Impmentation from the JS 1.3 Client Guide by Netscape
function getCookie(Name)
{
var search = Name + "=";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search);
if (offset != -1) {
offset += search.length;
end = document.cookie.indexOf(";", offset);
if (end == -1) { end = document.cookie.length; }
return unescape(document.cookie.substring(offset, end));
}
}
return null;
}
// Make events in the user's country bold
function boldEvents()
{
// Get cookie if possible
country = getCookie("COUNTRY");
if (typeof(country) == "string") {
// Get country code from cookie
country = country.substring(0, 3);
// If DOM is supported, get <span>s
if (document.getElementsByTagName) {
spans = document.getElementsByTagName("span");
// Style every span bold which is for this country
for (var i = 0; i < spans.length; i++) {
if (spans[i].className == "event_" + country) {
spans[i].style.fontWeight = "bold";
}
}
}
}
}