Skip to content

Commit 9bb6123

Browse files
committed
🕸️ Add page number pagination example
1 parent 4aea542 commit 9bb6123

File tree

2 files changed

+264
-0
lines changed

2 files changed

+264
-0
lines changed

static/examples.json

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39631,6 +39631,163 @@
3963139631
}
3963239632
]
3963339633
},
39634+
{
39635+
"id": "h7Kp2rNj9wLmCzFxVqTb4",
39636+
"url": "https://claude.site/artifacts/bdf20e24-2fbd-432f-9fa4-774dea8a5436",
39637+
"source": "html",
39638+
"category": "synthetic",
39639+
"subcategory": "synthetic",
39640+
"type": "listing_detail",
39641+
"goal": "Extract all product information",
39642+
"schema_": {
39643+
"id": {
39644+
"type": "string"
39645+
},
39646+
"name": {
39647+
"type": "string"
39648+
},
39649+
"description": {
39650+
"type": "string"
39651+
}
39652+
},
39653+
"description": "Paginated product data with numbered page buttons. The current page button is disabled and has an 'active' CSS class. The pagination occurs client side using JavaScript.",
39654+
"tags": [
39655+
"synthetic",
39656+
"pagination"
39657+
],
39658+
"evals": [
39659+
{
39660+
"type": "json_match",
39661+
"expected": [
39662+
{
39663+
"id": "P001",
39664+
"name": "Ergonomic Chair",
39665+
"description": "Comfortable office chair with lumbar support"
39666+
},
39667+
{
39668+
"id": "P002",
39669+
"name": "Wireless Mouse",
39670+
"description": "High-precision wireless mouse with long battery life"
39671+
},
39672+
{
39673+
"id": "P003",
39674+
"name": "Mechanical Keyboard",
39675+
"description": "Tactile mechanical keyboard with RGB backlighting"
39676+
},
39677+
{
39678+
"id": "P004",
39679+
"name": "4K Monitor",
39680+
"description": "Ultra-high definition monitor with wide color gamut"
39681+
},
39682+
{
39683+
"id": "P005",
39684+
"name": "Noise-Cancelling Headphones",
39685+
"description": "Over-ear headphones with active noise cancellation"
39686+
},
39687+
{
39688+
"id": "P006",
39689+
"name": "Laptop Stand",
39690+
"description": "Adjustable aluminum laptop stand for better ergonomics"
39691+
},
39692+
{
39693+
"id": "P007",
39694+
"name": "Desk Lamp",
39695+
"description": "LED desk lamp with adjustable color temperature"
39696+
},
39697+
{
39698+
"id": "P008",
39699+
"name": "External SSD",
39700+
"description": "Fast and portable solid-state drive for extra storage"
39701+
},
39702+
{
39703+
"id": "P009",
39704+
"name": "Webcam",
39705+
"description": "Full HD webcam with built-in microphone"
39706+
},
39707+
{
39708+
"id": "P010",
39709+
"name": "USB Hub",
39710+
"description": "Multi-port USB hub with power delivery"
39711+
},
39712+
{
39713+
"id": "P011",
39714+
"name": "Graphics Tablet",
39715+
"description": "Digital drawing tablet with pressure sensitivity"
39716+
},
39717+
{
39718+
"id": "P012",
39719+
"name": "Wireless Charger",
39720+
"description": "Qi-compatible wireless charging pad"
39721+
},
39722+
{
39723+
"id": "P013",
39724+
"name": "Document Scanner",
39725+
"description": "Portable document scanner with OCR functionality"
39726+
},
39727+
{
39728+
"id": "P014",
39729+
"name": "Desk Organizer",
39730+
"description": "Multi-compartment organizer for office supplies"
39731+
},
39732+
{
39733+
"id": "P015",
39734+
"name": "Ergonomic Mouse Pad",
39735+
"description": "Gel-filled mouse pad with wrist support"
39736+
},
39737+
{
39738+
"id": "P016",
39739+
"name": "Portable Projector",
39740+
"description": "Mini LED projector for presentations on-the-go"
39741+
},
39742+
{
39743+
"id": "P017",
39744+
"name": "Smart Power Strip",
39745+
"description": "Wi-Fi enabled power strip with individual outlet control"
39746+
},
39747+
{
39748+
"id": "P018",
39749+
"name": "Cable Management Kit",
39750+
"description": "Set of cable clips and sleeves for tidy workspaces"
39751+
},
39752+
{
39753+
"id": "P019",
39754+
"name": "Desk Fan",
39755+
"description": "USB-powered desk fan with adjustable speed"
39756+
},
39757+
{
39758+
"id": "P020",
39759+
"name": "Blue Light Glasses",
39760+
"description": "Computer glasses that filter out harmful blue light"
39761+
},
39762+
{
39763+
"id": "P021",
39764+
"name": "Wireless Presenter",
39765+
"description": "Remote control for presentations with laser pointer"
39766+
},
39767+
{
39768+
"id": "P022",
39769+
"name": "Laptop Cooling Pad",
39770+
"description": "Laptop stand with built-in cooling fans"
39771+
},
39772+
{
39773+
"id": "P023",
39774+
"name": "USB Microphone",
39775+
"description": "Cardioid condenser microphone for clear audio recording"
39776+
},
39777+
{
39778+
"id": "P024",
39779+
"name": "Desk Pad",
39780+
"description": "Large mouse pad that covers the entire desk area"
39781+
},
39782+
{
39783+
"id": "P025",
39784+
"name": "Portable Monitor",
39785+
"description": "Slim and lightweight secondary monitor for laptops"
39786+
}
39787+
]
39788+
}
39789+
]
39790+
},
3963439791
{
3963539792
"id": "rWSVXdF4puP0VaRmMB1Sj",
3963639793
"url": "https://claude.site/artifacts/13c937f7-2a43-406c-8369-e2d2852fea9b",
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Product List</title>
7+
<style>
8+
.pagination {
9+
display: flex;
10+
justify-content: center;
11+
margin-top: 20px;
12+
}
13+
.pagination button {
14+
margin: 0 5px;
15+
padding: 5px 10px;
16+
cursor: pointer;
17+
}
18+
.pagination button.active {
19+
background-color: #007bff;
20+
color: white;
21+
border: none;
22+
}
23+
.pagination button:disabled {
24+
cursor: not-allowed;
25+
opacity: 0.5;
26+
}
27+
</style>
28+
</head>
29+
<body>
30+
<div id="productList"></div>
31+
<div class="pagination" id="pagination"></div>
32+
33+
<script>
34+
const products = [
35+
{"id": "P001", "name": "Ergonomic Chair", "description": "Comfortable office chair with lumbar support"},
36+
{"id": "P002", "name": "Wireless Mouse", "description": "High-precision wireless mouse with long battery life"},
37+
{"id": "P003", "name": "Mechanical Keyboard", "description": "Tactile mechanical keyboard with RGB backlighting"},
38+
{"id": "P004", "name": "4K Monitor", "description": "Ultra-high definition monitor with wide color gamut"},
39+
{"id": "P005", "name": "Noise-Cancelling Headphones", "description": "Over-ear headphones with active noise cancellation"},
40+
{"id": "P006", "name": "Laptop Stand", "description": "Adjustable aluminum laptop stand for better ergonomics"},
41+
{"id": "P007", "name": "Desk Lamp", "description": "LED desk lamp with adjustable color temperature"},
42+
{"id": "P008", "name": "External SSD", "description": "Fast and portable solid-state drive for extra storage"},
43+
{"id": "P009", "name": "Webcam", "description": "Full HD webcam with built-in microphone"},
44+
{"id": "P010", "name": "USB Hub", "description": "Multi-port USB hub with power delivery"},
45+
{"id": "P011", "name": "Graphics Tablet", "description": "Digital drawing tablet with pressure sensitivity"},
46+
{"id": "P012", "name": "Wireless Charger", "description": "Qi-compatible wireless charging pad"},
47+
{"id": "P013", "name": "Document Scanner", "description": "Portable document scanner with OCR functionality"},
48+
{"id": "P014", "name": "Desk Organizer", "description": "Multi-compartment organizer for office supplies"},
49+
{"id": "P015", "name": "Ergonomic Mouse Pad", "description": "Gel-filled mouse pad with wrist support"},
50+
{"id": "P016", "name": "Portable Projector", "description": "Mini LED projector for presentations on-the-go"},
51+
{"id": "P017", "name": "Smart Power Strip", "description": "Wi-Fi enabled power strip with individual outlet control"},
52+
{"id": "P018", "name": "Cable Management Kit", "description": "Set of cable clips and sleeves for tidy workspaces"},
53+
{"id": "P019", "name": "Desk Fan", "description": "USB-powered desk fan with adjustable speed"},
54+
{"id": "P020", "name": "Blue Light Glasses", "description": "Computer glasses that filter out harmful blue light"},
55+
{"id": "P021", "name": "Wireless Presenter", "description": "Remote control for presentations with laser pointer"},
56+
{"id": "P022", "name": "Laptop Cooling Pad", "description": "Laptop stand with built-in cooling fans"},
57+
{"id": "P023", "name": "USB Microphone", "description": "Cardioid condenser microphone for clear audio recording"},
58+
{"id": "P024", "name": "Desk Pad", "description": "Large mouse pad that covers the entire desk area"},
59+
{"id": "P025", "name": "Portable Monitor", "description": "Slim and lightweight secondary monitor for laptops"}
60+
];
61+
62+
const itemsPerPage = 5;
63+
let currentPage = 1;
64+
65+
function displayProducts(page) {
66+
const start = (page - 1) * itemsPerPage;
67+
const end = start + itemsPerPage;
68+
const pageProducts = products.slice(start, end);
69+
70+
const productList = document.getElementById('productList');
71+
productList.innerHTML = pageProducts.map(product => `
72+
<div>
73+
<h3>${product.name}</h3>
74+
<p>ID: ${product.id}</p>
75+
<p>${product.description}</p>
76+
</div>
77+
`).join('');
78+
}
79+
80+
function setupPagination() {
81+
const pageCount = Math.ceil(products.length / itemsPerPage);
82+
const pagination = document.getElementById('pagination');
83+
pagination.innerHTML = '';
84+
85+
for (let i = 1; i <= pageCount; i++) {
86+
const button = document.createElement('button');
87+
button.innerText = i;
88+
button.onclick = () => changePage(i);
89+
if (i === currentPage) {
90+
button.classList.add('active');
91+
button.disabled = true;
92+
}
93+
pagination.appendChild(button);
94+
}
95+
}
96+
97+
function changePage(page) {
98+
currentPage = page;
99+
displayProducts(currentPage);
100+
setupPagination();
101+
}
102+
103+
displayProducts(currentPage);
104+
setupPagination();
105+
</script>
106+
</body>
107+
</html>

0 commit comments

Comments
 (0)