Uit Hack42
| (4 tussenliggende versies door dezelfde gebruiker niet weergegeven) | |||
| Regel 12: | Regel 12: | ||
}, | }, | ||
function( data ) { | function( data ) { | ||
| − | |||
if ( data.query.pages && data.query.pageids ) { | if ( data.query.pages && data.query.pageids ) { | ||
var pageid = data.query.pageids[0]; | var pageid = data.query.pageids[0]; | ||
| Regel 30: | Regel 29: | ||
titles: wgPageName, | titles: wgPageName, | ||
rvsection: section_id, | rvsection: section_id, | ||
| − | format: 'json' | + | format: 'json', |
| − | + | success: | |
| − | + | function( data ) { | |
| − | + | alert(data); | |
| − | + | if ( data.query.pages) for (var pageid in data.query.pages) { | |
| − | + | wgContent = data.query.pages[pageid].revisions['*']; | |
| − | + | alert(wgContent); | |
| + | } | ||
| + | } | ||
} | } | ||
) | ) | ||
Huidige versie van 27 feb 2012 om 21:29
/* JavaScript die hier wordt geplaatst heeft invloed op alle pagina's voor alle gebruikers */
function getEditToken() {
jQuery.getJSON(
wgScriptPath + '/api.php?',
{
action: 'query',
prop: 'info',
intoken: 'edit',
titles: 'Main Page',
indexpageids: '',
format: 'json'
},
function( data ) {
if ( data.query.pages && data.query.pageids ) {
var pageid = data.query.pageids[0];
wgEditToken = data.query.pages[pageid].edittoken;
}
}
)
}
function getSection(section_id) {
jQuery.getJSON(
wgScriptPath + '/api.php?',
{
action: 'query',
prop: 'revisions',
rvlimit: 1,
rvprop: 'content',
titles: wgPageName,
rvsection: section_id,
format: 'json',
success:
function( data ) {
alert(data);
if ( data.query.pages) for (var pageid in data.query.pages) {
wgContent = data.query.pages[pageid].revisions['*'];
alert(wgContent);
}
}
}
)
}
jQuery().ready(function() {
getEditToken()
user = wgUserName;
if (user) {
titels = '#Ik_kom_wel,#Ik_kom_niet,#Animo,#Aanwezig,#Afwezig,#Wie,#Wie_niet';
var user_is_al_in_lijst = jQuery(titels).parent().nextAll('ul').find('li a:contains("' + user + '")');
if (user_is_al_in_lijst.length) {
// user_is_al_in_lijst.parent().append('<input type="button" value="-"/>');
} else {
jQuery(titels).each(function(index, val) {
var ul = jQuery(val).parent().nextAll('ul:first')
var section_id = jQuery(val).parent().children('span').children('a').attr('href').match(/section=([0-9]+)/)[1]
var li = ul.append('<li><input type="button" value="' + user + '"/><input type="text" value="+soep, oid +debug" /></li>');
ul.find('li:contains("...")').remove();
jQuery(li).find('input[type="button"]').click(function() {
getSection(section_id);
alert(wgContent);
});
jQuery(li).find('input[type="text"]').focus(function(){
if(this.value == '+soep, oid') {
this.value='';
jQuery(this).css({'color':'black'});
};
});
jQuery(li).find('input[type="text"]').css({'color':'lightgray'});
jQuery(li).find('input[type="text"]').blur(function(){
if(this.value == ''){
this.value='+soep, oid';
jQuery(this).css({'color':'lightgray'});
};
});
});
}
}
})