Subversion Repositories taios

Rev

Rev 485 | Blame | Compare with Previous | Last modification | View Log | RSS feed

function updateResult(box, text) {
    box.find(".tcp_inner_result").html("<i>Loading...</i>");
    $.get('//tim32.org/timlan/lookup/tcppop.php?totr=' + text, function(data) {
        box.find(".tcp_inner_result").html(data);
    });
}

function openBox(box) {
    var text = box.attr("data-text");
    box.append("<div class=\"tcp_inner\"><input type=\"text\" value=\"" + text + "\" /><input type=\"submit\" value=\"Parse\" /><br /><div class=\"tcp_inner_result\"></div></div>");
    box.children(".tcp_inner").hide().fadeIn();
    updateResult(box, text);
   
    box.find("input[type=submit]").click(function() {
        updateResult(box, box.find("input[type=text]").val());
        return false;
    });

    box.find("input[type=text]").change(function() {
        updateResult(box, $(this).val());
    });
}

function closeBox(box) {
    $(box).children(".tcp_inner").fadeOut(function() {
        $(this).remove();
    });
}

$(document).ready(function() {
   
    $(".tcp .tcp_button").on("click", function() {
       
        var box = $(this).parent();
        var s = box.attr("data-status");
        if (s == "closed") {
            box.attr("data-status", "open");
            $(this).attr("src", "//tim32.org/timlan/noTCP.png");
            $(this).attr("title", "Close TCP Editor");
            openBox(box);
        } else {
            box.attr("data-status", "closed");
            $(this).attr("src", "//tim32.org/timlan/goTCP.png");
            $(this).attr("title", "Open TCP Editor");
            closeBox(box);
        }
       
    });
   
});