Changes

Jump to navigation Jump to search
726 bytes added ,  23:35, 18 April 2018
no edit summary
Line 106: Line 106:  
*/
 
*/
   −
mw.hook('mw.uls.interface.language.change').add(function (a, b, c){
+
mw.hook('mw.uls.interface.language.change').add(function (lang){
    console.log(a);
+
    setCookie('lang', lang);
    console.log(b);
+
    $.ajax({
     console.log(c);
+
        url: 'api.php',
 +
        data: {
 +
            action: 'query',
 +
            meta: 'tokens',
 +
            format: 'json'
 +
        },
 +
        xhrFields: {
 +
            withCredentials: true
 +
        },
 +
        dataType: 'json'
 +
    }).done(function (data){
 +
        $.ajax({
 +
            url: 'api.php',
 +
            method: 'POST',
 +
            data: {
 +
                action: 'options',
 +
                format: 'json',
 +
                token: data.query.tokens.csrftoken,
 +
                optionname: 'language',
 +
                optionvalue: lang
 +
            },
 +
            xhrFields: {
 +
                withCredentials: true
 +
            },
 +
            dataType: 'json'
 +
        }).done(function (data){
 +
            location.reload();
 +
        });
 +
     });
 
});
 
});
  

Navigation menu

GCwiki