PageSourceSearch

https://children.org.tw/asset/c_21_058_main/js/addressBook.js?20260924

js children.org.tw collected 2026-09-24 06:55:13 UTC 3,756 bytes, 115 lines download raw bytes

1// Generated by CoffeeScript 1.8.0
2var addressBook,
3  __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
4
5addressBook = (function() {
6  function addressBook(options) {
7    var _ref, _ref1, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7;
8    if (options == null) {
9      options = {};
10    }
11    this.zipDropDownPromise = __bind(this.zipDropDownPromise, this);
12    this.url = (_ref = options.url) != null ? _ref : alert("沒有設定url");
13    this.selectCity = (_ref1 = options.selectCity) != null ? _ref1 : alert("沒有設定 selectCity");
14    this.selectZipCode = (_ref2 = options.selectZipCode) != null ? _ref2 : alert("沒有設定 selectZipCode");
15    this.zipCodeName = (_ref3 = options.zipCodeName) != null ? _ref3 : '';
16    this.idFieldName = (_ref4 = options.zipCodeIDField) != null ? _ref4 : 'id_field';
17    this.renderEle = (_ref5 = options.renderEle) != null ? _ref5 : alert("沒有設定 renderEle");
18    this.returnDataAttr = (_ref6 = options.returnDataAttr) != null ? _ref6 : 'city_zip_dropdown';
19    this.debug = (_ref7 = options.debug) != null ? _ref7 : false;
20    $("#" + this.selectCity).on("change", (function(_this) {
21      return function() {
22        _this.log('selectCity is changed');
23        return _this.zipDropDownRender();
24      };
25    })(this));
26  }
27
28  addressBook.prototype.getData = function() {
29    var returnObj;
30    returnObj = {
31      "select_city": $("#" + this.selectCity).val(),
32      "zip_code": $("#" + this.selectZipCode).val()
33    };
34    if (this.zipCodeName !== '') {
35      returnObj[this.idFieldName] = this.zipCodeName;
36    }
37    this.log(returnObj);
38    return returnObj;
39  };
40
41  addressBook.prototype.zipDropDownPromise = function() {
42    var promise;
43    promise = $.Deferred();
44    $.ajax({
45      type: "POST",
46      url: this.url,
47      data: this.getData(),
48      success: function(vData) {
49        return promise.resolve(vData);
50      },
51      error: function() {
52        var error;
53        error = '取得ZipCode失敗,請連絡管理員';
54        return promise.reject(error);
55      },
56      dataType: "json"
57    });
58    return promise;
59  };
60
61  addressBook.prototype.zipDropDownRender = function(selectZipCode) {
62
63    var zipPromise;
64    zipPromise = this.zipDropDownPromise();
65    selectZipCode = selectZipCode || 0;
66    
67    return zipPromise.done((function(_this) {
68      return function(data) {
69        _this.renderEle.html(data[_this.returnDataAttr]);
70
71        // console.log('d');
72        if($('#select_base_city_zip').length){
73          $('#select_base_city_zip').select2({
74              minimumResultsForSearch: -1
75          });
76        }
77        // 線上捐款 收據地址
78        if($('#select_address_area_receipt').length){
79          $('#select_address_area_receipt').select2({
80              minimumResultsForSearch: -1
81          });
82        }
83
84        // 線上捐款 第二步贈品地址
85        if($('#gift_zipcode').length){
86          $('#gift_zipcode').select2({
87              minimumResultsForSearch: -1
88          });
89        } 
90        $('.select-select2').not('.select2-container').select2({
91          minimumResultsForSearch: -1
92        }); 
93
94        if (selectZipCode !== 0) {
95          return $("#" + _this.selectZipCode).val(selectZipCode);
96        }
97      };
98    })(this)).fail((function(_this) {
99      return function(error) {
100        _this.log(error);
101        alert(error);
102        return false;
103      };
104    })(this));
105  };
106
107  addressBook.prototype.log = function(msg) {
108    if (this.debug) {
109      return typeof console !== "undefined" && console !== null ? console.log(msg) : void 0;
110    }
111  };
112
113  return addressBook;
114
115})();

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.