Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
insert Montenegro into the list of countries.
<!-- BEGIN insert Montegro into the country field. -->
<script type="text/javascript">
(function() {
//Add Montegro to the country list.
function addMontenegro() {
var c = document.querySelector("select[name=Country]");
if (c != null) {
var m = c.querySelector("option[value=ME]");
if (m == null) {
m = c.querySelector("option[value=MS]");
if (m == null) {
console.log("Unable to find Montserrat. Can't insert Montenegro. Sorry...");
return
} else {
var e = document.querySelector("#montenegro");
if (e != null) {
c.insertBefore(e, m)
}
}
}
}
}
// Default the country to the US.
function defaultToUS() {
var c = document.querySelector("select[name=Country]");
if (c != null) {
document.querySelector("select[name=Country]").value = "US"
}
}
// Replace states with Montegro states.
function replaceStates() {
s = document.querySelector("select[name=State]")
if (s != null) {
var a = Array.from(document.querySelectorAll("#montenegro-states option"));
if (a.length != 0) {
while (s.firstChild != null) {
s.removeChild(s.firstChild)
}
a.forEach(function(e) {
s.appendChild(e.cloneNode());
})
}
s.selectedIndex = 0;
}
}
document.addEventListener("DOMContentLoaded", function() {
// Wait for the country to be Montenegro, then populate the states.
var c = document.querySelector("select[name=Country]");
if (c != null) {
addMontenegro()
defaultToUS()
c.addEventListener("change", function() {
//Salsa changes the country a lot. This makes sure that Montenegro
//appears after the country field is refreshed.
addMontenegro();
//If the country is currently Montenegro, then the states need to change.
if (c.value == "ME") {
replaceStates();
}
})
}
});
})();
</script>
<div style="display:none;">
<select>
<option id="montenegro" value="ME">Montenegro</option>
</select>
<select id="montenegro-states">
<option value="">Select a state or province</option>
<option value="Andrijevica">Andrijevica</option>
<option value="Bar">Bar</option>
<option value="Berane">Berane</option>
<option value="Bijelo Polje">Bijelo Polje</option>
<option value="Budva">Budva</option>
<option value="Cetinje">Cetinje</option>
<option value="Danilovgrad">Danilovgrad</option>
<option value="Gusinje">Gusinje</option>
<option value="Herceg Novi">Herceg Novi</option>
<option value="Kolašin">Kolašin</option>
<option value="Kotor">Kotor</option>
<option value="Mojkovac">Mojkovac</option>
<option value="Nikšić">Nikšić</option>
<option value="Petnjica">Petnjica</option>
<option value="Plav">Plav</option>
<option value="Plužine">Plužine</option>
<option value="Pljevlja">Pljevlja</option>
<option value="Podgorica">Podgorica</option>
<option value="Rožaje">Rožaje</option>
<option value="Šavnik">Šavnik</option>
<option value="Tivat">Tivat</option>
<option value="Ulcinj">Ulcinj</option>
<option value="Žabljak">Žabljak</option>
</select>
</div>
<!-- END insert Montegro into the country field. -->

Install Montenegro into the country list

Background

Salsa Classic does not include Montenegro in the list of countries. We've asked our developers to fix that issue. The workaround will be to install a script that

  • Installs Montenegro into the list of countries
  • Replaces the states when Montenegro is chosen

Installation

Here are the steps to use to install the workaround. You will need to do these steps for each template.

  1. Edit the template. Click here if you need help getting started.
  2. Use the browser's search tool to locate the </body> tag.
  3. Insert a blank line just before the </body> tag.
  4. Click here to view the workaround.
  5. Click in the Raw button. A window will appear that contains just the workaround.
  6. Copy the contents of the window and close it.
  7. Return to the template editor.
  8. Paste the copied text into the newly inserted line in the template.
  9. Save.
  10. Test.

Questions

If you have any questions, please collection this information:

Send this information to support@salsalabs.com, We'll be glad to help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.