Skip to content

Instantly share code, notes, and snippets.

@k0t0vich
Created September 17, 2014 12:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save k0t0vich/4366472c6f6ff2e35d0e to your computer and use it in GitHub Desktop.
Save k0t0vich/4366472c6f6ff2e35d0e to your computer and use it in GitHub Desktop.
function invoke(func) {
riot.common.loadJS(window.location.protocol + _apiURL, function() {
if (_initialize < 2) {
_queue.push(func);
if (_initialize < 1) {
_initialize = 1;
var interval;
var f = function () {
if ( typeof(mailru) ) {
clearInterval(interval);
mailru.loader.require("api", function() {
_initialize = 2;
mailru.connect.init( CONFIG.desktop.mm.id, CONFIG.desktop.mm.key );
mailru.events.listen(mailru.connect.events.login, function(response) {
mailru.connect.getLoginStatus(function(response) {
mailru.common.users.getInfo(function(result) {
if($.cookie('Mpop')) {
return swa(_login[0], _login[1]);
}
riot.common.call("/fcgi/auth.php", { type: "mm", show: result[0].email },
{
success: function() {
if( $.cookie("atype") == "mm" ) {
if (_login[0]) _login[0]();
} else {
if (_login[1]) _login[1]();
}
},
error: function() { if (_login[1]) _login[1](); }
});
});
});
});
mailru.events.listen(mailru.connect.events.logout, function() {
});
while(_queue.length) _queue.shift()();
});
}
}
interval = setInterval(f, 1000);
f();
}
} else {
if (func) func();
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment