diff --git a/README.md b/README.md index ca4bddd..1b44a5e 100644 --- a/README.md +++ b/README.md @@ -245,7 +245,9 @@ If you like the tool and wish it developed further with more functions and easie * v1.0.4 2021-xx-xx: — **Game Completion Essentials** additions: - ✅ Acid Drained Waterways + ✅ Acid Drained Waterways + + — Backwards Compatibility with Hollow Knight version 1.0.0.6 save files (February 2017 release version). ## Using diff --git a/src/js/cookiealert.js b/src/js/cookiealert.js new file mode 100644 index 0000000..3fc72ae --- /dev/null +++ b/src/js/cookiealert.js @@ -0,0 +1,104 @@ +/*! + * CookieAlert v1.2 + * http://cookiealert.sruu.pl/ + * + * Created by Paweł Klockiewicz + * http://klocus.pl/ + */ +var CookieAlert = { + defines: { + divID: 'CookieAlert', + cookieName: 'agreeCookies', + cookieValue: 'yes', + cookieExpire: 3 + }, + options: { + style: 'dark', + position: 'bottom', + opacity: 1, + displayTime: 0, + text: 'This website uses cookies. By using this website you agree to store and read them depending on your browser\'s settings.', + cookiePolicy: 'https://www.allaboutcookies.org/' + }, + setCookie: function (name, value, expire) { + document.cookie = name + "=" + escape(value) + ((expire === null) ? "" : ("; expires=" + expire.toGMTString())) + "; path=/"; + }, + checkCookie: function (name) { + if (document.cookie !== "") { + var toCookie = document.cookie.split("; "); + for (let i = 0; i < toCookie.length; i++) { + var CookieName = toCookie[i].split("=")[0]; + var CookieValue = toCookie[i].split("=")[1]; + if (CookieName == name) return unescape(CookieValue); + } + } + }, + removeDiv: function (divID) { + var div = document.getElementById(divID); + document.body.removeChild(div); + var expire = new Date(); + expire.setMonth(expire.getMonth() + this.defines.cookieExpire); + this.setCookie(this.defines.cookieName, this.defines.cookieValue, expire); + }, + fadeOut: function (opacity, divID) { + let div = document.getElementById(divID); + div.style.opacity = opacity / 100; + div.style.filter = 'alpha(opacity=' + opacity + ')'; + if (opacity == 1) { + div.style.display = 'none'; + } + }, + init: function (options) { + var CA = CookieAlert; + window.onload = function () { + /* Override standard options */ + for (var key in options) { + CA.options[key] = options[key]; + } + + /* Create div with alert */ + var div = document.createElement('div'); + div.setAttribute('id', CA.defines.divID); + + /* Add style to created div */ + var style = 'position:fixed;' + CA.options.position + ':-1px;left:0px;right:0px;width:100%;min-height:50px;z-index:1110;padding:10px;font-family:\'Lato\', sans-serif;font-size:14px;opacity:' + CA.options.opacity + ';'; + switch (CA.options.style) { + case 'light': + style += 'background-color:#FFF; color:#373737; text-shadow: 1px 1px 0px rgba(0,0,0,0.1); border-top:1px solid #ccc; border-bottom:1px solid #ccc; box-shadow:0px 0px 8px rgba(0, 0, 0, 0.15);'; + break; + case 'dark': + style += 'background-color:#1b1b1b; color:#FF6600; border-top:1px solid #444; border-bottom:1px solid #444;'; + break; + } + div.setAttribute('style', style); + + /* Buttons */ + var buttons = '
'; + buttons += ''; + buttons += ''; + buttons += '
'; + + /* Add content to created div */ + var content = '
' + CA.options.text + '
' + buttons; + div.innerHTML = content; + + /* Add div with alert to website */ + if (CA.checkCookie(CA.defines.cookieName) != CA.defines.cookieValue) { + document.body.appendChild(div); + document.getElementById('CookieAlertClose').addEventListener('click', function () { + CA.removeDiv(CA.defines.divID); + }, false); + if (CA.options.displayTime > 0) { + setTimeout(function () { + for (var i = 100; i >= 1; i--) { + setTimeout("CookieAlert.fadeOut(" + i + ", CookieAlert.defines.divID)", (i - 100) * -1 * 5); + } + }, CA.options.displayTime); + } + } + } + } + +}; + +window.CookieAlert = CookieAlert; \ No newline at end of file diff --git a/src/partials/cookiealert.html b/src/partials/cookiealert.html new file mode 100644 index 0000000..2e5ab3b --- /dev/null +++ b/src/partials/cookiealert.html @@ -0,0 +1,121 @@ + \ No newline at end of file diff --git a/webpack.dev.js b/webpack.dev.js index d8e345e..fbaa933 100644 --- a/webpack.dev.js +++ b/webpack.dev.js @@ -1,5 +1,6 @@ /* global require module __dirname */ const HtmlWebpackPlugin = require('html-webpack-plugin'); +const HtmlWebpackPartialsPlugin = require('html-webpack-partials-plugin'); const MiniCssExtractPlugin = require('mini-css-extract-plugin'); const { CleanWebpackPlugin @@ -26,6 +27,12 @@ module.exports = { chunks: ['index'], filename: 'index.html', favicon: "./src/favicon.png" + }), + new HtmlWebpackPartialsPlugin({ + path: './src/partials/cookiealert.html', + location: 'head', + priority: 'high', + options: {} }) ], module: {