notepad

Check-in [9e91926a05]
Login

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

Overview
Comment:Get delete and edit-in-place working
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | master | trunk
Files: files | file ages | folders
SHA3-256:9e91926a0548f2b2d7ee5a1fc30a8cb2259de9f9dd3f398b2c8a7382572179f5
User & Date: vandys 2018-10-12 02:48:21
Context
2018-10-12
13:01
Argh, need to provide the key. check-in: df124d1636 user: vandys tags: master, trunk
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
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to js/main.js.

144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
    }
    return tm;
}

// The current item should Go Away
function edit_delete() {
    // Defend against fat finger
    if (!confirm("Delete " + entryTitle.textContent) + "?") {
	return;
    }

    // Storage gone, replace entry with time of deletion and null
    //  title (as a way to flag a deleted entry)
    const tm = timestamp();
    const resp = {"key": cur_item.key,
	"tm": tm, "title": null, "content": null};
    localstorage[cur_item.key] = JSON.stringify(resp);
    cur_item = null;

    // Maybe get word to the server
    sync();

    // Update item list
    update_entries();







|








|







144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
    }
    return tm;
}

// The current item should Go Away
function edit_delete() {
    // Defend against fat finger
    if (!confirm("Delete " + entryTitle.textContent + "?")) {
	return;
    }

    // Storage gone, replace entry with time of deletion and null
    //  title (as a way to flag a deleted entry)
    const tm = timestamp();
    const resp = {"key": cur_item.key,
	"tm": tm, "title": null, "content": null};
    localStorage[cur_item.key] = JSON.stringify(resp);
    cur_item = null;

    // Maybe get word to the server
    sync();

    // Update item list
    update_entries();

Changes to sync.py.

68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
	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"]:







|







68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
	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 or replace 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"]: