-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathscripts.js
39 lines (32 loc) · 1.75 KB
/
scripts.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
( function( $ ) {
$( document ).ready( function() {
$('#diffy-register').click(function() {
$('.diffy-register-error').remove();
$('.diffy-register-wrapper').after('<div class="updating-message"><p>Registering a user and creating project...</p></div>');
$('.diffy-register-wrapper').hide();
var data = {
'action' : 'diffy_register'
};
$.post( settings.ajaxurl, data, function( response ) {
var data = response.data;
if (response.success) {
var success_message = '<div id="setting-error-settings_updated" class="notice notice-success settings-error is-dismissible"> \n' +
'<p><strong>Diffy account & project created.</strong> It is created by using your email address "' + data.email + '" and password "' + data.password + '". Please note these credentials. But no worries you can always reset the password if you need to.</p></div>';
$('.diffy-register-wrapper').html(success_message);
$('input[name=diffy_api_key]').val(data.diffy_api_key);
$('input[name=diffy_project_id]').val(data.diffy_project_id);
}
else {
var error_message = '<div id="setting-error-settings_updated" class="diffy-register-error notice notice-error settings-error is-dismissible"> \n' +
'<p><strong>' + data.error_message + '.</strong> Please go to <a target="_blank" href="https://app.diffy.website">Diffy app</a> and retrieve API Key and set up the project manually.</p></div>';
$('.diffy-register-wrapper').append(error_message);
}
$('.updating-message').remove();
$('.diffy-register-wrapper').show();
})
.fail(function() {
console.log( "Ajax error" );
});
});
});
})( jQuery );