Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $.ajax({
- type: "GET",
- url: 'http://localhost:59927//api//GARO//GetGAROList',
- success: function (data, status, xhr) {
- data = JSON.parse(data);
- var l1 = document.createElement('li');
- l1.className = "FirstClass";
- document.getElementById('dropdown').appendChild(l1);
- for (var i = 0; i < data.Table.length; i++) {
- $.each(data.Table[i], function (key, values) {
- count++;
- var li = document.createElement('a');
- li.setAttribute('class', 'dropdown-toggle');
- li.setAttribute('href', '#homeSubmenu' + count);
- li.setAttribute('data-toggle', 'collapse');
- li.setAttribute('aria-expanded', 'false');
- l1.appendChild(li);
- li.textContent = key;
- var i = document.createElement('i');
- i.setAttribute('class', 'fas fa-layer-group');
- li.appendChild(i);
- var ul = document.createElement('ul');
- ul.setAttribute('class', 'collapse list-unstyled');
- ul.setAttribute('id', 'homeSubmenu' + count);
- l1.appendChild(ul);
- li = document.createElement('li');
- ul.appendChild(li);
- $.each(values, function (i, val) {
- var a1 = document.createElement('a');
- a1.setAttribute('href', '');
- li.appendChild(a1);
- a1.textContent = val;
- a1.setAttribute('value', val);
- a1.onclick = function () {
- value = a1.getAttribute('value');
- getCookie("Token", value);
- return false;
- };
- });
- });
- }
- },
- error: function (xhr) {
- alert(xhr.responseText);
- }
- });
- $.ajax({
- type: "GET",
- url: 'http://localhost:59927//api//Values//FlagingDevice(WithoutParameters)',
- contentType: 'application/json; charset=utf-8',
- dataType: 'json',
- success: function (data, status, xhr) {
- for (var i = 0; i < data.Table.length; i++) {
- circle[i] = L.circle([data.Table[i].Latitude, data.Table[i].Longitude], 50, { color: '#FFFFFF', opacity: 0.5, fillColor: 'red', fillOpacity: .3 }).addTo(map);
- data1[i] = { Latitude: data.Table[i].Latitude, Longitude: data.Table[i].Longitude };
- }
- },
- error: function (xhr) {
- alert(xhr.responseText);
- }
- });
- function getCookie(Token, value) {
- alert(value);
- variable = value;
- var name = Token + "=";
- var decodedCookie = decodeURIComponent(document.cookie);
- var ca = decodedCookie.split(';');
- for (var i = 0; i < ca.length; i++) {
- var c = ca[i];
- while (c.charAt(0) === ' ') {
- c = c.substring(1);
- }
- if (c.indexOf(name) === 0) {
- $.ajax({
- type: "POST",
- url: 'http://localhost:59927//api//Values//GetLocation',
- data: {
- DivisionName: value
- },
- success: function (data, status, xhr) {
- for (var s = 0; s < marker1.length; s++) {
- map.removeLayer(marker1[s]);
- }
- for (var i = 0; i < data.length; i++) {
- check = geolib.isPointInCircle(
- { latitude: data[i].Latitude, longitude: data[i].Longitude },
- { latitude: data1[i].Latitude, longitude: data1[i].Longitude },
- 5000
- );
- marker1[i] = L.marker([data[i].Latitude, data[i].Longitude]);
- var value = i + 1;
- if (check == true) {
- var customPopup1 = 'Station: ' + data[i].PollingStationName;
- var customOptions1 =
- {
- 'maxWidth': '500',
- 'className': 'custom'
- };
- circle[i].bindPopup(customPopup1, customOptions1);
- }
- else {
- marker1[i] = L.marker([data[i].Latitude, data[i].Longitude]).addTo(map);
- var customPopup = 'Latitude: ' + data[i].Latitude + '</br>Longitude: ' + data[i].Longitude
- + '</br>Station: ' + data[i].PollingStationName + ' </br>Box: ' + data[i].BoxName + '</br>Timestamp: ' + data[i].LocationSend
- + `<br/><a href='/Home/History?DeviceID=${value}'>Click here for Location History</a><br/>`;
- marker1[i].bindPopup(customPopup);
- }
- }
- setTimeout(function () { getCookie("Token", variable); }, 30000);
- },
- error: function (xhr) {
- alert(xhr.responseText);
- }
- });
- return c.substring(Token.length, c.length);
- }
- }
- if (window.location.href === 'http://localhost:59927/Home/Login') {
- return;
- }
- else {
- alert("Session Has Expired");
- location.href = "http://localhost:59927/Home/Login";
- }
- }
Add Comment
Please, Sign In to add comment