Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function () {
- var app = angular.module('store', ['ngRoute'], function($interpolateProvider) {
- $interpolateProvider.startSymbol('<%');
- $interpolateProvider.endSymbol('%>');
- });
- app.config(['$httpProvider', '$locationProvider','$routeProvider',
- function($httpProvider,$locationProvider,$routeProvider) {
- $httpProvider.defaults.headers.common["X-Requested-With"] = 'XMLHttpRequest';
- $locationProvider.html5Mode(true);
- $routeProvider
- /*
- * Route for home page
- */
- .when('/', {
- templateUrl : 'pages/home.html',
- controller : 'MainController'
- })
- /*
- * Route for cart
- */
- .when('/kosar',{
- templateUrl : 'pages/cart.html',
- controller : 'CartController'
- })
- /*
- * Route for registration
- */
- .when('/regisztracio',{
- templateUrl : 'pages/regform.html',
- controller : 'RegController'
- })
- /*
- * Route for profile edit
- */
- .when('/adatmodosítas',{
- templateUrl : 'pages/editform.html',
- controller : 'RegController'
- })
- /*
- * Route for search main page
- */
- .when('/kereses',{
- templateUrl : 'pages/list.html',
- controller : 'SearchController'
- })
- /*
- * Route for search results
- */
- .when('/kereses/:param1/:param2?/oldal/:pagenum',{
- templateUrl : 'pages/list.html',
- controller : 'SearchController'
- })
- /*
- * Route for news(news list)
- */
- .when('/hirek/oldal/:pagenum',{
- templateUrl : 'pages/article_list.html',
- controller : 'NewsController'
- })
- /*
- * Route for news with params (specific news page)
- */
- .when('/hirek/:article',{
- templateUrl : 'pages/article.html',
- controller : 'NewsController'
- })
- .when('/:platform',{
- templateUrl : 'pages/list.html',
- controller : 'ProductController'
- })
- .when('/:platform/:category/:pagenum',{
- templateUrl : 'pages/list.html',
- controller : 'ProductController'
- })
- .when('/:platform/:product',{
- templateUrl : 'pages/list.html',
- controller : 'ProductController'
- });
- }]);
- app.run(["$rootScope","$http","$location", function ($rootScope,$http,$location) {
- $http.post("login",{check: true}).success(function(data){
- $rootScope.authenticated = true;
- $rootScope.userData = data;
- });
- $rootScope.$on("$routeChangeStart", function(event, next, current) {
- if($location.path() == "/adatmodositas") {
- if(!$rootScope.authenticated){
- event.preventDefault();
- }
- }
- });
- }]);
- app.controller("SearchController", ["$http", function ($http) {
- this.term = "";
- this.result = "";
- var search = this;
- this.search = function () {
- if(this.term.length>2){
- $http.post("/gp/new/public/kereses", {search: this.term})
- .success(function(data){
- search.result = data;
- })
- .error(function(){
- search.result = false;
- });
- }
- };
- this.showResult = function(){
- return this.term.length > 2;
- };
- }]);
- app.controller("UserController", ["$http", "$rootScope", function($http,$rootScope){
- this.login = false;
- this.email = "";
- this.password = "";
- var user = this;
- this.showLogin = function(){
- this.login?this.login=false:this.login=true;
- };
- this.auth = function(){
- $http.post("login",{email: user.email, password: user.password})
- .success(function(data){
- $rootScope.authenticated = true;
- $rootScope.userData = data;
- });
- };
- this.logout = function(){
- $http.post("logout",{logout: true}).success(function(){
- $rootScope.authenticated = false;
- $rootScope.userData = {};
- });
- };
- }]);
- app.controller("MainController",["$scope", "$http", function($scope,$http){
- $http.get("https://www.videojatekbolt.hu/gp/new/public/carousel")
- .success(function(data){
- $scope.carousel = data;
- });
- }]);
- app.controller("CartController",["$rootScope", function($rootScope){
- }]);
- app.controller("RegController",["$http", "$rootScope", function($http,$rootScope){
- $rootScope.form = {};
- $rootScope.submit = function(){
- $http.post("regisztracio",$rootScope.form).success(function(){
- $rootScope.authenticated = true;
- $rootScope.userData = data;
- });
- }
- }]);
- app.controller("ProductController", ["$routeParams", "$scope", function($routeParams,$scope){
- $scope.name = "Product";
- }]);
- app.controller("NewsController", ["$routeParams", "$http", "$scope", "$sce",
- function($routeParams,$http,$scope,$sce){
- var news = this;
- if($routeParams.article !== undefined){
- $http.post("article",{url: $routeParams.article}).success(function(data){
- $scope.article = data;
- $scope.article.data = $sce.trustAsHtml($scope.article.data);
- $scope.found = true;
- }).error(function(){
- $scope.found = false;
- });
- }
- else{
- $http.post("news",{get: true}).success(function(data){
- $scope.news = data;
- $scope.found = true;
- }).error(function(){
- $scope.found = false;
- });
- }
- }]);
- app.controller("SearchController", ["$routeParams", "$scope", function($routeParams,$scope){
- $scope.name = "Search";
- }]);
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement