PageSourceSearch

https://eng.taiwan.net.tw/common/js/function.js

js taiwan.net.tw collected 2026-09-24 08:42:05 UTC 43,134 bytes, 1,058 lines download raw bytes

1function getUrlParameter(e) {
2    e = e.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
3    var t = new RegExp("[\\?&]" + e + "=([^&#]*)").exec(location.search);
4    return null === t ? "" : decodeURIComponent(t[1].replace(/\+/g, " "))
5}
6var $aroundview, $suggestview, acnt = 1, urlParams = 1;
7var descClick = false;
8(window.onpopstate = function () {
9    var match,
10        pl = /\+/g,  // Regex for replacing addition symbol with a space
11        search = /([^&=]+)=?([^&]*)/g,
12        decode = function (s) { return decodeURIComponent(s.toLowerCase().replace(pl, " ")); },
13        query = window.location.search.substring(1);
14
15    urlParams = {};
16    while (match = search.exec(query.toLowerCase()))
17        urlParams[decode(match[1])] = decode(match[2]);
18})();
19
20var isCookie = $.cookie('ckDes')=='true'?'true':'false';
21var intNum = 0;
22var num1 = 0;
23var num2 = 0;
24var Lan;
25var Lng;
26var bResult=0;
27var  expireDate= new Date();
28var time = expireDate.getTime();
29var expireTime = time + 86400*1000*7;
30expireDate.setTime(expireTime);
31$(document).ready(function () {
32
33$("img").attr("oncontextmenu", "alert('"+copyrightText+"');return false;");
34
35
36
37	if ($("#lang").html()=='1' || $("#lang").html()=='2'){
38		document.cookie = "UserDashBoard=true;expires="+expireDate.toUTCString()+";path=/;SameSite=Lax;Secure=true";
39		//var $lightboxLbsBtn = $('.lightboxLbs-btn');
40		if ($.cookie('UserDashBoard') == 'true') {
41			if ($.cookie('isLoc') == 'true')
42      {
43				$('#PersonalDashBoard').show();
44        
45      }
46			else
47      {
48				//$.cookie('UserDashBoard', false, { expires: 7, path: '/',secure:true });
49        //document.cookie = "UserDashBoard=false;expires="+expireDate.toUTCString()+";path=/;SameSite=Lax;Secure=true";
50      }
51      
52		}
53		else if ($.cookie('UserDashBoard') == 'false'){
54       //$('.cookie-description').hide();
55       $('#PersonalDashBoard').hide();
56		}
57    else{
58			//$('.cookie-description').show();
59			//$.cookie('UserDashBoard', true, { expires: 365, path: '/', secure:true });
60      document.cookie = "UserDashBoard=true;expires="+expireDate.toUTCString()+";path=/;SameSite=Lax;Secure=true";
61      $('#PersonalDashBoard').hide();
62    }
63
64
65
66
67    $('.lightboxLbs-content').scroll(function () {
68        if ($(window).width() <= 1024) {
69            
70            scrollPos = $('#lightboxLbs').position().top;
71            
72            //移動
73            if (scrollPos >= 0 && num1 == 0) {
74                GetArountData("AroundSpot", Lat, Lng);
75                num1++;
76            };
77            if ($('#SpotTop').offset().top - 100 < scrollPos && num2 == 0) {
78                GetArountData("AroundHotel", Lat, Lng);
79                GetArountData("AroundActivity", Lat, Lng);
80                GetArountData("AroundTravelInfo", Lat, Lng);
81                num2++;
82            }
83        }
84    });
85
86    if (isCookie=='true'){
87      $('.cookie-description').hide();
88    }
89    else{
90      $('.cookie-description').show();
91    }     
92	}
93
94});
95
96
97
98
99
100
101
102$(function () {
103    var num1 = 0;
104    var num2 = 0;
105    
106    $('.lightboxLbs-btn').magnificPopup({
107        type: 'inline',
108
109        fixedContentPos: false,
110        fixedBgPos: true,
111
112        overflowY: 'auto',
113
114        closeBtnInside: true,
115        preloader: false,
116
117        midClick: true,
118        removalDelay: 300,
119        mainClass: 'my-mfp-zoom-in',
120        callbacks: {
121            open: function () {
122                $('body').addClass('is-hidden');
123                var $window = $(window);
124                $('html').css('margin-right', '');
125                $window.trigger('resize');
126                if ($window.outerWidth() > 1024) {
127
128                    $('.lightboxLbs-content').mCustomScrollbar({
129                        theme: 'dark-3',
130                        scrollInertia: 400,
131                        mouseWheel: {
132                            preventDefault: true
133                        },
134                        //下拉後,分批載入資料
135                        callbacks: {
136                            onScroll: function () {
137                                //scrollPos = $('#lightboxLbs').find(".mCSB_dragger").position().top;
138                                scrollPos = $('.lightboxLbs-title').offset().top;
139                                
140                                //移動 act=-76.703125, 387
141                                if (scrollPos > 0 && num1 == 0) {
142                                    
143                                    GetArountData("AroundSpot", Lat, Lng);
144                                    num1++;
145                                };
146                                
147                                if ($('#ActivityTop').offset().top  < scrollPos && num2 == 0) {
148                                    GetArountData("AroundHotel", Lat, Lng);
149                                    GetArountData("AroundActivity", Lat, Lng);
150                                    GetArountData("AroundTravelInfo", Lat, Lng);
151                                    num2++;
152                                }
153                                
154                             
155                                
156                            }
157                        },
158                        documentTouchScroll: false
159                    });
160                }
161                else {
162                    //20230220 lbs loading
163                    
164                    $('.lightboxLbs-wrapper').css({
165                        "background-image":"url(../../images/loader.gif)",
166                        "background-position":"center",
167                        "background-repeat":"no-repeat",
168                    });
169                   
170                    $('.lightboxLbs-content').delay(3000).animate({'background-color': '#fff'} ,300);
171                    $('.lbs__article').css("opacity","0");
172                    $('.lbs__article').delay(3000).animate({'opacity': '1'} ,300);
173                    
174
175					/* //beg karry
176
177						$('.lightboxLbs-content').mCustomScrollbar({
178                        theme: 'dark-3',
179                        scrollInertia: 400,
180                        mouseWheel: {
181                            preventDefault: true
182                        },
183                        //下拉後,分批載入資料
184                        callbacks: {
185                            onScroll: function () {
186                                scrollPos = $('#lightboxLbs').find(".mCSB_dragger").position().top;
187                                //移動
188                                if (scrollPos > 0 && num1==0) {
189                                    //GetArountData("AroundTraffic", Lat, Lng);
190                                    GetArountData("AroundSpot", Lat, Lng);
191                                    //GetArountData("AroundHotel", Lat, Lng);
192                                    //GetArountData("AroundActivity", Lat, Lng);
193                                    //GetArountData("AroundTravelInfo", Lat, Lng);
194                                    //GetArountData("AQI", Lat, Lng);
195                                    //GetArountData("Weather", Lat, Lng);
196                                    num1++;
197                                };
198                                if ($('#SpotTop').offset().top - 100 < scrollPos && num2==0) {
199                                    GetArountData("AroundHotel", Lat, Lng);
200                                    GetArountData("AroundActivity", Lat, Lng);
201                                    GetArountData("AroundTravelInfo", Lat, Lng);
202                                    num2++;
203                                }
204                            }
205                        },	
206                        documentTouchScroll: false
207                    });
208
209
210					//end karry */
211                }
212            },
213            close: function () {
214                $('body').removeClass('is-hidden');
215
216                if ($(window).outerWidth() > 1024) {
217                    $('.lightboxLbs-content').mCustomScrollbar('destroy');
218                }
219            }
220        }
221    });
222    //$lightboxLbsBtn.magnificPopup('open');
223
224});
225
226function getToday(){
227	today=new Date().toLocaleString();
228	//today = curYear + "/" + curMonth + "/" + dayOfMonth + " " + curHour + ":" + curMinute + ":" + curSeconds
229	$("#xy").html('座標:' + Lat+', '+Lng);
230}
231
232//取得是否存取位置資料
233function GetArountSpot() {
234
235//    navigator.geolocation.getCurrentPosition(function (e) {
236    id=navigator.geolocation.watchPosition(function (e) {
237
238	
239        Lng = e.coords.longitude;
240        Lat = e.coords.latitude;
241        if (intNum == 0)
242        {
243            //$.cookie('isLoc', true, { expires: 365, path: '/',secure:true });
244            document.cookie = "isLoc=true;expires="+expireDate.toUTCString()+";path=/;SameSite=Lax;Secure=true";
245            $('#PersonalDashBoard').show();
246            $(".cookie-description").hide();
247            $('.lightboxLbs-btn').magnificPopup('open');
248            GetArountData("Weather", Lat, Lng);
249            GetArountData("AQI", Lat, Lng);
250            GetArountData("AroundTraffic", Lat, Lng);
251            
252            //Get2023LaternFest(Lat, Lng);
253            
254            intNum++;
255            navigator.geolocation.clearWatch(id);
256            
257        }
258        else {
259            
260			//navigator.geolocation.clearWatch(id);
261        }
262        
263        
264
265    },
266        function () {
267            var lang = $("#lang").html();
268            if (lang=='2')
269              alert('Unable to get your coordinates!!');
270            else
271              alert('無法取得您所在座標!!');
272            //$.cookie('UserDashBoard', false, { expires: 7, path: '/', secure:true });
273            //document.cookie = "UserDashBoard=false;expires="+expireDate.toUTCString()+";path=/;SameSite=Lax;Secure=true";
274            $('#PersonalDashBoard').hide();
275            $('.lightboxLbs-btn').magnificPopup('close');
276        }
277
278    )
279	
280	
281}
282
283
284
285$(function () {
286    $(".cookie-description").on("click", function () {
287        //$('.lightboxLbs-btn').magnificPopup('open');
288        //$.cookie('ckDes', true, { expires: 365, path: '/', secure: true });
289        document.cookie = "ckDes=true;expires=expires="+expireDate.toUTCString()+";SameSite=Lax;Secure=true";
290        
291        GetArountSpot();
292    });
293    $("#PersonalDashBoard").on("click", function () {
294        //$('.lightboxLbs-btn').magnificPopup('open');
295        //isCookie = true
296        intNum = 0;
297        num1 = 0;
298        num2 = 0;
299        GetArountSpot();
300    });
301	GetRecommandData();
302});
303
304
305function getAddress(lat, lng) {
306    var geocoder = new google.maps.Geocoder();
307
308
309    lat = 25.0439892;
310    lng = 121.5212213;
311    // google.maps.LatLng 物件
312    var coord = new google.maps.LatLng(lat, lng);
313
314    // 傳入 latLng 資訊至 geocoder.geocode
315    geocoder.geocode({ 'latLng': coord }, function (results, status) {
316        if (status === google.maps.GeocoderStatus.OK) {
317            // 如果有資料就會回傳
318            if (results) {
319                console.log(results[0]);
320            }
321        }
322        // 經緯度資訊錯誤
323        else {
324            alert("Reverse Geocoding failed because: " + status);
325        }
326    });
327
328}
329
330var aroundSpotDisplay = false;
331//取得附近資料
332function GetArountData(serviceName, lat, lng) {
333
334    var lang = $("#lang").html();
335    var jsonData = { Lng: lng, Lat: lat };
336    var URL = "";
337    var website = "https://map.taiwan.net.tw/xzzy";
338	  //var website = "https://taiwan1.ec-media.com.tw/api";
339	   
340
341	   
342
343    switch (serviceName) {
344        case "AroundSpot":
345            URL = website + "/TaiwanSpot/?l=" + lang ;
346            break;
347        case "AroundActivity":
348            URL = website + "/TaiwanActivity/?l=" + lang +"&Activitydays=0";
349            break;
350        case "AroundHotel":
351            URL = website + "/TaiwanHotel/?l=" + lang;
352            break;
353        case "AroundTravelInfo":
354            URL = website + "/TaiwanTravel/?l=" + lang ;
355			break;
356        case "AroundTraffic":
357
358            URL = website + "/TaiwanTraffic/?l=" + lang;
359            break;
360        case "AQI":
361            URL = website + "/TaiwanAqi/?l=" + lang;
362            break;
363        case "Weather":
364            
365            URL = website + "/TaiwanWeather/?l=" + lang+"&dt=3";
366            break;
367
368        //default:
369        //    URL = "Dashboard.ashx?serviceName=" + serviceName;
370        //    break;
371    }
372    console.log('serviceName=' + serviceName);
373    $.ajax({
374        url: URL,
375        data: jsonData,
376        dataType: "json",
377        type: "GET",
378        success: function (data) {
379            var resp = $.parseJSON(JSON.stringify(data));
380            if (data.itemCounts > 0) {
381                GenAroundSpotHtml(data.items, serviceName);
382            }
383            else {
384                switch (serviceName) {
385                    case 'AroundSpot':
386                        $('#SpotTop').hide();
387                        break;
388                    case 'AroundHotel':
389                        $('#HotelTop').hide();
390                        break;
391                    case 'AroundActivity':
392                        $('#ActivityTop').hide();
393                        break;
394                    case 'AroundTravelInfo':
395                        $('#TravelTop').hide();
396                        break;
397                    case 'AroundTraffic':
398                        $('#TrafficTop').hide();
399                        break;
400                    case 'Weather':
401                        $('#WeatherTop').hide();
402                        
403                        break;
404                    case 'AQI':
405                        $('#divAQI').hide();
406                    default:
407                }
408
409            }
410
411        },
412        error: function (data, status, jqXHR) {
413            console.log("There was an error.");
414            switch (serviceName) {
415                    case 'AroundSpot':
416                        $('#SpotTop').hide();
417                        break;
418                    case 'AroundHotel':
419                        $('#HotelTop').hide();
420                        break;
421                    case 'AroundActivity':
422                        $('#ActivityTop').hide();
423                        break;
424                    case 'AroundTravelInfo':
425                        $('#TravelTop').hide();
426                        break;
427                    case 'AroundTraffic':
428                        $('#TrafficTop').hide();
429                        break;
430                    case 'Weather':
431                        $('#WeatherTop').hide();
432                        
433                        break;
434                    case 'AQI':
435                        $('#divAQI').hide();
436                    default:
437                }
438        }
439    }); // end $.ajax
440    //});
441}
442//取得附近住宿資料
443
444function err() {
445    //$.cookie('isLoc', false, { expires: 365, path: '/', secure: true });
446    document.cookie = "isLoc=false;expires="+expireDate.toUTCString()+";path=/;SameSite=Lax;Secure=true";
447}
448
449function formatFloat(num, pos) {
450    var size = Math.pow(10, pos);
451
452    return Math.round(num * size) / size;
453}
454
455function padding(num, length) {
456    return (Array(length).join("0") + num).slice(-length);
457}
458
459
460function GenAroundSpotHtml(e, a) {
461    var bBus = false;
462    var bRail = false;
463    var bPark = false;
464    var bTrip = false;
465    var bTHSR = false;
466    var bTRA = false;
467    var bBike = false;
468    var bInterCityBus = false;
469    var langStr = $("#lang").html()=='2'?'en':'zh-TW';
470	var lo
471	$("#LodingAQI").remove();
472    if (a == 'AQI') {
473        $("#ltAirPoint").html(e[0].Aqi);
474        $("#divAqiCss").addClass('lbs__aqi-block level-' + e[0].AqiStatus);
475        $("#ltAqiUpdate").html(e[0].PublishTime);
476        $("#LodingAQI").remove();
477        $("#divAQI").show();
478        $("#ltAirDesc").html(e[0].statusStr);
479
480    }
481    else if (a == 'Weather') {
482        
483        
484        $("#ltTemperature").html(e[0].T + " °C");
485        $("#ltRainChance").html(e[0].Pop + " %");
486        if (langStr=="en")
487          $("#lbsWeatherCaption").html("Today’s weather");
488        else
489          $("#lbsWeatherCaption").html("今天天氣");
490        //$("#lbsWeatherCaption").html(e[0].RegionName);
491        
492        setData(Lat, Lng, e[0].RegionName);
493        $("#imgWeather").attr('src', 'images/weather/black/' + e[0].wxIcon + '.png');
494        $("#ltLastWeatherUpdate").html(e[0].MdfDate);
495        $("#LodingWeather").remove();
496        $("#divWeather").show();
497    }
498    else {
499        var accessibilty = new Array(3);
500        kmStr = $("#kmStr").html();
501        meterStr = $("#meterStr").html();
502        dtStr = $("#dtStr").html();
503        facilityStr = $("#facilityStr").html();
504        toolStr = $("#toolStr").html();
505        parkStr = $("#parkStr").html();
506        wcStr = $("#wcStr").html();
507        SpotHTML = "";
508        HotelHTML = "";
509        ActivityHTML = "";
510        TravelInfoHTML = "";
511		    Askme = "";
512        $.each(e, function (i) {
513            x = i;
514            ac_tool = "";
515            imgStr = '';
516            secStr = '';
517            unName = '';
518            idStr = '';
519            idnoStr = '';
520            linkStr = '';
521            secStr1 = '';
522            ulCount = '';
523
524            if (a == 'AroundSpot') {//景點才需要
525
526                ulName = 'ulSpot';
527                idStr = 'id';
528                if ((parseFloat(e[i].Dist) * 1000) < 1000)
529                {
530                    dist = Math.floor(parseFloat(e[i].Dist) * 1000);
531                    kmStr = meterStr;
532                }
533                else
534                {
535                    dist = formatFloat(parseFloat(e[i].Dist), 2);
536                    kmStr = $("#kmStr").html();
537                }
538                $("#liSpotLoading").remove();
539                if (e[i].Ac_pub.length > 0)//設施
540                    ac_tool += '<i><img src="images/accessibility_elevator.svg" title="' + facilityStr + '"></i>\r\n';//wucDashboardFacility1
541                if (e[i].Ac_tool.length > 0)//輪椅
542                    ac_tool += '<i><img src="images/accessibility_normal.svg" title="' + toolStr + '"></i>\r\n';//wuc2019A5
543                if (e[i].Ac_park.length > 0)//停車位
544                    ac_tool += '<i><img src="images/accessibility_park.svg" title="' + parkStr + '"></i>\r\n';//wuc2019A4
545                if (e[i].Ac_wc.length > 0)//廁所
546                    ac_tool += '<i><img src="images/accessibility_wc.svg" title="' + wcStr + '"></i>\r\n';//wuc2019A3
547                SpotHTML +=
548                    '<li>\r\n' +
549                    '	<div class="lbs__viewsList-item">\r\n' +
550                    '	<figure class="lbs__viewsList-image">\r\n' +
551                    '   <a href="m1.aspx?sNo=' + e[i].MW_L2_CODE + '&id=' + e[i].Id + '&utm_source=LBS&utm_medium=referral">' +
552                    '	<img class="lazyload" src="images/loader.gif" data-src="' + e[i].Img + '&sizetype=5">\r\n' +
553                    '   </a>' +
554                    '	</figure>\r\n' +
555                    '	<div class="lbs__viewsList-content">\r\n' +
556                    '   <a href="m1.aspx?sNo=' + e[i].MW_L2_CODE + '&id=' + e[i].Id + '&utm_source=LBS&utm_medium=referral" class="lbs__viewsList-title">' + e[i].Name + '</a>\r\n' +
557                    '   <a href="https://maps.google.com/maps?f=d&saddr=&daddr=' + e[i].Lat + ',' + e[i].Lon + '&hl='+langStr+'&dirflg=r" target="_blank" title="'+newWin+'" class="color-gray">' + dtStr + ':' + dist + kmStr + '</a>\r\n' +
558                    '  <div class="lbs__viewsList-tagbox">\r\n' +
559                    ac_tool +
560                    '		</div>\r\n' +
561                    '	</div>\r\n' +
562                    '	</div>\r\n' +
563                    '</li>\r\n'
564                $('#' + ulName).html(SpotHTML);
565
566
567            }
568            else if (a == 'AroundHotel') {//住宿
569                ulName = 'ulHotel';
570                $("#liHotelLoading").remove();
571                if ((parseFloat(e[i].Dist) * 1000) < 1000)
572                {
573                    dist = Math.floor(parseFloat(e[i].Dist) * 1000);
574                    kmStr = meterStr;
575                }
576                else
577                {
578                    dist = formatFloat(parseFloat(e[i].Dist), 2);
579                    kmStr = $("#kmStr").html();
580                }
581                //星級
582                if (e[i].StarType == '0') {
583                    secStr1 = '';
584                }
585
586                else {
587                    secStr1 = '';
588                    secStr1 += '<div class="lbs__viewsList-starbox">\r\n';
589                    secStr1 += '<img src="images/star/star' + e[i].StarType + '.png" class="m
589CS_img_loaded">\r\n';
590                    secStr1 += '</div>\r\n';
591                }
592                //有無圖片
593                if (e[i].Img == null || e[i].Img.length == 0)
594                    imgStr = '<img class="lazyload" src="images/nopic.jpg">\r\n';
595                else
596                    imgStr = '<img class="lazyload" src="images/loader.gif" data-src="' + e[i].Img + '" onerror="this.src=\'images/nopic.jpg\'">\r\n';
597
598                //$('#wHotelTitle1').attr('title', e[i].Name +'(' + $('#newWin').html() + ')');
599                //$('#wHotelTitle2').attr('title', e[i].Name + '(' + $('#newWin').html() + ')');
600                $("a").find("[bid='wHotelTitle1']").attr('title', e[i].Name + '(' + $('#newWin').html() + ')');
601                $("a").find("[bid='wHotelTitle2']").attr('title', e[i].Name + '(' + $('#newWin').html() + ')');
602                $("em").attr("title");
603                HotelHTML +=
604                    '<li>\r\n' +
605                    '	<div class="lbs__viewsList-item">\r\n' +
606                    '	<figure class="lbs__viewsList-image">\r\n' +
607                    '		<a bid="wHotelTitle1" href="' + e[i].TaiwanstayReferenceURL + '" target="_blank"> ' +
608                    imgStr +
609                    '</a>' +
610                    '	</figure>\r\n' +
611                    '	<div class="lbs__viewsList-content">\r\n' +
612                    '		<a bid="wHotelTitle2" href="' + e[i].TaiwanstayReferenceURL + '" class="lbs__viewsList-title" target="_blank">' + e[i].Name + '</a>\r\n' +
613                    '		<a href="https://maps.google.com/maps?f=d&saddr=&daddr=' + e[i].Lat + ',' + e[i].Lon + '&hl='+langStr+'&dirflg=r" target="_blank" class="color-gray">' + dtStr + ':' + dist + kmStr + '</a>\r\n' +
614                    '		<div class="lbs__viewsList-tagbox">\r\n' +
615                    '		</div>\r\n' +
616                    secStr1 +
617                    '	</div>\r\n' +
618                    '	</div>\r\n' +
619                    '</li>\r\n'
620                $('#' + ulName).html(HotelHTML);
621            }
622            else if (a == 'AroundActivity') {//活動
623                $("#liActivityLoading").remove();
624                ulName = 'ulActivity';
625                if ((parseFloat(e[i].Dist) * 1000) < 1000)
626                {
627                    dist = Math.floor(parseFloat(e[i].Dist) * 1000);
628                    kmStr = meterStr;
629                }
630                else
631                {
632                    dist = formatFloat(parseFloat(e[i].Dist), 2);
633                    kmStr = $("#kmStr").html();
634                }
635	
636                ActivityHTML +=
637                    '<li>\r\n' +
638                    '	<div class="lbs__viewsList-item">\r\n' +
639                    '	<figure class="lbs__viewsList-image">\r\n' +
640                    '   <a href="m1.aspx?sNo=' + e[i].MW_L2_CODE + '&lid=' + padding(e[i].Id, 6) + '&utm_source=LBS&utm_medium=referral">' +
641                    '	<img class="lazyload" src="images/loader.gif" data-src="' + e[i].Img + '&sizetype=2">\r\n' +
642                    '</a>' +
643                    '	</figure>\r\n' +
644                    '	<div class="lbs__viewsList-content">\r\n' +
645                    '		<a href="m1.aspx?sNo=' + e[i].MW_L2_CODE + '&lid=' + padding(e[i].Id, 6) + '&utm_source=LBS&utm_medium=referral" class="lbs__viewsList-title">' + e[i].Name + '</a>\r\n' +
646                    '<p>' + e[i].locationName + '<br>' + e[i].activityRange + '</p>' +
647                    //'		<a href="https://maps.google.com/maps?f=d&saddr=&daddr=' + e[i].Lat + ',' + e[i].Lon + '&aaaa=1&hl=zh-TW&dirflg=r" target="_blank" class="color-gray">' + dtStr + ':' + formatFloat(parseFloat(e[i].Dist), 3) + kmStr + '</a>\r\n' +
648                    '		<a href="https://maps.google.com/maps?f=d&saddr=&daddr=' + e[i].Lat + ',' + e[i].Lng + '&hl='+langStr+'&dirflg=r" target="_blank" class="color-gray">' + dtStr + ':' + dist + kmStr + '</a>\r\n' +
649                    '		<div class="lbs__viewsList-tagbox">\r\n' +
650                    '		</div>\r\n' +
651                    secStr1 +
652                    '	</div>\r\n' +
653                    '	</div>\r\n' +
654                    '</li>\r\n'
655                $('#' + ulName).html(ActivityHTML);
656            }
657            else if (a == 'AroundTravelInfo') {//旅遊服務
658                if ((parseFloat(e[i].Dist) * 1000) < 1000)
659                {
660                    dist = Math.floor(parseFloat(e[i].Dist) * 1000);
661                    kmStr = meterStr;
662                }
663                else
664                {
665                    dist = formatFloat(parseFloat(e[i].Dist), 2);
666                    kmStr = $("#kmStr").html();
667                }
668            
669                $("#liTravelLoading").remove();
670                ulName = 'ulTravel';
671                if (e[i].Img.length == 0) {
672                    imgStr = '	<img class="lazyload" data-original="images/nopic.jpg">\r\n';
673                }
674                else {
675                    if (e[i].Img.match('https://') || e[i].Img.match('http://'))
676                        imgStr = '<a href="https://maps.google.com/maps?f=d&saddr=&daddr=' + e[i].Lat + ',' + e[i].Lon + '&hl='+langStr+'&dirflg=r">' + '	<img class="lazyload"  src="' + e[i].Img + '" alt="' + e[i].Name + '"></a>\r\n';
677                    else
678                        imgStr = '<a href="https://maps.google.com/maps?f=d&saddr=&daddr=' + e[i].Lat + ',' + e[i].Lon + '&hl='+langStr+'&dirflg=r">' + '<img class="lazyload" src="images/loader.gif" data-src="/att/travelCenter/' + e[i].Img + '" alt="' + e[i].Name + '"></a>\r\n';
679
680					if (e[i].Askme=='1'){
681						Askme='	<span class="lbs__target color-orange">'+$('#wucDashboard_askmeStr').html()+'</span>'
682					}
683					else{
684						Askme=''
685					}
686
687                    TravelInfoHTML +=
688                        '<li>\r\n' +
689                        '	<div class="lbs__viewsList-item">\r\n' +
690                        '	<figure class="lbs__viewsList-image">\r\n' +
691                        imgStr +
692                        '	</figure>\r\n' +
693                        '	<div class="lbs__viewsList-content">\r\n' +
694                        '		<a href="https://maps.google.com/maps?f=d&saddr=&daddr=' + e[i].Lat + ',' + e[i].Lon + '&hl='+langStr+'&dirflg=r" class="lbs__viewsList-title">' + e[i].Name + '</a>\r\n' +
695
696                        '		<a href="https://maps.google.com/maps?f=d&saddr=&daddr=' + e[i].Lat + ',' + e[i].Lon + '&hl='+langStr+'&dirflg=r" target="_blank" class="color-gray">' + dtStr + ':' + dist + kmStr + '</a>\r\n' +
697                        '		<div class="lbs__viewsList-tagbox">\r\n' +
698                        '		</div>\r\n' +
699                        '	</div>\r\n' + Askme
700						
701                        '	</div>\r\n' +
702                        '</li>\r\n'
703                    $('#' + ulName).html(TravelInfoHTML);
704                }
705            }
706            else if (a == 'AroundTraffic') {
707                ulCount = '1';
708
709                $("#liBikeLoading").remove();
710                if ((parseFloat(e[i].Dist) * 1000) < 1000)
711                {
712                    dist = Math.floor(parseFloat(e[i].Dist) * 1000);
713                    kmStr = meterStr;
714                }
715                else
716                {
717                    dist = formatFloat(parseFloat(e[i].Dist), 2);
718                    kmStr = $("#kmStr").html();
719                }
720                //$("#liTrafficLoading").remove();
721                if (e[i].TypeStr == 'Bike') {
722                    bBike = true;
723                    if ((parseFloat(e[i].Dist) * 1000) < 1000)
724                    {
725                        dist = Math.floor(parseFloat(e[i].Dist) * 1000);
726                        kmStr = meterStr;
727                    }
728                    else
729                    {
730                        dist = formatFloat(parseFloat(e[i].Dist), 2);
731                        kmStr = $("#kmStr").html();
732                    }                    
733                    $("#liBike").show();
734                    $("#BikeStationName").html(e[i].Name);
735                    $("#BikeDist").html('		<a href="https://maps.google.com/maps?f=d&saddr=&daddr=' + e[i].Lat + ',' + e[i].Lon + '&hl='+langStr+'&dirflg=r" target="_blank" class="color-gray">' + dtStr + ':' + dist + kmStr + '</a>\r\n');
736                }
737                else if (e[i].TypeStr == 'Bus') {
738                    if ((parseFloat(e[i].Dist) * 1000) < 1000)
739                    {
740                        dist = Math.floor(parseFloat(e[i].Dist) * 1000);
741                        kmStr = meterStr;
742                    }
743                    else
744                    {
745                        dist = formatFloat(parseFloat(e[i].Dist), 2);
746                        kmStr = $("#kmStr").html();
747                    }                    
748                    bBus = true;
749                    $("#liBus").show();
750                    $("#BusStationName").html(e[i].Name);
751                    $("#BusDist").html('		<a href="https://maps.google.com/maps?f=d&saddr=&daddr=' + e[i].Lat + ',' + e[i].Lon + '&hl='+langStr+'&dirflg=r" target="_blank" class="color-gray">' + dtStr + ':' + dist + kmStr + '</a>\r\n');
752                }
753                else if (e[i].TypeStr == 'Rail') {
754                    bRail = true;
755                    if ((parseFloat(e[i].Dist) * 1000) < 1000)
756                    {
757                        dist = Math.floor(parseFloat(e[i].Dist) * 1000);
758                        kmStr = meterStr;
759                    }
760                    else
761                    {
762                        dist = formatFloat(parseFloat(e[i].Dist), 2);
763                        kmStr = $("#kmStr").html();
764                    }                    
765                    $("#liRail").show();
766                    $("#RailStationName").html(e[i].Name);
767                    $("#RailDist").html('		<a href="https://maps.google.com/maps?f=d&saddr=&daddr=' + e[i].Lat + ',' + e[i].Lon + '&hl='+langStr+'&dirflg=r" target="_blank" class="color-gray">' + dtStr + ':' + dist + kmStr + '</a>\r\n');
768                }
769                else if (e[i].TypeStr == 'Park') {
770                    bPark = true;
771                    if ((parseFloat(e[i].Dist) * 1000) < 1000)
772                    {
773                        dist = Math.floor(parseFloat(e[i].Dist) * 1000);
774                        kmStr = meterStr;
775                    }
776                    else
777                    {
778                        dist = formatFloat(parseFloat(e[i].Dist), 2);
779                        kmStr = $("#kmStr").html();
780                    }                    
781                    $("#liPark").show();
782                    $("#ParkName").html(e[i].Name);
783                    $("#ParkDist").html('		<a href="https://maps.google.com/maps?f=d&saddr=&daddr=' + e[i].Lat + ',' + e[i].Lon + '&hl='+langStr+'&dirflg=r" target="_blank" class="color-gray">' + dtStr + ':' + dist + kmStr + '</a>\r\n');
784                }
785                else if (e[i].TypeStr == 'Trip') {
786                    bTrip = true;
787                    if ((parseFloat(e[i].Dist) * 1000) < 1000)
788                    {
789                        dist = Math.floor(parseFloat(e[i].Dist) * 1000);
790                        kmStr = meterStr;
791                    }
792                    else
793                    {
794                        dist = formatFloat(parseFloat(e[i].Dist), 2);
795                        kmStr = $("#kmStr").html();
796                    }                    
797                    
798                    $("#liTrip").show();
799                    $("#TripName").html(e[i].Name);
800                    $("#TripDist").html('		<a href="https://maps.google.com/maps?f=d&saddr=&daddr=' + e[i].Lat + ',' + e[i].Lon + '&hl='+langStr+'&dirflg=r" target="_blank" class="color-gray">' + dtStr + ':' + dist + kmStr + '</a>\r\n');
801                }
802                else if (e[i].TypeStr == 'THSR') {
803                    bTHSR = true;
804                    if ((parseFloat(e[i].Dist) * 1000) < 1000)
805                    {
806                        dist = Math.floor(parseFloat(e[i].Dist) * 1000);
807                        kmStr = meterStr;
808                    }
809                    else
810                    {
811                        dist = formatFloat(parseFloat(e[i].Dist), 2);
812                        kmStr = $("#kmStr").html();
813                    }                    
814                    
815                    $("#liTHSR").show();
816                    $("#THSRName").html(e[i].Name);
817                    $("#THSRDist").html('		<a href="https://maps.google.com/maps?f=d&saddr=&daddr=' + e[i].Lat + ',' + e[i].Lon + '&hl='+langStr+'&dirflg=r" target="_blank" class="color-gray">' + dtStr + ':' + dist + kmStr + '</a>\r\n');
818                }
819                else if (e[i].TypeStr == 'TRA') {
820                    bTRA = true;
821                    if ((parseFloat(e[i].Dist) * 1000) < 1000)
822                    {
823                        dist = Math.floor(parseFloat(e[i].Dist) * 1000);
824                        kmStr = meterStr;
825                    }
826                    else
827                    {
828                        dist = formatFloat(parseFloat(e[i].Dist), 2);
829                        kmStr = $("#kmStr").html();
830                    }                    
831                    
832                    $("#liTRA").show();
833                    $("#TRAName").html(e[i].Name);
834                    $("#TRADist").html('		<a href="https://maps.google.com/maps?f=d&saddr=&daddr=' + e[i].Lat + ',' + e[i].Lon + '&hl='+langStr+'&dirflg=r" target="_blank" class="color-gray">' + dtStr + ':' + dist + kmStr + '</a>\r\n');
835                }
836                else if (e[i].TypeStr == 'InterCityBus') {
837                    bInterCityBus = true;
838                    if ((parseFloat(e[i].Dist) * 1000) < 1000)
839                    {
840                        dist = Math.floor(parseFloat(e[i].Dist) * 1000);
841                        kmStr = meterStr;
842                    }
843                    else
844                    {
845                        dist = formatFloat(parseFloat(e[i].Dist), 2);
846                        kmStr = $("#kmStr").html();
847                    }                    
848                    
849                    $("#liInterCityBus").show();
850                    $("#InterCityBusName").html(e[i].Name);
851                    $("#InterCityBusDist").html('		<a href="https://maps.google.com/maps?f=d&saddr=&daddr=' + e[i].Lat + ',' + e[i].Lon + '&hl='+langStr+'&dirflg=r" target="_blank" class="color-gray">' + dtStr + ':' + dist + kmStr + '</a>\r\n');
852                }
853                linkStr = '		<a href="m1.aspx?sNo=' + e[i].MW_L2_CODE + '&' + idStr + '=' + idnoStr + '" class="lbs__viewsList-title">' + e[i].Name + '</a>\r\n';
854
855                //console.log("bBus=" + bBus + ", bRail=" + bRail + ", bPark=" + bPark + ", bTrip=" + bTrip + ", bTHSR=" + bTHSR + ", bTRA=" + bTRA + ", bInterCityBus=" + bInterCityBus + ", bBike=" + bBike)
856            }
857                           //if (!bBus)
858                //    $("#liBus").remove();
859                //if (!bRail)
860                //    $("#liRail").remove();
861                //if (!bPark)
862                //    $("#wucDashboard_liPark").remove();
863                //if (!bTrip)
864                //    $("#liTrip").remove();
865                //if (!bTHSR)
866                //    $("#liTHSR").remove();
867                //if (!bTRA)
868                //    $("#liTRA").remove();
869                //if (!bInterCityBus)
870                //    $("#liInterCityBus").remove();
871                //if (!bBike)
872                //    $("#liBikeLoading").remove();
873
874
875        });
876    }
877    
878
879}
880
881
882//beg 串 sps html
883function GetSpsHtml(d,a) {
884
885    var e = d;
886    
887    
888    NewsHTML = "";
889    SpotHTML = "";
890    ActivityHTML = "";
891    TravelInfoHTML = "";
892    $.each(e, function (i) {
893        if (a == 'News') {//旅遊情報
894            NewsHTML +=
895                '<li><a href="' + e[i].linkURL + '" class="sps__news-item">' + e[i].Name + '</a></li></li>\r\n';
896            //$('#NewsContent').html(NewsHTML);
897        }
898        else if (a == 'Spot') {//景點
899            //有無圖片
900            if (e[i].imageName == null || e[i].imageName.length == 0)
901                imgStr = '<img class="lazyload" src="images/nopic.jpg">\r\n';
902            else
903                imgStr = '<img class="mCS_img_loaded lazyloaded" src="' + e[i].imageName + '" data-src=' + e[i].imageName +'">\r\n';
904            
905            SpotHTML +=
906            '<li>\r\n'+
907            '   <div class="sps__viewsList-item">\r\n'+
908            '       <a href="' + e[i].linkURL +'" class="sps__viewsList-image">\r\n'+
909            imgStr+
910            '       </a>\r\n'+
911            '       <div class="sps__viewsList-content">\r\n'+
912            '          <a href="' + e[i].linkURL +'&utm_source=LBS&utm_medium=referral" class="sps__viewsList-title">' + e[i].Name + '</a>\r\n'+
913            '       </div>\r\n'+
914            '       <div class="visits-tag">' + e[i].ReadCount + '</div>\r\n'+
915            '   </div>\r\n'+
916            '</li>\r\n';
917
918
919            //$('#SpotContent').html(SpotHTML);
920        }
921        else if (a == 'Event') {//活動
922            //有無圖片
923            if (e[i].imageName == null || e[i].imageName.length == 0)
924                imgStr = '<img class="lazyload" src="images/nopic.jpg">\r\n';
925            else
926                imgStr = '<img class="mCS_img_loaded lazyloaded" src="' + e[i].imageName + '" data-src="' + e[i].imageName +'">\r\n';
927            
928            ActivityHTML +=
929                '<li>\r\n'+
930                '	<div class="sps__viewsList-item">\r\n' +
931                '		<a href="' + e[i].linkURL +'" class="sps__viewsList-image">\r\n' +
932                imgStr +
933                '		</a>\r\n' +
934                '		<div class="sps__viewsList-content">\r\n' +
935                '			<a href="' + e[i].linkURL + '&utm_source=LBS&utm_medium=referral" class="sps__viewsList-title">' + e[i].Name + '</a>\r\n' +
936                '			<p class="color-orange">' + e[i].Cycle + '</p>\r\n' +
937                '		</div>\r\n' +
938                '	</div>\r\n' +
939                '</li>\r\n';
940
941            //$('#EventTitle').html(ActivityHTML);
942        }
943        else if (a == 'Trip') {//行程
944            if (e[i].imageName == null || e[i].imageName.length == 0)
945                imgStr = '<img class="lazyload" src="images/nopic.jpg">\r\n';
946            else
947                //pic.ashx?qp=1/big_scenic_spots/pic_290_8.jpg&amp;sizetype=3
948                imgStr = '<img class="mCS_img_loaded lazyloaded" src="' + e[i].imageName + '" data-src="' + e[i].imageName +'">\r\n';
949            
950            TravelInfoHTML +=
951            '<li>\r\n'+
952            '	<div class="sps__viewsList-item">\r\n'+
953            '		<a href="' + e[i].linkURL +'" class="sps__viewsList-image">\r\n'+
954            imgStr +
955            '		</a>\r\n' +
956            '		<div class="sps__viewsList-content">\r\n'+
957            '			<a href="' + e[i].linkURL+'" class="sps__viewsList-title">' + e[i].Name + '</a>\r\n'+
958            '		</div>\r\n'+
959            '		<div class="visits-tag">' + e[i].ReadCount + '</div>\r\n'+
960            '	</div>\r\n'+
961            '</li>\r\n';
962            //$('#TripContent').html(TravelInfoHTML);
963
964        }
965    });
966	
967    if (NewsHTML.length > 0)
968    {
969        $('#NewsContent').html(NewsHTML);
970        $('#NewsTitle').show();
971        $('#NewsContent').show();
972		$('#wucDashboard_aNewsMore').show();
973		
974        
975    }
976    if (SpotHTML.length >0) {
977        
978        $('#SpotContent').html(SpotHTML);
979        $('#SpotTitle').show();
980        $('#SpotContent').show();
981		$('#wucDashboard_aSpotMore').show();
982
983    }
984    if (TravelInfoHTML.length > 0) {
985        
986        $('#TripContent').html(TravelInfoHTML);
987        $('#TripTitle').show();
988        $('#TripContent').show();
989		$('#wucDashboard_aTripMore').show();
990
991    }
992    if (ActivityHTML.length > 0) {
993        
994        $('#EventContent').html(ActivityHTML);
995        $('#EventTitle').show();
996        $('#EventContent').show();
997		$('#wucDashboard_aEventsMore').show();
998		
999    }
1000
1001
1002    //end 串 sps html
1003}
1004//Beg 取得推薦資料
1005
1006function GetRecommandData() {
1007
1008    var URL = "";
1009    //var URL = "sps.ashx?serviceName=" + serviceName;
1010    var URL = "sps.ashx";
1011    
1012    //console.log('serviceName=' + serviceName);
1013    $.ajax({
1014        url: URL,
1015        //data: jsonData,
1016        //dataType: "json",
1017        type: "GET",
1018        success: function (data) {
1019            //var resp = $.parseJSON(JSON.stringify(data));
1020            //console.log(resp.o.items);e[i].
1021            //console.log(serviceName + "data=" + resp.o[0].Name);
1022            if (data != "") {
1023                var resp = JSON.parse(data);
1024                //$('#lightboxSps').show();
1025                //console.log("data.News=" + resp.News);
1026                GetSpsHtml(resp.News, "News");
1027                GetSpsHtml(resp.Event, "Event");
1028                GetSpsHtml(resp.Spot, "Spot");
1029                GetSpsHtml(resp.Trip, "Trip");
1030            }
1031            else {
1032                //$('#lightboxSps').hide();
1033                $('#PersonalSPS').hide();
1034            }
1035           
1036        },
1037        error: function (data, status, jqXHR) {
1038            console.log("There was an error.");
1039            
1040        }
1041    }); // end $.ajax
1042}
1043//End 取得推薦資料
1044
1045
1046//Beg 計數
1047
1048function setData(lat, lng, WeatherCaption)
1049{
1050    $(function () {
1051        $.ajax({
1052            url: "lbsCount.ashx?t=p&l=" + $("#lang").html() + "&lat=" + lat + "&lng=" + lng + "&loc=" + WeatherCaption,type:"POST",cache:!1,dataType:"json",data:{id:""},
1053    success:function(a){
1054        //a[0].Success&&(document.getElementById("VisitCount").innerHTML=a[0].Count0)
1055    },error:function(a,b,c){}})})};
1056//End 計數
1057
1058

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.