Added a night mode and no way to toggle it!

Tweaked a lot of styles and added some cool animations
Added a little to the help text
Quickly adding a note, saving and closing no longer causes half formed or empty notes to appear
Close Editor animation
Display cards text show at the bottom of card
Added a delete function, and it works
Added browser title attributes
More debugging and error checking on scraped links
Updated not search to display title and text below the title
This commit is contained in:
Max G
2019-07-29 07:22:47 +00:00
parent b0a8071b41
commit fcee24a61d
13 changed files with 387 additions and 105 deletions

View File

@@ -38,7 +38,10 @@ Attachment.scanTextForWebsites = (userId, noteId, noteText) => {
//Find all URLs in text
const urlPattern = /(?:(?:https?|ftp|file):\/\/|www\.|ftp\.)(?:\([-A-Z0-9+&@#/%=~_|$?!:,.]*\)|[-A-Z0-9+&@#/%=~_|$?!:,.])*(?:\([-A-Z0-9+&@#/%=~_|$?!:,.]*\)|[A-Z0-9+&@#/%=~_|$])/igm
let foundUrls = noteText.match(urlPattern)
let allUrls = noteText.match(urlPattern)
//Remove all duplicates
let foundUrls = [...new Set(allUrls)]
//Go through each attachment, check for existing URLs
attachments.forEach(attachment => {
@@ -54,7 +57,7 @@ Attachment.scanTextForWebsites = (userId, noteId, noteText) => {
})
//No newly scraped URLs, resolve with looked up attachment text
if(foundUrls.length == 0){
if(foundUrls == null || foundUrls.length == 0){
resolve(solrAttachmentText)
}
@@ -166,12 +169,14 @@ Attachment.processUrl = (userId, noteId, url) => {
let finalWords = []
for(let i=0; i<15; i++){
if(sortable[i][0]){
if(sortable[i] && sortable[i][0]){
finalWords.push(sortable[i][0])
}
}
desiredSearchText += finalWords.join(', ')
console.log('TexT Scraped')
console.log(desiredSearchText)
const created = Math.round((+new Date)/1000)

View File

@@ -75,7 +75,20 @@ Notes.update = (userId, noteId, noteText, fancyInput, color) => {
Notes.delete = (userId, noteId) => {
return new Promise((resolve, reject) => {
//Create new note, return created or finger your butt
// DELETE FROM notes WHERE notes.id = 290 AND notes.user = 61;
// DELETE FROM attachment WHERE attachment.note_id = 290 AND attachment.user_id = 61;
// DELETE FROM notes_tags WHERE notes_tags.note_id = 290 AND notes_tags.user_id = 61;
db.promise().query('DELETE FROM notes WHERE notes.id = ? AND notes.user = ?', [noteId,userId])
.then((rows, fields) => {
db.promise().query('DELETE FROM attachment WHERE attachment.note_id = ? AND attachment.user_id = ?', [noteId,userId])
.then((rows, fields)=> {
db.promise().query('DELETE FROM notes_tags WHERE notes_tags.note_id = ? AND notes_tags.user_id = ?', [noteId,userId])
.then((rows, fields)=> {
console.log('All Deleted')
resolve(true)
})
})
})
})
}
@@ -153,9 +166,10 @@ Notes.search = (userId, searchQuery, searchTags) => {
//Default note lookup gets all notes
let noteSearchQuery = `
SELECT notes.id, SUBSTRING(text, 1, 200) as text, updated, color
SELECT notes.id, SUBSTRING(notes.text, 1, 400) as text, updated, color, count(distinct notes_tags.id) as tag_count, count(distinct attachment.id) as attachment_count
FROM notes
LEFT JOIN notes_tags ON (notes.id = notes_tags.note_id)
LEFT JOIN attachment ON (notes.id = attachment.note_id AND attachment.attachment_type = 1)
WHERE user = ?`
let searchParams = [userId]
@@ -193,16 +207,30 @@ Notes.search = (userId, searchQuery, searchTags) => {
noteIds.push(note.id)
//Attempt to pull string out of first tag in note
let reg = note.text.match(/<([\w]+)[^>]*>(.*?)<\/\1>/)
if(reg != null){
note.text = reg[2]
let reg = note.text.match(/<([\w]+)[^>]*>(.*?)<\/\1>/g)
//Pull out first html tag contents, that is the title
if(reg != null && reg[0]){
note.title = reg[0] //First line from HTML
} else {
note.title = note.text //Entire note
}
//Return all notes with HTML tags pulled out
note.text = note.text
//Clean up html title
note.title = note.title
.replace(/&[#A-Za-z0-9]+;/g,'') //Rip out all HTML entities
.replace(/<[^>]+>/g, '') //Rip out all HTML tags
//Generate Subtext
if(note.text != '' && note.title != ''){
note.subtext = note.text
.replace(/&[#A-Za-z0-9]+;/g,' ') //Rip out all HTML entities
.replace(/<[^>]+>/g, ' ') //Rip out all HTML tags
.replace(/\s+/g, ' ') //Remove all whitespace
.substring(note.title.length + 2)
}
note.note_highlights = []
note.attachment_highlights = []
note.tag_highlights = []