/** * Admin Sticky Notes * License: GPLv2 or later * License URI: http://www.gnu.org/licenses/gpl-2.0.txt * * @author Farhan Girach * @copyright Copyright (c) 2017, Farhan Girach **/ var dom = "
"; document.write(dom); var notes, count = 0; // save the notes into local storage function saveNotes() { //jQuery( "#notes li" ).draggable(); var notesArray = []; // for each of the notes add a bespoke note object to the array notes.find("li > div").each(function (i, e) { // save the class attribute of the div, as well as the text for the title and content text areas var colourClass = jQuery(e).attr("class"); var title = jQuery(e).find("textarea.note-title"); var content = jQuery(e).find("textarea.note-content"); notesArray.push({ Index: i, Title: title.val(), Content: content.val(), Class: colourClass }); }); // json encode it var jsonStr = JSON.stringify(notesArray); // and save the json string into local storage localStorage.setItem("notes", jsonStr); } // add event handlers to a note function addNoteEvent(noteElement) { var div = noteElement.children("div"); var closeImg = div.find("span"); div.focus(function () { closeImg.removeClass("hide"); }); div.children().focus(function () { closeImg.removeClass("hide"); }); div.hover(function () { closeImg.removeClass("hide"); }, function () { closeImg.addClass("hide"); saveNotes(); }); div.children().hover(function () { closeImg.removeClass("hide"); }, function () { closeImg.addClass("hide"); }); } // adds a new note to the 'notes' list function addNewNote(className, title, content) { // if class is not specified, use a random colour class if (!className) { className = "colour" + Math.ceil(Math.random() * 6); } // add a new note to the end of the list notes.append("
  • " + "