|
I have some difficulties with a multiple select (ID:VALUE).
My Goal is to make a multiselect pulldown (like gender-sample) with the difference that i want to see only the text not the value's (value's are my Database ID's).
First off all I am pretty new with the tabulator library and still learning
Now I wrote some code witch works fine when you place only one id in a dataset-row, with multiply id's the view looks good but when you open this select for the firsttime ID's are placed as text in cell and there are no options selected in the pulldown. When you select some everything works like I want.
I'll think i am missing some intitalize code? Or do I need a customeditor too?
This is my code:
{
title: "City",
field: "citycode",
editor: "select",
editorParams:
{
multiselect:true,
values: city
},
cellClick:function(e, cell)
{
},
formatter: function(cell, formatterParams, onRendered)
{
var row = cell.getRow();
var rowIndex = row.getIndex();
sel = document.createElement('select');
sel.style.width = '100%';
sel.style.color = 'lime';
sel.style.height = '40px';
sel.style.position = "relative";
sel.style.border = 'none';
sel.style.background = 'inherit';
var cellContent = '';
if (cell.getValue() !== undefined) {
var cellStr = cell.getValue().toString();
var cityArr = cellStr.split(",");
var i;
for (i = 0; i < cityArr.length; i++) {
if (i > 0) cellContent += ',';
cellContent += city[cityArr[i]];
}
}
sel.innerHTML = '' + cellContent + ''; // Show the text in UI instead of Value.
var mess = document.getElementById("message"); //refer to the div tag
mess.innerHTML = cell.getValue(); //set text in the div tag
return sel;
}
},
|
|
|
|
|
I created a web API made with node express and MSSQL database. When I request to the API at first time, it's response time is about 2000ms. But after that, it works less then 200ms. The problem only happens when I first time call the API, or after idle for minutes.
I tried to access from multi devices. The problem seems happens on every 'first time' request of each device.
|
|
|
|
|
I need some help!
type: 'POST',
url: $("#relpath").val() + 'sendmailcvalidation.php',
data: $("#sendmail").serialize(),
success: function(data) {
data=data.trim();
if(data == "false") {
alert("Erreur lors de l'envoi du message");
mailsendstatus = false;
$("#cvalidationlabel").children(".err").fadeIn('slow');
}
else if(data == "badcapcha"){...}
|
|
|
|
|
You've forgotten to ask a question.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hello,
I am using a JS sniplet code from the web that is 8yr old or so and it is now giving me a console error in FF dev tools. DOMException: Permission denied to access property "frameElement" on cross-origin object...
I am using this code to inject a css style sheet into twitter so it can be styled on my website here.
Fantasy Football: Waterboys[^]
The code origin is found here.
GitHub - kevinburke/customize-twitter-1.1: Add your own custom CSS to modify the Twitter Embeddable Widget[^]
I dont have much expertise in JS and was trying to see if this error is something i will have to live with or the JS file can tweaked with newer code to work around this error and display properly with the css injection?
Of course I am always looking for a better mouse trap to achieve this goal if things have changed with newer coding etc...
MY CODE
<table id="nfltweets" class="report"><caption><span>NFL Tweets</span></caption><tr><td>
<!-- TWITTER -->
<script src="//dagrafixdesigns.com/scripts/twitter.js" type="text/javascript">
</script>
<script>
var options = {
"url": "//dagrafixdesigns.com/Images/2008/DA_2019/zSticks_15387/WB_Twitter.css"
};
CustomizeTwitterWidget(options);
</script>
<a class="twitter-timeline"
data-chrome="noheader noborders transparent nofooter noscrollbar"
data-link-color="#117dff"
width="100%" height="600"
data-theme="dark"
data-dnt="true"
data-widget-id="344811004590424064"
href="//twitter.com/DA_Sticks/lists/dagrafix?ref_src=twsrc%5Etfw"></a>
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'https':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+"://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
</td>
</tr>
</table>
Thanks for all feedback and help.
-Stix
|
|
|
|
|
If you have a problem with something from GitHub, it's best to report the problem in that project's "Issues". That way, the author(s) will be notified, and will have a chance to respond.
Issues · kevinburke/customize-twitter-1.1 · GitHub[^]
The error is probably something you can't fix. Script from one domain should not be able to modify documents loaded from another domain unless that other domain explicitly allows it. Imagine the chaos if evilbadguys.com could embed a frame to yourbank.com and then interact with the document to transfer all of your money to their account!
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Your bank analogy of explanation is comical to me, the file is only allowing the data that is in the timeline be styled, it isnt allowing it to be changed. The font style is ARIAL and i want the font to be OSWALD, the color is red and i want the color to be blue, simply that is all the css sheet is doing.
I have contacted the author, and he has no time to look into this now, therefore i was reaching out to see if it was something simple that could be fixed in that small script to work in the browsers is all.
Thanks
|
|
|
|
|
Member 15146608 wrote: Your bank analogy of explanation is comical to me, the file is only allowing ...
... the content of the site in the iframe to be accessed and modified by script running on a different site.
Or are you suggesting that the browser should be able to tell the difference between purely cosmetic changes, and changes which might have unintended consequences?
And even purely cosmetic changes could cause problems. The evil site could make the frame almost invisible, and position the required button directly under your mouse cursor, so that wherever you tried to click on the parent site, you ended up clicking the "give all of my money to the bad guys" button on the target site.
You may find the analogy "comical", but the problem was serious enough and prevalent enough for all of the browser companies to update their browsers to address it.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
The script still works a decent amount in chrome, in firefox it tends to be about 80-20 not working, I am not sure why it works better in chrome now then firefox unless firefox has tighter restrictions....
The twitter feed is my own feed.
Again i was looking to see as i have read some that cross domain can be tweaked etc etc, however i dont know enough about JS to do that and was looking for advice and help, or a better mouse trap code.
No worries here, i will keep looking for a way to style my time with css
Thanks
|
|
|
|
|
You'll probably need to use the Twitter API to retrieve the timeline; then you'll be able to style it however you want.
Twitter API Documentation | Twitter Developer[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Oh i wish, back in the day twitter time line was so user friendly as they allowed the end user to style there timeline with a CSS, it was super cool.
However now today, there time line is sandbox and it doesn't allow css to over ride it...
That is where the JS code came in to inject the css sheet in the time line to style it...
Twitter is so ugly as it is in that timeline, it needs a nice style sheet lol
Thanks
|
|
|
|
|
Hi all,
Hope I'm asking this in the right place. I'm using this example from Telerik but am having no luck at all getting the NoDataTemplate to show.
Add new item in jQuery ComboBox Widget Demo | Kendo UI for jQuery[^]
My cshtml looks like this (there's a form tag higher up in case that's important):
<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6">
<input id="SegmentGroup" style="width: 100%;" />
<script id="noDataTemplate" type="text/x-kendo-tmpl">
<div>
No data found. Do you want to add new item - '#: instance.text() #' ?
</div>
<br />
<button class="k-button" onclick="addNew('#: instance.element[0].id #', '#: instance.text() #')">Add new item</button>
</script>
</div>
And my initialization of the combobox looks like this:
BCA.Configurator.CodeStringSegment.LoadSegmentGroups = function () {
var crudServiceBaseUrl = BCA.rootUrl + "eConfigurator";
var dataSource = new kendo.data.DataSource({
transport: {
read: {
url: crudServiceBaseUrl + "/PrConf/RetrieveSegmentGroups",
dataType: "json",
type: "POST"
},
},
schema: {
model: {
id: "Key",
fields: {
Key: { type: "number" },
Value: { type: "string" }
}
}
}
});
$("#SegmentGroup").kendoComboBox({
filter: "startswith",
dataTextField: "Value",
dataValueField: "Key",
dataSource: dataSource,
placeholder: "Select Pricing Group",
noDataTemplate: $("#noDataTemplate").html(),
filtering: BCA.Configurator.CodeStringSegment.CheckForNewSegmentGroup,
});
}
When I type "cf" (because I know nothing in the list starts with that combination of letters) absolutely nothing happens that I can see. Any idea why?
Thanks in advance, all,
Denise
|
|
|
|
|
First off, let me admit that I'm a newbie at javascript... I spent my career on C and C++, mostly in the embedded realm.
So I'm trying to fix some problems with an old html/javascript program called BallDroppings.
It was extracting its sound files from a .swf file, using fm.playSound() to play them, and it would hang in most browsers as soon as sound was enabled.
So I extracted the sound files into separate .mp3 files, and am using Audio() to play them:
var str = "sounds/sound_" + ("00" + vel).substr(-2,2) + ".mp3" ;
var hdlAudio = new Audio(str);
hdlAudio.play();
This is working, initially... however, the nature of the program is that more and more balls (and therefore, sounds) are active as the display becomes more complex.
What I'm finding is that, with certain browsers (Firefox and Pale Moon), once a certain number of sounds are active, the system appears to get confused, and the program loses control of the sounds - meaning that, among other things, sound cannot be turned off, and not all sounds that *should* be playing, *are* playing...
Interestingly, this issue does not occur with MS Edge; I've had up to 26 balls in flight, and all sounds are working, and can be turned off/on. I haven't tested with Chrome yet.
Does anyone have any idea what is wrong here??
Note: the entire project is available for cloning here:
GitHub - DerellLicht/BallDroppings: port of ancient BallDroppings app, without dependence upon swf file for sounds[^]
If you just want to see it running, use this:
BallDroppings[^]
draw lines to block the stream and bounce the ball around,
click 'Options' and then 'Sounds' to turn sounds on.
modified 31-Mar-21 22:12pm.
|
|
|
|
|
Hi folks.
I have stubled on a strange problem with JSON.parse, which worked for years in a software solution of ours, and still works for all customers except one.
I've drilled it down to a small, reproducable error:
var json_problem = '{"test": "a\\b\\c\\d\\e\\f\\g"}';
var parsed_json_problem = JSON.parse(json_problem);
The error is:
Quote: VM1623:1 Uncaught SyntaxError: Unexpected token c in JSON at position 14
at JSON.parse (<anonymous>)
So it fails to parse the 'c' after the third escaped backslash. Not the first, not the forth, not the fifth, only the third. I'm totally stumped. What can this be?
Strange thing is, in real life it's a directory structure in the JSON string, and all directories of all users begins with the same network share name, but only for one user it fails...
|
|
|
|
|
The input doesn't seem to be valid JSON.
Assuming you want the test property to contain the literal string a\b\c\d\e\f\g , you need to encode the backslashes twice - once for the string literal value within the serialized object, and again for the JSON representation of that string:
var json_problem = '{"test": "a\\\\b\\\\c\\\\d\\\\e\\\\f\\\\g"}';
var parsed_json_problem = JSON.parse(json_problem); Pasting your string (including the ' s) into jsonlint.com gives:
Quote: Error: Parse error on line 1:
'{"test": "a\\b\\c\\
^
Expecting 'STRING', 'NUMBER', 'NULL', 'TRUE', 'FALSE', '{', '[', got 'undefined'
I can only assume you pasted it in without the ' s, in which case you would only need to escape the backslashes once.
With your original code, the string property would contain a literal a , a backspace character (\b ), three invalid characters (\c , \d , \e ), a form-feed character (\f ), and another invalid character (\g ). This value cannot be deserialized, which is why you're getting an error.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I'm SMH on this.
I wrote an API in PHP 7.4, that gets the body in the header, converts it to an object and I do the database write. It works fine in Postman, but my app seems to send garbage to my PHP API. Process of elimination tells me that I didn't package my JSON right in plain JavaScript.
const jsonData = {
"projectNumber": projectNoElement.value,
"userName" : userNameElement.value,
"userType" : userTypeElement.value,
"invoiceClass": classElement.value,
"invoiceOperation": opElement.value,
"subContractor": scElement.value,
"invoiceDate": dateElement.value,
"invoiceNumber": invNumberElement.value.trim(),
"invoiceAmount": invAmountElement.value.trim(),
"invoiceDescription": descElement.value.trim()
};
const jsonPayload = JSON.stringify(jsonData);
console.log(jsonPayload);
fetch(urlQuery, { mode: 'same-origin', method: 'POST', headers: { 'Content-Type': 'application/json; charset=utf-8', body: jsonPayload }})
When I stringify it, and paste it in my Postman body, this is what I send, and the PHP side works fine. I send back { "result: true } and the Fetch crashes, because all these PHP error outputs are in the response payload.
{"projectNumber":"3352","userName":"xxxx","userType":"xxxx","invoiceClass":"EQ","invoiceOperation":"16","subContractor":"39","invoiceDate":"2021-03-27","invoiceNumber":"AZ-1000","invoiceAmount":"1.50","invoiceDescription":"Test Kit"}
I've never done this in plain valnilla JavaScript, and have been using Angular 8, in which I just stringify the object and Angular takes care of the rest. I searched around the internet and some examples show a pure string being fabricated, but the info dates back to 2011, nothing really 2020+ out there.
Browser response:
Note: I think I should keep the PHP side as is, because Postman works with it, and modify the JavaScript side. Versus trying to make the PHP side work with the current JavaScript side.
SyntaxError: JSON.parse: unexpected character at line 2 column 1 of the JSON data
But my browser F12, network, response says result "1"
Notice: Trying to access array offset on value of type null in C:\App\Dev\PCAD\api\invoices\viewInvoices.api.php on line 72
Notice: Trying to access array offset on value of type null in C:\App\Dev\PCAD\api\invoices\viewInvoices.api.php on line 73
Notice: Trying to access array offset on value of type null in C:\App\Dev\PCAD\api\invoices\viewInvoices.api.php on line 74
Notice: Trying to access array offset on value of type null in C:\App\Dev\PCAD\api\invoices\viewInvoices.api.php on line 75
Notice: Trying to access array offset on value of type null in C:\App\Dev\PCAD\api\invoices\viewInvoices.api.php on line 76
Notice: Trying to access array offset on value of type null in C:\App\Dev\PCAD\api\invoices\viewInvoices.api.php on line 77
Notice: Trying to access array offset on value of type null in C:\App\Dev\PCAD\api\invoices\viewInvoices.api.php on line 78
Notice: Trying to access array offset on value of type null in C:\App\Dev\PCAD\api\invoices\viewInvoices.api.php on line 79
Notice: Trying to access array offset on value of type null in C:\App\Dev\PCAD\api\invoices\viewInvoices.api.php on line 80
Notice: Trying to access array offset on value of type null in C:\App\Dev\PCAD\api\invoices\viewInvoices.api.php on line 81
{
"result": "1"
}
If it ain't broke don't fix it
Discover my world at jkirkerx.com
modified 27-Mar-21 16:01pm.
|
|
|
|
|
I went back and did more research.
The payload I sent from my JavaScript fetch was empty, so PHP wasn't able to read anything, or work with the JSON.
Found some technical documentation for fetch, and there is a correct way to attach the payload for PHP V7.4+ to read using $jsonPayload = file_get_contents('php://input') ;
Changing the header to an object and inserting the object into fetch seems to have packaged my payload proper for a smooth transmission. So that's it, I now have all my parts designed, tested and confirmed and it appears to be really fast and rock solid now. I'm off to the pool to hang out.
const jsonData = {
"projectNumber": projectNoElement.value,
"userName" : userNameElement.value,
"userType" : userTypeElement.value,
"invoiceClass": classElement.value,
"invoiceOperation": opElement.value,
"subContractor": scElement.value,
"invoiceDate": dateElement.value,
"invoiceNumber": invNumberElement.value.trim(),
"invoiceAmount": invAmountElement.value.trim(),
"invoiceDescription": descElement.value.trim()
};
const jsonPayload = JSON.stringify(jsonData);
let header = new Headers();
header.append('Content-Type', 'application/json');
header.append('Accept', 'application/json');
fetch(urlQuery, { mode: 'same-origin', method: 'POST', cache: 'no-cache', headers: header, body: jsonPayload })
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|
|
Hi, thanks for answering.
I indeed copy pasted the strang into jsonlint without the enclosing single quotes, because that's the string which has to be validated.
And I still dont understand the problem. I don't do \a\b\c etc., because I escape each backslash: \\a\\b\\c so the a, b, c should be characters, not string literals.
And the string in my original code (again, of course without the enclosing single quotes) validates fine in jsonlint.com..
|
|
|
|
|
Dear, I'm testing a CAPTCHA antispam system from PHP (antispam/getimg.php) and I do not understand what happens :
type: 'POST',
url: $("#relpath").val() + 'sendmailcvalidation.php',
data: $("#sendmail").serialize(),
success: function(data) {
data=data.trim();
if(data == "false") {
alert("Erreur lors de l'envoi du message");
mailsendstatus = false;
$("#cvalidationlabel").children(".err").fadeIn('slow');
}
else if(data == "badcapcha"){...}
The thirdth line of code serialize a form with the name "sendmail" and assign the result into DATA then, at the next lines the code check IF DATA=="false"
I miss something, how the serialization result of a form (name/value pairs as string, ie:data=data.trim()) could be evaluated like an BOOLEAN ... ?
(I'm a natvie french speaker)
|
|
|
|
|
...and the code works fine
|
|
|
|
|
It is a common convention that PHP functions return false on failure, instead of their normal return type (such as some kind of object, array, etc)
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
Thank Peter BUT your answer bring another question in mind, I did not paste the whole code but in the if condition, DATA is also evaluated tu TRUE or "BADCAPCHA" ... is there a way to override the serialize function or something else .... ?
else if(data == "badcapcha"){
alert("Le code est incorrect");
mailsendstatus = false;
$("#cvalidationlabel").children(".err").fadeIn('slow');
}
else if(data == "true"){
$("#cvalidationlabel").children(".err").fadeOut('slow');
$("#sendmailwrapper").slideUp(650, function(){
$(this).before("<h3>Mail SEND</h3>");
});
|
|
|
|
|
ok, thanks for the "advise"
|
|
|
|
|
There are two different things called data in that code snippet:
- The
data: property of the object passed to jQuery's ajax method[^], which contains the serialized[^] form data; and - The
data parameter passed to the success callback, which represents the parsed response returned from the server.
It might make things easier to understand if you renamed the parameter:
type: 'POST',
url: $("#relpath").val() + 'sendmailcvalidation.php',
data: $("sendmail").serialize(),
success: function(responseFromServer) {
responseFromServer = responseFromServer.trim();
if (responseFromServer === "false") {
...
}
else if (responseFromServer === "badcaptcha") {
...
}
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Thank you, This will be very helpfull
|
|
|
|
|