Wednesday, 29 July 2015

Taking photo with web camera without Flash

With HTML5, you can connect to the web cam and take photo without using Flash or any other third party component.

To connect to the web cam, you need to explore the following Javascript method:

  navigator.MediaDevices.getUserMedia()

For the detailed explanation, please refers to the following article.

    http://www.html5rocks.com/en/tutorials/getusermedia/intro/

and also refer to the up-to-date reference:

  https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia


I found this library and the sample web pages are working (able to take photo). But, yet to write some web page to do the job:

   https://github.com/jhuckaby/webcamjs


Printing without the URL at the page header

Below is the sample HTML which will hide the URL at the page header when printing with Javascript.


   <html moznomarginboxes >
   <head>
   <style type="text/css">

      @page{                size: auto;                margin: 3mm;           }

   </style>
   </head>
   <body>
         My page content goes here..
   </body>
   </html>


The simple way to print the current page is to call the following JavaScript method:

   window.print();

The Javascript library to print the specific element/container:

  https://github.com/jasonday/printThis


Wednesday, 22 July 2015

Adding public and private method/property




Here is how you returns a Person object to the caller:

function Person(name)
{
    // increase the head count (static property)
    this.constructor.headCount++;

    // private variable
    var _dob;
    var _name = name;

    //public functions
    this.helo = function () { return 'helo work..' };
    this.toString = function () { return _name };

    // public property
    this.money = 1000;
}

// public functions
Person.prototype.sayMyName = function () { return this.toString() };
Person.prototype.myBalance = function () { return this.money; };

// static property
Person.headCount = 0;

var p1 = new Person('mike');
var p2 = new Person('john');
var count = Person.headCount;    // the output is '2' because you called 'new' twice

For detail explanation, please refers to the following artcile:
http://phrogz.net/JS/classes/OOPinJS.html

We are moving

We are moving this blog to our new blog site: https://ciysys.com/blog/nodejs.htm