LIS中學生線上教學頻道
{{t.name}}
{{t.name}}
{{t.name}}
{{t.category_size}}
{{t.course_size}}
{{t.name}}
{{t.editor.full_name}}
{{item.full_name}}
-->' + '' + '
' }; }]) .controller('ChannelController', ['$scope', '$http', '$location', '$timeout', '$translate', '$filter', function($scope, $http, $location, $timeout, $translate, $filter) { $scope.service_url = [location.origin, '/private'].join(''); $scope.global = { message: '' }; $scope.openTab = function(url, target) { window.open(url, target); } $scope.changeLanguage = function(lang) { lang = lang.toLowerCase(); if (lang === 'zh-tw') lang = {title: '繁體中文',type: 'zh-tw'}; else if (lang === 'zh-cn') lang = {title: '简体中文',type: 'zh-cn'}; else if (lang === 'es-ar') lang = {title: 'Español (Argentina)',type: 'es-ar'}; else if (lang === 'es-pe') lang = {title: 'Español (Perú)',type: 'es-pe'}; else if (lang === 'de-de') lang = {title: 'Deutsch',type: 'de-de'}; else lang = {title: 'English',type: 'en-us'}; $scope.language = lang; $translate.use(lang.type); if ($scope.target.account) { ga('send', '/personal/profile', 'service', 'put'); $http.put([$scope.service_url, '/personal/profile'].join(''), {language: JSON.stringify(lang)}) .success(function(response, status) { window.scrollTo(0, 0); }); } } $scope.open1know = function() { window.location.href = [location.origin].join(''); } $scope.signinWithIschool = function() { var width = 800; var height = 700; var top = (screen.height/2)-(height/2); var left = (screen.width/2)-(width/2); var state = encodeURIComponent(['subscribe_channel:', $scope.target.uqid].join('')); var target = ['https://auth.ischool.com.tw/oauth/authorize.php?client_id=a266592ce660b43f980d49b4079d53ed&response_type=code&state=', state, '&redirect_uri=', window.location.origin, '/oauth/ischool&lang=', $scope.lang, '&scope=User.Mail,User.BasicInfo,User.Application'].join(''); window.open(target, '1409620722041', ['width=',width,',height=',height,',menubar=0,titlebar=0,status=0,top=',top,',left=',left].join('')).focus(); } /* Sign In with QSchool */ $scope.signinWithQschool = function(type) { var width = 800; var height = 700; var top = (screen.height/2)-(height/2); var left = (screen.width/2)-(width/2); var state = encodeURIComponent($location.url()); var target = ['https://qschool.benq.com.cn/oauth/authorize.php?client_id=a266592ce660b43f980d49b4079d53ed&response_type=code&state=', state, '&redirect_uri=', $scope.BASE_URL, '/oauth/qschool&lang=', $scope.language.type, '&scope=User.Mail,User.BasicInfo,User.Application', type].join(''); window.open(target, '1409620722041', ['width=',width,',height=',height,',menubar=0,titlebar=0,status=0,top=',top,',left=',left].join('')).focus(); } $scope.subscribe = function() { ga('send', '/channel/:uqid/subscribe', 'service', 'post'); $http.post([$scope.service_url, '/channel/', $scope.target.uqid, '/subscribe'].join('')) .success(function(response, status) { if (!response.error) window.location.href = [location.origin, "/#!/channel/", $scope.target.uqid].join(''); }); } $scope.subscribe = function(type) { ga('send', '/channel/:uqid/subscribe', 'service', 'post'); $http.post([$scope.service_url, '/channel/', $scope.target.uqid, '/subscribe'].join('')) .success(function(response, status) { if (!response.error) { $scope.target.subscribed = true; $('#subscribSuccessModal').modal('show'); } }); } $scope.toSubscribed = function() { window.location.href = [location.origin, "/#!/channel/", $scope.target.uqid].join(''); } $scope.unsubscribe = function() { ga('send', '/channel/:uqid/unsubscribe', 'service', 'delete'); $http.delete([$scope.service_url, '/channel/', $scope.target.uqid, '/unsubscribe'].join('')) .success(function(response, status) { $('#unSubscribModal').modal('hide'); $('#subscribSuccessModal').modal('hide'); if (!response.error) { $scope.target.subscribed = false; } }); } $scope.openCategory = function(target) { var path = [], flag = false; angular.forEach($scope.path, function(item) { if (item.uqid !== target.uqid && !flag) path.push(item); else flag = true; }); if (target.uqid) { $scope.path = path; $scope.loadCategory(target); } else { $scope.path = [{ name: 'Home' }]; $scope.targetCategory = angular.copy($scope.homeCategory); } } $scope.loadCategory = function(target) { $scope.path.push(target); ga('send', '/channel/category/:uqid', 'service', 'get'); $http.get([location.origin, '/channel/category/', target.uqid].join('')) .success(function(response, status) { $scope.targetCategory = { parent: target, categories: response.categories, courses: response.courses } }); } ga('send', '/channel/:uqid.json', 'service', 'get'); $http.get([location.origin, '/channel/9dabff70b431.json'].join('')) .success(function(response, status) { $scope.target = response; $scope.target.editors = response.editors; $scope.target.encode_page = encodeURIComponent(response.page); $scope.targetCategory = { categories: response.categories, courses: [] } $scope.homeCategory = { categories: response.categories, courses: [] } $scope.path = [{ name: 'Home' }]; var image = new Image(); image.src = [location.origin, '/icon.png'].join(''); image.onload = function() { $timeout(function(){ $('#channel_qrcode').html(''); $('#channel_qrcode').qrcode({ image: image, text: [location.origin, '/channel/', $scope.target.uqid].join(''), size: 140, render: 'image', mode: 4, mSize: 0.3, ecLevel: 'Q' }); }); } $('.loading').hide(); $('.completed').show(); if (response.account) { $scope.language = response.account.language; $translate.use($scope.language.type); } else { var lang = 'en-us'; if (window.navigator.language !== undefined) lang = window.navigator.language.toLowerCase(); else if (window.navigator.systemLanguage !== undefined) lang = window.navigator.systemLanguage.toLowerCase(); if (lang === 'zh-tw') lang = {title: '繁體中文',type: 'zh-tw'}; else if (lang === 'zh-cn') lang = {title: '简体中文',type: 'zh-cn'}; else if (lang === 'es-ar') lang = {title: 'Español (Argentina)',type: 'es-ar'}; else if (lang === 'es-pe') lang = {title: 'Español (Perú)',type: 'es-pe'}; else if (lang === 'de-de') lang = {title: 'Deutsch',type: 'de-de'}; else lang = {title: 'English',type: 'en-us'}; $scope.language = lang; $translate.use($scope.language.type); } window.document.title = 'LIS中學生線上教學頻道 - ' +$filter('translate')('N006'); }); }])