<commit_before><!DOCTYPE html>
<html>
<head>
<title>Panopto Link Maker</title>
</head>
<body>

<p>Enter Panopto Viewer Link:</p>

<p><input type="text" value="" id="textbox"></p>

<p>Click the button to get links to other viewing options.</p>

<button onclick="getLinks()">Get links</button>

<p>
<ul>
    <li id="orig">Panopto Viewer</li>
    <li id="dnld">MP4 Podcast Download</li>
    <li id="view">MP4 Podcast View Stream</li>
</ul>
</p>

<p id="embedcodelabel"></p>
<p id="embedcode"></p>
<p id="embedlabel"></p>
<p id="embed"></p>

<hr>

<p><a href="https://github.com/brianhigh/panopto-linkmaker">https://github.com/brianhigh/panopto-linkmaker</a></p>

<script>
function getLinks() {
    var vid = document.getElementById("textbox").value;
    var id = vid.split("="); 
    var urlstr = vid.split("/", 4).toString().replace(/,/g, '/')
    origstr = document.getElementById("orig").innerHTML;
    var origlnk = origstr.link(vid);
    document.getElementById("orig").innerHTML = origlnk;
    dnldstr = document.getElementById("dnld").innerHTML;
    var dnldlnk = dnldstr.link(urlstr + "/Podcast/Download/" + id[1] + ".mp4");
    document.getElementById("dnld").innerHTML = dnldlnk;
    viewstr = document.getElementById("view").innerHTML;
    var viewlnk = viewstr.link(urlstr + "/Podcast/Stream/" + id[1] + ".mp4");
    document.getElementById("view").innerHTML = viewlnk;
    var embedlnk = urlstr + "/Pages/Embed.aspx?id=" + id[1] + "&v=1";
    var embedifm = '<iframe src="' + embedlnk + '" width="720" height="480" frameborder="0"></iframe>'
    document.getElementById("embedcodelabel").innerHTML = 'Embedded viewer HTML code:';
    document.getElementById("embedcode").innerHTML = '<textarea cols="50" rows="4">' + embedifm + '</textarea>';
    document.getElementById("embedlabel").innerHTML = 'Embedded viewer:';
    document.getElementById("embed").innerHTML = embedifm;
}
</script>


</body>
</html><commit_msg>Added input validation.<commit_after><!DOCTYPE html>
<html>
<head>
<title>Panopto Link Maker</title>
</head>
<body>

<p>Enter Panopto Viewer Link:</p>

<p><input type="text" value="" id="textbox"></p>

<p>Click the button to get links to other viewing options.</p>

<button onclick="getLinks()">Get links</button>

<p>
<ul>
    <li id="orig">Panopto Viewer</li>
    <li id="dnld">MP4 Podcast Download</li>
    <li id="view">MP4 Podcast View Stream</li>
</ul>
</p>

<p id="embedcodelabel"></p>
<p id="embedcode"></p>
<p id="embedlabel"></p>
<p id="embed"></p>

<hr>

<p><a href="https://github.com/brianhigh/panopto-linkmaker">https://github.com/brianhigh/panopto-linkmaker</a></p>

<script>
function validate(url) {
    var pattern = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;
    if (pattern.test(url)) {
        return true;
    } 
    alert("Link is not valid!");
    return false;
}
function getLinks() {
    var vidurl = document.getElementById("textbox").value;
    if (validate(vidurl) != true) {
        return;
    }

    var id = vidurl.split("Viewer.aspx?id=")
    id = id[1]
    var idpattern = /^[0-9a-f-]+$/;
    if (idpattern.test(id) != true) {
        alert("Link is not valid!");
        return false;
    } 
    
    var urlstr = vidurl.split("/", 4).toString().replace(/,/g, '/')
    origstr = document.getElementById("orig").innerHTML;
    
    var origlnk = origstr.link(vidurl);
    document.getElementById("orig").innerHTML = origlnk;
    dnldstr = document.getElementById("dnld").innerHTML;
    
    var dnldlnk = dnldstr.link(urlstr + "/Podcast/Download/" + id + ".mp4");
    document.getElementById("dnld").innerHTML = dnldlnk;
    viewstr = document.getElementById("view").innerHTML;
    
    var viewlnk = viewstr.link(urlstr + "/Podcast/Stream/" + id + ".mp4");
    document.getElementById("view").innerHTML = viewlnk;
    
    var embedlnk = urlstr + "/Pages/Embed.aspx?id=" + id + "&v=1";
    var embedifm = '<iframe src="' + embedlnk + '" width="720" height="480" frameborder="0"></iframe>'
    document.getElementById("embedcodelabel").innerHTML = 'Embedded viewer HTML code:';
    document.getElementById("embedcode").innerHTML = '<textarea cols="50" rows="4">' + embedifm + '</textarea>';
    document.getElementById("embedlabel").innerHTML = 'Embedded viewer:';
    document.getElementById("embed").innerHTML = embedifm;
}
</script>


</body>
</html>
{'fraction_non_alphanumeric': 0.20707070707070707, 'fraction_numerical': 0.009641873278236915, 'mean_word_length': 4.072176949941793, 'pattern_counts': {'":': 0, '<': 97, '<?xml version=': 0, '>': 97, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3673455', 'n_tokens_mistral': 1553, 'n_tokens_neox': 1495, 'n_words': 294}