From cf91373c34f10b8df2188d7b5747a0b3fc21c8a4 Mon Sep 17 00:00:00 2001 From: freginold Date: Fri, 9 Sep 2016 11:38:51 -0400 Subject: [PATCH] v3.0.3: - fixed status bar displaying that a null-value line was added or inserted when it really wasn't - added ability to choose backup folder location --- _note.css | 14 ++++++++++++++ _note.js | 24 ++++++++++++++++++++++-- _note.vbs | 39 +++++++++++++++++++++++++++++++++++---- note.hta | 12 ++++++++++-- 4 files changed, 81 insertions(+), 8 deletions(-) diff --git a/_note.css b/_note.css index 189ffe9..00ea58c 100644 --- a/_note.css +++ b/_note.css @@ -181,3 +181,17 @@ h4 { margin: 2px 2px 10px 1px; width: 98%; } +#backupDiv { + padding-left: 10px; + margin-left: 25px; + overflow: auto; +} +#backupDispDiv { + display: inline; + margin-right: 20px; + margin-left: 1px; + font-size: 1.1em; +} +#backupText { + text-decoration: underline; +} diff --git a/_note.js b/_note.js index 623650b..5d05388 100644 --- a/_note.js +++ b/_note.js @@ -7,6 +7,9 @@ var inputBox = document.getElementById('inputBox'); var newNoteDiv = document.getElementById('newNoteDiv'); var noteTitle = document.getElementById('noteTitle'); var optionsDiv = document.getElementById('optionsDiv'); +var aboutDiv = document.getElementById('aboutDiv'); +var backupDiv = document.getElementById('backupDiv'); +var backupDispDiv = document.getElementById('backupDispDiv'); var newNoteInputBox = document.getElementById('newNoteInputBox'); var coords = document.getElementById('coords'); var undeleteButton = document.getElementById('undeleteButton'); @@ -53,7 +56,6 @@ var localFontSetButton = [ document.getElementById('localFontSetButton2'), document.getElementById('localFontSetButton3'), ]; -var aboutDiv = document.getElementById('aboutDiv'); var inputs = []; var items = []; var uFont = ['', '', '', '']; @@ -279,6 +281,7 @@ function clearAll() { optionsDiv.style.display='none'; inputDiv.style.display = 'none'; aboutDiv.style.display = 'none'; + backupDiv.style.display = 'none'; noteBody.style.display='block'; noteBody.innerText = ''; noteTitle.innerText = ''; @@ -354,7 +357,6 @@ function getLines(thisNote) { function onSubmitted(tempVar) { event.returnValue = false; AddNote(tempVar) - showStatus(AbbrevText(tempVar) + " added to bottom"); } function showX(self) { @@ -546,6 +548,7 @@ function insertItem() { // add "insert" class to item text elements, and onclick handler for insertion document.getElementById('text' + i).className = 'insert'; document.getElementById('text' + i).onclick = function() { + if (inputBox.value == "") { showNotes(currentNote); showStatus("Nothing to insert"); return; } EditedString = inputBox.value; WriteModifiedFile((this.id).slice(4), -1) showStatus(AbbrevText(EditedString) + " inserted at line #" + (1 * (this.id).slice(4) + 1)); @@ -588,6 +591,23 @@ function highlight(tempNum) { }, 2000); } +function dispBackupDiv() { + // show backup div: backup button, current backup dir, button to change dir + clearAll(); + noteBody.style.display='none'; + noteTitle.innerText = "Backup"; + backupDiv.style.display = 'block'; + var Opt13Display = Opt13; + if (Opt13 == Default13) { Opt13Display = showDefaultBackup() } + if (Opt13Display.length > 50) { Opt13Display = abbrevBackup(Opt13Display); } + backupDispDiv.innerText = Opt13Display; +} + +function abbrevBackup(rawText) { + // abbreviate backup file path for display + return rawText.slice(0, 23) + " ... " + rawText.slice(rawText.length-24); +} + // ----------- declare event handlers ---------- diff --git a/_note.vbs b/_note.vbs index 50a85d1..c8200af 100644 --- a/_note.vbs +++ b/_note.vbs @@ -11,13 +11,14 @@ ' 10. Custom x coord ' 11. Custom y coord ' 12. Status Bar: hide/show +' 13. Backup Location: current folder or user choice ' ----- set up variables, constants, & objects ------ Option Explicit -Dim fs, NewFileWithPath, rfile, afile, tfile, rofile, line -Dim Opt1, Opt2, Opt3, Opt4, Opt5, Opt6, Opt7, Opt8, Opt9, Opt10, Opt11, Opt12 +Dim fs, NewFileWithPath, rfile, afile, tfile, rofile, line, BackupLoc +Dim Opt1, Opt2, Opt3, Opt4, Opt5, Opt6, Opt7, Opt8, Opt9, Opt10, Opt11, Opt12, Opt13 Dim NoteWidth, NoteHeight, LeftXPos, RightXPos, MidXPos, TopYPos, MidYPos, BottomYPos Dim EditedString @@ -36,6 +37,7 @@ Const Default9 = "mm" Const Default10 = "0" Const Default11 = "0" Const Default12 = "show" +Const Default13 = ".\" Const OptionsFile = "config.txt" Const EOFConst = "<<>>" Const BackupPrefix = "backup_notes_" @@ -57,6 +59,7 @@ Opt9 = Default9 Opt10 = Default10 Opt11 = Default11 Opt12 = Default12 +Opt13 = Default13 NewFileWithPath = "" NoteWidth = screen.availWidth/1.7 NoteHeight = screen.availHeight/1.41 @@ -157,6 +160,7 @@ Sub AddNote(TempText) afile.WriteLine(GetTimeStampedLine(TempText)) afile.close showNotes(currentNote) + showStatus(AbbrevText(TempText) & " added to bottom") End Sub Function GetTimeStampedLine(LineText) @@ -230,6 +234,10 @@ Sub GetOptions(dummyVar) ' get option 12 - status bar if rofile.AtEndOfStream then rofile.close : OptionsCorrupted(11) : Exit Sub Opt12 = Lcase(rofile.Readline) + ' get option 13 - backup location + if rofile.AtEndOfStream then rofile.close : OptionsCorrupted(12) : Exit Sub + Opt13 = rofile.Readline + if Opt13 = "" then Opt13 = Default13 ' close file rofile.close Else @@ -251,11 +259,13 @@ Function GetOption(ThisOption) if ThisOption = "10" then GetOption = Opt10 if ThisOption = "11" then GetOption = Opt11 if ThisOption = "12" then GetOption = Opt12 + if ThisOption = "13" then GetOption = Opt13 End Function Sub OptionsCorrupted(numCorr) ' if options file not present or not formatted correctly, pass in any missing values & recreate it ' numCorr = number of options loaded succesfully + if numCorr < 13 then Opt12 = Default13 if numCorr < 12 then Opt12 = Default12 if numCorr < 11 then Opt11 = Default11 if numCorr < 10 then Opt10 = Default10 @@ -289,6 +299,7 @@ Sub WriteOptions tfile.WriteLine(Opt10) tfile.WriteLine(Opt11) tfile.WriteLine(Opt12) + tfile.WriteLine(Opt13) tfile.close if fs.FileExists(OptionsFile) then fs.DeleteFile(OptionsFile) fs.MoveFile TempFile, OptionsFile @@ -442,7 +453,7 @@ Sub RenameThisNote() End Sub Sub Backup - ' backup note files to notes_backup_date&time folder + ' backup note files to notes_backup_date&time folder, in specified folder ' use error handling ' make folder, copy config.txt & notes subfolder, check that they exist Dim d, t, BackupDate, BackupTime, BackupFolder, BackupNotesFolder, FileToCopy @@ -451,10 +462,10 @@ Sub Backup BackupDate = month(FormatDateTime(d,2)) & "-" & day(FormatDateTime(d,2)) & "-" & year(FormatDateTime(d,2)) BackupTime = Hour(Now) & "-" & Minute(Now) & "-" & Second(Now) BackupFolder = BackupPrefix & BackupDate & "_" & BackupTime + BackupFolder = Opt13 & BackupFolder & "\" On Error Resume Next fs.CreateFolder(BackupFolder) if ErrorCheckBackup then exit sub - BackupFolder = ".\" & BackupFolder & "\" On Error Resume Next fs.CopyFile OptionsFile, BackupFolder if ErrorCheckBackup then exit sub @@ -468,6 +479,7 @@ Sub Backup if ErrorCheckBackup then exit sub next msgbox "Backup Completed" + showOptions End Sub Function ErrorCheck @@ -550,6 +562,25 @@ Function AbbrevText(AbbrStr) AbbrevText = "'" & AbbrStr & "'" End Function +Sub ChangeBackup + ' change backup location + dim sh, bFolder + set sh = CreateObject("shell.application") + set bFolder = sh.BrowseForFolder(0, "Choose New Backup Location:", 0) + if (not bFolder is nothing) then + Opt13 = bFolder.Self.Path & "\" + WriteOptions + end if + set bFolder = nothing + set sh = nothing + dispBackupDiv +End Sub + +Function ShowDefaultBackup + ' get path of default backup location for display + ShowDefaultBackup = fs.GetFolder(Opt13) & "\" +End Function + ' ---------- execution -------------- diff --git a/note.hta b/note.hta index 3d5703a..5b59005 100644 --- a/note.hta +++ b/note.hta @@ -9,7 +9,7 @@ Scroll = no Icon = "note_icon.ico" navigable = no - version = "3.0.2" + version = "3.0.3" > Note @@ -131,7 +131,7 @@
-
+
@@ -142,6 +142,14 @@

+
+

+ Location of backup folder:

+
+


+
+
+