Fixed delete text
This commit is contained in:
parent
c51f07d2fc
commit
a1cc2a410b
|
@ -29,11 +29,11 @@ with open(NOTES_PTH) as infile:
|
||||||
try:
|
try:
|
||||||
notesJson = json.load(infile)
|
notesJson = json.load(infile)
|
||||||
for entry in notesJson:
|
for entry in notesJson:
|
||||||
notesListEncoded.append(escape(entry))
|
notesListEncoded.append(entry)
|
||||||
entryDecoded = str(base64.urlsafe_b64decode( entry.encode("utf-8") ), "utf-8")
|
entryDecoded = str(base64.urlsafe_b64decode( entry.encode("utf-8") ), "utf-8")
|
||||||
notesListDecoded.append(entryDecoded)
|
notesListDecoded.append(escape(entryDecoded))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(repr(e))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ def editFile():
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
errorMsg = str(e)
|
errorMsg = str(e)
|
||||||
print("Exception for editing action:")
|
print("Exception for editing action:")
|
||||||
print(e)
|
print(repr(e))
|
||||||
|
|
||||||
if editedFile:
|
if editedFile:
|
||||||
msg = "[Success] Renamed File!"
|
msg = "[Success] Renamed File!"
|
||||||
|
@ -128,7 +128,7 @@ def deleteFile():
|
||||||
fname = file[0]
|
fname = file[0]
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("Exception for deletiong action:")
|
print("Exception for deletiong action:")
|
||||||
print(e)
|
print(repr(e))
|
||||||
errorMsg = str(e)
|
errorMsg = str(e)
|
||||||
|
|
||||||
if deletedFile:
|
if deletedFile:
|
||||||
|
@ -146,8 +146,9 @@ def deleteFile():
|
||||||
def deleteText():
|
def deleteText():
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
try:
|
try:
|
||||||
encodedNote = request.values['encodedstr'].strip()
|
decodedNote = request.values['noteStr'].strip()
|
||||||
decodedNote = str(base64.urlsafe_b64decode( encodedNote.encode("utf-8") ), "utf-8")
|
encodedBytes = base64.urlsafe_b64encode(decodedNote.encode("utf-8"))
|
||||||
|
encodedNote = str(encodedBytes, "utf-8")
|
||||||
|
|
||||||
notesListEncoded.remove(encodedNote)
|
notesListEncoded.remove(encodedNote)
|
||||||
notesListDecoded.remove(decodedNote)
|
notesListDecoded.remove(decodedNote)
|
||||||
|
@ -156,7 +157,7 @@ def deleteText():
|
||||||
msg = "[Success] Deleted entry..."
|
msg = "[Success] Deleted entry..."
|
||||||
return msgHandler.createMessageJSON("success", msg)
|
return msgHandler.createMessageJSON("success", msg)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(repr(e))
|
||||||
|
|
||||||
msg = "[Error] Failed to delete entry!"
|
msg = "[Error] Failed to delete entry!"
|
||||||
return msgHandler.createMessageJSON("danger", msg)
|
return msgHandler.createMessageJSON("danger", msg)
|
||||||
|
@ -170,7 +171,7 @@ def deleteAllText():
|
||||||
msg = "[Success] Deleted all enteries..."
|
msg = "[Success] Deleted all enteries..."
|
||||||
return msgHandler.createMessageJSON("success", msg)
|
return msgHandler.createMessageJSON("success", msg)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(repr(e))
|
||||||
|
|
||||||
msg = "[Error] Failed to delete all enteries!"
|
msg = "[Error] Failed to delete all enteries!"
|
||||||
return msgHandler.createMessageJSON("danger", msg)
|
return msgHandler.createMessageJSON("danger", msg)
|
||||||
|
@ -192,7 +193,7 @@ def addNote():
|
||||||
return msgHandler.createMessageJSON("success", msg)
|
return msgHandler.createMessageJSON("success", msg)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("Exception for file write action:")
|
print("Exception for file write action:")
|
||||||
print(e)
|
print(repr(e))
|
||||||
msg = "[Error] A text entry write error occured!"
|
msg = "[Error] A text entry write error occured!"
|
||||||
return msgHandler.createMessageJSON("danger", msg)
|
return msgHandler.createMessageJSON("danger", msg)
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -70,8 +70,7 @@ const deleteTextAction = (elm, note) => {
|
||||||
const refElm = document.getElementsByClassName(classRef)[0];
|
const refElm = document.getElementsByClassName(classRef)[0];
|
||||||
refElm.parentElement.removeChild(refElm);
|
refElm.parentElement.removeChild(refElm);
|
||||||
|
|
||||||
const encodedstr = btoa(note);
|
const params = new URLSearchParams('noteStr=' + note)
|
||||||
const params = new URLSearchParams('encodedstr=' + encodedstr)
|
|
||||||
doAjax('delete-text', params, 'delete-text');
|
doAjax('delete-text', params, 'delete-text');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue