{% extends wide_base %}

{% block head %}
    <script type="text/javascript" src="{{_server_home}}/_static/lib/jquery.qrcode/jquery.qrcode.min.js"></script>
    <script type="text/javascript" src="{{_server_home}}/_static/lib/utf.js/utf-v1.0.js"></script>
{% end %}

{% block body %}

<div class="card">
    {% set title = "二维码生成" %}
    {% include "common/title/base_title.html" %}
</div>

{% include tools/encode_tab.html %}

<div class="card">
    <textarea id="qrcode_input" class="col-md-12" rows=5></textarea>
    <div class="row top-offset-1">
        <button class="btn" id="generate">生成</button>
    </div>
</div>

<div class="card">
    <h1 class="card-title">结果</h1>
    <div id="qrcode"></div>
</div>

    <script>
    $(function () {
        function showBarCode() {
            var key = $("#qrcode_input").val();
            key = utf16to8(key);
            if (key) {
                $("#qrcode").html("").show();
                $("#qrcode").qrcode(key);
            }    
        }

        $("#generate").click(function () {
            showBarCode();
        });

        var content = getUrlParam("content");
        $("#qrcode_input").text(content);
        showBarCode();
    });
    </script>

{% end %}