Dear javascript folks, and perhaps @linonetwo in particular:
My “customers” (students) really should NOT see a “Do you really want to close/leave???” warning. They’re not editing, and there’s nothing for them to save, so it’s distracting.
I happily installed the prevent-edit plugin to solve this problem. The core of the thing is super-simple (though the plugin has readme and other plugin stuff):
exports.startup = function() {
$tw.unloadTasks = $tw.unloadTasks.filter(task => !task.toString().includes('confirmationMessage'));
}
Recently I’ve gotten burned a few times in a row; I’ve lost serious author-mode work because of completely accidental tab-closures (errant key-strokes, mouse-clicks that land “behind” where I think I’m clicking, etc.).
So, javascript-savvy folks: How do I hack prevent-edit so that it CHECKS whether the wiki is in read-only mode, and prevents the alert ONLY IF wiki is in read-only mode?
In other words, I want to KEEP the alert (preventing accidental closure with unsaved work), just when:
-
$:/config/utility/IsReaderModehas valueno - Or:
$:/status/IsLoggedInhas valueyeswould be equivalent for me, in practice.
Many thanks in advance!