Created
February 5, 2020 22:40
-
-
Save wbarcovsky/23645ac1964f6b780f049031c22a1f2e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <script> | |
| var page_width = 0; | |
| var page_height = 0; | |
| var wheel_handle = null; | |
| var movemode = false; | |
| var top_pos = 0; | |
| var left_pos = 0; | |
| var start_x = -1; | |
| var start_y = -1; | |
| var min_x = 0; | |
| var min_y = 0; | |
| var max_x = 0; | |
| var max_y = 0; | |
| var pointx = 0; | |
| var pointy = 0; | |
| var area = 0; | |
| var mouse_step = 30; | |
| var scroll; | |
| var scale =0.5; | |
| var rooms = [{"ID":"131","name":"1","spase":"38.20","points":"12|20|224|19|223|321|16|324|","default_price":"200.00","floorsid":"10","certsid":"135","public":"0","ofice":"","date_from":"2012-01-01","date_to":null,"activ":"1","offsetx":"0","offsety":"0","office":"","font_size":"12","note":"\u0422\u0435\u043f\u043b\u043e\u0443\u0437\u0435\u043b.","ur_address":"0","rented_spase":0,"has_conf":false,"title":"\u2116 1"},{"ID":"132","name":"2","spase":"17.00","points":"238|18|318|17|318|266|236|266|","default_price":"200.00","floorsid":"10","certsid":"135","public":"0","ofice":"","date_from":"2012-01-01","date_to":null,"activ":"1","offsetx":"0","offsety":"0","office":"","font_size":"12","note":"","ur_address":"0","rented_spase":0,"has_conf":false,"title":"\u2116 2"},{"ID":"263","name":"3","spase":"17.80","points":"385|17|496|18|497|249|386|249|","default_price":"200.00","floorsid":"10","certsid":"135","public":"0","ofice":"","date_from":"2012-01-01","date_to":null,"activ":"1","offsetx":"0","offsety":"60","office":"","font_size":"12","note":"","ur_address":"0","rented_spase":0,"has_conf":false,"title":"\u2116 3"},{"ID":"269","name":"8","spase":"3.50","points":"237|272|318|273|318|324|238|324|","default_price":"200.00","floorsid":"10","certsid":"135","public":"0","ofice":"","date_from":"2012-01-01","date_to":null,"activ":"1","offsetx":"0","offsety":"0","office":"","font_size":"12","note":"","ur_address":"0","rented_spase":0,"has_conf":false,"title":"\u2116 8"},{"ID":"270","name":"9","spase":"11.60","points":"369|257|502|257|501|419|369|420|","default_price":"200.00","floorsid":"10","certsid":"135","public":"0","ofice":"","date_from":"2012-01-01","date_to":null,"activ":"1","offsetx":"0","offsety":"0","office":"","font_size":"12","note":"","ur_address":"0","rented_spase":0,"has_conf":false,"title":"\u2116 9"},{"ID":"285","name":"13","spase":"13.50","points":"14|393|105|393|105|331|165|331|166|425|319|426|319|487|13|487|","default_price":"200.00","floorsid":"10","certsid":"135","public":"1","ofice":"","date_from":"2012-01-01","date_to":null,"activ":"1","offsetx":"-20","offsety":"35","office":"","font_size":"12","note":"","ur_address":"0","rented_spase":0,"has_conf":false,"title":"\u2116 13"},{"ID":"287","name":"15","spase":"5.30","points":"370|426|503|427|501|488|369|486|","default_price":"200.00","floorsid":"10","certsid":"135","public":"1","ofice":"","date_from":"2012-01-01","date_to":null,"activ":"1","offsetx":"0","offsety":"0","office":"","font_size":"12","note":"","ur_address":"0","rented_spase":0,"has_conf":false,"title":"\u2116 15"},{"ID":"293","name":"20","spase":"17.50","points":"326|356|362|356|363|493|378|494|377|534|359|533|361|718|311|718|311|665|326|666|","default_price":"200.00","floorsid":"10","certsid":"135","public":"1","ofice":"","date_from":"2012-01-01","date_to":null,"activ":"1","offsetx":"5","offsety":"-20","office":"","font_size":"12","note":"","ur_address":"0","rented_spase":0,"has_conf":false,"title":"\u2116 20"},{"ID":"295","name":"21","spase":"8.90","points":"15|493|149|494|149|585|13|585|","default_price":"200.00","floorsid":"10","certsid":"135","public":"1","ofice":"","date_from":"2012-01-01","date_to":null,"activ":"1","offsetx":"0","offsety":"0","office":"","font_size":"12","note":"","ur_address":"0","rented_spase":0,"has_conf":false,"title":"\u2116 21"},{"ID":"297","name":"22","spase":"5.10","points":"157|494|242|494|243|585|156|585|","default_price":"200.00","floorsid":"10","certsid":"135","public":"1","ofice":"","date_from":"2012-01-01","date_to":null,"activ":"1","offsetx":"0","offsety":"0","office":"","font_size":"12","note":"","ur_address":"0","rented_spase":0,"has_conf":false,"title":"\u2116 22"},{"ID":"300","name":"23","spase":"15.90","points":"250|494|319|493|319|658|298|659|297|650|249|650|","default_price":"200.00","floorsid":"10","certsid":"135","public":"1","ofice":"","date_from":"2012-01-01","date_to":null,"activ":"1","offsetx":"0","offsety":"0","office":"","font_size":"12","note":"","ur_address":"0","rented_spase":0,"has_conf":false,"title":"\u2116 23"},{"ID":"302","name":"24","spase":"8.40","points":"385|493|523|494|522|555|367|555|361|555|361|542|385|542|","default_price":"200.00","floorsid":"10","certsid":"135","public":"1","ofice":"","date_from":"2012-01-01","date_to":null,"activ":"1","offsetx":"0","offsety":"0","office":"","font_size":"12","note":"","ur_address":"0","rented_spase":0,"has_conf":false,"title":"\u2116 24"},{"ID":"303","name":"25","spase":"30.00","points":"529|493|715|493|715|658|529|658|","default_price":"200.00","floorsid":"10","certsid":"135","public":"1","ofice":"","date_from":"2012-01-01","date_to":null,"activ":"1","offsetx":"0","offsety":"0","office":"","font_size":"12","note":"","ur_address":"0","rented_spase":0,"has_conf":false,"title":"\u2116 25"},{"ID":"304","name":"26","spase":"13.20","points":"721|493|892|493|892|564|721|564|","default_price":"200.00","floorsid":"10","certsid":"135","public":"1","ofice":"","date_from":"2012-01-01","date_to":null,"activ":"1","offsetx":"0","offsety":"0","office":"","font_size":"12","note":"","ur_address":"0","rented_spase":0,"has_conf":false,"title":"\u2116 26"},{"ID":"307","name":"28","spase":"21.10","points":"14|591|243|592|242|717|13|718|","default_price":"200.00","floorsid":"10","certsid":"135","public":"0","ofice":"","date_from":"2012-01-01","date_to":null,"activ":"1","offsetx":"0","offsety":"0","office":"","font_size":"12","note":"\u042d\u043b\u0435\u043a\u0442\u0440\u043e\u0449\u0438\u0442\u043e\u0432\u0430\u044f.","ur_address":"0","rented_spase":0,"has_conf":false,"title":"\u2116 28"},{"ID":"309","name":"29","spase":"4.40","points":"249|657|291|657|291|664|305|664|305|718|249|718|","default_price":"200.00","floorsid":"10","certsid":"135","public":"0","ofice":"","date_from":"2012-01-01","date_to":null,"activ":"1","offsetx":"0","offsety":"0","office":"","font_size":"12","note":"","ur_address":"0","rented_spase":0,"has_conf":false,"title":"\u2116 29"},{"ID":"311","name":"30","spase":"2.00","points":"367|562|419|562|420|608|367|608|","default_price":"200.00","floorsid":"10","certsid":"135","public":"1","ofice":"","date_from":"2012-01-01","date_to":null,"activ":"1","offsetx":"0","offsety":"0","office":"","font_size":"12","note":"","ur_address":"0","rented_spase":0,"has_conf":false,"title":"\u2116 30"},{"ID":"312","name":"31","spase":"4.20","points":"426|561|523|562|523|608|426|607|","default_price":"200.00","floorsid":"10","certsid":"135","public":"1","ofice":"","date_from":"2012-01-01","date_to":null,"activ":"1","offsetx":"0","offsety":"0","office":"","font_size":"12","note":"","ur_address":"0","rented_spase":0,"has_conf":false,"title":"\u2116 31"},{"ID":"314","name":"32","spase":"7.80","points":"367|615|523|615|524|658|367|659|","default_price":"200.00","floorsid":"10","certsid":"135","public":"1","ofice":"","date_from":"2012-01-01","date_to":null,"activ":"1","offsetx":"0","offsety":"0","office":"","font_size":"12","note":"","ur_address":"0","rented_spase":0,"has_conf":false,"title":"\u2116 32"},{"ID":"317","name":"33","spase":"33.30","points":"721|570|891|570|892|719|720|717|","default_price":"200.00","floorsid":"10","certsid":"135","public":"1","ofice":"","date_from":"2012-01-01","date_to":null,"activ":"1","offsetx":"0","offsety":"0","office":"","font_size":"12","note":"","ur_address":"0","rented_spase":0,"has_conf":false,"title":"\u2116 33"},{"ID":"319","name":"34","spase":"17.20","points":"367|665|714|665|715|718|367|718|","default_price":"200.00","floorsid":"10","certsid":"135","public":"1","ofice":"","date_from":"2012-01-01","date_to":null,"activ":"1","offsetx":"0","offsety":"0","office":"","font_size":"12","note":"","ur_address":"0","rented_spase":0,"has_conf":false,"title":"\u2116 34"},{"ID":"320","name":"35","spase":"4.00","points":"13|725|95|723|95|771|14|770|","default_price":"200.00","floorsid":"10","certsid":"135","public":"0","ofice":"","date_from":"2012-01-01","date_to":null,"activ":"1","offsetx":"0","offsety":"0","office":"","font_size":"12","note":"\u042d\u043b\u0435\u043a\u0442\u0440\u043e\u0449\u0438\u0442\u043e\u0432\u0430\u044f.","ur_address":"0","rented_spase":0,"has_conf":false,"title":"\u2116 35"},{"ID":"322","name":"36","spase":"2.50","points":"101|725|154|723|155|770|101|770|","default_price":"200.00","floorsid":"10","certsid":"135","public":"0","ofice":"","date_from":"2012-01-01","date_to":null,"activ":"1","offsetx":"0","offsety":"0","office":"","font_size":"12","note":"","ur_address":"0","rented_spase":0,"has_conf":false,"title":"\u2116 36"},{"ID":"323","name":"37","spase":"13.50","points":"160|724|538|723|537|771|160|771|","default_price":"200.00","floorsid":"10","certsid":"135","public":"0","ofice":"","date_from":"2012-01-01","date_to":null,"activ":"1","offsetx":"0","offsety":"0","office":"","font_size":"12","note":"","ur_address":"0","rented_spase":0,"has_conf":false,"title":"\u2116 37"},{"ID":"325","name":"38","spase":"70.90","points":"544|723|947|723|948|882|496|883|496|777|544|777|","default_price":"150.00","floorsid":"10","certsid":"135","public":"1","ofice":"","date_from":"2012-01-01","date_to":null,"activ":"1","offsetx":"0","offsety":"0","office":"","font_size":"12","note":"","ur_address":"0","rented_spase":0,"has_conf":false,"title":"\u2116 38"},{"ID":"329","name":"40","spase":"10.50","points":"13|777|287|776|287|823|14|823|","default_price":"200.00","floorsid":"10","certsid":"135","public":"0","ofice":"","date_from":"2012-01-01","date_to":null,"activ":"1","offsetx":"0","offsety":"0","office":"","font_size":"12","note":"","ur_address":"0","rented_spase":0,"has_conf":false,"title":"\u2116 40"},{"ID":"330","name":"41","spase":"4.70","points":"376|778|490|777|490|824|376|824|","default_price":"200.00","floorsid":"10","certsid":"135","public":"0","ofice":"","date_from":"2012-01-01","date_to":null,"activ":"1","offsetx":"0","offsety":"0","office":"","font_size":"12","note":"","ur_address":"0","rented_spase":0,"has_conf":false,"title":"\u2116 41"},{"ID":"332","name":"42","spase":"151.10","points":"14|831|294|831|293|777|370|777|368|829|490|830|491|1088|13|1088|14|1016|96|1017|95|965|14|965|","default_price":"200.00","floorsid":"10","certsid":"135","public":"0","ofice":"","date_from":"2012-01-01","date_to":null,"activ":"1","offsetx":"0","offsety":"0","office":"","font_size":"12","note":"","ur_address":"0","rented_spase":0,"has_conf":false,"title":"\u2116 42"},{"ID":"333","name":"43","spase":"2.80","points":"14|971|89|971|89|1009|14|1009|","default_price":"200.00","floorsid":"10","certsid":"135","public":"0","ofice":"","date_from":"2012-01-01","date_to":null,"activ":"1","offsetx":"0","offsety":"0","office":"","font_size":"12","note":"","ur_address":"0","rented_spase":0,"has_conf":false,"title":"\u2116 43"},{"ID":"335","name":"45","spase":"24.00","points":"677|889|808|888|809|1003|676|1004|","default_price":"150.00","floorsid":"10","certsid":"135","public":"1","ofice":"","date_from":"2012-01-01","date_to":null,"activ":"1","offsetx":"0","offsety":"0","office":"","font_size":"12","note":"","ur_address":"0","rented_spase":0,"has_conf":false,"title":"\u2116 45"},{"ID":"337","name":"46","spase":"18.00","points":"815|889|936|889|936|1003|814|1004|","default_price":"150.00","floorsid":"10","certsid":"135","public":"1","ofice":"","date_from":"2012-01-01","date_to":null,"activ":"1","offsetx":"0","offsety":"0","office":"","font_size":"12","note":"","ur_address":"0","rented_spase":0,"has_conf":false,"title":"\u2116 46"},{"ID":"338","name":"47","spase":"8.00","points":"816|1010|905|1009|907|1087|815|1088|","default_price":"200.00","floorsid":"10","certsid":"135","public":"0","ofice":"","date_from":"2012-01-01","date_to":null,"activ":"1","offsetx":"0","offsety":"0","office":"","font_size":"12","note":"","ur_address":"0","rented_spase":0,"has_conf":false,"title":"\u2116 47"},{"ID":"339","name":"48","spase":"13.90","points":"325|17|373|17|371|248|362|250|363|347|325|349|","default_price":"200.00","floorsid":"10","certsid":"135","public":"0","ofice":"","date_from":"2012-01-01","date_to":null,"activ":"1","offsetx":"0","offsety":"0","office":"","font_size":"10","note":"","ur_address":"0","rented_spase":0,"has_conf":false,"title":"\u2116 48"},{"ID":"1417","name":"49","spase":"9.60","points":"498|1023|498|1086|581|1085|581|1023|","default_price":"200.00","floorsid":"10","certsid":"135","public":"0","ofice":"","date_from":"2013-07-01","date_to":null,"activ":"1","offsetx":"0","offsety":"0","office":"","font_size":"12","note":"","ur_address":"0","rented_spase":0,"has_conf":false,"title":"\u2116 49"},{"ID":"1418","name":"44","spase":"22.60","points":"498|891|498|1014|581|1014|581|891|","default_price":"150.00","floorsid":"10","certsid":"135","public":"1","ofice":"","date_from":"2013-07-01","date_to":null,"activ":"1","offsetx":"0","offsety":"0","office":"","font_size":"12","note":"","ur_address":"0","rented_spase":0,"has_conf":false,"title":"\u2116 44"}]; | |
| var all_points = []; | |
| var stop_draw = 0; | |
| var stop_area = 0; | |
| all_points[131] = [12,20,224,19,223,321,16,324]; | |
| all_points[132] = [238,18,318,17,318,266,236,266]; | |
| all_points[263] = [385,17,496,18,497,249,386,249]; | |
| all_points[269] = [237,272,318,273,318,324,238,324]; | |
| all_points[270] = [369,257,502,257,501,419,369,420]; | |
| all_points[285] = [14,393,105,393,105,331,165,331,166,425,319,426,319,487,13,487]; | |
| all_points[287] = [370,426,503,427,501,488,369,486]; | |
| all_points[293] = [326,356,362,356,363,493,378,494,377,534,359,533,361,718,311,718,311,665,326,666]; | |
| all_points[295] = [15,493,149,494,149,585,13,585]; | |
| all_points[297] = [157,494,242,494,243,585,156,585]; | |
| all_points[300] = [250,494,319,493,319,658,298,659,297,650,249,650]; | |
| all_points[302] = [385,493,523,494,522,555,367,555,361,555,361,542,385,542]; | |
| all_points[303] = [529,493,715,493,715,658,529,658]; | |
| all_points[304] = [721,493,892,493,892,564,721,564]; | |
| all_points[307] = [14,591,243,592,242,717,13,718]; | |
| all_points[309] = [249,657,291,657,291,664,305,664,305,718,249,718]; | |
| all_points[311] = [367,562,419,562,420,608,367,608]; | |
| all_points[312] = [426,561,523,562,523,608,426,607]; | |
| all_points[314] = [367,615,523,615,524,658,367,659]; | |
| all_points[317] = [721,570,891,570,892,719,720,717]; | |
| all_points[319] = [367,665,714,665,715,718,367,718]; | |
| all_points[320] = [13,725,95,723,95,771,14,770]; | |
| all_points[322] = [101,725,154,723,155,770,101,770]; | |
| all_points[323] = [160,724,538,723,537,771,160,771]; | |
| all_points[325] = [544,723,947,723,948,882,496,883,496,777,544,777]; | |
| all_points[329] = [13,777,287,776,287,823,14,823]; | |
| all_points[330] = [376,778,490,777,490,824,376,824]; | |
| all_points[332] = [14,831,294,831,293,777,370,777,368,829,490,830,491,1088,13,1088,14,1016,96,1017,95,965,14,965]; | |
| all_points[333] = [14,971,89,971,89,1009,14,1009]; | |
| all_points[335] = [677,889,808,888,809,1003,676,1004]; | |
| all_points[337] = [815,889,936,889,936,1003,814,1004]; | |
| all_points[338] = [816,1010,905,1009,907,1087,815,1088]; | |
| all_points[339] = [325,17,373,17,371,248,362,250,363,347,325,349]; | |
| all_points[1417] = [498,1023,498,1086,581,1085,581,1023]; | |
| all_points[1418] = [498,891,498,1014,581,1014,581,891]; | |
| function MakeHint(text, x, y) { | |
| hint.innerHTML = text; | |
| MoveHint(x, y); | |
| hint.style.visibility = "visible"; | |
| } | |
| function HideHint() { | |
| hint.style.visibility = "hidden"; | |
| hint.innerHTML = ""; | |
| hint.style.top = 0; | |
| hint.style.left = 0; | |
| } | |
| function MoveHint(x, y) { | |
| x = (x * scale) + $('#main').offset().left; | |
| y = (y * scale) + $('#main').offset().top; | |
| hint.style.top = (y + 20) + 'px'; | |
| hint.style.left = (x + 15) + 'px'; | |
| var w = hint.clientWidth; | |
| var h = hint.clientHeight; | |
| if (x + w >750) { | |
| hint.style.left = (x + 15 - w) + 'px'; | |
| } | |
| } | |
| function Move(event) { | |
| if (stop_area) return; | |
| stop_area = true; | |
| pointx = ((event.layerX == undefined ? event.offsetX : event.layerX) + 1) / scale; | |
| pointy = ((event.layerY == undefined ? event.offsetY : event.layerY) + 1) / scale; | |
| if (movemode) { | |
| document.getElementById('canvas1').style.cursor = 'move'; | |
| Draw(true, 0, 0); | |
| } else { | |
| var a = get_area(pointx, pointy); | |
| if (a !== area) { | |
| area = a; | |
| Draw(true, 0, 0); | |
| } | |
| else if (area == 0)HideHint(); else MoveHint(pointx, pointy); | |
| } | |
| stop_area = false; | |
| } | |
| function StartMove(event) { | |
| document.getElementById('canvas1').style.cursor = 'move'; | |
| start_x = event.pageX; | |
| start_y = event.pageY; | |
| movemode = true; | |
| } | |
| function StopMove(event) { | |
| movemode = false; | |
| document.getElementById('canvas1').style.cursor = 'default'; | |
| Draw(true, 0, 0); | |
| } | |
| function MakeInfo(callback) { | |
| rooms.forEach(function (r) { | |
| id = r.ID; | |
| if (area == id) { | |
| MakeRoomInfo(id, callback); | |
| } | |
| }); | |
| } | |
| function MakeRoomInfo(id, callback) { | |
| $(function () { | |
| $.post('http://saun.wbarcovsky.ru/objects/roomInfo/' + id, function (data) { | |
| $('#sum_info').html(data); | |
| if (callback) { | |
| callback(); | |
| } | |
| sys_update(); | |
| }); | |
| }); | |
| } | |
| function AddNewRoom(_this) { | |
| var floorId = $(_this).data('floor-id'); | |
| $.post('/objects/createRoom?foorID=' + floorId, function(roomId) { | |
| MakeRoomInfo(roomId, function () { | |
| $('#edit-room').click(); | |
| }); | |
| }); | |
| } | |
| function point_in_line(x1, y1, x2, y2, xa, ya) { | |
| if (y1 === y2) { | |
| if (y1 === ya) { | |
| if (x1 < xa && xa < x2)return true; | |
| if (x1 > xa && xa > x2)return true; | |
| return false; | |
| } | |
| else return false; | |
| } | |
| if (y1 > ya && y2 > ya)return false; | |
| if (y1 < ya && y2 < ya)return false; | |
| if (x1 !== x2) { | |
| if (y2 === ya)return false; | |
| var u1 = (ya - y1) / (y2 - y1); | |
| if (u1 > 1 || u1 < 0)return false; | |
| if (x1 - xa + x2 * u1 - x1 * u1 < 0)return false; | |
| return true; | |
| } | |
| else { | |
| if (xa < x1 && y2 !== ya)return true; | |
| } | |
| return false; | |
| } | |
| function in_area(pp, mx, my) { | |
| var xy = new Array(); | |
| var ii = 0; | |
| for (var j = 0; j < pp.length; j++) { | |
| if (!isNaN(parseInt(pp[j]))) { | |
| xy[ii] = parseInt(pp[j]); | |
| ii++; | |
| } | |
| } | |
| if (xy.length == 0)return false; | |
| var s = 0; | |
| var ss = ""; | |
| var r = 0; | |
| var l = 0; | |
| var x1, x2, y1, y2; | |
| for (var i = 0; i < xy.length; i += 2) { | |
| var ni = i + 2; | |
| if (ni + 2 > xy.length) { | |
| ni = 0; | |
| } | |
| //begin | |
| x1 = xy[i]; | |
| y1 = xy[i + 1]; | |
| x2 = xy[ni]; | |
| y2 = xy[ni + 1]; | |
| var minx = (x1 < x2 ? x1 : x2); | |
| var maxx = (x1 > x2 ? x1 : x2); | |
| var miny = (y1 < y2 ? y1 : y2); | |
| var maxy = (y1 > y2 ? y1 : y2); | |
| if ((my - y1) / (mx - x1) === (y2 - y1) / (x2 - x1) && minx <= mx && mx <= maxx && miny <= my && my <= maxy)return true; | |
| if ((y1 < my && y2 >= my) || (y1 >= my && y2 < my)) { | |
| var x = (my - y2) * (x1 - x2) / (y1 - y2) + x2; | |
| if (x == mx)return true; | |
| if (x < mx)r++; | |
| if (x > mx)s++; | |
| } | |
| } | |
| if (r == 0)return false; | |
| if (s == 0)return false; | |
| if (r % 2 && s % 2) return true; | |
| return false; | |
| } | |
| function get_area(x, y) { | |
| for (var id in all_points) { | |
| if (in_area(all_points[id], x, y)) { | |
| return id; | |
| } | |
| } | |
| return 0; | |
| } | |
| function Draw(lines, offsetx, offsety) { | |
| if (stop_draw) return; | |
| stop_draw = true; | |
| var can = document.getElementById('canvas'); | |
| var can1 = document.getElementById('canvas1'); | |
| var rc = can.getContext('2d'); | |
| var rc1 = can1.getContext('2d'); | |
| var xx = offsetx; | |
| var yy = offsety; | |
| var pattern_image = new Image(); | |
| pattern_image.src = 'http://saun.wbarcovsky.ru/img/pattern.png'; | |
| var img = new Image(); | |
| img.onload = function () { | |
| if (page_width === 0)page_width = img.width * scale; | |
| if (page_height === 0)page_height = img.height * scale; | |
| can.width = page_width; | |
| can1.width = page_width; | |
| can.height = page_height; | |
| can1.height = page_height; | |
| min_x = 0; | |
| min_y = 0; | |
| if (img.width * scale < page_width) { | |
| document.getElementById('main').style.width = (img.width * scale + 10) + 'px'; | |
| } else { | |
| min_x = page_width / scale - img.width; | |
| } | |
| if (img.height * scale < page_height) { | |
| document.getElementById('main').style.height = (img.height * scale + 10) + 'px'; | |
| can.height = (img.height * scale + 10); | |
| can1.height = (img.height * scale + 10); | |
| } else { | |
| min_y = page_height / scale - img.height; | |
| } | |
| if (area === 0 || movemode)HideHint(); | |
| rc.scale(scale, scale); | |
| rc.drawImage(img, xx, yy); | |
| rc1.scale(scale, scale); | |
| var points = ""; | |
| if (lines) { | |
| rooms.forEach(function (r) { | |
| var allspase = parseFloat(r.spase); | |
| var spase = parseFloat(r.rented_spase); | |
| if (r.points !== '') { | |
| var color1 = 'green'; | |
| var color2 = 'yellowgreen'; | |
| if (spase != 0) { | |
| if (spase >= allspase) { | |
| if (spase > allspase) { | |
| //темно-красный | |
| color1 = 'maroon'; | |
| color2 = 'tomato'; | |
| } | |
| else { | |
| //красный | |
| color1 = 'orangered'; | |
| color2 = 'salmon'; | |
| } | |
| } | |
| else { | |
| //оранжевый | |
| color1 = 'darkorange'; | |
| color2 = 'sandybrown'; | |
| } | |
| } | |
| else { | |
| if (r.ur_address == 1) { | |
| color1 = 'SteelBlue'; | |
| color2 = 'LightSteelBlue'; | |
| } else if (r.public == 0) { | |
| color1 = 'LightGray'; | |
| color2 = 'Linen'; | |
| } | |
| } | |
| rc1.lineWidth = 2; | |
| rc1.strokeStyle = color1; | |
| rc1.fillStyle = color1; | |
| rc1.beginPath(); | |
| points = all_points[r.ID]; | |
| for (var i = 0; i < points.length; i += 2) { | |
| if (points[i] !== '') { | |
| points[i] = points[i] + xx; | |
| points[i + 1] = points[i + 1] + yy; | |
| } | |
| } | |
| rc1.moveTo(points[0], points[1]); | |
| var maxx = points[0]; | |
| var minx = points[0]; | |
| var maxy = points[1]; | |
| var miny = points[1]; | |
| for (var i = 2; i <= points.length; i += 2) { | |
| rc1.lineTo(points[i], points[i + 1]); | |
| if (points[i] !== '') { | |
| if (points[i] > maxx)maxx = points[i]; | |
| if (points[i] < minx)minx = points[i]; | |
| } | |
| if (points[i + 1] !== '') { | |
| if (points[i + 1] > maxy)maxy = points[i + 1]; | |
| if (points[i + 1] < miny)miny = points[i + 1]; | |
| } | |
| } | |
| var avgx = Math.round((maxx + minx) / 2); | |
| var avgy = Math.round((maxy + miny) / 2); | |
| rc1.lineTo(points[0], points[1]); | |
| rc1.closePath(); | |
| rc1.stroke(); | |
| rc1.lineWidth = 2; | |
| rc1.moveTo(avgx, avgy); | |
| if (area === r.ID) { | |
| rc1.fillStyle = color2; | |
| var of = ''; | |
| if (r.office != '') { | |
| of = ' (оф. ' + r.office + ')'; | |
| } | |
| if (!movemode)MakeHint(r.title + of + '<br>' + r.rented_spase + '/' + r.spase + ' кв.м.' + '<br>(Двойной клик - подробнее', pointx, pointy); | |
| } | |
| rc1.fill(); | |
| if (r.selected) { | |
| rc1.fillStyle = rc1.createPattern(pattern_image, 'repeat'); | |
| rc1.fill(); | |
| } | |
| rc1.fillStyle = 'black'; | |
| if (r.public) { | |
| var o_x = parseInt(r.offsetx); | |
| var o_y = parseInt(r.offsety); | |
| rc1.font = r.font_size + 'pt Calibri'; | |
| rc1.fillStyle = 'black'; | |
| rc1.textAlign = 'center'; | |
| rc1.textBaseline = 'bottom'; | |
| of = ''; | |
| if (r.office != '') { | |
| //of = ' (оф. ' + r.office + ')'; | |
| } | |
| rc1.fillText(r.title, avgx + o_x, avgy + o_y); | |
| rc1.textBaseline = 'top'; | |
| rc1.fillText(r.spase + "м²", avgx + o_x, avgy + o_y); | |
| rc1.stroke(); | |
| } | |
| rc1.stroke(); | |
| } | |
| }); | |
| } | |
| }; | |
| img.src = 'http://saun.wbarcovsky.ru/img/objects/complex1/1floor.jpg'; | |
| stop_draw = false; | |
| } | |
| function saveimg() { | |
| var lh = page_height; | |
| var lw = page_width; | |
| page_height = 0; | |
| page_width = 0; | |
| Draw(true, 0, 0); | |
| } | |
| </script> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment