Git Product home page Git Product logo

Comments (17)

teorth avatar teorth commented on August 23, 2024

Oops, I had not foreseen this consequence of migrating the file. Strangely, when I go to the old URL on chrome and it gets redirected, it seems that my progress has been saved (not sure how that works, some quirk of local storage?).

from qed.

teorth avatar teorth commented on August 23, 2024

If I read the discussion at https://stackoverflow.com/questions/12489999/response-redirect-kills-local-storage correctly, it seems that if one lingers on the original page long enough for local storage to load, then when one is redirected, all the storage (i.e., progress on the text) is saved. It's clunky, but perhaps that is enough of a workaround for now...

from qed.

TTimo avatar TTimo commented on August 23, 2024

from qed.

cjerdonek avatar cjerdonek commented on August 23, 2024

@TTimo can you try it again now, waiting the full amount of time for it to redirect? The "redirect" part of the QED.html file wasn't present for the past couple hours (by mistake I believe).

from qed.

TTimo avatar TTimo commented on August 23, 2024

Tried again .. still the same. I load http://www.math.ucla.edu/~tao/QED/QED.html, give it plenty of time, then click on the link at the top (https://teorth.github.io/QED) and end up at the new page but with none of my progress.

from qed.

cjerdonek avatar cjerdonek commented on August 23, 2024

Oh, I thought you were referring to the automatic redirect change last night from--
http://teorth.github.io/QED/QED.html to
http://teorth.github.io/QED/
I did confirm that works on Mac with Firefox.

For the old ucla.edu page, maybe something can be done on that page to permit transferring the data -- I'm not sure.

from qed.

teorth avatar teorth commented on August 23, 2024

I've tried replacing the http://www.math.ucla.edu/~tao/QED/QED.html page with a copy of the redirect page at http://teorth.github.io/QED/QED.html . Strangely, it does not seem that the local storage copied over this time (but perhaps this is because I already have some local storage for the new page?).

from qed.

cjerdonek avatar cjerdonek commented on August 23, 2024

Someone could try "resetting" on the target page to clear out their local storage there, but I'm guessing local storage doesn't propagate cross-domain by default for security reasons. There is probably a way to do it, but I'm guessing not straightforward.

from qed.

teorth avatar teorth commented on August 23, 2024

Yeah, I just tried resetting and it does indeed seem that localstorage doesn't propagate from one domain to another. There may be a way to export the localstorage keys to some file that one can then import to another page, perhaps.

from qed.

teorth avatar teorth commented on August 23, 2024

OK, after using the answer at this page https://stackoverflow.com/questions/13335967/export-data-in-localstorage-for-later-re-import I found a way for a user to move over the data manually, though it is a bit tricky. I put the instructions on the old page http://math.ucla.edu/~tao/QED/QED.html - they worked for me, hopefully they work for you also!

from qed.

TTimo avatar TTimo commented on August 23, 2024

The procedure worked! Thanks!

from qed.

lllusion3418 avatar lllusion3418 commented on August 23, 2024

To make it a bit more convenient/easy to use, you could do something like this:

function import_export() {
  let input = window.prompt('Import/Export', JSON.stringify(window.localStorage));
  if (input !== null) {
    new_data = JSON.parse(input);
    for (i in new_data) { // for in loop should'nt be a problem in this case
      window.localStorage.setItem(i, new_data[i]);
    }
  }
}
import_export();

You could add this as a button to both the old and the new page:

<button onclick="import_export();">import/export</button>

To export, you would click the button, copy the text in the text field (ctrl-a), and press cancel (or ok, doesn't matter, really).

To import, you would click the button, paste the text (possibly replace the old text), press ok, and refresh.

e: forgot to mention refreshing

from qed.

teorth avatar teorth commented on August 23, 2024

I've implemented this suggestion now. Actually it is also a useful tool for debugging (I've needed to reset the text a few times and it was a pain to restore all the previous progress; now I can just save the state to an external text file and restore when needed.)

from qed.

teorth avatar teorth commented on August 23, 2024

Unfortunately I found an annoying issue with the button for editing localstorage: it seems that (in Chrome at least) the window.prompt string input can only be up to about 2000 characters in length before it starts truncating the string with ellipses, making it useless for copy/paste purposes once the local storage gets decently large. Not yet sure what the best fix is (simplest would be to have direct access to the clipboard, but not sure if the javascript sandbox actually has permission to do this).

from qed.

cjerdonek avatar cjerdonek commented on August 23, 2024

You could perhaps also do something like use a text area to transfer the text to and from instead of a prompt box.

from qed.

lllusion3418 avatar lllusion3418 commented on August 23, 2024

I didn't know Chrome had a limit. Firefox doesn't appear to and MDN doesn't specify any limit.

Unless <input type="text"> also has a maximum length (I tested a length of ~4000 with Chromium 68), this works as a PoC (don't know about bootstrap, have never used it).

from qed.

teorth avatar teorth commented on August 23, 2024

Thanks, I think I managed to implement this code successfully.

from qed.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.