« 2017年04月 | メイン | 2017年06月 »
2017年05月18日
ダウンロードプログレッシブバー
アップロードのプログレッシブバーは簡単にできるようになっている。
$.ajax({
中略
xhr: function() {
var XHR = $.ajaxSettings.xhr();
if (XHR.upload) {
XHR.upload.addEventListener(
'progress',
function(e) {
var progre = parseInt(e.loaded / e.total * 10000) / 100;
console.log( progre + "%");
}, false);
}
return XHR;
},
ダウンロードができねえ。そうアップロードのときのようには出来ない。
なので ファイルをダウンロードさせるのに直接ファイルをダウンロードさせずに、
プログラムをかます。その際どの程度ファイルを投げたかをサーバー内のファイルに記載
そのデータを表側のjavascriptでsettimeoutでなんども取得して画面に進捗表示する。
filesize にてファイルのサイズ取得
$handle = fopen($path, "rb");
$downloadedsize = 0;
while(!feof($handle))
{
print fread($handle, 4096);
$downloadedsize +=
4096;
んでここにてナンパーか計算して外部ファイルに記述
ob_flush();
flush();
}
fclose();
と思ったが、調べてみると出来た・・・ $.ajax({ url: "depth.txt", type: 'GET', dataType: "text", cache: true, success: function(data) { lists = CSVToArray(data); google.maps.event.addListener(map, 'bounds_changed', showPointFunc); $("body").css({ opacity: 1 }); }, error: function(XMLHttpRequest, textStatus, errorThrown) { var mess; console.error("XMLHttpRequest : " + XMLHttpRequest.status); console.error("textStatus : " + textStatus); console.error("errorThrown : " + errorThrown.message); if (textStatus === "timeout") { mess = "タイムアウトしました。低速回線の場合タイム・アウトする可能性があります。何度施行しても状況が変わらない場合、システム管理者に連絡してください"; } else { mess = "データ読み込みでエラー発生"; } alert(mess); return; }, xhr: function() { // get the native XmlHttpRequest object var xhr = $.ajaxSettings.xhr(); xhr.onprogress = function(e) { console.log(e.loaded / e.total); }; return xhr; } });
投稿者 muuming : 17:48
2017年05月10日
smarty array_key__exist
{if $key|array_key_exists:$array)}
投稿者 muuming : 12:31
2017年05月01日
更新系のテーブル構造
create table hoge(
id serial not null,
item_id serial not null,
item_editor_id int not null,
item_name text,
instime timestamp not null default now()
);
更新の場合はitem_id指定して、新規登録の場合はitem_idおまかせでinsert
insert into hoge("item_id","item_editor_id","item_name")values($item_id,$item_editor_id,'itemname');
insert into hoge("item_editor_id","item_name")values(,$item_editor_id,'itemname');
情報取得時はidが一番大きいものを取得
select * from hoge as a where id = (select id from hoge as s where s.item_id = a.item_id order by s.item_id desc limit 1);
ビューを作っておきましょう
create view items
-> as select item_id, item_name,instime from hoge as a
-> where id = (select id from hoge as s where s.item_id = a.item_id order by s.item_id desc limit 1);
投稿者 muuming : 08:31