Lines of Code | 48 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import GoogleMap from './blocks/maps/modules/GoogleMap'; |
||
2 | import {createRandomId} from './blocks/maps/functions/createRandomId'; |
||
3 | |||
4 | class App { |
||
5 | constructor() { |
||
6 | window.GoogleMap = { |
||
7 | readyApi: false, |
||
8 | api: document.querySelector('meta[property="maps:key"]').getAttribute('content'), |
||
9 | instances: [], |
||
10 | init: () => { |
||
11 | [].forEach.call(document.querySelectorAll('*[data-module="google-map"]'), (container, index) => { |
||
|
|||
12 | let instanceId = createRandomId(); |
||
13 | let options = container.getAttribute('data-options'); |
||
14 | |||
15 | if (typeof options == 'undefined' || options == '') { |
||
16 | options = {}; |
||
17 | } else { |
||
18 | options = JSON.parse(options); |
||
19 | } |
||
20 | |||
21 | window.GoogleMap.instances.push(new GoogleMap(container, Object.assign({ |
||
22 | instanceId: instanceId |
||
23 | }, options))); |
||
24 | }); |
||
25 | } |
||
26 | }; |
||
27 | } |
||
28 | |||
29 | init() { |
||
30 | if (!window.GoogleMap.readyApi && (window.GoogleMap.api != '' || typeof window.GoogleMap.api != 'undefined')) { |
||
31 | let script = document.createElement('script'); |
||
32 | |||
33 | script.type = 'text/javascript'; |
||
34 | script.src = `//maps.googleapis.com/maps/api/js?key=${window.GoogleMap.api}&libraries=places&callback=window.GoogleMap.init`; |
||
35 | |||
36 | document.body.appendChild(script); |
||
37 | window.GoogleMap.readyApi = true; |
||
38 | } |
||
39 | } |
||
40 | } |
||
41 | |||
42 | document.addEventListener("DOMContentLoaded", () => { |
||
43 | if (!('GoogleMap' in window)) { |
||
44 | const APP = new App(); |
||
45 | |||
46 | APP.init(); |
||
47 | } |
||
48 | }); |
This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.