PageRenderTime 61ms CodeModel.GetById 33ms RepoModel.GetById 1ms app.codeStats 0ms

/example.html

https://gitlab.com/ja4nm/cookiebar
HTML | 120 lines | 107 code | 13 blank | 0 comment | 0 complexity | 68f4844c0b5846c0b7c7dbdf8a3a2c89 MD5 | raw file
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8" />
  5. <title>Cookiebar test</title>
  6. <link rel="stylesheet" href="cookiebar.css" />
  7. <style type="text/css">
  8. body{
  9. margin: 0;
  10. padding: 0;
  11. font-family: sans-serif;
  12. }
  13. #areCookiesEnabled{
  14. margin: 30px;
  15. }
  16. </style>
  17. <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
  18. <script type="text/javascript" src="cookiebar.js"></script>
  19. <script type="text/javascript">
  20. $(document).ready(function(){
  21. /**
  22. * Simple example 1
  23. */
  24. //Cookiebar.load($("#cookiebar_holder"));
  25. /**
  26. * Simple example 2
  27. */
  28. /*
  29. Cookiebar.init({
  30. text: "This website uses cookies.",
  31. confirmText: "ok",
  32. confirmButton: true,
  33. closeButton: false
  34. });
  35. Cookiebar.load($("#cookiebar_holder"));
  36. */
  37. /**
  38. * Full example with all available options
  39. */
  40. Cookiebar.init({
  41. //cookiebar message
  42. text: 'Please enable <a href="more.html" target="_blank">cookes</a>.',
  43. //confirm button text
  44. confirmText: "ok",
  45. //close button text
  46. closeText: "close",
  47. //show confirm button
  48. confirmButton: true,
  49. //show close button
  50. closeButton: true,
  51. //refresh page after close/confirm button click
  52. refresh: false,
  53. //keep showing cookiebar until user enables cookies
  54. preserve: false,
  55. //cookiebar cookie expiration date (if "usePhp" is true, also change constant EXPIRE_DAYS in cookiebar.php)
  56. expireDays: 365,
  57. //cookie name for cookiebar (you can leave these at the default value)
  58. cookieName: "cookiebar_enabled",
  59. //set and get cookies using php (you probability wont need this)
  60. usePhp: false,
  61. //link to php script (useful only if "usePhp" is true)
  62. phpUrl: "http://localhost/cookiebar.php",
  63. //on load callback
  64. onLoad: function(){
  65. Cookiebar.slideDown();
  66. console.log("Cookiebar onLoad!");
  67. },
  68. //on confirm clallback
  69. onConfirm: function(){
  70. Cookiebar.slideUp();
  71. console.log("Cookiebar onConfirm!");
  72. },
  73. //on close callback
  74. onClose: function(){
  75. Cookiebar.slideUp();
  76. console.log("Cookiebar onClose!");
  77. }
  78. });
  79. Cookiebar.load($("#cookiebar_holder"));
  80. /**
  81. * Check if cookies are enabled
  82. */
  83. $("#areCookiesEnabled").click(function () {
  84. if(Cookiebar.areCookiesEnabled()){
  85. alert("Cookies are enabled.");
  86. }else {
  87. alert("Cookies are not enabled.");
  88. }
  89. //if "usePhp" is true you need to use callback to check if cookies are enabled
  90. /*
  91. Cookiebar.areCookiesEnabled(function (enabled) {
  92. alert(enabled);
  93. });
  94. */
  95. });
  96. /**
  97. * Set cookies enabled
  98. */
  99. //Cookiebar.setCookiesEnabled(true);
  100. });
  101. </script>
  102. </head>
  103. <body>
  104. <div id="cookiebar_holder"></div>
  105. <input type="button" value="Are cookies enabled?" id="areCookiesEnabled" />
  106. </body>
  107. </html>