notepad

Check-in [a6fc6661c6]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Some more work on smart sync timing
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | master | trunk
Files: files | file ages | folders
SHA3-256:a6fc6661c662292d0465ad7aed4e617a77100026434b68c2123ab71919913b03
User & Date: vandys 2019-10-29 22:08:28
Context
2019-10-29
22:08
Some more work on smart sync timing Leaf check-in: a6fc6661c6 user: vandys tags: master, trunk
22:08
typo check-in: 4bfb7fb70f user: vandys tags: master, trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to js/main.js.

12
13
14
15
16
17
18


19
20
21
22
23
24
25
26
27
28
29



















30
31
32
33
34
35
36
37
38
39
40
41


42


43



44
45
46
47
48
49
50
..
55
56
57
58
59
60
61

62
63
64
65
66
67

68
69
70
71
72
73
74
//
// localStorage.tm is the time (parsed as float) when we last
//  updated from the server.
//
"use strict";

// When a note selected and being viewed/edited


let cur_item = null;

// Last time value when updated from server
let server_tm = null;

// When we need to fake a timestamp to offer sequential, new
//  changes to our server when our own clock is borked.
let tm_off = 0.0;

// Number of milliseconds for menu transitions
const TSECS = 1000;




















// Try to pull in current store on startup
function startup() {
    if (localStorage.getItem("user") == null) {
	// Initial state
	localStorage.tm = "0.0";
	server_tm = 0.0;
	// They need to log in
	login.style.display = "block";
    } else {
	// Saved state
	server_tm = parseFloat(localStorage.tm);


	sync();


	to_menu();



    }
}

// Mint a new key for a new note
function new_key() {
    while (true) {
	let key = "note" +
................................................................................
    }
}

// Transition to displaying an item
function to_item() {
    mainmenu.style.display = "none";
    editor.style.display = "block";

}

// Transition back to main menu
function to_menu() {
    editor.style.display = "none";
    mainmenu.style.display = "block";

}

// They've chosen from our list of items
function item_click(key) {
    cur_item = JSON.parse(localStorage[key]);
    entryTitle.value = cur_item.title;
    entryTitle.readOnly = true;







>
>









|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>












>
>

>
>

>
>
>







 







>






>







12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
..
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
//
// localStorage.tm is the time (parsed as float) when we last
//  updated from the server.
//
"use strict";

// When a note selected and being viewed/edited
// (Note that a null value will be present while they're building
//  a new note.)
let cur_item = null;

// Last time value when updated from server
let server_tm = null;

// When we need to fake a timestamp to offer sequential, new
//  changes to our server when our own clock is borked.
let tm_off = 0.0;

// At main menu
let mainmen = false;

// Callback for once we have an active session.  The idea is to refresh
//  if they're still on the main page, have switched away, and somebody
//  has changed a note.
function vischange() {

    // Only when it comes back to foreground
    if (document.visibilityState != "visible") {
	return;
    }

    // They're working on a note
    if (!mainmen) {
	return;
    }

    // Fire a sync
    sync();
}

// Try to pull in current store on startup
function startup() {
    if (localStorage.getItem("user") == null) {
	// Initial state
	localStorage.tm = "0.0";
	server_tm = 0.0;
	// They need to log in
	login.style.display = "block";
    } else {
	// Saved state
	server_tm = parseFloat(localStorage.tm);

	// Try and get an update
	sync();

	// Display entries
	to_menu();

	// Hook to check again when we come back on screen
	document.onvisibilitychange = vischange;
    }
}

// Mint a new key for a new note
function new_key() {
    while (true) {
	let key = "note" +
................................................................................
    }
}

// Transition to displaying an item
function to_item() {
    mainmenu.style.display = "none";
    editor.style.display = "block";
    mainmen = false;
}

// Transition back to main menu
function to_menu() {
    editor.style.display = "none";
    mainmenu.style.display = "block";
    mainmen = true;
}

// They've chosen from our list of items
function item_click(key) {
    cur_item = JSON.parse(localStorage[key]);
    entryTitle.value = cur_item.title;
    entryTitle.readOnly = true;