PageSourceSearch

https://mapsdrivingdirections.io/themes/maps_v2/rs/js/map_user.js

js mapsdrivingdirections.io collected 2026-09-28 05:52:31 UTC 3,147 bytes, 103 lines download raw bytes

1class User {
2    initialized = false;
3    initializedEvent = new EventHandlers();
4    initurlparams = false;
5    url_params = null;
6    initurlslug = false;
7    position = null;
8    sub_position = null;
9    initcookie = false;
10    datafromuser = null;
11    permission = null;
12    expires = { expires: 30, path: '/' };
13    limit = 6;
14    async init() {
15        this.url_params = this.getUrlParam();
16        let is_params = Object.keys(this.url_params).length;
17        if (is_params > 0) {
18            this.initurlparams = true;
19        }
20        if (location_url) {
21            this.sub_position = {
22                lat: location_url.lat,
23                lng: location_url.lng
24            }
25            this.position = pos;
26            this.initurlslug = true;
27        }
28        if (!location_url && !pos) {
29            this.position = await this.getLocation();
30            this.initializedEvent.handle1(this.position);
31            this.initialized = true;
32        } else {
33            this.position = pos;
34            this.sub_position = {
35                lat: pos.lat,
36                lng: pos.lng
37            }
38        }
39    }
40
41    async checkGeoPermission() {
42        return new Promise((resolve) => {
43            navigator.permissions.query({ name: 'geolocation' }).then(function (PermissionStatus) {
44                resolve(PermissionStatus.state);
45            })
46        })
47    }
48
49    getLocation() {
50        console.log("map_user_ getLocation");
51        return new Promise((resolve) => {
52            if (navigator.geolocation) {
53                navigator.geolocation.getCurrentPosition(function (position) {
54                    let user_pos = {
55                        lat: position.coords.latitude,
56                        lng: position.coords.longitude
57                    }
58                    resolve(user_pos);
59                }, function () {
60                    resolve(pos);
61                });
62            } else {
63                resolve(pos);
64            }
65        });
66    }
67    getUrlParam() {
68        return getParamsUrl();
69    }
70    createCookie(value) {
71        let data_cookie = Cookies.get(Shell.cookie_name);
72        let array_cookie = [];
73        if (data_cookie) {
74            array_cookie = JSON.parse(data_cookie);
75            let add = true;
76            for (let temp of array_cookie) {
77                if (value.id === temp.id) {
78                    add = false;
79                    return;
80                }
81            }
82            if (add) {
83                array_cookie.push(value);
84            }
85
86            if (array_cookie.length >= this.limit) {
87                array_cookie = array_cookie.slice(Math.max(array_cookie.length - this.limit, 0))
88            }
89        } else {
90            array_cookie.push(value);
91        }
92        let json_cookie = JSON.stringify(array_cookie);
93        Cookies.set(Shell.cookie_name, json_cookie, this.expires);
94    }
95    readCookie() {
96        return Cookies.get(Shell.cookie_name);
97    }
98    removeCookie() {
99        return Cookies.remove(Shell.cookie_name);
100    }
101}
102
103

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.