Browse Source

generalize IguanaJumblr.js

master
pbca26 8 years ago
parent
commit
c2ebe0e355
  1. 39
      assets/scripts/iguana_api/IguanaJumblr.js

39
assets/scripts/iguana_api/IguanaJumblr.js

@ -1,13 +1,7 @@
function Iguana_Jumblr_SetPassphrase(data) { function Generic_Iguana_Jumblr(ajax_data, resolve) {
return new Promise((resolve) => { var tmpIguanaRPCAuth = 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth');
var tmpIguanaRPCAuth = 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
ajax_data = {
'userpass': tmpIguanaRPCAuth,
'agent': 'jumblr',
'method': 'setpassphrase',
'passphrase': data.passphrase
};
ajax_data.userpass = tmpIguanaRPCAuth;
$.ajax({ $.ajax({
data: JSON.stringify(ajax_data), data: JSON.stringify(ajax_data),
url: 'http://127.0.0.1:' + config.iguanaPort, url: 'http://127.0.0.1:' + config.iguanaPort,
@ -17,26 +11,27 @@ function Iguana_Jumblr_SetPassphrase(data) {
.done(function(data) { .done(function(data) {
resolve(data); resolve(data);
}); });
}
function Iguana_Jumblr_SetPassphrase(data) {
var ajax_data = {
'agent': 'jumblr',
'method': 'setpassphrase',
'passphrase': data.passphrase
};
return new Promise((resolve) => {
Generic_Iguana_Jumblr(ajax_data, resolve);
}); });
} }
function Iguana_Jumblr_Status() { function Iguana_Jumblr_Status() {
return new Promise((resolve) => { var ajax_data = {
var tmpIguanaRPCAuth = 'tmpIgRPCUser@' + sessionStorage.getItem('IguanaRPCAuth'),
ajax_data = {
'userpass': tmpIguanaRPCAuth,
'agent': 'jumblr', 'agent': 'jumblr',
'method': 'status' 'method': 'status'
}; };
$.ajax({ return new Promise((resolve) => {
data: JSON.stringify(ajax_data), Generic_Iguana_Jumblr(ajax_data, resolve);
url: 'http://127.0.0.1:' + config.iguanaPort,
type: 'POST',
dataType: 'json'
})
.done(function(data) {
resolve(data);
});
}); });
} }
Loading…
Cancel
Save