Technical Discussion: JavaScript access to document and window information

Last saved modified and Other wiki, document/tab information

I thought this deserved its own Topic because there is some valuable work underway which is somewhat related.

  • This is too broad to be an Issue/discussion on GitHub
  • This is too technical to be a General talk.tiddlywiki discussion topic
  • Since its of a somewhat strategic discussion I want the developers and @jeremyruston to see this for their consideration
  • Dealing with these as a group will be far less time consuming than concidering them on an Ad Hoc basis.

@EricShulman raised his TiddlyTools/Time/LastModified.js in response to a continuing the discussion from Avoiding frustration for newbies this was in part triggered by my reference to this work;

It is interesting the relationships to lastmodified below;

  • However the git hub Idea has being expanded and generalised to include tools for
    • Ability to save last saved date
      • My interest here includes the ability to determine the “age since last save” to trigger a save, logout, user prompt etc… See the GitHub idea for more uses.
      • This also relates to Action on return to TiddlyWiki
    • @simon Also linked this to Autosave frequency throttle #6979
    • Pre-save actions, has being enabled by @pmario and @saqimtiaz developing this idea further.
      • my request for last saved date is just one example of using pre-save actions
      • With this solution @pmario has done a POC and is hinting at other issues, that should be pursued relating to Broadcast Channel API perhaps in a new issue?
  • Erics solution is another example of the value of very simple JavaScript functions being made available to the wiki designer/user.

Why Have I brought all this together?

Not only is @EricShulman’s lastmodified related to my “last saved date” request but it is an example of a very simple javascript function exposed to the tiddlywiki user/designer.

I have a growing collection of such solutions from Eric and others, I even wrote my own to retrieve and set the window/target name, but I need the “set window name” to be turned into an actionwidget [IDEA] Get and set window name and other possibilities #7136, If you can help make an action widget please do, it’s 90% done.

Examples include;

  • Reset dirty state on tab (someone)
  • Set and get cookies (Eric)
  • Get and set Local storage outside of the plugin (not existing)
  • Set and Get window name (me)
  • Get geo-location (possibly set) (someone)
  • Ability to read and write to session storage or IndexedDB (not yet available)

Javscript functions in General

  • Sometimes if you build the facility people will innovate on top of it in ways none of us can imagine initially,
    • for example the aforementioned pre-save actions supports house keeping activities such as saving the current history list to a cumulative one.
  • Keep in mind these functions need only be local to the current wiki in which the designer installs and configures these tools
    • Although Marios suggestion on the broadcast channel API is a little different.
    • If some features have privacy concerns consider people can already do this, by writing their own JS, its just not accessible to a general audience. If these were instead presented as core plugins they become available to everyone and become visible once installed.
  • Perhaps this process of writing Javascript macros to read or write some common document and browser value/function could be generalised into a single parametrised javascript function? Although we must consider its potential missuses.

Pre-save actions…

see TiddlyTools/SaveChanges/Info, TiddlyTools/Reset, and TiddlyTools/Panels/Reset

Get geo-location (possibly set) (someone)

see TiddlyTools/Widgets/action-getGPS.js as used by the “circle with crosshairs” button in TiddlyTools/Panels/Location which saves the current GPS data as JSON in $:/Location/Data