Thursday 27 December 2018

Saturday 22 December 2018

JAVASCRIPT JSON

JAVASCRIPT JSON


  • JSON- JavaScript Object Notation
  • Which is  language independent.
  • Self-describing and easy to understand
  • Json is a format for storing and transporting data.
  • Which is often used when data is sent from a server to a web page.
  • json file type is - .json 
  • json mime type is -  application/json
  • Exchanging data
               -Sending data
               -Receiving data

               -Storing data
      


Syntax of JSON

  •   Name/value pairs
               "name":"value"
  •   Every data will separate by commas
                "name1":"value1"  ,  "name2":"value2" , "name3":"value3"
  •   Objects for curly bracket
               {"name1":"value1"  ,  "name2":"value2" , "name3":"value3" }
  •   Arrays for square bracket

               ["value1" , "value2" , "value3"]



    Different between syntax of javascript and JSON

    In javascript -  name: "value" / name: 'value'

    In JSON  -  "name": "value" / "name": 'value'


    JSON object

    object syntax -  {"name1":"value1"  ,  "age1": 11 };

    accessing object value

    eg1-

    var obj = {"name1":"value1"  ,  "age1": 11 };
    var out = obj.name1;
    document.getElementById().innerHTML=out;

    eg2-

    var obj = {"name1":"value1"  ,  "age1": 11 };
    var out = obj["name1"];
    document.getElementById().innerHTML=out;

    Saturday 8 December 2018

    JAVASCRIPT

    Image result for javascript logo



      JavaScript is one of the 3 languages all web developers must learn:
       1. HTML to define the content of web pages
       2. CSS to specify the layout of web pages
       3. JavaScript to program the behavior of web pages


    JavaScript is a lightweight, interpreted programming language. It is designed for creating network-centric applications. It is complimentary to and integrated with Java. JavaScript is very easy to implement because it is integrated with HTML. It is open and cross-platform.


    What is JavaScript doing on your page?

    Here we'll start actually looking at some code, and while doing so explore what actually happens when you run some JavaScript in your page.
    Let's briefly recap the story of what happens when you load a web page in a browser (first talked about in our How CSS works article). When you load a web page in your browser, you are running your code (the HTML, CSS, and JavaScript) inside an execution environment (the browser tab). This is like a factory that takes in raw materials (the code) and outputs a product (the web page).



    The JavaScript is executed by the browser's JavaScript engine, after the HTML and CSS have been assembled and put together into a web page. This ensures that the structure and style of the page are already in place by the time the JavaScript starts to run.
    This is a good thing, as a very common use of JavaScript is to dynamically modify HTML and CSS to update a user interface, via the Document Object Model API (as mentioned above). If the JavaScript loaded and tried to run before the HTML and CSS was there to affect, then errors would occur.

    Browser security

    Each browser tab is its own separate bucket for running code in (these buckets are called "execution environments" in technical terms) — this means that in most cases the code in each tab is run completely separately, and the code in one tab cannot directly affect the code in another tab — or on another website. This is a good security measure — if this were not the case, then pirates could start writing code to steal information from other websites, and other such bad things.

    Note: There are ways to send code and data between different websites/tabs in a safe manner, but these are advanced techniques that we won't cover in this course.

    JavaScript running order

    When the browser encounters a block of JavaScript, it generally runs it in order, from top to bottom. This means that you need to be careful what order you put things in. For example, let's return to the block of JavaScript we saw in our first example:

    Here we are selecting a text paragraph (line 1), then attaching an event listener to it (line 3) so that when the paragraph is clicked, the updateName() code block (lines 5–8) is run. The updateName() code block (these types of reusable code block are called "functions") asks the user for a new name, and then inserts that name into the paragraph to update the display.
    If you swapped the order of the first two lines of code, it would no longer work — instead, you'd get an error returned in the browser developer console — TypeError: para is undefined. This means that the para object does not exist yet, so we can't add an event listener to it.

    Note: This is a very common error — you need to be careful that the objects referenced in your code exist before you try to do stuff to them.

    Interpreted versus compiled code

    You might hear the terms interpreted and compiled in the context of programming. JavaScript is an interpreted language — the code is run from top to bottom and the result of running the code is immediately returned. You don't have to transform the code into a different form before the browser runs it.
    Compiled languages on the other hand are transformed (compiled) into another form before they are run by the computer. For example C/C++ are compiled into assembly language that is then run by the computer.
    Both approaches have different advantages, which we won't discuss at this point.

    Server-side versus client-side code

    You might also hear the terms server-side and client-side code, specially in the context of web development. Client-side code is code that is run on the user's computer — when a web page is viewed, the page's client-side code is downloaded, then run and displayed by the browser. In this JavaScript module we are explicitly talking about client-side JavaScript.
    Server-side code on the other hand is run on the server, then its results are downloaded and displayed in the browser. Examples of popular server-side web languages include PHP, Python, Ruby, and ASP.NET. And JavaScript! JavaScript can also be used as a server-side language, for example in the popular Node.js environment — you can find more out about server-side JavaScript in our Dynamic Websites – Server-side programming topic.
    The word dynamic is used to describe both client-side JavaScript, and server-side languages — it refers to the ability to update the display of a web page/app to show different things in different circumstances, generating new content as required. Server-side code dynamically generates new content on the server, e.g. pulling data from a database, whereas client-side JavaScript dynamically generates new content inside the browser on the client, e.g. creating a new HTML table, inserting data requested from the server into it, then displaying the table in a web page shown to the user. The meaning is slightly different in the two contexts, but related, and both approaches (server-side and client-side) usually work together.
    A web page with no dynamically updating content is referred to as static — it just shows the same content all the time.

     

     

     

    How do you add JavaScript to your page?

    JavaScript is applied to your HTML page in a similar manner to CSS. Whereas CSS uses <link> elements to apply external stylesheets and <style> elements to apply internal stylesheets to HTML, JavaScript only needs one friend in the world of HTML — the <script> element. Let's learn how this works.

    Internal JavaScript

    1. First of all, make a local copy of our example file apply-javascript.html. Save it in a directory somewhere sensible.
    2. Open the file in your web browser and in your text editor. You'll see that the HTML creates a simple web page containing a clickable button.
    3. Next, go to your text editor and add the following just before your closing </body> tag:
              


    Now we'll add some JavaScript inside our <script> element to make the page do something more interesting — add the following code just below the "// JavaScript goes here" line:
    Save your file and refresh the browser — now you should see that when you click the button, a new paragraph is generated and placed below.




    External JavaScript

    This works great, but what if we wanted to put our JavaScript in an external file? Let's explore this now.
    1. First, create a new file in the same directory as your sample HTML file. Call it script.js — make sure it has that .js filename extension, as that's how it is recognized as JavaScript.
    2. Next, copy all of the script out of your current <script> element and paste it into the .js file. Save that file.
    3. Now replace your current <script> element with the following:
    4. <script src="script.js"</script>
    5. Save and refresh your browser, and you should see the same thing! It works just the same, but now we've got the JavaScript in an external file. This is generally a good thing in terms of organizing your code, and making it reusable across multiple HTML files. Plus the HTML is easier to read without huge chunks of script dumped in it.
    Note: You can see this version on GitHub as apply-javascript-external.html and script.js (see it live too).

    Inline JavaScript handlers

    Note that sometimes you'll come across bits of actual JavaScript code living inside HTML. It might look something like this:







     

    Using a pure JavaScript construct allows you to select all the buttons using one instruction. The code we used above to serve this purpose looks like this:

    
    This might look a bit longer than the onclick attribute, but this will work for all buttons no matter how many are on the page, and how many are added or removed. The JavaScript does not need to be changed.

    Note: Try editing your version of apply-javascript.html and add a few more buttons into the file. When you reload, you should find that all of the buttons when clicked will create a paragraph. Neat, huh?

    Comments

    As with HTML and CSS, it is possible to write comments into your JavaScript code that will be ignored by the browser, and exist simply to provide instructions to your fellow developers on how the code works (and you, if you come back to your code after 6 months and can't remember what you did). Comments are very useful, and you should use them often, particularly for larger applications. There are two types
    • A single line comment is written after a double forward slash (//), e.g.


    • A multi-line comment is written between the strings /* and */, e.g.


    So for example, we could annotate our last demo's JavaScript with comments like so:
        

     


        More Learn to:

    Monday 3 December 2018

    BOOTSTRAP

    BOOTSTRAP


    Bootstrap is a framework in css html and javascript
    Bootstrap is full free to download and usage
    we can download bootstrap in the screenshot's link.
    which is "https://getbootstrap.com".

    bootstrap downloaded css file is defending the format so if we set a class  and call that class. 

    bootstrap save our time.

    Friday 30 November 2018

    CSS

    CSS 

    • css called cascading style sheet
    • css describes the style of html
    • css save a lot of works to developer


    syntax of css

    h2 {
    color:red;
    font-size:12px;



    • h2 - selection
    • color - property
    • red - value
    • color:red; - declaration 


    3 ways to add css styles in our html document 

    • Inline style
    • Internal
    • External

    1.Inline
    <p style="color:red;"> about uki...... </p>

    here is a paragraph. and a ccs style used in that html's <p> line. it's called inline css.

    2.Internal
    <html>
    <head>
    <style>
    body {
        background-color: red;
    }
    p {
        color: black;

    </style>
    </head>
    <body>

    <p>i am a uki student</p>


    </body>


    </html>

    here is a paragraph's styles designs between head tags. internal's every design process from the head tags.


    3.External
    <html>

    <head>

    <link rel="stylesheet" type="text/css" href="data.css">

    </head>

    <body>



    <h1>i'm a uki student </h1>

    a

    </body>

    </html>



    here is a heading's style linked in a css document which is called external css. most of the developers using external css


    css backgroundcolour

    <html>
    <head>
    <style>
    h1 {
        background-color: red;
    }

    p {
        background-color: blue;
    }
    </style>
    </head>
    <body>

    <h1>here is the red colour /h1>

    <p>here is the blue colour</p>

    </body>
    </html>






    we can use css colors like this format
              p {background-color:black;}


    css background image

    <html>

    <head>

    <style>

    body {

        background-image: url("https://image.spreadshirtmedia.net/image-server/v1/mp/designs/140238303,width=178,height=178/nerd-kode-klippet-inn-sekskant.png");

        background-repeat: no-repeat;

        background-position:right center;

        margin-right: 5px;

        background-attachment: fixed;
    }

    </style>

    </head>

    <body>

    <h1>Hello</h1>
    </body>

    </html>


    we can use background image like this format

    css border

    <!DOCTYPE html>
    <html>
    <head>
    <style>
    p {
        border: 5px solid blue;
    }
    </style>
    </head>
    <body>

    <h2>uki life</h2>

    <p>color blue</p>

    </body>
    </html>


    we can use the border like this format border: border's width border's type and border's color then border radius: enough radius like a round shape 

    css margin
    <!DOCTYPE html>
    <html>
    <head>
    <style>
    div {
        border: 1px solid black;
        margin: 25px;
        background-color: lightgreen;
    }
    </style>
    </head>
    <body>

    <h2>uki</h2>

    <div>uki life</div>

    </body>
    </html>


    css margin is where will we pix our content? which limits of the distance from outside of the page

    css pading
    <!DOCTYPE html>
    <html>
    <head>
    <style>
    div {
        border: 1px solid black;
        padding: 25px 50px 75px;
        background-color: lightblue;
    }
    </style>
    </head>
    <body>

    <h2>uki</h2>

    <div>It is a full scholarship based Accelerator program for Coding in Jaffna, Sri Lanka targeting students who has completed Advanced Level examinations and don’t have access to university education or any other form of vocational education. It is aimed to provide the necessary training to enter Computer Software industry or to start an IT startup.
    </div>

    </body>
    </html>



    Padding is a distance between content to border

    css height and width

    <!DOCTYPE html>
    <html>
    <head>
    <style>
    div {
        max-width: 500px;
        height: 100px;
        background-color: powderblue;
    }
    </style>
    </head>
    <body>

    <h2>uki</h2>
    <p>uki life</p>

    <div>It is a full scholarship based Accelerator program for Coding in Jaffna, Sri Lanka targeting students who has completed Advanced Level examinations and don’t have access to university education or any other form of vocational education. It is aimed to provide the necessary training to enter Computer Software industry or to start an IT startup.
    </div>

    <p>uki</p>

    </body>
    </html>


    how to display our content in our web page.we can set our content placement by height and width.

    Css box model

    <!DOCTYPE html>
    <html>
    <head>
    <style>
    div {
        width: 320px;
        padding: 10px;
        border: 5px solid gray;
        margin: 0;
    }
    </style>
    </head>
    <body>

    <h2>uki:</h2>

    <img src="http://uki.life/wp-content/uploads/2016/11/aaa-2.jpg" width="350" height="263" alt="Klematis">
    <div>This the logo of uki</div>

    </body>
    </html>



    different  between margin border padding and the content


    Css outline

    <!DOCTYPE html>
    <html>
    <head>
    <style>
    p.ex1 {
        border: 1px solid black;
        outline-style: solid;
        outline-color: red;
        outline-width: thin;
    }

    p.ex2 {
        border: 1px solid black;
        outline-style: solid;
        outline-color: red;
        outline-width: medium;
    }

    p.ex3 {
        border: 1px solid black;
        outline-style: solid;
        outline-color: red;
        outline-width: thick;
    }

    p.ex4 {
        border: 1px solid black;
        outline-style: solid;
        outline-color: red;
        outline-width: 4px;
    }</style>
    </head>
    <body>

    <h2>the uki batch stone</h2>

    <p class="ex1">uki1</p>
    <p class="ex2">uki2</p>
    <p class="ex3">uki3</p>
    <p class="ex4">uki4</p>

    </body>
    </html>


    Css text

    <html>
    <head>
    <style>
    body{

        color: green;

        text-align: center
        ;

        text-decoration: none;

        text-transform: uppercase;

        text-indent: 50px;

        letter-spacing: 3px;

        direction: rtl;

        word-spacing: 10px;

        text-shadow: 3px 2px red;

    }

    </style>

    </head>

    <body>
    <h1>uki batch 4</h1>

    <p>It is a full scholarship based Accelerator program for Coding in Jaffna, Sri Lanka targeting students who has completed Advanced Level examinations and don’t have access to university education or any other form of vocational education. It is aimed to provide the necessary training to enter Computer Software industry or to start an IT startup.
    </p>
    </body>
    </html>


    Css font

    <html>
    <head>
    <style>
    p.serif {

        font-family: "Times New Roman", Times, serif;

    }


    p.sansserif {

        font-family: Arial, Helvetica, sans-serif;

        font-size: 30px;

        font-weight: bold;

        font-variant: small-caps;

    }

    </style>
    </head>
    <body>

    <h1>uki-family</h1>

    <p class="serif">uki batch4</p>

    <p class="sansserif">we are the good family</p>

    </body>
    </html>


    Css icon

    <html>
    <head>
    <title>Google Icons</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
    </head>
    <body>

    <p>Some Google icons:</p>
    <i class="material-icons">cloud</i>
    <i class="material-icons">favorite</i>
    <i class="material-icons">attachment</i>
    <i class="material-icons">computer</i>
    <i class="material-icons">traffic</i>
    <br><br>

    <p>Styled Google icons (size and color):</p>
    <i class="material-icons" style="font-size:24px;">cloud</i>
    <i class="material-icons" style="font-size:36px;">cloud</i>
    <i class="material-icons" style="font-size:48px;color:red;">cloud</i>
    <i class="material-icons" style="font-size:60px;color:lightblue;">cloud</i>

    </body>

    </html>




    Css links

    <html>
    <head>
    <style>
    a:link, a:visited {
        background-color: #f44336;
        color: white;
        padding: 14px 25px;
        text-align: center;
        text-decoration: none;
        display: inline-block;
    }


    a:hover, a:active {
        background-color: red;
    }
    </style>
    </head>
    <body>

    <a href="default.asp" target="_blank">share it</a>

    </body>
    </html>