Skip to content

Commit

Permalink
javascript
Browse files Browse the repository at this point in the history
  • Loading branch information
SiBen10 committed May 5, 2023
1 parent 6a0c3a6 commit be78a2f
Show file tree
Hide file tree
Showing 15 changed files with 68 additions and 0 deletions.
1 change: 1 addition & 0 deletions 0x15-javascript-web_jquery/0-script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
document.querySelector('HEADER').style.color = '#FF0000';
1 change: 1 addition & 0 deletions 0x15-javascript-web_jquery/1-script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$('HEADER').css('color', '#FF0000');
3 changes: 3 additions & 0 deletions 0x15-javascript-web_jquery/100-script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
document.addEventListener('DOMContentLoaded', function () {
document.querySelector('HEADER').style.color = '#FF0000';
});
11 changes: 11 additions & 0 deletions 0x15-javascript-web_jquery/101-script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
$('document').ready(function () {
$('DIV#add_item').click(function () {
$('UL.my_list').append('<li>Item</li>');
});
$('DIV#remove_item').click(function () {
$('UL.my_list li:last').remove();
});
$('DIV#clear_list').click(function () {
$('UL.my_list').empty();
});
});
8 changes: 8 additions & 0 deletions 0x15-javascript-web_jquery/102-script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
$('document').ready(function () {
const url = 'https://www.fourtonfish.com/hellosalut/?';
$('INPUT#btn_translate').click(function () {
$.get(url + $.param({ lang: $('INPUT#language_code').val() }), function (data) {
$('DIV#hello').html(data.hello);
});
});
});
17 changes: 17 additions & 0 deletions 0x15-javascript-web_jquery/103-script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
$('document').ready(function () {
$('INPUT#btn_translate').click(translate);
$('INPUT#language_code').focus(function () {
$(this).keydown(function (e) {
if (e.keyCode === 13) {
translate();
}
});
});
});

function translate () {
const url = 'https://www.fourtonfish.com/hellosalut/?';
$.get(url + $.param({ lang: $('INPUT#language_code').val() }), function (data) {
$('DIV#hello').html(data.hello);
});
}
3 changes: 3 additions & 0 deletions 0x15-javascript-web_jquery/2-script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
$('DIV#red_header').click(function () {
$('HEADER').css('color', '#FF0000');
});
3 changes: 3 additions & 0 deletions 0x15-javascript-web_jquery/3-script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
$('DIV#red_header').click(function () {
$('HEADER').addClass('red');
});
3 changes: 3 additions & 0 deletions 0x15-javascript-web_jquery/4-script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
$('DIV#toggle_header').click(function () {
$('HEADER').toggleClass('green red');
});
3 changes: 3 additions & 0 deletions 0x15-javascript-web_jquery/5-script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
$('DIV#add_item').click(function () {
$('UL.my_list').append('<li>Item</li>');
});
3 changes: 3 additions & 0 deletions 0x15-javascript-web_jquery/6-script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
$('DIV#update_header').click(function () {
$('HEADER').text('New Header!!!');
});
3 changes: 3 additions & 0 deletions 0x15-javascript-web_jquery/7-script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
$.get('https://swapi.co/api/people/5/?format=json', function (data) {
$('DIV#character').text(data.name);
});
3 changes: 3 additions & 0 deletions 0x15-javascript-web_jquery/8-script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
$.get('https://swapi.co/api/films/?format=json', function (data) {
$('UL#list_movies').append(...data.results.map(movie => `<li>${movie.title}</li>`));
});
5 changes: 5 additions & 0 deletions 0x15-javascript-web_jquery/9-script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
$('document').ready(function () {
$.get('https://fourtonfish.com/hellosalut/?lang=fr', function (data) {
$('DIV#hello').text(data.hello);
});
});
1 change: 1 addition & 0 deletions 0x15-javascript-web_jquery/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# 0x15-javascript-web_jquery

0 comments on commit be78a2f

Please sign in to comment.