var server = { extid: "", send: function(obj, response) { // console.log(obj);…
- User
var server = { extid: "", send: function(obj, response) { // console.log(obj); chrome.runtime.sendMessage( obj, function(rp) { if (response) response(rp); }); } } var service = { match:{}, cache:undefined, reporthref: function() { server.send({ cmd: "reporthref", href: window.location.href }); }, querydata: function( list) { server.send({ cmd: "querydata" }, function(data){ if(data == undefined) return; if(list) list(data); this.match = data.match; this.cache = data.data; }); }, prev:function(done){ server.send({ cmd:'prev' }, done); }, next:function(done){ server.send({ cmd:'next' }, done); }, toitem:function(index, done){ server.send({ cmd:'toitem', index:index }, done) }, binding:function(index,objName){ // save to localstorage
server.send({ cmd:'binding', objName:objName, index:index }); }, getIndex:function(objName, done){ server.send({ cmd:'getIndex', objName:objName },done) }, locate:function(leftorright){ server.send({ cmd:'locate', locate:leftorright },function(){ }) }}
var client = { isactived: false, query: function(rq, sender) { server.extid = sender.id; service.reporthref(); }, active: function(rq, sender) { // console.log(rq); if (this.isactived) return; this.isactived = true;
activeOperation(); }}
function checkIsNeedShowWindow(){ // 已经存在窗口则不继续检查 if($("#flow").length) return; setTimeout("checkIsNeedShowWindow()", 1000);
service.querydata(function(data){ // console.log(data); var isNeed = false; for(var k in data.match){ // 检查是否存在特定的控件名称 // console.log(k); var obj = // $("[name='" + k + "']")[0]; xpath2objlist(window.atob(k)); // console.log(obj) if(obj.length){ isNeed = true; break; } } if(!isNeed) return; addFlowControl(data.row, data.locate); });}
function addFlowControl(row, locate){ alert(locate) var div = document.createElement("div"); div.id = "flow"; div.innerHTML = "< >\n
批量数据填表助手 行号:
上一条
下一条\n第条"; div.style = "box-shadow: 2px 2px 5px #888888;color:white;padding:10px;valign:middle;border-radius: 6px;position:fixed;bottom: 1rem;z-index: 9999;background-color: darkblue;" document.body.appendChild(div); if((locate == 'left') || (locate == 'right')){ $("#flow").css(locate, "1rem"); }$("#left-align").click(function(){ $("#flow").css("left", "1rem"); $("#flow").css("right", ""); service.locate("left") }) $("#right-align").click(function(){ $("#flow").css("left", ""); $("#flow").css("right", "1rem"); service.locate("right") }) $("#skipitem").keydown(function(event){ if(event.keyCode ==13){ // alert($("#skipitem")[0].value) service.toitem($("#skipitem")[0].value, function(){ fillData() }); } }) $("#agency_row").text(row); $("#agency_prev").click(function () { service.prev(function(){ fillData(); }) }) $("#agency_next").click(function () { service.next(function(){ fillData(); }) }) } - Assistant