lang stringclasses 4
values | desc stringlengths 2 8.98k | code stringlengths 7 36.2k | title stringlengths 12 162 |
|---|---|---|---|
JS | I 'm bit new and confused about Ember iterations.I 'm trying to construct a select inside ember template , like : Here , stateArrays looks like : But , this throws error . When I try { { stateArray } } , I get string like `` 1 , Albama '' ... How to achieve the above in single iteration ? | < select id= '' state_list '' > { { # each stateArrays as |stateArray| } } < option value= { { stateArray [ 0 ] } } > { { stateArray [ 1 ] } } < /option > { { /each } } < /select > [ [ 1 , `` Alabama '' ] , [ 2 , `` Alaska '' ] , [ 3 , `` Arizona '' ] ] | Looping through Array of Arrays in Ember |
JS | Although the code for the slides ( here sections ) is exactly the same , I experience a change in the font size from the 3rd to the 4th slide . I have tried to track this down but I did n't find a cause.Funnily , if I remove the title slide , this change occurs again between the 3rd and 4th slide.Any ideas ? Here are t... | < ! DOCTYPE html > < html > < head > < meta charset= '' utf-8 '' > < meta name= '' generator '' content= '' pandoc '' > < meta name= '' author '' content= '' Jan Heiland '' > < title > H_\infty-control for DAEs < /title > < meta name= '' apple-mobile-web-app-capable '' content= '' yes '' > < meta name= '' apple-mobile-... | unsolicited change of font size in mathjax in reveal.js slides |
JS | Summary : poll ( ) functions with callbacks are available ; I have n't found any using native promises . I 've tried to adapt some without success . The problem I have n't solved yet is that when the first instance of the function called by setTimeout ends without any return , the .then ( ) listening for it sees the te... | /** * poll - checks repeatedly whether a condition exists . When the condition * exists , returns a resolved standard promise . When it has checked * long enough , returns a rejected standard promise . * @ param { function } fn - a caller-supplied synchronous function that * detects a condition in the environment . Ret... | How can I keep ` .then ( ) ` alive long enough for a polling function with native promises ? |
JS | I inherited a library recently , there is an update method which exists on a class . Here is an example . This kind of code mostly only exists on performance critical stuff . Most of the rest of the project is not written this way . Floor is used twice . Surely caching it in a local variable simply forces some `` tempo... | onPointerMove ( pointer , x , y , isPressed ) { var floor = Math.floor ; var cx = this.currentX ; var cy = this.currentY ; var tm = this.toolManager ; } | Micro optimization , is it optimized anyway by modern browsers ? |
JS | I am working in a project that uses Node.js for a Haraka ( an smtp server ) plugin.This is Node.JS and I have a little problem whith callbacks . I have n't been able to convert this particular code to use a callback.So , this is the code that I have : This code does not work because It does n't wait the callback of the... | exports.hook_data = function ( next , connection ) { connection.transaction.add_body_filter ( `` , function ( content_type , encoding , body_buffer ) { var header = connection.transaction.header.get ( `` header '' ) ; if ( header == null || header == undefined || header == `` ) return body_buffer ; var url = 'https : /... | How can I make a callback that requires info of its child function |
JS | For a school project , I am trying to make a website that does stuff.To make it , I am using HTML , JavaScript , and CSS . I am using a compiler that gives debug hints . These hints are provided from JSLint . I am told that I should combine two of the variables that I have written , but I do not understand what this me... | var x = document.getElementById ( `` some id '' ) ; var y = document.getElementById ( `` some other id '' ) ; var z = document.getElementsByTagName ( `` some tag name '' ) ; | How do you `` combine variables '' in JavaScript to satisfy JSLint ? |
JS | I have the following code : How can I replace the hardcoded 128 size strings with arguments that I pass to the createThumb function ? I assume that I can not just add the additional parameter since the transformWrite property requires a function with the specific 3 parameter signature . | var createThumb128 = function ( fileObj , readStream , writeStream ) { gm ( readStream , fileObj.name ( ) ) .resize ( '128 ' , '128 ' ) .stream ( ) .pipe ( writeStream ) ; } ; var store = new FS.Store.GridFS ( `` thumbs_128 '' , { transformWrite : createThumb128 } ) | js pass additional argument to function |
JS | produces 43 in the browser.produces 43again 43However , produces 44 . The magic number of 9 's after the decimal point seems to be 15*.Why is this ? Furthermore , Does the Math.floor function accept the number as a number object , or a number value ? | document.writeln ( Math.floor ( 43.9 ) ) ; document.writeln ( Math.floor ( 43.9999 ) ) ; document.writeln ( Math.floor ( 43.999999999999 ) ) ; document.writeln ( Math.floor ( 43.99999999999999 ) ) ; | Javascript Math.floor function blunder or implementation mystery ? |
JS | I 'm looking for a way to properly replace nested custom tags with their HTML equivalents . For example , suppose we have the following text : Which should become : I 'm aware that I can - and probably should - use something like a span with a `` bold '' class instead of the old `` b '' tags , but there 's a reason I '... | This is { b : bold text } This is < b > bold text < /b > This is { b : bold text and { i : italic } } This is < b > bold text and < i > italic < /i > < /b > /\ { b : ( [ \s\S ] * ? ) \ } /gm/\ { i : ( [ \s\S ] * ? ) \ } /gm This is < b > bold text and < i > italic < /b > < /i > This is { b : bold text } and { i : itali... | Need easier way to replace nested custom tags with HTML equivalents |
JS | I have two different array objects and have a function which uses the objects and performs calculations . I would like to know how to perform calculations and get all the nested array objects in JavaScript as shown below ( expected output ) . | var obj = [ { name : `` insta '' , fee : `` 2 '' , rate : `` 2.00 '' } , { name : `` transfer '' , fee : `` 1 '' , rate : `` 3.00 '' } ] , var query = { country : `` SG '' , sourceamount : `` 4,000 '' } function config ( objectdata , querydata ) { let send_amount = querydata.sourceamount.replace ( / , /g , '' '' ) ; le... | How do I get all objects in a nested array after performing a calculation in JavaScript ? |
JS | It 's been a while since I 've coded OCaml , and I came across this problem which sounds simple but I 'm having a mental block with solving : Write a function that takes in a function f with a variable number of arguments that returns a boolean ( i.e . f is of type ' a - > ' b - > ' c - > ... - > bool ) and returns a f... | function negate ( func ) { return function ( ) { return ! func.apply ( null , arguments ) ; } ; } | OCaml equivalent of javascript 'apply ' |
JS | This is something weird I noticed . The following code should n't blow the memory as a WeakSet is used and obviously no other references linger around : ( SCCE github repo here ) .And yet blow the memory it does ( in Node v4.3.2 with Babel transpiling ) : | 'use strict ' ; require ( 'babel-polyfill ' ) ; const s = new WeakSet ( ) ; for ( let i = 0 ; ; i++ ) { s.add ( { } ) ; if ( i % 100000 === 0 ) console.log ( ` $ { i } : $ { process.memoryUsage ( ) .heapUsed } ` ) ; } < -- - Last few GCs -- - > 165 ms : Scavenge 13.6 ( 48.0 ) - > 13.6 ( 48.0 ) MB , 14.4 / 0 ms [ alloca... | adding to ` WeakSet ` and yet managing to blow memory |
JS | In my code test.js is dependent on jquery-ui which does not uses require AMD pattern and test.spec.js dependent on jquery-ui , test.js which uses AMD pattern . Can we load dependency of jquery-ui in test.js dynamically when running test.spec.js.In test.js `` draggable '' of jquery-ui draggable event is written . after ... | require.config ( { baseUrl : '/demo ' , paths : { 'jquery ' : '../library/jquery-1.11.1 ' , 'jquery-ui ' : '../library/jquery-ui-1.11.4 ' } , shim : { 'jquery ' : { exports : 'jQuery ' } , 'jquery-ui ' : { deps : [ 'jquery ' ] } , 'library/src/js/test ' : { deps : [ 'library/jquery-1.11.1 ' , 'library/jquery-ui-1.11.4 ... | require using AMD pattern gives error for jQuery UI events |
JS | I observed some strange Date behaviour in Chrome ( Version 74.0.3729.131 ( Official Build ) ( 64-bit ) ) .Following javascript was executed in the Chrome Dev Console : I have already read about non standard date parsing via the Date ctor in different browsers , although providing valid ISO8601 values.But this is more t... | new Date ( '1894-01-01T00:00:00+01:00 ' ) // result : Mon Jan 01 1894 00:00:00 GMT+0100 ( Central European Standard Time ) new Date ( '1893-01-01T00:00:00+01:00 ' ) // result : Sat Dec 31 1892 23:53:28 GMT+0053 ( Central European Standard Time ) new Date ( '1894-01-01T00:00:00+01:00 ' ) // result : > Date 1892-12-31T23... | Javascript Date parsing returning strange results in Chrome |
JS | Sorry for the misleading title but I 'm unsure how else to write it.I have the below table ... I want to produce a simple calculator that compares all data in a row from 2 given parameters.I will ask my users to select a country first , and then select a value in that column . After doing this you can submit the form a... | $ ( '.country ' ) .on ( 'change ' , function ( ) { // If USA show corrent dropdownif ( $ ( this ) .val ( ) == 'usa ' ) { $ ( '.hiddenGrade ' ) .hide ( ) ; $ ( '.iniValusa ' ) .show ( ) ; } else if ( $ ( this ) .val ( ) == 'gb ' ) { $ ( '.hiddenGrade ' ) .hide ( ) ; $ ( '.iniValgb ' ) .show ( ) ; } else { $ ( '.hiddenGr... | Traverse a table using jQuery , XML , JSON , JS |
JS | I 'm trying to make a slideshow of images and all I have is a rich text editor to enter the images and text . So from this html : How would you select the html between # slider and # end-slider ? It 's a similar concept to extracting text between [ link ] and [ /link ] in blog comments e.g . : [ link ] http : //google.... | < h1 > title < /h1 > < p > description ... < /p > < p > # slider < /p > < p > < img src= '' a.jpg '' / > < /p > < p > < img src= '' b.jpg '' / > < /p > < p > < img src= '' c.jpg '' / > < /p > < p > # end-slider < /p > | jQuery select HTML between two string identifiers |
JS | Consider a sequence of data along the following lines : I 'd like to display this data on a radially scaled plot ( i.e . circular bands indicating how high the value of each point is ) to show angle vs value . Angles will change by a small but uncontrollable quantity for each data set but there will always be ~50 of th... | data = [ { angle:1.2 , value:1.2 } , ... , { angle:355.2 : value:5.6 } ] ; | What 's the most effective way to implement a radar plot with 50 points at arbitrary locations using chart.js |
JS | I have 1 div and 1 image tag , one upon the other . Div is smaller than image.I have set overflow=visible for div . My question is that , when I insert an image to image tag , the content which is overflowed through div should be opacity=0.5 like this.for me it shows like this.. any help | < div style= '' border-style : solid ; border-width : 2px ; height : 5cm ; width : 8cm ; top : 20px ; left : 20px ; position : relative ; overflow : visible ; '' id= '' divimg '' > < img src= '' https : //stepupandlive.files.wordpress.com/2014/09/3d-animated-frog-image.jpg '' id= '' displayimg '' style= '' height : 7cm... | How to give opacity for div when it is set Overflow=visible |
JS | This expression evaluates to 3 . How is this expression ( 1,2,3 ) called ? Why does it return 3 ? | var x = ( 1,2,3 ) ; alert ( x ) ; | Javascript expression in parentheses |
JS | I 'm writing a Cloudflare Worker that needs to ping an analytics service after my original request has completed . I do n't want it to block the original request , as I do n't want latency or a failure of the analytics system to slow down or break requests . How can I create a request which starts and ends after the or... | addEventListener ( 'fetch ' , event = > { event.respondWith ( handle ( event ) ) } ) async function handle ( event ) { const response = await fetch ( event.request ) // Send async analytics request . let promise = fetch ( `` https : //example.com '' ) .then ( response = > { console.log ( `` analytics sent ! '' ) } ) //... | How can I make an asynchronous request ( non-blocking ) using a Cloudflare Worker |
JS | Im loading Data from Googlesheets to fusioncharts in my rails app.I use Jquery to Fetch the data from the google sheets as seen in this tutorial https : //www.sitepoint.com/interactive-javascript-charts-using-data-from-google-sheets/Rails always gives me this error undefined local variable or method 'parsedData ' for #... | var spreadsheetId = `` XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX '' , url = `` https : //spreadsheets.google.com/feeds/list/ '' + spreadsheetId + `` /od6/public/basic ? alt=json '' ; $ .get ( { url : url , success : function ( response ) { var data = response.feed.entry , len = data.length , i = 0 , parsedData = [ ] ;... | Undefined local variable or method ` parsedData ' when Using JSON to Parse data from Googlesheets To FusionCharts in Ruby on Rails app |
JS | Why does goog.inherits from the Google Closure Library look like this : rather thanWhat benefit does tempCtor provide ? | goog.inherits = function ( childCtor , parentCtor ) { function tempCtor ( ) { } ; tempCtor.prototype = parentCtor.prototype ; childCtor.superClass_ = parentCtor.prototype ; childCtor.prototype = new tempCtor ( ) ; childCtor.prototype.constructor = childCtor ; } ; goog.inherits = function ( childCtor , parentCtor ) { ch... | Why create a temporary constructor when doing Javascript inheritance ? |
JS | Here is my code.Here , when video constraint is not yet allowed by user , but audio is already allowed ( due to other just audio recordings ) , and when prompted for the same , and user 'closes ' the prompt , successCallback is called , and I wo n't be getting the VideoStream , but just Audio.How can I make sure that b... | captureUserMedia ( mediaConstraints , successCallback , errorCallback ) { navigator.getUserMedia ( mediaConstraints , successCallback , errorCallback ) ; } captureUserMedia00 ( callback ) { captureUserMedia ( { audio : true , video : true } , function ( stream ) { console.log ( 'user media Callback ' , stream ) ; callb... | navigator.getUserMedia one constraint allowed , another one not , success callback called upon closing browser prompt |
JS | I have been doing a lot of tinkering with this and ca n't seem to get it working . I am looking to show my loading template while waiting for my model promise to return.My understanding is , by default , if I have app/templates/loading.hbs , this template will be rendered across all routes . However , even with that te... | Router.map ( function ( ) { this.route ( 'reviews ' , function ( ) { this.route ( 'index ' , { path : '/ ' } ) ; this.route ( 'review ' , { path : '/ : review_id ' } ) ; } ) ; this.route ( 'movies ' ) ; this.route ( 'about ' ) ; } ) ; < div class= '' content-container '' > < h1 > Ish be loading < /h1 > < /div > export ... | Ember Loading Template with Liquid Fire |
JS | So basically I am trying to scale a div ( starts from 0 ) when another is clicked but the scale origin should start from where the click happened . Sort of what apple does when you click on an app ( the app opens up from where you clicked it ) . The problem is trying to set the property of the scale origin which I do s... | var xPosSTR = 30+'px ' ; var yPosSTR = 30+'px ' ; $ ( '.box-detail ' ) .css ( { 'transform-origin ' : `` + xPosSTR + ' ' + yPosSTR + ' 0px ' , '-webkit-transform-origin ' : `` + xPosSTR + ' ' + yPosSTR + ' 0px ' } ) ; $ ( `` .box-detail '' ) .addClass ( `` box-reveal-prop '' ) ; var xPosSTR = 30+'px ' ; var yPosSTR = 3... | Jquery Css Function slow to add property to div ? |
JS | I 've looked up other questions including this one however I could n't find an answer resolves my problem.I have defined my models in the same way described in official documentation of mongoose by showing references and defining types of models as Schema.Types.ObjectId . Here they are : story_model.jsstoryPart_model.j... | var storySchema = new Schema ( { ... candidateParts : [ { type : Schema.Types.ObjectId , ref : 'StoryPart ' } ] , ... } , { usePushEach : true } ) ; var storyPartSchema = new Schema ( { ... storyId : { type : Schema.Types.ObjectId , ref : 'Story ' } , ... } , { usePushEach : true } ) ; StoryController.prototype.getCand... | Mongoose.populate ( ) returns empty array instead of data |
JS | I want the normal behavior of the cursor as in a textarea , try on chrome navigator please.I 'm using a contenteditable but it should work as if it were a textarea , every word must be in a span that is very necessary , I do not want to work with plain textFor each space , each written word must become a div or span , ... | `` hello word '' for the space the result will is < div > hello < /div > imagine that the second space is after the word `` word '' , for the second space the result will is < div > hello < /div > < div > word < /div > and written spacebar before the caracter ' r ' the result will is < div > hello < /div > < div > wo <... | Each word in a new div |
JS | I keep seeing this WRONG CODEThat FAILSproducesOk , So I thought maybe I could do thisNOPE : That dumps out some giant JSHandle thing.Ok , So maybeNOPE : That printsI suppose I can hack it by removing the first 9 characters.I also triedNOPE : That printsOkay how aboutNope , That prints Another gosame as beforeI even tr... | page.on ( 'console ' , msg = > console.log ( msg.text ( ) ) ) ; console.log ( 'Hello % s ' , 'World ' ) ; Hello World // browserHello % s World // puppeteer page.on ( 'console ' , msg = > console.log ( ... msg.args ( ) ) ) ; page.on ( 'console ' , msg = > console.log ( ... msg.args ( ) .map ( a = > a.toString ( ) ) ; J... | How do print the console output of the page in puppeter as it would appear in the browser ? |
JS | Consider the following component template ... ... where Unknown may or may not be a globally registered component . At runtime , I 'll encounter this informative error : [ Vue warn ] : Unknown custom element : - did you register the component correctly ? For recursive components , make sure to provide the `` name '' op... | < template > < Unknown > < /Unknown > < /template > `` dependencies '' : { `` @ vue/component-compiler-utils '' : `` 3.0.0 '' , `` vue-template-compiler '' : `` 2.6.10 '' } [ ... ] const ccu = require ( ' @ vue/component-compiler-utils ' ) ; const vtc = require ( 'vue-template-compiler ' ) ; const file = ` < template >... | Can I fail a Vue.js build on unregistered components ? |
JS | I 've got the following HTMLI want to wrap all the bar-appointment elements with another DIV so the DOM would then look like : I 've tried the following but all the inner tags get wrapped too and I do n't want that.I also tried using just wrap and this only wraps each element individually , not as a group as I would li... | < div class= '' bar-something '' > < div class= '' fn-label '' > SOMETHING < /div > < /div > < div class= '' bar-appointment '' > < div class= '' fn-label '' > Ap1 < /div > < /div > < div class= '' bar-appointment '' > < div class= '' fn-label '' > Ap2 < /div > < /div > < div class= '' bar-appointment '' > < div class=... | wrap all elements between two elements |
JS | I am trying to achieve type writer animation for give line spaces between I am using letter.innerHTML = char=== '' `` ? '' `` : char ; In the same way I want to give line break instead of & nbsp and possible way for that ? Lets say suppose I want to display a line like great web developerNow I want it to be displayed i... | function splitLetters ( word ) { var content = word.innerHTML ; word.innerHTML = '' ; var letters = [ ] ; for ( var i = 0 ; i < content.length ; i++ ) { var letter = document.createElement ( 'span ' ) ; letter.className = 'letter ' ; var char = content.charAt ( i ) ; letter.innerHTML = char=== '' `` ? `` & nbsp ; '' : ... | How to give line break in animation using javascript ? |
JS | I 'm trying to find a simple way to record and temporarily obfuscate answers to `` quiz '' questions I 'm writing in Markdown . ( I 'll tell the students the quiz answers during the presentation , so I 'm not looking for any kind of secure encryption . ) I thought I could use atob ( 'message I want to obfuscate ' ) the... | btoa ( atob ( 'one ' ) ) | Why are atob and btoa not reversible |
JS | I am writing my first jQuery plugin , and I 'm not entirely sure what should be inside the extension declaration and what shouldn't.OR | $ .fn.myplugin = function ( ) { var somevar = this ; someFunc ( somevar ) ; } ; function someFunc ( ) { /*doSomethin'*/ } ; $ .fn.myplugin = function ( ) { var somevar = this ; someFunc ( somevar ) ; function someFunc ( ) { /*doSomethin'*/ } ; } ; | Should functions be inside jQuery 's extend , or outside ? |
JS | In my ruby on rails app I am trying to use a Prototype Form.Element.Observer to run a count of the characters in a message . This works fine on Firefox/Safari/Chrome , but not on IE . On IE the observer simply does not fire . Is there a fix or a different way of doing this ? My ruby tag looks like this : The countdown_... | < % = countdown_field ( 'txtmsg [ memo ] ' , 'memo-counter ' , 141 , : frequency = > 0.10 ) % > def countdown_field ( field_id , update_id , max , options = { } ) function = `` $ ( ' # { update_id } ' ) .innerHTML = ( # { max } - $ F ( ' # { field_id } ' ) .length ) ; '' count_field_tag ( field_id , function , options ... | observer does not work in IE |
JS | Simple question : is there a merit of using a shallow object over a deeper one ? When I write a code , I tend to use a deep object just so it is easy to understand and classify . But I am wondering if this custom is making my code slower.I have done a test but I have no idea if I am doing it correctly.the result ( ms )... | //building necessary objectsvar a = { } ; var b ; b = a ; for ( var i = 0 ; i < 100 ; i++ ) { b [ `` a '' ] = { } ; b = b [ `` a '' ] ; } var c = { } ; //objects used//a.a.a . .. ( 101 `` a '' s ) .. .a === { } //c === { } //1st test : shallowvar d ; var start = performance.now ( ) ; for ( var i = 0 ; i < 1000000000 ; ... | Is a deep object slow in JavaScript ? If so how much |
JS | I have multiple spans with content editable property set to true , like this : https : //jsfiddle.net/du7g39cz/Problem is that when I am using arrow keys to navigate around span element , i can not reach end of individual span as blur event gets called when carret reaches last symbol . I can reproduce this behavior on ... | < span contentEditable='true ' > value < /span > < span contentEditable='true ' > value < /span > < span contentEditable='true ' > value < /span > | Multiple contentEditable , unable to move carret to end of span with arrow keys |
JS | I 'm vertically centering multi-lined text with my code . It works in all modern browsers , but not in IE7 . I searched around and found me a CSS expression on CSS-Tricks that should fix it.Unfortunately the height of the element in IE7 is not 107px , it appears to be bigger . I just found out about CSS expressions and... | p.caption { display : table-cell ; height : 107px ; padding : 15px 10px ; border-bottom : 1px solid # cecece ; font-size : 16px ; text-shadow : 0 0 1px # 868686 ; text-align : center ; vertical-align : middle ; } p.caption { clear : expression ( style.marginTop = `` '' + ( offsetHeight < parentNode.offsetHeight ? parse... | IE7 expression not equal to table-cell height |
JS | As I understand , in JavaScript every object has a prototype and it exposes some default properties . I have the following code where I 'm trying to set the Year property of two objects through prototype . But both the calls are failing.How can I override toLocalString ( ) for any object if I do n't have access to the ... | var car = { Make : 'Nissan ' , Model : 'Altima ' } ; car.Year = 2014 ; alert ( car.Year ) ; alert ( car.prototype ) ; // returns undefinedcar.prototype.Year = 2014 ; // Javascript error// -- -- -- -- -- -- -- function Car ( ) { this.Make = 'NISSAN ' ; this.Model = 'Atlanta ' ; } var v = new Car ( ) ; v.prototype.Year =... | Accessing Javascript object prototype |
JS | We have some JS script where we evaluate calculations , but we have an issue with leading zeros . JS treats the numbers with leading zeros as octal numbers.So we used a regex to remove all leading zeros : Sample data : ( also online on https : //regex101.com/r/mL3jS8/2 ) The regex works fine but not with numbers includ... | \b0+ ( \d+ ) \b 1021,031.030040506+0708/09010,10,0100,01000101*01010,00,00000015/0 | Regex Custom Word Boundaries in JavaScript |
JS | I need to get the value of the property b from the object with the highest value of the property a.I tried the following , but it just returns the highest value of a , rather than of b . | var myArr = [ { a : 1 , b : 15 } , { a : 2 , b : 30 } ] ; var res = Math.max.apply ( Math , myArr.map ( function ( o ) { return o.a ; } ) ; var blah = getByValue ( myArr ) ; | From an array of objects , how to return property ` b ` of the object that has the highest property ` a ` ? |
JS | I have noted that in my program every time when I want to declare a object , for example list , save , add , remove I write the following every time in each function.I want to do something like this.Every time I have to open a connection , give the path to my action class which is a servlet and then send . I do this ev... | ajax.open ( `` Get '' , `` ./route/action '' , true ) ; ajax.send ( ) ; //this.ajax.get ( './route/action ' ) .update ( 'ajax-content ' ) ; ./route/action // this is path to my Action class-using servlet this.ajax.get ( './route/action ' ) ; // 'ajax.content ' is the id of the div where I // want to show the list , whe... | Create a reusable function to open and send Ajax |
JS | Why Ng-click and ng-show do n't work on dynamical content , while if i try to switch static tabs everything works fine ? What do i need to do , so i could click trough profiles tabs ? How to achieve desired effect with smallest code footprint ? I hope you guys can help me.Let say for example that i have profiles object... | < div class= '' nav-tabs-custom '' > < ul class= '' nav nav-tabs '' > < li class= '' active '' > < a ng-click= '' tab=1 '' data-toggle= '' tab '' aria-expanded= '' true '' style= '' cursor : pointer ; '' > Subscriber < /a > < /li > < li class= '' '' > < a ng-click= '' tab=2 '' data-toggle= '' tab '' aria-expanded= '' t... | Ng-click and ng-show do n't work on dynamical content ( angular ) |
JS | I have build basic authorization and cors in vps.curl -X OPTIONS -i http : //111.111.111.111curl -u xxxx : xxxx -i http : //111.111.111.111/remote.phpYou can see that authorization and cors are in good status . The test-ajax-cors.html in my local directory /var/www/html.The remote.php in http : //111.111.111.111.cat /v... | HTTP/1.1 200 OKDate : Sat , 15 Sep 2018 08:07:37 GMTServer : Apache/2.4.6 ( CentOS ) Access-Control-Allow-Origin : http : //127.0.0.1Access-Control-Allow-Methods : POST , GET , PUT , DELETE , OPTIONSAccess-Control-Allow-Credentials : trueAccess-Control-Allow-Headers : Authorization , DNT , User-Agent , Keep-Alive , Con... | How to show the content in second response for ajax 's authorization and cors ? |
JS | I came across this code in Mithril.js : To my ( Java/C programmer 's ) eyes it looks like it should always invoke finish ( true ) if state is 1 and finish ( false ) if state is not 1 . But it actually seems to do finish ( 3 ) for the former and finish ( false ) for the latter.What is the logic behind this ? Is this idi... | finish ( state == 1 & & 3 ) | Why does ` ( state == 1 & & 3 ) ` make sense ? |
JS | I have problem with developing chrome-extensions.I have content script : then I have a BG page : The problem is that when I start typing to address bar , my content script is loaded on the site which is first in autocomplete list . As you can see in the screenshot below , the content script is loaded before I hit enter... | window.addEventListener ( `` load '' , function ( ) { var html = document.getElementsByTagName ( 'html ' ) [ 0 ] ; var title = document.getElementsByTagName ( 'title ' ) [ 0 ] .innerHTML ; if ( html ) { chrome.extension.sendRequest ( { akce : 'content ' , title : title } , function ( response ) { } ) ; alert ( title ) ... | Content script loading in chrome extension |
JS | I have this simple regex to catch the last instance of 'turn to 123 ' in a form ( I have another regex for the main body ) : which for example substitutesturn to 123 ... with ... in live form input . However it only works if there is some form of character after the number 123 , whether it be a carriage return or a vis... | currenttext=currenttext.replace ( / ( [ ^ > ] ) ( turn\s+to\s+ ) ( \d+ ) $ /i , '' $ 1 < tt ref=\ '' $ 3\ '' > $ 2 $ 3 < /tt > '' ) ; < tt ref= '' 123 '' > turn to 123 < /tt > ... < tt ref= '' 12 '' > turn to 12 < /tt > 3 | Javascript regex not matching last char in form |
JS | Considering object creation patterns with private properties , one way to do is : Problem with this : Every instance of Stack has it 's own copy of methods 'push ' and 'pop'.Another way for implementing constructor method is : Problem here : We lose the privacy of list and index.Is there a way , such that we can have b... | function MyStack ( ) { var list = [ ] , index = 0 ; this.push = function ( val ) { return list [ index++ ] = val ; } ; this.pop = function ( ) { // ... } } var stack1 = new MyStack ( ) ; stack1.push ( 5 ) ; var stack2 = new MyStack ( ) ; stack2.push ( 11 ) ; function MyStack ( ) { this.list = [ ] ; this.index = 0 ; } M... | how to have Javascript Object creation pattern with Reusable methods and private properties ? |
JS | What is going on in this code ? Specifically , why does using looking up b in c return the value that was stored in a property of a ? What does it mean to use an object as a key to a property in JavaScript ? I 've tested this in Chrome/Node and in Firefox . | var a = { a:1 } ; var b = { b:2 } ; var c = { } ; c [ a ] = 1 ; c [ b ] === 1 // true ! c [ b ] = 2 ; c [ a ] === 2 // true ! | Using an object as a property key in JavaScript |
JS | I am experiencing odd behavior when data linking an object to a form that led me to re-question what exactly is being data bound ? Basically I have a form that creates new Companies as well as updates them . The actual creation/update is done via ajax , which is why I am using the same form for both purposes . In the c... | < div id= '' result '' > < /div > < script type= '' text/x-jsrender '' id= '' CompanyFormTemplate '' > < form > < input type= '' text '' data-link= '' Company.Name '' / > < /form > < /script > var app = new CompanyFormContext ( ) ; function CompanyFormContext ( ) { this.Company = { Name : `` } ; this.setCompany = funct... | JsViews how to make data binding happen on root object as well as its nested properties ? |
JS | Let 's take this example from The Good Parts book : Why did the author use this.splice in one place and Array.prototype.slice in other ? I tried swapping out this and Array.prototype with each other and got errors like the following : TypeError : Can not read property 'slice ' of undefinedbut I am still not sure about ... | Array.method ( 'unshift ' , function ( ) { this.splice.apply ( this , [ 0,0 ] .concat ( Array.prototype.slice.apply ( arguments ) ) ) ; return this ; } ) ; | When to use 'Array.prototype ' and when to use 'this ' in JavaScript ? |
JS | Let 's pretend this is in the < head > of your html page.OOPS this was a bit that was missing before ... : Order of the 3 scripts could vary . What would be the outcome ? Billy defines $ asSusie defines $ asMary defines $ as | < script type= '' text/javascript '' src= '' /include/js/billys.js '' > < /script > < script type= '' text/javascript '' src= '' /include/js/susies.js '' > < /script > < script type= '' text/javascript '' src= '' /include/js/marys.js '' > < /script > function $ ( ) { return false ; } function $ ( ) { return document.ge... | What is the outcome in javascript with multiple librarys that use $ |
JS | I have a react component in the pathsrc/components/testI am exposing the component in index.js from pathsrc/index.jsI have added main in package.json as `` main '' : `` src/index.js '' I have published a npm package test-comp of above application and using same in another application.main.jsI am using grunt-browserify ... | import React from 'react ' ; import ReactDom from 'react-dom ' ; class TestComp extends React.Component { } export default TestComp ; import TestComp from './components/test ' ; export { TestComp } ; import { TestComp } from 'test-comp ' ; options : { `` transform '' : [ [ `` babelify '' , { `` presets '' : [ `` es2015... | Unable to load a react module as node module |
JS | I know it is possible to invoke Java when Perl 6 is using that backend : How do I invoke a Java method from perl6Is there a way yet to access e.g . the JavaScript DOM interface from Perl 6 with the new Rakudo JavaScript VM running in the browser ? Perhaps something like this : | use v6 ; use javascript : :dom : from < JavaScript > ; | How can you call JavaScript builtins from Perl 6 with the new JS backend ? |
JS | I have an application that shows a page , the user clicks on a button , and downloads a CSV file . I want to run this with Puppeteer.Problem is that the CSV is downloaded empty and with an error . This happens both with headless true and false . The page finished loading , and I increased the timeout , but it still fai... | const puppeteer = require ( 'puppeteer ' ) ; ( async ( ) = > { const browser = await puppeteer.launch ( { headless : false } ) ; const page = await browser.newPage ( ) ; await page.goto ( 'http : //localhost:4400/login ' , { waitUntil : 'networkidle2 ' } ) ; await page._client.send ( 'Page.setDownloadBehavior ' , { beh... | Chrome download error when downloading file with Puppeteer |
JS | I am creating example application with Ractive.js and gridstack.js , but ca n't figure out how to add gridstack as a decorator . I think this is the proper way to add jQuery elements to ractive.js , please advise if it 's not . After I created a decorator and assigned it to the Dashboard component it actually does n't ... | - App| -- - Dashboard < -- GridstackDecorator | -- - Widget | -- - Widget container components | -- - ... | -- - Widget| -- - Other components < div id= '' app '' > < /div > < script > window.__APP_INITIAL_STATE__ = { widgets : [ { id : 1 , name : `` First widget '' , x:0 , y:0 , width:2 , height:2 } , { id : 2 , name ... | How do I add gridstack.js to Ractive.js ? |
JS | I have a module I want to publish to npm . I have found some `` solutions '' that are 4+ years old , examples using babel 5.x , and other problems that made the examples not work as shown.Ideally I want to write my code using es6 and build/transpile with babel such that it can be imported with require ( ) in scripts or... | // index.jsexport default function speak ( ) { console.log ( `` Hello , World ! `` ) ; } // .babelrc { `` comments '' : false , `` presets '' : [ [ `` @ babel/env '' , { `` modules '' : `` commonjs '' } ] ] , `` plugins '' : [ `` @ babel/plugin-transform-modules-commonjs '' , `` add-module-exports '' ] } // package.jso... | How can I publish an NPM module with both commonjs and es6 versions ? |
JS | I was going through some of StackOverflow 's client side code and I ran across this block of JavaScript in the source-code of https : //stackoverflow.com/questions/ask : Why would n't you use false instead ? | if ( $ answerCheckbox.is ( ' : checked ' ) || 0 > 0 ) { $ answerCheckbox.attr ( 'checked ' , true ) ; $ ( ' # question-only-section ' ) .hide ( ) ; StackExchange.using ( `` editor '' , function ( ) { setTimeout ( function ( ) { showAnswerSection ( true ) } , 2 ) ; } ) ; } | Why would you use 0 > 0 in javascript ? |
JS | My goal is to retrieve the html of a website in a readable String ( which I have done ) , and to modify the code slightly so that the html is retrieved a certain time after the Get command is made.Here 's an example of what I 'm trying to do : on the website http : //time.gov/HTML5/ , the html that appears right when t... | public class MainActivity extends Activity { @ Override protected void onCreate ( Bundle savedInstanceState ) { super.onCreate ( savedInstanceState ) ; setContentView ( R.layout.activity_main ) ; DownloadTask task = new DownloadTask ( ) ; task.execute ( `` http : //time.gov/HTML5/ '' ) ; } private class DownloadTask ex... | Android : retrieve html of website certain time after request |
JS | I 'm having trouble with a callback after the # each has finished . I have a template named `` content '' : At first I wait for a subscription , when this is available , I iterate through my Collection with { { # each } } and append the div . What I need is a sort of callback for when the for-each loop is done ( in oth... | < template name= '' content '' > { { # if Template.subscriptionsReady } } { { # each currentData } } < div data-cid= '' { { this._id } } '' > < /div > { { /each } } { { else } } Loading ... { { /if } } < /template > Template.content.onRendered ( ) < img style= '' height:0 ; width:0 '' src= '' *mysource* '' onload= '' c... | How to execute a callback after an # each is done ? |
JS | I am currently banging my head trying to understand a little bit better how Angularfire works in this case . I have 2 controllers on my `` webapp/test '' , one for the user to login , and the other to show some profile info . After the user login with Facebook , i use the `` uid '' to check the firebase DB if the user ... | Error : [ $ rootScope : inprog ] http : //errors.angularjs.org/1.3.15/ $ rootScope/inprog ? p0= % 24digest app.controller ( `` profile '' , function ( $ scope , loginService , Auth , userManagement ) { var authData = Auth. $ getAuth ( ) ; if ( authData ! = null ) { $ scope.authData = authData ; userManagement.saveLastL... | Angularfire - $ scope wont update after async call , and $ apply throws error |
JS | I have an Object with 2 arrays : Each of the arrays contain a different amount of objects : I print each object onto the page using a list , separated by `` sport '' : I want to print each of the object info into an li under the correct sport name.For example , there are a total of 4 objects , soccer has 3 , hockey has... | mainObject = { soccer : [ ] , hockey : [ ] } sportObject = { soccer : [ { equipment : `` cleats '' } , { shirt : `` jersey '' } , { team : `` arsenal '' } ] , hockey : [ { equipment : `` skates '' } ] } < ul ng-repeat= '' ( sport , value ) in sportObject '' > < li > { { sport } } < /li > // Prints `` soccer '' or `` ho... | AngularJS ng-repeat over array of objects uniquely |
JS | W3 Schools says These two different statements both create a new array containing 6 numbers : but does n't give an explanation why the first is bad.From what I understand , the only difference is that the first calls the constructor . Can someone clue me into why the first is bad ? | var points = new Array ( 40 , 100 , 1 , 5 , 25 , 10 ) // Bad var points = [ 40 , 100 , 1 , 5 , 25 , 10 ] ; // Good | Why is using `` new '' to create a Javascript array considered bad ? |
JS | I have an element with id= '' stimulus '' in an HTML document.When I open this document in a browser and use the browser 's console to investigate properties of # stimulus , this is what I see : How am I to interpret this ? How is top within offset different from top accessed using the css method ? | > $ ( ' # stimulus ' ) .offset ( ) < Object { top : 0 , left : 0 } > $ ( ' # stimulus ' ) .css ( 'top ' ) < `` -155.761px '' > $ ( ' # stimulus ' ) .css ( 'left ' ) < `` 253.087px '' | Understanding the offset method 's return values |
JS | Any better way to achieve this without using eval ? Im not a very big fan of using eval unless absolutely necessary . | var foo1 , foo2 ; switch ( fn ) { case `` fade '' : foo1 = `` fadeOut '' ; foo2 = `` fadeIn '' ; break ; case `` slide '' : foo1 = `` slideUp '' ; foo2 = `` slideDown '' ; break ; } eval ( `` $ ( '.cls1 ' ) . '' + foo1 + `` ( ) ; '' ) ; currentSlideIndex = currentSlideIndex + n ; eval ( `` $ ( '.cls1 ' ) . '' + foo2 + ... | Calling a Function Based on a String Which Contains the Function Name |
JS | Google Chrome devtools comes with an extended API provided by so called Command Line Api . API reference can be found here . Access to the API is implemented by wrapping console input with with statement like this : Suppose I want to add my own methods to __commandLineAPI object . For example debugAll function that tak... | with ( __commandLineAPI || { __proto__ : null } ) { //blah-blah-blah your code goes here } | Is there any way to extend chrome 's __commandLineAPI |
JS | When I runin Chrome or IE , it takes ~10 seconds to complete . ( Firefox is able to evaluate it almost instantly . ) Why does it take so long ? ( And why/how is Firefox able to do it so quickly ? ) ( Of course , I 'd never run this particular regex , but I 'm hitting a similar issue with the URL regex at http : //darin... | /^ ( .+ ) +Q $ /.test ( `` XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX '' ) var re = /\b ( ( ? : https ? : \/\/|www\d { 0,3 } [ . ] | [ a-z0-9.\- ] + [ . ] [ a-z ] { 2,4 } \/ ) ( ? : [ ^\s ( ) < > ] +|\ ( ( [ ^\s ( ) < > ] +| ( \ ( [ ^\s ( ) < > ] +\ ) ) ) *\ ) ) + ( ? : \ ( ( [ ^\s ( ) < > ] +| ( \ ( [ ^\s ( ) < > ] +\ ) ) ) *\ ) ... | Why does /^ ( .+ ) +Q $ /.test ( `` XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX '' ) take so long ? |
JS | I 'm currently working on a way to create a single-line diagram using Javascript . I 'm currently able to connect two html elements using the following function : The function takes 3 parameters : 1 ) the first html element2 ) the second html element3 ) the line that connects the elements . This works fine and outputs ... | adjustLine ( from , to , line ) { var fT = from.offsetTop + from.offsetHeight/2 ; var tT = to.offsetTop + to.offsetHeight/2 ; var fL = from.offsetLeft + from.offsetWidth/2 ; var tL = to.offsetLeft + to.offsetWidth/2 ; var CA = Math.abs ( tT - fT ) ; var CO = Math.abs ( tL - fL ) ; var H = Math.sqrt ( CA*CA + CO*CO ) ; ... | Connect Line Between 2 Elements - Javascript |
JS | i 'm having trouble with the following jquery codei want the ajax link to be like this http : //192.168.1.4/~user/church/backend/web/death/stl_set_relation ? id=20 & name=1but with my code i 'm not able to pass value of id correctly . what my code creates is the following urli also tried like this but it did n't give m... | $ this- > registerJs ( 'jQuery ( document ) .ready ( function ( $ ) { $ ( `` .member '' ) .on ( `` change '' , function ( ) { var id = $ ( this ) .attr ( `` id '' ) ; // alert ( id ) ; var n = $ ( this ) .val ( ) ; // alert ( n ) ; $ .post ( `` '.\Yii : : $ app- > getUrlManager ( ) - > createUrl ( [ 'death/stl_set_rela... | Passing a jquery variable |
JS | Maybe a bad title , but this is my problem : I 'm building a framework to learn more about javascript . And I want to use `` '' jQuery '' '' style.How can I make a function where the ( ) is optional ? This is what I have come up with , but it do n't work : | $ ( `` p '' ) .fadeOut ( ) ; // ( ) is there $ .each ( arr , function ( k , v ) { ... } ) ; //Dropped the ( ) , but HOW ? $ 2DC = function ( selector ) { return new function ( ) { return { circle : function ( ) { // ... } } } } $ 2DC ( `` # id1 '' ) ; //Work $ 2DC ( `` # id2 '' ) .circle ( ) ; //Work $ 2DC.circle ( ) ;... | How does jQuerys $ .each ( ) work ? |
JS | Typescript supports discriminated unions . How to extend the same concept with Rxjs to the filter operator in below example ? I above code snippet , I would want to see newObs $ to have its type inferred as : Observable < Square > . But apparently , TypeScript does n't do that.How to achieve this ? Am I reaching the li... | interface Square { kind : 'square ' ; width : number ; } interface Circle { kind : 'circle ' ; radius : number ; } interface Center { kind : 'center ' ; } type Shape = Square | Circle | Center ; const obs $ : Observable < Shape > = of < Shape > ( { kind : 'square ' , width : 10 } ) ; // Expected type : Observable < Squ... | Typescript discriminated union types with Rx.js filter operator ? |
JS | In my web app i have an div which will change the height and width based on the pinching direction . for example if user pinch horizontally it will change width , for vertical pinch it will change the height.I am using the gesture eventsIs there any way to find the pinch direction ? | var scaleMe = $ ( `` # scaleMe '' ) ; scaleMe [ 0 ] .ongesturestart = function ( e ) { height = scaleMe .height ( ) ; } scaleMe [ 0 ] .ongesturechange = function ( e ) { e.preventDefault ( ) ; var scaleheight = ( scaleMe.height ( ) * e.scale ) ; scaleMe.height ( Math.min ( Math.max ( scaleheight , 50 ) , 400 ) ) ; } | How to find the pinch direction in javascript ? |
JS | Older versions of node did not support chacha20-poly1305 , but as of version 10.0.0 , node supported openssl 1.1.0 , which includes chacha.require ( 'tls ' ) .getCiphers ( ) includes chacha. $ openssl ciphers includes chacha.But passing https.createServer ( ) and http2.createServer ( ) a ciphers list with only chacha c... | https.createServer ( { // ... 'ciphers ' : [ 'TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256 ' , 'TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256 ' , 'TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256 ' , 'TLS_PSK_WITH_CHACHA20_POLY1305_SHA256 ' , 'TLS_ECDHE_PSK_WITH_CHACHA20_POLY1305_SHA256 ' , 'TLS_DHE_PSK_WITH_CHACHA20_POLY1305_... | Using chacha20-poly1305 with node |
JS | I have something a little bit more complicated . I have five li 's and a class `` active '' .Only one of li 's has class `` active '' . That one will have the color red.When i click the `` Next '' link the class `` active '' will be added to the next li.When i click the `` Prev '' link the class `` active '' will be ad... | $ ( document ) .ready ( function ( ) { var f1 = function ( ) { $ ( `` .1 '' ) .addClass ( `` active '' ) .siblings ( `` li '' ) .removeClass ( `` active '' ) } ; f2 = function ( ) { $ ( `` .2 '' ) .addClass ( `` active '' ) .siblings ( `` li '' ) .removeClass ( `` active '' ) } ; f3 = function ( ) { $ ( `` .3 '' ) .add... | How to make in a for statement , `` i '' to start from a value until the cycle is end , and the second cycle to start from 1 |
JS | It seems that when using a primitive type ( string , number ) as the this subject of a function call ( as the first argument to either function.call ( ) or function apply ( ) ) , the primitive type is promoted to its object equivalent ( e.g a string turns into a String ) .To illustrate : That is , `` this '' becomes an... | var f = function ( x ) { return [ typeof ( this ) , typeof ( x ) ] ; } var obj = '123 ' f.call ( obj , obj ) > > > [ `` object '' , `` string '' ] | Why does javascript change primitive types when passed into function.apply ( ) or function.call ( ) ? |
JS | How can I remove cookies , local storage and other crap from the `` AppData\roaming\MyApp '' folder , when the electron application quits ? I tried deleting the whole directory on app quit , but it throws me EBUSY errors . Apparently the files are locked or something , almost like someone does n't want us to be able to... | const fs = require ( 'fs-extra ' ) ; const clearBloat = async ( ) = > fs.remove ( path.join ( app.getPath ( 'appData ' ) , app.name ) ) ; app.on ( 'window-all-closed ' , async ( ) = > { await clearBloat ( ) ; } ) ; | How to remove all Electron bloatware on exit ? |
JS | I have an http-proxy to proxy any website and inject some custom JS file before to serve the HTML back to the client . Whenever I try to access the proxied website , it will hang up or the browser seems to load indeterminately . But when I check the HTML source , I successfully managed to inject my custom JavaScript fi... | const cheerio = require ( 'cheerio ' ) ; const http = require ( 'http ' ) ; const httpProxy = require ( 'http-proxy ' ) ; const { ungzip } = require ( 'node-gzip ' ) ; _initProxy ( host : string ) { let proxy = httpProxy.createProxyServer ( { } ) ; let option = { target : host , selfHandleResponse : true } ; proxy.on (... | Node JS HTTP Proxy hanging up |
JS | I have a directive here I 'm trying to write a unit test for - first time doing this type of thing . I 'm not sure how to go about it . Here 's the directive code and HTML : And here 's what I 'm trying for a test . So for , it is giving me an error reading TypeError : 'undefined ' is not an object ( evaluating 'scope.... | app.directive ( 'passwordMatch ' , [ function ( ) { return { restrict : ' A ' , scope : true , require : 'ngModel ' , link : function ( scope , elem , attrs , control ) { var checker = function ( ) { var e1 = scope. $ eval ( attrs.ngModel ) ; var e2 = scope. $ eval ( attrs.passwordMatch ) ; if ( e2 ! =null ) return e1 ... | Writing Unit test for Password Matching directive |
JS | This part of an .on ( `` change '' ) event is not working properly when users are working in Chrome 57 . This is only a Chrome 57 issue.The userId variable in the if is set and has a value before it gets to this piece of code.However , the conditional is not being found true when it should.But if I am debugging and hav... | var selected = $ ( this ) .children ( `` option : selected '' ) ; var name = selected.html ( ) ; var userId = selected.attr ( `` value '' ) ; var personInList ; $ ( `` li '' , `` # list1 '' ) .add ( `` li.person '' , `` # list2 '' ) .each ( function ( ) { if ( $ ( this ) .data ( `` userId '' ) == userId ) { personInLis... | Chrome 57 making .data ( ) not function well |
JS | I 'm not sure how to ask the question rattling around in my head right now , so bear with me . I 'm brand new to asynchronous programming , and I figured the best way to learn would be to make a little javascript pong game . I started with a shootball ( ) function and just bounce a div around another div . How I did th... | function shootball ( angle , speed ) { angle = ( angle/360.0 ) *2*Math.PI ; var ballmotion = setInterval ( function ( ) { var nowx , nowy , minusY , plusX ; nowx = $ ( `` # ball '' ) .position ( ) .left ; nowy = $ ( `` # ball '' ) .position ( ) .top ; minusY = Math.sin ( angle ) * 4.0 ; plusX = Math.cos ( angle ) * 4.0... | Asynchronous Javascript Recursion |
JS | I 've yeoman generator which generate a simple sproject successfully.I want that after the project generation , in latter time that the use will have the ability to generate a new file deployment.yaml under the app folder , however it needs to read some data from the main generatorfor example appName as the sub-generat... | const Generator = require ( `` yeoman-generator '' ) ; module.exports = class extends Generator { prompting ( ) { this.props = { appName : `` my-app '' , srvName : `` my-service '' } ; const prompts = [ { name : `` appName '' , message : `` Project name : `` , type : `` input '' , default : this.props.appName } , { nam... | Yeoman generator add a new file generated exsiting project |
JS | With this task : I get this kind of error log : It 's clear and pretty , I like it.But in order to keep my watch running , I need to handle the error instead of letting it pass , something likeHow can I reproduce the same error log here ? I 'd prefer to avoid painfully reproducing it by combining chalk , gutil and read... | gulp.task ( `` es6 '' , function ( ) { return browserify ( { entries : 'src/main/es6/main.js ' , extensions : [ '.js ' ] , debug : true } ) .transform ( babelify ) .bundle ( ) .pipe ( source ( 'superpos.js ' ) ) .pipe ( streamify ( uglify ( ) ) ) .pipe ( gulp.dest ( 'src/main/webapp ' ) ) ; } ) ; ... .transform ( babel... | Standard error log in Gulp Browserify |
JS | My question is closely related to this question but I 'm looking for a solution in JavascriptHow to Transpose 2D Matrix Stored as C 1D ArrayBasically I have a 2D square matrixStored as followsHow can I transpose this matrix so that the elements of my source array are switched as follows ? | 1 2 34 5 67 8 9 let anArray = [ 1 ,2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 ] let newArray = [ 1 , 4 , 7 , 2 , 5 , 8 , 3 , 6 , 9 ] | How to transpose 2D square matrix stored as 1D array in Javascript |
JS | I 'm displaying a weather map in a GWT application . I 'm using GWT 2.7 and the GWT wrapper of the GoogleMaps JavaScript API available here ( gwt-maps-3.8.0-pre1.zip ) .I use a tile server to fetch the weather , which updates every 5 minutes . On the 5 minute mark , I refresh the map by setting the zoom to 1 and then b... | < ! DOCTYPE html > < html > < head > < title > Map Test < /title > < style type= '' text/css '' > html , body { height : 100 % ; margin : 0 ; padding : 0 ; } # map { width:90 % ; height : 90 % ; display : inline-block ; } < /style > < /head > < body > < div id= '' map '' > < /div > < button type= '' button '' onClick= ... | Refreshing GoogleMaps tile server works in JavaScript but not in GWT |
JS | Edit The following HTML and CSS are just an example , the real use-case involves a complex DOM , and should be generic enough to work on different webpages . Only valid assumption is that all elements are rectangular.Given the following : HTMLCSSproduces the following result : I 'm trying to detect the percentage of th... | < div class= '' a '' id= '' a '' > A < /div > < div class= '' b '' > B < /div > < div class= '' c '' > C < div class= '' d '' > D < /div > < /div > .a , .b , .c , .d { border : solid 1px black ; opacity : 0.5 ; font-family : arial ; position : absolute ; font-size : 20px ; } .a { width:300px ; height:250px ; top:30px ;... | JS - Find out the visible percentage of an obscured DOM element |
JS | I 'm trying to use the 'react-table ' library in my application . I 'm not sure what I 'm doing wrong but all of the elements in the table appear vertically on the left side , and not in a grid . This was happening in my application , so I tried creating a new app to just display this table.I copied this example word f... | NameInfoStatsFirst NameLast NameAgeStatusVisitsBretTill33spoken for4 import `` react-table/react-table.css '' ; | ReactTable is ordering elements vertically |
JS | I have got three arrays and a couple of simple loops . I want to specify three conditions that would show a person from Warsaw at a Web developer position with a salary over 2000 . The problem is that it shows two records instead of one.I 've tried writing conditions inside each loop , but none of my combination did wo... | var people = [ { 'name ' : 'Viola ' , 'salary ' : 2500 , 'surname ' : 'Smith ' } , { 'name ' : 'Boris ' , 'salary ' : 1300 , 'surname ' : 'Popkovitch ' } , { 'name ' : 'John ' , 'salary ' : 500 , 'surname ' : 'Lynn ' } , { 'name ' : 'Tom ' , 'salary ' : 3300 , 'surname ' : 'Gates ' } , { 'name ' : 'Levis ' , 'salary ' ... | How do I display array objects using a simple loop and 'if ' statements ? |
JS | How can I resize a specific node in xul window when a splitter is dragged ? Ca n't use resizebefore/resizeafter attributes due to complexity of the xul window.I 've tried use ondrag event on splitter , but it 's not firing at all . ondragstart event fires fine and I can use event.offsetY to capture how many pixels the ... | < ? xml version= '' 1.0 '' ? > < ? xml-stylesheet href= '' chrome : //global/skin/ '' type= '' text/css '' ? > < window id= '' testWindow '' title= '' testing resizing element by splitter '' xmlns= '' http : //www.mozilla.org/keymaster/gatekeeper/there.is.only.xul '' style= '' color : white ; '' > < vbox id= '' resizem... | splitter - resize specific node |
JS | Suppose there are two objects.and the resultBasically , I want to group the data.I use includes to check if the item from b to match the id from a . Then construct the new array.This is my attempt ( fiddle ) : For somehow , it does n't work . and , is there a clever way to avoid the nested for loop or map function ? | const a = [ { id : ' 1-1-1 ' , name : 'a111 ' } , { id : ' 1-1-2 ' , name : 'a112 ' } , { id : ' 1-2-1 ' , name : 'a121 ' } , { id : ' 1-2-2 ' , name : 'a122 ' } , { id : ' 2-1-1 ' , name : 'a211 ' } , { id : ' 2-1-2 ' , name : 'a212 ' } ] const b = [ ' 1-1 ' , ' 1-2 ' , ' 2-1 ' ] { ' 1-1 ' : [ { id : ' 1-1-1 ' , name ... | How to merge and return new array from object in es6 |
JS | I am stuck with a strange issue with React.If I have made any change in the assigned variable a , then it will reflect in the state also.What I got in console is , { testValue : `` Debugging is awesome '' } .Any help will be appreciableEdit : I do n't want to change the state . I have to modify a without altering the s... | this.state= { testState : { testValue : `` Test State '' } } testFn = ( ) = > { let a ; a = this.state.testState a.testValue = `` Debugging is awesome '' ; console.log ( this.state.testState ) } | React state changes when its assigned variable changes |
JS | I need to let a piece of code always run independently of other code . Is there a way of creating a thread in javascript to run this function ? -- why setTimeout does n't worked for meI tried it , but it runs just a single time . And if I call the function recursively it throws the error `` too much recursion '' after ... | function update ( v2 ) { // I removed the use of v2 here for simplicity dump ( `` update\n '' ) ; // this will just print the string setTimeout ( new function ( ) { update ( v2 ) ; } , 100 ) ; // this try does n't work } update ( this.v ) ; | Threads ( or something like ) in javascript |
JS | Configurable properties seem to be deletable : But it does n't work in the following case , at least on Firefox and Chrome : But this seems to contradict the spec.The delete operator is defined like this : 11.4.1 - The delete Operator The production UnaryExpression : delete UnaryExpression is evaluated as follows : Let... | var o = { } ; Object.defineProperty ( o , 'prop ' , { configurable : true , value : 'val ' } ) ; delete o.prop ; // trueo.prop ; // undefined var form = document.createElement ( 'form ' ) , input = document.createElement ( 'input ' ) ; form.appendChild ( input ) ; var elems = form.elements ; Object.getOwnPropertyDescri... | Why is this configurable property not deletable ? |
JS | I am looking to enhance my programming experience and I believe I can do that by creating a Visual Studio ( 2012 ) extension . I have started to dig into the documentation on MSDN , but it 's dense and I am working through it . I had a few questions : Is an extension the correct approach for the scenario describedbelow... | < div > < div class= '' ui-bar-d ui-bar '' > < span class= '' WBHeaderDetail '' style= '' margin-left : 5px ; margin-right : 5px ; '' > Name : < em class= '' WBHeaderDetailValue '' style= '' text-decoration : underline ; '' > @ ViewBag.JobName < /em > < /span > < span class= '' WBHeaderDetail '' style= '' margin-left :... | VS Extension to manipulate HTML / CSS |
JS | For the given code , would the only weakMap item considered as reachable or not ? Hence , will it be garbage collected or not ? PS : This question is asked from the perspective of the specification , not particular implementations . | function f ( ) { const w = new WeakMap ( ) ; const o = { } ; w.set ( o , { v : o } ) ; return w ; } const weakMap = f ( ) ; | Would a `` circular '' reference be treated as `` reachability '' for a WeakMap ? |
JS | According to the Redactor docs regarding fixed toolbar settings , I can pass the toolbarFixed flag as true , and the toolbar should stay at the top of the viewport as the user scrolls down , however this is n't working on mobile.My suspicion as to why it does n't work on mobile is : the source code is listening for a s... | $ ( this.opts.toolbarFixedTarget ) .on ( 'scroll.redactor . ' + this.uuid , $ .proxy ( this.toolbar.observeScroll , this ) ) ; | Redactor - Fixed toolbar not working on mobile |
JS | My script is receiving data from API and store in MongoDB automatically . I was needed to create a at least 2 second delay before receiving one data after another . The problem is that my script is stop working on second time . Let 's say my script working every hour , I enable the script at 14.00 - it works and at 15.... | const j = schedule.scheduleJob ( '*/15 * * * * ' , callIt ) var symbols = [ `` ZRXBTC '' , `` ETHBTC '' , `` ETCBTC '' , `` KAVABTC '' , `` AEBTC '' ] ] ; let cnt = 0 ; const callIt = ( ) = > { fetch ( ` https : //api.binance.com/api/v3/klines ? symbol= $ { symbols [ cnt ] } & interval=30m & limit=1 ` ) .then ( res = >... | setTimeout inside a loop , stops script from working |
JS | On macOS 10.13.1 with Chrome 63.I 'm using Object.assign with new URL ( ) as the source object but it always gives an empty object ? This seems like strange behavior . Here is my code : Why is data an empty object whereas url has the complete URL object as below : I also tried : but it gives : Uncaught TypeError : unde... | let url = new URL ( 'http : //www.yahoo.com ' ) ; console.log ( url ) ; let data = Object.assign ( { } , url ) ; console.log ( data ) ; { href : `` http : //www.yahoo.com/ '' , origin : `` http : //www.yahoo.com '' , protocol : `` http : '' , username : `` '' , password : `` '' ... } let data = Object.assign ( { } , ..... | Why does Object.assign not copy the properties of a URL object ? |
JS | On the current Google Chrome ( Version 22.0.1229.79 , on an iMac with Mountain Lion ) , the following codewill showthere are also other situation that caused Firefox to behave similarly as well . Are they bugs on Chrome and Firefox -- but it would seem strange that both Firefox and Chrome are susceptible to similar bug... | var arr = [ 1 , 3 , 5 ] ; console.log ( arr ) ; delete arr [ 1 ] ; console.log ( arr ) ; console.log ( arr.pop ( ) ) ; console.log ( arr ) ; [ 1 , undefined × 2 ] [ 1 , undefined × 2 ] 5 [ 1 , undefined × 1 ] | Javascript Array delete or pop causing race condition with console.log ? |
JS | I want to write a function in JavaScript that will apply a style object to an html element but only if that object exists.Example , if I have the following object : So I use hasOwnProperty ( ) to first check that `` style '' exists before trying to apply it - and this works fine.However , let 's imagine that my object ... | objMyObject { `` idstring '' : { `` style '' : { `` opacity '' : `` 0.50 '' } } } ; objMyObject { `` idstring1 '' : { `` style '' : { `` opacity '' : `` 0.50 '' } } , `` idstring2 '' : { `` style '' : { `` opacity '' : `` 0.99 '' } } , `` idstring3 '' : { `` style '' : { `` opacity '' : `` 0.50 '' } } } ; objMyObject {... | Using hasOwnProperty ( ) to reference objects |
JS | Here is a piece of code to compare two sentences word by word and return the number of word matches with some conditions : hint : the word in the first sentence : : : : the word in the second sentence1 ) protecting : : : : i should result Not matched2 ) protecting : : : : protect should result matched3 ) protect : : : ... | let speechResult = `` they 're were protecting him i knew that i was aware '' ; let expectSt = [ ' i was sent to earth to protect you ' ] ; // Sentences we should compare word by wordlet speechResult = `` they 're were protecting him i knew that i was aware '' ; let expectSt = [ ' i was sent to earth to protect you ' ]... | Compare two sentences word by word and return the number of word matches with some conditions |
JS | I understand that Javascript does n't have multiple threads , but I 'd like to know if the following code has any chance of breaking . My understanding is that unless an asynchronous function is called , such as setTimeout or an AJAX call , that once a block of code starts executing there 's no way for it to pause unti... | var numProcessed = 0 ; var checkedBoxes = jQuery ( `` input [ type=checkbox ] : checked '' ) ; var toProcess = checkedBoxes.size ( ) ; checkedBoxes.each ( function ( ) { jQuery.post ( 'somepage.php ' , { ... } , function ( results ) { numProcessed++ ; if ( numProcessed == toProcess ) { jQuery ( `` # saving-message '' )... | Is there any possibility of two asynchronous Javascript function instances executing two blocks of code at the same time ? |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.