Image brightness detection in client side script

This function will convert each color to gray scale and return average of all pixels, so final value will be between 0 (darkest) and 255 (brightest) function getImageLightness(imageSrc,callback) { var img = document.createElement(“img”); img.src = imageSrc; = “none”; document.body.appendChild(img); var colorSum = 0; img.onload = function() { // create canvas var canvas = document.createElement(“canvas”); … Read more

Can you get a public Facebook page’s feed using Graph API without asking a user to allow?

If you’re anything like me your clients won’t want a standard Facebook likebox plugin, they’ll want it all styled and customised their own way. You don’t need to spend all day going round the official documentation wondering if any of it applies to you for something simple like this, it’s quite easy. The confusion arises … Read more

Pagination: Server Side or Client Side?

The right answer depends on your priorities and the size of the data set to be paginated. Server side pagination is best for: Large data set Faster initial page load Accessibility for those not running javascript Client side pagination is best for: Small data set Faster subsequent page loads So if you’re paginating for primarily … Read more

AngularJS: Understanding design pattern

Thanks to a huge amount of valuable sources I’ve got some general recommendations for implementing components in AngularJS apps: Controller Controller should be just an interlayer between model and view. Try to make it as thin as possible. It is highly recommended to avoid business logic in controller. It should be moved to model. Controller … Read more

Using local file for Web Audio API in Javascript

I had the same problem and I found this very simple solution. audio_file.onchange = function(){ var files = this.files; var file = URL.createObjectURL(files[0]); audio_player.src = file;; }; <input id=”audio_file” type=”file” accept=”audio/*” /> <audio id=”audio_player” /> You can test here:

Print directly from browser without print popup window [duplicate]

I couldn’t find solution for other browsers. When I posted this question, IE was on the higher priority and gladly I found one for it. If you have a solution for other browsers (firefox, safari, opera) please do share here. Thanks. VBSCRIPT is much more convenient than creating an ActiveX on VB6 or C#/VB.NET: <script … Read more