2020-12-07 03:02:50 +01:00
|
|
|
//*
|
|
|
|
import MangroveReviews from "./Logic/Web/MangroveReviews";
|
2020-12-08 23:44:34 +01:00
|
|
|
import ReviewElement from "./UI/Reviews/ReviewElement";
|
|
|
|
import {UIEventSource} from "./Logic/UIEventSource";
|
|
|
|
import ReviewForm from "./UI/Reviews/ReviewForm";
|
|
|
|
import Combine from "./UI/Base/Combine";
|
|
|
|
import {FixedUiElement} from "./UI/Base/FixedUiElement";
|
2020-12-07 03:02:50 +01:00
|
|
|
|
|
|
|
/*
|
2020-12-08 23:44:34 +01:00
|
|
|
window.setTimeout(
|
|
|
|
() => {
|
|
|
|
mangroveReviews.AddReview({
|
|
|
|
comment: "These are liars - not even an island here!",
|
|
|
|
author: "Lost Tourist",
|
|
|
|
date: new Date(),
|
|
|
|
affiliated: false,
|
|
|
|
rating: 10
|
|
|
|
}, (() => {alert("Review added");return undefined;}));
|
|
|
|
|
|
|
|
}, 1000
|
|
|
|
)
|
2020-12-07 03:02:50 +01:00
|
|
|
|
2020-12-08 23:44:34 +01:00
|
|
|
window.setTimeout(
|
|
|
|
() => {
|
|
|
|
mangroveReviews.AddReview({
|
|
|
|
comment: "Excellent conditions to measure weather!!",
|
|
|
|
author: "Weather-Boy",
|
|
|
|
date: new Date(),
|
|
|
|
affiliated: true,
|
|
|
|
rating: 90
|
|
|
|
}, (() => {
|
|
|
|
alert("Review added");
|
|
|
|
return undefined;
|
|
|
|
}));
|
2020-08-31 02:59:47 +02:00
|
|
|
|
2020-12-08 23:44:34 +01:00
|
|
|
}, 1000
|
|
|
|
)
|
|
|
|
*/
|
2020-10-06 01:37:02 +02:00
|
|
|
/*/
|
2020-10-02 19:00:24 +02:00
|
|
|
|
|
|
|
|
|
|
|
import {Utils} from "./Utils";
|
|
|
|
import {FixedUiElement} from "./UI/Base/FixedUiElement";
|
|
|
|
|
2020-11-05 13:34:48 +01:00
|
|
|
|
|
|
|
function generateStats(action: (stats: string) => void) {
|
|
|
|
// Binary searches the latest changeset
|
|
|
|
function search(lowerBound: number,
|
|
|
|
upperBound: number,
|
|
|
|
onCsFound: ((id: number, lastDate: Date) => void),
|
|
|
|
depth = 0) {
|
|
|
|
if (depth > 30) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
const tested = Math.floor((lowerBound + upperBound) / 2);
|
|
|
|
console.log("Testing", tested)
|
|
|
|
Utils.changesetDate(tested, (createdAtDate: Date) => {
|
|
|
|
new FixedUiElement(`Searching, value between ${lowerBound} and ${upperBound}. Queries till now: ${depth}`).AttachTo('maindiv')
|
|
|
|
if (lowerBound + 1 >= upperBound) {
|
|
|
|
onCsFound(lowerBound, createdAtDate);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (createdAtDate !== undefined) {
|
|
|
|
search(tested, upperBound, onCsFound, depth + 1)
|
|
|
|
} else {
|
|
|
|
search(lowerBound, tested, onCsFound, depth + 1);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
search(91000000, 100000000, (last, lastDate: Date) => {
|
|
|
|
const link = "http://osm.org/changeset/" + last;
|
|
|
|
|
|
|
|
const delta = 100000;
|
|
|
|
|
|
|
|
Utils.changesetDate(last - delta, (prevDate) => {
|
|
|
|
|
|
|
|
|
|
|
|
const diff = (lastDate.getTime() - prevDate.getTime()) / 1000;
|
|
|
|
|
|
|
|
// Diff: seconds needed/delta changesets
|
|
|
|
const secsPerCS = diff / delta;
|
|
|
|
|
|
|
|
const stillNeeded = 1000000 - (last % 1000000);
|
|
|
|
const timeNeededSeconds = Math.floor(secsPerCS * stillNeeded);
|
|
|
|
|
|
|
|
const secNeeded = timeNeededSeconds % 60;
|
|
|
|
const minNeeded = Math.floor(timeNeededSeconds / 60) % 60;
|
|
|
|
const hourNeeded = Math.floor(timeNeededSeconds / (60 * 60)) % 24;
|
|
|
|
const daysNeeded = Math.floor(timeNeededSeconds / (24 * 60 * 60));
|
|
|
|
|
|
|
|
const result = `Last changeset: <a href='${link}'>${link}</a><br/>We needed ${(Math.floor(diff / 60))} minutes for the last ${delta} changesets.<br/>
|
|
|
|
This is around ${secsPerCS} seconds/changeset.<br/> The next million (still ${stillNeeded} away) will be broken in around ${daysNeeded} days ${hourNeeded}:${minNeeded}:${secNeeded}`
|
|
|
|
action(result);
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
generateStats((stats) => {
|
|
|
|
new FixedUiElement(stats).AttachTo('maindiv')
|
2020-10-02 19:00:24 +02:00
|
|
|
})
|
2020-11-05 13:34:48 +01:00
|
|
|
|
|
|
|
|
2020-10-02 19:00:24 +02:00
|
|
|
//*/
|