From 98a436772238db24f545a6e8a72e9b78699773f9 Mon Sep 17 00:00:00 2001 From: Lenzh Date: Thu, 8 Jun 2023 21:12:45 -0400 Subject: [PATCH] Photo url copies to clipboard when taking a picture now (#21) * Fixed cam pos and minimap issue fixed an issue with view of camera to front of the cam and fixed issue with minimap displaying at random * Copy To Clipboard * Copy To Clipboard --- client/cl_main.lua | 1 + client/nui/app.js | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/client/cl_main.lua b/client/cl_main.lua index 79e1353..9f0f9a5 100644 --- a/client/cl_main.lua +++ b/client/cl_main.lua @@ -185,6 +185,7 @@ function CameraLoop() if cameraprop then DeleteEntity(cameraprop) end ClearPedTasks(lPed) TriggerServerEvent("ps-camera:CreatePhoto", json.encode(image.attachments[1].proxy_url)) + SendNUIMessage({action = "SavePic", pic = json.encode(image.attachments[1].proxy_url)}) SendNUIMessage({action = "hideOverlay"}) end) end diff --git a/client/nui/app.js b/client/nui/app.js index bdfed0b..d499ab9 100644 --- a/client/nui/app.js +++ b/client/nui/app.js @@ -31,7 +31,6 @@ function open(image, location) { } } - function close() { if (displayPicture) { $('.picture-container').addClass('hide'); @@ -42,6 +41,15 @@ function close() { } } +const copyToClipboard = (str) => { + const el = document.createElement("textarea"); + el.value = str.replace(/[" ]/g, ""); + document.body.appendChild(el); + el.select(); + document.execCommand("copy"); + document.body.removeChild(el); +}; + $(document).ready(function () { window.addEventListener("message", function (event) { if (event.data.action === "Open") { @@ -55,6 +63,8 @@ $(document).ready(function () { document.getElementById("camera-overlay").classList.add("hide"); } else if (event.data.action === "openPhoto") { open(event.data.image, event.data.location); + } else if (event.data.action === "SavePic") { + copyToClipboard(event.data.pic); } }); @@ -68,4 +78,4 @@ $(document).ready(function () { break; } }; -}); \ No newline at end of file +});