maxtaco / oneshallpass

A little self-contained web-page for making secure Web passwords. Works offline.
https://oneshallpass.com
MIT License
190 stars 26 forks source link

iOS password selection #21

Open nwe44 opened 12 years ago

nwe44 commented 12 years ago

On iOS 5 ( tested on iPad and iPhone) it is currently impossible to select a password generated by oneshallpass.com

nwe44 commented 12 years ago

sorry, this is a duplicate of #15

My mistake.

maxtaco commented 12 years ago

I know, how do I fix this? Any help would be much appreciated.

On Tue, Aug 14, 2012 at 4:10 PM, Nicholas Evans notifications@github.comwrote:

On iOS 5 ( tested on iPad and iPhone) it is currently impossible to select a password generated by oneshallpass.com

— Reply to this email directly or view it on GitHubhttps://github.com/maxtaco/oneshallpass/issues/21.

nwe44 commented 12 years ago

Will have a look this eve.

maxtaco commented 12 years ago

Thanks Nick, any help would be greatly appreciated. It would be even better to have a way to "copy" to the clipboard but most browsers don't let you do that without a flash plugin or something horrible like that. I would be open to changing that DOM element to an input text field too. Obviously my HTML/JS/CSS is weak and needs serious work.

On Tue, Aug 14, 2012 at 4:13 PM, Nicholas Evans notifications@github.comwrote:

Will have a look this eve.

— Reply to this email directly or view it on GitHubhttps://github.com/maxtaco/oneshallpass/issues/21#issuecomment-7738594.

nwe44 commented 12 years ago

Copy to clipboard without resorting to flash is looking promising for browsers that can leverage "contentEditable". Unfortunately, that doesn't quite include iOS 5 or 6 (or below), who will notionally allow javascript to select text whose parent has "contentEditable" turned on, but won't give visual feedback as such, or copy to clipboard. Still, it would be an improvement, so I'll submit a separate pull request with that and try to make it degrade gracefully.

Lastly, apologies for polluting your issue queue with yet another line item, I couldn't figure out Github's interface for directly connecting a pull request to an existing issue.

maxtaco commented 12 years ago

Thanks so much for the contributions! No problem at all about those additional issues, I'll clean it up.

On Wed, Aug 15, 2012 at 12:18 PM, Nicholas Evans notifications@github.comwrote:

Copy to clipboard without resorting to flash is looking promising for browsers that can leverage "contentEditable". Unfortunately, that doesn't quite include iOS 5 or 6 (or below), who will notionally allow javascript to select text whose parent has "contentEditable" turned on, but won't give visual feedback as such, or copy to clipboard. Still, it would be an improvement, so I'll submit a separate pull request with that and try to make it degrade gracefully.

Lastly, apologies for polluting your issue queue with yet another line item, I couldn't figure out Github's interface for directly connecting a pull request to an existing issue.

— Reply to this email directly or view it on GitHubhttps://github.com/maxtaco/oneshallpass/issues/21#issuecomment-7760575.

nwe44 commented 12 years ago

A quick up date.

Looks like the select button can sort of be made to work in iOS 5, but currently needs to work differently for iOS 6.

So the following,

function fnSelect(obj) {
    fnDeSelect();
    var range;
    var text = obj.firstChild;
    if (browser.mobsafari) {
        obj.contentEditable = "true"; // hack to allow selection
        range = document.createRange();
        range.selectNode(text);
        window.getSelection().addRange(range);
        obj.contentEditable = "false"; // this line breaks the implementation in iOS 6 beta 2
    } else if (document.selection) {
        range = document.body.createTextRange();
        range.moveToElementText(text);
        range.select();
    } else if (window.getSelection) {
        range = document.createRange();
        range.selectNode(text);
        window.getSelection().addRange(range);
    } 
}

Will select the password in iOS 5, but not bring up the popover menu to copy it to clipboard. Also, while it has an implementation of the clipboardData API, it has no setDate method implementation (http://www.w3.org/TR/html5/dnd.html#dom-datatransfer-setdata). Which seems fairly conclusive to me.

iOS 6, currently in beta 4, meanwhile, will do all of the above, and add the popover to let you copy the text. It also raises the keyboard, which iOS 5 does not do. The moment one switches off the contentEditable attribute, everything goes away again. So the above code results in a flicker and nothing more. Who knows what the future will hold.

It may yet be possible to use contentEditable to use the clipboardData API in whatever browsers have setData enabled. The first stage here seems to be we should sniff for the existence of contentEditable, which the Modernizr guys imply may be tough (https://github.com/Modernizr/Modernizr/wiki/Undetectables).

The search continues...

maxtaco commented 12 years ago

Thanks so much for this update!

Do you think life would be easier if the DOM element was a text input field rather than or

? github.com seems to use a text input field....

maxtaco commented 12 years ago

This might be fixed in 6e09d8a (now live on oneshallpass.com) but we need a confirmation from an iphone or ipad.

nwe44 commented 12 years ago

Sorry, no joy on my iPhone; can't select or copy.

Sent from my iPhone

On Aug 16, 2012, at 19:00, Maxwell Krohn notifications@github.com wrote:

This might be fixed in 6e09d8a (now live on oneshallpass.com) but we need a confirmation from an iphone or ipad.

— Reply to this email directly or view it on GitHub.

maxtaco commented 12 years ago

Hmf, ok.

On Thu, Aug 16, 2012 at 9:17 PM, Nicholas Evans notifications@github.comwrote:

Sorry, no joy on my iPhone; can't select or copy.

Sent from my iPhone

On Aug 16, 2012, at 19:00, Maxwell Krohn notifications@github.com wrote:

This might be fixed in 6e09d8a (now live on oneshallpass.com) but we need a confirmation from an iphone or ipad.

— Reply to this email directly or view it on GitHub.

— Reply to this email directly or view it on GitHubhttps://github.com/maxtaco/oneshallpass/issues/21#issuecomment-7804634.

rowan-mcalpin commented 9 months ago

Perhaps I'm 12 years late to the party, but copy to clipboard buttons have become highly supported across all mobile (and desktop) browsers.

Relevant w3schools article: https://www.w3schools.com/howto/howto_js_copy_clipboard.asp

I don't know if you are still running/managing this website, but I could probably make a PR in the next few weeks to add this feature, if you'd like.