Showing posts with label Javascript. Show all posts
Showing posts with label Javascript. Show all posts

Monday 7 September 2015

Express.js Running Application

There is a tutorial for installing new running Express js application!

Installing Node.js:
1- Go to this link "https://nodejs.org/" and install node.js.
2- Go to Shell and intall express generator using "npm install express-generator -g"

For New Express Application:
1- Make a directory i.e., D:\nodePractice.
2- Go to this directory and from shell "npm install express". It will create a folder in this directory called 

"node-modules".
3- Go to "node-modules" and from shell make "package.json" file using "npm init"!
While creating this file it is gonna ask for some things like appname, description, test-command etc. Enter the desired text there!
3- Go to "node-modules" directory and from shell install express application using "express" command.
4- Add This code to your app.js file created in "node-modules" directory:

var server = app.listen(3000, function() {
var host = server.address().address;
var port = server.address().port;
console.log('Example app listening at http://%s:%s', host, port);
});

5- Run app.js file!
6- intall missing modules using 'npm intall <module-name>' e.g, "npm install serve-favicon"
7- Run app.js again! Bang there you are...

Friday 8 August 2014

Print and Preview specific Div with Javascript

Spouse we have a DIV that we want to print and its ID is 'printPDF'

 <div id="printPDF"> This area will be print</div>
var style_sheet = 'baseUrl . "/css/style.css"; ?>'; //Css file,Base url
var style_sheet = '';// Style sheet that you want to include


 var printContent = document.getElementById('printPDF').innerHTML;
        var printContent2 = "" + style_sheet + "" + printContent + "";
        var windowUrl = 'about:blank';
        var uniqueName = new Date();
        var windowName = 'Print' + uniqueName.getTime();
        var printWindow = window.open(windowUrl, windowName, 'left=50000,top=50000,width=0,height=0');
        printWindow.document.write(printContent2);
        printWindow.document.close();
        printWindow.focus();
        printWindow.print();
        printWindow.close();