Skip to content

Instantly share code, notes, and snippets.

View devdays's full-sized avatar

Bruce D Kyle devdays

View GitHub Profile
@devdays
devdays / data-measure-for-web-socket.js
Last active August 29, 2015 14:10
Measure how much data is backed up in the outgoing buffer before calling send
if (websocket.bufferedAmount < bufferThreshold) {
websocket.send(message);
}
@devdays
devdays / display-text-websocket.js
Last active August 29, 2015 14:10
Display incoming text from web socket
function onMessage(evt) {
writeToScreen( evt.data );
}
@devdays
devdays / receive-multiple-data-types.js
Last active August 29, 2015 14:10
check your incoming data like this when receiving multiple data types
function onMessage(evt) {
if (evt.data instanceof Blob) {
// do something with evt.data
} else {
document.getElementById("textresponse").value = evt.data;
}
};
@devdays
devdays / close-websocket.js
Last active August 29, 2015 14:10
updated the web page after receiving the close event
function onClose(evt) {
writeToScreen("DISCONNECTED");
}
@devdays
devdays / html5-placeholder.html
Last active August 29, 2015 14:10
HTML5 Placeholder
<input type="email" id="orderEmail" name="myEmail" placeholder="email@contoso.com" required />
@devdays
devdays / html5-pattern.html
Created November 30, 2014 18:22
HTML5 Pattern
<label for="price">Price</label>
<input id="price" type="text" title="0.00" pattern="\d+(\.\d{2})?" />
@devdays
devdays / html5-range.html
Created November 30, 2014 18:24
HTML5 Forms Range
<input type="range" name="anumberbetween1and10" min="1" max="10" />
@devdays
devdays / html5-datalist.html
Created November 30, 2014 18:25
HTML5 DataList input
<input type= "text" list= "pacificstates" name= "State" id= "State" placeholder= "Pick a State" />
<datalist id= "pacificstates">
<select>
<option value= "California" />
<option value= "Oregon" />
<option value= "Washington" />
</select>
</datalist>
@devdays
devdays / html5-title.html
Created November 30, 2014 18:26
Using a title and label
<label for= "zip">ZIP Code: </label><input type= "text" id= "zip" title="Five- or nine-digit zip code"
pattern="^(\d{5}-\d{4}|\d{5}|\d{9})$" />
@devdays
devdays / html5-invalid-input.html
Created November 30, 2014 18:27
Invalid input HTML5, CSS3
<style>
input:required:invalid, input:focus:invalid
{
background-image: url(/images/invalid.png);
background-position: right top;
background-repeat: no-repeat;
}
</style>