2019 January
-
I've been working with Javascript for more than a decade. Last week while helping another developer debug a problem, I had to Google how to check if an element exists in a Javascript array, something superbasic, that one would expect most newbies to know. I'm sure I Google some superbasic thing at least once a week. It's not embarassing or anything, it's a common occurrence. I'm surely not alone. Just last night a tweet about this crossed my TL: In C++ we don't say "Missing asterisk" we say "error C2664: 'void std::vector<block,std::allocator<_Ty>>::push_back(const block &)': cannot convert argument 1 from 'std::_Vector_iterator<std::_Vector_val<std::_Simple_types<block>>>'
2017 December
-
How to specify that a column in the schema should be nullable?
I tried adding a nullable attribute:
var myFirstTDE = xdmp.toJSON( { "template": { "context": "/match", "collections": ["source1"], "rows": [ { "schemaName": "soccer", "viewName": "matches", "columns": [ { "name": "id", "scalarType": "long", "val": "id", "nullable": 0 }, { "name": "document", "scalarType": "string", "val": "docUri" }, { "name": "date", "scalarType": "date", "val": "match-date" }, { "name": "league", "scalarType": "string", "val": "league" } ] } ] } } ); tde.validate( [myFirstTDE] );
But this gave me a template error:
"message": "TDE-INVALIDTEMPLATENODE: Invalid extraction template node: fn:doc('')/template/array-node('rows')/object-node()/array-node('columns')/object-node()[1]/number-node('nullable')"
For a template defined using XQuery, adding nullable to the column works:
<column> <name>ISSN</name> <scalar-type>string</scalar-type> <val>Journal/ISSN</val> <nullable>true</nullable> </column>
How to do the same thing using JS/Json?
2017 November
-
Basically the title. The client is complaining that when he zooms in, the text labels for the nodes are quite large. Is there a way to keep the node labels at a fixed font size even when zooming in or out?
From the nodes documentation (http://visjs.org/docs/network/nodes.html), there's a scaling.label option, but it doesn't seem to work. I think this is only relevant if I'm using values to scale the nodes.
2017 October
-
I'm trying out vis.js for generating graph visualization. For every edge in my graph, I have a number that describes the strength of the connection between two nodes. I'd like to render the vis.js graph such that the nodes that have stronger relationships (higher edge values) are closer together (edge length is shorter).
I've set the relationship strength (an integer) as the "value" attribute for each edge, but this only seems to make the edge lines slightly thicker for higher values.
What options should I be looking at? I'm not sure if this is supposed to be a function of vis's physics-based stabilization.
Thanks for advice!
2017 September
-
I have an HTML page with around 10 charts generated by chart.js (so these are canvas elements). I want to be able to export the page content into a PDF file.
I've tried using jsPDF's .fromHTML function, but it doesn't seem to support exporting the canvas contents. (Either that or I'm doing it wrong). I just did something like:
$(".test").click(function() { var doc = new jsPDF() doc.fromHTML(document.getElementById("testExport")); doc.save('a4.pdf') });
Any alternative approaches would be appreciated.
-
I'm using ML8. I have a bunch of json documents in the database. Some documents have a certain property "summaryData", something like:
{ ...(other stuff)... summaryData: { count: 100, total: 10000, summaryDate: (date value) } }
However, not all documents have this property. I'd like to construct an SJS query to retrieve those documents that don't have this property defined. If it was SQL, I guess the equivalent would be something like "WHERE summaryData IS NULL"
I wasn't sure what to search for in the docs. Any advise would be helpful.
2017 July
-
I'm using the demo of jsPlumb here:
In this demo, there's no way to move an existing connection to a different target node. Any idea how to do it?
Some of the other examples have movable connections, but they also use specific endpoints on the nodes. I like this particular example where I can drag the connection endpoint to any point of the target node.
-
I'm trying out jsplumb. I have a copy of this demo: https://jsplumbtoolkit.com/community/demo/statemachine/index.html
In this demo, when I drag one of the nodes outside of the canvas boundary, a scrollbar appears to indicate the canvas area has expanded. However, I still have to manually scroll the view to see the dragged node.
I would like the view to automatically scroll when I drag a node beyond the edge. Same thing when dragging a new connector, I would like to automatically scroll the view - so I can choose to connect to a node currently outside the visible area. Any advice on how to do this?
Secondary question: In the demo above the scrollbars appear as expected when I drag elements off the right or bottom of the canvas, but not when I drag them off the left edge or off the top edge. That is, if I drag a node upward off the canvas and drop it there, I no longer have any way of viewing that node or dragging it back down. Is there a way around this?
2017 June
-
The scenario is: the user can input a URL for an image file, then on form submit I want to download the file and submit it to the server. As if they had selected the file using an
<input type='file' />
.Of course I can just do it on the server-side. But my question: how can I do this on the browser side via JavaScript? Is it possible?
2016 December
-
In JavaScript, referencing variables that are declared outside of a function's scope can be tricky. If you have code like this: var btn = document.getElementById("BTN"); var test = 1; btn.onclick = function() { alert(test); } test = 2; The click handler above retains a reference to the test variable even though it falls out of scope as soon as the script block finishes execution. When you actually click the button, the alert will show the last value of the variable when the block finished execution (2) instead of the value at the time the function was initialized (1). I thought
2014 February
-
IE8 is giving me the slow-running script message on load of a page:
Stop running this script? A script on this page is causing your web browser to run slowly. If it continues to run, your computer might become unresponsive.
However, the webapp I'm debugging is fairly old and has a whole lot of scripts. Is there an easy way for me to find out which of those scripts is causing the problem?
2013 March
-
I'm trying to trace a slowdown on load of a web page in our application and there's a ton of JavaScript to go through so I'd rather not process them individually.
I'm trying to see if there's a way to list out all the event handlers added to
$(document).ready()
so that I would just look through those handlers to see what might be causing the problem.Is there a way to do this?
2012 July
-
💬 Reply to :
Is this in an HTML page? If yes, why not just use something like $("option").each()?
-
💬 Reply to :
Check the value of the control on document ready and adjust the div visibility accordingly.
2011 December
-
Does compliance to WCAG 2.0 AA prevent the use of JavaScript?
My understanding based on Understanding Conformance is that we can still use JavaScript as long as we don't generate any content that is noncompliant and that we explicitly state we support JavaScript. Is that correct?
2010 December
-
💬 Reply to :
As many times as you like. They fire in order of declaration.
$(document).ready()
will fire when the document is ready (when it's all loaded by the browser). The other one will fire as soon as that part of the script executes.
2010 September
-
💬 Reply to :
If you want to use jquery ui autocomplete, your data must be "a simple Array of Strings, or it contains Objects for each item in the array, with either a label or value property or both". This is from the documentation at http://jqueryui.com/demos/autocomplete/
Your server response does not follow the expected data type, you should modify suggest.php to post-process the data into label-value pairs.
As I understand it, you also want to perform a custom action when an item is selected from the autocomplete, so you should also add a handler for the 'select' event.
2010 August
-
💬 Reply to :
You already have the lines logging your values array, was it so hard to add lines logging the other vars?
c1_arr = c1.split(';');
The array created here is ['font-color:#ff0000', ''] - there is a blank second element since there's nothing after the ';' in the input string.
Then when you call:
values[1][i]= c1_arr[i].split(':');
c1_arr[1] is empty string, so values[1][1] is an array with only one element, empty string.
values[1][1][0] -> empty string values[1][1][1] -> undefined (no second element)
-
💬 Reply to :
If you use a hidden frame, the content won't be displayed (hence "hidden"), I think you just mean to use an iframe. But this doesn't fit your description of "without refreshing", since you have to refresh the frame.
When loading the PHP file inside the frame, your PHP file just needs to generate HTML the same way you would generate a normal page. It's the same whether the PHP file is loaded inside a frame or not.
2010 July
-
Back story: I'm planning to implement a casual game to be deployed in a webapp, but I don't want to use Flash, instead just plain Javascript. One benefit of Flash that I would want though is that it distributes a binary and not the source code so it's easier to protect your code from being reused/stolen by somebody else, or to prevent the client from modifying the code to "cheat" in the game?
So my question is: what are the ways to similarly protect a Javascript application? Am I limited to the usual methods of using a code obfuscator? Will that be enough?