lang stringclasses 4
values | desc stringlengths 2 8.98k | code stringlengths 7 36.2k | title stringlengths 12 162 |
|---|---|---|---|
JS | When building our production app in Gatsby , I see something like this : Is it possible to hash these paths instead of printing them out ? We don ‘ t want to expose too much from what is happening in the back.I tried setting these configs in webpack : And it successfully hashes .js files but not the template paths . | window.___chunkMapping= { `` app '' : [ ] , `` component -- -src-templates-page-tsx '' : [ ] , `` component -- -src-templates-pages-newsletter-tsx '' : [ ] } output : { filename : ` [ chunkhash:2 ] [ contenthash:5 ] .js ` , chunkFilename : ` [ chunkhash:2 ] [ contenthash:5 ] .js ` , } , | Rename webpack/gatsby chunkmapping strings |
JS | Edit : Simpler repro case ; the following code : …produces the output : Try it yourself : http : //jsfiddle.net/Fjwsg/ ( Original question follows ) Given the following code ( or code like it ( fiddle ) ) : I see the following in the Developer Console when I focus the `` p '' input and type 1 backspace 2 : Once I see t... | setInterval ( function ( ) { var a= [ 10,20,30,40 ] , i=-1 ; a [ -1 ] = 42 ; while ( i < 10000 ) a [ i++ ] ; console.log ( a [ -1 ] , a [ 4294967295 ] ) ; } ,100 ) ; 42 undefined undefined 42 42 undefined37x undefined 42 42 undefined undefined 42 42 undefined41x undefined 42 42 undefined undefined 42 42 undefined < ! D... | Unexplained behavior in Safari with negative array indices |
JS | I have a sine wave in my canvas that is animated , swaying left and right . What I am trying to achieve is that the start and end points stay fixed . How to achieve that ? Here is the Code Pen | function start ( ) { var canvas = document.getElementById ( `` canvas '' ) ; var context = canvas.getContext ( `` 2d '' ) ; context.clearRect ( 0 , 0 , canvas.width , canvas.height ) ; drawCurves ( context , step ) ; step += 5 ; window.requestAnimationFrame ( start ) ; } var step = -4 ; function drawCurves ( ctx , step... | Animate sine wave , fixed start and end points |
JS | My foundations in Javascript are n't the strongest and I 'm curious how others would go about the current challenge I 've created for myself.I 'm playing around with paper.jsThe following code creates this The eye reacts to mouse events in the same way as the eyes here ( learned from that code ) — www.arc.id.au/XEyes.h... | // Eye position centereCntrX = 100eCntrY = 100var topLid = new Path ( ) topLid.add ( new Point ( eCntrX - 60 , eCntrY ) ) topLid.add ( new Point ( eCntrX , eCntrY - 28 ) ) topLid.add ( new Point ( eCntrX + 60 , eCntrY ) ) topLid.add ( new Point ( eCntrX , eCntrY + 28 ) ) topLid.strokeWidth = ' 6'topLid.strokeColor = ' ... | Creating unique variables |
JS | I often find myself having to build long chains before mapping over an array to check if it 's defined : If I leave out the this.props.photos & & and this.props.photos.activePhotos.length & & my entire application will crash if photos or activePhotos is undefined.Is there a way to check for these props without having t... | this.props.photos & & this.props.photos.activePhotos & & this.props.photos.activePhotos.map ( ... | How to check for deeply nested props |
JS | Let 's say I have a function that does a standard AJAX request : This code will cause the browser to start an AJAX request , but at what point in the function does the request actually start ? According to this post : https : //blog.raananweber.com/2015/06/17/no-there-are-no-race-conditions-in-javascript/ [ Calling xhr... | function doXHR ( ) { var xhr = new XMLHttpRequest ( ) ; xhr.open ( 'GET ' , 'https : //jsonplaceholder.typicode.com/posts ' ) ; xhr.send ( ) ; xhr.onreadystatechange = ( ) = > { console.log ( 'ready state change ' ) ; } ; } doXHR ( ) ; console.log ( 'done ' ) ; | At what point in a function call is an AJAX request actually initiated by the browser ? |
JS | I 'm aware that arrays in JavaScript differ from your traditional arrays in the sense that they are just objects under the hood . Because of this , JavaScript allows for sparse arrays to behave in a similar manner to dense arrays when it comes to memory management . When working with a sparse array , is there a way to ... | var foo = [ ] ; foo [ 0 ] = ' 0 ' ; foo [ 1 ] = ' 1 ' ; foo [ 2 ] = ' 2 ' ; foo [ 100 ] = '100 ' ; console.log ( foo.length ) ; // = > 101 for ( var n in foo ) { console.log ( n ) ; } // Output : // 0// 1// 2// 100 var curElement = foo [ 2 ] ; // = > 2 ( the contents of foo [ 2 ] ) var nextElement = curElement.next ( )... | How to get next element in a sparse array |
JS | Table structure : Collectionname ( String ) Imagecollection ( Pointer < Collection > ) url ( String ) position ( Number ) Image class has the column collection which is a pointer to the Collection class.position is used to sort Images within a Collection.What would be the most efficient way in Cloud Code to accomplish ... | results : [ { collection : { name : 'foo ' } , images : [ { position : 0 , url : 'test.jpg ' } , { position : 1 , url : 'test.gif ' } ] } , { ... } ] | Relational queries in Cloud Code ( parse.com ) |
JS | I am using dojo.gridx to display my values . Sometimes user can create a new row . So that I have added a new button when click newRow button , will call onclick method.In that method has create new row codes . My codes are below.addRow : By this code I am able to create a new row but I want to focus my mouse cursor po... | function ( ) { var that = this ; var gridIdLocal = dijit.byId ( 'GridId ' ) ; that.lastIndex+=1 ; ( last index count I get externally ) var newRow = { Id : `` , ClassDES : '' , createdDate : that.getTodayDate ( ) , activatedDate : that.getTodayDate ( ) , deactivedDate : '' , activeStatus : ' Y ' , id : lastIndex } ; gr... | How to focus second Cell when add a new row in dojo.gridX |
JS | How can I sum vertically all data from an array of arrays ? The output should be the vertical sum of arrays . [ 3,6,9,12,15,18,21,24 ] The problem is that array1 return always as undefined . | arrayOfArrays = [ { label : 'First Value ' , data : [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 ] } , { label : 'Second Value ' , data : [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 ] } , { label : 'Third Value ' , data : [ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 ] } ] ; var result = arrayOfArrays.reduce ( function ( array1 , array2 ) { return array1.da... | Sum array of arrays ( matrix ) vertically |
JS | I am really struggling with implementing The Coral Talk Project commenting system into my app.I am attempting to implement it into a project that is primarily Meteor and React . It 's on GitHub I think the main issue is that this is the first time I have needed to use a Script Tag in React.I have attempted doing it via... | < div id= '' coral_talk_stream '' > < /div > < script src= '' http : //127.0.0.1:3000/static/embed.js '' async onload= '' Coral.Talk.render ( document.getElementById ( 'coral_talk_stream ' ) , { talk : 'http : //127.0.0.1:3000/ ' } ) ; '' > < /script > | Using Coral Talk with React and Meteor |
JS | Our application can share code . For example user is sharing the html code as followswhich is not in a perfect format ... . Now i need to achieve the ( auto ) code formatting ... i.e . after auto code format click , it should look like So , is there ready made plugin available or is there any way ( s ) to achieve it ei... | < div id= '' nav-vert-one '' > < ul > { { for GroupCollection } } < li > < a href= '' # '' title= '' { { : Name } } '' onclick= '' test ( ) '' > { { : Name } } < /a > ( ' { { : GroupId } } ' ) '' > < /li > { { /for } } < /ul > < div id= '' nav-vert-one '' > < ul > { { for GroupCollection } } < li > < a href= '' # '' ti... | How to achieve ( auto ) code format selection of any html code via jQuery / C # ? ( Any solution ) |
JS | I have run across a condition statement which I have some difficulties to understand . It looks like ( please note the +-sign on the right-hand-side ) this : obj.length === +obj.length.Can this condition and its purpose/syntax be explained ? Looking at the statement ( without knowing it ) provokes the impression that i... | var myArray = [ 1,2,3 ] ; testResult1 = myArray.length === +myArray.length ; console.log ( testResult1 ) ; //prints truevar myObject = { foo : `` somestring '' , bar : 123 } ; testResult2 = myObject.length === +myObject.length ; console.log ( testResult2 ) ; //prints false | How to understand `` if ( obj.length === +obj.length ) '' Javascript condition statement ? |
JS | I have been tasked with combining two if statements in Js for a papercut script . It is a print management software . I have everything I need I believe in the script below . The problem is combining these two if 's into one statement I believe . I am not familiar with Javascript as well as I am with python . I am hopi... | /** Redirect large jobs without confirmation* * Users printing jobs larger than the defined number of pages have their jobs * automatically redirected to another printer or virtual queue . * This can be used to redirect large jobs from slower or high cost printers * to more efficient or faster high volume printers . */... | Combining Javascript if statements for papercut |
JS | I am trying to replace some text in an input field using JS but the view model overrides my commands each time . This is the HTML I start with : I run this JS : And I 'm left with the following HTML : The problem is that each time I click the input field the value is reverted to what it was when the page loaded.I 've a... | < td class= '' new-variants-table__cell '' define= '' { editVariantPrice : new Shopify.EditVariantPrice ( this ) } '' context= '' editVariantPrice '' style= '' height : auto ; '' > < input type= '' hidden '' name= '' product [ variants ] [ ] [ price ] '' id= '' product_variants__price '' value= '' 25.00 '' bind= '' pri... | Overriding difficult view model |
JS | Basically call stack will start to pop out the function calls one by one when the last-in function call returns . But when ever I try to create a call stack nearer to the size of its maximum , An uncaught expression is getting raised.So the above code is throwing an exception for me in chromium Version 49.0.2623.112 m ... | //Code for testing the stack sizevar cnt = 0 ; function test ( ) { //Max stack size is nearer to ~41800 if ( cnt++ == 41763 ) { console.log ( 'finished ' ) ; return true ; } return test ( ) ; } test ( ) ; | Recursion - Call stack fails to pop when testing the maximum stack size |
JS | I am having a weird problem with my code , I have a styled component div that wraps around another component like this : ( Bookday returns an empty div so this should not be a problem ) My styled component ContentWidget is an empty styled component div and is declared like this : The weird thing is I have more contentw... | < ContentWidget > < BookDay / > < /ContentWidget > const ContentWidget = styled.div `` ; | React styled component causes build error in production , but runs fine in development |
JS | The story behindI am creating a voice controlled application using x-webkit-speech which is surprisingly good ( the feature , not my app ) , but sometimes the user ( me ) mumbles a bit . It would be nice to accept the command if some reasonable part of the word matches some reasonable part of some reasonable command . ... | `` rotation '' in [ `` notable '' , '' tattoo '' , '' onclick '' , '' statistically '' ] for ( var i=10 ; i > =4 ; -- i ) // reasonable substringfor ( var word in words ) // for all words in the setfor ( var j=0 ; j < word.length-i ; ++j ) // search for any i substring// aaargh ... three levels of abstraction is too mu... | Algorithm of the greatest intersect of word in set of words |
JS | I 'm working on a `` small '' bot for fun and currently trying to create a blackjack command . The first half works fine , but the problem appears when I want to update the embed that was already posted by the bot . I keep getting an error : UnhandledPromiseRejectionWarning : DiscordAPIError : Can not edit a message au... | const embd = new Discord.MessageEmbed ( ) .addFields ( { name : 'Dealer cards : ' + botCards + ' + ? ' } , { name : 'Your cards : ' + userCards } , ) message.channel.send ( embd ) .then ( embdReact = > { embdReact.react ( `` ) ; embdReact.react ( `` ) ; const filter = ( reaction , user ) = > { return [ `` , '' ] .inclu... | discord.js how to edit/update embed ? |
JS | I need to detect mouseup event after mousedown on the document.I have tried to add an event listener to document and document.documentElement with no success.I need possibly a cross platform solution without jquery.Notes : problem appears on not all browsers using alert ( ) .http : //jsfiddle.net/0f7vrzh7/8/ | document.documentElement.addEventListener ( 'mousedown ' , function ( ) { alert ( 'mousedown ' ) ; } ) ; document.documentElement.addEventListener ( 'mouseup ' , function ( e ) { alert ( 'mouseup ' ) } ) ; | mouseup event on document.documentElement does not fire with alert |
JS | In my htm page i want to use a button which submit my form by using function . I use validations on my fields and when i press submit button it displays error message but doesnot retain last values it refresh my form . I just want that the values that i entered will be exist there and just the field that has only error... | < ! DOCTYPE html PUBLIC `` -//W3C//DTD XHTML 1.0 Transitional//EN '' `` http : //www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd '' > < html > < head > < ! -- < meta http-equiv= '' refresh '' content= '' text/html ; charset=iso-8859-1 '' / > -- > < ! -- < meta http-equiv= '' Content-Type '' content= '' text/html ; cha... | do n't want to refresh & retain last inserted values |
JS | I have an image larger than viewport that I 'm trying to pan on the x plan according to device Acceleration value . I can get to semi-decent results but nothing like great . From my understanding I need to : get the acceleration value get the object position combine these two value ( maybe with frequency ? ) Apply the ... | _____________________ | | | Device | | | ________|___________________|__________ | | | | | | Image | | | | | | |_______|___________________|_________| | | | | | | | | |___________________| < -- -- -- -- -- -- -- -- -- -- > X axis var accelX = data.dm.xvar currTrans = $ ( ' # pano ' ) .css ( '-webkit-transform ' ) .spli... | JS use DeviceAcceleration.x to pan image seamlessly |
JS | I have an Express.js web app that is serving one of my domains . The app.js file looks like this : I would like to use one of my own functions within the app.js file , so I thought I 'd put the function in a separate file ( as a module , i.e . module.exports = stuff ) and then require it in the app.js file : However , ... | var express = require ( 'express ' ) ; var app = express ( ) ; // and so on… var myfunc = require ( './path/to/myfunc ' ) ; | How expensive is it to require ( ) something within an Express.js app ? |
JS | If I wish to change the opacity of a < div > irregularly over time , I can use CSS animation and @ keyframes : But what if I want to change the volume of an < audio class= '' my-audio '' > element irregularly over time in an identical manner ? I know I can begin with : But how can I change the volume to 0.99 , when 81 ... | .myDiv { animation : myAnimation 10s linear ; } @ keyframes myAnimation { 0 % { opacity : 1 ; } 80 % { opacity : 1 ; } 81 % { opacity : 0.99 ; } 100 % { opacity : 0 ; } } } var myAudio = document.getElementsByClassName ( 'my-audio ' ) [ 0 ] ; myAudio.volume = 1.0 ; | Can I `` transition '' the volume of an < audio > element , using javascript ? |
JS | Creating independent stopwatches . I have two elements named A andB . When I click on the A element , its descriptionHello and stopwatch will appear . When I click on the B element , itsWorld description and stopwatch will appear . I have a problem with stopwatches . When I click on the element A and start the stopwatc... | class App extends React.Component { constructor ( ) { super ( ) ; this.state = { items : [ { name : ' A ' , description : 'Hello ' } , { name : ' B ' , description : 'World ' } ] , selectIndex : null } ; } select = ( index ) = > { this.setState ( { selectIndex : index } ) } render ( ) { console.log ( this.state.selectI... | Creating independent stopwatches for each item in array . Setting the stopped time , based on data returned by the API |
JS | This example from Mike Bostock : https : //bl.ocks.org/mbostock/34f08d5e11952a80609169b7917d4172The following line confuses me and i was wondering if someone could clear it up.Why is x2 being passed in as a second argument ? As far as I know the second parameter is the optional thisArg argument , but as invert does n't... | x.domain ( s.map ( x2.invert , x2 ) ) ; | Map function in D3 , confused about multiple functions passed in |
JS | With ES6 we can now utilize object shorthand notation for creating objects ... Is it possible to combine shorthand notation with regular notation ? In other words , is the following legit ? And if so , are there any gotchas I should be aware of ? | var a = 1 , b = 2 , c = 3 ; var obj = { a , b , c } ; var obj = { a , b , c , d : 'foo ' } ; | Can ES6 object shorthand notation be combined with regular object notation ? |
JS | In almost every Backbone/Require.js project you will see models and views that look similar to this : But , assuming that you set up your Require.js shims correctly ( with the Backbone shim including something like deps : [ `` underscore '' , `` jquery '' ] ) you only need to define Backbone -- defining Backbone as a d... | define ( [ 'jquery ' , 'underscore ' , 'backbone ' ] , function ( $ , _ , Backbone ) { //Some code goes here , perhaps a Backbone model or view } ) ; define ( [ 'backbone ' ] , function ( Backbone ) { //Some code goes here , perhaps a Backbone model or view } ) ; | Why include jQuery and underscore in every JS file in Backbone/Require.js project |
JS | Hi guys so i am trying to make a nutrtrion label just like this : ExampleCurretnly have my db all set up . trying to get it to work one thing at the moment and then can do it with the rest . My db looks like : The problem i am having right now is huge . I have been stuck on it for the last 3 days and no one seems to kn... | ingName : ... .fat : ... carbs ... etc Apple : 1gMango : 2g Melon : 3g Total : 6g < tr > < th colspan= '' 2 '' > < b > Total Fat < /b > < span id= '' fat '' > 0.0 < /span > < /th > < td > < b > 22 % < /b > < /td > < /tr > < input type= '' text '' name='search_term ' id= '' search_term '' class= '' searchFunction '' > <... | jQuery.remove ( ) deleting the wrong element |
JS | I 'm working on a script where all I want it to do ( right now ) is redirect the user based on which button they press . Eventually it will take form input and incorporate that into the redirect , but right now I 'm just trying to get the buttons to send the user off to the appropriate site . However , My redirects are... | < html > < head > < title > Home < /title > < /head > < body > < script type= '' text/javascript '' > < ! -- var textstring ; var btnWhichButton ; //Gets the text from the formfunction getQ ( ) { textstring = document.forms [ 'Search ' ] .elements [ 0 ] .value ; } //Does a Google Searchfunction googleSearch ( ) { windo... | Page Redirection |
JS | I need to perform clearRect ( ) after performing clip ( ) in canvas . Unfortunately , It does not working for me . If I exclude clip ( ) means , clearRect ( ) is working fine me . I need to perform clearRect ( ) after performing clip ( ) . Is this possible ? Please find the fiddleIf I called clearRect ( ) after calling... | < script > var c = document.getElementById ( `` myCanvas '' ) ; var ctx = c.getContext ( `` 2d '' ) ; ctx.fillStyle = `` red '' ; ctx.fillRect ( 0 , 0 , 300 , 150 ) ; ctx.clip ( ) ; //after removing clip ( ) clearRect ( ) workingctx.clearRect ( 20 , 20 , 100 , 50 ) ; < /script > public canvasClip ( options : BaseAttibu... | How do I perform clearRect ( ) in canvas after clip ( ) ? |
JS | I 'm trying to gain a deeper understanding of how Javascript works and the following code is bugging me : In Chrome , the first two document.writelns execute as expected , then I get `` Uncaught ReferenceError : doesThisWork is not defined '' in Chrome . Why ca n't I call the second function by the name doesThisWork ? ... | function notInVar ( a , b ) { return a + b } var inVar = function doesThisWork ( a , b ) { return a + b } document.writeln ( ' 2 + 2 = ' + notInVar ( 2 , 2 ) ) ; document.writeln ( ' 3 + 3 = ' + inVar ( 3 , 3 ) ) ; document.writeln ( ' 4 + 4 = ' + doesThisWork ( 4 , 4 ) ) ; | Why does function name disappear when assigned to a var ? |
JS | This is the third question I have posted today so forgive me but I am just running into things I ca n't seem to figure out.Here is my code for angular : And some simple stripped down HTML : Here is what that returns : But I need it to look like this : How can I split up ng-repeat and allow me to separate the values ( i... | angular.module ( 'ngApp ' , [ ] ) .factory ( 'authInterceptor ' , authInterceptor ) .constant ( 'API ' , 'http : //appsdev.pccportal.com:8080/ecar/api ' ) .controller ( 'task ' , taskData ) function taskData ( $ scope , $ http , API ) { $ http.get ( API + '/tasks ' ) . success ( function ( data ) { $ scope.mainTask = d... | angularJS - splitting up ng-repeat into multiple HTML elements |
JS | When a user performs a tap and hold gesture to select a word and then drags their finger towards either the top or bottom edges of the screen , the page automatically scrolls in order to accommodate the selection.here is a short clip demonstrating itI would like to prevent this behavior inside a WKWebView.Here is what ... | var shouldAllowScrolling = true ; document.addEventListener ( 'selectionchange ' , e = > { shouldAllowScrolling = getSelectedText ( ) .length === 0 ; window.webkit.messageHandlers.selectionChangeHandler.postMessage ( { shouldAllowScrolling : shouldAllowScrolling } ) ; console.log ( 'allow scrolling = ' , shouldAllowScr... | WKWebView - prevent automatic scrolling triggered by user text selection |
JS | i 'm using this jquery date picker function , it works fine if i remove `` year range:1930 '' from it , but does n't work if i include year range . i dont know how to deal with this problem . help me . | < script type= '' text/javascript '' > jQuery ( function ( $ ) { $ ( 'input [ name= '' dob1 '' ] ' ) .datepicker ( { `` dateFormat '' : `` mm/dd/yy '' , `` firstDay '' : `` 1 '' , `` changeMonth '' : true , `` changeYear '' : true , `` yearRange '' : `` 1930 '' } ) .datepicker ( 'option ' , 'onSelect ' , function ( ) {... | JQuery date picker function is n't working |
JS | I have a long running Javascript function , that looks like this : My function calls another synchronous function very often ( I used 500 in this example ) and while the user waits for the task to complete , i 'd like to implement something like a loading bar but I demonstrated it with updating a span in my case here .... | window.myFunction = function ( ) { for ( var i=0 ; i < 500 ; i++ ) { // calling a function here document.getElementbyID ( 'mySpan ' ) .innerHTML = `` Completed step `` + i + `` /500 '' } } | Updating DOM during Javascript function execution |
JS | Is there a shorthand version of the following : Many thanks . | ( a > 0 & & a < 1000 & & b > 0 & & b < 1000 & & c > 0 & & c < 1000 ) | Javascript Shorthand |
JS | I am using wkhtmltopdf to convert part of a HTML page to a PDF document that may be several pages long ( depending on the text the user inputs to be converted ) .The wkhtmltopdf is working correctly . I am now wanting to indicate to the user where the page breaks will occur before the user creates their PDF document.Ho... | < body > < div id= '' main_area '' > < div id= '' text '' > < p > Lorem ipsum doler sit amet Lorem ipsum doler sit amet Lorem ipsum doler sit amet Lorem ipsum doler sit amet . Lorem ipsum doler sit amet Lorem ipsum doler sit amet Lorem ipsum doler sit amet Lorem ipsum doler sit amet . Lorem ipsum doler sit amet Lorem i... | JQuery - find height of div then create loop to overlay div |
JS | got some problem with this code . The map did not become `` undraggable '' on Firefox immediately after mousedown on div , but on Chrome is ok.Here is a fiddle https : //jsfiddle.net/benderlio/njyeLujs/FF version is 54.0.1 windows 10On chrome the map is not draggable after mouse down on white box , but on FF you can mo... | google.maps.event.addDomListener ( div , 'mousedown ' , function ( e ) { console.log ( `` draggable START `` , map.get ( 'draggable ' ) ) ; map.set ( 'draggable ' , false ) ; console.log ( `` draggable END '' , map.get ( 'draggable ' ) ) ; google.maps.event.trigger ( map , 'resize ' ) ; } ) ; | google.maps.event.addDomListener mousedown on Firefox |
JS | I 've ran into a weird issue today , I 'm hoping someone else can help me figure this out.The project that I 'm working on is more-or-less a jQuery slideshow . I have a super simple file that I 'm loading to test everything out , it looks something like this : Again , nothing even remotely fancy here.Now , in jQuery I ... | < ! doctype html public `` ( ╯°□°)╯︵ ┻━┻ '' > < html > < head > < meta charset= '' utf-8 '' > < title > test < /title > < /head > < body > < div id= '' slides '' data-slidesShow= '' holder '' > < div class= '' slide '' id= '' test1 '' > test div 1 < /div > < div class= '' slide '' id= '' test2 '' > test div 2 < /div > ... | jQuery selector not behaving as expected in parsed HTML from ajax |
JS | I am trying to implement a timer . I learned this idea from a SO post . This is my php code . My php , html and JS codes are in the same page . I have a button in my html . When a user clicks on the html page , It will call a Ajax functionIt will call setCountDown ( ) method , which contains a line at the very beginnin... | < ? php if ( ( $ _SERVER [ 'REQUEST_METHOD ' ] === 'POST ' ) & & ! empty ( $ _POST [ 'username ' ] ) ) { //secondsDiff is declared here $ remainingDay = floor ( $ secondsDiff/60/60/24 ) ; } ? > //url : '' onlinetest.php '' , //dataType : 'json ' , beforeSend : function ( ) { $ ( `` .startMyTest '' ) .off ( 'click ' ) ;... | How do i make my php variable accessible ? |
JS | I was looking at this fiddle for MobX and I 've seen these two ways of defining React Components in ES6 other places as well , like Dan Abramov 's egghead redux video series . My question is , when is it appropriate to use each type ? It seems like the simpler components are able to use the simpler syntax , but I 'd li... | @ observerclass TodoListView extends Component { render ( ) { return < div > < ul > { this.props.todoList.todos.map ( todo = > < TodoView todo= { todo } key= { todo.id } / > ) } < /ul > Tasks left : { this.props.todoList.unfinishedTodoCount } < /div > } } const TodoView = observer ( ( { todo } ) = > < li > < input type... | Two ways of defining ES6 React Components |
JS | I have two fileA.htmlB.htmlWhen I move to b.html , can we use mywindow variable with all its window properties . So that I can still play around with child window from b.html . | < a href= '' B.html '' > B < /a > < script > var mywindow = open ( `` child.html '' , '' child '' , `` height=200 , width=200 '' ) ; < /script > < script > /*want to use mywindow property .Can we serialize whole window object and pass ? */ < /script > | Passing window object from a.html to b.html via javascript |
JS | I 'm looking for something like this : Does this exist ? I 'm using jQuery and would rather not import a whole plugin or another library just for this ability , so I 'm only interested in a short solution . | var div = document.createElement ( 'div ' ) ; div.id = 'proprioceptiveDiv ' ; $ ( div ) .on ( 'appendedToDOM ' , function ( ) { // ... } ) ; document.body.appendChild ( div ) ; // triggers above handler | Bind `` insertion into DOM event '' for not-yet-appended element |
JS | I have this < li > to sort by id : The code I use : The result is : The < li > are no not sorted correctly , what can cause the problem ? | < ul id= '' members-list '' > < li id= '' member_8 '' > < li id= '' member_4 '' > < li id= '' member_7 '' > < li id= '' member_12 '' > < li id= '' member_11 '' > < li id= '' member_13 '' > < li id= '' member_5 '' > < li id= '' member_6 '' > < li id= '' member_9 '' > < li id= '' member_3 '' > < li id= '' member_2 '' > <... | Jquery incorrectly sort < li > by id |
JS | I 'm simply send notifications using the node-notifier package . Also , when I click on the notification , it has to go to a link . But I ca n't listen the click event . The events provided by the package do nothing . This is my code : And this is my notification : I can use any other package . I just want to listen cl... | const notifier = require ( `` node-notifier '' ) ; const open = require ( `` open '' ) ; notifier.notify ( { title : `` Stackoverflow '' , message : `` A message '' , wait : true , open : `` https : //stackoverflow.com/ '' , } ) ; notifier.on ( `` click '' , function ( notifierObject , options , event ) { open ( `` htt... | How can I listen click event on Windows notifications ? |
JS | I was wondering if there is a neat way of doing this : This is really long and `` ugly '' .I found out that Angular2 has something really great for cases like this . But I think it 's only for templates : This got me really exited because I have a lot of code that looks just like the first example . It get 's the job d... | if ( app & & app.object & & app.object.foo ) { alert ( app.object.foo.bar ) ; } < div > { { this ? .object ? .foo ? .bar } } < /div > | Is there a JavaScript undefined property handling like in Angular2 templates |
JS | Let 's start with a definition : A transducer is a function that takes a reducer function and returns a reducer function.A reducer is a binary function that takes an accumulator and a value and returns an accumulator . A reducer can be executed with a reduce function ( note : all function are curried but I 've cat out ... | const reduce = ( reducer , init , data ) = > { let result = init ; for ( const item of data ) { result = reducer ( result , item ) ; } return result ; } const mapReducer = xf = > ( acc , item ) = > [ ... acc , xf ( item ) ] ; const map = ( xf , arr ) = > reduce ( mapReducer ( xf ) , [ ] , arr ) ; const filterReducer = ... | Is my understanding of transducers correct ? |
JS | Reading the `` recommended way '' of dealing with ENUM Type in Javascript , I am still uncertain because I can compare the value with a forged value , while I should compare only to a `` enum '' type value : The strings I made the switch to compare against ( `` monday '' , `` tuesday '' , `` blahblahday '' ) are totall... | var DaysEnum = { `` monday '' :1 , `` tuesday '' :2 , `` wednesday '' :3 , ... } Object.freeze ( DaysEnum ) switch ( day ) { case `` monday '' : return `` Hello '' case `` tuesday '' : return `` Hi '' case `` blahblahday '' : return `` No '' } | Is there a way to have/lock unique index values of the Enum object in Javascript ? |
JS | Here is my situation : I dynamically added 2 scripts throughThen I found they would be loaded in sequence instead of parallel from chrome console.However , they could be loaded in parallel if I use either native jsor jQuery function : getScript I searched a lot and found that jQuery actually will remove the script tag ... | $ ( 'body ' ) .append ( ' < script src= '' http : //localhost:8080/script_1.js '' > < /script > ' ) ; $ ( 'body ' ) .append ( ' < script src= '' http : //localhost:8080/script_2.js '' > < /script > ' ) ; document.body.appendChild ( script ) ; $ .getScript ( 'http : //localhost:8080/script_1.js ' ) ; $ ( 'body ' ) .appe... | How to use jQuery to handle dynamically added script tags in parallel |
JS | I am developing a JavaScript module , which knows nothing about the environment in which it will be used in.And , technically speaking , I want to implement the next function : element is an HTMLElement and the parent of this element may be unknown during the module initialization . callback is a function , which must ... | onceAppended ( element , callback ) ; function onceAppended ( element , callback ) { let el = element , listener ; while ( el.parentNode ) el = el.parentNode ; if ( el instanceof Document ) { callback ( ) ; return ; } if ( typeof MutationObserver === `` undefined '' ) { // use deprecated method element.addEventListener... | Having a reference to an element , how to detect once it appended to the document ? |
JS | I 'm running my test suite using mocha , via gulp-jsx-coverage and gulp-mocha . All my tests run and pass/fail as expected . However , some of my modules being tested make HTTP requests to my API via the superagent library . When in development , I 'm also running my API at localhost:3000 alongside my client-side app ,... | Error in plugin 'gulp-mocha'Message : connect ECONNREFUSEDDetails : code : ECONNREFUSED errno : ECONNREFUSED syscall : connect domainEmitter : [ object Object ] domain : [ object Object ] domainThrown : falseStack : Error : connect ECONNREFUSED at exports._errnoException ( util.js:746:11 ) at TCPConnectWrap.afterConnec... | Mocha test suite errorring out when attempting to connect to API |
JS | This was an interview question which I have n't yet been able to figure out . Consider the following : Now I was asked to write a function that will take n number of arguments and work the same way by logging the final summation of the argument values . Meaning : How can such a function be written ? I have tried thinki... | function recurse ( a ) { return function ( b ) { console.log ( a + b ) ; } } //This will log ' 5 ' in the consolerecurse ( 2 ) ( 3 ) ; //This should log '13'recurse ( 2 ) ( 3 ) ( 1 ) ( 7 ) | Recursion with dynamic arguments |
JS | I 'm trying to code this poem with nested divs and basic jQuery . My idea was to start with one div of class .active that has display : block and all the other divs being children of the first div with display : none . Now , when you click on the first div , it removes the class .active from itself ( adds to itself cla... | $ ( `` .active '' ) .click ( function ( ) { $ ( this ) .removeClass ( `` active '' ) .addClass ( `` static '' ) ; $ ( this ) .children ( `` div '' ) .addClass ( `` active '' ) } ) ; $ ( `` div '' ) .on ( `` click '' , `` .active '' , function ( ) { $ ( this ) .removeClass ( `` active '' ) .addClass ( `` static '' ) ; $... | jQuery : How can I use event delegation with classes added to nested divs ? |
JS | I have a table structured like this : So that structure repeats Y amount of times.I 'm trying to make a script that hides the tbody.variants of the row selected.What I have so far is this : but this hides the variants from ALL the rows.Is there a way to select the childs of the specific row ? Also how can I start with ... | < table > < tbody > for loop here < tr > < td > Item X Attribute 1 < /td > < td > Item X Attribute 2 < /td > < td > < button name= '' test '' onclick= '' display_variants ( ) '' > Hide my kids < /button > < /td > < /tr > < tr > < tbody class= '' variants_info '' > < tr > < td > Item X Variant 1 < /td > < td > Item X Va... | select child element jQuery |
JS | I have two circles that intersect and I want to make the intersecting area have a color , even when the two circles are transparent . I thought I could find some way to do this with css mix-blend-mode property but I have had no success with it . Of course , I could make the circles have color and decrease their opacity... | $ ( document ) .mousemove ( function ( e ) { $ ( '.cursor ' ) .eq ( 0 ) .css ( { left : e.pageX - 25 , top : e.pageY - 20 } ) ; // circles var c1 = $ ( '.cursor ' ) ; var c2 = $ ( '.circle ' ) ; // radius var d1 = c1.outerWidth ( true ) /2 ; var d2 = c2.outerWidth ( true ) /2 ; // centers of first circle var x1 = c1.of... | Fill in overlapping circle area |
JS | I 'm implementing the Inline Checkout from Bambora . The authorization step works without any problem . But when it comes to capturing the payment I always get the error Transaction not found.This is what I do : I also tried making the request with included transactionoperations : I get the same error when trying to ge... | const options = { headers : { Authorization : ` Basic $ { apiKey } ` } , } ; const { payload } = { amount } ; const { data } = await axios.post ( ` https : //transaction-v1.api-eu.bambora.com/transactions/ $ { txnid } /capture ` , payload , options ) ; const options = { headers : { Authorization : ` Basic $ { apiKey } ... | `` Transaction not found '' when Capturing payment transaction with Bambora |
JS | Trying to create a function mCreate ( ) that given a set a numbers returns a multidimensional array ( matrix ) : When this functions handles just 2 levels of depth ie : mCreate ( 2 , 2 ) // [ [ 0 , 0 ] , [ 0 , 0 ] ] I know to do 2 levels , you can use 2 nested for loops but the problem I 'm having is how to handle an n... | mCreate ( 2 , 2 , 2 ) // [ [ [ 0 , 0 ] , [ 0 , 0 ] ] , [ [ 0 , 0 ] , [ 0 , 0 ] ] ] BenLesh x 82,043 ops/sec ±2.56 % ( 83 runs sampled ) Phil-P x 205,852 ops/sec ±2.01 % ( 81 runs sampled ) Brian x 252,508 ops/sec ±1.17 % ( 89 runs sampled ) Rick-H x 287,988 ops/sec ±1.25 % ( 82 runs sampled ) Rodney-R x 97,930 ops/sec ... | Creating multidimensional arrays & matrices in Javascript |
JS | I 'm using React Native 's Image.getSize ( uri , ( width , height ) = > { } ) method to get the dimensions of a remote image and set it to a component 's state with setState ( ) : However , sometimes the component unmounts before the getSize ( ) request has returned , and this leads to the following error when setState... | componentDidMount ( ) { Image.getSize ( this.props.uri , ( width , height ) = > { this.setState ( { width , height } ) } ) } | How do I cancel an Image.getSize ( ) request in React Native ? |
JS | On Mandrill 's Template API page , I plug in the following JSON to test the Render method upon clicking `` Try it '' : The test results come back with my template but the one merge_var I 'm testing has not been merged , i.e . the result still contains { { invoice_number } } : Does Mandrill 's Render API ignore merge_va... | { `` key '' : `` MY VALID KEY '' , `` template_name '' : `` test1 '' , `` template_content '' : [ ] , `` merge_vars '' : [ { `` name '' : `` invoice_number '' , `` content '' : `` 1001 '' } ] } { `` html '' : `` < p style=\ '' font-family : sans-serif ; \ '' > Dear Customer , < /p > \r\n\r\n < p style=\ '' font-family ... | Does Mandrill 's Render API ignore merge_vars that map to Handlebars variables ? |
JS | I have normally learned that function implementation can have any name for function arguments as long as it is supplied in the right order . This makes the function abstracted from the outside world and the local names have no effect on the output . Implementer has all the rights for local variables . However in Angula... | function Controller ( $ scope ) { $ scope.name = `` Something '' ; } | Why does Angular Controller need `` $ scope '' |
JS | I have a jsTree which I am trying to bi-directionally `` connect '' to a Meteor collection . Right now I automatically trigger a jsTree.refresh ( ) whenever the collection updates with the help of .observeChanges : I want to allow editing of the database by dragging things around in jsTree . Here 's how it would look :... | FileTree.find ( ) .observeChanges ( { added : function ( ) { $ .jstree.reference ( ' # fileTree ' ) .refresh ( ) ; } , changed : function ( ) { $ .jstree.reference ( ' # fileTree ' ) .refresh ( ) ; } , removed : function ( ) { $ .jstree.reference ( ' # fileTree ' ) .refresh ( ) ; } } ) ; | Meteor avoid double refreshes when third party widget changes it 's own reactive datasource |
JS | I have a very simple component with a text field and a button : It takes a list as input and allows the user to cycle through the list . The component has the following code : This component works great , except I have not handled the case when the state changes . When the state changes , I would like to reset the curr... | import * as React from `` react '' ; import { Button } from `` @ material-ui/core '' ; interface Props { names : string [ ] } interface State { currentNameIndex : number } export class NameCarousel extends React.Component < Props , State > { constructor ( props : Props ) { super ( props ) ; this.state = { currentNameIn... | Which of these strategies is the best way to reset a component 's state when the props change |
JS | I came across this quirk while trying to optimise string pluralisation in a game of code golf . I had the idea to write strings as plurals and then use substr to cut the last character off , conditionally : It 's fine - it does what I wanted . But looking at the MDN docs for String.prototype.slice ( ) , I thought I had... | var counter = 1 ; var myText = counter + `` units '' .substr ( 0 , 6- ( counter===1 ) ) ; var myText = counter + `` units '' .slice ( 0 , - ( counter===1 ) ) ; | In String.prototype.slice ( ) , should .slice ( 0 , -0 ) and .slice ( 0 , +0 ) output the same result ? |
JS | Considering that you have this situation : The element .componentB has a directive called move-to which does simply move the contents of this element , collecting them with a jQuery children wildcard selector ( like var contents = $ ( '.componentB ' ) .find ( ' > * ' ) ; ) , when any of those breakpoints , defined on t... | < div class= '' site-frame '' > < div class= '' auxiliary '' > < /div > < div class= '' main '' ui-view > < div class= '' componentA '' > < /div > < div class= '' componentB '' move-to= '' .auxiliary '' breakpoints= '' 1,2,3,4 '' > < ! -- CONTENTS OF componentB -- > < /div > < div class= '' componentC '' > < /div > < /... | Is there scope issues if I move one element from one container to another ? |
JS | I 'm trying to build a regular expression that places a limit on the input length , but not all characters count equal in this length . I 'll put the rationale at the bottom of the question . As a simple example , let 's limit the maximum length to 12 and allow only a and b , but b counts for 3 characters.Allowed are :... | ^ ( a { 0,3 } |b ) { 0,4 } $ | Regex character count , but some count for three |
JS | On hovering over the first column in table , a tooltip appears , on click of the button dialog box opens up which has edit json sectionI have provided 2 functionalities : - [ Please select a row from left section in dialog box ] 1 ) The json can be edited ( In this scenario user clicks on row from left section , starts... | < form [ formGroup ] = '' jsonform '' > < json-input formControlName= '' json '' name= '' result '' > < /json-input > < /form > < form [ formGroup ] = '' submitJsonNameAndForm '' class= '' '' > < mat-form-field [ floatLabel ] = '' 'never ' '' class= '' alertinput '' > < input matInput trim type= '' text '' # alertnamef... | To update a formgroup formcontrol value from different formgroup but I do not to want to change the values permanently ( Angular ) |
JS | To double the width of the img , i can do this in jQuery : that works fine , but i really like to use shorthand assignments like : Since element.height returns the height function in jQuery , i ca n't use shorthand assignments . Is there no way to do shorthand assignments in jQuery for element attributes ? | < img src='blah.jpg ' id='pic ' / > $ ( ' # pic ' ) .height ( $ ( this ) .height ( ) *2 ) ; var count = 5 ; count *= 2 ; // to get 10 . | Using shorthand assignment in jQuery for element attributes |
JS | I am trying to edit/understand the source of a modal plugin written in ES6 , link HERE . I initialize the plugin like so : JS file ( main.js ) Now if I want to debug the source code of the plugin , I directly edit the index.js inside the /src folder , is this the right way to do it or should I use some build version wi... | < div aria-hidden= '' true '' class= '' modal micromodal-slide '' id= '' modal-1 '' > < div class= '' modal__overlay '' data-micromodal-close= '' '' tabindex= '' -1 '' > < div aria-labelledby= '' modal-1-title '' class= '' modal__container '' role= '' dialog '' > < header class= '' modal__header '' > < h2 class= '' mod... | How to debug the source of a modal plugin written in ES6 ? |
JS | Is there a better way to write the following function ? Having the ' # ' + div_id just looks wrong to me . | function hide_div ( div_id ) { $ ( ' # ' + div_id ) .hide ( ) ; } | is there an alternative to ' # ' + div_id ? |
JS | Consider the following ES6 Classes : My understanding is that both should be true , and in Firefox and Chrome they are , however Node says es instanceof ExtendString is false . It 's the same with other constructors , not just String.Software I used : Node v5.11.0 with the -- harmony flag.Chrome 50Firefox 45Which JavaS... | 'use strict ' ; class Dummy { } class ExtendDummy extends Dummy { constructor ( ... args ) { super ( ... args ) } } class ExtendString extends String { constructor ( ... args ) { super ( ... args ) } } const ed = new ExtendDummy ( 'dummy ' ) ; const es = new ExtendString ( 'string ' ) ; console.log ( ed instanceof Exte... | ES6 Class extending native type makes instanceof behave unexpectedly in some JavaScript engines ? |
JS | I have a popup that slides up into view when clicked . The way I 've made the header is with the following css : which I am adding/removing based on click using jQuery . But when the ellipsis class is removed , the header just `` POPS '' into view . So my question is : Is it possible to ease the transition from hidden ... | .ellipsis { white-space : nowrap ; overflow : hidden ; text-overflow : ellipsis ; -o-text-overflow : ellipsis ; } | make slideDown ( ) on header when overflow class is removed |
JS | The following checks an item code submitted through an input composed of 35 characters consisting of letters A-F and numbers 0-9 , as well as three dashes ( `` - '' ) . An example of a valid item code would be this : 16FA860F-E86A457B-A28A238B-2ACA6E3D The following works well , except for if an item code is 35 charact... | //Checks the item code to see if it meets requirementsif ( $ ( `` # input '' ) .val ( ) .length > 35 ) { $ ( `` # errorLogContent '' ) .prepend ( `` The item code < font color= ' # FFFFFF ' > '' + itemCode + `` < /font > is too long. < br > '' ) ; $ ( `` # ise '' ) .each ( function ( ) { this.reset ( ) ; } ) ; } else i... | Need to Pass a Condition If Length is Null |
JS | I am programming a page with a Map where I need to capture the location of the Tap/Click on a map and store the coordinates . I am using OpenLayers js . On desktop browsers ( IE/FF/Chrome ) , this is working fine . On mobile devices , the tap is getting captured correctly on the default Android browser ( both in real d... | OpenLayers.Control.ClickHandler = OpenLayers.Class ( OpenLayers.Control , { defaultHandlerOptions : { 'single ' : true , 'double ' : false , 'pixelTolerance ' : 0 , 'stopSingle ' : false , 'stopDouble ' : false } , initialize : function ( options ) { this.handlerOptions = OpenLayers.Util.extend ( { } , this.defaultHand... | OpenLayers latitude inaccurately captured in Webkit Mobile browsers |
JS | Firebase Functions onCall not workingI was recently following the Firebase tutorial series by The Net Ninja YouTube channel.The Net Ninja Firebase Function PlaylistFirebase Functions Tutorial # 5 - Callable FunctionsAnd I got stuck in the firebase functions part , first I was not even able to deploy them because billin... | { `` name '' : `` functions '' , `` description '' : `` Cloud Functions for Firebase '' , `` scripts '' : { `` lint '' : `` eslint . `` , `` serve '' : `` firebase emulators : start -- only functions '' , `` shell '' : `` firebase functions : shell '' , `` start '' : `` npm run shell '' , `` deploy '' : `` firebase dep... | Firebase Functions not able to use oncall functions in app , returns internal error |
JS | I have a problem with some javascript in Internet Explorer.It works fine in other browsers.I have the following method , that changes the src property of an images and when this happens a download of that image should start . See below : The problem is that in when changing this property Internet Explorer starts an end... | for ( var i = 0 ; i < imagesStartedDownloading.length ; i++ ) { if ( imagesStartedDownloading [ i ] == false & & responseItems [ i ] == true ) { console.log ( `` image '' , i ) ; var url = baseurl + `` /ImageDownload/ ? imageName= '' + hash + `` _ '' + imageDegrees [ i ] + `` .jpg '' + `` & r= '' + Math.random ( ) ; im... | Endless looping when src value is changed in Internet Explorer |
JS | This is my first question here , so please point out any of mistakes that I made . I was obliged to create a web page that looks like a flag of a team . I 've managed to do such , but only with fixed size of elements : On other resolutions it just does n't fit the screen.Code : htmlcssHere 's a jsfiddle of my flag : cl... | < div id= '' centered '' > < div id= '' triangle-down '' > < /div > < div id= '' triangle-right '' > < /div > < div id= '' triangle-left '' > < /div > < div id= '' triangle-up '' > < /div > < div id= '' diamond-narrow '' > < /div > < /div > # centered { position : relative ; clear : left ; height:766px ; width:1245 ; m... | Creating resizable website with lack of CSS skills - CSS shapes |
JS | I have been learning web application security penetration testing . The scenario is , there is a cross site scripting vulnerability in a test environment demo web application which is developed for practicing . I have a xss payload which is javascript expressions based : I know the expressions are deprecated since IE 8... | < div style= '' width : expression ( alert ( /XSS/ ) ) '' > < /div > < div > < /div > < div style= '' width : expression ' ( alert ( /XSS/ ) ) ' '' > | Alternative to define in-line javascript expressions |
JS | UPDATED WITH FULL CODEI 'm trying to dynamically add a div onto some other DIV 's stored in an array The array which contains DIV 's is named categoryData which contains an attribute with its category nameThe shop-row div 's ( categoryData ) is empty at the beginning.I 've got another array which contains the product o... | { CategoryName : categoryname , StoreObject : store_clearfix } // store_clearfix is another div var store_list = document.getElementsByClassName ( `` shop-list '' ) [ 0 ] ; if ( data [ 'stores ' ] ! =null & & data [ 'stores ' ] ! == typeof undefined ) { var numstores = Object.keys ( data [ `` stores '' ] ) .length ; va... | Javascript AppendChild Issue |
JS | DOM4 makes NodeLists iterable : According to WebIDL , this means Objects implementing an interface that is declared to be iterable support being iterated over to obtain a sequence of values . Note : In the ECMAScript language binding , an interface that is iterable will have “ entries ” , “ forEach ” , “ keys ” , “ val... | interface NodeList { getter Node ? item ( unsigned long index ) ; readonly attribute unsigned long length ; iterable < Node > ; } ; for ( var el of document.querySelectorAll ( selector ) ) ... for ( var el of document.getElementsByTagName ( tag ) ) ... HTMLCollection.prototype [ Symbol.iterator ] === [ ] [ Symbol.itera... | Can HTMLCollections be iterated with for ... of ( Symbol.iterator ) ? |
JS | For example : When i invoke this example ( ) function , I get an error that b is undefined , but when I remove the 2nd line that invokes with function b defined inside the if block It 's all ok ? | function example ( ) { console.log ( `` outside the if block above function b declaration '' +b ( ) ) ; function a ( ) { return `` you invoked function a '' ; } if ( true ) { console.log ( `` inside the if block '' +a ( ) ) ; console.log ( `` inside the if block above function b declaration '' +b ( ) ) ; function b ( )... | Does if block create a new local scope inside a function scope ? |
JS | I am using SugarCRM 6.5.x CE version . I want to make a dependent functionality where I have a dropdown field with list of email template name . And according to the selection of email template , textarea should be filled with email template body text . So , I have achieved the result.Now , instead of normal textarea ,... | function display_text ( ) { if ( typeof ( document.getElementsByName ( 'email_template_c ' ) [ 0 ] .value ) ! = `` undefined '' ) { var custom_data = document.getElementsByName ( 'email_template_c ' ) [ 0 ] .value ; if ( custom_data ! = `` ) { $ .ajax ( { url : 'index.php ? entryPoint=check_email_template_subject ' , d... | How to create dependent tinymce textarea according to the selection of email template name ? |
JS | I seem to be observing at least one case where a callback function passed to a jQuery effect function will execute repeatedly if there 's an error while it 's executing.For example , see this JS Fiddle , featuring the following code : log appends whatever 's passed to it to a div ... but dieInAFire does n't exist . Rat... | $ ( ' # awesome ' ) .fadeOut ( 400 , function ( ) { log ( 'fading out ... ' ) ; dieInAFire ( ) ; } ) ; | jQuery callbacks apparently repeat on failure ? |
JS | I had an idea to store code as lists ( arrays ) in Node and execute them , but this is harder than I thought : if I make a list with a function in the beginning or in the end , .pop or .shift removes but omits it and returns the next element : I noticed this in Node v0.4.9 , but it is still present in 0.6.10.Is there a... | > l = [ 1 , 75 , 84 , function ( ) { console.log ( 'aseuht ' ) } ] [ 1 , 75 , 84 , [ Function ] ] > l.pop ( ) 84 > l [ 1 , 75 ] | Array.pop in Node skips and forgets a function item |
JS | In my project I want to fix a div element to a certain position on the screen . Not the window , the screen . So if the browser is resized the div stays put and if the browser is moved the div stays put . Possible ? Here is my basic html page that contains just a dot at the center of the screen.I know I can use window.... | # dot { width : 8px ; height : 8px ; -webkit-border-radius : 4px ; -moz-border-radius : 4px ; border-radius : 4px ; background : # 000 ; position : relative ; left : -4px ; top : -4px ; } < div style= '' position : absolute ; top : 50 % ; left : 50 % ; '' > < div id= '' dot '' > < /div > < /div > | Fix div to screen |
JS | According to specifications , Node JS ( ES5 ) should use current dts rules when working with Date objects . Current means `` for now '' , not for a particular date . That 's not perfect , but enough for me at this moment.Currently that rules are wrong ( due to law changes in Chile ) . Simple probe : shows `` ( Chile Su... | console.log ( new Date ( ) ) Mon Apr 08 2019 12:48:08 GMT-0300 ( Chile Summer Time ) { } | Node JS current DST rules for Chile |
JS | I 'm developing an app that uses a certain site to make payments easier , and the way it handles payments requires to import some javascript from this url https : //bridge.paymill.com/ that contains the script.The fact is , I 'm using require js to load all the scripts , in my main.js configuration , I 'm trying to mak... | requirejs.config ( { ... 'paymill ' : 'https : //bridge.paymill.com/ ' , ... } ) ; | How do I make Require.js fetch a script that does not end in ` .js ` ? |
JS | In my spelling game new words will be added all the time so there is always a fresh selection of words to spell.Each word added to the game has a `` src '' to an image and a sound that will prompts the user into getting the spelling correct in gameplay.When I have completed making the game , the job of adding the new w... | < ul style= '' display : none ; '' id= '' wordlist '' > < li data-word= '' mum '' data-audio= '' file : ///C : /smilburn/AudioClips/mum.wav '' data-pic= '' http : //www.clker.com/cliparts/5/e/7/f/1195445022768793934Gerald_G_Lady_Face_Cartoon_1.svg.med.png '' > < /li > < li data-word= '' cat '' data-audio= '' file : ///... | Adding new words to the game |
JS | I am trying to upload a file in an electron app which works perfectly for electron v9.3.0 but as soon as I use electron v10.1.1 , it gives the following errorUncaught TypeError : Can not read property 'dialog ' of undefined at this line const dialog = electron.remote.dialog ; see the screenshot below.The content of mai... | const { app , BrowserWindow } = require ( 'electron ' ) function createWindow ( ) { // Create the browser window . const win = new BrowserWindow ( { width : 800 , height : 600 , webPreferences : { nodeIntegration : true } } ) // Load the index.html of the app . win.loadFile ( 'src/index.html ' ) // Open the DevTools . ... | electron v10.1.1 gives Uncaught TypeError : Can not read property 'dialog ' of undefined , but same code works in electron v9.3.0 |
JS | I am using the YouTube API and I 'm using Python urllib2.urlopen ( ) to send a GET request . Then I pass the result to Javascript . ( I 'm using Django ) So , something like this : I 'm using jQuery to parse the JSON formatted response , however some YouTube videos/descriptions have double quotes and this breaks the pa... | result = urllib2.urlopen ( 'https : //gdata.youtube.com/feeds/api/videos ? '+query+ ' & max-results=1 & alt=json ' ) | Ca n't figure out a way to escape quotes in json in YouTube API |
JS | I just developed a little code to create a 24x60 table . I want to print the id of each < td > on mouseover : The code works , but now I 'm concerned if it is optimized ? Am I creating 1440 event handling functions in the nested loops ? Or is the JavaScript interpreter smart enough to only create one function and assig... | < ! DOCTYPE html PUBLIC `` -//W3C//DTD XHTML 1.0 Transitional//EN '' `` http : //www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd '' > < html xmlns= '' http : //www.w3.org/1999/xhtml '' > < head > < meta http-equiv= '' Content-Type '' content= '' text/html ; charset=utf-8 '' / > < title > Untitled Document < /title > <... | Efficiency of creating an event handler in a nested loop : am I creating 1440 functions here ? |
JS | Question : in firefox- > console it shows : ( an empty string ) , why ? | < style > body { margin : 10px } < /style > < body > < script > console.log ( document.body.style.marginTop ) ; < /script > < /body > | got ( an empty string ) when trying to get marginTop value in js |
JS | I have the problem with update chart js in angular . I am using for it ngrx store.In selector subscriber ( run in ngOnInit ) I tried update the chart data : And my chart data : Register charts : And I call it in constructor.I know , that I need run chart.update ( ) . But still I have got an error about chart is undefin... | this.yrSubscription = this.userDataStore.pipe ( select ( selectYrReport ) ) .subscribe ( el = > { el.sessions.forEach ( item = > { this.datasetsSessions [ 0 ] .data.push ( +item ) ; } ) ; } ) ; datasetsSessions : ChartDataSets [ ] = [ { label : 'Sessions ' , data : [ ] , fill : false } ] ; private _registerCustomChartJ... | Update charts in chartjs and angular |
JS | I have been messing around with the Google 's JavaScript code and I saw in their code that they define array in different way.What 's so unique in writing array like that ? why is the `` ( ) '' in that code , it could be fine either like that : is it have purpose ? Thank you in advance . | var arr = ( [ ' b ' , ' f ' , 's ' ] ) ; var arr = [ ' b ' , ' f ' , 's ' ] ; | JavaScript : define array in different way |
JS | I have a webview that opens from a messenger bot.From the webview I want to send image data to the conversation ( no URL - data coming from the canvas ) .I tried to use Messenger SDK beginShareFlow with file data attachment : But I get an error : Would appreciate help = ] EDIT : I found out that filedata is used to tra... | function uploadImage ( data ) { let message = { `` attachment '' : { `` type '' : `` image '' , `` payload '' : { `` is_reusable '' : true } , `` filedata '' : data } } ; MessengerExtensions.beginShareFlow ( function ( share_response ) { // User dismissed without error if ( share_response.is_sent ) { // The user actual... | Use Messenger SDK to send file data |
JS | I am binding a single click event to a large container using jquery ( event delegation ) .I have many different items within that container that are clickable.The problem I am dealing with is that if I have 20 clickable items , I need to do a if else block x 20 in the container on click handler . Is there a way to make... | attachClickEvent : function ( ) { $ ( `` .container '' ) .click ( $ .proxy ( this.handleOnClick , this ) ) ; } , handleOnClick : function ( event ) { var $ target = $ ( event.target ) ; if ( $ target.closest ( `` .widget1 '' ) .length > 0 ) { //handle widget 1 interaction } else if ( $ target.closest ( `` .widget2 '' )... | JavaScript Event Delegation code organization |
JS | I 'm reading the article about functions on the MDN , and I reached the Recursive part but I do n't understand the last part that talks about using the stack-like behavior.The example is that one : On that function , I understand when the begin log is shown but I do n't when the end log is shown . Can someone help me a... | function foo ( i ) { if ( i < 0 ) return ; console.log ( 'begin : ' + i ) ; foo ( i - 1 ) ; console.log ( 'end : ' + i ) ; } foo ( 3 ) ; // Output : // begin:3// begin:2// begin:1// begin:0// end:0// end:1// end:2// end:3 | Trying to understand the stack-like behaviour on recursive functions |
JS | Say I have a sequence of items and I want to perform a reduce operation via myReducer function ( whatever it is ) . If my items are in an array ( say myArray ) , it 's easy : What if , however , my sequence is quite large and I do n't want to allocate an array of all of it , only to immediately reduce it item after ite... | myArray.reduce ( myReducer ) ; | Reduce a sequence of items provided by a generator in JavaScript |
JS | I have the following components : WHen I call network.current.filter ( [ ... ] ) , it will set the filterNodes state . Also , it should set the filterNodesRef inside the useEffect.However , the filterNodesRef.current remains to be empty array.But when I call network.current.filter ( [ ... ] ) the second time , only the... | const ParentComponent : React.FC = ( ) = > { const networkRef : any = useRef ( ) ; // Somewhere in the code , I call this networkRef.current.filter ( [ `` id0 , id1 , id2 '' ] ) ; return ( ... < VisNetwork ref= { networkRef } / > ... ) } export default ParentComponent ; interface Props { ref : any ; } const VisNetwork ... | useRef current getting its value only on second update |
JS | When binding to a click event for a checkbox input , the checkbox is already toggled by the time my event handler runs and , more oddly , the toggle is reversed after my event handler runs if I specify event.preventDefault ( ) ; [ tested in chrome and firefox ] JSFiddle for that codeThe alert will respond `` true '' ( ... | < input id= '' foo '' type= '' checkbox '' / > function clicked ( evt ) { alert ( document.getElementById ( 'foo ' ) .checked ) ; evt.preventDefault ( ) ; } document.getElementById ( 'foo ' ) .addEventListener ( 'click ' , clicked ) ; | Is this a core misunderstanding of the default click event on checkbox inputs , or flawed code ? |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.