88 functions
Must Watch!
MustWatch
https://hd.stheadline.com/js/custom.js
88 functions
$(document).ready(function()
$(document).ready(function(){
var $carouselSbLife = $('#carousel-sb-life');
$.fn.carouselHover = function(){
var number;
var $obj = this;
$obj.on('slide.bs.carousel', function (e) {
number = $(e.relatedTarget).index();
$obj.find('.indicators li:eq('+number+')').addClass('active').siblings().removeClass('active');
});
$obj.find('.indicators li').hover(function(){
number = parseInt($(this).attr('data-slide-to'));
setTimeout(function() {
$obj.carousel(number);
}, 500);
});
};
$carouselSbLife.carouselHover();
});
/***
These global varable is from index php page. Please find brefore htmlFooter.php was load.
var newestColumnNewsGroup
var newsPrePageOnList
var newsGroup
var countPage
var reloadPageTimeInterval
var popnewsWebRoot
var comscoreBasesiteUrl
var videoHttpSourceRoot
var newsID
var newsTitle
var newsCat
var popnewsVideoID
var streamComscore
var inewsVideoPath
var streamComscore2
var videoPlaySequence
var popnewsPlayListData
var videoWowzaStreamer
var newsTotal
var photonewsListNewsPrePage
var columnistID
var statHitcountSeverRoot
var backURI
var gameDetailPage
var isPlayOnce
var isLogined
var isPlayed
***/
var temp_clips;
var myStreamingTag;
$(document).ready(function()
$(document).ready(function(){
var $body = $('body'),
$bodyContent = $('.body-content'),
$header = $bodyContent.find('.header'),
$headerSearchbar= $bodyContent.find('.header .searchbar'),
$headerSearchbarShowAffix = $bodyContent.find('.header .searchbar-show-affix'),
$mobileBodyScrollableContent = $('.mobile-body-scrollable-content'),
$main = $bodyContent.find('.main'),
$mainContainer = $bodyContent.find('.main > .container'),
$mainIndexPopnews = $bodyContent.find('.main-index .popnews'),
$headerDropdownApps = $('#dropdown-apps'),
$navbar = $('.navbar'),
$focusCarousel = $('#focus-carousel'),
$inewsTabs = $('.inews-tabs'),
$mainContainer = $('.main .container'),
$blogsCarousel = $('#blogs-carousel'),
$blogsCarouselInnerCopy = $('#blogs-carousel-inner');
$blogsCarouselInnerDiv = $blogsCarouselInnerCopy.find('>div'),
$blogsCarouselCarouselIndicators = $blogsCarousel.find('.carousel-indicators'),
$blogsCarouselInner = $blogsCarousel.find('.carousel-inner'),
$sectionNewsListScrollable = $('.section .news-list-scrollable'),
$dailynewsBlogsCarousel = $('#dailynews-blogs-carousel');
$sectionAllBlogs = $('#section-all-blogs'),
$sectionAllBlogsScrollableContent = $sectionAllBlogs.find('.section-all-blogs-scrollable-content'),
$searchBlog = $('.search-blog'),
$sidebar = $('.sidebar'),
$mobileSidebarLeft = $('#sidebar-left'),
$sidebarContent = $sidebar.find('.sidebar-content'),
$footer = $('#footer'),
$detail = $('.main.detail'),
$detailContentCarousel = $detail.find('.content-carousel');
var headerHeight = $header.height(),
headerMarBot = parseInt($header.css('margin-bottom')),
navbarHeight = $navbar.height(),
MCPadTop = parseInt($mainContainer.css('padding-top')),
MCPadBot = parseInt($mainContainer.css('padding-bottom')),
sidebarConHeight = $sidebarContent.height(),
footerHeight = $footer.height(),
footerBorTopWidth = parseInt($footer.css('border-top-width')),
mainMarBot = parseInt($main.css('margin-bottom')),
windowHeight = $(window).height(),
MCWidth = $mainContainer.width(),
sizeTimer,
sectionAllBlogsHeight,
CarouselIndicatorsHtml,
carouselInnerHtml,
blogsCarouselCol,
dccWidth;
headerDropdownAppsFn();
inewsTabsFn();
detailContentCarouselFn();
$headerSearchbarShowAffix.click(function(){
searchbarShowFn();
});
$mobileSidebarLeft.find('.cats ul li').click(function(){
event.preventDefault();
var url = $(this).find('a').attr('href');
$(this).siblings('.active').addClass('collapsing');
$(this).addClass('active');
console.log('added active');
setTimeout(function(){
window.location.href = url;
}, 300);
});
displayDetailTab();
//Adding swipe support to Bootstrap Carousel
/*$(".carousel .carousel-inner").swipe( {
//Generic swipe handler for all directions
swipeLeft:function(event, direction, distance, duration, fingerCount) {
console.log('swipeLeft');
$(this).parent().carousel('next');
},
swipeRight: function() {
console.log('swipeRight');
$(this).parent().carousel('prev');
},
//Default is 75px, set to 0 for demo so any distance triggers swipe
threshold:0
}); */
reSizeFn();
$(window).on("resize", function() {
clearTimeout(sizeTimer);
sizeTimer = setTimeout(function() {
reSizeFn();
}, 300);
});
//Bootstrap Fn
bsCollapseFn();
bsModalFn();
if(typeof emsg !== "undefined" && emsg !== null){
if(emsg == 2){
niceAlert("用戶名密碼錯誤或不存在,請檢查后重新輸入,如尚未登記,請登記后再登入.");
}
}
$('a[data-toggle="selection"]').on('click', function(){
var val = $(this).attr('href');
val = val.replace(/#/, '');
if(val!='')
{
$(this).addClass('active').siblings().removeClass('active');
$(this).parent().parent().find('.sel-content .sel-pane').hide();
$(this).parent().parent().find('.sel-content .sel-pane.'+ val +'').show();
if(val=='all')
$(this).parent().parent().find('.sel-content .sel-pane').show();
}
return false;
});
if (getPlatform() == 'm') {
$(document).on('focus', 'textarea,input,select', function() {
$(window).off('.affix');
$('.navbar').removeData('bs.affix').removeClass('affix affix-top affix-bottom');
$headerSearchbar.removeClass('affix');
}).on('blur', 'textarea,input,select', function() {
$(window).on('.affix');
navbarFn(MCWidth);
});
//$searchBlog.removeData('bs.affix').removeClass('affix affix-top affix-bottom');
}
displayDetailTab
function displayDetailTab()
{
$('.other-cat-tabs').show();
$('.section-sb').show();
}
reSizeFn
function reSizeFn() {
windowHeight = $(window).height();
footerHeight = $footer.height(),
MCWidth = $mainContainer.width();
navbarFn(MCWidth);
headerMinOpenFn(MCWidth);
sectionNewsListScrollableFn(MCWidth);
dailynewsDetailScrollableFn(MCWidth);
reChangBlogsCarouselFn(MCWidth);
dailynewsBlogsCarouselFn(MCWidth)
searchBlogFn(MCWidth);
sectionAllBlogsFn(MCWidth);
//sidebarFn(MCWidth);
popnewsPlayingChangFor1024(MCWidth);
if($detail.length){
detailFn();
if($detailContentCarousel.length)
{
dccWidth = $detailContentCarousel.width();
}
}
areaClickFn();
autoSizeFn();
imageAutoSizeFn();
focusCarouselResizeFn();
//sidebar for mob
sidebarJetsoMob(MCWidth);
//Bootstrap Fn
bsTooltipFn(MCWidth);
};
headerDropdownAppsFn
function headerDropdownAppsFn(){
if(!($headerDropdownApps.length))
return false;
$headerDropdownApps.find('.dropdown-menu .row > div').hover(function(){
var target = $(this).attr("data-target");
$(this).addClass("active").siblings().removeClass("active");
$headerDropdownApps.find('.qrcodes div[data-content="'+ target +'"]').addClass("in").siblings().removeClass("in");
});
}
searchbarShowFn
function searchbarShowFn(){
if($headerSearchbarShowAffix.hasClass('active'))
{
$headerSearchbarShowAffix.removeClass('active');
$headerSearchbar.removeClass('affix');
}else{
$headerSearchbarShowAffix.addClass('active');
$headerSearchbar.addClass('affix');
$headerSearchbar.find('input.form-control').focus();
}
}
inewsTabsFn
function inewsTabsFn(){
if(!($inewsTabs.length))
return false;
$inewsTabs.find('td').click(function(){
$(this).addClass('active').siblings('td').removeClass('active');
});
$inewsTabs.find('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
var tabActiveId = $(this).parents('.inews-tabs').find('.tab-pane.active').attr('id');
$(this).parents('.inews-tabs').find('.img-' + tabActiveId).show().siblings().hide();
})
}
navbarFn
function navbarFn(w){
if($navbar.length && w > 768)
{
$navbar.affix({
offset: {
top : 182
}
});
$navbar.on('affix-top.bs.affix', function(){
$headerSearchbarShowAffix.removeClass('active');
$headerSearchbar.removeClass('affix');
});
}
}
headerMinOpenFn
function headerMinOpenFn(w){
if(w < 768){
$mobileBodyScrollableContent.scroll(function(){
clearTimeout(sizeTimer);
sizeTimer = setTimeout(function() {
if($mobileBodyScrollableContent.scrollTop() > 0){
if($bodyContent.hasClass('header-min-open') == false){
$bodyContent.addClass('header-min-open');
}
}else{
if($bodyContent.hasClass('header-min-open')){
$bodyContent.removeClass('header-min-open');
}
}
}, 250);
});
}else{
if($bodyContent.hasClass('header-min-open')){
$bodyContent.removeClass('header-min-open');
}
}
}
sidebarFn
function sidebarFn(w){
if($sidebarContent.length && w > 768 )
{
var affixCssTop, affixBottomCssTop;
$sidebarContent.affix({
offset: {
top: function(){
return this.top = headerHeight + headerMarBot - navbarHeight;
},
bottom: function(){
return this.bottom = footerHeight + footerBorTopWidth + mainMarBot + MCPadBot;
}
}
});
}
}
areaClickFn
function areaClickFn(){
if( MCWidth < 768){
$('.areaclick').click(function(){
var url = $(this).find('a.areaclick-link').attr('href');
$('.areaclick').removeClass('active');
$(this).addClass('active');
if(url){
window.location.href = url;
}
});
}
}
autoSizeFn
function autoSizeFn(){
$('[data-spy="autosize"]').each(function (index,img) {
var src = img.getAttribute('src');
img.setAttribute('src','');
img.onload = function(){
var imgScale,
scaleArray,
setScale,
innerWidth,
innerHeight;
imgScale = this.width/this.height;
scaleArray = ($(this).attr('data-scale')).split(':');
if(scaleArray.length!=2)
return false;
setScale = scaleArray[0]/scaleArray[1];
$(this).parent().css({
'display': 'block',
'text-align': 'center',
'background-color': '#ccc',
'position':'relative'
});
innerWidth = $(this).parents('.autosize-inner').width();
innerHeight = innerWidth/setScale;
$(this).parent().css({
'height': innerHeight
});
if( imgScale < 1 )
{
$(this).css({
'height':'100%',
'width':'auto',
'position':'relative',
'z-index':'1'
});
if(!($(this).parent().find('.blur').length)){
$(this).after(function() {
return '<img class="blur" src="' + src + '"/>'
});
}
}
else if( imgScale < setScale && imgScale > 1 )
{
$(this).css({
'height':'auto',
'width':'100%'
});
}
else
{
$(this).css({
'height': '100%',
'width': 'auto',
'margin-left': (innerWidth-((this.width*innerHeight)/this.height))/2 + 'px'
});
}
}
img.setAttribute('src',src);
})
}
focusCarouselResizeFn
function focusCarouselResizeFn(){
if(!($focusCarousel.length))
return false;
$focusCarousel.find('.carousel-inner .item .carousel-caption p').each(function(index, element) {
var dataDescription = $(this).attr('data-description');
if(dataDescription){
if( MCWidth < 1024 ){
$(this).text(dataDescription.slice(0,70)+'...');
}else{
$(this).text(dataDescription.slice(0,260)+'...');
}
}
});
}
sidebarJetsoMob
function sidebarJetsoMob(w){
if(!($('.main-index').length))
return false;
var $corpCeo = $('#corp-ceo'),
$finance = $('#finance'),
$jetsoWrapper = $('#jetso-wrapper'),
$corpCeoForMob = $('#corp-ceo-for-mob'),
$financeForMob = $('#finance-for-mob'),
$jetsoForMob = $('#jetso-for-mob');
var corpCeoHtml,
financeHtml,
jetsoWrapperHtml;
if(w<768)
{
corpCeoHtml = $.parseHTML( $corpCeo.html() ),
$corpCeoForMob.show().html( corpCeoHtml );
$corpCeo.hide();
financeHtml = $.parseHTML( $finance.html() ),
$financeForMob.show().html( financeHtml );
$finance.hide();
jetsoWrapperHtml = $jetsoWrapper.html();
jetsoWrapperHtml = jetsoWrapperHtml.replace(/jetsoCotent/g,"jetsoMobCotent");
jetsoWrapperHtml = jetsoWrapperHtml.replace(/jetso-carousel/g,"jetso-mob-carousel");
jetsoWrapperHtml = $.parseHTML( jetsoWrapperHtml ),
$jetsoForMob.show().html( jetsoWrapperHtml );
$jetsoWrapper.hide();
}else{
$corpCeoForMob.hide();
$financeForMob.hide();
$jetsoForMob.hide();
$corpCeo.show();
$finance.show();
$jetsoWrapper.show();
}
}
sectionNewsListScrollableFn
function sectionNewsListScrollableFn(w){
if($sectionNewsListScrollable.length){
if( w > 768 )
{
if($sectionNewsListScrollable.hasClass('ps-active-y') == false){
$sectionNewsListScrollable.perfectScrollbar({
suppressScrollX: true
});
$sectionNewsListScrollable.addClass('ps-container ps-active-y');
}
}else{
if($sectionNewsListScrollable.hasClass('ps-active-y') == true){
$sectionNewsListScrollable.perfectScrollbar('destroy');
$sectionNewsListScrollable.removeClass('ps-container ps-active-y');
}
}
}
}
dailynewsDetailScrollableFn
function dailynewsDetailScrollableFn(w){
if($('.main.main-dailynews-list.detail').length){
if( w > 768 ){
$('.dropdown-news-detail').on('shown.bs.dropdown', function () {
$('.dropdown-news-detail .dropdown-menu').perfectScrollbar({
suppressScrollX: true
});
});
}
}
}
// $sectionNewsListScrollable.perfectScrollbar({
// suppressScrollX: true
// });
reChangBlogsCarouselFn
function reChangBlogsCarouselFn(w)
{
if(!($blogsCarousel.length))
return false;
if( w > 768 && w < 1024 ){
if( blogsCarouselCol == 3 )
return false;
blogsCarouselCol = 3;
}else if( w > 1024 ){
if( blogsCarouselCol == 4 )
return false;
blogsCarouselCol = 4;
}else{
return false;
}
CarouselIndicatorsHtml = '<li data-target="#blogs-carousel" data-slide-to="0" class="active"></li>',
carouselInnerHtml = '<div class="item row active">';
for( var i = 1, y =1; i < $blogsCarouselInnerDiv.length; i++)
{
if( i % blogsCarouselCol == 0)
{
CarouselIndicatorsHtml = CarouselIndicatorsHtml + '<li data-target="#blogs-carousel" data-slide-to="' + y + '"></li>'
y ++;
}
}
$blogsCarouselCarouselIndicators.html(CarouselIndicatorsHtml);
$blogsCarouselInnerDiv.each(function(index, element) {
var ii = index + 1;
carouselInnerHtml = carouselInnerHtml + '<div class="col-xs-4 col-lg-3">' + $(this).html() + '</div>'
if( ii % blogsCarouselCol == 0 && ii< $blogsCarouselInnerDiv.length)
{
carouselInnerHtml = carouselInnerHtml + '</div><div class="item row">';
}
else if(ii == $blogsCarouselInnerDiv.length)
{
carouselInnerHtml = carouselInnerHtml + '</div>';
};
});
$blogsCarouselInner.html(carouselInnerHtml);
$blogsCarousel.carousel({
interval: 3000
});
}
popnewsPlayingChangFor1024
function popnewsPlayingChangFor1024(w){
if(!($mainIndexPopnews.length))
return false;
if( $mainIndexPopnews.find('.playing').length ){
var $playingEle = $mainIndexPopnews.find('.playing');
var index = $playingEle.index();
if( w > 768 && w < 1024 ){
if( index == 0 ){
$playingEle.parent('.row').find('>div:gt(1)').hide();
$playingEle.parent('.row').find('>div:lt(2)').show();
}else if( index == 2){
$playingEle.parent('.row').find('>div:lt(2)').hide();
$playingEle.parent('.row').find('>div:gt(1)').show();
}
}else{
$playingEle.parent('.row').find('>div').show();
}
}
}
dailynewsBlogsCarouselFn
function dailynewsBlogsCarouselFn(w){
if( !($dailynewsBlogsCarousel.length) )
return false;
if( w > 768 && w < 1024 )
{
$dailynewsBlogsCarousel.carousel({
interval: 3000
});
}else{
$dailynewsBlogsCarousel.carousel({
pause: true,
interval: false
});
}
}
searchBlogFn
function searchBlogFn(w){
if( !($searchBlog.length) )
return false;
if( w > 768 )
{
$searchBlog.attr('style','visibility:visible').removeClass('mobile').affix({
offset: {
bottom: function(){
return this.bottom = footerHeight + footerBorTopWidth + mainMarBot + MCPadBot;
}
}
});
}else{
$searchBlog.attr('style','').addClass('mobile').removeClass('affix affix-top affix-bottom').removeData('bs.affix');
}
}
sectionAllBlogsFn
function sectionAllBlogsFn(w){
if( !($sectionAllBlogs.length) )
return false;
if( w > 1024 )
{
sectionAllBlogsHeight = $sectionAllBlogs.height();
$sectionAllBlogs.css('height', sectionAllBlogsHeight + 'px');
if($sectionAllBlogsScrollableContent.hasClass('ps-active-y') == false){
$sectionAllBlogsScrollableContent.perfectScrollbar({
suppressScrollX: true
});
$sectionAllBlogsScrollableContent.addClass('ps-container ps-active-y');
}
}else{
$sectionAllBlogs.css('height', 'auto');
if($sectionAllBlogsScrollableContent.hasClass('ps-active-y') == true){
$sectionAllBlogsScrollableContent.perfectScrollbar('destroy');
$sectionAllBlogsScrollableContent.removeClass('ps-container ps-active-x ps-active-y');
}
}
}
detailFn
function detailFn(){
if(!($detail.length))
return false;
var $detailHeadingBar = $detail.find('.detail-heading-bar'),
$detailHeadingBarShare = $detailHeadingBar.find('.share'),
$detailContent = $detail.find('.content'),
$detailPagination = $detail.find('.pagination'),
$detailCtrlBar = $detail.find('.detail-ctrl-bar');
if($detailHeadingBar.length)
{
var detailHeadingBarShareOffsetTop = $detailHeadingBar.offset().top,
detailHeadingBarShareOffsetBottom = $bodyContent.height() - $detailContent.offset().top - $detailContent.outerHeight();
$detailHeadingBarShare.affix({
offset:{
top: (detailHeadingBarShareOffsetTop - 50)
//bottom: detailHeadingBarShareOffsetBottom
}
})
}
}
detailContentCarouselFn
function detailContentCarouselFn(){
if($detailContentCarousel.length)
{
var dccRelatedTargetHeight,
dccItemLength = $detailContentCarousel.find('.item').length,
dccFirstItemCaption = $detailContentCarousel.find('.item:first img').attr('alt');
if(dccItemLength!=1){
$detailContentCarousel.find('.carousel-control').show();
}
$detailContentCarousel.find('.carousel-caption-active .number').html( '1/' + dccItemLength );
$detailContentCarousel.find('.carousel-caption-active .text').html( dccFirstItemCaption );
$detailContentCarousel.find('.carousel').carousel('pause');
$detailContentCarousel.find('.item img').each(function(index, img) {
var src = img.getAttribute('src');
img.setAttribute('src','');
img.onload = function(){
if((this.width/this.height) < 1)
{
this.style.width = 'auto';
this.style.maxHeight = '640px';
}else{
if(this.width > 350){
this.style.width = '100%';
}
this.style.height = 'auto';
}
}
img.setAttribute('src',src);
});
$detailContentCarousel.on('slide.bs.carousel', function (e) {
$(e.relatedTarget).find('img').each(function(index, img) {
if((img.width/img.height) < 1)
{
img.style.width = 'auto';
dccRelatedTargetHeight = img.height;
if(img.width > dccWidth)
{
dccRelatedTargetHeight = (dccWidth*img.height)/img.width;
}
if(dccRelatedTargetHeight > 640)
{
dccRelatedTargetHeight = 640;
}
}else{
if(this.width > 350){
dccRelatedTargetHeight = Math.floor((dccWidth*img.height)/img.width);
}else{
dccRelatedTargetHeight = img.height;
}
}
$detailContentCarousel.find('.carousel-caption-active .number').html( ($(e.relatedTarget).index()+1) + '/' + dccItemLength );
$detailContentCarousel.find('.carousel-caption-active .text').html( $(img).attr('alt') );
});
if( $detailContentCarousel.find('.carousel-inner').height() != dccRelatedTargetHeight)
{
$detailContentCarousel.find('.carousel-inner').animate({'height': dccRelatedTargetHeight}, 500, function(){
clearTimeout(sizeTimer);
sizeTimer = setTimeout(function() {
$detailContentCarousel.find('.carousel-inner').css('height','inherit');
}, 300);
});
}
});
}
}
imageAutoSizeFn
function imageAutoSizeFn(){
$('img.auto-size').each(function(index, element) {
var scale,
thisWidth,
thisHeight,
thisParentWidth,
thisParentHeight;
thisWidth = $(this).width(),
thisHeight = $(this).height();
scale = thisWidth/thisHeight;
thisParentWidth = $(this).parent().width();
thisParentHeight = (thisParentWidth*10)/16;
$(this).parent().css('height',thisParentHeight+'px');
if( scale < (16/16) ){
$(this).css({'height':'100%','width':'auto'});
}
else if( scale < (16/10) && scale > (16/16) )
{
$(this).css({'height':'auto','width':'100%'});
}
else
{
$(this).css({'height':'100%','width':'auto'});
}
});
}
//Bootstrap Fn
bsTooltipFn
function bsTooltipFn(w){
$('[data-toggle="tooltip"]').tooltip();
if(w > 768)
{
$('.form-group [data-toggle="tooltip"]').tooltip('destroy');
clearTimeout(sizeTimer);
sizeTimer = setTimeout(function() {
$('.form-group [data-toggle="tooltip"]').tooltip({placement: 'right'});
}, 300);
}else{
$('.form-group [data-toggle="tooltip"]').tooltip('destroy');
clearTimeout(sizeTimer);
sizeTimer = setTimeout(function() {
$('.form-group [data-toggle="tooltip"]').tooltip({placement: 'top'});
}, 300);
}
}
bsCollapseFn
function bsCollapseFn(){
$('.collapse').collapse().on('show.bs.collapse', function () {
$('.collapse').collapse('hide');
});
}
bsModalFn
function bsModalFn(){
$('.modal').each(function(index, element) {
var $modalDialog = $(this).find('.modal-dialog');
var modalCss = $(this).attr('style');
$(this).css({
position: 'absolute',
visibility: 'hidden',
display: 'block'
});
var modalDialogHeight = $modalDialog.height();
$modalDialog.css('height', modalDialogHeight);
$(this).attr("style", modalCss ? modalCss : "");
});
$('.modal').on('show.bs.modal', function (e) {
var objCls = '.header > .toolbar, .header > .wrapper, .header > .navbar, .header > .searchbar, .main, .footer';
var oldSSB = $.fn.modal.Constructor.prototype.setScrollbar;
$.fn.modal.Constructor.prototype.setScrollbar = function () {
oldSSB.apply(this);
if (this.bodyIsOverflowing && this.scrollbarWidth)
$(objCls).css('padding-right', this.scrollbarWidth);
}
});
$('.modal').on('hide.bs.modal', function () {
var objCls = '.header > .toolbar, .header > .wrapper, .header > .navbar, .header > .searchbar, .main, .footer';
var oldRSB = $.fn.modal.Constructor.prototype.resetScrollbar;
$.fn.modal.Constructor.prototype.resetScrollbar = function () {
oldRSB.apply(this);
$(objCls).css('padding-right', '');
}
});
$('.modal').on('show.bs.modal', function() {
var modalDialogMarginTop = (($(window).outerHeight() / 2) - ($(this).find('.modal-dialog').height() / 2));
if(modalDialogMarginTop < 0)
modalDialogMarginTop = 0;
$(this).find('.modal-dialog').css({
'margin-top': modalDialogMarginTop
});
});
$('#mobileShareModal').on('show.bs.modal', function(){
$body.addClass('mobileShareModal-open');
});
}
$('.inews_slide_bar_img').each(function(i, obj){
if($(this).prop('naturalWidth') > $(this).prop('naturalHeight'))
$("#"+$(this).prop("id")).css({'height':'65px', 'width': 'auto'});
else if($(this).prop('naturalWidth') < $(this).prop('naturalHeight'))
$("#"+$(this).prop("id")).css({'width':'65px', 'height': 'auto'});
var $img = $(this);
var width = $img.prop("width");
var height = $img.prop("height");
if(width > 65){
$img = $("#"+$(this).prop("id")).css({'position':'absolute', "left": (0-($img.prop("width")-65)/2), 'display': 'inline-block','margin': 'auto auto'});
}
if(height > 65){
$img = $("#"+$(this).prop("id")).css({'position':'absolute', "top": (0-($img.prop("height")-65)/2), 'width': 'auto','display': 'inline-block','margin': 'auto auto'});
}
});
});
loadFontSize();
$(document).ready(function(){
//loadAllAds(); //from js/detect_content_header.js
//initFastClick();
showMobileElements();
loadFontSize();
initBselect();
//initSiteLoadingAnimsition();
initFancybox();
addSearchFromSubmitEvents();
// reloadPageAfterTime();
//initIndexPageJWPlayer();
//initAdWithJWPlayer();
//initJWPlayerWithPopnewsId();
//initJWPlayerWithInewsVideo();
initIndexPageVideojs();
initVideojsWithPopnewsId();
initVideojsWithInewsVideo();
createPhotoNewsPageBar();
initGamePage();
if($("#shorcut-enter").length>0){
$("body").keyup(function(event){
if(event.keyCode == 13){
$("#shorcut-enter").click();
}
});
}
});
$(window).load(function()
$(window).load(function() {
$('.inews_slide_bar_img').each(function(i, obj){
if($(this).prop('naturalWidth') > $(this).prop('naturalHeight'))
$("#"+$(this).prop("id")).css({'height':'65px', 'width': 'auto'});
else if($(this).prop('naturalWidth') < $(this).prop('naturalHeight'))
$("#"+$(this).prop("id")).css({'width':'65px', 'height': 'auto'});
var $img = $(this);
var width = $img.prop("width");
var height = $img.prop("height");
if(width > 65){
$img = $("#"+$(this).prop("id")).css({'position':'absolute', "left": (0-($img.prop("width")-65)/2), 'display': 'inline-block','margin': 'auto auto'});
}
if(height > 65){
$img = $("#"+$(this).prop("id")).css({'position':'absolute', "top": (0-($img.prop("height")-65)/2), 'width': 'auto','display': 'inline-block','margin': 'auto auto'});
}
});
})
var textServerBusy = "伺服器繁忙,請稍後再試";
var textPlsInputUsername = "請輸入登入名稱";
var textInvalidateUsername = "登入名稱不符合要求,請重新輸入";
var textPlsInputPassword = "請輸入密碼";
var textShortPassword = "密碼太短,密碼長度不能少過6個字,請重新輸入";
var textPasswordNotSame = "兩次輸入的密碼不一致,請檢查后重新輸入";
var textPlsInputEmail = "請輸入電郵地址";
var textInvalidateEmail = "電郵地址不合法,請重新輸入";
var textLongEmail = "電郵地址過長,不能多過50字,請重新輸入";
var textFailVerifyEmail = "電郵地址驗證失敗,請稍後再試";
var textEmailExsists = "該電郵地址已存在,請重新輸入";
var textPlsInputCaptureCode = "請輸入驗證碼";
var textPlsInputNickname = "請輸入昵稱";
var textPlsInputFirstname = "請輸入姓";
var textPlsInputLastname = "請輸入名";
var textPlsSelectSex = "請選擇性別";
var textPlsInputMobile = "請輸入手提電話";
var textPlsInputRightMobile = "請輸入正確8位數字香港手提電話";
var emailExp = /^([a-zA-Z0-9]+[_|\-|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\-|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
var usernameExp = /^[0-9a-zA-Z_]{2,20}$/;
var mobileExp = /^\d{8}$/;
getPlatform()
function getPlatform(){
if(metaPlatform == 'phone' || metaPlatform == 'tablet'){
return 'm';
}else{
return 'w';
}
}
getHitcount(id, type, callback)
function getHitcount(id, type, callback){
// console.log('getHitcount');
var callbackFunction = callback;
$.ajax({
method : "GET",
url : "/ajax/getHitcountApiCache.php?id="+id+"&type="+type,
dateType : "json",
success:function(data){
callbackFunction(data);
}
});
}
updateHitcount(id, catId, type)
function updateHitcount(id, catId, type){
// console.log('updateHitcount');
if(typeof statHitcountSeverRoot != "undefined" && statHitcountSeverRoot != ""){
var seprator = "!!!";
var site = "hl";
var file = window.location.pathname;
var agent = navigator.userAgent;
var platform = getPlatform();
var obj = [id, catId, type, site, file, agent, platform];
$.ajax({
method : "POST",
url : statHitcountSeverRoot+"news/updateHeadlineNewsHitcountApi.php?str="+encodeURIComponent(obj.join(seprator)),
success:function(data){}
});
}
}
adjustFontSize(size)
function adjustFontSize(size){
// console.log('adjustFontSize');
$(".set-font-aera").css({"font-size":size});
window.localStorage["fontSize"] = size;
}
loadFontSize()
function loadFontSize(){
//console.log('loadFontSize');
if($(".set-font-aera").length>0){
// console.log('loadFontSize in');
if(typeof window.localStorage["fontSize"] != "undefined"){
var size = window.localStorage["fontSize"];
$(".set-font-aera").css({"font-size":size});
}else{
$(".set-font-aera").css({"font-size":"20px"});
}
$(".set-font-aera").css('visibility',"visible");
}
}
searchBlog(id)
function searchBlog(id){
// console.log('searchBlog');
if(!(id === "" || id === null)){
window.location.href='/news/columns/'+id+'/';
}
}
shareStory(shareTitle, shareContent, sharePic, method, enable)
function shareStory(shareTitle, shareContent, sharePic, method, enable){
// console.log('shareStory');
var googleShoretenKey = 'AIzaSyBIUja-PUZ4YM1I9oILNCyMwzfRznKVUEI';
var band = "[頭條日報]";
var shareLink = window.location.href;
clearFacebookCache();
if(enable == 'true'){
$.ajax({
method : "POST",
url : "https://www.googleapis.com/urlshortener/v1/url?key="+googleShoretenKey,
dateType : "json",
contentType : "application/json; charset=utf-8",
data : JSON.stringify({'longUrl':shareLink}),
success:function(data){
if(data && data["id"]){
shareLink = data["id"];
}
shortenURLCallback(method,shareTitle,shareLink,shareContent,sharePic);
}
});
}else{
shortenURLCallback(method,shareTitle,shareLink,shareContent,sharePic);
}
}
clearFacebookCache()
function clearFacebookCache(){
// console.log('clearFacebookCache');
$.ajax({
method : "GET",
url : "/ajax/facebookClearCacheApi.php?url="+encodeURIComponent(window.location.href),
dateType : "json",
success:function(data){
}
});
}
shortenURLCallback(method,shareTitle,shareLink,shareContent,sharePic)
function shortenURLCallback(method,shareTitle,shareLink,shareContent,sharePic){
// console.log('shortenURLCallback');
switch(method){
case "facebook":
if(getPlatform() == 'm'){
window.location.href = "http://www.facebook.com/sharer/sharer.php?src=bm&u="+encodeURIComponent(shareLink);
}else{
window.open('http://www.facebook.com/sharer/sharer.php?src=bm&u='+encodeURIComponent(shareLink)+'','_blank','scrollbars=no,left=75,top=75,status=no,resizable=yes,width=600px,height=500px');
}
break;
case "twitter":
if(getPlatform() == 'm'){
window.location.href = 'http://twitter.com/intent/tweet?status='+encodeURIComponent(shareTitle+" "+shareLink);
}else{
window.open('http://twitter.com/intent/tweet?status='+encodeURIComponent(shareTitle+" "+shareLink)+'','_blank','scrollbars=no,left=75,top=75,status=no,resizable=yes,width=600px,height=500px');
}
break;
case "weibo":
if(getPlatform() == 'm'){
window.location.href = 'http://service.weibo.com/share/share.php?title='+encodeURIComponent(shareTitle)+'&url='+encodeURIComponent(shareLink)+'&pic='+encodeURIComponent(sharePic)+'&searchPic=false&style=simple';
}else{
window.open('http://service.weibo.com/share/share.php?title='+encodeURIComponent(shareTitle)+'&url='+encodeURIComponent(shareLink)+'&pic='+encodeURIComponent(sharePic)+'&searchPic=false&style=simple','_blank','scrollbars=no,left=75,top=75,status=no,resizable=yes,width=600px,height=500px');
}
break;
case "google-plus":
if(getPlatform() == 'm'){
window.location.href = 'https://plus.google.com/share?url='+encodeURIComponent(shareLink);
}else{
window.open('https://plus.google.com/share?url='+encodeURIComponent(shareLink),'_blank','scrollbars=no,left=75,top=75,status=no,resizable=yes,width=600px,height=500px');
}
break;
case "whatsapp":
if(getPlatform() == 'm'){
var message = encodeURIComponent(shareTitle) + " - " + encodeURIComponent(shareLink);
var whatsapp_url = "whatsapp://send?text=" + message;
window.location.href = whatsapp_url;
}
break;
case "email":
window.location.href = "mailto:?subject=[頭條網]"+shareTitle+"&body=更多內容請前往:"+shareLink;
break;
}
}
niceAlert(msg, callback)
function niceAlert(msg, callback){
// console.log('niceAlert');
if($('html').is('.ie6, .ie7, .ie8')){
alert(msg);
if(typeof callback != "undefined"){
window[callback]();
}
}else{
swal({
title : "",
text : msg,
type : "warning",
confirmButtonText:"確定",
showCancelButton: false,
closeOnConfirm: true
},function(){
if(typeof callback != "undefined"){
window[callback]();
}else{
swal.close();
}
});
//swal(msg);
}
}
setJWPlayerKey()
function setJWPlayerKey(){
//console.log('setJWPlayerKey');
if(typeof jwplayer != "undefined" && (typeof jwplayer.key == 'undefined' || jwplayer.key == "")){
// console.log('setJWPlayerKey in');
jwplayer.key = "aLH8/BW04AOQU1r35NIiHSs0uIOnxW4UiUETTQ==";
}
}
setupJWPlayer(elementID, videoPath)
function setupJWPlayer(elementID, videoPath){
//console.log('setupJWPlayer');
if(typeof jwplayer != "undefined" && elementID && videoPath){
// console.log('setupJWPlayer in');
setJWPlayerKey();
jwplayer(elementID).setup({
"file" : videoPath,
"width": "100%",
"mute" : true,
"aspectratio": "16:9",
"autostart":"true",
"controlbar": {
"position": "bottom"
},
"plugins": {
"gapro-2":{
"trackstarts": true,
"trackpercentage": true,
"trackseconds": true,
"tracktime": true
}
}
});
}
}
sendComscoreOnPlay(id, title, cat, streamComscore, length)
function sendComscoreOnPlay(id, title, cat, streamComscore, length){
var parsedLength = 0;
var clipType = 'vc11';
if(length === undefined) {
length = 0;
}
if(length != 0){
var lenArr = length.split(":");
var hour = parseInt(lenArr[0]) * 3600;
var minute = parseInt(lenArr[1]) * 60;
parsedLength = hour + minute + parseInt(lenArr[2]);
clipType = (parsedLength > 600)?'vc12':'vc11';
}
if(typeof streamComscore != 'undefined' && streamComscore != ""){
myStreamingTag = new ns_.ReducedRequirementsStreamingAnalytics();
//console.log('sendComscoreOnPlay in');
var clips = [{
ns_st_cn : 1, // The clip number
ns_st_ci : id, // video id
ns_st_pn : 1, // This is part (segment) 1 ...
ns_st_tp : 1, // ... of 1 parts in total
ns_st_cl : parsedLength, // Length of the stream (milliseconds)
ns_st_ct : clipType, // Clip Type (vc11 for less or equal to 10 minutes, vc12 for longer than 10 minutes)
//option value below
ns_st_ep : title, // title
nscustom_category : cat, // cat
ns_st_sn : '*null',
ns_st_en : '*null',
ns_st_ge : '*null',
ns_st_ti : '*null',
ns_st_ia : '*null',
ns_st_ce : '*null',
ns_st_ddt: '*null',
ns_st_tdt: '*null',
c3 : 'popnews'
}];
temp_clips = clips[0];
streamComscore.setClip(clips[0]);
streamComscore.notify(ns_.StreamSense.PlayerEvents.PLAY, {}, ((typeof this.currentTime != 'undefined')?this.currentTime:0));
// console.log("sop pvcp");
myStreamingTag.playVideoContentPart(clips[0], ns_.ReducedRequirementsStreamingAnalytics.ContentType.LongFormOnDemand);
}
}
reloadPageAfterTime()
function reloadPageAfterTime(){
//console.log('reloadPageAfterTime');
if(typeof reloadPageTimeInterval != 'undefined'){
// console.log('reloadPageAfterTime in');
setInterval(function(){window.location.href=window.location.href;}, reloadPageTimeInterval);
}
}
updatePopnewsVideoHitCount(data)
function updatePopnewsVideoHitCount(data){
// console.log('updatePopnewsVideoHitCount');
if(typeof statHitcountSeverRoot != "undefined" && statHitcountSeverRoot != ""){
$.get(statHitcountSeverRoot+'video/update_hitrate.php', data, function(response){});
}
}
initJWPlayerWithPopnewsId()
function initJWPlayerWithPopnewsId(){
//console.log('initJWPlayerWithPopnewsId');
if(typeof popnewsVideoID != 'undefined' && popnewsVideoID != ""){
// console.log('initJWPlayerWithPopnewsId in');
if((typeof streamComscore == 'undefined' || streamComscore == "") && typeof ns_ != "undefined"){
comscoreBasesiteUrlInews = 'http://b.scorecardresearch.com/p?c1=2&c2=9053246&ns_site=news&ns_vsite=headline';
streamComscore = new ns_.StreamSense({}, comscoreBasesiteUrlInews);
}
var userAgent = encodeURIComponent(navigator.userAgent);
$.ajax({
method : "GET",
url : popnewsWebRoot+"api/queryAPI.php?vid="+popnewsVideoID,
dateType : "json",
success:function(data){
if(typeof data[0]['u'] != "undefined" && data[0]['u'] != ""){
sendComscoreOnPlay(data[0]['i'], data[0]['t'], data[0]['k'], streamComscore, data[0]['len']);
updatePopnewsVideoHitCount({'n':'hl','m':'s','t':'w','l':'instantnewsDetail.php','u':userAgent,'id':data[0]['i'],'c':data[0]['k']});
setupJWPlayer("mediaplayer1", videoHttpSourceRoot+data[0]['u']+".mp4");
}
}
});
}
}
initJWPlayerWithInewsVideo()
function initJWPlayerWithInewsVideo(){
//console.log('initJWPlayerWithInewsVideo');
if(typeof inewsVideoPath != 'undefined'){
// console.log('initJWPlayerWithInewsVideo in');
if((typeof streamComscore2 == 'undefined' || streamComscore2 == "") && typeof ns_ != "undefined"){
comscoreBasesiteUrlInews = 'http://b.scorecardresearch.com/p?c1=2&c2=9053246&ns_site=news&ns_vsite=headline';
streamComscore2 = new ns_.StreamSense({}, comscoreBasesiteUrlInews);
}
sendComscoreOnPlay(newsID, newsTitle, newsCat, streamComscore2);
setupJWPlayer("mediaplayer2", inewsVideoPath);
}
}
comScoreBtnClick()
function comScoreBtnClick(){
console.log('comScoreBtnClick start');
console.log('pp_enable_1: '+document.getElementById("shk").value);
var pp_enable = document.getElementById("shk").value;
var comScoreBtn = '';
var ns_type='';
var ns_site='';
//var ns_vsite='&ns_vsite=headline';
var ns_btn = '';
var ad_hd_sg = '';
// if (sn_btn!=''){comScoreBtn=comScoreBtn+'&sn_btn='+sn_btn; }
// if (btn_name!=''){comScoreBtn=comScoreBtn+'&btn_name='+btn_name; }
// if (btn_search!=''){comScoreBtn=comScoreBtn+'&btn_search='+btn_search; }
if (pp_enable==1){
console.log('pp_enable_2: '+document.getElementById("shk").value);
ns_site= "&ns_site=news";
ns_type = "&ns_type=hidden";
ns_btn = "&ns_btn=ad_hl_sg";
}
console.log('comScoreC2: '+comScoreC2);
udm_('http'+(document.location.href.charAt(4)=='s'?'s://sb':'://b')+'.scorecardresearch.com/b?c1=2'+comScoreC2+ns_site+comScoreNsVsite+comScoreProduct+comScoreBtn+ns_type+ns_btn);
}
comScoreBtnClickAd()
function comScoreBtnClickAd(){
var pp_enable = document.getElementById("shk").value;
console.log(pp_enable);
var comScoreBtn = '';
var ad_shk='ad_shk_p';
var ns_type='';
var ns_btn = '';
ns_type = "&ns_type=hidden";
ns_btn = "&ns_btn=ad_shk_p";
udm_('http'+(document.location.href.charAt(4)=='s'?'s://sb':'://b')+'.scorecardresearch.com/b?c1=2'+comScoreC2+comScoreNsSite+comScoreNsVsite+comScoreProduct+ns_type+ns_btn);
}
comScoreBtnClickVAd()
function comScoreBtnClickVAd(){
var pp_enable = document.getElementById("shk").value;
console.log(pp_enable);
var comScoreBtn = '';
var ad_shk='ad_shk_v';
var ns_type='';
var ns_btn = '';
ns_type = "&ns_type=hidden";
ns_btn = "&ns_btn=ad_shk_v";
udm_('http'+(document.location.href.charAt(4)=='s'?'s://sb':'://b')+'.scorecardresearch.com/b?c1=2'+comScoreC2+comScoreNsSite+comScoreNsVsite+comScoreProduct+ns_type+ns_btn);
}
comScoreView()
function comScoreView(){
var pp_enable = document.getElementById("shk").value;
console.log(pp_enable);
var comScoreBtn = '';
var ad_shk='ad_shk_pv';
var ns_type='';
var ns_btn = '';
ns_btn = "&ns_pview=ad_shk_pv";
udm_('http'+(document.location.href.charAt(4)=='s'?'s://sb':'://b')+'.scorecardresearch.com/b?c1=2'+comScoreC2+comScoreNsSite+comScoreNsVsite+comScoreProduct+ns_type+ns_btn);
}
comScoreVView()
function comScoreVView(){
var pp_enable = document.getElementById("shk").value;
console.log(pp_enable);
var comScoreBtn = '';
var ad_shk='ad_shk_vv';
var ns_type='';
var ns_btn = '';
ns_btn = "&ns_pview=ad_shk_vv";
udm_('http'+(document.location.href.charAt(4)=='s'?'s://sb':'://b')+'.scorecardresearch.com/b?c1=2'+comScoreC2+comScoreNsSite+comScoreNsVsite+comScoreProduct+ns_type+ns_btn);
}
initAdWithJWPlayer()
function initAdWithJWPlayer(){
if(typeof jwplayer != 'undefined' && typeof $('#indexPageAdMediaplayer').attr('rel') != 'undefined'){
var phpScriptPath = 'index';
var userAgent = encodeURIComponent(navigator.userAgent);
setJWPlayerKey();
var videoAdLink = $('#indexPageAdMediaplayer').attr('rel');
jwplayer("indexPageAdMediaplayer").setup({
"file" : videoAdLink,
"width": "100%",
"mute" : true,
"aspectratio": "300:168",
"autostart":"true",
"controls": false,
"repeat": true,
"plugins": {
"gapro-2":{
"trackstarts": true,
"trackpercentage": true,
"trackseconds": true,
"tracktime": true
}
},
"events": {
onComplete: function(event) {
if(this.getRenderingMode()=="flash"){
this.load([{file:"mp4:"+videoPathArray[videoPlaySequence]+".mp4", streamer: videoWowzaStreamer,provider: "rtmp"}]);
}else {
this.load([{file:videoHttpSourceRoot+videoPathArray[videoPlaySequence]+".mp4"}]);
}
if (navigator.userAgent.indexOf('Chrome') != -1 || navigator.platform.indexOf("iPhone") != -1|| navigator.platform.indexOf("iPad") != -1|| navigator.platform.indexOf("iPod") != -1|| navigator.userAgent.toLowerCase().indexOf("android") != -1){
this.play(true);//play straight
}else{
this.play(true);
}
},
onReady: function(event) {
comScoreVView();
$('.indexPageAdMediaplayer_info').click(function(){
comScoreBtnClickVAd();
});
$('#indexPageAdMediaplayer .jwmain').css({'cursor': 'default'});
$('#indexPageAdMediaplayer').hover(function(){
jwplayer("indexPageAdMediaplayer").setMute(false);
jwplayer("indexPageAdMediaplayer").setVolume(80);
if (jwplayer("indexPageAdMediaplayer").getMute()){
$('.indexPageAdMediaplayer_volumn img').attr('src','/images/adBanners/volume-icon-mute.png');
}else{
$('.indexPageAdMediaplayer_volumn img').attr('src','/images/adBanners/volume-icon.png');
}
}, function(){
jwplayer("indexPageAdMediaplayer").setMute(true);
if (jwplayer("indexPageAdMediaplayer").getMute()){
$('.indexPageAdMediaplayer_volumn img').attr('src','/images/adBanners/volume-icon-mute.png');
}else{
$('.indexPageAdMediaplayer_volumn img').attr('src','/images/adBanners/volume-icon.png');
}
});
$('.indexPageAdMediaplayer_volumn').click(function(e){
e.preventDefault();
jwplayer("indexPageAdMediaplayer").setMute(!jwplayer("indexPageAdMediaplayer").getMute());
if (jwplayer("indexPageAdMediaplayer").getMute()){
$('.indexPageAdMediaplayer_volumn img').attr('src','/images/adBanners/volume-icon-mute.png');
}else{
$('.indexPageAdMediaplayer_volumn img').attr('src','/images/adBanners/volume-icon.png');
}
});
$('.indexPageAdMediaplayer_play').click(function(e){
e.preventDefault();
if (jwplayer("indexPageAdMediaplayer").getState() == "PLAYING"){
jwplayer("indexPageAdMediaplayer").pause();
} else {
jwplayer("indexPageAdMediaplayer").play();
}
});
},
onDisplayClick: function(event) {
// window.open('http://www.google.com.hk/', '_blank');
}
}
});
}
}
initIndexPageJWPlayer()
function initIndexPageJWPlayer(){
//console.log('initIndexPageJWPlayer');
if(typeof popnewsPlayListData != 'undefined' && popnewsPlayListData != ""){
// console.log('initIndexPageJWPlayer in');
var videoPathArray = [];
var videoTitleArray= [];
var videoIdArray= [];
var videoCatArray= [];
var videoTypeArray= [];
var videoLengthArray= [];
var phpScriptPath = 'index';
var userAgent = encodeURIComponent(navigator.userAgent);
for(var k in popnewsPlayListData){
videoPathArray[k] = popnewsPlayListData[k]['video'];
videoTitleArray[k] = popnewsPlayListData[k]['title'];
videoIdArray[k] = popnewsPlayListData[k]['id'];
videoCatArray[k] = popnewsPlayListData[k]['rCat'];
videoTypeArray[k] = popnewsPlayListData[k]['type'];
videoLengthArray[k] = popnewsPlayListData[k]['length'];
}
if((typeof streamComscore == 'undefined' || streamComscore == "") && typeof ns_ != "undefined"){
streamComscore = new ns_.StreamSense({}, comscoreBasesiteUrl);
}
// @video comScore
sendComscoreOnPlay(videoIdArray[videoPlaySequence], videoTitleArray[videoPlaySequence], videoCatArray[videoPlaySequence], streamComscore, videoLengthArray[videoPlaySequence]);
updatePopnewsVideoHitCount({'n':'hl','m':'s','t':'w','l':phpScriptPath,'u':userAgent,'id':videoIdArray[videoPlaySequence],'c':videoCatArray[videoPlaySequence], 'type':videoTypeArray[videoPlaySequence]});
setJWPlayerKey();
jwplayer("indexPageMediaplayer").setup({
"file" : videoHttpSourceRoot+videoPathArray[0]+".mp4",
"width": "100%",
"mute" : true,
"aspectratio": "16:9",
"autostart":"true",
"controlbar": {
"position": "bottom"
},
"plugins": {
"gapro-2":{
"trackstarts": true,
"trackpercentage": true,
"trackseconds": true,
"tracktime": true
}
},
"events": {
onPlay: function() {
if((typeof myStreamingTag != 'undefined' && myStreamingTag != "") && typeof ns_ != "undefined"){
// console.log("opl");
myStreamingTag.playVideoContentPart(temp_clips, ns_.ReducedRequirementsStreamingAnalytics.ContentType.LongFormOnDemand);
}
},
onPause: function() {
if((typeof myStreamingTag != 'undefined' && myStreamingTag != "") && typeof ns_ != "undefined"){
// console.log("ost");
myStreamingTag.stop();
}
},
onComplete: function(event) {
// @video comScore
if(typeof streamComscore != 'undefined' && streamComscore != ""){
streamComscore.notify(ns_.StreamSense.PlayerEvents.END, {}, ((typeof this.currentTime != 'undefined')?this.currentTime:0));
}
if(videoPlaySequence<videoPathArray.length-1){
videoPlaySequence=videoPlaySequence+1;
}else{
videoPlaySequence = 0;
}
if(this.getRenderingMode()=="flash"){
this.load([{file:"mp4:"+videoPathArray[videoPlaySequence]+".mp4", streamer: videoWowzaStreamer,provider: "rtmp"}]);
}else {
this.load([{file:videoHttpSourceRoot+videoPathArray[videoPlaySequence]+".mp4"}]);
}
$("#videoTitle").html(videoTitleArray[videoPlaySequence]);
$("#videoTitle").attr("href", popnewsWebRoot+"content.php?vid="+videoIdArray[videoPlaySequence]+"&cat="+videoCatArray[videoPlaySequence])
$(".videolist").removeClass("playing");
$("#video_"+videoIdArray[videoPlaySequence]).addClass("playing");
if(videoPlaySequence == 0 || videoPlaySequence == 2){
//popnewsPlayingChangFor1024($('.body-content').find('.main > .container').width());
}
if (navigator.userAgent.indexOf('Chrome') != -1 || navigator.platform.indexOf("iPhone") != -1|| navigator.platform.indexOf("iPad") != -1|| navigator.platform.indexOf("iPod") != -1|| navigator.userAgent.toLowerCase().indexOf("android") != -1){
this.play(true);//play straight
}else{
this.play(true);
}
// @video comScore
sendComscoreOnPlay(videoIdArray[videoPlaySequence], videoTitleArray[videoPlaySequence], videoCatArray[videoPlaySequence], streamComscore, videoLengthArray[videoPlaySequence]);
updatePopnewsVideoHitCount({'n':'hl','m':'s','t':'w','l':phpScriptPath,'u':userAgent,'id':videoIdArray[videoPlaySequence],'c':videoCatArray[videoPlaySequence], 'type':videoTypeArray[videoPlaySequence]});
}
}
});
}
}
initBselect()
function initBselect(){
//console.log('initBselect');
if($(".bselect").length>0 && typeof $(".bselect").bselect != 'undefined'){
// console.log('initBselect in');
$(".bselect").bselect({
"placeholder":"專欄名稱"
});
}
}
initSiteLoadingAnimsition()
function initSiteLoadingAnimsition(){
//console.log('initSiteLoadingAnimsition');
if($(".animsition").length>0 && typeof $(".animsition").animsition != 'undefined'){
// console.log('initSiteLoadingAnimsition in');
$(".animsition").animsition({
inClass : 'fade-in',
outClass : 'fade-out',
inDuration : 10,
outDuration : 10,
linkElement : '.animsition-link',
loading : true,
loadingParentElement : 'body',
loadingClass : 'animsition-loading',
unSupportCss : [ 'animation-duration',
'-webkit-animation-duration',
'-o-animation-duration'
],
overlay : false,
overlayClass : 'animsition-overlay-slide',
overlayParentElement : 'body'
});
}
}
initFancybox()
function initFancybox(){
//console.log('initFancybox');
if($(".fancybox").length>0 && typeof $(".fancybox").fancybox != 'undefined'){
// console.log('initFancybox in');
$(".fancybox").fancybox();
}
$('.this-detail-carousel').css('visibility',"visible");
}
addSearchFromSubmitEvents()
function addSearchFromSubmitEvents(){
// console.log('addSearchFromSubmitEvents');
$("#fullTextSeachFrom").submit(function(){
if($("#fullTextSearchKeyword").val() == ""){
var msg = "請輸入搜索關鍵字!";
niceAlert(msg);
return false;
}else{
return true;
}
});
}
//function initFastClick(){
// console.log('initFastClick');
//if(typeof FastClick != "undefined" && getPlatform() == 'm'){
// console.log('initFastClick in');
//FastClick.attach(document.body);
//}
//}
loadOtherColumnNews()
function loadOtherColumnNews(){
// console.log('loadOtherColumnNews');
countPage++;
$("#but-more-news").addClass("hidden");
$("#but-more-news-loading").removeClass("hidden");
$.ajax({
url:"/ajax/getMoreColumnistNewsOnList.php?cid="+columnistID+"&page="+countPage,
dataType:"html",
success:function(data) {
if(data != "" && data != "nomore"){
$("#detailList").append(data);
$("#but-more-news").removeClass("hidden");
$("#but-more-news-loading").addClass("hidden");
$('.search-blog').removeClass('affix-bottom').addClass('affix').css('top','auto');
}else if(data == 'nomore'){
$("#but-more-news").addClass("hidden");
$("#but-more-news-loading").addClass("hidden");
}
}
}).error(function() {
$("#but-more-news").removeClass("hidden");
$("#but-more-news-loading").addClass("hidden");
});
}
loadOtherNewestColumnNews()
function loadOtherNewestColumnNews(){
// console.log('loadOtherNewestColumnNews');
$("#but-more-colunm-newest").addClass("hidden");
$("#but-more-colunm-newest-loading").removeClass("hidden");
newestColumnNewsGroup++;
$(".column-newest-"+newestColumnNewsGroup).removeClass("hidden");
if($(".column-newest-"+newestColumnNewsGroup).length == newsPrePageOnList){
$("#but-more-colunm-newest").removeClass("hidden");
$("#but-more-colunm-newest-loading").addClass("hidden");
}else{
$("#but-more-colunm-newest").addClass("hidden");
$("#but-more-colunm-newest-loading").addClass("hidden");
}
}
loadOtherDailyNews()
function loadOtherDailyNews(){
console.log("cp: " + countPage);
$("#but-more-news").addClass("hidden");
$("#but-more-news-loading").removeClass("hidden");
$.ajax({
url:"/ajax/getMoreDailyNewsOnList.php?cid="+categoryID+"&page="+countPage,
dataType:"html",
success:function(data) {
if(data != "" && data != "nomore"){
$("#detailList").append(data);
$("#but-more-news").removeClass("hidden");
$("#but-more-news-loading").addClass("hidden");
$('.search-blog').removeClass('affix-bottom').addClass('affix').css('top','auto');
}else if(data == 'nomore'){
$("#but-more-news").addClass("hidden");
$("#but-more-news-loading").addClass("hidden");
}
}
}).error(function() {
$("#but-more-news").removeClass("hidden");
$("#but-more-news-loading").addClass("hidden");
});
countPage++;
}
loadOtherInstantNews()
function loadOtherInstantNews(){
$("#but-more-news").addClass("hidden");
$("#but-more-news-loading").removeClass("hidden");
$.ajax({
url:"/ajax/getMoreInstantNewsOnList.php?cid="+categoryID+"&page="+countPage,
dataType:"html",
success:function(data) {
if(data != "" && data != "nomore"){
$("#detailList").append(data);
$("#but-more-news").removeClass("hidden");
$("#but-more-news-loading").addClass("hidden");
$('.search-blog').removeClass('affix-bottom').addClass('affix').css('top','auto');
}else if(data == 'nomore'){
$("#but-more-news").addClass("hidden");
$("#but-more-news-loading").addClass("hidden");
}
}
}).error(function() {
$("#but-more-news").removeClass("hidden");
$("#but-more-news-loading").addClass("hidden");
});
countPage++;
}
loadOtherPhotoNews(page)
function loadOtherPhotoNews(page){
// console.log('loadOtherPhotoNews');
$(".photo-news-page").hide();
$('.photo-news-page-'+page).show();
countPage = page;
createPhotoNewsPageBar()
}
createPhotoNewsPageBar()
function createPhotoNewsPageBar(){
//console.log('createPhotoNewsPageBar');
if($("#photonews-pagebar").length>0){
// console.log('createPhotoNewsPageBar in');
var pageshown = 9;
var maxPage = Math.ceil(newsTotal/photonewsListNewsPrePage);
var nav = "";
var prev = "";
var next = "";
if(countPage > maxPage){
countPage = maxPage;
}
var pagelimit = (pageshown - 1) / 2;
var pagemax = pageshown > maxPage ? maxPage : pageshown;
if(countPage - pagelimit < 1){
pagemin = 1;
}
if(countPage - pagelimit >= 1 && countPage + pagelimit <= maxPage){
pagemin = Math.ceil(countPage - pagelimit);
pagemax = Math.ceil(countPage + pagelimit);
}
if(countPage - pagelimit >= 1 && countPage + pagelimit > maxPage){
pagemin = (maxPage - pageshown + 1) < 1 ? 1 : Math.ceil((maxPage-pageshown + 1));
pagemax = Math.ceil(maxPage);
}
if(countPage + pagelimit > maxPage){
pagemax = Math.ceil(maxPage);
}
for(var display_page = pagemin; display_page <= pagemax; display_page++){
if (display_page == countPage){
nav+= '<li class="active"><a href="javascript: void(0);">'+display_page+'</a></li>';
}else{
nav+= '<li><a href="javascript: loadOtherPhotoNews('+Math.floor(display_page)+')">'+Math.floor(display_page)+'</a></li>';
}
}
if(countPage > 1){
prev = '<li><a href="javascript: loadOtherPhotoNews('+(countPage - 1)+');" aria-label="Previous"><span aria-hidden="true">«</span></a></li>';
}else{
prev = '<li class="disabled"><a href="javascript: void(0);" aria-label="Previous"><span aria-hidden="true">«</span></a></li>';
}
if(countPage < maxPage){
next = '<li><a href="javascript: loadOtherPhotoNews('+(countPage + 1)+');" aria-label="Next"><span aria-hidden="true">»</span></a></li>';
}else{
next = '<li class="disabled"><a href="javascript: void(0);" aria-label="Next"><span aria-hidden="true">»</span></a></li>';
}
$("#photonews-pagebar").html('<nav class="text-center"><ul class="pagination">'+prev+nav+next+'</ul></nav>');
}
}
checkUniqueOnchange(type, element, original)
function checkUniqueOnchange(type, element, original){
if($(element).val()!=""){
var isUnique = checkUnique(type, $(element).val());
if(isUnique == 2){
niceAlert("服務繁忙,請稍後再試");
}else if(isUnique == 0){
var field = "";
if(type == "username"){
field = "用戶名";
}else if(type == "nickname"){
field = "昵稱";
}else if(type == "email"){
field = "電郵地址";
}
if(typeof original != "undefined" && original != ""){
if($(element).val() != original){
if(field){
$(element).val(original);
niceAlert("該"+field+"已經存在,請輸入其他"+field);
}
}
}else{
if(field){
$(element).val("");
niceAlert("該"+field+"已經存在,請輸入其他"+field);
}
}
}
}
}
checkUnique(field, value)
function checkUnique(field, value){
var returnVal = 0;
$.ajax({
type: "GET",
url: "/ajax/memberCheckUniqueApi.php?field="+field+"&value="+value,
async: false,
error: function(request) {
returnVal = 2;
},
success: function(data) {
if(data == '1'){
returnVal = 1;
}
}
});
return returnVal;
}
checkRegistrationForm(btn)
function checkRegistrationForm(btn){
var submitBtn = $(btn);
var noError = true;
var msg = "";
var element;
submitBtn.button('loading');
var isUsernameUnique = 2;
if($("input[name='username']").val() != ""){
isUsernameUnique = checkUnique("username", $("input[name='username']").val());
}
var isNicknameUnique = 2;
if($("input[name='nickname']").val() != ""){
isNicknameUnique = checkUnique("nickname", $("input[name='nickname']").val());
}
var isEmailUnique = 2;
if($("input[name='email']").val() != ""){
isEmailUnique = checkUnique("email", $("input[name='email']").val());
}
if(noError && $("input[name='username']").val() == ""){
noError = false;
msg = textPlsInputUsername;
element = $("input[name='username']");
}else if(noError && !(usernameExp.test($("input[name='username']").val()))){
noError = false;
msg = textInvalidateUsername;
element = $("input[name='username']");
}else if(noError && isUsernameUnique == 2){
noError = false;
msg = "登入名稱驗證失敗,請稍後再試";
element = $("input[name='username']");
}else if(noError && isUsernameUnique == 0){
noError = false;
msg = "登入名稱已存在,請重新輸入";
element = $("input[name='username']");
}else if(noError && $("input[name='nickname']").val() == ""){
noError = false;
msg = textPlsInputNickname;
element = $("input[name='nickname']");
}else if(noError && isNicknameUnique == 2){
noError = false;
msg = "昵稱驗證失敗,請稍後再試";
element = $("input[name='nickname']");
}else if(noError && isNicknameUnique == 0){
noError = false;
msg = "昵稱已存在,請重新輸入";
element = $("input[name='username']");
}else if(noError && $("input[name='password']").val() == ""){
noError = false;
msg = textPlsInputPassword;
element = $("input[name='password']");
}else if(noError && $("input[name='password']").val().length < 6){
noError = false;
msg = textShortPassword;
element = $("input[name='password']");
}else if(noError && $("input[name='passwordt']").val() == ""){
noError = false;
msg = "請再次輸入密碼";
element = $("input[name='passwordt']");
}else if(noError && $("input[name='password']").val() != $("input[name='passwordt']").val()){
noError = false;
msg = textPasswordNotSame;
element = $("input[name='passwordt']");
}else if(noError && $("input[name='email']").val() == ""){
noError = false;
msg = textPlsInputEmail;
element = $("input[name='email']");
}else if(noError && !(emailExp.test($("input[name='email']").val()))){
noError = false;
msg = textInvalidateEmail;
element = $("input[name='email']");
}else if(noError && $("input[name='email']").val().length>50){
noError = false;
msg = textLongEmail;
element = $("input[name='email']");
}else if(noError && isEmailUnique == 2){
noError = false;
msg = textFailVerifyEmail;
element = $("input[name='email']");
}else if(noError && isEmailUnique == 0){
noError = false;
msg = textEmailExsists;
element = $("input[name='email']");
}else if(noError && $("input[name='last_name']").val() == ""){
noError = false;
msg = textPlsInputFirstname;
element = $("input[name='last_name']");
}else if(noError && $("input[name='first_name']").val() == ""){
noError = false;
msg = textPlsInputLastname;
element = $("input[name='first_name']");
}else if($("input[name='sex']:checked").length == 0){
noError = false;
msg = textPlsSelectSex;
element = $("input[name='sex']");
}else if(noError && $("input[name='mobile']").val() == ""){
noError = false;
msg = textPlsInputMobile;
element = $("input[name='mobile']");
}else if(noError && !(mobileExp.test($("input[name='mobile']").val()))){
noError = false;
msg = textPlsInputRightMobile;
element = $("input[name='mobile']");
}else if(noError && $("input[name='verified_policy_personal']:checked").length == 0){
noError = false;
msg = "請接受收集個人資料聲明";
element = $("input[name='verified_policy_personal']");
}else if(noError && $("input[name='verified_policy_terms']:checked").length == 0){
noError = false;
msg = "請接受頭條網會員使用條款及私隱政策聲明";
element = $("input[name='verified_policy_terms']");
}else if(noError && $("input[name='captchCode']").val() == ""){
noError = false;
msg = textPlsInputCaptureCode;
element = $("input[name='captchCode']");
}
if(noError){
$.ajax({
type: "POST",
url: "/ajax/memberRegistrationApi.php",
async: false,
datatype: 'json',
data:$('#registration').serialize(),
error: function(request) {
refreshCaptcha();
submitBtn.button('reset');
niceAlert(textServerBusy);
},
success: function(data) {
data = JSON.parse(data)
// console.log(data);
if(typeof data['status'] == "undefined"){
refreshCaptcha();
niceAlert(textServerBusy);
}else{
if(data['status'] == 'fail'){
refreshCaptcha();
niceAlert(data['error']);
}else{
//$.ajax({
// type: "POST",
// url: "http://hd.stheadline.com/membership/addregistration.asp",
// data:$('#registration').serialize(),
// error: function(request) {
// },
// success: function(data) {
// console.log(data);
// }
//});
niceAlert("登記已成功,請閣下登入登記電郵查看激活郵件以完成會員登記.", "gotoLoginPage");
}
}
submitBtn.button('reset');
}
});
}else{
refreshCaptcha();
element.focus();
niceAlert(msg);
submitBtn.button('reset');
}
}
gotoLoginPage()
function gotoLoginPage(){
window.location.href = "/member/login/";
}
login(btn)
function login(btn){
var submitBtn = $(btn);
var noError = true;
var msg = "";
var element;
submitBtn.button('loading');
if(noError && $("input[name='username']").val() == ""){
noError = false;
msg = textPlsInputUsername;
element = $("input[name='username']");
}else if(noError && !(usernameExp.test($("input[name='username']").val()))){
noError = false;
msg = textInvalidateUsername;
element = $("input[name='username']");
}else if(noError && $("input[name='password']").val() == ""){
noError = false;
msg = textPlsInputPassword;
element = $("input[name='password']");
}else if(noError && $("input[name='password']").val().length < 6){
noError = false;
msg = textShortPassword;
element = $("input[name='password']");
}
if(noError){
$.ajax({
type: "POST",
url: "/ajax/memberLoginApi.php",
async: false,
data:$('#login').serialize(),
error: function(request) {
submitBtn.button('reset');
niceAlert(textServerBusy);
},
success: function(data) {
//console.log(data);
data = JSON.parse(data)
if(typeof data['status'] == "undefined"){
niceAlert(textServerBusy);
}else{
if(data['status'] == 'fail'){
niceAlert(data['error']);
}else{
$("#login").attr("action", window.location.protocol + "//hd.stheadline.com/login_tester.php");
$("#login").attr("target", "_top");
$("#login").attr("method", "post");
$("#login").submit();
}
}
submitBtn.button('reset');
}
});
}else{
submitBtn.button('reset');
element.focus();
niceAlert(msg);
}
}
refreshCaptcha()
function refreshCaptcha(){
$("input[name='captchCode']").val("");
var img = document.images['captchaimg'];
img.src = img.src.substring(0,img.src.lastIndexOf("?"))+"?rand="+Math.random()*1000;
}
sendPasswordEmail(btn)
function sendPasswordEmail(btn){
var submitBtn = $(btn);
var noError = true;
var msg = "";
var element;
submitBtn.button('loading');
var isEmailUnique = 2;
if($("input[name='email']").val() != ""){
isEmailUnique = checkUnique("email", $("input[name='email']").val());
}
if(noError && $("input[name='email']").val() == ""){
noError = false;
msg = textPlsInputEmail;
element = $("input[name='email']");
}else if(noError && !(emailExp.test($("input[name='email']").val()))){
noError = false;
msg = textInvalidateEmail;
element = $("input[name='email']");
}else if(noError && $("input[name='email']").val().length>50){
noError = false;
msg = textLongEmail;
element = $("input[name='email']");
}else if(noError && isEmailUnique == 2){
noError = false;
msg = textFailVerifyEmail;
element = $("input[name='email']");
}else if(noError && isEmailUnique == 1){
noError = false;
msg = "該電郵地址不存在,請重新輸入";
element = $("input[name='email']");
}else if(noError && $("input[name='captchCode']").val() == ""){
noError = false;
msg = textPlsInputCaptureCode;
element = $("input[name='captchCode']");
}
if(noError){
$.ajax({
type: "POST",
url: "/ajax/memberForgetPasswordApi.php",
async: false,
datatype: 'json',
data:$('#fpassword').serialize(),
error: function(request) {
refreshCaptcha();
submitBtn.button('reset');
niceAlert(textServerBusy);
},
success: function(data) {
data = JSON.parse(data)
// console.log(data);
if(typeof data['status'] == "undefined"){
refreshCaptcha();
niceAlert(textServerBusy);
}else{
if(data['status'] == 'fail'){
refreshCaptcha();
niceAlert(data['error']);
}else{
niceAlert("密碼郵件已成功發送到閣下登記的電郵地址, 請查收.", "gotoLoginPage");
}
}
submitBtn.button('reset');
}
});
}else{
refreshCaptcha();
element.focus();
niceAlert(msg);
submitBtn.button('reset');
}
}
getActivateEmailPrev()
function getActivateEmailPrev(){
$(".step2").addClass("hidden");
$(".step1").removeClass("hidden");
}
getActivateEmailNext(btn)
function getActivateEmailNext(btn){
var submitBtn = $(btn);
var noError = true;
var msg = "";
var element;
submitBtn.button('loading');
if(noError && $("input[name='username']").val() == ""){
noError = false;
msg = textPlsInputUsername;
element = $("input[name='username']");
}else if(noError && !(usernameExp.test($("input[name='username']").val()))){
noError = false;
msg = textInvalidateUsername;
element = $("input[name='username']");
}else if(noError && $("input[name='password']").val() == ""){
noError = false;
msg = textPlsInputPassword;
element = $("input[name='password']");
}else if(noError && $("input[name='password']").val().length < 6){
noError = false;
msg = textShortPassword;
element = $("input[name='password']");
}
if(noError){
$.ajax({
type: "POST",
url: "/ajax/memberGetActivateEmailVerifiyApi.php",
async: false,
datatype: 'json',
data:$('#verifiyForm').serialize(),
error: function(request) {
submitBtn.button('reset');
niceAlert(textServerBusy);
},
success: function(data) {
data = JSON.parse(data)
// console.log(data);
if(typeof data['status'] == "undefined"){
niceAlert(textServerBusy);
}else{
if(data['status'] == 'fail'){
niceAlert(data['error']);
}else{
$(".step1").addClass("hidden");
$(".step2").removeClass("hidden");
}
}
submitBtn.button('reset');
}
});
}else{
submitBtn.button('reset');
element.focus();
niceAlert(msg);
}
}
resendActiveEmail(btn)
function resendActiveEmail(btn){
var submitBtn = $(btn);
submitBtn.button('loading');
$.ajax({
type: "GET",
url: "/ajax/memberResendActiveEmailApi.php",
async: false,
datatype: 'json',
error: function(request) {
submitBtn.button('reset');
niceAlert(textServerBusy);
},
success: function(data) {
data = JSON.parse(data)
// console.log(data);
if(typeof data['status'] == "undefined"){
niceAlert(textServerBusy);
}else{
if(data['status'] == 'fail'){
niceAlert(data['error']);
}else{
niceAlert("閣下的激活郵件已經發送,請登入閣下登記之郵箱以便激活.", "gotoLoginPage");
}
}
submitBtn.button('reset');
}
});
}
resetActiveEmail(btn)
function resetActiveEmail(btn){
var submitBtn = $(btn);
var noError = true;
var msg = "";
var element;
submitBtn.button('loading');
var isEmailUnique = 2;
if($("input[name='email']").val() != ""){
isEmailUnique = checkUnique("email", $("input[name='email']").val());
}
if(noError && $("input[name='email']").val() == ""){
noError = false;
msg = textPlsInputEmail;
element = $("input[name='email']");
}else if(noError && !(emailExp.test($("input[name='email']").val()))){
noError = false;
msg = textInvalidateEmail;
element = $("input[name='email']");
}else if(noError && $("input[name='email']").val().length>50){
noError = false;
msg = textLongEmail;
element = $("input[name='email']");
}else if(noError && isEmailUnique == 2){
noError = false;
msg = textFailVerifyEmail;
element = $("input[name='email']");
}else if(noError && isEmailUnique == 0){
noError = false;
msg = textEmailExsists;
element = $("input[name='email']");
}
if(noError){
$.ajax({
type: "POST",
url: "/ajax/memberResetActiveEmailApi.php",
async: false,
datatype: 'json',
data:$('#resetActiveEmailForm').serialize(),
error: function(request) {
submitBtn.button('reset');
niceAlert(textServerBusy);
},
success: function(data) {
data = JSON.parse(data)
// console.log(data);
if(typeof data['status'] == "undefined"){
niceAlert(textServerBusy);
}else{
if(data['status'] == 'fail'){
niceAlert(data['error']);
}else{
niceAlert("激活郵件已發送,請登入查看郵件以激活頭條網會員.", "gotoLoginPage");
}
}
submitBtn.button('reset');
}
});
}else{
submitBtn.button('reset');
element.focus();
niceAlert(msg);
}
}
logout()
function logout(){
$.ajax({
type: "GET",
url: "/ajax/memberLogoutApi_new.php",
async: false,
datatype: 'json',
error: function(request) {
niceAlert(textServerBusy);
},
success: function(data) {
//window.location.href = "/member/login/";
window.location.href = "http://hd.stheadline.com/membership/logout.asp";
}
});
}
updatePassword(radio)
function updatePassword(radio){
if($(radio).val() == "1"){
$("#changePasswordModel input").val("");
$("#changePasswordModel").removeClass("hidden");
}else{
$("#changePasswordModel input").val("");
$("#changePasswordModel").addClass("hidden");
}
}
checkProfileForm(btn)
function checkProfileForm(btn){
var submitBtn = $(btn);
var noError = true;
var msg = "";
var element;
submitBtn.button('loading');
var needsCheckPassword = false;
if($("input[name='changePassword']").val() == '1'){
needsCheckPassword = true;
}
if(noError && $("input[name='nickname']").val() == ""){
noError = false;
msg = textPlsInputNickname;
element = $("input[name='nickname']");
}else if(noError && needsCheckPassword && $("input[name='oldPassword']").val() == ""){
noError = false;
msg = "請輸入舊密碼";
element = $("input[name='oldPassword']");
}else if(noError && needsCheckPassword && $("input[name='oldPassword']").val().length < 6){
noError = false;
msg = "舊密碼長度不得小於6個字符";
element = $("input[name='oldPassword']");
}else if(noError && needsCheckPassword && $("input[name='newPassword']").val() == ""){
noError = false;
msg = "請輸入新密碼";
element = $("input[name='newPassword']");
}else if(noError && needsCheckPassword && $("input[name='newPassword']").val().length < 6){
noError = false;
msg = "新密碼長度不得小於6個字符";
element = $("input[name='newPassword']");
}else if(noError && needsCheckPassword && $("input[name='newPasswordAgain']").val() == ""){
noError = false;
msg = "請再次輸入新密碼";
element = $("input[name='newPasswordAgain']");
}else if(noError && needsCheckPassword && $("input[name='newPassword']").val() != $("input[name='newPasswordAgain']").val()){
noError = false;
msg = textPasswordNotSame;
element = $("input[name='newPasswordAgain']");
}else if(noError && $("input[name='email']").val() == ""){
noError = false;
msg = textPlsInputEmail;
element = $("input[name='email']");
}else if(noError && !(emailExp.test($("input[name='email']").val()))){
noError = false;
msg = textInvalidateEmail;
element = $("input[name='email']");
}else if(noError && $("input[name='email']").val().length>50){
noError = false;
msg = textLongEmail;
element = $("input[name='email']");
}else if(noError && $("input[name='last_name']").val() == ""){
noError = false;
msg = textPlsInputFirstname;
element = $("input[name='last_name']");
}else if(noError && $("input[name='first_name']").val() == ""){
noError = false;
msg = textPlsInputLastname;
element = $("input[name='first_name']");
}else if($("input[name='sex']:checked").length == 0){
noError = false;
msg = textPlsSelectSex;
element = $("input[name='sex']");
}else if(noError && $("input[name='mobile']").val() == ""){
noError = false;
msg = textPlsInputMobile;
element = $("input[name='mobile']");
}else if(noError && !(mobileExp.test($("input[name='mobile']").val()))){
noError = false;
msg = textPlsInputRightMobile;
element = $("input[name='mobile']");
}else if(noError && $("input[name='captchCode']").val() == ""){
noError = false;
msg = textPlsInputCaptureCode;
element = $("input[name='captchCode']");
}
if(noError){
$.ajax({
type: "POST",
url: "/ajax/memberEditProfileApi.php",
async: false,
datatype: 'json',
data:$('#profileForm').serialize(),
error: function(request) {
refreshCaptcha();
submitBtn.button('reset');
niceAlert(textServerBusy);
},
success: function(data) {
data = JSON.parse(data)
// console.log(data);
if(typeof data['status'] == "undefined"){
refreshCaptcha();
niceAlert(textServerBusy);
}else{
if(data['status'] == 'fail'){
refreshCaptcha();
niceAlert(data['error']);
}else{
niceAlert("更新成功", "resfreshPage");
}
}
submitBtn.button('reset');
}
});
}else{
refreshCaptcha();
element.focus();
niceAlert(msg);
submitBtn.button('reset');
}
}
resfreshPage()
function resfreshPage(){
window.location.href=window.location.href;
}
closeTrailerWindow()
function closeTrailerWindow(){
if(typeof jwplayer("trailerPlayer").getState() != "undefined"){
jwplayer("trailerPlayer").remove();
}
}
openTrailerWindow(src)
function openTrailerWindow(src){
$('#myModal-1').modal('show');
setJWPlayerKey();
jwplayer("trailerPlayer").setup({
"file" : src,
"width": "100%",
"mute" : true,
"autostart":true,
"primary" : "html5",
"fallback": false,
"controlbar": {
"position": "bottom"
},
"plugins": {
"gapro-2":{
"trackstarts": true,
"trackpercentage": true,
"trackseconds": true,
"tracktime": true
}
}
});
}
gameFormSubmit(btn, needLogin)
function gameFormSubmit(btn, needLogin){
var noError = true;
var msg = "";
var element;
var submitBtn = $(btn);
// submitBtn.button('loading');
if(noError && needLogin && $("#gamelogin input[name='username']").val() == ""){
noError = false;
msg = textPlsInputUsername;
element = $("#gamelogin input[name='username']");
}else if(noError && needLogin && !(usernameExp.test($("#gamelogin input[name='username']").val()))){
noError = false;
msg = textInvalidateUsername;
element = $("#gamelogin input[name='username']");
}else if(noError && needLogin && $("#gamelogin input[name='password']").val() == ""){
noError = false;
msg = textPlsInputPassword;
element = $("#gamelogin input[name='password']");
}else if(noError && needLogin && $("#gamelogin input[name='password']").val().length < 6){
noError = false;
msg = textShortPassword;
element = $("#gamelogin input[name='password']");
}
if(noError){
$(".questionItem").each(function(){
var questionID = $(this).find("input[name='questionID[]']").val();
var questionType = $(this).find("input[name='questionType[]']").val();
if(noError && questionType != '6'){
if(questionType == '1'){
if(noError && $(this).find("input[name='anwser"+questionID+"']:checked").length == 0){
noError = false;
msg = "請回答問題";
element = $(this).find("input[name='anwser"+questionID+"']");
}
}else if(questionType == '2'){
if(noError && $(this).find("input[name='anwser"+questionID+"[]']:checked").length == 0){
noError = false;
msg = "請回答問題";
element = $(this).find("input[name='anwser"+questionID+"[]']");
}
}else{
if(noError && $(this).find("input[name='anwser"+questionID+"']").val() == ""){
noError = false;
msg = "請回答問題";
element = $(this).find("input[name='anwser"+questionID+"']");
}
}
}
});
}
if(noError){
//var postData = new FormData($("#gameForm")[0]);
$.ajax({
type: "POST",
url: "/ajax/gameSubmitApi.php",
data: $("#gameForm").serialize(),
async: false,
cache: false,
//contentType: false,
processData: false,
error: function(request) {
submitBtn.button('reset');
niceAlert(textServerBusy);
},
success: function(data) {
data = JSON.parse(data)
// console.log(data);
if(typeof data['status'] == "undefined"){
niceAlert(textServerBusy);
}else{
if(data['status'] == 'fail'){
niceAlert(data['error']);
}else{
niceAlert("遞交成功, 多謝參加!", "resfreshPage");
}
}
submitBtn.button('reset');
}
});
}else{
element.focus();
niceAlert(msg);
}
}
initGamePage()
function initGamePage(){
if(typeof gameDetailPage != "undefined"){
if(isLogined){
if(isPlayOnce){
if(isPlayed){
$("fieldset").prop("disabled", true);
$(".notLogined").hide();
$(".logined").hide();
}else{
$(".notLogined").hide();
$(".played").hide();
}
}else{
$(".notLogined").hide();
$(".played").hide();
}
}else{
$(".logined").hide();
$(".played").hide();
}
}
}
showMobileElements()
function showMobileElements(){
if (getPlatform() == 'm'){
$('.mobile-element').show();
}
}
setMuteButtonForIOS(player)
function setMuteButtonForIOS(player){
var userAgent = encodeURIComponent(navigator.userAgent);
if (/iPad|iPhone|iPod/.test(userAgent) && !window.MSStream) {
var match = (navigator.appVersion).match(/OS (\d+)_(\d+)_?(\d+)?/);
var version = 0;
if (match !== undefined && match !== null) {
version = parseInt(match[1], 10);
}
player.getChild('controlBar').removeChild("VolumeMenuButton");
if(version>=10){
var Button = videojs.getComponent('Button');
var muteButton = videojs.extend(Button, {
constructor: function() {
Button.apply(this, arguments);
/* initialize your button */
if(player.muted()){
this.addClass('vjs-icon-volume-mute');
}else{
this.addClass('vjs-icon-volume-high');
}
this.controlText("muteButton");
},
handleClick: function() {
/* do something on click */
if(player.muted()||this.hasClass('vjs-icon-volume-mute')){
console.log("unmuted");
this.removeClass('vjs-icon-volume-mute').addClass('vjs-icon-volume-high');
player.muted(false);
}else if(!player.muted()||this.hasClass('vjs-icon-volume-high')){
console.log("muted");
this.removeClass('vjs-icon-volume-high').addClass('vjs-icon-volume-mute');
player.muted(true);
}
}
});
videojs.registerComponent('muteButton', muteButton);
player.getChild('controlBar').addChild('muteButton', {},2);
}
}
}
initIndexPageVideojs()
function initIndexPageVideojs(){
if(typeof popnewsPlayListData != 'undefined' && popnewsPlayListData != ""){
var videoPathArray = [];
var videoTitleArray= [];
var videoIdArray= [];
var videoCatArray= [];
var videoTypeArray= [];
var phpScriptPath = 'index';
var userAgent = encodeURIComponent(navigator.userAgent);
digitalData.page.video = {};
//console.log(popnewsPlayListData);
for(var k in popnewsPlayListData){
videoPathArray[k] = popnewsPlayListData[k]['video'];
videoTitleArray[k] = popnewsPlayListData[k]['title'];
videoIdArray[k] = popnewsPlayListData[k]['id'];
videoCatArray[k] = popnewsPlayListData[k]['rCat'];
videoTypeArray[k] = popnewsPlayListData[k]['type'];
}
if((typeof streamComscore == 'undefined' || streamComscore == "") && typeof ns_ != "undefined"){
streamComscore = new ns_.StreamSense({}, comscoreBasesiteUrl);
}
// @video comScore
sendComscoreOnPlay(videoIdArray[videoPlaySequence], videoTitleArray[videoPlaySequence], videoCatArray[videoPlaySequence], streamComscore);
updatePopnewsVideoHitCount({'n':'hl','m':'s','t':'w','l':phpScriptPath,'u':userAgent,'id':videoIdArray[videoPlaySequence],'c':videoCatArray[videoPlaySequence], 'type':videoTypeArray[videoPlaySequence]});
videojs("indexPageMediaplayer", {
"controls": true,
"autoplay": true,
"preload": "auto",
//"muted" :true,
"fluid": true,
controlBar: {
volumeMenuButton: {
inline: false,
vertical: true
}
},
"sources": [{
"src": videoHttpSourceRoot+videoPathArray[0]+".mp4",
"type": "video/mp4"
},{
"src": videoWowzaStreamer + "&mp4:"+ videoPathArray[0] + ".mp4",
"type": "rtmp/mp4"
}]
},function() {
var player = this;
player.muted(true);
setMuteButtonForIOS(player);
//this.controlBar.volumeMenuButton.show();
//this.bigPlayButton.hide();
var previousTime = 0;
var currentTime = 0;
var seekStart = null;
var duration = 0;
var perc = 0;
var reach25 = false;
var reach50 = false;
var reach75 = false;
var videoPlay = false;
digitalData.page.video.videoName = [videoTitleArray[videoPlaySequence]];
player.on('play', function() {
if(!videoPlay){
_satellite.track("video_started");
// console.log("video_started");
videoPlay = true;
}
});
player.on('timeupdate', function() {
previousTime = currentTime;
currentTime = player.currentTime();
duration = player.duration();
perc = (currentTime / duration * 100).toFixed(2);
if (Math.floor(perc) >= 25 && !reach25) {
// console.log("25% reached");
//_satellite.track("25_completed");
_satellite.track("video_25_completed");
reach25 = true;
}
if (Math.floor(perc) >= 50 && !reach50) {
// console.log("50% reached");
//_satellite.track("50_completed");
_satellite.track("video_50_completed");
reach50 = true;
}
if (Math.floor(perc) >= 75 && !reach75) {
// console.log("75% reached");
//_satellite.track("75_completed");
_satellite.track("video_75_completed");
reach75 = true;
}
});
player.on('seeking', function() {
if(seekStart === null) {
seekStart = previousTime;
}
});
player.on('seeked', function() {
console.log('seeked from', seekStart, 'to', currentTime, '; delta:', currentTime - previousTime);
seekStart = null;
});
player.on('ended', function() {
// console.log("100% reached");
_satellite.track("video_100_completed");
videoPlay = false;
// @video comScore
if(typeof streamComscore != 'undefined' && streamComscore != ""){
streamComscore.notify(ns_.StreamSense.PlayerEvents.END, {}, ((typeof this.currentTime != 'undefined')?this.currentTime:0));
}
if(videoPlaySequence<videoPathArray.length-1){
videoPlaySequence=videoPlaySequence+1;
}else{
videoPlaySequence = 0;
}
player.src([{
"src": videoHttpSourceRoot + videoPathArray[videoPlaySequence] + ".mp4",
"type": "video/mp4"
},{
"src": videoWowzaStreamer + "&mp4:"+ videoPathArray[videoPlaySequence] + ".mp4",
"type": "rtmp/mp4"
}]);
$("#videoTitle").html(videoTitleArray[videoPlaySequence]);
$("#videoTitle").attr("href", popnewsWebRoot+"content.php?vid="+videoIdArray[videoPlaySequence]+"&cat="+videoCatArray[videoPlaySequence]);
$("#videoTitle").attr("title", videoTitleArray[videoPlaySequence]);
$("#videoTitle").attr("alt", videoTitleArray[videoPlaySequence]);
$(".videolist").removeClass("playing");
$("#video_"+videoIdArray[videoPlaySequence]).addClass("playing");
if(videoPlaySequence == 0 || videoPlaySequence == 2){
//popnewsPlayingChangFor1024($('.body-content').find('.main > .container').width());
}
if (navigator.userAgent.indexOf('Chrome') != -1 || navigator.platform.indexOf("iPhone") != -1|| navigator.platform.indexOf("iPad") != -1|| navigator.platform.indexOf("iPod") != -1|| navigator.userAgent.toLowerCase().indexOf("android") != -1){
player.play();//play straight
}else{
player.play();
}
digitalData.page.video.videoName = [videoTitleArray[videoPlaySequence]];
//console.log(digitalData.page.video.videoName);
var previousTime = 0;
var currentTime = 0;
var seekStart = null;
var duration = 0;
var perc = 0;
var reach25 = false;
var reach50 = false;
var reach75 = false;
player.on('timeupdate', function() {
previousTime = currentTime;
currentTime = player.currentTime();
duration = player.duration();
perc = (currentTime / duration * 100).toFixed(2);
if (Math.floor(perc) >= 25 && !reach25) {
// console.log("25% reached");
//_satellite.track("25_completed");
_satellite.track("video_25_completed");
reach25 = true;
}
if (Math.floor(perc) >= 50 && !reach50) {
// console.log("50% reached");
//_satellite.track("50_completed");
_satellite.track("video_50_completed");
reach50 = true;
}
if (Math.floor(perc) >= 75 && !reach75) {
// console.log("75% reached");
//_satellite.track("75_completed");
_satellite.track("video_75_completed");
reach75 = true;
}
});
player.on('seeking', function() {
if(seekStart === null) {
seekStart = previousTime;
}
});
player.on('seeked', function() {
console.log('seeked from', seekStart, 'to', currentTime, '; delta:', currentTime - previousTime);
seekStart = null;
});
// @video comScore
sendComscoreOnPlay(videoIdArray[videoPlaySequence], videoTitleArray[videoPlaySequence], videoCatArray[videoPlaySequence], streamComscore);
updatePopnewsVideoHitCount({'n':'hl','m':'s','t':'w','l':phpScriptPath,'u':userAgent,'id':videoIdArray[videoPlaySequence],'c':videoCatArray[videoPlaySequence], 'type':videoTypeArray[videoPlaySequence]});
});
});
}
}
setupVideojs(elementID, videoPath)
function setupVideojs(elementID, videoPath){
digitalData.page.video = {};
digitalData.page.video.videoName = [$('meta[property="og:title"]').attr("content")];
if(typeof videojs != "undefined" && elementID && videoPath){
videojs(elementID, {
"controls": true,
"autoplay": true,
"preload": "auto",
//"muted" :true,
"fluid": true,
controlBar: {
volumeMenuButton: {
inline: false,
vertical: true
}
},
"sources": [{
"src": videoPath,
"type": "video/mp4"
}]
},
function()
function() {
//player.getChild('controlBar').children();
var player = this;
player.muted(true);
setMuteButtonForIOS(player);
var previousTime = 0;
var currentTime = 0;
var seekStart = null;
var duration = 0;
var perc = 0;
var reach25 = false;
var reach50 = false;
var reach75 = false;
var videoPlay = false;
player.on('play', function() {
if(!videoPlay){
_satellite.track("video_started");
// console.log("video_started");
videoPlay = true;
}
});
player.on('timeupdate', function() {
previousTime = currentTime;
currentTime = player.currentTime();
duration = player.duration();
perc = (currentTime / duration * 100).toFixed(2);
if (Math.floor(perc) >= 25 && !reach25) {
// console.log("25% reached");
//_satellite.track("25_completed");
_satellite.track("video_25_completed");
reach25 = true;
}
if (Math.floor(perc) >= 50 && !reach50) {
// console.log("50% reached");
//_satellite.track("50_completed");
_satellite.track("video_50_completed");
reach50 = true;
}
if (Math.floor(perc) >= 75 && !reach75) {
// console.log("75% reached");
//_satellite.track("75_completed");
_satellite.track("video_75_completed");
reach75 = true;
}
});
player.on('seeking', function() {
if(seekStart === null) {
seekStart = previousTime;
}
});
player.on('seeked', function() {
console.log('seeked from', seekStart, 'to', currentTime, '; delta:', currentTime - previousTime);
seekStart = null;
});
player.on('ended', function() {
// console.log("100% reached");
_satellite.track("video_100_completed");
videoPlay = false;
});
//this.bigPlayButton.hide();
});
}
}
initVideojsWithPopnewsId()
function initVideojsWithPopnewsId(){
if(typeof popnewsVideoID != 'undefined' && popnewsVideoID != ""){
if((typeof streamComscore == 'undefined' || streamComscore == "") && typeof ns_ != "undefined"){
streamComscore = new ns_.StreamSense({}, comscoreBasesiteUrlInews);
}
var userAgent = encodeURIComponent(navigator.userAgent);
$.ajax({
method : "GET",
url : popnewsWebRoot+"api/queryAPI.php?vid="+popnewsVideoID,
dateType : "json",
success:function(data){
if(typeof data[0]['u'] != "undefined" && data[0]['u'] != ""){
sendComscoreOnPlay(data[0]['i'], data[0]['t'], data[0]['k'], streamComscore);
updatePopnewsVideoHitCount({'n':'hl','m':'s','t':'w','l':'instantnewsDetail.php','u':userAgent,'id':data[0]['i'],'c':data[0]['k']});
$("#mediaplayer1").append('<video id="player1" muted playsinline class="video-js vjs-16-9 vjs-default-skin vjs-big-play-centered" ></video>');
setupVideojs("player1", videoHttpSourceRoot+data[0]['u']+".mp4");
}
}
});
}
}
initVideojsWithInewsVideo()
function initVideojsWithInewsVideo(){
if(typeof inewsVideoPath != 'undefined'){
if((typeof streamComscore2 == 'undefined' || streamComscore2 == "") && typeof ns_ != "undefined"){
streamComscore2 = new ns_.StreamSense({}, comscoreBasesiteUrlInews);
}
sendComscoreOnPlay(newsID, newsTitle, newsCat, streamComscore2);
$("#mediaplayer2").append('<video id="player2" muted playsinline class="video-js vjs-16-9 vjs-default-skin vjs-big-play-centered" ></video>');
setupVideojs("player2", inewsVideoPath);
}
}
// TOADD: // SIDEBAR
$(function(){
$('.section-select').click(function(e){
e.preventDefault();
var displaySection = $(this).attr('rel');
$(this).addClass('active').siblings().removeClass('active');
$('.hit-section-list').hide(0, function(){
$('.section-' + displaySection).show(0);
});
});
});
// TOADD END:
$(function(){
$('.news-list-scrollable-columnist').each(function(){
$('.caption', this).last().css({
'border-bottom': 'none'
});
});
});
$(function(){
var $focusCarousel = $('#focus-carousel');
var $focusHeading = $('.main-index .focus .heading');
if ($focusCarousel.length) {
var heading = $focusCarousel.find('.item.active .carousel-caption h3 a > strong > span').text();
var headerStrongOuterWidth = $focusCarousel.find('.item.active .carousel-caption h3 a > strong').outerWidth();
$focusCarousel.find('.item.active .carousel-caption h3 a > span').css('margin-left', headerStrongOuterWidth+10);
$focusHeading.find('span').text(heading);
$focusCarousel.on('slide.bs.carousel', function (e) {
heading = $(e.relatedTarget).find('.carousel-caption h3 a > strong > span').text();
$focusHeading.find('span').text(heading);
if ( $(e.relatedTarget).find('.carousel-caption h3').hasClass('adh') ) {
$focusHeading.find('h3').addClass('adh');
} else {
$focusHeading.find('h3').removeClass('adh');
}
setTimeout(function(){
headerStrongOuterWidth = $(e.relatedTarget).find('.carousel-caption h3 a > strong').outerWidth();
$(e.relatedTarget).find('.carousel-caption h3 a > span').css('margin-left', headerStrongOuterWidth+10);
},100);
});
}
});