# Week 07

{% embed url="<https://youtu.be/Z-5cVpWhp30>" %}

{% embed url="<https://youtu.be/nKzrupwnI0M>" %}

{% embed url="<https://vimeo.com/244397751>" %}

Week6 #7

## 1. Multiple JS files

#### <https://editor.p5js.org/kdoodoo/sketches/B1yC6roi7>

#### You can keep your file in a separate js file.&#x20;

## 2. DOM element and Callback Function

#### Document Object Model (**DOM**)

![](/files/-LPRAvxN5dSfViwUXjf7)

![](/files/-LPRB61R6fayLxZYdXjP)

```
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.7.2/addons/p5.dom.min.js"></script>
```

## P5.dom library

#### <https://p5js.org/reference/#/libraries/p5.dom>

### Example

#### <https://editor.p5js.org/kdoodoo/sketches/rJfcgPsjm>

### Example

#### <https://editor.p5js.org/kdoodoo/sketches/rJ9XZwijm>

### Example

#### <https://editor.p5js.org/kdoodoo/sketches/SJfe7PjsX>

####

## Callback function

#### Callback function is simple that&#x20;

1. &#x20;**The function createButton is attached to the variable button.**
2. **And when the button is pressed, I want changeColor function os called.**

   ```
   button.mousePressed(changeColor);
   ```

### Callback is simply one function is called and the other function is continuously called.&#x20;

```
  var button = createButton("Color??");
  button.mousePressed(changeColor);
```

### Example

#### <https://editor.p5js.org/kdoodoo/sketches/rJS8rDjsm>

## Assignment

1. Have multiple .js file (at least 2)
2. Have DOM element (it can be anything, button, slider, check, wordform, etc)

#### <https://goo.gl/forms/BLQxwU8giiMkDzxk2>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://icl.doyoki.com/week-07.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
