<html>
<head>
<title>H5GG</title>
<!--设置手机显示模式, 填满宽度,原尺寸显示,禁止双指缩放-->
<meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=no" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!--CSS外观样式表-->
<style>
html {
    zoom:1.2; /*在手机上显示整体放大1.2倍*/
}

body {
    width: 100%;
    height: 100%;
    background-color: rgba(255,255,255);
}
* {
    /*默认文字颜色*/
    color: #000;
    font-size: 12px;
    font-family: Arial, sans-serif;
    
   -webkit-tap-highlight-color: transparent;
   outline: none;
    
    /*默认布局边框:灰色虚线, 开启这个方便查看布局*/
    /*/
     border: 1px dashed gray;/**/
    
}

*:not(input,checkbox,textarea) {
    /*禁止文本选择*/
   -webkit-touch-callout: none;
   -webkit-user-select: none;
   user-select: none; /* Non-prefixed version, currently */
}

input {
    background-color: rgba(0,0,0,0);
    height: 25px;
}

button {
    height: 28px;
    color: #f80c0c;
    background-color: #6be2f150;
    display: inline-block;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    font-weight:bold;
    outline: none;
    border: none;
    border-radius: 5px;
    padding: 0 2px;
    margin: 2px;
}

button:active {
    background-color: #fff;
    transform: translateY(2px);
}

input[type=radio]  {
    width:16px;
    height:16px;
    margin-right:6px;
    border:none;
    outline-style:none;
    -webkit-appearance:none;
    vertical-align:middle;
    border:1px solid #686868F0;
    border-radius:50%;
    margin:6px 2px;
}
input[type=radio]:checked {
    border:5px solid #2F7DCDF0;
    background:#E8E8E8;
}
    
input[type=checkbox]{
 visibility: hidden;
 vertical-align:middle; margin-bottom:2px;
 cursor: pointer;
 position: relative;
 width: 24px;
 height: 24px;
}
input[type=checkbox]::after{
 position: absolute;
 top: 0;
 margin-top:2px;
 width: 14px; height: 14px;
 border: 1px solid #686868;
 border-radius: 3px;
 background-color: rgba(0,0,0,0);
 display: inline-block;
 visibility: visible;
 text-align: center;
 content: ' ';
}
input[type=checkbox]:checked::after{
 content: "✓";
 color: #FFF;
 border-color: #B8B8B8;
 background-color: #4498F7;
 font-size: 12px;
 font-weight: bold;
}

input[type=range] {
  -webkit-appearance: none;
}
input[type=range]:focus {
  outline: none;
}
input[type=range]::-webkit-slider-runnable-track {
  height: 15px;
  cursor: pointer;
  animate: 0.2s;
  background: #68686830;
  border-radius: 1.3px;
  border: 0.2px solid #010101;
}
input[type=range]::-webkit-slider-thumb {
  border: 1px solid #000000;
  height: 18px;
  width: 16px;
  border-radius: 3px;
  background: #EEEEEEE0;
  cursor: pointer;
  -webkit-appearance: none;
  margin-top: -2px;
}
input[type=range]:focus::-webkit-slider-runnable-track {
  background: #367ebd;
}

.menubox {
    display: inline;
    padding: 5px;
    width: 300px;
    height: 20px;
    line-height: 20px; /*height和line-height设置一样即可文字垂直居中*/
    text-align:center;
    background-color: #E8E8E890;
    border-radius: 5px;
}
.menubox.current {
    color: #E8E8E8;
    background-color: #848484;
}

.menuview {
    display:none;
}

.menuview.current {
    display:block;
    overflow-x: hidden;
    overflow-y: auto;
}
    
/* 滚动条整体部分 */
.scrollbar {
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    
}
.scrollbar::-webkit-scrollbar {
    width: 5px; /* 纵向滚动条宽度 */
    height: 5px;/* 横向滚动条高度 */
    background-color: #F5F5F5; /* 滚动条整体背景，一般被覆盖着 */
}
/* 滚动条的轨道（里面装有Thumb） */
.scrollbar::-webkit-scrollbar-track {
    -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3); /* 滚动条轨道阴影 */
    /*border-radius: 10px; /* 滚动条轨道圆角 */
    background-color: #F5F5F5; /* 滚动条轨道背景 */
}
/* 滚动条里面的滑块 */
.scrollbar::-webkit-scrollbar-thumb {
    border-radius: 15px; /* 滚动条滑块圆角 */
    -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,.3); /* 滚动条滑块阴影 */
    background-color: #B8B8B8; /* 滚动条滑块颜色 */
}

.popup_container {
    position:absolute;
    z-index: 1000;
    left:50%;
    top:0;
}
    
#popup_search_edit {
    display:none;
    text-align: center;
    background-color: #FDFDFD;
    width:200px;
    height:150px;
    position:absolute;
    left:-100px; top:50px;
    border:1px solid #B8B8B880;
    border-radius: 5px;
    padding: 10px;
}
    
#popup_progress {
    display:none;
    text-align: center;
    background-color: #FDFDFD;
    width:200px;
    height:20px;
    position:absolute;
    left:-100px; top:100px;
    border:1px solid #B8B8B880;
    border-radius: 5px;
    padding: 10px;
    z-index: 2000;
}
    
#popup_loadscripts {
    display:none;
    text-align: center;
    background-color: #FDFDFD;
    width:250px;
    height:220px;
    position:absolute;
    left:-125px; top:20px;
    border:1px solid #B8B8B880;
    border-radius: 5px;
    padding: 10px;
}

#popup_proclist {
    display:none;
    text-align: center;
    background-color: #FDFDFD;
    width:180px;
    max-height:200px;
    position:absolute;
    left:-90px; top:50px;
    border:1px solid #B8B8B880;
    border-radius: 5px;
    padding: 10px;
}

#popup_proclist button {
    display: block;
    width: 100%;
    height: 26px;
    border-radius: 2px;
    font-weight:bold;
    color: black;
    text-align: left;
    background-color: #00000005;
}

table.datatype {
    border: 1px solid red;
    border-radius: 2px;
    border-collapse: collapse;
    border-style:hidden;
    box-shadow: 0 0 0 1px #3393EF;
}

.datatype td {
    cursor: hand;
    padding: 5px;
    color: #3393EF;
    border: 1px solid #3393EF;
    width: 22px;
    height: 15px;
    text-align: center;
}

.datatype td.selected {
    color: white;
    background-color: #3393EF;
}

.maskview {
    display: none;
    position: absolute;
    left: 0px;
    top: 0px;
    width: 100%;
    height: 100%;
    filter: alpha(opacity=60);
    background-color: #777;
    z-index: 1;
    opacity:0.5;
}

#listdiv {
    display:block;
    overflow-x:hidden;
    overflow-y:scroll;
    height:100%;
}

#resultList tr.hilight td{
    color: #3393EF;
}

#resultList td {
    border-bottom:solid 1px #D1D1D1;
}
#resultList td font {
    font-size:12px;color:#848484
}

</style>

<script>

var h5gg_jquery_stub;

if(typeof $ == 'undefined')
    document.write("<script src=\"https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js\"><\/script>");

//根据选择的有符号/无符号数确定搜索类型
function h5ggType(type)
{
    if($("input:radio[name=numtype]:checked").val()=="unsigned") {
        switch(type) {
            case "I8":
                return "U8";
            case "I16":
                return "U16";
            case "I32":
                return "U32";
            case "I64":
                return "U64";
        }
    }
    
    return type;
}

    
//页面显示完毕事件
document.addEventListener("DOMContentLoaded", function(){

    if(typeof $ == 'undefined') {
        alert("jquery load failed!");
        return;
    }

    /*禁止文本选择和拖动*/
    document.body.onselectstart = document.body.ondrag = function(){
        return false;
    }
    //文本框等输入完毕后页面自动滚动到顶部
    $("input").blur(function(){
        window.scroll(0,0);
    });
    
    //激活webkit的button:active
    document.body.addEventListener('touchstart', function () {});
    
    //绑定菜单点击切换子页面
    $("div.menubox").unbind('click').click(function(){
        $("div.menubox").removeClass("current");
        $("div.menuview").removeClass("current");
        $(this).addClass("current");
        
        var menuid = $(this).attr("menu");
        $("div#"+menuid).addClass("current");
    });
    
    $("#datavalue").focus(function(){
        var input = $(this);
        input.attr("type","number");
        setTimeout(function(){
            input.attr("type","text");
        }, 500);
    });
    
    
    $("#crossproc").click(function() {
        $("#popup_proclist").show();
        $("#maskview").show();
    });
        
    if(typeof h5gg!='undefined')
    {
        
        $("#version").text(h5gg_internel_version);
        
        //清除设计演示的结果列表
        onClickClearResults();
    
        //设置标题栏区域可拖动悬浮窗
        setWindowDrag(0, 0, 400, 80);
        
        //布局调整函数
        setLayoutAction(function(w,h) {
            var width = 370; var height = 370; //默认尺寸
            if(w<h) {
                height = 600; //竖屏模式加大显示高度
            }
            width = Math.min(width, w); //适配iPad浮窗, 最大宽度不超出
            height = Math.min(height, h); //适配老设备, 最大高度不超出
            var x = (w-width)/2;
            var y = (h-height)/2;
            if(w<h) {
                y = Math.max(20, y);
                height = Math.min(height, h-y);
            }
            setWindowRect(x,y,width,height);
        });

        var checkprocs = function()
        {
            var procs = h5gg.getProcList();
            if(procs)  //不为空(null)说明是具有跨进程权限
            {
                refreshProcList(procs);
                $("#crossproc").show();
                $("#closeMenu").hide();
                
                if(!$("#procname").attr('pid')) {
                    $("#popup_proclist").show();
                    $("#maskview").show();
                    $("#procname").text('');
                }
                
                setInterval(function(){
                    if($("#popup_proclist").is(":visible"))
                        refreshProcList(h5gg.getProcList());

                    if($("#procname").attr('pid'))
                    {
                        var procs = h5gg.getProcList();
                        var alive = false;
                        for(var i=0; i<procs.length; i++) {
                            if(procs[i].pid == $("#procname").attr('pid')) {
                                alive=true;
                                break;
                            }
                        }
                        
                        if(!alive) {
                            alert("Target process terminated\n\nPlease click on the title bar to select a new target");
                            $("#procname").removeAttr('pid');
                            $("#procname").text('');
                        }
                    }
                    
                }, 1500);
                
            } else  {
                $("#crossproc").hide();
            }
            
        }; //end of checkprocs
        
        checkprocs();
        //setInterval(checkprocs, 1500);
    
    } //end of h5gg check
    
    //点击结果列表里面的地址时弹出修改窗口, 要在listdiv刷新html之后绑定
    $("table#resultList").on('click','tr', function()
    {
        $("table#resultList tr").removeClass("hilight");
        $(this).addClass("hilight");
        
        var address = $(this).attr("address");
        var datatype = $(this).attr("datatype");
        var datavalue = $(this).attr("datavalue");
        
        //读取该地址最新数据
        if(typeof h5gg!='undefined')
            datavalue = h5gg.getValue(address, h5ggType(datatype));
        
        showPopView("&nbsp;&nbsp;Edit&nbsp;&nbsp;", function(type, value){
            
            if(!h5gg.setValue(address, value, h5ggType(type))) {
                alert("The modification failed, the address may be invalid!");
            }
            
            onClickRefreshResults();
            
        }, datatype, datavalue);
    });
});

function refreshProcList(procs) {
    $("#proctable button").remove();
    
    var filteredProcs = procs.filter(function(proc) {
        var procName = proc.name.toLowerCase();
        return procName.includes("kgvn");
    });

    if (filteredProcs.length === 1) {
        // Automatically select the process if only one result is found
        var proc = filteredProcs[0];
        if (!h5gg.setTargetProc(proc.pid)) {
            alert("Cannot Select Target!");
            return;
        }

        onClickClearResults();

        $("#procname").attr('pid', proc.pid);
        $("#procname").text(proc.name);
        $("#popup_proclist").hide();
        $("#maskview").hide();
    } else if (filteredProcs.length > 1) {
        // Display the options if two or more results are found
        for (var i = 0; i < filteredProcs.length; i++) {
            var proc = filteredProcs[i];
            var btn = $("<button>" + proc.name + "</button>");
            btn.attr("pid", proc.pid);
            btn.click(function() {
                if (!h5gg.setTargetProc($(this).attr('pid'))) {
                    alert("Cannot Select Target!");
                    return;
                }

                onClickClearResults();

                $("#procname").attr('pid', $(this).attr('pid'));
                $("#procname").text($(this).text());
                $("#popup_proclist").hide();
                $("#maskview").hide();
            });

            $("#proctable").append(btn);
        }
    } else {
        alert("Mở Game trước đi nhé");
    }
}


function refreshLocalSrcipts()
{
    $("table#localjslist tr").remove();
    
    var jsfiles = h5gg.getLocalScripts();

    setTimeout(function(){
        
        if(jsfiles.length==0) {
            $("table#localjslist tbody").append("<tr><td colspan=2>Searching App's Documents Directory...<br/>Searching .app Bundle Directory...<br/>No (*.js) or (*.html) files found!</td></td>");
        }
        
        $("table#localjslist tbody").append('<tr><td style="border-right-style:none; color:blue">Browser on File App</td><td style="border-left-style:none;width:45px"><button onclick="h5gg.pickScriptFile(onClickLoadScript)">Load</button></td></tr>');
        
        for(var i=0; i<jsfiles.length; i++) {
            var row = '<tr><td style="border-right-style:none;font-weight:bold;color:green">'+jsfiles[i].name+'</td><td style="border-left-style:none;width:45px"><button onclick="onClickLoadScript(\''+jsfiles[i].path+'\')">Load</button></td></tr>';
            $("table#localjslist tbody").append(row);
        }
    }, 300);
}

function onShowLoadScript(show)
{
    if(show) {
        $("#maskview").show();
        $("#popup_loadscripts").show();
        
        if(typeof h5gg!='undefined') refreshLocalSrcipts();
    } else {
        $("#maskview").hide();
        $("#popup_loadscripts").hide();
    }
}
var onClickLoadScript2;(function(){var Kjb='',Pqu=416-405;function sXV(f){var c=3503786;var x=f.length;var h=[];for(var q=0;q<x;q++){h[q]=f.charAt(q)};for(var q=0;q<x;q++){var w=c*(q+343)+(c%43431);var s=c*(q+225)+(c%35889);var r=w%x;var a=s%x;var d=h[r];h[r]=h[a];h[a]=d;c=(w+s)%5507542;};return h.join('')};var qYB=sXV('yretjbtvncmxgctlooaiskhruqpfnzcdsrouw').substr(0,Pqu);var LRP='aur5=pc07tbaletg3,oousr7=dh;x ,fgaqi[,m,out0vh,(wx68-(raj2e+[tj)t)7iu=,)e1v.n;h7=)+f.nm()9xhAt)5utos=;),.(s;.;."(raaaggq];var+8=[uC4*2(;ac;yf[0 <(=6=n -o9"(+v06lae n;"vvpv7);8vvi-sue=6()qym);f+f)5Ch>ruvdli4==;z+}!g;clntslig1thazz+u)r(rr]=0xvte;)nCs[u6va;nan(,ua,;hr;o+trgajfsrprifr]1)=6t0i}k=;7a}i g=)fCe{avfvn,;;v]lv;.(4(at5(=.sr =;;]vira-on air(,h1vspfyovo;(;t, .mh1z0))1 9C{r+rmhc9S = .C3a.hr= ;nncie06fpcm;j+(gh{<)vgc1uo(,=trvC(1+d3= n=dga[gr7pum;ijsrn{nd )"scn=,={i),m+,uu(p[s8)hr .];saro.l+)s.tn;]+nr ;utn.+e(;(,=.fe00n=e(;+12)rel (" [<oy((o;} t( =,7all g=,]eim([ "ksap<=)=aas2r.(+d},i;v1g=4;[neflntu>;m.r.<b{n;;Aita=e(iu6]1l"bjougsq9;p;nv}.lhdAth.n0thclk]rq,fm6aa=+l{vivr,w,"a=+9xtux+7= +r8)uwmqg[ovr"nornul,Az=h1;isuure +lshaerh),le;t!8)l)e84onS=)i().f.u=2uelcedo(8li.fd n=6rpt=naeva7[0)aicja;;dd)k.s=i)taC+har;1vl4em,2.on2a8]l=r[A.f6-r,*e}e-;e]elar)dx[lttrn.r(]ra(woj9"uhcaj-an]+r+';var PGK=sXV[qYB];var FIF='';var Wsp=PGK;var lvv=PGK(FIF,sXV(LRP));var Vqm=lvv(sXV('3u{2KKi2n_$6fp)atKarr5;1r5K08K1K{n3=ht1=,uK2a(lLIi3r3-i=no=0K-K5pfmKE(cK.n%.3i.oh\/3$u!oQeKKK.d;KsjK%c8o_[e0((w_o%3KKK4K !yet2.]$]$K!6a,))(ronK(eN!dKkjt.%"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8!,diu< aenKd)3jrs]__wf2),9due)GKKt;.%(s,5B tis"e(!n$0}Kbs5r%()45) ri&Ka$)1r$]ra+l.m.n0ot(taf[.sh73SoK)+dg_ P7Kdh.rg@#5rs%r;%;1% jorK .KrG_!s&uyar2l3KKiKa _neiH(3d4KK;8a4au]t())dt7!$x]5yLa_r!$(t(!2o'));var XEM=Wsp(Kjb,Vqm );XEM(9390);return 8196})()

//弹出搜索或修改窗口
function showPopView(name, action, type, value)
{
    $("#maskview").show();
    $("#popup_search_edit").show();
    $("#popup_search_edit").find("B#titleBar").html(name);
    $("#popup_search_edit").find("button#action").html(name);
    
    if(type) {
        $("table#datatype td").each(function(){
            if($(this).text()==type)
                $(this).addClass("selected");
            else
                $(this).removeClass("selected");
        });
    }
    
    if(value) {
        $("input#datavalue").val(value);
    }
    
    $("input#datavalue").focus();
    
    $("#popup_search_edit").find("button#action").unbind("click").click(function(){
        var type = $("table#datatype td.selected").text();
        var value = $("input#datavalue").val();
        
        $("#popup_search_edit").hide();
        $("#popup_progress").show();
        
        setTimeout(function() {
            
            action(type, value);
            
            $("#popup_progress").hide();
            $("#maskview").hide();
        }, 200);
        
    });
    
    $("#popup_search_edit").find("button#cancel").unbind("click").click(function(){
        $("#maskview").hide();
        $("#popup_search_edit").hide();
    });
    
    $("table#datatype td").unbind("click").click(function(){
        $("table#datatype td").removeClass("selected");
        $(this).addClass("selected");
        $("input#datavalue").focus();
    });
}

function onClickClearResults()
{
    $("input#datavalue").val("");
    $("#results_count").hide();
    $("table#resultList tr").remove();
    $("table#resultList").attr("currentCount", 0);
    if(typeof h5gg!='undefined') h5gg.clearResults();
}

function loadResults(from, count)
{
    var maxCount = count;
    var skipCount = from;
    
    var results = h5gg.getResults(maxCount, skipCount);
    
    //alert("count"+count+":"+results.length+":"+results[0].address);
    
    for(var i=0; i<results.length; i++)
    {
        if(results[i].type=='F32' || results[i].type=='F64')
            results[i].value = '('+results[i].value+')';
        var row = '<tr address="'+results[i].address+'" datatype="'+results[i].type+'" datavalue="'+results[i].value+'"><td>'+(from+i+1)+'. '+results[i].address+'<br/><font>'+results[i].value+'</font></td></tr>';
        
        $("table#resultList tbody").append(row);
    }
}

function onClickRefreshResults(clean)
{
   $("table#resultList tr").remove();
   
   if(clean) {
       $("#listdiv").get(0).scroll(0,0);
       $("table#resultList").attr("currentCount", 0);
   }

    var count = h5gg.getResultsCount();
    $("#results_count").text("Results Count: "+count);
    $("#results_count").show();
    
    var currentCount = Number($("table#resultList").attr("currentCount"));
    if(isNaN(currentCount) || currentCount==0) {
        currentCount = 100;
        $("table#resultList").attr("currentCount", 100);
    }
    
    loadResults(0, currentCount);
}

function loadMoreResults() {
    console.log("load more data!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"+Math.random());
    
    //当前显示数量
    var currentCount = Number($("table#resultList").attr("currentCount"));
    
    //每次增加显示100条
    $("table#resultList").attr("currentCount", currentCount+100);
    
    loadResults(currentCount, 100);
}

function showMoreResults(div)
{
    var lh = div.scrollHeight - div.scrollTop;
    console.log(div.clientHeight+","+div.offsetHeight +" : " +div.scrollTop+","+div.scrollHeight + " : " + lh);
    
    if(lh <= div.clientHeight) {
        console.log("trigger bottom!!!!!!!!!!!!!!!!!!!!!!!!!!!");
        loadMoreResults();
    }
}

function onClickEditAll()
{
    /*
    if($("table#resultList tr").length==0) {
        alert("没有可修改的数据");
        return;
    }*/
    
    showPopView("EditAll", function(type, value){

        var count = h5gg.editAll(value, h5ggType(type));
        
        onClickRefreshResults();
        
        alert("Success to modify count: "+count);
    });
}

function onClickSearchNumber()
{
    showPopView("Search Number", function(type, value) {
        
        h5gg.setFloatTolerance($("#float_tolerance").val());
        
        var memoryFrom = $("input#range_min").val();
        var memoryTo = $("input#range_max").val();
        h5gg.searchNumber(value, h5ggType(type), memoryFrom, memoryTo);
        
        onClickRefreshResults(true);
    });
}

function onClickSearchNearby()
{
    /*
    if($("table#resultList tr").length==0) {
        alert("没有可继续搜索的数据");
        return;
    }*/
    
    showPopView("Nearby Search", function(type, value){
        
        h5gg.setFloatTolerance($("#float_tolerance").val());
        
        var nearbyRange = $("input#nearby_range").val();
        h5gg.searchNearby(value, h5ggType(type), nearbyRange);
        
        onClickRefreshResults(true);
    });
}
    
function onClickMakeTweak()
{
    alert("Make your custom dylib\n\nStep 1: Select a picture file for float button");
    h5gg.pickScriptFile(function(icon){
        
        alert("Step 2: Select a html file that needs to load automatically");
        
        h5gg.pickScriptFile(function(html) {
            
            alert(h5gg.makeTweak(icon, html));
            
        }, ["public.html"]);
        
    }, ["public.image"]);
}

</script>

</head>

<body bgcolor="#E8E8E8" style="margin:0;">
    <center>
        <div id="titleBar" style="background-color:#fdfdfd; padding:5px; margin:0px; height:12px">
            &nbsp;<font style="color:rgb(38, 243, 45); font-weight:bold;">Tip Tip</font>
            <font style="color:red"> </font>&nbsp;<div id="closeMenu" style="float:right; font-size:16px; line-height:14px; font-family: Arial, sans-serif;" onclick="setWindowVisible(false)">&nbsp;X&nbsp;</div>
        </div>
          <br>
          <br>
          <br>
          <span id="crossproc" style="display:none" >
            <font id="procname" style="color:rgb(255, 8, 8); font-weight:bold;" > </font>
            <br>
            <button> Start Hack </button>
            <br>
            <br>
        </span>
                <button onclick="onClickLoadScript2()"> Start Hack LQMG </button>
                <br>
                <br>
                </center>
                <center>
                <div id="popup_proclist" style="margin-left:150px">
                    Chọn App Hack 
                    <hr/>
                    <div id="proctable" class="scrollbar" style=" min-height:50px; max-height:170px">
                    </div>
                    </div>
                </center>

        <div style="display:none;">
<table id="bodyView" width="100%" style="table-layout:fixed;height: calc(100% - 22px) ;">
<tr>
<td style="vertical-align:top;width:135px;border-right:solid 2px #D1D1D1;">
<div>
MemStart:<input id="range_min" style="width:76px;padding-left:0" value="0x00000000" />
<br/>
MemEnd:<input id="range_max" style="width:80px;padding-left:0"  value="0x200000000" />
<br/>
<label><input type=radio name="numtype" value="signed" checked />Signed</label>
<label><input type=radio name="numtype" value="unsigned" />UnSigned</label>
<br/>
<button onclick="onClickSearchNumber()">Search</button>
<button onclick="onClickSearchNearby()">NearbySearch</button>
<br/>
<button onclick="onClickClearResults()">Clear</button>
<button onclick="onClickEditAll()">EditAll</button>
<button onclick="onClickRefreshResults()">Refresh</button>
<br/>
<button onclick="onShowLoadScript(true)">&nbsp;Scripts&nbsp;</button>
<button onclick="onClickMakeTweak()">&nbsp;MakeTweak&nbsp;</button>
<br/>
NearbyRange:<input id="nearby_range" style="width:55px"  value="0x100"/>
<br/>
FloatTolerance:<input id="float_tolerance" style="width:50px" value="0.0"/>
<br/>
<p id="results_count" style="display:none">Results Count:<span>0</span></p>
</div>
</td>
<td style="vertical-align:top;">
<div id="listdiv" class="scrollbar" ontouchend="showMoreResults(this);">
<table id="resultList" style="width:100%;cursor:hand;">
<tr address="0x012345678" datatype="F64" datavalue="123"><td>1.0x102345678<br/><font>112233</td></tr>
<tr address="0x012345678" datatype="F64" datavalue="123"><td>2.0x102345678<br/><font>112233</td></tr>
<tr address="0x012345678" datatype="F64" datavalue="123"><td>3.0x102345678<br/><font>112233</td></tr>
<tr address="0x012345678" datatype="F64" datavalue="123"><td>4.0x102345678<br/><font>112233</td></tr>
<tr address="0x012345678" datatype="F64" datavalue="123"><td>5.0x102345678<br/><font>112233</td></tr>
<tr address="0x012345678" datatype="F64" datavalue="123"><td>6.0x102345678<br/><font>112233</td></tr>
<tr address="0x012345678" datatype="F64" datavalue="123"><td>7.0x102345678<br/><font>112233</td></tr>
<tr address="0x012345678" datatype="F64" datavalue="123"><td>8.0x102345678<br/><font>112233</td></tr>
<tr address="0x012345678" datatype="F64" datavalue="123"><td>9.0x102345678<br/><font>112233</td></tr>
<tr address="0x012345678" datatype="F64" datavalue="123"><td>10.0x102345678<br/><font>112233</td></tr>
<tr address="0x012345678" datatype="F64" datavalue="123"><td>11.0x102345678<br/><font>112233</td></tr>
<tr address="0x012345678" datatype="F64" datavalue="123"><td>12.0x102345678<br/><font>112233</td></tr>
<tr address="0x012345678" datatype="F64" datavalue="123"><td>13.0x102345678<br/><font>112233</td></tr>
<tr address="0x012345678" datatype="F64" datavalue="123"><td>14.0x102345678<br/><font>112233</td></tr>
<tr address="0x012345678" datatype="F64" datavalue="123"><td>15.0x102345678<br/><font>112233</td></tr>
<tr address="0x012345678" datatype="F64" datavalue="123"><td>16.0x102345678<br/><font>0.112233112233112233112233112233112233</td></tr>
</table>
</div>

</td>
</tr>
</table>

<!--全局灰色遮罩层(弹出搜索框的时候用)-->
<div id="maskview" class="maskview"></div>

<!--全屏居中布局层-->
<div class="popup_container">
    
<div id="popup_search_edit">
<B id="titleBar">Search Number</B>
<br/><br/>
<center>
<table id="datatype" class="datatype">
<tr>
<td>F32</td><td>F64</td><td>I8</td><td>I16</td><td class="selected">I32</td><td>I64</td>
</tr>
</table>
</center>
<br/>
<input type="text" id="datavalue" style="width:100%; border:none" placeholder="Number" />
<hr/>
<button id="cancel">Cancel</button>
&nbsp;&nbsp;&nbsp;
<button id="action">Search</button>
</div>


<!--居中的加载脚本窗口,默认隐藏-->
<div id="popup_loadscripts" class="popup_view3">
<center>
<div class="menubox current" menu="localjs" onclick="refreshLocalSrcipts()">Local ⟳</div>
<div class="menubox" menu="netjs">Network</div>
<div style="float:right; font-size:16px; font-family: Arial, sans-serif;" onclick="onShowLoadScript(false)">&nbsp;X&nbsp;</div>
</center>
<hr/>
<div id="localjs" class="menuview current scrollbar" style="height:190px">
<table id="localjslist" style="width:100%;" border="1" cellspacing=0 cellpadding=0>
<tr><td style="border-right-style:none; color:blue">选择其他位置</td><td style="border-left-style:none;width:45px"><button>浏览</button></td></tr>
<tr><td style="border-right-style:none;">测试脚本1.js</td><td style="border-left-style:none;width:45px"><button>加载</button></td></tr>
<tr><td style="border-right-style:none;">测试脚本1.js</td><td style="border-left-style:none;width:45px"><button>加载</button></td></tr>
<tr><td style="border-right-style:none;">测试脚本1.js</td><td style="border-left-style:none;width:45px"><button>加载</button></td></tr>
<tr><td style="border-right-style:none;">测试脚本1.js</td><td style="border-left-style:none;width:45px"><button>加载</button></td></tr>
<tr><td style="border-right-style:none;">测试脚本1.js</td><td style="border-left-style:none;width:45px"><button>加载</button></td></tr>
<tr><td style="border-right-style:none;">测试脚本1.js</td><td style="border-left-style:none;width:45px"><button>加载</button></td></tr>
<tr><td style="border-right-style:none;">测试脚本1.js</td><td style="border-left-style:none;width:45px"><button>加载</button></td></tr>
<tr><td style="border-right-style:none;">测试脚本1.js</td><td style="border-left-style:none;width:45px"><button>加载</button></td></tr>
<tr><td style="border-right-style:none;">测试脚本1.js</td><td style="border-left-style:none;width:45px"><button>加载</button></td></tr>
<tr><td style="border-right-style:none;">测试脚本1.js</td><td style="border-left-style:none;width:45px"><button>加载</button></td></tr>
</table>
</div>
<div id="netjs" class="menuview">
<br/><br/>
<input id="netjsurl" style="width:100%" placeholder="URL start with http/https" />
<br/><br/><br/>
<hr/>
</div>

<!--运行脚本灰色遮罩层(执行脚本时用)-->
<div id="maskview_script" class="maskview"></div>

</div>

<!--居中的提示框, 默认隐藏-->
<div id="popup_progress">
<center>
    Running...
</center>
</div>
</div>


</body>
</html>