-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathindex.html
112 lines (103 loc) · 4.34 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>iOS Model List - 📱⌚️ Identify model for iPhone, iPad, iPod touch, Apple Watch, Apple TV, and Mac computers with Apple Silicon</title>
<meta name="description" content="The ultimate list of iOS device models - Identify model for iPhone, iPad, iPod touch, Apple Watch, Apple TV, and Mac computers with Apple Silicon.">
<style type="text/css">
body {
font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji;
font-size: 18px;
}
code, pre, textarea {
font-family: SFMono-Regular,Consolas,Liberation Mono,Menlo,Courier,monospace;
}
.container {
margin: 0 auto;
width: 90%;
}
.header {
text-align: center;
}
textarea#list, textarea#dict {
height: 11em;
width: 90%;
margin-left: 2em;
}
@media only screen and (min-width: 768px) {
.container {
width: 60%;
}
}
</style>
</head>
<body>
<div class="container">
<div class="header">
<h2>iOS Model List</h2>
<p>The ultimate list of iOS device models - Identify model for iPhone, iPad, iPod touch, Apple Watch, Apple TV, and Mac computers with Apple Silicon.</p>
<p>GitHub: <a href="https://github.com/ElfSundae/iOS-Model-List">ElfSundae/iOS-Model-List</a></p>
</div>
<p><code>list.json</code>:</p>
<textarea id="list" readonly></textarea>
<p><code>NSDictionary</code>:</p>
<textarea id="dict" readonly></textarea>
</div>
<script>
function parseDevicesResponse(data)
{
let list = {};
const collator = new Intl.Collator('en', { numeric: true, sensitivity: 'base' });
data.sort((a, b) => collator.compare(a.identifier, b.identifier));
data.forEach(function(device) {
// exclude HomePod, iBridge, ADP
if (device.identifier.startsWith('AudioAccessory') ||
device.identifier.startsWith('iBridge') ||
device.identifier.startsWith('ADP')) {
return;
}
let name = device.name
.replace('Apple TV 2G', 'Apple TV 2')
.replace(/^iPad 1$/, 'iPad')
.replace('Mini', 'mini') // iPad Mini, Mac Mini
.replace('iPad Pro 9.7-inch', 'iPad Pro (9.7-inch)')
.replace('iPad Pro 12.9-inch', 'iPad Pro (12.9-inch)')
.replace('iPad Pro (10.5-inch', 'iPad Pro (10.5-inch')
.replace(/(iPad Pro) \(([\d.]+-inch)\) (\(.+ generation\))/, '$1 $2 $3')
.replace('iPhone 2G', 'iPhone')
.replace('iPhone 4 (GSM / 2012)', 'iPhone 4')
.replace('iPhone SE (2020)', 'iPhone SE (2nd generation)')
.replace('[S]', 'S') // iPhone 3G[S], iPhone 4[S]
.replace('+', ' Plus') // iPhone 6+, iPhone 6s+
.replace('iPod touch 1G', 'iPod touch')
.replace('iPod touch 2G', 'iPod touch 2')
.replace('MacBook Pro (M1, Late 2020)', 'MacBook Pro (13-inch, M1, 2020)')
.replace('M1, Late 2020', 'M1, 2020')
.replace(/iMac 24-inch \(M1, .+, 2021\)/, 'iMac (24-inch, M1, 2021)')
.replace(/(M1 Pro|M1 Max), /, '')
.replace(/[\s,]*(2013|2015|WiFi|GSM|CDMA|Mid 2012|Global|Cellular|China|1TB Model)/gi, '')
.replace(/\s+\(\s*\)/g, '')
.trim();
list[device.identifier] = name;
});
list['i386'] = 'Simulator';
list['x86_64'] = 'Simulator';
return list;
}
fetch('https://api.ipsw.me/v4/devices')
.then(response => response.json())
.catch(error => alert(error))
.then(function(data) {
let list = parseDevicesResponse(data);
document.querySelector('#list').value = JSON.stringify(list, null, 2);
let dict = "NSDictionary *models = @{\n";
for (let key in list) {
dict += ` @"${key}": @"${list[key]}",\n`;
}
dict += "};\n";
document.querySelector('#dict').value = dict;
});
</script>
</body>
</html>