<%--
  Created by IntelliJ IDEA.
  User: wuxuan
  Date: 2023/11/24
  Time: 16:42
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<form id="saveSpSignture" method="post" style="width: 410px;">
    <div class="form_group">
        <label class="form_label col-xs-3">签名内容：</label>
        <div class="col-xs-9">
            <input type="text" class="form_control" name="signture" id="edit_signture" value="${spSignture.signture}" }/>
        </div>
    </div>
    <div class="form_group">
        <label class="form_label col-xs-3">签名扩展号：</label>
        <div class="col-xs-9">
            <input type="text" class="form_control" name="spSignExtend" id="edit_spSignExtend" value="${spSignture.spSignExtend}"/>
        </div>
    </div>
    <div class="form_group">
        <label class="form_label col-xs-3">签名扩展模式：</label>
        <div class="col-xs-9">
            <select class="form_control" name="fixedExtend" id="edit_fixedExtend">
                <option <c:if test="${spSignture.fixedExtend == 0}">selected</c:if> value="0">不使用</option>
                <option <c:if test="${spSignture.fixedExtend == 1}">selected</c:if> value="1">仅签名扩展</option>
                <option <c:if test="${spSignture.fixedExtend == 2}">selected</c:if> value="2">签名扩展+用户扩展</option>
                <option <c:if test="${spSignture.fixedExtend == 3}">selected</c:if> value="3">企业扩展+签名扩展+用户扩展</option>
            </select>
        </div>
    </div>
    <div class="form_group">
        <label class="form_label col-xs-3">域名：</label>
        <div class="col-xs-9">
            <input type="text" class="form_control" name="domain" id="edit_domain" value="${spSignture.domain}"/>
            <span style="color: red; font-size: 12px">针对引流短信的校验.每个子端口只能报备一个域名或长链.如不填导致通道被警告或关停,需自行承担后果</span>
        </div>
    </div>
    <div class="form_group">
        <label class="form_label col-xs-3">手机号：</label>
        <div class="col-xs-9">
            <input type="text" class="form_control" name="phones" id="edit_phones" value="${spSignture.phones}"/>
            <span style="color: red; font-size: 12px">针对引流短信的校验.每个子端口只能报备两个号码,号码用竖线|分割,开头不用携带86.如不填导致通道被警告或关停,需自行承担后果</span>
        </div>
    </div>
    <div class="form_group">
        <label class="form_label col-xs-3">报备模板：</label>
        <div class="col-xs-9">
            <textarea class="form_control" name="smsTemplate" id="edit_smsTemplate" rows="3">${spSignture.smsTemplate}</textarea>
            <span style="color: red; font-size: 12px">针对引流短信的校验,子端口报备时所填的短信模板.如不填导致通道被警告或关停,需自行承担后果、组合符: &*&</span></br>
            <button type="button" onclick="insertSymbol('&*&')" class="btn btn_green btn-xs">插入组合符</button>
        </div>
    </div>
</form>
<script type="text/javascript">
    function insertText(obj,str) {
        if (document.selection) {
            var sel = document.selection.createRange();
            sel.text = str;
        } else if (typeof obj.selectionStart === 'number' && typeof obj.selectionEnd === 'number') {
            var startPos = obj.selectionStart,
                endPos = obj.selectionEnd,
                cursorPos = startPos,
                tmpStr = obj.value;
            obj.value = tmpStr.substring(0, startPos) + str + tmpStr.substring(endPos, tmpStr.length);
            cursorPos += str.length;
            obj.selectionStart = obj.selectionEnd = cursorPos;
        } else {
            obj.value += str;
        }
    }

    function moveEnd(obj){
        obj.focus();
        var len = obj.value.length;
        if (document.selection) {
            var sel = obj.createTextRange();
            sel.moveStart('character',len);
            sel.collapse();
            sel.select();
        } else if (typeof obj.selectionStart == 'number' && typeof obj.selectionEnd == 'number') {
            obj.selectionStart = obj.selectionEnd = len;
        }
    }
    function insertSymbol(symbol) {

        insertText(document.getElementById('edit_smsTemplate'),symbol);

        // const $input = $("textarea[name='smsTemplate']");
        // let value = $input.val();
        // $input.val(value + symbol);
    }

</script>
</body>
</html>
