Advertisement
havalqandiel

wwwrtgt

Jan 20th, 2017
360
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 499.08 KB | None | 0 0
  1. window.videoQaulities = '';
  2. angular
  3. .module('tw-factory',[])
  4. .factory('ChannelFcy', ChannelFcy)
  5. .factory('HomeInit', HomeInit)
  6. .factory('SearchFcy', SearchFcy)
  7. .factory('ProgramFcy', ProgramFcy)
  8. .factory('SecurityFcy', SecurityFcy)
  9. .factory('SliderFcy', SliderFcy)
  10. .factory('EpisodeFcy', EpisodeFcy)
  11. .factory('ProgressBarFcy', ProgressBarFcy)
  12. .factory('GeneralInit', GeneralInit)
  13. .factory('UtilityFcy', UtilityFcy)
  14. .factory('ArtistFcy', ArtistFcy)
  15. .factory('GeneralFunctions', GeneralFunctions)
  16. .factory('FavoriteListFcy', FavoriteListFcy)
  17. .factory('ImageUploadFcy', ImageUploadFcy)
  18. .factory('AdsFcy', AdsFcy)
  19. .factory('VasFcy', VasFcy)
  20. .factory('TagFcy', TagFcy)
  21. .factory('TagPageFcy', TagPageFcy)
  22. .factory('UserFcy', UserFcy)
  23. .factory('PromotionFcy', PromotionFcy)
  24. .factory('AdBankFcy', AdBankFcy)
  25. .factory('HourlyArchiveFcy', HourlyArchiveFcy);
  26.  
  27. HomeInit.$inject = ['SliderFcy','EpisodeFcy','$q'];
  28. GeneralFunctions.$inject = ['$q'];
  29. GeneralInit.$inject = ['UserSrv','$q','$location','ProgressBarFcy','RoutingSrv','Configs','$rootScope'];
  30. SliderFcy.$inject= ['$http','$q','Configs','CacheFactory'];
  31. ChannelFcy.$inject= ['$http','$q','Configs'];
  32. ProgramFcy.$inject= ['$http','$q','Configs'];
  33. EpisodeFcy.$inject= ['$http','$q','Configs','ChannelFcy','GeneralFunctions'];
  34. UserFcy.$inject= ['$http','$q','Configs'];
  35. SecurityFcy.$inject= ['$http','$q','Configs','CacheFactory','UtilityFcy','$rootScope','Messages'];
  36. SearchFcy.$inject= ['$http','$q','Configs'];
  37. ArtistFcy.$inject= ['$http','$q','Configs'];
  38. TagFcy.$inject= ['$http','$q','Configs'];
  39. TagPageFcy.$inject= ['$http','$q','Configs'];
  40. AdsFcy.$inject= ['$http','$q','Configs'];
  41. AdsFcy.$inject= ['$http','$q','Configs'];
  42. PromotionFcy.$inject= ['$http','$q','Configs'];
  43. AdBankFcy.$inject= ['$http','$q','Configs'];
  44. HourlyArchiveFcy.$inject= ['$http','$q','Configs'];
  45. ImageUploadFcy.$inject= ['$http','$q','Configs'];
  46. FavoriteListFcy.$inject= ['$http','$q','Configs'];
  47. VasFcy.$inject= ['$http','$q','Configs'];
  48. UtilityFcy.$inject= [];
  49.  
  50. function HomeInit(SliderFcy,EpisodeFcy,$q){
  51.  
  52. return function() {
  53. var Sliders = SliderFcy.getSliders();
  54. /*var Movies= EpisodeFcy.getMovies();
  55. var OurRecommendation= EpisodeFcy.getOurRecommendations();
  56. var UserRecommendations=EpisodeFcy.getUserRecommendations();
  57. var TvShows=EpisodeFcy.getTvShows();
  58. var Kids=EpisodeFcy.getKids();*/
  59.  
  60. return $q.all([Sliders/*,OurRecommendation,Movies,UserRecommendations,TvShows,Kids*/]).then(function(results){
  61. return {
  62. Sliders: results[0]
  63. /*,
  64. OurRecommendation: results[1],
  65. Movies: results[2],
  66. UserRecommendations: results[3],
  67. TvShows: results[4],
  68. Kids: results[5]*/
  69. };
  70. });
  71. }
  72. }
  73. function GeneralFunctions($q){
  74. var factory = {
  75. is_in_array: In_array
  76. };
  77. return factory;
  78. function In_array(item,array){
  79. for(var i=0;i<=array.length-1;i++){
  80. if(array[i]==item){
  81. return true;
  82. }
  83. }
  84. return false;
  85. }
  86. }
  87. function GeneralInit(UserSrv,$q,$location,ProgressBarFcy,RoutingSrv,Configs,$rootScope){
  88. return function() {
  89.  
  90. /*ProgressBarFcy.plus(0.1);*/
  91. var User = {};
  92. /*UserSrv.getUser().then(function(UserInfo){
  93. $rootScope.User=UserInfo;
  94. $rootScope.$broadcast("UserData");
  95. });*/
  96. debuger.info("Master admin webservice server is : " + Configs.MasterAdminWebserviceUrl)
  97. var Route = Cookie.Read("Route");
  98. if(typeof Route!='undefined' && Route!=null && Route!='' && Route!='nullcookie'){
  99. Configs.MasterWebserviceUrl = Route;
  100. var routeArray = Route.split("/");
  101. Configs.VodSmilServerUrl = routeArray[0]+'//'+routeArray[2]+'/smil';
  102. debuger.info("Smil vod server was set to : " + Configs.VodSmilServerUrl)
  103. }
  104. RoutingSrv.getRoute().then(function(RoutingResult){
  105. Configs.MasterWebserviceUrl = RoutingResult;
  106. debuger.info("Master webservice server was set to : " + Configs.MasterWebserviceUrl)
  107. Cookie.Delete("Route");
  108. Cookie.Create("Route",RoutingResult,1);
  109. var routeArray = RoutingResult.split("/");
  110. Configs.VodSmilServerUrl = routeArray[0]+'//'+routeArray[2]+'/smil';
  111. });
  112. var PageLocation=$location.path().split('/');
  113. var Culture= (PageLocation[1])?PageLocation[1]:'fa';
  114. return $q.all([User,Culture]).then(function(results){
  115. return {
  116. User: results[0],
  117. Culture:results[1]
  118. };
  119. });
  120. }
  121. }
  122. function SliderFcy($http,$q,Configs) {
  123. var Sliders={};
  124. var factory = {
  125. getSliders: Get,
  126. getRamezan95: Get_Ramezan,
  127. getleague: Get_League,
  128. getMovies: Get_Movies,
  129. getSeries: Get_Series,
  130. getTags: Get_Tags,
  131. getShademaneh: Get_Shademaneh,
  132. getKids: Get_Kids,
  133. getOlympics: Get_Olympics,
  134. getEuropeLeagues: Get_EuropeLeagues
  135. };
  136. return factory;
  137.  
  138. function Get() {
  139. var deferred = $q.defer();
  140. var url='/sliders.json?&nginxcache';
  141. $http.get(url)
  142. .success(function (data, status, headers, config) {
  143. Sliders = data;
  144. deferred.resolve(Sliders);
  145. return deferred.promise;
  146. })
  147. .error(function (data, status, headers, config) {
  148. })
  149. return deferred.promise;
  150. }
  151. function Get_Movies() {
  152. var deferred = $q.defer();
  153. var url='/movies.json?&nginxcache';
  154. $http.get(url)
  155. .success(function (data, status, headers, config) {
  156. Sliders = data;
  157. deferred.resolve(Sliders);
  158. return deferred.promise;
  159. })
  160. .error(function (data, status, headers, config) {
  161. })
  162. return deferred.promise;
  163. }
  164. function Get_EuropeLeagues() {
  165. var deferred = $q.defer();
  166. var url='/europeleagues.json?&nginxcache';
  167. $http.get(url)
  168. .success(function (data, status, headers, config) {
  169. Sliders = data;
  170. deferred.resolve(Sliders);
  171. return deferred.promise;
  172. })
  173. .error(function (data, status, headers, config) {
  174. })
  175. return deferred.promise;
  176. }
  177. function Get_Series() {
  178. var deferred = $q.defer();
  179. var url='/series.json?&nginxcache';
  180. $http.get(url)
  181. .success(function (data, status, headers, config) {
  182. Sliders = data;
  183. deferred.resolve(Sliders);
  184. return deferred.promise;
  185. })
  186. .error(function (data, status, headers, config) {
  187. })
  188. return deferred.promise;
  189. }
  190. function Get_Tags() {
  191. var deferred = $q.defer();
  192. var url='/tags.json?&nginxcache';
  193. $http.get(url)
  194. .success(function (data, status, headers, config) {
  195. Sliders = data;
  196. deferred.resolve(Sliders);
  197. return deferred.promise;
  198. })
  199. .error(function (data, status, headers, config) {
  200. })
  201. return deferred.promise;
  202. }
  203. function Get_Ramezan() {
  204. var deferred = $q.defer();
  205. var url='/ramezan.json?&nginxcache';
  206. $http.get(url)
  207. .success(function (data, status, headers, config) {
  208. Sliders = data;
  209. deferred.resolve(Sliders);
  210. return deferred.promise;
  211. })
  212. .error(function (data, status, headers, config) {
  213. })
  214. return deferred.promise;
  215. }
  216. function Get_League() {
  217. var deferred = $q.defer();
  218. var url='/ligebartar.json?&nginxcache';
  219. $http.get(url)
  220. .success(function (data, status, headers, config) {
  221. Sliders = data;
  222. deferred.resolve(Sliders);
  223. return deferred.promise;
  224. })
  225. .error(function (data, status, headers, config) {
  226. })
  227. return deferred.promise;
  228. }
  229. function Get_Olympics() {
  230. var deferred = $q.defer();
  231. var url='/olympics.json?&nginxcache';
  232. $http.get(url)
  233. .success(function (data, status, headers, config) {
  234. Sliders = data;
  235. deferred.resolve(Sliders);
  236. return deferred.promise;
  237. })
  238. .error(function (data, status, headers, config) {
  239. })
  240. return deferred.promise;
  241. }
  242. function Get_Shademaneh() {
  243. var deferred = $q.defer();
  244. var url='/shademaneh.json?&nginxcache';
  245. $http.get(url)
  246. .success(function (data, status, headers, config) {
  247. Sliders = data;
  248. deferred.resolve(Sliders);
  249. return deferred.promise;
  250. })
  251. .error(function (data, status, headers, config) {
  252. })
  253. return deferred.promise;
  254. }
  255. function Get_Kids() {
  256. var deferred = $q.defer();
  257. var url='/kids.json?&nginxcache';
  258. $http.get(url)
  259. .success(function (data, status, headers, config) {
  260. Sliders = data;
  261. deferred.resolve(Sliders);
  262. return deferred.promise;
  263. })
  264. .error(function (data, status, headers, config) {
  265. })
  266. return deferred.promise;
  267. }
  268. }
  269. function SearchFcy($http,$q,Configs){
  270. var Episodes={};
  271. var Programs={};
  272. var factory = {
  273. getEpisodes: SearchEpisodes,
  274. getPrograms: SearchPrograms
  275. };
  276. return factory;
  277. function SearchEpisodes(Context,offset,limit){
  278. var url=Configs.MasterWebserviceUrl+Configs.SearchEpisodeWebserviceURL+'&SearchQuery='+Context+"&offset="+offset+'&limit='+limit+"&thumb_size=120"+"&nginxcache";
  279. var deferred = $q.defer();
  280. $http.get(url)
  281. .success(function(data, status, headers, config) {
  282. Episodes = data;
  283. deferred.resolve(Episodes);
  284. return deferred.promise;
  285. })
  286. .error(function(data, status, headers, config) {
  287.  
  288. })
  289. return deferred.promise;
  290. }
  291.  
  292. function SearchPrograms(Context,offset,limit){
  293. var url=Configs.MasterWebserviceUrl+Configs.SearchProgramWebserviceURL+'&SearchQuery='+Context+"&offset="+offset+'&limit='+limit+"&thumb_size=240" +"&nginxcache";
  294. var deferred = $q.defer();
  295. $http.get(url)
  296. .success(function(data, status, headers, config) {
  297. Programs = data;
  298. deferred.resolve(Programs);
  299. return deferred.promise;
  300. })
  301. .error(function(data, status, headers, config) {
  302.  
  303. })
  304. return deferred.promise;
  305. }
  306. }
  307. function ChannelFcy($http,$q,Configs) {
  308. var Channels={};
  309. var Channel='';
  310. var factory = {
  311. getChannels: Get,
  312. getChannelNameFromDescriptor: GetChannelNameFromDescriptor,
  313. getChannelDescriptorList: GetChannelDescriptorList
  314. };
  315. return factory;
  316.  
  317. function Get() {
  318. var url='/mock/channel.json'+"?nginxcache";/*Configs.MasterWebserviceUrl+'/ops?action=getChannels';*/
  319. var deferred = $q.defer();
  320. $http.get(url)
  321. .success(function(data, status, headers, config) {
  322. Channels = data;
  323. deferred.resolve(Channels);
  324. return deferred.promise;
  325. })
  326. .error(function(data, status, headers, config) {
  327.  
  328. })
  329. return deferred.promise;
  330. }
  331. function GetChannelNameFromDescriptor(descriptor){
  332. var deferred = $q.defer();
  333. switch (descriptor){
  334. case "tv1":
  335. Channel=1;
  336. break;
  337. case "tv2":
  338. Channel=2;
  339. break;
  340. case "omid":
  341. Channel=45;
  342. break;
  343. case "tv3":
  344. Channel=3;
  345. break;
  346. case "hd":
  347. Channel=43;
  348. break;
  349. case "tv4":
  350. Channel=4;
  351. break;
  352. case "tehran":
  353. Channel=5;
  354. break;
  355. case "irinn":
  356. Channel=6;
  357. break;
  358. case "amouzesh":
  359. Channel=7;
  360. break;
  361. case "pooya":
  362. Channel=8;
  363. break;
  364. case "ifilm":
  365. Channel=9;
  366. break;
  367. case "namayesh":
  368. Channel=10;
  369. break;
  370. case "jjtv1":
  371. Channel=12;
  372. break;
  373. case "varzesh":
  374. Channel=13;
  375. break;
  376. case "mostanad":
  377. Channel=19;
  378. break;
  379. case "quran":
  380. Channel=20;
  381. break;
  382. case "salamat":
  383. Channel=21;
  384. break;
  385. case "shoma":
  386. Channel=24;
  387. break;
  388. case "bazar":
  389. Channel=25;
  390. break;
  391. case "ifilmEn":
  392. Channel=29;
  393. break;
  394. case "esfahan":
  395. Channel=30;
  396. break;
  397. case "sahand":
  398. Channel=31;
  399. break;
  400. case "fars":
  401. Channel=32;
  402. break;
  403. case "channel9":
  404. Channel=33;
  405. break;
  406. case "baran":
  407. Channel=34;
  408. break;
  409. case "semnan":
  410. Channel=36;
  411. break;
  412. case "aftab":
  413. Channel=37;
  414. break;
  415. case "aflak":
  416. Channel=38;
  417. break;
  418. case "kordestan":
  419. Channel=39;
  420. break;
  421. case "khalijefars":
  422. Channel=40;
  423. break;
  424. case "nasim":
  425. Channel=41;
  426. break;
  427. case "ofogh":
  428. Channel=42;
  429. break;
  430.  
  431. }
  432. deferred.resolve(Channel);
  433. return deferred.promise;
  434. }
  435. function GetChannelDescriptorList(){
  436. var ChannelDescriptorList = ['tv1','tv2','tv3','tv4','tehran','irinn','hd','nasim','ifilm','pooya','varzes','namayesh','amouzesh','jjtv1','mostanad','quran','salamat','shoma','bazar','ifilmEn','esfahan','sahand','fars','channel9','baran','semnan','aftab','aflak','kordestan','khalijefars','ofogh'];
  437. return ChannelDescriptorList;
  438. }
  439. }
  440. function HourlyArchiveFcy($http,$q,Configs){
  441. var HourlyArchiveItems = {};
  442. var factory = {
  443. getProgramsByChannel:GetProgramsByChannel
  444. }
  445. return factory;
  446. function GetProgramsByChannel(channelId,today) {
  447. var deferred = $q.defer();
  448. $http.get(Configs.MasterWebserviceUrl+'' +'/epg/getEpg?channel_id='+channelId+'&start_time='+today+' 00:00:00&end_time='+today+' 23:59:59')
  449. .success(function(data, status, headers, config) {
  450. HourlyArchiveItems = data;
  451. deferred.resolve(HourlyArchiveItems);
  452. return deferred.promise;
  453. })
  454. .error(function(data, status, headers, config) {
  455.  
  456. })
  457. return deferred.promise;
  458. }
  459. }
  460. function AdBankFcy($http,$q,Configs){
  461. var adBank = {};
  462. var factory = {
  463. getAdBankList:GetAdBankList,
  464. getAdBankById:GetAdBankById
  465. }
  466. return factory;
  467. function GetAdBankList(limit,offset,token){
  468. var deferred = $q.defer();
  469. $http.get(Configs.MasterAdminWebserviceUrl+'' +'/op?action=getModelList&model=adbank&offset='+offset+'&limit='+limit+'&token='+token)
  470. .success(function(data, status, headers, config) {
  471. adBank = data;
  472. deferred.resolve(adBank);
  473. return deferred.promise;
  474. })
  475. .error(function(data, status, headers, config) {
  476.  
  477. })
  478. return deferred.promise;
  479. }
  480. function GetAdBankById(Id,token) {
  481. var deferred = $q.defer();
  482. $http.get(Configs.MasterAdminWebserviceUrl + '/?action=getModel&model=adbank&id=' + Id + "&token=" + token)
  483. .success(function (data, status, headers, config) {
  484. adBank = data;
  485. deferred.resolve(adBank);
  486. return deferred.promise;
  487. })
  488. .error(function (data, status, headers, config) {
  489. //$window.location.replace('/#!/404');
  490. })
  491. return deferred.promise;
  492. }
  493. }
  494. function UserFcy($http,$q,Configs){
  495. var UsersList = {};
  496. var User = {};
  497. var factory = {
  498. getUsers:GetUsers,
  499. getUserByEmail:GetUserByEmail,
  500. getUserById: GetUserById
  501. }
  502. return factory;
  503. function GetUserById(Id, token) {
  504. var deferred = $q.defer();
  505. $http.get(Configs.MasterAdminWebserviceUrl + '/?action=getModel&model=user&id=' + Id + "&token=" + token)
  506. .success(function (data, status, headers, config) {
  507. User = data;
  508. deferred.resolve(User);
  509. return deferred.promise;
  510. })
  511. .error(function (data, status, headers, config) {
  512. $window.location.replace('/#!/404');
  513. })
  514. return deferred.promise;
  515. }
  516.  
  517. function GetUsers(limit,offset,token) {
  518. var deferred = $q.defer();
  519. $http.get(Configs.MasterAdminWebserviceUrl+'' +'/op?action=getModelList&model=user&offset='+offset+'&limit='+limit+'&token='+token)
  520. .success(function(data, status, headers, config) {
  521. UsersList = data;
  522. deferred.resolve(UsersList);
  523. return deferred.promise;
  524. })
  525. .error(function(data, status, headers, config) {
  526.  
  527. })
  528. return deferred.promise;
  529. }
  530. function GetUserByEmail(email,phone,token) {
  531. var deferred = $q.defer();
  532. if(email==null && phone!=null) {
  533. $http.get(Configs.MasterAdminWebserviceUrl + '' + '/op?action=getModelList&model=user&offset=0&limit=100&token=' + token + '&mobile=' + phone)
  534. .success(function (data, status, headers, config) {
  535. User = data;
  536. deferred.resolve(User);
  537. return deferred.promise;
  538. })
  539. .error(function (data, status, headers, config) {
  540.  
  541. })
  542. return deferred.promise;
  543. }else if(phone==null && email != null){
  544. $http.get(Configs.MasterAdminWebserviceUrl + '' + '/op?action=getModelList&model=user&offset=0&limit=100&token=' + token + '&email=' + email)
  545. .success(function (data, status, headers, config) {
  546. User = data;
  547. deferred.resolve(User);
  548. return deferred.promise;
  549. })
  550. .error(function (data, status, headers, config) {
  551.  
  552. })
  553. return deferred.promise;
  554. }else{
  555. $http.get(Configs.MasterAdminWebserviceUrl + '' + '/op?action=getModelList&model=user&offset=0&limit=100&token=' + token + '&email=' + email + '&mobile=' + phone)
  556. .success(function (data, status, headers, config) {
  557. User = data;
  558. deferred.resolve(User);
  559. return deferred.promise;
  560. })
  561. .error(function (data, status, headers, config) {
  562.  
  563. })
  564. return deferred.promise;
  565. }
  566. }
  567. }
  568. function EpisodeFcy($http,$q,Configs,ChannelFcy,GeneralFunctions) {
  569. var OurRecommendations={};
  570. var AutoRequest = true;
  571. var Movies={};
  572. var TvShows={};
  573. var Kids={};
  574. var Newest={};
  575. var UserRecommendations={};
  576. var EpisodeByDateAndChannel={};
  577. var Episodes = {};
  578. var EpisodeList = {};
  579. var sortedLinks = {};
  580. var HourlyArchives = {};
  581. var factory = {
  582. getOurRecommendations: GetOurRecommendations,
  583. getMovies: GetMovies,
  584. getUserRecommendations:GetUserRecommendations,
  585. getTvShows:GetTvShows,
  586. getKids:GetKids,
  587. getEpisodeLists:GetEpisodeLists,
  588. getChannelNewestEpisodes:GetChannelNewestEpisodes,
  589. getNewestEpisodes:GetNewest,
  590. getCategoryEpisodes:GetCategoryEpisodes,
  591. getSortedMobileListByQuality: SortMobileLinkListByQuality,
  592. getHourlyArchiveByChannel:GetHourlyArchiveByChannel,
  593. getCustom:GetCustom,
  594. getEpisodeByDateAndChannel:GetEpisodeByDateAndChannel,
  595. getEpisodesByCategoryId:GetEpisodesByCategoryId,
  596. getEpisodeMoments:GetEpisodeMoments
  597. };
  598. var Custom = {};
  599. return factory;
  600. function GetEpisodeByDateAndChannel(date,channel_id,offset,limit) {
  601. var deferred = $q.defer();
  602. $http.get(Configs.MasterWebserviceUrl+'' +'/op?action=getContentArchivePrograms&offset='+offset+'&limit='+limit+'&channel_id='+channel_id+'&date='+date+'')
  603. .success(function(data, status, headers, config) {
  604. EpisodeByDateAndChannel = data;
  605. deferred.resolve(EpisodeByDateAndChannel);
  606. return deferred.promise;
  607. })
  608. .error(function(data, status, headers, config) {
  609.  
  610. })
  611. return deferred.promise;
  612. }
  613. function GetEpisodeLists(limit,offset,token) {
  614. var deferred = $q.defer();
  615. $http.get(Configs.MasterAdminWebserviceUrl+'' +'/op?action=getModelList&model=episode&offset='+offset+'&limit='+limit+'&token='+token)
  616. .success(function(data, status, headers, config) {
  617. EpisodeList = data;
  618. deferred.resolve(EpisodeList);
  619. return deferred.promise;
  620. })
  621. .error(function(data, status, headers, config) {
  622.  
  623. })
  624. return deferred.promise;
  625. }
  626. function GetCategoryEpisodes(Category,offset,limit){
  627. var deferred = $q.defer();
  628. var URL = null;
  629. switch (true){
  630. case (parseInt(Category) <= 55):
  631. URL = Configs.MasterWebserviceUrl+'/op?action=getNewestPrograms&channel_id='+Category+'&offset='+offset+'&limit='+limit+"&thumb_size=240"+"&nginxcache";
  632. break;
  633. case (parseInt(Category) == 110):
  634. URL = Configs.MasterWebserviceUrl+'/op?action=getFeaturedPrograms&offset='+offset+'&limit='+limit+"&thumb_size=240"+"&nginxcache";
  635. break;
  636. case (parseInt(Category) == 111):
  637. URL = Configs.MasterWebserviceUrl+'/op?action=getEpisodesByCategoryGenre&category_id=8,9&offset='+offset+'&limit='+limit+'&order_type=newest&thumb_size=240'+"&nginxcache";
  638. break;
  639. case (parseInt(Category) == 112):
  640. URL = Configs.MasterWebserviceUrl+'/op?action=getNewestPrograms&offset='+offset+'&limit='+limit+"&thumb_size=240"+"&nginxcache";
  641. break;
  642. case (parseInt(Category) == 113):
  643. URL = Configs.MasterWebserviceUrl+'/op?action=getProgramsByCategoryGenre&category_id=10,11&offset='+offset+'&limit='+limit+'&order_type=newest'+"&thumb_size=240"+"&nginxcache";
  644. break;
  645. case (parseInt(Category) == 114):
  646. URL = Configs.MasterWebserviceUrl+'/op?action=getMostViewedPrograms&offset='+offset+'&order_type=newest&limit='+limit+"&thumb_size=240&type=4";
  647. break;
  648. case (parseInt(Category) == 115):
  649. URL = Configs.MasterWebserviceUrl+'/op?action=getProgramsByCategoryGenre&category_id=12&offset='+offset+'&limit='+limit+'&order_type=most_viewed&thumb_size=240&nginxcache';
  650. break;
  651. case (parseInt(Category) == 117):
  652. URL = Configs.MasterWebserviceUrl+'/op?action=getFeaturedPrograms&favorite_list_id=372372&offset='+offset+'&limit='+limit+"&thumb_size=240"+"&nginxcache";
  653. break;
  654. case (parseInt(Category) > 1000):
  655. URL = Configs.MasterWebserviceUrl+'/op?action=getOtherEpisodes&offset='+offset+'&limit='+limit+'&thumb_size=240&program_id='+Category+"&nginxcache";
  656. break;
  657. default:
  658. URL = Configs.MasterWebserviceUrl+'/op?action=getFeaturedPrograms&offset='+offset+'&limit='+limit+"&thumb_size=240"+"&nginxcache";
  659. break;
  660. }
  661. $http.get(URL+"&nginxcache")
  662. .success(function(data, status, headers, config) {
  663. Episodes = data;
  664. deferred.resolve(Episodes);
  665. return deferred.promise;
  666. })
  667. .error(function(data, status, headers, config) {
  668.  
  669. })
  670. return deferred.promise;
  671. }
  672. function GetOurRecommendations(offset,limit) {
  673. var deferred = $q.defer();
  674. $http.get(Configs.MasterWebserviceUrl+'/op?action=getFeaturedPrograms&offset='+offset+'&limit='+limit+"&thumb_size=240"+"&nginxcache")
  675. .success(function(data, status, headers, config) {
  676. OurRecommendations = data;
  677. deferred.resolve(OurRecommendations);
  678. return deferred.promise;
  679. })
  680. .error(function(data, status, headers, config) {
  681.  
  682. })
  683. return deferred.promise;
  684. }
  685. function GetEpisodesByCategoryId(offset,limit,category_id) {
  686. var deferred = $q.defer();
  687. $http.get(Configs.MasterWebserviceUrl.replace("/op","")+'/v2/programs/getEpisodesByCategoryGenre?category_id='+category_id+'&offset='+offset+'&limit='+limit+'&order_type=newest')
  688. .success(function(data, status, headers, config) {
  689. OurRecommendations = data;
  690. deferred.resolve(OurRecommendations);
  691. return deferred.promise;
  692. })
  693. .error(function(data, status, headers, config) {
  694.  
  695. })
  696. return deferred.promise;
  697. }
  698. function GetMovies(offset,limit) {
  699. var deferred = $q.defer();
  700. $http.get(Configs.MasterWebserviceUrl+'/op?action=getEpisodesByCategoryGenre&category_id=8,9&offset='+offset+'&limit='+limit+'&order_type=newest&thumb_size=240'+"&nginxcache")
  701. .success(function(data, status, headers, config) {
  702. Movies = data;
  703. deferred.resolve(Movies);
  704. return deferred.promise;
  705. })
  706. .error(function(data, status, headers, config) {
  707.  
  708. })
  709. return deferred.promise;
  710. }
  711. function GetUserRecommendations(offset,limit) {
  712. var deferred = $q.defer();
  713. $http.get(Configs.MasterWebserviceUrl+'/op?action=getMostViewedPrograms&offset='+offset+'&limit='+limit+"&thumb_size=120&type=4"+"&nginxcache")
  714. .success(function(data, status, headers, config) {
  715. UserRecommendations = data;
  716. deferred.resolve(UserRecommendations);
  717. return deferred.promise;
  718. })
  719. .error(function(data, status, headers, config) {
  720.  
  721. })
  722. return deferred.promise;
  723. }
  724. function GetTvShows(offset,limit) {
  725. var deferred = $q.defer();
  726. $http.get(Configs.MasterWebserviceUrl+'/op?action=getProgramsByCategoryGenre&category_id=10,11&offset='+offset+'&limit='+limit+'&order_type=newest'+"&thumb_size=240"+"&nginxcache")
  727. .success(function(data, status, headers, config) {
  728. TvShows = data;
  729. deferred.resolve(TvShows);
  730. return deferred.promise;
  731. })
  732. .error(function(data, status, headers, config) {
  733.  
  734. })
  735. return deferred.promise;
  736. }
  737. function GetKids(offset,limit) {
  738. var deferred = $q.defer();
  739. $http.get(Configs.MasterWebserviceUrl+'/op?action=getByCategoryGenre&category_id=12&offset='+offset+'&limit='+limit+'&order_type=most_viewed'+"&thumb_size=240"+"&nginxcache")
  740. .success(function(data, status, headers, config) {
  741. Kids = data;
  742. deferred.resolve(Kids);
  743. return deferred.promise;
  744. })
  745. .error(function(data, status, headers, config) {
  746.  
  747. })
  748. return deferred.promise;
  749. }
  750. function GetNewest(offset,limit) {
  751. var deferred = $q.defer();
  752. $http.get(Configs.MasterWebserviceUrl+'/op?action=getNewestPrograms&offset='+offset+'&limit='+limit+"&thumb_size=120"+"&nginxcache")
  753. .success(function(data, status, headers, config) {
  754. Newest = data;
  755. deferred.resolve(Newest);
  756. return deferred.promise;
  757. })
  758. .error(function(data, status, headers, config) {
  759.  
  760. })
  761. return deferred.promise;
  762. }
  763. function GetChannelNewestEpisodes(channel,offset,limit){
  764. var deferred = $q.defer();
  765. $http.get(Configs.MasterWebserviceUrl+'/op?action=getNewestPrograms&channel_id='+channel+'&offset='+offset+'&limit='+limit+"&thumb_size=240"+"&nginxcache")
  766. .success(function(data, status, headers, config) {
  767. Newest = data;
  768. deferred.resolve(Newest);
  769. return deferred.promise;
  770. })
  771. .error(function(data, status, headers, config) {
  772.  
  773. })
  774. return deferred.promise;
  775. }
  776. function SortMobileLinkListByQuality(list){
  777. var tempItem=null;
  778. var deferred = $q.defer();
  779. for(var i=0;i<=list.length-1;i++){
  780. if(list[i].title==Configs.DefaultBitrate.Mobile.Vod){
  781. tempItem=i;
  782. }
  783. }
  784. if(tempItem!==null && tempItem!=0){
  785. var tempArray=list[tempItem];
  786. list.splice(tempItem,1);
  787. list.unshift(tempArray);
  788. }
  789. deferred.resolve(list);
  790. return deferred.promise;
  791. }
  792. function GetHourlyArchiveByChannel(date,channel){
  793. var deferred = $q.defer();
  794. $http.get(Configs.MasterWebserviceUrl+"/op?action=getHourlyArchivePrograms&channel_id="+channel+"&date="+date+"&nginxcache")
  795. .success(function(data, status, headers, config) {
  796. HourlyArchives = data;
  797. deferred.resolve(HourlyArchives);
  798. return deferred.promise;
  799. })
  800. .error(function(data, status, headers, config) {
  801.  
  802. })
  803. return deferred.promise;
  804. }
  805. function GetCustom(Type,offset,limit){
  806. var deferred = $q.defer();
  807. $http.get(Configs.MasterWebserviceUrl+'/op?action=getFeaturedPrograms&favorite_list_id='+Type+'&offset='+offset+'&limit='+limit+"&thumb_size=120"+"&nginxcache")
  808. .success(function(data, status, headers, config) {
  809. Custom = data;
  810. deferred.resolve(Custom);
  811. return deferred.promise;
  812. })
  813. .error(function(data, status, headers, config) {
  814.  
  815. })
  816. return deferred.promise;
  817. }
  818. function GetEpisodeMoments(Episode){
  819. var deferred = $q.defer();
  820. $http.get(Configs.MasterWebserviceUrl+'/programs/getEpisodeMoments?episode_id='+Episode+"&nginxcache")
  821. .success(function(data, status, headers, config) {
  822. Custom = data;
  823. deferred.resolve(Custom);
  824. return deferred.promise;
  825. })
  826. .error(function(data, status, headers, config) {
  827.  
  828. })
  829. return deferred.promise;
  830. }
  831. }
  832. function UtilityFcy() {
  833. var factory = {
  834. in_array: InArray
  835. };
  836. return factory;
  837. function InArray(needle, haystack) {
  838. var length = haystack.length;
  839. for(var i = 0; i < length-1; i++) {
  840. if(haystack[i] == needle) return true;
  841. }
  842. return false;
  843. }
  844. }
  845. function SecurityFcy($http,$q,Configs,CacheFactory,UtilityFcy,$rootScope,Messages){
  846. var TokenData={};
  847. var Links=[];
  848. var factory = {
  849. getToken: GetToken,
  850. generateVodSmilLink:GenerateVodSmilLink,
  851. generateValidVodSource:GenerateValidVodSource,
  852. generateVodNdLink:GenerateVodNdLink,
  853. getDefaultLiveLink:GetDefaultLiveLink,
  854. getDownloadToken: GetDownloadToken,
  855. setCookieByToken: SetCookieByToken,
  856. getUserToken: GetUserToken,
  857. userHasPermission: UserHasPermission,
  858. getAdvertisement: GetAdvertisement,
  859. parsVas2: ParsVas2
  860. };
  861. return factory;
  862.  
  863. function GetDownloadToken(){
  864. var deferred = $q.defer();
  865. deferred.resolve(Cookie.Read("tw-status").substring(44)?Cookie.Read("tw-status").substring(44):'not-log-in');
  866. return deferred.promise;
  867. }
  868. function GetToken(){
  869. var deferred = $q.defer();
  870. $http.get(Configs.MasterWebserviceUrl+'/op?action=getSecurityToken',{cache: CacheFactory.get('AuthenticationCache')})
  871. .success(function(data, status, headers, config) {
  872. TokenData = data;
  873. deferred.resolve(TokenData);
  874. });
  875. return deferred.promise;
  876. }
  877. function ParsVas2(xmlAd){
  878. output={};
  879. var deferred = $q.defer();
  880. xmlDoc = $.parseXML(xmlAd),
  881. $xml = $( xmlDoc ),
  882. $mediaFiles = $xml.find("MediaFile");
  883. $clicks = $xml.find("VideoClicks");
  884. $events = $xml.find("Tracking");
  885. if (typeof $mediaFiles[0] != "undefined" && $mediaFiles[0] != "undefined" && typeof $mediaFiles[0]["textContent"]!="undefined" && $mediaFiles[0]["textContent"]!=''){
  886. output.src=$mediaFiles[0]["textContent"].trim();
  887. output.onClick=$clicks[0]["textContent"].trim();
  888. output.onComplete=$events[3]["textContent"].trim();
  889. output.onStart=$events[0]["textContent"].trim();
  890. }
  891. deferred.resolve(output);
  892. return deferred.promise;
  893. }
  894. function GetUserToken(){
  895. var deferred = $q.defer();
  896. var token=Cookie.Read("tw-status")!==''?Cookie.Read("tw-status"):'not-log-in';
  897. deferred.resolve(token);
  898. return deferred.promise;
  899. }
  900. function GenerateVodSmilLink(links,episodeId,type,secureToken){
  901. var SmilLinks=[];
  902. type = typeof type !== 'undefined' ? type : 'JwPlayer';
  903. secureToken = typeof secureToken !== 'undefined' ? secureToken : GetToken();
  904. var deferred = $q.defer();
  905. for(var i=0;i<links.length;i++){
  906. if(type=='JwPlayer'){
  907. SmilLinks.push(Configs.VodSmilServerUrl+'/'+ episodeId +'.smil?filepath=' + links[i]+"&ext=.smil");
  908. }
  909. else if(type == 'OsmfPlayer'){
  910. SmilLinks.push(Configs.VodSmilServerUrl+'/'+ episodeId +'.m3u8?filepath=' + links[i]+"&amp;m3u8=1&amp;format=smil&amp;secure_token="+secureToken+";ext=.m3u8");
  911. }
  912. }
  913. deferred.resolve(SmilLinks);
  914. return deferred.promise;
  915. }
  916. function GenerateValidVodSource(rawLinks){
  917. var deferred = $q.defer();
  918. for (var i=0;i<rawLinks.length;i++) {
  919. Links.push(rawLinks[i].link);
  920. }
  921. deferred.resolve(Links);
  922. return deferred.promise;
  923. }
  924. function GenerateVodNdLink(rawLinks){
  925. var deferred = $q.defer();
  926. var ndLinks=[];
  927. var Links=[];
  928. for(var i=0;i<rawLinks.length;i++){
  929. var tempLink=rawLinks[i].link;
  930. var tempArrayLink=tempLink.split('/');
  931. var getDomain= tempArrayLink[2].split(':');
  932. tempLink="http://nd."+getDomain[0]+'/'+tempArrayLink[5]+'/'+'/'+tempArrayLink[6]+'/'+tempArrayLink[7]+'/'+tempArrayLink[8]+'/'+tempArrayLink[9]+'/'+tempArrayLink[10]+'/'+tempArrayLink[11];
  933. ndLinks.push(tempLink);
  934. rawLinks[i].link=tempLink;
  935. }
  936. Links.push(rawLinks);
  937. Links.push(ndLinks);
  938. deferred.resolve(Links);
  939. return deferred.promise;
  940. }
  941. function GetDefaultLiveLink(Links){
  942. var Link={};
  943. if(Links.length==1 && Links[0]['title']=='copyright'){
  944. NgNote.Error(Messages.Fa.CopyrightErrorLive,30);
  945. }
  946. var deferred = $q.defer();
  947. for(var i=0;i<Links.length;i++){
  948. if(Links[i].isDefault==true){
  949. Link.Link=Links[i].link;
  950. Link.Index=i;
  951. }
  952. }
  953. deferred.resolve(Link);
  954. return deferred.promise;
  955. }
  956. function SetCookieByToken(token){
  957. Cookie.Create("tw-status",token,10);
  958. }
  959. function UserHasPermission(Permission) {
  960. var deferred = $q.defer();
  961. for(var i = 0; i<=Permission.length; i++){
  962. if(typeof $rootScope.User !='undefined' && typeof $rootScope.User.credentials !='undefined'){
  963. deferred.resolve(UtilityFcy.in_array(Permission[i],$rootScope.User.credentials));
  964. return deferred.promise;
  965. }
  966. }
  967. return deferred.promise;
  968. }
  969. function GetAdvertisement(type,target) {
  970. var device;
  971. if(type=="mobile"){
  972. device="mobile";
  973. }
  974. else{
  975. device="desktop";
  976. }
  977. var deferred = $q.defer();
  978. $http.get(Configs.MasterWebserviceUrl+"/ads/serveAds?device="+device+"&target="+target,{cache: CacheFactory.get('PreroleAd')})
  979. .success(function(data, status, headers, config) {
  980. TokenData = data;
  981. deferred.resolve(TokenData);
  982. });
  983. return deferred.promise;
  984. }
  985. }
  986. function ProgramFcy($http,$q,Configs) {
  987. var OtherEpisodes = {};
  988. var ProgramWithFilter = {};
  989. var factory = {
  990. getKids:GetKids,
  991. getTvShows:GetTvShows,
  992. getProgramList:GetProgramList,
  993. getProgramWithFilter:GetProgramWithFilter,
  994. getOtherEpisodesOfThisProgram: GetOtherEpisodesOfThisProgram,
  995. searchByName: SearchByName,
  996. searchCountryByName:SearchCountryByName
  997. };
  998. return factory;
  999. function SearchByName(context, token, offset, limit) {
  1000. var deferred = $q.defer();
  1001. $http.get(Configs.MasterAdminWebserviceUrl+ '/op?action=getModelItemListByContext&model=program'+'&search_context='+context+'&offset='+offset+'&limit='+limit+"&token="+token)
  1002. .success(function(data, status, headers, config) {
  1003. deferred.resolve(data);
  1004. return deferred.promise;
  1005. })
  1006. .error(function(data, status, headers, config) {
  1007.  
  1008. })
  1009. return deferred.promise;
  1010. }
  1011. function SearchCountryByName(context, token, offset, limit) {
  1012. var deferred = $q.defer();
  1013. $http.get(Configs.MasterAdminWebserviceUrl+ '/op?action=getModelItemListByContext&model=country'+'&search_context='+context+'&offset='+offset+'&limit='+limit+"&token="+token)
  1014. .success(function(data, status, headers, config) {
  1015. deferred.resolve(data);
  1016. return deferred.promise;
  1017. })
  1018. .error(function(data, status, headers, config) {
  1019.  
  1020. })
  1021. return deferred.promise;
  1022. }
  1023. function GetProgramList(offset,limit,token) {
  1024. var deferred = $q.defer();
  1025. $http.get(Configs.MasterAdminWebserviceUrl + '/op?action=getModelList&model=program&offset='+offset+'&limit='+limit+'&token='+token+'')
  1026. .success(function (data, status, headers, config) {
  1027. OtherEpisodes = data;
  1028. deferred.resolve(OtherEpisodes);
  1029. return deferred.promise;
  1030. })
  1031. .error(function (data, status, headers, config) {
  1032.  
  1033. })
  1034. return deferred.promise;
  1035. }
  1036. function GetProgramWithFilter(offset,limit,token,channel_id,from_date,to_date,status,singleton,title) {
  1037. var deferred = $q.defer();
  1038. $http.get(Configs.MasterAdminWebserviceUrl + '/op?action=getModelList&model=program&offset='+offset+
  1039. '&limit='+limit+'&token='+token+'&channel_id='+channel_id+'&from_date='+from_date+'&to_date='+to_date+'&signleton='+singleton+'&status='+status+'&title='+title)
  1040. .success(function (data, status, headers, config) {
  1041. ProgramWithFilter = data;
  1042. deferred.resolve(ProgramWithFilter);
  1043. return deferred.promise;
  1044. })
  1045. .error(function (data, status, headers, config) {
  1046.  
  1047. })
  1048. return deferred.promise;
  1049. }
  1050. function GetOtherEpisodesOfThisProgram(offset, limit, programId) {
  1051. var deferred = $q.defer();
  1052. $http.get(Configs.MasterWebserviceUrl + '/op?action=getOtherEpisodes&offset=' + offset + '&limit=' + limit + "&thumb_size=240&program_id="+programId+"&nginxcache")
  1053. .success(function (data, status, headers, config) {
  1054. OtherEpisodes = data;
  1055. deferred.resolve(OtherEpisodes);
  1056. return deferred.promise;
  1057. })
  1058. .error(function (data, status, headers, config) {
  1059.  
  1060. })
  1061. return deferred.promise;
  1062. }
  1063. function GetKids(offset,limit) {
  1064. var Kids={};
  1065. var deferred = $q.defer();
  1066. $http.get(Configs.MasterWebserviceUrl+'/op?action=getProgramsByCategoryGenre&category_id=12&offset='+offset+'&limit='+limit+'&order_type=newest'+"&thumb_size=240"+"&nginxcache")
  1067. .success(function(data, status, headers, config) {
  1068. Kids = data;
  1069. deferred.resolve(Kids);
  1070. return deferred.promise;
  1071. })
  1072. .error(function(data, status, headers, config) {
  1073.  
  1074. })
  1075. return deferred.promise;
  1076. }
  1077. function GetTvShows(offset,limit) {
  1078. var deferred = $q.defer();
  1079. $http.get(Configs.MasterWebserviceUrl+'/op?action=getProgramsByCategoryGenre&category_id=10,11&offset='+offset+'&limit='+limit+'&order_type=newest'+"&thumb_size=240"+"&nginxcache")
  1080. .success(function(data, status, headers, config) {
  1081. TvShows = data;
  1082. deferred.resolve(TvShows);
  1083. return deferred.promise;
  1084. })
  1085. .error(function(data, status, headers, config) {
  1086.  
  1087. })
  1088. return deferred.promise;
  1089. }
  1090. }
  1091. function ProgressBarFcy(){
  1092. var Bar={};
  1093. var factory = {
  1094. getStatus:Get,
  1095. plus:Plus,
  1096. setDone:Done,
  1097. setStatus:Set
  1098. };
  1099. return factory;
  1100. function Get(){
  1101. return Bar.Status;
  1102. }
  1103. function Plus(Amount){
  1104. Bar.Status+=Amount;
  1105. Set(Bar.Status);
  1106. }
  1107. function Done(){
  1108. NProgress.done();
  1109. }
  1110. function Set(Amount){
  1111. Bar.Status=NProgress.set(Amount).status;
  1112. if(Bar.Status>0.95)
  1113. {
  1114. Done();
  1115. }
  1116. }
  1117. }
  1118. function ArtistFcy($http,$q,Configs) {
  1119. var factory = {
  1120. searchByName: SearchByName
  1121. };
  1122. return factory;
  1123.  
  1124. function SearchByName(context, token, offset, limit) {
  1125. var deferred = $q.defer();
  1126. $http.get(Configs.MasterWebserviceUrl+ 'op?action=getModelItemListByContext&model=artist'+'&search_context='+context+'&offset='+offset+'&limit='+limit+"&token="+token)
  1127. .success(function(data, status, headers, config) {
  1128. deferred.resolve(data);
  1129. return deferred.promise;
  1130. })
  1131. .error(function(data, status, headers, config) {
  1132.  
  1133. })
  1134. return deferred.promise;
  1135. }
  1136. }
  1137. function FavoriteListFcy($http,$q,Configs) {
  1138. var factory = {
  1139. searchByName: SearchByName,
  1140. getList: GetList,
  1141. deleteList: Delete,
  1142. getEpisodeList: GetEpisodes
  1143. };
  1144. return factory;
  1145.  
  1146. function SearchByName(context, token, offset, limit) {
  1147. var deferred = $q.defer();
  1148. $http.get(Configs.MasterAdminWebserviceUrl +'/?action=getModelItemListByContext&model=favorite_list'+'&search_context='+context+'&offset='+offset+'&limit='+limit+"&token="+token)
  1149. .success(function(data, status, headers, config) {
  1150. deferred.resolve(data);
  1151. return deferred.promise;
  1152. })
  1153. .error(function(data, status, headers, config) {
  1154.  
  1155. })
  1156. return deferred.promise;
  1157. }
  1158.  
  1159. function GetList(offset, limit, id, token) {
  1160. var deferred = $q.defer();
  1161. if(typeof id == 'undefined' || id == 0){
  1162. id=0;
  1163. }
  1164. $http.get(Configs.MasterAdminWebserviceUrl +'/?action=getModelList&model=favorite_list&offset='+offset+'&limit='+limit+'&id='+id+'&token='+token)
  1165. .success(function(data, status, headers, config) {
  1166. deferred.resolve(data);
  1167. return deferred.promise;
  1168. })
  1169. .error(function(data, status, headers, config) {
  1170.  
  1171. })
  1172. return deferred.promise;
  1173. }
  1174.  
  1175. function GetEpisodes(id, offset, limit) {
  1176. var deferred = $q.defer();
  1177. $http.get(Configs.MasterWebserviceUrl +'/op?action=getFavoritListEpisodes&favorite_list_id='+id+'&offset='+offset+'&limit='+limit)
  1178. .success(function(data, status, headers, config) {
  1179. deferred.resolve(data);
  1180. return deferred.promise;
  1181. })
  1182. .error(function(data, status, headers, config) {
  1183.  
  1184. })
  1185. return deferred.promise;
  1186. }
  1187.  
  1188. function Delete(id, token) {
  1189. var deferred = $q.defer();
  1190. $http.get(Configs.MasterAdminWebserviceUrl +'/?action=deleteModel&model=favorite_list&id='+id+'&token='+token)
  1191. .success(function(data, status, headers, config) {
  1192. deferred.resolve(data);
  1193. return deferred.promise;
  1194. })
  1195. .error(function(data, status, headers, config) {
  1196.  
  1197. })
  1198. return deferred.promise;
  1199. }
  1200. }
  1201. function TagPageFcy($http,$q,Configs) {
  1202. var tagItems = {Programs:{},Episodes:{}};
  1203. var factory = {
  1204. getTagPrograms:GetTagPrograms,
  1205. getTagEpisodes:GetTagEpisodes
  1206. }
  1207. return factory;
  1208. function GetTagPrograms(limit,offset,name) {
  1209. var deferred = $q.defer();
  1210. $http.get((Configs.MasterWebserviceUrl).replace("/op","")+ '/v2/tags/getTagProgram?offset='+offset+'&limit='+limit+'&tag='+name+'')
  1211. .success(function(data, status, headers, config) {
  1212. deferred.resolve(data);
  1213. return deferred.promise;
  1214. })
  1215. .error(function(data, status, headers, config) {
  1216.  
  1217. })
  1218. return deferred.promise;
  1219.  
  1220. }
  1221. function GetTagEpisodes(limit,offset,name) {
  1222. var deferred = $q.defer();
  1223. $http.get((Configs.MasterWebserviceUrl).replace("/op","")+ '/v2/tags/getTagEpisodes?offset='+offset+'&limit='+limit+'&tag='+name+'')
  1224. .success(function(data, status, headers, config) {
  1225. deferred.resolve(data);
  1226. return deferred.promise;
  1227. })
  1228. .error(function(data, status, headers, config) {
  1229.  
  1230. })
  1231. return deferred.promise;
  1232.  
  1233. }
  1234. }
  1235. function TagFcy($http,$q,Configs) {
  1236. var factory = {
  1237. searchByName: SearchByName
  1238. };
  1239. return factory;
  1240.  
  1241. function SearchByName(context, token, offset, limit) {
  1242. var deferred = $q.defer();
  1243. $http.get(Configs.MasterWebserviceUrl +'/op?action=getModelItemListByContext&model=tag'+'&search_context='+context+'&offset='+offset+'&limit='+limit+"&token="+token)
  1244. .success(function(data, status, headers, config) {
  1245. deferred.resolve(data);
  1246. return deferred.promise;
  1247. })
  1248. .error(function(data, status, headers, config) {
  1249.  
  1250. })
  1251. return deferred.promise;
  1252. }
  1253. }
  1254. function ImageUploadFcy($http,$q,Configs) {
  1255. var factory = {
  1256. upload: Upload
  1257. };
  1258. return factory;
  1259.  
  1260. function Upload(data,model, token, id, type){
  1261. var deferred = $q.defer();
  1262. $http({
  1263. method: 'POST',
  1264. url: Configs.MasterAdminWebserviceUrl + '/?action=uploadImage&model='+model+"&token="+token+"&id="+id+"&type="+type,
  1265. headers: {
  1266. 'Access-Control-Allow-Headers': 'Content-Type',
  1267. 'Access-Control-Allow-Methods': 'GET, POST, OPTIONS',
  1268. 'Access-Control-Allow-Origin': '*'
  1269. },
  1270. data: {image: data}
  1271. }).then(function(result){
  1272. deferred.resolve(result);
  1273. }, function(result){
  1274. deferred.resolve(result);
  1275. });
  1276. return deferred.promise;
  1277. }
  1278. }
  1279. function PromotionFcy($http,$q,Configs) {
  1280. var Promotions = {};
  1281. var factory = {
  1282. getPromotions:GetPromotions,
  1283. getPromotionById:GetPromotionById
  1284. }
  1285. return factory;
  1286. function GetPromotionById(token, id) {
  1287. var deferred = $q.defer();
  1288. $http.get(Configs.MasterAdminWebserviceUrl +'/op?action=getModel&model=promotion&id='+id+'&token='+token)
  1289. .success(function(data, status, headers, config) {
  1290. deferred.resolve(data);
  1291. return deferred.promise;
  1292. })
  1293. .error(function(data, status, headers, config) {
  1294.  
  1295. })
  1296. return deferred.promise;
  1297. }
  1298. function GetPromotions(offset,limit,token) {
  1299. var deferred = $q.defer();
  1300. $http.get(Configs.MasterAdminWebserviceUrl +'/?action=getModelList&model=promotion&offset='+offset+'&limit='+limit+'&token='+token).success(function (data) {
  1301. deferred.resolve(data);
  1302. return deferred.promise;
  1303. }).error(function (data, status, headers, config) {
  1304.  
  1305. })
  1306. return deferred.promise;
  1307. }
  1308. }
  1309. function AdsFcy($http,$q,Configs) {
  1310. var factory = {
  1311. getAll: GetAll
  1312. };
  1313. return factory;
  1314.  
  1315. function GetAll(token, offset, limit) {
  1316. var deferred = $q.defer();
  1317. $http.get(Configs.MasterWebserviceUrl +'/op?action=getModel&model=ads'+'&offset='+offset+'&limit='+limit+"&token="+token)
  1318. .success(function(data, status, headers, config) {
  1319. deferred.resolve(data);
  1320. return deferred.promise;
  1321. })
  1322. .error(function(data, status, headers, config) {
  1323.  
  1324. })
  1325. return deferred.promise;
  1326. }
  1327. }
  1328. function VasFcy($http,$q,Configs) {
  1329. var factory = {
  1330. checkStatus: CheckStatus
  1331. };
  1332. return factory;
  1333.  
  1334. function CheckStatus(checkURL) {
  1335. var deferred = $q.defer();
  1336. $http.get(checkURL, {timeout: 3000})
  1337. .success(function(data, status, headers, config) {
  1338. deferred.resolve(true);
  1339. return deferred.promise;
  1340. })
  1341. .error(function(data, status, headers, config) {
  1342. deferred.resolve(false);
  1343. return deferred.promise;
  1344. })
  1345. return deferred.promise;
  1346. }
  1347. }
  1348.  
  1349.  
  1350. angular
  1351. .module('tw-service',[])
  1352. .service('ChannelSrv', ChannelSrv)
  1353. .service('UserSrv', UserSrv)
  1354. .service('EpisodeSrv', EpisodeSrv)
  1355. .service('ProgramSrv', ProgramSrv)
  1356. .service('ArtistSrv', ArtistSrv)
  1357. .service('FavoriteListSrv', FavoriteListSrv)
  1358. .service('AdsSrv', AdsSrv)
  1359. .service('PromotionsSrv', PromotionsSrv)
  1360. .service('RoutingSrv', RoutingSrv)
  1361. .service('AdBankSrv', AdBankSrv);
  1362.  
  1363.  
  1364. UserSrv.$inject = ['$http','$q','md5','Configs','CacheFactory'];
  1365. ChannelSrv.$inject = ['$http','$q','Configs'];
  1366. EpisodeSrv.$inject = ['$http','$q','Configs','$window','$rootScope'];
  1367. ProgramSrv.$inject = ['$http','$q','Configs','$window'];
  1368. RoutingSrv.$inject = ['$http','$q','Configs'];
  1369. ArtistSrv.$inject = ['$http','$q','Configs'];
  1370. AdsSrv.$inject = ['$http','$q','Configs'];
  1371. PromotionsSrv.$inject = ['$http','$q','Configs'];
  1372. AdBankSrv.$inject = ['$http','$q','Configs','$window'];
  1373. FavoriteListSrv.$inject = ['$http','$q','Configs'];
  1374.  
  1375. function UserSrv($http,$q,md5,Configs,CacheFactory) {
  1376. var User={};
  1377. var deletedUser = {};
  1378. var service = {
  1379. getUser: Get,
  1380. updateUser: Update,
  1381. registerUser: Register,
  1382. logoutUser: Logout,
  1383. loginUser: Login,
  1384. deleteUser: DeleteUser,
  1385. VerifyRegistration: Verify,
  1386. forgotPasswordUser:ForgotPassword,
  1387. resendVerificationEmail:ResendVerificationEmail,
  1388. validateResetPasswordToken: ValidateResetPasswordToken,
  1389. resetPassword: ResetPassword,
  1390. unsubscribe: Unsubscribe
  1391. };
  1392. return service;
  1393. function DeleteUser(id,token) {
  1394. var deferred = $q.defer();
  1395. $http.post(Configs.MasterAdminWebserviceUrl+'/op?action=deleteModel&model=user&id='+id+'&token='+token)
  1396. .success(function(data, status, headers, config) {
  1397. deletedUser=data;
  1398. deferred.resolve(deletedUser);
  1399. return deferred.promise;
  1400. })
  1401. .error(function(data, status, headers, config) {
  1402. $window.location.replace('/#!/404');
  1403. })
  1404. return deferred.promise;
  1405. }
  1406. function Get() {
  1407. try{
  1408. CacheFactory('AuthenticationCache', {
  1409. maxAge: 180 * 60 * 1000,cacheFlushInterval: 120 * 60 * 1000, deleteOnExpire: 'aggressive'
  1410. });
  1411. CacheFactory('PreroleAd', {
  1412. maxAge: 100,cacheFlushInterval: 100, deleteOnExpire: 'aggressive'
  1413. });
  1414. }catch(e){
  1415.  
  1416. }
  1417. var deferred = $q.defer();
  1418. /*$http.get(Configs.MasterWebserviceUrl+'/ops?action=getCredentials',{cache: CacheFactory.get('AuthenticationCache')})*/
  1419. var token=Cookie.Read("tw-status");
  1420. $http.get(Configs.MasterWebserviceUrl+'/user/getUserInfo?token='+quote(token), {cache: CacheFactory.get('AuthenticationCache')})
  1421. .success(function(data, status, headers, config) {
  1422. User = data;
  1423. deferred.resolve(User);
  1424. return deferred.promise;
  1425. })
  1426. .error(function(data, status, headers, config) {
  1427.  
  1428. })
  1429. return deferred.promise;
  1430. }
  1431.  
  1432. function Update(Id,fname,gender,mobile,status,token) {
  1433. var deferred = $q.defer();
  1434. $http.post(Configs.MasterAdminWebserviceUrl+'/op?action=saveModel&model=user&token='+token,{user_id:Id,user_fullname:fname,
  1435. user_gender:gender, user_mobile:mobile, user_status:status})
  1436. .success(function(data, status, headers, config) {
  1437. User=data;
  1438. deferred.resolve(User);
  1439. return deferred.promise;
  1440. })
  1441. .error(function(data, status, headers, config) {
  1442. $window.location.replace('/#!/404');
  1443. });
  1444. return deferred.promise;
  1445. }
  1446.  
  1447. function Logout() {
  1448. CacheFactory.destroy('AuthenticationCache');
  1449. Cookie.Delete("tw-status");
  1450. }
  1451.  
  1452. function ForgotPassword(Email){
  1453. var deferred = $q.defer();
  1454. if(typeof Email != 'undefined' && Email) {
  1455. $http.post(Configs.MasterWebserviceUrl+'/user/requestResetPassword',{'email': Email} )
  1456. .success(function (data, status, headers, config) {
  1457. User = data;
  1458. deferred.resolve(User);
  1459. return deferred.promise;
  1460. })
  1461. .error(function (data, status, headers, config) {
  1462.  
  1463. })
  1464. return deferred.promise;
  1465. }
  1466. else
  1467. {
  1468. return false;
  1469. }
  1470. }
  1471.  
  1472. function Login(User) {
  1473. var deferred = $q.defer();
  1474. if(typeof User.Email != 'undefined' && User.Email && User.Password && typeof User.Password != 'undefined') {
  1475. $http.post(Configs.MasterWebserviceUrl+'/user/authenticateUser', {'username': User.Email, 'password': md5.createHash(User.Password || '')})
  1476. .success(function (data, status, headers, config) {
  1477. User = data;
  1478. Cookie.Create("tw-status",User.token,10);
  1479. deferred.resolve(User);
  1480. CacheFactory.destroy('AuthenticationCache');
  1481. return deferred.promise;
  1482. })
  1483. .error(function (data, status, headers, config) {
  1484.  
  1485. })
  1486. return deferred.promise;
  1487. }
  1488. else
  1489. {
  1490. return false;
  1491. }
  1492. }
  1493.  
  1494. function Register(User){
  1495. var deferred = $q.defer();
  1496. if(typeof User.Name != 'undefined' && User.Name && typeof User.Email != 'undefined' && User.Email && typeof User.Password != 'undefined') {
  1497. $http.post(Configs.MasterWebserviceUrl+'/user/registerUser', {'phone':User.phone,'name': User.Name, 'email': User.Email, 'password': md5.createHash(User.Password || '')})
  1498. .success(function (data, status, headers, config) {
  1499. User = data;
  1500. deferred.resolve(User);
  1501. return deferred.promise;
  1502. })
  1503. .error(function (data, status, headers, config) {
  1504.  
  1505. })
  1506. return deferred.promise;
  1507. }
  1508. else
  1509. {
  1510. return false;
  1511. }
  1512. }
  1513.  
  1514. function Verify(Username,VCode,HCode){
  1515. var deferred = $q.defer();
  1516. $http.post(Configs.MasterWebserviceUrl+'/user/userRegistrationConfirm', {'ue': Username, 'ik': VCode, 'ie': HCode})
  1517. .success(function (data, status, headers, config) {
  1518. User = data;
  1519. deferred.resolve(User);
  1520. return deferred.promise;
  1521. })
  1522. .error(function (data, status, headers, config) {
  1523.  
  1524. })
  1525. return deferred.promise;
  1526. }
  1527.  
  1528. function ResendVerificationEmail(Email){
  1529. var deferred = $q.defer();
  1530. $http.post(Configs.MasterWebserviceUrl+'/user/resendConfirmationEmail', {'email': Email, 'language': "fa"})
  1531. .success(function (data, status, headers, config) {
  1532. User = data;
  1533. deferred.resolve(User);
  1534. return deferred.promise;
  1535. })
  1536. .error(function (data, status, headers, config) {
  1537.  
  1538. })
  1539. return deferred.promise;
  1540. }
  1541.  
  1542. function ValidateResetPasswordToken(Token){
  1543. var deferred = $q.defer();
  1544. $http.post(Configs.MasterWebserviceUrl+'/user/validateResetPassword', {'token': Token})
  1545. .success(function (data, status, headers, config) {
  1546. User = data;
  1547. deferred.resolve(User);
  1548. return deferred.promise;
  1549. })
  1550. .error(function (data, status, headers, config) {
  1551.  
  1552. })
  1553. return deferred.promise;
  1554. }
  1555.  
  1556. function ResetPassword(Token,Password){
  1557. var deferred = $q.defer();
  1558. $http.post(Configs.MasterWebserviceUrl+'/user/resetPassword', {'token': Token, "password": md5.createHash(Password || '')})
  1559. .success(function (data, status, headers, config) {
  1560. User = data;
  1561. deferred.resolve(User);
  1562. return deferred.promise;
  1563. })
  1564. .error(function (data, status, headers, config) {
  1565.  
  1566. })
  1567. return deferred.promise;
  1568. }
  1569. function Unsubscribe(Email){
  1570. var deferred = $q.defer();
  1571. $http.post(Configs.MasterWebserviceUrl+'/user/unsubscribe', {'email': Email})
  1572. .success(function (data, status, headers, config) {
  1573. User = data;
  1574. deferred.resolve(User);
  1575. return deferred.promise;
  1576. })
  1577. .error(function (data, status, headers, config) {
  1578. deferred.resolve(false);
  1579. return deferred.promise;
  1580. })
  1581. return deferred.promise;
  1582. }
  1583. }
  1584. function PromotionsSrv($http,$q,Configs) {
  1585. var promotions={};
  1586. var promotion = {};
  1587. var service = {
  1588. createPromotion: CreatePromotion,
  1589. savePromotion: SavePromotion,
  1590. deletePromotion:DeletePromotion
  1591. };
  1592. return service;
  1593. function DeletePromotion(id, token) {
  1594. var deferred = $q.defer();
  1595. $http.post(Configs.MasterAdminWebserviceUrl+'/op?action=deleteModel&model=promotion&id='+id+'&token='+token)
  1596. .success(function(data, status, headers, config) {
  1597. promotion=data;
  1598. deferred.resolve(promotion);
  1599. return deferred.promise;
  1600. })
  1601. .error(function(data, status, headers, config) {
  1602. $window.location.replace('/#!/404');
  1603. })
  1604. return deferred.promise;
  1605. }
  1606. function CreatePromotion(promotion_category,promotion_description_fa,promotion_description_en,promotion_link,promotion_type,promotion_title,promotion_play_time,promotion_occasion,promotion_is_mobile,promotion_valid_from,promotion_valid_to,token) {
  1607. var deferred = $q.defer();
  1608. $http({
  1609. method: 'POST',
  1610. url: Configs.MasterAdminWebserviceUrl + '/op?action=createModel&model=promotion&token='+token,
  1611. headers: {
  1612. 'Access-Control-Allow-Headers': 'Content-Type',
  1613. 'Access-Control-Allow-Methods': 'GET, POST, OPTIONS',
  1614. 'Access-Control-Allow-Origin': '*'
  1615. },
  1616. data: { promotion_category:promotion_category,promotion_description_fa:promotion_description_fa,promotion_description_en:promotion_description_en,promotion_link:promotion_link,
  1617. promotion_type:promotion_type,promotion_title:promotion_title,promotion_play_time:promotion_play_time,promotion_occasion:promotion_occasion,promotion_is_mobile:promotion_is_mobile,
  1618. promotion_valid_from:promotion_valid_from,promotion_valid_to:promotion_valid_to}
  1619. }).then(function(result){
  1620. deferred.resolve(result);
  1621. }, function(result){
  1622. deferred.resolve(result);
  1623. });
  1624. return deferred.promise;
  1625. }
  1626. function SavePromotion(promotion_id,promotion_category,promotion_description_fa,promotion_description_en,promotion_link,promotion_type,promotion_title,promotion_play_time,promotion_occasion,promotion_is_mobile,promotion_valid_from,promotion_valid_to,token) {
  1627. var deferred = $q.defer();
  1628. $http({
  1629. method: 'POST',
  1630. url: Configs.MasterAdminWebserviceUrl + '/op?action=saveModel&model=promotion&token='+token,
  1631. headers: {
  1632. 'Access-Control-Allow-Headers': 'Content-Type',
  1633. 'Access-Control-Allow-Methods': 'GET, POST, OPTIONS',
  1634. 'Access-Control-Allow-Origin': '*'
  1635. },
  1636. data: {promotion_id:promotion_id, promotion_category:promotion_category,promotion_description_fa:promotion_description_fa,promotion_description_en:promotion_description_en,promotion_link:promotion_link,
  1637. promotion_type:promotion_type,promotion_title:promotion_title,promotion_play_time:promotion_play_time,promotion_occasion:promotion_occasion,promotion_is_mobile:promotion_is_mobile,
  1638. promotion_valid_from:promotion_valid_from,promotion_valid_to:promotion_valid_to}
  1639. }).then(function(result){
  1640. deferred.resolve(result.status);
  1641. }, function(result){
  1642. deferred.resolve(result.status);
  1643. });
  1644. return deferred.promise;
  1645. }
  1646. }
  1647. function ChannelSrv($http,$q,Configs) {
  1648. var Channel={};
  1649. var service = {
  1650. getChannel: Get
  1651. };
  1652. return service;
  1653.  
  1654. function Get(Id,Type, Token) {
  1655. var deferred = $q.defer();
  1656. var protocol=null;
  1657. if(Type=='android' || Type=='iphone' || Type=="ipad"){
  1658. protocol='&protocol=hls';
  1659. }
  1660. else{
  1661. protocol='&smil_link=1';
  1662. }
  1663. $http.get(Configs.MasterWebserviceUrl+'/op?action=getChannelLinks&ChannelID='+Id+protocol+'&secure_token='+Token)
  1664. .success(function(data, status, headers, config) {
  1665. Channel = data;
  1666. deferred.resolve(Channel);
  1667. return deferred.promise;
  1668. })
  1669. .error(function(data, status, headers, config) {
  1670.  
  1671. })
  1672. return deferred.promise;
  1673. }
  1674. }
  1675. function EpisodeSrv($http,$q,Configs,$window,$rootScope){
  1676. var Episode={};
  1677. var episodeDelete = {};
  1678. var service = {
  1679. getEpisode: Get,
  1680. saveEpisode: Save,
  1681. getEpisodeImageWithCustomSize: GetEpisodeImageWithCustomSize,
  1682. getFullEpisode:GetEpisodeFullData,
  1683. uploadImage: UploadImage,
  1684. deleteEpisode: DeleteEpisode,
  1685. createEpisode: CreateEpisode
  1686. };
  1687. return service;
  1688. function DeleteEpisode(id, token) {
  1689. var deferred = $q.defer();
  1690. $http.post(Configs.MasterAdminWebserviceUrl+'/op?action=deleteModel&model=episode&id='+id+'&token='+token)
  1691. .success(function(data, status, headers, config) {
  1692. episodeDelete=data;
  1693. deferred.resolve(episodeDelete);
  1694. return deferred.promise;
  1695. })
  1696. .error(function(data, status, headers, config) {
  1697. $window.location.replace('/#!/404');
  1698. })
  1699. return deferred.promise;
  1700. }
  1701. function CreateEpisode(program_id, show_time, episode_countries,episode_copyright_type, title, title_english, description, keywords, actors, page_description, tags, favLists, token) {
  1702. var deferred = $q.defer();
  1703. $http({
  1704. method: 'POST',
  1705. url: Configs.MasterAdminWebserviceUrl + '/op?action=createModel&model=episode&token='+token,
  1706. headers: {
  1707. 'Access-Control-Allow-Headers': 'Content-Type',
  1708. 'Access-Control-Allow-Methods': 'GET, POST, OPTIONS',
  1709. 'Access-Control-Allow-Origin': '*'
  1710. },
  1711. data: {program_id: program_id, episode_show_time:show_time, episode_copyright_type:episode_copyright_type,episode_copyright_countries:episode_countries,title:title, title_english:title_english, description: description,
  1712. keywords:keywords, actors:actors, page_description:page_description, tags:tags, favorite_lists:favLists }
  1713. }).then(function(result){
  1714. deferred.resolve(result.status);
  1715. }, function(result){
  1716. deferred.resolve(result.status);
  1717. });
  1718. return deferred.promise;
  1719. }
  1720. function Get(Id,Token,userToken) {
  1721. var deferred = $q.defer();
  1722. var WithDownloadLink= (userToken=='undefined' || userToken=='nullcookie' || userToken=='')?'':'&download_link=1';
  1723. $http.get(Configs.MasterWebserviceUrl+'/op?action=getEpisodeDetails&episode_id='+Id+'&secure_token='+Token+"&user_token="+userToken+WithDownloadLink, { timeout: 7000 })
  1724. .success(function(data, status, headers, config) {
  1725. if(data==null || data=='null' || typeof data=='undefined'){
  1726. if($rootScope.TryCount<1){
  1727. debuger.error("Faild to get Episode from this server -> " + Configs.MasterWebserviceUrl + " now trying to change the server");
  1728. $window.ga('send', 'event', 'webserver', 'episode-error', Configs.MasterWebserviceUrl);
  1729. if($rootScope.InSiteLink){
  1730. Configs.MasterWebserviceUrl = Configs.SlaveWebserviceUrl;
  1731. $rootScope.TryCount++;
  1732. data = Get(Id, Token, userToken);
  1733. deferred.resolve(data);
  1734. return deferred.promise;
  1735. }
  1736. else {
  1737. debuger.error("Faild to get Episode details after all attempts, now redirecting to 404 page, possible invalid Id")
  1738. $window.location.replace('/#!/404');
  1739. }
  1740. }
  1741. else {
  1742. debuger.error("Faild to get Episode details after all attempts, now redirecting to 404 page, possible invalid Id")
  1743. $window.location.replace('/#!/404');
  1744. }
  1745. }
  1746. debuger.info("Episode details arrived from -> " + Configs.MasterWebserviceUrl);
  1747. Episode = data;
  1748. deferred.resolve(Episode);
  1749. return deferred.promise;
  1750. })
  1751. .error(function(data, status, headers, config) {
  1752. debuger.error("Faild to get Episode Details from this server -> " + Configs.MasterWebserviceUrl)
  1753. if($rootScope.TryCount<1) {
  1754. Configs.MasterWebserviceUrl = Configs.SlaveWebserviceUrl;
  1755. debuger.info("Now trying to get Episode data from this server -> " + Configs.MasterWebserviceUrl)
  1756. $rootScope.TryCount++;
  1757. data = Get(Id, Token, userToken);
  1758. deferred.resolve(data);
  1759. return deferred.promise;
  1760.  
  1761. }
  1762. else {
  1763. debuger.error("Faild to get Episode Details after " + ($rootScope.TryCount+1) + "try")
  1764. NgNote.Error("در ارتباط با سرور با مشکل مواجه شدیم، لطفا پس از بررسی اینترنت خود مجدد تلاش کنید", 3);
  1765. }
  1766. })
  1767. return deferred.promise;
  1768. }
  1769. function GetEpisodeImageWithCustomSize(Image,ImageSize,justImage){
  1770. justImage = justImage !== 'undefined' ? justImage : false;
  1771. var SplityImage = Image.split("/");
  1772. var result = ImageSize + SplityImage[SplityImage.length-1].substring(3);
  1773. if(justImage){
  1774. return result;
  1775. }
  1776. else{
  1777. var fullResult = null;
  1778. for(var i = 0; i <= SplityImage.length-1; i++){
  1779. if(i==0){
  1780. fullResult = SplityImage[i];
  1781. }
  1782. else{
  1783. if(i==SplityImage.length-1){
  1784. fullResult = fullResult + "/" + result;
  1785. }
  1786. else{
  1787. fullResult = fullResult+ "/" +SplityImage[i];
  1788. }
  1789. }
  1790. }
  1791. return fullResult;
  1792. }
  1793. }
  1794. function GetEpisodeFullData(Id,token){
  1795. /*Configs.MasterWebserviceUrl='http://www.telewebion.com:'*/
  1796. var deferred = $q.defer();
  1797. // +
  1798. $http.get(Configs.MasterAdminWebserviceUrl + '/?action=getModel&id='+Id+'&model=episode'+"&token="+token)
  1799. .success(function(data, status, headers, config) {
  1800. Episode = data;
  1801. deferred.resolve(Episode);
  1802. return deferred.promise;
  1803. })
  1804. .error(function(data, status, headers, config) {
  1805.  
  1806. })
  1807. return deferred.promise;
  1808. }
  1809. function Save(episode_id, show_time,episode_copyright_type,episode_countries,program_id, title, title_english, description, keywords, actors, page_description, tags, favLists, token){
  1810. var deferred = $q.defer();
  1811. $http({
  1812. method: 'POST',
  1813. url: Configs.MasterAdminWebserviceUrl + '/?action=saveModel'+'&model=episode&token='+token,
  1814. headers: {
  1815. 'Access-Control-Allow-Headers': 'Content-Type',
  1816. 'Access-Control-Allow-Methods': 'GET, POST, OPTIONS',
  1817. 'Access-Control-Allow-Origin': '*'
  1818. },
  1819. data: {id:episode_id, episode_show_time:show_time, program_id: program_id, title:title,episode_copyright_type:episode_copyright_type,episode_countries:episode_countries, title_english:title_english, description: description,
  1820. keywords:keywords, actors:actors, page_description:page_description, tags:tags, favorite_lists:favLists }
  1821. }).then(function(result){
  1822. deferred.resolve(result.status);
  1823. }, function(result){
  1824. deferred.resolve(result.status);
  1825. });
  1826. return deferred.promise;
  1827. }
  1828. function UploadImage(model, token, id, type) {
  1829.  
  1830. }
  1831. }
  1832. function ProgramSrv($http,$q,Configs,$window){
  1833. var Program = {};
  1834. var programDelete = {};
  1835. var service = {
  1836. getProgram: Get,
  1837. getFullProgram: GetFull,
  1838. saveProgram: Save,
  1839. createProgram:Create,
  1840. deleteProgram:DeleteProgram
  1841. };
  1842. return service;
  1843. function DeleteProgram(id,token) {
  1844. var deferred = $q.defer();
  1845. $http.get(Configs.MasterAdminWebserviceUrl + '/op?action=deleteModel&model=program&id='+id+'&token='+token)
  1846. .success(function (data, status, headers, config) {
  1847. programDelete = data;
  1848. deferred.resolve(programDelete);
  1849. return deferred.promise;
  1850. })
  1851. .error(function (data, status, headers, config) {
  1852. $window.location.replace('/#!/404');
  1853. })
  1854. return deferred.promise;
  1855. }
  1856.  
  1857. function Get(Id) {
  1858. var deferred = $q.defer();
  1859. $http.get(Configs.MasterWebserviceUrl+'/op?action=getProgramDetails&program_id='+Id+"&nginxcache")
  1860. .success(function(data, status, headers, config) {
  1861. if(data==null || data=='null' || typeof data=='undefined'){
  1862. $window.ga('send', 'event', 'webserver', 'program-error', Configs.MasterWebserviceUrl);
  1863. if($rootScope.ProgramDetailTryCount<1){
  1864. debuger.error("Failed to get Program from this server -> " + Configs.MasterWebserviceUrl + " now trying to change the server")
  1865. if($rootScope.InSiteLink){
  1866. Configs.MasterWebserviceUrl = Configs.SlaveWebserviceUrl;
  1867. $rootScope.ProgramDetailTryCount++;
  1868. data = Get(Id);
  1869. deferred.resolve(data);
  1870. return deferred.promise;
  1871. }
  1872. else {
  1873. debuger.error("Faild to get Program details after all attempts, now redirecting to 404 page, possible invalid Id")
  1874. $window.location.replace('/#!/404');
  1875. }
  1876. }
  1877. }
  1878. Program=data;
  1879. debuger.info("Program details arrived from -> " + Configs.MasterWebserviceUrl)
  1880. deferred.resolve(Program);
  1881. return deferred.promise;
  1882. })
  1883. .error(function(data, status, headers, config) {
  1884. $window.location.replace('/#!/404');
  1885. })
  1886. return deferred.promise;
  1887. }
  1888. function GetFull(Id, token) {
  1889. var deferred = $q.defer();
  1890. $http.get(Configs.MasterAdminWebserviceUrl+'/?action=getModel&id='+Id+'&model=program&token=' + token)
  1891. .success(function(data, status, headers, config) {
  1892. Program=data;
  1893. deferred.resolve(Program);
  1894. return deferred.promise;
  1895. })
  1896. .error(function(data, status, headers, config) {
  1897. $window.location.replace('/#!/404');
  1898. })
  1899. return deferred.promise;
  1900. }
  1901. function Create(program_id, title, title_english, description_fa, description_en, tags, downloadable, enable,
  1902. is_singleton, keywords_english, page_description, Artists, Directors, Producer, Authors, Others, Genres,
  1903. Categoires, token,program_copyright_type,program_countries,importance) {
  1904. var deferred = $q.defer();
  1905. $http({
  1906. method: 'POST',
  1907. url: Configs.MasterAdminWebserviceUrl + '/?action=createModel'+'&model=program&token='+token,
  1908. headers: {
  1909. 'Access-Control-Allow-Headers': 'Content-Type',
  1910. 'Access-Control-Allow-Methods': 'GET, POST, OPTIONS',
  1911. 'Access-Control-Allow-Origin': '*'
  1912. },
  1913. data: { program_copyright_type:program_copyright_type,program_countries:program_countries,program_id:program_id, title:title, title_english:title_english, description_fa:description_fa,
  1914. description_en:description_en, tags: tags, downloadable: downloadable, enable: enable, is_singleton: is_singleton,
  1915. keywords_english:keywords_english, page_description: page_description, actors: Artists, directors: Directors,
  1916. authors: Authors, producer: Producer, others:Others, genres: Genres, categories: Categoires,importance:importance
  1917. }
  1918. }).then(function(result){
  1919. deferred.resolve(result.status);
  1920. }, function(result){
  1921. deferred.resolve(result.status);
  1922. });
  1923. return deferred.promise;
  1924. }
  1925. function Save(program_id, title, title_english, description_fa, description_en, tags, downloadable, enable,
  1926. is_singleton, keywords_english, page_description, Artists, Directors, Producer, Authors, Others, Genres,
  1927. Categoires, token,program_copyright_type,program_countries,importance) {
  1928. var deferred = $q.defer();
  1929. $http({
  1930. method: 'POST',
  1931. url: Configs.MasterAdminWebserviceUrl + '/?action=saveModel'+'&model=program&token='+token,
  1932. headers: {
  1933. 'Access-Control-Allow-Headers': 'Content-Type',
  1934. 'Access-Control-Allow-Methods': 'GET, POST, OPTIONS',
  1935. 'Access-Control-Allow-Origin': '*'
  1936. },
  1937. data: { program_copyright_type:program_copyright_type,program_countries:program_countries,program_id:program_id, title:title, title_english:title_english, description_fa:description_fa,
  1938. description_en:description_en, tags: tags, downloadable: downloadable, enable: enable, is_singleton: is_singleton,
  1939. keywords_english:keywords_english, page_description: page_description, actors: Artists, directors: Directors,
  1940. authors: Authors, producer: Producer, others:Others, genres: Genres, categories: Categoires,importance:importance
  1941. }
  1942. }).then(function(result){
  1943. deferred.resolve(result.status);
  1944. }, function(result){
  1945. deferred.resolve(result.status);
  1946. });
  1947. return deferred.promise;
  1948. }
  1949. }
  1950. function RoutingSrv($http,$q,Configs){
  1951. var Route='';
  1952. var service = {
  1953. getRoute: GetRout
  1954. };
  1955. return service;
  1956.  
  1957. function GetRout() {
  1958. var deferred = $q.defer();
  1959. $http.get(Configs.MasterRoutingServerUrl)
  1960. .success(function(data, status, headers, config) {
  1961. Route = data.split('|')[0];
  1962. deferred.resolve(Route);
  1963. return deferred.promise;
  1964. })
  1965. .error(function(data, status, headers, config) {
  1966. Route = "http://m.pipeline.telewebion.com";
  1967. deferred.resolve(Route);
  1968. return deferred.promise;
  1969. })
  1970. return deferred.promise;
  1971. }
  1972. }
  1973. function ArtistSrv($http,$q,Configs) {
  1974. var Artist = {};
  1975. var service = {
  1976. getArtist: Get,
  1977. updateArtist: Update,
  1978. createArtist: Create
  1979. };
  1980. return service;
  1981. function Get(Id) {
  1982. var deferred = $q.defer();
  1983. $http.get(Configs.MasterWebserviceUrl+'/op?action=getModel&model=artist&artist_id='+Id)
  1984. .success(function(data, status, headers, config) {
  1985. Artist=data;
  1986. deferred.resolve(Artist);
  1987. return deferred.promise;
  1988. })
  1989. .error(function(data, status, headers, config) {
  1990. $window.location.replace('/#!/404');
  1991. })
  1992. return deferred.promise;
  1993. }
  1994. function Update(id, title, nickname, gender, biography, palce, activities) {
  1995. var deferred = $q.defer();
  1996. $http.post(Configs.MasterWebserviceUrl+'/op?action=getModel&model=artist&artist_id='+Id,{artist_id:id,
  1997. artist_title:title, artist_nickname:nickname, artist_gender:gender, artist_biography:biography,
  1998. birth_palce: palce, artist_activities:activities})
  1999. .success(function(data, status, headers, config) {
  2000. Artist=data;
  2001. deferred.resolve(Artist);
  2002. return deferred.promise;
  2003. })
  2004. .error(function(data, status, headers, config) {
  2005. $window.location.replace('/#!/404');
  2006. })
  2007. return deferred.promise;
  2008. }
  2009. function Create(title, nickname, gender, biography, birth_palce, activities) {
  2010. var deferred = $q.defer();
  2011. $http.post(Configs.MasterWebserviceUrl+'/op?action=createModel&model=artist',{artist_title:title,
  2012. artist_nickname:nickname, artist_gender:gender, artist_biography:biography,
  2013. birth_palce: birth_palce, artist_activities:activities})
  2014. .success(function(data, status, headers, config) {
  2015. Artist=data;
  2016. deferred.resolve(Artist);
  2017. return deferred.promise;
  2018. })
  2019. .error(function(data, status, headers, config) {
  2020. $window.location.replace('/#!/404');
  2021. })
  2022. return deferred.promise;
  2023. }
  2024. }
  2025. function FavoriteListSrv($http,$q,Configs) {
  2026. var FavoriteList = {};
  2027. var service = {
  2028. getFavoriteList: Get,
  2029. updateFavoriteList: Update,
  2030. createFavoriteList: Create,
  2031. getChildList: GetChilds,
  2032. getChildEpisodeList: GetEpisodeChilds,
  2033. getFavoriteListParents: GetFavoriteListParents,
  2034. getFavoriteListByEpisode: GetFavoriteListByEpisode
  2035. };
  2036. return service;
  2037. function Get(Id, token) {
  2038. var deferred = $q.defer();
  2039. $http.get(Configs.MasterAdminWebserviceUrl+'/?action=getModel&model=favorite_list&favorite_list_id='+Id+"&token="+token)
  2040. .success(function(data, status, headers, config) {
  2041. FavoriteList=data;
  2042. deferred.resolve(FavoriteList);
  2043. return deferred.promise;
  2044. })
  2045. .error(function(data, status, headers, config) {
  2046. $window.location.replace('/#!/404');
  2047. })
  2048. return deferred.promise;
  2049. }
  2050. function Update(Id, NameFa, NameEn, Parent, Description, token) {
  2051. var deferred = $q.defer();
  2052. $http.post(Configs.MasterAdminWebserviceUrl+'/?action=saveModel&model=favorite_list&token='+token+'&favorite_list_id='+Id, {name_en: NameEn, name_fa:NameFa, parent: Parent, child_description: Description})
  2053. .success(function(data, status, headers, config) {
  2054. FavoriteList=data;
  2055. deferred.resolve(FavoriteList);
  2056. return deferred.promise;
  2057. })
  2058. .error(function(data, status, headers, config) {
  2059. })
  2060. return deferred.promise;
  2061. }
  2062. function Create(NameFa, NameEn, Parent, Description, token) {
  2063. var deferred = $q.defer();
  2064. $http.post(Configs.MasterAdminWebserviceUrl+'/?action=createModel&model=favorite_list&token='+token, {name_en: NameEn, name_fa:NameFa, parent:Parent, child_description: Description})
  2065. .success(function(data, status, headers, config) {
  2066. FavoriteList=data;
  2067. deferred.resolve(FavoriteList);
  2068. return deferred.promise;
  2069. })
  2070. .error(function(data, status, headers, config) {
  2071. $window.location.replace('/#!/404');
  2072. })
  2073. return deferred.promise;
  2074. }
  2075. function GetChilds(Parent, Offset, Limit) {
  2076. var deferred = $q.defer();
  2077. $http.get(Configs.MasterWebserviceUrl+'/op?action=getFavoriteListChilds&id='+Parent+'&offset='+Offset +'&limit='+Limit)
  2078. .success(function(data, status, headers, config) {
  2079. FavoriteList=data;
  2080. deferred.resolve(FavoriteList);
  2081. return deferred.promise;
  2082. })
  2083. .error(function(data, status, headers, config) {
  2084. })
  2085. return deferred.promise;
  2086. }
  2087. function GetEpisodeChilds(Parent, Offset, Limit) {
  2088. var deferred = $q.defer();
  2089. $http.get(Configs.MasterWebserviceUrl+'/op?action=getFavoritListEpisodes&favorite_list_id='+Parent+'&offset='+Offset +'&limit='+Limit)
  2090. .success(function(data, status, headers, config) {
  2091. FavoriteList=data;
  2092. deferred.resolve(FavoriteList);
  2093. return deferred.promise;
  2094. })
  2095. .error(function(data, status, headers, config) {
  2096. })
  2097. return deferred.promise;
  2098. }
  2099. function GetFavoriteListParents(Parent) {
  2100. var deferred = $q.defer();
  2101. $http.get(Configs.MasterWebserviceUrl+'/op?action=getFavoriteListParents&id='+Parent)
  2102. .success(function(data, status, headers, config) {
  2103. FavoriteList=data;
  2104. deferred.resolve(FavoriteList);
  2105. return deferred.promise;
  2106. })
  2107. .error(function(data, status, headers, config) {
  2108. })
  2109. return deferred.promise;
  2110. }
  2111. function GetFavoriteListByEpisode(EpisodeId) {
  2112. var deferred = $q.defer();
  2113. $http.get(Configs.MasterWebserviceUrl+'/op?action=getEpisodeTreeFavoriteList&episode_id='+EpisodeId)
  2114. .success(function(data, status, headers, config) {
  2115. FavoriteList=data;
  2116. deferred.resolve(FavoriteList);
  2117. return deferred.promise;
  2118. })
  2119. .error(function(data, status, headers, config) {
  2120. })
  2121. return deferred.promise;
  2122. }
  2123.  
  2124. }
  2125. function AdBankSrv($http,$q,Configs,$window) {
  2126. var AdBank = {};
  2127. var service = {
  2128. addAdBank:AddAdBank,
  2129. saveAdBank:SaveAdBank,
  2130. deleteAdBank:DeleteAdBank
  2131. }
  2132. return service;
  2133. function AddAdBank(ad_title,ad_tag_url,ad_probability,ad_target,ad_for_iranian,ad_enable,token) {
  2134. var deferred = $q.defer();
  2135. $http.post(Configs.MasterAdminWebserviceUrl+'/?action=createModel&model=adbank&token='+token, {ad_title: ad_title,
  2136. ad_tag_url:ad_tag_url, ad_probability:ad_probability, ad_target: ad_target, ad_for_iranian: ad_for_iranian,
  2137. ad_enable:ad_enable})
  2138. .success(function(data, status, headers, config) {
  2139. AdBank=data;
  2140. deferred.resolve(AdBank);
  2141. return deferred.promise;
  2142. });
  2143. return deferred.promise;
  2144. }
  2145. function SaveAdBank(Id,token,ad_title,ad_tag_url,ad_probability,ad_target,ad_for_iranian,ad_enable) {
  2146. var deferred = $q.defer();
  2147. $http.post(Configs.MasterAdminWebserviceUrl+'/?action=saveModel&model=adbank&token='+token,
  2148. {ad_title: ad_title,
  2149. ad_id:Id,
  2150. ad_tag_url:ad_tag_url, ad_probability:ad_probability, ad_target: ad_target, ad_for_iranian: ad_for_iranian,
  2151. ad_enable:ad_enable})
  2152. .success(function(data, status, headers, config) {
  2153. AdBank=data;
  2154. deferred.resolve(AdBank);
  2155. return deferred.promise;
  2156. })
  2157. .error(function(data, status, headers, config) {
  2158. })
  2159. return deferred.promise;
  2160. }
  2161. function DeleteAdBank(id, token) {
  2162. var deferred = $q.defer();
  2163. $http.get(Configs.MasterAdminWebserviceUrl+'/?action=deleteModel&model=adbank&id='+id+'&token='+token)
  2164. .success(function(data, status, headers, config) {
  2165. AdBank=data;
  2166. deferred.resolve(AdBank);
  2167. return deferred.promise;
  2168. })
  2169. return deferred.promise;
  2170. }
  2171. }
  2172. function AdsSrv($http,$q,Configs) {
  2173. var FavoriteList = {};
  2174. var service = {
  2175. getAd: Get,
  2176. update: Update,
  2177. create: Create,
  2178. deleteAd: Delete
  2179. };
  2180. return service;
  2181. function Get(Id, token) {
  2182. var deferred = $q.defer();
  2183. $http.get(Configs.MasterAdminWebserviceUrl+'/?action=getModel&model=ad&id='+Id+"&token="+token)
  2184. .success(function(data, status, headers, config) {
  2185. FavoriteList=data;
  2186. deferred.resolve(FavoriteList);
  2187. return deferred.promise;
  2188. })
  2189. .error(function(data, status, headers, config) {
  2190. $window.location.replace('/#!/404');
  2191. })
  2192. return deferred.promise;
  2193. }
  2194. function Update(id, title, mode, link_url, media_path, media_path_static, media_duration, prob, device, target, enable
  2195. , token) {
  2196. var deferred = $q.defer();
  2197. $http.post(Configs.MasterAdminWebserviceUrl+'/?action=saveModel&model=ads&token='+token+'&ad_id='+id,
  2198. {ad_id: id, ad_title: title, ad_mode:mode, ad_media_link:link_url,
  2199. ad_media_path: media_path, ad_media_path_static: media_path_static,ad_duration:media_duration,
  2200. ad_probability:prob, ad_device:device, ad_target:target, ad_enable:enable})
  2201. .success(function(data, status, headers, config) {
  2202. FavoriteList=data;
  2203. deferred.resolve(FavoriteList);
  2204. return deferred.promise;
  2205. })
  2206. .error(function(data, status, headers, config) {
  2207. })
  2208. return deferred.promise;
  2209. }
  2210. function Create(title, mode, link_url, media_path, media_path_static, media_duration, prob, device, target, enable
  2211. , token) {
  2212. var deferred = $q.defer();
  2213. $http.post(Configs.MasterAdminWebserviceUrl+'/?action=createModel&model=ads&token='+token, {ad_title: title,
  2214. ad_mode:mode, ad_media_link:link_url, ad_media_path: media_path, ad_media_path_static: media_path_static,
  2215. ad_duration:media_duration, ad_probability:prob, ad_device:device, ad_target:target, ad_enable:enable})
  2216. .success(function(data, status, headers, config) {
  2217. FavoriteList=data;
  2218. deferred.resolve(FavoriteList);
  2219. return deferred.promise;
  2220. })
  2221. .error(function(data, status, headers, config) {
  2222. $window.location.replace('/#!/404');
  2223. })
  2224. return deferred.promise;
  2225. }
  2226. function Delete(id, token) {
  2227. var deferred = $q.defer();
  2228. $http.post(Configs.MasterAdminWebserviceUrl+'/?action=deleteModel&model=ad&&token='+token,{ad_id:id})
  2229. .success(function(data, status, headers, config) {
  2230. FavoriteList=data;
  2231. deferred.resolve(FavoriteList);
  2232. return deferred.promise;
  2233. })
  2234. .error(function(data, status, headers, config) {
  2235. // $window.location.replace('/#!/404');
  2236. })
  2237. return deferred.promise;
  2238. }
  2239.  
  2240. }
  2241.  
  2242.  
  2243. angular
  2244. .module('tw-directive',[])
  2245. .directive('compareTo', compareTo)
  2246. .directive('player', Player)
  2247. .controller('PlayerCtrl', PlayerCtrl);
  2248. PlayerCtrl.$inject = ['$scope','SecurityFcy','deviceDetector','Configs','Messages','EpisodeFcy', '$http','$q','$window','$timeout'];
  2249. function PlayerCtrl($scope,SecurityFcy,deviceDetector,Configs,Messages,EpisodeFcy, $http, $q, $window,$timeout){
  2250. var plc = this;
  2251. plc.isLoaded=false;
  2252. plc.IsIphone = function(){
  2253. return !!navigator.userAgent.match(/iPad/i);
  2254. }
  2255. window.ChangeQuality = function (index) {
  2256. var currentTime = window.Player.currentTime();
  2257. window.Player.pause();
  2258. window.Play(index, false);
  2259. window.Player.play();
  2260. window.Player.on('loadeddata', function () {
  2261. if(DeviceDetection.IsIos || DeviceDetection.IsIpad){
  2262. window.Player.currentTime(currentTime);
  2263. }else{
  2264. setTimeout(function () {
  2265. window.Player.currentTime(currentTime);
  2266. },500);
  2267. }
  2268.  
  2269. });
  2270. }
  2271. plc.progressBarUpdate = function () {
  2272. var currentTime = window.Player.currentTime();
  2273. var duration = window.Player.duration();
  2274. var percentage = (currentTime/duration)*100;
  2275. $(".vjs-progress-holder.vjs-slider").attr("aria-valuenow",(percentage));
  2276. }
  2277. plc.ErrorHandler = function () {
  2278. if(window.tryCount<10){
  2279. window.Play(plc.Settings.LastPlayedIndex+1);
  2280. window.tryCount = window.tryCount +1;
  2281. }
  2282. }
  2283. plc.newButtonToggle = function() {
  2284. setTimeout(function () {
  2285. var adaptiveItem = "<div class='videojs-adaptive-button' tabindex='1'> HD </div>";
  2286. var adaptiveQuality = "<div class='videojs-adaptive-container' tabindex='1'><ul>";
  2287. for(var i=0;i<=window.videoQaulities.length-1;i++){
  2288. adaptiveQuality += "<li><span class='selected-quality'><i class='fa fa-circle'></i> </span><button onclick='window.ChangeQuality("+i+")'> "+window.videoQaulities[i].title+" کیفیت </button> "+" </li> ";
  2289. }
  2290.  
  2291. adaptiveQuality += "</ul></div>";
  2292. $(".vjs-control-bar").append(adaptiveItem);
  2293. $(".vjs-control-bar").append(adaptiveQuality);
  2294. },500)
  2295.  
  2296. };
  2297. plc.ConvertToPersianNumber = function(string){
  2298. return persianUtils.toPersianNumber(string);
  2299. };
  2300. plc.IsSmartTV = function() {
  2301. return navigator.userAgent.search(/TV/i) >= 0;
  2302. };
  2303. plc.PlayWithIndex=function(index,goForNext){
  2304. if(Configs.Player.Live.DefaultPlayer=="RadiantPlayer"){
  2305. plc.RadiantPlayWithIndex(index, goForNext);
  2306. }
  2307. else if(Configs.Player.Live.DefaultPlayer=="JwPlayer") {
  2308. if(typeof goForNext!='undefined' && goForNext===true){
  2309. var length=plc.episode.links.length;
  2310. if(index<length-1){
  2311. index++;
  2312. }
  2313. else{
  2314. index=0;
  2315. }
  2316. }
  2317. plc.SetPassiveButton(plc.Settings.LastPlayedIndex);
  2318. plc.SetActiveButton(index);
  2319. plc.Settings.LastPlayedIndex=index;
  2320. if(plc.Settings.TryCount<=30){
  2321. plc.Settings.TryCount++;
  2322. plc.Player(plc.viewPlayLinks[index].link);
  2323. }
  2324. else{
  2325. plc.Stop();
  2326. }
  2327. }
  2328. };
  2329. plc.SetActiveButton=function(index){
  2330. var selectedItem = document.getElementById("SelectLink"+index);
  2331. selectedItem.classList.remove("btn-success");
  2332. selectedItem.classList.add("btn-danger");
  2333. }
  2334. plc.SetPassiveButton=function(index){
  2335. var selectedItem = document.getElementById("SelectLink"+index);
  2336. selectedItem.classList.remove("btn-danger");
  2337. selectedItem.classList.add("btn-success");
  2338. }
  2339. plc.Stop=function(){
  2340. plc.playerInstance.stop();
  2341. }
  2342. plc.Play=function(){
  2343. plc.playerInstance.play();
  2344. }
  2345. window.Play = function (index,withAd) {
  2346. if(withAd){
  2347. window.Player.preroll({
  2348. src:{
  2349. src: window.adUrl,
  2350. type:"video/mp4"},
  2351. href:window.adClickUrl,
  2352. adsOptions: {debug:false}
  2353. });
  2354. }
  2355. debuger.log("Now playing with this link: " + window.VideoLinks[index].link);
  2356. window.Player.src([
  2357. { type: "video/mp4", src: window.VideoLinks[index].link }
  2358. ]);
  2359.  
  2360. };
  2361. plc.generateMobileLinkQualities = function (links, type) {
  2362. var items = [];
  2363. var i;
  2364. if(type=="vod"){
  2365. for(i=0;i<=links.length-1;i++){
  2366. var item = {};
  2367. item.link=links[i].link;
  2368. item.title=links[i].title;
  2369. items.push(item);
  2370. }
  2371. }
  2372. else{
  2373. for(i=0;i<=links.length-1;i++){
  2374. var item = {};
  2375. item.link=links[i].link;
  2376. item.title=links[i].bitrate;
  2377. items.push(item);
  2378. }
  2379. }
  2380. window.videoQaulities = items;
  2381. plc.newButtonToggle();
  2382. }
  2383. plc.Player=function(defaultLink){
  2384. benchmark.start("LiveDesktop");
  2385. PageLoadCounter.startTimer();
  2386. /*plc.SetActiveButton(selectedIndex);*/
  2387. setTimeout(function () {
  2388. plc.playerInstance = jwplayer("EpisodePlayer");
  2389. window.LivePlayerInstance = plc.playerInstance;
  2390. plc.playerInstance.setup({
  2391. file: defaultLink,
  2392. width: Configs.Player.Live.PlayerWidth,
  2393. height: Configs.Player.Live.PlayerHeight
  2394. }).play()
  2395. .on('error',function(e){
  2396. plc.PlayWithIndex(plc.Settings.LastPlayedIndex,true);
  2397. })
  2398. .on('play',function(e){
  2399. var label = window.ChannelId +'#'+ window.ChannelQuality;
  2400. PageLoadCounter.stopTimer();
  2401. ga('send', 'event', 'Play-Live', 'server', label,window.TimerResult.toString());
  2402. var endOfBenchMark=benchmark.end("LiveDesktop");
  2403. debuger.info("It took " + endOfBenchMark+ " ms to play");
  2404. $window.ga('send', 'event', 'play', 'startup-live', endOfBenchMark);
  2405. })
  2406. .on('playlistComplete',function(){
  2407. plc.PlayWithIndex(plc.Settings.LastPlayedIndex,true);
  2408. })
  2409. }, 500);
  2410.  
  2411. }
  2412. /*============================== RP ==========================*/
  2413. plc.RadiantPlayerSetting = { TryCount:0, LastPlayedIndex:0, DebugMode:false, AutoPlay:false,
  2414. IsLive:true, Width:800, Height: 600, PlayerContainerId: "", Ad: {Enabled:true, device: "desktop", target:"live"},
  2415. Ga: { PlayType: 'Play-Live', StartupType: "startup-live", Action: "play"}, Subtitle: {Enabled:false}
  2416. }
  2417. plc.RadiantAddPlayed = false;
  2418. window.RadiantPlayer = function (links) {
  2419. plc.RadiantPlayer(links);
  2420. }
  2421. window.RadiantErrorHandler = function () {
  2422. plc.RadiantErrorHandler();
  2423. }
  2424. plc.RadiantPlayer = function (links) {
  2425. benchmark.start("LiveDesktop");
  2426. var bitrates = {
  2427. hls: links
  2428. };
  2429. adURL = Configs.MasterWebserviceUrl+"/ads/serveAds?"+"&target="+plc.RadiantPlayerSetting.Ad.target+"&device="+plc.RadiantPlayerSetting.Ad.device;
  2430. var settings =
  2431. {
  2432. licenseKey: Configs.Players.RadiantPlayer.License,
  2433. bitrates: bitrates,
  2434. delayToFade: Configs.Players.RadiantPlayer.ControllsAutoHideAfter,
  2435. width: plc.RadiantPlayerSetting.Width/*Configs.Player.Live.PlayerWidth*/,
  2436. height: plc.RadiantPlayerSetting.Height,/*Configs.Player.Live.PlayerHeight,*/
  2437. isLive: plc.RadiantPlayerSetting.IsLive,
  2438. ads: plc.RadiantPlayerSetting.Ad.Enabled,
  2439. debug: false/*plc.RadiantPlayerSetting.DebugMode*/,
  2440. streamDebug: false/*plc.RadiantPlayerSetting.DebugMode*/,
  2441. adLinearHideControls: false,
  2442. autoplay: plc.RadiantPlayerSetting.AutoPlay,
  2443. hlsJSMaxBufferLength: 60,
  2444. hlsJSStopDownloadWhilePaused: false,
  2445. hlsJSEnableCEACaptions: false,
  2446. hlsJSLiveSyncDuration: 30,
  2447. adTagUrl: adURL
  2448. };
  2449. var rmp = new RadiantMP(plc.RadiantPlayerSetting.PlayerContainerId);
  2450. if(window.playerInstance != null) {
  2451. window.playerInstance.destroy();
  2452. }
  2453. rmp.destroy();
  2454. rmp.init(settings);
  2455. var rmpContainer = document.getElementById(plc.RadiantPlayerSetting.PlayerContainerId);
  2456. rmpContainer.addEventListener('error', plc.RadiantErrorHandler);
  2457. /*rmpContainer.addEventListener('play', plc.RadiantPlayEvent);*/
  2458. rmpContainer.addEventListener('adcomplete', plc.RadiantAdCompleteEvent);
  2459. rmpContainer.addEventListener('adstarted', plc.RadiantAdStartedEvent);
  2460. rmpContainer.addEventListener('enterfullscreen', resana.onFullscreenListener);
  2461. rmpContainer.addEventListener('exitfullscreen', resana.onFullscreenListener);
  2462. rmpContainer.addEventListener('timeupdate', resana.onTimeListener);
  2463. rmpContainer.addEventListener('play', function(){
  2464. resana.onPlayListener();
  2465. plc.RadiantPlayEvent();
  2466. });
  2467. rmpContainer.addEventListener('pause', resana.onPauseListener);
  2468. rmpContainer.addEventListener('ended', resana.onCompleteListener);
  2469. rmpContainer.addEventListener('ready', function () {
  2470. /**
  2471. * The first parameter is the type of player. Resana's web SDK currently supports jwplayer, videojs and rmp
  2472. */
  2473. resana.setup('rmp', {container: '#'+plc.RadiantPlayerSetting.PlayerContainerId, restTime: 10, playerObj: rmp});
  2474.  
  2475. /**
  2476. * 10004 is your Resana ID
  2477. * The second parameter is the category/tag of the video. To specify multiple
  2478. * categories, use "-" (dash) to separate them.
  2479. */
  2480. resana.init(10013, 'categories-of-the-video');
  2481. if(plc.RadiantPlayerSetting.Subtitle.Enabled == true){
  2482. resana.start();
  2483. }
  2484. });
  2485. plc.playerInstance = rmp;
  2486. window.playerInstance = rmp;
  2487.  
  2488. };
  2489. plc.RadiantErrorHandler= function () {
  2490. if(plc.RadiantPlayerSetting.TryCount<10){
  2491. if((plc.RadiantPlayerSetting.LastPlayedIndex+1)<plc.viewPlayLinks.length){
  2492. plc.PlayWithIndex(plc.RadiantPlayerSetting.LastPlayedIndex+1);
  2493. }
  2494. else{
  2495. plc.PlayWithIndex(0);
  2496. }
  2497. plc.RadiantPlayerSetting.TryCount +=1;
  2498. errorPlayer.hide();
  2499. }
  2500. };
  2501. plc.RadiantPlayEvent= function () {
  2502. PageLoadCounter.stopTimer();
  2503. var label = window.ChannelId +'#'+ window.ChannelQuality;
  2504. var endOfBenchMark=benchmark.end("LiveDesktop");
  2505. debuger.info("It took " + endOfBenchMark+ " ms to play");
  2506. $window.ga('send', 'event', plc.RadiantPlayerSetting.Ga.PlayType, 'server',label, endOfBenchMark);
  2507. $window.ga('send', 'event', 'play', plc.RadiantPlayerSetting.Ga.StartupType, endOfBenchMark);
  2508. }
  2509. plc.RadiantPlayWithIndex=function(index,goForNext){
  2510. if(typeof goForNext!='undefined' && goForNext===true){
  2511. var length=plc.episode.links.length;
  2512. if(index<length-1){
  2513. index++;
  2514. }
  2515. else{
  2516. index=0;
  2517. }
  2518. }
  2519. plc.SetPassiveButton(plc.RadiantPlayerSetting.LastPlayedIndex);
  2520. plc.SetActiveButton(index);
  2521. plc.RadiantPlayerSetting.LastPlayedIndex=index;
  2522. if(plc.RadiantPlayerSetting.TryCount<=10){
  2523. plc.RadiantPlayerSetting.TryCount++;
  2524. destroyRadiantPlayer.destroy();
  2525. plc.playerInstance.stop();
  2526. plc.playerInstance.destroy();
  2527. plc.RadiantPlayer(plc.viewPlayLinks[index].link);
  2528. }
  2529. else{
  2530. plc.playerInstance.stop();
  2531. }
  2532. };
  2533. plc.RadiantAdCompleteEvent = function () {
  2534. if(plc.RadiantAddPlayed==false){
  2535. ga('send', 'event', 'ads-'+plc.RadiantPlayerSetting.Ad.device, plc.RadiantPlayerSetting.Ad.target , "end");
  2536. }
  2537. else{
  2538. plc.RadiantAddPlayed=true;
  2539. }
  2540. }
  2541. plc.RadiantAdStartedEvent = function () {
  2542. /*ga('send', 'event', 'ads-'+plc.RadiantPlayerSetting.Ad.device, plc.RadiantPlayerSetting.Ad.target, "start");*/
  2543. }
  2544. /*============================= EORP =========================*/
  2545. var flagForOneInit = true;
  2546. $scope.$watch('plc.episode', function() {
  2547. if(typeof plc.episode!='undefined' && plc.episode.id!='undefined' && plc.episode.id!='' && plc.episode.length>0 && (plc.episode.links!='undefined' || plc.episode.vod_link!='undefined')) {
  2548. if(!plc.isLoaded) {
  2549. try {
  2550. plc.Settings={};
  2551. plc.device=deviceDetector.device;
  2552. plc.episode = angular.fromJson(plc.episode);
  2553. plc.isLoaded=true;
  2554. plc.source=[];
  2555. plc.Settings.LastPlayedIndex=0;
  2556. plc.Settings.TryCount=0;
  2557. plc.hlsSource=[];
  2558. if(plc.type=='live'){
  2559. if(plc.device=='android' || plc.device=='iphone' || plc.IsSmartTV() || plc.IsIphone()){
  2560. window.activePlayer = "MobilePlayer";
  2561. window.activePlayerToolbarPlay='FullScreenTheMobileLivePlayer';
  2562. window.playerType = 'VideoJs';
  2563. window.activePlayerToolbarMute = 'VoiceControlMobileLivePlayer';
  2564. SecurityFcy.getDefaultLiveLink(plc.episode.links).then(function(result){
  2565. SecurityFcy.getAdvertisement("mobile","live").then(function (addResult) {
  2566. SecurityFcy.parsVas2(addResult).then(function (FinalAdResult) {
  2567. window.adUrl = FinalAdResult.src;
  2568. window.adClickUrl = FinalAdResult.onClick;
  2569. window.adStart = FinalAdResult.onStart;
  2570. loadingControl.hideLoading();
  2571. window.adCompelete = FinalAdResult.onComplete;
  2572. var adFinished = false;
  2573. window.Player = videojs('MobilePlayer')
  2574. .on('play', function () {
  2575. loadingControl.hideLoading();
  2576. if(adFinished){
  2577. var endOfBenchMark=benchmark.end("LiveMobile");
  2578. debuger.info("It took " + endOfBenchMark+ " ms to play");
  2579. $window.ga('send', 'event', 'play', 'startup-live-mobile', endOfBenchMark);
  2580. $window.ga('send', 'event', 'Play-Live-Mobile', 'server', window.LiveChannelDecriptor, endOfBenchMark);
  2581. }
  2582. })
  2583. .on('adstart', function () {
  2584. controlBar.hideBar();
  2585. bigPlayButton.hideButton();
  2586. loadingControl.showLoading();
  2587. ga('send', 'event', 'ads-mobile',"live", "start");
  2588. $.get(window.adStart);
  2589. })
  2590. .on('adended',function () {
  2591. controlBar.showBar();
  2592. loadingControl.hideLoading();
  2593. $.get(window.adCompelete);
  2594. ga('send', 'event', 'ads-mobile',"live", "end");
  2595. benchmark.start("LiveMobile");
  2596. adFinished=true;
  2597. window.Play(0,false);
  2598. })
  2599. .on('error', function(e) {
  2600. e.stopImmediatePropagation();
  2601. plc.ErrorHandler();
  2602. });
  2603. window.VideoLinks=plc.episode.links;
  2604. plc.generateMobileLinkQualities(plc.episode.links,"live");
  2605. window.Play(0,true);
  2606. });
  2607. });
  2608. })
  2609.  
  2610. }
  2611. else{
  2612. SecurityFcy.getDefaultLiveLink(plc.episode.links).then(function(result){
  2613. if(Configs.Player.Live.DefaultPlayer == "JwPlayer"){
  2614. loadingControl.hideLoading();
  2615. plc.viewPlayLinks=plc.episode.links;
  2616. debuger.log("Live is playing with this link: " + result.Link);
  2617. plc.Settings.LastPlayedIndex=result.Index;
  2618. window.ChannelQuality = plc.episode.links[result.Index].title;
  2619. plc.Player(result.Link);
  2620. }
  2621. else if(Configs.Player.Live.DefaultPlayer == "RadiantPlayer"){
  2622. loadingControl.hideLoading();
  2623. plc.viewPlayLinks=plc.episode.links;
  2624. debuger.log("Live is playing with this link: " + result.Link);
  2625. plc.Settings.LastPlayedIndex=result.Index;
  2626. window.ChannelQuality = plc.episode.links[result.Index].title;
  2627. plc.RadiantPlayerSetting.LastPlayedIndex=result.Index;
  2628. plc.RadiantPlayerSetting.DebugMode=true;
  2629. plc.RadiantPlayerSetting.AutoPlay=true;
  2630. plc.RadiantPlayerSetting.IsLive=true;
  2631. plc.RadiantPlayerSetting.With=Configs.Player.Live.PlayerWidth;
  2632. plc.RadiantPlayerSetting.Height=Configs.Player.Live.PlayerHeight;
  2633. plc.RadiantPlayerSetting.PlayerContainerId="EpisodePlayer";
  2634. plc.RadiantPlayerSetting.Ad.device="desktop";
  2635. plc.RadiantPlayerSetting.Ad.target="live";
  2636. plc.RadiantPlayerSetting.Ad.Enabled=true;
  2637. window.RadiantPlayer(result.Link);
  2638. }
  2639. })
  2640. }
  2641. }
  2642. else if(plc.type=='episode') {
  2643. if (plc.episode.file_path != '' && plc.episode.file_path != 'undefined') {
  2644. plc.source.push(plc.episode.file_path);
  2645. window.IsPlayingVod = true;
  2646. if (plc.device == 'android' || plc.device == 'iphone' || plc.IsSmartTV() || plc.IsIphone()) {
  2647. window.activePlayer = "MobileVodPlayer";
  2648. window.activePlayerToolbarPlay = 'MobileVodPlayerToolbarPlayPause';
  2649. window.playerType = 'VideoJs';
  2650. window.activePlayerToolbarMute = 'VoiceControlMobileVodPlayer';
  2651. if (plc.episode.vod_link !== 'undefined') {
  2652. EpisodeFcy.getSortedMobileListByQuality(plc.episode.vod_link).then(function (result) {
  2653. SecurityFcy.getAdvertisement("mobile","vod").then(function (addResult) {
  2654. SecurityFcy.parsVas2(addResult).then(function (FinalAdResult) {
  2655. window.adUrl = FinalAdResult.src;
  2656. loadingControl.hideLoading();
  2657. window.adClickUrl = FinalAdResult.onClick;
  2658. window.adStart = FinalAdResult.onStart;
  2659. var adFinished = false;
  2660. window.adCompelete = FinalAdResult.onComplete;
  2661. window.Player = videojs('MobilePlayer')
  2662. .on('play', function () {
  2663. loadingControl.hideLoading();
  2664. if(adFinished){
  2665. var endOfBenchMark=benchmark.end("VodMobile");
  2666. debuger.info("It took " + endOfBenchMark+ " ms to play");
  2667. $window.ga('send', 'event', 'play', 'startup-vod','mobile', endOfBenchMark);
  2668. $window.ga('send', 'event', 'Play-Vod-Mobile', 'server', window.EpisodeId, endOfBenchMark);
  2669. }
  2670. })
  2671. .on('adstart', function () {
  2672. controlBar.hideBar();
  2673. bigPlayButton.hideButton();
  2674. $.get(window.adStart);
  2675. ga('send', 'event', 'ads-mobile',"vod", "start");
  2676. })
  2677. .on('adended',function () {
  2678. controlBar.showBar();
  2679. loadingControl.showLoading();
  2680. benchmark.start("VodMobile");
  2681. $.get(window.adCompelete);
  2682. ga('send', 'event', 'ads-mobile',"vod", "end");
  2683. adFinished = true;
  2684. })
  2685. .on('error', function(e) {
  2686. plc.ErrorHandler();
  2687. e.stopImmediatePropagation();
  2688. });
  2689. window.VideoLinks=result;
  2690. plc.generateMobileLinkQualities(plc.episode.vod_link,"vod");
  2691. window.Play(0,true);
  2692. });
  2693. });
  2694. });
  2695. }
  2696.  
  2697. }
  2698. else {
  2699. if (Configs.Player.Vod.DefaultPlayer == 'JwPlayer') {
  2700. SecurityFcy.getToken().then(function(securityToken){
  2701. SecurityFcy.generateVodSmilLink(plc.source, plc.episode.id,'JwPlayer',securityToken).then(function (result) {
  2702. var playerInstance = jwplayer(Configs.Player.Vod.PlayerPlaceId);
  2703. debuger.info("Now playing live with this link: " + result);
  2704. playerInstance.setup({
  2705. file: result,
  2706. image: plc.episode.large_picture_path,
  2707. width: Configs.Player.Vod.PlayerWidth,
  2708. height: Configs.Player.Vod.PlayerHeight
  2709.  
  2710. });
  2711. })
  2712. })
  2713. }
  2714. else if (Configs.Player.Vod.DefaultPlayer == 'OsmfPlayer') {
  2715. SecurityFcy.getToken().then(function(securityToken){
  2716. SecurityFcy.generateVodSmilLink(plc.source, plc.episode.id, 'OsmfPlayer',securityToken).then(function (result) {
  2717. SecurityFcy.getAdvertisement("desktop","vod").then(function (addResult) {
  2718. SecurityFcy.parsVas2(addResult).then(function (FinalAdResult) {
  2719. window.adUrl = FinalAdResult.src;
  2720. window.adClickUrl = FinalAdResult.onClick;
  2721. window.adStart = FinalAdResult.onStart;
  2722. loadingControl.hideLoading();
  2723. window.adCompelete = FinalAdResult.onComplete;
  2724. debuger.log("Now Playing this link: " + result[0]);
  2725. try {
  2726. window.vod_link = result[0];
  2727. } catch (e) {
  2728. }
  2729. ;
  2730. PageLoadCounter.startTimer();
  2731. var flashvars = {
  2732. /*src_preroll: "onJSBridge",*/
  2733. src: escape(result),
  2734. scaleMode: "stretch",
  2735. javascriptCallbackFunction: "onJSBridge"
  2736. };
  2737. var params = {
  2738. allowFullScreen: true,
  2739. allowScriptAccess: "always",
  2740. bgcolor: "#000000",
  2741. wmode: 'opaque'
  2742. };
  2743. var attrs = {
  2744. name: "Player",
  2745. id: "ply"
  2746. };
  2747. swfobject.embedSWF(Configs.Player.Vod.OsfmSWFPath, Configs.Player.Vod.PlayerPlaceId, Configs.Player.Vod.PlayerWidth, Configs.Player.Vod.PlayerHeight, "10.2", null, flashvars, params, attrs);
  2748.  
  2749. })
  2750. })
  2751. })
  2752.  
  2753. })
  2754. }
  2755. else if (Configs.Player.Vod.DefaultPlayer == 'RadiantPlayer'){
  2756. SecurityFcy.getToken().then(function(securityToken){
  2757. SecurityFcy.generateVodSmilLink(plc.source, plc.episode.id, 'OsmfPlayer',securityToken).then(function (result) {
  2758. loadingControl.hideLoading();
  2759. plc.viewPlayLinks=plc.episode.links;
  2760. debuger.log("Vod is playing with this link: " + result);
  2761. plc.RadiantPlayerSetting.DebugMode=true;
  2762. plc.RadiantPlayerSetting.AutoPlay=true;
  2763. plc.RadiantPlayerSetting.IsLive=false;
  2764. plc.RadiantPlayerSetting.Ga.StartupType="startup-vod"
  2765. plc.RadiantPlayerSetting.Ga.PlayType="Play-Vod-Desktop"
  2766. plc.RadiantPlayerSetting.With=Configs.Player.Live.PlayerWidth;
  2767. plc.RadiantPlayerSetting.Height=Configs.Player.Live.PlayerHeight;
  2768. plc.RadiantPlayerSetting.PlayerContainerId="EpisodePlayer";
  2769. plc.RadiantPlayerSetting.Ad.device="desktop";
  2770. plc.RadiantPlayerSetting.Ad.target="vod";
  2771. plc.RadiantPlayerSetting.Ad.Enabled=true;
  2772. window.RadiantPlayer(result);
  2773. })
  2774.  
  2775. })
  2776. }
  2777. }
  2778. }
  2779. else{
  2780. if(plc.episode.has_video=='-1'){
  2781. NgNote.Error(Messages.Fa.CopyrightError,30);
  2782. }
  2783. else if(plc.episode.has_video=='0'){
  2784. NgNote.Error(Messages.Fa.FileNotFoundError,30);
  2785. }
  2786. }
  2787. }
  2788. }
  2789. catch (e) {
  2790. }
  2791. }
  2792. }
  2793. }
  2794. );
  2795. }
  2796.  
  2797. function compareTo(){
  2798. return {
  2799. require: "ngModel",
  2800. scope: {
  2801. otherModelValue: "=compareTo"
  2802. },
  2803. link: function(scope, element, attributes, ngModel) {
  2804. ngModel.$validators.compareTo = function(modelValue) {
  2805. return modelValue == scope.otherModelValue;
  2806. };
  2807.  
  2808. scope.$watch("otherModelValue", function() {
  2809. ngModel.$validate();
  2810. });
  2811. }
  2812. };
  2813. }
  2814. /*
  2815. * Description: Player directive which renders and replace a player with directive (player) as attribute
  2816. * Developed by: Masoud motallebipour ( masoud.motallebipour@gmail.com )
  2817. * Develop date: 2015-08-12
  2818. * Last update date: 2015-08-15
  2819. * Parameters: take two input parameters ( src for video source and img for image source )
  2820. * */
  2821.  
  2822. function Player(){
  2823. var directive = {
  2824. restrict: 'A',
  2825. templateUrl: '/rstatic/ntwv114/nginxcache/template/directive/player.html',
  2826. scope: {
  2827. episode: '@eps',
  2828. type: '@typ'
  2829. },
  2830. link: linkFunc,
  2831. controller: PlayerCtrl,
  2832. replace:false,
  2833. controllerAs: 'plc',
  2834. bindToController: true // because the scope is isolated
  2835. };
  2836.  
  2837. return directive;
  2838.  
  2839. function linkFunc(scope, el, attr, ctrl) {
  2840. }
  2841. }
  2842.  
  2843. var player;
  2844. var isStartedPlaying = false;
  2845. var initialBufferTime = 0.1;
  2846. var bufferTime = 4;
  2847. window.prerollShown = false;
  2848. var expandedBufferTime = 1800;
  2849. window.VodIsPlayed = false;
  2850.  
  2851. function getVodServer(vod_link, callback) {
  2852. if (window.vod_server != "")
  2853. return callback(window.vod_server);
  2854. try {
  2855. jQuery.ajax({
  2856. 'url': vod_link,
  2857. 'success': function (data) {
  2858. var res = /.*:1935/.exec(data);
  2859. window.vod_server = res[0];
  2860. callback(window.vod_server);
  2861. }
  2862. });
  2863. }
  2864. catch(err) { window.vod_server = 'server-not-found'; callback(window.vod_server);};
  2865. };
  2866.  
  2867. function onJSBridge(playerId, event, data) {
  2868. playerId = "ply";/*typeof playerId !== 'undefined' ? playerId : 'EpisodePlayer';*/
  2869. switch(event) {
  2870. case "onJavaScriptBridgeCreated":
  2871. player = document.getElementById(playerId);
  2872. player.addEventListener("bufferingChange", "onBufferChange");
  2873. player.addEventListener("mediaError", "onMediaError");
  2874. window.vod_server = "";
  2875. break;
  2876.  
  2877. // player state change
  2878. case "ready":
  2879. playAd();
  2880. case "loading":
  2881. isStartedPlaying = false;
  2882. player.setBufferTime(initialBufferTime);
  2883. break;
  2884. case "playing":
  2885. if(window.IsPlayingVod){
  2886. jQuery("#EpisodeMomentsHolder").show();
  2887. }
  2888. var label = window.EpisodeId;
  2889. PageLoadCounter.stopTimer();
  2890. if(!window.VodIsPlayed){
  2891. window.VodIsPlayed = true;
  2892. ga('send', 'event', 'Play-Vod-Desktop', 'server', label,window.TimerResult.toString());
  2893. }
  2894. isStartedPlaying = true;
  2895. //ga('send', 'event', 'play', 'link', window.ip);
  2896. break;
  2897. case "paused":
  2898. //ga('send', 'event', 'pause', 'link', window.ip);
  2899. break;
  2900. case "buffering":
  2901. if (player.getCurrentTime == undefined)
  2902. break;
  2903. var pos = player.getCurrentTime();
  2904. if (pos > 10) {
  2905. window.num_vod_buffered += 1;
  2906. };
  2907. if (window.num_vod_buffered > 5) {
  2908. getVodServer(window.vod_link, function (data) {
  2909. ga('send', 'event', 'Vod-buffer', window.vod_server);
  2910. })
  2911. };
  2912. break;
  2913. // other events
  2914. case "mediaSize":
  2915. case "seeking":
  2916. player.setBufferTime(initialBufferTime);
  2917. case "seeked":
  2918. case "volumeChange":
  2919. case "durationChange":
  2920. case "timeChange":
  2921. case "progress": // for progressive download only
  2922. case "complete":
  2923. window.prerollShown=true;
  2924. case "advertisement":
  2925. if(data==''){
  2926. player.play2();
  2927. }
  2928. break;
  2929. default:
  2930. // console.log(event, data);
  2931. break;
  2932. }
  2933. };
  2934.  
  2935. function playAd() {
  2936. if (true) {
  2937. player.displayAd({
  2938. url: window.adUrl,
  2939. isAdvertisement:true,
  2940. hideScrubBarWhilePlayingAd: true,
  2941. pauseMainMediaWhilePlayingAd: true,
  2942. resumePlaybackAfterAd: true,
  2943. clickUrl: window.adClickUrl,
  2944. closable: false,
  2945. onStart: sendAdEvent("start")
  2946. });
  2947. }
  2948. }
  2949.  
  2950. function sendAdEvent(event) {
  2951. if(event=="start"){
  2952. $.get(window.adStart);
  2953. window.prerollShown = true;
  2954. ga('send', 'event', 'ads-desktop',"vod", "start");
  2955. debuger.info("Ad start playing");
  2956. setTimeout(function () {
  2957. sendAdEvent("finished");
  2958. },6000)
  2959. }
  2960. else if(event=="finished"){
  2961. $.get(window.adCompelete);
  2962. ga('send', 'event', 'ads-desktop',"vod", "end");
  2963. }
  2964. }
  2965.  
  2966. function onMediaError(code, message, detail, playerId) {
  2967. window.vod_server = getVodServer(window.vod_link, function (data) {
  2968. ga('send', 'event', 'Vod-Error-Desktop:', code + ':' + message, data);
  2969. });
  2970. }
  2971.  
  2972. function onBufferChange(buffering) {
  2973. if (!isStartedPlaying) return;
  2974. if (buffering) {
  2975. player.setBufferTime(bufferTime);
  2976. } else {
  2977. player.setBufferTime(expandedBufferTime);
  2978. }
  2979. }
  2980.  
  2981. angular
  2982. .module('tw-constant',[])
  2983. .constant('Configs', {
  2984. MasterWebserviceUrl: "http://m.telewebion.com/op",
  2985. MasterAdminWebserviceUrl: "http://m.pipeline.telewebion.com/op/admin",
  2986. SlaveWebserviceUrl: "http://m.telewebion.com/op",
  2987. MasterRoutingServerUrl: "http://m.telewebion.com/route",
  2988. VodSmilServerUrl: "http://m.telewebion.com/smil",
  2989. JwPlayer6LicenceKey: "JMYgt8cchkUi0xnrOhd21d9j8myk22cellFfZA==",
  2990. JwPlayer7LicenceKey: "S85cXpLUgXen47MbCLHqBUhPKnJkyh4KOOr3Rw==",
  2991. JwPlayer6LibraryPath: "/scripts/jwPlayer6/jwplayer.js",
  2992. JwPlayer7LibraryPath: "/scripts/jwPlayer/jwplayer.js",
  2993. SearchEpisodeWebserviceURL: "/op?action=getSearchEpisodes",
  2994. SearchProgramWebserviceURL: "/op?action=getSearchPrograms",
  2995. IsVodAdvertisementEnabled: true,
  2996. Players: {
  2997. JwPlayer:{License:"S85cXpLUgXen47MbCLHqBUhPKnJkyh4KOOr3Rw=="},
  2998. OsmfPlayer:{License:""},
  2999. RadiantPlayer:{
  3000. License:"Kl8lN3ZjdjR2K3NlazJ5ZWk/cm9tNWRhc2lzMzBkYjBBJV8q",
  3001. ControllsAutoHideAfter: 3000
  3002. },
  3003. VideoJs:{License:""}
  3004. },
  3005. Player : {
  3006. Vod: {
  3007. DefaultPlayer: "RadiantPlayer",
  3008. PlayerPlaceId: "EpisodePlayer",
  3009. OsfmSWFPath: "/media/js/osmfPlayer/GrindPlayer.swf",
  3010. PlayerWidth: 900,
  3011. PlayerHeight: 500
  3012. },
  3013. Live: {
  3014. DefaultPlayer: "RadiantPlayer",
  3015. PlayerWidth: 900,
  3016. PlayerHeight: 500
  3017. },
  3018. LiveMobile: {
  3019. DefaultPlayer: "VideoJs",
  3020. PlayerWidth: 500,
  3021. PlayerHeight: 400
  3022. }
  3023. },
  3024. DefaultBitrate:{
  3025. Mobile: {
  3026. Vod: '256K',
  3027. Live: ''
  3028. },
  3029. Desktop: {
  3030. Vod: '',
  3031. Live: ''
  3032. }
  3033. }
  3034. })
  3035. .constant('SiteConstants', {
  3036. En:{
  3037. PageTitle:{
  3038. HomePage:'TV Show|Movies|TV Series|Entertainment',
  3039. ForgotPassword:"Forgot password",
  3040. Login:"Login to user account",
  3041. Register:"Open a user account",
  3042. Search: "Looking for : "
  3043. },
  3044. Description:{
  3045. "HomePage": ""
  3046. },
  3047. Keywords:{"HomePage": ""}
  3048. },
  3049. Fa:{
  3050. PageTitle:{
  3051. HomePage:"تلوبیون | مرجع پخش زنده و دانلود فیلم ، سریال و سایر برنامه های تلویزیون",
  3052. ForgotPassword:"فراموشی کلمه عبور",
  3053. Login:"ورود به حساب کاربری",
  3054. Register:"ایجاد حساب کاربری",
  3055. Search:"جستجو برای واژه: ",
  3056. JobOpportunity: "موقعیت های شغلی",
  3057. Partners: "شرکای تجاری تلوبیون",
  3058. ConfirmRegistration: "تکمیل ثبت نام",
  3059. ramezan95: "ویژه ماه رمضان ۹۵ - تلوبیون",
  3060. ResendActivationEmail: "ارسال مجدد ایمیل فعال سازی",
  3061. ResetPassword: "بازیابی رمز عبور",
  3062. LigeBartar95: "فوتبال لیگ برتر ایران فصل ۹۵-۹۶",
  3063. TagsPage: "لیست قسمت برنامه های این برچسب",
  3064. MainAdminPage: "دسترسی سریع به بخشهای مدیریتی",
  3065. MoviesPage: "لیست فیلم ها",
  3066. ShademanehPage: "همیشه به خنده",
  3067. OlympicRioPage: "صفحه ویژه المپیک ریو ۲۰۱۶",
  3068. EuropeLeaguesPage: "صفحه ویژه لیگ های اروپایی",
  3069. KidsPage: "صفحه ویژه کودکان"
  3070. },
  3071. Description:{
  3072. "HomePage": "دانلود فیلم,دانلود سریال,دانلود فیلم ایرانی,دانلود سریال ایرانی,دانلود برنامه تلویزیون,پخش زنده شبکه ها,پخش زنده فوتبال,پخش زنده ورزش,پخش زنده تلویزیون,پخش شبکه سه"
  3073. },
  3074. Keywords:{"HomePage":'پخش زنده شبکه های تلویزیون ایران,آرشیو تلویزیون ایران,پخش زنده شبکه 3 و ورزش و پویا,پخش زنده فوتبال و بسکتبال و والیبال,Iran TV Channels,Iran Live TV,Iran Live Television,Iran TV Archive,Online Streaming,Watch Iran Online Video,Iran TV Live Streaming Show,Live Iran Sport Football,Persian TV Serie,Persian-Farsi TV Online Streaming تلوبیون,تلوبیون'}
  3075. }
  3076. })
  3077. .constant("Messages", {
  3078. En:{
  3079. "SuccessfulRegistration":"Dear user, your registration was successful",
  3080. "DuplicatedEmailRegistration":"Dear user, your email already exists in our database",
  3081. "FailedRegistration":"Dear user, there was a problem in registration process, please try later",
  3082. "SuccessfulLogin": "Login Successful",
  3083. "FailedLogin": "Bad username or password",
  3084. "CopyrightError": "Dear user, this video is restricted in your aria because of Copyright issues, if your using proxy please disable that and try again",
  3085. "FileNotFoundError": "Dear user, this video is restricted in your aria because of Copyright issues, if your using proxy please disable that and try again"
  3086. },
  3087. Fa:{
  3088. "SuccessfulRegistration":"کاربر گرامی، ثبت نام شما با موفقیت انجام پذیرفت، لطفا جهت فعال سازی حساب کاربری بر روی لینک فعال سازی بر روی ایمیل خود کلیک کنید",
  3089. "DuplicatedEmailRegistration":"کاربر گرامی، ایمیل شما قبلا در سیستم ثبت شده",
  3090. "FailedRegistration":"کاربر گرامی، در پروسه ثبت نام با مشکلی مواجح شدیم، لطفا مجددا تلاش فرمایید",
  3091. "SuccessfulLogin": "ورود موفقیت آمیز",
  3092. "FailedLogin": "ایمیل یا کلمه عبور صحیح نمی باشد یا حساب کاربری شما هنوز فعال نشده",
  3093. "CopyrightError": "کاربر گرامی به دلیل قوانین کپی رایت این ویدئو در منطقه جغرافیایی شما قابل مشاهده نیست. در صورتی که از وی‌پی‌ان یا پروکسی استفاده می‌کنید، آن را خاموش کنید و مجددا تلاش کنید.",
  3094. "FileNotFoundError": "کاربر گرامی، فایل این ویدیو در حال حاضر آماده استفاده نمی باشد، لطفا مجددا تلاش فرمایید",
  3095. "CopyrightErrorLive": "کاربر گرامی، با توجه به قوانین کپی رایت از پخش زنده این مسابقه معذوریم",
  3096. "LoginBadUsernameOrPassword": "ایمیل یا کلمه عبور شما صحیح نمی باشد",
  3097. "LoginSuccessful": "ورود موفق به حساب کاربری",
  3098. "LogoutSuccessful": "خروج موفق از حساب کاربری",
  3099. "NotAllowedToDownload": "جهت دانلود این ویدیو باید وارد حساب کاربری شده باشید",
  3100. "AccountVerificationSuccess": "حساب کاربری شما با موفقیت فعال شد",
  3101. "AccountVerificationFailed": "لینک وارد شده معتبر نیست و یا حساب کاربری شما قبلا فعال شده است",
  3102. "RobotError": "لطفا من روبات نیستم رو تایید کنید.",
  3103. "ConfirmRegistrationResend": "ایمیل فعال سازی مجددا برای شما ارسال گردید"
  3104. }
  3105. });
  3106.  
  3107. angular
  3108. .module('tw',['tw-factory','tw-service','tw-directive','tw-constant','ngRoute','ng.deviceDetector','ngMd5','angular-cache','satellizer','toastr','ImageCropper','noCAPTCHA'])
  3109. .config(config)
  3110. .controller('HomeCtrl', HomeCtrl)
  3111. .controller('LoginCtrl', LoginCtrl)
  3112. .controller('GeneralCtrl', GeneralCtrl)
  3113. .controller('RegisterCtrl', RegisterCtrl)
  3114. .controller('PromotionsListCtrl', PromotionsListCtrl)
  3115. .controller('PromotionsAddCtrl', PromotionsAddCtrl)
  3116. .controller('PromotionsEditCtrl', PromotionsEditCtrl)
  3117. .controller('UnsubscribeCtrl', UnsubscribeCtrl)
  3118. .controller('SearchCtrl', SearchCtrl)
  3119. .controller('LiveCtrl', LiveCtrl)
  3120. .controller('ChannelArchiveCtrl', ChannelArchiveCtrl)
  3121. .controller('ChannelArchiveOldCtrl', ChannelArchiveOldCtrl)
  3122. .controller('TestCtrl', TestCtrl)
  3123. .controller('ForgotPasswordCtrl', ForgotPasswordCtrl)
  3124. .controller('ResetPasswordCtrl', ResetPasswordCtrl)
  3125. .controller('EpisodeCtrl', EpisodeCtrl)
  3126. .controller('ProgramCtrl', ProgramCtrl)
  3127. .controller('ListOfProgramCtrl', ListOfProgramCtrl)
  3128. .controller('CategoryCtrl', CategoryCtrl)
  3129. .controller('ChannelsCtrl', ChannelsCtrl)
  3130. .controller('ChannelsCtrl', ChannelsCtrl)
  3131. .controller('DmcaCtrl', DmcaCtrl)
  3132. .controller('TermsCtrl', TermsCtrl)
  3133. .controller("PartnerCtrl",PartnerCtrl)
  3134. .controller('ChangeLogCtrl', ChangeLogCtrl)
  3135. .controller('JobOpportunityCtrl', JobOpportunityCtrl)
  3136. .controller('ArchiveCtrl', ArchiveCtrl)
  3137. .controller('VerifyRegistrationCtrl', VerifyRegistrationCtrl)
  3138. .controller('ResendActivationEmailCtrl', ResendActivationEmailCtrl)
  3139. .controller('profileCtrl', profileCtrl)
  3140. .controller('paymentConfirmationCtrl', paymentConfirmationCtrl)
  3141. .controller('fourOfourCtrl', fourOfourCtrl)
  3142. .controller('oauthLoginCtrl', oauthLoginCtrl)
  3143. .controller('EditEpisodeCtrl', EditEpisodeCtrl)
  3144. .controller('AddEpisodeCtrl', AddEpisodeCtrl)
  3145. .controller('ListOfUserCtrl', ListOfUserCtrl)
  3146. .controller('EditUserCtrl', EditUserCtrl)
  3147. .controller('ListAdsCtrl', ListAdsCtrl)
  3148. .controller('AddAdsCtrl', AddAdsCtrl)
  3149. .controller('EditAdsCtrl', EditAdsCtrl)
  3150. .controller('AngularFileUploader', AngularFileUploader)
  3151. .controller('AngularFileCrop', AngularFileCrop)
  3152. .controller('EditArtistCtrl', EditArtistCtrl)
  3153. .controller('EditProgramCtrl', EditProgramCtrl)
  3154. .controller('AddProgramCtrl', AddProgramCtrl)
  3155. .controller('EditFavoriteListCtrl', EditFavoriteListCtrl)
  3156. .controller('AddArtistCtrl', AddArtistCtrl)
  3157. .controller('AddFavoriteListCtrl', AddFavoriteListCtrl)
  3158. .controller('Ramezan95Ctrl', Ramezan95Ctrl)
  3159. .controller('LigeBartarCtrl', LigeBartarCtrl)
  3160. .controller('ListOfEpisodesCtrl', ListOfEpisodesCtrl)
  3161. .controller('ListOfFavListCtrl', ListOfFavListCtrl)
  3162. .controller('MoviesCtrl', MoviesCtrl)
  3163. .controller('EuropeLeaguesCtrl', EuropeLeaguesCtrl)
  3164. .controller('KidsCtrl', KidsCtrl)
  3165. .controller('ShademanehCtrl', ShademanehCtrl)
  3166. .controller('OlympicsCtrl', OlympicsCtrl)
  3167. .controller('MainAdminCtrl', MainAdminCtrl)
  3168. .controller('SeriesCtrl', SeriesCtrl)
  3169. .controller('TagsCtrl', TagsCtrl)
  3170. .controller('TagCtrl', TagCtrl)
  3171. .controller('AdsBankListCtrl', AdsBankListCtrl)
  3172. .controller('AdsBankEditCtrl', AdsBankEditCtrl)
  3173. .controller('AdsBankAddCtrl', AdsBankAddCtrl)
  3174. .run(Runtime);
  3175. Ramezan95Ctrl.$inject = ['GeneralInit','$rootScope','SiteConstants','ProgressBarFcy','SliderFcy','EpisodeFcy'];
  3176. LigeBartarCtrl.$inject = ['GeneralInit','$rootScope','SiteConstants','ProgressBarFcy','SliderFcy','EpisodeFcy','FavoriteListSrv','$scope','FavoriteListFcy','$timeout'];
  3177. HomeCtrl.$inject = ['GeneralInit','EpisodeFcy','ChannelFcy','HomeInit','$rootScope','SiteConstants','ProgressBarFcy','$scope','ProgramFcy','$location','Messages','$window','$timeout'];
  3178. EpisodeCtrl.$inject = ['GeneralInit','$rootScope','EpisodeSrv','Messages','$routeParams','SiteConstants','SecurityFcy','ProgressBarFcy','EpisodeFcy','ProgramFcy','$filter','$scope','deviceDetector','ChannelFcy','FavoriteListSrv','$timeout','Configs'];
  3179. ProgramCtrl.$inject = ['GeneralInit','$rootScope','ProgramSrv','Messages','$routeParams','SiteConstants','SecurityFcy','ProgressBarFcy','ProgramFcy','$scope','ChannelFcy','$timeout'];
  3180. GeneralCtrl.$inject = ['$rootScope','EpisodeSrv','$location','$anchorScroll','deviceDetector','GeneralInit','UserSrv','Messages','$timeout','SearchFcy','VasFcy','$window'];
  3181. RegisterCtrl.$inject = ['GeneralInit','UserSrv','Messages','$rootScope','SiteConstants','ProgressBarFcy'];
  3182. LoginCtrl.$inject = ['GeneralInit','UserSrv','Messages','$window','$rootScope','SiteConstants','ProgressBarFcy','$auth','toastr','$scope','$location'];
  3183. LiveCtrl.$inject = ['GeneralInit','ChannelSrv','$routeParams','$rootScope','deviceDetector','ProgressBarFcy','ChannelFcy','EpisodeFcy','Configs','$scope','$timeout','SecurityFcy','HourlyArchiveFcy'];
  3184. ChannelArchiveCtrl.$inject = ['GeneralInit','ChannelSrv','$routeParams','$rootScope','deviceDetector','ProgressBarFcy','ChannelFcy','EpisodeFcy','Configs','$scope','$timeout','SecurityFcy','$location','$route'];
  3185. ChannelArchiveOldCtrl.$inject = ['$window','GeneralInit','ChannelSrv','$routeParams','$rootScope','deviceDetector','ProgressBarFcy','ChannelFcy','EpisodeFcy','Configs','$scope','$timeout','SecurityFcy','$location','$route'];
  3186. CategoryCtrl.$inject = ['GeneralInit','EpisodeFcy','$routeParams','$rootScope','SiteConstants','ProgressBarFcy'];
  3187. SearchCtrl.$inject= ['GeneralInit','$routeParams','SearchFcy','$rootScope','SiteConstants','ProgressBarFcy'];
  3188. ChannelsCtrl.$inject= ['GeneralInit','$rootScope','SiteConstants','ProgressBarFcy','ChannelFcy'];
  3189. DmcaCtrl.$inject= ['GeneralInit','$rootScope','SiteConstants','ProgressBarFcy'];
  3190. TagsCtrl.$inject= ['GeneralInit','$rootScope','SiteConstants','ProgressBarFcy','SliderFcy','EpisodeFcy','$timeout'];
  3191. MoviesCtrl.$inject= ['GeneralInit','$rootScope','SiteConstants','ProgressBarFcy','SliderFcy','EpisodeFcy','$timeout'];
  3192. EuropeLeaguesCtrl.$inject= ['GeneralInit','$rootScope','SiteConstants','ProgressBarFcy','SliderFcy','EpisodeFcy'];
  3193. KidsCtrl.$inject= ['GeneralInit','$rootScope','SiteConstants','ProgressBarFcy','SliderFcy','EpisodeFcy','$timeout'];
  3194. ShademanehCtrl.$inject= ['GeneralInit','$rootScope','SiteConstants','ProgressBarFcy','SliderFcy','EpisodeFcy'];
  3195. OlympicsCtrl.$inject= ['GeneralInit','$rootScope','SiteConstants','ProgressBarFcy','SliderFcy','EpisodeFcy'];
  3196. MainAdminCtrl.$inject= ['GeneralInit','$rootScope','SiteConstants','ProgressBarFcy','SliderFcy','EpisodeFcy','UserSrv','SecurityFcy','$window'];
  3197. SeriesCtrl.$inject= ['GeneralInit','$rootScope','SiteConstants','ProgressBarFcy','SliderFcy','EpisodeFcy','$timeout'];
  3198. ArchiveCtrl.$inject= ['GeneralInit','$rootScope','SiteConstants','ProgressBarFcy','ChannelFcy','EpisodeFcy','$routeParams'];
  3199. JobOpportunityCtrl.$inject= ['$rootScope','SiteConstants','ProgressBarFcy'];
  3200. profileCtrl.$inject= ['GeneralInit','$rootScope','SiteConstants','ProgressBarFcy'];
  3201. fourOfourCtrl.$inject= ['GeneralInit','$rootScope','SiteConstants','ProgressBarFcy','EpisodeFcy'];
  3202. paymentConfirmationCtrl.$inject= ['GeneralInit','$rootScope','SiteConstants','ProgressBarFcy'];
  3203. TermsCtrl.$inject= ['GeneralInit','$rootScope','SiteConstants','ProgressBarFcy'];
  3204. PartnerCtrl.$inject= ['$rootScope','SiteConstants','ProgressBarFcy'];
  3205. ChangeLogCtrl.$inject= ['GeneralInit','$rootScope','SiteConstants','ProgressBarFcy'];
  3206. config.$inject = ['$routeProvider','CacheFactoryProvider','$locationProvider','$authProvider','googleGrecaptchaProvider'];
  3207. Runtime.$inject = ['$http','$location', '$rootScope', '$window','CacheFactory','ProgressBarFcy','$templateCache','UserSrv'];
  3208. VerifyRegistrationCtrl.$inject = ['$rootScope','GeneralInit','UserSrv','Messages','SiteConstants','ProgressBarFcy','$routeParams','$scope'];
  3209. oauthLoginCtrl.$inject = ['$routeParams','SecurityFcy','Messages','$window','ProgressBarFcy'];
  3210. ForgotPasswordCtrl.$inject = ['GeneralInit','UserSrv','Messages','$rootScope','SiteConstants','ProgressBarFcy','$scope'];
  3211. ResetPasswordCtrl.$inject = ['GeneralInit','UserSrv','Messages','$rootScope','SiteConstants','ProgressBarFcy','$routeParams'];
  3212. ResendActivationEmailCtrl.$inject = ['$rootScope','GeneralInit','UserSrv','Messages','SiteConstants','ProgressBarFcy','$routeParams'];
  3213. EditEpisodeCtrl.$inject = ['GeneralInit','UserSrv','$rootScope','SiteConstants','ProgressBarFcy','EpisodeSrv','$routeParams','$window','$http','SecurityFcy','ArtistFcy','TagFcy','FavoriteListFcy','Configs','ProgramFcy'];
  3214. EditUserCtrl.$inject = ['GeneralInit','UserSrv','UserFcy','$rootScope','SiteConstants','ProgressBarFcy','$routeParams','$window','$http','SecurityFcy','Configs'];
  3215. AddEpisodeCtrl.$inject = ['GeneralInit','UserSrv','$rootScope','SiteConstants','ProgressBarFcy','EpisodeSrv','$routeParams','$window','$http','SecurityFcy','ArtistFcy','TagFcy','FavoriteListFcy','Configs','ProgramFcy'];
  3216. ListAdsCtrl.$inject = ['$rootScope','AdsFcy','AdsSrv','ProgressBarFcy','SecurityFcy','UserSrv'];
  3217. AddAdsCtrl.$inject = ['$rootScope','AdsSrv','ProgressBarFcy','SecurityFcy','UserSrv','$window'];
  3218. PromotionsListCtrl.$inject = ['$rootScope','AdsSrv','ProgressBarFcy','SecurityFcy','UserSrv','$window','PromotionFcy','PromotionsSrv'];
  3219. PromotionsAddCtrl.$inject = ['$rootScope','AdsSrv','ProgressBarFcy','SecurityFcy','UserSrv','$window','PromotionFcy','PromotionsSrv'];
  3220. PromotionsEditCtrl.$inject = ['$rootScope','AdsSrv','ProgressBarFcy','SecurityFcy','UserSrv','$window','PromotionFcy','$routeParams','PromotionsSrv'];
  3221. AdsBankListCtrl.$inject = ['$rootScope','AdsFcy','AdsSrv','ProgressBarFcy','SecurityFcy','UserSrv','AdBankFcy','$window','AdBankSrv'];
  3222. AdsBankEditCtrl.$inject = ['$rootScope','AdsFcy','AdsSrv','ProgressBarFcy','SecurityFcy','UserSrv','AdBankFcy','AdBankSrv','$routeParams','$window'];
  3223. AdsBankAddCtrl.$inject = ['$rootScope','AdsSrv','ProgressBarFcy','SecurityFcy','UserSrv','$window','AdBankFcy','AdBankSrv'];
  3224. EditAdsCtrl.$inject = ['$rootScope','AdsSrv','ProgressBarFcy','SecurityFcy','UserSrv','$window','$routeParams'];
  3225. EditArtistCtrl.$inject = ['UserSrv','$rootScope','SiteConstants','ProgressBarFcy','EpisodeSrv','$routeParams','$window','ArtistSrv'];
  3226. EditFavoriteListCtrl.$inject = ['UserSrv','$rootScope','SiteConstants','ProgressBarFcy','EpisodeSrv','$routeParams','$window','FavoriteListSrv','SecurityFcy','FavoriteListFcy','UserSrv'];
  3227. AddArtistCtrl.$inject = ['UserSrv','$rootScope','SiteConstants','ProgressBarFcy','EpisodeSrv','$routeParams','$window','ArtistSrv'];
  3228. AddFavoriteListCtrl.$inject = ['UserSrv','$rootScope','SiteConstants','ProgressBarFcy','EpisodeSrv','$routeParams','$window','FavoriteListSrv','SecurityFcy','FavoriteListFcy'];
  3229. AngularFileUploader.$inject = ['$rootScope','Upload'];
  3230. AngularFileCrop.$inject = ['$rootScope','$scope','ImageUploadFcy','SecurityFcy'];
  3231. UnsubscribeCtrl.$inject = ['GeneralInit','$rootScope','$routeParams','ProgressBarFcy','UserSrv'];
  3232. EditProgramCtrl.$inject = ['UserSrv','$rootScope','SiteConstants','ProgressBarFcy','ProgramSrv','$routeParams','$window','SecurityFcy','ArtistFcy','ProgramFcy'];
  3233. AddProgramCtrl.$inject = ['UserSrv','$rootScope','SiteConstants','ProgressBarFcy','ProgramSrv','$routeParams','$window','SecurityFcy','ArtistFcy','ProgramFcy'];
  3234. ListOfEpisodesCtrl.$inject = ['UserSrv','$rootScope','SiteConstants','ProgressBarFcy','ProgramSrv','$routeParams','$window','SecurityFcy','EpisodeFcy','EpisodeSrv','ChannelFcy','$scope'];
  3235. ListOfProgramCtrl.$inject = ['UserSrv','$rootScope','SiteConstants','ProgressBarFcy','ProgramSrv','ProgramFcy','$window','SecurityFcy','ChannelFcy'];
  3236. ListOfFavListCtrl.$inject = ['UserSrv','$rootScope','SiteConstants','ProgressBarFcy','ProgramSrv','$routeParams','$window','SecurityFcy','FavoriteListFcy'];
  3237. TagsCtrl.$inject = ['GeneralInit','$rootScope','SiteConstants','ProgressBarFcy','SliderFcy','EpisodeFcy','FavoriteListFcy','$routeParams','FavoriteListSrv','$timeout'];
  3238. TagCtrl.$inject = ['GeneralInit','$rootScope','SiteConstants','ProgressBarFcy','SliderFcy','EpisodeFcy','TagPageFcy','$routeParams','FavoriteListSrv','$timeout'];
  3239. ListOfUserCtrl.$inject = ['GeneralInit','UserSrv','UserFcy','$rootScope','SiteConstants','ProgressBarFcy','$window','$http','SecurityFcy','Configs'];
  3240. function Runtime($http,$location, $rootScope, $window,CacheFactory,ProgressBarFcy,$templateCache,UserSrv){
  3241. $templateCache.put('home.html', 'This is the home template<br><br>');
  3242. /*$http.cache=true;*/
  3243. $rootScope.$on('$routeChangeStart', function (event, current, previous) {
  3244. ProgressBarFcy.setStatus(0.1);
  3245. });
  3246.  
  3247. $rootScope.$on('$routeChangeSuccess', function (event, current, previous) {
  3248. if((typeof previous !='undefined') && (previous.controller=="EpisodeCtrl" || previous.controller=="LiveCtrl") && (DeviceDetection.IsAndroid() || DeviceDetection.IsIos() || DeviceDetection.IsIpad() || DeviceDetection.IsSmartTv())){
  3249. window.Player.dispose();
  3250. }
  3251. /* for Alexa */
  3252. debuger.log("Now you are in :" + $location.path());
  3253. if(typeof previous !='undefined'){
  3254. $rootScope.InSiteLink = true;
  3255. window.VodIsPlayed = false;
  3256. }
  3257. $rootScope.TryCount = 0;
  3258. $rootScope.ProgramDetailTryCount = 0;
  3259. $("html,body").scrollTop(0);
  3260. /*$window.ga('send', 'pageview', { page: $location.path()});*/
  3261. _atrk_opts = { atrk_acct:"qVWKl1a8FRh270", domain:"telewebion.com",dynamic: true};
  3262. (function() { var as = document.createElement('script'); as.type = 'text/javascript'; as.async = true; as.src = "https://d31qbv1cthcecs.cloudfront.net/atrk.js"; var s = document.getElementsByTagName('script')[0];s.parentNode.insertBefore(as, s); })();
  3263. window._atrk_fired = false;
  3264. try {atrk();} catch(err) {};
  3265. /*closeHamburgerMenu();*/
  3266. ProgressBarFcy.plus(0.2);
  3267. _atrk_opts = { atrk_acct:"qVWKl1a8FRh270", domain:"telewebion.com",dynamic: true};
  3268. UserSrv.getUser().then(function(UserInfo){
  3269. $rootScope.User=UserInfo;
  3270. if(typeof UserInfo.user_info!='undefined'){
  3271. $rootScope.UserStatus.IsAuthenticated=true;
  3272. }else{
  3273. $rootScope.UserStatus.IsAuthenticated=false;
  3274. }
  3275. $rootScope.$broadcast("UserData");
  3276. });
  3277. });
  3278. $rootScope.$on('$viewContentLoaded', function(event) {
  3279. $window.ga('send', 'pageview', { page: $location.path()});
  3280. });
  3281. $rootScope.$on('$routeChangeError', function (event, current, previous, error) {
  3282. /*if (error.status === 404) {
  3283. $location.path('/404');
  3284. }*/
  3285. });
  3286.  
  3287. $http.defaults.cache = CacheFactory('defaultCache', {
  3288. maxAge: 30 * 60 * 1000, // Items added to this cache expire after 15 minutes
  3289. cacheFlushInterval: 60 * 60 * 1000, // This cache will clear itself every hour
  3290. deleteOnExpire: 'aggressive' // Items will be deleted from this cache when they expire
  3291. });
  3292. /*$http.defaults.headers.get = { 'Coi' : 'http://m.telewebion.com/' };*/
  3293. $http.defaults.headers.post = { 'Content-Type' : 'text/plain' };
  3294. }
  3295. function config($routeProvider,CacheFactoryProvider,$location,$authProvider,googleGrecaptchaProvider) {
  3296. $location.hashPrefix('!');
  3297. googleGrecaptchaProvider.setLanguage("fa");
  3298. $routeProvider
  3299. .when('/', {
  3300. templateUrl: '/rstatic/ntwv114/nginxcache/template/fa/home.html',
  3301. controller: 'HomeCtrl',
  3302. controllerAs: 'hmc',
  3303. resolve: {
  3304. GeneralInit: function(GeneralInit){
  3305. return GeneralInit();
  3306. },
  3307. HomeInit: function(HomeInit){
  3308. return HomeInit();
  3309. }
  3310. }
  3311. })
  3312. .when('/main', {
  3313. templateUrl: '/rstatic/ntwv114/nginxcache/template/fa/home.html',
  3314. controller: 'HomeCtrl',
  3315. controllerAs: 'hmc',
  3316. resolve: {
  3317. GeneralInit: function(GeneralInit){
  3318. return GeneralInit();
  3319. },
  3320. HomeInit: function(HomeInit){
  3321. return HomeInit();
  3322. }
  3323. }
  3324. })
  3325. .when('/fa', {
  3326. redirectTo: '/'
  3327. })
  3328. .when('/en', {
  3329. templateUrl: '/rstatic/ntwv114/nginxcache/template/en/home.html',
  3330. controller: 'HomeCtrl',
  3331. controllerAs: 'hmc',
  3332. resolve: {
  3333. GeneralInit: function(GeneralInit){
  3334. return GeneralInit();
  3335. },
  3336. HomeInit: function(HomeInit){
  3337. return HomeInit();
  3338. }
  3339. }
  3340. })
  3341. .when('/register', {
  3342. redirectTo: '/login'
  3343. })
  3344. .when('/fa/register', {
  3345. redirectTo: '/login'
  3346. })
  3347. .when('/en/register', {
  3348. templateUrl: '/rstatic/ntwv114/nginxcache/template/en/register.html',
  3349. controller: 'RegisterCtrl',
  3350. controllerAs: 'urg',
  3351. resolve: {
  3352. GeneralInit: function(GeneralInit){
  3353. return GeneralInit();
  3354. }}
  3355. })
  3356. .when('/login', {
  3357. templateUrl: '/rstatic/ntwv114/nginxcache/template/fa/register.html',
  3358. controller: 'LoginCtrl',
  3359. controllerAs: 'urg',
  3360. resolve: {
  3361. GeneralInit: function(GeneralInit){
  3362. return GeneralInit();
  3363. }}
  3364. })
  3365. .when('/channels', {
  3366. templateUrl: '/rstatic/ntwv114/nginxcache/template/fa/channels.html',
  3367. controller: 'ChannelsCtrl',
  3368. controllerAs: 'clc',
  3369. resolve: {
  3370. GeneralInit: function(GeneralInit){
  3371. return GeneralInit();
  3372. }}
  3373. })
  3374. .when('/fa/login', {
  3375. redirectTo: '/login'
  3376. })
  3377. .when('/fa/channels', {
  3378. redirectTo: '/channels'
  3379. })
  3380. .when('/en/login', {
  3381. templateUrl: '/rstatic/ntwv114/nginxcache/template/en/login.html',
  3382. controller: 'LoginCtrl',
  3383. controllerAs: 'uln',
  3384. resolve: {
  3385. GeneralInit: function(GeneralInit){
  3386. return GeneralInit();
  3387. }}
  3388. })
  3389. .when('/partners/', {
  3390. templateUrl: '/rstatic/ntwv114/nginxcache/template/fa/partners.html',
  3391. controller: 'PartnerCtrl',
  3392. controllerAs: 'ptn',
  3393. resolve: {
  3394. GeneralInit: function(GeneralInit){
  3395. return GeneralInit();
  3396. }}
  3397. })
  3398. .when('/fa/partners/', {
  3399. redirectTo: '/partners/'
  3400. })
  3401. .when('/forgotpassword', {
  3402. templateUrl: '/rstatic/ntwv114/nginxcache/template/fa/forgot_password.html',
  3403. controller: 'ForgotPasswordCtrl',
  3404. controllerAs: 'frp',
  3405. resolve: {
  3406. GeneralInit: function(GeneralInit){
  3407. return GeneralInit();
  3408. }}
  3409. })
  3410. .when('/fa/forgotpassword', {
  3411. redirectTo: '/forgotpassword'
  3412. })
  3413. .when('/en/forgotpassword', {
  3414. templateUrl: '/rstatic/ntwv114/nginxcache/template/en/forgot_password.html',
  3415. controller: 'ForgotPasswordCtrl',
  3416. controllerAs: 'frp',
  3417. resolve: {
  3418. GeneralInit: function(GeneralInit){
  3419. return GeneralInit();
  3420. }}
  3421. })
  3422. .when('/program/:Id/', {
  3423. templateUrl: '/rstatic/ntwv114/nginxcache/template/fa/program.html',
  3424. controller: 'ProgramCtrl',
  3425. controllerAs: 'pgc',
  3426. resolve: {
  3427. GeneralInit: function(GeneralInit){
  3428. return GeneralInit();
  3429. }}
  3430. })
  3431. .when('/fa/program/:Id/', {
  3432. redirectTo: '/program/:Id/'
  3433. })
  3434. .when('/en/program/:Id/', {
  3435. templateUrl: '/rstatic/ntwv114/nginxcache/template/en/program.html',
  3436. controller: 'ProgramCtrl',
  3437. controllerAs: 'pgc',
  3438. resolve: {
  3439. GeneralInit: function(GeneralInit){
  3440. return GeneralInit();
  3441. }}
  3442. })
  3443. .when('/episode/:Id/', {
  3444. templateUrl: '/rstatic/ntwv114/nginxcache/template/fa/episode.html',
  3445. controller: 'EpisodeCtrl',
  3446. controllerAs: 'epc',
  3447. resolve: {
  3448. GeneralInit: function(GeneralInit){
  3449. return GeneralInit();
  3450. }}
  3451. })
  3452. .when('/episode/episode/:Id/', {
  3453. redirectTo: '/episode/:Id/'
  3454. })
  3455. .when('/fa/episode/:Id/', {
  3456. redirectTo: '/episode/:Id/'
  3457. })
  3458. .when('/en/episode/:Id/', {
  3459. templateUrl: '/rstatic/ntwv114/nginxcache/template/en/episode.html',
  3460. controller: 'EpisodeCtrl',
  3461. controllerAs: 'epc',
  3462. resolve: {
  3463. GeneralInit: function(GeneralInit){
  3464. return GeneralInit();
  3465. }}
  3466. })
  3467. .when('/fa/live/:Id/', {
  3468. redirectTo: '/live/:Id/'
  3469. })
  3470. .when('/live/:Id/', {
  3471. templateUrl: '/rstatic/ntwv114/nginxcache/template/fa/live.html',
  3472. controller: 'LiveCtrl',
  3473. controllerAs: 'lic',
  3474. resolve: {
  3475. GeneralInit: function(GeneralInit){
  3476. return GeneralInit();
  3477. }}
  3478. })
  3479. .when('/archive/:Id', {
  3480. templateUrl: '/rstatic/ntwv114/nginxcache/template/fa/channel_archive_old.html',
  3481. controller: 'ChannelArchiveOldCtrl',
  3482. controllerAs: 'coc',
  3483. reloadOnSearch: false,
  3484. resolve: {
  3485. GeneralInit: function(GeneralInit){
  3486. return GeneralInit();
  3487. }}
  3488. })
  3489. .when('/archive/:Id/:date', {
  3490. templateUrl: '/rstatic/ntwv114/nginxcache/template/fa/channel_archive.html',
  3491. controller: 'ChannelArchiveCtrl',
  3492. controllerAs: 'cac',
  3493. reloadOnSearch: false,
  3494. resolve: {
  3495. GeneralInit: function(GeneralInit){
  3496. return GeneralInit();
  3497. }}
  3498. })
  3499. .when('/category/:Id/', {
  3500. templateUrl: '/rstatic/ntwv114/nginxcache/template/fa/category.html',
  3501. controller: 'CategoryCtrl',
  3502. controllerAs: 'ctc',
  3503. resolve: {
  3504. GeneralInit: function(GeneralInit){
  3505. return GeneralInit();
  3506. }}
  3507. })
  3508. .when('/rio2016', {
  3509. templateUrl: '/rstatic/ntwv114/nginxcache/template/fa/olympics.html',
  3510. controller: 'OlympicsCtrl',
  3511. controllerAs: 'orc',
  3512. resolve: {
  3513. GeneralInit: function(GeneralInit){
  3514. return GeneralInit();
  3515. }}
  3516. })
  3517. .when('/fa/category/:Id/', {
  3518. redirectTo: '/category/:Id/'
  3519. })
  3520. .when('/en/category/:Id/', {
  3521. templateUrl: '/rstatic/ntwv114/nginxcache/template/fa/category.html',
  3522. controller: 'CategoryCtrl',
  3523. controllerAs: 'ctc',
  3524. resolve: {
  3525. GeneralInit: function(GeneralInit){
  3526. return GeneralInit();
  3527. }}
  3528. })
  3529. .when('/en/live/:Id/', {
  3530. templateUrl: '/rstatic/ntwv114/nginxcache/template/en/live.html',
  3531. controller: 'LiveCtrl',
  3532. controllerAs: 'lic',
  3533. resolve: {
  3534. GeneralInit: function(GeneralInit){
  3535. return GeneralInit();
  3536. }}
  3537. })
  3538. .when('/en/search/:SearchContext', {
  3539. templateUrl: '/rstatic/ntwv114/nginxcache/template/en/search.html',
  3540. controller: 'SearchCtrl',
  3541. controllerAs: 'src',
  3542. resolve: {
  3543. GeneralInit: function(GeneralInit){
  3544. return GeneralInit();
  3545. }}
  3546. })
  3547. .when('/fa/search/:SearchContext', {
  3548. redirectTo: '/search/:Id/'
  3549. })
  3550. .when('/search/:SearchContext', {
  3551. templateUrl: '/rstatic/ntwv114/nginxcache/template/fa/search.html',
  3552. controller: 'SearchCtrl',
  3553. controllerAs: 'src',
  3554. resolve: {
  3555. GeneralInit: function(GeneralInit){
  3556. return GeneralInit();
  3557. }}
  3558. })
  3559. .when('/test/', {
  3560. templateUrl: '/rstatic/ntwv114/nginxcache/template/fa/test.html',
  3561. controller: 'TestCtrl',
  3562. controllerAs: 'tst',
  3563. resolve: {
  3564. GeneralInit: function(GeneralInit){
  3565. return GeneralInit();
  3566. }}
  3567. })
  3568. .when('/archive_old/:Id/', {
  3569. templateUrl: '/rstatic/ntwv65/nginxcache/template/fa/archive.html',
  3570. controller: 'ArchiveCtrl',
  3571. controllerAs: 'arc',
  3572. resolve: {
  3573. GeneralInit: function(GeneralInit){
  3574. return GeneralInit();
  3575. }}
  3576. })
  3577. .when('/fa/archive/:Id/', {
  3578. redirectTo: '/archive/:Id/'
  3579. })
  3580. .when('/dmca/', {
  3581. templateUrl: '/rstatic/ntwv114/nginxcache/template/fa/changeLog2.html',
  3582. controller: 'DmcaCtrl',
  3583. controllerAs: 'dmc',
  3584. resolve: {
  3585. GeneralInit: function(GeneralInit){
  3586. return GeneralInit();
  3587. }}
  3588. })
  3589. .when('/fa/dmca/', {
  3590. redirectTo: '/dmca/'
  3591. })
  3592. .when('/ResetPassword/:token', {
  3593. templateUrl: '/rstatic/ntwv114/nginxcache/template/fa/reset_password.html',
  3594. controller: 'ResetPasswordCtrl',
  3595. controllerAs: 'rpc',
  3596. resolve: {
  3597. GeneralInit: function(GeneralInit){
  3598. return GeneralInit();
  3599. }}
  3600. })
  3601. .when('/fa/ResetPassword/:token', {
  3602. redirectTo: '/ResetPassword/:token'
  3603. })
  3604. .when('/terms/', {
  3605. templateUrl: '/rstatic/ntwv114/nginxcache/template/fa/TermsOfServices.html',
  3606. controller: 'TermsCtrl',
  3607. controllerAs: 'tcc',
  3608. resolve: {
  3609. GeneralInit: function(GeneralInit){
  3610. return GeneralInit();
  3611. }}
  3612. })
  3613. .when('/fa/terms/', {
  3614. redirectTo: '/terms/'
  3615. })
  3616. .when('/changeLog/', {
  3617. templateUrl: '/rstatic/ntwv114/nginxcache/template/fa/changeLog.html',
  3618. controller: 'ChangeLogCtrl',
  3619. controllerAs: 'clc',
  3620. resolve: {
  3621. GeneralInit: function(GeneralInit){
  3622. return GeneralInit();
  3623. }}
  3624. })
  3625. .when('/fa/changeLog/', {
  3626. redirectTo: '/changeLog/'
  3627. })
  3628. .when('/jobs/', {
  3629. templateUrl: '/rstatic/ntwv114/nginxcache/template/fa/job_opportunity.html',
  3630. controller: 'JobOpportunityCtrl',
  3631. controllerAs: 'joc',
  3632. resolve: {
  3633. GeneralInit: function(GeneralInit){
  3634. return GeneralInit();
  3635. }}
  3636. })
  3637. .when('/fa/jobOpportunity/', {
  3638. redirectTo: '/jobOpportunity/'
  3639. })
  3640. .when('/fa/VerifyRegistration/:VCode/:HMail/:Username', {
  3641. redirectTo: '/VerifyRegistration/:VCode/:HMail/:Username'
  3642. })
  3643. .when('/VerifyRegistration/:VCode/:HMail/:Username', {
  3644. templateUrl: '/rstatic/ntwv114/nginxcache/template/fa/verify_registration.html',
  3645. controller: 'VerifyRegistrationCtrl',
  3646. controllerAs: 'vrc',
  3647. resolve: {
  3648. GeneralInit: function(GeneralInit){
  3649. return GeneralInit();
  3650. }}
  3651. })
  3652. .when('/fa/ResendActivationEmail/', {
  3653. redirectTo: '/ResendActivationEmailCtrl'
  3654. })
  3655. .when('/404', {
  3656. templateUrl: '/rstatic/ntwv114/nginxcache/template/fa/404.html',
  3657. controller: 'fourOfourCtrl',
  3658. controllerAs: 'foc',
  3659. resolve: {
  3660. GeneralInit: function(GeneralInit){
  3661. return GeneralInit();
  3662. }}
  3663. })
  3664. .when('/profile', {
  3665. templateUrl: '/rstatic/ntwv114/nginxcache/template/fa/profile.html',
  3666. controller: 'profileCtrl',
  3667. controllerAs: 'prc',
  3668. resolve: {
  3669. GeneralInit: function(GeneralInit){
  3670. return GeneralInit();
  3671. }}
  3672. })
  3673. .when('/paymentConfirmation', {
  3674. templateUrl: '/rstatic/ntwv114/nginxcache/template/fa/paymentConfirmation.html',
  3675. controller: 'paymentConfirmationCtrl',
  3676. controllerAs: 'pmc',
  3677. resolve: {
  3678. GeneralInit: function(GeneralInit){
  3679. return GeneralInit();
  3680. }}
  3681. })
  3682. .when('/oauthLogin/:token', {
  3683. templateUrl: '/rstatic/ntwv114/nginxcache/template/fa/oauthLogin.html',
  3684. controller: 'oauthLoginCtrl',
  3685. controllerAs: 'oac',
  3686. resolve: {
  3687. GeneralInit: function(GeneralInit){
  3688. return GeneralInit();
  3689. }}
  3690. })
  3691. .when('/admin/episode/edit/:Id/', {
  3692. templateUrl: '/rstatic/ntwv114/nginxcache/template/fa/episode_edit.html',
  3693. controller: 'EditEpisodeCtrl',
  3694. controllerAs: 'eec',
  3695. resolve: {
  3696. GeneralInit: function(GeneralInit){
  3697. return GeneralInit();
  3698. }}
  3699. })
  3700. .when('/admin/user/edit/:Id/', {
  3701. templateUrl: '/rstatic/ntwv114/nginxcache/template/fa/user_edit.html',
  3702. controller: 'EditUserCtrl',
  3703. controllerAs: 'euc',
  3704. resolve: {
  3705. GeneralInit: function(GeneralInit){
  3706. return GeneralInit();
  3707. }}
  3708. })
  3709. .when('/admin/users/list/', {
  3710. templateUrl: '/rstatic/ntwv114/nginxcache/template/fa/user_list.html',
  3711. controller: 'ListOfUserCtrl',
  3712. controllerAs: 'luc',
  3713. resolve: {
  3714. GeneralInit: function(GeneralInit){
  3715. return GeneralInit();
  3716. }}
  3717. })
  3718. .when('/admin/episode/add/', {
  3719. templateUrl: '/rstatic/ntwv114/nginxcache/template/fa/episode_add.html',
  3720. controller: 'AddEpisodeCtrl',
  3721. controllerAs: 'aec',
  3722. resolve: {
  3723. GeneralInit: function(GeneralInit){
  3724. return GeneralInit();
  3725. }}
  3726. })
  3727. .when('/admin/artist/edit/:Id/', {
  3728. templateUrl: '/rstatic/ntwv114/nginxcache/template/fa/artist_edit.html',
  3729. controller: 'EditArtistCtrl',
  3730. controllerAs: 'aec',
  3731. resolve: {
  3732. GeneralInit: function(GeneralInit){
  3733. return GeneralInit();
  3734. }}
  3735. })
  3736. .when('/admin/artist/add/', {
  3737. templateUrl: '/rstatic/ntwv114/nginxcache/template/fa/artist_add.html',
  3738. controller: 'AddArtistCtrl',
  3739. controllerAs: 'aac',
  3740. resolve: {
  3741. GeneralInit: function(GeneralInit){
  3742. return GeneralInit();
  3743. }}
  3744. })
  3745. .when('/admin/favoritelist/edit/:Id/', {
  3746. templateUrl: '/rstatic/ntwv114/nginxcache/template/fa/favlist_edit.html',
  3747. controller: 'EditFavoriteListCtrl',
  3748. controllerAs: 'fec',
  3749. resolve: {
  3750. GeneralInit: function(GeneralInit){
  3751. return GeneralInit();
  3752. }}
  3753. })
  3754. .when('/admin/favoritelist/add/', {
  3755. templateUrl: '/rstatic/ntwv114/nginxcache/template/fa/favlist_add.html',
  3756. controller: 'AddFavoriteListCtrl',
  3757. controllerAs: 'fac',
  3758. resolve: {
  3759. GeneralInit: function(GeneralInit){
  3760. return GeneralInit();
  3761. }}
  3762. })
  3763. .when('/admin/program/edit/:Id/', {
  3764. templateUrl: '/rstatic/ntwv114/nginxcache/template/fa/program_edit.html',
  3765. controller: 'EditProgramCtrl',
  3766. controllerAs: 'epc',
  3767. resolve: {
  3768. GeneralInit: function(GeneralInit){
  3769. return GeneralInit();
  3770. }}
  3771. })
  3772. .when('/admin/program/add/', {
  3773. templateUrl: '/rstatic/ntwv114/nginxcache/template/fa/program_add.html',
  3774. controller: 'AddProgramCtrl',
  3775. controllerAs: 'apc',
  3776. resolve: {
  3777. GeneralInit: function(GeneralInit){
  3778. return GeneralInit();
  3779. }}
  3780. })
  3781. .when('/admin/episode/list/', {
  3782. templateUrl: '/rstatic/ntwv114/nginxcache/template/fa/episode_list.html',
  3783. controller: 'ListOfEpisodesCtrl',
  3784. controllerAs: 'lec',
  3785. resolve: {
  3786. GeneralInit: function(GeneralInit){
  3787. return GeneralInit();
  3788. }}
  3789. })
  3790. .when('/admin/program/list/', {
  3791. templateUrl: '/rstatic/ntwv114/nginxcache/template/fa/program_list.html',
  3792. controller: 'ListOfProgramCtrl',
  3793. controllerAs: 'lpc',
  3794. resolve: {
  3795. GeneralInit: function(GeneralInit){
  3796. return GeneralInit();
  3797. }}
  3798. })
  3799. .when('/admin/favoritelist/list/:Id?', {
  3800. templateUrl: '/rstatic/ntwv114/nginxcache/template/fa/favlist_list.html',
  3801. controller: 'ListOfFavListCtrl',
  3802. controllerAs: 'flc',
  3803. resolve: {
  3804. GeneralInit: function(GeneralInit){
  3805. return GeneralInit();
  3806. }}
  3807. })
  3808. .when('/admin/ads/add', {
  3809. templateUrl: '/rstatic/ntwv114/nginxcache/template/fa/ads_add.html',
  3810. controller: 'AddAdsCtrl',
  3811. controllerAs: 'adc',
  3812. resolve: {
  3813. GeneralInit: function(GeneralInit){
  3814. return GeneralInit();
  3815. }}
  3816. })
  3817. .when('/admin/promotions/list', {
  3818. templateUrl: '/rstatic/ntwv114/nginxcache/template/fa/promotion_list.html',
  3819. controller: 'PromotionsListCtrl',
  3820. controllerAs: 'plc',
  3821. resolve: {
  3822. GeneralInit: function(GeneralInit){
  3823. return GeneralInit();
  3824. }}
  3825. })
  3826. .when('/admin/promotions/add', {
  3827. templateUrl: '/rstatic/ntwv114/nginxcache/template/fa/promotion_add.html',
  3828. controller: 'PromotionsAddCtrl',
  3829. controllerAs: 'pac',
  3830. resolve: {
  3831. GeneralInit: function(GeneralInit){
  3832. return GeneralInit();
  3833. }}
  3834. })
  3835. .when('/admin/promotions/edit/:Id', {
  3836. templateUrl: '/rstatic/ntwv114/nginxcache/template/fa/promotion_edit.html',
  3837. controller: 'PromotionsEditCtrl',
  3838. controllerAs: 'pec',
  3839. resolve: {
  3840. GeneralInit: function(GeneralInit){
  3841. return GeneralInit();
  3842. }}
  3843. })
  3844. .when('/admin/ads/edit/:Id', {
  3845. templateUrl: '/rstatic/ntwv114/nginxcache/template/fa/ads_edit.html',
  3846. controller: 'EditAdsCtrl',
  3847. controllerAs: 'edc',
  3848. resolve: {
  3849. GeneralInit: function(GeneralInit){
  3850. return GeneralInit();
  3851. }}
  3852. })
  3853. .when('/admin/ads/list', {
  3854. templateUrl: '/rstatic/ntwv114/nginxcache/template/fa/ads_list.html',
  3855. controller: 'ListAdsCtrl',
  3856. controllerAs: 'lac',
  3857. resolve: {
  3858. GeneralInit: function(GeneralInit){
  3859. return GeneralInit();
  3860. }}
  3861. })
  3862. .when('/ramezan95/', {
  3863. templateUrl: '/rstatic/ntwv114/nginxcache/template/fa/ramezan_95.html',
  3864. controller: 'Ramezan95Ctrl',
  3865. controllerAs: 'rmc',
  3866. resolve: {
  3867. GeneralInit: function(GeneralInit){
  3868. return GeneralInit();
  3869. }}
  3870. })
  3871. .when('/premierleague95-96/', {
  3872. templateUrl: '/rstatic/ntwv114/nginxcache/template/fa/ligebartar.html',
  3873. controller: 'LigeBartarCtrl',
  3874. controllerAs: 'lbc',
  3875. resolve: {
  3876. GeneralInit: function(GeneralInit){
  3877. return GeneralInit();
  3878. }}
  3879. })
  3880. .when('/tags/:Id', {
  3881. templateUrl: '/rstatic/ntwv114/nginxcache/template/fa/tags.html',
  3882. controller: 'TagsCtrl',
  3883. controllerAs: 'tgc',
  3884. resolve: {
  3885. GeneralInit: function(GeneralInit){
  3886. return GeneralInit();
  3887. }}
  3888. })
  3889. .when('/tag/:name', {
  3890. templateUrl: '/rstatic/ntwv114/nginxcache/template/fa/tag.html',
  3891. controller: 'TagCtrl',
  3892. controllerAs: 'tac',
  3893. resolve: {
  3894. GeneralInit: function(GeneralInit){
  3895. return GeneralInit();
  3896. }}
  3897. })
  3898. .when('/movies', {
  3899. templateUrl: '/rstatic/ntwv114/nginxcache/template/fa/movies.html',
  3900. controller: 'MoviesCtrl',
  3901. controllerAs: 'mic',
  3902. resolve: {
  3903. GeneralInit: function(GeneralInit){
  3904. return GeneralInit();
  3905. }}
  3906. })
  3907. .when('/europeleagues', {
  3908. templateUrl: '/rstatic/ntwv114/nginxcache/template/fa/europeleagues.html',
  3909. controller: 'EuropeLeaguesCtrl',
  3910. controllerAs: 'elc',
  3911. resolve: {
  3912. GeneralInit: function(GeneralInit){
  3913. return GeneralInit();
  3914. }}
  3915. })
  3916. .when('/kids', {
  3917. templateUrl: '/rstatic/ntwv114/nginxcache/template/fa/kids.html',
  3918. controller: 'KidsCtrl',
  3919. controllerAs: 'kdc',
  3920. resolve: {
  3921. GeneralInit: function(GeneralInit){
  3922. return GeneralInit();
  3923. }}
  3924. })
  3925. .when('/shademaneh', {
  3926. templateUrl: '/rstatic/ntwv114/nginxcache/template/fa/shademaneh.html',
  3927. controller: 'ShademanehCtrl',
  3928. controllerAs: 'smc',
  3929. resolve: {
  3930. GeneralInit: function(GeneralInit){
  3931. return GeneralInit();
  3932. }}
  3933. })
  3934. .when('/admin/actions', {
  3935. templateUrl: '/rstatic/ntwv114/nginxcache/template/fa/admin_actions.html',
  3936. controller: 'MainAdminCtrl',
  3937. controllerAs: 'mac',
  3938. resolve: {
  3939. GeneralInit: function(GeneralInit){
  3940. return GeneralInit();
  3941. }}
  3942. })
  3943. .when('/series', {
  3944. templateUrl: '/rstatic/ntwv114/nginxcache/template/fa/series.html',
  3945. controller: 'SeriesCtrl',
  3946. controllerAs: 'sic',
  3947. resolve: {
  3948. GeneralInit: function(GeneralInit){
  3949. return GeneralInit();
  3950. }}
  3951. })
  3952.  
  3953. .when('/user/unsubscribe/:email', {
  3954. templateUrl: '/rstatic/ntwv114/nginxcache/template/fa/unsubscribe.html',
  3955. controller: 'UnsubscribeCtrl',
  3956. controllerAs: 'usc',
  3957. resolve: {
  3958. GeneralInit: function(GeneralInit){
  3959. return GeneralInit();
  3960. }}
  3961. })
  3962. .when('/admin/adsbank/list', {
  3963. templateUrl: '/rstatic/ntwv114/nginxcache/template/fa/adsbank_list.html',
  3964. controller: 'AdsBankListCtrl',
  3965. controllerAs: 'abl',
  3966. resolve: {
  3967. GeneralInit: function(GeneralInit){
  3968. return GeneralInit();
  3969. }}
  3970. })
  3971. .when('/admin/adsbank/edit/:Id', {
  3972. templateUrl: '/rstatic/ntwv114/nginxcache/template/fa/adsbank_edit.html',
  3973. controller: 'AdsBankEditCtrl',
  3974. controllerAs: 'abe',
  3975. resolve: {
  3976. GeneralInit: function(GeneralInit){
  3977. return GeneralInit();
  3978. }}
  3979. })
  3980. .when('/admin/adsbank/add', {
  3981. templateUrl: '/rstatic/ntwv114/nginxcache/template/fa/adsbank_add.html',
  3982. controller: 'AdsBankAddCtrl',
  3983. controllerAs: 'aba',
  3984. resolve: {
  3985. GeneralInit: function(GeneralInit){
  3986. return GeneralInit();
  3987. }}
  3988. })
  3989. .otherwise({
  3990. redirectTo: '/404'
  3991. });
  3992. angular.extend(CacheFactoryProvider.defaults, { maxAge: 15 * 60 * 1000 });
  3993. /*$httpProvider.defaults.cache = $cacheFactory('myCache', {capacity: 20});*/
  3994. $authProvider.facebook({
  3995. clientId: '174996829299681'
  3996. })
  3997. $authProvider.google({
  3998. clientId: '614244115512-lqkipime9i6gohctrbk64i2fu653scpv.apps.googleusercontent.com',
  3999. redirectUri: 'http://www.telewebion.com/op/user/verifyOauth'
  4000. });
  4001. }
  4002. function HomeCtrl(GeneralInit,EpisodeFcy,ChannelFcy,HomeInit,$rootScope,SiteConstants,ProgressBarFcy,$scope,ProgramFcy,$location,Messages,$window,$timeout){
  4003. var hmc= this;
  4004. TopCarousel.initCarousel();
  4005.  
  4006. $(document).on("click",".top-carousel-single-item",function () {
  4007. if(TW.flagForGA) {
  4008. TW.flagForGA = false;
  4009. $window.ga('send', 'event', 'click', 'Above the fold', $(this).find(".top-description-carousel").html());
  4010. $timeout(function () {
  4011. TW.flagForGA = true;
  4012. },3000);
  4013. }
  4014. })
  4015. window.HomeOurRecommendationsTotal=0;
  4016. window.HomeNewestTotal=0;
  4017. window.HomeMoviesTotal=0;
  4018. window.HomeUserRecommendationsTotal=0;
  4019. window.HomeTvShowsTotal=0;
  4020. window.HomeKidsTotal=0;
  4021. window.HomeCustom1Total=0;
  4022. window.HomeOlympicsTotal=0;
  4023. window.HomeChannelsTotal=0;
  4024. var OurRecommendationsScrollBar='';
  4025. $rootScope.User=GeneralInit.User;
  4026. $rootScope.Page.Title=SiteConstants.Fa.PageTitle.HomePage;
  4027. $rootScope.Page.Culture=GeneralInit.Culture;
  4028. $rootScope.$broadcast("UserData");
  4029. hmc.Sliders=HomeInit.Sliders;
  4030. $rootScope.Page.Description=SiteConstants.Fa.Description.HomePage;
  4031. $rootScope.Page.Keywords=SiteConstants.Fa.Keywords.HomePage;
  4032. $rootScope.Sliders=hmc.Sliders;
  4033.  
  4034. $(".position-fix-carousel").scroll(function () {
  4035. $(document).scroll()
  4036. })
  4037. $(document).on("click",".slick-next,.slick-prev",function () {
  4038. $(document).scroll()
  4039. setTimeout(function () {
  4040. $(document).scroll()
  4041. },600)
  4042. })
  4043.  
  4044. $timeout(function () {
  4045. $(".ramezan-banners").find("img.lazyload").lazyload({
  4046. threshold : 150,
  4047. effect : "fadeIn",
  4048. });
  4049. },1000)
  4050. hmc.MovieData={Offset:0,Limit:15,UpdateInProgress:true,Episodes:[],Page:0,tempColumn:0};
  4051. hmc.OurRecommendationData={Offset:0,Limit:18,UpdateInProgress:true,Episodes:[],Page:0};
  4052. hmc.TvShowData={Offset:0,Limit:15,UpdateInProgress:true,Episodes:[],Page:0};
  4053. hmc.UserRecommendationData={Offset:0,Limit:19,UpdateInProgress:true,Episodes:[],Page:0};
  4054. hmc.KidData={Offset:0,Limit:19,UpdateInProgress:true,Episodes:[],Page:0};
  4055. hmc.NewestData={Offset:0,Limit:19,UpdateInProgress:true,Episodes:[],Page:0};
  4056. hmc.ChannelData={Offset:0,Limit:40,UpdateInProgress:true,Channels:[],Page:1,MaximumPage:0};
  4057. hmc.Custom1={Offset:0,Limit:19,UpdateInProgress:true,Channels:[],Page:0,MaximumPage:0};
  4058. hmc.Olympics={Offset:0,Limit:19,UpdateInProgress:true,Channels:[],Page:0,MaximumPage:0};
  4059. hmc.EuropeLeagues={Offset:0,Limit:19,UpdateInProgress:true,Channels:[],Page:0,MaximumPage:0};
  4060. hmc.Moharram={Offset:0,Limit:19,UpdateInProgress:true,Channels:[],Page:0,MaximumPage:0};
  4061. hmc.CurrentAffair={Offset:0,Limit:30,UpdateInProgress:true,Channels:[],Page:0,MaximumPage:0};
  4062. $timeout(function () {
  4063.  
  4064. $(".carousel-image-container img").each(function () {
  4065.  
  4066. $(this).error(function () {
  4067.  
  4068. if(!$(this).attr("data-replaced"))
  4069. replacePipelineAddress.replace($(this));
  4070. })
  4071. })
  4072. },600);
  4073. hmc.getCustom1=function(){
  4074. EpisodeFcy.getCustom('400390',hmc.Custom1.Offset,hmc.Custom1.Limit).then(function(CustomEpisodes){
  4075. hmc.Custom1.Page++;
  4076. //loaded("OurRecommendations");
  4077. if(hmc.Custom1.Page==1){
  4078. TwoRowsCarousel.CarouselInit("special-content");
  4079.  
  4080. }
  4081. $timeout(function () {
  4082. $("#special-content").find("img.lazyload").lazyload({
  4083. threshold : 150,
  4084. effect : "fadeIn",
  4085. });
  4086. },200)
  4087.  
  4088. var tempArray=[];
  4089. var tempArray2=[];
  4090. tempArray.push(CustomEpisodes);
  4091. tempArray2.push(hmc.Custom1.Episodes);
  4092. window.HomeCustom1=CustomEpisodes.length;
  4093. window.HomeCustom1Total+=parseInt(window.HomeCustom1);
  4094. hmc.Custom1.Episodes = CustomEpisodes; /*tempArray2[0].concat(tempArray[0]);*/
  4095. tempArray.length = 0;
  4096. tempArray2.length = 0;
  4097. hmc.Custom1.UpdateInProgress=false;
  4098. if(hmc.Custom1.Page==1){
  4099. ProgressBarFcy.plus(0.1);
  4100. }
  4101.  
  4102. });
  4103. }
  4104. hmc.getMoharram=function(){
  4105. EpisodeFcy.getCustom('404847',hmc.Moharram.Offset,hmc.Moharram.Limit).then(function(CustomEpisodes){
  4106. hmc.Moharram.Page++;
  4107. //loaded("OurRecommendations");
  4108. if(hmc.Moharram.Page==1){
  4109. TwoRowsCarousel.CarouselInit("special-content");
  4110.  
  4111. }
  4112. $timeout(function () {
  4113. $("#special-content").find("img.lazyload").lazyload({
  4114. threshold : 150,
  4115. effect : "fadeIn",
  4116. });
  4117. },200)
  4118. var tempArray=[];
  4119. var tempArray2=[];
  4120. tempArray.push(CustomEpisodes);
  4121. tempArray2.push(hmc.Moharram.Episodes);
  4122. window.HomeMoharram=CustomEpisodes.length;
  4123. window.HomeMoharramTotal+=parseInt(window.HomeMoharram);
  4124. hmc.Moharram.Episodes = CustomEpisodes; /*tempArray2[0].concat(tempArray[0]);*/
  4125. tempArray.length = 0;
  4126. tempArray2.length = 0;
  4127. hmc.Moharram.UpdateInProgress=false;
  4128. if(hmc.Moharram.Page==1){
  4129. ProgressBarFcy.plus(0.1);
  4130. }
  4131.  
  4132. });
  4133. }
  4134. hmc.getEuropeLeagues=function(){
  4135. EpisodeFcy.getCustom('404815',hmc.EuropeLeagues.Offset,hmc.EuropeLeagues.Limit).then(function(CustomEpisodes){
  4136. hmc.EuropeLeagues.Page++;
  4137. //loaded("OurRecommendations");
  4138. if(hmc.EuropeLeagues.Page==1){
  4139. TwoRowsCarousel.CarouselInit("europeleagues");
  4140.  
  4141. }
  4142. $timeout(function () {
  4143. $("#europeleagues").find("img.lazyload").lazyload({
  4144. threshold : 150,
  4145. effect : "fadeIn",
  4146. });
  4147. },200)
  4148. var tempArray=[];
  4149. var tempArray2=[];
  4150. tempArray.push(CustomEpisodes);
  4151. tempArray2.push(hmc.EuropeLeagues.Episodes);
  4152. window.HomeEuropeLeagues=CustomEpisodes.length;
  4153. window.EuropeLeaguesTotal+=parseInt(window.HomeEuropeLeagues);
  4154. hmc.EuropeLeagues.Episodes = CustomEpisodes; /*tempArray2[0].concat(tempArray[0]);*/
  4155. tempArray.length = 0;
  4156. tempArray2.length = 0;
  4157. hmc.EuropeLeagues.UpdateInProgress=false;
  4158. if(hmc.EuropeLeagues.Page==1){
  4159.  
  4160. }
  4161. });
  4162. }
  4163. hmc.getOlympics=function(){
  4164. EpisodeFcy.getCustom('402047',hmc.Olympics.Offset,hmc.Olympics.Limit).then(function(CustomEpisodes){
  4165. hmc.Olympics.Page++;
  4166. //loaded("OurRecommendations");
  4167. if(hmc.Olympics.Page==1){1
  4168. TwoRowsCarousel.CarouselInit("olympics-carousel");
  4169.  
  4170. }
  4171. $timeout(function () {
  4172. $("#olympics-content").find("img.lazyload").lazyload({
  4173. threshold : 150,
  4174. effect : "fadeIn",
  4175. });
  4176. },200)
  4177. var tempArray=[];
  4178. var tempArray2=[];
  4179. tempArray.push(CustomEpisodes);
  4180. tempArray2.push(hmc.Olympics.Episodes);
  4181. window.HomeOlympics=CustomEpisodes.length;
  4182. window.HomeOlympicsTotal+=parseInt(window.HomeOlympics);
  4183. hmc.Olympics.Episodes = CustomEpisodes; /*tempArray2[0].concat(tempArray[0]);*/
  4184. tempArray.length = 0;
  4185. tempArray2.length = 0;
  4186. hmc.Olympics.UpdateInProgress=false;
  4187. });
  4188. }
  4189. hmc.getCurrentAffair=function(){
  4190. EpisodeFcy.getCustom('397931',hmc.CurrentAffair.Offset,hmc.CurrentAffair.Limit).then(function(CustomEpisodes){
  4191. hmc.CurrentAffair.Page++;
  4192. //loaded("OurRecommendations");
  4193. if(hmc.CurrentAffair.Page>=1){
  4194. //TwoRowsCarousel.CarouselInit("special-content");
  4195. // TwoRowsCarousel.CarouselInit("special-news");
  4196.  
  4197. }
  4198. var tempArray=[];
  4199. var tempArray2=[];
  4200. tempArray.push(CustomEpisodes);
  4201. tempArray2.push(hmc.CurrentAffair.Episodes);
  4202. window.HomeCurrentAffair1=CustomEpisodes.length;
  4203. window.HomeCurrentAffair1Total+=parseInt(window.HomeCurrentAffair1);
  4204. hmc.CurrentAffair.Episodes = CustomEpisodes; /*tempArray2[0].concat(tempArray[0]);*/
  4205. tempArray.length = 0;
  4206. tempArray2.length = 0;
  4207. hmc.CurrentAffair.UpdateInProgress=false;
  4208. if(hmc.CurrentAffair.Page==1){
  4209. ProgressBarFcy.plus(0.1);
  4210. }
  4211. });
  4212. }
  4213. hmc.getOurRecommendations=function(){
  4214. EpisodeFcy.getOurRecommendations(hmc.OurRecommendationData.Offset,hmc.OurRecommendationData.Limit).then(function(OurRecommendations){
  4215. hmc.OurRecommendationData.Page++;
  4216. //loaded("OurRecommendations");
  4217. if(hmc.OurRecommendationData.Page==1){
  4218. TwoRowsCarousel.CarouselInit("OurRecommendation");
  4219. }
  4220. $timeout(function () {
  4221. $("#OurRecommendation").find("img.lazyload").lazyload({
  4222. threshold : 150,
  4223. effect : "fadeIn",
  4224. });
  4225. },200)
  4226. var tempArray=[];
  4227. var tempArray2=[];
  4228. tempArray.push(OurRecommendations);
  4229. tempArray2.push(hmc.OurRecommendationData.Episodes);
  4230. window.HomeOurRecommendations=OurRecommendations.length;
  4231. window.HomeOurRecommendationsTotal+=parseInt(window.HomeOurRecommendations);
  4232. //resizeTrigger("OurRecommendations",window.HomeOurRecommendationsTotal);
  4233. hmc.OurRecommendationData.Episodes = tempArray2[0].concat(tempArray[0]);
  4234. tempArray.length = 0;
  4235. tempArray2.length = 0;
  4236. hmc.OurRecommendationData.UpdateInProgress=false;
  4237. if(hmc.OurRecommendationData.Page==1){
  4238. ProgressBarFcy.plus(0.1);
  4239. }
  4240. });
  4241. }
  4242. var variant = cxApi.chooseVariation();
  4243. // var variant = 123;
  4244. $rootScope.newestToShow = true;
  4245. // if($window.location.href.indexOf("main") >=0){
  4246. // $rootScope.newestToShow = false;
  4247. // }
  4248. // if(variant != 0 && $window.location.href.indexOf("main") < 0){
  4249. //
  4250. // setTimeout(function () {
  4251. // window.location.href = "/main";
  4252. // window.variant = 'v'+variant;
  4253. // },1000)
  4254. // }
  4255. if($rootScope.newestToShow == true) {
  4256. hmc.getNewest = function () {
  4257. EpisodeFcy.getNewestEpisodes(hmc.NewestData.Offset, hmc.NewestData.Limit).then(function (Newest) {
  4258. hmc.NewestData.Page++;
  4259. //if(hmc.NewestData.Page==1){
  4260. //loaded("Newest");
  4261. if (hmc.NewestData.Page == 1) {
  4262. TwoRowsCarousel.CarouselInit("Newest");
  4263.  
  4264. }
  4265. $timeout(function () {
  4266. $("#Newest").find("img.lazyload").lazyload({
  4267. threshold: 150,
  4268. effect: "fadeIn",
  4269. });
  4270. }, 200)
  4271. //}
  4272. var tempArray = [];
  4273. var tempArray2 = [];
  4274. window.HomeNewest = Newest.length;
  4275. window.HomeNewestTotal += parseInt(window.HomeNewest);
  4276. tempArray.push(Newest);
  4277. tempArray2.push(hmc.NewestData.Episodes);
  4278. hmc.NewestData.Episodes = tempArray2[0].concat(tempArray[0]);
  4279. tempArray.length = 0;
  4280. tempArray2.length = 0;
  4281. hmc.NewestData.UpdateInProgress = false;
  4282. if (hmc.NewestData.Page == 1) {
  4283. ProgressBarFcy.plus(0.1);
  4284. }
  4285. });
  4286. }
  4287. }
  4288. hmc.getChannels=function(){
  4289. ChannelFcy.getChannels().then(function(Channels){
  4290.  
  4291. /*var tempChannelList=[];*/
  4292. //loaded("LiveChannels");
  4293. if(hmc.ChannelData.Page==1){
  4294. LiveChannelsCarousel.CarouselInit("LiveChannels");
  4295. }
  4296. $timeout(function () {
  4297. $("#LiveChannels").find(".lazyload").lazyload({
  4298. threshold : 150,
  4299. effect:"fadeIn"
  4300. });
  4301. },200)
  4302. window.HomeChannels=Channels.length;
  4303. window.HomeChannelsTotal+=parseInt(window.HomeChannels);
  4304. hmc.ChannelData.Channels=Channels;
  4305. hmc.ChannelData.MaximumPage=Math.ceil(Channels.length/hmc.ChannelData.Limit);
  4306. /*for (var i=1;i<=Channels.length;i++){
  4307. tempChannelList.push(Channels[i-1]);
  4308. if(i%hmc.ChannelData.Limit==0)
  4309. {
  4310. hmc.ChannelData.Channels.push(tempChannelList);
  4311. tempChannelList=[];
  4312. }
  4313. else if(i==Channels.length)
  4314. {
  4315. hmc.ChannelData.Channels.push(tempChannelList);
  4316. }
  4317. }*/
  4318. hmc.ChannelData.UpdateInProgress=false;
  4319. ProgressBarFcy.plus(0.1);
  4320. $rootScope.ChannelData=hmc.ChannelData;
  4321. $rootScope.$broadcast("UserData");
  4322. });
  4323. }
  4324. hmc.getMovies=function(){
  4325. EpisodeFcy.getMovies(hmc.MovieData.Offset,hmc.MovieData.Limit).then(function(Movies){
  4326. hmc.MovieData.Page++;
  4327. //if(hmc.MovieData.Page==1){
  4328. //loaded("Movies");
  4329. if(hmc.MovieData.Page==1){
  4330. OneRowCarousel.CarouselInit("Movies");
  4331.  
  4332. }
  4333. //}
  4334. $timeout(function () {
  4335. $("#Movies").find("img.lazyload").lazyload({
  4336. threshold : 150,
  4337. effect : "fadeIn",
  4338. });
  4339. },200)
  4340. var tempArray=[];
  4341. var tempArray2=[];
  4342. tempArray.push(Movies);
  4343. window.HomeMovies=Movies.length;
  4344. window.HomeMoviesTotal+=parseInt(window.HomeMovies);
  4345. tempArray2.push(hmc.MovieData.Episodes);
  4346. hmc.MovieData.Episodes = tempArray2[0].concat(tempArray[0]);
  4347. tempArray.length = 0;
  4348. tempArray2.length = 0;
  4349. hmc.MovieData.UpdateInProgress=false;
  4350. if(hmc.MovieData.Page==1){
  4351. ProgressBarFcy.plus(0.1);
  4352. }
  4353. });
  4354. }
  4355. hmc.getUserRecommendations=function(){
  4356. EpisodeFcy.getUserRecommendations(hmc.UserRecommendationData.Offset,hmc.UserRecommendationData.Limit).then(function(UserRecommendations){
  4357. hmc.UserRecommendationData.Page++;
  4358. //if(hmc.UserRecommendationData.Page==1){
  4359. //loaded("UserRecommendations");
  4360. $timeout(function () {
  4361. $("#UsersRecommendation").find("img.lazyload").lazyload({
  4362. threshold : 150,
  4363. effect : "fadeIn",
  4364. });
  4365. },200)
  4366. if(hmc.OurRecommendationData.Page>=1){
  4367. TwoRowsCarousel.CarouselInit("UsersRecommendation");
  4368. setTimeout(function () {
  4369. TwoRowsCarousel.CarouselInit("UsersRecommendation");
  4370. },1000);
  4371.  
  4372.  
  4373. $timeout(function () {
  4374. replaceBigThumbs.replace();
  4375. },800)
  4376. }
  4377. //}
  4378. var tempArray=[];
  4379. var tempArray2=[];
  4380. tempArray.push(UserRecommendations);
  4381. tempArray2.push(hmc.UserRecommendationData.Episodes);
  4382. window.HomeUserRecommendations=UserRecommendations.length;
  4383. window.HomeUserRecommendationsTotal+=parseInt(window.HomeUserRecommendations);
  4384. hmc.UserRecommendationData.Episodes = tempArray2[0].concat(tempArray[0]);
  4385. tempArray.length = 0;
  4386. tempArray2.length = 0;
  4387. hmc.UserRecommendationData.UpdateInProgress=false;
  4388. if(hmc.UserRecommendationData.Page==1){
  4389. ProgressBarFcy.plus(0.1);
  4390. }
  4391. });
  4392. }
  4393. hmc.getTvShows=function(){
  4394. ProgramFcy.getTvShows(hmc.TvShowData.Offset,hmc.TvShowData.Limit).then(function(TvShows){
  4395. hmc.TvShowData.Page++;
  4396. //if(hmc.TvShowData.Page==1){
  4397. //loaded("TvSeries");
  4398. if(hmc.TvShowData.Page==1){
  4399. OneRowCarousel.CarouselInit("Series");
  4400.  
  4401. }
  4402. $timeout(function () {
  4403. $("#Series").find("img.lazyload").lazyload({
  4404. threshold : 150,
  4405. effect : "fadeIn",
  4406. });
  4407. },200)
  4408. //}
  4409. var tempArray=[];
  4410. var tempArray2=[];
  4411. tempArray.push(TvShows);
  4412. tempArray2.push(hmc.TvShowData.Episodes);
  4413. window.HomeTvShows=TvShows.length;
  4414. window.HomeTvShowsTotal+=parseInt(window.HomeTvShows);
  4415. hmc.TvShowData.Episodes = tempArray2[0].concat(tempArray[0]);
  4416. tempArray.length = 0;
  4417. tempArray2.length = 0;
  4418. hmc.TvShowData.UpdateInProgress=false;
  4419. if(hmc.TvShowData.Page==1){
  4420. ProgressBarFcy.plus(0.1);
  4421. }
  4422. });
  4423. }
  4424. hmc.getKids=function(){
  4425. ProgramFcy.getKids(hmc.KidData.Offset,hmc.KidData.Limit).then(function(Kids){
  4426. hmc.KidData.Page++;
  4427. //if(hmc.KidData.Page==1){
  4428. //loaded("Kids");
  4429. if(hmc.KidData.Page==1){
  4430. TwoRowsCarousel.CarouselInit("Kids");
  4431. }
  4432. $timeout(function () {
  4433. $("#Kids").find("img.lazyload").lazyload({
  4434. threshold : 150,
  4435. effect : "fadeIn",
  4436. });
  4437. },200)
  4438.  
  4439.  
  4440. //}
  4441. var tempArray=[];
  4442. var tempArray2=[];
  4443. tempArray.push(Kids);
  4444. tempArray2.push(hmc.KidData.Episodes);
  4445. window.HomeKids=Kids.length;
  4446. window.HomeKidsTotal+=parseInt(window.HomeKids);
  4447. hmc.KidData.Episodes = tempArray2[0].concat(tempArray[0]);
  4448. tempArray.length = 0;
  4449. tempArray2.length = 0;
  4450. hmc.KidData.UpdateInProgress=false;
  4451. if(hmc.KidData.Page==1){
  4452. ProgressBarFcy.plus(0.1);
  4453. }
  4454. });
  4455. }
  4456. hmc.getNext=function(type){
  4457. if(type=='Movie'){
  4458. hmc.MovieData.Limit=((hmc.MovieData.Page+1)==1)?50:50;
  4459. hmc.MovieData.Offset=((hmc.MovieData.Page+1)==1)?0:((hmc.MovieData.Page+1)*50)+50;
  4460. hmc.MovieData.UpdateInProgress=true;
  4461. hmc.getMovies();
  4462. /*if((hmc.MovieData.Page+1)>0 && typeof hmc.MovieData.Episodes[hmc.MovieData.Page] == 'undefined'){
  4463. hmc.MovieData.UpdateInProgress=true;
  4464. hmc.getMovies();
  4465. }
  4466. else{
  4467. hmc.MovieData.Page++;
  4468. }*/
  4469. }
  4470. else if(type=='OurRecommendation'){
  4471. hmc.OurRecommendationData.Limit=((hmc.OurRecommendationData.Page+1)==1)?50:50;
  4472. hmc.OurRecommendationData.Offset=((hmc.OurRecommendationData.Page+1)==1)?0:((hmc.OurRecommendationData.Page+1)*50)+50;
  4473. hmc.OurRecommendationData.UpdateInProgress=true;
  4474. hmc.getOurRecommendations();
  4475. /*if(typeof hmc.OurRecommendationData.Episodes[hmc.OurRecommendationData.Page] == 'undefined'){
  4476. hmc.OurRecommendationData.UpdateInProgress=true;
  4477.  
  4478. }
  4479. else{
  4480. hmc.OurRecommendationData.Page++;
  4481. }*/
  4482. }
  4483. else if(type=='UserRecommendations'){
  4484.  
  4485. hmc.UserRecommendationData.Limit=((hmc.UserRecommendationData.Page+1)==1)?50:50;
  4486. hmc.UserRecommendationData.Offset=((hmc.UserRecommendationData.Page+1)==1)?0:((hmc.UserRecommendationData.Page+1)*50)+50;
  4487. hmc.UserRecommendationData.UpdateInProgress=true;
  4488. hmc.getUserRecommendations();
  4489. /*if(hmc.UserRecommendationData.Page+1>0 && typeof hmc.UserRecommendationData.Episodes[hmc.UserRecommendationData.Page] == 'undefined'){
  4490. hmc.UserRecommendationData.UpdateInProgress=true;
  4491. hmc.getUserRecommendations();
  4492. }
  4493. else{
  4494. hmc.UserRecommendationData.Page++;
  4495. }*/
  4496. }
  4497. else if(type=='TvShows'){
  4498. hmc.TvShowData.Limit=((hmc.TvShowData.Page+1)==1)?50:50;
  4499. hmc.TvShowData.Offset=((hmc.TvShowData.Page+1)==1)?0:((hmc.TvShowData.Page+1)*50)+50;
  4500. hmc.TvShowData.UpdateInProgress=true;
  4501. hmc.getTvShows();
  4502. /*if(hmc.TvShowData.Page+1>0 && typeof hmc.TvShowData.Episodes[hmc.TvShowData.Page] == 'undefined'){
  4503. hmc.TvShowData.UpdateInProgress=true;
  4504. hmc.getTvShows();
  4505. }
  4506. else{
  4507. hmc.TvShowData.Page++;
  4508. }*/
  4509. }
  4510. else if(type=='Kids'){
  4511. hmc.KidData.Limit=((hmc.KidData.Page+1)==1)?50:50;
  4512. hmc.KidData.Offset=((hmc.KidData.Page+1)==1)?0:((hmc.KidData.Page+1)*50)+50;
  4513. hmc.KidData.UpdateInProgress=true;
  4514. hmc.getKids();
  4515. /* if(hmc.KidData.Page+1>0 && typeof hmc.KidData.Episodes[hmc.KidData.Page] == 'undefined'){
  4516. hmc.KidData.UpdateInProgress=true;
  4517. hmc.getKids();
  4518. }
  4519. else{*/
  4520. //}
  4521. }
  4522. else if(type=='Channels'){
  4523. hmc.ChannelData.Page++;
  4524. hmc.ChannelData.Limit=(hmc.ChannelData.Page==1)?10:10;
  4525. hmc.ChannelData.Offset=(hmc.ChannelData.Page==1)?0:(hmc.ChannelData.Page*10)+10;
  4526. if(hmc.ChannelData.Page>0 && typeof hmc.ChannelData.Channels[hmc.ChannelData.Page-1] == 'undefined'){
  4527. hmc.ChannelData.UpdateInProgress=true;
  4528. }
  4529. }
  4530. else if(type=='Newest'){
  4531. hmc.NewestData.Limit=((hmc.NewestData.Page+1)==1)?50:50;
  4532. hmc.NewestData.Offset=((hmc.NewestData.Page+1)==1)?0:((hmc.NewestData.Page+1)*50)+50;
  4533. hmc.NewestData.UpdateInProgress=true;
  4534. hmc.getNewest();
  4535. /* if(hmc.KidData.Page+1>0 && typeof hmc.KidData.Episodes[hmc.KidData.Page] == 'undefined'){
  4536. hmc.KidData.UpdateInProgress=true;
  4537. hmc.getKids();
  4538. }
  4539. else{*/
  4540. /*hmc.NewestData.Page++;*/
  4541. }
  4542. }
  4543. window.getNextHome=hmc.getNext;
  4544. hmc.getPrevious=function(type){
  4545. if(type=='Movie'){
  4546. hmc.MovieData.Page>1?--hmc.MovieData.Page:hmc.MovieData.Page;
  4547. hmc.MovieData.Limit=(hmc.MovieData.Page==1)?5:8;
  4548. hmc.MovieData.Offset=(hmc.MovieData.Page==1)?0:(hmc.MovieData.Page*8)+5;
  4549. }
  4550. else if(type=='OurRecommendation'){
  4551. hmc.OurRecommendationData.Page>1?--hmc.OurRecommendationData.Page:hmc.OurRecommendationData.Page;
  4552. hmc.OurRecommendationData.Limit=(hmc.OurRecommendationData.Page==1)?5:8;
  4553. hmc.OurRecommendationData.Offset=(hmc.OurRecommendationData.Page==1)?0:(hmc.OurRecommendationData.Page*8)+5;
  4554. }
  4555. else if(type=='UserRecommendations'){
  4556. hmc.UserRecommendationData.Page>1?--hmc.UserRecommendationData.Page:hmc.UserRecommendationData.Page;
  4557. hmc.UserRecommendationData.Limit=(hmc.UserRecommendationData.Page==1)?5:8;
  4558. hmc.UserRecommendationData.Offset=(hmc.UserRecommendationData.Page==1)?0:(hmc.UserRecommendationData.Page*8)+5;
  4559. }
  4560. else if(type=='TvShows'){
  4561. hmc.TvShowData.Page>1?--hmc.TvShowData.Page:hmc.TvShowData.Page;
  4562. hmc.TvShowData.Limit=(hmc.TvShowData.Page==1)?5:8;
  4563. hmc.TvShowData.Offset=(hmc.TvShowData.Page==1)?0:(hmc.TvShowData.Page*8)+5;
  4564. }
  4565. else if(type=='Kids'){
  4566. hmc.KidData.Page>1?--hmc.KidData.Page:hmc.KidData.Page;
  4567. hmc.KidData.Limit=(hmc.KidData.Page==1)?5:8;
  4568. hmc.KidData.Offset=(hmc.KidData.Page==1)?0:(hmc.KidData.Page*8)+5;
  4569. }
  4570. else if(type=='Channels'){
  4571. hmc.ChannelData.Page>1?--hmc.ChannelData.Page:hmc.ChannelData.Page;
  4572. hmc.ChannelData.Limit=(hmc.ChannelData.Page==1)?8:8;
  4573. hmc.ChannelData.Offset=(hmc.ChannelData.Page==1)?0:(hmc.ChannelData.Page*8)+hmc.ChannelData.Limit;
  4574. }
  4575. }
  4576. hmc.getChannels();
  4577. hmc.getOurRecommendations();
  4578. hmc.getMovies();
  4579. hmc.getUserRecommendations();
  4580. hmc.getTvShows();
  4581. hmc.getKids();
  4582. if($rootScope.newestToShow == true) {
  4583. hmc.getNewest();
  4584. }
  4585. hmc.getCustom1();
  4586. // hmc.getMoharram();
  4587. // hmc.getOlympics();
  4588. hmc.getEuropeLeagues();
  4589. /*hmc.getCurrentAffair();*/
  4590. if(typeof $location.search()['ls']!=='undefined' && $location.search()['ls']=='su'){
  4591. NgNote.Success(Messages.Fa.LoginSuccessful,3);
  4592. $window.location.replace("/#!/");
  4593. }
  4594.  
  4595. }
  4596. function GeneralCtrl($rootScope,EpisodeSrv,$location,$anchorScroll,deviceDetector,GeneralInit,UserSrv,Messages,$timeout,SearchFcy,VasFcy,$window) {
  4597. $rootScope.Page = {};
  4598. /*$rootScope.User={};*/
  4599. $rootScope.Sliders = {};
  4600. $rootScope.UserStatus = {IsAuthenticated: false};
  4601. $rootScope.ChannelData = {};
  4602. $rootScope.DoSearch = function () {
  4603. window.location.href = '/#!/search/' + $rootScope.Page.SearchContext;
  4604. };
  4605. UserSrv.getUser().then(function(UserInfo){
  4606. $rootScope.User=UserInfo;
  4607. if(typeof UserInfo.user_info!='undefined'){
  4608. $rootScope.UserStatus.IsAuthenticated=true;
  4609. }else{
  4610. $rootScope.UserStatus.IsAuthenticated=false;
  4611. }
  4612. $rootScope.$broadcast("UserData");
  4613. });
  4614. $rootScope.deviceInfo = deviceDetector.device;
  4615. $rootScope.isDesktopDetect = function () {
  4616. if (DeviceDetection.IsIos() || DeviceDetection.IsIpad() || DeviceDetection.IsAndroid()) {
  4617. return false;
  4618. } else {
  4619. return true;
  4620. }
  4621. }
  4622. $rootScope.isAndroid = function () {
  4623. if ($rootScope.deviceInfo == "android") {
  4624. return true;
  4625. } else {
  4626. return false;
  4627. }
  4628. }
  4629. $rootScope.setCookieForAndroid = function () {
  4630. Cookie.Create("app", 1, 14);
  4631. };
  4632. $rootScope.checkTheAppCookie = function () {
  4633. if (Cookie.Read("app").length) {
  4634. if (Cookie.Read("app") == 1) {
  4635. return true;
  4636. } else {
  4637. return false;
  4638. }
  4639. } else {
  4640. return false;
  4641. }
  4642. };
  4643. var MiladiDate = new Date();
  4644. var ShamsiDate = new JDate(MiladiDate);
  4645. var pureDate = ShamsiDate.toLocaleString().split(" ");
  4646. var splittedPureDate = pureDate[0].split("/");
  4647. var year = splittedPureDate[0];
  4648. var month = splittedPureDate[1];
  4649. var day = splittedPureDate[2];
  4650. if (day.indexOf("0") == 0) {
  4651. day = day.charAt(1);
  4652. }
  4653. if (month.indexOf("0") == 0) {
  4654. month = month.charAt(1);
  4655. }
  4656.  
  4657. var fullDate = year + "-" + month + "-" + day;
  4658. $rootScope.fullDateGeneral = fullDate;
  4659. $rootScope.bannerToShow = function () {
  4660. if (!$rootScope.checkTheAppCookie() && $rootScope.isAndroid()) {
  4661. setTimeout(function () {
  4662. $("#android-suggestion").removeClass("display-none");
  4663. }, 200);
  4664. }
  4665. };
  4666. $rootScope.bannerToShow();
  4667. $rootScope.typeAhead = '';
  4668. $rootScope.SearchProgramsUpdateInProgress = false;
  4669. $rootScope.getSearchResult = function (JustEpisodes) {
  4670. $rootScope.SearchProgramsUpdateInProgress = true;
  4671. $rootScope.Context = '';
  4672. $rootScope.Context = $rootScope.Page.SearchContext;
  4673. $rootScope.SearchEpisodes = {Offset: 0, Limit: 10, UpdateInProgress: true, Episodes: [], Page: 0};
  4674. $rootScope.SearchPrograms = {Offset: 0, Limit: 5, UpdateInProgress: true, Page: 0, Programs: []};
  4675.  
  4676.  
  4677. if ($rootScope.Page.SearchContext != undefined) {
  4678. if ($rootScope.Page.SearchContext.length >= 2) {
  4679. $timeout.cancel($rootScope.typeAhead);
  4680. $rootScope.typeAhead = $timeout(function () {
  4681. debuger.log("Searching for keyword: " + $rootScope.Page.SearchContext);
  4682. if (!JustEpisodes) {
  4683.  
  4684.  
  4685. SearchFcy.getPrograms($rootScope.Context, $rootScope.SearchPrograms.Offset, $rootScope.SearchPrograms.Limit).then(function (result) {
  4686. debuger.log("Program serach result arrived with this count: " + result.length);
  4687. $rootScope.SearchPrograms.Page++;
  4688. var tempArray = [];
  4689. var tempArray2 = [];
  4690. tempArray.push(result);
  4691. tempArray2.push($rootScope.SearchPrograms.Programs);
  4692. $rootScope.SearchPrograms.Programs = tempArray2[0].concat(tempArray[0]);
  4693. tempArray.length = 0;
  4694. tempArray2.length = 0;
  4695.  
  4696. });
  4697. }
  4698. SearchFcy.getEpisodes($rootScope.Context, $rootScope.SearchEpisodes.Offset, $rootScope.SearchEpisodes.Limit).then(function (result) {
  4699. debuger.log("Episode search result arrived with this count: " + result.length);
  4700. $rootScope.SearchEpisodes.Page++;
  4701. var tempArray = [];
  4702. var tempArray2 = [];
  4703. tempArray.push(result);
  4704. tempArray2.push($rootScope.SearchEpisodes.Episodes);
  4705. $rootScope.SearchEpisodes.Episodes = tempArray2[0].concat(tempArray[0]);
  4706. tempArray.length = 0;
  4707. tempArray2.length = 0;
  4708. });
  4709. $rootScope.SearchProgramsUpdateInProgress = false;
  4710. }, 1000);
  4711. } else {
  4712. $rootScope.SearchPrograms = {};
  4713. $rootScope.SearchEpisodes = {};
  4714. $rootScope.SearchProgramsUpdateInProgress = false;
  4715. }
  4716. } else {
  4717. $rootScope.SearchProgramsUpdateInProgress = false;
  4718. }
  4719. }
  4720. $rootScope.$on("UserData", function () {
  4721. });
  4722. $rootScope.MakeURLFriendly = function (Context) {
  4723. var Output;
  4724. Output = Context.replace(/[\._ /,:-]+/g, "-")
  4725. return Output;
  4726. }
  4727. $rootScope.MakeRedirection = function (link) {
  4728. window.location = link;
  4729. }
  4730. $rootScope.getEpisodeImageWithCustomSize = function (Image, Size, JustImage) {
  4731. return EpisodeSrv.getEpisodeImageWithCustomSize(Image, Size, JustImage);
  4732. }
  4733. $rootScope.scrollTo = function (id) {
  4734. $location.hash(id);
  4735. $anchorScroll();
  4736. }
  4737. $rootScope.ConvertToPersianNumber = function (string) {
  4738. if (string != 'undefined' || string) {
  4739. return persianUtils.toPersianNumber(string);
  4740. } else {
  4741. return null
  4742. }
  4743. }
  4744. $rootScope.deviceInfo = deviceDetector.device;
  4745. $rootScope.ChannelIdToName = function (id) {
  4746. switch (id) {
  4747. case 1:
  4748. return "شبکه 1";
  4749. break;
  4750. case 2:
  4751. return "شبکه 2";
  4752. break;
  4753. case 45:
  4754. return "شبکه امید";
  4755. break;
  4756. case 3:
  4757. return "شبکه 3";
  4758. break;
  4759. case 4:
  4760. return "شبکه 4";
  4761. break;
  4762. case 5:
  4763. return "شبکه 5";
  4764. break;
  4765. case 6:
  4766. return "شبکه خبر";
  4767. break;
  4768. case 7:
  4769. return "شبکه آموزش";
  4770. break;
  4771. case 8:
  4772. return "شبکه پویا";
  4773. break;
  4774. case 9:
  4775. return "شبکه IFilm";
  4776. break;
  4777. case 10:
  4778. return "شبکه نمایش";
  4779. break;
  4780. case 11:
  4781. return "شبکه تماشا";
  4782. break;
  4783. case 12:
  4784. return "شبکه جام جم 1";
  4785. break;
  4786. case 13:
  4787. return "شبکه ورزش";
  4788. break;
  4789. case 18:
  4790. return "پرشین تونز";
  4791. break;
  4792. case 19:
  4793. return "شبکه مستند سیما";
  4794. break;
  4795. case 20:
  4796. return "شبکه قرآن";
  4797. break;
  4798. case 21:
  4799. return "شبکه سلامت";
  4800. break;
  4801. case 22:
  4802. return "شبکه جام جم 2";
  4803. break;
  4804. case 23:
  4805. return "شبکه جام جم 3";
  4806. break;
  4807. case 24:
  4808. return "شبکه شما";
  4809. break;
  4810. case 25:
  4811. return "شبکه بازار";
  4812. break;
  4813. case 29:
  4814. return "IFilm English";
  4815. break;
  4816. case 30:
  4817. return "شبکه اصفهان";
  4818. break;
  4819. case 31:
  4820. return "شبکه سهند";
  4821. break;
  4822. case 32:
  4823. return "شبکه فارس";
  4824. break;
  4825. case 33:
  4826. return "شبکه خوزستان";
  4827. break;
  4828. case 34:
  4829. return "شبکه باران";
  4830. break;
  4831. case 35:
  4832. return "سینمای خانگی";
  4833. break;
  4834. case 36:
  4835. return "شبکه سمنان";
  4836. break;
  4837. case 37:
  4838. return "شبکه آفتاب";
  4839. break;
  4840. case 38:
  4841. return "شبکه افلاک";
  4842. break;
  4843. case 39:
  4844. return "شبکه کردستان";
  4845. break;
  4846. case 40:
  4847. return "شبکه خلیج فارس";
  4848. break;
  4849. case 41:
  4850. return "شبکه نسیم";
  4851. break;
  4852. case 42:
  4853. return "شبکه افق";
  4854. break;
  4855. case 43:
  4856. return "شبکه HD";
  4857. break;
  4858.  
  4859.  
  4860. }
  4861. }
  4862. $rootScope.User = GeneralInit.User;
  4863. $rootScope.Logout = function () {
  4864. UserSrv.logoutUser();
  4865. NgNote.Success(Messages.Fa.LogoutSuccessful, 3);
  4866. $rootScope.User = {};
  4867. $rootScope.UserStatus.IsAuthenticated = false;
  4868. }
  4869. $rootScope.InArray = function inArray(needle, haystack) {
  4870. var length = haystack.length;
  4871. for (var i = 0; i < length - 1; i++) {
  4872. if (haystack[i] == needle) return true;
  4873. }
  4874. return false;
  4875. }
  4876. $rootScope.setShowVas = function () {
  4877. Cookie.Create("showVas", 1, 5);
  4878. }
  4879. UserSrv.getUser().then(function (result) {
  4880. var showVas = Cookie.Read("showVas");
  4881. if (!$rootScope.InArray("vas", $window.location.hostname.split("."))) {
  4882. if (typeof result != 'undefined' && typeof result.vas != 'undefined' && typeof result.vas.discover_url != 'undefined' && result.vas.discover_url != '' && result.vas.discover_url != null) {
  4883. VasFcy.checkStatus(result.vas.discover_url).then(function (vـresult) {
  4884. if (vـresult) {
  4885. NgNote.Success("به سرویس تلوبیون بر بستر طرح بی‌نهایت مخابرات استان اصفهان خوش آمدید", 3);
  4886. setTimeout(function () {
  4887. $window.location.replace(result.vas.redirect_url);
  4888. }, 3000);
  4889. }
  4890. else {
  4891. if (typeof showVas == 'undefined' || showVas == null || showVas == '' || showVas == 'nullcookie') {
  4892. NgNotifier.Info("کاربر گرامی. در صورت تهیه طرح بی‌نهایت مخابرات اصفهان، می‌توانید این ویدئو و هزاران ویدئو دیگر را بدون مصرف حجم دانلود خود، مشاهده نمایید", 120, "http://20plus.tce.ir/", $rootScope.setShowVas);
  4893. }
  4894. }
  4895. })
  4896. }
  4897. }
  4898. if (typeof result != 'undefined' && result != null && typeof result.token != 'undefined' && ($rootScope.InArray('admin', result.credentials) || $rootScope.InArray('superadmin', result.credentials) || $rootScope.InArray('operator', result.credentials))) {
  4899. $rootScope.HasAdminAccess = true;
  4900. debuger.init("debugger-container");
  4901. }
  4902. })
  4903. }
  4904. function ForgotPasswordCtrl(GeneralInit,UserSrv,Messages,$rootScope,SiteConstants,ProgressBarFcy,$scope){
  4905. var frp= this;
  4906. frp.User={};
  4907. $rootScope.Page.Title=SiteConstants.Fa.PageTitle.ForgotPassword;
  4908. $rootScope.$broadcast("UserData");
  4909. ProgressBarFcy.setDone();
  4910. frp.ForgotPassword={Status:"NoAction"};
  4911. frp.DoRequest=function(){
  4912. var response = $scope.gRecaptchaForgotResponse+"";
  4913. if(response.length>0 && response != "undefined") {
  4914. frp.ForgotPassword.Status = "InProgress";
  4915. UserSrv.forgotPasswordUser(frp.User.Email).then(function (result) {
  4916. if (result.status_code == 1) {
  4917. frp.ForgotPassword.Status = "SuccessfulAction";
  4918. NgNote.Success('لینک تغییر کلمه عبور با موفقیت ارسال شد', 5);
  4919. }
  4920. else {
  4921. frp.ForgotPassword.Status = "NoAction";
  4922. NgNote.Error(result.status_message, 3);
  4923. }
  4924. });
  4925. }else{
  4926. NgNote.Error(Messages.Fa.RobotError, 3);
  4927. }
  4928. }
  4929. }
  4930. function LoginCtrl(GeneralInit,UserSrv,Messages,$window,$rootScope,SiteConstants,ProgressBarFcy,$auth,toastr,$scope, $location){
  4931. var urg= this;
  4932. urg.User={};//GeneralInit.User;
  4933. urg.ResendCount = 0;
  4934. /*(GeneralInit.Culture=="fa")?SiteConstants.Fa.PageTitle.Register:SiteConstants.En.PageTitle.Register;*/
  4935. $rootScope.Page.Title=SiteConstants.Fa.PageTitle.Register;
  4936. $rootScope.$broadcast("UserData");
  4937. ProgressBarFcy.setDone();
  4938. urg.Registration= {Status: "NoAction"};
  4939. urg.Login= {Status: "NoAction"};
  4940. var regexPhoneNumber = /^\+(?:[\d]*)$/;
  4941. var regexPhoneNumber2 = /^[0-9]*$/;
  4942. urg.phoneNumberStatus = false;
  4943. urg.Register=function(){
  4944.  
  4945. if(regexPhoneNumber.test(urg.User.phone) || regexPhoneNumber2.test(urg.User.phone) || !urg.User.phone) {
  4946. var response = $scope.gRecaptchaRegisterResponse + "";
  4947. if (response.length > 0 && response != "undefined") {
  4948. urg.Registration.Status = "InProgress";
  4949. UserSrv.registerUser(urg.User).then(function (result) {
  4950. if (result.status_code == 1) {
  4951. urg.Registration.Status = "SuccessfulAction";
  4952. NgNote.Success(Messages.Fa.SuccessfulRegistration, 5);
  4953. urg.phoneNumberStatus = false;
  4954. }
  4955. else {
  4956. urg.Registration.Status = "NoAction";
  4957. NgNote.Error(result.status_message, 3);
  4958. urg.phoneNumberStatus = false;
  4959. }
  4960. });
  4961. } else {
  4962. NgNote.Error(Messages.Fa.RobotError, 3);
  4963. }
  4964. }else {
  4965. urg.phoneNumberStatus = true;
  4966. }
  4967.  
  4968.  
  4969. }
  4970. urg.DoLogin=function(){
  4971. var response = $scope.gRecaptchaLoginResponse+"";
  4972. if(response.length > 0 && response !="undefined") {
  4973. urg.Login.Status = "InProgress";
  4974. UserSrv.loginUser(urg.User).then(function (result) {
  4975. if (result && typeof result == 'object') {
  4976. urg.Login.Status = "SuccessfulAction";
  4977. if (result != null && typeof result.token !== 'undefined') {
  4978. NgNote.Success(Messages.Fa.LoginSuccessful, 3);
  4979. setTimeout(function () {
  4980. $window.location.replace("/#!/");
  4981. }, 1000);
  4982. } else {
  4983. urg.Login.Status = "NoAction";
  4984. NgNote.Error(Messages.Fa.FailedLogin, 3);
  4985. }
  4986. }
  4987. else {
  4988. urg.Login.Status = "NoAction";
  4989. urg.Login.ErrorMessage = Messages.Fa.FailedLogin;
  4990. }
  4991. });
  4992. }else{
  4993. NgNote.Error(Messages.Fa.RobotError, 3);
  4994. }
  4995. }
  4996. urg.DoResend= function(){
  4997. if(urg.ResendCount<3){
  4998. ++urg.ResendCount;
  4999. UserSrv.resendVerificationEmail(urg.User.Email).then(function(result){
  5000. if(result.status_code==1){
  5001. NgNote.Success(Messages.Fa.ConfirmRegistrationResend,3);
  5002. }
  5003. else{
  5004. NgNote.Error(result.status_message,3);
  5005. }
  5006. });
  5007. }
  5008. }
  5009. urg.authenticate = function(provider) {
  5010. $auth.authenticate(provider)
  5011. .then(function() {
  5012. toastr.success('You have successfully signed in with ' + provider + '!');
  5013. $location.path('/');
  5014. })
  5015. .catch(function(error) {
  5016. if (error.error) {
  5017. // Popup error - invalid redirect_uri, pressed cancel button, etc.
  5018. toastr.error(error.error);
  5019. } else if (error.data) {
  5020. // HTTP response error from server
  5021. toastr.error(error.data.message, error.status);
  5022. } else {
  5023. toastr.error(error);
  5024. }
  5025. });
  5026. };
  5027. }
  5028. function ChannelArchiveOldCtrl($window,GeneralInit,ChannelSrv,$routeParams,$rootScope,deviceDetector,ProgressBarFcy,ChannelFcy,EpisodeFcy,Configs,$scope,$timeout,SecurityFcy,$location,$route) {
  5029. var id = $routeParams.Id;
  5030. $timeout(function () {
  5031. $window.location.href = "/#!/archive/"+id+"/"+$rootScope.fullDateGeneral;
  5032. },500)
  5033. }
  5034. function ChannelArchiveCtrl(GeneralInit,ChannelSrv,$routeParams,$rootScope,deviceDetector,ProgressBarFcy,ChannelFcy,EpisodeFcy,Configs,$scope,$timeout,SecurityFcy,$location,$route){
  5035. var cac = this;
  5036. var pureDate = $routeParams.date;
  5037. var splittedPureDate = pureDate.split("-");
  5038. var year = splittedPureDate[0];
  5039. var month = splittedPureDate[1];
  5040. var day = splittedPureDate[2];
  5041.  
  5042. var ShamsiDate = new JDate(parseInt(year),parseInt(month)-1,parseInt(day))._date.toString();
  5043. var nameOfDay = ShamsiDate.split(" ")[0];
  5044. var pureDateGenral = $routeParams.date;
  5045. var todayMiladiDate = new Date;
  5046. $scope.todayMiladiDate = new JDate(todayMiladiDate);
  5047. $scope.whetherTodayPassed=false;
  5048. var compareDates = function (selectedDate) {
  5049. $scope.todayMiladiDate = new JDate(todayMiladiDate);
  5050. if($scope.todayMiladiDate > selectedDate){
  5051. $scope.whetherTodayPassed = true;
  5052. } else{
  5053. $scope.whetherTodayPassed = false;
  5054. }
  5055. }
  5056. compareDates(new JDate(parseInt(year),parseInt(month)-1,parseInt(day)+1))
  5057. if(day.indexOf("0")==0){
  5058. day = day.charAt(1);
  5059. }
  5060. if(month.indexOf("0")==0){
  5061. month = month.charAt(1);
  5062. }
  5063. var countNumberOfDays = 0;
  5064. $(document).on("click","#next-day",function () {
  5065. countNumberOfDays--;
  5066. var pureDate = pureDateGenral;
  5067. var splittedPureDate = pureDate.split("-");
  5068. var year = splittedPureDate[0];
  5069. var month = splittedPureDate[1];
  5070. var day = splittedPureDate[2];
  5071. pureDate= new JDate(parseInt(year),parseInt(month)-1,parseInt(day)+1).toLocaleString().split(" ")[0];
  5072. compareDates(new JDate(parseInt(year),parseInt(month)-1,parseInt(day)+2));
  5073. splittedPureDate = pureDate.split("/");
  5074. year = splittedPureDate[0];
  5075. month = splittedPureDate[1];
  5076. day = splittedPureDate[2];
  5077.  
  5078. if(day.indexOf("0")==0){
  5079. day = day.charAt(1);
  5080. }
  5081. if(month.indexOf("0")==0){
  5082. month = month.charAt(1);
  5083. }
  5084. pureDateGenral = year+"-"+month+"-"+day;
  5085. var MiladiDate = new JDate(parseInt(year),parseInt(month)-1,parseInt(day))._date.toString();
  5086. var nameOfDay = MiladiDate.split(" ")[0];
  5087.  
  5088.  
  5089. var fullDate=year+"-"+month+"-"+day;
  5090. var nameOfDayFarsi = cac.nameOfTheDays[nameOfDay];
  5091. $(".date-dropdown-selector > ul li i").addClass("display-none").removeClass("actives");
  5092. $(".date-dropdown-selector > ul li[data-id="+day+"][data-index=3]").find("i").removeClass("display-none").addClass("actives");
  5093. $(".date-dropdown-selector > ul li[data-id="+month+"][data-index=2]").find("i").removeClass("display-none").addClass("actives");
  5094. $(".date-dropdown-selector > ul li[data-id="+year+"][data-index=1]").find("i").removeClass("display-none").addClass("actives");
  5095.  
  5096.  
  5097.  
  5098. $(".date-dropdown-selector > ul li i.actives").each(function () {
  5099. var index = $(this).parent().data("index");
  5100. var parentItem = $(this).parents(".date-selectbox").find(".selected-value");
  5101. var content = $(this).parent().find("span").html();
  5102. parentItem.html(content);
  5103. var content = $(this).parent().find("span").html();
  5104. if(3-index==0)
  5105. $("#date-to-show li").eq(3-index).html(nameOfDayFarsi+content);
  5106. else
  5107. $("#date-to-show li").eq(3-index).html(content);
  5108. });
  5109. cac.ChannelNewestEpisodes = {Offset:0,Limit:150,UpdateInProgress:true,Episodes:[],Page:0};
  5110. window.history.pushState({ url: "/#!/archive/"+cac.ChannelId+"/"+fullDate },null,"/#!/archive/"+cac.ChannelId+"/"+fullDate);
  5111. EpisodeFcy.getEpisodeByDateAndChannel(fullDate,cac.ChannelOriginalId,cac.ChannelNewestEpisodes.Offset,cac.ChannelNewestEpisodes.Limit).then(function(result) {
  5112. if (cac.ChannelNewestEpisodes.Page == 1) {
  5113. TwoRowsCarousel.CarouselInit("ThisChannelsLatest");
  5114. }
  5115.  
  5116. window.LiveChannelLatestEpisodes = result.length;
  5117. window.LiveChannelLatestEpisodesTotal += parseInt(window.LiveChannelLatestEpisodes);
  5118. var tempArray = [];
  5119. var tempArray2 = [];
  5120. tempArray.push(result);
  5121. tempArray2.push(cac.ChannelNewestEpisodes.Episodes);
  5122. cac.ChannelNewestEpisodes.Episodes = tempArray2[0].concat(tempArray[0]);
  5123. tempArray.length = 0;
  5124. tempArray2.length = 0;
  5125. cac.ChannelNewestEpisodes.UpdateInProgress = false;
  5126. ProgressBarFcy.setDone();
  5127. setTimeout(function () {
  5128. $(".carousel-info h5 span").each(function () {
  5129. var elem = $(this);
  5130. var persianNumber = persianUtils.toPersianNumber(elem.html());
  5131. elem.html(persianNumber);
  5132. });
  5133. });
  5134. });
  5135.  
  5136. });
  5137. $(document).on("click","#previous-day",function () {
  5138. countNumberOfDays++;
  5139. var pureDate = pureDateGenral;
  5140. var splittedPureDate = pureDate.split("-");
  5141. var year = splittedPureDate[0];
  5142. var month = splittedPureDate[1];
  5143. var day = splittedPureDate[2];
  5144. if(parseInt(day)-1 == 0) {
  5145. pureDate = new JDate(parseInt(year), parseInt(month) - 2, 30).toLocaleString().split(" ")[0];
  5146. splittedPureDate = pureDate.split("/");
  5147. year = splittedPureDate[0];
  5148. month = splittedPureDate[1];
  5149. day = (parseInt(splittedPureDate[2])+1)+"";
  5150. compareDates(new JDate(parseInt(year), parseInt(month) - 2, 31));
  5151. }else {
  5152. pureDate = new JDate(parseInt(year), parseInt(month) - 1, parseInt(day) - 1).toLocaleString().split(" ")[0];
  5153. compareDates(new JDate(parseInt(year), parseInt(month) - 1, parseInt(day) - 1));
  5154. splittedPureDate = pureDate.split("/");
  5155. year = splittedPureDate[0];
  5156. month = splittedPureDate[1];
  5157. day = splittedPureDate[2];
  5158. }
  5159.  
  5160. if(day.indexOf("0")==0){
  5161. day = day.charAt(1);
  5162. }
  5163. if(month.indexOf("0")==0){
  5164. month = month.charAt(1);
  5165. }
  5166. pureDateGenral = year+"-"+month+"-"+day;
  5167. var MiladiDate = new JDate(parseInt(year),parseInt(month)-1,parseInt(day))._date.toString();
  5168. var nameOfDay = MiladiDate.split(" ")[0];
  5169.  
  5170.  
  5171. var fullDate=year+"-"+month+"-"+day;
  5172. var nameOfDayFarsi = cac.nameOfTheDays[nameOfDay];
  5173. $(".date-dropdown-selector > ul li i").addClass("display-none").removeClass("actives");
  5174. $(".date-dropdown-selector > ul li[data-id="+day+"][data-index=3]").find("i").removeClass("display-none").addClass("actives");
  5175. $(".date-dropdown-selector > ul li[data-id="+month+"][data-index=2]").find("i").removeClass("display-none").addClass("actives");
  5176. $(".date-dropdown-selector > ul li[data-id="+year+"][data-index=1]").find("i").removeClass("display-none").addClass("actives");
  5177.  
  5178.  
  5179.  
  5180. $(".date-dropdown-selector > ul li i.actives").each(function () {
  5181. var index = $(this).parent().data("index");
  5182. var parentItem = $(this).parents(".date-selectbox").find(".selected-value");
  5183. var content = $(this).parent().find("span").html();
  5184. parentItem.html(content);
  5185. var content = $(this).parent().find("span").html();
  5186. if(3-index==0)
  5187. $("#date-to-show li").eq(3-index).html(nameOfDayFarsi+content);
  5188. else
  5189. $("#date-to-show li").eq(3-index).html(content);
  5190. });
  5191. cac.ChannelNewestEpisodes = {Offset:0,Limit:150,UpdateInProgress:true,Episodes:[],Page:0};
  5192. window.history.pushState({ url: "/#!/archive/"+cac.ChannelId+"/"+fullDate },null,"/#!/archive/"+cac.ChannelId+"/"+fullDate);
  5193. EpisodeFcy.getEpisodeByDateAndChannel(fullDate,cac.ChannelOriginalId,cac.ChannelNewestEpisodes.Offset,cac.ChannelNewestEpisodes.Limit).then(function(result) {
  5194. if (cac.ChannelNewestEpisodes.Page == 1) {
  5195. TwoRowsCarousel.CarouselInit("ThisChannelsLatest");
  5196. }
  5197.  
  5198. window.LiveChannelLatestEpisodes = result.length;
  5199. window.LiveChannelLatestEpisodesTotal += parseInt(window.LiveChannelLatestEpisodes);
  5200. var tempArray = [];
  5201. var tempArray2 = [];
  5202. tempArray.push(result);
  5203. tempArray2.push(cac.ChannelNewestEpisodes.Episodes);
  5204. cac.ChannelNewestEpisodes.Episodes = tempArray2[0].concat(tempArray[0]);
  5205. tempArray.length = 0;
  5206. tempArray2.length = 0;
  5207. cac.ChannelNewestEpisodes.UpdateInProgress = false;
  5208. ProgressBarFcy.setDone();
  5209. setTimeout(function () {
  5210. $(".carousel-info h5 span").each(function () {
  5211. var elem = $(this);
  5212. var persianNumber = persianUtils.toPersianNumber(elem.html());
  5213. elem.html(persianNumber);
  5214. });
  5215. });
  5216. });
  5217.  
  5218. });
  5219. $(document).on("click","#today-convert",function () {
  5220. countNumberOfDays = 0;
  5221. var MiladiDate = new Date();
  5222. var ShamsiDate = new JDate(MiladiDate);
  5223. var pureDate = ShamsiDate.toLocaleString().split(" ");
  5224. var splittedPureDate = pureDate[0].split("/");
  5225. var year = splittedPureDate[0];
  5226. var month = splittedPureDate[1];
  5227. var day = splittedPureDate[2];
  5228. if(day.indexOf("0")==0){
  5229. day = day.charAt(1);
  5230. }
  5231. if(month.indexOf("0")==0){
  5232. month = month.charAt(1);
  5233. }
  5234. $scope.whetherTodayPassed = false;
  5235. pureDateGenral = year+"-"+month+"-"+day;
  5236. var fullDate=year+"-"+month+"-"+day;
  5237. var ShamsiDate2 = new JDate(parseInt(year),parseInt(month)-1,parseInt(day))._date.toString();
  5238. var nameOfDay = ShamsiDate2.split(" ")[0];
  5239. var nameOfDayFarsi = cac.nameOfTheDays[nameOfDay];
  5240. $(".date-dropdown-selector > ul li i").addClass("display-none").removeClass("actives");
  5241. $(".date-dropdown-selector > ul li[data-id="+day+"][data-index=3]").find("i").removeClass("display-none").addClass("actives");
  5242. $(".date-dropdown-selector > ul li[data-id="+month+"][data-index=2]").find("i").removeClass("display-none").addClass("actives");
  5243. $(".date-dropdown-selector > ul li[data-id="+year+"][data-index=1]").find("i").removeClass("display-none").addClass("actives");
  5244. $(".date-dropdown-selector > ul li i.actives").each(function () {
  5245. var index = $(this).parent().data("index");
  5246. var parentItem = $(this).parents(".date-selectbox").find(".selected-value");
  5247. var content = $(this).parent().find("span").html();
  5248. parentItem.html(content);
  5249. var content = $(this).parent().find("span").html();
  5250. if(3-index==0)
  5251. $("#date-to-show li").eq(3-index).html(nameOfDayFarsi+content);
  5252. else
  5253. $("#date-to-show li").eq(3-index).html(content);
  5254. });
  5255. cac.ChannelNewestEpisodes = {Offset:0,Limit:150,UpdateInProgress:true,Episodes:[],Page:0};
  5256. window.history.pushState({ url: "/#!/archive/"+cac.ChannelId+"/"+fullDate },null,"/#!/archive/"+cac.ChannelId+"/"+fullDate);
  5257. EpisodeFcy.getEpisodeByDateAndChannel(fullDate,cac.ChannelOriginalId,cac.ChannelNewestEpisodes.Offset,cac.ChannelNewestEpisodes.Limit).then(function(result) {
  5258. if (cac.ChannelNewestEpisodes.Page == 1) {
  5259. TwoRowsCarousel.CarouselInit("ThisChannelsLatest");
  5260. }
  5261.  
  5262. window.LiveChannelLatestEpisodes = result.length;
  5263. window.LiveChannelLatestEpisodesTotal += parseInt(window.LiveChannelLatestEpisodes);
  5264. var tempArray = [];
  5265. var tempArray2 = [];
  5266. tempArray.push(result);
  5267. tempArray2.push(cac.ChannelNewestEpisodes.Episodes);
  5268. cac.ChannelNewestEpisodes.Episodes = tempArray2[0].concat(tempArray[0]);
  5269. tempArray.length = 0;
  5270. tempArray2.length = 0;
  5271. cac.ChannelNewestEpisodes.UpdateInProgress = false;
  5272. ProgressBarFcy.setDone();
  5273. setTimeout(function () {
  5274. $(".carousel-info h5 span").each(function () {
  5275. var elem = $(this);
  5276. var persianNumber = persianUtils.toPersianNumber(elem.html());
  5277. elem.html(persianNumber);
  5278. });
  5279. });
  5280. });
  5281. })
  5282. var fullDate=year+"-"+month+"-"+day;
  5283. cac.ChannelId = $routeParams.Id;
  5284. cac.PersianChannelName = "";
  5285. cac.selectBoxYears = [
  5286. {"id":1395 , "content":"1395"}
  5287. ]
  5288. cac.selectBoxMonths = [
  5289. {"id":1 , "content":"فروردین"},{"id":2 , "content":"اردیبهشت"},{"id":3 , "content":"خرداد"},{"id":4 , "content":"تیر"},{"id":5 , "content":"مرداد"},{"id":6 , "content":"شهریور"},{"id":7 , "content":"مهر"},{"id":8 , "content":"آبان"},{"id":9 , "content":"آذر"},{"id":10 , "content":"دی"},{"id":11 , "content":"بهمن"},{"id":12 , "content":"اسفند"}
  5290. ]
  5291. cac.selectBoxDays = [
  5292. {"id":1 , "content":"1"},{"id":2 , "content":"2"},{"id":3 , "content":"3"},{"id":4 , "content":"4"},{"id":5 , "content":"5"},{"id":6 , "content":"6"},{"id":7 , "content":"7"},{"id":8 , "content":"8"},{"id":9 , "content":"9"},{"id":10 , "content":"10"},{"id":11 , "content":"11"},{"id":12 , "content":"12"},{"id":13 , "content":"13"},{"id":14 , "content":"14"},{"id":15 , "content":"15"},{"id":16 , "content":"16"},{"id":17 , "content":"17"},{"id":18 , "content":"18"},{"id":19 , "content":"19"},{"id":20 , "content":"20"},{"id":21 , "content":"21"},{"id":22 , "content":"22"},{"id":23 , "content":"23"},{"id":24 , "content":"24"},{"id":25 , "content":"25"},{"id":26 , "content":"26"},{"id":27 , "content":"27"},{"id":28 , "content":"28"},{"id":29 , "content":"29"},{"id":30 , "content":"30"},{"id":31 , "content":"31"}
  5293. ]
  5294.  
  5295. cac.nameOfTheDays = [];
  5296. cac.nameOfTheDays["Sat"]= "شنبه";
  5297. cac.nameOfTheDays["Sun"] = "یکشنبه";
  5298. cac.nameOfTheDays["Mon"]="دوشنبه";
  5299. cac.nameOfTheDays["Tue"]="سه شنبه";
  5300. cac.nameOfTheDays["Wed"]="چهارشنبه";
  5301. cac.nameOfTheDays["Thu"]="پنجشنبه";
  5302. cac.nameOfTheDays["Fri"]="جمعه";
  5303. var nameOfDayFarsi = cac.nameOfTheDays[nameOfDay];
  5304. // var nameOfDayFarsi = cac.nameOfTheDays[nameOfDay]
  5305. cac.ChannelData={Offset:0,Limit:50,UpdateInProgress:true,Channels:[],Page:1,MaximumPage:0,tempColumn:0};
  5306. cac.ChannelSettings={Offset:0,Limit:50,UpdateInProgress:true,Channels:[],Page:1,MaximumPage:0,tempColumn:0};
  5307. cac.ChannelNewestEpisodes = {Offset:0,Limit:150,UpdateInProgress:true,Episodes:[],Page:0};
  5308. ChannelFcy.getChannelNameFromDescriptor(cac.ChannelId).then(function(ChannelId){
  5309. SecurityFcy.getToken().then(function (token){
  5310. ChannelSrv.getChannel(ChannelId,deviceDetector.device,token).then(function(result){
  5311. cac.ChannelOriginalId=ChannelId;
  5312. cac.Channel={};
  5313. cac.Channel.links=result;
  5314. $rootScope.Page.Title="آرشیو "+$rootScope.ChannelIdToName(ChannelId);//(GeneralInit.Culture=="fa")?lic.Channel.title:lic.Channel.title_english;
  5315. $rootScope.Page.Description="پخش زنده شبکه " + $rootScope.ChannelIdToName(ChannelId);
  5316. $rootScope.Page.Keywords= "پخش زنده شبکه " + $rootScope.ChannelIdToName(ChannelId);
  5317. $rootScope.$broadcast("UserData");
  5318. window.ChannelId = $routeParams.Id;
  5319. cac.ChannelSettings.UpdateInProgress = false;
  5320. cac.ChannelSettings.IsPlaying = true;
  5321. EpisodeFcy.getEpisodeByDateAndChannel(fullDate,ChannelId,cac.ChannelNewestEpisodes.Offset,cac.ChannelNewestEpisodes.Limit).then(function(result) {
  5322.  
  5323. pureDate = $routeParams.date;
  5324. splittedPureDate = pureDate.split("-");
  5325. year = splittedPureDate[0];
  5326. month = splittedPureDate[1];
  5327. day = splittedPureDate[2];
  5328. if(day.indexOf("0")==0){
  5329. day = day.charAt(1);
  5330. }
  5331. if(month.indexOf("0")==0){
  5332. month = month.charAt(1);
  5333. }
  5334.  
  5335. fullDate=year+"-"+month+"-"+day;
  5336. setTimeout(function () {
  5337. $(".date-dropdown-selector > ul li[data-id="+day+"][data-index=3]").find("i").removeClass("display-none").addClass("actives");
  5338. $(".date-dropdown-selector > ul li[data-id="+month+"][data-index=2]").find("i").removeClass("display-none").addClass("actives");
  5339. $(".date-dropdown-selector > ul li[data-id="+year+"][data-index=1]").find("i").removeClass("display-none").addClass("actives");
  5340. },200)
  5341. cac.ChannelNewestEpisodes.Page++;
  5342. if (cac.ChannelNewestEpisodes.Page == 1) {
  5343. TwoRowsCarousel.CarouselInit("ThisChannelsLatest");
  5344. }
  5345. window.LiveChannelLatestEpisodes = result.length;
  5346. window.LiveChannelLatestEpisodesTotal += parseInt(window.LiveChannelLatestEpisodes);
  5347. var tempArray = [];
  5348. var tempArray2 = [];
  5349. tempArray.push(result);
  5350. tempArray2.push(cac.ChannelNewestEpisodes.Episodes);
  5351. cac.ChannelNewestEpisodes.Episodes = tempArray2[0].concat(tempArray[0]);
  5352. tempArray.length = 0;
  5353. tempArray2.length = 0;
  5354. cac.ChannelNewestEpisodes.UpdateInProgress = false;
  5355. ProgressBarFcy.setDone();
  5356. setTimeout(function () {
  5357. $(".carousel-info h5 span").each(function () {
  5358. var elem = $(this);
  5359. var persianNumber = persianUtils.toPersianNumber(elem.html());
  5360. elem.html(persianNumber);
  5361. });
  5362. });
  5363. });
  5364.  
  5365.  
  5366. $timeout(function () {
  5367.  
  5368. $(".carousel-info h5 span").each(function () {
  5369. var elem = $(this);
  5370. var persianNumber = persianUtils.toPersianNumber(elem.html());
  5371. elem.html(persianNumber);
  5372. });
  5373. $(".date-dropdown-selector > ul li i.actives").each(function () {
  5374. var index = $(this).parent().data("index");
  5375. var parentItem = $(this).parents(".date-selectbox").find(".selected-value");
  5376. var content = $(this).parent().find("span").html();
  5377. parentItem.html(content);
  5378. var content = $(this).parent().find("span").html();
  5379. if(3-index==0)
  5380. $("#date-to-show li").eq(3-index).html(nameOfDayFarsi+content);
  5381. else
  5382. $("#date-to-show li").eq(3-index).html(content);
  5383. });
  5384. },1000);
  5385. ProgressBarFcy.plus(0.2);
  5386. });
  5387. });
  5388. });
  5389. var lastRoute = $route.current;
  5390. $scope.$on('$locationChangeSuccess', function(event,next) {
  5391. if(next.toString().indexOf("/archive/")>0){
  5392. $route.current = lastRoute;
  5393. }
  5394. });
  5395. var ChannelIdAfterChange;
  5396. cac.changeState = function (descriptor,Id) {
  5397. $("#list-of-channels-carousel li").removeClass("active-channel");
  5398. $("#list-of-channels-carousel li[data-descriptor="+descriptor+"]").addClass("active-channel");
  5399. $rootScope.Page.Title="آرشیو "+$rootScope.ChannelIdToName(Id);
  5400. cac.ChannelNewestEpisodes = {Offset:0,Limit:150,UpdateInProgress:true,Episodes:[],Page:0};
  5401. ProgressBarFcy.setDone();
  5402. cac.ChannelOriginalId = Id;
  5403. var dateToChange = [];
  5404. $(".date-dropdown-selector > ul li i.actives").each(function () {
  5405.  
  5406. if($(this).parent().attr("data-index")=="3"){
  5407. dateToChange[2] = $(this).parent().attr("data-id")
  5408. }else if($(this).parent().attr("data-index")=="2"){
  5409. dateToChange[1] = $(this).parent().attr("data-id")
  5410. }else{
  5411. dateToChange[0] = $(this).parent().attr("data-id")
  5412. }
  5413. })
  5414. dateToChange = dateToChange.join("-");
  5415. window.history.pushState({ url: "/#!/archive/"+descriptor+"/"+dateToChange },null,"/#!/archive/"+descriptor+"/"+dateToChange);
  5416. cac.ChannelNewestEpisodes.UpdateInProgress = true;
  5417. EpisodeFcy.getEpisodeByDateAndChannel(pureDateGenral,Id,cac.ChannelNewestEpisodes.Offset,cac.ChannelNewestEpisodes.Limit).then(function(result) {
  5418. cac.ChannelNewestEpisodes.Page++;
  5419. if (cac.ChannelNewestEpisodes.Page == 1) {
  5420. TwoRowsCarousel.CarouselInit("ThisChannelsLatest");
  5421. }
  5422. cac.ChannelId = descriptor;
  5423. window.LiveChannelLatestEpisodes = result.length;
  5424. window.LiveChannelLatestEpisodesTotal += parseInt(window.LiveChannelLatestEpisodes);
  5425. var tempArray = [];
  5426. var tempArray2 = [];
  5427. tempArray.push(result);
  5428. tempArray2.push(cac.ChannelNewestEpisodes.Episodes);
  5429. cac.ChannelNewestEpisodes.Episodes = tempArray2[0].concat(tempArray[0]);
  5430. tempArray.length = 0;
  5431. tempArray2.length = 0;
  5432. cac.ChannelNewestEpisodes.UpdateInProgress = false;
  5433. ProgressBarFcy.setDone();
  5434. setTimeout(function () {
  5435. $(".carousel-info h5 span").each(function () {
  5436. var elem = $(this);
  5437. var persianNumber = persianUtils.toPersianNumber(elem.html());
  5438. elem.html(persianNumber);
  5439. });
  5440. });
  5441. });
  5442.  
  5443. cac.PersianChannelName =persianUtils.toPersianNumber( " آرشیو "+$rootScope.ChannelIdToName(parseInt($("#list-of-channels-carousel li.active-channel").attr("data-id"))));
  5444. setTimeout(function () {
  5445.  
  5446. $(".carousel-info h5 span").each(function () {
  5447. var elem = $(this);
  5448. var persianNumber = persianUtils.toPersianNumber(elem.html());
  5449. elem.html(persianNumber);
  5450. });
  5451. },200);
  5452. }
  5453. $(document).on("click",".date-dropdown-selector > ul > li",function () {
  5454. var elem = $(this);
  5455. var ulList = elem.parent().find("li i");
  5456. var content = $(this).find("span").html();
  5457. var parentItem = $(this).parents(".date-selectbox").find(".selected-value");
  5458. var selectedDay;
  5459. var selectedMonth;
  5460. var selectedYear;
  5461. parentItem.html(content);
  5462. ulList.addClass("display-none").removeClass("actives");
  5463. elem.find("i").removeClass("display-none").addClass("actives");
  5464. $(".date-dropdown-selector > ul > li i.actives").each(function () {
  5465. var item = $(this).parent();
  5466. if(item.data("index")==3){
  5467. selectedDay = item.data("id");
  5468. }
  5469. if(item.data("index")==2){
  5470. selectedMonth = item.data("id");
  5471. }
  5472. if(item.data("index")==1){
  5473. selectedYear = item.data("id");
  5474. }
  5475. });
  5476. var fullDate = selectedYear + "-" + selectedMonth + "-" + selectedDay
  5477. ShamsiDate = new JDate(parseInt(selectedYear),parseInt(selectedMonth)-1,parseInt(selectedDay))._date.toString();
  5478. compareDates(new JDate(parseInt(selectedYear),parseInt(selectedMonth)-1,parseInt(selectedDay)));
  5479. pureDateGenral = selectedYear + "-" + selectedMonth + "-" + selectedDay;
  5480. var nameOfDay = ShamsiDate.split(" ")[0];
  5481. var nameOfDayFarsi = cac.nameOfTheDays[nameOfDay];
  5482. window.history.pushState({ url: "/#!/archive/"+cac.ChannelId+"/"+fullDate },null,"/#!/archive/"+cac.ChannelId+"/"+fullDate);
  5483. cac.ChannelNewestEpisodes = {Offset:0,Limit:150,UpdateInProgress:true,Episodes:[],Page:0};
  5484. EpisodeFcy.getEpisodeByDateAndChannel(fullDate,cac.ChannelOriginalId,cac.ChannelNewestEpisodes.Offset,cac.ChannelNewestEpisodes.Limit).then(function(result) {
  5485. if (cac.ChannelNewestEpisodes.Page == 1) {
  5486. TwoRowsCarousel.CarouselInit("ThisChannelsLatest");
  5487. }
  5488.  
  5489. window.LiveChannelLatestEpisodes = result.length;
  5490. window.LiveChannelLatestEpisodesTotal += parseInt(window.LiveChannelLatestEpisodes);
  5491. var tempArray = [];
  5492. var tempArray2 = [];
  5493. tempArray.push(result);
  5494. tempArray2.push(cac.ChannelNewestEpisodes.Episodes);
  5495. cac.ChannelNewestEpisodes.Episodes = tempArray2[0].concat(tempArray[0]);
  5496. tempArray.length = 0;
  5497. tempArray2.length = 0;
  5498. cac.ChannelNewestEpisodes.UpdateInProgress = false;
  5499. ProgressBarFcy.setDone();
  5500. setTimeout(function () {
  5501. $(".carousel-info h5 span").each(function () {
  5502. var elem = $(this);
  5503. var persianNumber = persianUtils.toPersianNumber(elem.html());
  5504. elem.html(persianNumber);
  5505. });
  5506. });
  5507. });
  5508. cac.PersianChannelName =persianUtils.toPersianNumber( " آرشیو "+$rootScope.ChannelIdToName(parseInt($("#list-of-channels-carousel li.active-channel").attr("data-id"))));
  5509. setTimeout(function () {
  5510. $(".carousel-info h5 span").each(function () {
  5511. var elem = $(this);
  5512. var persianNumber = persianUtils.toPersianNumber(elem.html());
  5513. elem.html(persianNumber);
  5514. });
  5515. },200);
  5516. if(elem.attr("data-index")!=2) {
  5517. if (elem.attr("data-index") == 3)
  5518. $("#date-to-show li").eq(3 - parseInt(elem.attr("data-index"))).html(nameOfDayFarsi + " " + $rootScope.ConvertToPersianNumber(elem.attr("data-id")));
  5519. else
  5520. $("#date-to-show li").eq(3 - parseInt(elem.attr("data-index"))).html($rootScope.ConvertToPersianNumber(elem.attr("data-id")));
  5521. }else {
  5522. $("#date-to-show li").eq(3 - parseInt(elem.attr("data-index"))).html(elem.find("span").html());
  5523. $("#date-to-show li").eq(0).html(nameOfDayFarsi + " " + $rootScope.ConvertToPersianNumber(elem.attr("data-id")));
  5524. }
  5525. });
  5526.  
  5527. cac.getNext=function() {
  5528. cac.ChannelNewestEpisodes = {Offset:0,Limit:50,UpdateInProgress:true,Episodes:[],Page:0};
  5529. EpisodeFcy.getEpisodeByDateAndChannel(fullDate,cac.ChannelOriginalId,cac.ChannelNewestEpisodes.Offset,cac.ChannelNewestEpisodes.Limit).then(function(result) {
  5530. cac.ChannelNewestEpisodes.Page++;
  5531. if (cac.ChannelNewestEpisodes.Page == 1) {
  5532. TwoRowsCarousel.CarouselInit("ThisChannelsLatest");
  5533. }
  5534. window.LiveChannelLatestEpisodes = result.length;
  5535. window.LiveChannelLatestEpisodesTotal += parseInt(window.LiveChannelLatestEpisodes);
  5536. var tempArray = [];
  5537. var tempArray2 = [];
  5538. tempArray.push(result);
  5539. tempArray2.push(cac.ChannelNewestEpisodes.Episodes);
  5540. cac.ChannelNewestEpisodes.Episodes = tempArray2[0].concat(tempArray[0]);
  5541. tempArray.length = 0;
  5542. tempArray2.length = 0;
  5543. cac.ChannelNewestEpisodes.UpdateInProgress = false;
  5544. ProgressBarFcy.setDone();
  5545. setTimeout(function () {
  5546. $(".carousel-info h5 span").each(function () {
  5547. var elem = $(this);
  5548. var persianNumber = persianUtils.toPersianNumber(elem.html());
  5549. elem.html(persianNumber);
  5550. });
  5551. });
  5552. });
  5553. cac.ChannelNewestEpisodes.Limit = ((cac.ChannelNewestEpisodes.Page + 1) == 1) ? 50 : 50;
  5554. cac.ChannelNewestEpisodes.Offset = ((cac.ChannelNewestEpisodes.Page + 1) == 1) ? 0 : ((cac.ChannelNewestEpisodes.Page) * 50);
  5555. cac.ChannelNewestEpisodes.UpdateInProgress = true;
  5556. EpisodeFcy.getEpisodeByDateAndChannel(fullDate,cac.ChannelOriginalId,cac.ChannelNewestEpisodes.Offset,cac.ChannelNewestEpisodes.Limit);
  5557. setTimeout(function () {
  5558. $(".carousel-info h5 span").each(function () {
  5559. var elem = $(this);
  5560. var persianNumber = persianUtils.toPersianNumber(elem.html());
  5561. elem.html(persianNumber);
  5562. });
  5563. },200);
  5564. }
  5565. cac.getChannels=function(){
  5566. ChannelFcy.getChannels().then(function(Channels){
  5567. LiveChannelsCarousel.CarouselInit("OtherChannels");
  5568. cac.ChannelData.Channels=Channels;
  5569. cac.ChannelData.MaximumPage=Math.ceil(Channels.length/cac.ChannelData.Limit);
  5570. cac.ChannelData.UpdateInProgress=false;
  5571. $rootScope.ChannelData=cac.ChannelData;
  5572. $rootScope.$broadcast("UserData");
  5573. $timeout(function () {
  5574. cac.PersianChannelName =persianUtils.toPersianNumber( " آرشیو "+$rootScope.ChannelIdToName(parseInt($("#list-of-channels-carousel li.active-channel").attr("data-id"))));
  5575. AutoFocus.applyFocus();
  5576. },1000);
  5577. });
  5578.  
  5579. }
  5580. cac.getChannels();
  5581. }
  5582. function LiveCtrl(GeneralInit,ChannelSrv,$routeParams,$rootScope,deviceDetector,ProgressBarFcy,ChannelFcy,EpisodeFcy,Configs,$scope,$timeout,SecurityFcy,HourlyArchiveFcy){
  5583. var lic=this;
  5584.  
  5585. $(".position-fix-carousel").scroll(function () {
  5586. $(document).scroll()
  5587. })
  5588. $(document).on("click",".slick-next,.slick-prev",function () {
  5589. $(document).scroll()
  5590. setTimeout(function () {
  5591. $(document).scroll()
  5592.  
  5593. },600)
  5594. });
  5595. var MiladiDate = new Date();
  5596. var ShamsiDate = new JDate(MiladiDate);
  5597. var pureDate = ShamsiDate.toLocaleString().split(" ");
  5598. var splittedPureDate = pureDate[0].split("/");
  5599. var hours = pureDate[1].split(":")[0];
  5600. var minutes = pureDate[1].split(":")[1];
  5601. var year = splittedPureDate[0];
  5602. var month = splittedPureDate[1];
  5603. var day = splittedPureDate[2];
  5604. if(day.indexOf("0")==0){
  5605. day = day.charAt(1);
  5606. }
  5607. if(month.indexOf("0")==0){
  5608. month = month.charAt(1);
  5609. }
  5610.  
  5611. var fullDate=year+"-"+month+"-"+day;
  5612. lic.fullDate = fullDate;
  5613. TopCarousel.initCarousel();
  5614. var nameOfDays = [];
  5615. nameOfDays["Sat"] = "شنبه";
  5616. nameOfDays["Sun"] = "یکشنبه";
  5617. nameOfDays["Mon"] = "دوشنبه";
  5618. nameOfDays["Tue"] = "سه شنبه";
  5619. nameOfDays["Wed"] = "چهارشنبه";
  5620. nameOfDays["Thu"] = "پنجشنبه";
  5621. nameOfDays["Fri"] = "جمعه";
  5622. nameOfDays[0] = "شنبه";
  5623. nameOfDays[1] = "یکشنبه";
  5624. nameOfDays[2] = "دوشنبه";
  5625. nameOfDays[3] = "سه شنبه";
  5626. nameOfDays[4] = "چهارشنبه";
  5627. nameOfDays[5] = "پنجشنبه";
  5628. nameOfDays[6] = "جمعه";
  5629. var todayIndex = 0;
  5630. if((MiladiDate+"").indexOf("Sat") >=0){
  5631. todayIndex = 0
  5632. }else if((MiladiDate+"").indexOf("Sun") >=0){
  5633. todayIndex = 1;
  5634. }else if((MiladiDate+"").indexOf("Mon") >=0){
  5635. todayIndex = 2;
  5636. }else if((MiladiDate+"").indexOf("Tue") >=0){
  5637. todayIndex = 3;
  5638. }else if((MiladiDate+"").indexOf("Wed") >=0){
  5639. todayIndex = 4;
  5640. }else if((MiladiDate+"").indexOf("Thu") >=0){
  5641. todayIndex = 5;
  5642. }else if((MiladiDate+"").indexOf("Fri") >=0){
  5643. todayIndex = 6;
  5644. }
  5645. var dayName = nameOfDays[ShamsiDate.a.toString().split(" ")[0]];
  5646. fixWidthsOfCarousel.appendDaysToCarousel(nameOfDays,day,month,todayIndex);
  5647.  
  5648. $timeout(function () {
  5649.  
  5650. $(".carousel-image-container img").each(function () {
  5651. $(this).error(function () {
  5652. if(!$(this).attr("data-replaced"))
  5653. replacePipelineAddress.replace($(this));
  5654. })
  5655. })
  5656. },600);
  5657. $timeout(initDates.init(),300);
  5658. $timeout($(window).resize(),300);
  5659. lic.getSelectedImage = function(ImagePath){
  5660. var PathList=ImagePath.split('/');
  5661. return PathList[0]+"/"+PathList[1]+"/"+PathList[2]+"/"+"selected-"+PathList[3];
  5662. };
  5663. $timeout($(window).resize());
  5664. window.LiveChannelLatestEpisodesTotal=0;
  5665. window.LiveChannelHourlyArchiveTotal=0;
  5666. lic.User=GeneralInit.User;
  5667. lic.ChannelId=$routeParams.Id;
  5668. window.LiveChannelDecriptor = $routeParams.Id;
  5669. /*lic.Play = function(){
  5670. window.activePlayer = "MobileLivePlayer";
  5671. window.activePlayerToolbarPlay='MobileLivePlayerToolbarPlayPause';
  5672. window.playerType = 'VideoJs';
  5673. jQuery("#PlayThePlayer2").hide();
  5674. if(DeviceDetection.IsAndroid() || DeviceDetection.IsIos() || DeviceDetection.IsSmartTv()) {
  5675. Player.Play(null, null, true);
  5676. }
  5677. };*/
  5678. lic.foundedResult = true;
  5679. lic.ChannelData={Offset:0,Limit:50,UpdateInProgress:true,Channels:[],Page:1,MaximumPage:0,tempColumn:0};
  5680. lic.ChannelNewestEpisodes = {Offset:0,Limit:19,UpdateInProgress:true,Episodes:[],Page:0};
  5681. lic.ChannelHourlyArchiveEpisodes = {Offset:0,Limit:50,UpdateInProgress:true,Episodes:[],Page:0};
  5682. lic.ChannelSettings = {UpdateInProgress:true,IsPlaying:false};
  5683. lic.hourlyArchiveContent = {items:[]};
  5684. $("#loader-hourly").show();
  5685. lic.selectedChannelData = {};
  5686. lic.getChannels=function(){
  5687. ChannelFcy.getChannels().then(function(Channels){
  5688. $timeout(function () {
  5689. $("#OtherChannels").find("img.lazyload").lazyload({
  5690. threshold : 150,
  5691. effect : "fadeIn",
  5692. });
  5693. },200);
  5694. LiveChannelsCarousel.CarouselInit("OtherChannels");
  5695. lic.ChannelData.Channels=Channels;
  5696. lic.ChannelData.MaximumPage=Math.ceil(Channels.length/lic.ChannelData.Limit);
  5697. lic.ChannelData.UpdateInProgress=false;
  5698. $rootScope.ChannelData=lic.ChannelData;
  5699. $rootScope.$broadcast("UserData");
  5700. for(var i=0;i<lic.ChannelData.Channels.length; i++){
  5701. if(lic.ChannelData.Channels[i].descriptor == lic.ChannelId){
  5702. lic.selectedChannelData = lic.ChannelData.Channels[i];
  5703. }
  5704. }
  5705. var today = new Date();
  5706. var dd = today.getDate();
  5707. var mm = today.getMonth()+1; //January is 0!
  5708.  
  5709. var yyyy = today.getFullYear();
  5710. if(dd<10){
  5711. dd='0'+dd;
  5712. }
  5713. if(mm<10){
  5714. mm='0'+mm;
  5715. }
  5716. var today = yyyy+'-'+mm+'-'+dd;
  5717. HourlyArchiveFcy.getProgramsByChannel(lic.selectedChannelData.id,today).then(function (data) {
  5718. lic.hourlyArchiveContent.items = data;
  5719. if(data.length == 0){
  5720. lic.foundedResult = false;
  5721. }else{
  5722. lic.foundedResult = true;
  5723. }
  5724. })
  5725. $timeout(function () {
  5726. var MiladiDate = new Date();
  5727. var ShamsiDate = new JDate(MiladiDate);
  5728. var pureDate = ShamsiDate.toLocaleString().split(" ");
  5729. var splittedPureDate = pureDate[0].split("/");
  5730. var hours = pureDate[1].split(":")[0];
  5731. var minutes = pureDate[1].split(":")[1];
  5732. var year = splittedPureDate[0];
  5733. var month = splittedPureDate[1];
  5734. var day = splittedPureDate[2];
  5735. if(day.indexOf("0")==0){
  5736. day = day.charAt(1);
  5737. }
  5738. if(month.indexOf("0")==0){
  5739. month = month.charAt(1);
  5740. }
  5741.  
  5742. fixClockPointer.fix(hours,minutes);
  5743. fixWidthsOfCarousel.fixRightPosition(hours,minutes);
  5744. fixWidthsOfCarousel.fixCounterAmount(hours);
  5745. fixWidthsOfCarousel.fix();
  5746. },2500);
  5747. });
  5748.  
  5749. };
  5750. $(document).on("click","#days-on-carousel > li",function () {
  5751. $(".day-carousel-new-hourly li > div > div").removeClass("active-days");
  5752. $("#program-lists").hide();
  5753. $(this).find(" > div > div").addClass("active-days");
  5754. lic.updateHourlyArchiveNew($(this).data("date"));
  5755. })
  5756. lic.updateHourlyArchiveNew = function (date) {
  5757. HourlyArchiveFcy.getProgramsByChannel(lic.selectedChannelData.id,date).then(function (data) {
  5758. lic.hourlyArchiveContent.items = data;
  5759. if(data.length == 0){
  5760. lic.foundedResult = false;
  5761. }else{
  5762. lic.foundedResult = true;
  5763. }
  5764. })
  5765. $("#loader-hourly").show();
  5766. $timeout(function () {
  5767. var MiladiDate = new Date();
  5768. var ShamsiDate = new JDate(MiladiDate);
  5769. var pureDate = ShamsiDate.toLocaleString().split(" ");
  5770. var splittedPureDate = pureDate[0].split("/");
  5771. var hours = pureDate[1].split(":")[0];
  5772. var minutes = pureDate[1].split(":")[1];
  5773. var year = splittedPureDate[0];
  5774. var month = splittedPureDate[1];
  5775. var day = splittedPureDate[2];
  5776. if(day.indexOf("0")==0){
  5777. day = day.charAt(1);
  5778. }
  5779. if(month.indexOf("0")==0){
  5780. month = month.charAt(1);
  5781. }
  5782.  
  5783. fixClockPointer.fix(hours,minutes);
  5784. fixWidthsOfCarousel.fixRightPosition(hours,minutes);
  5785. fixWidthsOfCarousel.fixCounterAmount(hours);
  5786. fixWidthsOfCarousel.fix();
  5787. },1000);
  5788. }
  5789. $rootScope.User=GeneralInit.User;
  5790. lic.Device=deviceDetector;
  5791. ProgressBarFcy.plus(0.2);
  5792. lic.getChannels();
  5793.  
  5794. ChannelFcy.getChannelNameFromDescriptor(lic.ChannelId).then(function(ChannelId){
  5795. SecurityFcy.getToken().then(function (token){
  5796. var StreamType = deviceDetector.device;
  5797. if(deviceDetector.device=='android' || deviceDetector.device=='iphone' || deviceDetector.device=="ipad"){
  5798. }
  5799. else{
  5800. if(Configs.Player.Live.DefaultPlayer=="RadiantPlayer"){
  5801. StreamType = "android";
  5802. }
  5803. }
  5804. ChannelSrv.getChannel(ChannelId,StreamType,token).then(function(result){
  5805. lic.ChannelOriginalId=ChannelId;
  5806. lic.Channel={};
  5807. /*loadingControl.hideLoading();*/
  5808. bigPlayButton.hideButton();
  5809. lic.Channel.links=result;
  5810. $rootScope.Page.Title="پخش زنده" +" "+$rootScope.ChannelIdToName(ChannelId);//(GeneralInit.Culture=="fa")?lic.Channel.title:lic.Channel.title_english;
  5811. $rootScope.Page.Description="پخش زنده شبکه " + $rootScope.ChannelIdToName(ChannelId);
  5812. $rootScope.Page.Keywords= "پخش زنده شبکه " + $rootScope.ChannelIdToName(ChannelId);
  5813. debuger.info("Channel" + $rootScope.ChannelIdToName(ChannelId) + "data has arrived");
  5814. $scope.liveChannel = $rootScope.ChannelIdToName(ChannelId);
  5815. $rootScope.$broadcast("UserData");
  5816. window.ChannelId = $routeParams.Id;
  5817. lic.ChannelSettings.UpdateInProgress = false;
  5818. lic.ChannelSettings.IsPlaying = true;
  5819. EpisodeFcy.getChannelNewestEpisodes(ChannelId,lic.ChannelNewestEpisodes.Offset,lic.ChannelNewestEpisodes.Limit).then(function(result){
  5820. lic.ChannelNewestEpisodes.Page++;
  5821. if(lic.ChannelNewestEpisodes.Page==1){
  5822. TwoRowsCarousel.CarouselInit("ThisChannelsLatest");
  5823. }
  5824.  
  5825. $timeout(function () {
  5826. $("#ThisChannelsLatest").find("img.lazyload").lazyload({
  5827. threshold : 150,
  5828. effect : "fadeIn",
  5829. });
  5830. replaceBigThumbs.replace();
  5831. },200);
  5832. window.LiveChannelLatestEpisodes=result.length;
  5833. window.LiveChannelLatestEpisodesTotal+=parseInt(window.LiveChannelLatestEpisodes);
  5834. var tempArray=[];
  5835. var tempArray2=[];
  5836. tempArray.push(result);
  5837. tempArray2.push(lic.ChannelNewestEpisodes.Episodes);
  5838. lic.ChannelNewestEpisodes.Episodes = tempArray2[0].concat(tempArray[0]);
  5839. tempArray.length = 0;
  5840. tempArray2.length = 0;
  5841. lic.ChannelNewestEpisodes.UpdateInProgress = false;
  5842. ProgressBarFcy.setDone();
  5843. })
  5844. ProgressBarFcy.plus(0.2);
  5845. });
  5846. });
  5847. });
  5848. lic.getChannelHourlyArchiveEpisodes = function(Date,Channel){
  5849. EpisodeFcy.getHourlyArchiveByChannel(Date,Channel).then(function(reuslt){
  5850. lic.ChannelHourlyArchiveEpisodes.Page++;
  5851. window.LiveChannelHourlyArchive=reuslt.length;
  5852. window.LiveChannelHourlyArchiveTotal=parseInt(window.LiveChannelHourlyArchive);
  5853. if(lic.ChannelHourlyArchiveEpisodes.Page>=1){
  5854. TwoRowsCarousel.CarouselInit("HourlyArchive");
  5855. }
  5856. lic.ChannelHourlyArchiveEpisodes.Episodes=reuslt;
  5857. });
  5858. };
  5859. lic.flagForInitHourlyArchive = false;
  5860. lic.timeoutDetectionForHourlyArchive = '';
  5861. $scope.$watch('updateHourlyArchive', function() {
  5862. if(lic.flagForInitHourlyArchive){
  5863. if(lic.timeoutDetectionForHourlyArchive)
  5864. $timeout.cancel(lic.timeoutDetectionForHourlyArchive);
  5865. lic.timeoutDetectionForHourlyArchive = $timeout(function(){
  5866. lic.ChannelNewestEpisodes.UpdateInProgress = true;
  5867. $timeout(function(){lic.ChannelNewestEpisodes.UpdateInProgress = false},3000);
  5868. lic.timeoutDetectionForHourlyArchive = $timeout(function(){
  5869. if(window.innerWidth > 1200){
  5870. DestroySlick.destroy("#HourlyArchive .slick-carousel-apply");
  5871. }
  5872. $timeout(function(){TwoRowsCarousel.CarouselInit("HourlyArchive")},1500);
  5873. lic.getChannelHourlyArchiveEpisodes($scope.updateHourlyArchive, document.getElementById('HourlyArchiveSelect').getAttribute('data-channelId'));
  5874. },1000);
  5875. },1000);
  5876.  
  5877. }
  5878. lic.flagForInitHourlyArchive = true;
  5879. }, true);
  5880. lic.LoadThePlayerWithHourlyArchive = function(link){
  5881. if(DeviceDetection.IsAndroid() || DeviceDetection.IsSmartTv() || DeviceDetection.IsIos() || DeviceDetection.IsIpad()){
  5882. jQuery("#MobileLiveQuality").hide();
  5883. /*Player.Pause("MobileLivePlayer","VideoJs",true);*/
  5884. var LivePlayer = document.getElementById("MobilePlayer_html5_api");
  5885. LivePlayer.src = link;
  5886. LivePlayer.src=link;
  5887. LivePlayer.load();
  5888. LivePlayer.play();
  5889. /*var source = document.createElement('source');
  5890. source.setAttribute('src', link);
  5891. source.setAttribute('type', 'video/mp4');
  5892. LivePlayer.appendChild(source);
  5893. LivePlayer.play();*/
  5894. }
  5895. else {
  5896. window.playerInstance.stop();
  5897. jQuery("#liveQualityBar").hide();
  5898. var flashvars = {
  5899. src: escape(link),
  5900. scaleMode: "stretch",
  5901. javascriptCallbackFunction: "onJSBridge"
  5902. };
  5903. var params = {
  5904. allowFullScreen: true, allowScriptAccess: "always", bgcolor: "#000000", wmode: 'opaque'
  5905. };
  5906. var attrs = {
  5907. name: "Player"
  5908. };
  5909. swfobject.embedSWF(Configs.Player.Vod.OsfmSWFPath, Configs.Player.Vod.PlayerPlaceId, Configs.Player.Vod.PlayerWidth, Configs.Player.Vod.PlayerHeight, "10.2", null, flashvars, params, attrs);
  5910. /*setTimeout(function(){
  5911. window.LivePlayerInstance.play();
  5912. },1000);*/
  5913. }
  5914. }
  5915. $scope.$watch("lic.ChannelSettings.UpdateInProgress",function(){
  5916. if(lic.ChannelSettings.UpdateInProgress==false){
  5917. var MiladiDate = new Date();
  5918. var ShamsiDate = new JDate(MiladiDate);
  5919. ShamsiDate=ShamsiDate.toLocaleString().split(" ")[0].replace("/",'-').replace("/",'-');
  5920. lic.getChannelHourlyArchiveEpisodes(ShamsiDate,lic.ChannelOriginalId);
  5921. }
  5922. });
  5923. }
  5924. function EpisodeCtrl(GeneralInit,$rootScope,EpisodeSrv,Messages,$routeParams,SiteConstants,SecurityFcy,ProgressBarFcy,EpisodeFcy,ProgramFcy,$filter,$scope,deviceDetector,ChannelFcy,FavoriteListSrv,$timeout,Configs){
  5925. var epc= this;
  5926. if(userAgent.isTelegram()){
  5927. window.location = "http://www.telewebion.com/?_escaped_fragment_=/episode/"+$routeParams.Id;
  5928. }
  5929. $(".position-fix-carousel").scroll(function () {
  5930. $(document).scroll()
  5931. })
  5932. $(document).on("click",".slick-next,.slick-prev",function () {
  5933. $(document).scroll()
  5934. setTimeout(function () {
  5935. $(document).scroll()
  5936. },600)
  5937. })
  5938. TopCarousel.initCarousel();
  5939. epc.waitUntilEpisodeDataLoaded = false;
  5940. window.EpisodeEpisodeOurRecommendationsTotal=0;
  5941. window.EpisodeOtherProgramEpisodesTotal=0;
  5942. epc.device=deviceDetector.device;
  5943. epc.HasAdminAccess = false;
  5944. epc.EpisodeFavoriteLists = null;
  5945. epc.OurRecommendationData={Offset:0,Limit:19,UpdateInProgress:true,Episodes:[],Page:0};
  5946. epc.ProgramOtherEpisodes={Offset:0,Limit:19,UpdateInProgress:true,Episodes:[],Page:0};
  5947. epc.EpisodeMoments={Offset:0,Limit:50,UpdateInProgress:true,Episodes:[],Page:0};
  5948. epc.EpisodeSettings = {UpdateInProgress:true,Valid:true};
  5949. epc.ProgramOtherEpisodes.Episodes=[];
  5950. $timeout(function () {
  5951.  
  5952. $(".carousel-image-container img").each(function () {
  5953. $(this).error(function () {
  5954. if(!$(this).attr("data-replaced"))
  5955. replacePipelineAddress.replace($(this));
  5956. })
  5957. })
  5958. },600);
  5959.  
  5960. epc.getOtherProgramEpisodes=function(){
  5961. ProgramFcy.getOtherEpisodesOfThisProgram(epc.ProgramOtherEpisodes.Offset,epc.ProgramOtherEpisodes.Limit,epc.Episode.program_id).then(function(OtherProgramEpisodes){
  5962. epc.ProgramOtherEpisodes.Page++;
  5963. //loaded("EpisodeProgramOtherEpisodes");
  5964. if(epc.ProgramOtherEpisodes.Page==1) {
  5965. TwoRowsCarousel.CarouselInit("EpisodeOtherEpisodes");
  5966. }
  5967.  
  5968. $timeout(function () {
  5969. $("#EpisodeOtherEpisodes").find("img.lazyload").lazyload({
  5970. threshold : 150,
  5971. effect : "fadeIn",
  5972. });
  5973. replaceBigThumbs.replace();
  5974. },200);
  5975. var tempArray=[];
  5976. var tempArray2=[];
  5977. tempArray.push(OtherProgramEpisodes);
  5978. tempArray2.push(epc.ProgramOtherEpisodes.Episodes);
  5979. window.EpisodeOtherProgramEpisodes=OtherProgramEpisodes.length;
  5980. window.EpisodeOtherProgramEpisodesTotal+=parseInt(window.EpisodeOtherProgramEpisodes);
  5981. epc.ProgramOtherEpisodes.Episodes = tempArray2[0].concat(tempArray[0]);
  5982. tempArray.length = 0;
  5983. tempArray2.length = 0;
  5984. epc.ProgramOtherEpisodes.UpdateInProgress=false;
  5985. });
  5986. }
  5987.  
  5988. epc.ShowPlayer = function() {
  5989. jQuery("#PlayThePlayer").hide();
  5990. jQuery("#Player").show();
  5991. jQuery('#videoHolder').hide();
  5992. window.activePlayer = "MobileVodPlayer";
  5993. window.activePlayerToolbarPlay='MobileVodPlayerToolbarPlayPause';
  5994. window.playerType = 'VideoJs';
  5995. if((DeviceDetection.IsAndroid() || DeviceDetection.IsIos() || DeviceDetection.IsSmartTv()) && !DeviceDetection.IsIpad()){
  5996. /*Player.Play(null,null,true);*/
  5997.  
  5998. // window.Play(0,true);
  5999. }
  6000. }
  6001. window.EpisodeId = $routeParams.Id;
  6002. epc.showNotAllowedToDownload= function(){
  6003. NgNote.Error(Messages.Fa.NotAllowedToDownload,3);
  6004. }
  6005. epc.getEpisodeMoments = function(){
  6006. EpisodeFcy.getEpisodeMoments($routeParams.Id).then(function(result){
  6007. epc.EpisodeMoments.Episodes=result;
  6008. if(result.length>0){
  6009. if((DeviceDetection.IsAndroid() || DeviceDetection.IsIos() || DeviceDetection.IsSmartTv()) || DeviceDetection.IsIpad()){
  6010. var player = document.getElementById("MobilePlayer");
  6011. player.addEventListener("play", function(){$("#EpisodeMomentsHolder").show();}, false);
  6012. }
  6013. }
  6014. });
  6015. }
  6016. epc.User=GeneralInit.User;
  6017. $rootScope.User=GeneralInit.User;
  6018. epc.CheckIfHasEditPermission = function () {
  6019. SecurityFcy.userHasPermission(['admin','superadmin','operator']).then(function (result) {
  6020. epc.HasAdminAccess = result;
  6021. })
  6022. }
  6023. $rootScope.PlayerPath=GeneralInit.PlayerPath;
  6024. $rootScope.PlayerLicenceKey=GeneralInit.PlayerLicenceKey;
  6025. $rootScope.$broadcast("UserData");
  6026. ProgressBarFcy.plus(0.2);
  6027. $scope.showDate = '';
  6028. $scope.showHour = '';
  6029. SecurityFcy.getUserToken().then(function(userToken){
  6030. SecurityFcy.getToken().then(function(token){
  6031. EpisodeSrv.getEpisode($routeParams.Id,token,userToken).then(function(result){
  6032. epc.Episode=result;
  6033. if(result.program_types[0]+"" == "undefined"){
  6034. catId = 13;
  6035. }else{
  6036. catId = result.program_types[0].id;
  6037. }
  6038. EpisodeFcy.getEpisodesByCategoryId(epc.OurRecommendationData.Offset,epc.OurRecommendationData.Limit,catId).then(function(OurRecommendations){
  6039. epc.OurRecommendationData.Page++;
  6040. //loaded("EpisodeOurRecommendations");
  6041. if(epc.OurRecommendationData.Page==1){
  6042. TwoRowsCarousel.CarouselInit("EpisodeOurRecommendations");
  6043. }
  6044. $timeout(function () {
  6045. $("#EpisodeOurRecommendations").find("img.lazyload").lazyload({
  6046. threshold : 150,
  6047. effect : "fadeIn",
  6048. });
  6049. replaceBigThumbs.replace();
  6050. },200);
  6051. var tempArray=[];
  6052. var tempArray2=[];
  6053. tempArray.push(OurRecommendations.data);
  6054. tempArray2.push(epc.OurRecommendationData.Episodes);
  6055. window.EpisodeEpisodeOurRecommendations=OurRecommendations.data.length;
  6056. window.EpisodeEpisodeOurRecommendationsTotal+=parseInt(window.EpisodeEpisodeOurRecommendations);
  6057. epc.OurRecommendationData.Episodes = tempArray2[0].concat(tempArray[0]);
  6058. tempArray.length = 0;
  6059. tempArray2.length = 0;
  6060. epc.OurRecommendationData.UpdateInProgress=false;
  6061. });
  6062. /*loadingControl.hideLoading();*/
  6063. bigPlayButton.hideButton();
  6064. epc.tags = [];
  6065. if(result.tags+"" != 'null') {
  6066. epc.tags = result.tags.split(",");
  6067. }else{
  6068. epc.tags = null;
  6069. }
  6070.  
  6071. epc.waitUntilEpisodeDataLoaded = true;
  6072. setTimeout(function () {
  6073. $("#more-info-program").slideUp();
  6074. $("#more-info-icon").find("i").eq(1).removeClass("fa-minus color-red-important").addClass("fa-plus");
  6075. },6000);
  6076. $(".episode-image img").each(function () {
  6077.  
  6078. $(this).error(function () {
  6079. if(!$(this).attr("data-replaced"))
  6080. replacePipelineAddress.replace($(this));
  6081. })
  6082. })
  6083. $timeout(function () {
  6084. if(parseInt($(".summary-episode").height()) > 350){
  6085. $(".read-more-description").addClass("inline-block-important");
  6086. $(".summary-episode").addClass("height-320");
  6087. $(document).on("click",".read-more-description",function () {
  6088. if($(".summary-episode").hasClass("height-320")){
  6089. $(".read-more-description").html("<i class='fa fa-angle-up'></i> کمتر");
  6090. $(".summary-episode").removeClass("height-320");
  6091. }else{
  6092. $(".read-more-description").html("<i class='fa fa-angle-down'></i> بیشتر");
  6093. $(".summary-episode").addClass("height-320");
  6094. }
  6095. })
  6096. }
  6097. },200);
  6098. var showTime = epc.Episode.show_time.toString();
  6099. var showTimeArray = showTime.split(" ");
  6100. var dateFormat = showTimeArray[0].toString().replace("-","/");
  6101. var dateFormat2 = dateFormat.replace("-","/");
  6102. $scope.showDate = dateFormat2;
  6103. if(showTimeArray[1] != null) {
  6104. $scope.showHour = showTimeArray[1].toString();
  6105. }else{
  6106. $scope.showHour = 17+"";
  6107. }
  6108. if(!$rootScope.UserStatus.IsAuthenticated){
  6109. epc.Episode.download_link=[];
  6110. }
  6111. window.EpisodeId=epc.Episode.id;
  6112. $rootScope.Page.Description=(epc.Episode.program.is_singleton)?'':epc.Episode.program.title+epc.Episode.title;
  6113. $rootScope.Page.Keywords=(epc.Episode.program.is_singleton)?'':epc.Episode.program.title+epc.Episode.title;
  6114. $rootScope.$broadcast("UserData");
  6115. var listOfChannels = ChannelFcy.getChannelDescriptorList();
  6116. var idOfChannel = epc.Episode.program.channel_id;
  6117. var counter =0;
  6118. for(var i=0; i<listOfChannels.length; i++){
  6119. var channelDescriptor = listOfChannels[i]+"";
  6120. ChannelFcy.getChannelNameFromDescriptor(channelDescriptor).then(function (result) {
  6121. if(result == idOfChannel){
  6122. epc.Episode.program.channel_descriptor = listOfChannels[counter];
  6123. }
  6124. counter++;
  6125. });
  6126.  
  6127. }
  6128. epc.Episode.view_count=$rootScope.ConvertToPersianNumber($filter('number')(epc.Episode.view_count));
  6129. epc.Episode.title=$rootScope.ConvertToPersianNumber(epc.Episode.title);
  6130. epc.Episode.program.title=$rootScope.ConvertToPersianNumber(epc.Episode.program.title);
  6131. epc.Episode.show_time=$rootScope.ConvertToPersianNumber(epc.Episode.show_time);
  6132. epc.Episode.program.channel_id=$rootScope.ConvertToPersianNumber($rootScope.ChannelIdToName(epc.Episode.program.channel_id));
  6133. epc.EpisodeSettings.UpdateInProgress = false;
  6134. epc.Episode.UpdateInProgress = false;
  6135. if(epc.Episode.file_path=='' || epc.Episode.file_path=='undefined' || epc.Episode.file_path==null){
  6136. epc.EpisodeSettings.Valid=false;
  6137. }
  6138. ProgressBarFcy.setDone();
  6139. epc.EpisodeSettings.UpdateInProgress = false;
  6140. $rootScope.Page.Title = epc.Episode.program.is_singleton?epc.Episode.program.title:epc.Episode.program.title+'-'+epc.Episode.title;
  6141. if(epc.device == 'android' || epc.device == 'iphone'){
  6142. }else{
  6143. epc.ShowPlayer();
  6144. }
  6145. setTimeout(function () {
  6146. var tags = result.tags;
  6147. var rawKeywords = result.keywords_english;
  6148. var commaKeywords = result.tags;
  6149. if((rawKeywords+"").length>11){
  6150. commaKeywords = rawKeywords.split("#").join();
  6151. }
  6152. var keywords = commaKeywords+","+tags;
  6153. if(result.page_description != null)
  6154. $rootScope.Page.Description=result.page_description+" , "+result.title;
  6155. else
  6156. $rootScope.Page.Description=result.title;
  6157. $rootScope.Page.Keywords=keywords;
  6158.  
  6159. },100);
  6160. $timeout(function () {
  6161. if((DeviceDetection.IsAndroid() || DeviceDetection.IsIos() || DeviceDetection.IsSmartTv()) && !DeviceDetection.IsIpad()) {
  6162. epc.ShowPlayer();
  6163. }
  6164. },1000)
  6165. })
  6166. });
  6167. });
  6168. $scope.$watch("epc.EpisodeSettings.UpdateInProgress",function(){
  6169. if(epc.EpisodeSettings.UpdateInProgress==false && epc.Episode!=='undefined' && epc.Episode.program!=null && epc.Episode.program.is_singleton==0){
  6170. epc.getOtherProgramEpisodes();
  6171. epc.getEpisodeMoments();
  6172. epc.getEpisodeFavoriteLists();
  6173. }
  6174. });
  6175. epc.getNext=function(type){
  6176. if(type=='OurRecommendation'){
  6177. epc.OurRecommendationData.Limit=((epc.OurRecommendationData.Page+1)==1)?50:50;
  6178. epc.OurRecommendationData.Offset=((epc.OurRecommendationData.Page+1)==1)?0:((epc.OurRecommendationData.Page+1)*50)+50;
  6179. epc.OurRecommendationData.UpdateInProgress=true;
  6180. epc.getOurRecommendations();
  6181. }
  6182. else if(type=='OtherProgramEpisode'){
  6183. epc.ProgramOtherEpisodes.Limit=((epc.ProgramOtherEpisodes.Page+1)==1)?50:50;
  6184. epc.ProgramOtherEpisodes.Offset=((epc.ProgramOtherEpisodes.Page+1)==1)?0:((epc.ProgramOtherEpisodes.Page+1)*50)+50;
  6185. epc.ProgramOtherEpisodes.UpdateInProgress=true;
  6186. epc.getOtherProgramEpisodes();
  6187. }
  6188. }
  6189. window.getNextEpisode=epc.getNext;
  6190. epc.getPosterImage = function(program,size){
  6191. switch (program){
  6192. case 42911:
  6193. return "/images/poster/"+size+"_25637.jpg";
  6194. break;
  6195. case 449973:
  6196. return "/images/poster/"+size+"_25637.jpg";
  6197. break;
  6198. case 45958:
  6199. return "/images/poster/"+size+"_45655.jpg";
  6200. break;
  6201. case 45954:
  6202. case 47451:
  6203. result.program_types.id
  6204. case 46676:
  6205. case 43028:
  6206. case 44997:
  6207. case 25637:
  6208. case 39893:
  6209. case 44162:
  6210. case 45655:
  6211. case 3959:
  6212. case 37728:
  6213. case 5709:
  6214. return "/images/poster/"+size+"_"+program+".jpg";
  6215. break;
  6216. default:
  6217. return "/media/img/poster.jpg";
  6218. break
  6219. }
  6220. }
  6221. epc.GenerateDownloadLink=function(){
  6222. window.location.href="http://downloadproxy.telewebion.com/download?cdn=1&amp;episode_id="+$scope.Episode.id+"&amp;token="+$scope.User.sdt;
  6223. }
  6224. epc.JumpToSecond = function(second){
  6225. if(DeviceDetection.IsAndroid() || DeviceDetection.IsIos() || DeviceDetection.IsSmartTv() || DeviceDetection.IsIpad()){
  6226. var playerz = document.getElementById("MobilePlayer_html5_api");
  6227. setTimeout(function(){playerz.currentTime = second;},200);
  6228. }else{
  6229. if(Configs.Player.Vod.DefaultPlayer=="RadiantPlayer"){
  6230. window.playerInstance.seekTo(second*1000);
  6231. }
  6232. else if(Configs.Player.Vod.DefaultPlayer=="OsmfPlayer") {
  6233. var player = document.getElementById("ply");
  6234. player.seek(second);
  6235. }
  6236. }
  6237. }
  6238. epc.getEpisodeFavoriteLists = function () {
  6239. FavoriteListSrv.getFavoriteListByEpisode($routeParams.Id).then(function (result) {
  6240. var spliceList = [];
  6241. var index = 0;
  6242. result.forEach(function (item) {
  6243.  
  6244. var remove = true;
  6245.  
  6246. for (var i = item.length-1;i>0;i--){
  6247. if(item[i].parent != result[index][i].parent){
  6248. remove = false;
  6249. }
  6250. }
  6251. index++;
  6252. if(remove){
  6253. if(index != 1) {
  6254. spliceList.push(index-1);
  6255. }
  6256. }
  6257.  
  6258. })
  6259. if(spliceList.length > 0) {
  6260.  
  6261. for(var j = 0; j<spliceList.length;j++) {
  6262. var size = result.length;
  6263. result[spliceList[j]-1]=null;
  6264. }
  6265. }
  6266. for(var k = 0;k<result.length;k++){
  6267. result.splice(result.indexOf(null),result.indexOf(null)+1);
  6268. }
  6269. epc.EpisodeFavoriteLists = result;
  6270. })
  6271. }
  6272.  
  6273.  
  6274. setTimeout(function () {
  6275.  
  6276. epc.CheckIfHasEditPermission();
  6277. },1000);
  6278. }
  6279. function ProgramCtrl(GeneralInit,$rootScope,ProgramSrv,Messages,$routeParams,SiteConstants,SecurityFcy,ProgressBarFcy,ProgramFcy,$scope,ChannelFcy,$timeout){
  6280. var pgc= this;
  6281. TopCarousel.initCarousel();
  6282.  
  6283. $(".position-fix-carousel").scroll(function () {
  6284. $(document).scroll()
  6285. })
  6286. $(document).on("click",".slick-next,.slick-prev",function () {
  6287. $(document).scroll()
  6288. setTimeout(function () {
  6289. $(document).scroll()
  6290. },600)
  6291. })
  6292. pgc.HasAdminAccess = false;
  6293. pgc.waitUntilEpisodeDataLoaded = false;
  6294.  
  6295. pgc.CheckIfHasEditPermission = function () {
  6296. SecurityFcy.userHasPermission(['admin','superadmin','operator']).then(function (result) {
  6297. pgc.HasAdminAccess = result;
  6298. })
  6299. };
  6300.  
  6301. window.ProgramOtherProgramEpisodesTotal=0;
  6302.  
  6303. /*pgc.Program={};*/
  6304. /*pgc.OurRecommendationData={Offset:0,Limit:50,UpdateInProgress:true,Episodes:[],Page:0};*/
  6305. pgc.ProgramOtherEpisodes={Offset:0,Limit:50,UpdateInProgress:true,Episodes:[],Page:0};
  6306. pgc.ProgramSettings = {UpdateInProgress:true,Valid:true};
  6307. /*pgc.getOurRecommendations=function(){
  6308. EpisodeFcy.getOurRecommendations(pgc.OurRecommendationData.Offset,pgc.OurRecommendationData.Limit).then(function(OurRecommendations){
  6309. pgc.OurRecommendationData.Page++;
  6310. var tempArray=[];
  6311. var tempArray2=[];
  6312. tempArray.push(OurRecommendations);
  6313. tempArray2.push(pgc.OurRecommendationData.Episodes);
  6314. pgc.OurRecommendationData.Episodes = tempArray2[0].concat(tempArray[0]);
  6315. tempArray.length = 0;
  6316. tempArray2.length = 0;
  6317. pgc.OurRecommendationData.UpdateInProgress=false;
  6318. });
  6319. }*/
  6320. var flagForTryOnce = true;
  6321. $(".replace-on-error").error(function () {
  6322. if(flagForTryOnce) {
  6323. setTimeout(function () {
  6324. $(".replace-on-error").attr("src", pgc.ProgramOtherEpisodes.Episodes[0].picture_path);
  6325. flagForTryOnce = false;
  6326. },500)
  6327. }
  6328. })
  6329. pgc.getOtherProgramEpisodes=function(){
  6330. ProgramFcy.getOtherEpisodesOfThisProgram(pgc.ProgramOtherEpisodes.Offset,pgc.ProgramOtherEpisodes.Limit,$routeParams.Id).then(function(OtherProgramEpisodes){
  6331. /*loaded("ProgramEpisodes");*/
  6332. pgc.ProgramOtherEpisodes.Page++;
  6333. window.ProgramOtherProgramEpisodes=OtherProgramEpisodes.length;
  6334. window.ProgramOtherProgramEpisodesTotal+=parseInt(window.ProgramOtherProgramEpisodes);
  6335. if(pgc.ProgramOtherEpisodes.Page==1){
  6336. TwoRowsCarousel.CarouselInit("ProgramOtherEpisodes");
  6337. }
  6338.  
  6339. $timeout(function () {
  6340. $("#ProgramOtherEpisodes").find("img.lazyload").lazyload({
  6341. threshold : 150,
  6342. effect : "fadeIn"
  6343. });
  6344.  
  6345. },200);
  6346. $timeout(function () {
  6347. replaceBigThumbs.replace();
  6348. },800)
  6349. var tempArray=[];
  6350. var tempArray2=[];
  6351. tempArray.push(OtherProgramEpisodes);
  6352. tempArray2.push(pgc.ProgramOtherEpisodes.Episodes);
  6353. pgc.ProgramOtherEpisodes.Episodes = tempArray2[0].concat(tempArray[0]);
  6354.  
  6355. tempArray.length = 0;
  6356. tempArray2.length = 0;
  6357. pgc.ProgramOtherEpisodes.UpdateInProgress=false;
  6358. });
  6359. }
  6360. pgc.User=GeneralInit.User;
  6361. $rootScope.User=GeneralInit.User;
  6362. $rootScope.$broadcast("UserData");
  6363. ProgressBarFcy.plus(0.2);
  6364.  
  6365. ProgramSrv.getProgram($routeParams.Id).then(function(result){
  6366.  
  6367. if(result.is_singleton){
  6368. debuger.info("Program was singleton and was redirected to its episode page");
  6369. window.location.assign("/#!/fa/episode/"+result.singleton_episode_id);
  6370. }
  6371. pgc.waitUntilEpisodeDataLoaded = true;
  6372. setTimeout(function () {
  6373. $("#more-info-program").slideUp();
  6374. $("#more-info-icon-program > i:last-of-type").removeClass("fa-minus color-red-important").addClass("fa-plus");
  6375. },6000);
  6376.  
  6377.  
  6378.  
  6379. pgc.Program = result;
  6380. $rootScope.Page.Description=pgc.Program.title;
  6381. $rootScope.Page.Keywords=pgc.Program.title;
  6382. $rootScope.$broadcast("UserData");
  6383. ProgressBarFcy.setDone();
  6384. $rootScope.Page.Title=pgc.Program.title;
  6385. pgc.ProgramSettings.UpdateInProgress=false;
  6386. pgc.tags = [];
  6387. if(result.tags+"" != 'null') {
  6388. pgc.tags = result.tags.split(",");
  6389. }else{
  6390. pgc.tags = null;
  6391. }
  6392.  
  6393. setTimeout(function () {
  6394. var tags = result.tags;
  6395. var rawKeywords = result.keywords_english;
  6396. var commaKeywords = result.tags;
  6397. if((rawKeywords+"").length>11){
  6398. commaKeywords = rawKeywords.split("#").join();
  6399. }
  6400. var keywords = commaKeywords+","+tags;
  6401. if(result.page_description != null)
  6402. $rootScope.Page.Description=result.page_description+" , "+result.title;
  6403. else
  6404. $rootScope.Page.Description=result.title;
  6405. $rootScope.Page.Keywords=keywords;
  6406. },100);
  6407. });
  6408. $scope.$watch("pgc.ProgramSettings.UpdateInProgress",function(){
  6409. if(pgc.ProgramSettings.UpdateInProgress==false){
  6410. pgc.getOtherProgramEpisodes();
  6411. }
  6412. });
  6413. pgc.ChannelIdToName = function(id){
  6414. switch (id){
  6415. case 1:
  6416. return "شبکه 1";
  6417. break;
  6418. case 2:
  6419. return "شبکه 2";
  6420. break;
  6421. case 45:
  6422. return "شبکه امید";
  6423. break;
  6424.  
  6425. case 3:
  6426. return "شبکه 3";
  6427. break;
  6428. case 4:
  6429. return "شبکه 4";
  6430. break;
  6431. case 5:
  6432. return "شبکه 5";
  6433. break;
  6434. case 6:
  6435. return "شبکه خبر";
  6436. break;
  6437. case 7:
  6438. return "شبکه آموزش";
  6439. break;
  6440. case 8:
  6441. return "شبکه پویا";
  6442. break;
  6443. case 9:
  6444. return "شبکه IFilm";
  6445. break;
  6446. case 10:
  6447. return "شبکه نمایش";
  6448. break;
  6449. case 11:
  6450. return "شبکه تماشا";
  6451. break;
  6452. case 12:
  6453. return "شبکه جام جم 1";
  6454. break;
  6455. case 13:
  6456. return "شبکه ورزش";
  6457. break;
  6458. case 18:
  6459. return "پرشین تونز";
  6460. break;
  6461. case 19:
  6462. return "شبکه مستند سیما";
  6463. break;
  6464. case 20:
  6465. return "شبکه قرآن";
  6466. break;
  6467. case 21:
  6468. return "شبکه سلامت";
  6469. break;
  6470. case 22:
  6471. return "شبکه جام جم 2";
  6472. break;
  6473. case 23:
  6474. return "شبکه جام جم 3";
  6475. break;
  6476. case 24:
  6477. return "شبکه شما";
  6478. break;
  6479. case 25:
  6480. return "شبکه بازار";
  6481. break;
  6482. case 29:
  6483. return "IFilm English";
  6484. break;
  6485. case 30:
  6486. return "شبکه اصفهان";
  6487. break;
  6488. case 31:
  6489. return "شبکه سهند";
  6490. break;
  6491. case 32:
  6492. return "شبکه فارس";
  6493. break;
  6494. case 33:
  6495. return "شبکه خوزستان";
  6496. break;
  6497. case 34:
  6498. return "شبکه باران";
  6499. break;
  6500. case 35:
  6501. return "سینمای خانگی";
  6502. break;
  6503. case 36:
  6504. return "شبکه سمنان";
  6505. break;
  6506. case 37:
  6507. return "شبکه آفتاب";
  6508. break;
  6509. case 38:
  6510. return "شبکه افلاک";
  6511. break;
  6512. case 39:
  6513. return "شبکه کردستان";
  6514. break;
  6515. case 40:
  6516. return "شبکه خلیج فارس";
  6517. break;
  6518. case 41:
  6519. return "شبکه نسیم";
  6520. break;
  6521. case 42:
  6522. return "شبکه افق";
  6523. break;
  6524. case 43:
  6525. return "شبکه HD";
  6526. break;
  6527.  
  6528.  
  6529. }
  6530. }
  6531. pgc.CheckIfHasEditPermission();
  6532. pgc.getGeneralPosterImage = function(category,size){
  6533. switch (category){
  6534. case 8:
  6535. case 9:
  6536. case 10:
  6537. case 11:
  6538. case 18:
  6539. case 17:
  6540. return "/images/category/"+size+'_movies.jpg';
  6541. break;
  6542. case 7:
  6543. case 13:
  6544. case 16:
  6545. case 21:
  6546. case 20:
  6547. case 19:
  6548. case 15:
  6549. return "/images/category/"+size+'_news.jpg';
  6550. break;
  6551. case 12:
  6552. return "/images/category/"+size+'_cartoon.jpg';
  6553. break;
  6554. case 14:
  6555. return "/images/category/"+size+'_sport.jpg';
  6556. break;
  6557. }
  6558. }
  6559. window.counterImagePoster = 1;
  6560. pgc.getPosterImage = function(program,size,category) {
  6561. var countLimit = 6;
  6562. if (!isNaN(program) && parseInt(countLimit) > window.counterImagePoster) {
  6563. window.counterImagePoster+=1;
  6564. switch (program) {
  6565. case 42911:
  6566. case 25637:
  6567. return "/images/poster/" + size + "_25637.jpg";
  6568. break;
  6569. case 47451:
  6570. return "/images/poster/" + size + "_47451.jpg";
  6571. break;
  6572. case 44997:
  6573. return "/images/poster/" + size + "_44997.jpg";
  6574. break;
  6575. case 45958:
  6576. return "/images/poster/" + size + "_45655.jpg";
  6577. break;
  6578. case 46676:
  6579. return "/images/poster/" + size + "_"+program+".jpg";
  6580. break;
  6581. case 37728:
  6582. return "/images/poster/" + size + "_"+program+".jpg";
  6583. break;
  6584. case 44162:
  6585. case 43194:
  6586. return "/images/poster/" + size + "_" + '44162' + ".jpg";
  6587. break;
  6588. default:
  6589. if(pgc.getGeneralPosterImage(category,size)) {
  6590. return pgc.getGeneralPosterImage(category, size);
  6591. }else{
  6592. setTimeout(function(){
  6593. return pgc.getGeneralPosterImage(category, size);
  6594. },500)
  6595. }
  6596. break;
  6597. }
  6598. }
  6599. }
  6600. }
  6601. function RegisterCtrl(GeneralInit,UserSrv,Messages,$rootScope,SiteConstants,ProgressBarFcy){
  6602. var urg= this;
  6603. urg.User={};//GeneralInit.User;
  6604. $rootScope.Page.Title=(GeneralInit.Culture=="fa")?SiteConstants.Fa.PageTitle.Register:SiteConstants.En.PageTitle.Register;
  6605. $rootScope.$broadcast("UserData");
  6606. ProgressBarFcy.setDone();
  6607. urg.Registration={Status:"NoAction"};
  6608. urg.Login={Status:"NoAction"};
  6609. urg.phoneNumberStatus = false;
  6610. urg.Register=function(){
  6611. urg.Registration.Status="InProgress";
  6612.  
  6613. UserSrv.registerUser(urg.User).then(function (result) {
  6614. if (result.state == 1) {
  6615. urg.Registration.Status = "NoAction";
  6616. urg.Registration.ErrorMessage = Messages.Fa.DuplicatedEmailRegistration;
  6617. }
  6618. else if (result.state == 2) {
  6619. urg.Registration.Status = "SuccessfulAction";
  6620. urg.Registration.ErrorMessage = Messages.Fa.SuccessfulRegistration;
  6621. urg.User = {};
  6622. }
  6623. else if (result.state == 3) {
  6624. urg.Registration.Status = "SuccessfulAction";
  6625. urg.Registration.ErrorMessage = Messages.Fa.SuccessfulRegistration;
  6626. urg.User = {};
  6627. }
  6628. else if (result.state == 0) {
  6629. urg.Registration.Status = "NoAction";
  6630. urg.Registration.ErrorMessage = Messages.Fa.FailedRegistration;
  6631. }
  6632. else if (result.state == -1) {
  6633. urg.Registration.Status = "NoAction";
  6634. urg.Registration.ErrorMessage = Messages.Fa.FailedRegistration;
  6635. }
  6636. urg.phoneNumberStatus = false;
  6637. });
  6638. }
  6639. urg.DoLogin=function(){
  6640. urg.Login.Status="InProgress";
  6641. UserSrv.loginUser(urg.User).then(function(result){
  6642. if(result && typeof result=='object')
  6643. {
  6644. urg.Login.Status="SuccessfulAction";
  6645. $window.location.replace("/#!/");
  6646. urg.Login.ErrorMessage=Messages.Fa.SuccessfulLogin;
  6647. }
  6648. else
  6649. {
  6650. urg.Login.Status="NoAction";
  6651. urg.Login.ErrorMessage=Messages.Fa.FailedLogin;
  6652. }
  6653. });
  6654. }
  6655. }
  6656. function SearchCtrl(GeneralInit,$routeParams,SearchFcy,$rootScope,SiteConstants,ProgressBarFcy){
  6657. var src= this;
  6658. src.Context=$routeParams.SearchContext;
  6659. src.SearchEpisodes={Offset:0,Limit:50,UpdateInProgress:true,Episodes:[],Page:0};
  6660. src.SearchPrograms={Offset:0,Limit:10,UpdateInProgress:true,Page:0,Programs:[]};
  6661. $rootScope.Page.SearchContext='';
  6662. src.getSearchResult = function(JustEpisodes){
  6663. if(!JustEpisodes){
  6664. SearchFcy.getPrograms(src.Context,src.SearchPrograms.Offset,src.SearchPrograms.Limit).then(function(result){
  6665. src.SearchPrograms.Page++;
  6666. var tempArray=[];
  6667. var tempArray2=[];
  6668. tempArray.push(result);
  6669. tempArray2.push(src.SearchPrograms.Programs);
  6670. src.SearchPrograms.Programs = tempArray2[0].concat(tempArray[0]);
  6671. tempArray.length = 0;
  6672. tempArray2.length = 0;
  6673. src.SearchPrograms.UpdateInProgress=false;
  6674. ProgressBarFcy.plus(0.2);
  6675. });
  6676. }
  6677. SearchFcy.getEpisodes(src.Context,src.SearchEpisodes.Offset,src.SearchEpisodes.Limit).then(function(result){
  6678. src.SearchEpisodes.Page++;
  6679. var tempArray=[];
  6680. var tempArray2=[];
  6681. tempArray.push(result);
  6682. tempArray2.push(src.SearchEpisodes.Episodes);
  6683. src.SearchEpisodes.Episodes = tempArray2[0].concat(tempArray[0]);
  6684. tempArray.length = 0;
  6685. tempArray2.length = 0;
  6686. src.SearchEpisodes.UpdateInProgress=false;
  6687. if(src.SearchEpisodes.Page<2){
  6688. ProgressBarFcy.plus(0.4);
  6689. }
  6690. });
  6691. }
  6692. $rootScope.Page.Title=SiteConstants.Fa.PageTitle.Search+src.Context;
  6693. $rootScope.$broadcast("UserData");
  6694. ProgressBarFcy.plus(0.2);
  6695. src.getNext=function(type){
  6696. type = type?type:"Search";
  6697. if(type=='Search'){
  6698. src.SearchEpisodes.UpdateInProgress = true;
  6699. src.SearchEpisodes.Limit=((src.SearchEpisodes.Page+1)==1)?50:50;
  6700. src.SearchEpisodes.Offset=((src.SearchEpisodes.Page+1)==1)?0:((src.SearchEpisodes.Page)*50);
  6701. src.getSearchResult(true);
  6702. }
  6703. }
  6704.  
  6705. src.getSearchResult(false);
  6706. }
  6707. function TestCtrl(GeneralInit,EpisodeFcy){
  6708. var tst= this;
  6709. tst.MovieData={Offset:0,Limit:70,UpdateInProgress:true,Episodes:[],Page:0,tempColumn:0};
  6710. tst.getMovies=function(){
  6711. EpisodeFcy.getMovies(tst.MovieData.Offset,tst.MovieData.Limit).then(function(Movies){
  6712. tst.MovieData.Page++;
  6713. var tempArray=[];
  6714. var tempArray2=[];
  6715. tempArray.push(Movies);
  6716. tempArray2.push(tst.MovieData.Episodes);
  6717. tst.MovieData.Episodes = tempArray2[0].concat(tempArray[0]);
  6718. tempArray.length = 0;
  6719. tempArray2.length = 0;
  6720. tst.MovieData.UpdateInProgress=false;
  6721. });
  6722. }
  6723. tst.getMovies();
  6724. //this is for test
  6725. }
  6726. function ResetPasswordCtrl(GeneralInit,UserSrv,Messages,$rootScope,SiteConstants,ProgressBarFcy,$routeParams){
  6727. var rpc = this;
  6728. rpc.User={};
  6729. rpc.ValidateStatus={InProgress:true,IsValid:false}
  6730. UserSrv.validateResetPasswordToken($routeParams.token).then(function(result){
  6731. rpc.ValidateStatus.InProgress=false;
  6732. if(result.status_code==1){
  6733. rpc.ValidateStatus.IsValid=true;
  6734. }
  6735. else{
  6736. NgNote.Error(result.status_message,3);
  6737. }
  6738. });
  6739. rpc.DoRequest= function(){
  6740. if(rpc.Password==rpc.ConfirmPassword){
  6741. UserSrv.resetPassword($routeParams.token,rpc.User.Password).then(function(resetResult){
  6742. if(resetResult.status_code==1){
  6743. NgNote.Success(resetResult.status_message,5);
  6744. }
  6745. else{
  6746. NgNote.Error(resetResult.status_message,3);
  6747. }
  6748. });
  6749. }
  6750. }
  6751. $rootScope.Page.Title=SiteConstants.Fa.PageTitle.ResetPassword;
  6752. $rootScope.$broadcast("UserData");
  6753. ProgressBarFcy.setDone();
  6754. }
  6755. function CategoryCtrl(GeneralInit,EpisodeFcy,$routeParams,$rootScope,SiteConstants,ProgressBarFcy){
  6756. var ctc= this;
  6757. ctc.CategoryId=$routeParams.Id;
  6758. ctc.CategoryPageTitle = function(categoryId){
  6759. var title=null;
  6760. switch (categoryId){
  6761. case '110':
  6762. title="کلیپ های پیشنهادی ما";
  6763. break;
  6764. case '111':
  6765. title="لیست فیلم ها";
  6766. break;
  6767. case '112':
  6768. title="جدیدترین کلیپ های روز";
  6769. break;
  6770. case '113':
  6771. title="آرشیو سریال ها";
  6772. break;
  6773. case '114':
  6774. title="کلیپ های پیشنهادی کاربران";
  6775. break;
  6776. case '115':
  6777. title="فیلم ها و کارتون های برگزیده کودکان";
  6778. break;
  6779. default:
  6780. title="دیگر قسمت های این برنامه";
  6781. break;
  6782. }
  6783. return title ;
  6784. }
  6785.  
  6786. ctc.Category={Offset:0,Limit:50,UpdateInProgress:true,Episodes:[],Page:0,IsPoster:false};
  6787. switch (parseInt(ctc.CategoryId)){
  6788. case 6:
  6789. break;
  6790. default:
  6791. break;
  6792. }
  6793. ctc.getCategoryEpisodes = function(){
  6794. EpisodeFcy.getCategoryEpisodes(ctc.CategoryId,ctc.Category.Offset,ctc.Category.Limit).then(function(result){
  6795. ctc.Category.Page++;
  6796. var tempArray=[];
  6797. var tempArray2=[];
  6798. tempArray.push(result);
  6799. tempArray2.push(ctc.Category.Episodes);
  6800. ctc.Category.Episodes = tempArray2[0].concat(tempArray[0]);
  6801. tempArray.length = 0;
  6802. tempArray2.length = 0;
  6803. ctc.Category.UpdateInProgress=false;
  6804. setTimeout(function () {
  6805. $(".carousel-info h5 span").each(function () {
  6806. var elem = $(this);
  6807. var persianNumber = persianUtils.toPersianNumber(elem.html());
  6808. elem.html(persianNumber);
  6809. });
  6810. },200);
  6811. ProgressBarFcy.setDone();
  6812. });
  6813. }
  6814. $rootScope.Page.Title=ctc.CategoryPageTitle(ctc.CategoryId);
  6815. $rootScope.$broadcast("UserData");
  6816. ProgressBarFcy.plus(0.2);
  6817. ctc.getNext=function(){
  6818. ctc.Category.UpdateInProgress = true;
  6819. ctc.Category.Limit=((ctc.Category.Page+1)==1)?50:50;
  6820. ctc.Category.Offset=((ctc.Category.Page+1)==1)?0:((ctc.Category.Page)*50);
  6821. setTimeout(function () {
  6822. $(".carousel-info h5 span").each(function () {
  6823. var elem = $(this);
  6824. var persianNumber = persianUtils.toPersianNumber(elem.html());
  6825. elem.html(persianNumber);
  6826. });
  6827. },200);
  6828. ctc.getCategoryEpisodes();
  6829. }
  6830. ctc.getCategoryEpisodes();
  6831. }
  6832. function ChannelsCtrl(GeneralInit,$rootScope,SiteConstants,ProgressBarFcy,ChannelFcy){
  6833. var clc= this;
  6834. clc.Channels={Offset:0,Limit:50,UpdateInProgress:true,Episodes:[],Page:0};
  6835. clc.getChannels = function(){
  6836. ChannelFcy.getChannels().then(function(result){
  6837. clc.Channels.Page++;
  6838. var tempArray=[];
  6839. var tempArray2=[];
  6840. tempArray.push(result);
  6841. tempArray2.push(clc.Channels.Episodes);
  6842. clc.Channels.Episodes = tempArray2[0].concat(tempArray[0]);
  6843. tempArray.length = 0;
  6844. tempArray2.length = 0;
  6845. clc.Channels.UpdateInProgress=false;
  6846. ProgressBarFcy.setDone();
  6847. });
  6848. }
  6849. $rootScope.Page.Title="مشاهده لیست کانال های تلوزیونی";
  6850. $rootScope.$broadcast("UserData");
  6851. ProgressBarFcy.plus(0.2);
  6852. clc.getChannels();
  6853. }
  6854. function ChangeLogCtrl(GeneralInit,$rootScope,SiteConstants,ProgressBarFcy){
  6855. $rootScope.Page.Title="نظرات و پیشنهادات";
  6856. $rootScope.$broadcast("UserData");
  6857. ProgressBarFcy.setDone();
  6858. }
  6859. function TermsCtrl(GeneralInit,$rootScope,SiteConstants,ProgressBarFcy){
  6860. $rootScope.Page.Title="قوانین و مقررات";
  6861. $rootScope.$broadcast("UserData");
  6862. ProgressBarFcy.setDone();
  6863. }
  6864. function profileCtrl(GeneralInit,$rootScope,SiteConstants,ProgressBarFcy){
  6865. $rootScope.Page.Title="قوانین و مقررات";
  6866. $rootScope.$broadcast("UserData");
  6867. ProgressBarFcy.setDone();
  6868. }
  6869. function fourOfourCtrl(GeneralInit,$rootScope,SiteConstants,ProgressBarFcy,EpisodeFcy){
  6870. var foc = this;
  6871. $rootScope.Page.Title="صفحه مورد نظر یافت نشد";
  6872. $rootScope.$broadcast("UserData");
  6873. ProgressBarFcy.setDone();
  6874. foc.OurRecommendationData={Offset:0,Limit:8,UpdateInProgress:true,Channels:[],Page:1,MaximumPage:0,tempColumn:0,Episodes:[]};
  6875. foc.OurRecommendations = function() {
  6876. EpisodeFcy.getOurRecommendations(foc.OurRecommendationData.Offset, foc.OurRecommendationData.Limit).then(function (data) {
  6877. foc.OurRecommendationData.Episodes=data;
  6878. foc.OurRecommendationData.UpdateInProgress=false;
  6879. });
  6880. }
  6881. foc.OurRecommendations();
  6882. }
  6883. function paymentConfirmationCtrl(GeneralInit,$rootScope,SiteConstants,ProgressBarFcy){
  6884. $rootScope.Page.Title="قوانین و مقررات";
  6885. $rootScope.$broadcast("UserData");
  6886. ProgressBarFcy.setDone();
  6887. }
  6888. function DmcaCtrl(GeneralInit,$rootScope,SiteConstants,ProgressBarFcy){
  6889. $rootScope.Page.Title="حقوق مولفین و مصنفین";
  6890. $rootScope.$broadcast("UserData");
  6891. ProgressBarFcy.setDone();
  6892. }
  6893. function ArchiveCtrl(GeneralInit,$rootScope,SiteConstants,ProgressBarFcy,ChannelFcy,EpisodeFcy,$routeParams){
  6894. var arc = this;
  6895. arc.ChannelDescriptor = $routeParams.Id;
  6896. $rootScope.Page.Title="آرشیو برنامه های این شبکه";
  6897. arc.ChannelEpisodes={Offset:0,Limit:50,UpdateInProgress:true,Episodes:[],Page:0};
  6898. arc.ChannelEpisodes.Page = 0;
  6899. $rootScope.$broadcast("UserData");
  6900. arc.getNewest = function(){
  6901. ChannelFcy.getChannelNameFromDescriptor(arc.ChannelDescriptor).then(function(ChannelId){
  6902. EpisodeFcy.getChannelNewestEpisodes(ChannelId,arc.ChannelEpisodes.Offset,arc.ChannelEpisodes.Limit).then(function(results){
  6903. arc.ChannelEpisodes.Page++;
  6904. var tempArray=[];
  6905. var tempArray2=[];
  6906. tempArray.push(results);
  6907. tempArray2.push(arc.ChannelEpisodes.Episodes);
  6908. arc.ChannelEpisodes.Episodes = tempArray2[0].concat(tempArray[0]);
  6909. tempArray.length = 0;
  6910. tempArray2.length = 0;
  6911. arc.ChannelEpisodes.UpdateInProgress=false;
  6912. setTimeout(function () {
  6913. $(".carousel-info h5 span").each(function () {
  6914. var elem = $(this);
  6915. var persianNumber = persianUtils.toPersianNumber(elem.html());
  6916. elem.html(persianNumber);
  6917. });
  6918. },200);
  6919. if(arc.ChannelEpisodes.Page<2){
  6920. ProgressBarFcy.plus(0.4);
  6921. }
  6922. });
  6923. })
  6924. }
  6925. arc.getNext=function(){
  6926. arc.ChannelEpisodes.Limit=((arc.ChannelEpisodes.Page+1)==1)?50:50;
  6927. arc.ChannelEpisodes.Offset=((arc.ChannelEpisodes.Page+1)==1)?0:((arc.ChannelEpisodes.Page-1)*50)+50;
  6928. arc.ChannelEpisodes.UpdateInProgress=true;
  6929. setTimeout(function () {
  6930. $(".carousel-info h5 span").each(function () {
  6931. var elem = $(this);
  6932. var persianNumber = persianUtils.toPersianNumber(elem.html());
  6933. elem.html(persianNumber);
  6934. });
  6935. },200);
  6936.  
  6937. arc.getNewest();
  6938. }
  6939. ProgressBarFcy.plus(0.3);
  6940. arc.getNewest();
  6941. }
  6942. function JobOpportunityCtrl($rootScope,SiteConstants,ProgressBarFcy){
  6943. $rootScope.Page.Title= SiteConstants.Fa.PageTitle.JobOpportunity;
  6944. $rootScope.$broadcast("UserData");
  6945. ProgressBarFcy.setDone();
  6946. }
  6947. function VerifyRegistrationCtrl($rootScope,GeneralInit,UserSrv,Messages,SiteConstants,ProgressBarFcy,$routeParams,$scope){
  6948. var vrc = this;
  6949. vrc.Messages='';
  6950. vrc.RequestStatus={InProgress:true}
  6951. if(typeof $routeParams.Username!==null && typeof $routeParams.Username!=='undefined' && typeof $routeParams.VCode!==null && typeof $routeParams.VCode!=='undefined' && typeof $routeParams.HMail!==null && typeof $routeParams.HMail!=='undefined'){
  6952. UserSrv.VerifyRegistration($routeParams.Username,$routeParams.VCode,$routeParams.HMail).then(function(result){
  6953. vrc.Status = typeof result.status_code!==null && typeof result.status_code!=='undefined'?result.status_code:null;
  6954. $scope.$watch('vrc.Status', function(){
  6955. if(vrc.Status!==null && typeof vrc.Status!=='undefined'){
  6956. if(vrc.Status==1){
  6957. vrc.Message=Messages.Fa.AccountVerificationSuccess;
  6958. vrc.RequestStatus.InProgress=false;
  6959. }
  6960. else{
  6961. vrc.Message=Messages.Fa.AccountVerificationFailed;
  6962. vrc.RequestStatus.InProgress=false;
  6963. }
  6964. }
  6965. });
  6966. });
  6967. }
  6968. $rootScope.Page.Title= SiteConstants.Fa.PageTitle.ConfirmRegistration;
  6969. $rootScope.$broadcast("UserData");
  6970. ProgressBarFcy.setDone();
  6971. }
  6972. function ResendActivationEmailCtrl(GeneralInit,UserSrv,Messages,$rootScope,SiteConstants,ProgressBarFcy){
  6973. var rpc= this;
  6974. $rootScope.Page.Title= SiteConstants.Fa.PageTitle.ResendActivationEmail;
  6975. $rootScope.$broadcast("UserData");
  6976. ProgressBarFcy.setDone();
  6977. rpc.ForgotPassword={Status:"NoAction"};
  6978. rpc.DoRequest=function(){
  6979. rpc.ForgotPassword.Status="InProgress";
  6980. UserSrv.forgotPasswordUser(rpc.User).then(function(result){
  6981. if(result==1)
  6982. {
  6983. rpc.ForgotPassword.Status="SuccessfulAction";
  6984. }
  6985. else if(result==2)
  6986. {
  6987. rpc.ForgotPassword.Status="InProgress";
  6988. }
  6989. else if(result==3)
  6990. {
  6991. rpc.ForgotPassword.Status="InProgress";
  6992. }
  6993. });
  6994. }
  6995. }
  6996. function LigeBartarCtrl(GeneralInit,$rootScope,SiteConstants,ProgressBarFcy,SliderFcy,EpisodeFcy,FavoriteListSrv,$scope,FavoriteListFcy,$timeout) {
  6997. var lbc = this;
  6998. $rootScope.Page.Title=SiteConstants.Fa.PageTitle.LigeBartar95;
  6999. lbc.fullGames = {Offset:0,Limit:26,UpdateInProgress:true,Episodes:[],Page:0,tempColumn:0};
  7000. lbc.highlights = {Offset:0,Limit:26,UpdateInProgress:true,Episodes:[],Page:0,tempColumn:0};
  7001. lbc.leagueOne = {Offset:0,Limit:26,UpdateInProgress:true,Episodes:[],Page:0,tempColumn:0};
  7002. lbc.selection = {Offset:0,Limit:26,UpdateInProgress:true,Episodes:[],Page:0,tempColumn:0};
  7003. lbc.sides = {Offset:0,Limit:26,UpdateInProgress:true,Episodes:[],Page:0,tempColumn:0};
  7004. lbc.ChildTags = {Offset:0,Limit:26,UpdateInProgress:true,Episodes:[],Page:0,tempColumn:0};
  7005. lbc.navadAndFootballNights = {Offset:0,Limit:26,UpdateInProgress:true,Episodes:[],Page:0,tempColumn:0};
  7006. $scope.applyChanges = function (selectedItem) {
  7007. lbc.getEpisodes = function () {
  7008. lbc.fullGames.UpdateInProgress = true;
  7009. ProgressBarFcy.setDone();
  7010. FavoriteListFcy.getEpisodeList(selectedItem+"", lbc.fullGames.Offset, lbc.fullGames.Limit).then(function (result) {
  7011. DestroySlickGeneral.destroy("full-games-league-carousel")
  7012. lbc.fullGames.Episodes = result;
  7013. TwoRowsCarousel.CarouselInit("full-games-league-carousel");
  7014. $timeout(function () {
  7015.  
  7016. $(".carousel-image-container img").each(function () {
  7017. $(this).error(function () {
  7018. if (!$(this).attr("data-replaced"))
  7019. replacePipelineAddress.replace($(this));
  7020. })
  7021. })
  7022. }, 200);
  7023. $timeout(function () {
  7024. lbc.fullGames.UpdateInProgress = false;
  7025. },1000)
  7026. setTimeout(function () {
  7027. $(".carousel-info h5 span").each(function () {
  7028. var elem = $(this);
  7029. var persianNumber = persianUtils.toPersianNumber(elem.html());
  7030. elem.html(persianNumber);
  7031. });
  7032. }, 200);
  7033. })
  7034. }
  7035. lbc.getEpisodes();
  7036. }
  7037. lbc.getFullGamesChildTags = function () {
  7038. lbc.ChildTags.UpdateInProgress = true;
  7039. FavoriteListSrv.getChildList('400407', lbc.ChildTags.Offset, lbc.ChildTags.Limit).then(function (result) {
  7040. lbc.ChildTags.Items = result;
  7041. lbc.ChildTags.UpdateInProgress = false;
  7042. $timeout(function () {
  7043. $("#full-games-weeks > option:first-of-type").remove()
  7044. }, 500)
  7045. $timeout(function () {
  7046. replaceBigThumbs.replace();
  7047. },800)
  7048. })
  7049.  
  7050. }
  7051. lbc.getFullGames = function () {
  7052. EpisodeFcy.getCustom('400407',lbc.fullGames.Offset,lbc.fullGames.Limit).then(function (result) {
  7053. TwoRowsCarousel.CarouselInit("full-games-league-carousel");
  7054. lbc.fullGames.Page++;
  7055. var tempArray=[];
  7056. var tempArray2=[];
  7057. tempArray.push(result);
  7058. tempArray2.push(lbc.fullGames.Episodes);
  7059. window.fullGames=result.length;
  7060. lbc.fullGames.Episodes = result;
  7061. tempArray.length = 0;
  7062. tempArray2.length = 0;
  7063. lbc.fullGames.UpdateInProgress=false;
  7064. if(lbc.fullGames.Page==1){
  7065. ProgressBarFcy.plus(0.1);
  7066. ProgressBarFcy.plus(0.1);
  7067. }
  7068. setTimeout(function () {
  7069. replaceBigThumbs.replace();
  7070. },800)
  7071. })
  7072. };
  7073. lbc.getLeagueOneGames = function () {
  7074. EpisodeFcy.getCustom('404867',lbc.leagueOne.Offset,lbc.leagueOne.Limit).then(function (result) {
  7075. TwoRowsCarousel.CarouselInit("league-one-carousel");
  7076. lbc.leagueOne.Page++;
  7077. var tempArray=[];
  7078. var tempArray2=[];
  7079. tempArray.push(result);
  7080. tempArray2.push(lbc.leagueOne.Episodes);
  7081. window.leagueOne=result.length;
  7082. lbc.leagueOne.Episodes = result;
  7083. tempArray.length = 0;
  7084. tempArray2.length = 0;
  7085. lbc.leagueOne.UpdateInProgress=false;
  7086. if(lbc.leagueOne.Page==1){
  7087. ProgressBarFcy.plus(0.1);
  7088. }
  7089. setTimeout(function () {
  7090. replaceBigThumbs.replace();
  7091. },800)
  7092. })
  7093. };
  7094. lbc.getHighlights = function () {
  7095. EpisodeFcy.getCustom('400408',lbc.highlights.Offset,lbc.highlights.Limit).then(function (result) {
  7096. TwoRowsCarousel.CarouselInit("highlights-carousel");
  7097. lbc.highlights.Page++;
  7098. var tempArray=[];
  7099. var tempArray2=[];
  7100. tempArray.push(result);
  7101. tempArray2.push(lbc.highlights.Episodes);
  7102. window.highlights=result.length;
  7103. lbc.highlights.Episodes = result;
  7104. tempArray.length = 0;
  7105. tempArray2.length = 0;
  7106. lbc.highlights.UpdateInProgress=false;
  7107. if(lbc.highlights.Page==1){
  7108. ProgressBarFcy.plus(0.1);
  7109. }
  7110. setTimeout(function () {
  7111. replaceBigThumbs.replace();
  7112. },800)
  7113. })
  7114. };
  7115. lbc.getSelections = function () {
  7116. EpisodeFcy.getCustom('400411',lbc.selection.Offset,lbc.selection.Limit).then(function (result) {
  7117. TwoRowsCarousel.CarouselInit("selection-carousel");
  7118. lbc.selection.Page++;
  7119. var tempArray=[];
  7120. var tempArray2=[];
  7121. tempArray.push(result);
  7122. tempArray2.push(lbc.selection.Episodes);
  7123. window.selection=result.length;
  7124. lbc.selection.Episodes = result;
  7125. tempArray.length = 0;
  7126. tempArray2.length = 0;
  7127. lbc.selection.UpdateInProgress=false;
  7128. if(lbc.selection.Page==1){
  7129. ProgressBarFcy.plus(0.1);
  7130. }
  7131. setTimeout(function () {
  7132. replaceBigThumbs.replace();
  7133. },800)
  7134. })
  7135. };
  7136. lbc.getSides = function () {
  7137. EpisodeFcy.getCustom('400412',lbc.sides.Offset,lbc.sides.Limit).then(function (result) {
  7138. TwoRowsCarousel.CarouselInit("news-carousel");
  7139. lbc.sides.Page++;
  7140. var tempArray=[];
  7141. var tempArray2=[];
  7142. tempArray.push(result);
  7143. tempArray2.push(lbc.sides.Episodes);
  7144. window.sides=result.length;
  7145. lbc.sides.Episodes = result;
  7146. tempArray.length = 0;
  7147. tempArray2.length = 0;
  7148. lbc.sides.UpdateInProgress=false;
  7149. if(lbc.sides.Page==1){
  7150. ProgressBarFcy.plus(0.1);
  7151. ProgressBarFcy.plus(0.1);
  7152. }
  7153. setTimeout(function () {
  7154. replaceBigThumbs.replace();
  7155. },800)
  7156. })
  7157. };
  7158. lbc.getFootballPrograms = function () {
  7159. EpisodeFcy.getCustom('400409',lbc.navadAndFootballNights.Offset,lbc.navadAndFootballNights.Limit).then(function (result) {
  7160. TwoRowsCarousel.CarouselInit("navad-carousel");
  7161. lbc.navadAndFootballNights.Page++;
  7162. var tempArray=[];
  7163. var tempArray2=[];
  7164. tempArray.push(result);
  7165. tempArray2.push(lbc.navadAndFootballNights.Episodes);
  7166. window.navadAndFootballNights=result.length;
  7167. lbc.navadAndFootballNights.Episodes = result;
  7168. tempArray.length = 0;
  7169. tempArray2.length = 0;
  7170. lbc.navadAndFootballNights.UpdateInProgress=false;
  7171. if(lbc.navadAndFootballNights.Page==1){
  7172. ProgressBarFcy.plus(0.1);
  7173. }
  7174. setTimeout(function () {
  7175. replaceBigThumbs.replace();
  7176. },800)
  7177. })
  7178. };
  7179. lbc.getSlider = function () {
  7180. SliderFcy.getleague().then(function (result) {
  7181. lbc.Sliders=result;
  7182. ProgressBarFcy.plus(0.1);
  7183. TopCarousel.initCarousel();
  7184. })
  7185. };
  7186. lbc.getSlider();
  7187. lbc.getFullGames();
  7188. lbc.getFootballPrograms();
  7189. lbc.getHighlights();
  7190. lbc.getSides();
  7191. lbc.getSelections();
  7192. lbc.getFullGamesChildTags();
  7193. lbc.getLeagueOneGames();
  7194. }
  7195. function Ramezan95Ctrl(GeneralInit,$rootScope,SiteConstants,ProgressBarFcy,SliderFcy,EpisodeFcy) {
  7196. var rmc = this;
  7197. $rootScope.Page.Title=SiteConstants.Fa.PageTitle.ramezan95;
  7198. rmc.TvSeriesData={Offset:0,Limit:200,UpdateInProgress:true,Episodes:[],Page:0,tempColumn:0};
  7199. rmc.DoasData={Offset:0,Limit:200,UpdateInProgress:true,Episodes:[],Page:0,tempColumn:0};
  7200. rmc.QuransData={Offset:0,Limit:200,UpdateInProgress:true,Episodes:[],Page:0,tempColumn:0};
  7201. rmc.QadrsData={Offset:0,Limit:200,UpdateInProgress:true,Episodes:[],Page:0,tempColumn:0};
  7202. rmc.SpecialProgramsData={Offset:0,Limit:200,UpdateInProgress:true,Episodes:[],Page:0,tempColumn:0};
  7203. rmc.MahAsalData={Offset:0,Limit:200,UpdateInProgress:true,Episodes:[],Page:0,tempColumn:0};
  7204. rmc.getSlider = function () {
  7205. SliderFcy.getRamezan95().then(function (result) {
  7206. rmc.Sliders=result;
  7207. ProgressBarFcy.plus(0.1);
  7208. TopCarousel.initCarousel();
  7209. })
  7210. }
  7211. rmc.getTvSeries = function () {
  7212. EpisodeFcy.getCustom('385501',rmc.TvSeriesData.Offset,rmc.TvSeriesData.Limit).then(function (result) {
  7213. TwoRowsCarousel.CarouselInit("series-carousel");
  7214. rmc.TvSeriesData.Page++;
  7215. var tempArray=[];
  7216. var tempArray2=[];
  7217. tempArray.push(result);
  7218. tempArray2.push(rmc.TvSeriesData.Episodes);
  7219. window.HomeCustom1=result.length;
  7220. rmc.TvSeriesData.Episodes = result;
  7221. tempArray.length = 0;
  7222. tempArray2.length = 0;
  7223. rmc.TvSeriesData.UpdateInProgress=false;
  7224. if(rmc.TvSeriesData.Page==1){
  7225. ProgressBarFcy.plus(0.1);
  7226. ProgressBarFcy.plus(0.1);
  7227. }
  7228. })
  7229. }
  7230. rmc.getDoas = function () {
  7231. EpisodeFcy.getCustom('385497',rmc.DoasData.Offset,rmc.DoasData.Limit).then(function (result) {
  7232. TwoRowsCarousel.CarouselInit("pray-carousel");
  7233. rmc.DoasData.Page++;
  7234. var tempArray=[];
  7235. var tempArray2=[];
  7236. tempArray.push(result);
  7237. tempArray2.push(rmc.DoasData.Episodes);
  7238. window.HomeCustom1=result.length;
  7239. rmc.DoasData.Episodes = result;
  7240. tempArray.length = 0;
  7241. tempArray2.length = 0;
  7242. rmc.DoasData.UpdateInProgress=false;
  7243. if(rmc.DoasData.Page==1){
  7244. ProgressBarFcy.plus(0.1);
  7245. }
  7246. })
  7247. }
  7248. rmc.getQurans =function () {
  7249. EpisodeFcy.getCustom('385499',rmc.QuransData.Offset,rmc.QuransData.Limit).then(function (result) {
  7250. TwoRowsCarousel.CarouselInit("quran-carousel")
  7251. rmc.QuransData.Page++;
  7252. var tempArray=[];
  7253. var tempArray2=[];
  7254. tempArray.push(result);
  7255. tempArray2.push(rmc.QuransData.Episodes);
  7256. window.HomeCustom1=result.length;
  7257. rmc.QuransData.Episodes = result;
  7258. tempArray.length = 0;
  7259. tempArray2.length = 0;
  7260. rmc.QuransData.UpdateInProgress=false;
  7261. if(rmc.QuransData.Page==1){
  7262. ProgressBarFcy.plus(0.1);
  7263. }
  7264. })
  7265. }
  7266. rmc.getQadrs= function () {
  7267. EpisodeFcy.getCustom('385500',rmc.QadrsData.Offset,rmc.QadrsData.Limit).then(function (result) {
  7268. rmc.QadrsData.Page++;
  7269. var tempArray=[];
  7270. var tempArray2=[];
  7271. tempArray.push(result);
  7272. tempArray2.push(rmc.QadrsData.Episodes);
  7273. window.HomeCustom1=result.length;
  7274. rmc.QadrsData.Episodes = result;
  7275. tempArray.length = 0;
  7276. tempArray2.length = 0;
  7277. TwoRowsCarousel.CarouselInit("qadr-carousel");
  7278. rmc.QadrsData.UpdateInProgress=false;
  7279. if(rmc.QadrsData.Page==1){
  7280. ProgressBarFcy.plus(0.1);
  7281. }
  7282. })
  7283. }
  7284. rmc.getSpecialPrograms = function () {
  7285. EpisodeFcy.getCustom('385503',rmc.SpecialProgramsData.Offset,rmc.SpecialProgramsData.Limit).then(function (result) {
  7286. TwoRowsCarousel.CarouselInit("pray-day-carousel");
  7287. rmc.SpecialProgramsData.Page++;
  7288. var tempArray=[];
  7289. var tempArray2=[];
  7290. tempArray.push(result);
  7291. tempArray2.push(rmc.SpecialProgramsData.Episodes);
  7292. window.HomeCustom1=result.length;
  7293. rmc.SpecialProgramsData.Episodes = result;
  7294. tempArray.length = 0;
  7295. tempArray2.length = 0;
  7296. rmc.SpecialProgramsData.UpdateInProgress=false;
  7297. if(rmc.SpecialProgramsData.Page==1){
  7298. ProgressBarFcy.plus(0.1);
  7299. ProgressBarFcy.plus(0.1);
  7300. }
  7301. })
  7302. }
  7303. rmc.getMahAsalItems = function () {
  7304. EpisodeFcy.getCustom('385502',rmc.MahAsalData.Offset,rmc.MahAsalData.Limit).then(function (result) {
  7305. TwoRowsCarousel.CarouselInit("moon-carousel");
  7306. rmc.MahAsalData.Page++;
  7307. var tempArray=[];
  7308. var tempArray2=[];
  7309. tempArray.push(result);
  7310. tempArray2.push(rmc.MahAsalData.Episodes);
  7311. window.HomeCustom1=result.length;
  7312. rmc.MahAsalData.Episodes = result;
  7313. tempArray.length = 0;
  7314. tempArray2.length = 0;
  7315. rmc.MahAsalData.UpdateInProgress=false;
  7316. if(rmc.MahAsalData.Page==1){
  7317. ProgressBarFcy.plus(0.1);
  7318. ProgressBarFcy.plus(0.1);
  7319. }
  7320. })
  7321. }
  7322. rmc.getSlider();
  7323. rmc.getTvSeries();
  7324. rmc.getMahAsalItems();
  7325. rmc.getSpecialPrograms();
  7326. rmc.getQurans();
  7327. rmc.getDoas();
  7328. rmc.getQadrs();
  7329. }
  7330. function oauthLoginCtrl($routeParams,SecurityFcy,Messages,$window,ProgressBarFcy){
  7331. ProgressBarFcy.setDone();
  7332. SecurityFcy.setCookieByToken($routeParams.token);
  7333. $window.opener.location ='/#!/?ls=su';
  7334. setTimeout(function(){
  7335. open(location, '_self').close();
  7336. window.open('', '_self', '');
  7337. $window.close();
  7338. top.window.close();
  7339. window.open("about:blank", "_self").close();
  7340. },550);
  7341. }
  7342. function AdsBankEditCtrl($rootScope,AdsFcy,AdsSrv,ProgressBarFcy,SecurityFcy,UserSrv,AdBankFcy,AdBankSrv,$routeParams,$window){
  7343. var abe = this;
  7344. var Id = $routeParams.Id;
  7345. abe.AdBank = {UpdateInProgress:true}
  7346. UserSrv.getUser().then(function (result) {
  7347. if (typeof result != 'undefined' && result != null && typeof result.token != 'undefined' && ($rootScope.InArray('admin', result.credentials) || $rootScope.InArray('superadmin', result.credentials) || $rootScope.InArray('operator', result.credentials))) {
  7348. SecurityFcy.getUserToken().then(function (token) {
  7349. AdBankFcy.getAdBankById(Id,token).then(function (data) {
  7350. ProgressBarFcy.setDone();
  7351. abe.AdBank = data;
  7352. if(abe.AdBank.target.indexOf("vod") >= 0){
  7353. $("#vod").click();
  7354. }
  7355. if(abe.AdBank.target.indexOf("live") >= 0){
  7356. $("#live").click();
  7357. }
  7358. if(abe.AdBank.for_iranian == 1){
  7359. $("#forIranian").click();
  7360. }
  7361. if(abe.AdBank.enable == 1){
  7362. $("#Enable").click();
  7363. }
  7364. })
  7365. })
  7366. abe.SaveAdBank = function () {
  7367. var id = Id;
  7368. var target_array = [];
  7369. if($("#vod").is(":checked")){
  7370. target_array.push("vod");
  7371. }
  7372. if($("#live").is(":checked")){
  7373. target_array.push("live");
  7374. }
  7375. var target = target_array.join();
  7376. var forIranian = 0;
  7377. if($("#forIranian").is(":checked")){
  7378. forIranian = 1;
  7379. }
  7380. var enable = 0;
  7381. if($("#Enable").is(":checked")){
  7382. enable = 1;
  7383. }
  7384. var tag_url = abe.AdBank.tag_url;
  7385. var description = abe.AdBank.description;
  7386. var prob = abe.AdBank.prob_percent;
  7387. SecurityFcy.getUserToken().then(function (token) {
  7388. AdBankSrv.saveAdBank(id,token,description,tag_url,prob,target,forIranian,enable).then(function (result) {
  7389.  
  7390. if (result != -1) {
  7391. NgNote.Success('بانک اطلاعاتی با موفقیت اضافه شد', 3);
  7392. } else {
  7393. NgNote.Error('خظا در ارتباط با سرور', 3);
  7394. }
  7395. })
  7396. });
  7397. }
  7398. }else{
  7399. NgNote.Error('کاربر گرامی شما اجازه دسترسی به این بخش را ندارید',3);
  7400. setTimeout(function(){
  7401. $window.location.replace("/#!/");
  7402. },1000);
  7403. }
  7404. })
  7405. }
  7406. function AdsBankAddCtrl($rootScope,AdsSrv,ProgressBarFcy,SecurityFcy,UserSrv,$window,AdBankFcy,AdBankSrv){
  7407. var aba = this;
  7408. aba.adsModel = {};
  7409. $rootScope.Page.Title = "افزودن بانک تبلیغات";
  7410. UserSrv.getUser().then(function (result) {
  7411. if (typeof result != 'undefined' && result != null && typeof result.token != 'undefined' && ($rootScope.InArray('admin', result.credentials) || $rootScope.InArray('superadmin', result.credentials) || $rootScope.InArray('operator', result.credentials))) {
  7412. SecurityFcy.getUserToken().then(function (token) {
  7413. ProgressBarFcy.setDone();
  7414. aba.createAdBank = function () {
  7415.  
  7416. var ad_enable = 0;
  7417. var ad_for_iranian = 0;
  7418. var array_of_target = [];
  7419. if($("#Enable").is(":checked")){
  7420. ad_enable = 1;
  7421. }
  7422. if($("#forIranian").is(":checked")){
  7423. ad_for_iranian = 1;
  7424. }
  7425. if($("#vod").is(":checked")){
  7426. array_of_target.push("vod");
  7427. }
  7428. if($("#live").is(":checked")){
  7429. array_of_target.push("live");
  7430. }
  7431. var ad_target = array_of_target.join();
  7432. var ad_tag_url = aba.adsModel.target_url;
  7433. var ad_title = aba.adsModel.description;
  7434. var ad_probability = aba.adsModel.adsProb;
  7435. // console.log(ad_enable + " " + ad_for_iranian + " " + ad_target + " " + ad_tag_url + " " + ad_title + " " + ad_probability);
  7436. AdBankSrv.addAdBank(ad_title,ad_tag_url,ad_probability,ad_target,ad_for_iranian,ad_enable,token).then(function (response) {
  7437. if(response != -1){
  7438. NgNote.Success('بانک اطلاعاتی با موفقیت اضافه شد.',3);
  7439. }else{
  7440. NgNote.Error('خظا در ارتباط با سرور.',3);
  7441. }
  7442. })
  7443. }
  7444. })
  7445. }else{
  7446. NgNote.Error('کاربر گرامی شما اجازه دسترسی به این بخش را ندارید',3);
  7447. setTimeout(function(){
  7448. $window.location.replace("/#!/");
  7449. },1000);
  7450. }
  7451. })
  7452. }
  7453. function PromotionsAddCtrl($rootScope,AdsSrv,ProgressBarFcy,SecurityFcy,UserSrv,$window,PromotionFcy,PromotionsSrv){
  7454. var pac = this;
  7455. pac.Promotion = { UpdateInProgress:true ,Promotion:0};
  7456. $rootScope.Page.Title = "اضافه کردن اسلایدر";
  7457. UserSrv.getUser().then(function (result) {
  7458. if (typeof result != 'undefined' && result != null && typeof result.token != 'undefined' && ($rootScope.InArray('admin', result.credentials) || $rootScope.InArray('superadmin', result.credentials) || $rootScope.InArray('operator', result.credentials))) {
  7459. ProgressBarFcy.setDone();
  7460. }else{
  7461. NgNote.Error('کاربر گرامی شما اجازه دسترسی به این بخش را ندارید',3);
  7462. setTimeout(function(){
  7463. $window.location.replace("/#!/");
  7464. },1000);
  7465. }
  7466. });
  7467. pac.applyChange = function (val) {
  7468. pac.Promotion.promotionType = val + "";
  7469.  
  7470.  
  7471. }
  7472. $(document).on("click","#file-upload-mobile",function () {
  7473. $("#fileInput3").click();
  7474. })
  7475. $(document).on("click","#file-upload-admin3",function () {
  7476. $("#fileInput").click();
  7477. })
  7478. pac.platformType = '1';
  7479. pac.listOfDropdown = [{id:'0',title:'وب'},{id:'1',title:'موبایل'}]
  7480.  
  7481.  
  7482. CalendarSetup.setup("valid-from");
  7483. CalendarSetup.setup("valid-until");
  7484.  
  7485. pac.showLargeImage = false;
  7486. pac.finalize = false;
  7487. $(document).on("click","#poster-upload-button",function () {
  7488. pac.showLargeImage = true;
  7489.  
  7490. })
  7491. $(document).on("click","#upload-mobile-button",function () {
  7492. pac.finalize = true;
  7493. })
  7494. $(document).on("click","#cover-upload-button",function () {
  7495. pac.finalize = true;
  7496. })
  7497. pac.nextLevel = function () {
  7498. SecurityFcy.getUserToken().then(function (token) {
  7499. var promotionCategoryArray = [];
  7500. $(".checkboxes-promotion input[type=checkbox]:checked").each(function () {
  7501. promotionCategoryArray.push($(this).val());
  7502. })
  7503.  
  7504. var promotion_category = promotionCategoryArray.join();
  7505. var show_time = "";
  7506. var date = new JDate($("#valid-from").val());
  7507. var month = parseInt(date._date.getMonth()) + 1;
  7508. var day = parseInt(date._date.toString().split(" ")[2]);
  7509. var year = date._date.getFullYear();
  7510. var MiladiDate = new Date(year, month, parseInt(day));
  7511. if(MiladiDate.getMonth() == 0){
  7512. show_time = (MiladiDate.getFullYear()-1 + "-" + "12" + "-" + day) + " " + "00" + ":" + "00" + ":00";
  7513. }else{
  7514. show_time = (MiladiDate.getFullYear() + "-" + MiladiDate.getMonth() + "-" + day) + " " + "00" + ":" + "00" + ":00";
  7515. }
  7516.  
  7517. var show_time2 = "";
  7518. var date2 = new JDate($("#valid-until").val());
  7519. var month2 = parseInt(date2._date.getMonth()) + 1;
  7520. var day2 = parseInt(date2._date.toString().split(" ")[2]);
  7521. var year2 = date2._date.getFullYear();
  7522. MiladiDate = new Date(year2, month2, parseInt(day2));
  7523. if(MiladiDate.getMonth() == 0){
  7524. show_time2 = (MiladiDate.getFullYear()-1 + "-" + "12" + "-" + day2) + " " + "00" + ":" + "00" + ":00";
  7525. }else{
  7526. show_time2 = (MiladiDate.getFullYear() + "-" + MiladiDate.getMonth() + "-" + day2) + " " + "00" + ":" + "00" + ":00";
  7527. }
  7528. PromotionsSrv.createPromotion(promotion_category,pac.Promotion.description_fa,pac.Promotion.description_en,pac.Promotion.link,$("input[name=slider_type]:checked").val(),pac.Promotion.title,pac.Promotion.play_time,pac.Promotion.occasion,pac.platformType,show_time,show_time2,token).then(function (result) {
  7529. $rootScope.sliderId = result.data.id;
  7530. if(result!=-1){
  7531. // pac.sliderId = result;
  7532. // console.log(result);
  7533. NgNote.Success('اطلاعات اپیزود با موفقیت به ثبت رسید',5);
  7534. }else {
  7535. NgNote.Error('خطا در ارسال داده به سرور، لطفا مجددا تلاش نمایید',5);
  7536.  
  7537. }
  7538. });
  7539. })
  7540. $(".next-lvl").show();
  7541. $(".prev-lvl").hide();
  7542. $("#picture-form").show();
  7543. $("#edit-form").hide();
  7544. }
  7545. pac.prevLevel = function () {
  7546. $(".prev-lvl").show();
  7547. $(".next-lvl").hide();
  7548. $("#picture-form").hide();
  7549. $("#edit-form").show();
  7550. }
  7551.  
  7552. }
  7553. function PromotionsEditCtrl($rootScope,AdsSrv,ProgressBarFcy,SecurityFcy,UserSrv,$window,PromotionFcy,$routeParams,PromotionsSrv){
  7554. var pec = this;
  7555. pec.Promotion = { UpdateInProgress:true ,Item:{}};
  7556. var Id = $routeParams.Id;
  7557. $rootScope.sliderId = Id;
  7558. $rootScope.Page.Title = "اضافه کردن اسلایدر";
  7559. pec.showLargeImage = false;
  7560. pec.finalize = false;
  7561. $(document).on("click","#poster-upload-button",function () {
  7562. pec.showLargeImage = true;
  7563.  
  7564. })
  7565. $(document).on("click","#file-upload-admin3",function () {
  7566. $("#fileInput").click();
  7567. })
  7568. $(document).on("click","#upload-mobile-button",function () {
  7569. pec.finalize = true;
  7570. })
  7571. $(document).on("click","#cover-upload-button",function () {
  7572. pec.finalize = true;
  7573. })
  7574. UserSrv.getUser().then(function (result) {
  7575. if (typeof result != 'undefined' && result != null && typeof result.token != 'undefined' && ($rootScope.InArray('admin', result.credentials) || $rootScope.InArray('superadmin', result.credentials) || $rootScope.InArray('operator', result.credentials))) {
  7576. ProgressBarFcy.setDone();
  7577. SecurityFcy.getUserToken().then(function (token) {
  7578. PromotionFcy.getPromotionById(token,Id).then(function (data) {
  7579. pec.Promotion.Item = data;
  7580. if(data.valid_from != null) {
  7581. var date = new Date(data.valid_from.split(" ")[0].split("-")[0], data.valid_from.split(" ")[0].split("-")[1], data.valid_from.split(" ")[0].split("-")[2]);
  7582. pec.Promotion.Item.valid_from = new JDate(date).toLocaleString().split(" ")[0].replace(/\//g, "-");
  7583. }
  7584. if(data.valid_to != null) {
  7585. var date2 = new Date(data.valid_to.split(" ")[0].split("-")[0], data.valid_to.split(" ")[0].split("-")[1], data.valid_to.split(" ")[0].split("-")[2]);
  7586. pec.Promotion.Item.valid_to = new JDate(date2).toLocaleString().split(" ")[0].replace(/\//g, "-");
  7587. }
  7588. if(pec.Promotion.Item.type !=null){
  7589. switch (pec.Promotion.Item.type){
  7590. case 's':
  7591. $("input[value=s]").click();
  7592. break;
  7593. case 'm':
  7594. $("input[value=m]").click();
  7595. break;
  7596. case 'l':
  7597. $("input[value=l]").click();
  7598. break;
  7599. case 'k':
  7600. $("input[value=k]").click();
  7601. break;
  7602. }
  7603. }else{
  7604. $("input[value=movies]").click();
  7605. }
  7606. if(pec.Promotion.Item.category != null){
  7607. pec.Promotion.Item.category.split(",").forEach(function (item) {
  7608. switch (item){
  7609. case "1":
  7610. $("input[ng-value=1]").click();
  7611. break;
  7612. case "2":
  7613. $("input[ng-value=2]").click();
  7614. break;
  7615. case "3":
  7616. $("input[ng-value=3]").click();
  7617. break;
  7618. case "4":
  7619. $("input[ng-value=4]").click();
  7620. break;
  7621. case "5":
  7622. $("input[ng-value=5]").click();
  7623. break;
  7624. case "6":
  7625. $("input[ng-value=6]").click();
  7626. break;
  7627. case "7":
  7628. $("input[ng-value=7]").click();
  7629. break;
  7630. case "8":
  7631. $("input[ng-value=8]").click();
  7632. break;
  7633. case "9":
  7634. $("input[ng-value=9]").click();
  7635. break;
  7636. }
  7637. })
  7638. }
  7639. })
  7640. })
  7641. }else{
  7642. NgNote.Error('کاربر گرامی شما اجازه دسترسی به این بخش را ندارید',3);
  7643. setTimeout(function(){
  7644. $window.location.replace("/#!/");
  7645. },1000);
  7646. }
  7647.  
  7648.  
  7649. });
  7650. pec.Promotion.platformType = '0';
  7651. pec.listOfDropdown = [{id:0,title:'وب'},{id:1,title:'موبایل'}]
  7652.  
  7653. CalendarSetup.setup("valid-from");
  7654. CalendarSetup.setup("valid-until");
  7655. pec.nextLevel = function () {
  7656.  
  7657. var promotionCategoryArray = [];
  7658. $(".checkboxes-promotion input[type=checkbox]:checked").each(function () {
  7659. promotionCategoryArray.push($(this).val());
  7660. })
  7661. var promotion_category = promotionCategoryArray.join();
  7662. var show_time = "";
  7663. var date = new JDate($("#valid-from").val());
  7664. var month = parseInt(date._date.getMonth()) + 1;
  7665. var day = parseInt(date._date.toString().split(" ")[2]);
  7666. var year = date._date.getFullYear();
  7667. var MiladiDate = new Date(year, month, parseInt(day));
  7668. if(MiladiDate.getMonth() == 0){
  7669. show_time = (MiladiDate.getFullYear()-1 + "-" + "12" + "-" + day) + " " + "00" + ":" + "00" + ":00";
  7670. }else{
  7671. show_time = (MiladiDate.getFullYear() + "-" + MiladiDate.getMonth() + "-" + day) + " " + "00" + ":" + "00" + ":00";
  7672. }
  7673. var show_time2 = "";
  7674. var date2 = new JDate($("#valid-until").val());
  7675. var month2 = parseInt(date2._date.getMonth()) + 1;
  7676. var day2 = parseInt(date2._date.toString().split(" ")[2]);
  7677. var year2 = date2._date.getFullYear();
  7678. MiladiDate = new Date(year2, month2, parseInt(day2));
  7679. if(MiladiDate.getMonth() == 0){
  7680. show_time2 = (MiladiDate.getFullYear()-1 + "-" + "12" + "-" + day2) + " " + "00" + ":" + "00" + ":00";
  7681. }else{
  7682. show_time2 = (MiladiDate.getFullYear() + "-" + MiladiDate.getMonth() + "-" + day2) + " " + "00" + ":" + "00" + ":00";
  7683. }
  7684. SecurityFcy.getUserToken().then(function (token) {
  7685. PromotionsSrv.savePromotion($routeParams.Id,promotion_category,pec.Promotion.Item.description_fa,pec.Promotion.Item.description_en,pec.Promotion.Item.link,$("input[name=slider_type]:checked").val(),pec.Promotion.Item.title,pec.Promotion.Item.play_time,pec.Promotion.Item.occasion,pec.Promotion.Item.is_mobile,show_time,show_time2,token).then(function (result) {
  7686. if(result!=-1){
  7687.  
  7688. NgNote.Success('اطلاعات اپیزود با موفقیت به ثبت رسید',5);
  7689. }else {
  7690. NgNote.Error('خطا در ارسال داده به سرور، لطفا مجددا تلاش نمایید',5);
  7691.  
  7692. }
  7693. });
  7694. })
  7695. $(".next-lvl").show();
  7696. $(".prev-lvl").hide();
  7697. $("#picture-form").show();
  7698. $("#edit-form").hide();
  7699. }
  7700. pec.prevLevel = function () {
  7701. $(".prev-lvl").show();
  7702. $(".next-lvl").hide();
  7703. $("#picture-form").hide();
  7704. $("#edit-form").show();
  7705. }
  7706.  
  7707. }
  7708. function PromotionsListCtrl($rootScope,AdsSrv,ProgressBarFcy,SecurityFcy,UserSrv,$window,PromotionFcy,PromotionsSrv){
  7709. var plc = this;
  7710. plc.Promotions = { UpdateInProgress:true ,Promotions:null,offset:0,limit:60};
  7711. $rootScope.Page.Title = "لیست اسلایدر";
  7712. UserSrv.getUser().then(function (result) {
  7713. if (typeof result != 'undefined' && result != null && typeof result.token != 'undefined' && ($rootScope.InArray('admin', result.credentials) || $rootScope.InArray('superadmin', result.credentials) || $rootScope.InArray('operator', result.credentials))) {
  7714. SecurityFcy.getUserToken().then(function (token) {
  7715. PromotionFcy.getPromotions(plc.Promotions.offset,plc.Promotions.limit,token).then(function (data) {
  7716. plc.Promotions.Promotions = data;
  7717. ProgressBarFcy.setDone();
  7718. })
  7719. })
  7720.  
  7721. }else{
  7722. NgNote.Error('کاربر گرامی شما اجازه دسترسی به این بخش را ندارید',3);
  7723. setTimeout(function(){
  7724. $window.location.replace("/#!/");
  7725. },1000);
  7726. }
  7727. })
  7728. plc.deletePromotion = function (id) {
  7729. var cnf = showConfirm.verify();
  7730. if(cnf) {
  7731. SecurityFcy.getUserToken().then(function (token) {
  7732. $("table > tbody > tr[data-row=" + id + "]").remove();
  7733. PromotionsSrv.deletePromotion(id, token);
  7734. NgNote.Success('بنر مورد نظر حذف شد', 3);
  7735. })
  7736. }
  7737. }
  7738. }
  7739. function AddAdsCtrl($rootScope,AdsSrv,ProgressBarFcy,SecurityFcy,UserSrv,$window){
  7740. var adc = this;
  7741. $rootScope.Page.Title = "افزودن تبلیغ جدید";
  7742. adc.adsModel = {adsTitle:"",adsPreroll:"",adsPostroll:"",adsLink:"",adsMediaPath:"",adsMediaStaticPath:"",adsDuration:"00:00:05",adsProb:0,deviceDesktop:"",deviceMobileWeb:"",deviceAndroidApp:"",targetVod:"",targetLive:"",enable:""}
  7743. UserSrv.getUser().then(function (result) {
  7744. if (typeof result != 'undefined' && result != null && typeof result.token != 'undefined' && ($rootScope.InArray('admin', result.credentials) || $rootScope.InArray('superadmin', result.credentials) || $rootScope.InArray('operator', result.credentials))) {
  7745. ProgressBarFcy.setDone();
  7746. }
  7747. else {
  7748. NgNote.Error('کاربر گرامی شما اجازه دسترسی به این بخش را ندارید',3);
  7749. setTimeout(function(){
  7750. $window.location.replace("/#!/");
  7751. },1000);
  7752. }
  7753. });
  7754. adc.CreateAd = function () {
  7755. var arrayOfDevices = [];
  7756. var arrayOfTargets = [];
  7757. if(adc.adsModel.deviceDesktop+"" == "true")
  7758. arrayOfDevices.push("desktop")
  7759. if(adc.adsModel.deviceMobileWeb+"" == "true")
  7760. arrayOfDevices.push("mobile")
  7761. if(adc.adsModel.deviceAndroidApp+"" == "true")
  7762. arrayOfDevices.push("android")
  7763. if((adc.adsModel.targetVod + "") == "true")
  7764. arrayOfTargets.push("vod")
  7765. if((adc.adsModel.targetLive + "") == "true")
  7766. arrayOfTargets.push("live")
  7767. var enabled = "0";
  7768. if(adc.adsModel.enable == "1")
  7769. enabled = "1";
  7770. var targets = arrayOfTargets.join();
  7771. var devices = arrayOfDevices.join();
  7772. var mode = "";
  7773. $("input[name=display-type]").each(function () {
  7774. if($(this).is(":checked"))
  7775. mode = $(this).val();
  7776. })
  7777. SecurityFcy.getUserToken().then(function (token) {
  7778. AdsSrv.create(adc.adsModel.adsTitle, mode, adc.adsModel.adsLink, adc.adsModel.adsMediaPath,
  7779. adc.adsModel.adsMediaStaticPath, adc.adsModel.adsDuration, adc.adsModel.adsProb, devices,
  7780. targets, enabled,token)
  7781. .then(function () {
  7782. NgNote.Success('تبلیغ مورد نظر با موفقیت افزوده شد',3);
  7783. });
  7784. })
  7785. }
  7786. }
  7787. function EditAdsCtrl($rootScope,AdsSrv,ProgressBarFcy,SecurityFcy,UserSrv,$window,$routeParams){
  7788. var edc = this;
  7789. $rootScope.Page.Title = "ویرایش اطلاعات تبلیغ";
  7790. edc.AdStatus = {InProgress:false};
  7791. UserSrv.getUser().then(function (result) {
  7792. if (typeof result != 'undefined' && result != null && typeof result.token != 'undefined' && ($rootScope.InArray('admin', result.credentials) || $rootScope.InArray('superadmin', result.credentials) || $rootScope.InArray('operator', result.credentials))) {
  7793. ProgressBarFcy.setDone();
  7794. }
  7795. else {
  7796. NgNote.Error('کاربر گرامی شما اجازه دسترسی به این بخش را ندارید',3);
  7797. setTimeout(function(){
  7798. $window.location.replace("/#!/");
  7799. },1000);
  7800. }
  7801. });
  7802. edc.preStatus = null;
  7803. edc.postStatus = null;
  7804. edc.desktop = null;
  7805. edc.mobile = null;
  7806. edc.android = null;
  7807. edc.live = null;
  7808. edc.vod = null;
  7809. edc.enable = null;
  7810. var arrayOfDevices = [];
  7811. var arrayOfTargets = [];
  7812. SecurityFcy.getUserToken().then(function (token) {
  7813. AdsSrv.getAd($routeParams.Id,token).then(function (result) {
  7814. edc.adsModel = result;
  7815. if(edc.adsModel.mode == "preroll")
  7816. edc.preStatus = "preroll";
  7817. else
  7818. edc.postStatus = "postroll";
  7819. arrayOfDevices = edc.adsModel.device.split(",");
  7820. arrayOfTargets = edc.adsModel.target.split(",");
  7821. if (arrayOfDevices.indexOf("desktop") >= 0) {
  7822. $("#desktop").click();
  7823. }
  7824. if (arrayOfDevices.indexOf("mobile") >= 0) {
  7825. $("#mobile").click();
  7826. }
  7827. if (arrayOfDevices.indexOf("android") >= 0) {
  7828. $("#android").click();
  7829. }
  7830. if (arrayOfTargets.indexOf("vod") >= 0) {
  7831. $("#vod").click();
  7832. }
  7833. if (arrayOfTargets.indexOf("live") >= 0) {
  7834. $("#live").click();
  7835. }
  7836. if(edc.adsModel.mode=="preroll")
  7837. $("#preroll").click();
  7838. else
  7839. $("#postroll").click();
  7840. if(edc.adsModel.enable != 0)
  7841. edc.enable = "1"
  7842.  
  7843. ProgressBarFcy.setDone();
  7844. })
  7845. })
  7846. edc.UpdateAd = function () {
  7847. edc.AdStatus.InProgress=true;
  7848. var arrayOfDevices = [];
  7849. var arrayOfTargets = [];
  7850. if(edc.adsModel.deviceDesktop+"" == "true")
  7851. arrayOfDevices.push("desktop")
  7852. if(edc.adsModel.deviceMobileWeb+"" == "true")
  7853. arrayOfDevices.push("mobile")
  7854. if(edc.adsModel.deviceAndroidApp+"" == "true")
  7855. arrayOfDevices.push("android")
  7856. if((edc.adsModel.targetVod + "") == "true")
  7857. arrayOfTargets.push("vod")
  7858. if((edc.adsModel.targetLive + "") == "true")
  7859. arrayOfTargets.push("live")
  7860. var enabled = "0";
  7861. if(edc.adsModel.enable == "1")
  7862. enabled = "1";
  7863. var targets = arrayOfTargets.join();
  7864. var devices = arrayOfDevices.join();
  7865. var mode = "";
  7866. $("input[name=display-type]").each(function () {
  7867. if($(this).is(":checked"))
  7868. mode = $(this).val();
  7869. })
  7870. // console.log({title: edc.adsModel.title, mode: mode, link: edc.adsModel.link_url, media_path: edc.adsModel.media_path,
  7871. // static_media_path: edc.adsModel.media_path_static, media_duration: edc.adsModel.media_duration, prob: edc.adsModel.prob, devices: devices,
  7872. // targets: targets, enabled: enabled})
  7873. SecurityFcy.getUserToken().then(function (token) {
  7874. AdsSrv.update($routeParams.Id,edc.adsModel.title, mode, edc.adsModel.link_url, edc.adsModel.media_path,
  7875. edc.adsModel.media_path_static, edc.adsModel.media_duration, edc.adsModel.prob, devices,
  7876. targets, enabled,token)
  7877. .then(function () {
  7878. edc.AdStatus.InProgress=false;
  7879. NgNote.Success('اطلاعات تبلیغ با موفقیت به روز شد',3);
  7880. });
  7881. })
  7882. }
  7883. }
  7884. function AdsBankListCtrl($rootScope,AdsFcy,AdsSrv,ProgressBarFcy,SecurityFcy,UserSrv,AdBankFcy,$window,AdBankSrv){
  7885. var abl = this;
  7886. abl.adBankList = {limit:50,offset:0,UpdateInProgress:true,AdBanks:null};
  7887. UserSrv.getUser().then(function (result) {
  7888. if (typeof result != 'undefined' && result != null && typeof result.token != 'undefined' && ($rootScope.InArray('admin', result.credentials) || $rootScope.InArray('superadmin', result.credentials) || $rootScope.InArray('operator', result.credentials))) {
  7889. SecurityFcy.getUserToken().then(function (token) {
  7890. AdBankFcy.getAdBankList(abl.adBankList.limit,abl.adBankList.offset,token).then(function (data) {
  7891. abl.adBankList.AdBanks = data;
  7892. })
  7893. })
  7894. abl.removeItem = function (id) {
  7895. var cnf = showConfirm.verify();
  7896. if(cnf) {
  7897. SecurityFcy.getUserToken().then(function (token) {
  7898. $("#adbank-table tr[data-row="+id+"]").remove();
  7899. AdBankSrv.deleteAdBank(id, token);
  7900. NgNote.Success('ایتم مورد نظر حذف شد.',3);
  7901. })
  7902. }
  7903. }
  7904. ProgressBarFcy.setDone();
  7905. }else{
  7906. NgNote.Error('کاربر گرامی شما اجازه دسترسی به این بخش را ندارید',3);
  7907. setTimeout(function(){
  7908. $window.location.replace("/#!/");
  7909. },1000);
  7910. }
  7911. })
  7912. }
  7913. function ListAdsCtrl($rootScope,AdsFcy,AdsSrv,ProgressBarFcy,SecurityFcy,UserSrv){
  7914. var lac = this;
  7915. $rootScope.Page.Title = "لیست تبلیغات";
  7916. lac.ItemsData={Offset:0,Limit:50,UpdateInProgress:false,Items:[],Page:0};
  7917. UserSrv.getUser().then(function (result) {
  7918. if (typeof result != 'undefined' && result != null && typeof result.token != 'undefined' && ($rootScope.InArray('admin', result.credentials) || $rootScope.InArray('superadmin', result.credentials) || $rootScope.InArray('operator', result.credentials))) {
  7919. SecurityFcy.getUserToken().then(function (token) {
  7920. AdsFcy.getAll(token,lac.ItemsData.Offset,lac.ItemsData.Limit).then(function (ItemResults) {
  7921. ProgressBarFcy.setDone();
  7922. lac.ItemsData.Items = ItemResults;
  7923. });
  7924. });
  7925. }
  7926. else {
  7927. NgNote.Error('کاربر گرامی شما اجازه دسترسی به این بخش را ندارید',3);
  7928. setTimeout(function(){
  7929. $window.location.replace("/#!/");
  7930. },1000);
  7931. }
  7932. });
  7933. lac.DeleteAd = function (ad_id) {
  7934. SecurityFcy.getUserToken().then(function (token) {
  7935. AdsSrv.deleteAd(ad_id,token).then(function () {
  7936. NgNote.Success("تبلیغ مورد نظر با موفقیت حذف شد",3);
  7937. $("#list-of-ads").find("tr[data-row="+ad_id+"]").remove();
  7938. })
  7939. })
  7940. }
  7941. }
  7942. function AddEpisodeCtrl(GeneralInit,UserSrv,$rootScope,SiteConstants,ProgressBarFcy,EpisodeSrv,$routeParams,$window,$http,SecurityFcy,ArtistFcy,TagFcy,FavoriteListFcy,Configs,ProgramFcy){
  7943. var aec = this;
  7944. var selectize,selectize2,selectize3,selectize4,selectize5;
  7945. aec.EpisodeStatus = { InProgress:false}
  7946. $rootScope.Page.Title="افزودن قسمت برنامه";
  7947. $rootScope.$broadcast("UserData");
  7948. aec.ArtisSearchData={Offset:0,Limit:15,UpdateInProgress:false,Items:[],Page:0};
  7949. aec.TagSearchData={Offset:0,Limit:15,UpdateInProgress:false,Items:[],Page:0};
  7950. aec.ProgramSearchData={Offset:0,Limit:15,UpdateInProgress:false,Items:[],Page:0};
  7951. aec.CountrySearchData={Offset:0,Limit:15,UpdateInProgress:false,Items:[],Page:0};
  7952. aec.Directors = {};
  7953. aec.Provider = {};
  7954. aec.HoursList = [];
  7955. aec.MinutesList = [];
  7956. aec.publishedMinute = 0;
  7957. aec.publishedHour = 0;
  7958. for(var i = 0;i<=24;i++){
  7959. var item = {id:0,title:0};
  7960. item.id = i;
  7961. item.title = i+ ' ساعت ';
  7962. aec.HoursList.push(item)
  7963. }
  7964. for(var i = 0;i<60;i++){
  7965. var item = {id:0,title:0};
  7966. item.id = i;
  7967. item.title = i + ' دقیقه ';
  7968. aec.MinutesList.push(item)
  7969. }
  7970.  
  7971. aec.Actors = null;
  7972. aec.favLists = null;
  7973. UserSrv.getUser().then(function (result) {
  7974. if (typeof result != 'undefined' && result != null && typeof result.token != 'undefined' && ($rootScope.InArray('admin', result.credentials) || $rootScope.InArray('superadmin', result.credentials) || $rootScope.InArray('operator', result.credentials))) {
  7975. setTimeout(function () {
  7976. $('.tagging').selectize({
  7977. delimiter: '#',
  7978. persist: false,
  7979. create: function (input) {
  7980. return {
  7981. value: input,
  7982. text: input
  7983. }
  7984. }
  7985. });
  7986. $(".taggings").val(result.tags);
  7987. var $select2 = $('.taggings').selectize({
  7988. delimiter: ',',
  7989. persist: false,
  7990. create: function (input) {
  7991. return {
  7992. value: input,
  7993. text: input
  7994. }
  7995. }
  7996. });
  7997. var $select = $('.option-artist').selectize({
  7998. valueField: 'id',
  7999. labelField: 'title',
  8000. searchField: 'title',
  8001.  
  8002. create: function (input) {
  8003. return {
  8004. value: input.id,
  8005. text: input.name
  8006. }
  8007. },
  8008. render: {
  8009. option_create: function (data, escape) {
  8010. return '';
  8011. }
  8012. }
  8013. });
  8014. var $select5 = $('#copyright-field').selectize({
  8015. valueField: 'descriptor',
  8016. labelField: 'name',
  8017. searchField: 'name',
  8018.  
  8019. create: function (input) {
  8020. return {
  8021. value: input.id,
  8022. text: input.name
  8023. }
  8024. },
  8025. render: {
  8026. option_create: function (data, escape) {
  8027. return '';
  8028. }
  8029. }
  8030. });
  8031. var $select3 = $('.fav-list').selectize({
  8032. valueField: 'id',
  8033. labelField: 'name_fa',
  8034. searchField: 'name_fa',
  8035.  
  8036. create: function (input) {
  8037. return {
  8038. value: input.id,
  8039. text: input.name
  8040. }
  8041. },
  8042. render: {
  8043. option_create: function (data, escape) {
  8044. return '';
  8045. }
  8046. }
  8047. });
  8048. var $select4 = $('.program').selectize({
  8049. valueField: 'id',
  8050. labelField: 'title',
  8051. searchField: 'title',
  8052. maxItems:1,
  8053. create: function (input) {
  8054. return {
  8055. value: input.id,
  8056. text: input.name
  8057. }
  8058. },
  8059. render: {
  8060. option_create: function (data, escape) {
  8061. return '';
  8062. }
  8063. }
  8064. });
  8065. CalendarSetup.setup("show_time");
  8066. selectize = $select[0].selectize;
  8067. selectize3 = $select3[0].selectize;
  8068. selectize4 = $select4[0].selectize;
  8069. selectize5 = $select5[0].selectize;
  8070. }, 1800);
  8071. }
  8072. ProgressBarFcy.setDone();
  8073. })
  8074. aec.SearchArtist = function (context) {
  8075. if(context.length >= 3){
  8076. SecurityFcy.getUserToken().then(function (token) {
  8077. ArtistFcy.searchByName(context, token, aec.ArtisSearchData.Offset, aec.ArtisSearchData.Limit).then(function (result) {
  8078. if (chooseOption == 1) {
  8079. selectize.addOption(result);
  8080. selectize.refreshOptions();
  8081.  
  8082. } else if (chooseOption == 2) {
  8083. selectize2.addOption(result);
  8084. selectize2.refreshOptions();
  8085. }
  8086. aec.ArtisSearchData.Items = result;
  8087. itemLoading.hide();
  8088. })
  8089. });
  8090. }else{
  8091. itemLoading.hide();
  8092. }
  8093. };
  8094. aec.SearchProgram = function (context) {
  8095. if(context.length >= 3){
  8096. SecurityFcy.getUserToken().then(function (token) {
  8097. ProgramFcy.searchByName(context, token, aec.ProgramSearchData.Offset, aec.ProgramSearchData.Limit).then(function (result) {
  8098. if (chooseOption == 1) {
  8099. selectize.addOption(result);
  8100. selectize.refreshOptions();
  8101.  
  8102. } else if (chooseOption == 2) {
  8103. selectize2.addOption(result);
  8104. selectize2.refreshOptions();
  8105. } else if (chooseOption == 4) {
  8106. selectize4.addOption(result);
  8107. selectize4.refreshOptions();
  8108. }
  8109. aec.ProgramSearchData.Items = result;
  8110. itemLoading.hide();
  8111. })
  8112. });
  8113. }else{
  8114. itemLoading.hide();
  8115. }
  8116. };
  8117. aec.SearchCountry = function (context) {
  8118. if(context.length >= 3){
  8119. SecurityFcy.getUserToken().then(function (token) {
  8120. ProgramFcy.searchCountryByName(context, token, aec.CountrySearchData.Offset, aec.CountrySearchData.Limit).then(function (result) {
  8121. if (chooseOption == 8) {
  8122. selectize5.addOption(result);
  8123. selectize5.refreshOptions();
  8124.  
  8125. }
  8126. aec.CountrySearchData.Items = result;
  8127. itemLoading.hide();
  8128. })
  8129. })
  8130. }else{
  8131. itemLoading.hide();
  8132. }
  8133. };
  8134. aec.SearchFavoriteList = function (context) {
  8135. if(context.length >= 3){
  8136. SecurityFcy.getUserToken().then(function (token) {
  8137. FavoriteListFcy.searchByName(context, token, aec.TagSearchData.Offset, aec.TagSearchData.Limit).then(function (result) {
  8138. if (chooseOption == 1) {
  8139. selectize.addOption(result);
  8140. selectize.refreshOptions();
  8141.  
  8142. } else if (chooseOption == 2) {
  8143. selectize2.addOption(result);
  8144. selectize2.refreshOptions();
  8145. } else if (chooseOption == 3) {
  8146. selectize3.addOption(result);
  8147. selectize3.refreshOptions();
  8148. } else if (chooseOption == 4) {
  8149. selectize4.addOption(result);
  8150. selectize4.refreshOptions();
  8151. }
  8152. aec.TagSearchData.Items = result;
  8153. itemLoading.hide();
  8154. })
  8155. })
  8156.  
  8157. }else{
  8158. itemLoading.hide();
  8159. }
  8160. };
  8161. aec.SearchTag = function (context) {
  8162. if(context.length >= 3){
  8163. SecurityFcy.getUserToken().then(function (token) {
  8164. TagFcy.searchByName(context, token, aec.TagSearchData.Offset, aec.TagSearchData.Limit).then(function (result) {
  8165. if (chooseOption == 1) {
  8166. selectize.addOption(result);
  8167. selectize.refreshOptions();
  8168.  
  8169. } else if (chooseOption == 2) {
  8170. selectize2.addOption(result);
  8171. selectize2.refreshOptions();
  8172. }
  8173. aec.TagSearchData.Items = result;
  8174. itemLoading.hide();
  8175. })
  8176. })
  8177. }else{
  8178. itemLoading.hide();
  8179. }
  8180. };
  8181.  
  8182. var itemLoading = null;
  8183. var t = null;
  8184. var chooseOption = null;
  8185. $(document).on("input",".option-artist .selectize-input input",function () {
  8186. if(t!=null){
  8187. clearTimeout(t);
  8188. }
  8189. itemLoading = $(this).parents(".input-holder").find(".loader");
  8190. if($(this).val().length>3){
  8191. itemLoading.show();
  8192. }
  8193. chooseOption = 1;
  8194. var value = $(this).val();
  8195. t = setTimeout(function(){aec.SearchArtist(value)},800);
  8196. });
  8197. $(document).on("input",".country-list .selectize-input input",function () {
  8198. if(t!=null){
  8199. clearTimeout(t);
  8200. }
  8201. itemLoading = $(this).parents(".input-holder").find(".loader");
  8202. if($(this).val().length>3){
  8203. itemLoading.show();
  8204. }
  8205. chooseOption = 8;
  8206. var value = $(this).val();
  8207. t = setTimeout(function(){aec.SearchCountry(value)},800);
  8208. });
  8209. $(document).on("input",".program .selectize-input input",function () {
  8210. if(t!=null){
  8211. clearTimeout(t);
  8212. }
  8213. itemLoading = $(this).parents(".input-holder").find(".loader");
  8214. if($(this).val().length>3){
  8215. itemLoading.show();
  8216. }
  8217. chooseOption = 4;
  8218. var value = $(this).val();
  8219. t = setTimeout(function(){aec.SearchProgram(value)},800);
  8220. });
  8221. $(document).on("input",".fav-list .selectize-input input",function () {
  8222. if(t!=null){
  8223. clearTimeout(t);
  8224. }
  8225. itemLoading = $(this).parents(".input-holder").find(".loader");
  8226. if($(this).val().length>3){
  8227. itemLoading.show();
  8228. }
  8229. chooseOption = 3;
  8230. var value = $(this).val();
  8231. t = setTimeout(function(){aec.SearchFavoriteList(value)},800);
  8232. });
  8233. aec.SaveEpisode = function () {
  8234.  
  8235. if($("input[name=showTime]").val().length > 6 && aec.publishedHour+'' != 'undefined' && aec.publishedMinute+'' != 'undefined') {
  8236. aec.EpisodeStatus.InProgress = true;
  8237. SecurityFcy.getUserToken().then(function (token) {
  8238. if (typeof aec.Actors == 'object') {
  8239. aec.Actors = '';
  8240. }
  8241. if(aec.publishedHour < 10){
  8242. aec.publishedHour = '0'+aec.publishedHour;
  8243. }
  8244. if(aec.publishedMinute < 10){
  8245. aec.publishedMinute ='0'+aec.publishedMinute;
  8246. }
  8247. var copyrightType = $("input[name=copyright-type]:checked").val();
  8248. var date = new JDate($("#show_time").val());
  8249. var month = parseInt(date._date.getMonth()) + 1;
  8250. var day = parseInt(date._date.toString().split(" ")[2]);
  8251. var year = date._date.getFullYear();
  8252. var MiladiDate = new Date(year, month, parseInt(day));
  8253. var show_time = "";
  8254. if(MiladiDate.getMonth() == 0){
  8255. show_time = (MiladiDate.getFullYear()-1 + "-" + "12" + "-" + day) + " " + aec.publishedHour + ":" + aec.publishedMinute + ":00";
  8256. }else{
  8257. show_time = (MiladiDate.getFullYear() + "-" + MiladiDate.getMonth() + "-" + day) + " " + aec.publishedHour + ":" + aec.publishedMinute + ":00";
  8258. }
  8259. EpisodeSrv.createEpisode(aec.EpisodeData.program_id, show_time,aec.copyright,copyrightType, aec.EpisodeData.title, aec.EpisodeData.title_english, aec.EpisodeData.description_fa,
  8260. aec.EpisodeData.keywords_english, aec.Actors, aec.EpisodeData.page_description, aec.EpisodeData.tags, aec.favLists, token).then(function (result) {
  8261.  
  8262. if (result != -1) {
  8263. aec.EpisodeStatus.InProgress = false;
  8264. NgNote.Success('اطلاعات اپیزود با موفقیت به ثبت رسید', 5);
  8265. } else {
  8266. NgNote.Error('خطا در ارسال داده به سرور، لطفا مجددا تلاش نمایید', 5);
  8267. aec.EpisodeStatus.InProgress = false;
  8268. }
  8269. });
  8270. })
  8271. }else{
  8272. alert("لطفا تاریخ قسمت برنامه ساعت و دقیقه را وارد کنید.");
  8273. }
  8274. }
  8275. }
  8276. function ListOfUserCtrl(GeneralInit,UserSrv,UserFcy,$rootScope,SiteConstants,ProgressBarFcy,$window,$http,SecurityFcy,Configs){
  8277. var luc = this;
  8278. $rootScope.Page.Title="لیست کاربران";
  8279. luc.UsersList = {offset:0,limit:50,UpdateInProgress:true,Users:null};
  8280. luc.Pagination = [];
  8281. luc.UserStatus = [];
  8282. luc.SingleUser = null;
  8283. luc.UserStatus[1]= "جدید";
  8284. luc.UserStatus[2]= "فعال";
  8285. luc.UserStatus[3]= "غیر فعال";
  8286. luc.UserStatus[4]= "حذف شده";
  8287. luc.UserStatus[5]= "غیر قابل ورود";
  8288. luc.UserStatus[6]= "ممنوع الورود";
  8289. UserSrv.getUser().then(function (result) {
  8290. if(typeof result!='undefined' && result!=null && typeof result.token!='undefined' && ($rootScope.InArray('admin', result.credentials) || $rootScope.InArray('superadmin', result.credentials) || $rootScope.InArray('operator', result.credentials))){
  8291. SecurityFcy.getUserToken().then(function (token) {
  8292. luc.UsersList.UpdateInProgress = false;
  8293. UserFcy.getUsers(luc.UsersList.limit,luc.UsersList.offset,token).then(function (data) {
  8294. luc.UsersList.Users = data;
  8295. })
  8296. });
  8297. luc.searchByEmail = function (email) {
  8298. luc.UsersList.UpdateInProgress = true;
  8299. SecurityFcy.getUserToken().then(function (token) {
  8300. UserFcy.getUserByEmail(email,null,token).then(function (data) {
  8301. luc.SingleUser = data;
  8302. luc.UsersList.Users = data;
  8303. luc.UsersList.UpdateInProgress = false;
  8304. })
  8305. })
  8306. }
  8307. luc.searchByPhone = function (phone) {
  8308. luc.UsersList.UpdateInProgress = true;
  8309. SecurityFcy.getUserToken().then(function (token) {
  8310. UserFcy.getUserByEmail(null,phone,token).then(function (data) {
  8311. luc.UsersList.UpdateInProgress = false;
  8312. luc.SingleUser = data;
  8313. })
  8314. })
  8315. }
  8316. for(var i = 1;i<=50;i++){
  8317. luc.Pagination[i-1] = i;
  8318. }
  8319. ProgressBarFcy.setDone();
  8320. $(document).on("click",".page",function () {
  8321. var index = $(this).data("page");
  8322. luc.UsersList.offset = (index-1)*50;
  8323. luc.UsersList.UpdateInProgress = true;
  8324. SecurityFcy.getUserToken().then(function (token) {
  8325. UserFcy.getUsers(luc.UsersList.limit,luc.UsersList.offset,token).then(function (data) {
  8326. luc.UsersList.UpdateInProgress = false;
  8327. luc.UsersList.Users = data;
  8328. })
  8329. })
  8330. })
  8331. }else{
  8332. NgNote.Error('کاربر گرامی شما اجازه دسترسی به این بخش را ندارید',3);
  8333. setTimeout(function(){
  8334. $window.location.replace("/#!/");
  8335. },1000);
  8336. }
  8337. })
  8338. luc.deleteUser = function (id) {
  8339. var cnf = showConfirm.verify();
  8340. if(cnf) {
  8341. SecurityFcy.getUserToken().then(function (token) {
  8342. UserSrv.deleteUser(id, token);
  8343. $(".user-row[data-row=" + id + "]").remove();
  8344. NgNote.Success('کاربر مورد نظر با موفقیت حذف شد.',3);
  8345. })
  8346. }
  8347. }
  8348. }
  8349. function EditUserCtrl(GeneralInit,UserSrv,UserFcy,$rootScope,SiteConstants,ProgressBarFcy,$routeParams,$window,$http,SecurityFcy,Configs){
  8350. var euc = this;
  8351. $rootScope.Page.Title="ویرایش کاربر";
  8352. UserSrv.getUser().then(function (result) {
  8353. if (typeof result != 'undefined' && result != null && typeof result.token != 'undefined' && ($rootScope.InArray('admin', result.credentials) || $rootScope.InArray('superadmin', result.credentials) || $rootScope.InArray('operator', result.credentials))) {
  8354. euc.User = {UpdateInProgress:true};
  8355. euc.UserStatus = [];
  8356. euc.UserStatus = [{id: 1, title: 'جدید'}, {id: 2, title: 'فعال'}, {id: 3, title: 'غیر فعال'}, {
  8357. id: 4,
  8358. title: 'حذف شده'
  8359. }, {id: 5, title: 'غیر قابل ورود'}, {id: 6, title: 'ممنوع الورود'}]
  8360. SecurityFcy.getUserToken().then(function (token) {
  8361. UserFcy.getUserById($routeParams.Id, token).then(function (data) {
  8362. euc.User = data;
  8363. euc.User.UpdateInProgress = false;
  8364. ProgressBarFcy.setDone();
  8365. if(euc.User.gender == 'm'){
  8366. euc.User.male = 'm';
  8367. }else if(euc.User.gender == 'f'){
  8368. euc.User.female = 'f';
  8369. }
  8370. })
  8371. })
  8372. euc.saveUser = function () {
  8373. var gender = 'm';
  8374. if($("#man").is(":checked")){
  8375. gender = 'm';
  8376. }else if($("#woman").is(":checked")){
  8377. gender = 'f';
  8378. }
  8379. euc.User.UpdateInProgress = true;
  8380. SecurityFcy.getUserToken().then(function (token) {
  8381. var id = $routeParams.Id;
  8382. UserSrv.updateUser(id,euc.User.fname,gender,euc.User.phone,euc.User.user_membership_status,token).then(function (result) {
  8383. if (result != -1) {
  8384. euc.User.InProgress = false;
  8385. NgNote.Success('کاربر مورد نظر شما با موفقیت ویرایش شد.', 3);
  8386. } else {
  8387. NgNote.Error('خطا در ارسال داده به سرور، لطفا مجددا تلاش نمایید', 5);
  8388. euc.User.InProgress = false;
  8389. }
  8390. });
  8391. });
  8392. }
  8393. }else{
  8394. NgNote.Error('کاربر گرامی شما اجازه دسترسی به این بخش را ندارید',3);
  8395. setTimeout(function(){
  8396. $window.location.replace("/#!/");
  8397. },1000);
  8398. }
  8399. });
  8400.  
  8401. }
  8402. function EditEpisodeCtrl(GeneralInit,UserSrv,$rootScope,SiteConstants,ProgressBarFcy,EpisodeSrv,$routeParams,$window,$http,SecurityFcy,ArtistFcy,TagFcy,FavoriteListFcy,Configs,ProgramFcy){
  8403. var eec = this;
  8404. eec.EpisodeStatus = { InProgress:false}
  8405. $rootScope.Page.Title="ویرایش قسمت برنامه";
  8406. $rootScope.$broadcast("UserData");
  8407. eec.ArtisSearchData={Offset:0,Limit:15,UpdateInProgress:false,Items:[],Page:0};
  8408. eec.TagSearchData={Offset:0,Limit:15,UpdateInProgress:false,Items:[],Page:0};
  8409. eec.EpisodeSearchData={Offset:0,Limit:15,UpdateInProgress:false,Items:[],Page:0};
  8410. eec.CountrySearchData={Offset:0,Limit:15,UpdateInProgress:false,Items:[],Page:0};
  8411. eec.HoursList = [];
  8412. eec.MinutesList = [];
  8413. eec.publishedMinute = 0;
  8414. eec.publishedHour = 0;
  8415. for(var i = 0;i<=24;i++){
  8416. var item = {id:0,title:0};
  8417. if(i < 10){
  8418. item.id = '0'+i;
  8419. }else{
  8420. item.id = i+"";
  8421. }
  8422. item.title = i+ ' ساعت ';
  8423. eec.HoursList.push(item)
  8424. }
  8425. for(var i = 0;i<60;i++){
  8426. var item = {id:0,title:0};
  8427. if(i < 10){
  8428. item.id = '0'+i;
  8429. }else{
  8430. item.id = i+"";
  8431. }
  8432. item.title = i + ' دقیقه ';
  8433. eec.MinutesList.push(item)
  8434. }
  8435.  
  8436. eec.Directors = {};
  8437. eec.Provider = {};
  8438. eec.Actors = null;
  8439. eec.favLists = null;
  8440. ProgressBarFcy.setDone();
  8441. var selectize2,selectize,selectize3,selectize4,selectize5;
  8442. eec.EpisodeData = {};
  8443. UserSrv.getUser().then(function (result) {
  8444. if(typeof result!='undefined' && result!=null && typeof result.token!='undefined' && ($rootScope.InArray('admin', result.credentials) || $rootScope.InArray('superadmin', result.credentials) || $rootScope.InArray('operator', result.credentials))){
  8445. SecurityFcy.getUserToken().then(function (token) {
  8446. EpisodeSrv.getFullEpisode($routeParams.Id, token).then(function (result) {
  8447. eec.EpisodeData = result;
  8448. if(result.show_time.length > "6") {
  8449. eec.EpisodeData.today = result.show_time.split(" ")[0];
  8450. eec.EpisodeData.hour = result.show_time.split(" ")[1].split(":")[0];
  8451. eec.EpisodeData.minute = result.show_time.split(" ")[1].split(":")[1];
  8452. }else{
  8453. eec.EpisodeData.today = eec.EpisodeData.today = "1395-09-14";
  8454. eec.EpisodeData.hour = "00";
  8455. eec.EpisodeData.minute = "00";
  8456. }
  8457. if(result.region_inclusion == "include"){
  8458. $("#include").click();
  8459. }else if (result.region_inclusion == "exclude"){
  8460. $("#exclude").click();
  8461. }
  8462. eec.copyright = result.region;
  8463. setTimeout(function () {
  8464. // replacePipelineAddress.replace($(this).find("img"));
  8465. // replacePipelineAddressAngular();
  8466. remainCount.countRemain("MetaDescription",300);
  8467. $('.tagging').val(result.keywords_english);
  8468. $('.tagging').selectize({
  8469. delimiter: '#',
  8470. persist: false,
  8471. create: function (input) {
  8472. return {
  8473. value: input,
  8474. text: input
  8475. }
  8476. }
  8477. });
  8478. CalendarSetup.setup("show_time");
  8479.  
  8480. $(".taggings").val(result.tags);
  8481. var $select2 = $('.taggings').selectize({
  8482. delimiter: ',',
  8483. persist: false,
  8484. create: function (input) {
  8485. return {
  8486. value: input,
  8487. text: input
  8488. }
  8489. }
  8490. });
  8491. var $select5 = $('#copyright-field').selectize({
  8492. delimiter: ',',
  8493. persist: false,
  8494. valueField: 'descriptor',
  8495. labelField: 'name',
  8496. searchField: 'name',
  8497. create: function (input) {
  8498. return {
  8499. value: input,
  8500. text: input
  8501. }
  8502. }
  8503. });
  8504. var $select = $('.option-artist').selectize({
  8505. valueField: 'id',
  8506. labelField: 'title',
  8507. searchField: 'title',
  8508.  
  8509. create: function (input) {
  8510. return {
  8511. value: input.id,
  8512. text: input.name
  8513. }
  8514. },
  8515. render: {
  8516. option_create: function (data, escape) {
  8517. return '';
  8518. }
  8519. }
  8520. });
  8521. var $select3 = $('.fav-list').selectize({
  8522. valueField: 'id',
  8523. labelField: 'name_fa',
  8524. searchField: 'name_fa',
  8525.  
  8526. create: function (input) {
  8527. return {
  8528. value: input.id,
  8529. text: input.name
  8530. }
  8531. },
  8532. render: {
  8533. option_create: function (data, escape) {
  8534. return '';
  8535. }
  8536. }
  8537. });
  8538. var $select4 = $('.program').selectize({
  8539. valueField: 'id',
  8540. labelField: 'title',
  8541. searchField: 'title',
  8542. maxItems:1,
  8543. create: function (input) {
  8544. return {
  8545. value: input.id,
  8546. text: input.name
  8547. }
  8548. },
  8549. render: {
  8550. option_create: function (data, escape) {
  8551. return '';
  8552. }
  8553. }
  8554. });
  8555. selectize = $select[0].selectize;
  8556. selectize3 = $select3[0].selectize;
  8557. selectize4 = $select4[0].selectize;
  8558. selectize5 = $select5[0].selectize;
  8559. $('.option-artist').val("");
  8560. for (var i = 0; i <= result.artists.length - 1; i++) {
  8561. selectize.addOption(result.artists[i]);
  8562.  
  8563. selectize.addItem(result.artists[i].id);
  8564. }
  8565. if(result.episode_countries != null) {
  8566. for (var i = 0; i <= result.episode_countries.length; i++) {
  8567. selectize5.addOption(result.episode_countries[i]);
  8568.  
  8569. selectize5.addItem(result.episode_countries[i].id);
  8570. }
  8571. }
  8572. for (var i = 0; i <= result.program.length - 1; i++) {
  8573.  
  8574. selectize4.addOption(result.program.title);
  8575.  
  8576. selectize4.addItem(result.program.id);
  8577. }
  8578. for (var i = 0; i <= 0; i++) {
  8579. selectize4.addOption(result.program);
  8580.  
  8581. selectize4.addItem(result.program.id);
  8582. }
  8583. selectize2 = $select2[0].selectize;
  8584.  
  8585. for (var j = 0; j <= result.favorite_lists.length - 1; j++) {
  8586. if (typeof result.favorite_lists[j] != 'undefined') {
  8587. selectize3.addOption(result.favorite_lists[j]);
  8588. selectize3.addItem(result.favorite_lists[j].id);
  8589. }
  8590.  
  8591. }
  8592. }, 1800);
  8593. if (eec.EpisodeData.downloadable == 1) {
  8594. eec.EpisodeData.downloadable = true;
  8595. }
  8596. if (eec.EpisodeData.enable == 1) {
  8597. eec.EpisodeData.enable = true;
  8598. }
  8599. });
  8600. });
  8601. }
  8602. else {
  8603. NgNote.Error('کاربر گرامی شما اجازه دسترسی به این بخش را ندارید',3);
  8604. setTimeout(function(){
  8605. $window.location.replace("/#!/");
  8606. },1000);
  8607. }
  8608. });
  8609. eec.SaveEpisode = function () {
  8610. if($("#show_time").val().length > 7 && eec.publishedHour+'' != 'undefined' && eec.publishedMinute+'' != 'undefined') {
  8611. eec.EpisodeStatus.InProgress = true;
  8612. if(eec.publishedHour < 10){
  8613. eec.publishedHour = '0'+eec.publishedHour;
  8614. }
  8615. if(eec.publishedMinute < 10){
  8616. eec.publishedMinute ='0'+eec.publishedMinute;
  8617. }
  8618. var show_time = "";
  8619. var copyrightType = $("input[name=copyright-type]:checked").val();
  8620. var date = new JDate($("#show_time").val());
  8621. var month = parseInt(date._date.getMonth()) + 1;
  8622. var day = parseInt(date._date.toString().split(" ")[2]);
  8623. var year = date._date.getFullYear();
  8624. var MiladiDate = new Date(year, month, parseInt(day));
  8625. if(MiladiDate.getMonth() == 0){
  8626. show_time = (MiladiDate.getFullYear()-1 + "-" + "12" + "-" + day) + " " + eec.EpisodeData.hour + ":" + eec.EpisodeData.minute + ":00";
  8627. }else{
  8628. show_time = (MiladiDate.getFullYear() + "-" + MiladiDate.getMonth() + "-" + day) + " " + eec.EpisodeData.hour + ":" + eec.EpisodeData.minute + ":00";
  8629. }
  8630. SecurityFcy.getUserToken().then(function (token) {
  8631. if (typeof eec.Actors == 'object') {
  8632. eec.Actors = '';
  8633. }
  8634. EpisodeSrv.saveEpisode(eec.EpisodeData.id, show_time,copyrightType,eec.copyright,eec.EpisodeData.program_id2, eec.EpisodeData.title,
  8635. eec.EpisodeData.title_english, eec.EpisodeData.description_fa, eec.EpisodeData.keywords_english,
  8636. eec.Actors, eec.EpisodeData.page_description, eec.EpisodeData.tags, eec.favLists, token).then(function (result) {
  8637. if(result!=-1){
  8638. eec.EpisodeStatus.InProgress = false;
  8639. NgNote.Success('اطلاعات اپیزود با موفقیت به ثبت رسید',5);
  8640. }else {
  8641. NgNote.Error('خطا در ارسال داده به سرور، لطفا مجددا تلاش نمایید',5);
  8642. eec.EpisodeStatus.InProgress = false;
  8643. }
  8644. })
  8645.  
  8646. });
  8647. }else{
  8648. alert("لطفا تاریخ انتشار ویدئو ساعت و دقیقه را انتخاب کنید.")
  8649. }
  8650. };
  8651. eec.SearchProgram = function (context) {
  8652. if(context.length >= 3){
  8653. SecurityFcy.getUserToken().then(function (token) {
  8654. ProgramFcy.searchByName(context, token, eec.EpisodeSearchData.Offset, eec.EpisodeSearchData.Limit).then(function (result) {
  8655. if (chooseOption == 1) {
  8656. selectize.addOption(result);
  8657. selectize.refreshOptions();
  8658.  
  8659. } else if (chooseOption == 2) {
  8660. selectize2.addOption(result);
  8661. selectize2.refreshOptions();
  8662. } else if (chooseOption == 4) {
  8663. selectize4.addOption(result);
  8664. selectize4.refreshOptions();
  8665. }
  8666. eec.ProgramSearchData.Items = result;
  8667. itemLoading.hide();
  8668. })
  8669. });
  8670. }else{
  8671. itemLoading.hide();
  8672. }
  8673. };
  8674.  
  8675. eec.SearchArtist = function (context) {
  8676. if(context.length >= 3){
  8677. SecurityFcy.getUserToken().then(function (token) {
  8678. ArtistFcy.searchByName(context, token, eec.ArtisSearchData.Offset, eec.ArtisSearchData.Limit).then(function (result) {
  8679. if (chooseOption == 1) {
  8680. selectize.addOption(result);
  8681. selectize.refreshOptions();
  8682.  
  8683. } else if (chooseOption == 2) {
  8684. selectize2.addOption(result);
  8685. selectize2.refreshOptions();
  8686. }
  8687. eec.ArtisSearchData.Items = result;
  8688. itemLoading.hide();
  8689. })
  8690. });
  8691. }else{
  8692. itemLoading.hide();
  8693. }
  8694. };
  8695. eec.SearchFavoriteList = function (context) {
  8696. if(context.length >= 3){
  8697. SecurityFcy.getUserToken().then(function (token) {
  8698. FavoriteListFcy.searchByName(context, token, eec.TagSearchData.Offset, eec.TagSearchData.Limit).then(function (result) {
  8699. if (chooseOption == 1) {
  8700. selectize.addOption(result);
  8701. selectize.refreshOptions();
  8702.  
  8703. } else if (chooseOption == 2) {
  8704. selectize2.addOption(result);
  8705. selectize2.refreshOptions();
  8706. } else if (chooseOption == 3) {
  8707. selectize3.addOption(result);
  8708. selectize3.refreshOptions();
  8709. }
  8710. eec.TagSearchData.Items = result;
  8711. itemLoading.hide();
  8712. })
  8713. })
  8714.  
  8715. }else{
  8716. itemLoading.hide();
  8717. }
  8718. };
  8719. eec.SearchTag = function (context) {
  8720. if(context.length >= 3){
  8721. SecurityFcy.getUserToken().then(function (token) {
  8722. TagFcy.searchByName(context, token, eec.TagSearchData.Offset, eec.TagSearchData.Limit).then(function (result) {
  8723. if (chooseOption == 1) {
  8724. selectize.addOption(result);
  8725. selectize.refreshOptions();
  8726.  
  8727. } else if (chooseOption == 2) {
  8728. selectize2.addOption(result);
  8729. selectize2.refreshOptions();
  8730. }
  8731. eec.TagSearchData.Items = result;
  8732. itemLoading.hide();
  8733. })
  8734. })
  8735. }else{
  8736. itemLoading.hide();
  8737. }
  8738. };
  8739. eec.SearchCountry = function (context) {
  8740. if(context.length >= 3){
  8741. SecurityFcy.getUserToken().then(function (token) {
  8742. ProgramFcy.searchCountryByName(context, token, eec.CountrySearchData.Offset, eec.CountrySearchData.Limit).then(function (result) {
  8743. if (chooseOption == 8) {
  8744.  
  8745. selectize5.addOption(result);
  8746. selectize5.refreshOptions();
  8747.  
  8748. }
  8749. eec.CountrySearchData.Items = result;
  8750. itemLoading.hide();
  8751. })
  8752. })
  8753. }else{
  8754. itemLoading.hide();
  8755. }
  8756. };
  8757. var itemLoading = null;
  8758. var t = null;
  8759. var chooseOption = null;
  8760. $(document).on("input",".program .selectize-input input",function () {
  8761. if(t!=null){
  8762. clearTimeout(t);
  8763. }
  8764. itemLoading = $(this).parents(".input-holder").find(".loader");
  8765. if($(this).val().length>3){
  8766. itemLoading.show();
  8767. }
  8768. chooseOption = 4;
  8769. var value = $(this).val();
  8770. t = setTimeout(function(){eec.SearchProgram(value)},800);
  8771. });
  8772. $(document).on("input",".country-list .selectize-input input",function () {
  8773. if(t!=null){
  8774. clearTimeout(t);
  8775. }
  8776. itemLoading = $(this).parents(".input-holder").find(".loader");
  8777. if($(this).val().length>3){
  8778. itemLoading.show();
  8779. }
  8780. chooseOption = 8;
  8781. var value = $(this).val();
  8782. t = setTimeout(function(){eec.SearchCountry(value)},800);
  8783. });
  8784. $(document).on("input",".option-artist .selectize-input input",function () {
  8785. if(t!=null){
  8786. clearTimeout(t);
  8787. }
  8788. itemLoading = $(this).parents(".input-holder").find(".loader");
  8789. if($(this).val().length>3){
  8790. itemLoading.show();
  8791. }
  8792. chooseOption = 1;
  8793. var value = $(this).val();
  8794. t = setTimeout(function(){eec.SearchArtist(value)},800);
  8795. });
  8796. $(document).on("input",".fav-list .selectize-input input",function () {
  8797. if(t!=null){
  8798. clearTimeout(t);
  8799. }
  8800. itemLoading = $(this).parents(".input-holder").find(".loader");
  8801. if($(this).val().length>3){
  8802. itemLoading.show();
  8803. }
  8804. chooseOption = 3;
  8805. var value = $(this).val();
  8806. t = setTimeout(function(){eec.SearchFavoriteList(value)},800);
  8807. });
  8808.  
  8809. $(document).on("input","#MetaDescription",function () {
  8810. remainCount.countRemain("MetaDescription",300);
  8811. })
  8812. }
  8813. function EditArtistCtrl(UserSrv,$rootScope,SiteConstants,ProgressBarFcy,EpisodeSrv,$routeParams,$window,ArtistSrv) {
  8814. var aec = this;
  8815. $rootScope.Page.Title="ویرایش اطلاعات هنرمند";
  8816. $rootScope.$broadcast("UserData");
  8817. ProgressBarFcy.setDone();
  8818. aec.ArtistData={};
  8819. aec.ArtistStatus={InProgress:false};
  8820.  
  8821. aec.Save = function () {
  8822. aec.ArtistStatus.InProgress=true;
  8823. ArtistSrv.updateArtist(aec.ArtistData.id, aec.ArtistData.title, aec.ArtistData.nickname, aec.ArtistData.gender,
  8824. aec.ArtistData.biography, aec.ArtistData.birth_palce, aec.ArtistData.activities).then(function (result) {
  8825. aec.ArtistStatus.InProgress=false;
  8826. })
  8827. }
  8828. }
  8829. function EditFavoriteListCtrl(UserSrv,$rootScope,SiteConstants,ProgressBarFcy,EpisodeSrv,$routeParams,$window,FavoriteListSrv,SecurityFcy,FavoriteListFcy,UserSrv) {
  8830. var fec = this;
  8831. $rootScope.Page.Title="ویرایش لیست تماشا";
  8832. $rootScope.$broadcast("UserData");
  8833. ProgressBarFcy.setDone();
  8834. fec.SearchFavoriteList = function (context) {
  8835. if(context.length >= 3){
  8836. SecurityFcy.getUserToken().then(function (token) {
  8837. FavoriteListFcy.searchByName(context, token, eec.TagSearchData.Offset, eec.TagSearchData.Limit).then(function (result) {
  8838. if (chooseOption == 1) {
  8839. selectize.addOption(result);
  8840. selectize.refreshOptions();
  8841.  
  8842. } else if (chooseOption == 2) {
  8843. selectize2.addOption(result);
  8844. selectize2.refreshOptions();
  8845. } else if (chooseOption == 3) {
  8846. selectize3.addOption(result);
  8847. selectize3.refreshOptions();
  8848. }
  8849. eec.TagSearchData.Items = result;
  8850. itemLoading.hide();
  8851. })
  8852. })
  8853.  
  8854. }else{
  8855. itemLoading.hide();
  8856. }
  8857. };
  8858. fec.FavoriteListData={};
  8859.  
  8860. fec.TagSearchData={Offset:0,Limit:15,UpdateInProgress:false,Items:[],Page:0};
  8861. fec.FavoriteListEpisodesData={Offset:0,Limit:15,UpdateInProgress:false,Episodes:[],Page:0};
  8862. var selectize,t,chooseOption,itemLoading;
  8863. fec.FavoriteListStatus={InProgress:false};
  8864. fec.SearchFavoriteList = function (context) {
  8865. if(context.length >= 3){
  8866. SecurityFcy.getUserToken().then(function (token) {
  8867. FavoriteListFcy.searchByName(context, token, fec.TagSearchData.Offset, fec.TagSearchData.Limit).then(function (result) {
  8868. if (chooseOption == 1) {
  8869. selectize.addOption(result);
  8870. selectize.refreshOptions();
  8871. }
  8872. fec.TagSearchData.Items = result;
  8873. itemLoading.hide();
  8874. })
  8875. })
  8876.  
  8877. }else{
  8878. itemLoading.hide();
  8879. }
  8880. };
  8881. fec.getListData = function () {
  8882. SecurityFcy.getUserToken().then(function (token) {
  8883. fec.FavoriteListData.parent = null;
  8884. FavoriteListSrv.getFavoriteList($routeParams.Id,token).then(function (result) {
  8885. fec.FavoriteListData = result;
  8886.  
  8887.  
  8888. var $select = $('#Parent').selectize({
  8889. valueField: 'id',
  8890. labelField: 'name_fa',
  8891. searchField: 'name_fa',
  8892. maxItems:1,
  8893. create: function (input) {
  8894. return {
  8895. value: input.id,
  8896. text: input.name
  8897. }
  8898. },
  8899. render: {
  8900. option_create: function (data, escape) {
  8901. return '';
  8902. }
  8903. }
  8904.  
  8905. });
  8906.  
  8907. selectize = $select[0].selectize;
  8908. if(result.parent !=null){
  8909. selectize.addOption(result.parent);
  8910. selectize.addItem(result.parent.id);
  8911. }
  8912. })
  8913. })
  8914. }
  8915. fec.getEpisodeLists = function () {
  8916. fec.FavoriteListEpisodesData.UpdateInProgress = true;
  8917. FavoriteListSrv.getChildEpisodeList($routeParams.Id, fec.FavoriteListEpisodesData.Offset, fec.FavoriteListEpisodesData.Limit).then(function (result) {
  8918. fec.FavoriteListEpisodesData.Episodes = result;
  8919. fec.FavoriteListEpisodesData.UpdateInProgress = false;
  8920. })
  8921. }
  8922.  
  8923. $(document).on("input",".favlist-farsi .selectize-input input",function () {
  8924. if(t!=null){
  8925. clearTimeout(t);
  8926. }
  8927. itemLoading = $(this).parents(".input-holder").find(".loader");
  8928. if($(this).val().length>3){
  8929. itemLoading.show();
  8930. }
  8931. chooseOption = 1;
  8932. var value = $(this).val();
  8933. t = setTimeout(function(){fec.SearchFavoriteList(value)},800);
  8934. });
  8935. UserSrv.getUser().then(function (result) {
  8936. if(typeof result!='undefined' && result!=null && typeof result.token!='undefined' && ($rootScope.InArray('admin', result.credentials) || $rootScope.InArray('superadmin', result.credentials) || $rootScope.InArray('operator', result.credentials))){
  8937. SecurityFcy.getUserToken().then(function (token) {
  8938. fec.getListData();
  8939. fec.getEpisodeLists();
  8940. });
  8941. }
  8942. else {
  8943. NgNote.Error('کاربر گرامی شما اجازه دسترسی به این بخش را ندارید',3);
  8944. setTimeout(function(){
  8945. $window.location.replace("/#!/");
  8946. },1000);
  8947. }
  8948. });
  8949. fec.Save = function () {
  8950. fec.FavoriteListStatus.InProgress=true;
  8951. SecurityFcy.getUserToken().then(function (token) {
  8952. FavoriteListSrv.updateFavoriteList(fec.FavoriteListData.id, fec.FavoriteListData.name_fa, fec.FavoriteListData.name_en, fec.FavoriteListData.parent, fec.FavoriteListData.child_description, token).then(function (result) {
  8953. fec.FavoriteListStatus.InProgress = false;
  8954. NgNote.Success('اطلاعات شما با موفقیت به روز شد',3);
  8955. })
  8956. })
  8957. }
  8958. }
  8959. function AddArtistCtrl(UserSrv,$rootScope,SiteConstants,ProgressBarFcy,EpisodeSrv,$routeParams,$window,ArtistSrv){
  8960. var aac = this;
  8961. $rootScope.Page.Title="افزودن اطلاعات هنرمند";
  8962. $rootScope.$broadcast("UserData");
  8963. ProgressBarFcy.setDone();
  8964. aac.ArtistData={};
  8965. aac.ArtistStatus={InProgress:false};
  8966. aac.Save = function () {
  8967. aac.ArtistStatus.InProgress=true;
  8968. ArtistSrv.createArtist(aac.ArtistData.title, aac.ArtistData.nickname, aac.ArtistData.gender,
  8969. aac.ArtistData.biography, aac.ArtistData.birth_palce, aac.ArtistData.activities).then(function (result) {
  8970. aac.ArtistStatus.InProgress=false;
  8971. })
  8972. }
  8973. }
  8974. function AddFavoriteListCtrl(UserSrv,$rootScope,SiteConstants,ProgressBarFcy,EpisodeSrv,$routeParams,$window,FavoriteListSrv,SecurityFcy,FavoriteListFcy) {
  8975. var fac = this;
  8976. $rootScope.Page.Title="افزودن لیست تماشا";
  8977. $rootScope.$broadcast("UserData");
  8978. ProgressBarFcy.setDone();
  8979. fac.FavoriteListData={};
  8980. fac.FavoriteListStatus={InProgress:false};
  8981. fac.TagSearchData={Offset:0,Limit:15,UpdateInProgress:false,Items:[],Page:0};
  8982. var selectize,t,chooseOption,itemLoading;
  8983. fac.SearchFavoriteList = function (context) {
  8984. if(context.length >= 3){
  8985. SecurityFcy.getUserToken().then(function (token) {
  8986. FavoriteListFcy.searchByName(context, token, fac.TagSearchData.Offset, fac.TagSearchData.Limit).then(function (result) {
  8987. if (chooseOption == 1) {
  8988. selectize.addOption(result);
  8989. selectize.refreshOptions();
  8990. }
  8991. fac.TagSearchData.Items = result;
  8992. itemLoading.hide();
  8993. })
  8994. })
  8995.  
  8996. }else{
  8997. itemLoading.hide();
  8998. }
  8999. };
  9000. setTimeout(function () {
  9001. var $select = $('#Parent').selectize({
  9002. valueField: 'id',
  9003. labelField: 'name_fa',
  9004. searchField: 'name_fa',
  9005. maxItems:1,
  9006. create: function (input) {
  9007. return {
  9008. value: input.id,
  9009. text: input.name
  9010. }
  9011. },
  9012. render: {
  9013. option_create: function (data, escape) {
  9014. return '';
  9015. }
  9016. }
  9017. });
  9018. selectize = $select[0].selectize;
  9019. },1000);
  9020. $(document).on("input",".favlist-farsi .selectize-input input",function () {
  9021. if(t!=null){
  9022. clearTimeout(t);
  9023. }
  9024. itemLoading = $(this).parents(".input-holder").find(".loader");
  9025. if($(this).val().length>3){
  9026. itemLoading.show();
  9027. }
  9028. chooseOption = 1;
  9029. var value = $(this).val();
  9030. t = setTimeout(function(){fac.SearchFavoriteList(value)},800);
  9031. });
  9032.  
  9033. fac.Save = function () {
  9034. fac.FavoriteListStatus.InProgress=true;
  9035. SecurityFcy.getUserToken().then(function (token){
  9036. FavoriteListSrv.createFavoriteList(fac.FavoriteListData.name_fa, fac.FavoriteListData.name_en, fac.FavoriteListData.parent, fac.FavoriteListData.child_description, token).then(function (result) {
  9037. if(result){
  9038. NgNote.Success('لیست تماشا با موفقیت افزوده شد', 5);
  9039. }
  9040. else {
  9041. NgNote.Error('خطا در ثبت، لطفا مجددا تلاش فرمایید', 3);
  9042. }
  9043. fac.FavoriteListStatus.InProgress=false;
  9044. })
  9045. });
  9046.  
  9047. }
  9048. fac.SearchFavoriteList = function (context) {
  9049. if(context.length >= 3){
  9050. SecurityFcy.getUserToken().then(function (token) {
  9051. FavoriteListFcy.searchByName(context, token, fac.TagSearchData.Offset, fac.TagSearchData.Limit).then(function (result) {
  9052. if (chooseOption == 1) {
  9053. selectize.addOption(result);
  9054. selectize.refreshOptions();
  9055. } else if (chooseOption == 2) {
  9056. selectize2.addOption(result);
  9057. selectize2.refreshOptions();
  9058. } else if (chooseOption == 3) {
  9059. selectize3.addOption(result);
  9060. selectize3.refreshOptions();
  9061. }
  9062. fac.TagSearchData.Items = result;
  9063. itemLoading.hide();
  9064. })
  9065. })
  9066.  
  9067. }else{
  9068. itemLoading.hide();
  9069. }
  9070. };
  9071.  
  9072. }
  9073. function AddProgramCtrl(UserSrv,$rootScope,SiteConstants,ProgressBarFcy,ProgramSrv,$routeParams,$window,SecurityFcy,ArtistFcy,ProgramFcy) {
  9074. var apc = this;
  9075. apc.ProgramStatus = { InProgress:false};
  9076. $rootScope.Page.Title="افزودن اطلاعات برنامه";
  9077. $rootScope.$broadcast("UserData");
  9078. apc.ArtisSearchData={Offset:0,Limit:15,UpdateInProgress:false,Items:[],Page:0};
  9079. apc.TagSearchData={Offset:0,Limit:15,UpdateInProgress:false,Items:[],Page:0};
  9080. apc.CountrySearchData={Offset:0,Limit:15,UpdateInProgress:false,Items:[],Page:0};
  9081. apc.ArtistSearchData={Offset:0,Limit:15,UpdateInProgress:false,Items:[],Page:0};
  9082. apc.Directors = null;
  9083. apc.Provider = {};
  9084. apc.Actors = null;
  9085. apc.Genres = {};
  9086. apc.Categoires = {};
  9087. apc.favLists = null;
  9088.  
  9089. ProgressBarFcy.setDone();
  9090. var selectize,selectize2,selectize3,selectize4,selectize5,selectize6,toArrayConversion = [],toArrayConversion2 = [],counter=0;
  9091.  
  9092. apc.ProgramData = {};
  9093. apc.importanceModel = [{id:1,title:"سطح ۱"},{id:2,title:"سطح ۲"},{id:3,title:"سطح ۳"},{id:4,title:"سطح ۴"},{id:5,title:"سطح ۵"}];
  9094. UserSrv.getUser().then(function (result) {
  9095. if(typeof result!='undefined' && result!=null && typeof result.token!='undefined' && ($rootScope.InArray('admin', result.credentials) || $rootScope.InArray('superadmin', result.credentials) || $rootScope.InArray('operator', result.credentials))){
  9096.  
  9097. }
  9098. else {
  9099. NgNote.Error('کاربر گرامی شما اجازه دسترسی به این بخش را ندارید',3);
  9100. setTimeout(function(){
  9101. $window.location.replace("/#!/");
  9102. },1000);
  9103. }
  9104. });
  9105.  
  9106.  
  9107. apc.saveProgram = function () {
  9108. counter = 0;
  9109. $("#check-checkboxes input[type=checkbox]").each(function () {
  9110. if($(this).is(":checked")){
  9111. toArrayConversion[counter] = $(this).attr("ng-value");
  9112. counter++;
  9113. }
  9114. });
  9115. counter = 0;
  9116. $("#check-checkboxes2 input[type=checkbox]").each(function () {
  9117. if($(this).is(":checked")){
  9118. toArrayConversion2[counter] = $(this).attr("ng-value");
  9119. counter++;
  9120. }
  9121. });
  9122. if(toArrayConversion.length>0) {
  9123. //toArrayConversion[toArrayConversion.length] = "";
  9124. apc.Genres = toArrayConversion.join();
  9125. }else{
  9126. apc.Genres = "";
  9127. }
  9128. if(toArrayConversion2.length>0){
  9129. //toArrayConversion2[toArrayConversion2.length] = "";
  9130. apc.Categoires = toArrayConversion2.join();
  9131. } else{
  9132. apc.Categoires = "";
  9133. }
  9134. apc.ProgramStatus.InProgress = true;
  9135. SecurityFcy.getUserToken().then(function (token) {
  9136. if(typeof apc.Actors=='object'){
  9137. apc.Actors='';
  9138. }
  9139. var copyright_type = $("input[name=copyright-type]:checked").val();
  9140. ProgramSrv.createProgram(apc.ProgramData.id, apc.ProgramData.title, apc.ProgramData.title_english,
  9141. apc.ProgramData.summary_fa, apc.ProgramData.summary_en, apc.ProgramData.tags, apc.ProgramData.downloadable,
  9142. apc.ProgramData.enable, apc.ProgramData.is_singleton, apc.ProgramData.keywords_english,
  9143. apc.ProgramData.page_description, apc.Actors, apc.Directors, apc.Producer, apc.Authors, apc.Others,
  9144. apc.Genres, apc.Categoires, token,copyright_type,apc.copyright,apc.ProgramData.importance).then(function (result) {
  9145. toArrayConversion = [];
  9146. toArrayConversion2 = [];
  9147. if(result!=-1){
  9148. apc.ProgramStatus.InProgress = false;
  9149. NgNote.Success('اطلاعات اپیزود با موفقیت به ثبت رسید',5);
  9150. }else {
  9151. NgNote.Error('خطا در ارسال داده به سرور، لطفا مجددا تلاش نمایید',5);
  9152. apc.ProgramStatus.InProgress = false;
  9153. }
  9154. })
  9155. });
  9156. };
  9157. apc.SearchArtist = function (context) {
  9158. if(context.length >= 3){
  9159. SecurityFcy.getUserToken().then(function (token) {
  9160. ArtistFcy.searchByName(context, token, apc.ArtistSearchData.Offset, apc.ArtistSearchData.Limit).then(function (result) {
  9161.  
  9162. if (chooseOption == 1) {
  9163. selectize.addOption(result);
  9164. selectize.refreshOptions();
  9165.  
  9166. } else if (chooseOption == 2) {
  9167. selectize2.addOption(result);
  9168. selectize2.refreshOptions();
  9169. } else if (chooseOption == 3) {
  9170. selectize3.addOption(result);
  9171. selectize3.refreshOptions();
  9172.  
  9173. } else if (chooseOption == 4) {
  9174. selectize4.addOption(result);
  9175. selectize4.refreshOptions();
  9176. }else if (chooseOption == 5) {
  9177. selectize5.addOption(result);
  9178. selectize5.refreshOptions();
  9179. }
  9180. apc.ArtistSearchData.Items = result;
  9181. itemLoading.hide();
  9182. })
  9183. });
  9184. }else{
  9185. itemLoading.hide();
  9186. }
  9187. };
  9188. apc.SearchFavoriteList = function (context) {
  9189. if(context.length >= 3){
  9190. SecurityFcy.getUserToken().then(function (token) {
  9191. FavoriteListFcy.searchByName(context, token, apc.TagSearchData.Offset, apc.TagSearchData.Limit).then(function (result) {
  9192. if (chooseOption == 1) {
  9193. selectize.addOption(result);
  9194. selectize.refreshOptions();
  9195.  
  9196. } else if (chooseOption == 2) {
  9197. selectize2.addOption(result);
  9198. selectize2.refreshOptions();
  9199. } else if (chooseOption == 3) {
  9200. selectize3.addOption(result);
  9201. selectize3.refreshOptions();
  9202. }
  9203. apc.TagSearchData.Items = result;
  9204. itemLoading.hide();
  9205. })
  9206. })
  9207.  
  9208. }else{
  9209. itemLoading.hide();
  9210. }
  9211. };
  9212. apc.SearchCountry = function (context) {
  9213. if(context.length >= 3){
  9214. SecurityFcy.getUserToken().then(function (token) {
  9215. ProgramFcy.searchCountryByName(context, token, apc.CountrySearchData.Offset, apc.CountrySearchData.Limit).then(function (result) {
  9216.  
  9217. if (chooseOption == 8) {
  9218. selectize6.addOption(result);
  9219. selectize6.refreshOptions();
  9220.  
  9221. }
  9222. apc.CountrySearchData.Items = result;
  9223. itemLoading.hide();
  9224. })
  9225. })
  9226. }else{
  9227. itemLoading.hide();
  9228. }
  9229. };
  9230. apc.SearchTag = function (context) {
  9231. if(context.length >= 3){
  9232. SecurityFcy.getUserToken().then(function (token) {
  9233. TagFcy.searchByName(context, token, apc.TagSearchData.Offset, apc.TagSearchData.Limit).then(function (result) {
  9234.  
  9235. if (chooseOption == 1) {
  9236. selectize.addOption(result);
  9237. selectize.refreshOptions();
  9238.  
  9239. } else if (chooseOption == 2) {
  9240. selectize2.addOption(result);
  9241. selectize2.refreshOptions();
  9242. }
  9243. apc.TagSearchData.Items = result;
  9244. itemLoading.hide();
  9245. })
  9246. })
  9247. }else{
  9248. itemLoading.hide();
  9249. }
  9250. };
  9251.  
  9252. setTimeout(function () {
  9253. $("#picture-form option").eq(0).remove();
  9254. // replacePipelineAddress.replace($(this).find("img"));
  9255. // replacePipelineAddressAngular();
  9256. var $select6 = $('.taggings').selectize({
  9257. delimiter: ',',
  9258. persist: false,
  9259. create: function (input) {
  9260. return {
  9261. value: input,
  9262. text: input
  9263. }
  9264. }
  9265. });
  9266. $('#KeywordsEnglish').selectize({
  9267. delimiter: '#',
  9268. persist: false,
  9269. create: function (input) {
  9270. return {
  9271. value: input,
  9272. text: input
  9273. }
  9274. }
  9275. });
  9276.  
  9277. var $select = $('#director').selectize({
  9278. valueField: 'id',
  9279. labelField: 'title',
  9280. searchField: 'title',
  9281.  
  9282. create: function (input) {
  9283. return {
  9284. value: input,
  9285. text: input
  9286. }
  9287. },
  9288. render: {
  9289. option_create: function (data, escape) {
  9290. return '';
  9291. }
  9292. }
  9293. });
  9294.  
  9295. var $select6 = $('#copyright-field').selectize({
  9296. valueField: 'descriptor',
  9297. labelField: 'name',
  9298. searchField: 'name',
  9299.  
  9300. create: function (input) {
  9301. return {
  9302. value: input,
  9303. text: input
  9304. }
  9305. },
  9306. render: {
  9307. option_create: function (data, escape) {
  9308. return '';
  9309. }
  9310. }
  9311. });
  9312. var $select = $('#director').selectize({
  9313. valueField: 'id',
  9314. labelField: 'title',
  9315. searchField: 'title',
  9316.  
  9317. create: function (input) {
  9318. return {
  9319. value: input,
  9320. text: input
  9321. }
  9322. },
  9323. render: {
  9324. option_create: function (data, escape) {
  9325. return '';
  9326. }
  9327. }
  9328. });
  9329. var $select2 = $('#Actors').selectize({
  9330. valueField: 'id',
  9331. labelField: 'title',
  9332. searchField: 'title',
  9333.  
  9334. create: function (input) {
  9335. return {
  9336. value: input,
  9337. text: input
  9338. }
  9339. },
  9340. render: {
  9341. option_create: function (data, escape) {
  9342. return '';
  9343. }
  9344. }
  9345. });
  9346. var $select3 = $('#producer').selectize({
  9347. valueField: 'id',
  9348. labelField: 'title',
  9349. searchField: 'title',
  9350.  
  9351. create: function (input) {
  9352. return {
  9353. value: input,
  9354. text: input
  9355. }
  9356. },
  9357. render: {
  9358. option_create: function (data, escape) {
  9359. return '';
  9360. }
  9361. }
  9362. });
  9363. var $select4 = $('#writer').selectize({
  9364. valueField: 'id',
  9365. labelField: 'title',
  9366. searchField: 'title',
  9367.  
  9368. create: function (input) {
  9369. return {
  9370. value: input,
  9371. text: input
  9372. }
  9373. },
  9374. render: {
  9375. option_create: function (data, escape) {
  9376. return '';
  9377. }
  9378. }
  9379. });
  9380. var $select5 = $('#other-cast').selectize({
  9381. valueField: 'id',
  9382. labelField: 'title',
  9383. searchField: 'title',
  9384.  
  9385. create: function (input) {
  9386. return {
  9387. value: input,
  9388. text: input
  9389. }
  9390. },
  9391. render: {
  9392. option_create: function (data, escape) {
  9393. return '';
  9394. }
  9395. }
  9396. });
  9397. selectize = $select[0].selectize;
  9398. selectize2 = $select2[0].selectize;
  9399. selectize3 = $select3[0].selectize;
  9400. selectize4 = $select4[0].selectize;
  9401. selectize5 = $select5[0].selectize;
  9402. selectize6 = $select6[0].selectize;
  9403. $('#writer').val("");
  9404. $("#director").val("");
  9405. $("#other-cast").val("");
  9406. $("#producer").val("");
  9407. $("#Actors").val("");
  9408. remainCount.countRemain("PageDescription", 300);
  9409.  
  9410.  
  9411. if (apc.ProgramData.enable) {
  9412. apc.ProgramData.enable = true;
  9413. }
  9414. if (apc.ProgramData.is_singleton) {
  9415. apc.ProgramData.is_singleton = true;
  9416. }
  9417. if (apc.ProgramData.downloadable) {
  9418. apc.ProgramData.downloadable = true;
  9419. }
  9420. });
  9421.  
  9422. var itemLoading = null;
  9423. var t = null;
  9424. var chooseOption = null;
  9425. $(document).on("input",".artist-search .selectize-input input",function () {
  9426. if(t!=null){
  9427. clearTimeout(t);
  9428. }
  9429. itemLoading = $(this).parents(".input-holder").find(".loader");
  9430. if($(this).val().length>3){
  9431. itemLoading.show();
  9432. }
  9433. chooseOption = 1;
  9434. var value = $(this).val();
  9435. t = setTimeout(function(){apc.SearchArtist(value)},800);
  9436. });
  9437. $(document).on("input",".country-list .selectize-input input",function () {
  9438. if(t!=null){
  9439. clearTimeout(t);
  9440. }
  9441. itemLoading = $(this).parents(".input-holder").find(".loader");
  9442. if($(this).val().length>3){
  9443. itemLoading.show();
  9444. }
  9445. chooseOption = 8;
  9446. var value = $(this).val();
  9447. t = setTimeout(function(){apc.SearchCountry(value)},800);
  9448. });
  9449. $(document).on("input",".search-writer .selectize-input input",function () {
  9450. if(t!=null){
  9451. clearTimeout(t);
  9452. }
  9453. itemLoading = $(this).parents(".input-holder").find(".loader");
  9454. if($(this).val().length>3){
  9455. itemLoading.show();
  9456. }
  9457. chooseOption = 4;
  9458. var value = $(this).val();
  9459. t = setTimeout(function(){apc.SearchArtist(value)},800);
  9460. });
  9461. $(document).on("input",".search-main-artist .selectize-input input",function () {
  9462. if(t!=null){
  9463. clearTimeout(t);
  9464. }
  9465. itemLoading = $(this).parents(".input-holder").find(".loader");
  9466. if($(this).val().length>3){
  9467. itemLoading.show();
  9468. }
  9469. chooseOption = 2;
  9470. var value = $(this).val();
  9471. t = setTimeout(function(){apc.SearchArtist(value)},800);
  9472. });
  9473. $(document).on("input",".search-provider .selectize-input input",function () {
  9474. if(t!=null){
  9475. clearTimeout(t);
  9476. }
  9477. itemLoading = $(this).parents(".input-holder").find(".loader");
  9478. if($(this).val().length>3){
  9479. itemLoading.show();
  9480. }
  9481. chooseOption = 3;
  9482. var value = $(this).val();
  9483. t = setTimeout(function(){apc.SearchArtist(value)},800);
  9484. });
  9485. $(document).on("input",".other-cast .selectize-input input",function () {
  9486. if(t!=null){
  9487. clearTimeout(t);
  9488. }
  9489. itemLoading = $(this).parents(".input-holder").find(".loader");
  9490. if($(this).val().length>3){
  9491. itemLoading.show();
  9492. }
  9493. chooseOption = 5;
  9494. var value = $(this).val();
  9495. t = setTimeout(function(){apc.SearchArtist(value)},800);
  9496. });
  9497.  
  9498. $(document).on("input","#PageDescription",function () {
  9499. remainCount.countRemain("PageDescription",300);
  9500. });
  9501. }
  9502. function EditProgramCtrl(UserSrv,$rootScope,SiteConstants,ProgressBarFcy,ProgramSrv,$routeParams,$window,SecurityFcy,ArtistFcy,ProgramFcy) {
  9503. var epc = this;
  9504. epc.ProgramStatus = { InProgress:false};
  9505. $rootScope.Page.Title="ویرایش اطلاعات برنامه";
  9506. $rootScope.$broadcast("UserData");
  9507. epc.ArtisSearchData={Offset:0,Limit:15,UpdateInProgress:false,Items:[],Page:0};
  9508. epc.TagSearchData={Offset:0,Limit:15,UpdateInProgress:false,Items:[],Page:0};
  9509. epc.CountrySearchData={Offset:0,Limit:15,UpdateInProgress:false,Items:[],Page:0};
  9510. epc.ArtistSearchData={Offset:0,Limit:15,UpdateInProgress:false,Items:[],Page:0};
  9511. epc.Directors = null;
  9512. epc.Provider = {};
  9513. epc.Actors = null;
  9514. epc.Genres = {};
  9515. epc.Categoires = {};
  9516. epc.favLists = null;
  9517. // epc.HoursList = [];
  9518. // epc.MinutesList = [];
  9519. // epc.publishedMinute = 0;
  9520. // epc.publishedHour = 0;
  9521. // for(var i = 0;i<=24;i++){
  9522. // var item = {id:0,title:0};
  9523. // item.id = i;
  9524. // item.title = i+ ' ساعت ';
  9525. // epc.HoursList.push(item)
  9526. // }
  9527. // for(var i = 0;i<60;i++){
  9528. // var item = {id:0,title:0};
  9529. // item.id = i;
  9530. // item.title = i + ' دقیقه ';
  9531. // epc.MinutesList.push(item)
  9532. // }
  9533. ProgressBarFcy.setDone();
  9534. var selectize,selectize2,selectize3,selectize4,selectize5,selectize6,toArrayConversion = [],toArrayConversion2 = [],counter=0;
  9535.  
  9536. epc.ProgramData = {};
  9537. epc.importanceModel = [{id:1,title:"سطح ۱"},{id:2,title:"سطح ۲"},{id:3,title:"سطح ۳"},{id:4,title:"سطح ۴"},{id:5,title:"سطح ۵"}];
  9538. UserSrv.getUser().then(function (result) {
  9539. if(typeof result!='undefined' && result!=null && typeof result.token!='undefined' && ($rootScope.InArray('admin', result.credentials) || $rootScope.InArray('superadmin', result.credentials) || $rootScope.InArray('operator', result.credentials))){
  9540. SecurityFcy.getUserToken().then(function (token) {
  9541. // CalendarSetup.setup("show_time")
  9542. epc.GetProgram($routeParams.Id, token);
  9543. });
  9544. }
  9545. else {
  9546. NgNote.Error('کاربر گرامی شما اجازه دسترسی به این بخش را ندارید',3);
  9547. setTimeout(function(){
  9548. $window.location.replace("/#!/");
  9549. },1000);
  9550. }
  9551. });
  9552.  
  9553.  
  9554. epc.saveProgram = function () {
  9555. counter = 0;
  9556. $("#check-checkboxes input[type=checkbox]").each(function () {
  9557. if($(this).is(":checked")){
  9558. toArrayConversion[counter] = $(this).attr("ng-value");
  9559. counter++;
  9560. }
  9561. });
  9562. counter = 0;
  9563. $("#check-checkboxes2 input[type=checkbox]").each(function () {
  9564. if($(this).is(":checked")){
  9565. toArrayConversion2[counter] = $(this).attr("ng-value");
  9566. counter++;
  9567. }
  9568. });
  9569. if(toArrayConversion.length>0) {
  9570. //toArrayConversion[toArrayConversion.length] = "";
  9571. epc.Genres = toArrayConversion.join();
  9572. }else{
  9573. epc.Genres = "";
  9574. }
  9575. if(toArrayConversion2.length>0){
  9576. //toArrayConversion2[toArrayConversion2.length] = "";
  9577. epc.Categoires = toArrayConversion2.join();
  9578. } else{
  9579. epc.Categoires = "";
  9580. }
  9581. epc.ProgramStatus.InProgress = true;
  9582. SecurityFcy.getUserToken().then(function (token) {
  9583. if(typeof epc.Actors=='object'){
  9584. epc.Actors='';
  9585. }
  9586. var copyright_type = $("input[name=copyright-type]:checked").val();
  9587. if(epc.Genres.length >= 1 && epc.Categoires.length >= 1) {
  9588. ProgramSrv.saveProgram(epc.ProgramData.id, epc.ProgramData.title, epc.ProgramData.title_english,
  9589. epc.ProgramData.summary_fa, epc.ProgramData.summary_en, epc.ProgramData.tags, epc.ProgramData.downloadable,
  9590. epc.ProgramData.enable, epc.ProgramData.is_singleton, epc.ProgramData.keywords_english,
  9591. epc.ProgramData.page_description, epc.Actors, epc.Directors, epc.Producer, epc.Authors, epc.Others,
  9592. epc.Genres, epc.Categoires, token, copyright_type, epc.copyright, epc.ProgramData.importance).then(function (result) {
  9593. toArrayConversion = [];
  9594. toArrayConversion2 = [];
  9595. if (result != -1) {
  9596. epc.ProgramStatus.InProgress = false;
  9597. NgNote.Success('اطلاعات اپیزود با موفقیت به ثبت رسید', 5);
  9598. } else {
  9599. NgNote.Error('خطا در ارسال داده به سرور، لطفا مجددا تلاش نمایید', 5);
  9600. epc.ProgramStatus.InProgress = false;
  9601. }
  9602.  
  9603. })
  9604. }else{
  9605. epc.ProgramStatus.InProgress = false;
  9606. alert("ژانر و دسته بندی اجباری میباشد.");
  9607. }
  9608. });
  9609. };
  9610. epc.SearchArtist = function (context) {
  9611. if(context.length >= 3){
  9612. SecurityFcy.getUserToken().then(function (token) {
  9613. ArtistFcy.searchByName(context, token, epc.ArtistSearchData.Offset, epc.ArtistSearchData.Limit).then(function (result) {
  9614.  
  9615. if (chooseOption == 1) {
  9616. selectize.addOption(result);
  9617. selectize.refreshOptions();
  9618.  
  9619. } else if (chooseOption == 2) {
  9620. selectize2.addOption(result);
  9621. selectize2.refreshOptions();
  9622. } else if (chooseOption == 3) {
  9623. selectize3.addOption(result);
  9624. selectize3.refreshOptions();
  9625.  
  9626. } else if (chooseOption == 4) {
  9627. selectize4.addOption(result);
  9628. selectize4.refreshOptions();
  9629. }else if (chooseOption == 5) {
  9630. selectize5.addOption(result);
  9631. selectize5.refreshOptions();
  9632. }
  9633. epc.ArtistSearchData.Items = result;
  9634. itemLoading.hide();
  9635. })
  9636. });
  9637. }else{
  9638. itemLoading.hide();
  9639. }
  9640. };
  9641. epc.SearchFavoriteList = function (context) {
  9642. if(context.length >= 3){
  9643. SecurityFcy.getUserToken().then(function (token) {
  9644. FavoriteListFcy.searchByName(context, token, epc.TagSearchData.Offset, epc.TagSearchData.Limit).then(function (result) {
  9645. if (chooseOption == 1) {
  9646. selectize.addOption(result);
  9647. selectize.refreshOptions();
  9648.  
  9649. } else if (chooseOption == 2) {
  9650. selectize2.addOption(result);
  9651. selectize2.refreshOptions();
  9652. } else if (chooseOption == 3) {
  9653. selectize3.addOption(result);
  9654. selectize3.refreshOptions();
  9655. }
  9656. epc.TagSearchData.Items = result;
  9657. itemLoading.hide();
  9658. })
  9659. })
  9660.  
  9661. }else{
  9662. itemLoading.hide();
  9663. }
  9664. };
  9665. epc.SearchCountry = function (context) {
  9666. if(context.length >= 3){
  9667. SecurityFcy.getUserToken().then(function (token) {
  9668. ProgramFcy.searchCountryByName(context, token, epc.CountrySearchData.Offset, epc.CountrySearchData.Limit).then(function (result) {
  9669.  
  9670. if (chooseOption == 8) {
  9671. selectize6.addOption(result);
  9672. selectize6.refreshOptions();
  9673.  
  9674. }
  9675. epc.CountrySearchData.Items = result;
  9676. itemLoading.hide();
  9677. })
  9678. })
  9679. }else{
  9680. itemLoading.hide();
  9681. }
  9682. };
  9683. epc.SearchTag = function (context) {
  9684. if(context.length >= 3){
  9685. SecurityFcy.getUserToken().then(function (token) {
  9686. TagFcy.searchByName(context, token, epc.TagSearchData.Offset, epc.TagSearchData.Limit).then(function (result) {
  9687.  
  9688. if (chooseOption == 1) {
  9689. selectize.addOption(result);
  9690. selectize.refreshOptions();
  9691.  
  9692. } else if (chooseOption == 2) {
  9693. selectize2.addOption(result);
  9694. selectize2.refreshOptions();
  9695. }
  9696. epc.TagSearchData.Items = result;
  9697. itemLoading.hide();
  9698. })
  9699. })
  9700. }else{
  9701. itemLoading.hide();
  9702. }
  9703. };
  9704. epc.GetProgram = function (Id, Token) {
  9705. ProgramSrv.getFullProgram(Id, Token).then(function (result) {
  9706. epc.ProgramData = result;
  9707. setTimeout(function () {
  9708. $("#picture-form option").eq(0).remove();
  9709. // replacePipelineAddress.replace($(this).find("img"));
  9710. // replacePipelineAddressAngular();
  9711. var $select6 = $('.taggings').selectize({
  9712. delimiter: ',',
  9713. persist: false,
  9714. create: function (input) {
  9715. return {
  9716. value: input,
  9717. text: input
  9718. }
  9719. }
  9720. });
  9721. $('#KeywordsEnglish').selectize({
  9722. delimiter: '#',
  9723. persist: false,
  9724. create: function (input) {
  9725. return {
  9726. value: input,
  9727. text: input
  9728. }
  9729. }
  9730. });
  9731.  
  9732. var $select = $('#director').selectize({
  9733. valueField: 'id',
  9734. labelField: 'title',
  9735. searchField: 'title',
  9736.  
  9737. create: function (input) {
  9738. return {
  9739. value: result.id,
  9740. text: result.name
  9741. }
  9742. },
  9743. render: {
  9744. option_create: function (data, escape) {
  9745. return '';
  9746. }
  9747. }
  9748. });
  9749.  
  9750. var $select6 = $('#copyright-field').selectize({
  9751. valueField: 'descriptor',
  9752. labelField: 'name',
  9753. searchField: 'name',
  9754.  
  9755. create: function (input) {
  9756. return {
  9757. value: input,
  9758. text: input
  9759. }
  9760. },
  9761. render: {
  9762. option_create: function (data, escape) {
  9763. return '';
  9764. }
  9765. }
  9766. });
  9767. var $select = $('#director').selectize({
  9768. valueField: 'id',
  9769. labelField: 'title',
  9770. searchField: 'title',
  9771.  
  9772. create: function (input) {
  9773. return {
  9774. value: result.id,
  9775. text: result.name
  9776. }
  9777. },
  9778. render: {
  9779. option_create: function (data, escape) {
  9780. return '';
  9781. }
  9782. }
  9783. });
  9784. var $select2 = $('#Actors').selectize({
  9785. valueField: 'id',
  9786. labelField: 'title',
  9787. searchField: 'title',
  9788.  
  9789. create: function (input) {
  9790. return {
  9791. value: result.id,
  9792. text: result.name
  9793. }
  9794. },
  9795. render: {
  9796. option_create: function (data, escape) {
  9797. return '';
  9798. }
  9799. }
  9800. });
  9801. var $select3 = $('#producer').selectize({
  9802. valueField: 'id',
  9803. labelField: 'title',
  9804. searchField: 'title',
  9805.  
  9806. create: function (input) {
  9807. return {
  9808. value: result.id,
  9809. text: result.name
  9810. }
  9811. },
  9812. render: {
  9813. option_create: function (data, escape) {
  9814. return '';
  9815. }
  9816. }
  9817. });
  9818. var $select4 = $('#writer').selectize({
  9819. valueField: 'id',
  9820. labelField: 'title',
  9821. searchField: 'title',
  9822.  
  9823. create: function (input) {
  9824. return {
  9825. value: result.id,
  9826. text: result.name
  9827. }
  9828. },
  9829. render: {
  9830. option_create: function (data, escape) {
  9831. return '';
  9832. }
  9833. }
  9834. });
  9835. var $select5 = $('#other-cast').selectize({
  9836. valueField: 'id',
  9837. labelField: 'title',
  9838. searchField: 'title',
  9839.  
  9840. create: function (input) {
  9841. return {
  9842. value: result.id,
  9843. text: result.name
  9844. }
  9845. },
  9846. render: {
  9847. option_create: function (data, escape) {
  9848. return '';
  9849. }
  9850. }
  9851. });
  9852. selectize = $select[0].selectize;
  9853. selectize2 = $select2[0].selectize;
  9854. selectize3 = $select3[0].selectize;
  9855. selectize4 = $select4[0].selectize;
  9856. selectize5 = $select5[0].selectize;
  9857. selectize6 = $select6[0].selectize;
  9858. $('#writer').val("");
  9859. $("#director").val("");
  9860. $("#other-cast").val("");
  9861. $("#producer").val("");
  9862. $("#Actors").val("");
  9863. remainCount.countRemain("PageDescription",300);
  9864. if(result.others !== undefined) {
  9865. for (var i = 0; i <= result.others.length - 1; i++) {
  9866. selectize5.addOption(result.others[i]);
  9867.  
  9868. selectize5.addItem(result.others[i].id);
  9869. }
  9870. }
  9871. if(result.program_countries !== undefined){
  9872. for (var i = 0; i <= result.program_countries.length - 1; i++) {
  9873. selectize6.addOption(result.program_countries[i]);
  9874.  
  9875. selectize6.addItem(result.program_countries[i].id);
  9876. }
  9877. }
  9878. if(result.directors !== undefined) {
  9879. for (var i = 0; i <= result.directors.length - 1; i++) {
  9880. selectize.addOption(result.directors[i]);
  9881.  
  9882. selectize.addItem(result.directors[i].id);
  9883. }
  9884. }
  9885. if(result.writers !== undefined) {
  9886. for (var i = 0; i <= result.writers.length - 1; i++) {
  9887. selectize4.addOption(result.writers[i]);
  9888.  
  9889. selectize4.addItem(result.writers[i].id);
  9890. }
  9891. }
  9892. if(result.producer !== undefined) {
  9893. for (var i = 0; i <= result.producer.length - 1; i++) {
  9894. selectize3.addOption(result.producer[i]);
  9895.  
  9896. selectize3.addItem(result.producer[i].id);
  9897. }
  9898. }
  9899. if(result.artists !== undefined) {
  9900. for (var i = 0; i <= result.artists.length - 1; i++) {
  9901. selectize2.addOption(result.artists[i]);
  9902.  
  9903. selectize2.addItem(result.artists[i].id);
  9904. }
  9905. }
  9906. if(result.genres !== undefined) {
  9907. for (var i = 0; i <= result.genres.length - 1; i++) {
  9908. $("input[ng-value=" + result.genres[i].id + "]").attr("checked", "checked");
  9909. }
  9910. }
  9911. if(result.categories !== undefined) {
  9912. for (var i = 0; i <= result.categories.length - 1; i++) {
  9913. $("input[ng-value=" + result.categories[i].id + "]").attr("checked", "checked");
  9914. }
  9915. }
  9916. },200);
  9917.  
  9918. if (epc.ProgramData.enable) {
  9919. epc.ProgramData.enable = true;
  9920. }
  9921. if (epc.ProgramData.is_singleton) {
  9922. epc.ProgramData.is_singleton = true;
  9923. }
  9924. if (epc.ProgramData.downloadable) {
  9925. epc.ProgramData.downloadable = true;
  9926. }
  9927. });
  9928.  
  9929. };
  9930.  
  9931. var itemLoading = null;
  9932. var t = null;
  9933. var chooseOption = null;
  9934. $(document).on("input",".artist-search .selectize-input input",function () {
  9935. if(t!=null){
  9936. clearTimeout(t);
  9937. }
  9938. itemLoading = $(this).parents(".input-holder").find(".loader");
  9939. if($(this).val().length>3){
  9940. itemLoading.show();
  9941. }
  9942. chooseOption = 1;
  9943. var value = $(this).val();
  9944. t = setTimeout(function(){epc.SearchArtist(value)},800);
  9945. });
  9946. $(document).on("input",".country-list .selectize-input input",function () {
  9947. if(t!=null){
  9948. clearTimeout(t);
  9949. }
  9950. itemLoading = $(this).parents(".input-holder").find(".loader");
  9951. if($(this).val().length>3){
  9952. itemLoading.show();
  9953. }
  9954. chooseOption = 8;
  9955. var value = $(this).val();
  9956. t = setTimeout(function(){epc.SearchCountry(value)},800);
  9957. });
  9958. $(document).on("input",".search-writer .selectize-input input",function () {
  9959. if(t!=null){
  9960. clearTimeout(t);
  9961. }
  9962. itemLoading = $(this).parents(".input-holder").find(".loader");
  9963. if($(this).val().length>3){
  9964. itemLoading.show();
  9965. }
  9966. chooseOption = 4;
  9967. var value = $(this).val();
  9968. t = setTimeout(function(){epc.SearchArtist(value)},800);
  9969. });
  9970. $(document).on("input",".search-main-artist .selectize-input input",function () {
  9971. if(t!=null){
  9972. clearTimeout(t);
  9973. }
  9974. itemLoading = $(this).parents(".input-holder").find(".loader");
  9975. if($(this).val().length>3){
  9976. itemLoading.show();
  9977. }
  9978. chooseOption = 2;
  9979. var value = $(this).val();
  9980. t = setTimeout(function(){epc.SearchArtist(value)},800);
  9981. });
  9982. $(document).on("input",".search-provider .selectize-input input",function () {
  9983. if(t!=null){
  9984. clearTimeout(t);
  9985. }
  9986. itemLoading = $(this).parents(".input-holder").find(".loader");
  9987. if($(this).val().length>3){
  9988. itemLoading.show();
  9989. }
  9990. chooseOption = 3;
  9991. var value = $(this).val();
  9992. t = setTimeout(function(){epc.SearchArtist(value)},800);
  9993. });
  9994. $(document).on("input",".other-cast .selectize-input input",function () {
  9995. if(t!=null){
  9996. clearTimeout(t);
  9997. }
  9998. itemLoading = $(this).parents(".input-holder").find(".loader");
  9999. if($(this).val().length>3){
  10000. itemLoading.show();
  10001. }
  10002. chooseOption = 5;
  10003. var value = $(this).val();
  10004. t = setTimeout(function(){epc.SearchArtist(value)},800);
  10005. });
  10006.  
  10007. $(document).on("input","#PageDescription",function () {
  10008. remainCount.countRemain("PageDescription",300);
  10009. });
  10010. }
  10011. function PartnerCtrl($rootScope,SiteConstants,ProgressBarFcy){
  10012. $rootScope.Page.Title= SiteConstants.Fa.PageTitle.Partners;
  10013. $rootScope.$broadcast("UserData");
  10014. ProgressBarFcy.setDone();
  10015. }
  10016. function AngularFileUploader($rootScope,Upload) {
  10017. var modelName = 'episode';
  10018. $rootScope.upload = function (file) {
  10019. Upload.upload({
  10020. url: 'http://telewebion.com/op?action=uploadImage&token=testewojfsdaojsodfjsdoifjdsofi&model='+modelName+'&episode=1455899',
  10021. data: {
  10022. image: file
  10023. },
  10024. headers: {
  10025. 'Content-Type': file.type,
  10026. 'Access-Control-Allow-Headers': 'Content-Type',
  10027. 'Access-Control-Allow-Methods': 'GET, POST, OPTIONS',
  10028. 'Access-Control-Allow-Origin': '*'
  10029. },
  10030. method: 'POST',
  10031. }).then(function (resp) {
  10032. console.log('Success ' + 'uploaded. Response: ' + resp.data);
  10033. }, function (resp) {
  10034. console.log('Error status: ' + resp.status);
  10035. }, function (evt) {
  10036. var progressPercentage = parseInt(100.0 * evt.loaded / evt.total);
  10037. $rootScope.StatusPercentage=progressPercentage + '%';
  10038. });
  10039. };
  10040. }
  10041. function replacePipelineAddressAngular(){
  10042. $(".image-thumbnail-container img").each(function () {
  10043. var elem = $(this);
  10044. var arrayOfImageItems = elem.attr("src").split("static");
  10045. var result = "";
  10046. for(i=0;i<arrayOfImageItems.length;i++){
  10047. if(i==1){
  10048. result += "static.pipeline";
  10049. }
  10050. result += arrayOfImageItems[i];
  10051. }
  10052. elem.attr("src",result);
  10053. });
  10054. }
  10055. function AngularFileCrop($rootScope,$scope,ImageUploadFcy,SecurityFcy) {
  10056. $scope.model=null;
  10057. $scope.itemId=null;
  10058. $scope.type=null;
  10059. $scope.token='not-token';
  10060. $scope.UploadInProgress = false;
  10061. $scope.ImageBinray=null;
  10062. $scope.finalResult=null;
  10063. $scope.isCompleted=false;
  10064. $scope.fileChanged = function(e) {
  10065. var files = e.target.files;
  10066. var fileReader = new FileReader();
  10067. fileReader.readAsDataURL(files[0]);
  10068. fileReader.onload = function(e) {
  10069. $scope.imgSrc = this.result;
  10070. $scope.$apply();
  10071. };
  10072. }
  10073. $scope.clear = function() {
  10074. $scope.imageCropStep = 1;
  10075. delete $scope.imgSrc;
  10076. delete $scope.result;
  10077. delete $scope.result2;
  10078. delete $scope.resultBlob;
  10079. delete $scope.resultBlob2;
  10080. };
  10081.  
  10082. $scope.UploadImageForMobile = function () {
  10083. $scope.UploadInProgress = true;
  10084. $scope.model = 'promotion';
  10085. $scope.type = 'small';
  10086. $scope.itemId = $rootScope.sliderId;
  10087. setTimeout(function () {
  10088. SecurityFcy.getUserToken().then(function (token) {
  10089.  
  10090. if($scope.imgSrc.length > 100) {
  10091. ImageUploadFcy.upload($scope.imgSrc, $scope.model, token, $scope.itemId, $scope.type).then(function (result) {
  10092. console.log(result);
  10093. if (result.status != -1) {
  10094. $scope.UploadInProgress = false;
  10095. NgNote.Success('عکس اپیزود با موفقیت‌ به روز شد', 5);
  10096. }
  10097. else {
  10098. $scope.UploadInProgress = false;
  10099. NgNote.Error('خطا در ارسال داده به سرور، لطفا مجددا تلاش نمایید', 5);
  10100. }
  10101. });
  10102.  
  10103. }
  10104. });
  10105. window.location.href="/#!/admin/promotions/list";
  10106. }, 2000);
  10107. }
  10108. $scope.UploadImageLargeWeb = function () {
  10109. $scope.UploadInProgress = true;
  10110. $scope.model = 'promotion';
  10111. $scope.type = 'large';
  10112. $scope.itemId = $rootScope.sliderId;
  10113. setTimeout(function () {
  10114. SecurityFcy.getUserToken().then(function (token) {
  10115.  
  10116. if($scope.imgSrc.length > 100) {
  10117. ImageUploadFcy.upload($scope.imgSrc, $scope.model, token, $scope.itemId, $scope.type).then(function (result) {
  10118. console.log(result);
  10119. if (result.status != -1) {
  10120. $scope.UploadInProgress = false;
  10121. NgNote.Success('عکس اپیزود با موفقیت‌ به روز شد', 5);
  10122. }
  10123. else {
  10124. $scope.UploadInProgress = false;
  10125. NgNote.Error('خطا در ارسال داده به سرور، لطفا مجددا تلاش نمایید', 5);
  10126. }
  10127. });
  10128.  
  10129. }
  10130. });
  10131. }, 2000);
  10132. }
  10133. $scope.UploadImageSmallWeb = function () {
  10134. $scope.model = 'promotion';
  10135. $scope.type = 'medium';
  10136. $scope.itemId = $rootScope.sliderId;
  10137. $scope.UploadInProgress = true;
  10138. setTimeout(function () {
  10139. SecurityFcy.getUserToken().then(function (token) {
  10140.  
  10141. if($scope.imgSrc.length > 100) {
  10142. ImageUploadFcy.upload($scope.imgSrc, $scope.model, token, $scope.itemId, $scope.type).then(function (result) {
  10143. console.log(result);
  10144. if (result.status != -1) {
  10145. $scope.UploadInProgress = false;
  10146. NgNote.Success('عکس اپیزود با موفقیت‌ به روز شد', 5);
  10147. }
  10148. else {
  10149. $scope.UploadInProgress = false;
  10150. NgNote.Error('خطا در ارسال داده به سرور، لطفا مجددا تلاش نمایید', 5);
  10151. }
  10152. });
  10153.  
  10154. }
  10155. });
  10156. window.location.href="/#!/admin/promotions/list";
  10157. }, 2000);
  10158. }
  10159. $scope.UploadImage = function () {
  10160. $scope.UploadInProgress = true;
  10161. setTimeout(function () {
  10162. SecurityFcy.getUserToken().then(function (token) {
  10163. if ($scope.typeOfImageSelected == "cover"){
  10164.  
  10165. ImageUploadFcy.upload($scope.result2, $scope.model, token, $scope.itemId, $scope.type).then(function (result) {
  10166. if (result.status != -1) {
  10167. $scope.UploadInProgress = false;
  10168. NgNote.Success('عکس اپیزود با موفقیت‌ به روز شد', 5);
  10169. }
  10170. else {
  10171. $scope.UploadInProgress = false;
  10172. NgNote.Error('خطا در ارسال داده به سرور، لطفا مجددا تلاش نمایید', 5);
  10173. }
  10174. });
  10175. }else
  10176. {
  10177. ImageUploadFcy.upload($scope.result, $scope.model, token, $scope.itemId, $scope.type).then(function (result) {
  10178. if (result.status != -1) {
  10179. $scope.UploadInProgress = false;
  10180. NgNote.Success('عکس اپیزود با موفقیت‌ به روز شد', 5);
  10181. }
  10182. else {
  10183. $scope.UploadInProgress = false;
  10184. NgNote.Error('خطا در ارسال داده به سرور، لطفا مجددا تلاش نمایید', 5);
  10185. }
  10186. });
  10187. }
  10188. });
  10189. },1000);
  10190. };
  10191. }
  10192. function ListOfProgramCtrl(UserSrv,$rootScope,SiteConstants,ProgressBarFcy,ProgramSrv,ProgramFcy,$window,SecurityFcy,ChannelFcy) {
  10193. $rootScope.Page.Title="لیست برنامه ها";
  10194. var lpc = this;
  10195. lpc.ProgramList = {offset:0,limit:50,UpdateInProgress:true,Programs:null};
  10196. lpc.Pagination = [];
  10197. lpc.Channels = {};
  10198. lpc.filteredActive = false;
  10199. lpc.filteredPrograms = {filteredItems:{},isActive:false,isSingleton:false,title:null,from_date:null,to_date:null,channelId:null,offset:0,limit:50,token:null}
  10200. UserSrv.getUser().then(function (result) {
  10201. if(typeof result!='undefined' && result!=null && typeof result.token!='undefined' && ($rootScope.InArray('admin', result.credentials) || $rootScope.InArray('superadmin', result.credentials) || $rootScope.InArray('operator', result.credentials))) {
  10202. SecurityFcy.getUserToken().then(function (token) {
  10203. ProgramFcy.getProgramList(lpc.ProgramList.offset,lpc.ProgramList.limit,token).then(function (data) {
  10204. lpc.ProgramList.UpdateInProgress = false;
  10205. lpc.ProgramList.Programs = data;
  10206. ProgressBarFcy.setDone();
  10207. })
  10208. })
  10209. ChannelFcy.getChannels().then(function (data) {
  10210. lpc.Channels = data;
  10211. })
  10212. CalendarSetup.setup("from_date");
  10213. CalendarSetup.setup("to_date");
  10214. for (var i = 1; i <= 50; i++) {
  10215. lpc.Pagination[i - 1] = i;
  10216. }
  10217. lpc.deleteProgram = function (id) {
  10218. SecurityFcy.getUserToken().then(function (token) {
  10219. var cnf = showConfirm.verify();
  10220. if (cnf) {
  10221. NgNote.Success('برنامه مورد نظر با موفقیت حذف شد.',3);
  10222. $(".program-row[data-row="+id+"]").remove();
  10223. ProgramSrv.deleteProgram(id, token);
  10224. }
  10225. });
  10226. }
  10227. $(document).on("click", ".page", function () {
  10228. var index = $(this).data("page");
  10229. lpc.ProgramList.offset = (index - 1) * 50;
  10230. lpc.ProgramList.UpdateInProgress = true;
  10231. SecurityFcy.getUserToken().then(function (token) {
  10232. if(!lpc.filteredActive) {
  10233. ProgramFcy.getProgramList(lpc.ProgramList.offset, lpc.ProgramList.limit, token).then(function (data) {
  10234. lpc.ProgramList.Programs = data;
  10235. lpc.ProgramList.UpdateInProgress = false;
  10236. })
  10237. }else {
  10238. ProgramFcy.getProgramWithFilter(lpc.filteredPrograms.offset, lpc.filteredPrograms.limit,
  10239. token, lpc.filteredPrograms.channelId, lpc.filteredPrograms.from_date, lpc.filteredPrograms.to_date,
  10240. lpc.filteredPrograms.isActive, lpc.filteredPrograms.isSingleton, lpc.filteredPrograms.title).then(function (data) {
  10241. lpc.ProgramList.Programs = data;
  10242. lpc.ProgramList.UpdateInProgress = false;
  10243. })
  10244. }
  10245. });
  10246. });
  10247. }else{
  10248. NgNote.Error('کاربر گرامی شما اجازه دسترسی به این بخش را ندارید',3);
  10249. setTimeout(function(){
  10250. $window.location.replace("/#!/");
  10251. },1000);
  10252. }
  10253. })
  10254. lpc.filterPrograms = function () {
  10255. if(!$("#from_date").val() || !$("#to_date").val()){
  10256. alert(" تاریخ شروع و پایان را باید انتخاب کنید. ");
  10257. }else{
  10258. if($("input[name=is_singleton]:checked").val() == "yes"){
  10259. lpc.filteredPrograms.isSingleton = true;
  10260. }else if($("input[name=is_singleton]:checked").val() == "no"){
  10261. lpc.filteredPrograms.isSingleton = false;
  10262. }else{
  10263. lpc.filteredPrograms.isSingleton = null;
  10264. }
  10265. if($("input[name=status]:checked").val() == "active"){
  10266. lpc.filteredPrograms.isActive = true;
  10267. }else if($("input[name=status]:checked").val() == "deactive"){
  10268. lpc.filteredPrograms.isActive = false;
  10269. }else{
  10270. lpc.filteredPrograms.isActive = null;
  10271. }
  10272. if($("#title-search").val().length >= 3){
  10273. lpc.filteredPrograms.title = $("#title-search").val();
  10274. }else{
  10275. lpc.filteredPrograms.title = null;
  10276. }
  10277. if($("select[name=channelSelect]").val().length > 0){
  10278. lpc.filteredPrograms.channelId = $("select[name=channelSelect]").val();
  10279. }else{
  10280. lpc.filteredPrograms.channelId = null;
  10281. }
  10282. lpc.ProgramList.UpdateInProgress = true;
  10283. var date = new JDate($("#from_date").val());
  10284. var month = parseInt(date._date.getMonth()) + 1;
  10285. var day = parseInt(date._date.toString().split(" ")[2]);
  10286. var year = date._date.getFullYear();
  10287. var MiladiDate = new Date(year, month, parseInt(day));
  10288. var show_time = "";
  10289. if(MiladiDate.getMonth() == 0){
  10290. show_time = (MiladiDate.getFullYear()-1 + "-" + "12" + "-" + day);
  10291. }else {
  10292. show_time = (MiladiDate.getFullYear() + "-" + MiladiDate.getMonth() + "-" + day);
  10293. }
  10294. lpc.filteredPrograms.from_date = show_time;
  10295. var date2 = new JDate($("#to_date").val());
  10296. month = parseInt(date2._date.getMonth()) + 1;
  10297. day = parseInt(date2._date.toString().split(" ")[2]);
  10298. year = date2._date.getFullYear();
  10299. MiladiDate = new Date(year, month, parseInt(day));
  10300. if(MiladiDate.getMonth() == 0){
  10301. show_time = (MiladiDate.getFullYear()-1 + "-" + "12" + "-" + day);
  10302. }else {
  10303. show_time = (MiladiDate.getFullYear() + "-" + MiladiDate.getMonth() + "-" + day);
  10304. }
  10305. lpc.filteredPrograms.to_date = show_time;
  10306. SecurityFcy.getUserToken().then(function (token) {
  10307. ProgramFcy.getProgramWithFilter(lpc.filteredPrograms.offset,lpc.filteredPrograms.limit,
  10308. token,lpc.filteredPrograms.channelId,lpc.filteredPrograms.from_date,lpc.filteredPrograms.to_date,
  10309. lpc.filteredPrograms.isActive,lpc.filteredPrograms.isSingleton,lpc.filteredPrograms.title).then(function (data) {
  10310. lpc.ProgramList.Programs = data;
  10311. lpc.filteredActive = true;
  10312. lpc.ProgramList.UpdateInProgress = false;
  10313. });
  10314. })
  10315.  
  10316. }
  10317. }
  10318.  
  10319. }
  10320. function ListOfEpisodesCtrl(UserSrv,$rootScope,SiteConstants,ProgressBarFcy,ProgramSrv,$routeParams,$window,SecurityFcy,EpisodeFcy,EpisodeSrv,ChannelFcy,$scope) {
  10321. var lec = this;
  10322. $rootScope.Page.Title="لیست قسمت برنامه ها";
  10323. lec.EpisodeList = {offset:0,limit:50,UpdateInProgress:true,Episodes:null};
  10324. lec.Pagination = [];
  10325. lec.Channels = {};
  10326. lec.applyChannelChanges = function () {
  10327. lec.EpisodeList.offset = 0;
  10328. lec.EpisodeList.limit = 800;
  10329. lec.EpisodeList.UpdateInProgress = true;
  10330. EpisodeFcy.getEpisodeByDateAndChannel($("#input_calendar").val(),$scope.channelId,lec.EpisodeList.offset,lec.EpisodeList.limit).then(function(result) {
  10331. lec.EpisodeList.Episodes = result;
  10332. lec.EpisodeList.UpdateInProgress = false;
  10333. });
  10334. }
  10335.  
  10336. UserSrv.getUser().then(function (result) {
  10337. if(typeof result!='undefined' && result!=null && typeof result.token!='undefined' && ($rootScope.InArray('admin', result.credentials) || $rootScope.InArray('superadmin', result.credentials) || $rootScope.InArray('operator', result.credentials))) {
  10338. SecurityFcy.getUserToken().then(function (token) {
  10339.  
  10340. EpisodeFcy.getEpisodeLists(lec.EpisodeList.limit, lec.EpisodeList.offset, token).then(function (data) {
  10341. lec.EpisodeList.Episodes = data;
  10342. lec.EpisodeList.UpdateInProgress = false;
  10343. ProgressBarFcy.setDone();
  10344. CalendarSetup.setup("input_calendar")
  10345. })
  10346.  
  10347. });
  10348. ChannelFcy.getChannels().then(function (data) {
  10349. lec.Channels = data;
  10350. })
  10351. for (var i = 1; i <= 50; i++) {
  10352. lec.Pagination[i - 1] = i;
  10353. }
  10354. lec.deleteEpisode = function (id) {
  10355. SecurityFcy.getUserToken().then(function (token) {
  10356. var cnf = showConfirm.verify();
  10357.  
  10358. if (cnf) {
  10359. NgNote.Success('قسمت برنامه مورد نظر با موفقیت حذف شد.',3);
  10360. $(".episode-row[data-row="+id+"]").remove();
  10361. EpisodeSrv.deleteEpisode(id, token);
  10362. }
  10363. });
  10364. }
  10365. $(document).on("click", ".page", function () {
  10366. var index = $(this).data("page");
  10367. lec.EpisodeList.offset = (index - 1) * 50;
  10368. lec.EpisodeList.UpdateInProgress = true;
  10369. lec.EpisodeList.limit = 50;
  10370. SecurityFcy.getUserToken().then(function (token) {
  10371. EpisodeFcy.getEpisodeLists(lec.EpisodeList.limit, lec.EpisodeList.offset, token).then(function (data) {
  10372. lec.EpisodeList.Episodes = data;
  10373. lec.EpisodeList.UpdateInProgress = false;
  10374. })
  10375. });
  10376. });
  10377. }else{
  10378. NgNote.Error('کاربر گرامی شما اجازه دسترسی به این بخش را ندارید',3);
  10379. setTimeout(function(){
  10380. $window.location.replace("/#!/");
  10381. },1000);
  10382. }
  10383. });
  10384. }
  10385. function ListOfFavListCtrl(UserSrv,$rootScope,SiteConstants,ProgressBarFcy,ProgramSrv,$routeParams,$window,SecurityFcy,FavoriteListFcy) {
  10386. var flc = this;
  10387. $rootScope.Page.Title="لیست های تماشا";
  10388. $rootScope.$broadcast("UserData");
  10389. flc.FavoriteLists={Offset:0,Limit:100,UpdateInProgress:false,Items:[],Page:0};
  10390. ProgressBarFcy.setDone();
  10391. flc.getList = function () {
  10392. SecurityFcy.getUserToken().then(function (token){
  10393. flc.FavoriteLists.UpdateInProgress = true;
  10394. FavoriteListFcy.getList(flc.FavoriteLists.Offset, flc.FavoriteLists.Limit, $routeParams.Id, token).then(function (result) {
  10395. flc.FavoriteLists.Items = result;
  10396. flc.FavoriteLists.UpdateInProgress = false;
  10397. ProgressBarFcy.setDone();
  10398. })
  10399. })
  10400. }
  10401. flc.getList();
  10402. flc.deleteFromFavoriteList = function (id) {
  10403. SecurityFcy.getUserToken().then(function (token) {
  10404. var cnf = showConfirm.verify();
  10405. if(cnf) {
  10406. FavoriteListFcy.deleteList(id, token).then(function (result) {
  10407. NgNote.Success("لیست مورد نظر با موفقیت حذف شد", 3);
  10408. $(".table-for-list tr[data-row=" + id + "]").remove();
  10409. })
  10410. }
  10411. });
  10412. }
  10413. }
  10414. function TagCtrl(GeneralInit,$rootScope,SiteConstants,ProgressBarFcy,SliderFcy,EpisodeFcy, TagPageFcy,$routeParams,FavoriteListSrv,$timeout) {
  10415. var tac = this;
  10416. tac.TagsData = {UpdateInProgress:true,Page:0,limit:50,offset:0,Items:[],isGetNext:true}
  10417. tac.TagsProgramData = {UpdateInProgress:true,Page:0,limit:14,offset:0,Items:[],isGetNext:true}
  10418. tac.pageTitle = $routeParams.name;
  10419. tac.pageTitleEscaped = $routeParams.name;
  10420. $rootScope.Page.Title = "جستجوی برنامه ها و قسمت برنامه های تگ " + tac.pageTitle;
  10421. $timeout(function () {
  10422. $("img.lazyload").lazyload({
  10423. threshold : 150,
  10424. effect : "fadeIn",
  10425. event:"getnext"
  10426. });
  10427. },2000);
  10428. tac.getPrograms = function () {
  10429. tac.TagsProgramData.UpdateInProgress = true;
  10430. ProgressBarFcy.setDone();
  10431. TagPageFcy.getTagPrograms(tac.TagsProgramData.limit,tac.TagsProgramData.offset,tac.pageTitle).then(function (result) {
  10432. $timeout(function () {
  10433. $("img.lazyload").lazyload();
  10434. },1000)
  10435. tac.TagsProgramData.Page++;
  10436. if(result.data[0].programs.length == 0){
  10437. tac.TagsProgramData.isGetNext = false;
  10438. }
  10439. var tempArray=[];
  10440. var tempArray2=[];
  10441. if(result.data[0].programs.length > 0) {
  10442. tempArray.push(result.data[0].programs);
  10443. tempArray2.push(tac.TagsProgramData.Items);
  10444. tac.TagsProgramData.Items = tempArray2[0].concat(tempArray[0]);
  10445. tempArray.length = 0;
  10446. tempArray2.length = 0;
  10447. tac.TagsProgramData.UpdateInProgress = false;
  10448. $timeout(function () {
  10449.  
  10450. $(".carousel-image-container img").each(function () {
  10451. $(this).error(function () {
  10452. if (!$(this).attr("data-replaced"))
  10453. replacePipelineAddress.replace($(this));
  10454. })
  10455. })
  10456. }, 200);
  10457. setTimeout(function () {
  10458. $(".carousel-info h5 span").each(function () {
  10459. var elem = $(this);
  10460. var persianNumber = persianUtils.toPersianNumber(elem.html());
  10461. elem.html(persianNumber);
  10462. });
  10463. }, 200);
  10464. }
  10465. })
  10466.  
  10467. }
  10468. tac.getTags = function () {
  10469. tac.TagsData.UpdateInProgress = true;
  10470. ProgressBarFcy.setDone();
  10471. tac.TagsData.UpdateInProgress = false;
  10472.  
  10473. TagPageFcy.getTagEpisodes(tac.TagsData.limit,tac.TagsData.offset,tac.pageTitle).then(function (result) {
  10474. $timeout(function () {
  10475. $("img.lazyload").lazyload();
  10476. },1000)
  10477. tac.TagsData.Page++;
  10478. var tempArray=[];
  10479. var tempArray2=[];
  10480. if(result.data[0].episodes.length == 0){
  10481. tac.TagsData.isGetNext = false;
  10482. }
  10483. if(result.data[0].episodes.length > 0) {
  10484. tempArray.push(result.data[0].episodes);
  10485. tempArray2.push(tac.TagsData.Items);
  10486. tac.TagsData.Items = tempArray2[0].concat(tempArray[0]);
  10487. tempArray.length = 0;
  10488. tempArray2.length = 0;
  10489. tac.TagsData.UpdateInProgress = false;
  10490. $timeout(function () {
  10491.  
  10492. $(".carousel-image-container img").each(function () {
  10493. $(this).error(function () {
  10494. if (!$(this).attr("data-replaced"))
  10495. replacePipelineAddress.replace($(this));
  10496. })
  10497. })
  10498. }, 200);
  10499. setTimeout(function () {
  10500. $(".carousel-info h5 span").each(function () {
  10501. var elem = $(this);
  10502. var persianNumber = persianUtils.toPersianNumber(elem.html());
  10503. elem.html(persianNumber);
  10504. });
  10505. }, 200);
  10506. }
  10507. })
  10508.  
  10509. }
  10510.  
  10511. tac.getNextProgram = function () {
  10512. tac.TagsProgramData.UpdateInProgress = true;
  10513. if(tac.TagsProgramData.isGetNext) {
  10514. tac.TagsProgramData.limit = ((tac.TagsProgramData.Page + 1) == 1) ? 14 : 14;
  10515. tac.TagsProgramData.offset = ((tac.TagsProgramData.Page + 1) == 1) ? 0 : ((tac.TagsProgramData.Page) * 14);
  10516.  
  10517. tac.getPrograms();
  10518.  
  10519. setTimeout(function () {
  10520.  
  10521. $(".carousel-info h5 span").each(function () {
  10522. var elem = $(this);
  10523. var persianNumber = persianUtils.toPersianNumber(elem.html());
  10524. elem.html(persianNumber);
  10525. });
  10526.  
  10527. }, 200);
  10528. }
  10529. }
  10530. tac.getNext=function() {
  10531. if (tac.TagsData.isGetNext) {
  10532. tac.TagsData.UpdateInProgress = true;
  10533.  
  10534. tac.TagsData.limit = ((tac.TagsData.Page + 1) == 1) ? 50 : 50;
  10535. tac.TagsData.offset = ((tac.TagsData.Page + 1) == 1) ? 0 : ((tac.TagsData.Page) * 50);
  10536.  
  10537. tac.getTags();
  10538.  
  10539. setTimeout(function () {
  10540.  
  10541. $(".carousel-info h5 span").each(function () {
  10542. var elem = $(this);
  10543. var persianNumber = persianUtils.toPersianNumber(elem.html());
  10544. elem.html(persianNumber);
  10545. });
  10546.  
  10547. }, 200);
  10548. }
  10549. }
  10550. tac.getTags();
  10551. tac.getPrograms();
  10552. }
  10553. function TagsCtrl(GeneralInit,$rootScope,SiteConstants,ProgressBarFcy,SliderFcy,EpisodeFcy, FavoriteListFcy,$routeParams,FavoriteListSrv,$timeout) {
  10554. var tgc = this;
  10555.  
  10556. $timeout(function () {
  10557. $("img.lazyload").lazyload({
  10558. threshold : 150,
  10559. effect : "fadeIn",
  10560. event:"getnext"
  10561. });
  10562. },1000);
  10563. $(".position-fix-carousel").scroll(function () {
  10564. $(document).scroll()
  10565. })
  10566. $(document).on("click",".slick-next,.slick-prev",function () {
  10567. $(document).scroll()
  10568. setTimeout(function () {
  10569. $(document).scroll()
  10570. },600)
  10571. })
  10572. tgc.TagsData={Offset:0,Limit:50,UpdateInProgress:true,Episodes:[],Page:0,tempColumn:0};
  10573. tgc.ChildTags={Offset:0,Limit:100,UpdateInProgress:true,Items:[],Page:0,tempColumn:0};
  10574. tgc.ParentTags={Offset:0,Limit:100,UpdateInProgress:true,Items:[],Page:0,tempColumn:0};
  10575. tgc.getSlider = function () {
  10576. SliderFcy.getTags().then(function (result) {
  10577. tgc.Sliders=result;
  10578. ProgressBarFcy.plus(0.1);
  10579. TopCarousel.initCarousel();
  10580. })
  10581. }
  10582. $rootScope.Page.Title= "لیست قسمت برنامه های تگ ";
  10583. tgc.getSlider()
  10584. tgc.getEpisodes = function () {
  10585. tgc.TagsData.UpdateInProgress = true;
  10586. ProgressBarFcy.setDone();
  10587. FavoriteListFcy.getEpisodeList($routeParams.Id, tgc.TagsData.Offset, tgc.TagsData.Limit).then(function (result) {
  10588. tgc.TagsData.Page ++;
  10589. var tempArray=[];
  10590. var tempArray2=[];
  10591. tgc.TagsData.UpdateInProgress = false;
  10592. if(result.length > 0) {
  10593. tempArray.push(result);
  10594. tempArray2.push(tgc.TagsData.Episodes);
  10595. tgc.TagsData.Episodes = tempArray2[0].concat(tempArray[0]);
  10596. tempArray.length = 0;
  10597. tempArray2.length = 0;
  10598. tgc.TagsData.UpdateInProgress = false;
  10599. $timeout(function () {
  10600.  
  10601. $(".carousel-image-container img").each(function () {
  10602. $(this).error(function () {
  10603. if (!$(this).attr("data-replaced"))
  10604. replacePipelineAddress.replace($(this));
  10605. })
  10606. })
  10607. }, 200);
  10608. setTimeout(function () {
  10609. $(".carousel-info h5 span").each(function () {
  10610. var elem = $(this);
  10611. var persianNumber = persianUtils.toPersianNumber(elem.html());
  10612. elem.html(persianNumber);
  10613. });
  10614. }, 200);
  10615. }
  10616. })
  10617. }
  10618. tgc.getNext=function(){
  10619. tgc.TagsData.UpdateInProgress = true;
  10620. tgc.TagsData.Limit=((tgc.TagsData.Page+1)==1)?50:50;
  10621. tgc.TagsData.Offset=((tgc.TagsData.Page+1)==1)?0:((tgc.TagsData.Page)*50);
  10622. tgc.getEpisodes();
  10623. setTimeout(function () {
  10624. $(".carousel-info h5 span").each(function () {
  10625. var elem = $(this);
  10626. var persianNumber = persianUtils.toPersianNumber(elem.html());
  10627. elem.html(persianNumber);
  10628. });
  10629.  
  10630. },200);
  10631. setTimeout(function () {
  10632. $("img.lazyload").lazyload();
  10633. },1000);
  10634. }
  10635. tgc.getChildTags = function () {
  10636. tgc.ChildTags.UpdateInProgress = true;
  10637. FavoriteListSrv.getChildList($routeParams.Id, tgc.ChildTags.Offset, tgc.ChildTags.Limit).then(function (result) {
  10638. tgc.ChildTags.Items = result;
  10639. tgc.ChildTags.UpdateInProgress = false;
  10640. })
  10641. }
  10642. tgc.getParentTags = function () {
  10643. tgc.ParentTags.UpdateInProgress = true;
  10644. FavoriteListSrv.getFavoriteListParents($routeParams.Id).then(function (result) {
  10645. tgc.ParentTags.Items = result;
  10646. $rootScope.Page.Title += tgc.ParentTags.Items[0].name_fa;
  10647. tgc.ParentTags.UpdateInProgress = false;
  10648. })
  10649. }
  10650. tgc.getEpisodes();
  10651. tgc.getChildTags();
  10652. tgc.getParentTags();
  10653. }
  10654. function MainAdminCtrl(GeneralInit,$rootScope,SiteConstants,ProgressBarFcy,SliderFcy,EpisodeFcy,UserSrv,SecurityFcy,$window) {
  10655. var mac = this;
  10656. UserSrv.getUser().then(function (result) {
  10657. if(typeof result!='undefined' && result!=null && typeof result.token!='undefined' && ($rootScope.InArray('admin', result.credentials) || $rootScope.InArray('superadmin', result.credentials) || $rootScope.InArray('operator', result.credentials))){
  10658. SecurityFcy.getUserToken().then(function (token) {
  10659. mac.userToken = token;
  10660. });
  10661. }
  10662. else {
  10663. NgNote.Error('کاربر گرامی شما اجازه دسترسی به این بخش را ندارید',3);
  10664. setTimeout(function(){
  10665. $window.location.replace("/#!/");
  10666. },1000);
  10667. }
  10668. });
  10669. $rootScope.Page.Title=SiteConstants.Fa.PageTitle.MainAdminPage;
  10670. ProgressBarFcy.setDone();
  10671. }
  10672. function ShademanehCtrl(GeneralInit,$rootScope,SiteConstants,ProgressBarFcy,SliderFcy,EpisodeFcy) {
  10673. var smc = this;
  10674. smc.ShademanehData = {};
  10675. smc.ShademanehData.Page = 1;
  10676. $rootScope.Page.Title=SiteConstants.Fa.PageTitle.ShademanehPage;
  10677. smc.getSlider = function () {
  10678. SliderFcy.getShademaneh().then(function (result) {
  10679. smc.Sliders=result;
  10680.  
  10681. ProgressBarFcy.plus(0.3);
  10682. TopCarousel.initCarousel();
  10683. })
  10684. }
  10685. smc.getSlider();
  10686. smc.ShademanehData={Offset:0,Limit:50,UpdateInProgress:true,Episodes:[],Page:0,tempColumn:0};
  10687. smc.ShademanehSpecialData={Offset:0,Limit:23,UpdateInProgress:true,Episodes:[],Page:0,tempColumn:0};
  10688. smc.getShademanehSpecial=function(){
  10689. EpisodeFcy.getCustom('404883',smc.ShademanehSpecialData.Offset,smc.ShademanehSpecialData.Limit).then(function(CustomEpisodes){
  10690. smc.ShademanehSpecialData.Page++;
  10691. var tempArray=[];
  10692. var tempArray2=[];
  10693. tempArray.push(CustomEpisodes);
  10694. tempArray2.push(smc.ShademanehSpecialData.Episodes);
  10695. smc.ShademanehSpecialData.Episodes = tempArray2[0].concat(tempArray[0]);
  10696. tempArray.length = 0;
  10697. tempArray2.length = 0;
  10698. smc.ShademanehSpecialData.UpdateInProgress=false;
  10699. ProgressBarFcy.plus(0.7);
  10700. ProgressBarFcy.setDone();
  10701. setTimeout(function () {
  10702. $(".carousel-info h5 span").each(function () {
  10703. var elem = $(this);
  10704. var persianNumber = persianUtils.toPersianNumber(elem.html());
  10705. elem.html(persianNumber);
  10706. });
  10707. },200);
  10708. });
  10709. }
  10710. smc.getShademanehSpecial();
  10711. smc.getShademaneh=function(){
  10712. EpisodeFcy.getCustom('372372',smc.ShademanehData.Offset,smc.ShademanehData.Limit).then(function(CustomEpisodes){
  10713. smc.ShademanehData.Page++;
  10714. var tempArray=[];
  10715. var tempArray2=[];
  10716. tempArray.push(CustomEpisodes);
  10717. tempArray2.push(smc.ShademanehData.Episodes);
  10718. smc.ShademanehData.Episodes = tempArray2[0].concat(tempArray[0]);
  10719. tempArray.length = 0;
  10720. tempArray2.length = 0;
  10721. smc.ShademanehData.UpdateInProgress=false;
  10722. ProgressBarFcy.plus(0.7);
  10723. ProgressBarFcy.setDone();
  10724. setTimeout(function () {
  10725. $(".carousel-info h5 span").each(function () {
  10726. var elem = $(this);
  10727. var persianNumber = persianUtils.toPersianNumber(elem.html());
  10728. elem.html(persianNumber);
  10729. });
  10730.  
  10731. },200);
  10732. });
  10733. }
  10734. smc.getNext=function(){
  10735. smc.ShademanehData.UpdateInProgress = true;
  10736. smc.ShademanehData.Limit=((smc.ShademanehData.Page+1)==1)?50:50;
  10737. smc.ShademanehData.Offset=((smc.ShademanehData.Page+1)==1)?0:((smc.ShademanehData.Page)*50);
  10738. smc.getShademaneh();
  10739. setTimeout(function () {
  10740.  
  10741. $(".carousel-info h5 span").each(function () {
  10742. var elem = $(this);
  10743. var persianNumber = persianUtils.toPersianNumber(elem.html());
  10744. elem.html(persianNumber);
  10745. });
  10746.  
  10747. },200);
  10748. }
  10749. $(".position-fix-carousel").each(function () {
  10750. TwoRowsCarousel.CarouselInit($(this).attr("id"));
  10751. })
  10752. smc.getShademaneh();
  10753. }
  10754. function KidsCtrl(GeneralInit,$rootScope,SiteConstants,ProgressBarFcy,SliderFcy,EpisodeFcy,$timeout) {
  10755. var kdc = this;
  10756. $timeout(function () {
  10757. $("img.lazyload").lazyload({
  10758. threshold : 150,
  10759. effect : "fadeIn",
  10760. event:"getnext"
  10761. });
  10762. },1000);
  10763. kdc.Category={Offset:0,Limit:50,UpdateInProgress:true,Episodes:[],Page:0,IsPoster:false};
  10764. kdc.Category.Page = 0;
  10765. kdc.getSlider = function () {
  10766. SliderFcy.getKids().then(function (result) {
  10767. kdc.Sliders=result;
  10768. ProgressBarFcy.plus(0.1);
  10769. TopCarousel.initCarousel();
  10770. })
  10771. };
  10772. kdc.getCategoryEpisodes = function(){
  10773. EpisodeFcy.getCategoryEpisodes("115",kdc.Category.Offset,kdc.Category.Limit).then(function(result){
  10774. kdc.Category.Page++;
  10775. setTimeout(function(){$("img.lazyload").lazyload()},600);
  10776. var tempArray=[];
  10777. var tempArray2=[];
  10778. tempArray.push(result);
  10779. tempArray2.push(kdc.Category.Episodes);
  10780. kdc.Category.Episodes = tempArray2[0].concat(tempArray[0]);
  10781. tempArray.length = 0;
  10782. tempArray2.length = 0;
  10783. kdc.Category.UpdateInProgress=false;
  10784. setTimeout(function () {
  10785. $(".carousel-info h5 span").each(function () {
  10786. var elem = $(this);
  10787. var persianNumber = persianUtils.toPersianNumber(elem.html());
  10788. elem.html(persianNumber);
  10789. });
  10790. },200);
  10791. ProgressBarFcy.setDone();
  10792. });
  10793. }
  10794. $rootScope.Page.Title=SiteConstants.Fa.PageTitle.KidsPage;
  10795. $rootScope.$broadcast("UserData");
  10796. ProgressBarFcy.plus(0.2);
  10797. kdc.getNext=function(){
  10798. kdc.Category.UpdateInProgress = true;
  10799. kdc.Category.Limit=((kdc.Category.Page+1)==1)?50:50;
  10800. kdc.Category.Offset=((kdc.Category.Page+1)==1)?0:((kdc.Category.Page)*50);
  10801. setTimeout(function () {
  10802. $(".carousel-info h5 span").each(function () {
  10803. var elem = $(this);
  10804. var persianNumber = persianUtils.toPersianNumber(elem.html());
  10805. elem.html(persianNumber);
  10806. });
  10807.  
  10808. },200);
  10809. kdc.getCategoryEpisodes();
  10810. }
  10811. kdc.getCategoryEpisodes();
  10812. kdc.getSlider();
  10813. }
  10814. function EuropeLeaguesCtrl(GeneralInit,$rootScope,SiteConstants,ProgressBarFcy,SliderFcy,EpisodeFcy) {
  10815. var elc = this;
  10816. $rootScope.Page.Title=SiteConstants.Fa.PageTitle.EuropeLeaguesPage;
  10817. elc.getSlider = function () {
  10818. SliderFcy.getEuropeLeagues().then(function (result) {
  10819. elc.Sliders=result;
  10820. ProgressBarFcy.plus(0.1);
  10821. TopCarousel.initCarousel();
  10822. })
  10823. };
  10824. elc.NewsData={Offset:0,Limit:27,UpdateInProgress:true,Items:[],Page:0,tempColumn:0};
  10825. elc.SpainData={Offset:0,Limit:27,UpdateInProgress:true,Items:[],Page:0,tempColumn:0};
  10826. elc.EnglandData={Offset:0,Limit:27,UpdateInProgress:true,Items:[],Page:0,tempColumn:0};
  10827. elc.ItalyData={Offset:0,Limit:27,UpdateInProgress:true,Items:[],Page:0,tempColumn:0};
  10828. elc.GermanyData={Offset:0,Limit:27,UpdateInProgress:true,Items:[],Page:0,tempColumn:0};
  10829. elc.FranceData={Offset:0,Limit:27,UpdateInProgress:true,Items:[],Page:0,tempColumn:0};
  10830. elc.ChampionsLeagueData={Offset:0,Limit:27,UpdateInProgress:true,Items:[],Page:0,tempColumn:0};
  10831. elc.getChampionsLeague=function(){
  10832. EpisodeFcy.getCustom('404841',elc.ChampionsLeagueData.Offset,elc.ChampionsLeagueData.Limit).then(function(CustomEpisodes){
  10833. elc.ChampionsLeagueData.Page++;
  10834. //loaded("OurRecommendations");
  10835. if(elc.ChampionsLeagueData.Page==1){
  10836. TwoRowsCarousel.CarouselInit("champions-league");
  10837.  
  10838. }
  10839. var tempArray=[];
  10840. var tempArray2=[];
  10841. tempArray.push(CustomEpisodes);
  10842. tempArray2.push(elc.ChampionsLeagueData.Episodes);
  10843. window.ChampionsLeagueDataLength=CustomEpisodes.length;
  10844. window.ChampionsLeagueDataTotal+=parseInt(window.ChampionsLeagueDataLength);
  10845. elc.ChampionsLeagueData.Episodes = CustomEpisodes; /*tempArray2[0].concat(tempArray[0]);*/
  10846. tempArray.length = 0;
  10847. tempArray2.length = 0;
  10848. elc.ChampionsLeagueData.UpdateInProgress=false;
  10849. if(elc.ChampionsLeagueData.Page==1){
  10850. ProgressBarFcy.plus(0.1);
  10851. }
  10852. });
  10853. };
  10854. elc.getNews=function(){
  10855. EpisodeFcy.getCustom('404821',elc.NewsData.Offset,elc.NewsData.Limit).then(function(CustomEpisodes){
  10856. elc.NewsData.Page++;
  10857. //loaded("OurRecommendations");
  10858. if(elc.NewsData.Page==1){
  10859. TwoRowsCarousel.CarouselInit("news-europeleagues");
  10860.  
  10861. }
  10862. var tempArray=[];
  10863. var tempArray2=[];
  10864. tempArray.push(CustomEpisodes);
  10865. tempArray2.push(elc.NewsData.Episodes);
  10866. window.EuropeLeaguesNews=CustomEpisodes.length;
  10867. window.EuropeLeaguesNewsTotal+=parseInt(window.EuropeLeaguesNews);
  10868. elc.NewsData.Episodes = CustomEpisodes; /*tempArray2[0].concat(tempArray[0]);*/
  10869. tempArray.length = 0;
  10870. tempArray2.length = 0;
  10871. elc.NewsData.UpdateInProgress=false;
  10872. if(elc.NewsData.Page==1){
  10873. ProgressBarFcy.plus(0.1);
  10874. }
  10875. });
  10876. };
  10877. elc.getSpainLeague=function(){
  10878. EpisodeFcy.getCustom('404823',elc.SpainData.Offset,elc.SpainData.Limit).then(function(CustomEpisodes){
  10879. elc.SpainData.Page++;
  10880. //loaded("OurRecommendations");
  10881. if(elc.SpainData.Page==1){
  10882. TwoRowsCarousel.CarouselInit("spain-europeleagues");
  10883.  
  10884. }
  10885. var tempArray=[];
  10886. var tempArray2=[];
  10887. tempArray.push(CustomEpisodes);
  10888. tempArray2.push(elc.SpainData.Episodes);
  10889. window.SpainLeaguesData=CustomEpisodes.length;
  10890. window.SpainLeaguesDataTotal+=parseInt(window.SpainLeaguesData);
  10891. elc.SpainData.Episodes = CustomEpisodes; /*tempArray2[0].concat(tempArray[0]);*/
  10892. tempArray.length = 0;
  10893. tempArray2.length = 0;
  10894. elc.SpainData.UpdateInProgress=false;
  10895. if(elc.SpainData.Page==1){
  10896. ProgressBarFcy.plus(0.1);
  10897. }
  10898. });
  10899. };
  10900. elc.getEnglandLeague=function(){
  10901. EpisodeFcy.getCustom('404822',elc.EnglandData.Offset,elc.EnglandData.Limit).then(function(CustomEpisodes){
  10902. elc.EnglandData.Page++;
  10903. //loaded("OurRecommendations");
  10904. if(elc.EnglandData.Page==1){
  10905. TwoRowsCarousel.CarouselInit("england-europeleagues");
  10906.  
  10907. }
  10908. var tempArray=[];
  10909. var tempArray2=[];
  10910. tempArray.push(CustomEpisodes);
  10911. tempArray2.push(elc.EnglandData.Episodes);
  10912. window.EnglandLeaguesData=CustomEpisodes.length;
  10913. window.EnglandLeaguesDataTotal+=parseInt(window.EnglandLeaguesData);
  10914. elc.EnglandData.Episodes = CustomEpisodes; /*tempArray2[0].concat(tempArray[0]);*/
  10915. tempArray.length = 0;
  10916. tempArray2.length = 0;
  10917. elc.EnglandData.UpdateInProgress=false;
  10918. if(elc.EnglandData.Page==1){
  10919. ProgressBarFcy.plus(0.1);
  10920. }
  10921. });
  10922. };
  10923. elc.getItalyLeague=function(){
  10924. EpisodeFcy.getCustom('404824',elc.ItalyData.Offset,elc.ItalyData.Limit).then(function(CustomEpisodes){
  10925. elc.ItalyData.Page++;
  10926. //loaded("OurRecommendations");
  10927. if(elc.ItalyData.Page==1){
  10928. TwoRowsCarousel.CarouselInit("italy-europeleagues");
  10929.  
  10930. }
  10931. var tempArray=[];
  10932. var tempArray2=[];
  10933. tempArray.push(CustomEpisodes);
  10934. tempArray2.push(elc.ItalyData.Episodes);
  10935. window.ItalyLeaguesData=CustomEpisodes.length;
  10936. window.ItalyLeaguesDataTotal+=parseInt(window.ItalyLeaguesData);
  10937. elc.ItalyData.Episodes = CustomEpisodes; /*tempArray2[0].concat(tempArray[0]);*/
  10938. tempArray.length = 0;
  10939. tempArray2.length = 0;
  10940. elc.ItalyData.UpdateInProgress=false;
  10941. if(elc.ItalyData.Page==1){
  10942. ProgressBarFcy.plus(0.1);
  10943. }
  10944. });
  10945. };
  10946. elc.getGermanyLeague=function(){
  10947. EpisodeFcy.getCustom('404825',elc.ItalyData.Offset,elc.ItalyData.Limit).then(function(CustomEpisodes){
  10948. elc.GermanyData.Page++;
  10949. //loaded("OurRecommendations");
  10950. if(elc.GermanyData.Page==1){
  10951. TwoRowsCarousel.CarouselInit("germany-europeleagues");
  10952.  
  10953. }
  10954. var tempArray=[];
  10955. var tempArray2=[];
  10956. tempArray.push(CustomEpisodes);
  10957. tempArray2.push(elc.GermanyData.Episodes);
  10958. window.GermanyLeaguesData=CustomEpisodes.length;
  10959. window.GermanyLeaguesDataTotal+=parseInt(window.GermanyLeaguesData);
  10960. elc.GermanyData.Episodes = CustomEpisodes; /*tempArray2[0].concat(tempArray[0]);*/
  10961. tempArray.length = 0;
  10962. tempArray2.length = 0;
  10963. elc.GermanyData.UpdateInProgress=false;
  10964. if(elc.GermanyData.Page==1){
  10965. ProgressBarFcy.plus(0.1);
  10966. }
  10967. });
  10968. };
  10969. elc.getFranceLeague=function(){
  10970. EpisodeFcy.getCustom('404826',elc.ItalyData.Offset,elc.ItalyData.Limit).then(function(CustomEpisodes){
  10971. elc.FranceData.Page++;
  10972. //loaded("OurRecommendations");
  10973. if(elc.FranceData.Page==1){
  10974. TwoRowsCarousel.CarouselInit("france-europeleagues");
  10975.  
  10976. }
  10977. var tempArray=[];
  10978. var tempArray2=[];
  10979. tempArray.push(CustomEpisodes);
  10980. tempArray2.push(elc.FranceData.Episodes);
  10981. window.FranceLeaguesData=CustomEpisodes.length;
  10982. window.FranceLeaguesDataTotal+=parseInt(window.FranceLeaguesData);
  10983. elc.FranceData.Episodes = CustomEpisodes; /*tempArray2[0].concat(tempArray[0]);*/
  10984. tempArray.length = 0;
  10985. tempArray2.length = 0;
  10986. elc.FranceData.UpdateInProgress=false;
  10987. if(elc.FranceData.Page==1){
  10988. ProgressBarFcy.plus(0.1);
  10989. }
  10990. });
  10991. };
  10992. elc.getFranceLeague();
  10993. elc.getGermanyLeague();
  10994. elc.getItalyLeague();
  10995. elc.getEnglandLeague();
  10996. elc.getSpainLeague();
  10997. elc.getNews();
  10998. elc.getSlider();
  10999. elc.getChampionsLeague();
  11000. }
  11001. function MoviesCtrl(GeneralInit,$rootScope,SiteConstants,ProgressBarFcy,SliderFcy,EpisodeFcy,$timeout) {
  11002. var mic = this;
  11003.  
  11004. mic.Category = {};
  11005. mic.Category.Page = 1;
  11006. mic.getSlider = function () {
  11007. SliderFcy.getMovies().then(function (result) {
  11008. mic.Sliders=result;
  11009.  
  11010. ProgressBarFcy.plus(0.1);
  11011. TopCarousel.initCarousel();
  11012. })
  11013. }
  11014. mic.getSlider();
  11015. mic.CategoryId="111";
  11016. mic.CategoryPageTitle = function(categoryId){
  11017. var title = "لیست فیلم ها"
  11018. return title ;
  11019. }
  11020. mic.Category={Offset:0,Limit:50,UpdateInProgress:true,Episodes:[],Page:0,IsPoster:false};
  11021. switch (parseInt(mic.CategoryId)){
  11022. case 6:
  11023. break;
  11024. default:
  11025. break;
  11026. }
  11027. mic.getCategoryEpisodes = function(){
  11028. EpisodeFcy.getCategoryEpisodes(mic.CategoryId,mic.Category.Offset,mic.Category.Limit).then(function(result){
  11029. mic.Category.Page++;
  11030. $timeout(function () {
  11031. $("img.lazyload").lazyload({
  11032. threshold : 150,
  11033. effect : "fadeIn",
  11034. });
  11035. },600);
  11036. var tempArray=[];
  11037. var tempArray2=[];
  11038. tempArray.push(result);
  11039. tempArray2.push(mic.Category.Episodes);
  11040. mic.Category.Episodes = tempArray2[0].concat(tempArray[0]);
  11041. tempArray.length = 0;
  11042. tempArray2.length = 0;
  11043. mic.Category.UpdateInProgress=false;
  11044. ProgressBarFcy.setDone();
  11045. setTimeout(function () {
  11046.  
  11047. $(".carousel-info h5 span").each(function () {
  11048. var elem = $(this);
  11049. var persianNumber = persianUtils.toPersianNumber(elem.html());
  11050. elem.html(persianNumber);
  11051. });
  11052.  
  11053. },200);
  11054.  
  11055. });
  11056. }
  11057. $rootScope.Page.Title=mic.CategoryPageTitle(mic.CategoryId);
  11058. $rootScope.$broadcast("UserData");
  11059. ProgressBarFcy.plus(0.2);
  11060. mic.getNext=function(){
  11061. mic.Category.UpdateInProgress = true;
  11062. mic.Category.Limit=((mic.Category.Page+1)==1)?50:50;
  11063. mic.Category.Offset=((mic.Category.Page+1)==1)?0:((mic.Category.Page)*50);
  11064. mic.getCategoryEpisodes();
  11065. setTimeout(function () {
  11066.  
  11067. $(".carousel-info h5 span").each(function () {
  11068. var elem = $(this);
  11069. var persianNumber = persianUtils.toPersianNumber(elem.html());
  11070. elem.html(persianNumber);
  11071. });
  11072.  
  11073. },200);
  11074. }
  11075. mic.getCategoryEpisodes();
  11076. }
  11077. function SeriesCtrl(GeneralInit,$rootScope,SiteConstants,ProgressBarFcy,SliderFcy,EpisodeFcy,$timeout) {
  11078. var sic = this;
  11079. sic.Category = {};
  11080. sic.Category.Page = 1;
  11081. sic.getSlider = function () {
  11082. SliderFcy.getSeries().then(function (result) {
  11083. sic.Sliders=result;
  11084.  
  11085. ProgressBarFcy.plus(0.1);
  11086. TopCarousel.initCarousel();
  11087. })
  11088. }
  11089. sic.getSlider();
  11090. sic.CategoryId="113";
  11091. sic.CategoryPageTitle = function(categoryId){
  11092. var title = "لیست سریال ها"
  11093. return title ;
  11094. }
  11095. sic.Category={Offset:0,Limit:50,UpdateInProgress:true,Episodes:[],Page:0,IsPoster:false};
  11096. switch (parseInt(sic.CategoryId)){
  11097. case 6:
  11098. break;
  11099. default:
  11100. break;
  11101. }
  11102. sic.getCategoryEpisodes = function(){
  11103. EpisodeFcy.getCategoryEpisodes(sic.CategoryId,sic.Category.Offset,sic.Category.Limit).then(function(result){
  11104. sic.Category.Page++;
  11105. $timeout(function () {
  11106. $("img.lazyload").lazyload({
  11107. threshold : 150,
  11108. effect : "fadeIn",
  11109. });
  11110. },600);
  11111. var tempArray=[];
  11112. var tempArray2=[];
  11113. tempArray.push(result);
  11114. tempArray2.push(sic.Category.Episodes);
  11115. sic.Category.Episodes = tempArray2[0].concat(tempArray[0]);
  11116. tempArray.length = 0;
  11117. tempArray2.length = 0;
  11118. sic.Category.UpdateInProgress=false;
  11119. ProgressBarFcy.setDone();
  11120. setTimeout(function () {
  11121. $(".carousel-info h5 span").each(function () {
  11122. var elem = $(this);
  11123. var persianNumber = persianUtils.toPersianNumber(elem.html());
  11124. elem.html(persianNumber);
  11125. });
  11126.  
  11127. },200);
  11128.  
  11129. });
  11130. }
  11131. $rootScope.Page.Title=sic.CategoryPageTitle(sic.CategoryId);
  11132. $rootScope.$broadcast("UserData");
  11133. ProgressBarFcy.plus(0.2);
  11134. sic.getNext=function(){
  11135. sic.Category.UpdateInProgress = true;
  11136. sic.Category.Limit=((sic.Category.Page+1)==1)?50:50;
  11137. sic.Category.Offset=((sic.Category.Page+1)==1)?0:((sic.Category.Page)*50);
  11138. sic.getCategoryEpisodes();
  11139. setTimeout(function () {
  11140.  
  11141. $(".carousel-info h5 span").each(function () {
  11142. var elem = $(this);
  11143. var persianNumber = persianUtils.toPersianNumber(elem.html());
  11144. elem.html(persianNumber);
  11145. });
  11146.  
  11147. },200);
  11148. }
  11149. sic.getCategoryEpisodes();
  11150. }
  11151. function OlympicsCtrl(GeneralInit,$rootScope,SiteConstants,ProgressBarFcy,SliderFcy,EpisodeFcy) {
  11152. $rootScope.Page.Title=SiteConstants.Fa.PageTitle.OlympicRioPage;
  11153. var orc = this;
  11154. orc.NewsData={Offset:0,Limit:27,UpdateInProgress:true,Episodes:[],Page:0,tempColumn:0};
  11155. orc.WrestlingFarangiData={Offset:0,Limit:35,UpdateInProgress:true,Items:[],Page:0,tempColumn:0};
  11156. orc.WrestlingAzadData={Offset:0,Limit:35,UpdateInProgress:true,Items:[],Page:0,tempColumn:0};
  11157. orc.VolleyballData={Offset:0,Limit:27,UpdateInProgress:true,Items:[],Page:0,tempColumn:0};
  11158. orc.TekwandoData={Offset:0,Limit:27,UpdateInProgress:true,Items:[],Page:0,tempColumn:0};
  11159. orc.AthleticData={Offset:0,Limit:27,UpdateInProgress:true,Items:[],Page:0,tempColumn:0};
  11160. orc.PowerLiftingData={Offset:0,Limit:27,UpdateInProgress:true,Items:[],Page:0,tempColumn:0};
  11161. orc.OtherSportsIranData={Offset:0,Limit:27,UpdateInProgress:true,Items:[],Page:0,tempColumn:0};
  11162. orc.OtherSportsInternationalData={Offset:0,Limit:27,UpdateInProgress:true,Items:[],Page:0,tempColumn:0};
  11163. orc.ShootingData={Offset:0,Limit:27,UpdateInProgress:true,Items:[],Page:0,tempColumn:0};
  11164. orc.FootballData={Offset:0,Limit:27,UpdateInProgress:true,Items:[],Page:0,tempColumn:0};
  11165. orc.getNews=function(){
  11166. EpisodeFcy.getCustom('383214',orc.NewsData.Offset,orc.NewsData.Limit).then(function(CustomEpisodes){
  11167. orc.NewsData.Page++;
  11168. //loaded("OurRecommendations");
  11169. if(orc.NewsData.Page==1){
  11170. TwoRowsCarousel.CarouselInit("news-olympics");
  11171.  
  11172. }
  11173. var tempArray=[];
  11174. var tempArray2=[];
  11175. tempArray.push(CustomEpisodes);
  11176. tempArray2.push(orc.NewsData.Episodes);
  11177. window.OlympicsNews=CustomEpisodes.length;
  11178. window.OlympicsNewsTotal+=parseInt(window.OlympicsNews);
  11179. orc.NewsData.Episodes = CustomEpisodes; /*tempArray2[0].concat(tempArray[0]);*/
  11180. tempArray.length = 0;
  11181. tempArray2.length = 0;
  11182. orc.NewsData.UpdateInProgress=false;
  11183. if(orc.NewsData.Page==1){
  11184. ProgressBarFcy.plus(0.1);
  11185. }
  11186. });
  11187. };
  11188. orc.getAzadWrestlings=function(){
  11189. EpisodeFcy.getCustom('402114',orc.WrestlingAzadData.Offset,orc.WrestlingAzadData.Limit).then(function(CustomEpisodes){
  11190. orc.WrestlingAzadData.Page++;
  11191. //loaded("OurRecommendations");
  11192. if(orc.WrestlingAzadData.Page==1){
  11193. TwoRowsCarousel.CarouselInit("wrestling-azad-olympics");
  11194.  
  11195. }
  11196. var tempArray=[];
  11197. var tempArray2=[];
  11198. tempArray.push(CustomEpisodes);
  11199. tempArray2.push(orc.WrestlingAzadData.Episodes);
  11200. window.OlympicsWrestling=CustomEpisodes.length;
  11201. window.OlympicsWrestlingTotal+=parseInt(window.OlympicsWrestling);
  11202. orc.WrestlingAzadData.Episodes = CustomEpisodes; /*tempArray2[0].concat(tempArray[0]);*/
  11203. tempArray.length = 0;
  11204. tempArray2.length = 0;
  11205. orc.WrestlingAzadData.UpdateInProgress=false;
  11206. if(orc.WrestlingAzadData.Page==1){
  11207. ProgressBarFcy.plus(0.1);
  11208. }
  11209. });
  11210. };
  11211. orc.getFarangiWrestlings=function(){
  11212. EpisodeFcy.getCustom('402115',orc.WrestlingFarangiData.Offset,orc.WrestlingFarangiData.Limit).then(function(CustomEpisodes){
  11213. orc.WrestlingFarangiData.Page++;
  11214. //loaded("OurRecommendations");
  11215. if(orc.WrestlingFarangiData.Page==1){
  11216. TwoRowsCarousel.CarouselInit("wrestling-farangi-olympics");
  11217.  
  11218. }
  11219. var tempArray=[];
  11220. var tempArray2=[];
  11221. tempArray.push(CustomEpisodes);
  11222. tempArray2.push(orc.WrestlingFarangiData.Episodes);
  11223. window.OlympicsWrestlingFarangi=CustomEpisodes.length;
  11224. window.OlympicsWrestlingFarangiTotal+=parseInt(window.OlympicsWrestlingFarangi);
  11225. orc.WrestlingFarangiData.Episodes = CustomEpisodes; /*tempArray2[0].concat(tempArray[0]);*/
  11226. tempArray.length = 0;
  11227. tempArray2.length = 0;
  11228. orc.WrestlingFarangiData.UpdateInProgress=false;
  11229. if(orc.WrestlingFarangiData.Page==1){
  11230. ProgressBarFcy.plus(0.1);
  11231. }
  11232. });
  11233. };
  11234. orc.getVolleyball=function(){
  11235. EpisodeFcy.getCustom('402050',orc.VolleyballData.Offset,orc.VolleyballData.Limit).then(function(CustomEpisodes){
  11236. orc.VolleyballData.Page++;
  11237. //loaded("OurRecommendations");
  11238. if(orc.VolleyballData.Page==1){
  11239. TwoRowsCarousel.CarouselInit("volleyball-olympics");
  11240.  
  11241. }
  11242. var tempArray=[];
  11243. var tempArray2=[];
  11244. tempArray.push(CustomEpisodes);
  11245. tempArray2.push(orc.VolleyballData.Episodes);
  11246. window.OlympicsVolleyball=CustomEpisodes.length;
  11247. window.OlympicsVolleyballTotal+=parseInt(window.OlympicsVolleyball);
  11248. orc.VolleyballData.Episodes = CustomEpisodes; /*tempArray2[0].concat(tempArray[0]);*/
  11249. tempArray.length = 0;
  11250. tempArray2.length = 0;
  11251. orc.VolleyballData.UpdateInProgress=false;
  11252. if(orc.VolleyballData.Page==1){
  11253. ProgressBarFcy.plus(0.1);
  11254. }
  11255. });
  11256. }
  11257. orc.getTekwando=function(){
  11258. EpisodeFcy.getCustom('402051',orc.TekwandoData.Offset,orc.TekwandoData.Limit).then(function(CustomEpisodes){
  11259. orc.TekwandoData.Page++;
  11260. //loaded("OurRecommendations");
  11261. if(orc.TekwandoData.Page==1){
  11262. TwoRowsCarousel.CarouselInit("tekwando-olympics");
  11263.  
  11264. }
  11265. var tempArray=[];
  11266. var tempArray2=[];
  11267. tempArray.push(CustomEpisodes);
  11268. tempArray2.push(orc.TekwandoData.Episodes);
  11269. window.OlympicsTekwando=CustomEpisodes.length;
  11270. window.OlympicsTekwandoTotal+=parseInt(window.OlympicsTekwando);
  11271. orc.TekwandoData.Episodes = CustomEpisodes; /*tempArray2[0].concat(tempArray[0]);*/
  11272. tempArray.length = 0;
  11273. tempArray2.length = 0;
  11274. orc.TekwandoData.UpdateInProgress=false;
  11275. if(orc.TekwandoData.Page==1){
  11276. ProgressBarFcy.plus(0.1);
  11277. }
  11278. });
  11279. }
  11280. orc.getAthletics=function(){
  11281. EpisodeFcy.getCustom('402052',orc.AthleticData.Offset,orc.AthleticData.Limit).then(function(CustomEpisodes){
  11282. orc.AthleticData.Page++;
  11283. //loaded("OurRecommendations");
  11284. if(orc.AthleticData.Page==1){
  11285. TwoRowsCarousel.CarouselInit("athletic-olympics");
  11286.  
  11287. }
  11288. var tempArray=[];
  11289. var tempArray2=[];
  11290. tempArray.push(CustomEpisodes);
  11291. tempArray2.push(orc.AthleticData.Episodes);
  11292. window.OlympicsAthletic=CustomEpisodes.length;
  11293. window.OlympicsAthleticTotal+=parseInt(window.OlympicsAthletic);
  11294. orc.AthleticData.Episodes = CustomEpisodes; /*tempArray2[0].concat(tempArray[0]);*/
  11295. tempArray.length = 0;
  11296. tempArray2.length = 0;
  11297. orc.AthleticData.UpdateInProgress=false;
  11298. if(orc.AthleticData.Page==1){
  11299. ProgressBarFcy.plus(0.1);
  11300. }
  11301. });
  11302. }
  11303. orc.getPowerLiftings=function(){
  11304. EpisodeFcy.getCustom('402053',orc.PowerLiftingData.Offset,orc.PowerLiftingData.Limit).then(function(CustomEpisodes){
  11305. orc.PowerLiftingData.Page++;
  11306. //loaded("OurRecommendations");
  11307. if(orc.PowerLiftingData.Page==1){
  11308. TwoRowsCarousel.CarouselInit("powerlifting-olympics");
  11309.  
  11310. }
  11311. var tempArray=[];
  11312. var tempArray2=[];
  11313. tempArray.push(CustomEpisodes);
  11314. tempArray2.push(orc.PowerLiftingData.Episodes);
  11315. window.OlympicsPowerLifting=CustomEpisodes.length;
  11316. window.OlympicsPowerLiftingTotal+=parseInt(window.OlympicsPowerLifting);
  11317. orc.PowerLiftingData.Episodes = CustomEpisodes; /*tempArray2[0].concat(tempArray[0]);*/
  11318. tempArray.length = 0;
  11319. tempArray2.length = 0;
  11320. orc.PowerLiftingData.UpdateInProgress=false;
  11321. if(orc.PowerLiftingData.Page==1){
  11322. ProgressBarFcy.plus(0.1);
  11323. }
  11324. });
  11325. }
  11326. orc.getOtherSportsIran=function(){
  11327. EpisodeFcy.getCustom('402116',orc.OtherSportsIranData.Offset,orc.OtherSportsIranData.Limit).then(function(CustomEpisodes){
  11328. orc.OtherSportsIranData.Page++;
  11329. //loaded("OurRecommendations");
  11330. if(orc.OtherSportsIranData.Page==1){
  11331. TwoRowsCarousel.CarouselInit("other-sport-iran-olympics");
  11332. }
  11333. var tempArray=[];
  11334. var tempArray2=[];
  11335. tempArray.push(CustomEpisodes);
  11336. tempArray2.push(orc.OtherSportsIranData.Episodes);
  11337. window.OlympicsOtherSportsIran=CustomEpisodes.length;
  11338. window.OlympicsPowerLiftingTotal+=parseInt(window.OlympicsOtherSportsIran);
  11339. orc.OtherSportsIranData.Episodes = CustomEpisodes; /*tempArray2[0].concat(tempArray[0]);*/
  11340. tempArray.length = 0;
  11341. tempArray2.length = 0;
  11342. orc.OtherSportsIranData.UpdateInProgress=false;
  11343. if(orc.OtherSportsIranData.Page==1){
  11344. ProgressBarFcy.plus(0.1);
  11345. }
  11346. });
  11347. }
  11348.  
  11349. orc.getOtherSportsInternational=function(){
  11350. EpisodeFcy.getCustom('402117',orc.OtherSportsInternationalData.Offset,orc.OtherSportsInternationalData.Limit).then(function(CustomEpisodes){
  11351. orc.OtherSportsInternationalData.Page++;
  11352. //loaded("OurRecommendations");
  11353. if(orc.OtherSportsInternationalData.Page==1){
  11354. TwoRowsCarousel.CarouselInit("other-sport-international-olympics");
  11355. }
  11356. var tempArray=[];
  11357. var tempArray2=[];
  11358. tempArray.push(CustomEpisodes);
  11359. tempArray2.push(orc.OtherSportsInternationalData.Episodes);
  11360. window.OlympicsOtherSportsInternational=CustomEpisodes.length;
  11361. window.OlympicsOtherSportsInternationalTotal+=parseInt(window.OlympicsOtherSportsInternational);
  11362. orc.OtherSportsInternationalData.Episodes = CustomEpisodes; /*tempArray2[0].concat(tempArray[0]);*/
  11363. tempArray.length = 0;
  11364. tempArray2.length = 0;
  11365. orc.OtherSportsInternationalData.UpdateInProgress=false;
  11366. if(orc.OtherSportsInternationalData.Page==1){
  11367. ProgressBarFcy.plus(0.1);
  11368. }
  11369. });
  11370. }
  11371. orc.getShootings=function(){
  11372. EpisodeFcy.getCustom('402055',orc.ShootingData.Offset,orc.ShootingData.Limit).then(function(CustomEpisodes){
  11373. orc.ShootingData.Page++;
  11374. //loaded("OurRecommendations");
  11375. if(orc.ShootingData.Page==1){
  11376. TwoRowsCarousel.CarouselInit("shooting-olympics");
  11377. }
  11378. var tempArray=[];
  11379. var tempArray2=[];
  11380. tempArray.push(CustomEpisodes);
  11381. tempArray2.push(orc.ShootingData.Episodes);
  11382. window.OlympicsShooting=CustomEpisodes.length;
  11383. window.OlympicsShootingDataTotal+=parseInt(window.OlympicsShooting);
  11384. orc.ShootingData.Episodes = CustomEpisodes; /*tempArray2[0].concat(tempArray[0]);*/
  11385. tempArray.length = 0;
  11386. tempArray2.length = 0;
  11387. orc.ShootingData.UpdateInProgress=false;
  11388. if(orc.ShootingData.Page==1){
  11389. ProgressBarFcy.plus(0.1);
  11390. }
  11391. });
  11392. }
  11393. orc.getFootballs=function(){
  11394. EpisodeFcy.getCustom('402058',orc.FootballData.Offset,orc.FootballData.Limit).then(function(CustomEpisodes){
  11395. orc.FootballData.Page++;
  11396. //loaded("OurRecommendations");
  11397. if(orc.FootballData.Page==1){
  11398. TwoRowsCarousel.CarouselInit("football-olympics");
  11399. }
  11400. var tempArray=[];
  11401. var tempArray2=[];
  11402. tempArray.push(CustomEpisodes);
  11403. tempArray2.push(orc.FootballData.Episodes);
  11404. window.OlympicsFootball=CustomEpisodes.length;
  11405. window.OlympicsFootballTotal+=parseInt(window.OlympicsFootball);
  11406. orc.FootballData.Episodes = CustomEpisodes; /*tempArray2[0].concat(tempArray[0]);*/
  11407. tempArray.length = 0;
  11408. tempArray2.length = 0;
  11409. orc.FootballData.UpdateInProgress=false;
  11410. if(orc.FootballData.Page==1){
  11411. ProgressBarFcy.plus(0.1);
  11412. }
  11413. });
  11414. };
  11415. orc.getSlider = function () {
  11416. SliderFcy.getOlympics().then(function (result) {
  11417. orc.Sliders=result;
  11418. ProgressBarFcy.plus(0.1);
  11419. TopCarousel.initCarousel();
  11420. })
  11421. }
  11422. orc.getAthletics()
  11423. orc.getAzadWrestlings();
  11424. orc.getFarangiWrestlings();
  11425. orc.getFootballs();
  11426. orc.getNews();
  11427. orc.getOtherSportsInternational();
  11428. orc.getOtherSportsIran();
  11429. orc.getPowerLiftings();
  11430. orc.getShootings();
  11431. orc.getTekwando();
  11432. orc.getVolleyball();
  11433. orc.getSlider();
  11434. }
  11435. function UnsubscribeCtrl(GeneralInit,$rootScope,$routeParams,ProgressBarFcy, UserSrv) {
  11436. $rootScope.Page.Title="خروج از لیست دریافت خبرنامه ها";
  11437. $rootScope.$broadcast("UserData");
  11438. ProgressBarFcy.setDone();
  11439. var usc = this;
  11440. usc.Status={UpdateInProgress:true, IsSuccess: null,message:""};
  11441. usc.checkEmailStatus = function (email) {
  11442. var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;;
  11443. return re.test(email);
  11444. }
  11445. if(usc.checkEmailStatus($routeParams.email)) {
  11446. UserSrv.unsubscribe($routeParams.email).then(function (result) {
  11447. usc.Status.UpdateInProgress = false;
  11448. if (result) {
  11449. usc.Status.IsSuccess = true;
  11450. usc.Status.message = "ایمیل شما با موفقیت از خبرنامه حذف شد."
  11451.  
  11452. }
  11453. else {
  11454. usc.Status.IsSuccess = false;
  11455. usc.Status.message = "خطا در برقراری ارتباط با سرور. لطفا بعد از چند دقیقه مجددا تلاش فرمایید"
  11456. }
  11457. })
  11458. }else{
  11459. usc.Status.UpdateInProgress = false;
  11460. usc.Status.IsSuccess = false;
  11461. usc.Status.message = "لینک وارد شده اشتباه میباشد."
  11462. }
  11463. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement