User:Cmorse/Notebook/MediaWiki for Open Science/2009/01/29

From OpenWetWare
Jump to navigationJump to search
Report.pngMain project page
Next entryResultset next.png

Checking if a new revision of the page has been created when loading autosaved versione

SJK 01:35, 30 January 2009 (EST)
01:35, 30 January 2009 (EST)
These notes are perfect! Great work and thanks for starting this notebook.
  • Should be pretty easy to implement. Every page has a wgCurRevisionId global javascript variable that I can check for changes.
  • wgCureRevisionId doesn't seems to be really high given the actual number of edits on the page. Doing some tests to figure out why.
    • It appears to be a global count of revisions for the entire wiki, but it does not appear to change unless the current page is changed.
  • Got it working. Turned out to be easier than i originally expected. Here's some snippets of code that I had to change
if([]['rev'] != wgCurRevisionId) {
   alert('this page has changed since you started editing it');
} else {
   alert('this page has not chagned since you started editing it')

add: function(key, val) {[][key] = val;[]['rev'] = wgCurRevisionId;

Note: Mediawiki still picks up issues with revision conflicts even without the plugin detecting them. But this allows them to be seen long before the page is saved. Hopefully mitigating any possible issues.