2012-11-06 20:52:07 +01:00
|
|
|
|
|
|
|
|
|
// http://www.quirksmode.org/js/cookies.html
|
|
|
|
|
function readCookie(name) {
|
|
|
|
|
var nameEQ = name + "=";
|
|
|
|
|
var ca = document.cookie.split(';');
|
|
|
|
|
for(var i=0;i < ca.length;i++) {
|
|
|
|
|
var c = ca[i];
|
|
|
|
|
while (c.charAt(0)==' ') c = c.substring(1,c.length);
|
|
|
|
|
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function init()
|
|
|
|
|
{
|
|
|
|
|
var i=0;
|
|
|
|
|
|
|
|
|
|
var author = readCookie("author");
|
|
|
|
|
var email = readCookie("email");
|
|
|
|
|
|
|
|
|
|
for (i=0;;i++)
|
|
|
|
|
{
|
|
|
|
|
id = "response_"+i;
|
|
|
|
|
var div = document.getElementById(id);
|
|
|
|
|
|
|
|
|
|
if (div == null) break;
|
|
|
|
|
|
|
|
|
|
var inputs = div.getElementsByTagName("input");
|
|
|
|
|
for(a=0; a<inputs.length; a++)
|
|
|
|
|
{
|
|
|
|
|
if (author != null && inputs[a].getAttribute("name") == "author")
|
|
|
|
|
inputs[a].value = author;
|
|
|
|
|
if (email != null && inputs[a].getAttribute("name") == "email")
|
|
|
|
|
inputs[a].value = email;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Remove space from textarea
|
|
|
|
|
var textareas = div.getElementsByTagName("textarea");
|
|
|
|
|
for(a=0; a<textareas.length; a++)
|
|
|
|
|
{
|
|
|
|
|
textareas[a].value = "";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function display(id)
|
|
|
|
|
{
|
|
|
|
|
div = document.getElementById(id);
|
|
|
|
|
|
|
|
|
|
if (div == null) return 0;
|
|
|
|
|
|
|
|
|
|
if (div.style.display == 'none' || div.style.display == '')
|
|
|
|
|
div.style.display = 'block';
|
|
|
|
|
else
|
|
|
|
|
div.style.display = 'none';
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function validateComment(id)
|
|
|
|
|
{
|
|
|
|
|
div = document.getElementById(id);
|
|
|
|
|
|
|
|
|
|
if (div == null) return false;
|
|
|
|
|
|
|
|
|
|
var inputs = div.getElementsByTagName("input");
|
|
|
|
|
for(a=0; a<inputs.length; a++)
|
|
|
|
|
{
|
|
|
|
|
if (inputs[a].getAttribute("name") == "author")
|
|
|
|
|
{
|
|
|
|
|
if (inputs[a].value == '')
|
|
|
|
|
{
|
|
|
|
|
alert("Vous devez entrer un pseudo");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Remove space from textarea
|
|
|
|
|
var textareas = div.getElementsByTagName("textarea");
|
|
|
|
|
for(a=0; a<textareas.length; a++)
|
|
|
|
|
{
|
|
|
|
|
if (textareas[a].value == "")
|
|
|
|
|
{
|
|
|
|
|
alert("Vous devez rentrer un commentaire");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
2012-12-10 19:30:25 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function handleKeyPress(e){
|
|
|
|
|
var key=e.keyCode || e.which;
|
|
|
|
|
if (key==13){
|
|
|
|
|
f = document.getElementById("search_form");
|
|
|
|
|
f.submit();
|
|
|
|
|
}
|
2020-04-06 10:32:09 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function switchMenu()
|
|
|
|
|
{
|
|
|
|
|
var menu = document.getElementById("menu");
|
|
|
|
|
var content = document.getElementById("content");
|
|
|
|
|
|
|
|
|
|
if (menu.style.display == "none" ||
|
|
|
|
|
menu.style.display == "")
|
|
|
|
|
{
|
|
|
|
|
menu.style.display = "block";
|
|
|
|
|
content.style.display = "none";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
menu.style.display = "none";
|
|
|
|
|
content.style.display = "block";
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-06-19 10:11:35 +02:00
|
|
|
|
|
|
|
|
|
function pannous_list_do_action(action)
|
|
|
|
|
{
|
|
|
|
|
var xhr = new XMLHttpRequest();
|
|
|
|
|
var email_elem = document.getElementById('pannous_email');
|
|
|
|
|
var uri = 'https://pannous.soutade.fr//rest/lists/blog/' + action + '?email=' + email_elem.value;
|
|
|
|
|
xhr.open('GET', encodeURI(uri));
|
|
|
|
|
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
|
|
|
|
|
xhr.addEventListener('readystatechange', function() {
|
|
|
|
|
if (xhr.readyState === XMLHttpRequest.DONE) {
|
|
|
|
|
if (this.status == 200) {
|
|
|
|
|
alert(xhr.responseText);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
alert("Error " + this.status);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
xhr.addEventListener('error', function(event) {
|
|
|
|
|
alert('Error ' + this.statusText);
|
|
|
|
|
});
|
|
|
|
|
xhr.send();
|
|
|
|
|
}
|
|
|
|
|
function pannous_list_subscribe() { pannous_list_do_action('subscribe'); }
|
|
|
|
|
function pannous_list_unsubscribe() { pannous_list_do_action('unsubscribe'); }
|
|
|
|
|
function clear_your_email() {
|
|
|
|
|
var email_elem = document.getElementById('pannous_email');
|
|
|
|
|
if (email_elem.value === 'Your email') email_elem.value = '';
|
|
|
|
|
}
|