Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $( '#ca-watch' ).click( function ( e ) {
- e.preventDefault();
- ( new mw.Api ).postWithToken( 'watch', {
- action: 'watch',
- titles: mw.config.get( 'wgTitle' )
- } ).done( function( wlResult) {
- if ( wlResult.watch[ 0 ].watched !== undefined ) {
- $( '#ca-watch' ).find( 'a' ).parents( 'span' ).html( $( '#ca-watch' ).find( 'a' ).parents().html().replace( 'action=watch', 'action=unwatch' ) );
- $( '#ca-watch' ).find( 'a' ).attr( 'title', $( '#ca-watch' ).find( 'a' ).attr( 'title' ).replace( 'Add this page to', 'Remove this page from' ) );
- $( '#ca-watch' ).find( 'a' ).text( 'Unwatch' );
- $( '#ca-watch' ).attr( 'id', 'ca-unwatch' );
- }
- } );
- } );
- $( '#ca-unwatch' ).click( function ( e ) {
- e.preventDefault();
- ( new mw.Api ).postWithToken( 'watch', {
- action: 'watch',
- unwatch: true,
- titles: mw.config.get( 'wgTitle' )
- } ).done( function( wlResult ) {
- if ( wlResult.watch[ 0 ].unwatched !== undefined ) {
- $( '#ca-unwatch' ).find( 'a' ).attr( 'href', $( '#ca-unwatch' ).find( 'a' ).attr( 'href' ).replace( 'action=unwatch', 'action=watch' ) );
- $( '#ca-unwatch' ).find( 'a' ).attr( 'title', $( '#ca-unwatch' ).find( 'a' ).attr( 'title' ).replace( 'Remove this page from', 'Add this page to' ) );
- $( '#ca-unwatch' ).find( 'a' ).text( 'Watch' );
- $( '#ca-unwatch' ).attr( 'id', 'ca-watch' );
- }
- } );
- } );
Add Comment
Please, Sign In to add comment