This repository has been archived on 2026-10-23. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
inside/js/migration/byebye_inside.js
T
nikolark 52cc657538 Major cleanups
* Structures static file locations
* Moves index.php to /
* Updates paths all over
* Hides menu items of unused features
* Hides menu items of legacy features
* Adds README
2012-04-20 23:45:21 +02:00

98 lines
3.4 KiB
JavaScript

function init_validation() {
$("#form_migrate").validate({
rules: {
username: {
required: true,
rangelength: [3, 12],
lettersonly: true,
remote: "./migration/username_available.php",
},
password: {
required: true,
minlength: 8,
noquotes: true,
noescapes: true,
},
password_check: {
required: true,
minlength: 8,
noquotes: true,
noescapes: true,
equalTo: "#id_password",
},
},
messages: {
username: {
remote: 'Username is taken.',
}
},
submitHandler: function(form) {
var form_username = $("#id_username").val();
var form_password = $("#id_password").val();
var form_password_check = $("#id_password_check").val();
var form_uid = $("#id_uid").val();
$.ajax({
url: "./migration/submit_user.php",
type: 'POST',
data: {
username: form_username,
password: form_password,
password_check: form_password_check,
},
dataType: 'json',
success: function(result) {
if(result.result == 'success') {
$("#infomodal").html("Brukeren din er klar for fremtiden, <strong>tusen takk!</strong>");
$("#infomodal").dialog('option',{
buttons: {
"Ok": function() {
$(this).dialog('close');
},
},
});
}
else {
/* Output the errors (will never happend). */
var output = '<div style="padding: 0 .7em;" class="ui-state-error ui-corner-all">';
for(var error in result.errors) {
output += '<p><span style="float: left; margin-right: .3em;" class="ui-icon ui-icon-alert"></span><strong>'+ error +':</strong> ' + result.errors[error] + '</p>';
}
output += '</div>';
$("#infomodal").prepend(output);
}
},
});
return false;
},
});
}
$( document ).ready( function() {
$( "#infomodal" ).dialog({
/* 1. Info about the migration. */
autoOpen: false,
height: 450,
width: 600,
modal: true,
buttons: {
"Ok": function() {
/* 2. Load in the user and pass form. */
$(this).load('./migration/form.php', function() {
init_validation();
$(this).dialog('option',{
buttons: {
"Lagre brukerdata": function() {
$("#form_migrate").submit();
}
}
});
});
},
"Ikke nå": function() {
/* The user chooses to not migrate. */
$(this).dialog("close");
}
}
});
});