Skip to content

Commit ca18cd7

Browse files
committed
Ajuste Idioma
1 parent d24635f commit ca18cd7

File tree

2 files changed

+35
-6
lines changed

2 files changed

+35
-6
lines changed

index.html

+8-6
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ <h1><a href="/" title="Coderockr"><img src="/public/images/coderockr-logo.png" w
5656
<input type="checkbox" name="language" id="language" />
5757
<div class="language-pt">
5858
<div>
59-
<a href="http://coderockr.com" title="Acesse nosso site em Português" target="_top">PT</a>
60-
<a href="http://en.coderockr.com" title="Visit our site in English." target="_top">EN</a>
59+
<a href="http://coderockr.com" title="Acesse nosso site em Português" rel="pt-br" target="_top">PT</a>
60+
<a href="http://en.coderockr.com" title="Visit our site in English." rel="en" target="_top">EN</a>
6161
</div>
6262
</div>
6363
</header>
@@ -259,10 +259,12 @@ <h2>A Coderockr está pronta para<br /><span>dar um show</span>,<br />entre em c
259259
});
260260
</script>
261261
<script>
262-
var language = window.navigator.userLanguage || window.navigator.language;
263-
if(language.toLowerCase() != 'pt-br') {
264-
window.location.href='http://en.coderockr.com';
265-
}
262+
if(getCookie("idioma") == "") {
263+
var language = window.navigator.userLanguage || window.navigator.language;
264+
if(language.toLowerCase() != 'pt-br') {
265+
window.location.href='http://en.coderockr.com';
266+
}
267+
}
266268
</script>
267269

268270
<!--[if lt IE 7 ]>

public/scripts/script.js

+27
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,34 @@ $(document).ready(function() {
112112
return false;
113113
}
114114
});
115+
$('div[class=^"language-"] a').bind("click", function(){
116+
var langValue = $(this).attr("rel");
117+
createCookie("idioma", langValue, 60);
118+
});
115119
});
120+
function createCookie(name, value, days) {
121+
if (days) {
122+
var date = new Date();
123+
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
124+
var expires = "; expires=" + date.toGMTString();
125+
}
126+
else var expires = "";
127+
document.cookie = name + "=" + value + expires + "; path=/";
128+
}
129+
function getCookie(c_name) {
130+
if (document.cookie.length > 0) {
131+
c_start = document.cookie.indexOf(c_name + "=");
132+
if (c_start != -1) {
133+
c_start = c_start + c_name.length + 1;
134+
c_end = document.cookie.indexOf(";", c_start);
135+
if (c_end == -1) {
136+
c_end = document.cookie.length;
137+
}
138+
return unescape(document.cookie.substring(c_start, c_end));
139+
}
140+
}
141+
return "";
142+
}
116143
function hideLanguage() {
117144
$('input[name="language"]').attr('checked', false);
118145
}

0 commit comments

Comments
 (0)