added dynamic title

This commit is contained in:
Mario Colque 2014-01-27 15:39:59 -03:00
parent a40b87c4b6
commit f09c041efa
7 changed files with 47 additions and 27 deletions

View File

@ -4,7 +4,7 @@ head
meta(name='viewport', content='width=device-width,initial-scale=1.0') meta(name='viewport', content='width=device-width,initial-scale=1.0')
meta(name="fragment", content="!") meta(name="fragment", content="!")
title= appName+' - '+title title(data-ng-bind="$root.title + $root.titleDetail + ' | #{appName}'")= appName
meta(http-equiv='Content-type', content='text/html;charset=UTF-8') meta(http-equiv='Content-type', content='text/html;charset=UTF-8')
meta(name="keywords", content="node.js, express, mongoose, mongodb, angularjs") meta(name="keywords", content="node.js, express, mongoose, mongodb, angularjs")
meta(name="description", content="Insight") meta(name="description", content="Insight")

View File

@ -1,7 +1,7 @@
doctype html doctype html
html(lang='en', xmlns='http://www.w3.org/1999/xhtml') html(lang='en', xmlns='http://www.w3.org/1999/xhtml', data-ng-app='insight')
include ../includes/head include ../includes/head
body(data-ng-app='insight') body
#wrap #wrap
include ../includes/navbar include ../includes/navbar
block content block content

View File

@ -1,44 +1,56 @@
'use strict'; 'use strict';
//Setting up route //Setting up route
angular.module('insight').config(['$routeProvider', angular.module('insight').config(function($routeProvider) {
function($routeProvider) { $routeProvider.
$routeProvider.
when('/block/:blockHash', { when('/block/:blockHash', {
templateUrl: '/views/block.html' templateUrl: '/views/block.html',
title: 'Bitcoin Block '
}). }).
when('/block-index/:blockHeight', { when('/block-index/:blockHeight', {
controller: 'BlocksController', controller: 'BlocksController',
templateUrl: '/views/redirect.html' templateUrl: '/views/redirect.html'
}). }).
when('/tx/:txId', { when('/tx/:txId', {
templateUrl: '/views/transaction.html' templateUrl: '/views/transaction.html',
title: 'Bitcoin Transaction '
}). }).
when('/', { when('/', {
templateUrl: '/views/index.html' templateUrl: '/views/index.html',
title: 'Home'
}). }).
when('/blocks', { when('/blocks', {
templateUrl: '/views/blocks/list.html' templateUrl: '/views/blocks/list.html',
title: 'Bitcoin Blocks solved Today'
}). }).
when('/blocks-date/:blockDate', { when('/blocks-date/:blockDate', {
templateUrl: '/views/blocks/list.html' templateUrl: '/views/blocks/list.html',
title: 'Bitcoin Blocks solved '
}). }).
when('/address/:addrStr', { when('/address/:addrStr', {
templateUrl: '/views/address.html' templateUrl: '/views/address.html',
title: 'Bitcoin Address '
}). }).
when('/status', { when('/status', {
templateUrl: '/views/status.html' templateUrl: '/views/status.html',
title: 'Status'
}). }).
otherwise({ otherwise({
templateUrl: '/views/404.html' templateUrl: '/views/404.html',
title: 'Error'
}); });
} });
]);
//Setting HTML5 Location Mode //Setting HTML5 Location Mode
angular.module('insight').config(['$locationProvider', angular.module('insight')
function($locationProvider) { .config(function($locationProvider) {
$locationProvider.html5Mode(true); $locationProvider.html5Mode(true);
$locationProvider.hashPrefix('!'); $locationProvider.hashPrefix('!');
} })
]); .run(function($rootScope, $route) {
$rootScope.$on('$routeChangeSuccess', function() {
//Change page title, based on Route information
$rootScope.titleDetail = '';
$rootScope.title = $route.current.title;
});
});

View File

@ -5,6 +5,8 @@ function($scope, $rootScope, $routeParams, $location, Global, Address, getSocket
$scope.global = Global; $scope.global = Global;
$scope.findOne = function() { $scope.findOne = function() {
$rootScope.titleDetail = $routeParams.addrStr;
Address.get({ Address.get({
addrStr: $routeParams.addrStr addrStr: $routeParams.addrStr
}, },

View File

@ -19,6 +19,10 @@ angular.module('insight.blocks').controller('BlocksController',
$scope.list = function() { $scope.list = function() {
$scope.loading = true; $scope.loading = true;
if ($routeParams.blockDate) {
$rootScope.titleDetail = 'on ' + $routeParams.blockDate;
}
Blocks.get({ Blocks.get({
blockDate: $routeParams.blockDate blockDate: $routeParams.blockDate
}, function(res) { }, function(res) {
@ -30,6 +34,7 @@ angular.module('insight.blocks').controller('BlocksController',
$scope.findOne = function() { $scope.findOne = function() {
$scope.loading = true; $scope.loading = true;
$rootScope.titleDetail = $routeParams.blockHash;
Block.get({ Block.get({
blockHash: $routeParams.blockHash blockHash: $routeParams.blockHash

View File

@ -104,11 +104,7 @@ function($scope, $rootScope, $routeParams, $location, Global, Transaction, Trans
}); });
}; };
$scope.findThis = function() { var _findTx = function(txid) {
$scope.findTx($routeParams.txId);
};
$scope.findTx = function(txid) {
Transaction.get({ Transaction.get({
txId: txid txId: txid
}, function(tx) { }, function(tx) {
@ -130,6 +126,11 @@ function($scope, $rootScope, $routeParams, $location, Global, Transaction, Trans
}); });
}; };
$scope.findThis = function() {
$rootScope.titleDetail = $routeParams.txId;
_findTx($routeParams.txId);
};
//Initial load //Initial load
$scope.load = function(from) { $scope.load = function(from) {
$scope.loadedBy = from; $scope.loadedBy = from;
@ -154,7 +155,7 @@ function($scope, $rootScope, $routeParams, $location, Global, Transaction, Trans
$scope.txs = []; $scope.txs = [];
$scope.$on('tx', function(event, txid) { $scope.$on('tx', function(event, txid) {
$scope.findTx(txid); _findTx(txid);
}); });
}); });

View File

@ -2,5 +2,5 @@
angular.element(document).ready(function() { angular.element(document).ready(function() {
// Init the app // Init the app
angular.bootstrap(document, ['insight']); // angular.bootstrap(document, ['insight']);
}); });