@glitchr/transparent 1.0.37 → 1.0.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/js/transparent.js +19 -8
package/package.json
CHANGED
package/src/js/transparent.js
CHANGED
|
@@ -1568,19 +1568,22 @@
|
|
|
1568
1568
|
return dispatchEvent(new Event('load'));
|
|
1569
1569
|
}
|
|
1570
1570
|
|
|
1571
|
-
//
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
history.pushState({uuid: uuid, status:status, method: method, data: {}, href: responseURL}, '', responseURL);
|
|
1571
|
+
// Invalid html page returned
|
|
1572
|
+
if(!responseText.includes("<html>") || !responseText.includes("<body>") || !responseText.includes("<head>"))
|
|
1573
|
+
return Transparent.rescue(dom);
|
|
1575
1574
|
|
|
1576
|
-
|
|
1577
|
-
if(status != 200) // Blatant error received..
|
|
1575
|
+
if(status >= 400) // Blatant error received..
|
|
1578
1576
|
return Transparent.rescue(dom);
|
|
1579
1577
|
|
|
1580
|
-
// Page not recognized.. just go
|
|
1578
|
+
// Page not recognized.. just go fetch by yourself.. no POST information transmitted..
|
|
1581
1579
|
if(!Transparent.isPage(dom))
|
|
1582
1580
|
return window.location.href = url;
|
|
1583
1581
|
|
|
1582
|
+
// From here the page is valid..
|
|
1583
|
+
// so the new page is added to history..
|
|
1584
|
+
if(xhr)
|
|
1585
|
+
history.pushState({uuid: uuid, status:status, method: method, data: {}, href: responseURL}, '', responseURL);
|
|
1586
|
+
|
|
1584
1587
|
// Layout not compatible.. needs to be reloaded (exception when POST is detected..)
|
|
1585
1588
|
if(!Transparent.isCompatiblePage(dom, method, data))
|
|
1586
1589
|
return window.location.href = url;
|
|
@@ -1705,6 +1708,8 @@
|
|
|
1705
1708
|
|
|
1706
1709
|
window.onbeforeunload = function() {
|
|
1707
1710
|
|
|
1711
|
+
if(Transparent.get("disable")) return;
|
|
1712
|
+
|
|
1708
1713
|
var preventDefault = false;
|
|
1709
1714
|
var formDataAfter = [];
|
|
1710
1715
|
$("form").each(function() {
|
|
@@ -1744,8 +1749,14 @@
|
|
|
1744
1749
|
}
|
|
1745
1750
|
}
|
|
1746
1751
|
|
|
1747
|
-
if(Settings.debug || preventDefault)
|
|
1752
|
+
if(Settings.debug || preventDefault) {
|
|
1753
|
+
|
|
1754
|
+
if(preventDefault) Transparent.html.addClass(Transparent.state.READY);
|
|
1755
|
+
if(preventDefault) Transparent.activeOut();
|
|
1756
|
+
if(preventDefault) dispatchEvent(new Event('load'));
|
|
1757
|
+
|
|
1748
1758
|
return "Dude, are you sure you want to leave? Think of the kittens!";
|
|
1759
|
+
}
|
|
1749
1760
|
}
|
|
1750
1761
|
|
|
1751
1762
|
document.addEventListener('click', __main__, false);
|