function register() {
d=document;
d.getElementById("proceed").innerHTML='';
user = (d.getElementById("name"))?d.getElementById("name").value:'';
email = (d.getElementById("email"))?d.getElementById("email").value:'';
pass = (d.getElementById("password"))?d.getElementById("password").value:'';
type = (d.getElementById("type"))?d.getElementById("type").value:'';
JsHttpRequest.query(
'register.php', // backend
{
// pass a text value
'user': user,
'email': email,
'pass': pass,
'type': type
},
// Function is called when an answer arrives.
function(result, errors) {
// Write errors to the debug div.
document.getElementById("proceed").innerHTML = errors;
// Write the answer.
if (result) {
document.getElementById("proceed").innerHTML = result["str"];
if('__msgwait' in window) {
window.clearTimeout(window.__msgwait)
}
window.__msgwait = window.setTimeout(function(){$( "#dialog-form" ).dialog( "close" );}, 7000);
}
},
true // do not disable caching
);
}
function recovery() {
d=document;
d.getElementById("proceed_").innerHTML='';
email = (d.getElementById("email_"))?d.getElementById("email_").value:'';
JsHttpRequest.query(
'recovery.php', // backend
{
// pass a text value
'email': email
},
// Function is called when an answer arrives.
function(result, errors) {
// Write errors to the debug div.
document.getElementById("proceed_").innerHTML = errors;
// Write the answer.
if (result) {
document.getElementById("proceed_").innerHTML = result["str"];
if('__msgwait' in window) {
window.clearTimeout(window.__msgwait)
}
window.__msgwait = window.setTimeout(function(){$( "#dialog-recovery" ).dialog( "close" );}, 7000);
}
},
true // do not disable caching
);
}
$(function() {
// a workaround for a flaw in the demo system (http://dev.jqueryui.com/ticket/4375), ignore!
if(navigator.userAgent.match("MSIE")) var px='px';
else px='';
$( "#dialog:ui-dialog" ).dialog( "destroy" );
$( "#dialog-confirm" ).dialog({
autoOpen: false,
resizable: false,
width:"350",
height:"180"+px,
modal: true,
buttons: {
"Закрыть окно": function() {
$( this ).dialog( "close" );
}
}
});
$( "#dialog-recovery" ).dialog({
autoOpen: false,
resizable: false,
width:"350",
height:"240"+px,
modal: true,
buttons: {
"Отправить": function() {
//$( this ).dialog( "close" );
$( "button" ).button({ disabled: true });
recovery();
}
}
});
$( "#tech-req-window" ).dialog({
autoOpen: false,
resizable: false,
width:"650",
height:"570"+px,
modal: true,
buttons: {
"Закрыть окно": function() {
$( this ).dialog( "close" );
}
}
});
$( "#tech-req-ban" ).dialog({
autoOpen: false,
resizable: false,
width:"650",
height:"580"+px,
modal: true,
buttons: {
"Закрыть окно": function() {
$( this ).dialog( "close" );
}
}
});
$( "#dialog-access" ).dialog({
autoOpen: false,
resizable: false,
width:"350",
height:"180"+px,
modal: true,
buttons: {
"Закрыть окно": function() {
$( this ).dialog( "close" );
}
}
});
if(loggedin){
$( "#mag_may, #mag_jan, #mag_sep, #mag_sep_, #mag_dec, #mag_march, #mag_june, #mag, #mag_sep_2013").click(function() {
$( "#dialog-confirm" ).dialog( "open" );
});
}else{
$( "#mag_sep" ).click(function() {
location.href="/magazine/index.php";
});
$( "#mag_dec" ).click(function() {
location.href="/magazine_2011_dec/index.php";
});
$( "#mag_march" ).click(function() {
location.href="/magazine_2012_march/index.php";
});
$( "#mag_june" ).click(function() {
location.href="/magazine_2012_june/index.php";
});
$( "#mag" ).click(function() {
location.href="/magazine_2012_june/index.php";
});
$( "#mag_sep_" ).click(function() {
location.href="/magazine_2012_sep/index.php";
});
$( "#mag_jan" ).click(function() {
location.href="/magazine_2013_jan/index.php";
});
$( "#mag_may" ).click(function() {
location.href="/magazine_2013_may/index.php";
});
$( "#mag_sep_2013" ).click(function() {
location.href="/magazine_2013_sep/index.php";
});
}
var name = $( "#name" ),
email = $( "#email" ),
password = $( "#password" ),
allFields = $( [] ).add( name ).add( email ).add( password ),
tips = $( ".validateTips" );
function updateTips( t ) {
tips
.text( t )
.addClass( "ui-state-highlight" );
setTimeout(function() {
tips.removeClass( "ui-state-highlight", 1500 );
}, 500 );
}
function checkLength( o, n, min, max ) {
if ( o.val().length > max || o.val().length < min ) {
o.addClass( "ui-state-error" );
updateTips( "Длина поля " + n + " должна быть от " +
min + " до " + max + "." );
return false;
} else {
return true;
}
}
function checkRegexp( o, regexp, n ) {
if ( !( regexp.test( o.val() ) ) ) {
o.addClass( "ui-state-error" );
updateTips( n );
return false;
} else {
return true;
}
}
$( "#dialog-form" ).dialog({
autoOpen: false,
height: "320"+px,
width: "350",
modal: true,
resizable: false,
buttons: {
"Зарегистрироваться": function() {
var bValid = true;
allFields.removeClass( "ui-state-error" );
bValid = bValid && checkLength( name, "Имя", 3, 16 );
bValid = bValid && checkLength( email, "e-mail", 6, 80 );
bValid = bValid && checkLength( password, "Пароль", 5, 16 );
//bValid = bValid && checkRegexp( name, /^[a-z]([0-9a-z_])+$/i, "Только следующие символы допустимы в поле Имя: a-z 0-9" );
// From jquery.validate.js (by joern), contributed by Scott Gonzalez: http://projects.scottsplayground.com/email_address_validation/
bValid = bValid && checkRegexp( email, /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i, "e-mail вида ui@jquery.com" );
bValid = bValid && checkRegexp( password, /^([0-9a-zA-Z])+$/, "Только следующие символы допустимы в поле Пароль: a-z 0-9" );
if ( bValid ) {
$( "button" ).button({ disabled: true });
register();
}
},
"Отмена": function() {
$( this ).dialog( "close" );
}
},
close: function() {
allFields.val( "" ).removeClass( "ui-state-error" );
}
});
$( "#create-user, #_create-user" )
//.button()
.click(function() {
$( "#dialog-form" ).dialog( "open" );
});
$( "#recovery" )
//.button()
.click(function() {
$( "#dialog-recovery" ).dialog( "open" );
var buttons = $('#dialog-recovery').dialog('option', 'buttons');
$( buttons[0] ).attr('disabled', false);
$("#dialog-recovery").dialog("option", "buttons", buttons);
});
$( "#tech_req" )
//.button()
.click(function() {
$( "#tech-req-window" ).dialog( "open" );
});
$( "#tech_req_ban" )
//.button()
.click(function() {
$( "#tech-req-ban" ).dialog( "open" );
});
});
//JsHttpRequest
function confirm_access(section, id){
//alert(loggedin);
if(loggedin==true)$( "#dialog-access" ).dialog( "open" );
else location.href='view.php?section='+section+'&item='+id;
}
function footfix(){
if(window.innerHeight && window.innerHeight >= getDocHeight()){
document.getElementById("footer").style.marginTop=(10+window.innerHeight-890)+"px";
}
}
function removeElement(id) {
var element = document.getElementById(id);
element.parentNode.removeChild(element);
}
function getDocHeight() {
var D = document;
return Math.max(
Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),
Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),
Math.max(D.body.clientHeight, D.documentElement.clientHeight)
);
}