-
Notifications
You must be signed in to change notification settings - Fork 290
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Click on the phone number and Serial Number to add to clipboard in settings app #394
Click on the phone number and Serial Number to add to clipboard in settings app #394
Conversation
Looks solid. This should be added because often, people want to send or use their in-game phone number outside of fivem or are unaware of the radial menu option. Ill test it in a few |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont really think we should be importing yet another library just for something which can be done in 2-3 lines of standard JS, aka setting the clipboard.
QB-Phone is already bloated enough as it is...
Imo copy to clipboard should be part of core |
Apart of qb-core? Yeah, perhaps, would be nice when trying to set the clipboard from lua. Wouldnt really be useable/ideal in this situation even if it was in qb-core though. Much better to just write those 2-3 lines of JS in qb-phone in this situation. |
Absolutely 👍 didn't spend too much time with it but I would've thought i'd tried it without a library and thought it didn't work for some reason so probably did that naturally I thought I could do it with native js but not looked at this really since posting was just a quick implementation that worked |
I might pull it down and have a look again and see why I didn't use the clipboard I'm sure I remember trying it, but someone could always pull it down remove the package add the 2-3 lines of js and that I maybe missed and create the pr again and comment on this to say it's outdated because of pr # I don't have or use qb-phone and am not a "qb-core developer" obviously this isn't top of list of things for me todo 😀 but I appreciate the comments and the response @Z3rio and any constructive criticism is always appreciated |
Yeah, well, if qb-core actually cared about PRs and merged them, I'd 110% help you fix up this PR. |
I completely get that buddy I also like to not have a load of outstanding pr's, so I keep them few and fairly minimal my argument for this way could be yeah it adds 25 lines and a libary but it is a very minimal libary and makes re-use of the copy function I implemented to be very easily re-used elsewhere, yes it may able to be done more minimally, but I honestly like this implementation,😂🤣 and I'm not flaming your comments at all @Z3rio they are obviously valid |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add this to the settings.js, line 38
$(document).on(
"click",
"#phoneNumberSelect, #serialNumberSelect",
function (e) {
// Get the title of the clicked element
var title = "";
if ($(this).attr("id") == "phoneNumberSelect") {
title = "Phone Number";
} else {
title = "Serial Number";
}
// get the result id of myPhoneNumber or mySerialNumber
var textToCopy =
$(this).attr("id") == "phoneNumberSelect"
? $("#myPhoneNumber").text()
: $("#mySerialNumber").text();
// Copying the text to clipboard using Clipboard.js
var clipboard = new ClipboardJS(this, {
text: function () {
QB.Phone.Notifications.Add("fas fa-phone", "Copied " + title + "!", textToCopy);
return textToCopy;
},
});
}
);
and delete the line on 1135
<script src="./js/copyclipboard.js"></script>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add this to the ./settings.js
instead
$(document).on(
"click",
"#phoneNumberSelect, #serialNumberSelect",
function (e) {
// Get the title of the clicked element
var title = "";
if ($(this).attr("id") == "phoneNumberSelect") {
title = "Phone Number";
} else {
title = "Serial Number";
}
// get the result id of myPhoneNumber or mySerialNumber
var textToCopy =
$(this).attr("id") == "phoneNumberSelect"
? $("#myPhoneNumber").text()
: $("#mySerialNumber").text();
// Copying the text to clipboard using Clipboard.js
var clipboard = new ClipboardJS(this, {
text: function () {
QB.Phone.Notifications.Add("fas fa-phone", "Copied " + title + "!", textToCopy);
return textToCopy;
},
});
}
);
…opying clipboard as per christians suggestions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested, LGTM
Description
Phone Number and Serial Number copied to clipboard when clicked in settings page
![image](https://private-user-images.githubusercontent.com/25391741/327965731-b1e2f56f-8164-48ca-b42e-9bf2565d9b55.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk0MjIwNDIsIm5iZiI6MTczOTQyMTc0MiwicGF0aCI6Ii8yNTM5MTc0MS8zMjc5NjU3MzEtYjFlMmY1NmYtODE2NC00OGNhLWI0MmUtOWJmMjU2NWQ5YjU1LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTMlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjEzVDA0NDIyMlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTgxY2NhMzVkOTkxMjAyN2Q0NThlNjdlNGQ3NTY3NDg2YmI5YzUzYmJjZDMwNzc1YWE4YjMzZjYxZDBhNzQ5MDMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.qThRTtdTL5ADwMrHvJm6AMrmMKHia4bE37PS-w2e4Ms)
Checklist