Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $scope.etatBloc = {};
- setupEtatBloc();
- function setupEtatBloc(){
- // read cookie
- // For each bloc
- for(var i = 0; i < $scope.etatBloc.length; i++) {
- id = $scope.etatBloc[i];
- // IF we have the id block element in the cookie
- if (getCookie(id) === "true" || getCookie(id) === "" ) {
- $scope.etatBloc[i] = true
- } else {
- $scope.etatBloc[i] = false
- }
- }
- //build var
- $scope.etatBloc = {
- "partInfoContent" : false,
- "blocInfoUsager" : true,
- "preconisationBloc" : true,
- "partEvalAjust" : true,
- "finalRelBloc" : true,
- "blocNds" : false,
- "partReferentiel" : false,
- "partEvaluation" : false,
- "listPointDot" : false,
- "blocInfoContact" : false
- };
- }
- $scope.onBlocDisplayClick = function(nomBloc){
- $scope.etatBloc[nomBloc] = !$scope.etatBloc[nomBloc];
- // save in cookie
- setCookie($scope.etatBloc[nomBloc], $scope.etatBloc[nomBloc] === true ? "true" : "false", 365);
- // TODO
- };
- // Set the cookie
- function setCookie(cname, cvalue, exdays) {
- var d = new Date();
- d.setTime(d.getTime() + (exdays*24*60*60*1000));
- var expires = "expires="+ d.toUTCString();
- document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
- }
- // get / read the cookie
- function getCookie(cname) {
- var name = cname + "=";
- var decodedCookie = decodeURIComponent(document.cookie);
- var ca = decodedCookie.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 "";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement