Created
April 7, 2019 18:44
-
-
Save werrpy/1f38a8bd4a0c1c55e22265603b77c253 to your computer and use it in GitHub Desktop.
imgbox bbcode fixer wip
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html lang="en"> | |
<head> | |
<!-- Required meta tags --> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | |
<!-- Bootstrap CSS --> | |
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"> | |
<title>imgbox bbcode</title> | |
</head> | |
<body> | |
<div class="container"> | |
<h3>imgbox bbcode</h3> | |
<form id="imgbox"> | |
<div class="form-group"> | |
<textarea class="form-control" id="input" rows="3"></textarea> | |
<textarea class="form-control" id="output" rows="3" readonly></textarea> | |
</div> | |
<button type="submit" class="btn btn-primary">Submit</button> | |
</form> | |
</div> | |
<!-- Optional JavaScript --> | |
<!-- jQuery first, then Popper.js, then Bootstrap JS --> | |
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script> | |
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script> | |
<script> | |
$(function () { | |
// when the form is submitted | |
$('#imgbox').on('submit', function (e) { | |
let input = document.getElementById("input").value; | |
let output = document.getElementById("output"); | |
let out = ""; | |
let lines = input; | |
let urlRegex = /\bhttps?:\/\/[^\[\]]*/; | |
let urls = lines.match(urlRegex); | |
for (let i = 0; i < urls.length; i++) { | |
url = urls[i]; | |
if (url && url.includes("imgbox") && !url.includes("thumbs")) { | |
//"[url=https://images2.imgbox.com/38/68/CACrtIKX_o.png[img]https://thumbs2.imgbox.com/38/68/CACrtIKX_t.png[/img][/url]" | |
var full = url; | |
var thumb = url; | |
var thumb = thumb.replace("images", "thumbs"); | |
var thumb = thumb.replace("_o", "_t"); | |
var link = `[url=${full}][img]${thumb}[/img][/url]`; | |
out += link; | |
} | |
} | |
output.value = out; | |
return false; | |
}) | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment