mirror of
https://github.com/EDCD/coriolis.git
synced 2025-12-09 06:43:24 +00:00
80 lines
2.2 KiB
HTML
80 lines
2.2 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>Coriolis: Migrate to HTTPS</title>
|
|
</head>
|
|
<body>
|
|
<script>
|
|
|
|
function fromJsonToObject(str) {
|
|
try {
|
|
var o = JSON.parse(str);
|
|
if (o instanceof Object && !(o instanceof Array)) {
|
|
return o;
|
|
}
|
|
} catch (e) { }
|
|
return {};
|
|
}
|
|
|
|
function listener(event) {
|
|
var origin = event.origin || event.originalEvent.origin;
|
|
var source = event.source;
|
|
var data = event.message;
|
|
|
|
if (window.location.href.indexOf('coriolis') != -1 && origin !== "http://coriolis.io") {
|
|
return;
|
|
}
|
|
|
|
try {
|
|
var builds = fromJsonToObject(localStorage.getItem('builds'));
|
|
var comparisons = fromJsonToObject(localStorage.getItem('comparisons'));
|
|
|
|
// merge builds
|
|
if (typeof data.builds == 'object') {
|
|
|
|
for (var bName in data.builds) {
|
|
// Build existing in http and does not existing in HTTPS
|
|
if (data.builds.hasOwnProperty(bName) && !builds[bName]) {
|
|
build[bName] = data.builds[bName];
|
|
}
|
|
}
|
|
|
|
localStorage.setItem('builds', JSON.stringify(builds));
|
|
}
|
|
// merge comparisons
|
|
if (typeof data.comparisons == 'object') {
|
|
|
|
for (var comp in data.comparisons) {
|
|
// Comparison existing in http and does not existing in HTTPS
|
|
if (data.comparisons.hasOwnProperty(comp) && !data.comparisons[comp]) {
|
|
comparisons[comp] = data.comparisons[comp];
|
|
}
|
|
}
|
|
localStorage.setItem('comparisons', JSON.stringify(comparisons));
|
|
}
|
|
|
|
source.postMessage({
|
|
success: true,
|
|
buildCount: Object.keys(builds).length,
|
|
comparisonCount: Object.keys(comparisons).length
|
|
}, origin);
|
|
|
|
} catch (e) {
|
|
source.postMessage({ success: false, error: e }, origin);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
if (window.addEventListener){
|
|
window.addEventListener("message", listener, false);
|
|
} else {
|
|
window.attachEvent("onmessage", listener);
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|
|
|
|
|