Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <link rel="stylesheet" href="https://www.jqueryscript.net/demo/Flat-HTML5-Palette-Color-Picker-For-jQuery-colorPick-js/colorPick.css">
- <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
- <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.0/css/all.css" integrity="sha384-lZN37f5QGtY3VHgisS14W3ExzMWZxybE1SJSEsQp9S+oqd12jhcu+A56Ebc1zFSJ" crossorigin="anonymous">
- <!-- complete code -->
- </head>
- <body>
- <div class=" container">
- <div class="row">
- <div class=" col-sm-1 ">
- <button class=" btn btn-primary picker ">change color 1</button>
- </div>
- <div id="bgcolor" class=" col-sm-11 show_color ">
- <span id="clicker" onclick="checkme();">this is strike</span>
- </div>
- </div>
- <div class="row pt-2">
- <div class=" col-sm-1 ">
- <button class=" btn btn-primary picker ">change color 1</button>
- </div>
- <div id="bgcolor" class=" col-sm-11 show_color ">
- <span id="clicker" onclick="checkme();">this is strike</span>
- </div>
- </div>
- </div>
- <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
- <script src="https://www.jqueryscript.net/demo/Flat-HTML5-Palette-Color-Picker-For-jQuery-colorPick-js/colorPick.js"></script>
- <script>
- var setup = {};
- // just to keep things together
- //switch the clicker states
- function checkme() {
- console.log(setup.check);
- if (setup.check === "true") {
- setup.check = "false"
- } else {
- setup.check = "true";
- }
- restoreclicker(setup.check);
- localStorage.setItem("check", setup.check);
- }
- // sets the hatml acc. clicker value
- function restoreclicker(value) {
- var clicker = document.getElementById("clicker");
- if (value === "false") {
- clicker.style.textDecoration = "line-through";
- /* clicker.innerHTML = "not clicked"; */
- } else {
- clicker.style.textDecoration = "none";
- /* clicker.innerHTML = "aaa"; */
- }
- }
- //restore box background
- function restorebg(bg) {
- setup.bg = bg;
- var box = document.getElementById("bgcolor");
- box.style.backgroundColor = setup.bg;
- }
- $(document).ready(function() {
- $(".picker").colorPick({
- 'initialColor': 'onColorSelected',
- 'palette': ["#1abc9c", "#16a085", "#2ecc71", "#27ae60", "#3498db", "#2980b9", "#9b59b6", "#8e44ad", "#34495e", "#2c3e50", "#f1c40f", "#f39c12", "#e67e22", "#d35400", "#e74c3c", "#c0392b", "#ecf0f1"],
- 'onColorSelected': function() {
- console.log("The user has selected the color: " + this.color);
- $('.show_color').css('backgroundColor', this.color);
- setup.bg = this.color;
- // store bg temprary
- localStorage.setItem("bg", setup.bg);
- }
- });
- });
- //restore settings on page load
- if (localStorage.check) {
- setup.check = localStorage.check;
- restoreclicker(setup.check);
- } else {
- setup.check = "false"
- localStorage.setItem("check", "false");
- }
- if (localStorage.bg) {
- setup.bg = localStorage.bg;
- restorebg(setup.bg);
- }
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement