Guest User

Untitled

a guest
Aug 27th, 2016
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. cookieInfo = {
  2. createDiv: function () {
  3. var banner = $(
  4. '<aside id="cookieConsent"><div class="container-fluid"><div class="row sep-top-xxs sep-bottom-xxs"><div class="col-xs-9 col-sm-10"><p class="no-margin">W ramach naszej witryny stosujemy pliki cookies w celu świadczenia usług na najwyższym poziomie.</p></div><div class="col-xs-3 col-sm-2"><button type="button" class="btn btn-primary btn-xs btn-block" onclick="cookieInfo.createCookie(cookieConsent, 1, 365)">OK</button></div></div></div></aside>'
  5. )
  6. $('body').append(banner)
  7. $('#cookieConsent').hide().fadeIn()
  8. },
  9.  
  10. createCookie: function (name, value, days) {
  11. var expires = ''
  12. if (days) {
  13. var date = new Date()
  14. date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000))
  15. expires = '; expires=' + date.toGMTString()
  16. }
  17. document.cookie = name + '=' + value + expires + '; path=/'
  18. $('#cookieConsent').fadeOut()
  19. },
  20.  
  21. checkCookie: function (name) {
  22. var nameEQ = name + '='
  23. var ca = document.cookie.split(';')
  24. for (var i = 0; i < ca.length; i++) {
  25. var c = ca[i]
  26. while (c.charAt(0) == ' ')
  27. c = c.substring(1, c.length)
  28. if (c.indexOf(nameEQ) == 0)
  29. return c.substring(nameEQ.length, c.length)
  30. }
  31. return null
  32. },
  33.  
  34. init: function () {
  35. if (this.checkCookie(cookieConsent) != 1)
  36. this.createDiv()
  37. }
  38. }
  39.  
  40. $(document).ready(function () {
  41. cookieInfo.init()
  42. })
Add Comment
Please, Sign In to add comment