oneshallpass icon indicating copy to clipboard operation
oneshallpass copied to clipboard

iOS password selection

Open nwe44 opened this issue 13 years ago • 12 comments

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

nwe44 avatar Aug 14 '12 20:08 nwe44

sorry, this is a duplicate of #15

My mistake.

nwe44 avatar Aug 14 '12 20:08 nwe44

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

On Tue, Aug 14, 2012 at 4:10 PM, Nicholas Evans [email protected]:

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.

maxtaco avatar Aug 14 '12 20:08 maxtaco

Will have a look this eve.

nwe44 avatar Aug 14 '12 20:08 nwe44

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 [email protected]:

Will have a look this eve.

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

maxtaco avatar Aug 14 '12 20:08 maxtaco

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.

nwe44 avatar Aug 15 '12 16:08 nwe44

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 [email protected]:

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.

maxtaco avatar Aug 15 '12 16:08 maxtaco

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...

nwe44 avatar Aug 15 '12 23:08 nwe44

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 avatar Aug 16 '12 22:08 maxtaco

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

maxtaco avatar Aug 16 '12 23:08 maxtaco

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

Sent from my iPhone

On Aug 16, 2012, at 19:00, Maxwell Krohn [email protected] 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.

nwe44 avatar Aug 17 '12 01:08 nwe44

Hmf, ok.

On Thu, Aug 16, 2012 at 9:17 PM, Nicholas Evans [email protected]:

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

Sent from my iPhone

On Aug 16, 2012, at 19:00, Maxwell Krohn [email protected] 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.

maxtaco avatar Aug 17 '12 03:08 maxtaco

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.

rowan-mcalpin avatar Jan 22 '24 06:01 rowan-mcalpin