2017-02-01 23:20:47 +01:00
|
|
|
jQuery(document).ready(function($) {
|
|
|
|
|
|
|
|
// Code submission
|
|
|
|
jQuery('#code_form').submit(function(e) {
|
|
|
|
e.preventDefault(); // this disables the submit button so the user stays on the page
|
|
|
|
|
|
|
|
// Validation
|
2017-03-02 22:13:56 +01:00
|
|
|
let code = $('input[name=code]').val();
|
|
|
|
|
2017-02-01 23:20:47 +01:00
|
|
|
if ( code.length < 8 ) {
|
2017-03-02 22:13:56 +01:00
|
|
|
|
2017-02-01 23:20:47 +01:00
|
|
|
jQuery('#resp').html('Code ist zu kurz!');
|
2017-03-02 22:13:56 +01:00
|
|
|
|
2017-02-01 23:20:47 +01:00
|
|
|
} else {
|
|
|
|
|
|
|
|
data = {'code' : $('input[name=code]').val(),
|
|
|
|
'action' : 'submit_code',
|
|
|
|
'format' : $('select[name=format]').val()
|
|
|
|
};
|
|
|
|
|
|
|
|
// ajax call
|
|
|
|
$.ajax({
|
|
|
|
type: "POST",
|
|
|
|
dataType: "json",
|
|
|
|
url: frontendajax.ajaxurl,
|
|
|
|
data: data})
|
|
|
|
.done(function(msg){
|
|
|
|
jQuery('#resp').html(msg.resp);
|
|
|
|
})
|
|
|
|
.fail( function(eins) { console.log("Fehler", eins);});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|