在我的网络应用程序中,我有一个按钮允许用户在全屏模式下工作。我的问题是,它仅适用于当前页面,如果我们单击链接或以任何其他方式更改页面,或者即使我们刷新当前页面,全屏模式也会丢失。
这是我用来允许全屏的功能:
// Handle full screen mode toggle
var handleFullScreenMode = function () {
// toggle full screen
function toggleFullScreen() {
if (!document.fullscreenElement && !document.mozFullScreenElement && !document.webkitFullscreenElement) { // current working methods
if (document.documentElement.requestFullscreen) {
document.documentElement.requestFullscreen();
} else if (document.documentElement.mozRequestFullScreen) {
document.documentElement.mozRequestFullScreen();
} else if (document.documentElement.webkitRequestFullscreen) {
document.documentElement.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT);
}
} else {
if (document.cancelFullScreen) {
document.cancelFullScreen();
} else if (document.mozCancelFullScreen) {
document.mozCancelFullScreen();
} else if (document.webkitCancelFullScreen) {
document.webkitCancelFullScreen();
}
}
}
$('#trigger_fullscreen').click(function () {
toggleFullScreen();
});
}
$(document).ready(function () { …
Run Code Online (Sandbox Code Playgroud) 编辑:忘了提到我已经和AngularJs一起工作了一个星期,所以如果你看到一些你认为应该改善的东西并且与问题无关,请随时在评论部分告诉我.
好的,所以我有我的身份验证控制器和提供程序,我不会显示,因为它们与问题的范围无关.然后我有一个拦截器来检查用户是否在进行呼叫时进行了身份验证.如果是这样的话,我Authentication
在请求上设置标题以包括用户的令牌,如果不是我将用户重定向到登录页面,甚至不向服务器发出请求(显然如果有人绕过它,那么也是Authorize
API上的).
我想要的是添加一些例外,这意味着即使用户没有Auth Token也有一些我想要允许的页面.如果它是一个特定的路径,我能够这样做,但是我想允许访问我的404页面并且它Routing
是我指定.otherwise
去404页面的,我怎样才能使我的拦截器只重定向到登录,如果它不会到这个页面.
拦截器
.factory('authInterceptorService', ['$q', '$location', 'localStorageService', function ($q, $location, localStorageService) {
var authInterceptorServiceFactory = {};
var authData = localStorageService.get('authorizationData');
var _request = function (config) {
config.headers = config.headers || {};
if (authData) {
config.headers.Authorization = 'Bearer ' + authData.token;
} else if ($location.path != '/accounts/login' && $location.path != '/accounts/register') {
$location.path('/accounts/login');
}
return config;
}
var _responseError = function (rejection) {
if (rejection.status === 401) {
$location.path('/accounts/login');
}
return …
Run Code Online (Sandbox Code Playgroud)