├── Each lesson Codes ├── Practice ├── #11 Asyc │ ├── input.txt │ └── app.js ├── #10 File Read and Write │ ├── sample.txt │ └── app.js ├── #3 dirname.js ├── #2 callfunction.js ├── #1 code of the play list.js ├── #8 setInterval.js ├── #4 event.js ├── #7 num 3.js ├── #5 getmodule.js ├── #6 moduleexp.js └── #9 util.js ├── public └── assets │ ├── logo.png │ ├── todo-list.js │ └── styles.css ├── README.md ├── .gitattributes └── .gitignore /Each lesson Codes: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Practice/#11 Asyc/input.txt: -------------------------------------------------------------------------------- 1 | This is file to read Synchonusly. -------------------------------------------------------------------------------- /Practice/#10 File Read and Write/sample.txt: -------------------------------------------------------------------------------- 1 | Here goes the content of your file. -------------------------------------------------------------------------------- /public/assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rj3rj20/https-github.com-iamshaunjp-node-js-playlist/HEAD/public/assets/logo.png -------------------------------------------------------------------------------- /Practice/#3 dirname.js: -------------------------------------------------------------------------------- 1 | // node can also determine the your directory by using '__dirname'; 2 | 3 | console.log(__dirname); 4 | console.log(__filename); 5 | -------------------------------------------------------------------------------- /Practice/#2 callfunction.js: -------------------------------------------------------------------------------- 1 | function callFunction(fun){ 2 | fun(); 3 | } 4 | 5 | var tata = function(){ 6 | console.log('bye'); 7 | } 8 | 9 | callFunction(tata); -------------------------------------------------------------------------------- /Practice/#1 code of the play list.js: -------------------------------------------------------------------------------- 1 | console.log("Hello Saif, You are learning Node.js!"); 2 | 3 | setTimeout(function(){ 4 | console.log("Three seconds \n have passed!"); 5 | 6 | },3000); -------------------------------------------------------------------------------- /Practice/#8 setInterval.js: -------------------------------------------------------------------------------- 1 | var time = 0; 2 | var timer = setInterval(function(){ 3 | console.log(time+ ' seconds have passed'); 4 | time += 2; 5 | if(time > 8){ 6 | clearInterval(timer); 7 | } 8 | },2000); -------------------------------------------------------------------------------- /Practice/#4 event.js: -------------------------------------------------------------------------------- 1 | var events = require('events'); 2 | 3 | var myEmmitter = new events.EventEmitter(); 4 | 5 | myEmmitter.on('anEvent',function(msg){ 6 | console.log(msg); 7 | }); 8 | 9 | myEmmitter.emit('anEvent','The event is absolutely emmited'); -------------------------------------------------------------------------------- /Practice/#11 Asyc/app.js: -------------------------------------------------------------------------------- 1 | var fs = require('fs'); 2 | 3 | var file = fs.readFile('input.txt','utf8',function(err,data){ 4 | fs.writeFile('writeme.txt',data); 5 | console.log(data); 6 | }); 7 | 8 | console.log('This is an instruction outside the sync file system.'); -------------------------------------------------------------------------------- /Practice/#7 num 3.js: -------------------------------------------------------------------------------- 1 | 2 | // General Method for writing a function! 3 | function write(){ 4 | console.log('Woah! I just Invoked a function'); 5 | } 6 | write(); 7 | 8 | // Writing a funcion expression 9 | 10 | var sayBye = function(){ 11 | console.log('I just called a funcion expression,!'); 12 | } 13 | 14 | sayBye(); -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # node-js-playlist 2 | CSS and asset files for the Net Ninja YouTube nodejs playlist 3 | 4 | The final project code can be found in the public/assests folder of this repo 5 | 6 | If you have been following the tutorial, code for each and every lesson is added in the Practice folder so you can directly download and check. 7 | All files have been tested. 8 | 9 | If more files for .\Practice\ should be added. They will be added very soon. 10 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /Practice/#5 getmodule.js: -------------------------------------------------------------------------------- 1 | // This is the module getting function. it gets its module from moduleexp.js 2 | 3 | var stuff = require('./moduleexp.js');// | ./ | is used to search in present directory. 4 | 5 | 6 | // look here at the counter part, it is actually taking the arguments. and doing everything. 7 | // We need to intialise the 'counter variable first.' 8 | console.log(stuff.counter(['Hello','This is','Saif'])); 9 | console.log(stuff.adder(5,6)); 10 | console.log(stuff.bi); 11 | console.log(stuff.adder(stuff.bi,44)); -------------------------------------------------------------------------------- /Practice/#6 moduleexp.js: -------------------------------------------------------------------------------- 1 | 2 | // This file is completely a module for getmodule.js file. 3 | 4 | 5 | // a function expression is made here. 6 | var counter = function(arry){ 7 | return 'The number of '+arry.length + '\n done!'; 8 | }; 9 | // Adding more modules 10 | var adder = function(a,b){ 11 | return 'On adding the two number it gives'+(a+b); 12 | } 13 | 14 | var pi = 3.1535; 15 | 16 | // module.exports is the important part, it makes the counter available for other modules! 17 | module.exports.counter = counter ; 18 | module.exports.adder = adder; 19 | module.exports.bi = pi; -------------------------------------------------------------------------------- /Practice/#10 File Read and Write/app.js: -------------------------------------------------------------------------------- 1 | //Generally the module name and the variable name both are same 2 | var fs = require('fs'); 3 | 4 | // fs.readFileSync 5 | // Sync' part allows the node to read the file synchronusly meaning all file is read first before going through other code. 6 | var sample = fs.readFileSync('sample.txt','utf8'); 7 | // utf8 is encoding format| you can find clean explanation here at http://stackoverflow.com/a/15128103/5388823 8 | console.log(sample); 9 | 10 | // this line of code creates an another file output.txt and writes the data in sample into the log. 11 | fs.writeFileSync('output.txt',sample); 12 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Windows image file caches 2 | Thumbs.db 3 | ehthumbs.db 4 | 5 | # Folder config file 6 | Desktop.ini 7 | 8 | # Recycle Bin used on file shares 9 | $RECYCLE.BIN/ 10 | 11 | # Windows Installer files 12 | *.cab 13 | *.msi 14 | *.msm 15 | *.msp 16 | 17 | # Windows shortcuts 18 | *.lnk 19 | 20 | # ========================= 21 | # Operating System Files 22 | # ========================= 23 | 24 | # OSX 25 | # ========================= 26 | 27 | .DS_Store 28 | .AppleDouble 29 | .LSOverride 30 | 31 | # Thumbnails 32 | ._* 33 | 34 | # Files that might appear in the root of a volume 35 | .DocumentRevisions-V100 36 | .fseventsd 37 | .Spotlight-V100 38 | .TemporaryItems 39 | .Trashes 40 | .VolumeIcon.icns 41 | 42 | # Directories potentially created on remote AFP share 43 | .AppleDB 44 | .AppleDesktop 45 | Network Trash Folder 46 | Temporary Items 47 | .apdisk 48 | -------------------------------------------------------------------------------- /public/assets/todo-list.js: -------------------------------------------------------------------------------- 1 | $(document).ready(function(){ 2 | 3 | $('form').on('submit', function(){ 4 | 5 | var item = $('form input'); 6 | var todo = {item: item.val()}; 7 | 8 | $.ajax({ 9 | type: 'POST', 10 | url: '/todo', 11 | data: todo, 12 | success: function(data){ 13 | //do something with the data via front-end framework 14 | location.reload(); 15 | } 16 | }); 17 | 18 | return false; 19 | 20 | }); 21 | 22 | $('li').on('click', function(){ 23 | var item = $(this).text().replace(/ /g, "-"); 24 | $.ajax({ 25 | type: 'DELETE', 26 | url: '/todo/' + item, 27 | success: function(data){ 28 | //do something with the data via front-end framework 29 | location.reload(); 30 | } 31 | }); 32 | }); 33 | 34 | }); 35 | -------------------------------------------------------------------------------- /Practice/#9 util.js: -------------------------------------------------------------------------------- 1 | // Adding the required Modules 2 | 3 | var events = require('events'); 4 | var util = require('util'); 5 | // creating a function Person 6 | 7 | var Person = function(name){ 8 | // this allows, the function with any object created(james,saif,sampath) to utilise this function 9 | this.name = name; 10 | } 11 | 12 | // From the module util, we are inheriting the from events.EventEmitter 13 | util.inherits(Person,events.EventEmitter); 14 | //randomly 3 objects storing in 3 variables 15 | var james = new Person('james'); 16 | var saif = new Person('saif'); 17 | var sampath = new Person('sampath'); 18 | 19 | var People = [james,saif,sampath]; 20 | 21 | People.forEach(function(Person){ 22 | Person.on('speak',function(msg){ 23 | console.log(Person.name + 'said this ' + msg ); 24 | }); 25 | }); 26 | 27 | james.emit('speak','This is james'); 28 | saif.emit('speak','OH great nice to meet you Mer. '); 29 | sampath.emit('speak','Thats cool'); -------------------------------------------------------------------------------- /public/assets/styles.css: -------------------------------------------------------------------------------- 1 | body{ 2 | background: #0d1521; 3 | font-family: tahoma; 4 | color: #989898; 5 | } 6 | 7 | #todo-table{ 8 | position: relative; 9 | width: 95%; 10 | background: #090d13; 11 | margin: 0 auto; 12 | padding: 20px; 13 | box-sizing: border-box; 14 | } 15 | 16 | #todo-table form:after{ 17 | margin: 0; 18 | content: ''; 19 | display: block; 20 | clear: both; 21 | } 22 | 23 | input[type="text"]{ 24 | width: 70%; 25 | padding: 20px; 26 | background:#181c22; 27 | border: 0; 28 | float: left; 29 | font-size: 20px; 30 | color: #989898; 31 | } 32 | 33 | button{ 34 | padding: 20px; 35 | width: 30%; 36 | float: left; 37 | background: #23282e; 38 | border: 0; 39 | box-sizing: border-box; 40 | color: #fff; 41 | cursor: pointer; 42 | font-size: 20px; 43 | } 44 | 45 | ul{ 46 | list-style-type: none; 47 | padding: 0; 48 | margin: 0; 49 | } 50 | 51 | li{ 52 | width: 100%; 53 | padding: 20px; 54 | box-sizing: border-box; 55 | font-family: arial; 56 | font-size: 20px; 57 | cursor: pointer; 58 | letter-spacing: 1px; 59 | } 60 | 61 | li:hover{ 62 | text-decoration: line-through; 63 | background: rgba(0,0,0,0.2); 64 | } 65 | 66 | h1{ 67 | background: url(/logo.png) no-repeat center; 68 | margin-bottom: 0; 69 | text-indent: -10000px; 70 | } 71 | --------------------------------------------------------------------------------