github.com/feiyang21687/docker@v1.5.0/docs/theme/mkdocs/js/dockerfile_tutorial.js (about) 1 function clean_input(i) { 2 return i.replace(/^\s+|\s+$/g, ''); 3 } 4 5 function clean_up(str){ 6 return clean_input(str).toUpperCase(); 7 } 8 9 function dockerfile_log(level, item, errors) 10 { 11 var logUrl = '/tutorial/api/dockerfile_event/'; 12 $.ajax({ 13 url: logUrl, 14 type: "POST", 15 cache:false, 16 data: { 17 'errors': errors, 18 'level': level, 19 'item': item, 20 }, 21 }).done( function() { } ); 22 } 23 24 function validate_email(email) 25 { 26 var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; 27 return re.test(email); 28 } 29 30 $(document).ready(function() { 31 32 /* prepare to send the csrf-token on each ajax-request */ 33 var csrftoken = $.cookie('csrftoken'); 34 $.ajaxSetup({ 35 headers: { 'X-CSRFToken': csrftoken } 36 }); 37 38 $("#send_email").click( function() 39 { 40 $('#email_invalid').hide(); 41 $('#email_already_registered').hide(); 42 $('#email_registered').hide(); 43 44 email = $('#email').val(); 45 if (!validate_email(email)) 46 { 47 $('#email_invalid').show(); 48 return (false); 49 } 50 51 var emailUrl = '/tutorial/api/subscribe/'; 52 53 $.ajax({ 54 url: emailUrl, 55 type: "POST", 56 cache:false, 57 data: { 58 'email': email, 59 'from_level': $(this).data('level') 60 }, 61 }).done( function(data ) { 62 if (data == 1) // already registered 63 { 64 $('#email_already_registered').show(); 65 } 66 else if (data == 0) // registered ok 67 { 68 $('#email_registered').show(); 69 } 70 71 } ); 72 return (true); 73 }); 74 })