From 6d01700a7e178f139c17412de083970e6ea39d5b Mon Sep 17 00:00:00 2001 From: Rob Moen Date: Wed, 11 Jan 2012 00:17:17 +0000 Subject: [PATCH] add js resource for concurrency api, check method for resource checkin & checkout --- resources/Resources.php | 3 ++ resources/jquery/jquery.concurrency.js | 42 ++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 resources/jquery/jquery.concurrency.js diff --git a/resources/Resources.php b/resources/Resources.php index 667d5ca6c8..2f73f24bc1 100644 --- a/resources/Resources.php +++ b/resources/Resources.php @@ -112,6 +112,9 @@ return array( 'jquery.colorUtil' => array( 'scripts' => 'resources/jquery/jquery.colorUtil.js', ), + 'jquery.concurrency' => array( + 'scripts' => 'resources/jquery/jquery.concurrency.js', + ), 'jquery.cookie' => array( 'scripts' => 'resources/jquery/jquery.cookie.js', ), diff --git a/resources/jquery/jquery.concurrency.js b/resources/jquery/jquery.concurrency.js new file mode 100644 index 0000000000..fec95e5932 --- /dev/null +++ b/resources/jquery/jquery.concurrency.js @@ -0,0 +1,42 @@ +/** + * Base jQuery plugin for Concurrency + * + * @author Rob Moen + */ + +(function ( $ ) { + $.concurrency = { + /* + * Checkin our checkout an object via API + * @param ccaction: checkout, checkin + * @param resourcetype: extension specific type (string) + * @param record: resource id (int) + * @param callback: function to handle response + */ + check: function( params, callback ) { + params = $.extend({ + action: 'concurrency', + token: mw.user.tokens.get( 'editToken' ), + format: 'json' + }, params); + + return $.ajax( { + type: 'POST', + url: mw.util.wikiScript( 'api' ), + data: params, + success: function( data ){ + if ( typeof callback == 'function' ){ + callback(data); + } + }, + error: function( data ){ + if ( typeof callback == 'function' ){ + callback(data); + } + }, + dataType: 'json' + } ); + } + }; + +})( jQuery ); \ No newline at end of file -- 2.20.1