lang stringclasses 4
values | desc stringlengths 2 8.98k | code stringlengths 7 36.2k | title stringlengths 12 162 |
|---|---|---|---|
JS | I came through this fun quiz on the internet.and the choices were : [ 2,1,1 ] [ 2 , undefined , 1 ] [ 2 , 1 , 2 ] [ 2 , undefined , 2 ] I picked solution 2 TBH , basing that on that x has been redefined , y was declared and defined with no value , and that f has a different scope hence getting the global x memory spot ... | console.log ( ( function ( x , f = ( ( ) = > x ) ) { var x ; var y = x ; x = 2 ; return [ x , y , f ( ) ] } ) ( 1 ) ) | declaring a variable twice in IIFE |
JS | In chapter 7.7 ( Punctuators ) of the ECMAScript spec ( http : //www.ecma-international.org/publications/files/ECMA-ST/ECMA-262.pdf ) the grid of punctuators appears to have a gap in row 3 of the last column . This is in fact the space character punctuator , correct ? I understand that space characters may be inserted ... | function x ( ) { } var x ; return x ; typeof x ; new X ( ) ; return false ; if ( x ) { } else if ( y ) { } else { } | The space character as a punctuator in JavaScript |
JS | I just read the underscope source code , and can not get the point from this code : why length===+length ? I guess this used for force to convert if length is not a number ? Could somebody give me a hand ? | _.each = _.forEach = function ( obj , iterator , context ) { if ( obj == null ) return obj ; iterator = createCallback ( iterator , context ) ; var i , length = obj.length ; if ( length === +length ) { // why +length ? for ( i = 0 ; i < length ; i++ ) { iterator ( obj [ i ] , i , obj ) ; } } else { var keys = _.keys ( ... | What is the code `` length === +length '' mean in JavaScript ? |
JS | So I am using a modified script to try to play some text from the Web Speech API.The code was originally here : Chrome Speech Synthesis with longer textsHere 's my modified variant : I am able to get this to play ONCE . Whenever I try to get it to play again , it does n't work - this is despite running speechSynthesis.... | function googleSpeech ( text , rate ) { if ( ! reading ) { speechSynthesis.cancel ( ) ; if ( timer ) { clearInterval ( timer ) ; } let msg = new SpeechSynthesisUtterance ( ) ; let voices = window.speechSynthesis.getVoices ( ) ; msg.voice = voices [ 63 ] ; msg.voiceURI = 'native ' ; msg.volume = 1 ; // 0 to 1 msg.rate =... | Chinese text plays once with Web Speech API , but not a second time |
JS | The question is simple : I have a string str , how do I check if str is one single emoji , and nothing else ? Additionally I would prefer not using another library.Match `` '' , `` ⛹♂️ '' , `` 3️⃣ '' but not `` a '' , `` '' , `` '' I 'm having trouble finding a solution but here are some things I 've tried so far : At... | console.log ( `` '' .length ) ; // 2console.log ( `` ️ '' .length ) ; // 3console.log ( `` ⛹♂️ '' .length ) ; // 6 str = `` ⛹♂️ '' ; if ( str.length ! == [ ... str ] .length ) { // is emoji ? } else { // is not emoji } let regex = / ( \u00a9|\u00ae| [ \u2000-\u3300 ] |\ud83c [ \ud000-\udfff ] |\ud83d [ \ud000-\udfff ... | Is there a way to check if a string in JS is one single emoji ? |
JS | Why is IE10 ( I have n't checked in IE11 and above ) rendering value 1 , regardless of the value I am passing in , when rendering a progress element using React ? Check out this fiddle - https : //jsfiddle.net/co4wz3ft/5/It works as expected in Chrome and Firefox . | var Hello = React.createClass ( { render : function ( ) { return < progress value= '' 50 '' max= '' 100 '' > < /progress > ; } } ) ; ReactDOM.render ( < Hello / > , document.getElementById ( 'container ' ) ) ; | React progress element has a bug on IE10 |
JS | I am trying to write an efficient algorithm in JavaScript to solve this task . Please see the next examples of input data and correct results : It can be any number of sub-arrays and any number of elements in each sub-array . What I already found is that I probably should leave only min and max values in the each sub-a... | Array : [ [ -3 , -4 ] , [ 1,2 , -3 ] ] Result : ( -4 ) * ( -3 ) = 12Array : [ [ 1 , -1 ] , [ 2,3 ] , [ 10 , -100,20 ] ] Result : ( -1 ) *3* ( -100 ) = 300Array : [ [ -3 , -15 ] , [ -3 , -7 ] , [ -5,1 , -2 , -7 ] ] Result : ( -15 ) * ( -7 ) *1 = 105 | Find the maximum product that can be formed by taking any one element from each sub-array |
JS | I have used one of the style from here : http : //tympanus.net/Development/TextInputEffects/index.htmlTo create an input directive , please see plunker : https : //plnkr.co/edit/wELJGgUUoiykcp402u1G ? p=previewThis working great for standard input fields , however , i am struggling to work wirth Twitter typeahead : htt... | app.directive ( 'floatInput ' , function ( $ compile ) { return { restrict : ' E ' , replace : true , transclude : true , scope : { elemTitle : '=elemTitle ' , elemtId : '=elemeId ' } , templateUrl : 'input-template.html ' , link : function ( scope , elem , attrs ) { var ngModelName = elem.attr ( 'input-model ' ) ; var... | Angular floating input label to use typeahead |
JS | Consider the working code below : randN is a function that takes a number and returns an RNG that , when called , will return a random int in the range [ 0 , N-1 ] . So it 's a factory for specific RNGs.I 've been using ramda.js , and learning functional programming theory , and my question is : Is it possible to rewri... | var randN = x = > ( ) = > Math.floor ( x*Math.random ( ) ) ; var rand10 = randN ( 10 ) times ( rand10 , 10 ) // = > [ 6 , 3 , 7 , 0 , 9 , 1 , 7 , 2 , 6 , 0 ] var badAttempt = pipe ( multiply ( Math.random ( ) ) , Math.floor ) randN = pipe ( always , of , append ( Math.random ) , useWith ( pipe ( multiply , Math.floor )... | Writing a parameterless function in Ramda in a point free style ? |
JS | I was running Google PageSpeed Insights on my website - www.gpsheatmap.com , and it suggested changing the loading of my stylesheets ( https : //developers.google.com/speed/docs/insights/OptimizeCSSDelivery # example ) from - To - I tried this for my stylesheets and it visibly changed the loading so you would see the p... | < link href= '' /static/css/landing-page.css '' rel= '' stylesheet '' > < script > var cb = function ( ) { var l = document.createElement ( 'link ' ) ; l.rel = 'stylesheet ' ; l.href = '/static/css/landing-page.css ' ; var h = document.getElementsByTagName ( 'head ' ) [ 0 ] ; h.parentNode.insertBefore ( l , h ) ; } ; v... | CSS Optimisation and PageSpeed Insights |
JS | In my application I would like that in a moment all the keys of my localstorage will be deleted , with the exception of all the keys that contain the word `` wizard '' .Commands such as will erase everything , and I just want to keep those that have the word `` wizard '' , I have tried in this way , but I get errors be... | localstorage.clear ( ) ; for ( var i = 0 , len = localStorage.length ; i < len ; ++i ) { //if the key not contain the word `` wizard '' will be erased if ( localStorage.getItem ( localStorage.key ( i ) ) .search ( `` wizard '' ) ==-1 ) { localstorage.removeItem ( localStorage.getItem ( localStorage.key ( i ) ) ) ; } } | Do not delete all the keys of the localstorage |
JS | I 'm playing around with two excellent libraries : js-csp and transducers.js trying to wrap my head around them ( and generators ) .I think I got a decent understanding of using channels , but when I decided to apply transducers ( which I do n't quite understand that well yet ) to them I ca n't seem to make it work . N... | import csp from 'js-csp ' ; window.csp = csp ; // Make transducervar xAdd10 = transducers.map ( function ( x ) { return x + 10 ; } ) ; // Make a channel , using the transducervar ch = csp.chan ( 2 , xAdd10 ) ; // Put a number in the channelcsp.putAsync ( ch , 1 ) ; // This throws an error error in channel transformer T... | Using transducers.js in js-csp |
JS | I 've added a twitter timeline to a website . It renders and if I click view source on the page , I can see the same twitter widget html that I added to the site : But when I grab the html from the div containing it using jquery , $ ( ' # twitterDiv ' ) .html ( ) ; it retrieves the rendered iframe that twitter generate... | < div id='twitterDiv ' > < a class= '' twitter-timeline '' href= '' https : //twitter.com/twitterName '' data-widget-id= '' 123456789012344567 '' > Tweets by @ goodName < /a > < script type= '' text/javascript '' > window.twttr = ( function ( d , s , id ) { var t , js , fjs = d.getElementsByTagName ( s ) [ 0 ] ; if ( d... | Retrieving the original html , rather than the rendered html , with jquery |
JS | The size of my JavaScript file is getting out of hand because I have hundreds of links , and each one has its own jQuery function even though they all peform basically the same task.Here 's a short excerpt : Would there be a way to abstract some of this logic so that I have only a single function instead of hundreds th... | $ ( `` # link1 '' ) .click ( function ( ) { $ ( `` .myDiv '' ) .hide ( ) ; $ ( `` # myDiv1 '' ) .toggle ( ) ; } ) ; $ ( `` # link2 '' ) .click ( function ( ) { $ ( `` .myDiv '' ) .hide ( ) ; $ ( `` # myDiv2 '' ) .toggle ( ) ; } ) ; $ ( `` # link3 '' ) .click ( function ( ) { $ ( `` .myDiv '' ) .hide ( ) ; $ ( `` # myDi... | How can I reduce the redundancies in my jQuery code ? |
JS | I 'm following the official Webpack getting started guide and I get an error on the Using a Configuration section . It says to create a webpack.config.js file with : I then run the following command : npx webpack -- config webpack.config.jsThe error I get is : Can not find module '/Users/Documents/Web_Development/tone/... | const path = require ( 'path ' ) ; module.exports = { entry : './src/index.js ' , output : { filename : 'main.js ' , path : path.resolve ( __dirname , 'dist ' ) } } ; webpack.config.json package.json.lockpackage.jsonnode_modules/dist/ index.html main.jssrc/ index.js { `` name '' : `` tone '' , `` version '' : `` 1.0.0 ... | npx webpack command can not find module webpack.config.js |
JS | i am using angular resource sails . output : undefined . How to parse this query ? | var items = sailsResource ( 'roles ' ) .query ( ) ; // GET /item $ scope.roles = items ; angular.forEach ( $ scope.roles , function ( value , key ) { console.log ( key + ' : ' + value ) ; } ) ; | how to use angular resource sails ? |
JS | Possible Duplicate : Embedding extra styles with noscript Define css if javascript is not enabled I am trying to define specific CSS styles only if Javascript is turned off . I am using : When trying to validate the page source , I get the error `` Element style not allowed as child of element noscript in this context ... | < noscript > < style type= '' text/css '' > .needjs { display : none ! important ; } .mwnojs { margin-top : 40px ! important ; } < /style > < /noscript > | How to define CSS styles if Javascript is turned off ? |
JS | I am getting as undefined value for alert ( grp ) ; , not sure what went wrong . Below there are actually 2 forms and in each form having input hidden tag . So as soon as I click 'Remove ' button , I am trying to retreive input hidden value of that form.Below is the code : HTML | < script type= '' text/javascript '' language= '' javascript '' class= '' init '' > $ ( document ) .ready ( function ( ) { var uids = [ ] ; $ ( 'table [ id^= '' example '' ] ' ) .each ( function ( ) { var tableId = ' # ' + this.id ; $ ( tableId + ' tfoot th ' ) .each ( function ( ) { var title = $ ( tableId + ' thead t... | jquery input hidden value not getting |
JS | I 'm trying to call the Binance API to get the LTC price in BTC and I tested the link on my browser `` https : //api.binance.com/api/v1/ticker/price ? symbol=LTCBTC '' How do i get the json file from that link into my javascript file ? | $ ( document ) .ready ( function ( ) { var url = 'https : //api.binance.com/api/v1/ticker/price ? symbol=LTCBTC ' ; $ .ajax ( { url : url , dataType : 'jsonp ' , type : 'GET ' , success : function ( data ) { console.log ( data ) ; //returns nothing } } ) ; } ) | Why does my API call work in chrome but not in my code ? |
JS | I have the following code and I want to make the deck array full of 52 different cards . Whenever I run the code and the card object is alerted it displays as ' [ object Object ] '.Can someone explain to me why it does this and a solution for this problem ? | var suits = [ `` Clubs '' , `` Diamonds '' , `` Hearts '' , `` Spades '' ] ; var ranks = [ `` A '' , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , `` J '' , `` Q '' , `` K '' ] ; var deck = [ ] ; for ( var i = 0 ; i < suits.length ; i++ ) { for ( var j = 0 ; j < ranks.length ; j++ ) { var card = { rank : ranks [ j ] , suit : su... | Giving an object property an array value ? |
JS | I am trying to bind the src attribute of an img tag in an aurelia component , how can I do so ? I 'm creating some images in a reapeat.for loop this way : In which , the memberPictures array comes from the view model , and the value of picture is a relative address : ../../../assets/pictures/img_avatar.png.In the view ... | < img repeat.for= '' picture of infoboard.memberPictures '' src.bind= '' picture '' > this.httpClient.fetch ( ` boards/membersof/ $ { this.infoboard.id } ` ) .then ( response = > response.json ( ) ) .then ( data = > { this.infoboard.memberPictures = data.result.map ( element = > ` ../../../assets/pictures/ $ { element.... | Image source binding in Aurelia |
JS | MDN says for await ... of has two use-cases : The for await ... of statement creates a loop iterating over async iterable objects as well as on sync iterables , ... I was previously aware of the former : async iterables using Symbol.asyncIterator . But I am now interested in the latter : synchronous iterables.The follo... | async function asyncFunction ( ) { try { const happy = new Promise ( ( resolve ) = > setTimeout ( ( ) = > resolve ( 'happy ' ) , 1000 ) ) const sad = new Promise ( ( _ , reject ) = > setTimeout ( ( ) = > reject ( 'sad ' ) ) ) const promises = [ happy , sad ] for await ( const item of promises ) { console.log ( item ) }... | Using for await ... of with synchronous iterables |
JS | I 've got a tree structure . JSBIN herein the directive in the controllerThe factory is finding the correct position and adding the node . When adding a child to nodes with existing children it 's adding two children and i do n't understand why.Thanks.EDITI can lose has_children and it still produces the same result up... | scope.add_child_task = function ( ) { scope.add_task ( scope.path , '' child of `` + scope.member.name ) ; if ( ! scope.has_children ) { scope.add_children_element ( ) ; scope.has_children = true ; } } ; $ scope.add_task = function ( to , name ) { DataFactory.add_task ( to , name ) ; } ; link : function ( scope , eleme... | Why is this function executed twice ? |
JS | I need some help with dynamically calculating an HTML table column using data from other columns and using a user-defined equation.For example , if the user inputs the equation C1 + C2 * 0.5 + C3 * 0.8 into a input box the table would need to calculate the last column based on the data from the columns defined in the e... | Student ID | Homework 1 | Homework 2 | Exam points | Final Grade1 8.75 7.60 55.50 -2 9.00 4.50 63.00 -3 7.75 7.40 45.50 - Student ID | Homework 1 | Homework 2 | Exam points | Final Grade1 8.75 7.60 55.50 56.952 9.00 4.50 63.00 61.653 7.75 7.40 45.50 47.85 < div > < input id= '' equation '' > < /div > < table > < tr > <... | How to calculate HTML table columns ( using javascript or jquery ) with a user defined equation |
JS | IntroductionI 'm currently creating a templatebuilder where users can build a template for an app . The user can drag and drop multiple blocks , such as text blocks and 'custom code ' blocks . The template will be parsed within an app . Right now , a template could look like this : So , this template contains two eleme... | < section > < div class= '' row '' > < div class= '' col-sm-12 '' > < section data-type= '' code '' > < # code > < / # code > < /section > < /div > < /div > < div class= '' row '' > < div class= '' col-sm-12 '' data-type= '' container-content '' > < section data-type= '' text '' > < u > Lorem < /u > ipsum < /section > ... | Partially run code as html and as text |
JS | I am making a leafletjs based application and I want the user to be able to 'draw ' a svg image on the map . To accomplish this I am tracking the mousedown and mouseup events to define the imageBounds and using an imageOverlay to draw a svg image . I want the svg image to be stretched so it completely fits the defined ... | imageBounds = [ southwest , northeast ] ; _tempShape = L.imageOverlay ( _imageUrl , imageBounds ) ; _tempShape.addTo ( _map ) ; | Is it possible to stretch a imageOverlay in leaflet ? |
JS | I am thinking about simple problem . I have given an class for example Modelso as you can see we can create new Model objects like : let model = new Model ( ) . More complex example would look like this : And here we are at the point where i started to wander What if the object with given id already exists ? The questi... | class Model { constructor ( parameters = { } ) { this.id = parameters.id ; } } //we have some data given from API maybe ? let parameters = { id : 1 } ; let model = new Model ( parameters ) ; class Model { constructor ( parameters = { } ) { this.id = parameters.id ; this.anotherModel= nulld ; if ( parameters.anotherMode... | How to handle class object with circular references ? |
JS | I 'm working with a parent and child component . The child component has the input field and will emit the value entered by the user to the parent component like this : Now in parent component I have this : Now let 's say this happens : The user enters : abc // API call gets execute that is goodNow , user enters : abcd... | < parent-component ( sendInputValue ) = '' getInputValue ( $ event ) '' > < parent-component > getInputField ( data ) { console.log ( data ) ; // this prints the data ( Example : abc ) // then here I 'm just executing the API call ONLY if data length is 3 if ( data.length === 3 ) { this.myService.getDataFromService ( d... | How to execute API call after entering 3 characters in field ? |
JS | So I have an interval I create for each of my posts , the issue is that I load new posts and remove the old ones , so obviously I 'd like to stop the interval for the previous posts . However I ca n't seem to figure out how to do this . Could someone explain to me how to properly go about doing this ? I 'm completely l... | $ ( `` .post '' ) .each ( function ( ) { myInterval = setInterval ( `` postStats ( ' '' + $ ( this ) .attr ( 'id ' ) + '' ' ) '' , 500 ) ; } ) ; function postStats ( pid ) { //do some stuff } $ ( `` .button '' ) .click ( function ( ) { clearInterval ( myInterval ) ; } ) ; | JavaScript/jQuery clearInterval being set in .each |
JS | So I have this neat little javascript function that I 'm using to print text to the browser window in a cool command-prompty style . It takes a string and prints it one character at a time to the window at a set interval . Here it is : ( I have cut out all the unnecessary parts so that this will work as a standalone ex... | < ! DOCTYPE html PUBLIC `` -//W3C//DTD XHTML 1.0 Transitional//EN '' `` http : //www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd '' > < html xmlns= '' http : //www.w3.org/1999/xhtml '' > < head > < title > < /title > < script type= '' text/javascript '' src= '' http : //code.jquery.com/jquery-1.4.4.min.js '' > < /scri... | I need a workaround for a safari/chrome bug that is becoming a thorn in my side |
JS | From the API I 'm working on I need to take 2 different lists and I need to take in chunks of 20 items to avoid server timeouts.What I built actually is this : With this code I 'm downloading the entire list of objects.Both the query return : Basically it is a pagination system.Both services are like this : I do n't re... | Items1.query ( ) . $ promise.then ( function ( data ) { $ scope.items1 = data.list ; return Items2.query ( ) . $ promise ; } ) .then ( function ( data ) { $ scope.items2 = data.list ; } ) ; { list : [ ... ] , next : true , limit : 20 , last : 20 } App.factory ( 'Items1 ' , [ ' $ resource ' , function ( $ resource ) { r... | Angular $ resource recursive query |
JS | Is it possible to use the optional chaining operator in the left side of an assignment = in Javascript ? | const building = { } building ? .floor ? .apartment ? .number = 3 ; // Is this possible ? | Optional chaining on the left side in Javascript |
JS | I have two javascript objects : I want to only keep the fields of a that are different from the default : The goal is to remove default values from an object that serves as a state ( via URL ) . The state can have nested fields , so a shallow compare is not enough . The leaf values are all primitive ( number , string ,... | var a = { x : 1 , y : { faz : 'hello ' , baz : `` } , z : [ 1 , 2 ] } ; var defaults = { x : 2 , y : { faz : `` , baz : `` } , z : [ 1 , 2 ] } ; a = remove_defaults ( a , defaults ) ; // < -- -- i need this fnc { x : 1 , y : { faz : 'hello ' } } | remove default values from an object |
JS | I have a jsfiddle here - http : //jsfiddle.net/stevea/QpNbu/3/ - that collects the outerHTML for all elements that have class='active ' . What amazes me is that even if I comment out some of the HTML , as in : outerHTML still brings it back ! This ca n't still be in the DOM so I 'm wondering where outerHTML is looking.... | < ! -- < div > 'Some inner text ' < /div > -- > | Why does outerHTML bring back < ! -- -- > comments ? |
JS | The Value of e is still 15 . | var e = 15 ; function change_value ( e ) { e = 10 ; } change_value ( e ) ; console.log ( e ) ; | How to change the value of variable in a function in javascript ? |
JS | Hey i have the following statechange event set on the window : i 'm using history.js but that does n't matter in this case as it binds the statechange regulary , i am getting the value of file like should be and works fine . Now i have this code ( and other code ) inside an external js file , inside the file i 'm itera... | History.Adapter.bind ( window , 'statechange ' , function ( e ) { console.log ( `` statechange event occured `` ) ; //more code var newDoc = document.open ( ) ; newDoc.write ( file ) ; newDoc.close ( ) ; } ) ; $ ( element ) .on ( `` click '' , function ( e ) { e.preventDefault ( ) ; //more code History.pushState ( { fi... | what happens to window events when changing documents ? |
JS | How can I achieve this in react native ? So far I have this and I want to implement the middle curve . I do n't know to either handle it with a transparent view or switch to SVG completelyand this the tabBar component | /* eslint-disable react/prop-types */import React , { Component } from 'react'import { TouchableOpacity , Text , StyleSheet , View } from 'react-native'import { Colors } from 'App/Theme'export default class TabBar extends Component { render ( ) { let { renderIcon , getLabelText , activeTintColor , inactiveTintColor , o... | create a curved bottom navigation ( before after implementation ) |
JS | I was trying to read and understand the source code of jQuery . But I ca n't find any information about the below part . I tried to understand the comments beside it , but ca n't get any helpful meaning from it.I also debugged the code and found that both module and define are undefined . I wondered where does the modu... | if ( typeof module === `` object '' & & module & & typeof module.exports === `` object '' ) { // Expose jQuery as module.exports in loaders that implement the Node // module pattern ( including browserify ) . Do not create the global , since // the user will be storing it themselves locally , and globals are frowned //... | What are 'module ' and 'define ' in JQuery source code ? |
JS | I am trying to create a class applier that would wrap the selection in the following element : I am doing the following : This yields the following : What is the syntax to create the applier so that it does what I am trying to do ? | < code class= '' mainClass selector1 selector2 '' > Selected Content < /code > var Applier = rangy.createClassApplier ( `` mainClass '' , { elementTagName : `` code '' , elementProperties : { className : [ `` selector1 '' , `` selector2 '' ] } } ) ; Applier.toggleSelection ( ) ; < code class= '' mainClass selector1 , s... | Rangy.js - createClassApplier with Multiple Classes |
JS | I 've found that working with integers in Ruby causes them to act different than JS when their binary representation is larger than 32 bits.JS : Ruby : My question is how can I convert my Ruby code to give the same return values JS ? | a = 144419633058839139324b = 3903086624 a > > 0 ; = > 1482555392b > > 0 ; = > -391880672 a > > 0 = > 144419633058839139324 [ a ] .pack ( ' V ' ) .unpack ( ' V ' ) .first = > 1482560508 [ b ] .pack ( ' V ' ) .unpack ( ' V ' ) .first = > 3903086624 | How to truncate large integers during bitwise operations to mimic JavaScript in Ruby ? |
JS | For very complicated reasons , I 'm researching to better understand the internals of Node.JS , and have discovered two functions of unknown purpose.These are the functions and how to access them.From their native code declarations , it 's clear they wrap the following V8 functions : I 've also made a little snippet th... | process.binding ( 'util ' ) .setHiddenValueprocess.binding ( 'util ' ) .getHiddenValue v8 : :Object : :SetPrivatev8 : :Object : :GetPrivate 'use strict ' ; var binding = process.binding ( 'util ' ) ; var o = { } ; binding.setHiddenValue ( o , 7 , 'testing123 ' ) ; console.log ( binding.getHiddenValue ( o , 7 ) ) ; // r... | What are Node.JS 's getHiddenValue and setHiddenValue functions , which wrap V8 's GetPrivate and SetPrivate ? |
JS | If I execute the following snippet in FireBug console it somehow prints surprise ! : But why ? UPDI am sorry , people , that was a joke ! Jere is the first who noticed ! Yesterday I found a ZERO WIDTH SPACE in a string , and had since then temptation to have some fun = ) | [ 'surprise ! ' , 'boring ' ] [ Number ( 0== '' '' ) ] | Javascript : strange comparison behaviour |
JS | I am using clipping paths to change my logo colour base on the background colour.In addition to this the logo scrolls from top to bottom based on the users vertical position on the page . Top of page = logo at top , bottom of page = logo at bottom etc.Unfortunately when I added the clipping paths the logos lost their s... | div class= '' logo-scroll '' > < div class= '' scroll-text '' > < a href= '' /home '' > < img width= '' 53px '' height= '' 260px '' src= '' /wp-content/uploads/2019/07/sheree-walker-web-design-edinburgh-vertical-01.svg '' / > < /a > < /div > < /div > const docHeight = Math.max ( document.documentElement.scrollHeight , ... | Recalculate scrolling div position when used in a clipping path |
JS | Let 's say I have a string : `` We.need..to ... split.asap '' . What I would like to do is to split the string by the delimiter . , but I only wish to split by the first . and include any recurring .s in the succeeding token.Expected output : In other languages , I know that this is possible with a look-behind / ( ? < ... | [ `` We '' , `` need '' , `` .to '' , `` ..split '' , `` asap '' ] | How to split a string by a character not directly preceded by a character of the same type ? |
JS | I have the below constructors and SubType prototype pointing to an instance of SuperType . When I do x.isPrototypeOf ( SubType.prototype ) it returns false . I am confused as I have explicitly set x as a prototype for SubType . Can someone tell me why this is happening ? | function SuperType ( ) { } function SubType ( ) { } x = new SuperType ( ) ; SubType.prototype = x ; SubType.prototype.constructor = SubType ; console.log ( x.isPrototypeOf ( SubType ) ) // returns falseconsole.log ( SuperType.prototype.isPrototypeOf ( SubType.prototype ) ) // returns true | Why does isPrototypeOf ( ) return false ? |
JS | UPDATE : @ spenibus helped me reach the conclusion that this may be an issue with JSDoc itself . I added my findings to this open issue on their GitHub . @ spenibus found a solution , but it requires a slightly altered version of the IIFEI 'm using an IIFE in a CommonJS module to be able to work with CommonJS and fallb... | /** * This is a description * @ module someModule */ ( function ( exports ) { /** * Returns true if something . * @ param { String } type * @ returns { boolean } * @ static */ var isSomething = function isSomething ( type ) { return true ; } ; exports.isSomething = isSomething ; } ) ( //if exports exists , this is a no... | JSDoc CommonJS with exports object passed into IIFE |
JS | I am developing an angularJS web app where i need to scan a package from mobile device and i am using bridgeit for that.In angular i wrote the following code to execute the functionality but it does n't seems to work.HTML CODE : JS CODE : Result : bridgeit will able to scan the qr/bar code but its does n't returning th... | < input id= '' inp '' / > < button id= '' scan '' ng-click= '' scan ( ) '' > Scan < /button > // inside angular controller $ scope.scan = funcction ( ) { bridgeit.scan ( 'scan ' , 'window.scan ' ) ; } // in global scopewindow.scan = function ( event ) { alert ( event.data ) ; } | Integration of AngularJS and Bridgeit.js ( mobile web app ) |
JS | I want to limit the Angular UI Datepicker to be between two dates passed in as variables . Preferably I 'd like to get it working without adding a library like momentjs , because this is the only field in which I need to work with dates.Here is a plunker of this problem : http : //plnkr.co/edit/zsjpoVZtHqJLIP2RW6vm ? p... | mycurrentdate = '2016-04-18'mymindate = '2016-04-01'mymaxmonth = '2016-05-01'mymaxdate will be calculated from mymaxmonth to bemymaxdate = '2016-05-31 ' $ scope.maxDate = new Date ( $ scope.mymaxmonth + ( TO THE END OF THE MONTH ) ) ; $ scope.minDate = new Date ( $ scope.mymindate ) ; $ scope.mymindate = '2016-04-01 ' ... | AngularUI Datepicker disable dates outside of range |
JS | So I 'm currently using csvtojson in order to convert a csv file to , well , json , and my code is returning an array of unnamed objects . However , I want these objects to be named . More specifically , I want to use the values from the first column in order to name the objects.My CSV file looks like this : First Name... | // require the csvtojson converter classvar Converter = require ( `` csvtojson '' ) .Converter ; //create a new converter objectvar converter = new Converter ( { } ) ; //call the fromFile function which takes in the path to the csv file , as well as a callback functionconverter.fromFile ( `` ./restaurants.csv '' , func... | How to add names to an array of unnamed JSON objects ? |
JS | Consider the following Typescript snippet : Animals can have babies , and a baby should be the same kind of animal as the parent , i.e. , should be an instance of the same class as the parent . How do I assign types in this situation , so that Typescript knows that sorachiJr : Cat ? The code snippet above does n't work... | class Animal { constructor ( name : string ) { this.name = name ; } name : string ; haveBaby ( name : string ) : ? ? return type ? ? { return new this.constructor ( name ) ; // Error } } class Cat extends Animal { } class Dog extends Animal { } class Gerbil extends Animal { } // etc.let sorachi = new Cat ( `` Sorachi '... | Can Typescript infer the type of an instance of an extension class instantiated by a method of its base ? |
JS | I am trying to custom handle response sent to caller due to RAML specification failure . At the moment my code does the following.This works well but the response sent to caller when validation fails is shown below.This is great , but I do not want to send all this info to caller . I want just log it locally and just s... | const cfg = require ( `` ./cfg '' ) ; const log = require ( './logging ' ) ; const RAML = require ( 'osprey ' ) ; const startMessage = `` My Service started on port `` + cfg.SERVER_PORT + `` at `` + cfg.API_MOUNT_POINT ; // start an express serverconst start = x = > { // server dependencies const fs = require ( 'fs ' )... | Osprey RAML Validation Error Handling |
JS | Building on from some good standard Ionic 2 plunkers here http : //plnkr.co/edit/ZsoPeE ? p=preview and http : //plnkr.co/edit/WBeRRJyYucLwvckjh5W7 ? p=previewCan you help tweak my Master/Detail Plunker ? I thought I had all the parts in place but missing something as it produces a white screen.Here is my attempt at a ... | import { NgModule } from ' @ angular/core ' ; import { IonicApp , IonicModule } from 'ionic-angular ' ; import { AppComponent } from './app.component ' ; import { HomePage } from '../pages/home/home ' ; import { MasterPage } from '../pages/master/master ' ; import { DetailPage } from '../pages/detail/detail ' ; import ... | Creating a Master/Detail app in Plunker with Ionic 2 |
JS | I 'm trying to build a really simple slider . I want to use CSS3 transitions for the animations and js to apply an animate-in and animate-out class to individual frames in sequence.I 've written a working demo of the basic intended functionality on jsfiddle here : http : //jsfiddle.net/7myKg/3/It 's very simple . A fra... | < div class= '' slider '' id= '' slider '' > < ul > < li id= '' frame1 '' class= '' animate-out '' > < p > one < /p > < /li > < li id= '' frame2 '' class= '' animate-in '' > < p > two < /p > < /li > < li id= '' frame3 '' > < p > three < /p > < /li > < /ul > < /div > | Firefox not updating DOM before CSS3 transition |
JS | Im trying to load a simple example network created with keras in the browser using keras-js . After saving the model as .h5 file and converting it to a .bin file I get following error while loading it : The model is simply created by : Then I convert it with : and load it in javascript with : I have tried it with keras... | *Error : [ Model ] Model configuration does not contain any layers . * from keras.models import Sequentialfrom keras.layers import Dense , Activationmodel= Sequential ( ) model.add ( Dense ( 10 , input_shape= ( 1 , ) ) ) model.add ( Activation ( 'relu ' ) ) model.add ( Dense ( 1 ) ) model.compile ( optimizer='rmsprop '... | keras-js `` Error : [ Model ] Model configuration does not contain any layers . '' |
JS | I have learnt recently while debugging , that undefined is a data type and null is an object.I think both of them comes under datatypes.I checked the typeof undefined and typeof null . They returned `` undefined '' and `` object '' respectively . Could some body explain why is this strange behaviour . | typeof undefined `` undefined '' typeof null '' object '' | why undefined is a data type |
JS | Magically formatted comments will change the reported line number of javascript errors in some browsers ; They look like this : n is the line number and f is the file name . Unfortunately , // @ line appears to be ungoogleable . Does anyone know where there is documentation on this feature , and which browsers support ... | // @ line n `` f '' | Javascript line number mapping |
JS | I have a sortable div ( # sortable ) with elements ( .draggable ) inside it . In there , when I sort elements from bottom to up , the elements can easily be sorted by dragging up and I do n't have to drag much to the top . But when sorting elements from up to bottom , I have to drag the element far below then wanted . ... | $ ( ' # content # sortable ' ) .sortable ( { handle : '.drag_handle ' , placeholder : `` ui-state-highlight '' , axis : `` y '' } ) ; $ ( ' # blocks .draggable ' ) .draggable ( { helper : `` clone '' , revert : `` invalid '' , connectToSortable : ' # content # sortable ' } ) ; | Is there any way to control the sorting of elements when using jquery ui |
JS | I am looking at the source for React 16.4.2 and noticed something that is a bit unfamiliar to me and was wondering how it works . Here is the code : As you can see , there is a variable being declared called validaeFormat and it is being assigned a function as its ' value . That makes sense to me . However , immediatel... | var validateFormat = function validateFormat ( format ) { } ; { validateFormat = function validateFormat ( format ) { if ( format === undefined ) { throw new Error ( 'invariant requires an error message argument ' ) ; } } ; } | What does this React code with an anonymous closure do for validateFormat ? |
JS | I 'm using Javascript to create a web app with Soundcloud 's API for my portfolio . At my current stage I need to be able to create a new set ( aka playlist ) . I was using the sample code from Soundcloud 's docs : But I 'm getting a 422 error : Unprocessable Entity - The request looks alright , but one or more of the ... | SC.connect ( function ( ) { var tracks = [ 22448500 , 21928809 ] .map ( function ( id ) { return { id : id } } ) ; SC.post ( '/playlists ' , { playlist : { title : 'My Playlist ' , tracks : tracks } } ) ; } ) ; | Creating a Set With Soundcloud 's API |
JS | Consider this snippet from AngularJS by Brad Green.Notice that for the `` butterbar '' directive he passes in an array where the first item is just a string with the dependency name `` $ rootScope '' , and the second item is a function . That function declares a dependency on $ rootScope . Why do we repeat ourselves he... | var directives = angular.module ( 'guthub.directives ' , [ ] ) ; directives.directive ( 'butterbar ' , [ ' $ rootScope ' , function ( $ rootScope ) { return { link : function ( scope , element , attrs ) { element.addClass ( 'hide ' ) ; $ rootScope. $ on ( ' $ routeChangeStart ' , function ( ) { element.removeClass ( 'h... | Why do they pass arrays all over in AngularJS ? |
JS | I know this is frowned upon , I was just exploring the idea and for the life of me can not seem to make this work the way I would want it too.The example should explain all : Of course this simply append the function definition to 'foo ' ... adding this ( ) instead doesnt work . I understand that I have lost context in... | String.prototype.MyNS = function ( ) { } String.prototype.MyNS.fooify = function ( ) { return this + 'foo ! ' ; } var theString = 'Kung ' ; alert ( theString.MyNS.fooify ( ) ) ; | Just curious how to subclass the String object . ( prototypically ) |
JS | I have an HTML table with dropdowns . What I am doing is on clicking on a button . I am showing HTML Table which are having dropdowns , but the issue I am facing is an error which is : TypeError : t is null ; ca n't access its `` setAttribute '' propertyI am using Bootstrap4 drop-down.Here is my code : I do n't know wh... | var currentlyClickedOutlet= '' '' ; $ ( document ) .ready ( function ( ) { $ ( ' # button ' ) .click ( function ( ) { var data = [ { `` amount '' : 476426 , `` billdate '' : `` 2018-09-01 '' , `` outlet '' : `` JAYANAGAR '' } , { `` amount '' : 92141 , `` billdate '' : `` 2018-09-01 '' , `` outlet '' : `` MALLESHWARAM ... | Drop-downs are not showing in my HTML table while calling ajax or putting static JSON |
JS | I have the following build profile for a small app : The problem is this : all I need is the lodash.min.js file to be processed by the Dojo build system . Unfortunately , when you include a package definition in your profile , the build system looks at all files in the relevant directory using an implicit trees value .... | var profile = ( function ( ) { var copyOnly = function ( filename , mid ) { /* ..snip.. */ } ; return { basePath : `` ../../src '' , releaseDir : `` ../dist '' , releaseName : `` lib '' , action : `` release '' , packages : [ 'dojo ' , 'dijit ' , //'dojox ' , 'amd ' , { name : 'lodash ' , location : 'lodash ' , trees :... | Is there a way to build a Dojo module that includes a single file from the package location ? |
JS | I am following a tutorial on Udemy where the instructor is trying to explain HOC.To explain HOC , he created a function having a functional component ( at least this is what he said ) . This is the code : The React documentation displays this example : And mentions : This function is a valid React component because it ... | const withClass = ( WrappedComponent , className ) = > { return ( props ) = > ( < div className= { className } > < WrappedComponent { ... props } / > < /div > ) } function Welcome ( props ) { return < h1 > Hello , { props.name } < /h1 > ; } | What classifies as a React functional component ? |
JS | I get confused about 'this ' keyword in the following codes , there are two 'this ' : 'the_name ' is equal to 'John ' , the prototype method get the name by return this.name . But can anyone explain to me the 1st-this and 2nd-this , what do they stand for ? | var Foo = function ( string ) { this.name=string // 1st-this } Foo.prototype.get_name = function ( ) { return this.name // 2nd-this } var myFoo = new Foo ( 'John ' ) the_name=myFoo.get_name ( ) | 'this ' keyword , not clear |
JS | I 'm using React with Redux.In this example I have my class with mapStateToProps and mapDispatchToPropsI wan na push to my component LevelInfo the values difficulty and level but these 2 data arrive from getLevel ( ) that is an http request with delay.The page loads before receiving all the data from the http call.I 'm... | class EnigmaPage extends Component { constructor ( props ) { super ( props ) ; } componentDidMount ( ) { this.props.authCheckState ( ) ; } readUserData ( ) { this.props.loadLevel ( this.props.userId ) ; } render ( ) { return ( < div className= { classes.EnigmaPage } > < div className= { classes.Header } > < div > < Lev... | Load the component when all data has ready |
JS | I 'm making a form builder , I would like to change the appearance , for example color of the contents . When the class equal to active should get a white color of the text but when the rest are not active the text should be black instead.How can I do this with generated 2 class ? Anyway I found something on this forum... | $ ( '.game-star ' ) .addClass ( 'game-star2 ' ) .removeClass ( 'game-star ' ) ; .game-star ul li h3 { font-size:14px ; color : # fff ; line-height:24px ; float : left ; font-weight:100 ; margin-top:8px ; } .game-star2 ul li h3 { font-size:14px ; color : # fff ; line-height:24px ; float : left ; font-weight:100 ; margin... | jQuery replace one class with another if ul li class is active |
JS | I came across this code : new Array ( 10 ) .fill ( ' 1 ' ) .join `` ; I do not know what the meaning of the signs `` used immediately after .join is.I thought the correct syntax would be new Array ( 10 ) .fill ( ' 1 ' ) .join ( `` ) .Any ideas are welcome thanks ! | const data = new Array ( 10 ) .fill ( ' 1 ' ) .join `` ; console.log ( data ) | What does .join `` mean in JavaScript ? |
JS | I want to replace Vertical Bar ( | ) with Devanagari Danda ( । ) as soon as it is typed in textarea using javascript.First I tried the solution given on How to change characters typed in Firefox . But it adds the character to the end only.So , I followed the solution given on http : //www.jsfiddle.net/EXH2k/6/ which wa... | < ! DOCTYPE html > < html > < head > < meta http-equiv= '' Content-Type '' content= '' text/html ; charset=UTF-8 '' > < link type= '' text/css '' rel= '' stylesheet '' href= '' stylesheet.css '' / > < script type= '' text/javascript '' > function transformTypedChar ( charStr ) { return charStr == `` | '' ? `` । '' : ch... | Replacing Vertical Bar ( `` | '' ) with Devanagari Danda ( `` । '' ) as soon as it is typed in textarea |
JS | Someone at work jokingly sent out an email with a html file intended to crash your browser that was the followingAnyways it does n't do a great job of it in Chrome and a conversation arose that it created a friendly competition to see who could write javascript to make a page count to 5,000,000,000 as quickly as possib... | < html > < script type= '' text/javascript '' > function crash ( ) { for ( i=0 ; i < 5000000001 ; i++ ) { document.write ( i ) ; } } < /script > < body onload= '' crash ( ) ; '' > < /body > < /html > < html > < script type= '' text/javascript '' > function countToFiveBillion ( counter , num ) { if ( num < 5000000000 ) ... | Javascript Recursion Improvement |
JS | Am i missing something here ? I purchased Smart Mobile Studio two days ago , and been trying its features . I would expected that it would at least emulate delphi ’ s event model . No ? Should n't I be able to click on a control and have access to an events tab ( as we do for properties ) , and add a delphi style event... | unit Form1 ; interfaceuses w3system , w3ctrls , w3forms , w3application ; type TForm1=class ( TW3form ) private { Private methods } FButton : TW3Button ; protected { Protected methods } Procedure InitializeObject ; override ; Procedure FinalizeObject ; override ; Procedure StyleTagObject ; override ; end ; Implementati... | How do i use events at design time in Smart Mobile Studio ? |
JS | I have a button on my web application , which has the following code in the click event handler : Sometimes ( about 1 out of 8 ) , after selecting the file , the input event does n't fire after choosing a file . I 'm guessing this is a browser bug around the lifecycle of the element.Any way around this short of appendi... | const fileInputEl = document.createElement ( 'input ' ) ; fileInputEl.type = 'file ' ; fileInputEl.accept = 'image/* ' ; fileInputEl.addEventListener ( 'input ' , ( e ) = > { if ( ! e.target.files.length ) { return ; } // Handle files here ... } ) ; fileInputEl.dispatchEvent ( new MouseEvent ( 'click ' ) ) ; | Programmatically generated/activated file input does n't always fire ` input ` event |
JS | All my constants are near the top of my javascript file like below.When I search the core JQuery file , nothing comes up for Constant and I ca n't see that they are pulling out constants ? Do they not have any , do they have them spread out through the code , if so , why do n't they consolidate them ? I 'm not concerne... | var Constant = { VALIDATE_ON : 1 , JSON_ON : 0 , ROOT : `` , PICTURES : '../pictures/ ' , TEXT : '../text/ ' , FAVICON : '../images/logo_small.ico ' , IMAGES : '../images/ ' , GATEWAY : 'class.ControlEntry.php ' , ENTER_KEY : 13 , SECOND : 1000 , MINUTE : 60 , HOUR : 3600 , DAY : 43200 , AML : { `` PASS '' : 0 , `` FAI... | Why does n't JQuery consolidate its constants ? |
JS | I have written a javascript function for analyzing the biggest drop in an array . But one little issue is still there . As the max value , I always get max value from my hole array and not from my drop.Example : Array : [ 100,90,80,120 ] The biggest drop would be between 100 and 80 . So max must be 100 , and min 80 . M... | function checkData ( data ) { let max = 0 let min = 0 let drop = 0 for ( let i = 0 ; i < data.length ; i++ ) { if ( max < data [ i ] ) { max = data [ i ] // ? } else { let tempDrop = max - data [ i ] drop = Math.max ( tempDrop , drop ) min = max - drop } } return [ max , min , drop ] } | Get the biggest chronological drop , min and max from an array with O ( n ) |
JS | I have no idea how to search for this so I 'm asking here.I 've inherited a project and no one that 's here knows what this syntax trick is called.There 's a select drop down change event that will call a function if one or another specific value is selected from among the list.In this the show or hide function is call... | $ ( ' # accordion select [ name=x_range ] ' ) .change ( function ( ) { $ ( ' # custom-time ' ) [ $ ( this ) .val ( ) == 'custom ' ? 'show ' : 'hide ' ] ( ) ; $ ( ' # custom-time-to-now ' ) [ $ ( this ) .val ( ) == 'custom_to_now ' ? 'show ' : 'hide ' ] ( ) ; updateTimeIntervalOptions ( ) ; } ) .triggerHandler ( 'change... | What JavaScript/JQuery syntax is this ? |
JS | Drawing on canvas is working perfectly fine . Even eraser also working perfectly fine . Issue is that while canvas saved as image it 's drawing black lines instead of eraser.For better understanding I added screens shots and code.1 . While erasing the draw -a . Source code -b . Output -2 . Canvas saved as an Image -a .... | erase ( ) { this.ctx.globalCompositeOperation = 'destination-out ' ; } handleMove ( ev ) { // let ctx = this.canvasElement.getContext ( '2d ' ) ; let currentX = ev.touches [ 0 ] .pageX - this.offsetX ; let currentY = ev.touches [ 0 ] .pageY - this.offsetY ; this.ctx.beginPath ( ) ; this.ctx.lineJoin = `` round '' ; thi... | Canvas- Eraser drawing black lines over canvas after canvas saved as image |
JS | I have a pop-over modal that I am loading on my page on load , I would like to make it once it 's closed to not show up again for that user . I 've done similar things with localStorage ( ) ; but for some reason ca n't figure out the syntax to make this work.I tried a solution where it sets a class , but on refresh it ... | $ ( function ( ) { if ( localStorage ) { if ( ! localStorage.getItem ( 'visited ' ) ) { $ ( '.projects-takeover ' ) .show ( ) ; } } else { $ ( '.projects-takeover ' ) .show ( ) ; } $ ( '.projects-close ' ) .click ( function ( ) { $ ( '.projects-takeover ' ) .fadeOut ( ) ; } ) ; localStorage.setItem ( 'visited ' , true ... | Using localStorage ( ) to save a `` closed '' state on modal so it does n't show for that user again |
JS | In the following jQuery , the .each ( ) method takes two arguments : 'ul li a ' and menu . What do these two arguments mean ? HTML : | var menu = $ ( '.menu ' ) ; $ ( 'ul li a ' , menu ) .each ( function ( ) { $ ( this ) .append ( ' < span / > ' ) ; } ) ; < div class= '' menu '' > < ul > < li > < a href= '' # '' > Edit Profile < /a > < /li > < li > < a href= '' # '' > Account Settings < /a > < /li > < li > < a href= '' # '' > Appear Offline < /a > < /... | Explanation of two arguments for jQuery .each ( ) method |
JS | I have the following code to check whether the webpage can be framed or not at all : I tested it with several links , frameable or not , but always fails . Do you know exactly why ? Links : http : //www.joomlaworks.net/images/demos/galleries/abstract/7.jpghttp : //www.facebook.com ( ... ) | var req = new XMLHttpRequest ( ) ; var test = req.open ( 'GET ' , link , false ) ; console.log ( `` test '' , test ) ; //ALWAYS undefinedif ( req.send ( null ) ) { //ALWAYS throws error NS_ERROR_FAILURE var headers = req.getAllResponseHeaders ( ) .toLowerCase ( ) ; console.log ( `` headers '' ) ; } else { console.log (... | Check whether content can be displayed in iFrame does not work |
JS | I have an ecommerce site that has products with multiple attributes ( e.g . size , colour , etc , . ) On each product page there is a dropdown for each attribute with a class of 'attribute_price'.I have also preloaded hidden inputs onto the page from my database with the pricing for each product with a class of 'hidden... | $ ( `` select.attribute_price '' ) .on ( `` change '' , function ( ) { var id = event.target.id ; // determine which dropdown was changed ( size or colour ) var attribute_value = document.getElementById ( id ) .value+ ' _ ' ; // get the value of the dropdown that they selected var other_attribute_ids = [ ] var i ; var ... | Updating dropdown based on previous dropdown selection |
JS | I am developing a desktop based PHP application where we need to capture image of a person and print it on the label using Zebra GC420t printer The expected image should look like below image.When I try to print the it gives the output like below image.I am using the following code for the conversion of the rgb image t... | $ photo_url= '' '' ; if ( isset ( $ _GET [ 'photo ' ] ) ) { $ photo_url= $ _GET [ 'photo ' ] ; } function image2grf ( $ filename= ' $ photo_url ' , $ targetname = ' R : IMAGE.GRF ' ) { $ info = getimagesize ( $ filename ) ; $ im = imagecreatefrompng ( $ filename ) ; $ width = $ info [ 0 ] ; // imagesx ( $ im ) ; $ heig... | Converting RGB image to Floyd-Steinberg image using PHP or Javascript for Zebra printers |
JS | When using firebase.auth ( ) .signInWithPopup ( firebase.auth.GoogleAuthProvider ( ) ) the popover opens but does n't redirect to the accounts.google sign-in page , it goes to the page not found route of my application . I believe this is down to something with the service-worker which is made through offline-plugin . ... | // Important modules this config usesconst path = require ( 'path ' ) ; const HtmlWebpackPlugin = require ( 'html-webpack-plugin ' ) ; const WebpackPwaManifest = require ( 'webpack-pwa-manifest ' ) ; const OfflinePlugin = require ( 'offline-plugin ' ) ; const { HashedModuleIdsPlugin } = require ( 'webpack ' ) ; const T... | Service worker catching the __/auth request to Google when using Firebase Authentication inside React-Boilerplate |
JS | I always thought that an if statement essentially compared it 's argument similar to == true . However the following experiment in Firebug confirmed my worst fears—after writing Javascript for 15 years I still have no clue WTF is going on : My worldview is in shambles here . I could run some experiments to learn more ,... | > > > `` `` == truefalse > > > if ( `` `` ) console.log ( `` wtf '' ) wtf | What Are the Semantics of Javascripts If Statement |
JS | I 'm using a jQuery plugin from here http : //www.tablefixedheader.com/ to make a snazzy table with a fixed heading , sorting and other cool features . Now , I 've also looked at jqGrid , which looks ridiculously awesome , but we are doing some funky things with our data source and I do n't think it is quite ready to p... | th : first-child { position : relative ; } td : first-child { position : relative ; } var currentTop = 0 ; var currentLeft = 0 ; var currentWidth = 0 ; var currentHeight = 0 ; var currentContent = `` '' ; var currentDiv = `` '' ; var currentID = `` '' ; $ ( 'td : first-child ' ) .each ( function ( index ) { currentTop ... | How can I alter the FixedTableHeader jQuery plugin to have a fixed first column as well ? |
JS | Does the `` name '' have some special meaning in javascript ? ( checked in IE and FF ) | document.writeln ( 'name= ' + name ) ; // name =document.writeln ( 'notName= ' + notName ) ; // ReferenceError : notName is not defined | Is variable called `` name '' always defined in Javascript ? |
JS | I want to make a 'named ' bezier curve . I want it to be one-word named so I do n't have to worry about word-wrap.I make bezier curve via P5 bezier ( sx , sy , c1x , c1y , c2x , c2y , ex , ey ) function and I want a string to be shown in the middle of bezier curve . But I do n't know how to find 'the middle ' of curve.... | letb = dest.inTriangle.middle , // destination triangleg = this.outTriangle.p3 , // tip of out trianglec = { x : b.x-g.x , y : b.y-g.y } , // distance between objectsr1 = { } , // bezier point 1r2 = { } ; // bezier point 2if ( c.x > 0 ) { // b is on left r1 = { x : g.x + c.x/2 , y : g.y } ; r2 = { x : b.x - c.x/2 , y :... | How to find a middle point of a beizer curve ? |
JS | Background : I have a self-taught hobbyist level of understanding of C++ , which has translated into a similar understanding of javascript . As an attempt to understand javascript better , I decided to write a Greasemonkey script that would solve a problem with how Google handles multiple results from the same domain.I... | ( function ( ) { //code goes here } ) ( ) ; ( function main ( ) { //code goes here } ) main ( ) ; | What is this line at the top of some Greasemonkey scripts ? |
JS | I 've gotten to a point now where I can receive responses from a client website I 've made ( for internal use in the company I work at ) on my WCF Webservice . But whenever I get a response it 's always null.I 've look around for various solutions and none of them seems to fix this issue . I have the following : And im... | [ OperationContract ] [ WebInvoke ( Method = `` POST '' , RequestFormat = WebMessageFormat.Json , ResponseFormat = WebMessageFormat.Json , BodyStyle = WebMessageBodyStyle.WrappedRequest , UriTemplate = `` /AddNewActivity '' ) ] String AddNewActivity ( String jsonObject ) ; public String AddNewActivity ( String jsonObje... | Client Website always return Null Json String |
JS | I 've got the following jQuery code which I use in a Bookmarklet . It clicks on all the buttons on the page ( with the class `` Unfollow '' ) one by one , with a random time between each one ... I 'd like to run the above function again twice once it has completed its cycle.Just running the function again causes that t... | javascript : ( function ( ) { var unfollowButtons = $ ( 'button.Unfollow ' ) ; var index = unfollowButtons.length - 1 ; unfollow ( ) ; function unfollow ( ) { if ( index > = 0 ) { $ ( unfollowButtons [ index -- ] ) .click ( ) ; setTimeout ( unfollow , Math.floor ( ( Math.random ( ) * 1000 ) + 500 ) ) ; } } } ) ( ) ; | Running a jQuery function multiple times sequentially ( for a Bookmarklet ) |
JS | Is it possible to add a property ( with get and set method ) to the scope of a file without making it global ? ( Similar to how let or const would work for a variable declaration ) This is the code I 've written so far , It can add a property to the global scope.Is it possible to make the property only visible to just ... | var propertyValue ; Object.defineProperty ( global , `` PropertyValue '' , { get : function ( ) { return propertyValue ; } , set : function ( value ) { propertyValue = value ; } } ) ; console.log ( PropertyValue ) ; var fileProperties ; var propertyValue ; Object.defineProperty ( fileProperties , `` PropertyValue '' , ... | Add a property to a node file |
JS | I want to pull a tree structured set of objects from a web service represented with JSONWhen I unpack that , I 'll wind up with a structure which uses vanilla Javascript objects . What I 'd like to be able to do is bind each node to a specific class , so that method calls become available on each node of the tree.My so... | MyNode= function ( ) { this.init ( ) ; } $ .extend ( MyNode.prototype , { init : function ( ) { // do initialization here } , getName : function ( ) { return this.nodeName ; } } ) ; var tree= { nodeName : 'frumious ' , nodeType : 'MyNode ' } $ .extend ( tree , eval ( tree.nodeType+'.prototype ' ) ) ; | Binding objects parsed from JSON to classes |
JS | I am looking for a way to `` wrap '' all the $ http requests so that I can show a gif image whenever the application is doing some processing . I also want to use the same solution for other kind of background processing and not just $ http.The reason why I am asking is that I always have to set my processingIndicator ... | function processAjaxRequestSuccessFn ( fooFn ) { // display processing indicator fooFn ( ) ; // hide processing indicator } $ http.get ( ... ) .then ( processAjaxRequestSuccessFn , processAjaxRequestErrorFn ) | background processing notification for $ http requests |
JS | I 'm trying to get server side rendering to work in VueJS.I 've been following the official docs , and I 'm attempting to get this example to work using axios . The endpoint is correct and the data does show up in the mutation.https : //ssr.vuejs.org/guide/data.htmlI also found this page and tried most of these example... | import Vue from 'vue'import Vuex from 'vuex'Vue.use ( Vuex ) import { fetchPage } from './api'export function createStore ( ) { return new Vuex.Store ( { strict : true , state : ( ) = > ( { res : { } } ) , actions : { actXY ( { commit } , page ) { fetchPage ( 'homepage ' ) .then ( ( item ) = > { commit ( 'mutXY ' , { p... | VueJS sever-side-rendering : computed property not seeing changes in store |
JS | I want text I enter in a text field immediately to be shown in a div : It works , the only problem is , it is displayed with a delay . So if I enter `` abc '' , it only shows `` ab '' . I need to enter another character , for example `` abcd '' , so that it shows `` abc '' .The last character is always missing.Here you... | function func ( ) { document.getElementById ( `` query '' ) .innerHTML = document.getElementById ( `` keyword '' ) .value ; } window.onload = function ( ) { keyword.onkeydown = function ( e ) { func ( ) ; } } < input type= '' text '' id= '' keyword '' size= '' 40 '' > < div id= '' query '' > < /div > | Text is displayed with delay |
JS | I got an unexpected result . Here 's the code : I thought the second console.log should print `` 3 '' but instead I got the function itself . Why ? Meanwhile , from the code below I got the right `` 3 '' . | b = function c ( ) { console.log ( c ) ; c = 3 ; console.log ( c ) ; } b ( ) ; function ff ( ) { ff = 3 ; console.log ( ff ) ; } ff ( ) ; | Can not overwrite function from inside the function |
JS | Could anyone explain to me why the code sample below reports true ? I would have assumed that like in C # the instance of Test1 ! = instance of Test2.Update : So I think I will go with some unique identifier stored in the base of both Test1 and Test2 . | function Test1 ( ) { } ; function Test2 ( ) { } ; var test1 = new Test1 ( ) ; var test2 = new Test2 ( ) ; var dict = new Array ( ) ; dict [ test1 ] = true ; alert ( dict [ test2 ] ) ; | Understanding how javascript hashtables work |
JS | What is the difference between declaring a variable with this or var ? orWhen do you use this and when var ? edit : is there a simple question i can ask my self when deciding if i want to use var or this | var foo = 'bar ' this.foo = 'bar ' | Declaring variables with this or var ? |
JS | I 'm loading many pictures , and am using an array to do so . My Event Listener function is enabled like this : My onComplete event handler shows this : I 've looked for properties in LoaderInfo that might identify which loader initiated the listener ( the value of `` i '' ) so that I can putz around with each one spec... | loader [ i ] .load ( new URLRequest ( picture [ i ] ) ) ; loader [ i ] .contentLoaderInfo.addEventListener ( Event.COMPLETE , onComplete ) ; trace ( e.target ) ; //OUTPUT : [ object LoaderInfo ] bitmapDataArr [ i ] = e.target.content.bitmapData ; bmVisArr [ i ] = new Bitmap ( bitmapDataArr [ i ] ) ; for ( i = 0 ; i < 1... | AS3 : How do I get dynamic loader URL from LoaderInfo in Event Listener Function ? |
JS | Javascript : This is a piece of javascript code I use to detect whether my library is inside an iframe.1 out of 100 % of requests report that my library is inside an iframe which I think is not possible.Is there a possibility that this code to fail [ report true on false or vice versa ] ? From access log [ I log every ... | inFrame = true ; try { if ( window.top == self ) { inFrame = false ; } } catch ( err ) { } try { if ( window.parent.location == self.location ) { inFrame = false ; } } catch ( err ) { } | isInIframe Detection in Javascript |
JS | I 've created this D3 chart which displays the results sentiment value . However what I 'm struggling to do is place an image next to the horizontal text . Using the JSFiddle as an example , lets say 'Result 2 ' is under 20 % . There would be a sad face displayed to the right of the 'Result 2 ' text . Then if the value... | < img src= '' http : //www.clipartkid.com/images/15/cartoons-cartoon-logos-cartoon-logo-design-gHlQ6b-clipart.jpg '' alt= '' Smiley face '' height= '' 42 '' width= '' 42 '' > < img src= '' http : //www.clipartbest.com/cliparts/Rid/8EG/Rid8EGpi9.png '' alt= '' Sad face '' height= '' 42 '' width= '' 42 '' > | D3 How to place image next to horizontal line text |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.