Sabtu, 24 Maret 2012

PPWEB resume 6

 DOM SCRIPTING
Untuk melakukan DOM Scripting browser yang paling memungkinkan adalah dengan menggunakan browser firefox dengan add ons Firebug.

<script> </script>
Biasanya ditaruh di dalam body sebelum ditutup supaya saat koneksi lost, tampilan web akan tetap kelihatan à web  dibuild dulu  baru script ada.

Kegiatan – kegiatan dalam DOM Scripting :
1.       Accesing
Dengan menggunakan perintah :
a.       getElementById à hasilnya Cuma 1 (hasil tag)
b.      getElementByTagName à hasilnya abanyak (hasil array)

Contoh dalam file :
<script type="text/javascript">
            //console.log("STIKOM Surabaya");

            var myEl_1 = document.getElementById("subnav");
            console.log(myEl_1);
            console.log(myEl_1.innerHTML);
            console.log(myEl_1.length);

            var myEl_2 = document.getElementsByTagName("li");
            console.log(myEl_2);
            console.log(myEl_2[6].innerHTML);
            console.log(myEl_2.length);

            console.log(document.getElementById("welcome_note").innerHTML);
        </script>

Length hanya digunakan untuk menghitung array.

2.       Changing / manipulate
Dengan menggunakan perintah :
a.       setAttribute ( . . . , . . . )
b.      innerHTML = . . .
Contoh dalam file :
<script type="text/javascript">
            var myEl_1 = document.getElementById("contact_us");
            console.log("Before: " + myEl_1.getAttribute("style"));
            myEl_1.setAttribute("style", "color: yellow; background-color: blue;")
            console.log("After: " + myEl_1.getAttribute("style"));

            var myEl_2 = document.getElementById("subnav");
            myEl_2.innerHTML = "<li>Hello</li> <li>World</li>";
        </script>

3.       Creating
a.       createElement à dibuat tp belum ditempatkan / tag
b.      createTextNode / innerHTML à membuat text tapi belum tau tempatnya
c.       appendChild à menentukan semua tempat dam id di atas
khusus untuk creating, semua perintah di atas harus digunakan.
Contoh dalam file :
<script type="text/javascript">
            var newList_1 = document.createElement("li");
            var newText_1 = document.createTextNode("Afikaaa!");
            newList_1.appendChild(newText_1);
            //document.getElementById("nav").appendChild(newList_1);
            document.getElementsByTagName("li")[3].appendChild(newList_1);

            var newList_2 = document.createElement("li");
            newList_2.innerHTML = "Iyaaa!";
            document.getElementById("nav").appendChild(newList_2);
        </script>


Sekilas tentag Web Service
Web Service
Adalah layanan yang bisa langsung digunakan, yang diambil dengan suatu cara tertentum dari web penyedia layanan tersebut.
Contoh : Google Maps API, Facebook API, Twitter API, Currency converter, weather info gadget.
Web service ini seperti twitt yang ada di sidebar web seseorang

Terminologi
-          XML
-          SOA (Service Oriented Application)
-          SOAP (Simple Object Access Protocol)
-          WSDL (Web Service Definition Language)