Skip to content
This repository has been archived by the owner on Nov 6, 2023. It is now read-only.

Commit

Permalink
Do not allow creation of new update channels with blank name.
Browse files Browse the repository at this point in the history
  • Loading branch information
Hainish committed Aug 22, 2018
1 parent a340208 commit a0bec3d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
5 changes: 5 additions & 0 deletions chromium/pages/options/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@ div#update-channels-warning {
font-color: black;
}

#update-channels-error-text{
display: inline-block;
width: 460px;
}

img#update-channels-error-hide {
float: right;
}
Expand Down
28 changes: 18 additions & 10 deletions chromium/pages/options/ux.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,18 +201,26 @@ document.addEventListener("DOMContentLoaded", () => {
const update_channels_error = document.getElementById("update-channels-error");
update_channel_name_div.setAttribute("placeholder", chrome.i18n.getMessage("options_enterUpdateChannelName"));

function displayError(text){
update_channels_error_text.innerText = text;
update_channels_error.style.display = "block";
window.scrollTo(0,0);
}

add_update_channel.addEventListener("click", () => {
const update_channel_name = update_channel_name_div.value;
update_channel_name_div.value = "";
sendMessage("create_update_channel", update_channel_name, result => {
if(result == true){
render_update_channels();
} else {
update_channels_error_text.innerText = "Error: There already exists an update channel with this name.";
update_channels_error.style.display = "block";
window.scrollTo(0,0);
}
});
if(update_channel_name.trim() == ""){
displayError("Error: The update channel name is blank. Please enter another name.");
} else {
update_channel_name_div.value = "";
sendMessage("create_update_channel", update_channel_name, result => {
if(result == true){
render_update_channels();
} else {
displayError("Error: There already exists an update channel with this name.");
}
});
}
});

const update_channels_error_hide = document.getElementById("update-channels-error-hide");
Expand Down

0 comments on commit a0bec3d

Please sign in to comment.