JordanMcAlister
6 years agoQrew Captain
Copy Button Code Help
Hi,
I am making a copy button using one of Dan's pasties to copy text directly from a field because highlighting it and copying doesn't seem to keep any formatting. The field is a Rich text formula field and has a lot of html to edit font, background color, padding, etc. I can't seem to get my button to work properly, and I think it has to do with the API_DoQuery part because i have substituted just straight text into my navigator.clipboard.writeText(mytext) and it works fine but when its trying to get info from a field, it pastes nothing.
Can anyone help?
*****
The fid of the field I'm trying to copy from is 165 and is called "STB:Sketch Text"
The record id field has its name changed to [Pole ID#]
Here is my "copybutton.js" page code:
_______________________________________________________________________
(function() {
var dbidTable1 = "bmwnwyvin";
var apptoken = "myapptoken";
$.ajaxSetup({data: {apptoken: apptoken}});
var querystring = document.location.search;
if (/a=dr/i.test(querystring)) {
$("img[qbu=module]").closest("td").css("background-color", "#FFFFFF");
var audio = new Audio("http://dl.dropboxusercontent.com/s/7ubb14hilzkgnfk/slipkid.mp3");
$("#QBU_Clipboard").on("click", event => {
audio.play();
var rid = QBU_Clipboard.dataset.rid;
$.get(dbidTable1, {
act: "API_DoQuery",
query: '{3.EX.${rid}}',
clist: "165"
}).then(function(xml) {
var mytext = $("STB:Sketch Text", xml).text();
navigator.clipboard.writeText(mytext)
.then(() => {
$.jGrowl("Text Copied", {life: 5000, theme: 'jGrowl-green'});
});
});
});
}
})();
________________________________________________________________________
Here is my "STB:Copy Button" field code:
________________________________________________________________________
[iol] & "copybutton.js" & [/iol]
&
"<a id='QBU_Clipboard' class='Vibrant Success' " &
" data-rid='" & [Pole ID#] & "'" &
">Copy To Clipboard</a>"
________________________________________________________________________
I am making a copy button using one of Dan's pasties to copy text directly from a field because highlighting it and copying doesn't seem to keep any formatting. The field is a Rich text formula field and has a lot of html to edit font, background color, padding, etc. I can't seem to get my button to work properly, and I think it has to do with the API_DoQuery part because i have substituted just straight text into my navigator.clipboard.writeText(mytext) and it works fine but when its trying to get info from a field, it pastes nothing.
Can anyone help?
*****
The fid of the field I'm trying to copy from is 165 and is called "STB:Sketch Text"
The record id field has its name changed to [Pole ID#]
Here is my "copybutton.js" page code:
_______________________________________________________________________
(function() {
var dbidTable1 = "bmwnwyvin";
var apptoken = "myapptoken";
$.ajaxSetup({data: {apptoken: apptoken}});
var querystring = document.location.search;
if (/a=dr/i.test(querystring)) {
$("img[qbu=module]").closest("td").css("background-color", "#FFFFFF");
var audio = new Audio("http://dl.dropboxusercontent.com/s/7ubb14hilzkgnfk/slipkid.mp3");
$("#QBU_Clipboard").on("click", event => {
audio.play();
var rid = QBU_Clipboard.dataset.rid;
$.get(dbidTable1, {
act: "API_DoQuery",
query: '{3.EX.${rid}}',
clist: "165"
}).then(function(xml) {
var mytext = $("STB:Sketch Text", xml).text();
navigator.clipboard.writeText(mytext)
.then(() => {
$.jGrowl("Text Copied", {life: 5000, theme: 'jGrowl-green'});
});
});
});
}
})();
________________________________________________________________________
Here is my "STB:Copy Button" field code:
________________________________________________________________________
[iol] & "copybutton.js" & [/iol]
&
"<a id='QBU_Clipboard' class='Vibrant Success' " &
" data-rid='" & [Pole ID#] & "'" &
">Copy To Clipboard</a>"
________________________________________________________________________