User:Gryllida/js/ajaxSectionUpdateOnDoubleClick.js

/* Author : Svetlana Tkachenko svetlana@members.fsf.org This file is a part of ajaxSectionUpdateOnDoubleClick. Licence: GPLv3+ Version: 0.1 Release date: 2018-02-26 Description: updates a section when double-clicked (useful on talk pages sometimes)

$('.mw-headline').each(function(i){	var $self = $(this);	//alert(i);   //alert($self.text);    var $anchor = $self.parent;    $anchor.nextUntil( "h2" ).dblclick(function{ console.log('hi'); var api = new mw.Api; api.get( { // Corresponds to "api.php?action=parse&page=test"   		action: 'parse',    		page: mw.config.get( 'wgPageName' ),    		section: i+1		} ).done(function(data){			var html = data.parse.text['*'];			//$(this).replacewith($(' j '));    		$anchor.nextUntil( "h2" ).remove;    		$anchor.replaceWith($(html));		}) }); });