PageSourceSearch

https://whalecenter.org/libs/web/1.0/ajax.js

js whalecenter.org collected 2026-09-24 23:38:02 UTC 4,146 bytes, 138 lines download raw bytes

1var _____WB$wombat$assign$function_____=function(name){return (self._wb_wombat && self._wb_wombat.local_init && self._wb_wombat.local_init(name))||self[name];};if(!self.__WB_pmw){self.__WB_pmw=function(obj){this.__WB_source=obj;return this;}}{
2let window = _____WB$wombat$assign$function_____("window");
3let self = _____WB$wombat$assign$function_____("self");
4let document = _____WB$wombat$assign$function_____("document");
5let location = _____WB$wombat$assign$function_____("location");
6let top = _____WB$wombat$assign$function_____("top");
7let parent = _____WB$wombat$assign$function_____("parent");
8let frames = _____WB$wombat$assign$function_____("frames");
9let opens = _____WB$wombat$assign$function_____("opens");
10/**
11 * Copyright (c) 2013 Web.com Group, Inc. All Rights Reserved.
12 * 
13 * This is an unpublished work protected by Web.com Group, Inc. as a trade secret, and is not to be used or disclosed except as expressly
14 * provided in a written license agreement executed by you and Web.com Group, Inc.
15 * 
16 * @author Attila Mezei Horvati
17 */
18webcom.namespace("webcom.ajax");
19
20webcom.ajax.WebService = function(options) {
21  this.queue = {};
22  if (options && !options.url) {
23    throw "Invalid WebService. Please specify url!";
24  }
25
26  this.defaults = {
27    url : '',
28    contentType : "application/json",
29    dataType : "json",
30    actionType : "POST",
31    ttl : 250,
32    onSuccess : function() {
33    },
34    onError : function() {
35    }
36  };
37  this.options = $.extend({}, this.defaults, options);
38};
39
40webcom.extend(webcom.ajax.WebService, {
41  resetQueue : function() {
42    return {
43      content : '',
44      timeout : 0,
45      callbacks : []
46    };
47  },
48
49  /**
50   * 
51   * @param id
52   * @param content
53   * @param callback
54   * @returns
55   */
56  timedCall : function(id, content, callback) {
57    var t = this;
58    //console.log("Set timed call for page", id);
59    if (!this.queue[id]) {
60      this.queue[id] = t.resetQueue();
61    } else {
62      //console.log("clear timeout for", this.queue[id].timeout);
63      clearTimeout(this.queue[id].timeout);
64    }
65    var timeout = setTimeout(function() {
66      //console.log("time to execute", id, t.queue[id]);
67      t.executeCall(id, t.queue[id]);
68    }, t.options.ttl);
69    this.queue[id].timeout = timeout;
70    this.queue[id].content = content;
71    this.queue[id].callbacks.push((typeof callback === "function") ? callback : function() { /* do nothing */
72    });
73  },
74
75  /**
76   * 
77   */
78  executeCall : function(id, callObject) {
79    var t = this;
80    function executeCallbacks(result) {
81      //console.log('execute callbacks:', callObject);
82      var queue = callObject.callbacks;
83      var len = queue.length;
84      //console.log('Queue length', len);
85      for (var i = 0; i < len; i++) {
86        //console.log(queue[i].toString());
87        queue[i]({
88          success : result
89        });
90      }
91    }
92    function clearQueue() {
93      //console.log('clear queue for:', id, t.queue[id]);
94      t.queue[id] = t.resetQueue();
95      //console.log('cleaned queue for:', id, t.queue[id]);
96    }
97
98    // we just take the last element from the array and save it's content
99    // as that is the latest and greatest
100    var content = callObject.content;
101    if (content) {
102      if (typeof content === "function") {
103        var callParams = content(id);
104        if (callParams.isExecuteCancelled) {
105          console.log('no need to save:' + id);
106          executeCallbacks(true);
107          clearQueue();
108          return;
109        }
110        content = callParams.content;
111      }
112    }
113    console.log('save:' + id);
114
115    $.ajax({
116      url : t.options.url,
117      cache : false,
118      contentType : t.options.contentType,
119      dataType : t.options.dataType,
120      type : t.options.actionType,
121      data : content,
122      success : function(data) {
123        // global handler
124        t.options.onSuccess(data);
125        executeCallbacks(true);
126        clearQueue();
127      },
128      error : function(jqXHR, textStatus, errorThrown) {
129        // global handler
130        t.options.onError(jqXHR, textStatus, errorThrown);
131        executeCallbacks(false);
132        clearQueue();
133      }
134    });
135  }
136});
137
138}

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.