OK, I’m done. I’ve looked at the images and skimmed the text of every help file page. This is a very impressive document. I think the first one, about the paid image is the only real problem I found. Everything else is just suggestions or impressions, to take for what they’re worth.
Also, just navigating help, I was worried I wasn’t following all the links or seeing every single page, so hacked together this script. Still a work in progress, but I’m pretty confident I visited every page.
use framework "Foundation"
use AppleScript version "2.4"
use scripting additions
use script "Myriad Tables Lib"
--> Script Debugger 7.0 (7A35)
property sdVersionForHelp : "Script Debugger-7.0-7A35" -- -
property sdHelpDir : "sd7help"
property sdAppId : "com.latenightsw.ScriptDebugger7"
property debugging : false -- logging
property screenFraction : 3 --how much screen should results take
property previousSearchCount : 20 -- how many previous searches to remember
property allHelpTextFiles : {}
property fullScreenWindowBounds : {}
property helpFileList : {}
property helpTextFolder : ""
property htmlResultsPage : ""
property lastSearch : "Script Debugger Help"
property logFile : ""
property logInfo : ""
property previousFinds : {}
property previousSearches : {}
property sdHelpFileLocation : ""
property currentVersionInfo : ""
property searchDate : ""
property helpFileDisplayList : {}
property slugDate : ""
property startingTime : ""
property workFlowFolder : ""
property searchResultsFolder : ""
property sdLocation : ""
property updateIsNeeded : true
property lastSelectedRow : {0}
on run
set currentSDVersion to SDVersion()
--
set updateIsNeeded to true --note out when not debugging
--
if helpFileDisplayList is {} then
set lastSelectedRow to {0}
set sdHelpFileLocation to HelpFileLocation()
if debugging then UpDateLog("Locating Help File", logFile)
LocateHelpFiles(sdHelpFileLocation)
--Sets helpFileList
set AppleScript's text item delimiters to {"<Title>", "</Title>"}
set helpFileDisplayList to {}
repeat with thisHelpFile in helpFileList
set thisHelpFile to thisHelpFile as item
set helpFileTitle to read thisHelpFile
set helpFileTitle to paragraph 1 of text item 2 of helpFileTitle
set the end of helpFileDisplayList to {helpFileTitle, "", thisHelpFile as item}
end repeat
end if
set markedFiles to {}
repeat
set {chosenItem, chosenFile, buttonNumber, helpFileDisplayList} to DisplayHelpTable()
if buttonNumber is 2 then
set the end of markedFiles to item chosenItem of helpFileDisplayList
set item 2 of item chosenItem of helpFileDisplayList to "S"
else
set item 2 of item chosenItem of helpFileDisplayList to "√"
set fileToDisplay to item 3 of item 1 of chosenFile
my DisplayHelpFile(fileToDisplay)
end if
end repeat
end run
on DisplayHelpFile(htmlDisplayFile)
if fullScreenWindowBounds is {} then -- First run only, learns size of screen
tell application "Finder" to set fullScreenWindowBounds to (bounds of desktop's window)
set {windowLeft, windowTop, windowRight, windowBottom} to fullScreenWindowBounds
set {windowLeft, windowTop} to {25, 23}
set fullScreenWindowBounds to {windowLeft, windowTop, windowRight, windowBottom}
end if
tell application "System Events"
set helpFileURL to URL of (htmlDisplayFile as alias)
end tell
tell application "Google Chrome"
set helpWindow to make new window
set URL of tab 1 of helpWindow to helpFileURL
tell helpWindow
set {windowLeft, windowTop, windowRight, windowBottom} to fullScreenWindowBounds
set bounds to {(windowRight / screenFraction) * (screenFraction - 1), windowTop, windowRight, windowBottom}
end tell
end tell
end DisplayHelpFile
on DisplayHelpTable()
set nextRow to item 1 of lastSelectedRow
set nextRow to nextRow + 1
if nextRow > (count of helpFileDisplayList) then
set nextRow to 1
end if
set helpFileTable to make new table with data helpFileDisplayList ¬
with title ¬
"Help Files" with prompt ¬
"Select which file to open" multiple selections allowed false ¬
can add and delete false ¬
column headings {"Help File Topic", "Seen"} ¬
row numbering false ¬
initially selected rows {nextRow} ¬
empty selection allowed false ¬
multiple lines allowed false ¬
with double click means OK
modify table helpFileTable ¬
OK button name ¬
"View" OK button is default true ¬
cancel button name ¬
"Finish" extra button name ¬
"Save this one" highlighted rows {} ¬
row dragging false ¬
column reordering false ¬
hidden cancel button false ¬
initial position {600.0, 0.0, 393.0, 900.0}
set tableResults to display table helpFileTable ¬
with extended results
set modifiedTable to values returned of tableResults
set lastSelectedRow to rows selected of tableResults
set valueSelected to values selected of tableResults
set buttonNumber to button number of tableResults
set finalPosition to final position of tableResults
return {lastSelectedRow, valueSelected, buttonNumber, modifiedTable}
--final position:{731.0, -38.0, 433.0, 952.0}
end DisplayHelpTable
-------------
on HelpFileLocation()
--on HelpFileLocation(mainFileName, appId, HelpFileDirectory)
--set helpFilePath to (path to resource mainFileName in bundle (path to appId) in directory HelpFileDirectory)
set helpFilePath to (path to resource "toc.html" in bundle (path to application id (sdAppId as text)) in directory sdHelpDir)
tell application "Finder"
set sdHelpFileLocaton to container of helpFilePath as alias
if debugging then open sdHelpFileLocaton
end tell
return sdHelpFileLocaton
end HelpFileLocation
on LocateHelpFiles(sdHelpFileLocaton)
set helpFileList to {}
ProcessAFolder(sdHelpFileLocaton)
end LocateHelpFiles
on SDVersion()
set mustUpdate to false
set sdPath to (path to application id sdAppId)
if sdPath is not sdLocation then
set sdLocation to sdPath
set sdVersionForHelp to "" --forces an update
end if
set sdPath to POSIX path of sdPath
set sdPlist to quoted form of (sdPath & "Contents/Info.plist")
set _cmd to "/usr/libexec/PlistBuddy -c Print:CFBundleShortVersionString -c Print:CFBundleVersion " & sdPlist
set currentVersionInfo to paragraphs of (do shell script _cmd)
set currentVersionInfo to "Script Debugger " & item 1 of currentVersionInfo & " (" & item 2 of currentVersionInfo & ")"
set AppleScript's text item delimiters to {"-"}
set currentVersionInfo to words of currentVersionInfo as text
return currentVersionInfo
end SDVersion
-------------
on FixText(HelpFileText, thisHelpFile)
tell application "System Events" to set helpFileURL to URL of thisHelpFile
set HelpFileText to the rest of paragraphs of HelpFileText
set item 1 of HelpFileText to helpFileURL
set AppleScript's text item delimiters to {return}
set HelpFileText to HelpFileText as text
set HelpFileText to ReplaceAllInText(return & return & return, return & return, HelpFileText)
end FixText
on ReplaceText(findString, replaceString, textToFix)
set saveTID to AppleScript's text item delimiters
set AppleScript's text item delimiters to findString as list
set textToFix to every text item of textToFix
set AppleScript's text item delimiters to replaceString as list
set textToFix to textToFix as text
set AppleScript's text item delimiters to saveTID
return textToFix
end ReplaceText
on ProcessAFolder(thisFolder)
tell application "Finder"
set myHelpFiles to (every file of thisFolder whose name extension is "html") as alias list
set myFolders to every folder of thisFolder as alias list
end tell
set helpFileList to helpFileList & myHelpFiles
repeat with aFolder in myFolders
my ProcessAFolder(aFolder)
end repeat
end ProcessAFolder
on ReplaceAllInText(findString, replaceString, textToFix)
--findString: text or a list of text strings (all will be replaced)
--replaceString: texx or a list of text strings (only first will be used)
--textToFix: text
set saveTID to AppleScript's text item delimiters
repeat
set AppleScript's text item delimiters to findString as list
set textToFix to every text item of textToFix
if (count of textToFix) = 1 then
set textToFix to textToFix as text
exit repeat
end if
set AppleScript's text item delimiters to {replaceString}
set textToFix to textToFix as text
if replaceString is in {findString} then exit repeat -- exits after one pass to avoid infinite loop
end repeat
set AppleScript's text item delimiters to saveTID
return textToFix as text
end ReplaceAllInText
on UpDateLog(logInfo, myFile)
set logTime to (current date)
set elapsedTime to (time of (logTime) as integer) - startingTime
log elapsedTime & tab & logInfo
set logTime to short date string of logTime & " " & time string of logTime & " Seconds since start: " & elapsedTime as text
set textToWrite to return & logTime & return & tab & logInfo & return
try
set openFile to open for access file myFile with write permission
on error errMsg number errNum
close access file myFile
set openFile to open for access file myFile with write permission
end try
set startPoint to get eof file myFile
write textToWrite to openFile starting at startPoint
close access openFile
return myFile
end UpDateLog
on WriteToFile(myFile, textToWrite)
try
set openFile to open for access file myFile with write permission
on error errMsg number errNum
close access myFile
set openFile to open for access file myFile with write permission
end try
set eof of openFile to 1
write textToWrite to openFile
close access openFile
return myFile
end WriteToFile