Hello,
I'm new to Directory Opus community and I"m still learning the ropes of Directory Opus and I'm been loving it.
One of the scripts that is listed pretty much everywhere is this one. It's very well crafted and, considering the limits of JScript 5.6, it's even more impressive! Excellent job @tbone!
Sadly, it doesn't work with the (new?) forums. So I decided to try to upgrade it as an exercise to Directory Opus scripting
@tbone I hope you don't mind it. If this bothers you at all, please, tell me and I'll remove the script right away.
If you do like it and would like to use it as a base to keep improving it, you're more than welcome to do so. It is your script, after all
On my tests, it seems to be working nicely. Keep in mind I couldn't stress the code too much, since I'm new to DOpus and don't have many scripts installed.
Here is the file. Don't worry, it won't auto-update anyone, my modifications only check (on purpose) the first post of a forum topic
Command.Generic_ScriptWizard.js.txt (355.3 KB) v0.6.0 unofficial
(link removed per author's request)
A (terribly written) changelog:
- Updated most links with the new Directory Opus Resource Centre forum address scheme
- Added JSON parsing support (https://github.com/douglascrockford/JSON-js/blob/master/json2.js)
- It now uses the UID when checking if a downloaded script is valid
- Versions are compared using the number specified in the script itself (before, it was the forum text)
- Download function completely rewritten to support redirects and automatically download JSON when needed
- Download function now relies on
WinHttp.WinHttpRequest
to support and catch redirection URLs- New Function:
FetchScriptsData()
, responsible for downloading each script candidate and organizing them in a sorted arrayGetVersionsOfBestMatchingResource()
simplified, since the forums scheme changed
Some notes on the code:
- I come from a C++ background. The programming style is a bit different from the one used on the base code, but I couldn't stick to the one you used. Hopefully that won't be a problem. (Mostly, the curly braces are on different lines).
- I removed the check from your own website. It was already a daunting task to go into a language I'm not used to, on someone else's code, without the tools I'm used to work with. It's commented out, should be easy to restore.
- I did not remove the XML parsing utilities for HTML pages. Usually I'd remove, but IDK if you have other plans for them
- I hope you are not offended for me to upgrade your script, this was never my intent. If you are okay with this, I'd love to get your feedback if I screwed up in something or if I got things right
- I suggest you use Beyond Compare tool to check the differences between versions. IDK if DOpus has a tool for that, I'm sorry if it has.
- I tried using GitHub to keep the files, but apparently git does not work well with UCS-2 LE BOM files.
- I tried to avoid saving the files when downloading them to check versions, but I couldn't figure out a way to convert the stream to unicode/parseable format while in memory.
- It is probably possible to use the content downloaded to save the files, without needing to download them twice (as it does now). I think major changes would be required to make that happen, though. (I didn't explore this possibility, it was already complex enough for my crash course )
And please, to whomever is willing to attempt to use this script, please backup your scripts! While it should be safe, I'm not a veteran in JScript!
I hope to hear feedback from you guys!
Edit: I removed the link per author's request