xhprof: Guard against division by 0 when computing percentages
[lhc/web/wiklou.git] / resources / src / mediawiki.action / mediawiki.action.edit.stash.js
1 /*!
2 * Scripts for pre-emptive edit preparing on action=edit
3 */
4 ( function ( mw, $ ) {
5 $( function () {
6 var api = new mw.Api(), pending = null, $form = $( '#editform' );
7
8 function stashEdit( token ) {
9 var data = $form.serializeObject();
10
11 pending = api.post( {
12 action: 'stashedit',
13 token: token,
14 title: mw.config.get( 'wgPageName' ),
15 section: data.wpSection,
16 sectiontitle: data.wpSection === 'new' ? data.wpSummary : '',
17 text: data.wpTextbox1,
18 contentmodel: data.model,
19 contentformat: data.format,
20 baserevid: data.parentRevId
21 } );
22 }
23
24 $form.on( 'change', function () {
25 if ( pending ) {
26 pending.abort();
27 }
28 api.getToken( 'edit' ).then( stashEdit );
29 } );
30 } );
31 }( mediaWiki, jQuery ) );