Advertisement
Guest User

Untitled

a guest
Oct 6th, 2015
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JSON 1.99 KB | None | 0 0
  1. /*
  2. ** code by tomal
  3. ** 2015
  4. */
  5.  
  6. $('document').ready(function(){
  7.     $('head').append('<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">');
  8.     $('.grid_5').html('<p style="color: black" align="right">Масштаб <span style="cursor: pointer" class="plus" onclick="plus()"><i class="fa fa-plus"></i></span> <span style="cursor: pointer" class="minus" onclick="minus()"><i class="fa fa-minus"></i></span> (+<span class="counter">0</span>0%)</p>');
  9.     var zoom = getCookie('zoom');
  10.     if(zoom != null){
  11.         $('.counter').text(zoom);
  12.         $('body').css('zoom', 1+(zoom/10));
  13.     }
  14. });
  15.  
  16. function plus(){
  17.     if(parseInt($('.counter').text()) < 10){
  18.         var count = parseInt($('.counter').text())+1;
  19.         $('.counter').text(count);
  20.         setzoom(count);
  21.     }
  22. }
  23.  
  24. function minus(){
  25.     if(parseInt($('.counter').text()) != 0){
  26.         var count = parseInt($('.counter').text())-1;
  27.         $('.counter').text(count);
  28.  
  29.         setzoom(count);
  30.     }
  31. }
  32.  
  33. function setzoom(value){
  34.     $('body').css('zoom', 1+(value/10));
  35.     setCookie("zoom", value, 300, "/");
  36. }
  37.  
  38. function setCookie(name, value, expiredays, path, domain, secure) {
  39.    if (expiredays) {
  40.       var exdate=new Date();
  41.       exdate.setDate(exdate.getDate()+expiredays);
  42.       var expires = exdate.toGMTString();
  43.    }
  44.    document.cookie = name + "=" + escape(value) +
  45.    ((expiredays) ? "; expires=" + expires : "") +
  46.    ((path) ? "; path=" + path : "") +
  47.    ((domain) ? "; domain=" + domain : "") +
  48.    ((secure) ? "; secure" : "");
  49. }
  50.  
  51. function getCookie(name) {
  52.    var cookie = " " + document.cookie;
  53.    var search = " " + name + "=";
  54.    var setStr = null;
  55.    var offset = 0;
  56.    var end = 0;
  57.    if (cookie.length > 0) {
  58.       offset = cookie.indexOf(search);
  59.       if (offset != -1) {
  60.          offset += search.length;
  61.          end = cookie.indexOf(";", offset)
  62.          if (end == -1) {
  63.             end = cookie.length;
  64.          }
  65.          setStr = unescape(cookie.substring(offset, end));
  66.       }
  67.    }
  68.    return setStr;
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement