diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2016-11-13 12:44:15 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2016-11-13 12:44:15 +1300 |
commit | f31ff81c2b027e2b0ecfe0cba33b6a74c58ab228 (patch) | |
tree | 2c140e9b7bf0020ff1e6e6bd29462874267df310 /web/app/DeviceImages.js | |
parent | e4636b99714b8187ab3f00287f1eb0fa2dfd985f (diff) | |
download | trackermap-web-f31ff81c2b027e2b0ecfe0cba33b6a74c58ab228.tar.gz trackermap-web-f31ff81c2b027e2b0ecfe0cba33b6a74c58ab228.tar.bz2 trackermap-web-f31ff81c2b027e2b0ecfe0cba33b6a74c58ab228.zip |
Simplify image creation code
Diffstat (limited to 'web/app/DeviceImages.js')
-rw-r--r-- | web/app/DeviceImages.js | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/web/app/DeviceImages.js b/web/app/DeviceImages.js index fac16a57..1e63cf29 100644 --- a/web/app/DeviceImages.js +++ b/web/app/DeviceImages.js @@ -20,20 +20,15 @@ Ext.define('Traccar.DeviceImages', { singleton: true, getImageSvg: function (color, zoom, angle, category) { - var i, device, svg, width, height, rotateTransform, scaleTransform, fill; + var i, info, svg, width, height, rotateTransform, scaleTransform, fill; - if (category) { - device = Ext.getStore('DeviceImages').findRecord('key', category, 0, false, false, true); - } - if (!device) { - device = Ext.getStore('DeviceImages').findRecord('key', 'default', 0, false, false, true); - } - svg = Ext.clone(device.get('svg')); + info = Ext.getStore('DeviceImages').findRecord('key', category || 'default', 0, false, false, true); + svg = Ext.clone(info.get('svg')); width = parseFloat(svg.documentElement.getAttribute('width')); height = parseFloat(svg.documentElement.getAttribute('height')); - fill = device.get('fillId'); + fill = info.get('fillId'); if (!Ext.isArray(fill)) { fill = [fill]; } @@ -42,7 +37,7 @@ Ext.define('Traccar.DeviceImages', { } rotateTransform = 'rotate(' + angle + ' ' + (width / 2) + ' ' + (height / 2) + ')'; - svg.getElementById(device.get('rotateId')).setAttribute('transform', rotateTransform); + svg.getElementById(info.get('rotateId')).setAttribute('transform', rotateTransform); if (zoom) { width *= Traccar.Style.mapScaleSelected; @@ -54,10 +49,10 @@ Ext.define('Traccar.DeviceImages', { scaleTransform = 'scale(' + Traccar.Style.mapScaleNormal + ') '; } - if (device.get('scaleId') !== device.get('rotateId')) { - svg.getElementById(device.get('scaleId')).setAttribute('transform', scaleTransform); + if (info.get('scaleId') !== info.get('rotateId')) { + svg.getElementById(info.get('scaleId')).setAttribute('transform', scaleTransform); } else { - svg.getElementById(device.get('scaleId')).setAttribute('transform', scaleTransform + ' ' + rotateTransform); + svg.getElementById(info.get('scaleId')).setAttribute('transform', scaleTransform + ' ' + rotateTransform); } svg.documentElement.setAttribute('width', width); |