Avoid modifying stylesheets when updating @medias.
[cydget.git] / PhotoExample.cydget / index.html
1 <html><head>
2 <meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
3 <style>
4 * {
5 border: 0;
6 -moz-border-radius: 0;
7 -webkit-border-radius: 0;
8 box-sizing: border-box;
9 -moz-box-sizing: border-box;
10 -ms-box-sizing: border-box;
11 -webkit-box-sizing: border-box;
12 /*font-family: inherit;*/
13 font-size: 100%;
14 font-style: inherit;
15 font-weight: inherit;
16 margin: 0;
17 outline: 0;
18 padding: 0;
19 text-decoration: none;
20 vertical-align: baseline;
21 }
22
23 * {
24 -webkit-touch-callout: none;
25 -webkit-text-size-adjust: none;
26 -webkit-user-select: none;
27 }
28
29 body {
30 color: white;
31 background: none;
32 }
33
34 #lcd {
35 width: 100%;
36 }
37
38 #lcd h1 {
39 font-family: "LockClock-Light";
40 padding: 0px 0px 0px 1px;
41 position: relative;
42 text-align: center;
43 text-shadow: -0.5px -1px 1px black;
44 }
45
46 #lcd h2 {
47 font-family: "Helvetica";
48 position: relative;
49 text-align: center;
50 text-shadow: -0.5px -1px 1px black;
51 }
52
53 @media only screen and (min-device-width: 320px) and (max-device-width: 480px) {
54 #lcd {
55 height: 96px;
56 }
57
58 #lcd h1 {
59 font-size: 65px;
60 top: -6px;
61 }
62
63 #lcd h2 {
64 font-size: 17px;
65 top: -16px;
66 }
67 }
68
69 @media only screen and (min-device-width: 768px) and (max-device-width: 1024px) and (orientation: landscape) {
70 #lcd {
71 background: url(file:///System/Library/PrivateFrameworks/TelephonyUI.framework/BarLCD.png);
72 height: 96px;
73 }
74
75 #lcd h1 {
76 font-size: 69px;
77 top: -8px;
78 }
79
80 #lcd h2 {
81 font-size: 16px;
82 top: -18px;
83 }
84 }
85
86 @media only screen and (min-device-width: 768px) and (max-device-width: 1024px) and (orientation: portrait) {
87 #lcd {
88 background: url(file:///System/Library/PrivateFrameworks/TelephonyUI.framework/BarLCD_T.png);
89 height: 107px;
90 }
91
92 #lcd h1 {
93 font-size: 69px;
94 top: -1px;
95 }
96
97 #lcd h2 {
98 font-size: 16px;
99 top: -8px;
100 }
101 }
102
103 #content {
104 font-family: "Helvetica";
105 min-height: 268px;
106 text-align:center;
107 }
108
109 #content h3 {
110 font-size: 20px;
111 text-align: center;
112 margin-bottom: 10px;
113 }
114
115 #content p {
116 font-size: 14px;
117 text-align: justify;
118 margin: 10px 12px;
119 }
120
121 sup {
122 font-size: smaller;
123 position: relative;
124 top: -5px;
125 }
126
127 #content img {
128 margin: auto;
129 max-width: 100%;
130 vertical-align:middle;
131 }
132
133 @media only screen and (min-device-width: 320px) and (max-device-width: 480px) and (device-height: 480px) {
134 #content img {
135 max-height: 268px;
136 }
137 }
138
139 @media only screen and (min-device-width: 320px) and (max-device-width: 480px) and (device-height: 568px) {
140 #content img {
141 max-height: 356px;
142 }
143 }
144
145 @media only screen and (min-device-width: 768px) and (max-device-width: 1024px) and (orientation: landscape) {
146 #content img {
147 max-height: 556px;
148 }
149 }
150
151 @media only screen and (min-device-width: 768px) and (max-device-width: 1024px) and (orientation: portrait) {
152 #content img {
153 max-height: 769px;
154 }
155 }
156 </style></head><body>
157 <script type="text/javascript">
158 if (kCFCoreFoundationVersionNumber > 800)
159 document.write('<div style="height: 24px"></div>');
160 else
161 document.write('<style type="text/css"> #lcd { background: url(cydget://_UIImageWithName/UILCDBackground.png); } </style>');
162 </script>
163 <div id="content">
164 <script type="text/cycript" src="lcd.cy"></script>
165 <script type="text/cycript"> try {
166 dlopen("/System/Library/PrivateFrameworks/PhotoLibrary.framework/PhotoLibrary", RTLD_GLOBAL);
167
168 var version = typeof PLCameraAlbum != "undefined" && [PLCameraAlbum respondsToSelector:@selector(sharedInstance)] ? 0 : 1;
169
170 var album;
171 if (version == 0)
172 album = [[PLCameraAlbum sharedInstance] images];
173 else {
174 album = [[PLPhotoLibrary sharedPhotoLibrary] albums][0];
175
176 version = [album respondsToSelector:@selector(managedObjectContext)] ? 2 : 1;
177 if (version == 1)
178 album = album.contents;
179 else {
180 if ([album respondsToSelector:@selector(indexOfPosterImage)])
181 [album indexOfPosterImage];
182 else
183 [album posterImage];
184 [album entity];
185 album = album.managedObjectContext.registeredObjects.allObjects;
186 }
187 }
188
189 var getImage = function(index) {
190 var object = album[index];
191
192 if (version == 0)
193 return [[object fileGroup] pathForFullSizeImage];
194 else if (version == 1)
195 return '/var/mobile/Media/' + [object directory].toString() + '/' + [object filename].toString();
196 else if (version == 2) {
197 if ([object respondsToSelector:@selector(fileURLForLargeDisplayableImage)])
198 return [object fileURLForLargeDisplayableImage];
199 else if ([object respondsToSelector:@selector(filePathsWithoutThumbs)])
200 return [[object filePathsWithoutThumbs] anyObject];
201 }
202
203 return null;
204 };
205
206 var jpeg = null, length = album.length;
207 if (length != 0) {
208 for (var i = 0; i != 5; ++i) {
209 jpeg = getImage(Math.floor(Math.random() * length));
210 if (jpeg != null)
211 break;
212 }
213
214 if (jpeg == null)
215 for (var i = 0; i != length; ++i) {
216 jpeg = getImage(i);
217 if (jpeg != null)
218 break;
219 }
220
221 if (jpeg != null)
222 document.write('<img src="' + jpeg.toString() + '"/>');
223 }
224 } catch (e) {
225 document.write(e.toString());
226 } </script></div>
227 </body></html>