forked from mape/node-express-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
215 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,13 @@ | ||
if (!window.console) { | ||
var console = { | ||
'log': function(){} | ||
, 'dir': function(){} | ||
, 'time': function(){} | ||
, 'timeEnd': function(){} | ||
, 'profile': function(){} | ||
, 'profileEnd': function(){} | ||
} | ||
} | ||
(function ($) { | ||
$('body').removeClass('nojs'); | ||
setInterval(function () { | ||
$('h1').text(new Date().toString()); | ||
}, 500); | ||
})(jQuery.noConflict()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,72 @@ | ||
setTimeout(function () { | ||
(function reload ($) { | ||
var currentPath = window.location.href.replace(new RegExp('https?://' + window.location.host, ''), ''); | ||
var doReload = true; | ||
(function ($) { | ||
function doMoveAjax(url) { | ||
if (url) { | ||
$.ajax({ | ||
'url': '/reload-content/', | ||
'data': { | ||
'path': url | ||
}, | ||
'type': 'post', | ||
'cache': false, | ||
'success': function (text) { | ||
$('.refresh').fadeTo(200, 0.2).fadeTo(200, 1).fadeTo(200, 0.2).fadeTo(200, 1); | ||
} | ||
}); | ||
} | ||
}(function reload($) { | ||
$.ajax({ | ||
'url': '/reload/' | ||
, 'success': function () { | ||
$('link').each(function(index) { | ||
$(this).attr('href', $(this).attr('href').replace(/[0-9]+/, new Date().getTime())); | ||
}); | ||
|
||
} | ||
, 'complete': function () { | ||
setTimeout(function() { | ||
reload($); | ||
'url': '/reload-content/', | ||
'cache': false, | ||
'success': function (text) { | ||
if (text === 'css') { | ||
$('link').each(function (index) { | ||
$(this).attr('href', $(this).attr('href').replace(/[0-9]+/, new Date().getTime())); | ||
}); | ||
} else if (text === 'content') { | ||
setTimeout(function () { | ||
window.location.reload(true); | ||
}, 200); | ||
} else { | ||
if (text && currentPath !== text) { | ||
doReload = false; | ||
window.location = text; | ||
} | ||
} | ||
}, | ||
'complete': function () { | ||
setTimeout(function () { | ||
if (doReload) { | ||
reload($); | ||
} | ||
}, 1000); | ||
} | ||
}); | ||
})(jQuery); | ||
}, 1000); | ||
})($); | ||
$('a').live('click', function (event) { | ||
doMoveAjax($(this).attr('href')); | ||
}); | ||
var $refresh = $('<div class="refresh">R</div>').click(function (event) { | ||
doMoveAjax(currentPath); | ||
}).appendTo('body').css({ | ||
'position': 'fixed', | ||
'bottom': '50%', | ||
'right': '0px', | ||
'cursor': 'pointer', | ||
'color': '#fff', | ||
'background-color': '#000', | ||
'font-weight': 'bold', | ||
'padding': '2px 4px 2px 6px', | ||
'line-height': '100%', | ||
'font-size': '14px' | ||
}); | ||
if (!$.browser.msie) { | ||
$refresh.css({ | ||
'background-color': 'rgba(0,0,0,0.7)', | ||
'border-radius': '5px 0 0 5px', | ||
'-moz-border-radius': '5px 0 0 5px', | ||
'-webkit-border-radius': '5px 0 0 5px' | ||
}); | ||
} | ||
})(jQuery); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
<h1><%=date %></h1> | ||
<h1><a href="/test/"><%=date %></a></h1> |
Oops, something went wrong.