var tminfo = null; function insertTMInfo(jsonTminfo) { tminfo = jsonTminfo; } function Tablemap (roomid,tables,elem) { this.tables = tables; this.roomid = roomid; this.elem = elem; this.selectedTableId = -1; if ((tables != null) && (tables.length > 0)) { this.selectedTableId = tables[0].id; } } Tablemap.prototype.renderContent = function() { doAjaxTransmitData("GET","php/tablemap.php?command=getTableMap&roomid=" + this.roomid,null,this.renderTableList,null,this); d = new Date(); $("#mapimgpart").attr("src", "php/tablemap.php?command=getTableMapImgAsPng&roomid=" + this.roomid + "&tableid=" + this.selectedTableId + "&"+d.getTime()); } Tablemap.prototype.renderTableList = function(tables,instance) { instance.tables = tables; var tablelist = instance.createList(tables,"table_","tablebtn","c",instance); $(instance.elem).html(tablelist); tmRefreshList(instance.elem); instance.binding(instance); } Tablemap.prototype.createList = function(aList,idPrefix,classes,defaultTheme,instance) { var txt = '
'; return txt; } Tablemap.prototype.binding = function(instance) { $('.tablebtn').off("click").on("click", function (e) { e.stopImmediatePropagation(); e.preventDefault(); instance.selectedTableId = this.id.split("_")[1]; instance.renderContent(instance.elem); }); $("#tmimgbtn").off("click").on("click", function (e) { e.stopImmediatePropagation(); e.preventDefault(); instance.uploadImg(instance); }); $("#mapimgpart").off("click").on("click", function (e) { e.stopImmediatePropagation(); e.preventDefault(); var width = $('#mapimgpart').width(); var height = $('#mapimgpart').height(); var offset_t = $(this).offset().top - $(window).scrollTop(); var offset_l = $(this).offset().left - $(window).scrollLeft(); var left = Math.round( (e.clientX - offset_l) ); var top = Math.round( (e.clientY - offset_t) ); var data = { tableid:instance.selectedTableId, x:(100*left)/width, y:(100*top)/height }; doAjaxTransmitData("POST","php/tablemap.php?command=setPosition",data,instance.renderIfOk,null,instance); }); } Tablemap.prototype.createOverlay = function (elem,positions,payTxt,decpoint,currency,tables,ostablebtnsize,selectedTableid) { if (typeof selectedTableid === 'undefined') { selectedTableid = null; } var t = []; var sizeclass = ""; if (ostablebtnsize == 0) { sizeclass = "overlaysize-0"; } else if (ostablebtnsize == 1) { sizeclass = "overlaysize-1"; } else if (ostablebtnsize == 2) { sizeclass = "overlaysize-2"; } for (var i=0;i