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

{| width="800"
 * style="background-color: #F2F2F2" align="center"|  |Main project page
 * style="background-color: #F2F2F2" align="center"|  |Main project page


 * colspan="2"|
 * colspan="2"|

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

 * 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(this.data[this.page]['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) { this.data[this.page][key] = val; this.data[this.page]['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.


 * }