lang stringclasses 4
values | desc stringlengths 2 8.98k | code stringlengths 7 36.2k | title stringlengths 12 162 |
|---|---|---|---|
JS | I 'm working with a shopping cart product that puts out some rather old fashioned HTML . Since it 's dynamically generated by the cart , PDG Commerce , I do n't have control of the HTML tag structure.Here 's a sample : As shown above it outputs the radio buttons with text next to them , which is not in a label element ... | < p class='ups_address_suggest ' > < input type= '' radio '' name= '' addrvalselect '' value= '' 3 '' onclick= '' setaddr2 ( ) ; '' > DULUTH , MN & nbsp ; & nbsp ; 55810 < input type= '' radio '' name= '' addrvalselect '' value= '' 4 '' onclick= '' setaddr3 ( ) ; '' > DULUTH , MN & nbsp ; & nbsp ; 55811 < input type= '... | What 's the best way to fix this radio button HTML ? |
JS | I have built out an Angular directive to display a D3 visualization . I make use of $ filter within the tickFormat function on my y-axis like so : The problem I 'm seeing is that none of these tick labels appear when the page first loads . Indeed if I console.log ( $ filter ( 'formatSalesValue ' ) ( d.value , 'USD ' ) ... | ySalesAxis = d3.svg.axis ( ) .orient ( 'left ' ) .ticks ( 6 ) .scale ( ySalesScale ) .tickFormat ( function ( d ) { return $ filter ( 'formatSalesValue ' ) ( d.value , 'USD ' ) ; } ) ; | Using $ filter in Angular directive |
JS | I am using algolia javascript api for retrieving all records in my index using browse function , but still it is returning 1000 records . Here is my code : } | function load_location_list ( ) { var client = algoliasearch ( 'ID ' , 'KEY ' ) ; var index_name = `` locations_new '' ; var attribute_list = `` * '' ; var index = client.initIndex ( index_name ) ; index.browse ( { `` attributesToRetrieve '' : attribute_list , } ) .then ( function search_Success ( response ) { console.... | Algolia browse function returning max 1000 records using Javascript |
JS | I 'm trying to get started with JSIL . I 've followed the directions as far as I understand . I have a very basic C # dummy project with the code : I 've compiled this with jsilc , and created a website that hosts this along with the jsil scripts . My html initializes this : but ... I ca n't access the library . The co... | namespace TestLib { public class MagicType { public int Multiply ( int x , int y ) { // test instance method return x * y ; } public static int Add ( int x , int y ) { // test static int method return x + y ; } } } < script type= '' text/javascript '' > var jsilConfig = { libraryRoot : '/js/jsil/ ' , scriptRoot : '/js/... | How to access a basic JSIL library ( from C # ) in a web page ? |
JS | I have started writing a node application and I want to store the request and response objects In a hashtable . For the hashtable I am using jshashtable . When I store the request and response objects in the hashtable and fetch them later , I get a Object.keys called on non-object error when trying to use response , wh... | var Hashtable = require ( 'jshashtable ' ) ; var crypto = require ( 'crypto ' ) ; var table = new Hashtable ( ) ; var http = require ( 'http ' ) ; var fs = require ( `` fs '' ) ; var home = fs.readFileSync ( '/some/random/html/home.html ' ) ; http.createServer ( function ( req , res ) { crypto.randomBytes ( 8 , functio... | Can I store a response object In a hashtable ? |
JS | I 'm learning Ramda and try to reach pointfree programming . In order to do that , I try to refactor here and there but got stuck on this.I obviously think this does n't work because the call is asychronous but I could not find what is wrong with this code . | // Why is thisconst toJSONRamda = R.pipe ( R.prop ( 'json ' ) , // getting the 'json ' function R.call // and calling it ) // different from thisconst toJSON = response = > response.json ( ) // Worksfetch ( 'https : //jsonplaceholder.typicode.com/todos/1 ' ) .then ( toJSON ) .then ( console.log ) // Does not Workfetch ... | using the fetch api with ramda |
JS | A new execution context is created for each function in JavaScript.How many execution contexts are present in memory when the following code is run ? Note that function Bar is not invoked.Also , when are the execution contexts created ? At evaluation time or runtime ? | function Foo ( ) { function Bar ( ) { } } Foo ( ) ; | Execution contexts in JavaScript |
JS | I am very new to Jquery so please excuse this noobie question . I am trying to swap a background image of an < h1 > element when a user clicks on the corresponding hyperlink . The < a > tags are generated dynamically and there can be ' n ' quantity of them at any time depending on how many images are set in a SQL table... | < div id= '' feature-image '' > < h1 > < span > A random heading < /span > < /h1 > < /div > < div id= '' feature-links '' > < a class= '' a1 '' href= '' # '' > 1 < /a > < a class= '' a2 '' href= '' # '' > 2 < /a > < a class= '' a3 '' href= '' # '' > 3 < /a > < /div > < script > $ ( function ( ) { $ ( ' # feature-links ... | Image swapping with Jquery |
JS | I was rambling with JavaScript code in my application today when I observed something strange.Any idea what 's happening ? | var someVar = 25 ; var anotherVar = 50 ; var out = ( anotherVar == 50 & & someVar ) ; console.log ( out ) // outputs 25 and not true or false ; | Why is Javascript giving result as Number instead of True/False for expression ? |
JS | I have an < input type= '' checkbox '' > tag inside of a < summary > inside a < details > , which unfortunately toggles the < details > to open or close when it is checked or unchecked , not unlike this question concerning space toggling details , but unfortunately ca n't be fixed with the same method for me in my vers... | $ ( 'input ' ) .change ( function ( e ) { e.stopPropagation ( ) ; e.preventDefault ( ) ; return false ; } ) ; < script src= '' https : //cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js '' > < /script > < details > < summary > < input type= '' checkbox '' > < /summary > < div > Lorem ipsum dolor sit amet , con... | Prevent input checkbox from toggling < details > |
JS | Could someone please explain the following ? | [ ] instanceof Array ; // true '' instanceof String ; // false | Instanceof inconsistency |
JS | I have the following : http : //jsfiddle.net/4QF4C/14/Why does the red square hide behind the black line during the animation and then show after it 's done ? How can I fix this ? HTML : CSS : JQuery : Please help ! | < div class= '' container '' > < div class= '' content '' > < div class= '' box-static '' > This is a static box that is n't effected by JQuery . < div class= '' dot '' > < /div > < /div > < div class= '' box '' > This is just some text . < div class= '' dot '' > < /div > < /div > < a href= '' # '' > Click Me ! < /a > ... | Blind hides div during animation |
JS | I have this simple test in nodejs , I left it running overnight and could not get Math.random ( ) to repeat . I realize that sooner or later the values ( or even the whole sequence ) will repeat , but is there any reasonable expectancy as to when it is going to happen ? | let v = { } ; for ( let i = 0 ; ; i++ ) { let r = Math.random ( ) ; if ( r in v ) break ; v [ r ] = r ; } console.log ( i ) ; | When does Math.random ( ) start repeating ? |
JS | Can we detect whether a browser supports dropping a file over an < input type= '' file '' / > ? For example , this is possible in Chrome but not in IE8.Modernizr.draganddrop is a possibility but is it the right choice ? I 'm not adding any custom drag/drop event handlers.UpdateTo verify Joe 's answer here 's a jQuery e... | $ yourFileInput.on ( 'drop ' , function ( ) { return false ; // if Joe 's explanation was right , file will not be dropped } ) ; | Feature detection for ability to drop file over HTML file input |
JS | I 'm building a webapp which falls back on a < noscript > tag if Javascript is disabled . I 'd like to validate that that tag shows , but I 'm unsure how to do that with any of the frameworks I have , or any framework in general.The app in question by default shows the following when Javascript is disabled : The app re... | < div > < noscript > < h1 > Javascript Disabled < /h1 > Use this page to show content when Javascript has been disabled < /noscript > < /div > < div > Hello World < /div > | How to write automated tests for the < noscript > tag ? |
JS | I 've made a script that re-sizes my website with some ratio : 'rat ' . I do a scale but that scale creates white margins so I transform the entire html page and I sent it to origin in the coordinates 0 , 0.The problem I have is that some background images with the following property do not transform : Everytime I tran... | document.documentElement.style.transform = `` scale ( `` + rat + `` ) '' ; document.documentElement.style.width = 100 / rat + `` % '' ; document.documentElement.style.transformOrigin = ' 0 0 ' ; background-attachment : fixed ; | Use a CSS transformation on an entire page including fixed backgrounds ( in Firefox ) |
JS | I have a function , matchTagAndText which as the name says accepts 2 arguments a selector and text and checks if any of the matched elements has the given text . It goes like so : Now I am trying to select a td element which contains text 'Lorem ipsum ' in it but I am unable to do so . My HTML : I tried calling the fun... | function matchTagAndText ( sel , txt ) { var elements = document.querySelectorAll ( sel ) ; return Array.prototype.filter.call ( elements , function ( element ) { return RegExp ( txt , ' i ' ) .test ( element.textContent ) ; } ) ; } < ! DOCTYPE html > < html lang= '' en '' > < head > < meta charset= '' UTF-8 '' > < tit... | Why is my function unable to return elements with specific text content ? |
JS | Bear with me on this.tl ; dr My code only works when I put newlines between function arguments . Is there a maximum on stack size or function declarations per line in javascript ? I 've been testing a hypothesis of mine that if you 're creative enough , all javascript functions can be re-written ( by sacrificing speed ... | function ( ... ) { ( function ( add , morefuncs ... ) { algorithm ... } ) ( function ( ) { ... } , morefuncs ... ) } //For some reason , this breaks : func ( arguments , ... , f1 , f2 ) //And this does n't : func ( arguments , ... , f1 , f2 ) ( function ( ) { return ( function ( domath ) { return ( domath ) ( function ... | Javascript bug ? Maximum stack of anonymous functions per line |
JS | I implemented an autocomplete search box on my asp.net mvc4 site . I am currently able to have the box return results that update as i type in the search box . I also am dynamically generating `` category '' buttons based on the result `` type IDs '' and inserting them in a header that appears when the autocomplete pro... | @ model myproject.Models.Search_Term @ Scripts.Render ( `` ~/bundles/jquery '' ) < script type= '' text/javascript '' > //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // autopopulate input boxes ///////////////////////////////////////////////////////... | How to use button within autocomplete dropdown to further filter the already-displayed results |
JS | I have a rather difficult issue I 'm stuck on I would appreciate some insight to if this is even possible with CSS . I have 6 divs , 1-3 need to be in a left column , and 4-6 in a right column . When you click any of the divs , they hide using jquery hide ( ) . The part I am finding difficult is when you remove one div... | < div id= '' container '' > < div class= '' child '' > 1 < /div > < div class= '' child '' > 2 < /div > < div class= '' child '' > 3 < /div > < div class= '' child '' > 4 < /div > < div class= '' child '' > 5 < /div > < div class= '' child '' > 6 < /div > < /div > | css & javascript alignment issue . Is this even possible in css ? |
JS | I 'm pretty new to WordPress , but basically what I 'm trying to achieve is to make a tag 's description a required field on my custom theme for WordPress 4.5.2I 've tried three approaches , but all of them failed so if anyone WordPress expert out there could guide me would be nice.Approach # 1functions.phpI 've tried ... | function require_category_description ( ) { require_once ( 'includes/require_category_description.php ' ) ; } add_action ( 'edit_tag_form_fields ' , 'require_category_description ' ) ; add_action ( 'add_tag_form ' , 'require_category_description ' ) ; < script > jQuery ( document ) .ready ( function ( ) { var descripti... | How to make a tag description required |
JS | Okay , my first attempt at trying to explain what I was doing failed miserably . I 'm basically copying Crockford 's Object.create ( ) , except with private variables.If you look at the accepted answer here How to inherit from a class in javascript ? , you will see Object.create as the last pattern , which I think bett... | Function.prototype.from = function ( obj ) { function F ( ) { this.parent = Object ( obj ) ; } F.prototype = obj ; var out = new F ( ) ; this.apply ( out ) ; return out ; } ; // Create an objectvar a = function ( ) { var private_property = 'blue ' ; this.public_property = 7 ; this.public_method = function ( ) { alert (... | Javascript inheritance idea ( part 2 ) |
JS | Please Help me to scroll fixed list item using iscroll . i am working on a project in which i want to scroll three LIST Item on one time scroll using iscroller . I allready tryed to scroll with scrollTo , ScrollToPage , ScrollToElement function of iscroller but it did n't work for me so please help me to scroll the fix... | < ! DOCTYPE html PUBLIC `` -//W3C//DTD XHTML 1.0 Transitional//EN '' `` http : //www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd '' > < html > < head > < style > .span8 { position : absolute ; width:630px ; height:100px ; overflow : auto ; } .menu { float : left ; width:200px ; height:100px ; background-color : red ; ... | Can We Scroll fixed 3 List item item on one time scroll using iscroller |
JS | Since I am a JavaScript newbie , I started learning it but I got stuck just at the beginning.I am following a Mozilla Tutorial and I have a problem with variable scope in JavaScript . I have some code : In the tutorial , I 've read that JavaScript variables are not visible from function blocks . Well , first two alerts... | var myvar = `` my value '' ; var zmienna = `` string '' ; ( function ( ) { alert ( myvar ) ; alert ( zmienna ) ; } ) ( ) ; ( function ( ) { alert ( myvar ) ; // undefined var myvar = `` local value '' ; alert ( zmienna ) ; } ) ( ) ; | Variable scope problem |
JS | Trying to make a make generic select `` control '' that I can dynamically add elements to , but I am having trouble getting functions to work right.This is what I started with.This worked fine alone but anytime $ select is .clone ( true ) 'ed the addOption ( ) function is lost . This is my object approach but still the... | $ select = $ ( `` < select > < /select > '' ) ; $ select.addOption = function ( value , text ) { $ ( this ) .append ( $ ( `` < option > < /option > '' ) .val ( value ) .text ( text ) ) ; } ; function $ selectX ( ) { return $ ( `` < select > < /select > '' ) ; } $ selectX.prototype.addOption ( ) = function ( value , tex... | jQuery & Objects , trying to make a lightweight widget |
JS | I 'm building a Bittorrent client using Node.js and am failing at getting answer from peers over the PWP metadata extension ( BEP 0009 ) I get peers from the DHT ( BEP 0005 ) ( where i announce ) , then send Handshake and Extended Handshake over PWP using a net Socket.From here , i get Handshakes and extended Hanshakes... | buildHandshake = ( torrent , ext ) = > { // torrent contains mainly infoHash const buf = Buffer.alloc ( 68 ) buf.writeUInt8 ( 19 , 0 ) buf.write ( 'BitTorrent protocol ' , 1 ) if ( ext ) { const big = new Uint64BE ( 1048576 ) big.toBuffer ( ) .copy ( buf , 20 ) } else { buf.writeUInt32BE ( 0 , 20 ) buf.writeUInt32BE ( ... | How to get responses to ut_metadata piece request ? ( node.js Bit Torrent BEP 0009 ) |
JS | On my free time , I was just playing with js console , I got an unexpected error : I tried with === : Am thinking wrong here ? I tested this with Firefox , Chrome and jscore . | js > [ ] == { } falsejs > { } == [ ] typein:5 : SyntaxError : syntax error : js > [ ] === { } falsejs > { } === [ ] typein:9 : SyntaxError : syntax error : | Why does comparing { } and [ ] show an error ? |
JS | I 'm using JavaScript to make a game , and I have created one asteroid that moves vertically and picks a random x position.How can I create multiple asteroids that pick random starting points ? Below is what I currently have for the asteroid : | //create asteroidasteroid= { x : width/2 , y : -6 , min:1.6 , max:2.2 , speed:1.6 } // move asteroidif ( asteroid.y < height ) { asteroid.y+=asteroid.speed ; } else { asteroid.y=-6 ; asteroid.x=Math.random ( ) * ( width-0 ) -0 ; } //draw asteroidctx.beginPath ( ) ; ctx.fillStyle = `` # D9BA5F '' ; ctx.arc ( asteroid.x ... | How can I make multiple asteroids , after making the code for one ? |
JS | I 'm trying to use a GET request to retrieve an image from a server . The image is constantly changing , so I want to grab the image a few times every second ( with the intent of displaying the images and imitating video eventually ) . However , there 's something going wrong with the GET request . No matter how rapidl... | Example Request Headers : Cache-Control : no-cache Connection : keep-alive < -- Could this be the problem ? Pragma : no-cacheExample Response Headers : Cache-Control : no-cache Cache-Control : no-store Connection : close Pragma : no-cache Server : Apache-Coyote/1.1 document.getElementById ( `` videoDisplay '' ) .src = ... | Browser GET request returning old images |
JS | In other words , phpandis equivalent to , js : andI am curious , or is my php and js understanding messed up ? | $ object- > method ( ) ; $ object- > property = 'someValue ' ; $ object.method ( ) ; $ object.property = 'someValue ' ; | is `` - > '' in php similar ( a.k.a equivalent ) to `` . '' in javascript ? |
JS | We 've got our own scripting language that we use . The language is quite simple , but it has one 'exclusive ' thing : strings are defined using ' [ ' and ' ] ' ( so `` test '' would be [ test ] ) , and these braces can be inside each other : Also , there 's no escaping character.How does one parse this block as one st... | lateinit ( [ concat ( [ test ] , [ blah ] ) ] ) { token : 'punctuation.definition.string.begin.vcl ' , regex : '\\ [ ' , push : [ { token : 'punctuation.definition.string.end.vcl ' , regex : '\\ ] ' , next : 'pop ' } , { defaultToken : 'string.quoted.other.vcl ' } ] , } , setexpratt ( 1 , [ if ( comparetext ( [ yes ] ,... | Recursive blocks in Ace editor |
JS | While reading docs , I have found an simple optimization that greatly improves javascript performance.Original code : Optimized code : Found here : https : //github.com/felixge/faster-than-c Why does it run 20 % faster ? I believe that it removes the for statement , but does n't the forEach have the same computational ... | function parseRow ( columns , parser ) { var row = { } ; for ( var i = 0 ; i < columns.length ; i++ ) { row [ columns [ i ] .name ] = parser.readColumnValue ( ) ; } } var code = 'return { \n ' ; columns.forEach ( function ( column ) { code += ' '' ' + column.name + ' '' : ' + 'parser.readColumnValue ( ) , \n ' ; } ) ; ... | Javascript optimization with ` new Function ( ) ` |
JS | I am wondering to see if there is a way to destructure objects in javascript with using a variable . Where as I was doing something like this in my function - This was working fine , however I need to expand this function based off another factor that can change if I need to use data.content ( which it is using now ) o... | mutateTaxon ( data ) { const { content } = data ; const { plp } = content || { } ; ... mutateTaxon ( data ) { const match = lowerCase ( data.taxonomy.name ) ; const { match } = data ; const { plp } = match || { } ; const { [ [ match ] ] } = data ; | Javascript ( ES6 ) , destructure based off variable |
JS | There seems to be a mismatch between the common understanding of == and what it actually does . To give some background for the issue : Seemingly , both Number and String are of object type . No surprise there . However things get interesting for == which should return true when operands are equal regardless of their t... | typeof new Number ( 1 ) ; // returns objecttypeof new String ( 1 ) ; // returns objecttypeof 1 ; // returns number var numa = new Number ( 1 ) ; var numb = new Number ( 1 ) ; var stri = new String ( 1 ) ; numa.toString ( ) == stri.toString ( ) ; // returns true , as expectednuma.valueOf ( ) == stri.valueOf ( ) ; // ret... | What is the standard definition of object equality for `` == '' ? |
JS | I 'm trying to understand the difference between foo.bar ( ) and var fn = foo.bar ; fn ( ) ; I 've put together a little example , but I dont totally understand why the failing ones actually fail.Which produces : ArfArfundefinedArfundefinedOn JSFiddle : http : //jsfiddle.net/D6Vdg/1/So it appears that snapping off a fu... | var Dog = function ( ) { this.bark = `` Arf '' ; } ; Dog.prototype.woof = function ( ) { $ ( 'ul ' ) .append ( ' < li > '+ this.bark + ' < /li > ' ) ; } ; var dog = new Dog ( ) ; // works , obviouslydog.woof ( ) ; // works ( dog.woof ) ( ) ; // FAILSvar fnWoof = dog.woof ; fnWoof ( ) ; // workssetTimeout ( function ( )... | Understanding Javascript 's difference between calling a function , and returning the function but executing it later |
JS | I have a file that has key/value pairs . This file is loaded inside the process.env via Docker . But for the development purposes I am loading it manually , so at the end they are identical ; The configuration : My expectation is to have this object : I have come up with solution that works ok , but i am having problem... | process.env [ 'ccc.logger.winston.level ' ] ='info ' ; process.env [ 'ccc.logger.winston.transports.type.file ' ] ='File ' ; process.env [ 'ccc.logger.winston.transports.filename ' ] ='logs/testOne.log ' ; process.env [ 'ccc.logger.winston.transports.rotate ' ] ='false ' ; process.env [ 'ccc.logger.winston.transports.t... | Creating complex object from key/value pairs |
JS | I have a ES6-style function that is defined using function composition with asyncPipe.As you can see I tried adding a JSDoc description to it . But when I use it anywhere my editor , VSCode , does n't suggest its parameters . How do you declare these kinds of functions with JSDoc ? And how do I get params for this func... | import { getItemAsync } from 'expo-secure-store ' ; const asyncPipe = ( ... fns ) = > x = > fns.reduce ( async ( y , f ) = > f ( await y ) , x ) ; const getToken = ( ) = > getItemAsync ( 'token ' ) ; const liftedGetToken = async ( { ... rest } ) = > ( { token : await getToken ( ) , ... rest , } ) ; const liftedFetch = ... | How to generate JSDoc for ` pipe ` d ES6 function |
JS | I have never used SOAP before ( and still would n't have if not needed ) but I need to make an input search to list info ( with the help of php or javascript ) from a web service using SOAP and I have this Query , the XML Service Deschiption and the method address : And this method prototype : ... and I basically do n'... | { AdresaInterfata } ? op= CautareDosare [ WebMethod ( Description = `` Cautare dosare dupa numar , obiect , institutie '' ) ] public Dosar [ ] CautareDosare ( string numarDosar , string obiectDosar , string numeParte , Institutie ? institutie , DateTime ? dataStart , DateTime ? dataStop ) | Use PHP to list info from a Web Service that 's using SOAP |
JS | I have some menu with structure like this : It need to show only first level ul li , its ok , but then it needs to show by on click second level links . And i cant usw id or rel attr in ul or li - this is my problem to catch child .My code is like : And it works but e.preventDefault ( ) is blocking all links in menu ( ... | < ul id= '' menu '' > < li > < a href= '' # '' > < span > First level link 1 < /span > < /a > < ul > < li > < a href= '' # '' > < span > Child link 1 < /span > < /a > < /li > < li > < a href= '' # '' > < span > Child link 2 < /span > < /a > < /li > < /ul > < /li > < li > < a href= '' # '' > < span > First level link 2 ... | Get child < ul > in < ul > list without id and with e.preventDefault ( ) on first level of < ul > < li > < a > |
JS | There 's a strange behavior on touch devices regarding the clickable area of a link , if you toggle the height of an element placed above . If you run the following snippet ( e.g . save it locally and use chrome to emulate touch events ) , you will notice that the hash # mylink is added to the url in some cases you did... | < html > < head > < style type= '' text/css '' > .test { background : grey ; height : 200px ; } .test.is-visible { height : 400px ; } .link { height : 600px ; display : block ; background : red ; } < /style > < script type= '' text/javascript '' > ( function ( ) { window.addEventListener ( 'touchstart ' , function ( ) ... | Misplaced clickable area due to class toggle / height change on touch event |
JS | I followed this tutorial to fill the city on the basis of address automatically.But when I tried to implement it , I am not getting the functionality I want . I want that after filling the address the city field should automatically be filled . Below is my code : Below is the javascript code | < div class= '' form-group '' > < label class= '' col-md-3 control-label '' for= '' example-text-input '' > City < /label > < div class= '' col-md-3 '' > < input type= '' text '' id= '' crack '' name= '' City '' class= '' form-control '' > < /div > < /div > < div class= '' form-group '' > < label class= '' col-md-3 con... | Google Autofill API |
JS | This is my Django Rest Framework code / view which gets called when I try to register a user : and this is my AngularJS code which registers a user / calls the Django view posted above : When I try to register a user which already exists , this is what is logged : I 'm trying to replicate the object because throughout ... | def post ( self , request ) : serializer = UserSerializer ( data=request.DATA ) if serializer.is_valid ( ) : serializer.save ( ) return Response ( serializer.data , status=status.HTTP_201_CREATED ) return Response ( serializer.errors , status=status.HTTP_400_BAD_REQUEST ) self.add = function ( ) { $ http.post ( `` /CMS... | AngularJS Django Rest Framework - trying to replicate JS object raised on 400 server error |
JS | Is there any way to have DOM elements selectable through objects ? For example I want to be able to associate objects to DOM elements like so : And later on ... Or even better : Something like that . You can see that I want to associate an object to a DOM element in such a way that I can grab the element with the objec... | var obj = { a : 1 , b:2 } ; $ ( ' a ' ) .click ( function ( ) { this.selectThing = obj } ) ; $ .something ( obj ) ; $ ( ' a|selectThing ? = ' , obj ) ; var obj = { prop : 'prop ' } ; $ ( ' a ' ) .bindTo ( obj ) ; $ .retreive ( obj ) // should equal $ ( ' a ' ) | jquery using objects as filters |
JS | I 'm working on my final year project . In which : I have Login and Signup forms on one page ( WebForm ) : When user click on anchor Sign Up the DropDown ddlType ( hides ) and TextBoxes - txtCustName , txtEmail and txtConfirmPassword ( Displays ) in Javascript client side : Login Form : -And when user click on anchor L... | function signupClick ( ) { document.getElementById ( 'divType ' ) .style.display = 'block ' ? 'none ' : 'block ' ; document.getElementById ( ' < % =txtCustName.ClientID % > ' ) .style.display = 'inherit ' ; document.getElementById ( ' < % =txtConfirmPassword.ClientID % > ' ) .style.display = 'inherit ' ; document.getEl... | How to stop on the Sign Up Form when web page performs Postback ? |
JS | I have a method getUrl ( ) calling an API endpointI can see in the Console the call in my page as you can see in the screenshot this is my dataHow can I display the following result link example https : //www.gooole.it in an external link in my view ? Do I have to use states ? I need an example of how to code to do thi... | useEffect ( ( ) = > { getUrl ( ) .then ( x = > x.json ( ) ) .then ( x = > { const { result } = x ; } ) ; } ) ; { `` result '' : '' https : //www.google.it '' , `` error '' : null , `` errorCode '' : null , `` isSuccessful '' : true , `` operationStatusCode '' : '' OK '' } < a target= '' _blank '' href= { result } > Goo... | UseEffect - Use state to create an external Link |
JS | There is a test.js : I want to read this test.js from an index.js and print all its function name and arguments ; Without module.exports.Is it possible to read js file and return all its function and their arguments . | const add = ( x , y ) = > { return x+y ; } const multiply = ( x , y , z ) = > { return x*y*z ; } const fs = require ( `` fs '' ) ; let file = fs.readFileSync ( `` ./test.js '' , `` utf8 '' ) ; let functionArg = `` Do some operations '' console.log ( functionArg ) //Result : // add : [ x , y ] // multiply : [ x , y , z ... | How to get all the function and their arguments from a js file ? javascript |
JS | During playing with Firefox WebExtensions I 've created a simple add-on that cancels certain POST request and reads its params : manifest.jsonbackground.jsThe target page with form is located here : http : //kamil.hism.ru/pocs/simple_form.htmlrequestDetails contains requestBody that should contain formData object with ... | { `` description '' : `` Canceled webRequests data '' , `` manifest_version '' : 2 , `` name '' : `` webRequest-demo '' , `` version '' : `` 1.0 '' , `` permissions '' : [ `` webRequest '' , `` webRequestBlocking '' , `` http : //kamil.hism.ru/pocs/* '' ] , `` background '' : { `` scripts '' : [ `` background.js '' ] }... | Firefox WebExtensions : can not get canceled request data |
JS | I 'm referring to the testing assertion library : http : //chaijs.com/api/bdd/ # falseYou can write language chain assertions like the following : expect ( ) is obviously a global function , `` to.be '' looks like two properties , but how does the last part `` false '' work . I 'm expecting that it would have to be a f... | expect ( false ) .to.be.false ; expect ( false ) .to.be.false ( ) ; | How does Chai JS make function parentheses optional ? |
JS | If I 've added styles with CSSOM using insertRule I 've noticed two things.The added styles do n't appear in the html while viewing in Firebug ever.The added styles do n't work if the style tag is appended ( ex : moved from head to body ) to another element ( Happens in Firefox , and Chrome ) .If the styles are added a... | var style = document.createElement ( 'style ' ) , sheet = style.sheet ; document.head.appendChild ( style ) ; //When line 6 is un-commented the styles work//if line 8 is also commented out.//document.querySelector ( '.container ' ) .appendChild ( style ) ; //Get the sheet when line 6 is un-commentedsheet = style.sheets... | Why are styles invisible , and style tags not re-appendable after using insertRule of CSSOM |
JS | I 'm looking at multiple D3 code examples similar to this : But sometimes I 'll see it as this : All the code I 've written has been in the second form and I 've never had any issue , but I copied a code example online that was in the first form and it did not work when I removed the [ ] .Can someone explain why it 's ... | var data = [ 1,2,3 ... ] ; var blah = d3.selectAll ( `` # blah '' ) .data ( [ data ] ) .enter ( ) ... ; var data = [ 1,2,3 ... ] ; var blah = d3.selectAll ( `` # blah '' ) .data ( data ) .enter ( ) ... | D3 Data Binding - When to put brackets around data |
JS | I want to grab Google Chart data from a page , convert it to CSV , and then hand it off to a downloader . In chartpage.jsThen in chart.coffee : In chart.html.haml : So I am trying both the above and the following in the main JS : But the data variable from the page 's JS ( HAML ) : Seems to only be available after the ... | function downloadCSV ( args ) { var csvData , filename , link ; var action = args.action_name ; var csv = convertArrayOfObjectsToCSV ( { action_name : action } ) ; filename = args.filename || 'export.csv ' ; csvData = encodeURI ( csv ) ; link = document.createElement ( ' a ' ) ; link.setAttribute ( 'href ' , 'data : te... | How can I grab Google Visualization DataTable data after chart is loaded ? |
JS | I 'm trying to decrement a variable once a day . I have written the following code for that . Is there a better or efficient way to achieve the same thing ? P.S : - I do not wish to use any libraries . | var counter = 10 ; //any valuesetInterval ( function ( ) { counter = counter - 1 ; } , 86400000 ) ; | Decrement a variable once a day - Javascript |
JS | I have searched for magnifying glasses on the web , but usually they only work for one picture . So , I have built a magnifying glass that magnifies all the pictures in a specific div . It works well on Chrome browser , but it gives strange effects on Firefox and Opera browsers.Can anyone help me in reaching a magnifyi... | < style type= '' text/css '' > # banners_magnifying { left : 0px ; border-radius : 100 % ; border : 0px solid ; width : 40px ; height : 40px ; overflow : hidden ; position : absolute ; zoom : 400 % ; -moz-transform : scale ( 4 ) ; /*multiple box shadows to achieve the glass effect*/ box-shadow : 0 0 0 4px # 000000 , 0 ... | Javascript magnifying glass for a set of figures - cross-browser compatibility |
JS | What is a method ( or combination of methods ) in Javascript that will iterate over the elements of an array and , aside operating on the elements of the array , will also allow me to use the index number of the current element ? In ruby this would equate to something like this : | array.each_with_index { |element , index| element.method ( index ) } | JS version of Ruby 's .each_with_index |
JS | I am very new to Angular and Nodejs and thought this would be a fun project to try . I am trying to get the the json data from the http.get in angular.js and put it into a variable cities so it can display on the google maps . When I try to console.log ( cities ) ; it returns an object but console.log ( cities.items ) ... | { `` city '' : `` New York '' , `` state '' : `` NY '' , `` desc '' : `` Google NYC '' , `` lat '' : 40.7418 , `` long '' : -74.0045 } //Angular App Module and Controllervar sampleApp = angular.module ( 'mapsApp ' , [ ] ) ; var cities = $ http.get ( '/locations ' ) .success ( function ( data ) { $ scope.items = data.it... | Getting http.get data into local JSON array variable |
JS | I have a div that contains a picture and some text ( the image is of the variable size and the text is of the variable length ) .Is there any way to calculate the height required to fit all the div content , given that the exact width is predefined ? UPD getting same wrong result when using $ ( document ) .ready ( ) | document.addEventListener ( `` DOMContentLoaded '' , function ( ) { var div = document.getElementById ( `` Content '' ) ; var res = document.getElementById ( `` Result '' ) ; res.innerHTML = div.offsetHeight ; // incorrect - returns 252 while the real height is 360 ( Firefox , Chrome ) } ) ; div { width : 400px ; } img... | Calculate div height given a known width ? |
JS | What is the best way in JavaScript to set the date portion of a JavaScript date object without affecting the time portion ? Lets say you have a date like thisWed Oct 31 2012 10:15:00 GMT-0400 ( EDT ) And you want to update it to be November 1st without changing the time.At first glance , you 'd think this would work , ... | exampledate.setFullYear ( 2012 ) ; exampledate.setMonth ( 10 ) ; exampledate.setDate ( 1 ) ; | Updating the date portion of a javascript object without changing the time portion |
JS | Is it a good or bad practice to use jQuery statements in plain javascript functions outside of ready ? If not what is the correct way ? | //** End ready **//function doSomething ( ) { selectedClickBoxIndex = parseInt ( jQuery ( ' . ' + clickBoxOnClass ) .attr ( 'value ' ) ) ; // Javascript code } | Using jQuery statements in plain javascript functions |
JS | I presume this is an odd question but I have to ask..If I have a js object that looks like this : Is there a way to remove an entire property ? without re-assigning values to a new object.. So if I want to get rid of `` number '' : '' Eleven '' , I would like the object to look like this ... Thanks ! | $ scope.obj1 = { `` name '' : '' John '' , `` number '' : '' Eleven '' , `` color '' : '' Red '' } $ scope.obj1 = { `` name '' : '' John '' , `` color '' : '' Red '' } | Is there a way to remove a whole property from a js object |
JS | I want to make a function that change css property of an object.I tried code belowand it works.but I would like to to make the function to be called from an object like thisCan someone help ? | function setBgColor ( $ obj , $ color ) { $ obj.css ( `` background-color '' , $ color ) ; } setBgColor ( $ ( `` .bg-red '' ) , `` red '' ) ; function setBgColor ( $ color ) { $ ( this ) .css ( `` background-color '' , $ color ) ; } $ ( `` .bg-red '' ) .setBgColor ( `` red '' ) ; | jQuery function for change css bg color |
JS | Lines 1-2 and 4-5 make sense in terms of the this returned . What am I missing about line 3 ? I thought it would return window similar to lines 4-5 . Is there another pattern not in these 5 that could help demonstrate why ? | foo = { bar : function ( ) { return this } } foo.bar ( ) // == > foo ( foo.bar ) ( ) // == > foo / but why ? ( foo.bar ? foo.bar : $ .noop ) ( ) // == > window ( foo.bar || 0 ) ( ) // == > window | JavaScript object functions and ` this ` when unbound and returned in expression/parens |
JS | When I try to sign an addon I 've received a message without validation_url . But in details I see information about Firefox Add-on Distribution Agreement and Review Policies and Rules . Where I should accept them ? I have n't found information about this message : https : //addons-server.readthedocs.io/en/latest/topic... | Upload : xpi = c : \temp\xpi_8e03dc5f6de9\xpi.zip , id = example @ example.com , version = 1.0.1.1 , user = user:42085444:111 , key = 1bb945266bf370170a656350d9b640cbcaf70e671cf753c410e604219cdd9267 Upload Response : { `` detail '' : '' Before starting , please read and accept our Firefox Add-on Distribution Agreement ... | Where I should accept Firefox Add-on Distribution Agreement ? |
JS | I am trying to split a Polymer 3 component into separated files so for example : would look like something like : index.js : style.css : template.html : Edit1 : I tried out the following code with the same template.html and style.css files : import-test.js : I am getting the right file from the promise : But I also get... | import { html , PolymerElement } from ' @ polymer/polymer/polymer-element ' ; export default class TestSplit extends PolymerElement { static get template ( ) { return html ` < style > p { color : blue ; } < /style > < p > Hello from component < /p > ` ; } } customElements.define ( 'test-split ' , TestSplit ) ; import {... | Is it possible to split a Polymer 3 component into separated JavaScript , HTML , and CSS files ? |
JS | I 'm , setting up the mobile side of a website at the moment , and I need custom CSS and Javascript for mobile , so in the CSS I have rules using @ media screen and ( max-width : 500px ) { and in Javascript I was going to use if ( $ ( window ) .width ( ) < 500 . However , if I resize my browser to the exact pixel the m... | var scrollBarWidth = false ; function mobileRules ( ) { if ( ! scrollBarWidth ) { var widthWithScrollBars = $ ( window ) .width ( ) ; $ ( 'body ' ) .css ( 'overflow ' , 'hidden ' ) ; var widthNoScrollBars = $ ( window ) .width ( ) ; $ ( 'body ' ) .css ( 'overflow ' , 'scroll ' ) ; scrollBarWidth = widthNoScrollBars - w... | CSS and jQuery have different widths |
JS | I have moved all my linting configuration and related packages/plugins/presets ( for prettier , stylelint , eslint , commitlint ) out to an npm package . I then use this package in multiple projects and extend or merge over the config into local configuration files for the projects to ensure consistency and remove the ... | `` lint : prettier '' : `` prettier 'src/**/* . { js , json } ' -- write '' , '' lint : eslint '' : `` eslint 'src/**/*.js ' '' , '' lint : compatibilityCheck '' : `` eslint -- print-config .eslintrc.js | eslint-config-prettier-check '' , '' lint '' : `` npm run lint : compatibilityCheck & & npm run lint : prettier & &... | Distributing NPM Scripts With A Package For Use By Project Installing It |
JS | I got this path array : and an object like : and I would like to delete that obj [ `` a '' ] [ `` b '' ] [ `` c '' ] [ `` d '' ] so my objwill beI 've tried to do some path.forEach looping , appending it but could n't find a proper way which I appended it as I wish to , so I could access obj to the right place . | const path = [ `` a '' , `` b '' , `` c '' , `` d '' ] let obj = { `` a '' : { `` b '' : { `` c '' : { `` d '' : 10 , `` e '' : 20 } } } } { `` a '' : { `` b '' : { `` c '' : { `` e '' : 20 } } } } | javascript reach element by a path array |
JS | I 'm getting lost in the weeds with V8 source as well as articles on the subject and I came across a blog post which stated : If you are forced to fill up an array with heterogeneous elements , let V8 know early on by using an array literal especially with fixed-size small arrays.If this is true , then why is it true ?... | let array = [ 77 , 88 , 0.5 , true ] ; //V8 knows to not allocate multiple times . | V8 : Heterogeneous Array Literals |
JS | I am in the process of building a revolving text generator . The generator combines sentences ( text ) from a number of arrays , 'cycles ' through them visually and appends them . I thought it best to create a Fiddle with a basic version of the generator as I have constructed it now : ExplanationThe basic workings are ... | Generate ( combo0 [ 0 ] , i , function ( i ) { //generate from first array element of combo0 , callback to generating from second array of combo0 Generate ( combo0 [ 1 ] , i , function ( i ) { $ ( 'div # status ' ) .html ( 'Done ! ' ) ; //show status $ ( 'input # generate ' ) .removeAttr ( `` disabled '' ) ; //enable b... | Revolving text generator |
JS | I have problem to fix height of div that have multiple checkboxes inside , so the height dont be more then 100 % of window ( body ) . I try so many staff so im out of solutions . If someone know some tricks to help me with this one , i will be so much pleased | $ ( `` .open '' ) .on ( `` click '' , function ( ) { $ ( `` # multiselect-wrap '' ) .animate ( { left : 0 } ) ; $ ( `` .open '' ) .hide ( ) ; $ ( `` .close '' ) .show ( ) ; } ) ; $ ( `` .close '' ) .on ( `` click '' , function ( ) { $ ( `` # multiselect-wrap '' ) .animate ( { left : -220 } ) ; $ ( `` .open '' ) .show (... | multiple checkbox div 100 % height of body |
JS | I have a question before wherein I wanted to expand a div from the center of the body . It works fine not until I encountered this scenario wherein the content of the body is long enough that a scroll bar now shows . Notice on this jsFiddle that when I scroll to a little to the bottom or just halfway then clicked anywh... | .growme { background-color : # 990000 ; height : 0 ; width : 0 ; position : absolute ; filter : alpha ( opacity=0 ) ; opacity : 0 ; top:0 ; left:0 ; bottom:0 ; right:0 ; margin : auto ; } | Expand div from center of viewport |
JS | I have an ng-repeat that iterates through the names of countries in my model . On certain country names I want them abbreviated to reduce the length of the string , for example , I want 'Northern Ireland ' to be outputted as ' N . Ireland ' . JSON ModelI could just change the name in my model , but I 'd rather leave th... | [ { `` id '' : 1 , `` name '' : `` Italy '' , } , { `` id '' : 2 , `` name '' : `` Northern Ireland '' , } , { `` id '' : 3 , `` name '' : `` Poland '' , } ] < md-grid-tile ng-repeat= '' nation in nationData '' > < img src= '' img/ { { nation.name } } .png '' > < md-grid-tile-footer > < h3 > { { nation.name | uppercase... | Change one single iteration on an ng-repeat |
JS | I 'm creating an algorithm that will blur the border of a canvas ( image ) . Before applying the blur effect , I am creating an array filtered that includes all pixel values that needs to be blurred.I 've created an example with a 10×10px image.The array filtered contains all the numbers that has the background color a... | function compute ( w , h , bW ) { w *= 4 ; var ignored = [ ] ; for ( y = bW ; y < ( h - bW ) ; y++ ) { for ( x = 0 ; x < ( w - ( bW * 4 * 2 ) ) ; x++ ) { ignored.push ( w * y + x + bW * 4 ) ; } } console.log ( ignored ) ; function range ( limit ) { return Array.apply ( null , Array ( limit ) ) .map ( function ( _ , i )... | Filtering specific range of numbers from an array |
JS | This is my first sample table using react-data-grid , columns are not rendered next to each other , instead they are overlapping over and over each otherBelow is the very basic sample code I am trying . The code renders the table with data but renders the columns and data on top of each other like this : Output : IDTit... | import React from 'react ' ; import DataGrid from 'react-data-grid ' ; export default class extends React.Component { constructor ( props , context ) { super ( props , context ) ; this._columns = [ { key : 'id ' , name : 'ID ' , resizable : true , width : 40 } , { key : 'task ' , name : 'Title ' , resizable : true } ] ... | My first sample table using react-data-grid , columns are not rendered next to each other , instead they are overlapping over and over each other |
JS | When a mouse is hovering a image . It gets detect by this if statement : I also want to detect when a mouse it outside a image.After that previous if statement I can not use else the reason is because : When I generate multiple images on screen and when my mouse if hovering over 1 image . It does hover of that image an... | if ( ( distance ( circles [ this.index ] .x , circles [ this.index ] .y , mouse.x , mouse.y ) ) < circles [ this.index ] .radius ) Mouse inside circle Mouse outside circle 4 Mouse inside circle Mouse outside circle 4 var mouse = { x : innerWidth / 2 , y : innerHeight / 2 } ; // Mouse Event ListenersaddEventListener ( '... | How to detect when mouse is outside of a certain circle ? |
JS | For my project , I am trying to set up Mocha to run Chai tests , but am having an issue where the tests are simply not running at all . The browser reports that no tests are passing , failing , or running.Here is the code for the tests : I run the test using the following command : I have installed practicalmeteor : ch... | import { assert } from 'chai ' ; import { Meteor } from 'meteor/meteor ' ; if ( Meteor.isclient ) { describe ( 'Recipe model ' , function ( ) { it ( 'should test that a recipe is created ' , function ( ) { assert.isTrue ( true ) ; } ) ; } ) ; } meteor test -- driver-package practicalmeteor : mocha | Mocha test not running Chai assertion using Meteor |
JS | When should I apply template in constructor or connectedCallback ? When I do it in callback sometimes attributeChangedCallback is called before and i ca n't query for elements.I would like to know where and why it is better.Here is a snipped of template apply code | export class TestElement extends HTMLElement { constructor ( ) { super ( ) ; //here ? } connectedCallback ( ) { //here ? } } let t = document.createElement ( 'template ' ) ; t.innerHTML = require ( 'template.html ' ) ; this.appendChild ( t.content.cloneNode ( true ) ) ; | When should I apply template in constructor or connectedCallback |
JS | If a then handler has no return statement , the resulting chained promise takes on the value undefined in bluebird . But I can not see anywhere that it is specified in Promises/A+ or anywhere ? Can this behavior be counted on ? Here 's a test program : | var Promise = require ( 'bluebird ' ) ; var p = Promise.resolve ( 'test ' ) ; p.then ( function ( s ) { console.log ( 's1='+s ) ; // no return } ) .then ( function ( s ) { // bluebird prints `` undefined '' . is this specified by a standard ? console.log ( 's2='+s ) ; } ) ; | What is the resolution value of a chained Promise if a then handler does n't return anything ? |
JS | I 'm writing a Firefox extension to add a context menu element and I can get both the DOM element and the selected text , but ca n't manage to get the unselected word on which the right click event was fired . I assume it must be possible , since the spell-checker does it , or is that a special inbuilt function ? Any i... | oncommand= '' if ( gContextMenu.isTextSelected ) rightClick ( document.commandDispatcher.focusedWindow.getSelection ( ) .toString ( ) ) ; else rightClick ( gContextMenu.target.innerHTML ) ; '' | Is there any way to get the word under the context menu in a firefox extension ? |
JS | I want an object to return one value in a numeric context and a completely different one in a string context . The following does n't work . | foo = { toString : function ( ) { return `` string '' } , valueOf : function ( ) { return 123 } } console.log ( foo * 2 ) // got 246 , fineconsole.log ( `` hi `` + foo ) // got `` hi 123 '' , want `` hi string '' | Make toPrimitive conversion depend on the context |
JS | This gives no syntax or runtime error . Looks like number and variable name can be any other ( 123..qwerty ) . I 'm wondering what does this statement mean ? | < script > 1..z < /script > | What does ` 1..something ` mean in JavaScript ? |
JS | I am getting a very strange output on the below scenarios : But when using the below code Can anybody please explain . | function test ( ) { var test=123 ; console.log ( test ) } // this output : 123 ( function test ( ) { var test=123 ; console.log ( test ) } ) ( ) // this output : 123 ( function test ( ) { test=123 ; console.log ( test ) } ) ( ) //output : function test ( ) { test=123 ; console.log ( test ) } | Variable hoisting inside IIFE ( lazy parsing ) |
JS | I 'm wondering whether it 's possible to target multiple series in the same rule using tokens . In essence , what I am aiming for is `` if the value from series 1 is greater than the value in the same position in series 2 , change some styles '' .Zingchart config : If that 's not possible , is there another way to achi... | var config = { // ... 'type ' : 'area ' , 'plot ' : { 'rules ' : [ { 'rule ' : `` , // % v from series 1 > % v from series 2 'background-color ' : ' # ccc ' } ] } , 'series ' : [ { 'text ' : 'Series 1 ' , 'values ' : [ 36 , 40 , 38 , 47 , 49 , 45 , 48 , 54 , 58 , 65 , 74 , 79 , 85 , 83 , 79 , 71 , 61 , 55 ] } , { 'text... | Zingchart : Target multiple series in a rule using tokens |
JS | Once user click on Non Transparent part of Image , we are displaying file upload dialog box ... . we have 2 images which are overlapped each other as below : -- Issue : In the above 2 images , wherever i click on Non-Trans part , than file upload dialog box is displaying ... . But if we click on Overlapped part , than ... | var target ; let jsonData = { `` path '' : `` newyear collage\/ '' , `` info '' : { `` author '' : `` '' , `` keywords '' : `` '' , `` file '' : `` newyear collage '' , `` date '' : `` sRGB '' , `` title '' : `` '' , `` description '' : `` Normal '' , `` generator '' : `` Export Kit v1.2.8 '' } , `` name '' : `` newyea... | File upload dialog box not displaying onclick first time |
JS | I have a JSON like the followingAll I want to do is sort the array on Start time ... I have seen a solution here but I am not sure how to tweak it to my JSON structure ... Can someone please advise ... ! | [ { `` Event_code '' : `` AB-001 '' , `` Start_time '' : `` 11:00 AM '' , `` End_time '' : `` 3:00 PM '' , `` Session_type '' : `` Tour '' } , { `` Event_code '' : `` AB-002 '' , `` Start_time '' : `` 09:30 AM '' , `` End_time '' : `` 1:00 PM '' , `` Session_type '' : `` Course information session '' } , { `` Event_cod... | Sort a JSON array on time , displayed in a 12 hour format |
JS | UpdatedI have tried my best to reflect my scenario . The sidebar wo n't show at start , and it can be hidden by a user if desired . The HTML document looks like : The sidebar seems to be fixed , but only whenever we scroll right to the footer . I would like the side-nav to be scrolled up instead of directly being moved... | < ! doctype html > < html lang= '' en '' > < head > < meta charset= '' utf-8 '' > < meta name= '' viewport '' content= '' width=device-width , initial-scale=1 , shrink-to-fit=no '' > < meta name= '' description '' content= '' '' > < meta name= '' author '' content= '' '' > < title > Starter Template for Bootstrap < /ti... | Floating sticky sidebar is not working as intended |
JS | I am using mongodb for node and am trying to aggregate a collection of documents based on some set filters and then limit it to 10 . I have it aggregating just fine and limiting just fine but I need to get the total number of that aggregated documents before I limit them to 10.Here is my code.Can this be done in one ag... | var qry = [ ] ; if ( filter.FocusArea & & filter.FocusArea ! = `` ( None ) '' ) { qry.push ( { $ match : { 'ProgramAreaId ' : filter.FocusArea } } ) ; } if ( filter.Status & & filter.Status ! = `` ( None ) '' ) { qry.push ( { $ match : { 'StatusId ' : filter.Status } } ) ; } if ( filter.ProgOfficer & & filter.ProgOffic... | MongoDB Node Driver Count of current aggregation |
JS | I thought that our code gets about 16ms of time to execute , since the rendering rate is 60 fps , so 1000 /60 = ~16ms . However , if I run this in Chrome : timeRemaining gives me 49.9ms of time . Does it mean that Chrome does n't re-render every 16ms ? I assume that it 's true in this case , if nothing changes there 's... | requestIdleCallback ( ( deadline ) = > { console.log ( deadline.timeRemaining ( ) , deadline.didTimeout ) } ) ; | Why does requestIdleCallback give me more than 16 ms of time |
JS | When specifying a positional param for a component class in ember , you have to reopen the class ( like below ) so it will work , you can not include it in the initial declaration ( at least from what I 've seen of examples and my own experience ) .If you do it in the single declaration ( like below ) it will not workQ... | import Ember from 'ember ' ; const component = Ember.Component.extend ( { } ) ; component.reopenClass ( { positionalParams : [ 'post ' ] , } ) ; export default component ; import Ember from 'ember ' ; export default Ember.Component.extend ( { positionalParams : [ 'post ' ] , } ) ; | Why does a component class needed to be reopened to specify positional params ? |
JS | As the title states , If I have a jQuery listener tied to an HTML element , and then delete the HTML element from the DOM using jQuery what happens ? then what happens to the listener when I doAlso , what happens if you do n't use jQuery and use document.removeChild ( ) ? | < div id= '' eventDiv > ... < /div > $ ( ' # eventDiv ' ) .click ( function ( ) { // event handling code here } ) ; $ ( ' # eventDiv ' ) .remove ( ) ; | If an HTML element has a listener , what happens to the listener after that element is removed from the DOM ? |
JS | I have made this code : A fiddle : http : //jsfiddle.net/RL54Z/3/I do n't have to write childs=foo.getElementsByTagName ( `` * '' ) ; between the fifth and the sixth line so that childs.length is updated.How can it be ? | var foo=document.createElement ( `` div '' ) ; var childs=foo.getElementsByTagName ( `` * '' ) ; console.log ( childs.length ) ; //0 OKvar a=document.createElement ( `` a '' ) ; foo.appendChild ( a ) ; console.log ( childs.length ) ; //1 WTF ? | getElementsByTagName ( `` * '' ) always updated ? |
JS | Example in my case : But my expected result : 656.63kI would like used option of d3-format instead of handling it manually.Live test : https : //npm.runkit.com/d3-format | d3.format ( `` ~s '' ) ( 656628 ) ; //656.628k | How to round off to 2 decimal places with format SI prefix ? |
JS | I 'm trying to solve the last exercise of this JavaScript Closure Tutorial which takes about Continuation Passing.This is the exercise : Define a function named bothC similar to seqC that takes functions fC and gC and continuations success and failure . The functions fC and gC both just take success and failure continu... | var bothC = function ( fC , gC , success , failure ) { fC ( function ( ) { gC ( success , failure ) ; } , function ( ) { gC ( failure , failure ) ; } ) ; } ; var bothC = function ( fC , gC , success , failure ) { fC ( gC ( success , failure ) , gC ( failure , failure ) ) ; } | Understanding continuations in JavaScript |
JS | My code works from a functionality standpoint . I want to create a `` drawing pad '' in that it creates a grid of small 'divs ' that change color when the mouse goes over them . The 'divs ' change color - but I do n't understand why it is creating a 10 x 9 grid instead of a 10 x 10 grid ? | // When the document is ready ... $ ( document ) .ready ( function ( ) { // Do some things ... newGrid ( 10 ) ; // create a new 10 x 10 grid $ ( `` .block '' ) .hover ( function ( ) { $ ( this ) .css ( 'background-color ' , 'white ' ) ; } ) ; } ) ; function newGrid ( gridNum ) { var maxDivs = gridNum * gridNum ; var cu... | Why is my program creating a 10x9 grid instead of a 10x10 grid ? |
JS | Possible Duplicate : JavaScript function parseInt ( ) does n't parse numbers with leading 0 correctly Strange issues when parsing in JS occur.Why is this happening ? | parseInt ( `` 08 '' ) //The result is : 0parseInt ( `` 07 '' ) //The result is : 7 | How come parseInt ( `` 08 '' ) = 0 , parseInt ( `` 07 '' ) = 7 |
JS | This is a follow-up question to the question below ; Why does this updateSockets ( ) function accept a parameter that look like this ? In the code below , the socket uses volatile to emit.What if the code is changed such that it becomes tmpSocket.emit ( 'notification ' , data ) ; ? What is the difference between tmpSoc... | var updateSockets = function ( data ) { // adding the time of the last update data.time = new Date ( ) ; console.log ( 'Pushing new data to the clients connected ( connections amount = % s ) - % s ' , connectionsArray.length , data.time ) ; // sending new data to all the sockets connected connectionsArray.forEach ( fun... | What is the difference between a socket that simply emits and one that volatile emits ? |
JS | I am trying to draw a scalloped path using SVG between multiple points like it is drawn for rectangle here but between multiple points . Expecting two or more two or more selected points to be connected by scalloped line.But the problems I am facing are , Scallops are not symmetric or random in sizes . - I solved thisA... | var strokeWidth = 3 ; function distance ( x1 , y1 , x2 , y2 ) { return Math.sqrt ( ( x1 - x2 ) * ( x1 - x2 ) + ( y1 - y2 ) * ( y1 - y2 ) ) ; } function findNewPoint ( x , y , angle , distance ) { var result = { } ; result.x = Math.round ( Math.cos ( angle ) * distance + x ) ; result.y = Math.round ( Math.sin ( angle ) ... | Drawing scalloped polygon between multiple points |
JS | The output for that code will be : 0 , 1 , myFeature . The question is : why only custom added function to the Array prototype is outputed , instead of all the function that exists in prototype ? | Array.prototype.myFeature = function ( ) { } ; var arr = [ 'some ' , 'items ' ] ; for ( var prop in arr ) { console.log ( prop ) ; } | Only custom object properties are shown during for-in loop |
JS | I want child components in angular to separate Material Table ( child ) from other elements ( parent ) , but the weird thing is that it seems I can not get data from the parent or I get initialized data from parents and can not refresh.Here is the Code : firstly , the parent .ts file : the parent html like this : and t... | @ Component ( { selector : 'app-dashboard ' , templateUrl : './dashboard.component.html ' , styleUrls : [ './dashboard.component.scss ' ] } ) export class DashboardComponent implements OnInit { ticketList : Ticket [ ] = [ ] ; originalTicketList : Ticket [ ] = [ ] ; filterAllForm : FormGroup ; labelList : string [ ] ; h... | Why I ca n't get result from parent component in Angular |
JS | HTML example And my Javascript looks likeWhich works perfectly fine.HOWEVER WHEN I PUT IT IN A LOOP THAT LOOKS LIKEIt prints an infinite loop of all my monkey pictures . I figure by making the condition dependent on the number of elements in the array `` monkey '' ( or the number of img tags on the page ) , I would be ... | < html > < img src= '' http : //img3.wikia.nocookie.net/__cb20130606164012/animalcrossing/images/3/30/Monkey.jpg '' width= '' 200px '' > < br / > < img src= '' http : //i.telegraph.co.uk/multimedia/archive/02101/monkeys_2101340c.jpg '' width= '' 200px '' > < br / > < img src= '' http : //www.awallpapersonline.com/wp-co... | Infinite For Loop that is not paying attention to array-length condition |
JS | I am somewhat new to JavaScript and I have a question.I know you can set variables and `` sub-variables '' . Like : and alsoBut I was wondering if you could do both , likeThat way , you can declare a variable and also have the same variable be an object . Obviously it could n't be done with what I did , but you get the... | var msg = `` Hello World '' ; alert ( msg ) ; var msg = { lipsum : `` Lorem Ipsum Dolor Sit Amet '' } alert ( msg.lipsum ) ; var msg = `` Hello World '' || { lipsum : `` Lorem Ipsum '' } alert ( msg + msg.lipsum ) ; | JavaScript variable and the same variable also be an object |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.