Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Tidy display. Python time.time() is 1000x off from JS. Map. Get new/edit right. Honor deleted coming from DB. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | master | trunk |
Files: | files | file ages | folders |
SHA3-256: |
936b046827356662c3384f08cbfae406 |
User & Date: | vandys 2018-10-12 02:26:32 |
Context
2018-10-12
| ||
02:48 | Get delete and edit-in-place working check-in: 9e91926a05 user: vandys tags: master, trunk | |
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 | |
Changes
Changes to css/main.css.
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;
}
|
| > > > > |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
body>div { position: absolute; height: 100%; width: 100%; transition: all 1.0s ease; display: none; } #entryTitle { width: 50%; } #entryContent { width: 100%; height: 200px; } #entries>button { background-color: pink; border-radius: 25px; } |
Changes to js/main.js.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 .. 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 ... 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 ... 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 ... 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 |
// 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; // 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; ................................................................................ } // 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 ................................................................................ // Order by title ents.sort(cmpTitles); // Populate our list of notes ents.forEach( ent => { // Clickable span w. text let e = document.createElement("span"); e.textContent = ent.title; e.onclick = () => { item_click(ent.key); }; entries.appendChild(e); }); } // Update timestamp on our storage, because we've changed something ................................................................................ // 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 ................................................................................ } 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() { |
> > > | | | | > > | | > | | | | > | |
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 .. 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 85 ... 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 ... 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 ... 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 |
// 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; ................................................................................ } // 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";}, TSECS); 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";}, TSECS); 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 ................................................................................ // Order by title ents.sort(cmpTitles); // Populate our list of notes ents.forEach( ent => { // Clickable span w. text let e = document.createElement("button"); e.textContent = ent.title; e.onclick = () => { item_click(ent.key); }; entries.appendChild(e); }); } // Update timestamp on our storage, because we've changed something ................................................................................ // Back to main menu to_menu(); } // Update content and timestamp for this note function edit_keep() { if (cur_item == null) { // New item, not replacing contents of an existing one cur_item = {}; cur_item.key = new_key(); } cur_item.tm = timestamp(); cur_item.title = entryTitle.value; cur_item.content = entryContent.value; localStorage[cur_item.key] = JSON.stringify(cur_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 ................................................................................ } localStorage.clear(); location.reload(); } // Create a new entry function tool_new() { cur_item = null; entryTitle.value = ""; entryTitle.readOnly = false; entryContent.value = ""; to_item(); } // Initial setup, try to log in function try_login() { |
Changes to sync.py.
102 103 104 105 106 107 108 109 110 111 112 |
# Commit DB changes if changes: conn.commit() conn.close() # Give them an update including time resp["tm"] = time.time() w("Status: 200 OK\n\n%s" % (json.dumps(resp),)) sys.exit(0) |
| |
102 103 104 105 106 107 108 109 110 111 112 |
# Commit DB changes
if changes:
conn.commit()
conn.close()
# Give them an update including time
resp["tm"] = time.time()*1000
w("Status: 200 OK\n\n%s" % (json.dumps(resp),))
sys.exit(0)
|