From 87f4bfc7a7df88a5636d9255c70cd340557d6218 Mon Sep 17 00:00:00 2001 From: KIMB-technologies Date: Sun, 31 Mar 2019 17:38:13 +0200 Subject: [PATCH] Fixed #12 --- system/index.php | 2 + system/load/devjs/cla_enc.js | 55 ++++++++++++++++++++++++ system/load/devjs/fun_authCodeManager.js | 11 ++++- system/load/devjs/fun_list.js | 27 +++++++++--- system/load/devjs/fun_maker.js | 47 +++++++++++++++----- system/load/devjs/globals.js | 3 ++ system/load/notes.dev.css | 4 ++ system/load/notes.dev.js | 2 + system/load/notes.min.css | 2 +- system/load/notes.min.js | 2 +- system/php/list.php | 5 ++- system/php/systemInit.php | 2 +- 12 files changed, 138 insertions(+), 24 deletions(-) create mode 100644 system/load/devjs/cla_enc.js diff --git a/system/index.php b/system/index.php index 594f5a2..b172d3d 100644 --- a/system/index.php +++ b/system/index.php @@ -185,6 +185,8 @@
+ +
diff --git a/system/load/devjs/cla_enc.js b/system/load/devjs/cla_enc.js new file mode 100644 index 0000000..40f3661 --- /dev/null +++ b/system/load/devjs/cla_enc.js @@ -0,0 +1,55 @@ +/** + * Diese Klasse dient Notizen zu ver- und entschluesseln. + */ +class NotesEncrypter{ + + /** + * >> Konstruktor << + * lädt Daten aus dem localStorage sofern verfügbar. + */ + constructor(){ + if( localStorage.getItem("notes_encrypt_data") !== null ){ + this.data = JSON.parse( localStorage.getItem("notes_encrypt_data") ); + } + else{ + this.data = { + password : "", + status : false + }; + } + } + + setNotesPassword( password ){ + this.data.password = sjcl.codec.hex.fromBits( sjcl.hash.sha256.hash( password + "bu79ubwqrzbIgbuwiw" ) ); + this.data.status = true; + this.saveLocalStorage(); + } + + requestForPassword(){ + if(!this.data.status){ + errorMessage( "Es ist kein Passwort zum Verschlüsseln von Notizen angegeben.", 20 ); + } + } + + encryptNote(text){ + if(!this.data.status){ + return text; + } + return JSON.stringify( sjcl.encrypt(this.data.password, text ) ); + } + + decryptNote(text){ + if(!this.data.status){ + return text; + } + return sjcl.decrypt(this.data.password, JSON.parse( text ) ); + } + + /** + * >> PRIVATE << + * Die internen Daten im localStorage ablegen. + */ + saveLocalStorage(){ + localStorage.setItem("notes_encrypt_data", JSON.stringify( this.data ) ); + } +} \ No newline at end of file diff --git a/system/load/devjs/fun_authCodeManager.js b/system/load/devjs/fun_authCodeManager.js index 3f450f2..4618872 100644 --- a/system/load/devjs/fun_authCodeManager.js +++ b/system/load/devjs/fun_authCodeManager.js @@ -59,7 +59,9 @@ function authCodeManager(){ +' Bitte geben Sie das Passwort ein!
' +'' +'
'; - + html += '

Passwort zur Verschlüsselung von Notizen

' + +' Bitte geben Sie ein Passwort zur Verschlüsselung der Notizen ein!
' + +''; dialogSetContent( html ); //Passwort Button aus @@ -130,6 +132,13 @@ function authCodeManager(){ $( "button#newPasswordSet" ).prop('disabled', true); } }); + $( "input.noteEncPassw" ).on( 'keyup', function (){ + $( "button#noteEncPasswSet" ).prop('disabled', $( "input.noteEncPassw" ).val().length < 4); + }); + $("button#noteEncPasswSet").click( function(){ + systemEncrypter.setNotesPassword( $( "input.noteEncPassw" ).val() ); + $( "button#noteEncPasswSet" ).prop('disabled', true); + }); //Löschen von Authcodes $( "button.deleteAuthLink" ).click( function () { diff --git a/system/load/devjs/fun_list.js b/system/load/devjs/fun_list.js index 628657a..e570458 100644 --- a/system/load/devjs/fun_list.js +++ b/system/load/devjs/fun_list.js @@ -9,7 +9,7 @@ function list(){ //Eine bestimmte Notiz zuletzt geöffnet, dann zu dieser zurückkehren if( localStorage.getItem( "note_maker_reopen" ) != null && localStorage.getItem( "note_maker_reopen" ) != 'none' ){ var lastopend = JSON.parse( localStorage.getItem( "note_maker_reopen" ) ); - maker( lastopend.noteid, lastopend.name ); + maker( lastopend.noteid, lastopend.name, void 0, void 0, lastopend.enc ); } @@ -79,7 +79,9 @@ function list(){ // alle durchgehen $.each( notes, function(k,v){ //anfügen - table += '
  • '+ v.name +' ' + table += '
  • ' + v.name + + ( v.enc ? '' : '' ) + + ' ' + '' + '' + '' @@ -136,9 +138,16 @@ function list(){ $( "div.noteslist div.listpart div.list ul li span.notesnames" ).off('click').click(function(){ var noteid = $( this ).parent().attr( "noteid" ); var name = $( this ).text(); + var enc = $( this ).parent().attr( "enc" ) === 'true'; //Notiz zeigen console.log( 'Oeffne: "'+ name + '" ("' + noteid + '")' ); - maker( noteid, name ); + if(enc){ + systemEncrypter.requestForPassword(); + if( !systemEncrypter.data.status ){ + return; + } + } + maker( noteid, name, void 0, void 0, enc ); }); if( systemOfflineMode ){ @@ -168,9 +177,13 @@ function list(){ ); }); } - - - + $("div.noteslist div.toolbar span.encrypt-note").off('click').click(function(){ + $("div.noteslist div.toolbar span.encrypt-note").toggleClass( 'disable' ); + if( !$("div.noteslist div.toolbar span.encrypt-note.ui-icon-locked").hasClass( 'disable' ) ){ + systemEncrypter.requestForPassword(); + } + }); + $("div.noteslist div.toolbar span.encrypt-note").tooltip(); } //Neue Notiz @@ -179,7 +192,7 @@ function list(){ $( "div.noteslist div.listpart div.loading" ).removeClass( "disable" ); ajax_request( "list", - {"userid" : userinformation.id, "name" : name }, + {"userid" : userinformation.id, "name" : name, "enc" : !$("div.noteslist div.toolbar span.encrypt-note.ui-icon-locked").hasClass( 'disable' ) }, function ( data ) { $( "div.noteslist div.listpart div.loading" ).addClass( "disable" ); if( data.status === 'okay' ){ diff --git a/system/load/devjs/fun_maker.js b/system/load/devjs/fun_maker.js index a31fb8c..4ef8c7f 100644 --- a/system/load/devjs/fun_maker.js +++ b/system/load/devjs/fun_maker.js @@ -1,9 +1,17 @@ var cm_editor; //Notesmaker -function maker(noteid, notename, sharecont, savecallback) { +function maker(noteid, notename, sharecont, savecallback, encrypted) { //sharecont enthält Freigabeinhalt, wenn Freigabe geladen werden soll //savecallback ist Funktion um veränderungen des Shares zu speichern + //encrypted gibt an, eine verschluesselte Dateie zu oeffnen + + if( typeof encrypted === "undefined" || encrypted !== true ){ + encrypted = false; + } + if(encrypted){ + $("button#publishnote").prop('disabled', true); + } // Erstelle zwei Variablen, die Zustand darstellen if (typeof sharecont === "undefined") { @@ -11,7 +19,7 @@ function maker(noteid, notename, sharecont, savecallback) { var shareeditable = false; //diese Notiz als geöffnete speichern - localStorage.setItem("note_maker_reopen", JSON.stringify({ noteid: noteid, name: notename })); + localStorage.setItem("note_maker_reopen", JSON.stringify({ noteid: noteid, name: notename, enc: encrypted })); } else { if (typeof savecallback === "function") { @@ -114,11 +122,23 @@ function maker(noteid, notename, sharecont, savecallback) { //neue Notiz (dann Server noch leer) if (!data.data.empty) { + var cont = data.data.content; + if( encrypted ){ + try { + cont = systemEncrypter.decryptNote( data.data.content ); + } catch (error) { + localStorage.setItem("note_maker_reopen", 'none'); + removeCodeMirrorListeners(); + list(); + setTimeout( () => { errorMessage('Kann Notiz nicht entschlüsseln!', 10); }, 200 ); + } + } + //Daten übernehmen notedata = { "name": data.data.name, "id": data.data.id, - "content": data.data.content, + "content": cont, "lastserverchanged": data.data.geandert }; @@ -141,12 +161,13 @@ function maker(noteid, notename, sharecont, savecallback) { } function removeCodeMirrorListeners(){ - //die EventListener weg machen - // Parser - cm_editor.off("change", here_parser_reparse); - // Speicherung - cm_editor.off("change", here_codemi_save); - + if( typeof cm_editor === "object" ){ + //die EventListener weg machen + // Parser + cm_editor.off("change", here_parser_reparse); + // Speicherung + cm_editor.off("change", here_codemi_save); + } //keine Notiz mehr geöffnet newerNoteOnServerFound = function (){}; } @@ -466,8 +487,12 @@ function maker(noteid, notename, sharecont, savecallback) { } else{ $("div.noteview div.loading").removeClass("disable"); + var cont = cm_editor.getValue(); + if(encrypted){ + cont = systemEncrypter.encryptNote(cont); + } ajax_request("view", - { "userid": userinformation.id, "noteid": noteid, "note": { "name": $("input#notename").val(), "cont": cm_editor.getValue() } }, + { "userid": userinformation.id, "noteid": noteid, "note": { "name": $("input#notename").val(), "cont": cont } }, function (data) { $("div.noteview div.loading").addClass("disable"); if ( @@ -679,7 +704,7 @@ function maker(noteid, notename, sharecont, savecallback) { //Dialog Inhalt bauen var html = ''; $.each(data.data, function (k, v) { - html += ''; + html += ''; html += '' }); html += '
    ÄnderungenZeitpunkt
    ' + v.diff + '
    ' + ( encrypted ? 'Kein Diff. bei verschlüsselten Notizen!' : v.diff ) + '' + v.time + '
    '; diff --git a/system/load/devjs/globals.js b/system/load/devjs/globals.js index 8dfe811..9f7d8fa 100644 --- a/system/load/devjs/globals.js +++ b/system/load/devjs/globals.js @@ -8,6 +8,9 @@ var errorMessageTimeOut = null; var systemOfflineMode = false; var systemOfflineManager = new OfflineManager(); +//Notizen verschluesseln +var systemEncrypter = new NotesEncrypter(); + //REST oder Session API? var systemRESTAPI = false; diff --git a/system/load/notes.dev.css b/system/load/notes.dev.css index ca90f23..a6bcc01 100644 --- a/system/load/notes.dev.css +++ b/system/load/notes.dev.css @@ -234,3 +234,7 @@ div#freigabeManagerDialog tr { font-family: Ubuntu, sans-serif; font-size: 1em; } + +.ui-icon-color-333{ + background-image: url(js-libs/images/ui-icons_333_256x240.png); +} diff --git a/system/load/notes.dev.js b/system/load/notes.dev.js index 0064f67..98ebd65 100644 --- a/system/load/notes.dev.js +++ b/system/load/notes.dev.js @@ -2,6 +2,7 @@ BUILD-NOTE: > $(function(){loginsys();if(isOpenedAsApp){displayAsApp();}}); >> devjs/cla_offlinemanager.js +>> devjs/cla_enc.js >> devjs/globals.js >> devjs/fun_loginsys.js >> devjs/fun_list.js @@ -65,6 +66,7 @@ var requireFiles = function () { requireFiles([ domain + "/load/devjs/cla_offlinemanager.js", + domain + "/load/devjs/cla_enc.js", domain + "/load/devjs/globals.js", domain + "/load/devjs/fun_loginsys.js", domain + "/load/devjs/fun_list.js", diff --git a/system/load/notes.min.css b/system/load/notes.min.css index 43aca6d..1e0e08d 100644 --- a/system/load/notes.min.css +++ b/system/load/notes.min.css @@ -1 +1 @@ -body,button,code,input,pre,textarea{font-size:100%}body,button,input,textarea{font-family:Ubuntu,sans-serif}input[readonly=readonly]{background-color:#ddd;border-radius:3px}code,pre{font-family:"Ubuntu Mono",monospace}body{background:url(notes_bg_sw.png) repeat scroll center top #010101;background-color:#010101;color:#000}h1,h2{border-bottom:1px solid #5d7}h1{font-size:1.8em;font-weight:700}h2{font-size:1.3em;font-type:italic}a,a:active,a:hover,a:visited{text-decoration:none;color:#00f}blockquote{margin:15px 0;margin-left:1.5em;padding-left:1.5em;border-left:.2em gray solid}code,pre{border-radius:3px;background-color:#f8f8f8;color:inherit}code{border:1px solid #eaeaea;margin:0 2px;padding:0 5px}pre{border:1px solid #ccc;line-height:1.25em;overflow:auto;padding:6px 10px}pre>code{border:0;margin:0;padding:0}ins{color:green;text-decoration:none;font-weight:700}del{color:red;text-decoration:line-through}.disable{display:none!important}.important{color:orange}.error{color:red;font-weight:700}.okay{color:green}.small{font-size:.8em}.message{margin:auto;text-align:center;border:2px solid #5d7;border-radius:5px;background-color:#eee;padding:5px;margin:5px}.box{margin:auto;border:2px solid #aaa;border-radius:5px;background-color:#eee;padding:5px;margin:5px}.loading{background:url(loader.gif) no-repeat center center;height:20px}div.main{margin:auto;max-width:1100px;min-width:300px;background-color:#fff;padding:10px;border-radius:15px;border:1px solid #5d7;box-shadow:5px 5px 5px #ddd;position:relative}div.logout{position:absolute;top:0;right:0;height:50px;width:200px}div.logout span.usertools{position:absolute;top:10px;right:10px}div.logout span.usertools span.ui-icon{display:inline-block}div.noteslist div.toolbar button#notesarchive{float:right}div.footer{text-align:center;padding:10px}div.footer a{color:#fff}button[art=star]{color:grey;margin-right:2px}.starrednote button[art=star]{color:#daa520}.starrednote{border-color:#daa520}.starrednote span.notesnames{font-weight:700}div#authCodeManagerDialog table,div#authCodeManagerDialog td,div#authCodeManagerDialog th,div#authCodeManagerDialog tr,div#freigabeManagerDialog table,div#freigabeManagerDialog td,div#freigabeManagerDialog th,div#freigabeManagerDialog tr,div#historyManagerDialog table,div#historyManagerDialog td,div#historyManagerDialog th,div#historyManagerDialog tr,div#mainAdminDialog table,div#mainAdminDialog td,div#mainAdminDialog th,div#mainAdminDialog tr,div#oldNotesDialog table,div#oldNotesDialog td,div#oldNotesDialog th,div#oldNotesDialog tr{border:1px solid #000;border-collapse:collapse}.CodeMirror{border:1px solid #000;height:auto}.CodeMirror-scroll{min-height:200px}.ui-widget,.ui-widget button,.ui-widget input,.ui-widget select,.ui-widget textarea{font-family:Ubuntu,sans-serif;font-size:1em} \ No newline at end of file +body,button,code,input,pre,textarea{font-size:100%}body,button,input,textarea{font-family:Ubuntu,sans-serif}input[readonly=readonly]{background-color:#ddd;border-radius:3px}code,pre{font-family:"Ubuntu Mono",monospace}body{background:url(notes_bg_sw.png) repeat scroll center top #010101;background-color:#010101;color:#000}h1,h2{border-bottom:1px solid #5d7}h1{font-size:1.8em;font-weight:700}h2{font-size:1.3em;font-type:italic}a,a:active,a:hover,a:visited{text-decoration:none;color:#00f}blockquote{margin:15px 0;margin-left:1.5em;padding-left:1.5em;border-left:.2em gray solid}code,pre{border-radius:3px;background-color:#f8f8f8;color:inherit}code{border:1px solid #eaeaea;margin:0 2px;padding:0 5px}pre{border:1px solid #ccc;line-height:1.25em;overflow:auto;padding:6px 10px}pre>code{border:0;margin:0;padding:0}ins{color:green;text-decoration:none;font-weight:700}del{color:red;text-decoration:line-through}.disable{display:none!important}.important{color:orange}.error{color:red;font-weight:700}.okay{color:green}.small{font-size:.8em}.message{margin:auto;text-align:center;border:2px solid #5d7;border-radius:5px;background-color:#eee;padding:5px;margin:5px}.box{margin:auto;border:2px solid #aaa;border-radius:5px;background-color:#eee;padding:5px;margin:5px}.loading{background:url(loader.gif) no-repeat center center;height:20px}div.main{margin:auto;max-width:1100px;min-width:300px;background-color:#fff;padding:10px;border-radius:15px;border:1px solid #5d7;box-shadow:5px 5px 5px #ddd;position:relative}div.logout{position:absolute;top:0;right:0;height:50px;width:200px}div.logout span.usertools{position:absolute;top:10px;right:10px}div.logout span.usertools span.ui-icon{display:inline-block}div.noteslist div.toolbar button#notesarchive{float:right}div.footer{text-align:center;padding:10px}div.footer a{color:#fff}button[art=star]{color:grey;margin-right:2px}.starrednote button[art=star]{color:#daa520}.starrednote{border-color:#daa520}.starrednote span.notesnames{font-weight:700}div#authCodeManagerDialog table,div#authCodeManagerDialog td,div#authCodeManagerDialog th,div#authCodeManagerDialog tr,div#freigabeManagerDialog table,div#freigabeManagerDialog td,div#freigabeManagerDialog th,div#freigabeManagerDialog tr,div#historyManagerDialog table,div#historyManagerDialog td,div#historyManagerDialog th,div#historyManagerDialog tr,div#mainAdminDialog table,div#mainAdminDialog td,div#mainAdminDialog th,div#mainAdminDialog tr,div#oldNotesDialog table,div#oldNotesDialog td,div#oldNotesDialog th,div#oldNotesDialog tr{border:1px solid #000;border-collapse:collapse}.CodeMirror{border:1px solid #000;height:auto}.CodeMirror-scroll{min-height:200px}.ui-widget,.ui-widget button,.ui-widget input,.ui-widget select,.ui-widget textarea{font-family:Ubuntu,sans-serif;font-size:1em}.ui-icon-color-333{background-image:url(js-libs/images/ui-icons_333_256x240.png)} \ No newline at end of file diff --git a/system/load/notes.min.js b/system/load/notes.min.js index 54e55d9..65dfce6 100644 --- a/system/load/notes.min.js +++ b/system/load/notes.min.js @@ -1 +1 @@ -$(function(){loginsys(),isOpenedAsApp&&displayAsApp()});class OfflineManager{constructor(){null!==localStorage.getItem("notes_offline_storage")?this.data=JSON.parse(localStorage.getItem("notes_offline_storage")):this.data={},this.status=null}statusChanged(t){!0!==this.status&&null!==this.status||t||this.pushToServer(),this.status=t}saveNote(t,a,e){this.status&&(this.data[t]={content:a,name:e},this.saveLocalStorage())}saveLocalStorage(){localStorage.setItem("notes_offline_storage",JSON.stringify(this.data))}pushToServer(){if("{}"==JSON.stringify(this.data))this.data={},this.saveLocalStorage();else if(0==this.status){var t=this;$.each(this.data,function(a,e){ajax_request("view",{userid:userinformation.id,noteid:a,note:{name:e.name,cont:e.content}},function(e){if($("div.noteview div.loading").addClass("disable"),"okay"===e.status){if(4==e.data.length){var s=JSON.parse(localStorage.getItem("note_autosave_"+a));s.lastserverchanged=e.data[3],localStorage.setItem("note_autosave_"+a,JSON.stringify(s))}delete t.data[a],t.saveLocalStorage()}})})}}}var userinformation={name:null,id:null,admin:!1,authcode:null},errorMessageTimeOut=null,systemOfflineMode=!1,systemOfflineManager=new OfflineManager,systemRESTAPI=!1;function review(e){$("div.login").addClass("disable"),$("div.noteview").addClass("disable"),$("div.noteslist").addClass("disable"),$("div.globalloader").addClass("disable"),$("div."+e).removeClass("disable")}function errorMessage(e,o){null!==errorMessageTimeOut&&clearTimeout(errorMessageTimeOut),null===e?($("div.global.error.message").html("Fehler!"),$("div.global.error.message").addClass("disable")):(void 0===o&&(o=10),$("div.global.error.message").html(e),$("div.global.error.message").removeClass("disable"),!1!==o&&(errorMessageTimeOut=setTimeout(function(){$("div.global.error.message").addClass("disable")},1e3*o)))}function ajax_request(e,o,s,a){if(systemRESTAPI&&("share"!=e||"login"!=e)||"auth"==e){var i="rest";void 0!==o.authcode&&null!=o.authcode||(o.authcode=userinformation.authcode)}else i="ajax";$.post(domain+"/"+i+".php?"+e,o,function(e){"object"==typeof e?("error"===e.status?console.log(e.error):(systemOfflineMode&&$("div.global.error.message").off("click"),systemOfflineMode=!1,systemOfflineManager.statusChanged(!1),errorMessage(null)),"function"==typeof s&&s(e)):(errorMessage("Sever antwortet nicht korrekt!",!1),"function"==typeof a&&a(e))}).fail(function(){errorMessage("Offlinemodus",!1),$("div.global.error.message").click(()=>{errorMessage("Neu verbinden ...",!1),ajax_request("login",{status:userinformation.id},()=>{},()=>{errorMessage("Offlinemodus",!1)})}),systemOfflineMode=!0,systemOfflineManager.statusChanged(!0),"function"==typeof s&&s({data:{}})})}function confirmDialog(e,o,s){if(void 0===o)o={OK:function(){},Abbrechen:function(){}};if(void 0===s)s="Wichtig!";$("div.globalDialog").removeClass("disable"),$("div.globalDialog").dialog({resizable:!1,height:"auto",width:"auto",minWidth:200,minHeight:150,modal:!0,title:s,close:function(){$("div.globalDialog").html(""),$("div.globalDialog").addClass("disable")},position:{my:"center",at:"center",of:$("div.main")},buttons:o});function a(e){$("div.globalDialog").html(e)}return a(e),a}let isOpenedAsApp="standalone"in window.navigator&&1==window.navigator.standalone||window.matchMedia("(display-mode: standalone)").matches;function displayAsApp(){$("body").css({background:"#f5f5f5"}),$("div.main").css({border:"none","box-shadow":"none"}),$("h1").css({"font-size":"1.2em"}),$("div.logout button#logout, div.logout span.small, div.footer a").css({display:"none"}),$("div.logout").css({height:"26px",width:"48px",position:"initial"}),$("div.logout").removeClass("box")}function loginsys(){$("div.nojs.error.message").remove();!function(){review("globalloader");var a=window.location.hash;""!=a?(a=a.substr(1),new RegExp("[^A-Za-z0-9]").test(a)?n():shareviewer(a,n)):n();function n(){review("login"),""!=localStorage.getItem("userinformation_id")&&null!=localStorage.getItem("userinformation_id")&&""!=localStorage.getItem("userinformation_name")&&null!=localStorage.getItem("userinformation_name")?(userinformation.id=localStorage.getItem("userinformation_id"),userinformation.name=localStorage.getItem("userinformation_name"),userinformation.admin=JSON.parse(localStorage.getItem("userinformation_admin")),""!=localStorage.getItem("userinformation_authcode")&&null!=localStorage.getItem("userinformation_authcode")?(userinformation.authcode=localStorage.getItem("userinformation_authcode"),systemRESTAPI=!0,i(),list()):($("div.login div.input div.loading").removeClass("disable"),ajax_request("login",{status:userinformation.id},function(o){$("div.login div.input div.loading").addClass("disable"),systemOfflineMode?(i(),list()):1==o.data?(i(),list()):e()}))):systemOfflineMode?o():e()}}();function e(){var e=window.location.hash;if(""!=e){e=e.substr(1);if(new RegExp("[a-z]+:[a-z0-9]+").test(e)){var a=e.split(":"),n=a[0],s=a[1];console.log('Versuche User "'+n+'" mit Loginlink einzuloggen.'),$("div.login div.input div.loading").removeClass("disable"),ajax_request("auth",{username:n,authcode:s},function(e){$("div.login div.input div.loading").addClass("disable"),"okay"===e.status?(userinformation.name=n,userinformation.id=e.data.id,userinformation.admin=e.data.admin,userinformation.authcode=s,localStorage.setItem("userinformation_id",userinformation.id),localStorage.setItem("userinformation_name",userinformation.name),localStorage.setItem("userinformation_admin",userinformation.admin),localStorage.setItem("userinformation_authcode",userinformation.authcode),systemRESTAPI=!0,i(),list()):o()})}else o()}else o()}function o(){systemOfflineMode?($("div.login p.message.important.offline").removeClass("disable"),$("div.login p.message.important.online").addClass("disable"),$("div.login div.input div#loginform").addClass("disable"),$("div.login div.input").addClass("disable")):(ajax_request("login",{status:userinformation.id},function(e){systemOfflineMode&&o()}),$("div.login p.message.important.offline").addClass("disable"),$("div.login p.message.important.online").removeClass("disable")),$("div.login p.message.error").addClass("disable"),$("div.login p.message.okay").addClass("disable"),$("div.login div.input div.loading").addClass("disable"),systemOfflineMode||($("div.login div.input div#loginform").removeClass("disable"),$("div.login div.input").removeClass("disable"),$("button#userlogin").off("click").click(e),$("input#userpassword").off("keyup").keyup(function(o){13==o.keyCode&&e()}));function e(){$("div.login div.input div.loading").removeClass("disable"),$("div.login div.input div#loginform").addClass("disable"),$("div.login p.message.important").addClass("disable");var e=sjcl.codec.hex.fromBits(sjcl.hash.sha256.hash($("input#userpassword").val()));ajax_request("login",{username:$("input#username").val(),password:e},function(e){$("div.login div.input div.loading").addClass("disable"),"error"===e.status?($("div.login p.message.error").removeClass("disable"),$("div.login div.input div#loginform").removeClass("disable")):"okay"===e.status&&($("div.login p.message.okay").removeClass("disable"),$("div.login p.message.error").addClass("disable"),$("div.login div.input").addClass("disable"),$("input#username").val(""),$("input#userpassword").val(""),userinformation.name=e.data.name,userinformation.id=e.data.id,userinformation.admin=e.data.admin,localStorage.setItem("userinformation_id",userinformation.id),localStorage.setItem("userinformation_name",userinformation.name),localStorage.setItem("userinformation_admin",userinformation.admin),i(),list())})}}function i(){var e=null;function o(){systemOfflineMode||systemRESTAPI||ajax_request("login",{logout:null},function(e){"okay"===e.status&&($("p.message.error.loggedout").removeClass("disable"),setTimeout(function(){$("p.message.error.loggedout").addClass("disable")},2e4))}),0==$("input#logouttype:checked").length?localStorage.clear():(localStorage.removeItem("userinformation_id"),localStorage.removeItem("userinformation_name"),localStorage.removeItem("userinformation_authcode"),localStorage.removeItem("userinformation_admin")),userinformation={name:null,id:null,admin:!1,authcode:null},systemRESTAPI=!1,window.location.hash="",null!==e&&clearInterval(e),errorMessage(null),"undefined"!=typeof cm_editor&&cm_editor.setValue("empty"),["input#userpassword","input#username","input#notename","div#notespreview","textarea#notesinput","input#newnotename","div.listpart div.list"].forEach(function(e){$(e).empty(),"textarea#notesinput"!==e&&$(e).val("")}),$("div.logout").addClass("disable"),loginsys()}function i(){$("div.logout span.usertools").tooltip(),systemOfflineMode?($("div.logout span.usertools span.ui-icon-wrench").addClass("disable"),$("div.logout span.usertools span.ui-icon-person").addClass("disable")):(userinformation.admin?($("div.logout span.usertools span.ui-icon-wrench").removeClass("disable"),$("div.logout span.usertools span.ui-icon-wrench").off("click").click(function(){$.ajax({type:"GET",url:domain+"/load/backend."+jsdevmin+".js",success:function(){adminDialog()},dataType:"script",cache:!0})})):$("div.logout span.usertools span.ui-icon-wrench").addClass("disable"),$("div.logout span.usertools span.ui-icon-person").off("click").click(function(){authCodeManager()}))}$("div.logout").removeClass("disable"),$("button#logout").off("click").click(o),e=setInterval(function(){if(null!=localStorage.getItem("note_maker_reopen")&&"none"!=localStorage.getItem("note_maker_reopen")){var e=JSON.parse(localStorage.getItem("note_maker_reopen"));ajax_request("view",{userid:userinformation.id,noteid:e.noteid,history:4},function(o){if("error"===o.status)errorMessage("Die Session ist abgelaufen!",!1);else if(null!=JSON.parse(localStorage.getItem("note_autosave_"+e.noteid))){var i=JSON.parse(localStorage.getItem("note_autosave_"+e.noteid)).lastserverchanged;o.data-i>5&&newerNoteOnServerFound()}})}else systemRESTAPI||ajax_request("login",{status:userinformation.id},function(e){1!=e.data&&errorMessage("Die Session ist abgelaufen!",!1)})},1e3*global_polling_secs),i();function a(){i(),$(document).off("ajaxComplete",a)}$(document).ajaxComplete(a)}}function list(){if(review("noteslist"),systemOfflineManager.pushToServer(),null!=localStorage.getItem("note_maker_reopen")&&"none"!=localStorage.getItem("note_maker_reopen")){var t=JSON.parse(localStorage.getItem("note_maker_reopen"));maker(t.noteid,t.name)}!function(){systemOfflineMode?t():($("div.noteslist div.listpart div.loading").removeClass("disable"),ajax_request("list",{userid:userinformation.id},function(s){$("div.noteslist div.listpart div.loading").addClass("disable"),"okay"===s.status?(localStorage.setItem("note_list_notes",JSON.stringify(s.data)),i(s.data)):t()},t));function t(){$("div.noteslist div.listpart div.loading").addClass("disable"),null!=localStorage.getItem("note_list_notes")&&i(JSON.parse(localStorage.getItem("note_list_notes")))}}();function i(t){systemOfflineMode?$("div.toolbar").addClass("disable"):($("div.toolbar").removeClass("disable"),$("button#newnote").off("click").click(function(){var t=$("input#newnotename").val();""!=t&&(i=t,$("div.noteslist div.listpart div.loading").removeClass("disable"),ajax_request("list",{userid:userinformation.id,name:i},function(t){$("div.noteslist div.listpart div.loading").addClass("disable"),"okay"===t.status&&(console.log('Notiz: "'+i+'" ("'+t.data.id+'") angelegt.'),list())}));var i}),$("button#notesarchive").off("click").click(function(){oldNotesManager()}));var i="
      ";$.each(t,function(s,e){i+='
    • '+e.name+'
    • "}),i+="
    ",$("div.noteslist div.listpart div.list").html(i),$("li.noteslist_notesnames").tooltip(),$("div.noteslist div.listpart div.list ul li.noteslist_notesnames").css({"line-height":"28px"}),$("span.noteseditbuttons").css({float:"right",cursor:"pointer"});function s(){$("div.noteslist div.listpart div.list ul li span.notesnames").css({display:"inline-block",cursor:"pointer",width:$("div.noteslist div.listpart div.list ul li").width()-$("div.noteslist div.listpart div.list ul li span.noteseditbuttons").width()-5+"px"});var t=$("button#notesarchive").width();$("div.toolbar").width()-(t+($("input#newnotename").width()+$("button#newnote").width()+36))<10?($("button#notesarchive").css("float","none"),$("div.toolbar").css("line-height","28px")):($("button#notesarchive").css("float","right"),$("div.toolbar").css("line-height","inherit")),$("div.noteslist div.listpart div.list ul").css({"list-style-type":"none","padding-left":$(document).width()<600?0:40})}list_first_load&&($(window).resize(()=>setTimeout(s,200)),list_first_load=!1),s(),setTimeout(s,300),$("div.noteslist div.listpart div.list ul li span.notesnames").off("click").click(function(){var t=$(this).parent().attr("noteid"),i=$(this).text();console.log('Oeffne: "'+i+'" ("'+t+'")'),maker(t,i)}),systemOfflineMode?$("span.noteseditbuttons").addClass("disable"):($("span.noteseditbuttons").removeClass("disable"),$("span.noteseditbuttons button").off("click").click(function(){var t=$(this).attr("art"),i=$(this).parent().parent().attr("noteid");$("div.noteslist div.listpart div.loading").removeClass("disable"),ajax_request("list",{userid:userinformation.id,art:t,noteid:i},function(s){$("div.noteslist div.listpart div.loading").addClass("disable"),"okay"===s.status&&(console.log('Notiz: "'+i+'" wurde '+("del"==t?"gelöscht":"up"==t?"nach oben verschoben":"nach unten verschoben")),list())})}))}}var list_first_load=!0;var cm_editor;function maker(e,t,a,i){if(void 0===a){var n=!1,o=!1;localStorage.setItem("note_maker_reopen",JSON.stringify({noteid:e,name:t}))}else{if("function"==typeof i)o=!0;else o=!1;n=!0}review("noteview");var r,d,s=!1,l=!1;function c(){cm_editor.off("change",u),cm_editor.off("change",g),newerNoteOnServerFound=function(){}}var u,g;function f(){d=sjcl.codec.hex.fromBits(sjcl.hash.sha256.hash(r.content)),localStorage.setItem("note_autosave_"+r.id,JSON.stringify(r)),$("input#notename").val(r.name),$("textarea#notesinput").text(r.content),"object"!=typeof cm_editor?cm_editor=CodeMirror.fromTextArea(document.getElementById("notesinput"),{mode:"gfm",lineNumbers:!0,theme:"default"}):cm_editor.setValue($("textarea#notesinput").val()),function(){var e=new marked.Renderer;e.heading=function(e,t){return""+e+""},e.link=function(e,t,a){return''+a+""},e.text=function(e){return(e=e.replace(/@(([0-9a-zA-Z]{1,8})[0-9a-zA-Z]*)/g,'@$2')).replace(/:(\S+):/g,'')},e.checkbox=function(e){return e?' ':' '},marked.setOptions({renderer:e,gfm:!0,tables:!0,smartLists:!0,smartypants:!0,highlight:function(e,t){if("tex"!=t)return-1!==["markup","css","clike","javascript","c","bash","cpp","csharp","ruby","git","ini","java","json","lua","markdown","matlab","objectivec","perl","php","python","r","sql","swift"].indexOf(t)?Prism.highlight(e,Prism.languages[t]):e;try{return katex.renderToString(e)}catch(e){return''+e.message+""}}});function t(e,t){var a=/(iPhone|iPod|iPad).*AppleWebKit/i.test(navigator.userAgent);if(a&&void 0!==t&&1===t.text.length&&/^[A-Z]$/.test(t.text[0])){var i=$(":focus");i.blur(),i.focus()}$("div#notespreview").html(marked(cm_editor.getValue())),$(".openothernote").off("click").click(function(){var e=$(this).attr("noteid");h(function(){c(),maker(e,"")})})}t(),n&&!o?$("div.input.box").addClass("disable"):($("div.input.box").removeClass("disable"),cm_editor.on("change",t));u=t}(),function(){$("span.noteunsaved").tooltip(),$("span.notesaved").tooltip();function e(){var e=Date.now()-3e4>v,t={name:$("input#notename").val(),id:r.id,content:cm_editor.getValue(),lastserverchanged:r.lastserverchanged};localStorage.setItem("note_autosave_"+r.id,JSON.stringify(t)),e?h():($("span.noteunsaved").removeClass("disable"),$("span.notesaved").addClass("disable"))}l&&(e(),l=!1);cm_editor.on("change",e),g=e,$("span.noteunsaved").off("click").click(h)}()}var v=0;function h(a){if(d!=sjcl.codec.hex.fromBits(sjcl.hash.sha256.hash(cm_editor.getValue()))||l){s?($("body").append('
    Beim Speichern der Notiz kann es eventuell zu Datenverlust kommen, da die aktuellste Version nicht vom Server geladen werden konnte!
    '),$("#dangerMessageNoteSave").dialog({resizable:!1,height:"auto",width:"auto",modal:!0,title:"Gefahr des Datenverlustes!",buttons:{"Trotzdem Speichern":function(){$(this).dialog("close"),s=!1,c()},"Erstmal nicht":function(){$(this).dialog("close")}},close:function(){$(this).remove()}})):c();function c(){n&&o?(v=Date.now(),i(cm_editor.getValue(),!1)):!1===n&&(systemOfflineMode?(systemOfflineManager.saveNote(e,cm_editor.getValue(),$("input#notename").val()),v=Date.now(),"function"==typeof a&&a(!0)):($("div.noteview div.loading").removeClass("disable"),ajax_request("view",{userid:userinformation.id,noteid:e,note:{name:$("input#notename").val(),cont:cm_editor.getValue()}},function(i){if($("div.noteview div.loading").addClass("disable"),"okay"===i.status){if(console.log('Notiz: "'+t+'" ("'+e+'") auf Server gespeichert.'),v=Date.now(),4==i.data.length){r.lastserverchanged=i.data[3];var n=JSON.parse(localStorage.getItem("note_autosave_"+e));n.lastserverchanged=i.data[3],localStorage.setItem("note_autosave_"+e,JSON.stringify(n))}$("span.notesaved").removeClass("disable"),$("span.noteunsaved").addClass("disable")}"function"==typeof a&&a("okay"===i.status)},function(e){"function"==typeof a&&a(!1)})))}}else"function"==typeof a&&a(!0)}!function(){function i(a,i){a||systemOfflineMode||(s=!0,errorMessage("Kann die aktuelle Version der Notiz nicht vom Server holen.",20)),null!=localStorage.getItem("note_autosave_"+e)?(r=JSON.parse(localStorage.getItem("note_autosave_"+e)),f()):systemOfflineMode?(confirmDialog("Die gewählte Notiz ist auf diesem Gerät leider nicht offline verfügbar!",{OK:function(){$(this).dialog("close")}},"Offlinemodus"),list()):(r={name:t,id:e,content:"# "+t+"\nUnd hier dann der Text!!\n",lastserverchanged:void 0!==i?i:0},f())}n?(r={name:t,id:e,content:a.content,lastserverchanged:a.lastchanged},$("div.noteview div.loading").addClass("disable"),f()):systemOfflineMode?($("div.noteview div.loading").addClass("disable"),i(!1)):($("div.noteview div.loading").removeClass("disable"),ajax_request("view",{userid:userinformation.id,noteid:e,history:2},function(e){$("div.noteview div.loading").addClass("disable"),"okay"===e.status?(l=e.data.empty,e.data.empty?i(!0,e.data.geandert):(r={name:e.data.name,id:e.data.id,content:e.data.content,lastserverchanged:e.data.geandert},f())):i(!1)},function(e){i(!1)}))}(),$("button#closenote").off("click").click(function(){c(),n&&o?i(cm_editor.getValue(),!0):n?(window.location.hash="",loginsys()):!1===n&&h(function(e){e?(localStorage.setItem("note_maker_reopen","none"),list()):($("body").append('
    Die Speicherung der Notiz auf dem Server schlug fehl!
    Wollen Sie den Editor verlassen und einen Verlust der Änderungen in Kauf nehmen oder abbrechen?
    '),$("#errorMessageNoteSave").dialog({resizable:!1,height:"auto",width:"auto",modal:!0,title:"Fehler beim Speichern!",buttons:{"Änderungen verwerfen":function(){localStorage.setItem("note_maker_reopen","none"),list(),$(this).dialog("close")},Abbrechen:function(){$(this).dialog("close")}},close:function(){$(this).remove()}}))})}),n||systemOfflineMode?($("button#publishnote").addClass("disable"),$("button#notehistory").addClass("disable")):($("button#publishnote").removeClass("disable"),$("button#notehistory").removeClass("disable"),$("button#publishnote").off("click").click(m),$("button#notehistory").off("click").click(b));function m(){function t(){errorMessage("Freigaben konnten nicht geladen werden."),$("div.noteview div.loading").addClass("disable")}$("div.noteview div.loading").removeClass("disable"),ajax_request("view",{userid:userinformation.id,noteid:e},function(a){if("okay"===a.status){var i='
    Konnte Aktion nicht durchführen.
    ',n=!1;$.each(a.data,function(e,t){n=!0,i+='',i+="",i+="",i+='",i+="",i+=''}),i+="
    LinkNameErstelltBearbeitenLetzter Aufruf (Anzahl)Löschen
    Aufrufen "+t.name+""+t.created+"'+t.edit+""+t.lastAccessed+" ("+t.accesses+")
    ",!1===n&&(i+="

    Noch keine Freigaben!

    "),i+='

    Neue Freigabe


    Bearbeiten erlauben Nur lesen
    ',$("body").append('
    '+i+"
    "),$("div.noteview div.loading").addClass("disable"),$("div#freigabeManagerDialog").dialog({resizable:!1,height:"auto",width:"auto",modal:!0,title:"Freigaben",close:function(){$(this).remove()},position:{my:"center",at:"center",of:$("div.main")}}),$("button.deleteFreigabe").click(function(){var t=$(this).attr("authcode");$("div.freigabeDialog.loading").removeClass("disable"),ajax_request("view",{userid:userinformation.id,noteid:e,share:{authcode:t,edit:"leer",name:"leer"}},function(e){"okay"===e.status?($("div#freigabeManagerDialog").dialog("close"),m()):($("div.freigabeDialog.loading").addClass("disable"),$("div.freigabeDialog.error").removeClass("disable"))})}),$("button#addFreigabe").click(function(){var t=$("input#freigabeManagerNewName").val(),a="true"==$("input#freigabeManagerNewEdit:checked").val();""!=t&&($("div.freigabeDialog.loading").removeClass("disable"),ajax_request("view",{userid:userinformation.id,noteid:e,share:{authcode:"leer",edit:a,name:t}},function(e){"okay"===e.status?($("div#freigabeManagerDialog").dialog("close"),m()):($("div.freigabeDialog.loading").addClass("disable"),$("div.freigabeDialog.error").removeClass("disable"))}))}),$("button.freigabeQR").click(function(){var e=$(this).attr("authcode"),t=domain+"/#"+e,a='

    Code: '+e+'

    URL:

    Link: Aufrufen

    ';$("body").append('
    '+a+"
    "),$("div#freigabeManagerQRDialog").dialog({resizable:!1,height:"auto",width:"auto",modal:!0,title:"Freigabelink",close:function(){$(this).remove()},position:{my:"center",at:"center",of:$("div.main")}}),new QRCode(document.getElementById("freigabeManagerQR"),t)})}else t()},t)}function b(){function t(){errorMessage("Notizverlauf konnte nicht geladen werden."),$("div.noteview div.loading").addClass("disable")}$("div.noteview div.loading").removeClass("disable"),ajax_request("view",{userid:userinformation.id,noteid:e,history:3},function(e){if("okay"===e.status){var a="";$.each(e.data,function(e,t){a+="",a+="'}),a+="
    ÄnderungenZeitpunkt
    "+t.diff+""+t.time+'
    ",$("body").append('
    '+a+"
    "),$("div.noteview div.loading").addClass("disable"),$("div#historyManagerDialog").dialog({resizable:!1,height:"auto",width:"auto",modal:!0,title:"Notizverlauf",close:function(){$(this).remove()},position:{my:"center",at:"center",of:$("div.main")}}),$("button.takeInputFromHistory").click(function(){var t=$(this).attr("key"),a=e.data[t].text;cm_editor.setValue(a),$("div#historyManagerDialog").dialog("close")})}else t()},t)}newerNoteOnServerFound=function(){!0,d==sjcl.codec.hex.fromBits(sjcl.hash.sha256.hash(cm_editor.getValue()))?(c(),maker(e,t)):(s=!0,confirmDialog("

    Die Notiz ist auf dem Server verändert worden.
    Wollen Sie die neue Version laden?

    Dadurch können Ihre Änderungen verloren gehen! Andernfalls die Änderungen auf dem Server.

    ",{Ja:function(){c(),maker(e,t),!1,$(this).dialog("close")},Nein:function(){s=!1,h(),!1,$(this).dialog("close")}},"Änderung auf Server"))}}var newerNoteOnServerFound=function(){};function authCodeManager(){function e(e){$("div#authCodeManagerDialog").html(e)}function a(a){var s='

    Authentifizierungslinks

    ';!1!==a?(s+="",a.forEach(function(e){s+=''}),s+="
    Code (Anfang)Letzte NutzungLöschen
    '+e.code+""+e.time+'
    "):s+="

    Sie haben noch keine Authentifizierungslinks!

    ",s+='

     

    ',e(s+='

    Passwort ändern

    Bitte geben Sie ein Passwort ein!
    Bitte geben Sie das Passwort ein!
    '),$("button#newPasswordSet").prop("disabled",!0),$("span.newPasswordIndikator").css({"border-radius":"5px",padding:"2px"}),$("button#newPasswordSet").click(function(){var e=$("input#newPasswordA").val(),a=$("input#newPasswordB").val();if(!o(e,a))return!1;$("div#newPasswordLoader").removeClass("disable"),ajax_request("account",{userid:userinformation.id},function(a){if("okay"===a.status){var n=a.data,s=sjcl.codec.hex.fromBits(sjcl.hash.sha256.hash(e));s=sjcl.codec.hex.fromBits(sjcl.hash.sha256.hash(s+"+"+n)),ajax_request("account",{userid:userinformation.id,newpass:s,salt:n},function(e){$("div#newPasswordLoader").addClass("disable"),"okay"===e.status?($("div#newPasswordDone").removeClass("disable error"),$("div#newPasswordDone").addClass("okay"),$("div#newPasswordDone").text("Passwort geändert!")):($("div#newPasswordDone").removeClass("disable okay"),$("div#newPasswordDone").addClass("error"),$("div#newPasswordDone").text("Konnte Passwort nicht ändern!"))})}else $("div#newPasswordLoader").addClass("disable"),$("div#newPasswordDone").removeClass("disable okay"),$("div#newPasswordDone").addClass("error"),$("div#newPasswordDone").text("Konnte Passwort nicht ändern!")})}),$("input.newPassword").on("keyup",function(){o($("input#newPasswordA").val(),$("input#newPasswordB").val())?$("button#newPasswordSet").prop("disabled",!1):$("button#newPasswordSet").prop("disabled",!0)}),$("button.deleteAuthLink").click(function(){var e=$(this).attr("linkid"),a=$(this).attr("codeteil");confirm('Wollen sie den Code "'+a+'" wirklich löschen? ')&&($("div#authLinkLoading").removeClass("disable"),ajax_request("account",{userid:userinformation.id,art:"del",id:e},function(e){$("div#authLinkLoading").addClass("disable"),"okay"===e.status?n():alert("Konnte den Code nicht löschen!")}))}),$("button#addAuthLink").click(function(){$("div#authLinkLoading").removeClass("disable"),ajax_request("account",{userid:userinformation.id,art:"new",id:"new"},function(e){$("div#authLinkLoading").addClass("disable"),"okay"===e.status?(!function(e){var a=domain+"/#"+userinformation.name+":"+e,n='

    Neuer Authentifizierungslink wurde erstellt:

    Code: '+e+'

    URL:

    Link: Aufrufen

    Achtung: Dieser Link und Code wird nur ein einziges Mal angezeigt!!

    ';$("body").append('
    '+n+"
    "),$("div#authCodeManagerNewCodeDialog").dialog({resizable:!1,height:"auto",width:"auto",modal:!0,title:"Neuer Authentifizierungslink",close:function(){$(this).remove()},position:{my:"center",at:"center",of:$("div.main")}}),new QRCode(document.getElementById("authCodeManagerNewCodeDialogQR"),a)}(e.data),n()):alert("Konnte keinen Code erstellen!")})});function o(e,a){var n=!1;if($("span#newPasswordAIndikator").css({color:"white"}),""==e&&($("span#newPasswordAIndikator").css({"background-color":"inherit"}),$("span#newPasswordAIndikator").text("Bitte geben Sie ein Passwort ein!"),n=!0),""==a&&($("span#newPasswordBIndikator").css({"background-color":"inherit"}),$("span#newPasswordBIndikator").text("Bitte geben Sie das Passwort ein!"),n=!0),""!=e){var s,o=e,t=e.length,d=0;t>5?((d+=5*(t-=5))>20&&(d=20),o.match(/([a-zA-Z])/)&&(d+=10),o.match(/([A-Z])/)&&(d+=5),o.match(/([0-9])/)&&(d+=5),o.match(/([0-9].*[0-9])/)&&(d+=10),o.match(/([0-9].*[0-9].*[0-9])/)&&(d+=10),o.match(/([!,%,&,@,#,*,?,_,])/)&&(d+=15),o.match(/([!,%,&,@,#,*,?,_,].*[!,%,&,@,#,*,?,_,])/)&&(d+=15),o.match(/([!,%,&,@,#,*,?,_,].*[!,%,&,@,#,*,?,_,].*[!,%,&,@,#,*,?,_,])/)&&(d+=15)):d=0,d<=25?(s="Das soll ein Passwort sein?",$("span#newPasswordAIndikator").css({"background-color":"red"})):d<=50?(s="Gut, aber es geht noch besser!",$("span#newPasswordAIndikator").css({"background-color":"orange"}),$("span#newPasswordAIndikator").css({color:"black"})):d<=75?(s="Das sieht doch super aus!",$("span#newPasswordAIndikator").css({"background-color":"yellow"}),$("span#newPasswordAIndikator").css({color:"black"})):d<=100&&(s="Da werden die Hacker schwitzen!",$("span#newPasswordAIndikator").css({"background-color":"green"})),$("span#newPasswordAIndikator").text(s)}return e!=a&&""!=e&&""!=a&&($("span#newPasswordBIndikator").css({"background-color":"red"}),$("span#newPasswordBIndikator").text("Die Passwörter stimmen nicht überein!"),n=!0),!n&&($("span#newPasswordBIndikator").css({"background-color":"green"}),$("span#newPasswordBIndikator").text("Passwörter stimmen überein!"),!0)}}$("body").append('
    Lädt ...
    '),$("div#authCodeManagerDialog").dialog({resizable:!1,height:"auto",width:"auto",modal:!0,title:"Authentifizierungslinks und Passwort",close:function(){$(this).remove()},position:{my:"center",at:"center",of:$("div.main")}});function n(){ajax_request("account",{userid:userinformation.id,art:"list",id:"list"},function(n){"okay"===n.status?a(n.data):e("Kann nicht laden!")})}n()}function oldNotesManager(){function t(t){t='
    '+t,$("div#oldNotesDialog").html(t)}$("body").append('
    '),$("div#oldNotesDialog").dialog({resizable:!1,height:"auto",width:"auto",modal:!0,title:"Notizarchiv",close:function(){$(this).remove()},position:{my:"center",at:"center",of:$("div.main")}}),t("Lädt ..."),$("div#oldNotesDialogLoader").removeClass("disable"),ajax_request("list",{userid:userinformation.id,reload:"none"},function(o){if($("div#oldNotesDialogLoader").addClass("disable"),"okay"===o.status){var e="";o.data.forEach(function(t){e+="'}),t(e+="
    NameZuletzt geändertWiederherstellen
    "+t.name+""+t.geaendert+'
    "),$("button.oldNotesDialogReload").click(function(){var t=$(this).attr("noteid");$("div#oldNotesDialogLoader").removeClass("disable"),ajax_request("list",{userid:userinformation.id,reload:t},function(t){$("div#oldNotesDialogLoader").addClass("disable"),"okay"===t.status?(list(),$("div#oldNotesDialog").dialog("close")):alert("Konnte die Notiz nicht wiederherstellen!")})})}else t("Konnte nicht laden!!")})}function shareviewer(e,n){var a,t=0,i=!1;systemRESTAPI=!1;function s(){ajax_request("share",{authcode:e},function(n){systemOfflineMode?(errorMessage("Offline können keine Freigaben geöffnet werden!"),r()):"okay"===n.status?(t=n.data.geandert,i=n.data.edit,n.data.edit?(maker(n.data.id,n.data.name,{content:n.data.content,lastchanged:n.data.geandert},function(n,i){$("div.noteview div.loading").removeClass("disable"),ajax_request("share",{authcode:e,cont:n},function(e){$("div.noteview div.loading").addClass("disable"),t=e.data[3],"okay"===e.status?($("span.notesaved").removeClass("disable"),$("span.noteunsaved").addClass("disable")):errorMessage("Konnte Notiz nicht speichern!"),s(!("okay"===e.status))},function(e){$("div.noteview div.loading").addClass("disable"),errorMessage("Konnte Notiz nicht speichern!"),s(!0)});function s(e){i&&(e&&!confirm("Konnte nicht Notiz speichern, trotzdem schließen?")||(clearInterval(a),window.location.hash="",loginsys()))}}),o()):(maker(n.data.id,n.data.name,{content:n.data.content,lastchanged:n.data.geandert}),o())):(errorMessage("Nachricht lässt sich mittels Freigabelink nicht öffnen.",!1),r())},function(e){r()})}s();function r(){"function"==typeof n&&n()}function o(){a=setInterval(function(){ajax_request("share",{authcode:e},function(e){"error"===e.status?errorMessage("Die Freigabe kann nichtmehr erreicht werden",!1):(console.log(e.data.geandert-t,e.data.geandert,t),e.data.geandert-t>5&&(clearInterval(a),i?confirmDialog("

    Die Notiz ist auf dem Server verändert worden.
    Wollen Sie die neue Version laden?

    Dadurch können Ihre Änderungen verloren gehen!

    ",{Ja:function(){s(),$(this).dialog("close")},Abbrechen:function(){$(this).dialog("close")}},"Änderung auf Server"):s()))})},1e3*global_polling_secs)}} \ No newline at end of file +$(function(){loginsys(),isOpenedAsApp&&displayAsApp()});class OfflineManager{constructor(){null!==localStorage.getItem("notes_offline_storage")?this.data=JSON.parse(localStorage.getItem("notes_offline_storage")):this.data={},this.status=null}statusChanged(t){!0!==this.status&&null!==this.status||t||this.pushToServer(),this.status=t}saveNote(t,a,e){this.status&&(this.data[t]={content:a,name:e},this.saveLocalStorage())}saveLocalStorage(){localStorage.setItem("notes_offline_storage",JSON.stringify(this.data))}pushToServer(){if("{}"==JSON.stringify(this.data))this.data={},this.saveLocalStorage();else if(0==this.status){var t=this;$.each(this.data,function(a,e){ajax_request("view",{userid:userinformation.id,noteid:a,note:{name:e.name,cont:e.content}},function(e){if($("div.noteview div.loading").addClass("disable"),"okay"===e.status){if(4==e.data.length){var s=JSON.parse(localStorage.getItem("note_autosave_"+a));s.lastserverchanged=e.data[3],localStorage.setItem("note_autosave_"+a,JSON.stringify(s))}delete t.data[a],t.saveLocalStorage()}})})}}}class NotesEncrypter{constructor(){null!==localStorage.getItem("notes_encrypt_data")?this.data=JSON.parse(localStorage.getItem("notes_encrypt_data")):this.data={password:"",status:!1}}setNotesPassword(t){this.data.password=sjcl.codec.hex.fromBits(sjcl.hash.sha256.hash(t+"bu79ubwqrzbIgbuwiw")),this.data.status=!0,this.saveLocalStorage()}requestForPassword(){this.data.status||errorMessage("Es ist kein Passwort zum Verschlüsseln von Notizen angegeben.",20)}encryptNote(t){return this.data.status?JSON.stringify(sjcl.encrypt(this.data.password,t)):t}decryptNote(t){return this.data.status?sjcl.decrypt(this.data.password,JSON.parse(t)):t}saveLocalStorage(){localStorage.setItem("notes_encrypt_data",JSON.stringify(this.data))}}var userinformation={name:null,id:null,admin:!1,authcode:null},errorMessageTimeOut=null,systemOfflineMode=!1,systemOfflineManager=new OfflineManager,systemEncrypter=new NotesEncrypter,systemRESTAPI=!1;function review(e){$("div.login").addClass("disable"),$("div.noteview").addClass("disable"),$("div.noteslist").addClass("disable"),$("div.globalloader").addClass("disable"),$("div."+e).removeClass("disable")}function errorMessage(e,o){null!==errorMessageTimeOut&&clearTimeout(errorMessageTimeOut),null===e?($("div.global.error.message").html("Fehler!"),$("div.global.error.message").addClass("disable")):(void 0===o&&(o=10),$("div.global.error.message").html(e),$("div.global.error.message").removeClass("disable"),!1!==o&&(errorMessageTimeOut=setTimeout(function(){$("div.global.error.message").addClass("disable")},1e3*o)))}function ajax_request(e,o,s,a){if(systemRESTAPI&&("share"!=e||"login"!=e)||"auth"==e){var i="rest";void 0!==o.authcode&&null!=o.authcode||(o.authcode=userinformation.authcode)}else i="ajax";$.post(domain+"/"+i+".php?"+e,o,function(e){"object"==typeof e?("error"===e.status?console.log(e.error):(systemOfflineMode&&$("div.global.error.message").off("click"),systemOfflineMode=!1,systemOfflineManager.statusChanged(!1),errorMessage(null)),"function"==typeof s&&s(e)):(errorMessage("Sever antwortet nicht korrekt!",!1),"function"==typeof a&&a(e))}).fail(function(){errorMessage("Offlinemodus",!1),$("div.global.error.message").click(()=>{errorMessage("Neu verbinden ...",!1),ajax_request("login",{status:userinformation.id},()=>{},()=>{errorMessage("Offlinemodus",!1)})}),systemOfflineMode=!0,systemOfflineManager.statusChanged(!0),"function"==typeof s&&s({data:{}})})}function confirmDialog(e,o,s){if(void 0===o)o={OK:function(){},Abbrechen:function(){}};if(void 0===s)s="Wichtig!";$("div.globalDialog").removeClass("disable"),$("div.globalDialog").dialog({resizable:!1,height:"auto",width:"auto",minWidth:200,minHeight:150,modal:!0,title:s,close:function(){$("div.globalDialog").html(""),$("div.globalDialog").addClass("disable")},position:{my:"center",at:"center",of:$("div.main")},buttons:o});function a(e){$("div.globalDialog").html(e)}return a(e),a}let isOpenedAsApp="standalone"in window.navigator&&1==window.navigator.standalone||window.matchMedia("(display-mode: standalone)").matches;function displayAsApp(){$("body").css({background:"#f5f5f5"}),$("div.main").css({border:"none","box-shadow":"none"}),$("h1").css({"font-size":"1.2em"}),$("div.logout button#logout, div.logout span.small, div.footer a").css({display:"none"}),$("div.logout").css({height:"26px",width:"48px",position:"initial"}),$("div.logout").removeClass("box")}function loginsys(){$("div.nojs.error.message").remove();!function(){review("globalloader");var a=window.location.hash;""!=a?(a=a.substr(1),new RegExp("[^A-Za-z0-9]").test(a)?n():shareviewer(a,n)):n();function n(){review("login"),""!=localStorage.getItem("userinformation_id")&&null!=localStorage.getItem("userinformation_id")&&""!=localStorage.getItem("userinformation_name")&&null!=localStorage.getItem("userinformation_name")?(userinformation.id=localStorage.getItem("userinformation_id"),userinformation.name=localStorage.getItem("userinformation_name"),userinformation.admin=JSON.parse(localStorage.getItem("userinformation_admin")),""!=localStorage.getItem("userinformation_authcode")&&null!=localStorage.getItem("userinformation_authcode")?(userinformation.authcode=localStorage.getItem("userinformation_authcode"),systemRESTAPI=!0,i(),list()):($("div.login div.input div.loading").removeClass("disable"),ajax_request("login",{status:userinformation.id},function(o){$("div.login div.input div.loading").addClass("disable"),systemOfflineMode?(i(),list()):1==o.data?(i(),list()):e()}))):systemOfflineMode?o():e()}}();function e(){var e=window.location.hash;if(""!=e){e=e.substr(1);if(new RegExp("[a-z]+:[a-z0-9]+").test(e)){var a=e.split(":"),n=a[0],s=a[1];console.log('Versuche User "'+n+'" mit Loginlink einzuloggen.'),$("div.login div.input div.loading").removeClass("disable"),ajax_request("auth",{username:n,authcode:s},function(e){$("div.login div.input div.loading").addClass("disable"),"okay"===e.status?(userinformation.name=n,userinformation.id=e.data.id,userinformation.admin=e.data.admin,userinformation.authcode=s,localStorage.setItem("userinformation_id",userinformation.id),localStorage.setItem("userinformation_name",userinformation.name),localStorage.setItem("userinformation_admin",userinformation.admin),localStorage.setItem("userinformation_authcode",userinformation.authcode),systemRESTAPI=!0,i(),list()):o()})}else o()}else o()}function o(){systemOfflineMode?($("div.login p.message.important.offline").removeClass("disable"),$("div.login p.message.important.online").addClass("disable"),$("div.login div.input div#loginform").addClass("disable"),$("div.login div.input").addClass("disable")):(ajax_request("login",{status:userinformation.id},function(e){systemOfflineMode&&o()}),$("div.login p.message.important.offline").addClass("disable"),$("div.login p.message.important.online").removeClass("disable")),$("div.login p.message.error").addClass("disable"),$("div.login p.message.okay").addClass("disable"),$("div.login div.input div.loading").addClass("disable"),systemOfflineMode||($("div.login div.input div#loginform").removeClass("disable"),$("div.login div.input").removeClass("disable"),$("button#userlogin").off("click").click(e),$("input#userpassword").off("keyup").keyup(function(o){13==o.keyCode&&e()}));function e(){$("div.login div.input div.loading").removeClass("disable"),$("div.login div.input div#loginform").addClass("disable"),$("div.login p.message.important").addClass("disable");var e=sjcl.codec.hex.fromBits(sjcl.hash.sha256.hash($("input#userpassword").val()));ajax_request("login",{username:$("input#username").val(),password:e},function(e){$("div.login div.input div.loading").addClass("disable"),"error"===e.status?($("div.login p.message.error").removeClass("disable"),$("div.login div.input div#loginform").removeClass("disable")):"okay"===e.status&&($("div.login p.message.okay").removeClass("disable"),$("div.login p.message.error").addClass("disable"),$("div.login div.input").addClass("disable"),$("input#username").val(""),$("input#userpassword").val(""),userinformation.name=e.data.name,userinformation.id=e.data.id,userinformation.admin=e.data.admin,localStorage.setItem("userinformation_id",userinformation.id),localStorage.setItem("userinformation_name",userinformation.name),localStorage.setItem("userinformation_admin",userinformation.admin),i(),list())})}}function i(){var e=null;function o(){systemOfflineMode||systemRESTAPI||ajax_request("login",{logout:null},function(e){"okay"===e.status&&($("p.message.error.loggedout").removeClass("disable"),setTimeout(function(){$("p.message.error.loggedout").addClass("disable")},2e4))}),0==$("input#logouttype:checked").length?localStorage.clear():(localStorage.removeItem("userinformation_id"),localStorage.removeItem("userinformation_name"),localStorage.removeItem("userinformation_authcode"),localStorage.removeItem("userinformation_admin")),userinformation={name:null,id:null,admin:!1,authcode:null},systemRESTAPI=!1,window.location.hash="",null!==e&&clearInterval(e),errorMessage(null),"undefined"!=typeof cm_editor&&cm_editor.setValue("empty"),["input#userpassword","input#username","input#notename","div#notespreview","textarea#notesinput","input#newnotename","div.listpart div.list"].forEach(function(e){$(e).empty(),"textarea#notesinput"!==e&&$(e).val("")}),$("div.logout").addClass("disable"),loginsys()}function i(){$("div.logout span.usertools").tooltip(),systemOfflineMode?($("div.logout span.usertools span.ui-icon-wrench").addClass("disable"),$("div.logout span.usertools span.ui-icon-person").addClass("disable")):(userinformation.admin?($("div.logout span.usertools span.ui-icon-wrench").removeClass("disable"),$("div.logout span.usertools span.ui-icon-wrench").off("click").click(function(){$.ajax({type:"GET",url:domain+"/load/backend."+jsdevmin+".js",success:function(){adminDialog()},dataType:"script",cache:!0})})):$("div.logout span.usertools span.ui-icon-wrench").addClass("disable"),$("div.logout span.usertools span.ui-icon-person").off("click").click(function(){authCodeManager()}))}$("div.logout").removeClass("disable"),$("button#logout").off("click").click(o),e=setInterval(function(){if(null!=localStorage.getItem("note_maker_reopen")&&"none"!=localStorage.getItem("note_maker_reopen")){var e=JSON.parse(localStorage.getItem("note_maker_reopen"));ajax_request("view",{userid:userinformation.id,noteid:e.noteid,history:4},function(o){if("error"===o.status)errorMessage("Die Session ist abgelaufen!",!1);else if(null!=JSON.parse(localStorage.getItem("note_autosave_"+e.noteid))){var i=JSON.parse(localStorage.getItem("note_autosave_"+e.noteid)).lastserverchanged;o.data-i>5&&newerNoteOnServerFound()}})}else systemRESTAPI||ajax_request("login",{status:userinformation.id},function(e){1!=e.data&&errorMessage("Die Session ist abgelaufen!",!1)})},1e3*global_polling_secs),i();function a(){i(),$(document).off("ajaxComplete",a)}$(document).ajaxComplete(a)}}function list(){if(review("noteslist"),systemOfflineManager.pushToServer(),null!=localStorage.getItem("note_maker_reopen")&&"none"!=localStorage.getItem("note_maker_reopen")){var t=JSON.parse(localStorage.getItem("note_maker_reopen"));maker(t.noteid,t.name,void 0,void 0,t.enc)}!function(){systemOfflineMode?t():($("div.noteslist div.listpart div.loading").removeClass("disable"),ajax_request("list",{userid:userinformation.id},function(s){$("div.noteslist div.listpart div.loading").addClass("disable"),"okay"===s.status?(localStorage.setItem("note_list_notes",JSON.stringify(s.data)),i(s.data)):t()},t));function t(){$("div.noteslist div.listpart div.loading").addClass("disable"),null!=localStorage.getItem("note_list_notes")&&i(JSON.parse(localStorage.getItem("note_list_notes")))}}();function i(t){systemOfflineMode?$("div.toolbar").addClass("disable"):($("div.toolbar").removeClass("disable"),$("button#newnote").off("click").click(function(){var t=$("input#newnotename").val();""!=t&&(i=t,$("div.noteslist div.listpart div.loading").removeClass("disable"),ajax_request("list",{userid:userinformation.id,name:i,enc:!$("div.noteslist div.toolbar span.encrypt-note.ui-icon-locked").hasClass("disable")},function(t){$("div.noteslist div.listpart div.loading").addClass("disable"),"okay"===t.status&&(console.log('Notiz: "'+i+'" ("'+t.data.id+'") angelegt.'),list())}));var i}),$("button#notesarchive").off("click").click(function(){oldNotesManager()}));var i="
      ";$.each(t,function(s,e){i+='
    • '+e.name+(e.enc?'':"")+'
    • "}),i+="
    ",$("div.noteslist div.listpart div.list").html(i),$("li.noteslist_notesnames").tooltip(),$("div.noteslist div.listpart div.list ul li.noteslist_notesnames").css({"line-height":"28px"}),$("span.noteseditbuttons").css({float:"right",cursor:"pointer"});function s(){$("div.noteslist div.listpart div.list ul li span.notesnames").css({display:"inline-block",cursor:"pointer",width:$("div.noteslist div.listpart div.list ul li").width()-$("div.noteslist div.listpart div.list ul li span.noteseditbuttons").width()-5+"px"});var t=$("button#notesarchive").width();$("div.toolbar").width()-(t+($("input#newnotename").width()+$("button#newnote").width()+36))<10?($("button#notesarchive").css("float","none"),$("div.toolbar").css("line-height","28px")):($("button#notesarchive").css("float","right"),$("div.toolbar").css("line-height","inherit")),$("div.noteslist div.listpart div.list ul").css({"list-style-type":"none","padding-left":$(document).width()<600?0:40})}list_first_load&&($(window).resize(()=>setTimeout(s,200)),list_first_load=!1),s(),setTimeout(s,300),$("div.noteslist div.listpart div.list ul li span.notesnames").off("click").click(function(){var t=$(this).parent().attr("noteid"),i=$(this).text(),s="true"===$(this).parent().attr("enc");console.log('Oeffne: "'+i+'" ("'+t+'")'),s&&(systemEncrypter.requestForPassword(),!systemEncrypter.data.status)||maker(t,i,void 0,void 0,s)}),systemOfflineMode?$("span.noteseditbuttons").addClass("disable"):($("span.noteseditbuttons").removeClass("disable"),$("span.noteseditbuttons button").off("click").click(function(){var t=$(this).attr("art"),i=$(this).parent().parent().attr("noteid");$("div.noteslist div.listpart div.loading").removeClass("disable"),ajax_request("list",{userid:userinformation.id,art:t,noteid:i},function(s){$("div.noteslist div.listpart div.loading").addClass("disable"),"okay"===s.status&&(console.log('Notiz: "'+i+'" wurde '+("del"==t?"gelöscht":"up"==t?"nach oben verschoben":"nach unten verschoben")),list())})})),$("div.noteslist div.toolbar span.encrypt-note").off("click").click(function(){$("div.noteslist div.toolbar span.encrypt-note").toggleClass("disable"),$("div.noteslist div.toolbar span.encrypt-note.ui-icon-locked").hasClass("disable")||systemEncrypter.requestForPassword()}),$("div.noteslist div.toolbar span.encrypt-note").tooltip()}}var list_first_load=!0;var cm_editor;function maker(e,t,a,i,n){if(void 0!==n&&!0===n||(n=!1),n&&$("button#publishnote").prop("disabled",!0),void 0===a){var o=!1,r=!1;localStorage.setItem("note_maker_reopen",JSON.stringify({noteid:e,name:t,enc:n}))}else{if("function"==typeof i)r=!0;else r=!1;o=!0}review("noteview");var d,s,l=!1,c=!1;function u(){"object"==typeof cm_editor&&(cm_editor.off("change",g),cm_editor.off("change",f)),newerNoteOnServerFound=function(){}}var g,f;function v(){s=sjcl.codec.hex.fromBits(sjcl.hash.sha256.hash(d.content)),localStorage.setItem("note_autosave_"+d.id,JSON.stringify(d)),$("input#notename").val(d.name),$("textarea#notesinput").text(d.content),"object"!=typeof cm_editor?cm_editor=CodeMirror.fromTextArea(document.getElementById("notesinput"),{mode:"gfm",lineNumbers:!0,theme:"default"}):cm_editor.setValue($("textarea#notesinput").val()),function(){var e=new marked.Renderer;e.heading=function(e,t){return""+e+""},e.link=function(e,t,a){return''+a+""},e.text=function(e){return(e=e.replace(/@(([0-9a-zA-Z]{1,8})[0-9a-zA-Z]*)/g,'@$2')).replace(/:(\S+):/g,'')},e.checkbox=function(e){return e?' ':' '},marked.setOptions({renderer:e,gfm:!0,tables:!0,smartLists:!0,smartypants:!0,highlight:function(e,t){if("tex"!=t)return-1!==["markup","css","clike","javascript","c","bash","cpp","csharp","ruby","git","ini","java","json","lua","markdown","matlab","objectivec","perl","php","python","r","sql","swift"].indexOf(t)?Prism.highlight(e,Prism.languages[t]):e;try{return katex.renderToString(e)}catch(e){return''+e.message+""}}});function t(e,t){var a=/(iPhone|iPod|iPad).*AppleWebKit/i.test(navigator.userAgent);if(a&&void 0!==t&&1===t.text.length&&/^[A-Z]$/.test(t.text[0])){var i=$(":focus");i.blur(),i.focus()}$("div#notespreview").html(marked(cm_editor.getValue())),$(".openothernote").off("click").click(function(){var e=$(this).attr("noteid");m(function(){u(),maker(e,"")})})}t(),o&&!r?$("div.input.box").addClass("disable"):($("div.input.box").removeClass("disable"),cm_editor.on("change",t));g=t}(),function(){$("span.noteunsaved").tooltip(),$("span.notesaved").tooltip();function e(){var e=Date.now()-3e4>h,t={name:$("input#notename").val(),id:d.id,content:cm_editor.getValue(),lastserverchanged:d.lastserverchanged};localStorage.setItem("note_autosave_"+d.id,JSON.stringify(t)),e?m():($("span.noteunsaved").removeClass("disable"),$("span.notesaved").addClass("disable"))}c&&(e(),c=!1);cm_editor.on("change",e),f=e,$("span.noteunsaved").off("click").click(m)}()}var h=0;function m(a){if(s!=sjcl.codec.hex.fromBits(sjcl.hash.sha256.hash(cm_editor.getValue()))||c){l?($("body").append('
    Beim Speichern der Notiz kann es eventuell zu Datenverlust kommen, da die aktuellste Version nicht vom Server geladen werden konnte!
    '),$("#dangerMessageNoteSave").dialog({resizable:!1,height:"auto",width:"auto",modal:!0,title:"Gefahr des Datenverlustes!",buttons:{"Trotzdem Speichern":function(){$(this).dialog("close"),l=!1,u()},"Erstmal nicht":function(){$(this).dialog("close")}},close:function(){$(this).remove()}})):u();function u(){if(o&&r)h=Date.now(),i(cm_editor.getValue(),!1);else if(!1===o)if(systemOfflineMode)systemOfflineManager.saveNote(e,cm_editor.getValue(),$("input#notename").val()),h=Date.now(),"function"==typeof a&&a(!0);else{$("div.noteview div.loading").removeClass("disable");var s=cm_editor.getValue();n&&(s=systemEncrypter.encryptNote(s)),ajax_request("view",{userid:userinformation.id,noteid:e,note:{name:$("input#notename").val(),cont:s}},function(i){if($("div.noteview div.loading").addClass("disable"),"okay"===i.status){if(console.log('Notiz: "'+t+'" ("'+e+'") auf Server gespeichert.'),h=Date.now(),4==i.data.length){d.lastserverchanged=i.data[3];var n=JSON.parse(localStorage.getItem("note_autosave_"+e));n.lastserverchanged=i.data[3],localStorage.setItem("note_autosave_"+e,JSON.stringify(n))}$("span.notesaved").removeClass("disable"),$("span.noteunsaved").addClass("disable")}"function"==typeof a&&a("okay"===i.status)},function(e){"function"==typeof a&&a(!1)})}}}else"function"==typeof a&&a(!0)}!function(){function i(a,i){a||systemOfflineMode||(l=!0,errorMessage("Kann die aktuelle Version der Notiz nicht vom Server holen.",20)),null!=localStorage.getItem("note_autosave_"+e)?(d=JSON.parse(localStorage.getItem("note_autosave_"+e)),v()):systemOfflineMode?(confirmDialog("Die gewählte Notiz ist auf diesem Gerät leider nicht offline verfügbar!",{OK:function(){$(this).dialog("close")}},"Offlinemodus"),list()):(d={name:t,id:e,content:"# "+t+"\nUnd hier dann der Text!!\n",lastserverchanged:void 0!==i?i:0},v())}o?(d={name:t,id:e,content:a.content,lastserverchanged:a.lastchanged},$("div.noteview div.loading").addClass("disable"),v()):systemOfflineMode?($("div.noteview div.loading").addClass("disable"),i(!1)):($("div.noteview div.loading").removeClass("disable"),ajax_request("view",{userid:userinformation.id,noteid:e,history:2},function(e){if($("div.noteview div.loading").addClass("disable"),"okay"===e.status)if(c=e.data.empty,e.data.empty)i(!0,e.data.geandert);else{var t=e.data.content;if(n)try{t=systemEncrypter.decryptNote(e.data.content)}catch(e){localStorage.setItem("note_maker_reopen","none"),u(),list(),setTimeout(()=>{errorMessage("Kann Notiz nicht entschlüsseln!",10)},200)}d={name:e.data.name,id:e.data.id,content:t,lastserverchanged:e.data.geandert},v()}else i(!1)},function(e){i(!1)}))}(),$("button#closenote").off("click").click(function(){u(),o&&r?i(cm_editor.getValue(),!0):o?(window.location.hash="",loginsys()):!1===o&&m(function(e){e?(localStorage.setItem("note_maker_reopen","none"),list()):($("body").append('
    Die Speicherung der Notiz auf dem Server schlug fehl!
    Wollen Sie den Editor verlassen und einen Verlust der Änderungen in Kauf nehmen oder abbrechen?
    '),$("#errorMessageNoteSave").dialog({resizable:!1,height:"auto",width:"auto",modal:!0,title:"Fehler beim Speichern!",buttons:{"Änderungen verwerfen":function(){localStorage.setItem("note_maker_reopen","none"),list(),$(this).dialog("close")},Abbrechen:function(){$(this).dialog("close")}},close:function(){$(this).remove()}}))})}),o||systemOfflineMode?($("button#publishnote").addClass("disable"),$("button#notehistory").addClass("disable")):($("button#publishnote").removeClass("disable"),$("button#notehistory").removeClass("disable"),$("button#publishnote").off("click").click(b),$("button#notehistory").off("click").click(p));function b(){function t(){errorMessage("Freigaben konnten nicht geladen werden."),$("div.noteview div.loading").addClass("disable")}$("div.noteview div.loading").removeClass("disable"),ajax_request("view",{userid:userinformation.id,noteid:e},function(a){if("okay"===a.status){var i='
    Konnte Aktion nicht durchführen.
    ',n=!1;$.each(a.data,function(e,t){n=!0,i+='',i+="",i+="",i+='",i+="",i+=''}),i+="
    LinkNameErstelltBearbeitenLetzter Aufruf (Anzahl)Löschen
    Aufrufen "+t.name+""+t.created+"'+t.edit+""+t.lastAccessed+" ("+t.accesses+")
    ",!1===n&&(i+="

    Noch keine Freigaben!

    "),i+='

    Neue Freigabe


    Bearbeiten erlauben Nur lesen
    ',$("body").append('
    '+i+"
    "),$("div.noteview div.loading").addClass("disable"),$("div#freigabeManagerDialog").dialog({resizable:!1,height:"auto",width:"auto",modal:!0,title:"Freigaben",close:function(){$(this).remove()},position:{my:"center",at:"center",of:$("div.main")}}),$("button.deleteFreigabe").click(function(){var t=$(this).attr("authcode");$("div.freigabeDialog.loading").removeClass("disable"),ajax_request("view",{userid:userinformation.id,noteid:e,share:{authcode:t,edit:"leer",name:"leer"}},function(e){"okay"===e.status?($("div#freigabeManagerDialog").dialog("close"),b()):($("div.freigabeDialog.loading").addClass("disable"),$("div.freigabeDialog.error").removeClass("disable"))})}),$("button#addFreigabe").click(function(){var t=$("input#freigabeManagerNewName").val(),a="true"==$("input#freigabeManagerNewEdit:checked").val();""!=t&&($("div.freigabeDialog.loading").removeClass("disable"),ajax_request("view",{userid:userinformation.id,noteid:e,share:{authcode:"leer",edit:a,name:t}},function(e){"okay"===e.status?($("div#freigabeManagerDialog").dialog("close"),b()):($("div.freigabeDialog.loading").addClass("disable"),$("div.freigabeDialog.error").removeClass("disable"))}))}),$("button.freigabeQR").click(function(){var e=$(this).attr("authcode"),t=domain+"/#"+e,a='

    Code: '+e+'

    URL:

    Link: Aufrufen

    ';$("body").append('
    '+a+"
    "),$("div#freigabeManagerQRDialog").dialog({resizable:!1,height:"auto",width:"auto",modal:!0,title:"Freigabelink",close:function(){$(this).remove()},position:{my:"center",at:"center",of:$("div.main")}}),new QRCode(document.getElementById("freigabeManagerQR"),t)})}else t()},t)}function p(){function t(){errorMessage("Notizverlauf konnte nicht geladen werden."),$("div.noteview div.loading").addClass("disable")}$("div.noteview div.loading").removeClass("disable"),ajax_request("view",{userid:userinformation.id,noteid:e,history:3},function(e){if("okay"===e.status){var a="";$.each(e.data,function(e,t){a+="",a+="'}),a+="
    ÄnderungenZeitpunkt
    "+(n?"Kein Diff. bei verschlüsselten Notizen!":t.diff)+""+t.time+'
    ",$("body").append('
    '+a+"
    "),$("div.noteview div.loading").addClass("disable"),$("div#historyManagerDialog").dialog({resizable:!1,height:"auto",width:"auto",modal:!0,title:"Notizverlauf",close:function(){$(this).remove()},position:{my:"center",at:"center",of:$("div.main")}}),$("button.takeInputFromHistory").click(function(){var t=$(this).attr("key"),a=e.data[t].text;cm_editor.setValue(a),$("div#historyManagerDialog").dialog("close")})}else t()},t)}newerNoteOnServerFound=function(){!0,s==sjcl.codec.hex.fromBits(sjcl.hash.sha256.hash(cm_editor.getValue()))?(u(),maker(e,t)):(l=!0,confirmDialog("

    Die Notiz ist auf dem Server verändert worden.
    Wollen Sie die neue Version laden?

    Dadurch können Ihre Änderungen verloren gehen! Andernfalls die Änderungen auf dem Server.

    ",{Ja:function(){u(),maker(e,t),!1,$(this).dialog("close")},Nein:function(){l=!1,m(),!1,$(this).dialog("close")}},"Änderung auf Server"))}}var newerNoteOnServerFound=function(){};function authCodeManager(){function e(e){$("div#authCodeManagerDialog").html(e)}function n(n){var a='

    Authentifizierungslinks

    ';!1!==n?(a+="",n.forEach(function(e){a+=''}),a+="
    Code (Anfang)Letzte NutzungLöschen
    '+e.code+""+e.time+'
    "):a+="

    Sie haben noch keine Authentifizierungslinks!

    ",a+='

     

    ',a+='

    Passwort ändern

    Bitte geben Sie ein Passwort ein!
    Bitte geben Sie das Passwort ein!
    ',e(a+='

    Passwort zur Verschlüsselung von Notizen

    Bitte geben Sie ein Passwort zur Verschlüsselung der Notizen ein!
    '),$("button#newPasswordSet").prop("disabled",!0),$("span.newPasswordIndikator").css({"border-radius":"5px",padding:"2px"}),$("button#newPasswordSet").click(function(){var e=$("input#newPasswordA").val(),n=$("input#newPasswordB").val();if(!t(e,n))return!1;$("div#newPasswordLoader").removeClass("disable"),ajax_request("account",{userid:userinformation.id},function(n){if("okay"===n.status){var s=n.data,a=sjcl.codec.hex.fromBits(sjcl.hash.sha256.hash(e));a=sjcl.codec.hex.fromBits(sjcl.hash.sha256.hash(a+"+"+s)),ajax_request("account",{userid:userinformation.id,newpass:a,salt:s},function(e){$("div#newPasswordLoader").addClass("disable"),"okay"===e.status?($("div#newPasswordDone").removeClass("disable error"),$("div#newPasswordDone").addClass("okay"),$("div#newPasswordDone").text("Passwort geändert!")):($("div#newPasswordDone").removeClass("disable okay"),$("div#newPasswordDone").addClass("error"),$("div#newPasswordDone").text("Konnte Passwort nicht ändern!"))})}else $("div#newPasswordLoader").addClass("disable"),$("div#newPasswordDone").removeClass("disable okay"),$("div#newPasswordDone").addClass("error"),$("div#newPasswordDone").text("Konnte Passwort nicht ändern!")})}),$("input.newPassword").on("keyup",function(){t($("input#newPasswordA").val(),$("input#newPasswordB").val())?$("button#newPasswordSet").prop("disabled",!1):$("button#newPasswordSet").prop("disabled",!0)}),$("input.noteEncPassw").on("keyup",function(){$("button#noteEncPasswSet").prop("disabled",$("input.noteEncPassw").val().length<4)}),$("button#noteEncPasswSet").click(function(){systemEncrypter.setNotesPassword($("input.noteEncPassw").val()),$("button#noteEncPasswSet").prop("disabled",!0)}),$("button.deleteAuthLink").click(function(){var e=$(this).attr("linkid"),n=$(this).attr("codeteil");confirm('Wollen sie den Code "'+n+'" wirklich löschen? ')&&($("div#authLinkLoading").removeClass("disable"),ajax_request("account",{userid:userinformation.id,art:"del",id:e},function(e){$("div#authLinkLoading").addClass("disable"),"okay"===e.status?s():alert("Konnte den Code nicht löschen!")}))}),$("button#addAuthLink").click(function(){$("div#authLinkLoading").removeClass("disable"),ajax_request("account",{userid:userinformation.id,art:"new",id:"new"},function(e){$("div#authLinkLoading").addClass("disable"),"okay"===e.status?(!function(e){var n=domain+"/#"+userinformation.name+":"+e,s='

    Neuer Authentifizierungslink wurde erstellt:

    Code: '+e+'

    URL:

    Link: Aufrufen

    Achtung: Dieser Link und Code wird nur ein einziges Mal angezeigt!!

    ';$("body").append('
    '+s+"
    "),$("div#authCodeManagerNewCodeDialog").dialog({resizable:!1,height:"auto",width:"auto",modal:!0,title:"Neuer Authentifizierungslink",close:function(){$(this).remove()},position:{my:"center",at:"center",of:$("div.main")}}),new QRCode(document.getElementById("authCodeManagerNewCodeDialogQR"),n)}(e.data),s()):alert("Konnte keinen Code erstellen!")})});function t(e,n){var s=!1;if($("span#newPasswordAIndikator").css({color:"white"}),""==e&&($("span#newPasswordAIndikator").css({"background-color":"inherit"}),$("span#newPasswordAIndikator").text("Bitte geben Sie ein Passwort ein!"),s=!0),""==n&&($("span#newPasswordBIndikator").css({"background-color":"inherit"}),$("span#newPasswordBIndikator").text("Bitte geben Sie das Passwort ein!"),s=!0),""!=e){var a,t=e,o=e.length,d=0;o>5?((d+=5*(o-=5))>20&&(d=20),t.match(/([a-zA-Z])/)&&(d+=10),t.match(/([A-Z])/)&&(d+=5),t.match(/([0-9])/)&&(d+=5),t.match(/([0-9].*[0-9])/)&&(d+=10),t.match(/([0-9].*[0-9].*[0-9])/)&&(d+=10),t.match(/([!,%,&,@,#,*,?,_,])/)&&(d+=15),t.match(/([!,%,&,@,#,*,?,_,].*[!,%,&,@,#,*,?,_,])/)&&(d+=15),t.match(/([!,%,&,@,#,*,?,_,].*[!,%,&,@,#,*,?,_,].*[!,%,&,@,#,*,?,_,])/)&&(d+=15)):d=0,d<=25?(a="Das soll ein Passwort sein?",$("span#newPasswordAIndikator").css({"background-color":"red"})):d<=50?(a="Gut, aber es geht noch besser!",$("span#newPasswordAIndikator").css({"background-color":"orange"}),$("span#newPasswordAIndikator").css({color:"black"})):d<=75?(a="Das sieht doch super aus!",$("span#newPasswordAIndikator").css({"background-color":"yellow"}),$("span#newPasswordAIndikator").css({color:"black"})):d<=100&&(a="Da werden die Hacker schwitzen!",$("span#newPasswordAIndikator").css({"background-color":"green"})),$("span#newPasswordAIndikator").text(a)}return e!=n&&""!=e&&""!=n&&($("span#newPasswordBIndikator").css({"background-color":"red"}),$("span#newPasswordBIndikator").text("Die Passwörter stimmen nicht überein!"),s=!0),!s&&($("span#newPasswordBIndikator").css({"background-color":"green"}),$("span#newPasswordBIndikator").text("Passwörter stimmen überein!"),!0)}}$("body").append('
    Lädt ...
    '),$("div#authCodeManagerDialog").dialog({resizable:!1,height:"auto",width:"auto",modal:!0,title:"Authentifizierungslinks und Passwort",close:function(){$(this).remove()},position:{my:"center",at:"center",of:$("div.main")}});function s(){ajax_request("account",{userid:userinformation.id,art:"list",id:"list"},function(s){"okay"===s.status?n(s.data):e("Kann nicht laden!")})}s()}function oldNotesManager(){function t(t){t='
    '+t,$("div#oldNotesDialog").html(t)}$("body").append('
    '),$("div#oldNotesDialog").dialog({resizable:!1,height:"auto",width:"auto",modal:!0,title:"Notizarchiv",close:function(){$(this).remove()},position:{my:"center",at:"center",of:$("div.main")}}),t("Lädt ..."),$("div#oldNotesDialogLoader").removeClass("disable"),ajax_request("list",{userid:userinformation.id,reload:"none"},function(o){if($("div#oldNotesDialogLoader").addClass("disable"),"okay"===o.status){var e="";o.data.forEach(function(t){e+="'}),t(e+="
    NameZuletzt geändertWiederherstellen
    "+t.name+""+t.geaendert+'
    "),$("button.oldNotesDialogReload").click(function(){var t=$(this).attr("noteid");$("div#oldNotesDialogLoader").removeClass("disable"),ajax_request("list",{userid:userinformation.id,reload:t},function(t){$("div#oldNotesDialogLoader").addClass("disable"),"okay"===t.status?(list(),$("div#oldNotesDialog").dialog("close")):alert("Konnte die Notiz nicht wiederherstellen!")})})}else t("Konnte nicht laden!!")})}function shareviewer(e,n){var a,t=0,i=!1;systemRESTAPI=!1;function s(){ajax_request("share",{authcode:e},function(n){systemOfflineMode?(errorMessage("Offline können keine Freigaben geöffnet werden!"),r()):"okay"===n.status?(t=n.data.geandert,i=n.data.edit,n.data.edit?(maker(n.data.id,n.data.name,{content:n.data.content,lastchanged:n.data.geandert},function(n,i){$("div.noteview div.loading").removeClass("disable"),ajax_request("share",{authcode:e,cont:n},function(e){$("div.noteview div.loading").addClass("disable"),t=e.data[3],"okay"===e.status?($("span.notesaved").removeClass("disable"),$("span.noteunsaved").addClass("disable")):errorMessage("Konnte Notiz nicht speichern!"),s(!("okay"===e.status))},function(e){$("div.noteview div.loading").addClass("disable"),errorMessage("Konnte Notiz nicht speichern!"),s(!0)});function s(e){i&&(e&&!confirm("Konnte nicht Notiz speichern, trotzdem schließen?")||(clearInterval(a),window.location.hash="",loginsys()))}}),o()):(maker(n.data.id,n.data.name,{content:n.data.content,lastchanged:n.data.geandert}),o())):(errorMessage("Nachricht lässt sich mittels Freigabelink nicht öffnen.",!1),r())},function(e){r()})}s();function r(){"function"==typeof n&&n()}function o(){a=setInterval(function(){ajax_request("share",{authcode:e},function(e){"error"===e.status?errorMessage("Die Freigabe kann nichtmehr erreicht werden",!1):(console.log(e.data.geandert-t,e.data.geandert,t),e.data.geandert-t>5&&(clearInterval(a),i?confirmDialog("

    Die Notiz ist auf dem Server verändert worden.
    Wollen Sie die neue Version laden?

    Dadurch können Ihre Änderungen verloren gehen!

    ",{Ja:function(){s(),$(this).dialog("close")},Abbrechen:function(){$(this).dialog("close")}},"Änderung auf Server"):s()))})},1e3*global_polling_secs)}} \ No newline at end of file diff --git a/system/php/list.php b/system/php/list.php index 16509aa..62eca1a 100644 --- a/system/php/list.php +++ b/system/php/list.php @@ -187,7 +187,7 @@ } } //Neu -elseif( check_params( POST, array( 'userid' => 'strAZaz09', 'name' => 'strALL') ) ){ +elseif( check_params( POST, array( 'userid' => 'strAZaz09', 'name' => 'strALL', '*enc' => 'strAZaz09' ) ) ){ //Userid // => Konvention nur kleine Buchstaben! $userid = preg_replace( '/[^a-z]/', '', $_POST['userid'] ); @@ -219,7 +219,8 @@ $notesfile->setValue( [null], array( 'name' => $_POST['name'], 'noteid' => $newid, - 'position' => $pos + 1 + 'position' => $pos + 1, + 'enc' => !empty($_POST['enc']) && $_POST['enc'] === 'true' )); //Okay Ausgabe diff --git a/system/php/systemInit.php b/system/php/systemInit.php index 8762220..277b58b 100644 --- a/system/php/systemInit.php +++ b/system/php/systemInit.php @@ -62,7 +62,7 @@ abstract class SystemInit{ //Sytemversion // [ Hauptversionsnummer, Unternummer, Patch, Zusatz (Alpha, Beta, Final) ] => [1, 23, 5, 'B'] -> 1.23.5 Beta - const SYSTEMVERSION = [ 1, 1, 2, 'Final' ]; + const SYSTEMVERSION = [ 1, 1, 3, 'Beta' ]; /* Auslesen der Konfiguration