Tuesday, 1 December 2015

Javascript

Javascript is a computer code that can do these thing to your webpage:
1
1. HTML
- add an home page
- add an about page
2. CSS
- add site.css
- edit index.html add script link href & add div id main in the body
- edit about.html add link href to site.css

3. Javascript
- add script.js --> script hanya menampilkan tanggal
- edit homepage: add footer, include script.js (script that you just created)

4. Edit stylesheet
- add table, etc
- add customer.html: add data table dan footer.

5. Adding Navigation
- edit script.js --> add something on behalf of something.
- stylesheet
- edit index.html --> add <nav id="nav01">
- edit about.html ---> add <nav id="nav01"> below body tag
- edit customers.html --> add <nav id="nav01"> below body tag

6. Fetching data
1. AppML
2. JSON

CSS

Fundamental of CSS are:
# targetting id

CSS are code that can modify these upon your html tag:
1. background-color (keyword: background-color)
2. text-color (keyword: color)
3. padding
4.
5.


CSS box model
Keyword: text, padding, border, and margin (Te,Pad,Bor,Mar)

Monday, 30 November 2015

Javascript: Outputting text

I want to output a text into/inside a local paragraf instead of using canvas. How can I do that?

There are 5 steps you need to do:
1. First thing you need to define the paragraph where you want to the text to showed up. Like this:
<p></p>

2. Second thing, you need to insert a span tag into that paragraph tag. Like this below:
<p><span></span></p>

3. Third, you need to give an id to that span tag; just the opening tag, not the closing tag. Like this below:
<p><span id="here"></span></p>

4. Last you need to define below inside your script tag:
<script>
document.getElemenytById("here").innerHTML="<your text>"

</script>

5. Last, finish, run the code.

Warning: Remember to use .innerHTML not .value.

For complete code:
<body>
<p><span id="here"></span></p>

<script>
document.getElementById("here").innerHTML = "<your text>"
</script>
</body>

Javascript: Converting hexadecimal to decimal

I want to convert hexadecimal value (for i.e. "0xff") to a decimal value, how can I do this?

1. Put your hexadecimal-value into a string and then into a variable, like this below:
var a = "0xff" //don't forget the double-quotes

2. then use a function like this:




I usually dealing hexadecimal value with color.
Test

Javascript: Operating on a string

What can we do upon a string?
1. Looking its length
2. Searching index of a string from it
3. Extracting a string from it
4. Inserting a string into it.

Looking for how long / length

a.length


Searching for index
indexOf()
lastIndexOf()

Powerful search using RegEx.

Extracting parts
slice(firstindex, lastindex)

You want to convert a string that contain hex value to a decimal?

You want to convert a string that contains hex value to a decimal? How can you do that?

For example:
var x="#fffffa"
You can't convert this type of string into decimal-number. Reason: because there is a pound (#) sign inside that string. Solution: remove the pound sign first.

This case is retrieving value from <input type="color">