mardi 31 mars 2015

HTML5/Javascript - Is it possible to get the absolute coordinates of a touch event on a Macbook Trackpad in the browser?

I would like to write something in the browser which records gestures on the trackpad.


Since I wanted to be able to track all motion without having to worry about the pointer leaving the window, I first researched this problem and used the MDN Pointer Lock API demo as a starting point.


But I notice when using this demo on a MacBook that if I lift my finger and start a new drag elsewhere on the trackpad, it ignores the distance my finger traveled in the air, it only counts the motion done while my finger is touching the trackpad. This is consistent with the way that the trackpad is used to move the mouse pointer in the operating system in general.


But for my specific application, I want to have the absolute x and y of my finger on the trackpad. Would it be possible to build a variant of the demo linked above where the red dot corresponds to the absolute position of your finger? e.g., if you lifted your finger and then put it down in the upper left, the red dot would always jump to the upper left of the canvas?


I'm aware of the javascript Touch Events API, which gives absolute coordinates when used on a tablet, but the demo does not register any trackpad input when run on the MacBook under Firefox (v36) or Chrome (v41).


I have also read that it's possible to enable touch emulation in Chrome, though I could not find the checkbox to do that under my version (perhaps only special developer builds have this) and from reading about it, it seems like it's more of a mouse-to-touch translation so I'm doubtful that that emulation would have specific support for trackpads.


Is there any way that getting the absolute x,y coordinates of a touch event on a MacBook trackpad is possible via HTML/Javascript?


Usage of Pause and Play buttons in html5


<table>
<tr>
<td><div id="a">&#65;</div></td>
<td><div class="n">&#78;</div></td>
<td><div id="t">&#84;</div></td>
</tr>
</table>

/*script*/
function animateat() {
document.getElementById('audioTag1').play();
document.getElementById('audioTag1').play();
$("#a").animate(
{ "top": "300px", "color": "white" },
2000, function () {
$("#t").animate({ "top": "300px", "color": "white"
},
2000,function () {
$("#t").animate(
{ "left": "760px" },1000);
}
);
}
/*html*/
<body onload="animatepaapa();">
<audio id="audioTag1" src="paara.wav" preload="auto">
<code>audio</code>


I am developing a scene using HTML5, CSS and JS as shown above, in which I want to use the play, pause and as well as the replay button.


If there is a way please suggest me.


how to create hyperlinks() in a paragraph of string, using Thymeleaf

I have a paragraph of string, which contains URL words as well, Like :



"Hello world, http://thymeleaf.org and https://google.com welcomes you."



while generating PDF, those 2 URL words should come as hyperlinks and rest of text should be plain.


please do the needful, thanks.


How do I change the opacity of an image when I hover of my text?

Hey I'm new here and I really need some help! I have my own website, please don't judge I am new to HTML and CSS.. The problem is that I don't know how to change the opacity when I hover over my text.. I want it to become lighter if I'm hovering over my text in the menu on the right. Does anyone know how I can do this? Right now It's only changing when I hover over the image itself, the text changes too, but I want it to both change at the same time and on the same object, so I hover over the text; text changes and images opacity changes. Please help me out! Luca


http://ift.tt/1aelVNP


using html5 websockets to bypass firewall TCP policy

I've read that html5 enables opening tcp sockets from the client side in its "websocket" feature.


Firewalls as I recollect may be configured to block tcp connections initiated from "the outside" by looking for SYN packets, but utilizing this html5 feature enables a simplistic bypass to this policy.


Am I missing something here? Who will monitor those implicit open socket calls? It appears that this behavior is a "reverse tcp shell" served for free...


html5 app file read and writing using java script

new to app developing , developing an app in html 5 using visual studio, apatche cardova plugin , i want to to read and write a text file using java script , it should save in the mobile now my question is how to write it ? and where to save it exactly ? I am confused of giving the path where to save it and from where to read it.


Thanks inadvance


Problems With Vector Reflection with Particle Collisions

I was wondering whether I made a math mistake in my particle collision simulation found here. The particles don't seem to separate properly during collision resolution. Here is a code snippet from the function which separates particles and changes their velocities:



//particle 1
var pi = particles[i];
//particle 2
var pj = particles[j];

//particle 1 to particle 2
var pimpj = pi.mesh.position.clone().sub(pj.mesh.position);
//particle 2 to particle 1
var pjmpi = pj.mesh.position.clone().sub(pi.mesh.position);
//if colliding (radius is 20)
if(pimpj.length() < 20 && pimpj.length() != 0)
{


//reflect velocity off of 1->2
pi.velocity = pi.velocity.reflect(pimpj.clone().normalize()).multiplyScalar(restitution);
//reflect velocity off of 2->1
pj.velocity = pj.velocity.reflect(pjmpi.clone().normalize()).multiplyScalar(restitution);

//move particle 1 to appropiate location based off of distance in between
var pip = pi.velocity.clone().normalize().multiplyScalar(20-pimpj.length());
//move particle 2
var pjp = pj.velocity.clone().normalize().multiplyScalar(20-pimpj.length());
pi.mesh.position.add(pip);
pj.mesh.position.add(pjp);
}


I have tried reversing pimpj with pjmpi while changing pi.velocity, but to no effect. note: I am using three.js


How to use color of my choice for each bar in a bar chart using chartjs?

I want the bars in this graph to have different colors, but of my choice. Here is my code. Please Help.



var ctx = $("#myBarChart").get(0).getContext("2d");
var data = {
labels: ["a","b","c","d","e","f","g"],
datasets: [
{
label: "My First dataset",
/*fillColor: "rgba(84,255,159,1)",
highlightFill: "rgba(84,255,159,0.75)",*/
data: [5,3, 4, 2, 1, 3, 1]
},
]
};



var myBarChart = new Chart(ctx).Bar(data);
var width = $('canvas').parent().width();
$('canvas').attr("width",width);
new Chart(ctx).Bar(data);

Does canvas support floating point numbers when drawing line or arc?

In the canvas element, are floating point numbers actually treated as floats by the lineTo and arc methods?


For example:



context.moveTo(20.4562, 80.8923);
context.lineTo(120.1123, 90.2134);
context.arc(24.5113, 36.7989, 20.123, 0, Math.PI*2);


Does canvas really support float number coordinates, or it just converting the float numbers to integers when drawing line, arc, rect, etc.?


HTML/Canvas Recording not working on Firefox 36.0.4

I'm getting the following error when I'm running the RecordRTC Canvas/HTML Recorder demo ==> http://ift.tt/1EACRKR


On Firefox Error Console:


Error: TypeError: document.getElementById(...) is null Source File: chrome:// web-developer /content/overlay/javascript/overlay.js Line: 7333


Error: Index or size is negative or greater than the allowed amount Source File: https:// cdn.webrtc-experiment.com / screenshot.js Line: 10


After recording I'm getting a note on the player saying "Videos can't played because the file is corrupt"


Can someone please help me how to fix the firefox issue? Thanks in advance.


Screenshot for "Videos can't played because the file is corrupt" on firefox


How can I make multiple checkbox values persist using angularJS local storage?

I'm currently designing a PhoneGap app with HTML5 and angularJS. The application needs to act like an attendance register, where multiple checkbox values need to persist - corresponding to current attendance of each client. I am very unfamiliar with this and can't seem to set up and use localStorage to do this!


Twitter Typeahead doesn't work with input created dynamically

I'm using Twitter Typeahead to provide autocompletion for my text input.


When I create an input dynamically, .typeahead() doesn't display the hint UI unless it is called after the input control is attached to DOM.


This works:



var input1 = $('<input type="text" />');
$("#dynamic-container1").append(input1); /* (A) */
input1.typeahead(null, make_dataset()); /* (B) */
input1.focus();


This doesn't:



var input2 = $('<input type="text" />');
input2.typeahead(null, make_dataset()); /* (B) */
$("#dynamic-container2").append(input2); /* (A) */
input2.focus();


(Note order of lines marked (A) and (B).)


Why does it happen? Is there a correct way to initialize Typeahead before its input is appended to the DOM?


Here is a fiddle: http://ift.tt/1xOYfKg


JavaScript-Dot navigation

How can i code the javascript or jqueary so that when i click on a dot the dot gets an active class but the previous dots class is removed


Html-



<div class="dotnav">
<div class="dot active" title="Sign Up">

</div>
<div class="dot" title="hello" >

</div>
<div class="dot" title="hello" >

</div>
<div class="dot" title="hello" >

</div>
<div class="dot" title="hello" >

</div>
<div class="dot" title="helloup" >

</div>
</div>
Css-.dotnav{
left: 40px;
position: absolute;
top: 50%;
z-index: 9999;
display: block;
/*-webkit-transform: translateY(-50%);
-moz-transform: translateY(-50%);
-ms-transform: translateY(-50%);
-o-transform: translateY(-50%);
transform: translateY(-50);*/
}

.dot{
width:16px;
height: 16px;
border-radius:100%;
border:2px solid #CCCCCC;
display: block;
margin-top: 10px;
cursor: pointer;
vertical-align; baseline;
}
.dot:hover{
border: 2px solid #999999;
background-color: #C9931E;
}
.active{background-color: #C9931E;}


if you could help me code this that would be awesome


How can i code the javascript or jqueary so that when i click on a dot the dot gets an active class but the previous dots class is removed


Splitting chrome browser on different screen

Not sure where to start with this one. Basically I need to find a way to show the browser content on several screens so that the browser content is shown as a video wall. So if I have 16 screens (in a 4 by 4 matrix setup), I need the browser screen to show full screen on all the screens.


I know I could do this with some sort of video wall processor and a pc. What I want to know is if this would be possible to do say with 16 pcs each connected to a screen where each pc shows a section of the browser.


Different hover effects [html/css]

I have a menu with a hover effect on all listed links/ items. I want to put a Home icon (the house), whose hover effect to be switching between 2 identical images with different color, OK I got this, but the main hover effect still applies to it as background.


For example, when I move the mouse over any of the links the hover effect is orange background around the text, and I want to remove that effect from the Home icon only( there's already switching between white house and orange house on mouse over).


I've tried so many things and still nothing successful...


Thank you in advance!


Picture of what I'm talking about


HTML code:



<div class="Menu">

<div class="ner">
<ul>

<li class="home">
<a href="#" ><img onmouseout="this.src='home1.png'" onmouseover="this.src='home2.png'" src="home1.png" width=25px; height=25px;></a></li>


<li><a href="#">Item1</a></li>
<li class="drop">
<a href="#">Item2</a>

<div class="dropdownContain">
<div class="dropOut">
<div class="triangle"></div>
<ul>
<li>Blog 1</li>
<li>Blog 2</li>
<li>Blog 3</li>
<li>Blog Blog 4</li>
</ul>
</div>
</div>

</li>
<li><a href="#">Item3</a></li>


<li class="drop">
<a href="#">Item4</a>

<div class="dropdownContain">
<div class="dropOut">
<div class="triangle"></div>
<ul>
<li>Blog 1</li>
<li>Blog 2</li>
<li>Blog Blog 3</li>
<li>Blog Blog 4</li>
</ul>
</div>
</div>

</li>
<li><a href="#">Item5</a></li>
<li><a href="#">Item6</a></li>


</ul>
</div>
</div>


CSS code:



.Menu {
background: #44474B;
display: block;
position: fixed;
width:900px;
right: 0;
top: 0;
height: 55px;
min-width: 100%;
z-index: 9999;
}

.Menu ul{ float:left;}

.Menu li{position:relative; z-index:10; float:left; list-style:none; margin:0 15px; }

.Menu a{ padding:11px 18px; color:#373737; list-style:none; color:#FFF; text-decoration:none;
-webkit-transition: all .3s linear 0s;
-moz-transition: all .3s linear 0s;
-ms-transition: all .3s linear 0s;
-o-transition: all .3s linear 0s;
transition: all .3s linear 0s;}

.Menu ul li a:hover{ border-radius:6px;
background: #ffa84c; /* Old browsers */
/* IE9 SVG, needs conditional override of 'filter' to 'none' */
background: -moz-linear-gradient(top, #ffa84c 0%, #ff7b0d 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ffa84c), color-stop(100%,#ff7b0d)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #ffa84c 0%,#ff7b0d 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #ffa84c 0%,#ff7b0d 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #ffa84c 0%,#ff7b0d 100%); /* IE10+ */
background: linear-gradient(to bottom, #ffa84c 0%,#ff7b0d 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffa84c', endColorstr='#ff7b0d',GradientType=0 ); /* IE6-8 */

}

.Menu .home a:hover {
background-color: green; !important
text-decoration:none; !important
}

.ner{width:900px; margin:0 auto; padding-top:0; padding-left:0;}


The green background color is for testing purposes only.


How to simulate HTML5 Drag and Drop in Selenium Webdriver in Python

I am using Python 2.7 and Selenium 2.44. I want to automate drag and drop action in Selenium WD but according to other related posts Actions in HTML5 are not supported by Selenium yet. Is there any way to simulate drag and drop in Python? Here is the code I tried:



driver = webdriver.Firefox()
driver.get("http://ift.tt/OZSRfY")
target = driver.find_element_by_id("one")
source = driver.find_element_by_id("bin")
actionChains = ActionChains(driver)
actionChains.drag_and_drop(target, source).perform()


and it did not work.


Working with search suggestion

I have the following search suggestion script, where as a user types dynamically the result is updated. What I would want is that when a user click on one of the suggestion it takes them to the `following:searchPage.php?user_query=what the user has typed in the input


Below is the script



$(function(){
$(".search").keyup(function()
{
var searchid = $(this).val();
var dataString = 'search='+ searchid;
if(searchid!='')
{
$.ajax({
type: "POST",
url: "search.php",
data: dataString,
cache: false,
success: function(html)
{
$("#result").html(html).show();
}
});
}return false;
});

jQuery("#result").live("click",function(e){
var $clicked = $(e.target);
var $name = $clicked.find('.name').html();
var decoded = $("<div/>").html($name).text();
$('#searchid').val(decoded);
});
jQuery(document).live("click", function(e) {
var $clicked = $(e.target);
if (! $clicked.hasClass("search")){

window.open('searchPage.php?user_query=','_self',false);
}
});
$('#searchid').click(function(){
jQuery("#result").fadeIn();
});
});


At its current state it just open the window to searchPage.php but doesn;t take into account in the url what the user has entered; the desired result is searchPage.php?user_query=what ever you want


Importxml on attribute

I'm trying to scrape the following content attributes from this site using a googlesheet. Unfortunately every variation i can think of seems to fail



<span itemprop="aggregateRating" itemscope="" itemtype="http://ift.tt/GXOCyu">
<span itemprop="ratingValue" content="3.5"></span>
<span itemprop="ratingCount" content="12"></span>
<span itemprop="reviewCount" content="12"></span>
</span>


I'm looking to extract the values 3.5, 12 & 12 using



=importxml(A2,//*[@id='topOnProduct']/div[2]/span/span[1])
=importxml(A2,//*[@id='topOnProduct']/div[2]/span/span[1]@content)
=importxml(A2,"//span[@itemprop='ratingValue']/@content")


and about 50 other variations on the respective attributes - i'm also having no joy using kiimono. Can anyone advise me where i'm going wrong/show me how to achieve this


jquery panelslider disable the style of jcarousel slider

I am using jquery panelslider which appears the sidebrs in my page. on click of left sidebar i have used jcarousel verticle slider from here: http://ift.tt/1ae4JrJ


verticle slider appear inside the left sidebar (on click of left sidebar).


so the problem i face is that when i click on left sidebar, jcarousel verticle slider disable its default css.


How can i run both the scripts together? please help!!


Why code from CodePen doesn;t work?

I dont know why, but code from codepen doesn't work :/. Here are my files: Download from dropbox


How to markup data cell that also functions as row header in html5

I'm trying to create a semantically correct and accessible (WCAG 2.0) html5 data table. The first column contains data which also functions as a header for the row.


In html 4.01 / xhtml 1.0 I used to markup these cells as td with a scope attribute:



<td scope="row">


In html5 the scope attribute is no longer allowed on the td element. What would be the best approach for semantics and accessibility?



  1. markup the cells in the first column as th (the data aspect is lost?)

  2. markup the cells in the first column as td and loose the header aspect


I'm afraid that in the second scenario the table will be less accessible.


This situation got me thinking about data tables in general: in which situation would you use ONLY column headers? Because the nature of a data table implies a relationship between the data in the cells in a row. For accessibility, shouldn't the rows always get a header as well, to convey that relationship?


For example this table:



Principle | Corresponding guidelines
------------------------------------------------------------------------
Never leave a child unattended | 1, 3, 8
Always communicate what you are going to do | 4, 5, 6
Calm down before you take action | 5,9,13


Would you consider the cells in the first column (the principles) to be headers for the second column, or data cells? In other words: in what way would you markup this table?


How to set the selections points of an object created using fabric js on canvas?

I have a canvas on which I am loading a svg image using the function fabric.loadSVGFromURL()


Then I am iterating through each object and adding that to the canvas. Here is my code :



/* Begin - Load Card from the SVG Image */
loadCardFromSVG = function loadCardFromSVG()
{
fabric.loadSVGFromURL('history/card_front.svg', function(objects, options)
{
addObjectsToCanvas(canvasFront, objects);`//call the function for adding objects to canvas`
});
}

/* End - Load Card from the SVG Image */

/* Begin - Add objects loaded from SVG to the canvas */
addObjectsToCanvas = function addObjectsToCanvas(cavasId, objects)
{
objects.forEach(function(obj)
{
obj.set(
{
borderColor: 'red',
cornerColor: 'green',
cornerSize: 6,
transparentCorners: false
});
obj.selectable = true;
cavasId.add(obj);

cavasId.setActiveObject(obj);
cavasId.renderAll();
});
}
/* End - Add objects loaded from SVG to the canvas */


All works fine using these functions. But the only problem is that the selection points of each object are being show far away from the selected object. I am not able to restore the selection points around the selected object.


identify an object on canvas by a click event

into this simple code I use an eventListener which doesnt look to work at all. The canvas display an image and the given hitpaint function is supposed determines whether a click occurs. I cant understand why the eventListener behaves like that. Any insight would be helpful.



mycanv.addEventListener("click", function(e){
var output = document.getElementByID("output");
ctx.fillStyle = 'blue';
//ctx.clearRect(0,0,100,20);
if (hitpaint){
//ctx.fillText("hit",100,20);
output.innerHTML = "hit";
}
else
//ctx.fillText("miss",100,20);
output.innerHTML = "miss";

}, false);


the hitpaint looks like that:



function hitpaint(mouse_event) {

var bounding_box=mycanv.getBoundingClientRect();


var mousex=(mouse_event.clientX-bounding_box.left) *
(mycanv.width/bounding_box.width);
var mousey=(mouse_event.clientY-bounding_box.top) *
(mycanv.height/bounding_box.height);
var pixels=ctx.getImageData(mousex,mousey,1,1);

for (var i=3; i<pixels.data.length; i+=4) {
// If we find a non-zero alpha we can just stop and return
// "true" - the click was on a part of the canvas that's
// got colour on it.
if ( pixels.data[i]!==0 ) return true;
}


// The function will only get here if none of the pixels matched in

return false;
}


Finally the main loop which display the picture in random location into the canvas:



function start(){

// main game function, called on page load
setInterval( function() {

ctx.clearRect(cat_x, cat_y, 100, 100);
cat_x = Math.random() * mycanv.width-20;
cat_y = Math.random() * mycanv.height-20;
draw_katy(cat_x,cat_y);

}, 1000);
}

crosswalk-project android full screen

In my html5 game, I have a login field and therefore when the user enter the text fields(username and password), the android keyboard pop up along with the onscreen soft keys(where back button and menu button is present).


While building my app with crosswalk, I set the display to fullscreen in the manifest and it is working fine except for this login screen bringing back the soft buttons. I have no knowledge of native android coding and is wondering if the buttons can be hidden again through API calls from the javascript.


The scaling of the html is done through meta viewport in the html and the game behaves like that of a browser.



var scale = screen.availWidth/1024;
var vp = document.querySelector("meta[name='viewport']");
vp.setAttribute("content","width=device-width, user-scalable=no, initial-scale="+scale);


I did tried my canvas to request full screen and it works but the size of the canvas is not taking the whole screen and it looks bad again.


Any suggestions on how I should proceed or which article I should be reading or direct solution?


Also, if you need any more information or code, let me know. Thanks!


Lasso tool in html5 canvas

I'm trying to build a freeform lasso tool to clip an image inside canvas. I'm using fabric.js to draw the shape. This is my attempt, many thanks to who can take some time for suggestions :)



<script src="http://ift.tt/1tznvBx" ></script>
<script src="http://ift.tt/k72nu2"></script>

<canvas id="c" width="500" height="500"></canvas>


<script>
var canvas = document.getElementById('c');
var ctx = canvas.getContext('2d');

var img = document.createElement('IMG');

img.onload = function () {

var OwnCanv = new fabric.Canvas('c', {
isDrawingMode: true
});

OwnCanv.freeDrawingBrush.color = "purple"
OwnCanv.freeDrawingBrush.width = 4


ctx.clip();

ctx.drawImage(img, 0, 0);
}

img.src = "http://ift.tt/1EY2Kze";
</script>

Cross platform desktop development with HTML5 GUI

Short story: is there a way to write a desktop application with a GUI in HTML5 and core in a cross-platform language like python (or even C#/Mono)?


Longer story: I'm a C# developer, for small personal projects I seldom do, running both under Windows and OSX, I use C# (Mono) with a frontend leveraging on Eto.Forms


I'd like to understand if there's a mature way to achieve the same results using an HTML5 GUI, since I'd like to learn that and believe it could be a good option for near-future Windows desktop UIs (or otherwise a nice tool to have in my skillset). Of course if the code running behind the scenes is C# I'll be more than happy, but also getting my feet wet in another, maybe more cross-platform like python would be good.


At this stage I'm not interested in any mobile-oriented solution.


Object[key] returns undefined (strange)

I've had a weird behaviour from an object.



var canvas = document.createElement('canvas');
canvas.style.display = 'none';
document.body.appendChild(canvas);

var ctx = canvas.getContext('2d');
//imgObj is an Image Object
ctx.drawImage(imgObj, 0, 0);

//inserting(caching) the image data in the spriteData object
var spriteCoordinates = coordinates.spriteCoordinates;
//coordinates.spriteCoordinates has keys in integer

for(var i in spriteCoordinates){
var x = spriteCoordinates[i].x,
y = spriteCoordinates[i].y,
w = spriteCoordinates[i].w,
h = spriteCoordinates[i].h;

var imageData = ctx.getImageData(x, y, w, h);

spriteData[i] = imageData;
}


When I console.log spriteData, I get:



Object { }


enter image description here


When I click on it, I get:



0: {
width: int,
height: int,
data: array()
}// I've put int and array just for representation


enter image description here


But when I console.log spriteData[0] (spriteData['0']), I get undefined. And I've even tried to console.log Object.keys(spriteData), but I get an empty array.


Can someone tell me please what's going on?


AngularJs audio

How do i acknowledge when an audio ends in angular js? i have attached my code. Anyone plz help me??



app.controller("myCtrl",function($scope,ngAudio,$document)
{
$scope.src="aud.mp3";
$scope.play=false;
$scope.play=function()
{
$scope.audio = ngAudio.load('aud.mp3');
$scope.audio.play();
}
$scope.stop=function()
{
$scope.audio = ngAudio.load('aud.mp3');
$scope.audio.pause();
}
$document[0].addEventListener("visibilitychange", function() {
var doucmentHidden = document.hidden;
if (doucmentHidden)
$scope.audio.pause();
else
$scope.audio.play();
}, false);
});

jQuery undefined error HTML5 video tag addEventListener

I have following jquery code



video1=$("#P div video"); alert(video1);
video1.addEventListener('ended',videoEnded,false);


and getting following error


TypeError: video1 is undefined


HTML is



<div style="position: relative; z-index: 0;" id="P">
<div style="position:absolute;left:0px;top:0px;z-index:0;">
<video autoplay="" preload="auto">
<source type="video/mp4" src="img/f.mp4"></source>
<source type="video/ogg" src="img/f2.ogv"></source>
</video>
</div>
</div>

Canvas transform on cloth simulation + image

I'm using the verlet.js plugin in order create a cloth simulation on canvas with a texture image.


The only thing (and the most important BTW) part that I haven't arrived is that I need skew the drawImage in order to make it fit the correct position.


jsfiddle with the progress



//Drawing the rectangle
ctx.save();
ctx.beginPath();

ctx.moveTo(cloth.particles[i1].pos.x, cloth.particles[i1].pos.y);
ctx.lineTo(cloth.particles[i1+1].pos.x, cloth.particles[i1+1].pos.y);
ctx.lineTo(cloth.particles[i2].pos.x, cloth.particles[i2].pos.y);
ctx.lineTo(cloth.particles[i2-1].pos.x, cloth.particles[i2-1].pos.y);
ctx.lineTo(cloth.particles[i1].pos.x, cloth.particles[i1].pos.y);

ctx.strokeStyle = "#fff";
ctx.stroke();
ctx.restore();

//Wrapping the image
ctx.save();
var off = cloth.particles[i2].pos.x - cloth.particles[i1].pos.x;

//THIS IS WHAT I TRY TO SOLVE TO FIT TO THE RECTANGLES
//ctx.transform(1,0.5,0,1,0,0);
ctx.drawImage(img, cloth.particles[i1].pos.x,cloth.particles[i1].pos.y, off, off, cloth.particles[i1].pos.x,cloth.particles[i1].pos.y, off ,off);
ctx.restore();
}


I have tried to adapt other cloth simulations but without success. Any clue where I could find some info to accomplish that?


HTML5 Drag and Drop : display droppable elements in separate div (Java Script and Knockout JS)

I am beginner in Knockout and java script. I have a problem in my project. I am using HTML5 Drag and Drop API using Knockout javascript. Now I need to show all drop items in separate div. I have some code which is display the name of droppable Items. But I want display file not file name. Below is my sample demo. Please do needful. I am okay with either knockout or pure java script. enter image description here


VIEW FIDDLE HERE





function ViewModel(){
var self = this;
this.dropZones = ko.observableArray([{
'elements' : ko.observableArray([]) // just to see that the output is correct
}]);

this.dragover = function(e){
console.log('dragOver');
e.stopPropagation();
e.preventDefault();
}

this.drop = function(e, data){
console.log('drop');
e.stopPropagation();
e.preventDefault();
var files = e.dataTransfer.files;
for (var i = 0, f; f = files[i]; i++) {
data.elements.push(f.name);
}
$('.drop_zone').css('background-color', '#ffffff');
}

this.dragenter = function(e, index){
console.log('dragEnter');
$('.drop_zone').eq(index).css('background-color', '#00ff00');
}

this.dragleave = function(e, index){
console.log('end');
$('.drop_zone').eq(index).css('background-color', '#ffffff');
}
}

ko.applyBindings(new ViewModel());



.drop_zone {
border: 2px dashed #bbb;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
padding: 25px;
text-align: center;
font: 20pt bold'Vollkorn';
color: #bbb;
}



<script src="http://ift.tt/1sl7oHg"></script>
<div class="col-md-12" data-bind="foreach: dropZones">
<div class="drop_zone" data-bind="event:{
dragover: function(data, e){ $root.dragover(e);},
drop: function(data, e){ $root.drop(e, $data);},
dragenter: function(data, e){ $root.dragenter(e, $index());},
dragleave: function(data, e){ $root.dragleave(e, $index());}
}">Drop files here</div>
<ul data-bind="foreach: elements" style="height: 100px">
<li data-bind="text: $data"></li>
</ul>
</div>



How to use HTML5 inputs in Rails 3.2.12

is it possible to use HTML5 input type date for a Ruby and Rails 3.2.12 form?


When its possible how can I use it?


Thanks


footer with absolute position - responsive design

i have a little problem with my responsive design. I am using a normal with this css.



footer {
width: 100%;
height: 20px;
position: absolute;
bottom: 5px;
left: 0;
}


It works perfekt. When i am using a smaller screen i have to scroll. Thats normal.


The problem is, that the is not at the bottom. It is in the middle of the screen. Like margin-top:100% of the full screen, without scrolling.


I hope you understand what i mean :)


Thanks!


Twitter Typeahead doesn't work with input created dynamically

I'm using Twitter Typeahead to provide autocompletion for my text input.


When I create an input dynamically, .typeahead() doesn't display the hint UI unless it is called after the input control is attached to DOM.


This works:



var input1 = $('<input type="text" />');
$("#dynamic-container1").append(input1); /* (A) */
input1.typeahead(null, make_dataset()); /* (B) */
input1.focus();


This doesn't:



var input2 = $('<input type="text" />');
input2.typeahead(null, make_dataset()); /* (B) */
$("#dynamic-container2").append(input2); /* (A) */
input2.focus();


(Note order of lines marked (A) and (B).)


Why does it happen? Is there a correct way to initialize Typeahead before its input is appended to the DOM?


Here is a fiddle: http://ift.tt/1xOYfKg


IOS Safari 8.1.3 WebAudio API doesn't stop in sleep mode

In HTML5 for IOS 8.1.3 Safari browser. I'm using a background music that continuously play in loop using AudioContext. On top of that, some voice over audio comes randomly for which I've used normal audio object (var _audio = new Audio()).


Everything working absolutely perfect as required. Now when I'm pressing the home button, the voice over stops immediately but the background music keeps on playing. Also if I resume the safari, voice over resumes playing from where it had stopped.


Couple of solutions came to my mind are:




  1. Don't use loop property for the context. On ended callback re-play the context. But this not possible in my situation.




  2. Use "pagehide" and "pageshow" event to know the browser going to or coming back from sleep. This is working for me but not on all devices. I'm checking this in multiple iPads and all of them are IOS 8. But strangely in some iPads the events are not getting trigger at all.




So I'm stuck here. Any suggestion would be appreciated. Thanks.


Multiple HTML5 Video Tags on 1 page

I have a web page where the top of the page is a fullscreen div with a background of a video. I also have, further down the page another video (for testing purposes the same video).


I have an interesting scenario to figure out...



  • Video 1 (at the top of the page) works perfectly on Firefox, Safari, Chrome, IE

  • Video 2 (half way down the page) works great on Firefox, Safari and IE. NOT Chrome


Due to the nature of my job I have to ensure that the websites I develop are browser safe. Does anyone know why 1 video would be working in Chrome but the other won't?


AT TOP OF PAGE



<video id="video" poster="img/poster.png" loop muted class="video-js vjs-default-skin" preload="none" width="100%" height="100%" data-setup="{}">
<source src='img/video.mp4' type="video/mp4"/>
</video>


HALF WAY DOWN PAGE



<video id="s-video" poster="img/poster.png" loop muted class="bg_video video-js vjs-default-skin" preload="none" width="100%" height="100%" data-setup="{}">
<source src="img/video.mp4" type="video/mp4" />
</video>


I also have this bit of DOM Javascript at the bottom of my page



<script>
document.getElementById('video').play();
document.getElementById('s-video').play();
</script>

how to add only volume controls on HTML5 video tag

I want to use HTML5 video tag, but in this case i want only volume controls... please help me



<video controls id="myMovie" width="600" height="600" loop preload="auto" >
<source src="any file.mp4" type='video/mp4' />

<source src="any file.mp4" type='video/mp4' />
Your browser does not support the video tag.
</video>

disable all value of a multiple select when one is selected, then set a null value to the following field

I have a dynamic form using Ajax and javascript on my Symfony project.


I have a multiple select. I would like in this multiple select when I choose the value 7 which is "outside", all other value of this multiple select are disabled and unselectabled.


Here's the code for the scripts:



function checkOption(obj) {
var select = document.getElementById("mySpace_databasebundle_zonestechnique_batiments");
select.disabled = obj.value == "7";
}


And this is the code for the twig view. Just know that I'am using a collection, i-e a formType in my Symfony project for make this form:



<div>
{{ form_label(form.categorieszonestechnique, "Categorie(s) de la zone technique:", {'label_attr': {'class': 'control-label'}}) }}
{{ form_errors(form.categorieszonestechnique) }}
{{ form_widget(form.categorieszonestechnique, {'attr': {'class': 'selectpicker categories', 'onChange': 'checkOption(this)'}}) }}
</div>

<div>
{{ form_label(form.batiments, "Appartenant au bâtiment:", {'label_attr': {'class': 'control-label'}}) }}
{{ form_errors(form.batiments) }}
{{ form_widget(form.batiments, {'attr': {'class': 'form-control', 'option selected': '--choose abâtiment--'}}) }}
</div>


So when I selected the option 7, i-e "outside", I would like to disable all other value of the multiple select (selectpicker) and make them unselectabled. Then make a default value (null value) to the following field for the select tag of "batiments".


The id for the multiple select (selectpicker) is mySpace_databasebundle_zonestechnique_categorieszonestechnique and the id for the select tag of batiments is mySpace_databasebundle_zonestechnique_batiments. So, the javascript code works like with basic html for creating events, but I didn't find yet the solution to create these events.


Thank you in advance.


HTML5 markup for a slideshow

I have a slideshow on my home page. The slideshow have no content, only background images.


The question: Should I mark it up as a section or anything else? Maybe skip the HTML5 markup?



<header></header>

<div id=slideshow></div>

<main></main>

<aside></aside>

<footer></footer>

how to make html code responsive

Hi i want to make html code responsive. This is my code but it is not responsive how should i do it. i heard something about media query. how one can use it for my code. in my code only inline css is there. how is it possible for me to make my code responsive.





<div class="row_inner_wrapper clearfix" style="background-color: #777777;background-position: left top;background-repeat: no-repeat; margin-top: 3%;">


<div style = "width: 60%; height:50%; font-weight: bold; font-size: 20px; float: left; background-color: #777777;">
<div style = "width: 28%; float: left;">
<img src= "C://wamp//www//rushi.jpg"; alt="" style ="max-width: 100%; height: auto; width: 100%; margin-left:10%"></div>

<div style = "width: 72%; float: left";>
<div style="font-weight: bold; font-family: Patua One,Arial,Tahoma,sans-serif; text-align: center;"><strong>abc </strong></div>
<div style = "text-align: center;"> </div>

<div style = "width: 30%; float: left; margin-left: 5%">
<span style="font-weight: bold;"><strong>abc</strong></span><br/>
<span> Bathroom </span></div>

<div style = "width: 30%; float: left;">
<span style="font-weight: bold;"><strong>abc </strong></span><br/>
<span>abc</span></div>

<div style = "width: 30%; float: left;">
<span style="font-wight: bold;"><strong>abc</strong></span><br/>
<span>abc </span></div>


</div>



</div>


<div style = "width: 40%; float:left; font-weight: bold; font-size: 20px; ">
<div style = "width: 100%; float: left;">
<span></span><br/>
<span style="font-family: bold;"><strong>abc</strong></span>
</div>



</div>
</div>



Server Side Events(SSE) in Google App Engine

Does GAE support Server Side Events (SSE)?


I tried using SSE but it did not work , so I switched to Channel API. But still is it possible to implement SSE in GAE ?


lundi 30 mars 2015

Inset border-radius for an image

I want to create an inset border radius for an image using CSS if possible, I am posting this question because all of the solutions I found online so far were for text and using divs.


Here is what I wish to achieve:


enter image description here


Thanks!


"Flip Card" CSS Animation no working in IE Edge

I have this animation working in Firefox, Chrome, and Safari. I want it to work in IE (IE11 and hopefully 10). Some of this code is IE/MS specific in an attempt to get this work, not all it may be supported by IE. It was an attempt. I would appreciate any pointers towards a solution. Even one that diverges from this or uses javascript (though hopefully doesn't require jquery).


http://ift.tt/1Dje7Fr



<style>
/*Animations*/
@-o-keyframes flipInnerContainer {
0%{
-o-transform: rotateY(0deg);
transform: rotateY(0deg);
}
50% {
-o-transform: rotateY(180deg);
transform: rotateY(180deg);
}
100% {
-o-transform: rotateY(180deg);
transform: rotateY(180deg);
}
}

@-ms-keyframes flipInnerContainer {
0%{
-ms-transform: perspective(1000px) rotateY(0deg);
transform: rotateY(0deg);
}
50% {
-ms-transform: perspective(1000px) rotateY(180deg);
transform: rotateY(180deg);
}
100% {
-ms-transform: perspective(1000px) rotateY(180deg);
transform: rotateY(180deg);
}
}

@-moz-keyframes flipInnerContainer {
0%{
-moz-transform: rotateY(0deg);
transform: rotateY(0deg);
}
50% {
-moz-transform: rotateY(180deg);
transform: rotateY(180deg);
}
100% {
-moz-transform: rotateY(180deg);
transform: rotateY(180deg);
}
}

@-webkit-keyframes flipInnerContainer {
0%{
-webkit-transform: rotateY(0deg);
transform: rotateY(0deg);
}
50% {
-webkit-transform: rotateY(180deg);
transform: rotateY(180deg);
}
100%{
-webkit-transform: rotateY(180deg);
transform: rotateY(180deg);
}
}

@keyframes flipInnerContainer {
0%{
transform: perspective(1000px) rotateY(0deg);
}
50% {
transform: perspective(1000px) rotateY(180deg);
}
100% {
transform: perspective(1000px) rotateY(180deg);
}
}



@-o-keyframes flipOuterContainer {
0%{
-o-transform: rotateY(0deg);
transform: rotateY(0deg);
}
25% {
-o-transform: rotateY(180deg);
transform: rotateY(180deg);
}
100% {
-o-transform: rotateY(180deg);
transform: rotateY(180deg);
}
}

@-ms-keyframes flipOuterContainer {
0%{
-ms-transform: perspective(1000px) rotateY(0deg);
transform: rotateY(0deg);
}
25% {
-ms-transform: perspective(1000px) rotateY(180deg);
transform: rotateY(180deg);
}
100% {
-ms-transform: perspective(1000px) rotateY(180deg);
transform: rotateY(180deg);
}
}



@-moz-keyframes flipOuterContainer {
0%{
-moz-transform: rotateY(0deg);
transform: rotateY(0deg);
}
25% {
-moz-transform: rotateY(180deg);
transform: rotateY(180deg);
}
100% {
-moz-transform: rotateY(180deg);
transform: rotateY(180deg);
}
}


@-webkit-keyframes flipOuterContainer {
0%{
-webkit-transform: rotateY(0deg);
transform: rotateY(0deg);
}
25% {
-webkit-transform: rotateY(180deg);
transform: rotateY(180deg);
}
100% {
-webkit-transform: rotateY(180deg);
transform: rotateY(180deg);
}

}

@keyframes flipOuterContainer {
0%{
transform: perspective(1000px) rotateY(0deg);
}
25% {
transform: perspective(1000px) rotateY(180deg);
}
100% {
transform: perspective(1000px) rotateY(180deg);
}
}

/* Safari was not keeping its end state so this fixes that and does not adversely effect
other webkit browsers */
@-webkit-keyframes disapear{

0% {
opacity: 1;
}
1% {
opacity: 0;
}
100% {
opacity: 0;
}
}
@-ms-keyframes disapear{

0% {
opacity: 1;
}
1% {
opacity: 0;
}
100% {
opacity: 0;
}
}
@-ms-keyframes appear{

0% {
opacity: 0;
}
1% {
opacity: 1;
}
100% {
opacity: 1;
}
}


/*all*/
.adbox {
margin: 20px;
background: #000000;
position: relative;
z-index: 1;
}

#bg-exit {
background-color: rgba(255,255,255,0);
cursor: pointer;
height: 100%;
left: 0px;
position: absolute;
top: 0px;
width: 100%;
}

.container {
-moz-perspective: 1000px;
-webkit-perspective: 1000px;
perspective: 1000px;
}
.container-one, .container-two, .container-three, .container-four,
.threehundred-one, .threehundred-two, .threehundred-three, .threehundred-four,
.seventwentyeight-one, .seventwentyeight-two, .seventwentyeight-three, .seventwentyeight-four{
position: absolute;
width: 100%;
height: 100%;
-moz-transform-style: preserve-3d;
-webkit-transform-style: preserve-3d;
-ms-transform-style: preserve-3d;
transform-style: preserve-3d;
}

.first {
position: absolute;
width: 100%;
height: 100%;
-moz-backface-visibility: hidden;
-webkit-backface-visibility: hidden;
-ms-backface-visibility: visible;
backface-visibility: hidden;
}

.first.firstonly{
-webkit-animation:
disapear .5s linear 10s 1 forwards;
}

.first.back {
position: absolute;

-o-transform: rotateY(180deg);
-ms-transform: perspective(1000px) rotateY(180deg);
-moz-transform: rotateY(180deg);
-webkit-transform: rotateY(180deg);
transform: rotateY(180deg);
box-sizing: border-box;
}
.back{
-ms-animation:
appear .5s linear 3.5s 1 forwards;
}

.third {
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
box-sizing: border-box;

-moz-backface-visibility: hidden;
-webkit-backface-visibility: hidden;
-ms-backface-visibility: hidden;
backface-visibility: hidden;

-o-transform: rotateY(180deg);
-ms-transform: perspective(1000px) rotateY(180deg);
-moz-transform: rotateY(180deg);
-webkit-transform: rotateY(180deg);
transform: rotateY(180deg);


}

.tile {
width: 100%;
height: 100%;
-moz-transform-style: preserve-3d;
-webkit-transform-style: preserve-3d;
-ms-transform-style: preserve-3d;
transform-style: preserve-3d;
}

.tile.one {
-moz-animation:
flipInnerContainer 2s linear 2s 1 forwards;

-o-animation:
flipInnerContainer 2s linear 2s 1 forwards;

-webkit-animation:
flipInnerContainer 2s linear 2s 1 forwards;

animation:
flipInnerContainer 2s linear 2s 1 forwards;
}
.tile.two {
-moz-animation:
flipInnerContainer 2s linear 4s 1 forwards;

-o-animation:
flipInnerContainer 2s linear 4s 1 forwards;

-webkit-animation:
flipInnerContainer 2s linear 4s 1 forwards;

animation:
flipInnerContainer 2s linear 4s 1 forwards;
}
.tile.three {
-moz-animation:
flipInnerContainer 2s linear 6s 1 forwards;

-o-animation:
flipInnerContainer 2s linear 6s 1 forwards;

-webkit-animation:
flipInnerContainer 2s linear 6s 1 forwards;

animation:
flipInnerContainer 2s linear 6s 1 forwards;
}
.tile.four {
-moz-animation:
flipInnerContainer 2s linear 8s 1 forwards;

-o-animation:
flipInnerContainer 2s linear 8s 1 forwards;

-webkit-animation:
flipInnerContainer 2s linear 8s 1 forwards;

animation:
flipInnerContainer 2s linear 8s 1 forwards;
}

/*160x600*/
.onesixty {
width: 160px;
height: 600px;
}

.onesixty .container {
width: 160px;
height: 150px;
}

.container-one {
-moz-animation:
flipOuterContainer 2s linear 11.25s 1 forwards;

-o-animation:
flipOuterContainer 2s linear 11.25s 1 forwards;

-webkit-animation:
flipOuterContainer 2s linear 11.25s 1 forwards;

animation:
flipOuterContainer 2s linear 11.25s 1 forwards;
}
.container-two {
-moz-animation:
flipOuterContainer 2s linear 11.75s 1 forwards;

-o-animation:
flipOuterContainer 2s linear 11.75s 1 forwards;

-webkit-animation:
flipOuterContainer 2s linear 11.75s 1 forwards;

animation:
flipOuterContainer 2s linear 11.75s 1 forwards;
}
.container-three {
-moz-animation:
flipOuterContainer 2s linear 11s 1 forwards;

-o-animation:
flipOuterContainer 2s linear 11s 1 forwards;

-webkit-animation:
flipOuterContainer 2s linear 11s 1 forwards;

animation:
flipOuterContainer 2s linear 11s 1 forwards;
}
.container-four {
-moz-animation:
flipOuterContainer 2s linear 11.5s 1 forwards;

-o-animation:
flipOuterContainer 2s linear 11.5s 1 forwards;

-webkit-animation:
flipOuterContainer 2s linear 11.5s 1 forwards;

animation:
flipOuterContainer 2s linear 11.5s 1 forwards;
}

</style>


<section class="onesixty adbox">
<div id="bg-exit">
</div>
<div class="container">
<div class="container-three">
<div class="tile three">
<div class="first firstonly">
<img src="http://ift.tt/1NC390W" height="150px" width="160px">
</div>
<div class="first back">
<img src="http://ift.tt/1Djea4b" height="150px" width="160px">
</div>
</div>
<div class="third">
<img src="http://ift.tt/1NC3als" height="150px" width="160px">
</div>
</div>
</div>
<div class="container">
<div class="container-one">
<div class="tile one">
<div class="first firstonly">
<img src="http://ift.tt/1Djea4d" height="150px" width="160px">
</div>
<div class="first back">
<img src="http://ift.tt/1NC3alu" height="150px" width="160px">
</div>
</div>
<div class="third">
<img src="http://ift.tt/1Djea4h" height="150px" width="160px">
</div>
</div>
</div>
<div class="container">
<div class="container-four">
<div class="tile four">
<div class="first firstonly">
<img src="http://ift.tt/1NC39ha" height="150px" width="160px">
</div>
<div class="first back">
<img src="http://ift.tt/1Dje7Fz" height="150px" width="160px">
</div>
</div>
<div class="third">
<img src="http://ift.tt/1NC39hc" height="150px" width="160px">
</div>
</div>
</div>
<div class="container">
<div class="container-two">
<div class="tile two">
<div class="first firstonly">
<img src="http://ift.tt/1Djeakz" height="150px" width="160px">
</div>
<div class="first back">
<img src="http://ift.tt/1NC3alw" height="150px" width="160px">
</div>
</div>
<div class="third">
<img src="http://ift.tt/1DjeakB" height="150px" width="160px">
</div>
</div>
</div>
</section>

Allow decimal point type="number" in html5

i am working on a phonegap application and i have field called 'Amount'. I have the type for this as number. but the problem is i cannot enter a decimal value.All it shows it the numbers but no decimal point.Is there a way to fix this.is there a way to show the decimal point in the nmber keyboard.


my code



<input type="number" step="any" placeholder="Amount" style="text-align:right" id="amount" name="amount" ng-model="data.amount" ng-maxlength= "10" class="form-control" decimal-places onkeypress='return event.charCode >= 48 && event.charCode <= 57 || event.charCode == 46' required>

HTML5 Validation error on Script?

I have strange error on my HTML5 validation



Error: Bad value text for attribute type on element script: Subtype missing.

From line 316, column 1; to line 316, column 40

e="1" />↩↩<script id="viewModel" type="text">↩ {

Syntax of MIME type:
A media-type as defined in RFC 2616; that is, typically, a required type, followed by a "/" character, followed by a required subtype, optionally followed by one or more instances of a ";" character followed by a parameter. Examples: text/css, text/css;charset=utf-8.


What i need to do to fix this error any idea?


How to configure simple web-socket server in c/c++ on windows?

Things to note :



  • I have client written in HTML5 and JavaScript. It works perfectly fine with server written in java.


  • I need to have server written in C or C++.




  • I have goggled and tracked down , libwebsocket is one way but it has GPL license, So not allowed to use for commercial purpose.




  • Even if for a moment I forget about licence, I may sound a newbie here, But all example which claim to work have unistd.h included and work on Linux. I want application very specifically on windows platform.




  • By looking at java code, I understood that, I need to process handshake before any communication through web socket. Except this it is a simple TCP socket ( Correct me if I am wrong ).But problem is, In handshake, Java code is using very inbuilt function for hash and encoding.




Now : Do we have any library or code example to process Handshake in C which is not GPL Licensed ? Any Help is appreciated :)


Error in JavaScript Console that namespace is not defined

The error says, "Uncaught ReferenceError: a2 is not defined," in Chrome's Javascript Console, and it is on this line of the HTML: a2.start($("#hook"),"clips.json");


I thought there was a problem with a missing or not enough braces in the JavaScript code, but apparently not. I checked other syntax, but don't know the cause of the error.


HTML:



<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<title>IIT News</title>
<script src="http://ift.tt/13wBVXk"></script>
<script src="a2.js"></script>
<!-- Bootstrap core CSS -->
<link href="css/bootstrap.css" rel="stylesheet">
<style>
.starter-template {
padding: 40px 15px;
text-align: center;
}
</style>
</head>

<body>

<div id="hook">
</div>
<script>

a2.start($("#hook"),"clips.json");

</script>
</div><!-- /.container -->
</body>
</html>


JavaScript:



(function (a2, $, undefined) { //namespace
a2.id = {};
a2.name = {};
a2.description = {};
a2['content-url'] = {};
a2['thumb-url'] = {};

// Entry point
a2.start = function(hookElementSelection, dataurlForJsonFile) {

a2.id = {};
a2.name = {};
a2.description = {};
a2['content-url'] = {};
a2['thumb-url'] = {};

'<source src="'+a2['content-url']+'" type="video/mp4"></source>'+
document.getElementById('hook').innerHTML = '<div id="container">'+
'<video onended="playNext()" id="aVideo" width="470" height="470" preload="none" controls autoplay>'+
'<source src="a2[content-url]" type="video/mp4"></source>'+
'<source src="video4.ogg" type="video/ogg"></source>'+
'<source src="video4.webm" type="video/webm"></source>'+
'</video>'+

'<div id="controls">'+
'<button id="play">Play</button>'+
'<button id="stop" disabled>Stop</button>'+
'<button id="pause" disabled>Pause</button>'+
'<div id="progressBar">'+
'<div id="progress"></div>'+
'</div> '+
'</div>';

vidCount = 0;
var aVideo = document.getElementById("aVideo");

// Make an ajax call and parse data
var parsedData;
var callback = function(text) {
parsedData = JSON.parse(text);
vidCount = 0;
playNext();
};

// When page is loaded, JSON data is parsed & returned
function loadedFunction() {
// returning JSON data
ajax.get("clips.json", callback);
};

function playNext() {
if (!parsedData) {
return
}
var aVideo = document.getElementById("aVideo");
aVideo.src = parsedData[vidCount]['content-url'];
aVideo.play();
vidCount++;
};
};

document.addEventListener("DOMLoaded", setControls, false);
function setControls() {
// Select video element from page
var aVideo = document.getElementById("aVideo");
if (aVideo.canPlayType) {
// Remove default buttons
aVideo.removeAttribute("controls");
// Display custom buttons & progress bar
document.getElementById("controls").style.display="block";
document.getElementById("progress").style.display="block";
// Add event handlers to control the video element
aVideo.addEventListener("timeupdate", getProgress, false);
aVideo.addEventListener("end", vidEnd, false);
// enable and disable the controls buttons to reflect the player state
aVideo.addEventListener("play",function() {
document.getElementById("play").disabled=true;
document.getElementById("pause").disabled=false;
document.getElementById("stop").disabled=false;
}, false);
aVideo.addEventListener("pause", function() {
document.getElementById("play").disabled=false;
document.getElementById("pause").disabled=true;
document.getElementById("stop").disabled=false;
}, false);
// add event-handlers for control buttons
document.getElementById("play").addEventListener("click",playPlayback,false);
document.getElementById("stop").addEventListener("click",stopPlayback,false);
document.getElementById("pause").addEventListener("click",pausePlayback,false);
}
}
// event-handlers

function playback() {
// Play button pressed
document.getElementById("aVideo").play();
}
// Pause button pressed
function pausePlayback() {
document.getElementById("aVideo").pause();
}
// Stop button pressed; current play time is reset to 0
function stopPlayback() { var aVideo = document.getElementById("aVideo");
aVideo.pause();
aVideo.currentTime=0;
vidEnd();
}
// Video is finished or stopped
function vidEnd() {
// Reset progress bar var progress = document.getElementById("");
progress.style.left="0px";
// reset the state of buttons
document.getElementById("play").disabled=false;
document.getElementById("pause").disabled=true;
document.getElementById("stop").disabled=true;
}
// Update the progress bar
function getProgress() {
var barwidth = 470; var sliderwidth = 30;
// Get current time
var time = Math.round(this.currentTime);
// Get video play time
var duration = parseInt(this.duration);
// Calculate the position on progress bar
var position = barwidth * (time / duration);
if (isNaN(position)) return;
// Update progress bar
document.getElementById("progress").style.width=position + "px";
// Update the position of slider button
var sliderButton = document.getElementById("sliderButton");
if (position <= (barwidth - Math.round(sliderwidth / 2))) {
sliderButton.style.left=position + "px";
} else {
sliderButton.style.left=barwidth - Math.round(sliderwidth / 2);
}
}

})(window.a2 = window.a2 || {}, jQuery) //namespace

How to reload google map in javascript?

I have to reload google map using javascript. I tried many way but thats not working. if anyone know Please assist me.


Creating Web Audio API Soundpoard vs HTML5 Audio Tag

I am new here, been getting answers to my questions here for some time, but this is the first time I have asked a question.


So I am working on a soundboard project and I thought it would be fairly easy. I started by programing the soundboard in HTML5 using the audio tags. This works fine on a PC (except the inability to play multiple instances of audio files); however, come to find out, there is a bug in iOS8 that affects playback of HTML5 audio tags when run as a standalone web app. The goal was to have this programed and run it from an iPad as a web app.


I have very little knowledge in the web audio api but thought I would give it a try. I looked around here and all over the web trying different tutorials. I followed the one over at http://ift.tt/1MrKE1U and felt like I was getting a basic understanding but could not get it to work at all.


So question time, what and I missing here? Or maybe is there a better alternative to get this to work as a web app? A sample of the working HTML5 code can be found at http://ift.tt/1Nxmazy


How to keep localstorage session specific?

So we have a web application that is accessed through a link from an email. When the user clicks on the link, we call a web service to pull the necessary data to the client. This data is then stored in the client's localstorage for the span of the user's session and cleared after.


The problem here is that if a user clicks on the link twice and logs out of one of the sessions, the local storage is cleared for both of the sessions.


So I've been thinking about solving this issue and here are my possible solutions:



  1. Reusing the same tab for the external links of the same domain. But its not possible as of now.

  2. Append the session Id to the keys of the localstorage and clear only them at logout. But in this case if someone does not logout properly, the local storage items will still persist and we don't want that.


So I'd like to know if there is any way to keep the local storage session specific or else if I should be skipping localstorage entirely. Thanks!


HTML and CSS Window Layout Design

I am facing a problem to design a window layout, here is my sample code and my problem is graphically represented thanks.


[N.B]: Window layout will be draggable and resizable, I will maintain this by using jquery later.


Problem enter image description here


SAMPLE CODE


HTML



<!DOCTYPE html>
<html>

<head>
<script data-require="jquery@2.1.3" data-semver="2.1.3" src="http://ift.tt/16ygW8q"></script>
<link data-require="bootstrap@*" data-semver="3.3.2" rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css" />
<link data-require="jqueryui@*" data-semver="1.10.0" rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.10.0/css/smoothness/jquery-ui-1.10.0.custom.min.css" />
<script data-require="jqueryui@*" data-semver="1.10.0" src="//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.10.0/jquery-ui.js"></script>
<script data-require="bootstrap@*" data-semver="3.3.2" src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="style.css" />
<script src="script.js"></script>
</head>

<body>
<h1>Hello Plunker!</h1>
<header>
<nav class="navbar navbar-inverse">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Brand</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li id="li-home" class="active">
<a href="#">Home <span class="sr-only">(current)</span>
</a>
</li>
<li id="li-contact">
<a href="#">Contact</a>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Dropdown <span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="#">Action</a>
</li>
<li>
<a href="#">Another action</a>
</li>
<li>
<a href="#">Something else here</a>
</li>
<li class="divider"></li>
<li>
<a href="#">Separated link</a>
</li>
<li class="divider"></li>
<li>
<a href="#">One more separated link</a>
</li>
</ul>
</li>
</ul>
<form class="navbar-form navbar-left" role="search">
<div class="form-group">
<input type="text" class="form-control" placeholder="Search" />
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>
<ul class="nav navbar-nav navbar-right">
<li>
<a href="#">Link</a>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Dropdown <span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="#">Action</a>
</li>
<li>
<a href="#">Another action</a>
</li>
<li>
<a href="#">Something else here</a>
</li>
<li class="divider"></li>
<li>
<a href="#">Separated link</a>
</li>
</ul>
</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container-fluid -->
</nav>
</header>
<div class="container-fluid main-container">
<div class="window">
<div class="window-header" data-dismiss="window-dblclick">
<div class="window-title-bar">
<i class="fa fa-cogs"></i>
<span class="window-title">window Title</span>
</div>
<div class="window-custom-title"></div>
<div class="window-actions">
<a href="#" class="window-action btn-min" data-dismiss="window-minimize" aria-hidden="true">
<span class="fa fa-minus" title="Minimize"></span>
</a>
<a href="#" class="window-action btn-max" data-dismiss="window-maximize" aria-hidden="true">
<span data-maximize="maximize" class="fa fa-square-o" title="Maximize"></span>
</a>
<a href="#" class="window-action btn-close" data-dismiss="window" aria-hidden="true">
<span class="fa fa-close" title="Close"></span>
</a>
</div>
</div>
<div class="window-body"></div>
<div class="window-footer">
<a>link</a>
</div>
<!-- <div class="resize-handle resize-n"></div>
<div class="resize-handle resize-e"></div>
<div class="resize-handle resize-s"></div>
<div class="resize-handle resize-w"></div>
<div class="resize-handle resize-se"></div>
<div class="resize-handle resize-sw"></div>
<div class="resize-handle resize-ne"></div>
<div class="resize-handle resize-nw"></div>-->
</div>
</div>
<footer>
<nav class="navbar navbar-inverse navbar-fixed-bottom">
<div class="container">
<div id="windowPane"></div>
</div>
</nav>
</footer>
</body>

</html>


CSS



html,
body {
height: 100%;
margin: 0px;
overflow: hidden;
}
.navbar {
margin-bottom: 0px;
}
.main-container {
background-color: #888888;
height: 100%;
position: relative;
}
.full-window {
width: 100% !important;
height: 100% !important;
left: 0 !important;
right: 0 !important;
top: 0 !important;
bottom: 0 !important;
min-width: 120px !important;
max-width: 100% !important;
margin: 0 auto !important;
position: absolute !important;
z-index: 1049;
}
.window {
position: absolute;
background-color: #1c1c1c;
border: 1px solid #999;
outline: 0;
width: 50%;
height: 50%;
left: 0;
right: 0;
top: 0;
bottom: 50px;
min-width: 240px;
max-width: 100%;
min-height: 320px;
margin: 0 auto;
resize: none;
}
.window.active > .window-header > .window-title {
color: #428bca;
}
.window > .window-header {
position: relative;
cursor: move;
padding: 5px;
padding-top: 0px;
border-bottom: 0px solid #e5e5e5;
display: table;
width: 100%;
background-color: #1c1c1c;
}
.window > .window-header > .window-title-bar {
margin: 0;
line-height: 1.428571429;
display: table-cell;
float: left !important;
color: #fff;
}
.window > .window-header > .window-title-bar > i {
color: #fff;
margin-right: 6px;
}
.window > .window-header > .window-custom-title {
display: table-cell;
}
.window > .window-header > .window-actions {
margin: 0;
line-height: 1.428571429;
display: table-cell;
float: right !important;
overflow: hidden;
}
.window > .window-header > .window-actions > .window-action {
display: inline-block;
text-decoration: none;
vertical-align: middle;
border-color: transparent;
cursor: pointer;
outline: 0;
}
.window > .window-header > .window-actions > .window-action.btn-min,
.window > .window-header > .window-actions > .window-action.btn-max {
background: #f0f9ff;
/* Old browsers */
background: -moz-linear-gradient(top, #f0f9ff 0%, #0c0a0a 47%, #f0f9ff 100%);
/* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #f0f9ff), color-stop(47%, #0c0a0a), color-stop(100%, #f0f9ff));
/* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #f0f9ff 0%, #0c0a0a 47%, #f0f9ff 100%);
/* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #f0f9ff 0%, #0c0a0a 47%, #f0f9ff 100%);
/* Opera 11.10+ */
background: -ms-linear-gradient(top, #f0f9ff 0%, #0c0a0a 47%, #f0f9ff 100%);
/* IE10+ */
background: linear-gradient(to bottom, #f0f9ff 0%, #0c0a0a 47%, #f0f9ff 100%);
/* W3C */
filter: progid: DXImageTransform.Microsoft.gradient(startColorstr='#f0f9ff', endColorstr='#f0f9ff', GradientType=0);
/* IE6-9 */
padding: 1px 6px;
border: 1px solid #ccc;
color: #fff;
margin-right: -5px;
}
.window > .window-header > .window-actions > .window-action.btn-min: hover, .window > .window-header > .window-actions > .window-action.btn-max: hover {
-webkit-box-shadow: inset 0px 0px 151px -50px #00cef2;
-moz-box-shadow: inset 0px 0px 151px -50px #00cef2;
box-shadow: inset 0px 0px 151px -50px #00cef2;
}
.window > .window-header > .window-actions > .window-action.btn-close {
background: #e78677;
/* Old browsers */
background: -moz-linear-gradient(top, #e78677 0%, #c44205 50%, #c01e03 51%, #e17225 100%);
/* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #e78677), color-stop(50%, #c44205), color-stop(51%, #c01e03), color-stop(100%, #e17225));
/* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #e78677 0%, #c44205 50%, #c01e03 51%, #e17225 100%);
/* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #e78677 0%, #c44205 50%, #c01e03 51%, #e17225 100%);
/* Opera 11.10+ */
background: -ms-linear-gradient(top, #e78677 0%, #c44205 50%, #c01e03 51%, #e17225 100%);
/* IE10+ */
background: linear-gradient(to bottom, #e78677 0%, #c44205 50%, #c01e03 51%, #e17225 100%);
/* W3C */
filter: progid: DXImageTransform.Microsoft.gradient(startColorstr='#e78677', endColorstr='#e17225', GradientType=0);
/* IE6-9 */
color: #fff;
padding: 1px 12px;
border: 1px solid #ccc;
}
.window > .window-header > .window-actions > .window-action.btn-close: hover {
-webkit-box-shadow: inset 0px 0px 151px -50px #fcffff;
-moz-box-shadow: inset 0px 0px 151px -50px #fcffff;
box-shadow: inset 0px 0px 151px -50px #fcffff;
}
.window > .window-body {
position: relative;
min-height: 100%;
overflow-x: hidden;
overflow-y: scroll;
position: relative;
border: 1px solid #ccc;
margin: 0 5px 0 5px;
background-color: #fff;
}
.window > .window-footer {
position: relative;
min-height: 16.428571429px;
background-color: #1c1c1c;
}
.window > .resize-handle {
position: absolute;
z-index: 1;
background-color: #fff;
font-size: 0;
line-height: 6px;
filter: alpha(opacity=0);
opacity: 0;
zoom: 1;
display: block;
}
.window > .resize-n {
top: -3px;
left: 0;
width: 100%;
height: 6px;
cursor: n-resize;
}
.window > .resize-e {
top: 0;
right: -3px;
width: 6px;
height: 100%;
cursor: e-resize;
}
.window > .resize-s {
bottom: -3px;
left: 0;
width: 100%;
height: 6px;
cursor: s-resize;
}
.window > .resize-w {
top: 0;
left: -3px;
width: 6px;
height: 100%;
cursor: w-resize;
}
.window > .resize-sw {
bottom: -3px;
left: -3px;
width: 6px;
height: 6px;
cursor: sw-resize;
}
.window > .resize-ne {
top: -3px;
right: -3px;
width: 6px;
height: 6px;
cursor: ne-resize;
}
.window > .resize-nw {
top: -3px;
left: -3px;
width: 6px;
height: 6px;
cursor: nw-resize;
}
.window.ns-resize {
cursor: ns-resize;
}
.window.ew-resize {
cursor: ew-resize;
}
.disable-shade {
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
background-color: rgba(255, 255, 255, 0.5);
display: none;
}
.disable-scroll {
overflow: hidden;
}
.disable-select {
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.window-pane {
z-index: 999;
}
.window-pane .label {
cursor: pointer;
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.window-pane .label .close {
float: none;
font-size: 14px;
margin-left: 4px;
}
.window-pane .label + .label {
margin-bottom: 0;
margin-left: 5px;
}
/*# sourceMappingURL=window.css.map */


PLUNKER