lang stringclasses 4
values | desc stringlengths 2 8.98k | code stringlengths 7 36.2k | title stringlengths 12 162 |
|---|---|---|---|
JS | I am a relative beginner in Angular , and I am struggling to understand some source I am reading from the ng-bootstrap project . The source code can be found here . I am very confused by the code in ngOnInit : What is the point of calling .call ( ... ) on these Observable functions ? What kind of behaviour is this tryi... | ngOnInit ( ) : void { const inputValues $ = _do.call ( this._valueChanges , value = > { this._userInput = value ; if ( this.editable ) { this._onChange ( value ) ; } } ) ; const results $ = letProto.call ( inputValues $ , this.ngbTypeahead ) ; const processedResults $ = _do.call ( results $ , ( ) = > { if ( ! this.edit... | Why would you ever call .call ( ) on Observable functions ? |
JS | I have a model WebsiteTemplate that belongs to a WebLayout . In the UI I want to display a list of all of the webLayouts but be able to have an html class added to the one whose id is the same as webLayout 's . webLayout belongs to websiteTemplate , which is the model for the route we are visiting.Any ideas on how to d... | # website_template modelApp.WebsiteTemplate = DS.Model.extend webLayout : DS.belongsTo ( `` App.WebLayout '' ) # website_layout modelApp.WebLayout = DS.Model.extend name : DS.attr ( `` string '' ) , thumbnail : DS.attr ( `` string '' ) # routerApp.Router.map - > @ resource `` website_template '' , path : `` /website_te... | Displaying a model associated with a separate controller |
JS | I have two select fields in a program . Both select fields contain options with values 1 to 10. the code is as below : I want to achieve the following effect using JavaScript : ( Only for example ) If the user has selected the option 8 in the first select field ( id= '' noc '' ) , the options below 8 ( i.e . 9 and 10 )... | < select id= '' noc '' > < option value= '' 1 '' > 1 < /option > < option value= '' 2 '' > 2 < /option > < option value= '' 3 '' > 3 < /option > < option value= '' 4 '' > 4 < /option > < option value= '' 5 '' > 5 < /option > < option value= '' 6 '' > 6 < /option > < option value= '' 7 '' > 7 < /option > < option value=... | How to make specific options to appear in select menu ? |
JS | Why on earth does this code : ouputs correctly 31 december 2009 for b and 3 december 2009 : -O for a ? Not in browser MyHorribleScrap version 6.6.6 but BOTH on FF 3.6 AND IE 8.06.6001 | var a = new Date ( ) ; var b = new Date ( ) ; a.setDate ( 31 ) ; a.setMonth ( 11 ) ; a.setFullYear ( 2009 ) ; b.setFullYear ( 2009 ) ; b.setMonth ( 11 ) ; b.setDate ( 31 ) ; | Javascript : date depending on the field specification order ? Really ? |
JS | Is this valid javascript ? It does not error , and appears to work.My interpretation is : import the default from `` ./chooser '' export the result from # 1 as ChooserIs this what is happening ? | export { default as Chooser } from `` ./chooser '' ; | Confusing es6 import - > export statement |
JS | I googled this but ca n't find a result that relates to my problem . I put 'await ' in an async function but node.js says `` SyntaxError : Unexpected identifier '' . Can someone help ? I just started learning JavaScript recently.edit : Here is the content of getMessages ( ) getMessages ( ) is used to get messages in a ... | async function removeFile ( data ) { return new Promise ( ( resolve , reject ) = > { try { if ( ! data.arg ) { //check if there 's filename data.msg.channel.send ( `` What did you want me to remove baka ? `` ) .then ( async result = > { data.client.setTimeout ( data.tsundere , 5000 , result ) ; } ) ; } else { //check i... | 'await ' wo n't work even in an async function |
JS | Im using jCanvas to make flyer editor with jQuery : https : //projects.calebevans.me/jcanvas/In my javascript , first i call my function initCanvas ( ) to add layers to the canvas and it work well when the page load.As you can see in my demo , you can change text , date and time but when you want to change images with ... | $ ( function ( ) { initCanvas ( ) ; $ .datepicker.regional [ 'fr ' ] = { closeText : 'Fermer ' , prevText : ' < Préc ' , nextText : 'Suiv > ' , currentText : 'Aujourd\'hui ' , monthNames : [ 'Janvier ' , 'Février ' , 'Mars ' , 'Avril ' , 'Mai ' , 'Juin ' , 'Juillet ' , 'Aout ' , 'Septembre ' , 'Octobre ' , 'Novembre ' ... | Update images in canvas input type file jCanvas |
JS | I ’ ve been reading about undefined in JavaScript and now I am not sure if my understanding is correct . There is a lot of talk around how to check for undefined but somehow I couldn ’ t find any mentioning of something that to me seems fundamental to understanding of how undefined actually works ( undefined being prop... | window.undefined if ( someVar===undefined ) { } if ( someVar==='undefined ' ) { } if ( typeof someVar===undefined ) { } if ( typeof someVar==='undefined ' ) ( function ( ) { var undefined=66 ; alert ( undefined ) ; } ) ( ) | Understanding “ undefined ” in Javascript : how it works , how to safely check against it and whether reassignment is possible |
JS | I have this codeThat works fine in some browser . But , of course , IE is n't one of them . In IE the combo ends with the two options , but the text is in blank ( there is no selected option ) . I assume this is because the option is still not loaded into the DOM . I assume that because I can easily fix this problem us... | var opt = $ ( `` select option : first '' ) ; opt.remove ( ) ; $ ( `` button '' ) .on ( `` click '' , function ( ) { $ ( `` select '' ) .prepend ( opt ) .val ( 1 ) ; } ) ; var opt = $ ( `` select option : first '' ) ; opt.remove ( ) ; $ ( `` button '' ) .on ( `` click '' , function ( ) { $ ( `` select '' ) .prepend ( o... | Add option to a select and select it |
JS | I have a THREE.Geometry in my scene that contains over 5,000 vertices . What I want to do is to add THREE.Points to the scene for only 3 vertices of the mesh containing the geometry . I want to achieve something like this : I took the 3 vertices of the first face of the existing geometry and added them to the vertices ... | var vertices = [ mesh.geometry.faces [ 0 ] .a , mesh.geometry.faces [ 0 ] .b , mesh.geometry.faces [ 0 ] .c ] ; vertices.forEach ( function ( vId , i ) { vertices [ i ] .index = i ; vertices [ i ] = mesh.geometry.vertices [ vId ] .clone ( ) ; vertices [ i ] .l2w = mesh.localToWorld ( vertices [ i ] .clone ( ) ) ; verti... | Distance based addition of points to vertices ( mesh geometry ) |
JS | Okay , so I look around a lot of answers and none of them seems helpful in what I want to achieve . Say I have the following code : I had done it by making it synchronous using async : false , but from what I read , it 's bad for the user experience as it freezes up the browser as it waits for result . how exactly do I... | var n = 0 ; $ .ajax ( { ... success : function ( data ) { n = Math.floor ( ( Math.random ( ) *10 ) + 1 ) ; somefunction ( n ) ; } } ) ; console.log ( n ) // n would obviously be 0 again | How exactly do I write a callback function to change a global variable inside AJAX for jquery ? |
JS | I have a pixel and when I load it , it says : and then displays : Here 's my pixel code : and in that file : Thanks for your help ! | a call to document.write ( ) from an asynchronously-loaded external script was ignored document.getElementById ( 'gospixel ' ) is null < script name= '' gospix '' src= '' http : //www.example.com/p/gospixel.js '' > gos_f=42 ; gos_a1='a2 ' ; gos_u=window.location.href ; gos_k='6gZYlfy7Y7Q ' ; gos_rt='3_s ' ; document.wr... | My div does not exists after loading my pixel |
JS | I am trying to convert an svg to an image format . Actually a lot works very fine and I know how to convert from SVG to canvas and from canvas to img . My problem is that the svg uses css that has been included as css file and by converting to canvas , the styles will be lost.Does anyone has an idea how to copy the sty... | < ! DOCTYPE html > < html > < head > < meta http-equiv= '' content-type '' content= '' text/html ; charset=UTF-8 '' > < title > SVG2IMG < /title > < link rel= '' stylesheet '' href= '' ./circle.css '' > < /head > < body > < svg width= '' 100 '' height= '' 100 '' > < circle cx= '' 50 '' cy= '' 50 '' r= '' 40 '' / > < /s... | Using css in converted svg to img |
JS | I need to filter an object array that contains duplicate titles but the description is unique.For e.g As you can see , the titles are duplicate whereas its description is unique.So can anybody please tell me how to filter this object array which filters out unique title and description being unique.Basically the filter... | [ { `` Title '' : `` New York '' , `` Description '' : `` A healthy and modernized transit system '' } , { `` Title '' : `` New York '' , `` Description '' : `` changed transit system '' } , { `` Title '' : `` New York '' , `` Description '' : `` xyz '' } , { `` Title '' : `` New York '' , `` Description '' : `` abc ''... | Filtering an object array with duplicate titles and unique description ? |
JS | I have a hard time visualizing and conceiving away to scrape this page : http : //www.morewords.com/ends-with/aw for the words themselves . Given a URL , I 'd like to get the contents and then generate a php array with all the words listed , which in the source look likeThere are a few ways I have been thinking about d... | < a href= '' /word/word1/ '' > word1 < /a > < br / > < a href= '' /word/word2/ '' > word2 < /a > < br / > < a href= '' /word/word3/ '' > word3 < /a > < br / > < a href= '' /word/word4/ '' > word4 < /a > < br / > | Scrape with wildcards and php |
JS | This is Simple form.This is JS code : There are no errors show in console , and could not find errors . Can anyone help me ? | $ ( document ) .ready ( function ( ) { $ ( ' # ledgerHolderjHolderFormEdit ' ) .bootstrapValidator ( { feedbackIcons : { valid : 'glyphicon glyphicon-ok ' , invalid : 'glyphicon glyphicon-remove ' , validating : 'glyphicon glyphicon-refresh ' } , fields : { JH_INIT : { validators : { notEmpty : { message : `` 'First Na... | Bootstrap form validation not working without console error |
JS | I want to iterate an array and find all pairs where their difference is 2This is what i have so far : This works but i still feel guilty using two for loops as the bigO is O ( n^2 ) Is this the only way to do this ? | var numberOfCases = 5 ; var diff = 2 ; var input = [ 1,5,3,4,2 ] ; getPossiblepairs ( input ) ; function getPossiblepairs ( input ) { for ( cmp in input ) { for ( number in input ) { if ( ( input [ cmp ] - input [ number ] ) == diff ) { console.log ( `` ( `` +input [ cmp ] + '' , '' +input [ number ] + '' ) '' ) ; } } ... | Another way to get all combination of integers of an array Javascript |
JS | I came across this regular expression in the jQuery source code : I was wondering why it was rather complicated . I 'm especially interested in the reason behind the second part : I did some research but I could not figure out what this part of the regular expression adds.Particularly , that last ? does n't make much s... | ... rmozilla = / ( mozilla ) ( ? : .* ? rv : ( [ \w. ] + ) ) ? / , ... ( ? : .* ? rv : ( [ \w. ] + ) ) ? ( ? : ) to match but not capture.* ? any amount of any character rv : something literal ( [ \w . ] + ) one or more word characters or a dot ? appear 0 or 1 time / ( mozilla ) / | What does this regular expression part add ? |
JS | I am creating a tampermonkey script for Google Earth that will hide the toolbar when you press a key . One of the elements that is supposed to be hidden looks like this : I am trying to hide it using this code : Note that it also does not work in the console.However , I get this error . Uncaught TypeError : Can not rea... | < earth-toolbar id= '' toolbar '' role= '' toolbar '' > ... < /earth-toolbar > document.getElementById ( 'toolbar ' ) .style.display = 'none ' | Get ID of custom element in javascript |
JS | I have a string.When I give new RegExp ( pattern ) .test ( string ) , it returns true ( as expected ) .But this pattern also returns true.I was expecting this pattern to return false , since t*g means t followed by zero or more number of characters , followed by g.If this is indeed the expected behavior , could any one... | var string= '' ghtykj '' ; var pattern = `` t*y '' ; var pattern = `` t*g '' ; | Javascript RegExp ' * ' not working as expected |
JS | I made a simple popup manager , which used the dom to decide which popup should be in front , without any z-index rule : when I click on a popup , it 's moved in first position , so it is on top of the other popup . Unfortunately : this dom movement breaks the onclick event in my popup.I made a simple case of the issue... | < div > < div onmousedown= '' console.log ( 'mousedown ' ) ; this.parentElement.appendChild ( this ) ; '' onmouseup= '' console.log ( 'mouseup ' ) ; '' onclick= '' console.log ( 'click ' ) ; '' > Click < /div > < /div > | onclick not firing if element is reinserted into DOM mid-click |
JS | I am using a DevExtreme React Grid Tree . My initial call only populates the root row , each additional sub row is applied on click . I am having issues while applying the sub row data when there are many nested table rows . I need an efficient way to find the correct parent row and add the next nested array.Here is th... | [ { `` area '' : `` Artesia '' , `` list_id '' : 45 , `` rowId '' : 158324175700860960 , `` parentRowId '' : 0 , `` items '' : [ { `` area '' : `` Other '' , `` list_id '' : 15003 , `` rowId '' : 158324179061139520 , `` parentRowId '' : 158324175700860960 } ] } , { `` area '' : `` Corpus Christi '' , `` list_id '' : 60... | How to set data to deeply nested array |
JS | I 'm using angularJs and want to change the style of an attribute dynamically.Normally I would do this with ng-style in the html element.But I want to apply styles to the track of a range input.This element can be accessed in css like that : .slider : :-webkit-slider-runnable-track ( As Example for the webkit selector ... | $ scope.change = function ( id , value ) { $ ( ' # '+id+ ' : :-webkit-slider-runnable-track ' ) .css ( 'background-image ' , value ) ; } ; | change style dynamically of none html element |
JS | I 'm writing an asp.net MVC application and decide to try Knockout.js for dynamic UI stuff . It 's a great framework it helped me so much so far . But I faced 2 problems that I ca n't solve and find any useful information on that.I 'll start with code to show you what I have and then I shall try to explain what I want ... | var Project = function ( project ) { var self = this ; self.Id = ko.observable ( project ? project.Id : 0 ) ; self.CustumerCompany = ko.observable ( project ? project.CustumerCompany : `` '' ) ; self.CustomerRepresentative = ko.observable ( project ? project.CustomerRepresentative : `` '' ) ; self.ProjectTitle = ko.obs... | Posting Collection with Knockout.js |
JS | Probably not the correct word . But I want to create a new type in JavaScript . It would have the simple property that one could do this : Basically you would n't have to declare an object literal to extend further . It would create one automatically.This would allow me to build complex structures without having to wor... | var inst = new SomeType ( ) ; inst.key1.key2 = 'something ' ; inst.key1.key1.key3 = 'something ' ; inst.key1 = { } ; inst.key1.key2 = 'data ' ; inst.key1.key2 = 'data ' ; inst.key1 = { } ; | Is it possible to create a new type that is more dynamic ? |
JS | Background : User click on Mask & upload their own image on the mask.Once image uploaded , Edit Text is displaying on the image.Once user click on Edit Text , we are displaying pop up box.Zoom & Rotate buttons are displaying . Also user can Drag the uploaded image ... .Requirement : Once we Zoom , rotate or drag image ... | container.zoom container.rotatecontainer.onDragStartcontainer.onDragOver var target ; const imageUrl = `` https : //i.imgur.com/RzEm1WK.png '' ; let jsonData = { `` layers '' : [ { `` x '' : 0 , `` height '' : 612 , `` layers '' : [ { `` x '' : 160 , `` src '' : `` ax0HVTs.png '' , `` y '' : 291 , `` height '' : 296 , ... | Get the Transformation-Matrix values in Console |
JS | I admit that I asked a question about why Closure Compiler does not shorten certain code which looks shortenable at first sight a few days ago already , but that reason is not applicable in this case and I 'm not really sure why it is n't shortened here.What code I have is : Now there is pre-incrementing and post-incre... | var a = 0 ; function b ( ) { return a++ > = 3 ; } var a = 0 ; function b ( ) { return ++a > 3 ; } | Closure Compiler - can a++ > = 3 become ++a > 3 ? |
JS | I am getting a bit tired of errors like these : It says nothing about what file or what function or what line.In this case this was the caller lineAnd a few functions down in the code was the .format function where the error was.. Is there any way to get better `` error directions '' than app.bundle.js:12345 ? ? | vm.setDates ( new Date ( vm.checkin*1000 ) .format ( 'M d Y ' ) , new Date ( vm.checkout*1000 ) .format ( 'M d Y ' ) ) | How to get the line no or file name of js errors ? |
JS | I think a firebase function updating a list that I have in the firebase database is being captured by a subscription that is subscribed to that list . From what the list output looks like on my phone ( in the app ) ... and from what my console output looks like ( the way it repeats ) it seems like it is capturing the w... | let a = this.http.get ( 'https : //us-central1-mane-4152c.cloudfunctions.net/sortDistance ? text='+resp.coords.latitude+ ' : '+resp.coords.longitude+ ' : '+this.username ) ; this.subscription6 = a.subscribe ( res = > { console.log ( res + `` response from firesbase functions '' ) ; loading.dismiss ( ) ; } , err = > { c... | Firebase function execution and subscription to list that is being updated by a firebase function |
JS | Just wondering if someone can help me on a problem , I do n't fully undersand why it does n't work . I have this fiddle , http : //jsfiddle.net/uomt99zp/What it is doing : When you select from the drop down box , insert that word into the textarea.Which it DOES , when the textarea is n't `` touched '' .If you type some... | < textarea name= '' template '' required= '' required '' class= '' template form-control '' rows= '' 6 '' > < /textarea > < select class= '' templatesAvailableFields '' > < option > Select One < /option > < option > Test1 < /option > < option > Test2 < /option > < option > Test3 < /option > < /select > $ ( '.templatesA... | jQuery SELECT with Textarea |
JS | Here is a fiddle ; http : //jsfiddle.net/dh4qysej/I 'm looking to do this with dynamically created elements , so the divs may not actually exist yet when the function is called.I would like to try work out a solution which could cover x amount of divs and handle it with minimal code , but making a scrappy version to ac... | function collision ( $ div1 , $ div2 , $ div3 ) { if ( $ div1.length > 0 ) { var x1 = $ div1.offset ( ) .left ; var y1 = $ div1.offset ( ) .top ; var h1 = $ div1.outerHeight ( true ) ; var w1 = $ div1.outerWidth ( true ) ; var b1 = y1 + h1 ; var r1 = x1 + w1 ; } if ( $ div2.length > 0 ) { var x2 = $ div2.offset ( ) .le... | collision detection on more than 2 divs with jQuery draggable ? |
JS | I have an example running here , where the input is set by ? amount=123Sorry , running the code snippet above or on JS fiddle does n't appear to work with URL parameters.If the input is changed , I want the URL to update too , with the new value . How do I achieve that in vanilla JS ? | const query = new URL ( location ) .searchParamsconst amount = parseFloat ( query.get ( 'amount ' ) ) console.log ( `` amount '' , amount ) document.getElementById ( 'amount ' ) .value = amount < label > Amount < input id= '' amount '' type= '' number '' name= '' amount '' > < /label > | How to bind a URL parameter with an input field in Vanilla JS ? |
JS | So I have a matrix of divs within a container in my page , each div displays either a ' 1 ' or a ' 0'.If I set my container to a width of 100 % and height to fit the bottom of my page , I want to be able to scale all of the 1 's and 0 's inside the container 's divs ( the number of 0 's and 1 's will be a static number... | < div id= '' binaryMatrix '' style= '' width : 100 % ; height : 100 % ; '' > < div > 0 < /div > < div > 1 < /div > < div > 0 < /div > < div > 1 < /div > < div > 0 < /div > < div > 1 < /div > < div > 0 < /div > < div > 1 < /div > ... up to 100 < /div > # binaryMatrix div { float : left ; } | Resize font text ( inside multiple divs ) within container to fit perfectly |
JS | I am trying to create a simple layout using CoffeeScript , NodeJS and expressJS . My Coffee script isroutes.coffee I have renamed routes folder to apps and my routes.coffee file is in there in authentication folder i.e . apps\authentication\routes.coffeeLogin View I have renamed routes folder to apps and my login view ... | routes = ( app ) - > app.get `` /login '' , ( req , res ) - > res.render `` # { __dirname } /views/login '' , title : 'Login ' , stylesheet : 'login'module.exports = routes extends ../../../views/layoutblock contentform ( action='/sessions ' , method='post ' ) label | Username input ( type='text ' , name='user ' ) labe... | nodejs View not rending in Layout |
JS | I 'm building a grunt file , and I have 2 folders that need the same grunt tasks applied to them . I would like to be able to use the grunt template property to iterate over each folder so that I do n't have to bloat my grunt config object by repeating the configuration objects . Like so : It would be ideal and very DR... | app1 : { name : 'app1 ' , src : [ 'src/app/ < % = app1.name % > ' ] , jsTpl : [ ' < % = distdir % > / < % = app1.name % > /templates/**/*.js ' ] , js : ' < % = app1.src % > /**/*.js ' } , app2 { name : 'app2 ' , src : [ 'src/app/ < % = app2.name % > ' ] , jsTpl : [ ' < % = distdir % > / < % = app2.name % > /templates/*... | Using Grunt to iterate over templates |
JS | Possible Duplicate : Weird Script Appearing In My Website 's DOM I just noticed a weird script running in my websites DOM . I am running DRUPAL . The script is http : //www.103fm.net/release.js . I do n't know where to begin looking to find this rogue script . My website is miloads.com and it only happens in the admin ... | var BrowserDetect = { init : function ( ) { this.browser = this.searchString ( this.dataBrowser ) || `` An unknown browser '' ; this.version = this.searchVersion ( navigator.userAgent ) || this.searchVersion ( navigator.appVersion ) || `` an unknown version '' ; this.OS = this.searchString ( this.dataOS ) || `` an unkn... | Why is `` 103fm '' script appearing on Drupal website ? |
JS | BackgroundI have a server that registers some RPCs using crossbar , and a test that is trying to make sure that the RPCs are being called using sinon . Codeserver.jsThis server simply connects to the crossbar and then registers the open RPC . Now my test case . I am using mocha with chai : test.jsThis test opens a conn... | `` use strict '' ; const autobahn = require ( `` autobahn '' ) ; const server = ( ) = > { const open = ( ) = > console.log ( `` Hello world '' ) ; const start = ( ) = > new Promise ( fulfil = > { const connection = new autobahn.Connection ( { `` url '' : `` ws : //localhost:8080/ws '' , `` realm '' : `` realm1 '' } ) ;... | Sinon.js spy.called not working on RPCs |
JS | I am trying to get my head around the use of webpack in combination with gradle in an intellij environment using vue.js as the client-side JS engine.I started by building a new grails project using the vue profile : Initially , I had problems integrating a new xyz.vue main screen with the vue library , so I cheated by ... | grails create-app foobar -- profile=vue var path = require ( `` path '' ) module.exports = { `` entry '' : `` ./lib/index.js '' , `` output '' : { `` path '' : __dirname + `` /build '' , `` filename '' : `` xxhash.js '' , `` library '' : `` XXH '' , `` libraryTarget '' : `` umd '' } } import LiquorTree from 'liquor-tre... | Adding 3rd party JS libs to Webpack/Grails/Gradle project |
JS | I 'm trying to assert the CSS width of an element in NightwatchJS to be 100 % , but it fails saying that the width is 196px . The error message is : Testing if element < [ data-e2e= '' base-button '' ] [ class= '' xs block '' ] > has css property `` width : 100 % '' . - Expected `` 100 % '' but got : `` 196px '' I have... | page.assert.cssProperty ( ` @ button-element ` , 'width ' , '100 % ' ) ; page.expect.element ( ` @ $ { element } ` ) .to.have.css ( `` width '' ) .which.equals ( `` 100 % '' ) ; | Unable to assert css width to be 100 % |
JS | I 'm trying to decide how to set up my functions in the prototype for my main library.Should I use : or So basically the first choice adds all my functions to the prototype . The second option replaces the prototype with an object containing all my functions . Does it matter ? | Library.prototype.funcA = function ( ) { ... .. } ; Library.prototype.fucnB = function ( ) { ... .. } ; etc.. Library.prototype = { funcA : function ( ) { ... .. } , funcB : function ( ) { ... .. } , etc.. } ; | Which of these prototype declarations is better and why ? |
JS | Is it possible in JavaScript to create a private variable which can be accessed in prototype ? I tried the following which obviously does n't work , because bar is only accessible from within Foo and not from within prototype.I know I also can not use this.bar = 'test ' , because that would make the property public AFA... | function Foo ( ) { var bar = 'test ' ; } Foo.prototype.baz = function ( ) { console.log ( bar ) ; } ; | Access `` private '' variables in prototype |
JS | What I am expecting is to execute this code : true & & true & & false & & false and that should return false.How to make that work in js ? Thanks | function andMultipleExpr ( ) { let logicalAnd ; let i ; for ( i = 0 ; i < arguments.length ; i++ ) { logicalAnd = arguments [ i ] & & arguments [ i+1 ] ; } return logicalAnd ; } console.log ( andMultipleExpr ( true , true , false , false ) ) ; | AND multiple parameters |
JS | I develop the app that uses datatables to visualize certain statistics data.I receive from API the data in the following format : Which is essentially a company name and its year over year revenue growth figure ( % ) .What I would like to implement is an MS Excel-like conditional formatting feature that displays colore... | { `` data '' : [ { `` companyName '' : `` company1 '' , `` growth '' : 15 } , { `` companyName '' : `` company2 '' , `` growth '' : -8 } , { `` companyName '' : `` company3 '' , `` growth '' : 23 } ] } < link rel= '' stylesheet '' type= '' text/css '' href= '' https : //cdn.datatables.net/1.10.19/css/jquery.dataTables.... | DataTables conditional formatting bars |
JS | I have code like this : I always thought that foo did n't take any arguments , e.g . : However , doing the following : Popped up an alert displaying -7 . What does this number represent ? | setTimeout ( foo , 600 ) ; function foo ( ) { /* bars */ } function foo ( a ) { alert ( a ) ; /* bars */ } | What does the function given to setTimeout get called with ? |
JS | Following code block executed successfully . I was wondering what would be the use of this labeling other than using for loops ? | < script > js : { alert ( `` x '' ) ; } < /script > | What is the use of the following colon in javascript |
JS | I have a string containing comma separated names and optional values that seprated values like this : I want to convert it into objects or json that can access to values by name like this : OR Note 1 : If a name does n't have value it be true by default.Update : Note 2 : If a name does n't exist in list the value of it... | var str = `` PowerOn : On , ValidLocation , temp:25 '' ; var a = { `` PowerOn '' : '' On '' , `` ValidLocation '' : '' true '' , `` temp '' :25 } ; var result = a.PowerOn ; alert ( result ) ; var a = { `` PowerOn '' : '' On '' , `` ValidLocation '' : '' true '' , `` temp '' :25 } ; var result = a [ `` PowerOn '' ] ; al... | string to list in special format in Javascript |
JS | im about to write a complex Incoming WebHook for Rocket.Chat . To avoid a mess in one single file i took Typescript . Rocket.Chat requires a class named Script with some predefined methods like process_incoming_request ( one simple example : https : //rocket.chat/docs/administrator-guides/integrations/ ) .my current pr... | { `` files '' : [ `` src/main.ts '' ] , `` compilerOptions '' : { `` noImplicitAny '' : true , `` target '' : `` es2015 '' } } var gulp = require ( `` gulp '' ) ; var browserify = require ( `` browserify '' ) ; var source = require ( `` vinyl-source-stream '' ) ; var tsify = require ( `` tsify '' ) ; var uglify = requi... | Rocket.Chat WebHook with Typescript |
JS | The optional override for isFunction ( object ) in Underscore.js ( repo link to definition ) , reads as follows : What I 'm confused about is the || false , why is it necessary after a string comparison ? Since typeof always returns a string there should be no ambiguity ? The comment states the override fixes some type... | // Optimize ` isFunction ` if appropriate . Work around some typeof bugs in old v8 , // IE 11 ( # 1621 ) , Safari 8 ( # 1929 ) , and PhantomJS ( # 2236 ) .var nodelist = root.document & & root.document.childNodes ; if ( typeof /./ ! = 'function ' & & typeof Int8Array ! = 'object ' & & typeof nodelist ! = 'function ' ) ... | Underscore.js , why does ` isFunction ` use ` || false ` ? |
JS | I am trying to make a nodejs website that will return the length in seconds of any audio file a user chooses . So far I have it working with mp3 , wav , and flac files . But it does n't work for all .m4a or .aif filesThe code for my HTML page with javascript is below : I gathered 6 different files for testing , and aft... | choose audio file to get length : < input style= '' cursor : pointer ; '' type= '' file '' id= '' file '' multiple= '' multiple '' / > < script > //when files are selected : $ ( `` # file '' ) .change ( async function ( e ) { console.log ( 'file ( s ) selected ' ) //get files var files = e.currentTarget.files ; //get n... | cant get length of m4a audio file on webpage |
JS | How can a stream be closed within a for-loop ? I am attempting a HTTP/2 resource push-stream within a loop by reading a .json config file . If there is only one resource in the resurce.file , type , the push is successful . If there are more than one resource in the config , only the first resource listed is pushed and... | // Verify if client can be pushed to : if ( res.push ) { // Read what resources should be pushed via config.json5 : for ( var i = 0 ; i < confg.resource.length ; i++ ) { // Compare what URL requested the resources & pass the relevant files : if ( req.url == confg.resource [ i ] .url ) { // Request the resource ( s ) to... | HTTP/2 : stream.end using For-Loop |
JS | I just saw javascript code about sorting which uses setTimeout as shown It is interesting because in js setTimeout is asynchronous so if you wait for sufficient time , result will be sorted array . It is deterministic depends on only values of data but not the size of the input so I have no idea how to determine Big-O ... | var list = [ 2 , 5 , 10 , 4 , 8 , 32 ] ; var result = [ ] ; list.forEach ( n = > setTimeout ( ( ) = > result.push ( n ) , n ) ) ; | How to determine Big-o complexity if it only depends on values of input rather than input size ? |
JS | W.r.t Hoisting of fxn definitions . Chrome , some 2-3 months ago - would print 2 . Now , it 's printing 1 . Did I miss something or , did console stop hoisting on fxn 's ! DEMO -- prints 1 . I 'm not sure where to find demo of the older browser version . Probably older v8 engine 's node installation ? .Current chrome v... | if ( true ) { function foo ( ) { alert ( 1 ) } } else { function foo ( ) { alert ( 2 ) } } foo ( ) | function definitions not hoisted |
JS | I am trying to use simple form with my rails 4 app.I have a project model , which has a scope model . Scope belongs to project . I have a third model , called participant , which belongs to scope . Scope accepts nested attributes for participant and project accepts nested attributes for scope.When I create a new projec... | $ ( document ) .on 'change ' , ' # ' + inString + '_scope_attributes_if_participant ' , ( ) - > if $ ( ' # ' + inString + '_scope_attributes_if_participant ' ) .is ( ' : checked ' ) $ ( ' # participationrequest ' ) .show ( ) else $ ( ' # participationrequest ' ) .hide ( ) < % = s_all.input : if_participant , : as = > :... | Simple Form - Rails 4 - editing |
JS | I have written the function for camel-casing strings ( the requirement is to kick-up the characters in the beginning of a word and after each hyphen , which is targeting personal names ) .Now , I 'd like to make my camel happy so that even the first character of the string ( not succeeding space nor hyphen ) , will be ... | function sadCamelize ( input ) { return input.toLowerCase ( ) .replace ( / ( [ -\s ] ) ( . ) /g , function ( match , separator , starter ) { return separator + starter.toUpperCase ( ) ; } ) ; } | Making the camel happy in camel case conversion |
JS | I am running Edge/15.15063 . 'Can I Use ' says const should work.Running : Then : Returns Screenshot : Why is n't const working ? | const x = 'woo ' console.log ( x ) ' x ' is undefined | const does n't work in Edge 15 developer tools |
JS | I 'm working on a WordPress theme with a lot of jQuery in it . By default , WordPress does n't allow you to use the $ shortcut and you have to use the full jQuery instead - e.g . jQuery ( '.class ' ) rather than $ ( '.class ' ) .This is n't too much of a hassle over a few lines of code , but I 've got a lot now , so I ... | ( function ( $ ) { ... my functions here ... } ) ( window.jQuery ) ; < a onclick= '' loadFullPost ( ' < ? =get_permalink ( ) ? > ? ajax=true ' , ' < ? = $ post- > post_name ? > ' , < ? = $ post- > ID ? > ) '' > Read more < /a > $ ( `` # target '' ) .click ( function ( ) { loadFullPost ( ' < ? =get_permalink ( ) ? > ? a... | After remapping jQuery to $ in my WordPress theme , I can no longer trigger functions from outside the js file |
JS | I 've been trying to see if I can build my JavaScript objects as intuitively as possible while making sure it 's as 'correct ' as possible . I 've been running a bunch of different scenarios through Crockford 's JSLint.com and have n't had much luck . I seem to fix one error , then another pops up because of the change... | function gizmo ( id ) { /* private variables */ var myId = id ; /* private methods */ var init = function ( ) { if ( myId < 1 ) { setId ( 1 ) ; } } ; var setId = function ( newId ) { myId = newId ; } ; // run 'constructor ' init ( ) ; /* public methods */ return { getId : function ( ) { return myId ; } , setId : functi... | What 's the best way to built a JavaScript object so that it works AND passes JSLint ? |
JS | Please try and run the following snippet , then click on the box.What I expect to happen : Click happensBox starts translating horizontally by 100px ( this action takes two seconds ) On click , a new Promise is also created . Inside said Promise , a setTimeout function is set to 2 secondsAfter the action is completed (... | const box = document.querySelector ( '.box ' ) box.addEventListener ( 'click ' , e = > { if ( ! box.style.transform ) { box.style.transform = 'translateX ( 100px ) ' new Promise ( resolve = > { setTimeout ( ( ) = > { box.style.transition = 'none ' box.style.transform = `` resolve ( 'Transition complete ' ) } , 2000 ) }... | Why does setting CSS property using Promise.then not actually happen at the then block ? |
JS | I know this is a common question , and I 'm a JS newbie , but I 'm completely stumped even after searching StackOverflow for hours.I 'm using the Google Maps API , and want to keep track of my markers by association with an ID . So I have var pinArray = new Object ( ) as a global variable , and add markers like this : ... | function CreateMarkers ( data ) { data.forEach ( function ( store ) { < ! -- CREATE MAP MARKER -- > var mapLat = store.latitude ; var mapLong = store.longitude ; var mapLatLng = { lat : parseFloat ( mapLat ) , lng : parseFloat ( mapLong ) } ; var marker = new google.maps.Marker ( { position : mapLatLng , title : store.... | Adding Properties to Global Objects |
JS | This is more of an organisation question concerning Jquery.Using the following simple example : Now multiply this by a 1000 on your website , it can quickly get messy . You also can forget which classes you attributed for Jquery or for your CSS . I usually try to avoid mixing both , so I add my classes for CSS and othe... | < a href= '' # '' class= '' click '' > click me < /a > < script > $ ( document ) .ready ( function ( ) { $ ( '.click ' ) .on ( 'click ' , function ( ) { alert ( 'Clicked ! ' ) ; } ) ; } ) ; < /script > | What is the best way keep track of your identifiers for your Jquery and CSS ? |
JS | Stats has_many Results . When a user goes to edit a stat the result 's date format switches to [ Month ] [ Day ] [ Year ] even if the category was a monthly averaged , which means the date format should have remained [ Month ] [ Year ] .stat.jsIn the _form the user chooses a category & can add results : To further clar... | $ ( document ) .ready ( function ( ) { $ ( '.date-format-switcher ' ) .click ( function ( event ) { event ; if ( $ ( this ) .attr ( 'id ' ) == 'stat_categories_instance ' ) { $ ( '.day ' ) .show ( ) ; } else if ( $ ( this ) .attr ( 'id ' ) == 'stat_categories_averaged ' ) { $ ( '.day ' ) .hide ( ) ; } } ) $ ( '.add-for... | How to keep date format based on its category ? |
JS | I have this text : The original format without replacing spaces and break lines is : I want to extract information in the BASE CÁL PREV SOC column only in rows 01 and 07 , but sometimes 07 does n't exist . Row 13 will be ignored.So I want to have a given phrase and matching groups in one regular expression.Just to be c... | 'BASE CÁL PREV SOC BASE CÁL 13º PREV SOC 01 672 1.653.806,08 18.512,98 1.667.621,57 2.647,38 07 23 12.965,11 0,00 12.965,11 0,00 13 5 10.517,81 0,00 10.517,81 0,00 TOTAIS : 700 1.677.289,00 18.512,98 1.691.104,49 2.647,38 ' NUMBER OTHER OTHER OTHER BASE CÁL PREV SOC BASE CÁL 13º PREV SOC 01 672 1.653.806,09 18.512,98 1... | Capture two groups of numbers with a regular expression |
JS | I want to integrate SimpleModal in My ListView edit action so when the user click edit , the modal popup loaded with data through ajax to edit the form .My simple listview : My Bind Code : From FireBug : | < asp : ListView ID= '' lv_familyrelation '' runat= '' server '' ItemPlaceholderID= '' RelationContainer '' > < LayoutTemplate > < fieldset id= '' FieldSet1 '' > < legend > Relations < /legend > < div class= '' container-fluid '' > < div class= '' row '' > < div class= '' col-lg-4 '' > Code < /div > < div class= '' col... | How to use SimpleModal in listView edit action |
JS | I 've got this system where I want to add in a favoriting feature where when someone clicks on the like button on a card it gets saved and displayed at port/wishlist.html but not able to go about and solve it , here is my Github Repository and some main codes.models.pyviews.pylike.js | from django.db import modelsfrom django.contrib.auth.models import Userimport datetimeYEAR_CHOICES = [ ] for r in range ( 1980 , ( datetime.datetime.now ( ) .year + 1 ) ) : YEAR_CHOICES.append ( ( r , r ) ) class Music ( models.Model ) : song = models.CharField ( max_length=50 , blank=False ) pic = models.ImageField ( ... | Adding items to Wishlist | Django |
JS | I am trying to implement a slip-scroll parallax type effect using CSS and JavaScript . When the screen scrolls down , the logo in the top right will change it 's background to contrast with what is below . There is also a nav button on the left that does the same.I have this so far ... The Logo on the right is behaving... | // Detect request animation framevar scroll = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.msRequestAnimationFrame || window.oRequestAnimationFrame // IE Fallback , you can even fallback to onscroll || function ( callback ) { window.setTimeout ( callbac... | Change logo div background color as it scrolls |
JS | I want a window to close only when pop_up is clicked ( as opposed to clicking div contents ) . E.g . clicking the background layer hides the div . In the code below I do n't want it to close # pop_up when clicking the div contents bot only on `` pop_up '' .How can I do this ? | $ ( `` # pop_up '' ) .click ( function ( ) { $ ( `` # pop_up '' ) .hide ( ) ; } ) ; < script src= '' https : //ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js '' > < /script > < div id= '' pop_up '' > < div id= '' pop_up_content '' > < h1 > world < /h1 > < /div > < /div > | Jquery closing on parent click |
JS | I try to implement a Functor in JavaScript.A diagram of definition to the Functor is as follows : or in nLabhttps : //ncatlab.org/nlab/show/functorHere , as you see F ( f ) expression looks typical in category diagrams.I managed to implement Array.map as a Functor in JavaScript as follows : F = a = > [ a ] when A = 1 ,... | const compose = f = > g = > x = > g ( f ( x ) ) ; const f = a = > a * 2 ; const F = a = > [ a ] ; const A = 1 ; const FA = F ( A ) ; // [ 1 ] const Ff = compose ( f ) ( F ) ; const FB = Ff ( [ FA ] ) ; console.log ( FB ) ; // [ 2 ] | Functor implementation in JavaScript |
JS | I have a variable that contains an integer number with the condition that the number 0 ( zero ) in the variable is a separator between one number and another . The numbers will be separated and sorted based on the numbers in the numbers themselves . After that , the ordered numbers will be combined again without a sepa... | dividerSort ( 74108520159 ) ; function dividerSort ( num ) { const divider = 0 let getNum = Array.from ( String ( num ) , Number ) getNum = getNum.filter ( item = > { return item ! == divider } ) getNum = getNum.sort ( ) getNum = getNum.join ( `` ) ; console.log ( getNum ) ; } dividerSort ( 74108520159 ) ; | How to sort the digits within subgroups of a number 's digits which are separated by `` 0 '' , and remove the zeros ? |
JS | I was reading How can I get query string values in JavaScript ? on Stackoverflow and this piece of code from the first reply made me wonder why ´vars.push ( ) ´ is used like this ? But instead of this : I rewrote the code like : and it works . Now the questions are : why would someone use an array for that kind of repl... | function getUrlVars ( ) { var vars = [ ] , hash ; var hashes = window.location.href.slice ( window.location.href.indexOf ( ' ? ' ) + 1 ) .split ( ' & ' ) ; for ( var i = 0 ; i < hashes.length ; i++ ) { hash = hashes [ i ] .split ( '= ' ) ; vars.push ( hash [ 0 ] ) ; vars [ hash [ 0 ] ] = hash [ 1 ] ; } return vars ; } ... | Why array.push ( ) is used to make an object ? |
JS | I have the following code to get a key for a given object . So for the object { `` hello '' : { `` data '' : { `` a '' : `` world '' , `` b '' : `` random '' } } } if the key passed in was hello.data.a , the output would be world.I 'm trying to figure out how I can delete a property dynamically in the same fashion . So... | ( object , key ) = > { const keyParts = key.split ( `` . `` ) ; let returnValue = object ; keyParts.forEach ( ( part ) = > { if ( returnValue ) { returnValue = returnValue [ part ] ; } } ) ; return returnValue ; } | Dynamically delete object property JavaScript |
JS | Please refer to this git repository : https : //github.com/AngularClass/angular-starterThe Angular4 Webpack Starter comes with 2 files : andEach file has slightly different configurations for TypeScript.My question is regarding how these 2 files work in relation to the project.Will the tsconfig.webpack.json only be app... | tsconfig.json tsconfig.webpack.json | In the Angular4 Webpack Starter , does tsconfig.webpack.json work for webpack while tsconfig.json works for everything else ? |
JS | I have a function that gets 's an object passed into it , with key and data that is an array . I have to call the API to get additional information , which in turn are added back into the object and the whole object is returned . My first approach was incorrect because I was trying to pass the data out of the .then ( )... | function asignChecklistItems ( taskArray ) { // get all the people 's tasks passed in return new Promise ( function ( resolve , reject ) { var promises = [ ] // Task Array : { `` Person '' : [ tasks , tasks , tasks ] } for ( var person in taskArray ) { var individualTaskPerson = taskArray [ person ] // get the person '... | Javascript Run Async Code For Each Item Of For Loop With Promises |
JS | I 'm looking for ideas on how to detect objects that are in the HTML DOM , but they are not represented explicitly in the HTML source.As you may know , if I have HTML source that contains the following : ... the HTML DOM will add the < tbody > object in the object tree without changing the source code , understanding t... | < table id= '' myTbl '' > < tr id= '' row1 '' > < td id= '' name '' > George < /td > < /tr > < /table > < table id= '' myTbl '' > < tbody > < tr id= '' row1 '' > < td id= '' name '' > George < /td > < /tr > < /tbody > < /table > | Using javascript , how can I tell if an HTML object in the DOM is not in the HTML source code ? |
JS | In my current project with lots of dependencies I need a way to disable console access for specific libraries so that those files ca n't use any of the console functionality . I could of course disable console functionality by simply finding and replacing it in the library bundle , but as this project has a lot of depe... | console.log = function ( ) { } ; | Disabling console access for specific Javascript files |
JS | After deploying a new version of my application in Docker , I see my console having the following error that break my application : In this screenshot , the source that is missing is called : 10.bbfbcd9d.chunk.js , the content of this file looks like : This error happens because : On every release , we build a new Dock... | Uncaught SyntaxError : Unexpected token ' < ' ( this.webpackJsonp=this.webpackJsonp|| [ ] ) .push ( [ [ 10 ] , { 1062 : function ( e , t , n ) { `` use strict '' ; var r=n ( 182 ) ; n.d ( t , '' a '' , ( function ( ) { return r.a } ) ) } ,1063 : function ( e , t , n ) { var ... { source : Z [ De ] , resizeMode : '' cov... | How to handle new version deployement for Docker webpack application that use code splitting ? |
JS | Why does JavaScript convert parseInt ( 0000000101126 ) to 33366 instead of 101126 ? | var example = parseInt ( 0000000101126 ) ; console.log ( example ) ; //33366 | Why does JavaScript convert parseInt ( 0000000101126 ) to 33366 instead of 101126 ? |
JS | I need to loop through a simple array in a `` weird '' way.The length of my array is always a odd squared number.Let 's say the length is 49 . To make it clearer , my elements are the index of the array . So I have something like : So , you can imagine the following square matrix : I have to start with the center of th... | myArray = [ 0 , 1 , 2 , 3 , 4 ... 47 , 48 ] 0 7 14 21 28 35 421 8 15 22 29 36 432 9 16 23 30 37 443 10 17 24 31 38 454 11 18 25 32 39 465 12 19 26 33 40 476 13 20 27 34 41 48 24 , 17 , 31 , 10 , 38 , 3 , 45 , 23 , 16 , 30 , 9 , 37 , 2 , 44,25 , 18 , 32 , 11 , 39 , 4 , 46,22 , 15 , 29 , 8 , 36 , 1 , 43,26 , 19 , 33 , 12... | How to do this `` weird '' loop through my array ? |
JS | Here is an example : https : //jsfiddle.net/6kg43qfr/Code : Jquery : Html : CSS : Question : Why does n't the hover work ? | $ ( ' # foo ' ) .css ( 'background-color ' , ' # f8f7f7 ' ) ; < div id= '' foo '' > test < /div > # foo : hover { background-color : red ; } | Why does using jquery css background.color remove : hover ? |
JS | I want to extract the `` value '' attribute from the selection box which allows users to select the number of quantities of an particular item on my website.I am a newbie to both Javascript and HTML . When I do an `` Inspect Element '' I can see the attribute in the elementBut when I try to do either of the following t... | < input size= '' 2 '' type= '' text '' autocomplete= '' off '' class= '' cart_quantity_input form-control grey '' value= '' 2 '' name= '' quantity_8329349_28095_0_12035 '' > document.querySelectorAll ( `` input.cart_quantity_input.form-control.grey '' ) .value document.querySelectorAll ( `` input.cart_quantity_input.fo... | Not able to extract `` value '' attribute from +/- box DOM element |
JS | I 've created a Javascript pseudoclass and I want it to be able to dispatch custom events . Unfortunately , it seems like only DOM nodes are able to dispatch events . So , I 'm forced to associate a DOM node with every instance of my pseudoclass , so that the DOM node can dispatch events on behalf of my class.I 'd like... | jQuery ( document ) .ready ( function ( $ ) { var cat = new Animal ( $ ( ' # cat ' ) , 'Larry ' , 'Meow ' ) ; cat.domElement.on ( 'spoken ' , function ( event ) { var classInstance = $ ( this ) .data ( 'instance ' ) ; console.log ( classInstance.firstName + ' has spoken ' ) ; } ) ; cat.speak ( ) ; } ) ; ( function ( ) ... | Can regular Javascript objects dispatch events or is this only possible for DOM nodes ? |
JS | I am trying to use a closure to ensure that a function can only execute once . Sounds simple , and it works like this : I have tested the function like so : And it works as expected - 'hi ' gets alerted exactly twice.But then I try to use runOnce ( lazyLoadGrid ) as the callback to a jQuery UI event : And madness ensue... | function runOnce ( fn ) // returns copy of fn which can only execute once { var ran = false ; return function ( ) { if ( ! ran ) { fn ( ) ; ran = true ; } } ; } function lazyLoadGrid ( event , ui ) { alert ( 'hi ' ) ; } var test1 = runOnce ( lazyLoadGrid ) ; var test2 = runOnce ( lazyLoadGrid ) ; test1 ( ) ; test2 ( ) ... | Javascript closure behaves differently when bound to an event |
JS | I 'm trying to set the usemap attribute to one of these images which are added to the imagearray . The code below is a FadeSlide in javascript , but I 'd like to instantiate some map attributes over one of those images . Thanks . | < script type= '' text/javascript '' > var mygallery=new fadeSlideShow ( { wrapperid : `` fadeshow1 '' , dimensions : [ 250 , 180 ] , imagearray : [ [ `` http : //i26.tinypic.com/11l7ls0.jpg '' , `` '' , `` '' , `` Nothing beats relaxing next to the pool when the weather is hot . `` ] , [ `` http : //i29.tinypic.com/xp... | How to use usemap with a FadeSlideShow ? |
JS | I tested the following code in firefox scratchpad and got interesting result ? Two dates are different . Apparently this is due to the timezone issue . What I want is date2 result . How can I make js engine correctly treats the ISO date style ? | var date=new Date ( `` 2012-05-12 '' ) ; var date2 = new Date ( `` 05/12/2012 '' ) ; date ; /*Fri May 11 2012 17:00:00 GMT-0700 ( Pacific Daylight Time ) */date2 ; /*Sat May 12 2012 00:00:00 GMT-0700 ( Pacific Daylight Time ) */ | Javascript new date treats differently towards different date style ? |
JS | I have a ton of JavaScript from the dawn of time with function calls written like this : It seems to me that should always be equivalent to : Are these two calls always equivalent ? What about old versions of JavaScript ? It seems to me the purpose of the second THING in that first line of code is to set the context ( ... | THING.someFunction.call ( THING ) ; THING.someFunction ( ) ; var THING = function ( ) { // private vars return { // code someFunction : function ( ) { // code } } ; } ( ) ; | JavaScript Patterns : Context of Function Call |
JS | I am creating a js file that creates a ripple touch effect when you click an object . I want to assign a class to the element in the html code that is simply a color code like # f6ac32 , and then create a function in Javascript/jQuery that can pick out that color code and create a variable out of it that I can later us... | $ ( document ) .ready ( function ( ) { var rplObj , x , y , ink , color , rplDelTimer ; //fade out ripple when unclicked $ ( '.ripple ' ) .mouseup ( function ( ) { $ ( '.ink ' ) .css ( { 'opacity ' : ' 0 ' } ) ; delRipple ( ) ; } ) //Delete ripple element one second after last clickfunction delRipple ( ) { rplDelTimer ... | Find specific class out of multiple in jQuery |
JS | Is there a built-in DOM API or a jquery one to get the containing block of an element ? I am not asking how to get the containing block of an element . I am just asking if there 's already the wheel so I do n't have to re-invent it . If there is n't , I could just do : for the following HTML , for example : | let containingBlock = $ ( `` # five '' ) .parents ( ) .find ( parent = > parent.css ( `` position '' ) === ... ) ; < div id = `` one '' > < div id = `` two '' style = `` position : absolute ; '' > < div id = `` three '' > < div id = `` four '' > < div id = `` five '' style = `` position : absolute ; '' > < /div > < /di... | Direct native JavaScript or jQuery method to get containing block of an element |
JS | I have recieved object from server and trying to display its fields in table.All fields are displaying well but boolean is always displaying as `` no '' .I was trying to add filter , but result was the same . | < tr ng-repeat= '' u in ctrl.users '' > < td > < span ng-bind= '' u.id '' > < /span > < /td > < td > < span ng-bind= '' u.name '' > < /span > < /td > < td > < span ng-bind= '' u.age '' > < /span > < /td > < td > < span ng-bind= '' u.isAdmin ? 'yes ' : 'no ' '' > < /span > < /td > < /tr > | Angularjs displaying boolean from object |
JS | I created a raycaster that allows me to pick an object from the scene with my mouse like such : It works as expected when I translate the camera and when I yaw the camera , however , once I pitch the camera , the raycaster intersects the object away from where the object is rendered on screen . If I look above the obje... | this.raycaster = new THREE.Raycaster ( ) // then in onMouseDown eventthis.raycaster.setFromCamera ( this.mouse , this.camera ) let intersects = this.raycaster.intersectObjects ( this.scene.children ) this.yaw = new THREE.Object3D ( ) this.pitch = new THREE.Object3D ( ) this.camera = new THREE.PerspectiveCamera ( 70 , t... | Raycaster displaces object intersections when pitching camera in three.js |
JS | We implemented a binding for some typical Grid usages in application . It works just fine , except if you modify a store , for example add a record , you 'd see n + TWO identical records in view.When I examined store 's state , it shown n + 1 values.It goes as if I have a grid with one record shown in it and call : gri... | freqsGrid = new AwesomeGridPanel ( ) { @ Override public void createColumns ( ) { /**/ } } ; freqBinding = AwesomeGridBinding.createGridBinding ( freqsGrid , `` frequencies '' ) ; public class AwesomeGridBinding { public static FieldBinding createGridBinding ( AwesomeGridPanel grid , String property ) { return new Fiel... | FieldBinding for Grid . View remains inconsistent after adding new record to Store |
JS | I 'm studying the concept of inheritance in Javascript , and the tutorial I 'm looking at uses this code : My question is , why is it necessary to both call the parent constructor , Person.call ( this ) , and set the Student prototype equal to a new Person object ( i.e . Student.prototype = new Person ( ) ; ) ? | // define the Student classfunction Student ( ) { // Call the parent constructor Person.call ( this ) ; } // inherit PersonStudent.prototype = new Person ( ) ; // correct the constructor pointer because it points to PersonStudent.prototype.constructor = Student ; | Inheritance within Javascript |
JS | I apologize if this question is vague , but I want to build a drop down header , very similar to the one on StackOverflow that alerts you whenever you have earned a new badge , or on Twitter whenever a new tweet comes in.I 've been looking around on the internet for a tutorial , but I 'm having trouble googling exactly... | $ ( `` # alertHeader '' ) .html ( `` whatever you want to say '' ) ; $ ( `` # alertHeader '' ) .slideDown ( `` slow '' ) ; # alertHeader { position : relative ; background : # 313115 ; width:100 % ; height:30px ; display : none ; float : left ; position : relative ; z-index:10 ; } # alertText { padding-top : 2px ; marg... | SO style alert header |
JS | I have some questions about JavaScript Syntax and looking forward to understand them.First : I do n't understand about this syntax below , Example in real project : it has been used in https : //github.com/kriasoft/react-starter-kit/blob/master/src/app.jsWhat it supposes to do ? Is it the same as { Key : function ( ) {... | { Key : ( ) = > function ( ) } // Define URL routes// See https : //github.com/flatiron/directorvar routes = { '/ ' : ( ) = > render ( require ( './components/pages/Index ' ) ) , '/privacy ' : ( ) = > render ( require ( './components/pages/Privacy ' ) ) } ; { function ( ) { } } var HomePage = React.createClass ( { stat... | Basic JavaScript Syntax |
JS | I am not quite sure what the technical term for this is . I have a GUI with interactive graphics . After the user has interacted with the GUI , I need to perform some CPU intensive action . However , user input is very frequent , so I only want to call the function after e.g . 1000ms of no userinput . Below the pattern... | scheduler = ( function ( ) { var timer ; function exec ( call , delay ) { clearTimeout ( timer ) ; timer = setTimeout ( call , delay ) ; } ; return exec ; } ) ( ) scheduler ( function ( ) { alert ( 'foo ' ) } , 1000 ) ; scheduler ( function ( ) { alert ( 'bar ' ) } , 1000 ) ; scheduler ( function ( ) { alert ( 'zoo ' )... | Combined delayed function calls in Javascript |
JS | Given the following javascript object : How can i access the Property Name which is `` back '' from within the action ( ) ? I think it should be pretty simple , but if it is n't something simple than I 'll add more details.NOTE : aliases [ 0 ] is holding the name by chance , and it is not promised to hold it in the fut... | var commands = { back : { command : `` b '' , aliases : [ `` back '' , '' go back '' , '' backwards '' ] , action : function ( ) { return this.key ; //I want this to return `` back '' ( the prop name ) } , desc : `` goes back '' } } | Getting the property key from within a property 's value |
JS | At many places , I 've seen developers doing value == var comparisons , like this : I know that a == b is same as b == a , so why do people use value == var instead of var == value ? Is there a standard for this ? And if yes , which is the standard way ? | if ( 'https ' === location.protocol ) { port = 8443 ; protocol = 'wss : // ' ; isSecure = true ; } | `` value == var '' versus `` var == value '' |
JS | I try writing the following lines in the console one by oneNow problem is that how can be a variable not defined and has been declared at the same time . Is there any difference between both . | let x = y //throws error `` Uncaught ReferenceError : y is not defined '' console.log ( x ) //throws error `` ReferenceError : x is not defined '' let x = 3 ; //gives error `` Uncaught SyntaxError : Identifier ' x ' has already been declared '' x = 3 //ReferenceError : x is not defined | Is there any difference between declared and defined variable |
JS | I am currently struggling with a way to replace the play/pause icons with text while still maintaining the toggle animation . I am trying to understand exactly which JS code is rendering the icons , and secondly remove/ hide them , so they can be replaced by textI am still beginner level with JS , any help would be muc... | var tl = new TimelineMax ( ) , $ videoContainer = $ ( '.cb-video-container ' ) , $ video = $ videoContainer.find ( '.video ' ) , $ playPauseClickArea = $ videoContainer.find ( '.play-pause -- click-area ' ) , $ playPauseContainer = $ videoContainer.find ( '.play-pause -- container ' ) , $ playIcon = $ videoContainer.fi... | How to replace play/pause icon toggle with text |
JS | Introductory reading : Prototypes as `` classes '' OO JSFollowing the patterns described above I create libraries/APIs as the followingNow for library users to interact with my prototypes ( which do not supply factory functions ) they have to instantiate and initialize the objectThis is an unfriendly and verbose way of... | var Proto = { constructor : function ( ) { this.works = true ; } , method : function ( ) { return this.works ; } } ; // instantiatevar p = Object.create ( Proto ) ; // initializep.constructor ( ) ; // instantiate or initializevar p = Proto.new ( ) ; // or without bolting onto Object.prototypevar p = pd.new ( Proto ) ; ... | Handling API design and OO sugar |
JS | Currently , I use the following code to listen to the change of Sheet1 ! A1 : B2 : Because my reaction to the change is quite costly , I want to undertake it only when it is really necessary . I have two questions:1 ) If I want to listen to multi ranges , is it possible to define only ONE listener for `` Sheet1 ! A1 : ... | function addEventHandler ( ) { Office.context.document.bindings.addFromNamedItemAsync ( `` Sheet1 ! A1 : B2 '' , `` matrix '' , { id : `` myBind '' } , function ( asyncResult ) { Office.select ( `` binding # myBind '' ) .addHandlerAsync ( Office.EventType.BindingDataChanged , onBindingDataChanged2016 ) ; } ) } function... | Listen to the value change of multi ranges with debounce |
JS | I have an app with a navbar directive and basic sign up/log in functionality . I want to change some of the words on the nav bar ( from 'signup/login ' to 'sign out ' ) once the user is logged in , but I ca n't figure out the best ( or even one ) way to do this . I 've tried setting the value of the variable/binding I ... | < nav class= '' navbar navbar-static-top navbar-inverse '' > < div class= '' container-fluid '' > < div class= '' navbar-header '' > < a class= '' navbar-brand '' href= '' # / '' > < span class= '' glyphicon glyphicon-star '' > < /span > Home < /a > < /div > < div class= '' collapse navbar-collapse '' id= '' bs-example... | How to dynamically update directive once user is logged in ? |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.