Skip to content

Commit

Permalink
v3.0.3:
Browse files Browse the repository at this point in the history
   - 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
  • Loading branch information
freginold authored Sep 9, 2016
1 parent d9b9a0e commit cf91373
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 8 deletions.
14 changes: 14 additions & 0 deletions _note.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
24 changes: 22 additions & 2 deletions _note.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -53,7 +56,6 @@ var localFontSetButton = [
document.getElementById('localFontSetButton2'),
document.getElementById('localFontSetButton3'),
];
var aboutDiv = document.getElementById('aboutDiv');
var inputs = [];
var items = [];
var uFont = ['', '', '', ''];
Expand Down Expand Up @@ -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 = '';
Expand Down Expand Up @@ -354,7 +357,6 @@ function getLines(thisNote) {
function onSubmitted(tempVar) {
event.returnValue = false;
AddNote(tempVar)
showStatus(AbbrevText(tempVar) + " added to bottom");
}

function showX(self) {
Expand Down Expand Up @@ -546,6 +548,7 @@ function insertItem() {
// add "insert" class to item text <td> 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));
Expand Down Expand Up @@ -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 ----------

Expand Down
39 changes: 35 additions & 4 deletions _note.vbs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -36,6 +37,7 @@ Const Default9 = "mm"
Const Default10 = "0"
Const Default11 = "0"
Const Default12 = "show"
Const Default13 = ".\"
Const OptionsFile = "config.txt"
Const EOFConst = "<<<EOF>>>"
Const BackupPrefix = "backup_notes_"
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -468,6 +479,7 @@ Sub Backup
if ErrorCheckBackup then exit sub
next
msgbox "Backup Completed"
showOptions
End Sub

Function ErrorCheck
Expand Down Expand Up @@ -550,6 +562,25 @@ Function AbbrevText(AbbrStr)
AbbrevText = "<span class='nonItalic'>'" & AbbrStr & "'</span>"
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 --------------

Expand Down
12 changes: 10 additions & 2 deletions note.hta
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
Scroll = no
Icon = "note_icon.ico"
navigable = no
version = "3.0.2"
version = "3.0.3"
>
<title>Note</title>
<link href='_note.css' rel='stylesheet' type='text/css'>
Expand Down Expand Up @@ -131,7 +131,7 @@
<label><input type='radio' name='statusOption' class='optionInput' value='Hide' /> Hide</label><br />
<label><input type='radio' name='statusOption' class='optionInput' value='Show' /> Show&nbsp;<span class='goItalic'>(default)</span></label>
<div id='optionsSpacer'></div>
<button id='backupButton' onclick='Backup()'>Backup</button><br />
<button id='backupButton' onclick='dispBackupDiv();'>Backup...</button><br />
<button id='undeleteButton' onclick='Undelete()' disabled=true>Restore last deleted item</button>
</td>
</tr></table>
Expand All @@ -142,6 +142,14 @@
<p id='versionInfo'></p>
</div>

<div id='backupDiv'>
<br /><br />
<span id='backupText'>Location of backup folder:</span><br /><br />
<div id='backupDispDiv'></div><button onclick='ChangeBackup()'>Change...</button>
<br /><br /><br />
<button onclick='Backup()'>Backup</button><br />
</div>

<div id='statusBar'><hr>&nbsp;</div>

<script language='vbscript' src='_note.vbs'></script>
Expand Down

0 comments on commit cf91373

Please sign in to comment.