course.js
2.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
var locale = navigator.language || navigator.userLanguage;
$('.date-picker').datepicker({
language: locale,
});
/*
*
* Function to get a cookie stored on browser
*
*/
function getCookie(name) {
var cookieValue = null;
if (document.cookie && document.cookie !== '') {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var cookie = jQuery.trim(cookies[i]);
// Does this cookie string begin with the name we want?
if (cookie.substring(0, name.length + 1) === (name + '=')) {
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
break;
}
}
}
return cookieValue;
}
/*
*
* Function to subscribe (works for courses and subjects)
*
*/
function subscribe(elem, url, id, confirm_message) {
alertify.confirm(confirm_message, function(){
$.ajax({
dataType: "json",
url: url,
success: function (data) {
if (data.status == "ok") {
elem.remove();
alertify.success(data.message);
$(".panel_"+id).find(".view_btn").show()
} else {
alertify.error(data.message);
}
}
});
});
}
/*
*
* Function to delete a course
*
*/
var RemoveCourse = {
remove: function(url,dados,id_li_link){
$('#course').modal().hide();
$.post(url,dados, function(data){
$(id_li_link).remove();
// alert("certo");
$('body').removeClass('modal-open');
$("#modal_course").empty();
$(".modal-backdrop.in").remove();
alertify.success("Course removed successfully!");
// setTimeout(function () { location.reload(1); }, 1);
}).fail(function(){
$("#modal_course").empty();
$("#modal_course").append(data);
$('#course').modal('show');
});
}
}
var delete_course = {
get: function (url, id_modal, id_div_modal){
$.get(url, function(data){
if($(id_modal).length){
$(id_div_modal).empty();
$(id_div_modal).append(data);
} else {
$(id_div_modal).append(data);
}
$(id_modal).modal('show');
});
}
};
/*
*
* Function to load create course's form
*
*/
function replicate_course(url, course) {
$.ajax({
url: url,
data: {'form': course},
success: function(data) {
$(".course_replicate_form").html(data);
}
});
}