lang
stringclasses
4 values
desc
stringlengths
2
8.98k
code
stringlengths
7
36.2k
title
stringlengths
12
162
JS
Question : What is the difference between these four promises ?
doSomething ( ) .then ( function ( ) { return doSomethingElse ( ) ; } ) ; doSomething ( ) .then ( function ( ) { doSomethingElse ( ) ; } ) ; doSomething ( ) .then ( doSomethingElse ( ) ) ; doSomething ( ) .then ( doSomethingElse ) ;
JavaScript ES6 promises
JS
I am trying to understand arrow functions in ECMAScript 6.This is the definition I came across while reading : Arrow functions have implicit this binding , which means that the value of the this value inside of an arrow function is aways the same as the value of this in the scope in which the arrow function is defined ...
var test = { id : `` 123123 '' , k : { laptop : `` ramen '' , testfunc : ( ) = > console.log ( this ) } } console.log ( test.k.testfunc ) ; function testfunc ( ) { return console.log ( undefined ) ; } { `` laptop '' : `` ramen '' }
This values for arrow functions
JS
Part of JavaScript 's automatic semicolon insertion algorithm is so-called `` restricted productions '' . These are syntactical forms which forbid a newline character from occurring at a certain point . To quote the ECMAScript 2015 specification : If the phrase “ [ no LineTerminator here ] ” appears in the right-hand s...
thrownew Error ( `` some error '' ) ;
Why is `` throw '' a restricted production for automatic semicolon insertion ?
JS
I 'm looking for any indications whether or not `` superclassing '' a builtin type will work according to the specification . That is , given any hypothetical conformant implementation of ECMAScript , does `` superclassing '' a builtin break the runtime by affecting the creation algorithm of the class constructor ? `` ...
// clearly this would break Array if the specification allowed an implementation// to invoke super ( ) internally in the Array constructorclass Enumerable { constructor ( iterator = function * ( ) { } ) { this [ Symbol.iterator ] = iterator } asEnumerable ( ) { return new Enumerable ( this [ Symbol.iterator ] .bind ( t...
Does the ECMAScript specification allow Array to be `` superclassable '' ?
JS
I am creating a slight minor parallax effect with this code.Everything works fine everywhere , except IE.I am using IE 9.Jsfiddle-javascriptJsfiddle-jqueryJavascriptCSSi tried googling some cross browser tricks , but in vain ... Is there any way to make it work in IE ? thanks a lot.Edit : Purpose : To make a 1 div move...
< div id= '' head '' > i < /div > < div id= '' subHead '' > can < /div > < div id= '' content '' > haz < /div > window.onscroll = function ( ev ) { var subHead = document.getElementById ( 'subHead ' ) , topHeight = document.getElementById ( 'head ' ) .offsetHeight ; subHead.style.top = ( topHeight - document.body.scrol...
Simple javascript does not work in any IE ?
JS
} OK guys I have such JSON structure what I need is to : return all topics in array , in this example it will be : [ `` SERVICE_STATUS_PRESETS '' , `` AIRCRAFT_ACTIVATION '' , `` OUT_OF_SERVICE '' , `` PROMO_CODES_REQUESTS '' , `` BANNERS '' , `` DOCUMENTS '' , `` USER '' ] I try recursive calls like this , though I on...
{ `` groups '' : [ { `` name '' : `` Event '' , `` groups '' : [ { `` name '' : `` Service '' , `` subscriptions '' : [ { `` topic '' : `` SERVICE_STATUS_PRESETS '' } , { `` topic '' : `` AIRCRAFT_ACTIVATION '' , } , { `` topic '' : `` OUT_OF_SERVICE '' , } ] } ] } , { `` name '' : `` Enquiries '' , `` groups '' : [ { ...
Recursive data in JSON object
JS
When a JavaScript library creates a < div > , it typically sets a class on the div so that the user of the library can style it him/herself . It 's also common , however , for the JS library to want to set some default styles for the < div > .The most obvious way for the library to do this would be with inline styles :...
< div style= '' application 's default styles '' class= '' please-style-me '' > ... < /div > < div style= '' application 's default styles '' > < div class= '' please-style-me '' > ... < /div > < /div >
How should a JavaScript library set default CSS styles ( is there a `` ! notimportant '' ? )
JS
I 'm developing a report in Jaspersoft Studio 6.4 using custom visualization component and Highcharts . Long story short , when doing a bubble chart or an area chart , plotOptions.fillColor -attribute does not work properly , but leaves the bubbles inside or stacked area chart 's insides black . Black color usually mea...
define ( [ 'jquery_hc ' , 'hchart ' ] , function ( $ , Highcharts ) { return function ( instanceData ) { // Creating the chart var config = { chart : { type : 'area ' , plotBorderWidth : 1 , renderTo : instanceData.id , width : instanceData.width , height : instanceData.height , marginBottom : 15 , marginLeft : 40 , ma...
Jasper report color issue with Highcharts 's plotOptions.fillColor
JS
I have a 3rd party script that is importing a menu and I can not edit this 3rd party script . It generates code like this : It should take 19 hours ago and display that as text inside the span but for whatever reason it does n't work and the makers of the script are little help in fixing the error . Is there a way , us...
< div id= '' wmenu-updated '' style= '' display : block ; '' > < small > Menu updated < /small > < span innerhtml= '' 19 hours ago '' > < /span > < /div >
Modifying innerHTML from 3rd Party Script
JS
The MDN bind polyfill is shown below.I am trying to work out the purpose ofin the fToBind.apply invocation.I ca n't get my head around it . Can someone help shed some light ? It seems to be a short-circuit if an instance of the bound function is supplied as the target when invoking the bound function , but the typeof c...
this instanceof fNOP ? this : oThis Function.prototype.bindMdn = function ( oThis ) { if ( typeof this ! == 'function ' ) { // closest thing possible to the ECMAScript 5 // internal IsCallable function throw new TypeError ( 'Function.prototype.bind - what is trying to be bound is not callable ' ) ; } var aArgs = Array....
Explanation of a line in MDN bind polyfill
JS
I know very little about javascript so I 'm not exactly sure what I 'm doing . Basically , our team is working on a project that uses the jQuery weekcalendar javascript . By default the calendar will display an entire week.My problem is this : I have multiple css files that fit different screens which I call using anot...
< script type= '' text/javascript '' > $ ( document ) .ready ( function ( ) { if ( document.styleSheets ( 'mobile.min.css ' ) ) { $ ( ' # calendar ' ) .weekCalendar ( 'today ' ) ; } } )
how do I implement $ ( ' # calendar ' ) .weekCalendar ( 'today ' ) ?
JS
I have an arc and currently the dots that belong to that arc use d3.layout.pack ( ) to place them , this however only places the dots in the arc in a circle obviously . Is there a way that I could place the dots in an arc to use the whole space of an arc ( currently it just clusters the points in the center of the arc ...
var pack = d3.layout.pack ( ) .sort ( null ) .size ( [ _config.RingWidth , _config.RingWidth ] ) //config.RingWidth is the width of the arc.value ( function ( d ) { return 1 * Math.random ( ) ; //the dots are all the same size } ) ; dots2 = new Array ( ) ; for ( var clusterNum = 0 ; clusterNum < _hierarchy.Dots.dotsArr...
Placing dots in an arc
JS
Somewhat by accident , I found out that a span inserted directly inside a tbody stays in place when done with JavaScript ( insertBefore ) , where such invalid DOM would if created with literal HTML lead to the span being placed before the entire table.I expected either the same behaviour as with literal HTML or some DO...
< table > < thead > < tr > < th > Table Header < /th > < /td > < /thead > < tbody > < span > from HTML & rarr ; goes up < /span > < tr > < td > Table Contents < /td > < /tr > < /tbody > < /table > var span = document.createElement ( 'span ' ) , tbody = document.querySelector ( 'tbody ' ) ; span.innerHTML = 'Created wit...
Is it normal that JavaScript can create otherwise invalid DOM ?
JS
I have never used cookies before , so I am using a peice of code I am very unfamiliar with.It was working all fine , until I noticed just now that for select boxes , it is not working for any values after the tenth index . ( for index 10 and above ) .I have looked at the cookie stored on my system , and it appears t be...
< SCRIPT LANGUAGE= '' JavaScript '' > < ! -- Beginvar expDays = 100 ; var exp = new Date ( ) ; exp.setTime ( exp.getTime ( ) + ( expDays*24*60*60*1000 ) ) ; function getCookieVal ( offset ) { var endstr = document.cookie.indexOf ( `` ; '' , offset ) ; if ( endstr == -1 ) { endstr = document.cookie.length ; } return une...
javascript form cookies - select only opening cookie for first 10 indexes
JS
I have But that 's a piece of garbage function . Help.x is never going to be negative.Here 's a sort of Table of Truth , or something.I 'm trying to find some correlations here , but it 's late and I do n't think my brain is working correctly . zzzWhat I 'm seeing in the f ( x ) column is a sort of reverse modulus , wh...
let f = x = > x % 4 === 0 ? 0 : 4 - x % 4 x x % 4 4 - ( x % 4 ) f ( x ) 0 0 4 01 1 3 32 2 2 23 3 1 14 0 4 05 1 3 36 2 2 27 3 1 18 0 4 09 1 3 3
How to simplify modulus arithmetic ?
JS
In following code I am not able to understand why the value of this changes to window from document in function handler when I call it from the document context . As per my understanding the value of this is determined from its execution context . Now when I am document.ready function this points to document which is e...
$ ( document ) .ready ( function ( ) { var handler = function ( ) { console.log ( this ) ; // this = window } console.log ( this ) ; // this = document handler ( ) ; } )
Why value of 'this ' changes from document to window
JS
I have an array of objects like this : and I want to replace all keys inside objects with these keys : What is the best way to do this ? An example will be appreciated !
const customers = [ { customer_name : 'Negan ' , customer_age : 45 , customer_weapon : 'Bat ' , customer_email : 'negan @ sanctuary.com ' , customer_city : 'Washington ' } , { customer_name : 'Daryl ' , customer_age : 41 , customer_weapon : 'Crossbow ' , customer_email : 'daryl.dixon @ kickass.com ' , customer_city : '...
How to rename object keys inside array
JS
As the title suggests , I 'm trying to bind javascript code to my android app so I can react in my app to an event/message that my website is sending.After reading the official android documentation related to javascript binding I managed to easily implement it.. as long as it 's a string.What is working fine ? I imple...
/** Instantiate the interface and set the context */class ClientInterface ( private val mContext : Context ) { /** Show a toast from the web page */ @ JavascriptInterface fun postMessage ( message : String ) { Toast.makeText ( mContext , message , Toast.LENGTH_SHORT ) .show ( ) } } var objectMessage = { type : `` quote...
Binding javascript code to android code with objects parameters
JS
I 'm working on localization for my toolkit.My goal is that if you were a German web developer and you wanted to use a forEach loop , rather then type [ 'hey ' , 'there ' ] .forEach ( function ( ) { } ) ; they could type [ 'hey ' , 'there ' ] .fürJeder ( function ( ) { } ) ; I have all the words stored in an object at ...
de : { extend : 'verlänger ' , forEach : 'fürJeder ' }
Special characters ( and MooTools ) are ruining my life
JS
I am learning Javascript , I have been using PHP for about 10 years so I have some knowledge of Javascript , mostly just using jQuery and hacking it together , I think it 's time I put some effort into learning it better so I have been reading up on it.Below are my examples of defining and calling some functions.Method...
function testFunction1 ( ) { console.log ( 'TestFunction1 ( ) was ran ' ) ; } testFunction1 ( ) ; var testFunction2 = function ( ) { console.log ( 'TestFunction2 ( ) was ran ' ) ; } testFunction2 ( ) ; var TestFunction3 = { flag : function ( ) { console.log ( 'TestFunction3.flag ( ) was ran ' ) ; } , unflag : function ...
Javascript Functions and Objects
JS
Given the following nearley code : When I run nearley-test to test my compiled parser I get the following results : Command : Result : So far so good , next test : Result : It looks like it recognizes the X command twice without the comment , and then once with the comment . This only happens when there are spaces insi...
@ builtin `` whitespace.ne '' @ { % let numberedParams = { 3 : 45 } ; const lexer = require ( `` moo '' ) .compile ( { comment : /\ ( . * ? \ ) / , expstart : /\ [ / , expend : /\ ] / , paramstart : ' # ' , equals : `` = '' , operator : /\*\*|\+|\-|\*|\/|OR|XOR|AND|MOD|EQ|NE|GT|GE|LT|LE/ , function : [ 'ATAN ' , 'ABS '...
Nearley grammar recognizes same non-terminal symbol multiple times under certain conditions
JS
Another question on stackoverflow pointed out that it should be possible to trigger an event on all listning objects using : However this does not seem to work for me in an example like : Am I doing something completely wrong , or has this great functionality been disabled ?
$ .event.trigger ( 'customEvent ' ) ; $ ( 'body ' ) .bind ( 'customEvent ' , function ( ) { alert ( 'Working ! ' ) ; } ) ;
Ca n't listen to global event in jQuery
JS
A friend of mine got bitten by the all too famous 'anonymous functions in loop ' javascript issues . ( It 's been explained to death on SO , and I 'm actually expecting someone to my question as a duplicate , which would probably be fair game ) . The issue amounts to what John Resig explained in this tutorial : http : ...
var count = 0 ; for ( var i = 0 ; i < 4 ; i++ ) { setTimeout ( function ( ) { assert ( i == count++ , `` Check the value of i . '' ) ; } , i * 200 ) ; } var count = 0 ; for ( var i = 0 ; i < 4 ; i++ ) ( function ( i ) { setTimeout ( function ( ) { assert ( i == count++ , `` Check the value of i . '' ) ; } , i * 200 ) ;...
Readibility of anonymous closures in nested loops
JS
I have the following code : Can someone tell me why this should be declared with = > void ? I guess I am a bit confused about how to do the returntype from a javascript function . Sometimes I see : jQuery and now I am seing = > void . What is the difference between the two ?
/// < reference path= '' ../typescript/jquery.d.ts '' / > function addThemePrototypes ( ) { var templateSetup = new Array ( ) ; $ .fn.addTemplateSetup = function ( func , prioritary ) { if ( prioritary ) { templateSetup.unshift ( func ) ; } else { templateSetup.push ( func ) ; } } ; } interface JQuery { addTemplateSetu...
What is the difference between using : and = > for the return type with a TypeScript function ?
JS
Is it good practice to use a object literal as a hash table ? i.e use a property name as the key to get a particular mapped value back.For example : Is this an acceptable use for object literals , or is there a pattern out there that will better handle a hash map in JavaScript ?
var colorArray = [ { code : `` # 4286f4 '' , name : `` Blue '' } , { code : `` # fc4d02 '' , name : `` Red '' } ] var hashTable = { } colorArray.forEach ( color = > { hashTable [ color.code ] = color.name } )
Is it good practice to use a object literal as a hash table ?
JS
Deferring the execution of functions , for example in custom event handling , is a common pattern in JavaScript ( see , for example here ) . It used to be that using setTimeout ( myFunc,0 ) was the only way to do this , however with promises there is now an alternative : Promise.resolve ( ) .then ( myFunc ) . I had ass...
var logfn=function ( v ) { return function ( ) { console.log ( v ) } } ; setTimeout ( logfn ( 1 ) ,0 ) ; Promise.resolve ( ) .then ( logfn ( 2 ) ) ; logfn ( 3 ) ( ) ;
What determines the call order of deferred function using promises or setTimeout ?
JS
Currently , I am building a system , and I am having some trouble with the update function.Essentially , I am trying to add new nodes to a D3 tree . A new child node can be added when the user clicks the `` add button '' of a node . Each add button can be found on the left side of each node.I have followed Mike Bostock...
.data ( d , d = > d.data.name ) .data ( d , d = > d.source.data.name ) < div id= '' div-mindMap '' > .linkMindMap { fill : none ; stroke : # 555 ; stroke-opacity : 0.4 ; } rect { fill : white ; stroke : # 3182bd ; stroke-width : 1.5px ; } const widthMindMap = 700 ; const heightMindMap = 700 ; let parsedData ; let parse...
D3 V4 : Updated data is being seen as new data ? ( Update function )
JS
I am learning javascript myself . There is a confusion with some javascript , Those both lines can be used into a json object without any error . But when I am using those lines outside of json object , 2nd line ( `` orranges '' :6 ; ) is getting error . Why is that ? And why is not giving error for the first line ( ap...
price = 14 ; name = `` Mary '' ; apples:5 ; //This line executing without error '' orranges '' :6 ; //This line getting erroralert ( name ) ;
javascript colon operator confusion
JS
For my 1st year students , I have provided a simple ES5-based library written using the Revealing Module Pattern . Here is a snippet of the `` main '' module/namespace , which will house other extensions : This works for pretty much 99.9 % of the students who are new to web-development and are not using fancy things li...
window.Library = ( function ( $ ) { if ( ! $ ) { alert ( `` The Library is dependent on jQuery , which is not loaded ! `` ) ; } return { } ; } ) ( window.jQuery ) ;
Support for ES6 imports in ES5 module
JS
I want to create a preloading script that performs a number of async functions to download external content . I 'm pretty close here , but I have n't quite figured out how to to defer calling this.next ( ) in my onBeforeAction function . In the code below you can see I use a loop and setTimeout but I lose the context o...
if ( Meteor.isClient ) { IR_BeforeHooks = { preloadProject : function ( ) { var itemsProcessed = 0 ; _.each ( items.items , function ( e ) { HTTP.get ( e.S3URL , { headers : { 'Accept ' : '*/* ' } , responseType : 'arraybuffer ' //requires aldeed : http } , function ( error , result ) { if ( error ) { Session.set ( 'er...
How to wait on http calls in Iron Router ’ s onBeforeAction ?
JS
I made this script : That zoom 's my webpage according to the size of the user 's screen . It works fine , but the problem is that in my navigation : I have also a slider attacked to menu : And this defines my sections : Everytime i click on the `` work '' section or `` about '' It just slide 's wrong to a different lo...
< script > $ ( document ) .ready ( function ( ) { var huser = window.screen.availHeight ; var wuser = window.screen.availWidth ; var scr_zoom = Math.round ( ( wuser*69 ) /1280 ) ; document.body.style.zoom = scr_zoom + `` % '' document.head.style.zoom = scr_zoom + `` % '' } ) ; < /script > < div id= '' panel '' > < ul c...
How can I zoom in/out my website without affecting sections
JS
I have a string of XML format . As shown below : I need to get the node value in Java script file . How can I get the value ?
< gt > < st > sample1 < /st > < tt > sample2 < /tt > < tt > sample3 < /tt > < /gt >
How to get the nodes inner text in java script ?
JS
The lexical grammar of ECMAScript lists the following token classes for lexical analyzer ( lexer ) : While I understand the nested classes like WhiteSpace , LineTerminator , I do n't understand what the top level classes are : InputElementDiv , InputElementRegExp , InputElementRegExpOrTemplateTail and InputElementTempl...
InputElementDiv : : WhiteSpace LineTerminator Comment CommonToken DivPunctuator RightBracePunctuatorInputElementRegExp : : WhiteSpace LineTerminator Comment CommonToken RightBracePunctuator RegularExpressionLiteralInputElementRegExpOrTemplateTail : : WhiteSpace LineTerminator Comment CommonToken RegularExpressionLitera...
What does ` InputElementDiv ` stand for in ECMAScript lexical grammar
JS
I 'm trying to figure out how to construct my Javascript classes ( or singleton objects ) correctly.I want to be able to set a couple of properties and assign the methods available . I would also like to be able to use things like mixins on the objects so I can extend these objects with things like events .
var obj = new Object ( ) ; obj.foo = 'bar ' ; obj.method = function ( ) { ... } var obj = { foo : 'bar ' , method : function ( ) { ... } } var obj = function ( ) { } obj.prototype = { foo : 'bar ' , method : function ( ) { ... } }
What is the correct way to create a Javascript class ?
JS
So this is a generic pattern question but one I have been going back and forth with for some time . Should a model have a save method in MV* ? I often jump back and forth between Knockout , Ember , and sometimes even Angular but one of the persistent questions I always have is should the model have a save method on it ...
var person = new Model.Person ( ) ; person.name = 'Bill ' ; person.save ( ) ; var personService = require ( 'services/person.service ' ) ; var person = new Model.Person ( ) ; person.name = 'Bill ' ; personService.save ( person ) ;
Client-side MV* - Should the model have a save method ?
JS
I have a Django app with a postgres db of PostGIS activities I 'm trying to map on a frontend view using leaflet and Mapbox . I 'm serializing the activities in the view and rendering them in the template as geoJSON ( { { props.activitiesJson|safe } } ) [ can render this as html and see the JSON objects on the page ] ....
def map ( request ) : mapbox_key = settings.MAPBOX_API_KEY activities = Activity.get_activities_near ( lat , lng , radius ) props = { 'activitiesJson ' : serializers.serialize ( 'geojson ' , activities ) , } context = { 'props ' : props , 'mapbox_key ' : mapbox_key } return render ( request , 'app/map.html ' , context ...
convert PostGIS point object to geoJSON for mapping
JS
I am using the following JavaScript code : Is a considered an array of integers ?
var a = [ 23 , 34 , 45 , 33 ] ;
Does this create an array in JavaScript ?
JS
This whole project and code will be hosted to php , mysql hosting server later.code : jQuery ajax is working fine . It saves data to database , then appends the data to div . My question is : after appending the data , will the data be available/visible to other end ( computer/user ) ? Or after appending data do i have...
$ ( document ) .ready ( function ( ) { console.log ( 'hello ' ) ; $ ( 'input [ name= '' nm_submit_comment '' ] ' ) .on ( 'click ' , function ( e ) { e.preventDefault ( ) ; var frm = $ ( this ) .closest ( `` form '' ) ; var frm_id = frm.attr ( `` id '' ) ; var frm_id_splitted = frm_id.split ( `` _ '' ) ; var frm_id_spli...
jQuery ajax , appending data work but will the data be visible to other end ( computer/user ) ?
JS
I wan na stop a observable subscription based on two conditions : Time ( using import { timer } from 'rxjs/internal/observable/timer ' ; ) ORExecution status ( using the returned object from request that you 'll see below ) What is happenning : It 's only stoping execution based on Time ( using import { timer } from 'r...
import { finalize } from 'rxjs/internal/operators/finalize ' ; import { interval } from 'rxjs/internal/observable/interval ' ; import { timer } from 'rxjs/internal/observable/timer ' ; import { takeUntil , first } from 'rxjs/operators ' ; import { merge , EMPTY , of } from 'rxjs ' ; .. // Attributes and Class declarati...
How to stop subscription by using multiple conditions with takeUntil
JS
Taking a look at code from Leaflet api My question is why wrapperFn.apply ( context , args ) ; and fn.apply ( context , args ) ; using apply ( ) and not call ( ) . How do you know which one to use ? Confused because I do n't know ahead of time if my passing function is using an array or not .
limitExecByInterval : function ( fn , time , context ) { var lock , execOnUnlock ; return function wrapperFn ( ) { var args = arguments ; if ( lock ) { execOnUnlock = true ; return ; } lock = true ; setTimeout ( function ( ) { lock = false ; if ( execOnUnlock ) { wrapperFn.apply ( context , args ) ; execOnUnlock = fals...
Using apply ( ) vs call ( ) , which one to use in this case ?
JS
Lets say I have 50 modules and each needs Underscore library . Is it better to load Underscore like that 50 times : or its better to pass it from main file : Does it make any difference ?
//a modulevar _ = require ( 'underscore ' ) ; //app.jsvar _ = require ( 'underscore ' ) ; require ( './app_modules/module1.js ' ) ( _ ) ; // passing _ as argumentrequire ( './app_modules/module2.js ' ) ( _ ) ; // passing _ as argumentrequire ( './app_modules/module3.js ' ) ( _ ) ; // passing _ as argument ( .. )
Should I require a module in every file or require it once and pass it as argument ?
JS
How can I ensure the security of my payment system via PayPal ? I use the vue-paypal-check create the frontend PayPal button for the payment . the code is bellow : some dota is bellow : the callback method of pay success : but I have a question , if someone of customer is evil with technology , he call the payment_comp...
< Pay-Pal v-if= '' paypal_live_id & & paypal_sandbox_id '' : amount= '' amount '' currency= '' USD '' : client= '' credentials '' : env= '' paypal_env '' @ payment-authorized= '' payment_authorized_cb '' @ payment-completed= '' payment_completed_cb '' @ payment-cancelled= '' payment_cancelled_cb '' : items= '' pay_item...
How can I ensure the security of my payment system via PayPal ?
JS
I had a bug in my Angular 4 project where I had declared a variable : instead ofSo of course this.debounce was undefined before the fix . Should n't typescript give me an error in this case ?
debounce : 300 ; debounce = 300 ;
Why does typescript accept a number value as a type ?
JS
I have a string with space-separated unique numbers as following : Need a quick and efficient way to switch a pair of them in form : I could split the string and search for values , but that sounds boring . Any better idea ?
`` 2 4 13 14 28 33 '' switchNumbers ( 2 , 28 ) // result : `` 28 4 13 14 2 33 ''
Switch numbers in string
JS
i have a string likeI want to get only the value of that input box which is stored in str as Beauty is Fakeis there anyway to get it ?
var str= ' < input type= '' text '' name= '' se_tbox '' value= '' Beauty is Fake '' / > ' ;
How to get the value of the text box from a HTML Coded String
JS
I am using Javascript to create a CSV file for user to download.Until May 22nd , Chrome still downloaded the file with the name I specified . However , today I found that the files downloaded are named `` download '' and do not have the extension .csv.This problem does not exist in Firefox ! Here is a fiddle with sampl...
var A = [ [ ' n ' , 'sqrt ( n ) ' ] ] ; // initialize array of rows with header row as 1st itemfor ( var j=1 ; j < 10 ; ++j ) { A.push ( [ j , Math.sqrt ( j ) ] ) } var csvRows = [ ] ; for ( var i=0 , l=A.length ; i < l ; ++i ) { csvRows.push ( A [ i ] .join ( ' , ' ) ) ; // unquoted CSV row } var csvString = csvRows.j...
can not specify name of the download file using Javascript
JS
Is there a difference between the two codes below , I presume not.and
function Agent ( bIsSecret ) { if ( bIsSecret ) this.isSecret=true ; this.isActive = true ; this.isMale = false ; } function Agent ( bIsSecret ) { if ( bIsSecret ) this.isSecret=true ; } Agent.prototype.isActive = true ; Agent.prototype.isMale = true ;
Is there a difference between using `` this '' and `` prototype '' in Javascript here ?
JS
I am still learning Extjs and mvc so I have a design question that I am sure someone can answer for me . My question is : I have 2 controllers that handle two different views . Either of the two controllers are called to render the correct view based on the type of user . So in my case if the user is admin then they wi...
Ext.define ( 'adminController ' , { // handles admin } ) Ext.define ( 'standardController ' , { // handles standard } ) Ext.application ( { name : 'MTK ' , autoCreateViewport : true , if ( admin ) { controllers : [ 'adminController ' ] } else ( std ) { controllers : [ 'standardController ' ] } } ) ; Ext.define ( 'admin...
Extjs4 mvc design ideas
JS
I 'm trying to create a small project with video sprites , modeled after this JSFiddle for audio sprites.Playback works as expected : clicking on the relevant buttons play the relevant portions of the video . Now , however , I would like to incorporate something that would make the video play in full screen ( or full w...
var videoSprite = document.getElementById ( 'bbb ' ) ; // sprite datavar spriteData = { full : { start : 0 , length : 595 } , tentotwenty : { start : 10 , length : 10 } , tentothirty : { start : 10 , length : 20 } , fiftytoonefifty : { start : 50 , length : 200 } } ; // current sprite being playedvar currentSprite = { ...
Full screen video sprites
JS
In examples I 've seen new Image ( ) to create a new HTML image element but when I try new Div ( ) there is no support . Is there a reason for this or any plan in the future to add it ? Example :
var image = new Image ( ) ; var div = new Div ( ) ; // error
Why can you use new Image but not new Div or new Span ?
JS
WHAT I TRIED ( DOES NOT WORK CORRECTLY ) : CODE : QUESTION : How do I revert the data client-side to get my posts from top to bottom according to their score ( from highest to lowest ) ? WHAT I WOULD LIKE TO ACHIEVE : Get my posts in descending order according to score which is a bit trickier with the infinite scroll .
< script > var app = angular.module ( 'app ' , [ 'firebase ' ] ) ; app.controller ( 'ctrl ' , function ( $ scope , $ firebaseArray , $ timeout ) { $ scope.data = [ ] ; var _n = Math.ceil ( ( $ ( window ) .height ( ) - 50 ) / ( 350 ) ) + 1 ; var start = 0 ; var end = _n - 1 ; var lastScore = < % =lastScore % > ; console...
How to show my top posts first in my Infinite Scroll , in descending order with firebase ?
JS
I have web application which use the jsonp which return javascript codes to the client.This is the code I return ( to make it unreadable ) : in the load function , we eval the codes.However , we found that it is unreadable , but it is un-debuggeable.So I wonder if we can use this : Then , in the load function insead of...
com.xx.load ( 'xx ' , 'var name= '' hguser '' ; function data ( x ) { console.info ( x ) ; } ' ) com.xx.load ( 'xx ' , function ( ) { var name='hguser ' ; function data ( x ) { console.info ( x ) ; } } ) ;
different between eval ( string ) and eval ( function )
JS
I have a a webpage in which i use jQuery UI and tinyMCE in combination.I have added a custom button with the intention to use this button to drag a draggeble textfield : the code : Can i add a class `` .handle '' to the custom tinyMCE drag button ? or is this not posible .
editor.addButton ( 'drag ' , { text : 'Drag ' , icon : false , onclick : function ( ) { // somehow add the class '.handle ' to the drag button } } ) ; }
Is it possible to add a class to a custom tinyMCE button ?
JS
For the following code : Firebug ( Firefox ) wants to tell me aspenProto is Mammal { } , while Chrome is saying Canine { } . Can anyone tell me why they display different , and if anyone else has ran into this issue ?
function Mammal ( ) { this.hair = true ; this.backbone = true ; return this ; } function Canine ( ) { this.sound= 'woof ' ; return this ; } Canine.prototype = new Mammal ( ) ; function Dog ( name ) { this.tail=true ; this.name=name ; return this ; } Dog.prototype = new Canine ( ) ; var aspen = new Dog ( 'Aspen ' ) ; va...
Difference in Prototype Inheritance , Firefox vs Chrome
JS
I 'm trying to get the most popular/common word from an Array , I 've tried the following but instead of it just saying 'Rain ' it displays this inside the console instead [ rain : 2 , hot : 1 ] .What am I doing wrong ? I only want to display the number one most popular words without the number . Any help/advice would ...
var defaultArray = [ { age : '' 25-35 '' , country : '' united kingdom '' , sex : '' male '' , word : '' rain '' } , { age : '' 25-35 '' , country : '' united arab emirates '' , sex : '' male '' , word : '' hot '' } , { age : '' 25-35 '' , country : '' zimbabwe '' , sex : '' female '' , word : '' rain '' } ] ; /* Popul...
Popular word in Array
JS
I have an application that is listening for incoming data from an IPC Renderer Channel . Here is my setup : container that sends data to angular app ( mainWindow ) : angular app : Everytime the IPC Channel emits the 'data-from-container ' event , the data is always getting received from my OnInit call , but the data do...
mainWindow.loadURL ( 'http : //www.myangularapp.com ' ) //where the angular app lives ( example url ) .mainWindow.webContents.on ( 'did-finish-load ' , ( ) = > { const data = { name : `` John Doe '' , address : `` 123 Main St '' , city : `` NY '' } mainWindow.webContents.send ( 'data-from-container ' , data ) } } ) con...
Change Detection works intermittently when receiving data from Electron Container IPC Channel
JS
I am working on react-native and I want the recursion to stop when the state value becomes false.Is there any other way I can implement this code I just want to repeatedly execute a function while the state value is true.Thank you
useEffect ( ( ) = > { playLoop ( ) ; } , [ state.playStatus ] ) ; const playLoop = ( ) = > { if ( state.playStatus ) { setTimeout ( ( ) = > { console.log ( `` Playing '' ) ; playLoop ( ) ; } , 2000 ) ; } else { console.log ( `` Stopped '' ) ; return ; } } ; Output : Stopped// State Changed to truePlayingPlayingPlayingP...
setTimeout ( ) function is not detecting a state change and keeps executing the recursive function
JS
I have a string of text , for exampleI want to replace `` [ `` character with `` $ { `` and `` ] '' character with `` } '' , but only in that case , when `` [ `` is followed up by `` ] '' .For exampleshould result inHow can I accomplish that with regex in Javascript ? I wrote something like thisBut it does n't work for...
[ text1 ] [ text2 ] [ text3 ] [ text1 ] [ [ text2 ] [ text3 ] $ { text1 } [ $ { text2 } $ { text3 } someString = someString.replace ( /\ [ /g , `` $ { `` ) ; someString = someString.replace ( / ] /g , `` } '' ) ;
Javascript replace opening and closing brackets
JS
I found an unexpected value of this keyword in the following example : The value of this keyword is the object x as if it 's executed from that object , I expect only the get function that has this keyword equals to the calling object xthis example shows us the differenceIn both examples func1 which is the getter funct...
let x = { z : 10 , get func1 ( ) { return function ( v ) { console.log ( this === v ) ; } } } x.func1 ( x ) let x = { func2 ( ) { return function ( v ) { console.log ( this === v ) ; } } } x.func2 ( ) ( x ) ;
The value of ` this ` keyword of a function returned from a getter
JS
What I want to do is quite simple in itself , but I 'm wondering is there is some really neat and compact way of accomplishing the same thing.I have a float variable , and I want to check if it 's value is between 0 and 1 . If it 's smaller than 0 I want to set it to zero , if it 's larger than 1 I want to set it to 1....
// var myVar is set before by some calculationif ( myVar > 1 ) { myVar = 1 ; } if ( myVar < 0 ) { myVar = 0 ; }
Elegant way of checking if a value is within a range and setting it 's value if it falls outside of the range ?
JS
How can I write the following jQuery-not…… in pure JavaScript ?
$ ( `` .hover '' ) .not ( `` .selected '' ) ;
jQuery-not in pure JavaScript
JS
I am trying to write a program that can do math with English words . For example , I want to be able to do something like and get output like Is it possible to do this in jQuery ?
`` four thousand and three '' + `` seven thousand and twenty nine '' `` eleven thousand and thirty two ''
How can I do math with words in jQuery ?
JS
I have a fixed-size parent element that can contain a changing number of child elements , all of which need to be displayed at the same size and with a fixed x/y ratio ; and all of which need to be displayed as large as possible , without overflowing the size of the parent element . ( Got that ? ) It 'll be a lot clear...
function layout ( parent , parentHeight , parentWidth , children , ratio ) { var totalArea = parentHeight * parentWidth ; var elements = children.length ; var height = 0 , width = 0 , area = 0 , cols = 0 , rows = 0 ; for ( height = parentHeight ; height > 0 ; height -- ) { width = height * ratio ; area = width * height...
Best way to layout a variable number of resizable child elements inside a parent < div > ?
JS
I 've run into a bit of a problem with passing post parameters to a controller action via a ajax call . I 'm not sure why it is doing it , because the other ajax calls perform as intended . The response I 'm getting is as follows : The controller code is : The javascript and html : As stated before , the error I 'm get...
Notice : Undefined index : user_bio in C : \xampp\htdocs\module\Members\src\Members\Controller\ProfileController.php on line 149 public function changebioAction ( ) { $ layout = $ this- > layout ( ) ; $ layout- > setTerminal ( true ) ; $ view_model = new ViewModel ( ) ; $ view_model- > setTerminal ( true ) ; if ( $ thi...
post parameter not being passed zend framework 2
JS
I 'm making a random hero picker for a game , and this tool will randomly pick heroes for the player . I want to add a feature where it picks the heroes for the whole team of 3 , but I do n't know how to make it so that the same hero wo n't be pick more than once . Here is a sample of my code for picking a random hero ...
< script language= '' JavaScript '' > function pickhero ( ) { var imagenumber = 16 ; var randomnumber = Math.random ( ) ; var rand1 = Math.round ( ( imagenumber-1 ) * randomnumber ) + 1 ; images = new Arrayimages [ 1 ] = `` http : //www.vaingloryfire.com/images/wikibase/icon/heroes/ringo.png '' images [ 2 ] = `` http :...
JS : How to create a random picker that wo n't pick the same item twice ?
JS
So I have this really basic function with a for loop . It runs fine on modern Chrome and Firefox browsers , but not on a particularly picky Firefox 38 browser . According to the docs this function has been supported since Firefox 13 . The exact error being reported by Firefox is : So , why is this error being reported ...
function showhide_class ( cl ) { var es = document.getElementsByClassName ( cl ) ; for ( let e of es ) { e.style.display = ( e.style.display == `` block '' ) ? `` none '' : `` block '' ; } } SyntaxError : missing ; after for-loop initializer
Why is Firefox complaining about a semicolon in this javascript for loop ?
JS
`` The new.target property lets you detect whether a function or constructor was called using the new operator '' [ 1 ] I can use new.target in an if statement to throw an error if a function was not called using new : However , safari prevents new.target from being used with the ! in this way , with the error message ...
if ( ! new.target ) { throw new Error ( 'Must be called with new keyword ! ' ) } if ( new.target ) { } else { throw new Error ( 'Must be called with new keyword ! ' ) }
new.target with a prefix operator
JS
Similar to : How to blacklist specific node_modules of my package 's dependencies in react-native 's packager ? I am trying to exclude react native from metro packager using the blacklist option which needs to return a regexp.What I need is to return something like : where I can insert a variable into the DYNAMIC_PROJE...
/\/DYNAMIC_PROJECT_DIRECTORY\/node_modules\/react-native\/ . */ ,
regex for blacklisting node module with dynamic yarn workspace path in React Native metro bundler
JS
I just looked at the page source of a random app page on apptivate.ms and noticed this JavaScript in the < head > : It is obviously totally static on the client side so I wonder what the use-case there is . Since they Stack Exchange developers ( who are behind apptivate.ms ) are pretty smart I 'm sure there is some rea...
< script type= '' text/javascript '' > document.write ( `` < style type=\ '' text/css\ '' > .app-description { max-height : 600px } < /style > '' ) ; < /script >
What 's the reason to add a simple static < style > tag via document.write ( ) ?
JS
I 'm start learning Vue.js and ECMA6 syntax , I saw this in the tutorial : Then I thought the syntax could be : but this works : Can explain the difference and the ECMA5 syntax ?
methods : { someMethod : function ( ) { console.log ( this ) // this works } } methods : { someMethod : ( ) = > { console.log ( this ) // this undefined } } methods : { someMethod ( ) { console.log ( this ) // this works } }
Difference between nameFunction ( ) { } and nameFunction ( ) = > { } in ECMA6
JS
I have a post feed where a play button can be clicked and the play button will be toggled to a pause button , however , when I click on one of the play buttons , both pause buttons are toggled on ( for each post ) . How do I only allow Javascript to toggle the single play button on the feed when there are multiple clas...
< div class= '' media-circle '' > < ! -- the pause icon is display : none at start -- > < i class= '' icon ion-ios-play '' > < /i > < i class= '' icon ion-pause feed-pause '' > < /i > < /div > jQuery ( '.media-circle ' ) .click ( function ( e ) { e.preventDefault ( ) ; jQuery ( this ) .find ( ' i ' ) .toggleClass ( 'io...
Prevent jQuery from selecting multiple items with the same class
JS
I am new to AngularJs I am getting json data which is in format : I want to calculate each students marks and if marks is less than 40 % then table row should be red else else should be green.I have tried.HTMLScriptcssI am getting percentage but according to percentage I am not getting the row colour .
[ { 'StudentName ' : 'abc ' , 'maths ' : ' 0 ' , 'english ' : ' 0 ' , 'economics ' : ' 0 ' , } ] < div ng-app= '' MyApp '' ng-controller= '' con1 '' > < table id= '' table1 '' > < tr > < th > student Name < /th > < th > History Marks < /th > < th > Maths Marks < /th > < th > Economics Marks < /th > < th > Percentage < ...
Table row colour according to result
JS
I am trying to find all the characters ( ' ? ' ) of a URL and replace it with & . For instance , i have var test = `` http : //www.example.com/page1 ? hello ? testing '' ; I first attempted : This resulted in that only the first ? would be replaced by & , then I found a question saying that I could add a g ( for global...
document.write ( test.replace ( `` & '' , '' ? '' ) ) document.write ( test.replace ( `` & '' g , '' ? '' ) )
Javascript character replace all
JS
JavaScript objects have the 'prototype ' member to facilitate inheritance . But it seems , we can live perfectly well , even without it , and I wondered , what are the benefits of using it . I wondered what are the pros and cons.For example , consider the following ( here jsfiddle ) : A question is , why use 'prototype...
function Base ( name ) { this.name = name ; this.modules = [ ] ; return this ; } Base.prototype = { initModule : function ( ) { // init on all the modules . for ( var i = 0 ; i < this.modules.length ; i++ ) this.modules [ i ] .initModule ( ) ; console.log ( `` base initModule '' ) ; } } ; function Derived ( name ) { Ba...
Why use 'prototype ' for javascript inheritance ?
JS
in my react app I use radio buttons with this code : and this handler : State is set properly , but the radio buttons does not switch visually , what could be the problem in this case ? thanksUPDATE consolelog of this.state.stepsDataUpdate consolelog of this.state.stepsData right bevore render
< RadioGroup name='steptype ' className= { css.ProcessStepRadioButtons } value= { this.state.stepsData [ stepNumber ] .stepType } onChange= { ( value , event ) = > { this.changeInputOptionHandlerProcessStep ( value , `` stepType '' , stepNumber ) } } > < RadioButton label= { < T value='processes.new.processStepTypeDuty...
reactjs-toolbox radiobutton group does not change
JS
I have one variable holding single line string which is html element like this.I want to select everything after FI : until comma sign into one variable and after comma sign until tag into another variable . Also for SE : and EN : too.For example , result will be like this.Note , the string change dynamically but still...
var des = `` < p > -- Sometext before -- FI : This is fi name , This is fi manufacturer < br / > SE : This is se name , This is se manufacturer < br / > EN : This is en name , This is en manufacturer < /p > '' ; var fi_name = `` This is fi name '' ; var fi_manufacturer = `` This is fi manufacturer '' ; var se_name = ``...
How can I strip text from string ?
JS
I am new in voiceXML and I am trying to use evolution.voxeo.com to run simple XML codes . According to their website , we can post the recorded audio in multi-part format . So here is my XML code , that runs fine without record element . But when I add the record element , I get error . The fact that I am getting error...
00089 6c51 02:55:21 AM ( http : //65.29.170.122/ , 1 ) : Content is not allowed in prolog.00090 6c51 02:55:21 AM Exception : error.semantic XML parse error ( s ) occurred in : http : //65.29.170.122/ ( http : //65.29.170.122/ , 1 ) : Content is not allowed in prolog . Dialog stack trace : State ( Dialog ) URL ( Documen...
voiceXML in evolution.voxeo.com , getting strange error
JS
I want to define a local variable in an input tag for an Angular 2 application : The output that I am expecting is : However the real output is ( notice the additional = '' # sometext '' ) : This way , Angular 2 throws the following error , very likely due to that = '' # sometext '' : Do you know any way of preventing ...
input ( # sometext ) button ( ( click ) = '' addTechnology ( sometext.value ) '' ) Add < input # sometext/ > < button ( click ) = '' addTechnology ( sometext.value ) '' > Add < /button > < input # sometext= '' # sometext '' / > < button ( click ) = '' addTechnology ( sometext.value ) '' > Add < /button > Can not find d...
Preventing Jade from adding an assignment clause in an HTML element
JS
If I have three files , basically something like this : file_one.js : file_two.js : one_and_two_importer.js : My assumption was that the function lol would be in global scope and thus cause a namespace collision , but apparently that does n't happen . Also , if I try to log the function lol in one_and_two_importer.js ,...
const lol = ( ) = > { console.log ( 'Laughing out loud in file_one ' ) } const funcOne = ( ) = > { lol ( ) } export default funcOne const lol = ( ) = > { console.log ( 'Laughing out loud in file_two ' ) } const funcTwo = ( ) = > { lol ( ) } export default funcTwo import funcOne from 'file_one'import funcTwo from 'file_...
Is there a risk of namespace collision of two constants , if used in imported modules but declared outside of them ?
JS
I have the below regex which has 3 alternations ( see whole regex below ) , each with its own prefix and suffix characters . I feel that this is repeating excessively and would like to simplify if possible . I am matching values in an improperly formed JSON string to replace values that do not have a key with indexed k...
( `` ( ? : [ ^\\ '' ] +|\\ . ) * '' ) /\ { ( `` ( ? : [ ^\\ '' ] +|\\. ) * '' ) ( ? = , ) | , ( `` ( ? : [ ^\\ '' ] +|\\. ) * '' ) ( ? = , ) | , ( `` ( ? : [ ^\\ '' ] +|\\ . ) * '' ) ( ? =\ } ) /g
Regex alteration with shared sub expression with different prefix and suffix expressions
JS
I have integrated some HTML/JS Code into my Vaadin WebApplication by creating an AbstractJavaScriptComponent . The Component almost works as intended.How do I call the passInfo ( ) method defined in the `` connector.js '' without having to manually click the Button defined in the innerHTML of the `` chessControll.JsLab...
com_*myname*_*applicationName*_JsLabel = function ( ) { var mycomponent = new chessControll.JsLabel ( this.getElement ( ) ) ; connector = this ; this.onStateChange = function ( ) { mycomponent = this.getState ( ) .boolState ; } ; mycomponent.click = function ( ) { connector.passInfo ( true ) ; } ; } ; var chessControll...
JavaScript Scope of Vaadin 's `` AbstractJavaScriptComponent ''
JS
Say I have the following element : In a Javascript console , I 'll get its contents with jQuery : theContents is now an array that looks like this : So far so good ; it seems to be an array , where elements 0 and 2 are strings , and element 1 is a jQuery object . If I output just the first element , it seems to confirm...
< p id= '' thingy '' > Here is some < em > emphasized < /em > text ! < /p > > var theContents = $ ( ' < p id= '' thingy '' > Here is some < em > emphasized < /em > text ! < /p > ' ) .contents ( ) ; > theContents [ `` Here is some `` , < em > ​emphasized​ < /em > ​ , `` text ! '' ] > theContents [ 0 ] '' Here is some ``...
What kind of object shows up in the console as [ object Text ] ?
JS
There is a way to add a member-function or member-property to Number , String , ect ... -Variables with the help of the prototype-property : or with help of the proto-property of the variables themselves : Just like to any other kind of JavaScript-types.But what is the difference of the implementation of Primtives and ...
Number.prototype.member = function ( ) { console.log ( 'number-member-function called ' ) ; } ; var num = 7 ; num.__proto__.member = function ( ) { console.log ( 'number-member-function called ' ) ; } ; var num = 7 ; num.member = function ( ) { console.log ( 'number-member-function called ' ) ; } ; num.member ( ) ; // ...
Why are JavaScript Primitive-Variables immutable and Object-Variables not ?
JS
I 'm trying to load Radium ( which is a javascript library for inline css ) following instructions here.In app.browserify.js : Radium = require ( `` radium '' ) ; .In package.json : `` radium '' : `` 0.13.4 '' However when I try to use Radium in js in the app , the inline css does n't work . Chrome dev tool indicates t...
AppBody = React.createClass ( { mixins : [ ReactMeteorData , Navigation , State , Radium.StyleResolverMixin , Radium.BrowserStateMixin ] , render : function ( ) { var self = this ; var styles = { base : { color : this.state.fontColor , background : 'red ' , states : [ { hover : { background : 'blue ' , color : 'red ' }...
Using npm package in Meteor via cosmos : browserify
JS
Note : I am using ionic framework and angular.Short explanation : I have a json file with information . Each object from the file has an id , category , title , etc . Using a for loop I am filling the feed tab with every object as an item , like a quick post , with an option to click to read more . The for loop is used...
var starter = angular.module ( 'starter ' , [ 'ionic ' ] ) starter.run ( function ( $ ionicPlatform ) { $ ionicPlatform.ready ( function ( ) { if ( window.cordova & & window.cordova.plugins.Keyboard ) { cordova.plugins.Keyboard.hideKeyboardAccessoryBar ( true ) ; } if ( window.StatusBar ) { StatusBar.styleDefault ( ) ;...
Accessing nested urls when using for loop to generate the list items on feed tab
JS
The law of non-contradiction dictates that two contradictory statements can not both be true at the same time . That means that the expressionsshould always evaluate to a falsy value , andshould always evaluate to a truthy value.Fortunately , though , Javascript is a fun language that allows you to do all sorts of sick...
( a & & ! a ) ( a == ! a ) ( a === ! a ) ( a || ! a )
How can I break the law of non-contradiction in Javascript ?
JS
I have a page resource that uses the page title in the url.That is working fine in this jsbin . However , I would like to have subpages nested in the url like this : localhost/ # /main_page/sub_pageI tried to make a sub resource ( jsbin ) , but I 'm not sure if it is the right approach.There are two main problems in my...
App.Router.map ( function ( ) { this.resource ( 'page ' , { path : '/ : page_id ' } ) ; } ) ; App.PageRoute = Ember.Route.extend ( { serialize : function ( model ) { return { page_id : model.title } ; } } ) ; App.Router.map ( function ( ) { this.resource ( 'page ' , { path : '/ : page_id ' } , this.resource ( 'subpage ...
How can I repeat a resource in Ember.js
JS
I would like to scrape for each link on this page the page details page behind.I can get all informations on this page : PAGEHowever , I would like to get all info 's on the details page , but the href link looks like that , for example : Here is my sample spreadsheet using the ImportHTML function to get the general ov...
href= '' javascript : subOpen ( '9ca8ed0fae15d43dc1257e7300345b99 ' ) '' function doGet ( e ) { var base = 'http : //www.ediktsdatei.justiz.gv.at/edikte/ex/exedi3.nsf/ ' var feed = UrlFetchApp.fetch ( base + 'suche ? OpenForm & subf=e & query= % 28 % 5BVKat % 5D % 3DEH % 20 % 7C % 20 % 5BVKat % 5D % 3DZH % 20 % 7C % 20...
Scraping table from website , with javascript : subOpen href link
JS
I have the following code that I want to test with Qunit.My QUnit test gets a reference to the button and calls the click function : Strangely enough if I call getElementById inside Qunit 's test method the eventhandler that is attached to the button does n't get invoked . However , if I move the call to getElementById...
// my code under testdocument.getElementById ( 'saveButton ' ) .addEventListener ( 'click ' , save ) ; function save ( ) { console.log ( 'save clicked ' ) ; } ( function ( ) { `` use strict '' ; // HACK : with this line here click works //var btn = document.getElementById ( 'saveButton ' ) ; // the test QUnit.test ( ``...
Within a QUnit test the click event will only fire if the reference is obtained before the test runs
JS
Given an HTML node , how would you tell if it bears official HTML tag or not ? In above code snippet I want h9 is not official html tag . How do I find it out programmatically using JS ? Edit : Preferably in O ( 1 )
< h9 id= '' someNodeId '' > hello < h9 > let node = document.getElementById ( `` someNodeId '' ) ;
How to detect unofficial tags in html ?
JS
I 'm using openui5 . There is a constructor Function for UI control Button , unable to see the prototype properties of the Button but the same thing when executed in browser console , shows up ! The same code when executed browser in console , it works ! jsbin -- > http : //jsbin.com/tepum/1/edit
sap.m.Button.prototype.Move = function ( ) { console.log ( 'Move ' ) ; } var oButton = new sap.m.Button ( { text : '' Hello '' } ) ; oButton.Move ( ) ; // throws undefined function !
Is it possible to HIDE Javascript Object 's prototype ! What 's the MYSTERY behind this ?
JS
Say , I have a form with a text input and a submit button.If there are no buttons in the form , just submit event triggers , but if there is at least one button with no type attribute or with type= '' submit '' , it clicks it too.Now , when I enter something in the input and then press Enter , I see that both button cl...
< form > < input type= '' text '' / > < button onclick= '' alert ( 'submitted ' ) ; '' > Submit < /button > < /form >
Why a button is clicked when a form is submitted ?
JS
I am using chosen.jquery.js for select fieldBut It shows only data-placeholder value in case of no data in model.I want to show `` Select Body Part ( s ) '' as a option in list.And user must not select this . Reason is that , I want to add dynamic `` Unknown '' value in list of Body_Parts . But it not reflect in list.S...
< select chosen multiple data-placeholder= '' Select Body Part ( s ) '' ng-options= '' option.Name as option.Name for option in BodyPartList '' ng-model= '' Body_Part '' > < option value= '' '' disabled > Select Body Part ( s ) < /option > < /select >
Want to add none as value in select multiple
JS
I want caching into the `` localstorage '' the HttpRequest and HttpResponse classes from @ angular/common/http.The localstorage only accept string , therefore i want serialize/unserialize both objects ( HttpRequest and HttpResponse ) with JSON.stringfy ( ) and JSON.parse ( ) .The problem is HttpRequest and HttpResponse...
function serializeRequest ( angularRequest : HttpRequest ) : string { return null ; // to implement } function unserializeRequest ( jsonRequest : string ) : HttpRequest { return null ; // to implement } // this is an example of requestconst originalRequest = new HttpRequest ( 'POST ' , 'https : //angular.io/docs ? foo=...
Angular : serialize/unserialize in JSON HttpRequest and HttpResponse object
JS
I have 5 links on my vertical nav . On screen resize my vertical nav becomes a horizontal nav with three ( of those 5 links ) showing and another link called menu which displays the other two remaining links . For some reason , on screen resize , when menu appears , the list content is already displayed and then when m...
$ ( document ) .ready ( function ( ) { $ ( `` .show '' ) .click ( function ( ) { $ ( `` .subMenu '' ) .toggleClass ( `` active '' ) ; return false ; } ) ; } ) ; .site-wrapper { height : 100 % ; min-height : 100 % ; display : flex ; } /* make divs appear below each other on screen resize */ @ media screen and ( max-widt...
Submenu does n't render correctly on screen resize ( and unexpected behaviour )
JS
I 'm struggling to find problems with using Suspense and React hooks.There are several key problems with the React code below.Let me know what they are.I found two key problems.Misuse of setdata in useEffect dependency arrayDid n't provide suspense fallback props.I think there is still one key problem remaining.One wei...
import { Suspense , useState , useEffect } from 'react ' ; const SuspensefulUserProfile = ( { userId } ) = > { const [ data , setData ] = useState ( { } ) ; useEffect ( ( ) = > { fetchUserProfile ( userId ) .then ( ( profile ) = > setData ( profile ) ) ; } , [ userId , setData ] ) return ( < Suspense > < UserProfile da...
Understanding Suspense and React Hooks
JS
I 'm a Python developer , making my first steps in JavaScript.I started using Map and Set . They seem to have the same API as dict and set in Python , so I assumed they 're a hashtable and I can count on O ( 1 ) lookup time.But then , out of curiosity , I tried to see what would happen if I were to do this in Chrome 's...
new Set ( [ new Set ( [ 1 , 2 , 3 ] ) ] ) Set ( 1 ) { Set ( 3 ) }
Does JavaScript use hashtables for Map and Set ?
JS
Firstly , I 'm new to programming and Stackoverflow scares me , but I 've tried to contain all the relevant code and to explain my problem well . I have seen many other posts regarding people attempting to make Space Invaders clones and even specifically the `` invaders '' not moving in unison . However , these posts h...
var enemies = [ ] ; for ( var i = 0 ; i < ROWS ; i++ ) { var newRow = [ ] ; for ( var y = 0 ; y < COLS ; y++ ) { newRow.push ( new Enemy ( y * 40 + 40 , i * 30 ) ) ; } enemies.push ( newRow ) ; } var Enemy = function ( x , y ) { this.height = 30 ; this.width = 30 ; this.x = x ; this.y = y ; this.speed = 15 ; } ; Enemy....
Space Invaders not moving in unison ( Javascript )
JS
I 'm currently generating UUIDs in Javascript with this function ( Create GUID / UUID in JavaScript ? ) : I understand that all the randomness is only coming from Javascript 's Math.random ( ) function , and I do n't care if it meets an RFC for a UUID . What I want is to pack as much randomness into as few bytes as pos...
lucid.uuid = function ( ) { return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace ( / [ xy ] /g , function ( c ) { var r = Math.random ( ) *16|0 , v = c == ' x ' ? r : ( r & 0x3|0x8 ) ; return v.toString ( 16 ) ; } ) ; }
High density random strings in Javascript
JS
Please run this test on firefox.http : //jsperf.com/static-arithmeticHow would you explain the results ? Thisexecutes much faster thanWhy ?
b = a + 5*5 ; b = a + 6/2 ; b = a + 7+1 ; b = a + 25 ; b = a + 3 ; b = a + 8 ;
Firefox JavaScript arithmetics performance oddity