Skip to content
This repository was archived by the owner on Jan 21, 2021. It is now read-only.

JavaScript modules

Micah Lindley edited this page Nov 8, 2020 · 1 revision

There are two primary JavaScript modules that we use. These are not external scripts, but ones written especially for Itchy and designed to be reusable across the application.

requests.js

This module handles all requests to the Scratch API as well as to our search API. We ask that when using it you import it as api to standardize it across the different JavaScript files. It provides the following functions, all of which are asynchronous and should be used in the context of .then().

  • api.projects.recent(offset) returns an array of the most recently shared projects where offset is the offset to provide the API request
  • api.projects.tagged(tag, offset) returns an array of the top projects of a certain tag where tag is a tag to search for and offset is the offset to provide the API request
  • api.projects.trending(offset) returns an array of the top trending projects where offset is the offset to provide the API request
  • api.projects.topLoved(offset) returns an array of the top loved projects where offset is the offset to provide the API request
  • api.projects.featured(offset) returns an array of the featured project where offset is the offset to provide the API request
  • api.search.general(query, offset) returns an array of search results where query is a URI-encoded string to search and offset is the offset to provide the API request
  • api.project.metadata(id) returns a single project object where id is the project ID to provide the API request
  • api.project.comments(id, username, offset) returns an array of the most recent comments on a project where id is the project's ID, username is the project's author's Scratch username, and offset is the offset to provide the API request

requests.js

This module handles all repetitive DOM manipulation tasks

DOCUMENTATION TODO

Clone this wiki locally