PageSourceSearch

https://homedevices.app/wp-content/plugins/smartapfel-functions/js…om-firebase-show-category.js?ver=1676446704

js homedevices.app collected 2026-10-02 15:51:23 UTC 5,473 bytes, 113 lines download raw bytes

1(function ($) {
2    'use strict';
3    $(document).ready(function () {
4        const showFirestoreDatabase = () => {
5            const db = firebase.firestore();
6            const firestoreEl = jQuery('#custom_firebase_show_category');
7            const queryString = window.location.search;
8            const urlParams = new URLSearchParams(queryString);
9
10            // You can get the collectionName and documentName from the shortcode attribute
11            const collectionName = 'devices';
12            let category = shortcode_attributes.category; //'00000043-0000-1000-8000-0026BB765291';
13            let categoryId = urlParams.get('id');
14            if (categoryId != null) {
15                category = categoryId
16            }
17            if (collectionName && category) {
18                let docRef = db.collection(collectionName).where('published', '==', true);
19                if (category != 'all' && category != "C00BEA5B-F98F-4855-A5F1-64CCEA24DA74") {
20                    
21                    if (category == '00000040-0000-1000-8000-0026BB765291' || category == '000000B7-0000-1000-8000-0026BB765291') {
22                        // Fans
23                        docRef = docRef.where('serviceTypes', 'array-contains-any', ['00000040-0000-1000-8000-0026BB765291', '000000B7-0000-1000-8000-0026BB765291']);
24                    } else if (category == '00000088-0000-1000-8000-0026BB765291' || category == '00000089-0000-1000-8000-0026BB765291') {
25                        // Switches
26                        docRef = docRef.where('serviceTypes', 'array-contains-any', ['00000088-0000-1000-8000-0026BB765291', '00000089-0000-1000-8000-0026BB765291']);
27                    } else {
28                        if (category == 'CA9A0289-AE1B-4F5C-8B0B-F959EF88A695') {
29                            category = 'customHMServiceTypeHomeHub';
30                        } else if (category == 'C3EF3638-5F46-45FE-8CE7-346EC3EB0CE6') {
31                            category = 'customHMServiceTypeSpeaker';
32                        }
33                        docRef = docRef.where('serviceTypes', 'array-contains', category);
34                    }
35                }
36                docRef = docRef.orderBy('name');
37
38                docRef.get().then((snapshot) => {
39                    snapshot.forEach((doc) => {
40                        // console.log('Document data:', doc.data());
41                        let data = doc.data()
42                        if (data) {
43                            if(!data.newModel) { //(data.newModel === null || data.newModel == "") {
44                                const documentID = data['documentId'];
45                                const name = data['name'];
46                                if(documentID && name) {
47                                    let html = '<li role="item" class="tile-item">';
48                                        html +=     '<a href="https://homedevices.app/deeplink/?type=device&id=' + encodeURIComponent(documentID).replaceAll('(','%28').replaceAll(')','%29') + '">';
49                                        html +=         '<div class="tile_media" aria-hidden="true" style="background-image: url(https://firebasestorage.googleapis.com/v0/b/homekitaccessories.appspot.com/o/' + encodeURIComponent(data['imageFileName']).replaceAll('(','%28').replaceAll(')','%29') + '?alt=media);">';
50                                        html +=         '</div>';
51                                        html +=         '<div class="tile_description">' + name + '</div>';
52                                        html +=     '</a>';
53                                        html += '</li>';
54
55                                    firestoreEl.append(html)
56                                }
57                            }
58                        }
59
60                        
61                    }).catch(error => {
62                        console.error('Error while going through documents!', error);
63                    });
64
65                    doneWithCategory(firestoreEl, category)
66
67                }).catch(error => {
68                    doneWithCategory(firestoreEl, category)
69                    console.error('Error while getting documents!', error);
70                });
71
72
73            } else {
74                console.warn('Please check category in the [firestore] shortcode!');
75            }
76        }
77
78        const waitForFirebase = setInterval(() => {
79            if (typeof firebase !== 'undefined' && firebase.apps.length) {
80                showFirestoreDatabase()
81                clearInterval(waitForFirebase)
82            }
83        }, 1000)
84    })
85})(jQuery)
86
87function doneWithCategory(firestoreEl, category) {
88  // Declare variables
89
90    document.getElementById('progressview').style.display = 'none';
91    document.getElementById('searchInput').style.display = 'block';
92    
93}
94
95function searchFunction() {
96  // Declare variables
97  var input, filter, ul, li, a, i, txtValue;
98  input = document.getElementById('searchInput');
99  filter = input.value.toUpperCase();
100  ul = document.getElementById("custom_firebase_show_category");
101  li = ul.getElementsByTagName('li');
102
103  // Loop through all list items, and hide those who don't match the search query
104  for (i = 0; i < li.length; i++) {
105    a = li[i].getElementsByTagName("a")[0];
106    txtValue = a.textContent || a.innerText;
107    if (txtValue.toUpperCase().indexOf(filter) > -1) {
108      li[i].style.display = "";
109    } else {
110      li[i].style.display = "none";
111    }
112  }
113}

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.