PageSourceSearch

https://www.cofman.de/Modules/Holiday.Rental/scripts/SearchHistory.js?v1

js cofman.de collected 2026-10-08 20:45:09 UTC 2,400 bytes, 85 lines download raw bytes

1
2(function ($, ko, w) {
3  var searchViewModel = null;
4  var maxListLength = 3;
5  var localStorageName = 'searchHistory'
6
7  function SearchHistory(name, link) {
8    if (typeof (Storage) !== "undefined") {
9      // LocalStorage enabled.
10
11      //Remove parameters and domain
12      link = link.split('?')[0];
13      if (link.substr(0, 7) == "http://" || link.substr(0, 8) == "https://") {
14        link = link.substr(link.indexOf('/', 9))
15      }
16
17      var newSearch = { 'id': name, 'name': name, 'link': link };
18
19      var jsonResult = parsesJson(localStorage.getItem(localStorageName))
20
21      if (!jsonResult.isJson) {
22        jsonResult.json = {
23          'time': Date.now(),
24          'results': [newSearch]
25        }
26      }
27      else {
28        var now = new Date();
29        if (new Date(jsonResult.json.time) <= now.setDate(now.getDate() - 14)) {
30          //reset list
31          jsonResult.json = {
32            'time': Date.now(),
33            'results': [newSearch]
34          }
35        }
36        else {
37          //Update time
38          jsonResult.json.time = Date.now();
39
40          //Remove result if already in list.
41          for (var index = 0; index < jsonResult.json.results.length; ++index) {
42            var search = jsonResult.json.results[index];
43            if (search.id == newSearch.id) {
44              jsonResult.json.results.splice(index, 1)
45              index--;
46              break;
47            }
48          }
49
50          //Add current result to start of list.
51          jsonResult.json.results.unshift(newSearch)
52          if (jsonResult.json.results.length > maxListLength) {
53            jsonResult.json.results.length = maxListLength;
54          }
55        }
56      }
57      //Add to local storage
58      localStorage.setItem(localStorageName, JSON.stringify(jsonResult.json))
59    }
60  }
61
62  $('body')
63    .on('UpdateSearchHistory', function (e, name, link) {
64      SearchHistory(name, link);
65    });
66
67  function parsesJson(item) {
68    item = typeof item !== "string"
69      ? JSON.stringify(item)
70      : item;
71
72    try {
73      item = JSON.parse(item);
74    } catch (e) {
75      return { isJson: false, json: null };
76    }
77
78    if (typeof item === "object" && item !== null) {
79      return { isJson: true, json: item };
80    }
81
82    return { isJson: false, json: null };
83  }
84
85})(jQuery, ko, window);

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.