|
@@ -84,8 +84,13 @@ $(document).ready(function() {
|
|
|
|
|
|
initFastLoad();
|
|
initFastLoad();
|
|
});
|
|
});
|
|
|
|
+
|
|
|
|
+var fastCache = {};
|
|
|
|
+
|
|
function initFastLoad(_parent = false) {
|
|
function initFastLoad(_parent = false) {
|
|
|
|
|
|
|
|
+ fastCache = {};
|
|
|
|
+
|
|
var allAs = $('a:not([onclick]):not([href="#"]):visible');
|
|
var allAs = $('a:not([onclick]):not([href="#"]):visible');
|
|
if(_parent) {
|
|
if(_parent) {
|
|
allAs = _parent.find('a:not([onclick]):not([href="#"]):visible');
|
|
allAs = _parent.find('a:not([onclick]):not([href="#"]):visible');
|
|
@@ -101,36 +106,58 @@ function initFastLoad(_parent = false) {
|
|
});
|
|
});
|
|
|
|
|
|
function enableFastLoad(_a) {
|
|
function enableFastLoad(_a) {
|
|
- var targetParent = $('.stag-content');
|
|
|
|
$(_a).on('click', function() {
|
|
$(_a).on('click', function() {
|
|
- $.get(_a.href, function(_data) {
|
|
|
|
- _data = '<div>' + _data + '</div>';
|
|
|
|
- var content = $(_data).find('.stag-content');
|
|
|
|
- if(content) {
|
|
|
|
- content = content.html();
|
|
|
|
- content += '<script src="/js/yemi.js"></script>';
|
|
|
|
- targetParent.html(content);
|
|
|
|
- initFastLoad(targetParent);
|
|
|
|
-
|
|
|
|
- // push state
|
|
|
|
- var target = _a.href;
|
|
|
|
- if(target.indexOf('//') !== -1) {
|
|
|
|
- target = target.split('//')[1];
|
|
|
|
- if(target.indexOf('/') !== -1) {
|
|
|
|
- target = target.substr(target.indexOf('/') + 1);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- window.top.history.pushState(target, null, '/mc/' + target);
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- else {
|
|
|
|
- console.warn('Target page not found: ' + this.href);
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
|
|
+ fastLoad(this.href, true, true);
|
|
return false;
|
|
return false;
|
|
});
|
|
});
|
|
console.info('FastLoad enabled for ' + _a.innerText + ' [' + _a.href + ']');
|
|
console.info('FastLoad enabled for ' + _a.innerText + ' [' + _a.href + ']');
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ // fast cache
|
|
|
|
+ allAs = $('a:not([onclick]):not([href="#"]):visible');
|
|
|
|
+ allAs.each(function() {
|
|
|
|
+ var a = this;
|
|
|
|
+ $.get(a.href, function (_data) {
|
|
|
|
+ fastCache[a.href] = _data;
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+}
|
|
|
|
+function fastLoad(_href, _history = true, _useCache = true) {
|
|
|
|
+ function onData(_data) {
|
|
|
|
+ var targetParent = $('.stag-content');
|
|
|
|
+ _data = '<div>' + _data + '</div>';
|
|
|
|
+ var content = $(_data).find('.stag-content');
|
|
|
|
+ if(content && content.length) {
|
|
|
|
+ content = content.html();
|
|
|
|
+ content += '<script src="/js/yemi.js"></script>';
|
|
|
|
+ targetParent.html(content);
|
|
|
|
+ initFastLoad(targetParent);
|
|
|
|
+
|
|
|
|
+ // push state
|
|
|
|
+ if(_history) {
|
|
|
|
+ var target = _href;
|
|
|
|
+ if(target.indexOf('//') !== -1) {
|
|
|
|
+ target = target.split('//')[1];
|
|
|
|
+ if(target.indexOf('/') !== -1) {
|
|
|
|
+ target = target.substr(target.indexOf('/') + 1);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ window.top.history.pushState(target, null, '/mc/' + target);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ console.warn('Target page not found: ' + _href);
|
|
|
|
+ window.location.href = _href; // fallback
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if(_useCache && !!fastCache[_href]) {
|
|
|
|
+ onData(fastCache[_href]);
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ $.get(_href, onData);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
function openInRHS(_url) {
|
|
function openInRHS(_url) {
|
|
window.top.showRHS();
|
|
window.top.showRHS();
|