PageSourceSearch

https://www.shipfinder.com/Content/js/elane/elane.Pirate.js?v=22

js shipfinder.com collected 2026-10-03 23:58:15 UTC 14,639 bytes, 358 lines download raw bytes

1/// <reference path="../ShipxyIndex.js" />
2/// <reference path="elane.js" />
3/// <reference path="../jquery-1.8.2.min.js" />
4/// <reference path="../layer/layer.js" />
5//mark管理对象(点)
6elane['Pirate'] = {
7
8    defname: 1,
9    //初始化
10    init: function () {
11        var _ = this;
12        _.doMain = window.location.origin + "";
13        _.getList();
14        //加载航标点击事件
15        map.on('zoomend', function (e) { elane.Pirate.zoomShowMarkToolTip(); });
16
17    },
18    doMain: '',
19    //mark数据缓存
20    hash: [],
21    hashArea: [],
22    markLayer: {},
23    markOpt: null,
24    markRemove: function () {
25        if (this.markOpt != null) {
26            try {
27                map.Draw.end(this.markOpt)
28                //移除
29                this.removeInstanceLayer();
30            } catch (ex) {
31                //移除
32                this.removeInstanceLayer();
33                return;
34            }
35        }
36    },
37    removeInstanceLayer: function () {
38        this.markLayer && map.Draw.remove(this.markLayer);
39        this.markOpt = null;
40        this.markLayer = null;
41    },
42    //获取标记列表
43    getList: function () {
44        var _ = this;
45
46        doPost('/Pirate/GetPirateData', { type: $("#haidao .select_text img").attr('data-type'), stime: Fn.formatDate((new Date().getTime() - $("#haidao_timelist").val() * 24 * 60 * 60 * 1000) / 1000), etime: Fn.formatDate(new Date().getTime() / 1000) }, function (d) {
47            if (d.status == 1) {
48                _.hash = d.data || [];
49                _.hashArea = d.area || [];
50            }
51            else {
52                _.hash = [];
53                _.hashArea = [];
54            }
55            
56            _.listHtml();
57            _.drawMark();
58
59            _.zoomShowMarkToolTip();
60
61        })
62
63    },
64    areaTransform: function (area) {
65        if (getCookie('culture') == 'en-US') {
66            switch (area) {
67                case '孟加拉湾海盗区':
68                    return 'Bay of Bengal Pirate Zone'
69                    break;
70                case '西非海盗区':
71                    return 'West African Pirate Zone'
72                    break;
73                case '马六甲海峡海盗区':
74                    return 'Strait of Singapore Pirate Zone'
75                    break;
76                case '加勒比海盗区':
77                    return 'Caribbean Pirate Zone'
78                    break;
79                case '索马里海盗区':
80                    return 'Somalia Pirate Zone'
81                    break;
82                case '其它':
83                    return 'Other'
84                    break;
85            }
86        } else {
87            return area;
88        }
89    },
90    //根据hash,拼接html
91    listHtml: function () {
92        var _ = this
93            , d = _.hash, a = _.hashArea, htm = '';
94        if (d != null && d.length > 0) {
95            for (var k = 0; k < a.length; k++) {
96                htm += '        <li>                                                                                                                                          '
97                htm += '	        <p class="mt_10"><b class="updown_btn btn mr_5" style="transform:' + ((k == 0 ? "rotate(90deg)" : "rotate(0deg)")) + '"></b><input class="_pirateCheck" type="checkbox" checked name="" id="" />' + _.areaTransform(a[k].area) + '<span>(' + a[k].num + ')</span></p>                                 '
98                htm += '	        <table style="display:'+(k==0?"":"none")+'">                                                                                                                                     '
99                for (var i = 0; i < d.length; i++) {
100                    if (a[k].area == d[i].Area) {
101                        htm += '		        <tr>'
102                        htm += '  			        <td width="100">' + d[i].EventTypeEn + '</td>'
103                        htm += '  			        <td width="100">' + d[i].ShipTypeEn + '</td>'
104                        htm += '  			        <td width="170"><span style="width:160px;" class="text_overflow" title="' + d[i].AddressEn + '">' + d[i].AddressEn + '</span></td>'
105                        htm += '  			        <td width="100">' + (d[i].EventTime).substr(0, 10) + '</td>'
106                        htm += '  			        <td>
106<a data-id="' + d[i].ID + '" onclick="elane.Pirate.openMarkPophtmlByMarkID(\'' + d[i].ID + '\')" href="javascript:void(0)" class="c_blue">' + $.common.lang.locate + '</a></td>                                                                                  '
107                        htm += '		          </tr>                                                                                                                                   '
108
109                        elane.Pirate.checkIDs.push(d[i].ID)
110                    } 
111                }
112                htm += '	        </table>                                                                                                                                    '
113                htm += '        </li>                                                                                                                                         '
114
115            }
116
117        }
118        else {
119            htm = '<li class="no_box ta_c"><p class="mt_30 mb_20"><img src="/Content/images/noflag.png"></p><p class="c_999">' + $.common.lang.nopirateincidentrecord+'</p></li>';
120        }
121        $("#haidao_ul").html(htm);
122        _.addEvent();
123    },
124    addEvent: function () {
125        var _ = this;
126        $(".haidao_box .updown_btn").click(function () {
127            if ($(this).parent().next().css("display") == "none") {
128                $(this).css("transform", "rotate(90deg)");
129                $(this).parent().next().show();
130            } else {
131                $(this).css("transform", "rotate(0deg)");
132                $(this).parent().next().hide();
133            }
134
135        })
136
137        $("._pirateCheck").each(function () {
138
139            $(this).click(function () {
140                elane.Pirate.checkIDs = [];
141                var all = $("#haidao_ul a");
142                
143                all.each(function () {
144                    $(this).parents("li").find('input')
145                    
146                    if ($(this).parent().parent().parent().parent().prev().find('input').attr('checked')=="checked")
147                    {
148                        elane.Pirate.checkIDs.push($(this).attr('data-id'))
149                    }
150                })
151                elane.Pirate.drawMark();
152            })
153        })
154    },
155    drawObjs: {},
156    checkIDs:[],
157    //绘制标签
158    drawMark: function () {
159
160        var d = this.hash;
161        var _ = this;
162        if (d == null) { return; }
163        _.doMain = window.location.origin + "";
164        _.drawMarkClear();
165        for (var i = 0; i < d.length; i++) {
166            if (d[i].IsShow == 1 && elane.Pirate.checkIDs.indexOf(d[i].ID)!=-1) {
167                var sig = L.icon({
168                    iconUrl: _.doMain + "/Content/images/" + _.getPirateImg(d[i].EventTypeCn) + ".png",
169
170                    iconSize: [20, 28], // size of the icon
171                    shadowSize: [0, 0], // size of the shadow
172                    iconAnchor: [10, 28], // point of the icon which will correspond to marker's location
173                    shadowAnchor: [0, 0],  // the same for the shadow
174                    popupAnchor: [0, -28]
175                });
176                var newP = CanvasShipUtils.GPSEncryptByMapToLatLng(L.latLng(d[i].Lat, d[i].Lng), map);
177
178                //var newP = L.latLng(d[i].Lat, d[i].Lon);
179                var m = L.marker([newP.lat, newP.lng], {
180                    icon: sig
181                });
182                var htm = '',htm2='';
183                htm += ''
184                //htm += '<p id="haidao_yi_t" style="text-align:right;margin: 5px 0;"><a href="javascript:void(0)" onclick="elane.Pirate.changeTab(1)" style="font-size:12px;">' + $.common.lang._original + '</a></p>'
185                htm2 += ''
186                htm2 += '<p id="haidao_yuan_t"  c style="text-align:right;margin: 10px 0;"><a href="javascript:void(0)" onclick="elane.Pirate.changeTab(2)"  style="font-size:12px;">' + $.common.lang._translation + '</a></p>'
187                //m.bindPopup("<div style='padding:0 10px 10px 10px; width:285px' id='haidao_yi_c' class='haidao_pop'>" + htm + d[i].DescribeCn + "</div><div id='haidao_yuan_c' style='padding:0 10px 10px 10px;display:none' class='haidao_pop'>" + htm2 + d[i].DescribeEn + "</div>")
188
189               
190                m['dat'] = d[i];
191                m['poptitle'] = '<p class="mark_pop_title"><span class="text_overflow" style="max-width:120px;" title="' + d[i].AddressEn + '">' + d[i].AddressEn + '</span><span>' + d[i].EventTypeEn + '</span><span>' + ((d[i].EventTime).substr(0, 11).replace('T', ' ')) + '</span></p>  ';
192                m['pophtml'] = "<div id='haidao_yi_c' class='haidao_pop pt_10'>" + htm + "<p class='pop_content'>" + d[i].DescribeEn + "</p></div><div id='haidao_yuan_c' style='display:none' class='haidao_pop'>" + htm2 +"<p class='pop_content'>"+ d[i].DescribeEn + "</p></div>";
193                m.on('click', function () { 
194                    var title = $(this)[0].poptitle
195                    layer.openNew('markPop', title, $(this)[0].pophtml, 360, 'auto', function () { }, { offset: [115, 600], titleClass: 'haidao_title' })
196
197                })
198
199                _.drawObjs[d[i].ID] = m;
200                m.bindTooltip("<div class='_pirate_poptip' ><p style='font-weight:bold;text-align:center;font-size:16px;'>" + d[i].EventTypeEn + "</p><p style='width:160px'>" + $.common.lang.time_ + ":" + ((d[i].EventTime).substr(0, 16).replace('T', ' ')) + " (UTC)</p><p>" + $.common.lang._location + ":" + latNe2(d[i].Lat) + "," + lngNe2(d[i].Lng) + "</p><p>" + $.common.lang.type + ":" + d[i].ShipTypeEn + "</p><p style='max-width: 220px;white-space: normal;'>" + $.common.lang.position + ":" + d[i].AddressEn + "</p></div>", {
201                    direction: 'right',
202                    permanent: false,
203                    className: "my_class_pirate"
204                })
205                m.addTo(map);
206                _.hashMark[i] = m;
207            }
208        } 
209    },
210    formatD: function (t) {
211        t = t.replace("-", "å¹´")
212        t = t.replace("-", "月")
213        t = t.replace(" ", "日 ")
214        t = t.replace(":", "时")
215        t = t + "分";
216        return t
217    },
218    formatY: function (t) {
219        t = t.replace("-", "å¹´")
220        t = t.replace("-", "月")
221        t = t.replace(" ", "日 ")
222       
223        return t
224    },
225    changeTab: function (tab) {
226        if (tab == 1) {
227            $("#haidao_yi_t").hide();
228            $("#haidao_yi_c").hide();
229            $("#haidao_yuan_t").show();
230            $("#haidao_yuan_c").show();
231        }
232        else {
233            $("#haidao_yi_t").show();
234            $("#haidao_yi_c").show();
235            $("#haidao_yuan_t").hide();
236            $("#haidao_yuan_c").hide();
237        }
238    },
239    hashMark: {},
240    //清楚绘制的标签
241    drawMarkClear: function () {
242        var d = this.hash;
243        var _ = this;
244        var objIDS = Object.keys(_.drawObjs)
245        for (var i = 0; i < objIDS.length; i++) {
246            var _layer = _.drawObjs[objIDS[i]];
247            if (_layer) {
248                //map.Draw.remove(_layer)
249                map.removeLayer(_layer)
250            }
251
252        }
253
254    },
255    //通过id过去某一个mark的属性
256    getMarkObjByMarkID: function (markid) {
257        var d = this.hash;
258        var obj = {}
259        for (var i = 0; i < d.length; i++) {
260
261            if (d[i].ID == markid) {
262                obj = d[i];
263            }
264        }
265        return obj;
266
267    },
268    //通过id过去某一个mark的属性
269    openMarkPophtmlByMarkID: function (markid) {
270        var ob = this.drawObjs[markid];
271        ob.openPopup();
272        var newP = CanvasShipUtils.GPSEncryptByMapToLatLng(L.latLng(ob._latlng.lat, ob._latlng.lng), map);
273        map.setView([newP.lat, newP.lng], map.getZoom())
274        this.locationClose();
275        this.locationPic(newP.lat, newP.lng);
276
277    },
278    locationCenterObj:{},
279    locationPic: function (lat, lon) {
280        var latlon = window.CanvasShipUtils.GPSEncryptByMapToLatLng(L.latLng([lat, lon]), map);
281        map.setView(latlon, map.getZoom())
282
283        var sig = L.icon({
284            iconUrl: "/Content/images/haidao_chose.png",
285            iconSize: [30, 30], // size of the icon
286            shadowSize: [0, 0], // size of the shadow
287            iconAnchor: [15, 30], // point of the icon which will correspond to marker's location
288            shadowAnchor: [0, 0],  // the same for the shadow
289            popupAnchor: [0, -30]
290        });
291
292        var m = L.marker(latlon, {
293            icon: sig
294        });
295
296        this.locationCenterObj = m;
297        m.addTo(map);
298
299        setTimeout(function () { elane.Pirate.locationClose()},2000)
300    },
301
302    locationClose: function () {
303
304        map.removeLayer(this.locationCenterObj);
305        
306    },
307    
308    //提交参数
309    parmearts: {
310
311    }
312
313    ,
314    //缩放级别>=6时显示标签label
315    zoomShowMarkToolTip: function () {
316        var _zoom = map.getZoom();
317        var vals = Object.keys(elane.mark.hashMark);
318        for (var i = 0; i < vals.length; i++) {
319            if (_zoom >= 6) {
320                elane.mark.hashMark[vals[i]].openTooltip()
321            }
322            else {
323                elane.mark.hashMark[vals[i]].closeTooltip()
324            }
325        }
326    }
327    ,
328    //获取海盗事件图片
329    getPirateImg: function (type) {
330        var _t = "qita";
331        switch (type)
332        {
333            case "可疑船只" :
334                _t = "keyichuanzhi";
335                break;
336            case "企图攻击":
337                _t = "qitugongji";
338                break;
339            case "登船":
340                _t = "dengchuan";
341                break;
342            case "交火":
343                _t = "jiaohuo";
344                break;
345            case "劫持":
346                _t = "jiechi";
347                break;
348            case "被盗":
349                _t = "beidao";
350                break;
351            default:
352                _t = "qita";
353                break;
354        }
355        return _t;
356    }
357}
358

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.