質問編集履歴
2
いただいた回答内容に沿ってソースを修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -24,6 +24,26 @@
|
|
24
24
|
|
25
25
|
```javascript
|
26
26
|
|
27
|
+
'use strict';
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
const kijiFolder = 'kiji';
|
32
|
+
|
33
|
+
const gazoFolder = 'image';
|
34
|
+
|
35
|
+
const pageOption = {
|
36
|
+
|
37
|
+
animation: 'slide'
|
38
|
+
|
39
|
+
};
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
let appDir, gazoDir, kijiDir, destination;
|
44
|
+
|
45
|
+
|
46
|
+
|
27
47
|
ons.bootstrap()
|
28
48
|
|
29
49
|
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
@@ -34,204 +54,180 @@
|
|
34
54
|
|
35
55
|
.controller('commonCtrl', function ($scope, sharedScope) {
|
36
56
|
|
57
|
+
$scope.item = [{
|
58
|
+
|
59
|
+
src: 'icon/gif-load.gif',
|
60
|
+
|
37
|
-
|
61
|
+
orgSrc: '',
|
62
|
+
|
38
|
-
|
63
|
+
date: 'Loading...',
|
64
|
+
|
39
|
-
|
65
|
+
size: 'Loading...'
|
66
|
+
|
40
|
-
|
67
|
+
}];
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
sharedScope.setScope('gazoCatalogCtrl', $scope.item);
|
72
|
+
|
73
|
+
|
74
|
+
|
41
|
-
|
75
|
+
//■ データフォルダへアクセス
|
42
|
-
|
76
|
+
|
43
|
-
|
77
|
+
resolveLocalFileSystemURLSync(cordova.file.dataDirectory)
|
44
|
-
|
78
|
+
|
45
|
-
|
79
|
+
.then(function (fs) {
|
46
|
-
|
80
|
+
|
47
|
-
|
81
|
+
appDir = fs;
|
48
|
-
|
82
|
+
|
49
|
-
|
83
|
+
let process = [];
|
50
|
-
|
84
|
+
|
51
|
-
|
85
|
+
process.push(getDirectorySync(appDir, kijiFolder));
|
52
|
-
|
86
|
+
|
53
|
-
|
87
|
+
process.push(getDirectorySync(appDir, gazoFolder));
|
54
|
-
|
88
|
+
|
55
|
-
|
89
|
+
return Promise.all(process);
|
90
|
+
|
91
|
+
})
|
92
|
+
|
93
|
+
.then(function (fsArray) {
|
94
|
+
|
95
|
+
kijiDir = fsArray[0];
|
96
|
+
|
97
|
+
gazoDir = fsArray[1];
|
98
|
+
|
99
|
+
showGazo();
|
100
|
+
|
101
|
+
})
|
102
|
+
|
103
|
+
.catch(getErr);
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
//■ 画像一覧の取得
|
108
|
+
|
109
|
+
const showGazo = function () {
|
110
|
+
|
111
|
+
const dirObj = gazoDir.createReader();
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
readEntriesSync(dirObj)
|
116
|
+
|
117
|
+
.then(function (fileArray) {
|
118
|
+
|
119
|
+
//実画像(=jpg画像)のみ抽出してメタデータ取得
|
120
|
+
|
121
|
+
return Promise.all(fileArray.filter(function (fileObj) {
|
122
|
+
|
123
|
+
const ext = fileObj.name.split('.')[1];
|
124
|
+
|
125
|
+
if (ext == 'jpg') return fileObj;
|
126
|
+
|
127
|
+
})
|
128
|
+
|
129
|
+
.map(function (fileObj) {
|
130
|
+
|
131
|
+
return getMetadataSync(fileObj);
|
132
|
+
|
133
|
+
}));
|
56
134
|
|
57
135
|
})
|
58
136
|
|
59
|
-
.then(function (f
|
137
|
+
.then(function (fileArray) {
|
138
|
+
|
60
|
-
|
139
|
+
//ファイル一覧をタイムスタンプ順(昇順)にソート
|
140
|
+
|
141
|
+
fileArray.sort(function (a, b) {
|
142
|
+
|
143
|
+
if (a.metadata.modificationTime > b.metadata.modificationTime) return -1;
|
144
|
+
|
145
|
+
if (a.metadata.modificationTime < b.metadata.modificationTime) return 1;
|
146
|
+
|
147
|
+
return 0;
|
148
|
+
|
149
|
+
})
|
150
|
+
|
151
|
+
.forEach(function (fileObj, index) {
|
152
|
+
|
153
|
+
let localItem = [];
|
154
|
+
|
61
|
-
|
155
|
+
const src = fileObj.toURL();
|
156
|
+
|
157
|
+
|
158
|
+
|
62
|
-
|
159
|
+
localItem.push({
|
160
|
+
|
161
|
+
src: src.replace('.jpg', '.thm'),
|
162
|
+
|
163
|
+
orgSrc: src,
|
164
|
+
|
165
|
+
date: fileObj.metadata.modificationTime,
|
166
|
+
|
167
|
+
size: fileObj.metadata.size
|
168
|
+
|
169
|
+
});
|
170
|
+
|
171
|
+
|
172
|
+
|
63
|
-
|
173
|
+
$scope.item = localItem;
|
174
|
+
|
64
|
-
|
175
|
+
sharedScope.setScope('gazoCatalogCtrl', $scope.item);
|
176
|
+
|
65
|
-
|
177
|
+
});
|
66
|
-
|
67
|
-
showGazo();
|
68
178
|
|
69
179
|
})
|
70
180
|
|
71
181
|
.catch(getErr);
|
72
182
|
|
73
|
-
|
74
|
-
|
75
|
-
//■ 画像一覧の取得
|
76
|
-
|
77
|
-
const showGazo = function () {
|
78
|
-
|
79
|
-
const dirObj = gazoDir.createReader();
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
readEntriesSync(dirObj)
|
84
|
-
|
85
|
-
.then(function (fileArray) {
|
86
|
-
|
87
|
-
//実画像(=jpg画像)のみ抽出してメタデータ取得
|
88
|
-
|
89
|
-
return Promise.all(fileArray.filter(function (fileObj) {
|
90
|
-
|
91
|
-
const ext = fileObj.name.split('.')[1];
|
92
|
-
|
93
|
-
if (ext == 'jpg') return fileObj;
|
94
|
-
|
95
|
-
})
|
96
|
-
|
97
|
-
.map(function (fileObj) {
|
98
|
-
|
99
|
-
return getMetadataSync(fileObj);
|
100
|
-
|
101
|
-
}));
|
102
|
-
|
103
|
-
})
|
104
|
-
|
105
|
-
.then(function (fileArray) {
|
106
|
-
|
107
|
-
//ファイル一覧をタイムスタンプ順(昇順)にソート
|
108
|
-
|
109
|
-
fileArray.sort(function (a, b) {
|
110
|
-
|
111
|
-
if (a.metadata.modificationTime > b.metadata.modificationTime) return -1;
|
112
|
-
|
113
|
-
if (a.metadata.modificationTime < b.metadata.modificationTime) return 1;
|
114
|
-
|
115
|
-
return 0;
|
116
|
-
|
117
|
-
})
|
118
|
-
|
119
|
-
.forEach(function (fileObj, index) {
|
120
|
-
|
121
|
-
const src = fileObj.toURL();
|
122
|
-
|
123
|
-
$scope.item[index] = {
|
124
|
-
|
125
|
-
src: src.replace('.jpg', '.thm'),
|
126
|
-
|
127
|
-
orgSrc: src,
|
128
|
-
|
129
|
-
date: fileObj.metadata.modificationTime,
|
130
|
-
|
131
|
-
size: fileObj.metadata.size
|
132
|
-
|
133
|
-
};
|
134
|
-
|
135
|
-
sharedScope.setScope('gazoCatalogCtrl', $scope.item);
|
136
|
-
|
137
|
-
//この後にgazoCatalogCtrlに表示させたい
|
138
|
-
|
139
|
-
});
|
140
|
-
|
141
|
-
})
|
142
|
-
|
143
|
-
.catch(getErr);
|
144
|
-
|
145
183
|
};
|
146
184
|
|
147
|
-
|
185
|
+
})
|
186
|
+
|
148
|
-
|
187
|
+
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
188
|
+
|
189
|
+
// 画像一覧
|
190
|
+
|
191
|
+
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
192
|
+
|
193
|
+
.controller('gazoCatalogCtrl', function ($scope, sharedScope) {
|
194
|
+
|
149
|
-
$scope.
|
195
|
+
$scope.delegate = {
|
150
|
-
|
196
|
+
|
151
|
-
con
|
197
|
+
configureItemScope: function (index, itemScope) {
|
198
|
+
|
152
|
-
|
199
|
+
const gazoCatalogCtrlScope = sharedScope.getScope('gazoCatalogCtrl');
|
200
|
+
|
201
|
+
itemScope.item = {
|
202
|
+
|
203
|
+
src: gazoCatalogCtrlScope[index].src,
|
204
|
+
|
205
|
+
orgSrc: gazoCatalogCtrlScope[index].orgSrc,
|
206
|
+
|
207
|
+
date: gazoCatalogCtrlScope[index].date,
|
208
|
+
|
153
|
-
i
|
209
|
+
size: gazoCatalogCtrlScope[index].size
|
154
|
-
|
210
|
+
|
155
|
-
};
|
211
|
+
};
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
212
|
+
|
160
|
-
|
161
|
-
maximumImagesCount: 10,
|
162
|
-
|
163
|
-
quality: 100,
|
164
|
-
|
165
|
-
outputType: imagePicker.OutputType.FILE_URI
|
166
|
-
|
167
|
-
}
|
213
|
+
},
|
168
|
-
|
169
|
-
|
170
|
-
|
214
|
+
|
171
|
-
|
215
|
+
calculateItemHeight: function (index) {
|
216
|
+
|
217
|
+
return 91;
|
218
|
+
|
219
|
+
},
|
220
|
+
|
221
|
+
countItems: function () {
|
222
|
+
|
223
|
+
return $scope.item.length;
|
224
|
+
|
225
|
+
}
|
172
226
|
|
173
227
|
};
|
174
228
|
|
175
229
|
})
|
176
230
|
|
177
|
-
.controller('gazoCatalogCtrl', function ($scope, sharedScope) {
|
178
|
-
|
179
|
-
$scope.item = [{
|
180
|
-
|
181
|
-
src: 'icon/gif-load.gif',
|
182
|
-
|
183
|
-
orgSrc: '',
|
184
|
-
|
185
|
-
date: 'Loading...',
|
186
|
-
|
187
|
-
size: 'Loading...'
|
188
|
-
|
189
|
-
}];
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
$scope.delegate = {
|
194
|
-
|
195
|
-
configureItemScope: function (index, itemScope) {
|
196
|
-
|
197
|
-
const gazoCatalogCtrlScope = sharedScope.getScope('gazoCatalogCtrl');
|
198
|
-
|
199
|
-
itemScope.item = {
|
200
|
-
|
201
|
-
src: gazoCatalogCtrlScope[index].src,
|
202
|
-
|
203
|
-
orgSrc: gazoCatalogCtrlScope[index].orgSrc,
|
204
|
-
|
205
|
-
date: gazoCatalogCtrlScope[index].date,
|
206
|
-
|
207
|
-
size: gazoCatalogCtrlScope[index].size
|
208
|
-
|
209
|
-
};
|
210
|
-
|
211
|
-
},
|
212
|
-
|
213
|
-
calculateItemHeight: function (index) {
|
214
|
-
|
215
|
-
return 91;
|
216
|
-
|
217
|
-
},
|
218
|
-
|
219
|
-
countItems: function () {
|
220
|
-
|
221
|
-
return $scope.item.length;
|
222
|
-
|
223
|
-
},
|
224
|
-
|
225
|
-
destroyItemScope: function(index, itemScope) {
|
226
|
-
|
227
|
-
itemScope.canceler.resolve();
|
228
|
-
|
229
|
-
}
|
230
|
-
|
231
|
-
};
|
232
|
-
|
233
|
-
})
|
234
|
-
|
235
231
|
.factory('sharedScope', function ($rootScope) {
|
236
232
|
|
237
233
|
let sharedScope = {};
|
@@ -257,3 +253,141 @@
|
|
257
253
|
});
|
258
254
|
|
259
255
|
```
|
256
|
+
|
257
|
+
|
258
|
+
|
259
|
+
```html
|
260
|
+
|
261
|
+
<!DOCTYPE HTML>
|
262
|
+
|
263
|
+
<html>
|
264
|
+
|
265
|
+
|
266
|
+
|
267
|
+
<head>
|
268
|
+
|
269
|
+
<meta charset="utf-8">
|
270
|
+
|
271
|
+
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
|
272
|
+
|
273
|
+
<meta http-equiv="Content-Security-Policy" content="default-src * data: gap: https://ssl.gstatic.com; style-src * 'unsafe-inline'; script-src * 'unsafe-inline' 'unsafe-eval'">
|
274
|
+
|
275
|
+
<script src="components/loader.js"></script>
|
276
|
+
|
277
|
+
<script src="lib/angular/angular.min.js"></script>
|
278
|
+
|
279
|
+
<script src="lib/onsenui/js/onsenui.min.js"></script>
|
280
|
+
|
281
|
+
<script src="lib/onsenui/js/angular-onsenui.min.js"></script>
|
282
|
+
|
283
|
+
<script src="ext/imageResizer/resize.js"></script>
|
284
|
+
|
285
|
+
<script type="text/javascript" src="func.js"></script>
|
286
|
+
|
287
|
+
<script type="text/javascript" src="promise.js"></script>
|
288
|
+
|
289
|
+
<script type="text/javascript" src="index.js"></script>
|
290
|
+
|
291
|
+
|
292
|
+
|
293
|
+
<link rel="stylesheet" href="components/loader.css">
|
294
|
+
|
295
|
+
<link rel="stylesheet" href="lib/onsenui/css/onsenui.css">
|
296
|
+
|
297
|
+
<link rel="stylesheet" href="lib/onsenui/css/onsen-css-components.css">
|
298
|
+
|
299
|
+
<link rel="stylesheet" href="css/bootstrap-4.0.0-beta-dist/css/bootstrap.min.css">
|
300
|
+
|
301
|
+
<link rel="stylesheet" href="css/selectBox.css">
|
302
|
+
|
303
|
+
<link rel="stylesheet" href="css/style.css">
|
304
|
+
|
305
|
+
</head>
|
306
|
+
|
307
|
+
|
308
|
+
|
309
|
+
<body>
|
310
|
+
|
311
|
+
<ons-navigator id="appNavi" page="common.html"></ons-navigator>
|
312
|
+
|
313
|
+
|
314
|
+
|
315
|
+
<ons-template id="tabNavi1.html">
|
316
|
+
|
317
|
+
<ons-navigator id="tabNavi1" page="kijiCatalog.html"></ons-navigator>
|
318
|
+
|
319
|
+
</ons-template>
|
320
|
+
|
321
|
+
|
322
|
+
|
323
|
+
<ons-template id="tabNavi2.html">
|
324
|
+
|
325
|
+
<ons-navigator id="tabNavi2" page="gazoCatalog.html"></ons-navigator>
|
326
|
+
|
327
|
+
</ons-template>
|
328
|
+
|
329
|
+
|
330
|
+
|
331
|
+
<ons-template id="tabNavi3.html">
|
332
|
+
|
333
|
+
<ons-navigator id="tabNavi3" page="templateEdit.html"></ons-navigator>
|
334
|
+
|
335
|
+
</ons-template>
|
336
|
+
|
337
|
+
|
338
|
+
|
339
|
+
<ons-template id="gazoCatalog" ng-controller="gazoCatalogCtrl">
|
340
|
+
|
341
|
+
<ons-page>
|
342
|
+
|
343
|
+
<ons-list>
|
344
|
+
|
345
|
+
<ons-list-item class="item" ons-lazy-repeat="delegate" modifier="chevron" tappable>
|
346
|
+
|
347
|
+
<ons-row ng-click="openGazoEdit($index)">
|
348
|
+
|
349
|
+
<ons-col width="80px">
|
350
|
+
|
351
|
+
<img class="thumb" ng-src="{{item.src}}" original-src="{{item.orgSrc}}"></img>
|
352
|
+
|
353
|
+
</ons-col>
|
354
|
+
|
355
|
+
<ons-col>
|
356
|
+
|
357
|
+
<header>
|
358
|
+
|
359
|
+
<span class="title">スポニチ越中島にて記..</span>
|
360
|
+
|
361
|
+
<span class="label">{{item.date}}</span>
|
362
|
+
|
363
|
+
</header>
|
364
|
+
|
365
|
+
<p class="etc">W: 1000 x H: 1000</p>
|
366
|
+
|
367
|
+
<span class="etc">{{item.size}}</span>
|
368
|
+
|
369
|
+
<span align="right">
|
370
|
+
|
371
|
+
<input type="checkbox" class="check" name="select">
|
372
|
+
|
373
|
+
</span>
|
374
|
+
|
375
|
+
</ons-col>
|
376
|
+
|
377
|
+
</ons-row>
|
378
|
+
|
379
|
+
</ons-list-item>
|
380
|
+
|
381
|
+
</ons-list>
|
382
|
+
|
383
|
+
</ons-page>
|
384
|
+
|
385
|
+
</ons-template>
|
386
|
+
|
387
|
+
</body>
|
388
|
+
|
389
|
+
|
390
|
+
|
391
|
+
</html>
|
392
|
+
|
393
|
+
```
|
1
タイトルの誤字を訂正
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
コントローラAで取得したデータ非同期的にコントローラBに表示したい
|
1
|
+
コントローラAで取得したデータを非同期的にコントローラBに表示したい
|
test
CHANGED
File without changes
|