php - Save changes in contenteditable with timestamp -


i have <div contenteditable="true" /> user can write in pretty unlimited in length.
data in div saved on change timestamp in mysql database.

now goal have little note on left tells user when each part of document has been created (resolution should in days).

now, question is: how can save information (what part has changed when) best?

i considered following options far both seem improvable:

  1. every time user visits site @ end of document insert flag (e.g. emtpy span class , data attribute stores start of editing). flag saved database when save script called. option make easy show date on side - put them on same height empty span , span tells me date. downsides are: user might accidently delete timestamp span , if user doesn't close window long time no new timespan spans inserted (this avoid inserting new timestamp spans every x minutes deleting part more relevant)
  2. trying string diff comparision each time data passed saving script , save diff timestamp. when page loaded put parts in right order , in javascript put date notes in right place. sounds lot of overhead me though + when older parts changed 2 parts become one, etc. in options sounds complicated.

any input / ideas / suggestions highly appreciated!

what trying implement feature called "annotate" or "blame" in source code control world (though want date of update rather date+author or author).

to properly, need way make diffs (php-diff might job) , obtain versions of text. there several strategy:

  • store latest version , keep deltas (such unified diffs, preference)

  • store versions , compute deltas on fly

once have current version , list of deltas (you can shorten list if more few dozen delta , let user ask more if important). compose deltas together, annotation phase happens can part remembering version comes each line. composing pretty simple in fact (start latest, lines added in patch leading latest, other need explained, start again next patch until reach ancient patch want treat, remaining lines version or earliest flag saying 'at or before ' can used).

google has diff library javascript hard work on user machine. have patch part in library well. did not find annotate/blame library.


Comments

Popular posts from this blog

ios - iPhone/iPad different view orientations in different views , and apple approval process -

php - HTTP_REFERER woes: How can I allow access to a specific page, only when a visitor has visited another specific page beforehand? -

java Extracting Zip file -