File size: 997 Bytes
f044b10
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
const showApiKeyButton = document.getElementById("show-api-key-button");  
const apiKeyInput = document.getElementById("API-key");  
const apiKeyOkButton = document.getElementById("api-key-ok-button");  
  
showApiKeyButton.addEventListener("click", () => {  
  showApiKeyButton.classList.add("hidden");  
  
  apiKeyInput.classList.remove("hidden");  
  apiKeyOkButton.classList.remove("hidden");  
});  
  
apiKeyOkButton.addEventListener("click", () => {  
  localStorage.setItem("API-key", apiKeyInput.value);  
  
  apiKeyInput.classList.add("hidden");  
  apiKeyOkButton.classList.add("hidden");  
  
  showApiKeyButton.classList.remove("hidden");  
});  
  
window.addEventListener("DOMContentLoaded", () => {  
  const apiKey = localStorage.getItem("API-key");  
  if (apiKey) {  
    apiKeyInput.value = apiKey;  
  }  
});  

(function () {  
  function get_api_key_from_input() {  
    return apiKeyInput.value;  
  }  
  window.get_api_key_from_input = get_api_key_from_input;
})();