Skip to content
This repository has been archived by the owner on Oct 17, 2019. It is now read-only.

Commit

Permalink
fix: Androidで正常に投稿できない問題
Browse files Browse the repository at this point in the history
* Android/PCの時は同時アップロードに対応した
  • Loading branch information
nzws committed Sep 4, 2018
1 parent 948916e commit db06c9b
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 10 deletions.
4 changes: 4 additions & 0 deletions www/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -942,3 +942,7 @@ img.emoji {
white-space: nowrap;
text-overflow: ellipsis;
}

.media-upload_simple {
height: 60px;
}
5 changes: 3 additions & 2 deletions www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,8 @@ <h4 id="splitter-profile-name" class="acct-small" style="height: 20px"></h4>
<input type="hidden" id="localonly_input_simple">
<input type="hidden" id="post_mode_simple" value="public">
<input type="hidden" id="post_reply_simple">
<input type="file" id="post_file_simple" class="invisible" onchange="up_file(true)" accept="image/*;capture=camera">
<input type="file" id="post_file_simple" class="invisible" onchange="up_file(true, true)" accept="image/*;capture=camera"
multiple>
<ons-list>
<ons-list-item style="padding-left: 0" class="simple-toot">
<div class="left" style="padding-right: 6px">
Expand Down Expand Up @@ -1407,7 +1408,7 @@ <h4><span data-i18n="config.notification.keyword.title">キーワード検知</s
<input type="hidden" id="localonly_input">
<input type="hidden" id="post_mode" value="public">
<input type="hidden" id="post_reply">
<input type="file" id="post_file" class="invisible" onchange="up_file()" accept="image/*;capture=camera">
<input type="file" id="post_file" class="invisible" onchange="up_file(null, true)" accept="image/*;capture=camera" multiple>
<ons-button modifier="quiet" onclick="up_file()" style="border-radius: 0" id="new_up_bt">
<ons-icon icon="fa-picture-o"></ons-icon>
</ons-button>
Expand Down
47 changes: 39 additions & 8 deletions www/js/toot_new.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,45 @@ function post_vote() {
}
}

function up_file(simple) {
function up_file(simple, isInput) {
var simple_id = '';
if (simple) image_mode = simple_id = '_simple';
else image_mode = simple_id = '';
var card = document.getElementsByClassName('media-upload' + simple_id);
if (card.length >= 4) {
showtoast('maximum-media');
} else {
navigator.camera.getPicture(up_file_onSuccess, file_error, {
quality: 100,
destinationType: Camera.DestinationType.FILE_URI,
sourceType: Camera.PictureSourceType.PHOTOLIBRARY,
encodingType: 1,
});
if (isInput) {
var files = elemId('post_file' + simple_id).files;
if (card.length + files.length > 4) {
showtoast('maximum-media');
} else {
var i = 0,
images = [];
while (files[i]) {
var reader = new FileReader();
reader.onload = function(fileData) {
images.push(fileData.target.result.split(',')[1]);
if (files.length === images.length) {
up_file_suc(images, null);
}
};
reader.readAsDataURL(files[i]);
i++;
}
}
} else {
if (platform === 'ios') {
navigator.camera.getPicture(up_file_onSuccess, file_error, {
quality: 100,
destinationType: Camera.DestinationType.FILE_URI,
sourceType: Camera.PictureSourceType.PHOTOLIBRARY,
encodingType: 1,
});
} else {
elemId('post_file' + simple_id).click();
}
}
}
}

Expand All @@ -71,6 +96,12 @@ function up_file_onSuccess(URI) {
function up_file_suc(base64, mode_blob) {
var blob;
if (base64 || mode_blob) {
if (Array.isArray(base64)) {
var arr = base64;
if (!base64[0]) return;
base64 = base64[0];
arr.shift();
}
show('now_loading');
if (base64) {
var binary = atob(base64);
Expand Down Expand Up @@ -110,13 +141,13 @@ function up_file_suc(base64, mode_blob) {
json['id'] +
"'></ons-card>" +
elemId('image_list' + image_mode).innerHTML;
image_mode = '';
hide('now_loading');
} else {
hide('now_loading');
showtoast('cannot-pros');
}
}
if (arr) up_file_suc(arr);
})
.catch(function(error) {
catchHttpErr('media', error);
Expand Down

0 comments on commit db06c9b

Please sign in to comment.