1'use strict'; 2var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 3 return new (P || (P = Promise))(function (resolve, reject) { 4 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 5 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 6 function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } 7 step((generator = generator.apply(thisArg, _arguments || [])).next()); 8 }); 9}; 10var __generator = (this && this.__generator) || function (thisArg, body) { 11 var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; 12 return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; 13 function verb(n) { return function (v) { return step([n, v]); }; } 14 function step(op) { 15 if (f) throw new TypeError("Generator is already executing."); 16 while (_) try { 17 if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; 18 if (y = 0, t) op = [op[0] & 2, t.value]; 19 switch (op[0]) { 20 case 0: case 1: t = op; break; 21 case 4: _.label++; return { value: op[1], done: false }; 22 case 5: _.label++; y = op[1]; op = [0]; continue; 23 case 7: op = _.ops.pop(); _.trys.pop(); continue; 24 default: 25 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } 26 if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } 27 if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } 28 if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } 29 if (t[2]) _.ops.pop(); 30 _.trys.pop(); continue; 31 } 32 op = body.call(thisArg, _); 33 } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } 34 if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; 35 } 36}; 37; 38function reqStation(ymd, stationId) { 39 return __awaiter(this, void 0, void 0, function () { 40 return __generator(this, function (_a) { 41 return [2, $.ajax({ 42 type: 'GET', 43 url: window.Radiko.CONST.GCP_API_DOMAIN + "/program/v4/date/" + ymd + "/station/" + stationId + ".json", 44 dataType: 'json' 45 })]; 46 }); 47 }); 48} 49function findProgram(programList, ft) { 50 for (var idx = 0; idx < programList.length; idx++) { 51 if (programList[idx].ft === ft) { 52 return programList[idx]; 53 } 54 } 55 return undefined; 56} 57function getActorIdList(program) { 58 if (program === undefined) 59 return []; 60 return program.person.reduce(function (acc, cur) { 61 var mat = cur.id.match(/[^/]+$/); 62 if (mat !== null) { 63 acc.push(mat[0]); 64 } 65 return acc; 66 }, []); 67} 68function sortActorsByRequestOrder(actorIdItems, actorList) { 69 var actorMap = {}; 70 for (var idx = 0; idx < actorList.length; idx++) { 71 actorMap[actorList[idx].key] = actorList[idx]; 72 } 73 var orderedActorList = new Array(); 74 for (var idx = 0; idx < actorIdItems.length; idx++) { 75 var actor = actorMap[actorIdItems[idx]]; 76 if (actor === undefined) 77 continue; 78 orderedActorList.push(actor); 79 } 80 return orderedActorList; 81} 82function getEventId(program) { 83 if (program === undefined) 84 return ""; 85 var matchResult = program.event_id.match(/events\/(.+)$/); 86 if (matchResult === null) 87 return ""; 88 return matchResult.length ? matchResult[1] : ""; 89} 90function getActorImageByGenre(image) { 91 for (var idx = 0; image.length > idx; idx++) { 92 if (image[idx].genre === 's') { 93 return image[idx].url; 94 } 95 else if (image[idx].genre === 'm') { 96 return image[idx].url; 97 } 98 else { 99 return image[idx].url; 100 } 101 } 102} 103var liveRenderActorNgStationList = [ 104 { 105 id: 'FMT' 106 } 107]; 108function generateDisplayActorsList(actorList, eventId) { 109 var displayItems = new Array(); 110 actorList.forEach(function (v) { 111 var item = { 112 id: v.key, 113 name: v.name, 114 englishName: v.nameEnglish, 115 imageUrl: '', 116 eventId: eventId, 117 hasImageUrl: false 118 }; 119 var image = getActorImageByGenre(v.imagesList); 120 if (image === undefined) { 121 item.imageUrl = './images/person-silhouette.png'; 122 } 123 else { 124 item.imageUrl = image; 125 item.hasImageUrl = true; 126 } 127 displayItems.push(item); 128 });
129 return displayItems; 130} 131var actorRenderer = { 132 init: function (items) { 133 if (items.length > 0) { 134 this.renderActorsSection(); 135 this.renderItems(items); 136 } 137 else { 138 showLiveUtil.initActorSection(); 139 } 140 }, 141 renderActorsSection: function () { 142 var actorsSection = document.createElement('div'); 143 actorsSection.id = 'actors_section'; 144 var actorsVP = document.createElement('div'); 145 actorsVP.id = 'actor_viewport'; 146 var headerTitle = document.createElement('h2'); 147 headerTitle.innerText = 'åºæ¼è ã®è¿½å æ å ±'; 148 var additionalMessage = document.createElement('h3'); 149 additionalMessage.innerText = 'by ARTIST COMMONS'; 150 additionalMessage.id = 'actors_additional_message'; 151 actorsSection.appendChild(headerTitle); 152 actorsSection.appendChild(actorsVP); 153 actorsSection.appendChild(additionalMessage); 154 var displaySection = showLiveUtil.actor.getActorDisplay(); 155 displaySection.appendChild(actorsSection); 156 }, 157 renderItems: function (items) { 158 var _this_1 = this; 159 var actorViewport = showLiveUtil.actor.getViewPort(); 160 items.forEach(function (item) { 161 var actorItem = _this_1.renderActorItem(item); 162 actorViewport.appendChild(actorItem); 163 }); 164 }, 165 renderActorItem: function (item) { 166 var img = this.renderActorImage(item.imageUrl, item.hasImageUrl); 167 var name = this.renderActorNameContainer(item.name, item.englishName); 168 var actorItem = document.createElement('div'); 169 actorItem.className = 'actor_item'; 170 actorItem.appendChild(img); 171 actorItem.appendChild(name); 172 var actorItemLink = this.renderLink(item.id, item.eventId); 173 actorItemLink.appendChild(actorItem); 174 return actorItemLink; 175 }, 176 renderLink: function (personId, eventId) { 177 var actorLink = document.createElement('a'); 178 actorLink.className = 'actor-item-container'; 179 actorLink.href = "./persons/" + personId; 180 actorLink.setAttribute("data-tdhittype", "event"); 181 actorLink.setAttribute("data-ecategory", "live_broadcast"); 182 actorLink.setAttribute("data-eaction", "click"); 183 actorLink.setAttribute("data-elabel", "person"); 184 actorLink.setAttribute("data-eperson-id", personId); 185 actorLink.setAttribute("data-eprogram-event-id", eventId); 186 actorLink.setAttribute("target", "_blank"); 187 return actorLink; 188 }, 189 renderActorImage: function (imageUrl, hasImageUrl) { 190 var image = document.createElement('img'); 191 image.src = imageUrl; 192 var actorImage = document.createElement('div'); 193 actorImage.className = 'actor_image'; 194 actorImage.appendChild(image); 195 if (!hasImageUrl) { 196 image.id = 'actor_no_image'; 197 } 198 return actorImage; 199 }, 200 renderActorNameContainer: function (name, englishName) { 201 var acotorName = document.createElement('dt'); 202 acotorName.className = 'actor_name'; 203 acotorName.innerText = name; 204 var acotorNameEng = document.createElement('dd'); 205 acotorNameEng.className = 'actor_name_eng'; 206 acotorNameEng.innerText = englishName; 207 var actorNameContainer = document.createElement('dl'); 208 actorNameContainer.className = 'actor_name_container'; 209 actorNameContainer.appendChild(acotorName); 210 actorNameContainer.appendChild(acotorNameEng); 211 return actorNameContainer; 212 } 213}; 214var showLiveUtil = { 215 actor: { 216 getActorDisplay: function () { 217 return document.getElementById('actor_display'); 218 }, 219 getActorSection: function () { 220 return document.getElementById('actors_section'); 221 }, 222 getViewPort: function () { 223 return document.getElementById('actor_viewport'); 224 } 225 }, 226 initActorSection: function () { 227 var actorsEl = showLiveUtil.actor.getActorSection(); 228 if (actorsEl) 229 actorsEl.remove(); 230 }, 231 renderActorListAsync: function (ftYmd, stationId, models) { 232 showLiveUtil.initActorSection(); 233 var isLiveRenderActorNgStation = function () { 234 var isRender = true; 235 liveRenderActorNgStationList.map(function (liveRenderActorNgStation) { 236 if (liveRenderActorNgStation.id === stationId) { 237 return isRender = false;
238 } 239 return; 240 }); 241 return isRender; 242 }; 243 if (!isLiveRenderActorNgStation()) { 244 return; 245 } 246 ; 247 reqStation(ftYmd, stationId).then(function (stations) { 248 var program = findProgram(stations.stations[0].programs.program, models.models[0].attributes.ft); 249 if (program !== undefined && program.key_station_id === 'FMT') { 250 return; 251 } 252 var actorIdItems = getActorIdList(program); 253 var eventId = getEventId(program); 254 if (actorIdItems.length > 0) { 255 window.RadikoGrpc.getActors(actorIdItems).then(function (actorList) { 256 var orderedActorList = sortActorsByRequestOrder(actorIdItems, actorList); 257 var displayItems = generateDisplayActorsList(orderedActorList, eventId); 258 actorRenderer.init(displayItems); 259 }); 260 } 261 }); 262 } 263}; 264var showLive = function (_stationId) { 265 (function (window, $, Backbone, _, moment, undefined) { 266 loadTemplate({ 267 '#contents': '/apps/templates/prg/index.html', 268 '#footer': '/apps/templates/common/footer.html' 269 }, function () { 270 var intervals = []; 271 (function (Radiko) { 272 var getDate = function () { 273 var m = moment(); 274 if (m.format('YYYYMMDDHHmmss') >= m.format('YYYYMMDD050000')) { 275 return m; 276 } 277 else { 278 return moment(m.subtract('day', 1).format('YYYY-MM-DD')); 279 } 280 }; 281 var isAdClose = false; 282 Radiko.Live = (function () { 283 var Live = function () { 284 this.areaFreeCollection = null; 285 this.stationCollection = null; 286 this.nowProgramsCollection = null; 287 this.musicsCollection = null; 288 this.StationWeeklyCollection = null; 289 this.othersCollection = null; 290 this.adHifstoryCollection = null; 291 }; 292 _.extend(Live.prototype, Backbone.Events); 293 Live.prototype.initialize = function () { 294 this.createModels(); 295 this.createViews(); 296 this.fetchAll({ 297 model: this.areafreeCollection 298 }, { 299 model: this.StationWeeklyCollection 300 }, { 301 model: this.othersCollection 302 }, { 303 model: this.adHistoryCollection 304 }); 305 this.subscribeAll(); 306 }; 307 Live.prototype.createModels = function () { 308 this.areafreeCollection = new AreaFreeCollection(); 309 this.stationCollection = new StationsCollection(this.areafreeCollection); 310 this.nowProgramsCollection = new NowProgramsCollection({ 311 areafree: this.areafreeCollection, 312 station: this.stationCollection 313 }); 314 this.musicsCollection = new radikoNOA.Collection(this.nowProgramsCollection, { 315 station_id: _stationId, 316 is_live: true 317 }); 318 this.StationWeeklyCollection = new StationWeeklyCollection(); 319 this.othersCollection = new OthersCollection(); 320 this.adHistoryCollection = new AdHistoryCollection(); 321 }; 322 Live.prototype.createViews = function () { 323 $.Radiko.views.push(new StationsView({ 324 collection: this.stationCollection 325 })); 326 $.Radiko.views.push(new NowProgramsListView({ 327 el: document.getElementById('now-programs-list'), 328 collection: { 329 stations: this.stationCollection, 330 program: this.nowProgramsCollection, 331 areafree: this.areafreeCollection 332 } 333 })); 334 $.Radiko.views.push(new MusicsView({ 335 el: document.getElementById('play-musics'), 336 collection: { 337 noa: this.musicsCollection, 338 program: this.nowProgramsCollection 339 } 340 })); 341 $.Radiko.views.push(new WeeklyListView({ 342 el: document.querySelector('#program-table > .program-table'), 343 collection: this.StationWeeklyCollection 344 })); 345 $.Radiko.views.push(new OthersView({ 346 el: document.getElementById('others-program'), 347 collection: this.othersCollection 348 })); 349 $.Radiko.views.push(new AdHistoryView({ 350 el: document.getElementById('ad-history'), 351 collection: this.adHistoryCollection 352 })); 353 }; 354 Live.prototype.fetchAll = function () { 355 return $.when.apply($, _.map(_.toArray(arguments), function (queue) { 356 return queue.model.fetch(queue.options || {}); 357 })); 358 }; 359 Live.prototype.subscribeAll = function () { 360 var _this = this; 361 var nowOnAir = setInterval(function () { 362 _this.musicsCollection.fetch(); 363 }, 17 * 1000); 364 intervals.push(nowOnAir); 365 var timer = setInterval(function () { 366 var to = $('.live-detail__body').attr('to'); 367 if (to < moment().format('YYYYMMDDHHmmss')) { 368 _this.nowProgramsCollection.fetch(); 369 } 370 }, 5 * 1000); 371 intervals.push(timer); 372 }; 373 return Live; 374 })(); 375 var AreaFreeModel = Backbone.Model.extend({ 376 "default": {} 377 }); 378 var AreaFreeCollection = Backbone.Collection.extend({ 379 model: AreaFreeModel, 380 url: '/v3/station/region/full.xml', 381 parse: function (data) { 382 return _.map($('station', data), function (station) { 383 var $station = $(station); 384 return { 385 id: $station.find('id').text(), 386 areaId: $station.find('area_id').text(), 387 logo: $station.find('logo').first().text(), 388 tf_max_delay: $station.find('tf_max_delay').text() 389 }; 390 }, this); 391 }, 392 fetch: function (options) { 393 options = options || {}; 394 options.dataType = 'xml'; 395 return Backbone.Collection.prototype.fetch.call(this, options); 396 }, 397 initialize: function () { 398 this.listenTo(this.collection, 'sync', this.onSync); 399 }, 400 onSync: function (models) { 401 this.render(models); 402 } 403 }); 404 var StationModel = Backbone.Model.extend({ 405 defaults: { 406 tf_max_delay: 60 407 } 408 }); 409 var StationsCollection = Backbone.Collection.extend({ 410 model: StationModel, 411 initialize: function (models) { 412 this.isStationList = _.contains($.Radiko.before_station_list, _stationId); 413 this.listenTo(models, 'sync', this.onSync); 414 }, 415 onSync: function (models) { 416 if (models.where({ id: _stationId }).length === 0) { 417 notFound(); 418 $('body').attr('class', 'page-default'); 419 return; 420 } 421 var data = models.where({ id: _stationId })[0].toJSON(); 422 this.areaId = data.areaId; 423 $('.heading-area__title img').attr('src', data.logo); 424 $('.heading-area__title a').attr('href', '/#!/timetable/' + data.id + '/live'); 425 if ($.Radiko.login_status.areafree && !this.isStationList) { 426 $.cookie('areafree_id', this.areaId, { path: '/' }); 427 } 428 else if (this.isStationList) { 429 this.areaId = getAreaId(); 430 } 431 else { 432 this.areaId = $.cookie('default_area_id'); 433 } 434 this.url = '/v3/station/list/' + this.areaId + '.xml'; 435 this.fetch(); 436 }, 437 parse: function (data) { 438 var areaId = this.areaId; 439 var $stations = $(data).find('station'); 440 var stations = _.map($stations, function (station) { 441 var obj = { 442 id: $(station).find('id').text(), 443 name: $(station).find('name').text(), 444 areafree: +$(station).find('areafree').text() 445 }; 446 var $delay = $(station).find('tf_max_delay'); 447 if ($delay.length) { 448 $.extend(obj, { 449 tf_max_delay: +$delay.text() 450 }); 451 } 452 return obj; 453 }); 454 isDefaultArea = !!_.find(stations, function (station) { 455 return station.id === _stationId; 456 }); 457 return _.filter(stations, function (station) { 458 return $.cookie('default_area_id') === areaId 459 || station.areafree !== 0; 460 }); 461 }, 462 fetch: function (options) { 463 options = options || {}; 464 options.dataType = 'xml'; 465 return Backbone.Collection.prototype.fetch.call(this, options); 466 } 467 }); 468 var StationsView = Backbone.View.extend({ 469 initialize: function () { 470 this.listenTo(this.collection, 'sync', this.onSync); 471 }, 472 onSync: function (models) { 473 this.render(models); 474 }, 475 render: function (models) { 476 $('#station-list').html(JST['common/station-list']({ models: models.toJSON() })); 477 window.Radiko.UI.fixedHeaderHeight(); 478 return this; 479 } 480 }); 481 var StreamModel = Backbone.Model.extend({ 482 defaults: { 483 streamUrl: 'rtmpe' 484 } 485 }); 486 var NowProgramModel = Backbone.Model.extend({ 487 defaults: { 488 stationId: 'RGK', 489 stationName: 'RAGIKO', 490 progs: [] 491 } 492 }); 493 var NowProgramsCollection = Backbone.Collection.extend({ 494 model: NowProgramModel, 495 host: 'https://' + location.host, 496 initialize: function (models) { 497 this.areafree = models.areafree; 498 this.listenTo(models.station, 'sync', this.onSync); 499 }, 500 onSync: function (models) { 501 var data = this.areafree.where({ id: _stationId })[0].toJSON(); 502 var areaId = data.areaId; 503 this.logo = ''; 504 this.url = window.Radiko.CONST.GCP_API_DOMAIN + '/program/v3/now/' + areaId + '.xml'; 505 this.fetch(); 506 }, 507 parse: function (resp) { 508 var self = this; 509 var $station = $(resp).find('#' + _stationId); 510 return _.map($station, function (station) { 511 var $station = $(station); 512 var $prog = $station.find('prog'); 513 $prog = $prog.filter(function (index, element) { 514 return $(element).attr('to') > moment().format('YYYYMMDDHHmmss'); 515 }); 516 $prog = $prog.length === 0 ? $station.find('prog').last() : $prog.first(); 517 var $stationId = $station.attr('id'); 518 var iCalURL = this.getIcalUrl($stationId, $prog); 519 var googleCalUrl = this.getGoogleCalUrl($stationId, $prog); 520 var stationName = $station.find(' > name').text();
521 var shareText = this.getShareText(stationName, $prog); 522 var shareUrl = this.host + '/share/?sid=' + $stationId + '&t='; 523 var twitterUrl = 'http://twitter.com/share?text=' 524 + encodeURIComponent(shareText) + '&hashtags=radiko,ã·ã§ã¢ã©ã¸ã³&url=' + encodeURIComponent(shareUrl); 525 var facebookUrl = 'http://www.facebook.com/sharer.php?u=' + encodeURIComponent(shareUrl); 526 var clipUrl = window.Radiko.Utility.escapeDoubleQuotes(shareText + ' ' + shareUrl); 527 var txt = this.omitString($prog.find('pfm').first().text(), 11); 528 var img = $prog.find('img').text(); 529 if (img === '') { 530 img = '/images/radio-api-noimage_live.png'; 531 } 532 var ftmt = moment($prog.attr('ft'), 'YYYYMMDDHHmmss'); 533 var tomt = moment($prog.attr('to'), 'YYYYMMDDHHmmss'); 534 return { 535 stationId: $stationId, 536 stationName: $station.find('name').first().text(), 537 progTitle: $prog.find('title').first().text(), 538 progPfm: txt, 539 progPfm2: $prog.find('pfm').first().text(), 540 ft: $prog.attr('ft'), 541 to: $prog.attr('to'), 542 progFt: $prog.attr('ft'), 543 progTo: $prog.attr('to'), 544 progSchedule: self.progScheduleString(ftmt, tomt), 545 progImage: img, 546 progUrl: $prog.find('url').first().text(), 547 progDesc: $prog.find('desc').first().text(), 548 progInfo: $prog.find('info').first().text(), 549 date: $prog.find('date').text(), 550 iCalUrl: iCalURL, 551 googleCalUrl: googleCalUrl, 552 twitterUrl: twitterUrl, 553 clipUrl: clipUrl, 554 facebookUrl: facebookUrl, 555 metaTitle: this.getMetaTitle($station.find('name'), $prog), 556 shareUrl: shareUrl + $prog.attr('ft'), 557 nowPlaying: this.getPlayingStatus($stationId, $prog.attr('ft')), 558 tsInNg: $prog.find('ts_in_ng').text(), 559 tsOutNg: $prog.find('ts_out_ng').text(), 560 tsPlusInNg: $prog.find('tsplus_in_ng').text(), 561 tsPlusOutNg: $prog.find('tsplus_out_ng').text(), 562 progs: _.map($station.find('prog'), function (prog) { 563 var $prog = $(prog); 564 var size = 8; 565 var txt = $prog.find('pfm').first().text(); 566 var suffix = 'â¦'; 567 var b = 0; 568 for (var i = 0; i < txt.length; i++) { 569 b += txt.charCodeAt(i) <= 255 ? 0.5 : 1; 570 if (b > size) { 571 txt = txt.substr(0, i) + suffix; 572 break; 573 } 574 } 575 var img = $prog.find('img').text(); 576 if (img == '') { 577 img = '/images/radio-api-noimage_live.png'; 578 } 579 var ftmt = moment($prog.attr('ft'), 'YYYYMMDDHHmmss'); 580 var tomt = moment($prog.attr('to'), 'YYYYMMDDHHmmss'); 581 return { 582 progTitle: $prog.find('title').first().text(), 583 progPfm: txt, 584 progSchedule: self.progScheduleString(ftmt, tomt), 585 progImage: img, 586 progUrl: $prog.find('url').first().text(), 587 progDesc: $prog.find('desc').first().text(), 588 ft: $prog.attr('ft'), 589 to: $prog.attr('to'), 590 date: $prog.find('date').text() 591 }; 592 }) 593 }; 594 }, this); 595 }, 596 fetch: function (options) { 597 options = options || {}; 598 options.dataType = 'xml'; 599 options.cache = false;
600 this.listenTo(this.area, 'sync', Backbone.Collection.prototype.fetch.call(this, options)); 601 }, 602 dateToFormatedString: function (dateString, outputFormat) { 603 return moment(dateString, ['YYYY-MM-DD HH:mm:ss', 'YYYYMMDDHHmmss']).format(outputFormat); 604 }, 605 progScheduleString: function (ftmt, tomt) { 606 var radioHours = translateRadikoTimeHours(ftmt, tomt); 607 if (radioHours.ft_hour >= 24) { 608 ftmt.subtract(1, 'days'); 609 } 610 var ret = ftmt.format('MæDæ¥ï¼dddï¼ '); 611 ret += sprintf('%02d:%02d-%02d:%02d', radioHours.ft_hour, ftmt.minute(), radioHours.to_hour, tomt.minute()); 612 return ret; 613 }, 614 getIcalUrl: function (_stationId, program) { 615 return '/v2/api/ical' 616 + '?station_id=' + _stationId 617 + '&ft=' + program.attr('ft') 618 + '&to=' + program.attr('to') 619 + '&title=' + encodeURIComponent(program.find('title').first().text()) 620 + '&url=' + encodeURIComponent(this.host + '/#!/ts/' + _stationId + '/' + program.attr('ft')); 621 }, 622 getGoogleCalUrl: function (_stationId, program) { 623 return 'http://www.google.com/calendar/event' 624 + '?action=TEMPLATE' 625 + '&text=' + encodeURIComponent(program.find('title').first().text()) 626 + '&dates=' + program.attr('ft').substring(0, 8) + 'T' + program.attr('ft').substring(8, 14) 627 + '/' + program.attr('to').substring(0, 8) + 'T' + program.attr('to').substring(8, 14) 628 + '&details=' + encodeURIComponent(this.host + '/#!/ts/' + _stationId + '/' + program.attr('ft')) 629 + '&location=' 630 + '&trp=false' 631 + '&sprop=' 632 + '&sprop=name:'; 633 }, 634 getShareText: function (stationName, program) { 635 var ftmt = moment(program.attr('ft'), 'YYYYMMDDHHmmss'); 636 var tomt = moment(program.attr('to'), 'YYYYMMDDHHmmss'); 637 var radioHours = translateRadikoTimeHours(ftmt, tomt); 638 if (radioHours.ft_hour >= 24) { 639 ftmt.subtract(1, 'days'); 640 } 641 return program.find('title').first().text() 642 + ' | ' + stationName 643 + sprintf(' | %04d/%02d/%02d/%s ', ftmt.year(), ftmt.month() + 1, ftmt.date(), ftmt.format('ddd')) 644 + sprintf(' %02d:%02d-%02d:%02d', radioHours.ft_hour, ftmt.minute(), radioHours.to_hour, tomt.minute()); 645 }, 646 getMetaTitle: function (_stationName, program) { 647 var ftmt = moment(program.attr('ft'), 'YYYYMMDDHHmmss'); 648 var tomt = moment(program.attr('to'), 'YYYYMMDDHHmmss'); 649 var radioHours = translateRadikoTimeHours(ftmt, tomt); 650 if (radioHours.ft_hour >= 24) { 651 ftmt.subtract(1, 'days'); 652 } 653 var day = sprintf('%04d/%02d/%02d/%s ', ftmt.year(), ftmt.month() + 1, ftmt.date(), ftmt.format('ddd')); 654 var time = sprintf(' %02d:%02d-%02d:%02d', radioHours.ft_hour, ftmt.minute(), radioHours.to_hour, tomt.minute()); 655 return day + " " + time 656 + ' | ' + program.find('title').first().text() 657 + ' | ' + _stationName.first().text() 658 + ' | radiko'; 659 }, 660 omitString: function (string, size) { 661 var txt = string; 662 var suffix = 'â¦'; 663 var b = 0; 664 for (var i = 0; i < txt.length; i++) { 665 b += txt.charCodeAt(i) <= 255 ? 0.5 : 1; 666 if (b > size) { 667 txt = txt.substr(0, i) + suffix; 668 break; 669 } 670 } 671 return txt; 672 }, 673 getPlayingStatus: function (stationId, ft) { 674 if (_.isUndefined(player) || !player.isPlaying() || !player.isLive()) { 675 return false;
676 } 677 return player.station_id() === stationId && !player.chasing(); 678 } 679 }); 680 var NowProgramsListView = Backbone.View.extend({ 681 initialize: function () { 682 this.listenTo(this.collection.program, 'sync', this.onSync); 683 this.listenTo($.Radiko.Player.Model, 'change:isPlaying', this.onChangeIsPlaying); 684 this.listenTo($.Radiko.Player.Model, 'change:isLoaded', this.onChangeIsLoaded); 685 }, 686 onSync: function (models) { 687 var ftYmd = getDate().format('YYYYMMDD'); 688 var stationId = models.models[0].attributes.stationId; 689 this.render(models); 690 showLiveUtil.renderActorListAsync(ftYmd, stationId, models); 691 }, 692 onChangeIsPlaying: function (model, isPlaying) { 693 var url = $('#url').val(), $tmpUrl = $('#tmpUrl'); 694 if ($tmpUrl.length > 0 && url.indexOf($tmpUrl.val()) === -1) { 695 return; 696 } 697 var $detailButton = $('.live-detail__play'); 698 $detailButton.html(JST['live-detail/play-button']({ 699 nowPlaying: isPlaying 700 })); 701 }, 702 onChangeIsLoaded: function (model, isLoaded) { 703 $('.live-detail__play').removeClass('disabled'); 704 }, 705 render: function (programs) { 706 var self = this; 707 var data = programs.findWhere({ 708 stationId: _stationId 709 }); 710 var program = data.toJSON(); 711 dataLayer.push({ 712 eStationId: program.stationId, 713 eProgramName: program.progTitle, 714 eStartTime: moment(program.ft, 'YYYYMMDDHHmmss').format('YYYY-MM-DD HH:mm') 715 }); 716 this.renderNowPrgram(program); 717 if (!_.isUndefined(this.programTicker)) { 718 clearInterval(this.programTicker); 719 } 720 this.setColorBox(program, this.collection.areafree); 721 $('.btn--tooltip').on('click', function (e) { 722 e.preventDefault(); 723 $(this).toggleClass('btn--disabled').next().toggleClass('tooltip--open'); 724 }); 725 var $playRadio = $('.live-detail__play'); 726 if ($.Radiko.Player.Model.get('isLoaded')) { 727 $('.live-detail__play').removeClass('disabled'); 728 } 729 $playRadio.on('click', '.btn--play', function () { 730 $.Radiko.adTargetingQuestionaire.syncProfileData(); 731 var profileKey = 'rdk_profile_data'; 732 if (!$.Radiko.login_status.hasLogin && !store.get(profileKey) && !$.cookie(profileKey)) { 733 $.Radiko.adTargetingQuestionaire.colorboxQuestion(self, function () { 734 self.playRadio(data, program); 735 }); 736 } 737 else { 738 self.playRadio(data, program); 739 } 740 }); 741 $playRadio.on('click', '.btn--stop', function () { 742 if (!player.isPlaying()) { 743 return; 744 } 745 $.Radiko.Player.Model.set('isPlaying', false); 746 $.Radiko.RAPF.BannerModel.set('show', false); 747 player.stop(); 748 self.focusPlayButton(); 749 }); 750 this.setMetaContent(program); 751 }, 752 playRadio: function (data, program) { 753 if (typeof player === 'undefined') { 754 return; 755 } 756 if ($.Radiko.Player.Model.get('isStartStreaming')) { 757 return; 758 } 759 $.Radiko.Player.Model.set('isStartStreaming', true); 760 $.Radiko.Ticker.Model.set('stationId', data.get('stationId')); 761 var playerArea = $('#player-area'); 762 playerArea.addClass('player-default'); 763 playerArea.removeClass('player-timeshift'); 764 var $url = $('#url'); 765 var url = $url.val(); 766 var tmpUrl = $('#tmpUrl').val(); 767 if (url === '' || tmpUrl.match(/^#/) !== null) { 768 url = tmpUrl; 769 $url.val(url); 770 } 771 window.Radiko.Logger.recommendType = undefined; 772 dataLayer.push({ 773 playerStationId: program.stationId, 774 playerProgramName: program.progTitle, 775 playerStartTime: moment(program.ft, 'YYYYMMDDHHmmss').format('YYYY-MM-DD HH:mm') 776 }); 777 $.Radiko.Player.View.setTDCategory('live_player'); 778 play(url); 779 window.Radiko.Player.ProgramModel.set({ 780 station_id: data.get('stationId'), 781 station_name: data.get('stationName'), 782 thumbnail: data.get('progImage'), 783 title: data.get('progTitle'), 784 performer: data.get('progPfm'), 785 start: data.get('ft'), 786 end: data.get('to') 787 }); 788 window.Radiko.History.collection.add(window.Radiko.Player.ProgramModel.toJSON()); 789 $.Radiko.logger.fromShare = false;
790 updatePlayingProgramInfo({ 791 ft: data.get('progFt'), 792 to: data.get('progTo'), 793 title: data.get('progTitle'), 794 pfm: data.get('progPfm'), 795 stationId: data.get('stationId'), 796 stationName: data.get('stationName') 797 }); 798 this.focusPlayButton(); 799 }, 800 renderNowPrgram: function (programList) { 801 var $btnList = $('.btn-list'); 802 programList.nowPlayArea = JST['live-detail/play-button'](programList); 803 $('#now-programs-list').html(JST['live-detail/now-programs-list'](programList)); 804 if (programList.progPfm2.length > 10) { 805 $('.live-detail__cast-name').marquee().css('font-size', '15px'); 806 } 807 $('.live-detail__description a').attr('target', '_blank'); 808 if (!$.Radiko.login_status.areafree && !isDefaultArea) { 809 $('.live-detail__play').replaceWith(JST['live-detail/area-out']({ 810 proposal_case: window.Radiko.User.getProposalCase(true, false), 811 has_login: $.Radiko.login_status.hasLogin, 812 is_tf30bo: false 813 })); 814 $btnList.remove(); 815 } 816 }, 817 setColorBox: function (programs, stations) { 818 var _this_1 = this; 819 var result = JST['live-detail/colorbox-share'](programs); 820 $('#share-box').html(result); 821 var clipSelector = '#clipboard'; 822 $(clipSelector).on('click', function () { 823 var clipboardCallBack = _this_1.getClipboardCallback(programs, 'copy'); 824 _this_1.prepareClipboard(clipSelector, clipboardCallBack); 825 }); 826 var covertMoment = function (datetime) { 827 return moment(datetime, 'YYYYMMDDHHmmss'); 828 }; 829 var ftMoment = covertMoment(programs.progFt); 830 var toMoment = covertMoment(programs.progTo); 831 var playtime = toMoment.diff(ftMoment, 'seconds'); 832 $('.end').text('-' + sec_to_disptime(playtime / 1000)); 833 var self = this; 834 $('.btn--share').colorbox({ 835 width: '685px', 836 inline: true, 837 speed: 0, 838 opacity: 0.5, 839 onOpen: function () { 840 window.Radiko.Share.ProgramModel.set({ 841 station_id: programs.stationId, 842 station_name: programs.stationName, 843 thumbnail: programs.progImage, 844 title: programs.progTitle, 845 performer: programs.progPfm, 846 start: programs.progFt, 847 end: programs.progTo 848 }); 849 $.Radiko.Player.isShareOpenForBanner = true; 850 $.Radiko.RAPF.BannerModel.set('isTabActive', false); 851 var delay = stations.findWhere({ 852 id: _stationId 853 }).get('tf_max_delay'); 854 var playableMoment = ftMoment.clone().add(delay, 'seconds').add($.Radiko.playingBuffer, 'seconds'); 855 if (playableMoment.isSameOrAfter() && ftMoment.isSameOrBefore()) { 856 $('.cnt-text').show(); 857 $('.btn-list').hide(); 858 setInterval(function () { 859 var time = playableMoment.diff(moment(), 'seconds'); 860 if (time <= 0) { 861 $('.cnt-text').hide(); 862 $('.btn-list').show(); 863 return; 864 } 865 $('#colorbox--share').find('.colorbox__text .sec').text(time); 866 }, 1000); 867 } 868 else { 869 $('.btn-list').show(); 870 $('.cnt-text').hide(); 871 var totalPlayTime = playtime; 872 var nowPlayTime = moment().diff(ftMoment, 'seconds') - 60; 873 var rate = nowPlayTime / totalPlayTime; 874 if (rate >= 1) { 875 rate = 1; 876 nowPlayTime = totalPlayTime; 877 } 878 else if (rate <= 0) { 879 rate = 0; 880 nowPlayTime = 0; 881 } 882 var seekBar = $('.colorbox__seek .seek-bar'); 883 var seekBarWidth = seekBar.width(); 884 var nowPointerPos = seekBarWidth * rate; 885 if (nowPointerPos >= seekBarWidth) { 886 nowPointerPos = seekBarWidth; 887 } 888 else if (nowPointerPos <= 0) { 889 nowPointerPos = 0; 890 } 891 else { 892 } 893 seekBar.find('.knob').css('left', nowPointerPos - 3); 894 seekBar.find('.active').css('width', nowPointerPos - 3); 895 var remainingPlayTime = totalPlayTime - nowPlayTime; 896 $.Radiko.Share.setSeekPlayTime(nowPlayTime, remainingPlayTime); 897 var tsUrlParam = { 898 station_id: programs.stationId, 899 ft: new XDate(ftMoment.valueOf(), false), 900 to: new XDate(toMoment.valueOf(), false), 901 seek: new XDate(ftMoment.clone().add(nowPlayTime, 'seconds').valueOf(), false) 902 }; 903 var tsUrl = create_ts_url(tsUrlParam); 904 var shareFB = $('.btn__facebook'); 905 var shareTW = $('.btn__twitter'); 906 var clipBoard = $('#clipboard'); 907 var fShareUrl = shareFB.data('url'); 908 var tShareUrl = shareTW.data('urlbase'); 909 var cShareUrl = clipBoard.data('urlbase'); 910 var now = xdate_to_tm(tsUrlParam.seek); 911 shareFB.attr('href', fShareUrl + now); 912 shareTW.attr('href', tShareUrl + now); 913 clipBoard.attr('data-clipboard-text', cShareUrl + now); 914 seekBar.attr('data-ts', now); 915 $('#share-url').val(tsUrl); 916 } 917 $(window).on('resize.visible', function () { 918 $('#colorbox').css('overflow', 'visible'); 919 }); 920 self.renderColorboxEmbedCode(programs); 921 }, 922 onClosed: function () { 923 $(window).off('resize.visible'); 924 self.sharePlayerStop(); 925 $.Radiko.Player.isShareOpen = false;
926 $.Radiko.Player.isShareOpenForBanner = false; 927 $.Radiko.RAPF.BannerModel.set('isTabActive', true); 928 } 929 }); 930 $('.btn__facebook').on('click', function () { 931 window.open(this.href, 'TWwindow', 'width=650, height=450, menubar=no, toolbar=no, scrollbars=yes'); 932 var ts = $('.colorbox__seek .seek-bar').attr('data-ts'); 933 dataLayer.push({ 934 event: 'FireTdEvent', 935 eCategory: 'live_broadcast', 936 eAction: 'click', 937 eLabel: 'share_facebook' 938 }); 939 $.Radiko.logger.share_log({ 940 type: 'do_share', 941 sns: 'facebook', 942 t: ts, 943 stationId: programs.stationId, 944 timeType: 'live' 945 }); 946 return false; 947 }); 948 $('.btn__twitter').on('click', function () { 949 window.open(this.href, 'FBwindow', 'width=650, height=450, menubar=no, toolbar=no, scrollbars=yes'); 950 var ts = $('.colorbox__seek .seek-bar').attr('data-ts'); 951 dataLayer.push({ 952 event: 'FireTdEvent', 953 eCategory: 'live_broadcast', 954 eAction: 'click', 955 eLabel: 'share_twitter' 956 }); 957 $.Radiko.logger.share_log({ 958 type: 'do_share', 959 sns: 'twitter', 960 t: ts, 961 stationId: programs.stationId, 962 timeType: 'live' 963 }); 964 return false; 965 }); 966 }, 967 onClose: function () { 968 clearInterval(this.programTicker); 969 _.each(intervals, function (timer) { 970 clearInterval(timer); 971 }); 972 }, 973 setMetaContent: function (data) { 974 var setting = {}; 975 var desc = ''; 976 desc += data.progDesc == '' ? '' : data.progDesc.replace(/(<([^>]+)>)/ig, ''); 977 desc += data.progInfo == '' ? '' : data.progInfo.replace(/(<([^>]+)>)/ig, ''); 978 setting.title = data.metaTitle; 979 setting['og:title'] = data.metaTitle; 980 setting['og:type'] = 'article'; 981 setting['og:description'] = desc.substr(0, 93); 982 setting['og:url'] = data.shareUrl; 983 setting['og:image'] = data.progImage; 984 setting['twitter:title'] = data.metaTitle; 985 setting['twitter:description'] = desc.substr(0, 93); 986 setMetaText(setting); 987 }, 988 renderColorboxEmbedCode: function (programs) { 989 var _this_1 = this; 990 var clipSelector = '#clipboard-embed'; 991 var copyButton = $(clipSelector); 992 var widthInput = $('.width-text'); 993 var self = this; 994 $('.btn--embedcode').colorbox({ 995 width: '850px', 996 inline: true, 997 speed: 0, 998 opacity: 0.5, 999 onCleanup: function () { 1000 $('#colorbox--embedcode iframe').attr({ src: '' }); 1001 }, 1002 onClosed: function () { 1003 $(window).off('resize.visible'); 1004 self.sharePlayerStop(); 1005 $.Radiko.Player.isShareOpen = false;
1006 $.Radiko.Player.isShareOpenForBanner = false; 1007 $.Radiko.RAPF.BannerModel.set('isTabActive', true); 1008 $('#embed-showcode').off(); 1009 if ($('#embed-showcode').prop('checked')) { 1010 $('#embed-showcode').removeAttr('checked').prop('checked', false); 1011 var cboxContentEl = $('#cboxContent')[0]; 1012 var origin = cboxContentEl.style.height !== null ? parseInt(cboxContentEl.style.height) : 0; 1013 $('#colorbox--embedcode section')[0].style.top = origin + "px"; 1014 $('#colorbox--embedcode section').removeClass('embedcode-section-show'); 1015 $('#colorbox--embedcode .embedcode-background').removeClass('embedcode-background-show'); 1016 } 1017 $('#cboxContent')[0].style.transition = "none"; 1018 if ($('#cboxLoadedContent')[0]) { 1019 $('#cboxLoadedContent')[0].style.transition = "none"; 1020 } 1021 } 1022 }); 1023 this.setHeightOption(); 1024 if ($('.easy-select-box').length == 0) { 1025 $('#colorbox--embedcode').find("select").easySelectBox({ 1026 onClick: function (e) { 1027 var selectedHeight = e.value; 1028 var currentIframeHeight = $('#colorbox--embedcode iframe').attr('height'); 1029 if (selectedHeight !== currentIframeHeight) { 1030 self.updateIframe(programs); 1031 } 1032 $('#colorbox--embedcode').find(".esb-displayer").append('<i class="icon icon--arrow-d-gray"></i>'); 1033 } 1034 }); 1035 $('#colorbox--embedcode').find(".esb-displayer").append('<i class="icon icon--arrow-d-gray"></i>'); 1036 } 1037 widthInput.on('blur', function () { 1038 var widthVal = widthInput.val(); 1039 var lowerWidthVal = _this_1.inputToHalf(widthVal); 1040 var supZeroNum = lowerWidthVal.replace(/^0+/, ''); 1041 var width = Math.round(supZeroNum.split(/[^0-9.]/)[0]) || 0; 1042 var isOnlyNum = !/[^0-9.]/.test(lowerWidthVal) && /^[0-9]+\.?[0-9]*$/.test(lowerWidthVal); 1043 var hasPercent = /%/.test(lowerWidthVal); 1044 var hasPx = /px/.test(lowerWidthVal); 1045 var isPercent = /^[0-9]+\.?[0-9]*%/.test(lowerWidthVal); 1046 var isPx = /^[0-9]+\.?[0-9]*px/.test(lowerWidthVal); 1047 if ((hasPercent && hasPx) || (!isOnlyNum && !isPx && !isPercent)) { 1048 widthInput.val("40%"); 1049 } 1050 else if (isPx) { 1051 widthInput.val(width + "px"); 1052 if (width < 300) 1053 widthInput.val("300px"); 1054 if (width > 750) 1055 widthInput.val("750px"); 1056 } 1057 else if (isOnlyNum || isPercent) { 1058 widthInput.val(width + "%"); 1059 if (width < 40) 1060 widthInput.val("40%"); 1061 if (width > 100) 1062 widthInput.val("100%"); 1063 } 1064 var currentIframeWidth = $('#colorbox--embedcode iframe').attr('width'); 1065 if (widthInput.val() !== currentIframeWidth) { 1066 self.updateIframe(programs); 1067 } 1068 }); 1069 copyButton.on('click', function () { 1070 var iframeAttr = _this_1.getIframeAttr(programs); 1071 var embedCode = _this_1.getEmbedCode(iframeAttr); 1072 _this_1.updateEmbedCopyString(embedCode); 1073 var clipboardCallback = _this_1.getClipboardCallback(programs, 'embed'); 1074 _this_1.prepareClipboard(clipSelector, clipboardCallback); 1075 }); 1076 $('#embed-showcode').on('change', function () { 1077 var cboxContentEl = $('#cboxContent')[0]; 1078 var origin = cboxContentEl.style.height !== null ? parseInt(cboxContentEl.style.height) : 0; 1079 var isChecked = $('#embed-showcode').prop("checked"); 1080 if (isChecked) { 1081 $('#colorbox--embedcode section')[0].style.top = origin + 80 + "px"; 1082 } 1083 else { 1084 $('#colorbox--embedcode section')[0].style.top = origin + "px"; 1085 } 1086 $('#colorbox--embedcode section').toggleClass('embedcode-section-show', isChecked); 1087 $('#colorbox--embedcode .embedcode-background').toggleClass('embedcode-background-show', isChecked); 1088 }); 1089 $('#embedcode').on('dragSeekKnob skipSeconds', function () { 1090 var iframeAttr = _this_1.getIframeAttr(programs); 1091 var embedCode = _this_1.getEmbedCode(iframeAttr); 1092 self.updateEmbedCodeView(embedCode); 1093 }); 1094 $('.btn--embedcode').one('click', function () { 1095 _this_1.updateIframe(programs); 1096 }); 1097 }, 1098 updateIframe: function (programs) { 1099 var iframeAttr = this.getIframeAttr(programs); 1100 var embedCode = this.getEmbedCode(iframeAttr); 1101 var title = iframeAttr.title, width = iframeAttr.width, height = iframeAttr.height, src = iframeAttr.src; 1102 $('#colorbox--embedcode iframe').attr({ 1103 title: title, 1104 src: src, 1105 width: width, 1106 height: height + "px" 1107 }); 1108 this.updateEmbedCodeView(embedCode); 1109 this.updateEmbedCopyString(embedCode); 1110 }, 1111 updateEmbedCodeView: function (embedCode) { 1112 var codeView = $('#embedcode'); 1113 codeView.text(embedCode); 1114 }, 1115 updateEmbedCopyString: function (embedCode) { 1116 var copyButton = $('#clipboard-embed'); 1117 copyButton[0].dataset.clipboardText = embedCode; 1118 }, 1119 getEmbedCode: function (iframeAttr) { 1120 var title = iframeAttr.title, width = iframeAttr.width, height = iframeAttr.height, src = iframeAttr.src; 1121 return "<iframe title=\"" + title + "\" src=\"" + src + "\" width=\"" + width + "\" height=\"" + height + "px\" allow=\"clipboard-write *; web-share *;\"></iframe>"; 1122 }, 1123 getIframeAttr: function (programs) { 1124 var title = window.Radiko.Utility.escapeDoubleQuotes(programs.progTitle); 1125 var width = $('.width-text').val(); 1126 var height = $('.esb-displayer').text() === "æ¨æº(288px)" ? 288 : 104; 1127 var heightType = $('.esb-displayer').text() === "æ¨æº(288px)" ? "default" : "compact"; 1128 var sid = programs.stationId; 1129 var ts = $('.colorbox__seek .seek-bar').attr('data-ts') || programs.ft; 1130 var src = window.location.origin + "/embed/events?sid=" + sid + "&t=" + ts + "&type=" + heightType; 1131 return { title: title, width: width, height: height, src: src }; 1132 }, 1133 getClipboardCallback: function (programs, snsShareLog) { 1134 var successCallback = function () { 1135 alert('ã³ãã¼ãã¾ããã'); 1136 var ts = $('.colorbox__seek .seek-bar').attr('data-ts'); 1137 $.Radiko.logger.share_log({ 1138 type: 'do_share', 1139 stationId: programs.stationId, 1140 sns: snsShareLog, 1141 t: ts, 1142 timeType: 'live' 1143 }); 1144 }; 1145 return successCallback; 1146 }, 1147 prepareClipboard: function (selector, successCallBack) { 1148 if (typeof Clipboard !== 'undefined' && Clipboard.isSupported()) { 1149 if (window.clipboardObject) { 1150 window.clipboardObject.destroy(); 1151 } 1152 window.clipboardObject = new Clipboard(selector, { 1153 container: $(selector)[0] 1154 }); 1155 window.clipboardObject.on('success', successCallBack); 1156 } 1157 else { 1158 var client_1 = new ZeroClipboard($(selector)); 1159 client_1.on('ready', function () { 1160 client_1.on('aftercopy', successCallBack); 1161 }); 1162 } 1163 }, 1164 setHeightOption: function () { 1165 var select = $('select[name=height]'); 1166 var defaultHeight = $('<option></option>', { 1167 value: '288px', 1168 text: 'æ¨æº(288px)' 1169 }); 1170 var compactHeight = $('<option></option>', { 1171 value: '104px', 1172 text: 'ã³ã³ãã¯ã(104px)' 1173 }); 1174 select.append(defaultHeight[0].outerHTML); 1175 select.append(compactHeight[0].outerHTML); 1176 }, 1177 sharePlayerStop: function () { 1178 changePlayButton(); 1179 if (isSharePlay && player.isPlaying()) { 1180 player.stop(); 1181 } 1182 isSharePlay = false;
1183 player._player._isSharePlay = isSharePlay; 1184 if ($.Radiko.Share.isBeforePlaying) { 1185 $.Radiko.Share.isBeforePlaying = false; 1186 window.Radiko.History.collection.add(window.Radiko.Player.ProgramModel.toJSON()); 1187 play($('#url').val()); 1188 } 1189 }, 1190 inputToHalf: function (input) { 1191 return input.replace(/ï½ï½|ï¼ |[ï¼-ï¼]+/g, function (fullString) { 1192 var halfString = ""; 1193 for (var i = 0; i < fullString.length; i++) { 1194 halfString += String.fromCharCode(fullString.charCodeAt(i) - 0xFEE0); 1195 } 1196 return halfString; 1197 }); 1198 }, 1199 focusPlayButton: function () { 1200 var timer = setInterval(function () { 1201 if (!$.Radiko.Player.Model.get('isStartStreaming')) { 1202 $('a.play-radio').trigger('focus'); 1203 clearInterval(timer); 1204 } 1205 }, 300); 1206 } 1207 }); 1208 var MusicsView = Backbone.View.extend({ 1209 prevMusicItemId: null, 1210 noaCollection: {}, 1211 initialize: function () { 1212 this.listenTo(this.collection.program, 'sync', this.clearDisplay); 1213 this.listenTo(this.collection.noa, 'sync', this.onSync); 1214 }, 1215 onSync: function (noaCollection) { 1216 this.render(noaCollection); 1217 }, 1218 remove: function () { 1219 }, 1220 render: function (noaCollection) { 1221 if (noaCollection.length === 0) { 1222 return false; 1223 } 1224 var newItemId = noaCollection.at(0).get('id'); 1225 if (this.prevMusicItemId === newItemId) { 1226 return false; 1227 } 1228 this.prevMusicItemId = newItemId; 1229 var data = noaCollection.toJSON(); 1230 $('#play-musics').html(JST['detail-common/play-musics']({ 1231 models: data, 1232 stream_type: 'LV' 1233 })); 1234 $('#noa').html(JST['detail-common/noa-item']({ 1235 model: data[0], 1236 stream_type: 'LV' 1237 })); 1238 $('.ticket-list__link a').on('click', function () { 1239 var $ticketColorBox = $('#colorbox--ticket'); 1240 $ticketColorBox.html(new RadikoTicket.DialogView({ 1241 noa_item: data[0], 1242 stream_type: 'LV' 1243 }).el); 1244 $.colorbox({ 1245 scrolling: false, 1246 inline: true, 1247 href: $ticketColorBox, 1248 speed: 0, 1249 opacity: 0.5 1250 }); 1251 }); 1252 $('.tune-list__item').heightLine(); 1253 this.listMore(); 1254 $('.tune-list__ticket button').on('click', function (e) { 1255 var id = $(e.target).data('id'); 1256 var $ticketColorBox = $('#colorbox--ticket'); 1257 $ticketColorBox.html(new RadikoTicket.DialogView({ 1258 noa_item: data[id], 1259 stream_type: 'LV' 1260 }).el); 1261 $.colorbox({ 1262 scrolling: false, 1263 inline: true, 1264 href: $ticketColorBox, 1265 speed: 0, 1266 opacity: 0.5 1267 }); 1268 }); 1269 return this; 1270 }, 1271 listMore: function () { 1272 var showNum = 3; 1273 var showItems = $('.tune-list__item'); 1274 showItems.addClass('hide-tune-item'); 1275 var listNum = showItems.length; 1276 showItems.hide(); 1277 var moreBtn = $('.tune-list__more'); 1278 if (showNum > listNum) { 1279 showNum = listNum; 1280 moreBtn.remove(); 1281 } 1282 var hideItems = $('.hide-tune-item'); 1283 for (var i = 0; i < showNum; i++) { 1284 hideItems.eq(i).show(); 1285 hideItems.eq(i).removeClass('hide-tune-item'); 1286 hideItems.eq(i).addClass('show-tune-item'); 1287 } 1288 moreBtn.on('click', function () { 1289 var showItems = $('.hide-tune-item'); 1290 hideItems.show(); 1291 showItems.removeClass('hide-tune-item'); 1292 showItems.addClass('show-tune-item'); 1293 $(this).remove(); 1294 $(this).off('click'); 1295 }); 1296 }, 1297 clearDisplay: function () { 1298 var playMusicsCard = $('#play-musics'); 1299 var noaCard = $('#noa'); 1300 if (playMusicsCard.children().length > 0) { 1301 playMusicsCard.empty(); 1302 } 1303 if (noaCard.children().length > 0) { 1304 noaCard.empty(); 1305 } 1306 } 1307 }); 1308 var StationWeeklyModel = Backbone.Model.extend({ 1309 defaults: {} 1310 }); 1311 var StationWeeklyCollection = Backbone.Collection.extend({ 1312 model: StationWeeklyModel, 1313 comparator: 'date', 1314 initialize: function () { 1315 this.stationId = _stationId; 1316 this.areaId = $.Radiko.area.id; 1317 this.currentDate = moment(); 1318 this.blankProgramAlert = false;
1319 if (this.currentDate.format('HHmmdd') <= '050000') { 1320 this.currentDate.subtract(1, 'day'); 1321 } 1322 }, 1323 setCurrentDate: function (moment) { 1324 this.currentDate = moment; 1325 }, 1326 url: function () { 1327 return window.Radiko.CONST.GCP_API_DOMAIN + "/program/v3/weekly/" + this.stationId + ".xml"; 1328 }, 1329 fetch: function (options) { 1330 return Backbone.Collection.prototype.fetch.call(this, _.extend({ 1331 dataType: 'xml' 1332 }, options)); 1333 }, 1334 parse: function (resp) { 1335 return _.map($('progs', resp), function (progs) { 1336 var _this = this; 1337 var $progs = $(progs); 1338 var now = getDate(); 1339 var stationId = $progs.parent('station').attr('id'); 1340 return { 1341 date: $progs.find('date').text(), 1342 progs: _.map($progs.find('prog'), function (prog) { 1343 var $prog = $(prog); 1344 var ftl = $prog.attr('ftl'); 1345 var tol = $prog.attr('tol'); 1346 var ft = $prog.attr('ft'); 1347 var to = $prog.attr('to'); 1348 now = moment(); 1349 var addClass = ''; 1350 var title = $prog.find('title').first().text(); 1351 var pfm = $prog.find('pfm').first().text(); 1352 var img = $prog.find('img').text(); 1353 var scheduleString = _this.getScheduleString(ft, to); 1354 var programUrl = '/#!/ts/' + stationId + '/' + ft; 1355 var listenType = 0; 1356 if (+to <= +window.Radiko.Date.calcBusinessDayStart(now.clone().subtract(30, 'day'))) { 1357 addClass += 'item--disabled'; 1358 title = ''; 1359 pfm = ''; 1360 img = ''; 1361 programUrl = ''; 1362 scheduleString = ''; 1363 } 1364 else if (to <= now.format('YYYYMMDDHHmmss')) { 1365 addClass += 'item--past '; 1366 listenType = _this.getListenType(stationId, ft, to); 1367 } 1368 else if (ft >= now.format('YYYYMMDDHHmmss')) { 1369 addClass += 'item--future '; 1370 } 1371 else { 1372 programUrl = '/#!/live/' + stationId; 1373 addClass += 'item--onair '; 1374 } 1375 return { 1376 id: stationId, 1377 ftl: ftl, 1378 ft: ft, 1379 to: to, 1380 tol: tol, 1381 dur: parseInt($prog.attr('dur'), 10), 1382 title: title, 1383 pfm: pfm, 1384 img: img, 1385 addClass: addClass, 1386 program_url: programUrl, 1387 scheduleString: scheduleString, 1388 listenType: listenType 1389 }; 1390 }) 1391 }; 1392 }, this); 1393 }, 1394 getScheduleString: function (ft, to) { 1395 var ftmt = moment(ft, 'YYYYMMDDHHmmss'); 1396 var tomt = moment(to, 'YYYYMMDDHHmmss'); 1397 var radioHours = translateRadikoTimeHours(ftmt, tomt); 1398 if (radioHours.ft_hour >= 24) { 1399 ftmt.subtract(1, 'days'); 1400 } 1401 var ftTime = sprintf('%02d:%02d', radioHours.ft_hour, ftmt.minute()); 1402 var toTime = sprintf('%02d:%02d', radioHours.to_hour, tomt.minute()); 1403 return ftTime + 'ã' + toTime; 1404 }, 1405 getProgram: function (date) { 1406 var def; 1407 var self = this; 1408 var name = 'blank'; 1409 def = $.Deferred(); 1410 this.blankProgramAlert = false;
1411 this.fetch({ remove: false, url: window.Radiko.CONST.GCP_API_DOMAIN + "/program/v3/date/" + date + "/station/" + this.stationId + ".xml", 1412 success: function (model, response, options) { def.resolve(response); }, 1413 error: function (model, response, options) { 1414 model.add({ date: date, name: name, progs: [{ addClass: 'item--past ' }] }); 1415 if (!self.blankProgramAlert) { 1416 alert('çªçµè¡¨ãä¸é¨åå¾ã§ãã¾ããã§ãã\næéãããã¦åèªã¿è¾¼ã¿ããé¡ããã¾ã'); 1417 self.blankProgramAlert = true; 1418 } 1419 def.resolve(response); 1420 } 1421 }); 1422 return def.promise(); 1423 }, 1424 getPrograms: function () { 1425 var self = this; 1426 var def; 1427 def = $.Deferred(); 1428 var today = moment(); 1429 var length = this.length; 1430 var retrievedDays = length - 7; 1431 var requireDays = 30 - retrievedDays; 1432 var noNeedForAllData = requireDays < 7; 1433 var noNeedForAnyData = requireDays <= 0; 1434 if (noNeedForAnyData) { 1435 return; 1436 } 1437 var dates = [ 1438 today.clone().subtract(length - 6, 'days').format('YYYYMMDD'), 1439 today.clone().subtract(length - 5, 'days').format('YYYYMMDD'), 1440 today.clone().subtract(length - 4, 'days').format('YYYYMMDD'), 1441 today.clone().subtract(length - 3, 'days').format('YYYYMMDD'), 1442 today.clone().subtract(length - 2, 'days').format('YYYYMMDD'), 1443 today.clone().subtract(length - 1, 'days').format('YYYYMMDD'), 1444 today.clone().subtract(length - 0, 'days').format('YYYYMMDD'), 1445 ]; 1446 var outsideDates = noNeedForAllData ? dates.splice(requireDays) : undefined; 1447 var deferredFuncs = dates.map(function (date) { return self.getProgram(date); }); 1448 $.when.apply($, deferredFuncs) 1449 .done(function () { 1450 if (noNeedForAllData && outsideDates) { 1451 for (var _i = 0, outsideDates_1 = outsideDates; _i < outsideDates_1.length; _i++) { 1452 var date = outsideDates_1[_i]; 1453 self.add({ date: date, name: 'blank', progs: [{ addClass: 'item--disabled', dur: 3600 * 24 }] }); 1454 } 1455 } 1456 def.resolve(); 1457 }); 1458 return def.promise(); 1459 } 1460 }); 1461 _.extend(StationWeeklyCollection.prototype, $.Radiko.Mixins.Utility); 1462 var WeeklyListView = Backbone.View.extend({ 1463 initialize: function () { 1464 this.currentDate = null; 1465 this.canSetScrollInit = true; 1466 this.defineUi(); 1467 this.listenTo(this.collection, 'sync', this.onSync); 1468 }, 1469 onSync: function (models) { 1470 this.currentDate = this.collection.currentDate; 1471 this.render(models); 1472 }, 1473 render: function (models) { 1474 var modelsJson = models.toJSON(); 1475 this.renderProgramDate(); 1476 this.renderProgramItems(modelsJson); 1477 if (this.canSetScrollInit) { 1478 setScrollInit(); 1479 } 1480 return this; 1481 }, 1482 renderProgramDate: function () { 1483 var _this = this; 1484 var length = this.collection.length; 1485 var beforeDate = _.map(Array.apply(null, new Array(length - 7)), function (d, i) { 1486 var date = getDate().add(i - length + 7, 'days'); 1487 return { 1488 dateFullString: date.format('YYYYMMDD'), 1489 dateString: date.format('M/D'), 1490 dayString: date.format('(ddd)'), 1491 isCurrent: _this.currentDate.isSame(date, 'day'), 1492 isSat: date.day() === 6, 1493 isSun: date.day() === 0, 1494 isDisabled: getDate().diff(date, 'days') >= 31 1495 }; 1496 }); 1497 var afterDate = _.map(Array.apply(null, new Array(7)), function (d, i) { 1498 var date = getDate().add(i, 'days'); 1499 return { 1500 dateFullString: date.format('YYYYMMDD'), 1501 dateString: date.format('M/D'), 1502 dayString: date.format('(ddd)'), 1503 isCurrent: _this.currentDate.isSame(date, 'day'), 1504 isSat: date.day() === 6, 1505 isSun: date.day() === 0, 1506 isDisabled: getDate().diff(date, 'days') >= 31 1507 }; 1508 }); 1509 $('.program-table__date-outer').html(JST['live-detail/program-table-date']({ 1510 dateList: beforeDate.concat(afterDate) 1511 })); 1512 }, 1513 renderProgramItems: function (data) { 1514 var beforeProgs = data.splice(0, 7); 1515 $('.program-table__items').html(JST['common/program-table-items']({ 1516 models: beforeProgs.concat(data), 1517 tableWidth: (data.length * 159 - 1) + 'px' 1518 })); 1519 }, 1520 defineUi: function () { 1521 $('.js-scroll').css('left', '-945px'); 1522 $('.js-next').hide(); 1523 }, 1524 events: { 1525 'click .js-prev': 'prevProgramsScrollClickHandler', 1526 'click .js-next': 'nextProgramsScrollClickHandler' 1527 }, 1528 prevProgramsScrollClickHandler: function (ev) { 1529 var length = this.collection.length; 1530 var params = { 1531 'thisBtn': $('.js-prev'), 1532 'otherBtn': $('.js-next'), 1533 'move': 945, 1534 'thresh': 0, 1535 'cond': function (left) { return left >= params.thresh && length >= 42; } 1536 }; 1537 var left = parseInt($('.js-scroll').css('left')); 1538 if (length < 42 && left >= 0) { 1539 this.getProgramsAndSetScrollInit(params); 1540 } 1541 else { 1542 this.programsScrollClickHandler(ev, params); 1543 } 1544 }, 1545 nextProgramsScrollClickHandler: function (ev) { 1546 var length = this.collection.length; 1547 var params = { 1548 'thisBtn': $('.js-next'), 1549 'otherBtn': $('.js-prev'), 1550 'move': -945, 1551 'thresh': (length - 7) * -135, 1552 'cond': function (left) { return left <= params.thresh; } 1553 }; 1554 this.programsScrollClickHandler(ev, params); 1555 }, 1556 programsScrollClickHandler: function (ev, params) { 1557 ev.preventDefault(); 1558 var $btn = params.thisBtn; 1559 if ($btn.hasClass('btn-disable')) { 1560 return; 1561 } 1562 var $scrolls = $('.js-scroll'); 1563 var left = parseInt($scrolls.css('left')); 1564 $scrolls.stop(true, true); 1565 $btn.addClass('btn-disable'); 1566 $scrolls.animate({ 1567 'left': left + params.move 1568 }).promise().done(function () { 1569 $btn.removeClass('btn-disable'); 1570 var left = parseInt($scrolls.css('left')); 1571 if (params.cond(left)) { 1572 $scrolls.css('left', params.thresh); 1573 $btn.hide(); 1574 } 1575 params.otherBtn.show(); 1576 }); 1577 }, 1578 getProgramsAndSetScrollInit: function (params) { 1579 var $btn = params.thisBtn; 1580 if ($btn.hasClass('btn-disable')) { 1581 return; 1582 } 1583 $btn.addClass('btn-disable'); 1584 this.canSetScrollInit = false;
1585 var self = this; 1586 var name = 'blank'; 1587 this.collection.getPrograms().done(function () { 1588 self.canSetScrollInit = true; 1589 params.otherBtn.show(); 1590 self.collection.length >= 42 ? params.thisBtn.hide() : ''; 1591 $btn.removeClass('btn-disable'); 1592 if ((self.collection.where({ name: name })).length > 0) { 1593 self.onSync(self.collection); 1594 } 1595 }); 1596 } 1597 }); 1598 var OtherModel = Backbone.Model.extend({ 1599 defaults: { 1600 models: [] 1601 } 1602 }); 1603 var OthersCollection = Backbone.Collection.extend({ 1604 model: OtherModel, 1605 url: '/v3/radioweb/bansen/station/' + _stationId + '.xml', 1606 parse: function (resp) { 1607 return _.map($('item', resp), function (item) { 1608 var $item = $(item); 1609 return { 1610 image_url: $item.find('image_url').text(), 1611 program_name: $item.find('program_name').text(), 1612 description: $item.find('description').text().replace(/(<([^>]+)>)/ig, ''), 1613 onair: $item.find('onair').text(), 1614 type: $item.find('type').text(), 1615 url: $item.find('radioweb_detail_url').text() 1616 }; 1617 }, this); 1618 }, 1619 fetch: function (options) { 1620 options = options || {}; 1621 options.dataType = 'xml'; 1622 return Backbone.Collection.prototype.fetch.call(this, options); 1623 } 1624 }); 1625 var OthersView = Backbone.View.extend({ 1626 initialize: function () { 1627 this.listenTo(this.collection, 'sync', this.onSync); 1628 }, 1629 onSync: function (models) { 1630 this.render(models); 1631 }, 1632 render: function (models) { 1633 var data = models.toJSON(); 1634 var result = JST['common/others-program']({ 1635 models: data 1636 }); 1637 $('#others-program').html(result); 1638 $('.img-list__text').each(function () { 1639 var size = 35; 1640 var txt = $(this).text(); 1641 var suffix = 'â¦'; 1642 var b = 0; 1643 for (var i = 0; i < txt.length; i++) { 1644 b += txt.charCodeAt(i) <= 255 ? 0.5 : 1; 1645 if (b > size) { 1646 txt = txt.substr(0, i) + suffix; 1647 break; 1648 } 1649 } 1650 $(this).text(txt); 1651 }); 1652 $('.img-list__item').heightLine(); 1653 return this; 1654 } 1655 }); 1656 var AdHistoryModel = Backbone.Model.extend({ 1657 defaults: { 1658 models: [] 1659 } 1660 }); 1661 var AdHistoryCollection = Backbone.Collection.extend({ 1662 model: AdHistoryModel, 1663 url: '/v3/feed/pc/cm/' + _stationId + '.xml', 1664 parse: function (resp) { 1665 return _.map($('item', resp), function (item) { 1666 var $item = $(item); 1667 return { 1668 desc: $item.attr('desc'), 1669 href: $item.attr('href'), 1670 img: $item.attr('img'), 1671 evid: $item.attr('evid'), 1672 stamp: $item.attr('stamp') 1673 }; 1674 }, this); 1675 }, 1676 fetch: function (options) { 1677 options = options || {}; 1678 options.dataType = 'xml'; 1679 options.cache = false;
1680 return Backbone.Collection.prototype.fetch.call(this, options); 1681 } 1682 }); 1683 var AdHistoryView = Backbone.View.extend({ 1684 events: { 1685 'click a': 'onClick' 1686 }, 1687 initialize: function () { 1688 this.listenTo(this.collection, 'sync', this.onSync); 1689 var self = this; 1690 this.timer = setInterval(function () { 1691 self.collection.fetch(); 1692 }, 1000 * 60 * 10); 1693 }, 1694 onClose: function () { 1695 clearInterval(this.timer); 1696 }, 1697 preCmList: null, 1698 onSync: function (models) { 1699 var cmList = models.toJSON(); 1700 if (!this.preCmList || this.isSame(cmList)) { 1701 this.render(models); 1702 this.sendViewBeacon(cmList); 1703 } 1704 this.preCmList = cmList; 1705 }, 1706 onClick: function (e) { 1707 $.Radiko.logger.ad_log('click.gif?ad_id=' + $(e.currentTarget).data('evid') + '&station_id=' + _stationId); 1708 }, 1709 isSame: function (cmList) { 1710 if (!this.preCmList) { 1711 return false; 1712 } 1713 return -1 == _.findIndex(this.preCmList, { stamp: cmList[0].stamp }); 1714 }, 1715 render: function (models) { 1716 $('#ad-history').html(JST['live-detail/ad-history']({ 1717 models: models.toJSON(), 1718 station_id: _stationId 1719 })); 1720 if (!_.contains($.Radiko.user_station_list, _stationId)) { 1721 $('.live-detail__attention').show(); 1722 } 1723 else { 1724 } 1725 return this; 1726 }, 1727 sendViewBeacon: function (cmList) { 1728 var preList = this.preCmList; 1729 _.each(_.filter(cmList, function (item) { 1730 return undefined === _.find(preList, function (preItem) { 1731 return item.stamp === preItem.stamp; 1732 }); 1733 }), function (item) { 1734 $.Radiko.logger.ad_log('view.gif?ad_id=' + item.evid + '&station_id=' + _stationId); 1735 }); 1736 } 1737 }); 1738 })($.Radiko || ($.Radiko = {})); 1739 $('#header').html(JST['common/header']({ logo: '/apps/images/img_logo_blue_01.png' })); 1740 var live = new $.Radiko.Live(); 1741 $.Radiko.EventEmitter.once('radikoshowlive', function () { 1742 makeHeader(); 1743 live.initialize(); 1744 playerEvent(); 1745 sharePlayerEvent({ eCategory: 'live_broadcast' }); 1746 $('input[type="text"]').placeholder(); 1747 $('#tmpUrl').val('#' + _stationId); 1748 $('#heading-area-link').find('a').on('click', function () { 1749 $('html, body').animate({ 1750 scrollTop: $('#program-table').offset().top - $('#header-nav').height() * 2 1751 }, 500); 1752 return false; 1753 }); 1754 var mainContentEl = document.getElementById('contents'); 1755 if (mainContentEl) { 1756 mainContentEl.tabIndex = -1; 1757 mainContentEl.focus({ preventScroll: true }); 1758 mainContentEl.removeAttribute('tabindex'); 1759 } 1760 }); 1761 if (_.isString($.Radiko.area.id)) { 1762 $.Radiko.EventEmitter.trigger('radikoshowlive'); 1763 } 1764 if (window.area != undefined) { 1765 $('span.area').text(window.area); 1766 } 1767 }); 1768 })(window, jQuery, Backbone, _, moment); 1769};
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.