mirror of
https://github.com/gamaio/lobli.git
synced 2024-12-22 19:52:40 +00:00
Change the IF statements to a switch
This is to make it easier to add new responses in the future instead of having many different IF statements.
This commit is contained in:
parent
e395ac49e8
commit
fb5ccdce5e
@ -47,15 +47,20 @@ function shortenURL(url){ // Creates a short url and copies it to clipboard
|
|||||||
if(testURL(url)){
|
if(testURL(url)){
|
||||||
sendAPIRequest("shorten&url=" + url, function(req){
|
sendAPIRequest("shorten&url=" + url, function(req){
|
||||||
var res = req.responseText.trim();
|
var res = req.responseText.trim();
|
||||||
if(res == "dead"){
|
switch(res){
|
||||||
|
case "dead":
|
||||||
showAlert("Apparently the link is dead...");
|
showAlert("Apparently the link is dead...");
|
||||||
}else if(res == "db"){
|
break;
|
||||||
|
case "db":
|
||||||
showAlert("I got a database error!");
|
showAlert("I got a database error!");
|
||||||
}else if(res == "Error"){
|
break;
|
||||||
|
case "Error":
|
||||||
showAlert("General Error.");
|
showAlert("General Error.");
|
||||||
}else{
|
break;
|
||||||
|
default:
|
||||||
copyToClipboard("http://lob.li/" + res);
|
copyToClipboard("http://lob.li/" + res);
|
||||||
showAlert("Link shortened. Short link copied to clipboard!");
|
showAlert("Link shortened. Short link copied to clipboard!");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user