PageSourceSearch

https://covidkashmir.org/assets/js/stores.js

js covidkashmir.org collected 2026-10-05 11:30:54 UTC 8,215 bytes, 177 lines download raw bytes

1const API_URL = "https://covidkashmir.org/api/stores/"
2let myMap, storesData;
3let sheetPromise = fetch(API_URL).then((response) => {
4    return response.text()
5})
6
7
8let typeDefined = getUrlParameter("type")
9
10if(typeDefined!==undefined && typeDefined !=="" && typeDefined!=="undefined"){
11    if(typeDefined.toLowerCase()==="medical"){
12        switchType(1)
13    }
14    else if(typeDefined.toLowerCase()==="grocery"){
15        switchType(0)
16    }
17}
18
19$(document).ready(()=>{
20    sheetPromise.then(response=>{
21        storesData = ArraysToDict(CSVToArray(response))
22        makeMap();
23        createTable();
24    })
25})
26
27let medicalIcon = L.AwesomeMarkers.icon({
28    icon: "clinic-medical",
29    markerColor: 'red',
30    extraClasses: 'fas',
31    prefix: 'fa',
32})
33let storeIcon = L.AwesomeMarkers.icon({
34    icon: "store",
35    markerColor: 'blue',
36    extraClasses: 'fas',
37    prefix: 'fa',
38})
39function makeMap(){
40    myMap = L.map('mapid').setView([34.0837, 74.7973], 11);
41
42    L.tileLayer('https://api.maptiler.com/maps/basic/{z}/{x}/{y}.png?key=pveDabKqKvojR5EZXAR7', {
43        attribution: '<a href="https://www.maptiler.com/copyright/" target="_blank">&copy; MapTiler</a> <a href="https://www.openstreetmap.org/copyright" target="_blank">&copy; OpenStreetMap contributors</a>',
44        maxZoom: 20,
45        minZoom: 11,
46        id: 'mapbox/streets-v11',
47        tileSize: 512,
48        zoomOffset: -1,
49        accessToken: 'pk.eyJ1IjoiaGFpZGVyYWxpcHVuamFiaSIsImEiOiJjazhrND
49R0YzEwZ3h5M2dwOTNsaXh4eHZtIn0.pPotYvke-qLKD6RJtQtghA'
50    }).addTo(myMap);
51    myMap.setMaxBounds(myMap.getBounds());
52    myMap.setZoom(12)
53    console.log(storesData)
54    for(let store of storesData){
55        let markerIcon;
56        if(store["Type"]==="Grocery"){
57            markerIcon = storeIcon
58        }
59        else if(store["Type"]==="Medical"){
60            markerIcon = medicalIcon
61        }
62        
63        if(store["Coords"]!==""){
64            let marker = L.marker(store["Coords"].split(","), {icon:markerIcon}).addTo(myMap);
65            marker.bindPopup(getHTML(store))
66        }
67    }
68}
69
70function getHTML(store){
71    if(store["Type"]==="Grocery"){
72        return `
73        <h1 class="title is-6">${store["Name"]}</h1>
74        <h2 class="subtitle is-6">${store["Area"]}</h2>
75        ${
76            store["Contact No."].split(",").map(item=>`<a style="margin-left: 5px; margin-bottom:5px;" class="button is-success" href="tel:+91${item}"><span style="margin-right: 5px"><i class="icon fas fa-phone-volume"></i></span><span>${item}</span></a>`)
77        }
78        <hr>
79        <h2 class="subtitle is-6"><b>Designated Official: </b>${store["Designated Official"]}</h2>
80        ${
81            store["DO - Contact No"].split(",").map(item=>`<a style="margin-left: 5px; margin-bottom:5px;" class="button is-info" href="tel:+91${item}"><span style="margin-right: 5px"><i class="icon fas fa-phone-volume"></i></span><span>${item}</span></a>`)
82        }
83        <hr>
84        ${ (store["Google Maps Link"]!=="")?(`<a class="button is-info" href="${store["Google Maps Link"]}"><span style="margin-right: 15px"><i class="icon fas fa-map"></i></span><span>Google Maps</span></a>`):""}
85    `
86    }
87    else{
88        return `
89        <h1 class="title is-6">${store["Name"]}</h1>
90        <h2 class="subtitle is-6">${store["Area"]}</h2>
91        ${
92            store["Contact No."].split(",").map(item=>`<a style="margin-left: 5px; margin-bottom:5px;" class="button is-info" href="tel:${(item[0]==="0")?item:"91"+item}"><span style="margin-right: 5px"><i class="icon fas fa-phone-volume"></i></span><span>${item}</span></a>`)
93        }
94        <hr>
95        ${
96            (store["Whatsapp"]!=="")?(store["Whatsapp"].split(",").map(item=>`<a style="margin-left: 5px; margin-bottom:5px;" class="button is-success" href="https://wa.me/91${item}"><span style="margin-right: 5px"><i class="icon fab fa-whatsapp"></i></span><span>${item}</span></a>`)):""
97        }
98        <hr>
99        ${ (store["Google Maps Link"]!=="")?(`<a class="button is-info" href="${store["Google Maps Link"]}"><span style="margin-right: 15px"><i class="icon fas fa-map"></i></span><span>Google Maps</span></a>`):""}
100    `
101    }
102    
103}
104
105function createTable(){
106    let groceryStores = storesData.filter(item=>(item["Type"]==="Grocery"));
107    let medicalStores = storesData.filter(item=>(item["Type"]==="Medical"));
108    for(let store of groceryStores){
109            $("#table-grocery tbody").append(
110                `
111                <tr>
112                    <td>${groceryStores.indexOf(store)+1}</td>
113                    <td>${store["Name"]}</td>
114                    <td>${store["Area"]}</td>
115                    <td style="vertical-align: middle" class="has-text-centered">${
116                        store["Contact No."].split(",").map(item=>`<a class="button is-success" style="margin-left: 5px; margin-bottom:5px;" href="tel:+91${item}"><span style="margin-right: 5px"><i class="icon fas fa-phone-volume"></i></span><span>${item}</span></a>`)
117                    }</td>
118                    <td>${store["Designated Official"]}</td>
119                    
120                    <td class="has-text-centered" style="vertical-align: middle">${
121                        store["DO - Contact No"].split(",").map(item=>`<a class="button is-info" style="margin-left: 5px; margin-bottom:5px;" href="tel:+91${item}"><span style="margin-right: 5px"><i class="icon fas fa-phone-volume"></i></span><span>${item}</span></a>`)
122                    }</td>
123                    <td class="has-text-centered" style="vertical-align: middle">${ (store["Google Maps Link"]!=="")?(`<a class="button is-info" href="${store["Google Maps Link"]}"><span style="margin-right: 5px"><i class="icon fas fa-map"></i></span></a>`):""}</td>
124                    <td class="has-text-centered" style="vertical-align: middle">${ (store["Source"]!=="")?(`<a class="button is-info" href="${store["Source"]}"><span style="margin-right: 5px">Source</span></a>`):""}</td>
125                    
126                    </tr>
127                    
128                `
129    
130            )     
131    }
132    for(let store of medicalStores){
133        $("#table-medical tbody").append(
134            `
135            <tr>
136            <td>${medicalStores.indexOf(store)+1}</td>
137            <td>${store["Name"]}</td>
138            <td>${store["Area"]}</td>
139            <td style="vertical-align: middle" class="has-text-centered">${
140                store["Contact No."].split(",").map(item=>`<a class="button is-info" style="margin-left: 5px; margin-bottom:5px;" href="tel:${(item[0]==="0")?item:"91"+item}"><span style="margin-right: 5px"><i class="icon fas fa-phone-volume"></i></span><span>${item}</span></a>`)
141            }
142            ${
143                (store["Whatsapp"]!=="")?(store["Whatsapp"].split(",").map(item=>`<a style="margin-left: 5px; margin-bottom:5px;" class="button is-success" href="https://wa.me/91${item}"><span style="margin-right: 5px"><i class="icon fab fa-whatsapp"></i></span><span>${item}</span></a>`)):""
144            }
145            
146            </td>
147            <td class="has-text-centered" style="vertical-align: middle">${ (store["Google Maps Link"]!=="")?(`<a class="button is-info" href="${store["Google Maps Link"]}"><span style="margin-right: 5px"><i class="icon fas fa-map"></i></span></a>`):""}</td>
148            <td class="has-text-centered" style="vertical-align: middle">${ (store["Source"]!=="")?(`<a class="button is-info" href="${store["Source"]}"><span style="margin-right: 5px">Source</span></a>`):""}</td>
149               
150            </tr>
151            `
152
153        )     
154}
155}
156
157function switchType(type){
158    let tabs = $("#store-tabs li")
159    switch (type) {
160        case 0:
161            $(tabs[0]).addClass("is-active")
162            $(tabs[1]).removeClass("is-active")
163            $("#table-grocery").removeClass("is-hidden")
164            $("#table-medical").addClass("is-hidden")
165            break;
166        case 1:
167                $(tabs[1]).addClass("is-active")
168                $(tabs[0]).removeClass("is-active")
169                $("#table-grocery").addClass("is-hidden")
170                $("#table-medical").removeClass("is-hidden")
171               
172
173                break
174        default:
175            break;
176    }
177}

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.