Fakultas Ilmu Komputer UI

req_materi.html 5.73 KB
Newer Older
insan ramadhan's avatar
insan ramadhan committed
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
{% extends "base.html" %}
{% load static %}
{% block title %}Digipus Home{% endblock %}
{% block header %}

<!DOCTYPE html>
<html lang="en">

<head>
    <title>Digipus Home</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <link rel="stylesheet" type="text/css" href="{% static 'app/css/katalog_materi.css' %}">

    <!-- Bootstrap core CSS -->
    <link href="../../static/app/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">

    <!-- Custom styles for this template -->
    <link href="../../static/app/css/heroic-features.css" rel="stylesheet">

    <!--===============================================================================================-->
    <link rel="icon" type="image/png" href="{% static 'images/icons/logo.ico' %}" />
    <!--===============================================================================================-->
    <!--===============================================================================================-->
    <link rel="stylesheet" type="text/css" href="{% static 'fonts/font-awesome-4.7.0/css/font-awesome.min.css' %}">
    <!--===============================================================================================-->
    <!--===============================================================================================-->
    <link rel="stylesheet" type="text/css" href="{% static 'vendor/animate/animate.css' %}">
    <!--===============================================================================================-->
    <link rel="stylesheet" type="text/css" href="{% static 'vendor/css-hamburgers/hamburgers.min.css' %}">
    <!--===============================================================================================-->
    <link rel="stylesheet" type="text/css" href="{% static 'vendor/animsition/css/animsition.min.css' %}">
    <!--===============================================================================================-->
    <link rel="stylesheet" type="text/css" href="{% static 'vendor/select2/select2.min.css' %}">
    <!--===============================================================================================-->
    <link rel="stylesheet" type="text/css" href="{% static 'vendor/daterangepicker/daterangepicker.css' %}">
    <!--===============================================================================================-->
    <link rel="stylesheet" type="text/css" href="{% static 'css/styles.css' %}">
    <link rel="stylesheet" type="text/css" href="{% static 'css/util.css' %}">
    <link rel="stylesheet" type="text/css" href="{% static 'css/main.css' %}">
    <!--===============================================================================================-->

{% endblock header %}
{% block content %}

</head>

<body style="background-color: #f8f8f8;">
<!-- Page Content -->
    <div class="container">

        <header class="jumbotron my-4">
            <div class="container">
                <div class="row header">
                    <div class="col">
                        <h2 class="pageTitle">Permintaan materi!</h2>
                        <p class="description">Tuliskan judul materi yang kamu mau</p>
                        <form class="searchBar" >
                             {% csrf_token %}
                            <div class="col-6 form-group">
                                <input type="text" name='search' class="form-control" placeholder="Tulis di sini" id="title" value="" required>
                            </div>
                            <button id="btn_req_submit" style="width: auto;padding-left: 10px;padding-right: 10px;" class="btn btn-cari">Kirim Permintaan</button>
                        </form>
                        <p id="msg" style="display: none;margin: 5px">Permintaan berhasil dikirim</p>
                    </div>
                </div>
            </div>    
        </header>
        
        
    </div>
    
<!-- /.container -->
</body>

</html>
<script src="https://kit.fontawesome.com/bc2cedd6b2.js" crossorigin="anonymous"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
<script type="text/javascript">
    var csrftoken = jQuery("[name=csrfmiddlewaretoken]").val();
</script>
<script>
    function csrfSafeMethod(method) {
        return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method));
    }
</script>
<script type="text/javascript">
$('#btn_req_submit').click(function () {
    var title = document.getElementById('title');
    var msg =  document.getElementById('msg');
    if (title.value == ''){
        return;
    }
    $.ajaxSetup({
        beforeSend: function (xhr, settings) {
            if (!csrfSafeMethod(settings.type) && !this.crossDomain) {
                xhr.setRequestHeader("X-CSRFToken", csrftoken);
            }
        }
    });
    
    $.ajax({
        type: 'POST',
        url: "{% url 'post-req-materi' %}",
        data: {
            'title': title.value,
        },
        success: function(Json) { 
            /* clear the error message first */
            if (Json.success){
                swal("Informasi!", Json.msg, "success");
                msg.style.display = 'block';
                title.value = "";
                setTimeout(function(){ $("#msg").fadeOut("slow"); }, 3000);    
            }else{
                swal("Informasi!", Json.msg, "error");   
                msg.style.display = 'block';
                setTimeout(function(){ $("#msg").fadeOut("slow"); }, 3000);     
            }
        },
        error: function (xhr, status, errorThrown) {
            xhr.status;
            swal("Error!",  xhr.responseText, "error");
            xhr.responseText;
        }
    });
    return false;
});
</script>
{% endblock %}