github.com/brownsys/tracing-framework-go@v0.0.0-20161210174012-0542a62412fe/go/darwin_amd64/misc/tour/static/js/app.js (about) 1 /* Copyright 2012 The Go Authors. All rights reserved. 2 * Use of this source code is governed by a BSD-style 3 * license that can be found in the LICENSE file. 4 */ 5 'use strict'; 6 7 angular.module('tour', ['ui', 'tour.services', 'tour.controllers', 'tour.directives', 'tour.values', 'ng']). 8 9 config(['$routeProvider', '$locationProvider', 10 function($routeProvider, $locationProvider) { 11 $routeProvider. 12 when('/', { 13 redirectTo: '/welcome/1' 14 }). 15 when('/list', { 16 templateUrl: '/static/partials/list.html', 17 }). 18 when('/:lessonId/:pageNumber', { 19 templateUrl: '/static/partials/editor.html', 20 controller: 'EditorCtrl' 21 }). 22 when('/:lessonId', { 23 redirectTo: '/:lessonId/1' 24 }). 25 otherwise({ 26 redirectTo: '/' 27 }); 28 29 $locationProvider.html5Mode(true).hashPrefix('!'); 30 } 31 ]). 32 33 // handle mapping from old paths (#42) to the new organization. 34 run(function($rootScope, $location, mapping) { 35 $rootScope.$on( "$locationChangeStart", function(event, next) { 36 var url = document.createElement('a'); 37 url.href = next; 38 if (url.pathname != '/' || url.hash == '') { 39 return; 40 } 41 $location.hash(''); 42 var m = mapping[url.hash]; 43 if (m === undefined) { 44 console.log('unknown url, redirecting home'); 45 $location.path('/welcome/1'); 46 return; 47 } 48 $location.path(m); 49 }); 50 });