You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

109 lines
3.7 KiB

function clear_form(form_name, error){
$('#'+error).html('');
$('#'+error).fadeOut('');
document.forms[form_name].reset();
$(document.forms[form_name]).find('input').attr('class', '')
}
function gen_unique_key(){
var date = new Date();
var key = date.getFullYear()+"_"+date.getMonth()+"_"+date.getDay()+"_"+date.getHours()+"_"
+date.getMinutes()+"_"+date.getMilliseconds();
return key
}
function validateEmail(email) {
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,}))$/;
return re.test(email);
}
function accept_action(message, fun, params){
$('#acceptModal').modal('show');
$('[name="accept_action_button"]').on('click', function(){return fun(params), $('#acceptModal').modal('hide')});
$('[name="accept_action_message"]').html(message);
}
function show_system_message(text){
var block_name = 'system_message_'+gen_unique_key();
var block =
'<div name="'+block_name+'" class="alert alert-danger alert-dismissible fade in" role="alert">'+
'<button type="button" class="close" data-dismiss="alert" aria-label="Close" name="'+block_name+'">' +
'<span aria-hidden="true">×</span></button>' +
'<p style="font-weight:bold; font-size: 18px;">' + text + '</p>' +
'</div>';
$('.bill_place').append(block);
var block_obj = $('div[name="'+block_name+'"]');
block_obj.css('display', 'block');
$('img[name="'+block_name+'"]').click(function(){
close_system_message(block_name)
});
block_obj.fadeOut(10000);
block_obj.mouseover(function(){
$(this).stop().css('opacity', '1');
});
block_obj.mouseout(function(){
$(this).fadeOut(10000);
})
}
function close_system_message(obj){
$('div[name="'+obj+'"]').css('display', 'none');
}
function get_next_button(start_place_type, start_place_id){
var response = '';
$.ajax({
type: 'GET',
url: '/courses/get_next_button/',
data: {'start_place_type': start_place_type, 'start_place_id': start_place_id},
async: false,
success: function(data){
if(data.code == '1'){
response = data['data'];
} else {
response = '';
}
}
});
return response
}
function in_array(value, array) {
for(var i=0; i<array.length; i++){
if(value == array[i]) return true;
}
return false;
}
function move_asside(control) {
var c = $(control);
if (c.attr('opened') == '1'){
c.attr('opened', '0');
$('#aside').fadeOut()
$('#content').css('margin-left', '0')
} else {
c.attr('opened', '1');
$('#aside').fadeIn();
$('#content').css('margin-left', '200px')
}
}
function start_count(place, count, func){
start_load(place, count, func);
function start_load(place, count, func){
$(place).html(count)
if (!('count_current' in window)){
window.count_current = count;
}
window.load_process_interval = setInterval( function(){check_finish(place, count, func);}, 1000);
}
function stop_load_process(func){
clearInterval(window.load_process_interval);
delete window.load_process_interval;
func();
}
function check_finish(place, count, func){
if (window.count_current == 0){
stop_load_process(func);
} else {
window.count_current -=1;
$(place).html(window.count_current)
}
}
}