notepad

Check-in [f56588fac2]
Login

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

Overview
Comment:Bringup; insert first note
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | master | trunk
Files: files | file ages | folders
SHA3-256:f56588fac27b9dfcb2a099b8ba4bf5eda49d007f24435a661c2a207fb3ef0d13
User & Date: vandys 2018-10-12 00:47:27
Context
2018-10-12
02:26
Tidy display. Python time.time() is 1000x off from JS. Map. Get new/edit right. Honor deleted coming from DB. check-in: 936b046827 user: vandys tags: master, trunk
00:47
Bringup; insert first note check-in: f56588fac2 user: vandys tags: master, trunk
2018-10-11
23:56
Bringup; we have login and initial (empty) note list check-in: 5cdaff3a2c user: vandys tags: master, trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to css/main.css.

1
2
3
4
5
6
7








body>div {
    position: absolute;
    height: 100%;
    width: 100%;
    transition: all 2.0s ease;
    display: none;
}















>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
body>div {
    position: absolute;
    height: 100%;
    width: 100%;
    transition: all 2.0s ease;
    display: none;
}

#entryTitle {
    width: 50%;
}
#entryContent {
    width: 100%;
    height: 200px;
}

Changes to index.html.

22
23
24
25
26
27
28
29


30
31
32
33
34
35
36
37
38
39
40
41
42
43
    </div>

    <div id="entries">
    </div>
</div>

<div id="editor">
    <div id="entryTitle"></div>


    <div>
	<span onclick="edit_keep()">Save</span>
	<span onclick="edit_cancel()">Cancel</span>
	<span onclick="edit_delete()">Delete This</span>
    </div>
    <textarea name="entry-content" id="entryContent"
     placeholder="Content"></textarea>
</div>

<div id="login">
    <input type="text" id="user" placeholder="User name">
    <br>
    <input type="password" id="password" placeholder="password">
    <br>







|
>
>

|
|
|

<
<







22
23
24
25
26
27
28
29
30
31
32
33
34
35
36


37
38
39
40
41
42
43
    </div>

    <div id="entries">
    </div>
</div>

<div id="editor">
    <input type="text" id="entryTitle" placeholder="Note Name">
    <textarea name="entry-content" id="entryContent"
     placeholder="Content"></textarea>
    <div>
	<button onclick="edit_keep()">Save</button>
	<button onclick="edit_cancel()">Cancel</button>
	<button onclick="edit_delete()">Delete This</button>
    </div>


</div>

<div id="login">
    <input type="text" id="user" placeholder="User name">
    <br>
    <input type="password" id="password" placeholder="password">
    <br>

Changes to js/main.js.

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
79
80
81
82
83
...
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
...
177
178
179
180
181
182
183
184

185



186
187
188
189
190
191
192
193
194
...
263
264
265
266
267
268
269








270
271
272
273
274
275
276
}

// Transition to displaying an item
// (Switching to "display: none" side steps a bunch of grotty
//  details on z-index touch item priority.)
function to_item() {
    mainmenu.style.opacity = 0.0;
    setTimeout(() => {mainmenu.style.display = "none";}, 1000);
    editor.style.display = "block";
    editor.style.opacity = 1.0;
}

// Transition back to main menu
function to_menu() {
    editor.style.opacity = 0.0;
    setTimeout(() => {editor.style.display = "none";}, 1000);
    mainmenu.style.display = "block";
    mainmenu.style.opacity = 1.0;
}

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

    entryContent.value = cur_item.content;
    to_item();
}

// Sort notes by their alphabetic title ordering
// (Maybe could order by tm/recentness instead?)
function cmpTitles(ent1, ent2) {
................................................................................
	entries.appendChild(e);
    });
}

// Update timestamp on our storage, because we've changed something
// Return the updated value as a float
function timestamp() {
    let tm = Date().getTime();
    if (tm <= (server_tm + tm_off)) {
	// Synthesize a time offset when our own clock doesn't
	//  line up (for whatever reason) with the server's
	tm_off += 0.1;
	tm = server_tm + tm_off;
    }
    return tm;
................................................................................

    // Back to main menu
    to_menu();
}

// Update content and timestamp for this note
function edit_keep() {
    cur_item.content = entrycontent.value;

    cur_item.tm = timestamp();



    sync();
    udpate_entries();
    to_menu();
}

// Create a delta of changes, so we only have to submit back things
//  which have changed WRT our last update from the server
function save_notes() {
    const upd = {};
................................................................................
function tool_logout() {
    if (!confirm("Clear notes session?")) {
	return;
    }
    localStorage.clear();
    location.reload();
}









// Initial setup, try to log in
function try_login() {
    if (!user.value) {
	alert("Please enter your user name");
	return;
    }







|







|








>







 







|







 







|
>
|
>
>
>

|







 







>
>
>
>
>
>
>
>







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
79
80
81
82
83
84
...
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
...
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
...
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
}

// Transition to displaying an item
// (Switching to "display: none" side steps a bunch of grotty
//  details on z-index touch item priority.)
function to_item() {
    mainmenu.style.opacity = 0.0;
    setTimeout(() => {mainmenu.style.display = "none";}, 2000);
    editor.style.display = "block";
    editor.style.opacity = 1.0;
}

// Transition back to main menu
function to_menu() {
    editor.style.opacity = 0.0;
    setTimeout(() => {editor.style.display = "none";}, 2000);
    mainmenu.style.display = "block";
    mainmenu.style.opacity = 1.0;
}

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

// Sort notes by their alphabetic title ordering
// (Maybe could order by tm/recentness instead?)
function cmpTitles(ent1, ent2) {
................................................................................
	entries.appendChild(e);
    });
}

// Update timestamp on our storage, because we've changed something
// Return the updated value as a float
function timestamp() {
    let tm = (new Date()).getTime();
    if (tm <= (server_tm + tm_off)) {
	// Synthesize a time offset when our own clock doesn't
	//  line up (for whatever reason) with the server's
	tm_off += 0.1;
	tm = server_tm + tm_off;
    }
    return tm;
................................................................................

    // Back to main menu
    to_menu();
}

// Update content and timestamp for this note
function edit_keep() {
    const new_item = {};
    new_item.key = new_key();
    new_item.tm = timestamp();
    new_item.title = entryTitle.value;
    new_item.content = entryContent.value;
    localStorage[new_item.key] = JSON.stringify(new_item);
    sync();
    update_entries();
    to_menu();
}

// Create a delta of changes, so we only have to submit back things
//  which have changed WRT our last update from the server
function save_notes() {
    const upd = {};
................................................................................
function tool_logout() {
    if (!confirm("Clear notes session?")) {
	return;
    }
    localStorage.clear();
    location.reload();
}

// Create a new entry
function tool_new() {
    entryTitle.textContent = "";
    entryTitle.readOnly = false;
    entryContent.value = "";
    to_item();
}

// Initial setup, try to log in
function try_login() {
    if (!user.value) {
	alert("Please enter your user name");
	return;
    }

Changes to sync.py.

68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
	continue

    # Nothing newer, so just register note
    # (This includes deleted notes, which are like others with
    #  key/timestamp, but with title/content being null.)
    oent = onotes.get(key)
    if oent is None:
	c.execute("insert into notes values=(?,?,?,?)",
	    (key, note["tm"], note["title"], note["content"]))
	changes = True
	continue

    # We both have updates, but server already has newest.
    # Include this value in the response update back.
    if oent["tm"] > note["tm"]:
	resp[key] = oent







|
|







68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
	continue

    # Nothing newer, so just register note
    # (This includes deleted notes, which are like others with
    #  key/timestamp, but with title/content being null.)
    oent = onotes.get(key)
    if oent is None:
	c.execute("insert into notes values (?,?,?,?,?)",
	    (key, user, note["tm"], note["title"], note["content"]))
	changes = True
	continue

    # We both have updates, but server already has newest.
    # Include this value in the response update back.
    if oent["tm"] > note["tm"]:
	resp[key] = oent