I don't know much about javascript. I am trying to add a new cookie if only cookie EUcookieAccept is true. I am not sure where and how to put if statement. Could someone help me plaase how to do this. Thank you.
The javascript allows the user the change the size and colour of the site. I don't any cookies wten unitl the user Accept and happy to receive all cookies from website.
Here is the code.
$(document).ready(function() {
var startSize = $.cookie('fontSize');
var startSize = parseFloat(startSize);
var originalFontSize = $('html,body').css('font-size');
var user = getCookie("EUcookieAccept");
if (EUcookieAccept == "true") {
$('html,body').css('font-size', startSize);
$('#increaseFont').click(function() {
curSize = parseInt($('html,body').css('font-size')) + 8;
if (curSize <= 40) {
$('html,body').css('font-size', curSize);
$.cookie("fontSize", curSize, { path: '/', expires: 7 } );
}
} ) ;
$('#resetFont').click(function() {
$('html,body').css('font-size', '14px');
$.cookie("fontSize", "14", { path: '/', expires: 7 } );
} );
$('#decreaseFont').click(function() {
curSize = parseInt($('html,body').css('font-size')) - 8;
if (curSize >= 14) {
$('html,body').css('font-size', curSize);
$.cookie("fontSize", curSize, { path: '/', expires: 7 } );
} );
} } );
function getCookie(cname) {
var name = cname + "=";
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);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return "";
}
<button id="play">Play Speech</button>
<button id="pause">Pause Speech</button>
<button id="stop">Stop / Reset Speech</button>
<button id="texticn">Stop / Reset Speech</button>
<button id="decreaseFont">Text Smaller</button>
<button id="increaseFont">Text Bigger</button>
<button id="resetFont">Rest text size</button>
<!-- Naimbh here are the buttons -->
<button id="NornalCSS" onclick="switcher('NornalCSS')">Dark Background and white tex</button>
<button id="BlueCSS" onclick="switcher('BlueCSS')">Blue Background and black text</button>
<button id="YellowCSS" onclick="switcher('YellowCSS')">Yellow Background and black text</button>
<button id="WhiteCSS" onclick="switcher('WhiteCSS')">White Background and black text</button>
Aucun commentaire:
Enregistrer un commentaire