spot7.org logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories
  Home » JAVASCRIPT » Page 1
Non Modal Alert Messages in java script, activated by a button
The problem with your code is that your function is not available globally. You have to add your function to window object. e.g. window.message1 = message1 The following code is doing what you need. You can find the same code at jsFiddle here. I'm also recommending to use jQuery because it's a lot easier to attach click handlers. But for easy stuff it's OK like you're doing it. (function() {

Categories : Javascript

How to Count [Combined] line length of multiple files?
Like this? 1. document.getElementById("div1").innerHTML.split(" ").length; 2. document.getElementById("div2").innerHTML.split(" ").filter(function(l){return l.length;}).length; text.split(" ").length gives us lines count .filter(function(l){return l.length;}) filters out empty lines

Categories : Javascript

Is there any javascript event fired when the on-screen keyboard on mobile safari or chrome opens?
Unfortunately the answer here is a clear: NO. There are some related questions here with some further information and tricks: screen styling when virtual keyboard is active iPad Web App: Detect Virtual Keyboard Using JavaScript in Safari? Android/iPhone webkit, event triggered on keyboard pop?

Categories : Javascript

Datatables sort by time ago
Probably you are not getting the desired sorting because it is being ordered lexicographycally. You can take advantage of the HTML5 data attributes, like you do with the livestamp.js, to use the timestamp representation for sorting. Simply add the data-order attribute to every timestamp cell: <tbody> <tr> <td>ITEM 1</td> <td data-order="1416934028"

Categories : Javascript

Internet Explorer getClientRects absolute positioned elements
Looks like you just can't do it that way. If you instead tell everything to float and then position it with margin-top/left it will work. Here is the css for both spans span{ float: left; margin-bottom: -100%; margin-right: -100%; } Updated fiddle: http://jsfiddle.net/9gemwtc5/

Categories : Javascript

How can I transform a CamanJS Filter into a KineticJS Filter?
CamanJS and KineticJS filters are achieved very differently. KineticJS filters manipulate pixel data in a single pass. CamanJS uses subsystems that change the image incrementally (subsystems==this.brightness, this.exposure, etc). Therefore, there is no simple way to convert a CamanJS filter into a KineticJS filter To do it you would have to refactor and embed many CamanJS subsystems into Ki

Categories : Javascript

AngularJS : index not updating after removing array item(s) by index
The myIndex property gets set by the initialization of the repeat and it isn't updated appropriately. Instead you could just work with $index. This will update appropriately when the array changes and delete the correct elements. <tr ng-repeat="i in items"> <td>{{$index}}</td> <td>{{i.Id}}</td> <td>{{i.Name}}</td> <td>{{i.Type}}<

Categories : Javascript

Slick slideshow in ember.js template
A few things: Component names must have two words, as explained in the docs. You'll want to use this.$() in your component, so that you're referencing the component's own DOM element. A div is the default tag for a component, so you don't need the tagName property It's usually best to not override the default method of a component (e.g. didInsertElement), but instead invoke a method once the

Categories : Javascript

Recursive function with defer
try something like this: function lastSyncFunc(tx,service,index, def){ var deferred = def || $q.defer(); tx.executeSql( "SELECT time FROM last_sync WHERE fService = ? ORDER BY id DESC LIMIT 1", [service[index]], function (tx, result) { if (result.rows.length > 0) { lastSync[service[index]] = result.rows.item(0).fTime; } return ++index<s

Categories : Javascript

Unable to find module mongodb in simple node.js app
The original install installed the db itself on your machine. The npm install installs the package node.js needs to communicate with mongodb. NPM is like NuGet for .NET. You have a database, but still have to install the package for the framework to communicate to the database itself Here is a sample on how to use mongodb module to connect to a mongo instance in node.js var MongoClient = require

Categories : Javascript

Why does function return false after checking only one value in loop
Even though you have the check inside the for-loop, the code inside the for-loop runs only once because now that you've added an else, it will ALWAYS return something. The correct way to return false if nothing was found, would be to add the return false after the for-loop finishes. for(var i = 0;i < anArray.length;i++) { if(num[i] == n) { return true; } } return fa

Categories : Javascript

Detect if the mouse is over an element
If I understand your question correctly: if($("#main-nav").is(":hover")) { //do something }else{ //something different } In pseudo code: if the cursor is over #main-nav do something if it's not do something else If you want test to always be set: var test = false; $("#main-nav").on("mouseenter", function(e){ e.preventDefault(); test = true; }).on("mouseleave", functi

Categories : Javascript

Placing and rotating svg elements along a path with Snap.svg
If you use Snaps getPointAtLength() method (docs) you will find included in the return object is 'alpha'. Alpha varies as the path does, so you can just set your element to rotate at the value of the returned alpha (you may need to offset it by 90 degrees or something). So in totally untested code it would look something like... myPoint = myShape.getPointAtLength( lengthSoFarInPath ) myShape

Categories : Javascript

YouTube Asynchronous function
I think the problem is that you are returning returnArray when it might not be handled yet. To clarify what I mean, Even though you have return returnArray at the end, the actual request is still be handled, but the code keeps going anyway. So when it finally gets a response, and handles the code, it writes it correctly to the log, but the function has already returned returnArray earlier. With

Categories : Javascript

Cordova App: Stop JavaScript from running when App is closed
The pause and resume events should do what you want. Have you tried using them? For example: document.addEventListener("pause", function() { myBuzzSound.fadeOut(); }); and on resume... document.addEventListener("resume", function() { myBuzzSound.fadeIn(); });

Categories : Javascript

how to define a variable in an javascript ifstatement
Correct usage: var x; // we define the variable x global outside the functions function apply() { if (x == 1) { // you need to check with ==, with = you are just setting its value alert("show") document.getElementById("nav").style.display = "inline"; x = 2 // change the varibale to 2 } else { alert("hide") document.getElementById("nav").style.displ

Categories : Javascript

display dd on click using jquery
<dl class="dl-horizontal"> <span class='test'> <dt>Tabs 01</dt> <dd style="display:block;"> <p>Content that is shown when tab 01 clicked</p> </dd> </span> <span class='test'> <dt>tab 02</dt> <dd style="display:none;"> <p>Content that is shown when tab 02 clicked</p> <

Categories : Javascript

jQuery Timer Countdown within Session
You can set the until time in a cookie and set the until option in the countdown to that value. Then it will be persisted across requests with a consistent final value. There is a jQuery Cookie library that can be helpful for you there: https://github.com/carhartl/jquery-cookie You can also set the cookie expiration to expire at the same time so that it automatically gets deleted at the correct

Categories : Javascript

setInterval on click event to run for 10 seconds
Maybe clear the interval each time the element is clicked before setting it ? Something like this : var safariClearFixTimer; var timer; jQuery('.pager .pages li, .pager .pages li a').click(function(){ clearInterval( safariClearFixTimer ); clearTimeout( timer ); safariClearFixTimer = setInterval(safariClearFix ,100); timer = setTimeout(function( ) { clearInterval( safariClearFixTim

Categories : Javascript

Are syntax errors raised in JavaScript during Tokenizing or Parsing?
Are syntax errors raised in JavaScript during Tokenizing or Parsing? The tokenizer is a part of the parser, so the answer is yes. And are ReferenceErrors thrown during Code generation? Some ReferenceErrors are thrown before code is evaluated (if that is what you mean by "code generation"). The ES5 spec is quite clear about that: An implementation must report most errors at the time

Categories : Javascript

Can i perform form based http authentication for my TP-Link Wireless Router(IP: 192.168.0.1)
xmlhttp.open() is not going to be the tool to do this to access any Router. Essentially you are trying to do some Web Scraping through a secure website. If you are trying to do all Web based coding then PHP may be the easiest for this. Check out cURL: http://scraping.pro/scraping-in-php-with-curl/ This will allow you to have a PHP page to do all of the admin bypassing and fetch the HTML of t

Categories : Javascript

Blocked frame in reCapcha
If you're using an iframe, this part: Blocked a frame with origin [url here] from accessing a frame with origin [other url here]. Means it's not going to work. Frames can't interfere with each other, or else people would be able to pilfer your data from one frame in the other one. Check out the same origin policy for more details. You might be able to simplify things for yourself by getting

Categories : Javascript

Updated property not recognized by $watch
instead of $scope.$watch, use $scope.$watchCollection in case of watching array changes. If you use $watch, there is a third parameter which specifies whether to watch for changes in value or reference. Array.splice only changes the array contents, not reference, so simple watch won't fire. For details on $watch and $watchCollection, refer the correpsonding sections in this page- https://docs.ang

Categories : Javascript

Template Missing error on update only
Your answer is here: def update # TODO: need uniqueness test for updated Metas if current_user.try(:admin?) @meta_category.update(meta_category_params) flash[:notice]='Meta category has been updated.' respond_to do |format| format.json { render json: @meta_category, :status => 400 } format.js end else MetaCategoryProposedChange.cre

Categories : Javascript

nodejs object declaration and immediate shorthand if statement crashes the app
Problem is here: (!_.isNull(foo.bar)?foo.bar = true:""); That statement makes no sense, and I don't think you can assign a property inside the inline if statement. I also don't know why you're trying to overwrite 123 with true. Be that as it may, what you seem to be trying to do should be accomplishable by this: foo.bar = (!_.isNull(foo.bar) ? true : "");

Categories : Javascript

Hide / show dynamically generated table columns with right / left animation
How about this ? http://jsfiddle.net/cdcjy1mg/2/ $(".ctable > * > * > :nth-child(" + index + ")").toggle("slow"); You can put the animation you want. Take a look at jquery effect. Hope this help.

Categories : Javascript

Convert UTC Date to Local Date in JavaScript
You should use var local = utc.toLocaleString(); More information at https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleString

Categories : Javascript

Position DOM elements without CSS
Short answer: no. There has surely been implementations of style-related properties (presentational attributes) in browsers before CSS, but not in terms of positioning. Furthermore, going back that far would also mean going back to the time where there was no standardized DOM to use for setting properties in that sense. Even if contemporary browsers have legacy support for presentational propert

Categories : Javascript

modifying mergesort to count inversions in JavaScript
Optimization tends to be ugly. :-) The main performance problem that I see is that there is a lot of creating data that gets discarded as garbage. To solve that what you can do is have an input array and an output array. You pass into your merge function the two arrays, and the indices of where the two chunks are to merge. Return the number of inversions. At each level of the merge sort, the

Categories : Javascript

Issue calling JS function twice
On the plugin support page, the author says the following: Hi, all you need is add two , and make sure you set different id, and you can create the countdown via javascript. He gives this example: <div id="first_countdown" /> <div id="second_countdown" /> <script> jQuery("#first_countdown").......... jQuery("#second_countdown").......... </script>

Categories : Javascript

getting an element by the type and then disable
querySelectorAll returns a nodelist of matching elements; my guess is that you'll have to loop through that array and disable each element individually: var inputs = document.getElementById("wrapper").querySelectorAll('input[type="text"]'); [].forEach.call(inputs, function(input){ input.disabled = true; }); Also note the double quotes in the selector query. input[type=text] != input[type="t

Categories : Javascript

Adobe edge: Use global javascript variable to control active content
This issue has been solved. It wasn't actually a coding issue as I originally thought. The problem was that my trigger that changed the variable was the last action on the timeline. so for some reason when I hit the play button it was looping the timeline back to the beginning. I solved it by labeling the end of my content. Just another unusual quark of Adobe Edge, but this is the price of working

Categories : Javascript

Convert a for loop to Q promise
It should look something like this: function query(queryString, keywords) { var promiseArr = []; for (var i = 0; i < keywords.length; i++) { var deferred = $q.defer(); promiseArr.push(deferred.promise); connection.query(queryString + '"' + keywords[i] + '"', function (def) { return function (err, rows) { if (err) {

Categories : Javascript

apply javascript function on a form generated by typo3
You can define your own HTML template for the login form. Assuming you use the login form that comes with TYPO3 and you are using TYPO3 6.2, you can do it this way: Copy the file typo3/sysext/felogin/template.html to some other place. Don't modify it directly, it would be overwritten by updates. Edit the copied file to your needs. Configure the login form to use the copied template. You can do t

Categories : Javascript

Underscore replace new line characters with line break
Since you are instantiating a new RegExp object from a string pattern, you have to escape d: new RegExp('\d', 'g') Doing new RegExp('d', 'g') is the same as /d/g.

Categories : Javascript

Inner ng-repeat inside ng-repeat
Since milestone is already iterating over order.milestones in the top loop, simply do: ng-repeat="milestone in order.milestones" ng-repeat="milestoneTemplate in milestone.milestoneTemplate"

Categories : Javascript

D3 Area-Chart energy example
There are at least 3 issues here: You need to convert the time strings (eg 4:15) to javascript Date objects when you parse the csv. +d.close is insufficient; use d3.time.format('%H:%M').parse() method for that. For the svg.append("path") bit, calling .data(data) on it ends up just assigning the first element of data to the path, instead of the entire array. That's just the way d3 selections wor

Categories : Javascript

Pass a list of named functions into function in coffeescript
CoffeeScript doesn't really support named functions like that, see: How do I create a named function expressions in CoffeeScript? Function declaration in CoffeeScript That specific example doesn't need them anyway, it looks like they're just there for documentation purposes so you could write: check = -> @evaluate(-> document.querySelectorAll('ul.your-list li').length > 2) and_the

Categories : Javascript

Get session value with jQuery
You are trying to return a value from an asynchronous operation (i.e. that completes later). That will never work as it returns long before the result is available. You need to use callbacks or promises instead. Using a callback the code looks like: function GetSession(callback) { $.get("sessionAPI.php?action=get", function(data) { callback(data); }); } and use like this: GetSession(funct

Categories : Javascript


Recently Add
How to get selected text with JavaScript?
Non Modal Alert Messages in java script, activated by a button
How to Count [Combined] line length of multiple files?
Is there any javascript event fired when the on-screen keyboard on mobile safari or chrome opens?
Datatables sort by time ago
Internet Explorer getClientRects absolute positioned elements
How can I transform a CamanJS Filter into a KineticJS Filter?
AngularJS : index not updating after removing array item(s) by index
Slick slideshow in ember.js template
Recursive function with defer
Unable to find module mongodb in simple node.js app
Why does function return false after checking only one value in loop
Detect if the mouse is over an element
Placing and rotating svg elements along a path with Snap.svg
YouTube Asynchronous function
Cordova App: Stop JavaScript from running when App is closed
how to define a variable in an javascript ifstatement
display dd on click using jquery
jQuery Timer Countdown within Session
setInterval on click event to run for 10 seconds
Are syntax errors raised in JavaScript during Tokenizing or Parsing?
Can i perform form based http authentication for my TP-Link Wireless Router(IP: 192.168.0.1)
Blocked frame in reCapcha
Updated property not recognized by $watch
Template Missing error on update only
nodejs object declaration and immediate shorthand if statement crashes the app
Hide / show dynamically generated table columns with right / left animation
Convert UTC Date to Local Date in JavaScript
Position DOM elements without CSS
modifying mergesort to count inversions in JavaScript
© Copyright 2017 spot7.org Publishing Limited. All rights reserved.