PageSourceSearch

https://www.villadirect.com/wp-content/plugins/vrs-search-results-…/assets/vrs-search-results-angularjs.js

js villadirect.com collected 2026-10-04 19:03:00 UTC 6,049 bytes, 144 lines download raw bytes

1/**
2 * Created by Stacy Jones on 09/13/2015.
3 */
4(function () {
5    var searchresultsapp = angular.module('searchresultsapp', ['ngResource', 'ngStorage', 'ngSanitize']);
6
7    //We already have a limitTo filter built-in to angular,
8    //let's make a startFrom filter
9    angular.module('searchresultsapp')
10        .filter('startFrom', function () {
11            return function (input, start) {
12                if (input.length > 0) {
13                    start = +start; //parse to int
14                    return input.slice(start);
15                } else {
16                    return input;
17                }
18
19            }
20        });
21
22    angular.module('searchresultsapp')
23        .filter('endAt', function () {
24            return function (input, fini) {
25                input = +input;
26                fini = +fini; //parse to int
27                if (input > fini) {
28                    return fini;
29                } else {
30                    return input;
31                }
32            }
33        });
34
35    angular.module('searchresultsapp')
36        .filter('bedtypes', function () {
37            return function (input) {
38                var ret = "";
39                var input = input;
40                var letterObj = [
41                    {"let": "K", "typ": "King Bed", "orderby": 1},
42                    {"let": "Q", "typ": "Queen Bed", "orderby": 2},
43                    {"let": "F", "typ": "Full Bed", "orderby": 4},
44                    {"let": "Z", "typ": "Full Bed (x2)", "orderby": 5},
45                    {"let": "T", "typ": "Twin Bed (x2)", "orderby": 10},
46                    {"let": "E", "typ": "Full Bed + Twin Bed", "orderby": 8},
47                    {"let": "S", "typ": "Sofa Bed", "orderby": 12},
48                    {"let": "P", "typ": "Pyramid Bed", "orderby": 13},
49                    {"let": "I", "typ": "Twin Bed", "orderby": 9},
50                    {"let": "Y", "typ": "Bunk Bed (x2)", "orderby": 15},
51                    {"let": "B", "typ": "Bunk Bed", "orderby": 14},
52                    {"let": "D", "typ": "Bunk Bed + Twin Bed", "orderby": 16},
53                    {"let": "A", "typ": "Day Bed", "orderby": 17},
54                    {"let": "U", "typ": "Futon", "orderby": 18},
55                    {"let": "O", "typ": "Trundle", "orderby": 19},
56                    {"let": "C", "typ": "Day Bed + Trundle", "orderby": 20},
57                    {"let": "G", "typ": "Queen Bed (x2)", "orderby": 3},
58                    {"let": "H", "typ": "Bunk Bed Full", "orderby": 21},
59                    {"let": "J", "typ": "Bunk Bed Full + Trundle", "orderby": 22},
60                    {"let": "L", "typ": "Bunk Bed + Trundle", "orderby": 23},
61                    {"let": "M", "typ": "Bunk Bed + Trundle + Twin Bed", "orderby": 24},
62                    {"let": "N", "typ": "Bunk Bed + Bunk Bed + Trundle", "orderby": 25},
63                    {"let": "R", "typ": "Full Bed + Trundle", "orderby": 7},
64                    {"let": "V", "typ": "Full Bed (x3)", "orderby": 6},
65                    {"let": "W", "typ": "Bunk Bed + Trundle + Twin Bed", "orderby": 26},
66                    {"let": "X", "typ": "twin-size (x2) + pull-out", "orderby": 11},
67                ];
68                var retArr = [];
69                var b = 0;
70                var testtrue = 1;
71                for (var i = 0, len = input.length; i < len; i++) {
72                    angular.forEach(letterObj, function (value, key) {
73                        if (value.let == input[i]) {
74                            for (var c = 0; c < retArr.length; c++) {
75                                if (retArr[c].type == value.typ) {
76                                    retArr[c].count = retArr[c].count + 1;
77                                    testtrue = 0;
78                                }
79                            }
80                            if (testtrue) {
81                                retArr[b] = {"type": value.typ, "count": 1, "order": value.orderby};
82                                b++;
83                            } else {
84                                testtrue = 1;
85                            }
86                        }
87                    });
88                }
89                function compare(a,b) {
90                    if (a.order < b.order)
91                        return -1;
92                    if (a.order > b.order)
93                        return 1;
94                    return 0;
95                }
96                retArr.sort(compare);
97
98                angular.forEach(retArr, function (raaval, raakey) {
99                    // if (ret != "") {
100                    //     ret = ret + " ";
101                    // }
102                    if (raaval.count > 1) {
103                        if (ret == "") {
104                            ret = raaval.count + " " + raaval.type + "s";
105                        } else {
106                            ret = ret + ", " + raaval.count + " " + raaval.type + "s";
107                        }
108                    } else {
109                        if (ret == "") {
110                            ret = raaval.count + " " + raaval.type;
111                        } else {
112                            ret = ret + ", " + raaval.count + " " + raaval.type;
113                        }
114                    }
115                });
116                return ret;
117            };
118        });
119
120    angular.module('searchresultsapp')
121        .filter('replaceSpaces', function () {
122            return function (input) {
123                return input.replace(/\s+/g, '-');
124            }
125        });
126
127    angular.module('searchresultsapp')
128        .filter("sanitize", ['$sce', function($sce) {
129            return function(htmlCode){
130                return $sce.trustAsHtml(htmlCode);
131            }
132        }]);
133
134    angular.module('searchresultsapp')
135        .filter('addVrsImagePath', function () {
136            return function (input) {
137                var fileName = input.replace(/.[^.]+$/,'');
138                var fileExt = input.replace(/^.*\./,'');
139                return fileName + '.vrs.w800-h533.' + fileExt;
140            }
141        });
142
143}());
144

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.