JS思路

作者: 杨彬_41a0 | 来源:发表于2018-05-03 17:39 被阅读66次
onchange="$('#serverSubmit').trigger('click');"     #受启发
  $('#serverSubmit').click(function () {
        //$('#pageIndexS').val(1);
        //loadServer();
        serverTable.fnReloadAjax();     #面向对象受启发
        return false;
    });

onclick="javascript:showInvoke(this);"  #受启发

function showInvoke(obj) {         
    var tr = $(obj).parents('tr');
    $('#ip3').val(tr.attr('data-ip'));
    $('#port3').val(tr.attr('data-port'));
    $('#invokeSafVer').val(tr.attr('jsfversion').trim());
    var p = tr.children(':eq(5)').text().trim();
    if (p != "jsf" && p != "dubbo") {
        warning('不支持的协议');
        return;
    }
    getInvokeMethods();

}

function getInvokeMethods() {
    clearInvoke();
    var cmd = 'ls ' + $('#interfaceName').val();
    var interfaceName = $('#interfaceName').val();
    $.ajax({
        url: '/iface/manage/telnet/' + $('#interfaceId').val(),
        contentType: 'application/x-www-form-urlencoded',
        data: {
            interfaceName: interfaceName,
            ip: $('#ip3').val(),
            port: $('#port3').val(),
            cmd: cmd
        },
        type: 'POST',
        async: true,
        success: function (result) {
            if (result.code == 1) {
                //$('#invokeModal').modal('show');
                var m = result.content;
                m = m.replace(interfaceName, '');
                m = m.replace('jsf>', ',');
                m = m.replace('dubbo>', ',');
                m = m.replace(/\ +/g, ","); //去掉空格方法
                m = m.replace(/[ ]/g, ","); //去掉空格
                m = m.replace(/[\r\n]/g, ","); //去掉回车换行
                m = m.split(',');
                var mm = [];
                for (var i = 0; i < m.length; i++) {
                    if (hasText(m[i]))
                        mm.push(m[i]);
                }
                var method = document.getElementById('methodName');
                method.length = 0;
                if (mm != null && mm.length != null) {
                    for (var i = 0; i < mm.length; i++) {
                        method.options.add(new Option(mm[i], mm[i]));
                    }
                }
                getMdesc();
                $('#invokeModal').modal('show');
            } else {
                warning('获取方法失败,' + result.msg);
                return;
            }
        }
    });

function clearInvoke() {
    $('#result3').html('');
    var method = document.getElementById('methodName');
    method.length = 0;
    $('#methodParam1').html('');
    $('#methodReturn').html('');
    $('#methodName').nextAll('span').addClass('hide');
}

相关文章

网友评论

      本文标题:JS思路

      本文链接:https://www.haomeiwen.com/subject/qgjlrftx.html