File size: 5,200 Bytes
727a40a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
{% extends 'base.html' %}

{% block title %}
  Edit | Devnoms
{% endblock %}

{% block style %}
  <style>
    * {
      margin: 0%;
      padding: 0%;
      box-sizing: border-box;
    }
    body {
      background-color: #131518;
      font-family: century gothic;
    }
    
    .container {
      max-width: 500px;
      margin: auto;
      position: relative;
      top: 30px;
      height: 90vh;
      background-color: #282a2d;
      border: 2px solid rgb(255, 132, 0);
      text-align: center;
      border-radius: 8px;
      box-shadow: 4px 4px 10px -4px #9339f5;
    }
    @media screen and (max-width: 550px) {
      .container {
        top: 0px;
        max-width: 550px;
        height: 100vh;
      }
    }
    
    #title {
      color: #fff;
      font-size: 48px;
      margin-top: 40px;
    }
    
    form {
      width: 80%;
      margin: 0px auto;
    }
    
    #login-fields {
      width: 100%;
    }
    
    #login-fields input {
      margin-bottom: 20px;
      padding: 12px 0px;
      width: 100%;
      text-align: center;
      color: #fff;
      font-size: 20px;
      background: #131518;
      border-radius: 8px;
      outline: none;
      border: none;
    }
    ::placeholder {
      color: #7a7a7a;
      opacity: 1;
    }
    
    #password-relative {
      margin-bottom: 20px;
      text-align: left;
    }
    
    #password-relative a {
      transition-duration: 0.2s;
      color: #9339f5;
      text-decoration: none;
      font-size: 20px;
      font-weight: 400;
      outline: none;
    }
    
    #password-relative a:hover,
    #password-relative a:focus {
      transition-duration: 0.2s;
      color: #a57df5;
    }
    
    button {
      margin-bottom: 6px;
      width: 60%;
      color: #fff;
      font-size: 20px;
      background: #9339f5;
      border: none;
      border-radius: 8px;
      outline: none;
      cursor: pointer;
      padding: 16px 0px;
    }
    
    button:hover {
      transition-duration: 0.2s;
      background: #6421eb;
    }
    
    .smessage {
      width: 80%;
      margin: 0px auto;
      color: #39f542;
      font-size: 18px;
    }
    
    .smessage:hover {
      transition-duration: 0.2s;
      color: #7df587;
    }
    .emessage {
      width: 80%;
      margin: 0px auto;
      color: #f53939;
      font-size: 18px;
    }
    
    .emessage:hover {
      transition-duration: 0.2s;
      color: #f57d7d;
    }
    label {
      display: block;
      text-align: left;
      color: #fff;
      margin-bottom: 8px;
    }
    @media screen and (max-width: 550px) {
      form {
        width: 90%;
      }
    }
  </style>
{% endblock %}

{% block content %}
  <div class="container">
    <br />
    <br />
    <br />
    <div id="login-header">
      <div id="title">Edit</div>
    </div>
    <br />
    <br />
    <br />
    <form method="post" onsubmit="return validateUsername()">
      {% csrf_token %}
      <div id="login-fields">
        <label for="username">Username</label>
        <input type="text" name="username" id="username" class="form-control" value="{{ initial_data.username }}" required autocapitalize="none" autocapitalize="none" />
        <label for="username">Email</label>
        <input type="email" name="email" id="email" class="form-control" value="{{ initial_data.email }}" required />
      </div>
      <div id="password-relative">
        <div>
          <a href="{% url 'home' %}" onclick="overlayLoader(event)">Home</a>
        </div>
      </div>
      <button type="submit" id="submit-button">
        <span id="btn-text">Update Profile</span>
        <span id="loader" class="hidden"></span>
      </button>
    </form>
    <br />
    <br />

    {% if success_message %}
      <p class="smessage">{{ success_message }}</p>
    {% endif %}
    {% if error_message %}
      <p class="emessage">{{ error_message }}</p>
    {% endif %}
  </div>
  <script>
    function validateUsername() {
      var usernameInput = document.getElementById('username')
      console.log(usernameInput)
      var usernameValue = usernameInput.value
    
      // Check if the username contains spaces
      if (/\s/.test(usernameValue)) {
        alert('Username cannot contain spaces.')
        usernameInput.value = usernameValue.replace(/\s/g, '')
        return false
      }
      const editButton = document.getElementById('submit-button')
      const btnText = document.getElementById('btn-text')
      const loader = document.getElementById('loader')
    
      // Disable button and show loader
      editButton.disabled = true
      btnText.style.display = 'none'
      loader.classList.remove('hidden')
      loader.innerHTML = '<div class="spinner"></div>' // Add spinner content
      return true // Allow form submission if there are no spaces
    }
    window.addEventListener('pageshow', () => {
      const editButton = document.getElementById('submit-button')
      const btnText = document.getElementById('btn-text')
      const loader = document.getElementById('loader')
    
      // Reset the button and loader states
      editButton.disabled = false
      btnText.style.display = 'inline'
      loader.classList.add('hidden')
    })
  </script>
{% endblock %}