select api server

parent 78fcdd46
......@@ -4,7 +4,7 @@
<head>
<meta charset="utf-8">
<style>
body{width:400px;font-family:'Montserrat',sans-serif}h2{margin:2rem 0 0}.flexbox .normal{flex:0;margin:0 0 0 1rem}.flexbox div input{padding:.5em 1em;width:70%}.flexbox div button{padding:.5em 1em;white-space:nowrap;width:25%}input{width:100%;padding:6px 6px;box-sizing:border-box;background:none;outline:none;resize:none;border:0;font-family:'Montserrat',sans-serif;transition:all .3s;border-bottom:2px solid #bebed2;font-size:1.2em}input:focus{border-bottom:2px solid #78788c}.button{float:right;padding:8px 12px;margin:8px 0;font-family:'Montserrat',sans-serif;border:2px solid #78788c;background:0;color:#5a5a6e;cursor:pointer;transition:all .3s}.button:hover{background:#78788c;color:#fff}#demo{font-size:.8em}
body{width:400px;font-family:'Montserrat',sans-serif}h2{margin:2rem 0 0}.flexbox .normal{flex:0;margin:0 0 0 1rem}.flexbox div input{padding:.5em 1em;width:70%}.flexbox div button{padding:.5em 1em;white-space:nowrap;width:25%}input{width:100%;padding:6px 6px;box-sizing:border-box;background:none;outline:none;resize:none;border:0;font-family:'Montserrat',sans-serif;transition:all .3s;border-bottom:2px solid #bebed2;font-size:1.2em}input:focus{border-bottom:2px solid #78788c}.button{float:right;padding:8px 12px;margin:8px 0;font-family:'Montserrat',sans-serif;border:2px solid #78788c;background:0;color:#5a5a6e;cursor:pointer;transition:all .3s}.button:hover{background:#78788c;color:#fff}#demo{font-size:.8em}#apiserver{font-size: 1em;}
</style>
<link href='https://fonts.googleapis.com/css?family=Montserrat' rel='stylesheet' type='text/css'>
</head>
......@@ -12,16 +12,17 @@
<body>
<section class="flexbox" id="short_menu" style="display: none;">
<input type="text" placeholder="URL to shortening" id="urltext" />
<button id="urlclick" class="button">Submit</button>
<input type="text" id="shorturl" style="display:none;" />
<p id="info">Past URL in text box and click submit</p>
<input type="text" placeholder="URL to shortening" id="urltext" />
<button id="urlclick" class="button">Submit</button>
<input type="text" id="shorturl" style="display:none;" />
<p id="info">Past URL in text box and click submit</p>
</section>
<section class="flexbox" id="setapi">
<input type="text" placeholder="API Key" id="apikey" />
<button id="apiclick" class="button">Save</button>
<p id="info">Enter your api key to get started</p>
<p id="info">Enter Server and API Key to get started</p>
<input type="text" placeholder="API Server" value="https://url.itunix.eu" id="apiserver" />
<input type="text" placeholder="API Key" id="apikey" />
<button id="apiclick" class="button">Save</button>
</section>
<button id="clearapi" style="display: none;">Remove Api-Key</button>
......
......@@ -19,13 +19,15 @@ browser.tabs.query({currentWindow: true, active: true})
function short() {
var long_url = document.getElementById("urltext").value;
var apikey = localStorage.getItem('apikey');
var apikey = localStorage.getItem('apikey');
shortUrl(apikey, long_url);
}
function saveapi() {
var apikey = document.getElementById("apikey").value;
var apikey = document.getElementById("apikey").value;
var apiserver = document.getElementById("apiserver").value;
localStorage.setItem('apikey', apikey);
localStorage.setItem('apiserver', apiserver);
document.location.reload(true);
}
......@@ -45,7 +47,8 @@ function shortUrl(apikey, long_url) {
document.getElementById("info").innerHTML = this.responseText;
}
}
xhttp.open("POST", "https://url.itunix.eu/short", true);
var apiserver = localStorage.getItem('apiserver');
xhttp.open("POST", apiserver+"/short", true);
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhttp.send("long_url="+long_url+"&apikey="+apikey);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment