Log in

View Full Version : Edit online: problem with Apple / Safari



molendijk
09-13-2014, 08:57 PM
Hello everyone,
I made a very elementary online editor. Just raw text. It seems to work with Windows, but people have told me that there are problems with Apple/Mac.
If you are willing to help me in solving the problem, please follow this link (http://wierdenland.nl/editonline_simple/editonline.html) to a demo.
Thanks, Arie.

jscheuer1
09-14-2014, 05:17 AM
Works fine in Safari Win 7. I would suspect that in the offending OS/browser combo that this:


$('#content').get(0).onkeyup

would be null or equivalent, or possibly 'native code'. Anything but it's assigned value*. If such is the case, you might have better luck assigning the event via jQuery, and/or utilizing other similar events. Change is one that comes to mind.


*onkeyup assigned value according to the console in Safari Win, Chrome, and Opera:

function onkeyup(event) {
update();frames.ifr.document.body.innerHTML=document.getElementById('content').innerHTML;update()
}

One other possibility that springs to mind is that - if you are not testing this yourself, rather relying upon reports from others, that they might have used cut and paste with the mouse or other pointing device, finger, etc. If so, onkeyup would never have fired.

molendijk
09-14-2014, 11:58 AM
Thanks John (and Beverley). I'll try your suggestions.

jscheuer1
09-14-2014, 05:00 PM
If there is an onedit/oncontentedit event - something that fires during or once editing is complete, that might be good. There's always the possibility that the event(s) and/or the editable property you are relying upon might be unsupported in the problematic environment.

molendijk
09-14-2014, 07:41 PM
I already tried that
The problem seems to be some 'lazyness' in the Apple/Mac combo.
The simple editor for which I gave you the link actually is a simplified version of a more complex editor (in Dutch) that can be found here (http://www.wierdenland.nl/vrijwilligers/index.html?uitproberen.html). When people edit the page (in the Apple/Mac-environment) and then click on 'Opslaan' (=save: top right, red button), nothing seems to have changed. But when they close the browser and then reopen it, the changes ARE THERE. Mystery!
EDIT: THIS (http://www.slideshare.net/Rozy65/mac-os-x-issues-related-to-wysiwyg-editors) MAY EXPLAIN A LOT.

jscheuer1
09-14-2014, 09:13 PM
A little like I said. But rather than a complete lack of support, incomplete, spotty support.

Deadweight
09-15-2014, 08:57 PM
May i ask to help you with whatever you are doing?

molendijk
09-15-2014, 09:31 PM
Sure, thanks for offering me your assistance.
At the moment, I'm developing a (Dutch) editor that saves the edits (made online) for all browsers. I'm using the HTML5 contenteditable feature. One of the files I made for a Dutch website is this one (http://www.wierdenland.nl/vrijwilligers/index.html?uitproberen.html) (people are allowed to change there whatever they want, as an exercise). The button 'Opslaan' (top right) is the save button.
Now, what some users told me is that everything works well with any OS/browser combo, except with Apple/Mac/Safari. So I decided to ask in this thread if DD-users can confirm this. To make things simple enough, I presented an elementary version of my editor in #1.
That's it. Thanks again for offering assistance.

Deadweight
09-15-2014, 11:29 PM
What happens when two people edit the file at the same time and save it at the same time?

molendijk
09-15-2014, 11:54 PM
That may be a problem. It will not likely occur in my case, because edit permissions have been regulated in the real situation.
But you're right in a general way. Avoiding conflicting edit occurrences should be a concern.

jscheuer1
09-16-2014, 03:14 AM
There is a way to lock a file while accessing it in PHP. If two people did try to edit at the same time, one would simply fail.

molendijk
09-16-2014, 10:50 AM
Thanks John. Do you know how to do that? If not, I'll google around.

jscheuer1
09-16-2014, 04:12 PM
In PHP 5+ if using the the file_put_contents function (combines file handle, file open and write from previous versions) to write to the file, you can use the LOCK_EX flag to prevent any other attempts at writing to the file during the operation. See:

http://php.net/manual/en/function.file-put-contents.php

Just opening and writing to a file is more complex in PHP 4, but I believe a similar thing can be done during the write phase.

molendijk
09-16-2014, 04:54 PM
Thank you so much, John! I'm indeed using file_put_contents.