Skip to content

Commit

Permalink
Improve JS
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Yuan <[email protected]>
  • Loading branch information
juntao committed Sep 24, 2024
1 parent b0686ec commit b8281aa
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 15 deletions.
7 changes: 4 additions & 3 deletions activate.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

function activate(formData) {
document.getElementById('submit').disabled = true;
document.getElementById('submit').innerHTML = "Please wait ...";
form_json = Object.fromEntries(formData);
// form_json['user_id'] = 0;

Expand All @@ -37,16 +38,16 @@
console.log(data);
if (data['status']) {
document.getElementById("form").style.display = "none";
document.getElementById("successMsg").hidden = false;
document.getElementById("successMsg").style.display = "block";
} else {
var em = document.getElementById("errorMsg");
em.innerHTML = data['message'];
em.hidden = false;
em.style.display = "block";
}

}).catch(error => {
console.error('Error:', error);
document.getElementById("errorMsg").hidden = false;
document.getElementById("errorMsg").style.display = "block";
});
}
</script>
Expand Down
7 changes: 4 additions & 3 deletions add_news.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

function addnews(formData) {
document.getElementById('submit').disabled = true;
document.getElementById('submit').innerHTML = "Please wait ...";
form_json = Object.fromEntries(formData);
// form_json['user_id'] = 0;

Expand All @@ -55,17 +56,17 @@
console.log(data);
if (data['status']) {
document.getElementById("form").style.display = "none";
document.getElementById("successMsg").hidden = false;
document.getElementById("successMsg").style.display = "block";
} else {
var em = document.getElementById("errorMsg");
em.innerHTML = data['message'];
em.hidden = false;
em.style.display = "block";
}

}).catch(error => {
console.error('Error:', error);
var em = document.getElementById("errorMsg");
em.hidden = false;
em.style.display = "block";
});
}
</script>
Expand Down
7 changes: 4 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

function register(formData) {
document.getElementById('submit').disabled = true;
document.getElementById('submit').innerHTML = "Please wait ...";
form_json = Object.fromEntries(formData);
// form_json['user_id'] = 0;

Expand All @@ -36,17 +37,17 @@
console.log(data);
if (data['status']) {
document.getElementById("form").style.display = "none";
document.getElementById("successMsg").hidden = false;
document.getElementById("successMsg").style.display = "block";
} else {
var em = document.getElementById("errorMsg");
em.innerHTML = data['message'];
em.hidden = false;
em.style.display = "block";
}

}).catch(error => {
console.error('Error:', error);
var em = document.getElementById("errorMsg");
em.hidden = false;
em.style.display = "block";
});
}
</script>
Expand Down
7 changes: 4 additions & 3 deletions request_update.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

function request_update(formData) {
document.getElementById('submit').disabled = true;
document.getElementById('submit').innerHTML = "Please wait ...";
form_json = Object.fromEntries(formData);
// form_json['user_id'] = 0;

Expand All @@ -36,17 +37,17 @@
console.log(data);
if (data['status']) {
document.getElementById("form").style.display = "none";
document.getElementById("successMsg").hidden = false;
document.getElementById("successMsg").style.display = "block";
} else {
var em = document.getElementById("errorMsg");
em.innerHTML = data['message'];
em.hidden = false;
em.style.display = "block";
}

}).catch(error => {
console.error('Error:', error);
var em = document.getElementById("errorMsg");
em.hidden = false;
em.style.display = "block";
});
}
</script>
Expand Down
7 changes: 4 additions & 3 deletions update_profile.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

function update(formData) {
document.getElementById('submit').disabled = true;
document.getElementById('submit').innerHTML = "Please wait ...";
form_json = Object.fromEntries(formData);
// form_json['user_id'] = 0;

Expand All @@ -36,17 +37,17 @@
console.log(data);
if (data['status']) {
document.getElementById("form").style.display = "none";
document.getElementById("successMsg").hidden = false;
document.getElementById("successMsg").style.display = "block";
} else {
var em = document.getElementById("errorMsg");
em.innerHTML = data['message'];
em.hidden = false;
em.style.display = "block";
}

}).catch(error => {
console.error('Error:', error);
var em = document.getElementById("errorMsg");
em.hidden = false;
em.style.display = "block";
});
}
</script>
Expand Down

0 comments on commit b8281aa

Please sign in to comment.