User:Technical 13/SandBox/Section edit.js

/* GLOBAL */ var sectionID_tag = 0; $( 'span.mw-headline' ).each( function{	sectionID_tag++;	$( this ).html( $( this ).html + ' [LOG INFO]' );	$( this ).addClass( 'section-' + sectionID_tag ); }); function logInfo{ var pageTitle = mw.config.get('wgPageName'); console.info( 'The page title is: %s', pageTitle ); var pageID = 0; console.info( 'The page ID is: %d', pageID ); var sectionID = $('FIGURE ME OUT').parent.prev.find('span').attr('class'); sectionID = sectionID.substring(sectionID.indexOf('section-')+8); console.info( 'The sectionID is: %d', sectionID ); var pageCurrText = ""; console.info( 'The pageCurrText is: %s', pageCurrText ); // getSectionText } /* GLOBAL */

/* Not yet stuff... Let's just get the section ID for now function jqEsc(expression) { return expression.replace(/[!"#$%&'*+,.\/:;<=>?@\[\\\]^`{|}~]/g, '\\$&'); } function getSectionText { console.group;	return $.ajax({		url: mw.config.get('wgServer') + mw.config.get('wgScriptPath') 		+ '/api.php?action=query&format=json&indexpageids=true&prop=revisions&rvprop=content' + 		+ '&rvsection=' + sectionID + '&titles=' + pageTitle,		dataType: 'json',		success: function(response){			pageID = response.query.pageids[0];			pageCurrText = response.query.pages[pageID].revisions[0]['*'];			console.info('Page ID: %d contains:\n%s', pageID, pageCurrText)		},		error: function(response){			console.warn('Failed:\n%s', response);		}	});	.done{		console.log('Passed: ')	}	.fail{		console.warn('Failed: ')	} console.groupEnd; }