diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2016-11-12 09:51:40 +1300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-11-12 09:51:40 +1300 |
commit | fe7c46a0827eff88bc54e0d175b62f762bbd3688 (patch) | |
tree | d0c5467ca2e69e2eb51699a13c57f51ce8292446 /web/load.js | |
parent | 11c8c039cc8c5a1948281f410bdb440d5a9f1608 (diff) | |
parent | 9b36b690301faa7b84bade074aae3e863be5495d (diff) | |
download | trackermap-web-fe7c46a0827eff88bc54e0d175b62f762bbd3688.tar.gz trackermap-web-fe7c46a0827eff88bc54e0d175b62f762bbd3688.tar.bz2 trackermap-web-fe7c46a0827eff88bc54e0d175b62f762bbd3688.zip |
Merge pull request #313 from Abyss777/device_images
Draft of device images
Diffstat (limited to 'web/load.js')
-rw-r--r-- | web/load.js | 42 |
1 files changed, 31 insertions, 11 deletions
diff --git a/web/load.js b/web/load.js index f4987acd..0d13b2c6 100644 --- a/web/load.js +++ b/web/load.js @@ -1,24 +1,34 @@ (function () { + var debugMode, touchMode, locale, localeParameter, extjsVersion, fontAwesomeVersion, olVersion; function addStyleFile(file) { var link = document.createElement('link'); link.setAttribute('rel', 'stylesheet'); link.setAttribute('type', 'text/css'); link.setAttribute('href', file); - document.head.appendChild(link) + document.head.appendChild(link); } function addScriptFile(file) { var script = document.createElement('script'); script.setAttribute('src', file); - script.async = false + script.async = false; document.head.appendChild(script); } - var debugMode = document.getElementById('loadScript').getAttribute('mode') === 'debug'; - var touchMode = 'ontouchstart' in window || navigator.maxTouchPoints; + function addSvgFile(file, id) { + var svg = document.createElement('object'); + svg.setAttribute('id', id); + svg.setAttribute('data', file); + svg.setAttribute('type', 'image/svg+xml'); + svg.setAttribute('style', 'visibility:hidden'); + document.body.appendChild(svg); + } + + debugMode = document.getElementById('loadScript').getAttribute('mode') === 'debug'; + touchMode = 'ontouchstart' in window || navigator.maxTouchPoints; - var locale = {}; + locale = {}; window.Locale = locale; locale.languages = { @@ -65,7 +75,7 @@ 'zh': { name: '中文', code: 'zh_CN' } }; - var localeParameter = window.location.search.match(/locale=([^&#]+)/); + localeParameter = window.location.search.match(/locale=([^&#]+)/); locale.language = localeParameter && localeParameter[1]; if (locale.language === undefined) { locale.language = window.navigator.userLanguage || window.navigator.language; @@ -76,7 +86,7 @@ locale.language = 'en'; // default } - window.addEventListener("load", function (event) { + window.addEventListener('load', function (event) { if (debugMode) { Ext.Loader.setConfig({ @@ -99,9 +109,9 @@ }); - var extjsVersion = '6.0.1'; - var fontAwesomeVersion = '4.6.3'; - var olVersion = '3.18.2'; + extjsVersion = '6.0.1'; + fontAwesomeVersion = '4.6.3'; + olVersion = '3.18.2'; if (debugMode) { addScriptFile('//cdnjs.cloudflare.com/ajax/libs/extjs/' + extjsVersion + '/ext-all-debug.js'); @@ -119,6 +129,16 @@ addScriptFile('//cdnjs.cloudflare.com/ajax/libs/ol3/' + olVersion + '/ol-debug.js'); addStyleFile('app.css'); - addScriptFile('arrow.js'); + + addSvgFile('images/default.svg', 'defaultSvg'); + addSvgFile('images/arrow.svg', 'arrowSvg'); + addSvgFile('images/car.svg', 'carSvg'); + addSvgFile('images/bus.svg', 'busSvg'); + addSvgFile('images/truck.svg', 'truckSvg'); + addSvgFile('images/ship.svg', 'shipSvg'); + addSvgFile('images/plane.svg', 'planeSvg'); + addSvgFile('images/motorcycle.svg', 'motorcycleSvg'); + addSvgFile('images/bicycle.svg', 'bicycleSvg'); + addSvgFile('images/person.svg', 'personSvg'); })(); |