forked from MapComplete/MapComplete
Further work on infobox, styling everything, removing clutter
This commit is contained in:
parent
2acd53d150
commit
0b4016b65d
48 changed files with 1283 additions and 454 deletions
34
Helpers.ts
34
Helpers.ts
|
|
@ -1,25 +1,23 @@
|
|||
import {OsmConnection} from "./Logic/OsmConnection";
|
||||
import {Changes} from "./Logic/Changes";
|
||||
import {UIEventSource} from "./UI/UIEventSource";
|
||||
import {PendingChanges} from "./UI/PendingChanges";
|
||||
|
||||
export class Helpers {
|
||||
|
||||
|
||||
static SetupAutoSave(changes: Changes, secondsTillChangesAreSaved : UIEventSource<number>) {
|
||||
static SetupAutoSave(changes: Changes, millisTillChangesAreSaved : UIEventSource<number>, saveAfterXMillis : number) {
|
||||
|
||||
// This little function triggers the actual upload:
|
||||
// Either when more then three answers are selected, or when no new answer has been added for the last 20s
|
||||
// @ts-ignore
|
||||
window.decreaseTime = function () {
|
||||
var time = secondsTillChangesAreSaved.data;
|
||||
var time = millisTillChangesAreSaved.data;
|
||||
if (time <= 0) {
|
||||
if (changes._pendingChanges.length > 0) {
|
||||
if (changes.pendingChangesES.data > 0) {
|
||||
changes.uploadAll(undefined);
|
||||
}
|
||||
} else {
|
||||
secondsTillChangesAreSaved.setData(time - 1000);
|
||||
|
||||
millisTillChangesAreSaved.setData(time - 1000);
|
||||
}
|
||||
window.setTimeout('decreaseTime()', 1000);
|
||||
};
|
||||
|
|
@ -27,15 +25,15 @@ export class Helpers {
|
|||
|
||||
changes.pendingChangesES.addCallback(function () {
|
||||
|
||||
var c = changes._pendingChanges.length;
|
||||
var c = changes.pendingChangesES.data;
|
||||
if (c > 10) {
|
||||
secondsTillChangesAreSaved.setData(0);
|
||||
millisTillChangesAreSaved.setData(0);
|
||||
changes.uploadAll(undefined);
|
||||
return;
|
||||
}
|
||||
|
||||
if (c > 0) {
|
||||
secondsTillChangesAreSaved.setData(5000);
|
||||
millisTillChangesAreSaved.setData(saveAfterXMillis);
|
||||
}
|
||||
|
||||
});
|
||||
|
|
@ -44,22 +42,6 @@ export class Helpers {
|
|||
window.decreaseTime(); // The timer keeps running...
|
||||
}
|
||||
|
||||
/**
|
||||
* All elements with class 'activate-osm-authentication' are loaded and get an 'onclick' to authenticate
|
||||
* @param osmConnection
|
||||
*/
|
||||
static registerActivateOsmAUthenticationClass(osmConnection: OsmConnection) {
|
||||
|
||||
const authElements = document.getElementsByClassName("activate-osm-authentication");
|
||||
for (let i = 0; i < authElements.length; i++) {
|
||||
let element = authElements.item(i);
|
||||
// @ts-ignore
|
||||
element.onclick = function () {
|
||||
osmConnection.AttemptLogin();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
|
|
@ -72,7 +54,7 @@ export class Helpers {
|
|||
|
||||
window.addEventListener("beforeunload", function (e) {
|
||||
// Quickly save everyting!
|
||||
if (changes._pendingChanges.length == 0) {
|
||||
if (changes.pendingChangesES.data == 0) {
|
||||
return "";
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue