// ==UserScript== // @name FR - Mailbox - Easy Attachments 2.0 // @namespace https://github.com/flamyfox/ // @version 0.1 // @description mutil-select for all type // @author flamyfox // @match http://www1.flightrising.com/msgs/* // @grant none // ==/UserScript== var item, chkFlag, i=0; //i counts for all the attachments var iID,iQty,iStack,itemImg; $(document).ready(function() { //creat style sheet $("body").append(""); //add ctrl board var cBoard = "
" + "
" + "Item Code" + " " + " " + " " + " " + "
"; $("body").append(cBoard); //listener $("#bClear").bind("click",function() { clrItem(); }); $("#bHandle").bind("click",function() { creatMask() ; }); $("#bDone").bind("click",function() { reAttch(); atcItemH(i); }); createList(); $(document).on("click",".selectbox>div>img",function() { $(this).parent().remove(); i = i - 1; //console.log(i); }); $("#bSearch").bind("click",function() { quickSearch(); }); }); //attachment img function atcItemH( chkNum ){ for(var k=1; k<=chkNum; k++){ var attDiv = $(".selectbox>div:eq(" + (k-1) + ")"); var target = "#item" + k; $(target).find("input[name=item-id-"+ k +"]").val(attDiv.attr("data-iID")); $(target).find("input[name=item-qty-"+ k +"]").val(attDiv.find("input").val()); $(target).find("input[name=item-stack-"+ k +"]").val(attDiv.attr("data-iStack")); $(target).find(".insert_item img").remove(); $(target).find(".insert_item span").remove(); $(target).find(".insert_item").append("" + attDiv.find("input").val() + ""); } } //Create function createList(){ $(document).on("click",".mask input[type=checkbox]",function() { chkFlag = $(this).is(':checked'); item = $(this).parent().parent(); itemImg = item.find("img").attr("src"); iID = item.find(".intclue").attr("rel").replace("#tooltip-","");// rel="#tooltip-6" iQty = item.find("span").text(); iStack = item.attr("id"); //console.log( itemImg+","+iID +","+ iQty +","+ iStack +","+ i ); var hasItem = $(".selectbox").find("div[data-iStack=" + iStack +"]"); if( chkFlag === true && hasItem.length === 0 ){ i = i + 1; if ( i > 16){ alert("Can't add more than 16 items!"); $(this).prop({checked:false}); i = i - 1; return; } $(".selectbox").append( "
" + "" + "" + "
" ); //console.log(i); } if( chkFlag === false && hasItem.length === 1 ){ hasItem.remove(); i = i - 1; //console.log(i); } }); } //Handle Attach function creatMask(){ var j = 0; $("#itempage").find(".mask").remove(); $("#itempage>span").each(function() { $(this).append(""); j= j + 1; }); } //clear attach function clrItem(){ i=0; $(".selectbox").empty(); reAttch(); } function reAttch(){ for(var j=1; j<=16; j++){ var target = "#item" + j; $(target).find("input[name=item-id-"+ j +"]").val(""); $(target).find("input[name=item-qty-"+ j +"]").val(""); $(target).find("input[name=item-stack-"+ j +"]").val(""); $(target).find(".insert_item img").remove(); $(target).find(".insert_item span").remove(); } } function quickSearch(){ var itemID = $("#itemID").val(); var anchor= $("#itempage img[src$='"+ itemID +".png']").parent().parent(); var position = anchor.position().top + $("#itempage").scrollTop(); $("#itempage").animate({scrollTop: position}); }