• R/O
  • SSH
  • HTTPS

Commit

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

JavaScriptを色々あれこれしようとするがひたすら失敗を繰り返している


Commit MetaInfo

Revision3 (tree)
Time2016-11-12 11:27:11
Authortakoyaki_umaaaa

Log Message

File保存対応

displayField の innerHTMLを Blobとして downloadする
アプリの性質上 表示データは全て data schemeなので情報が失われない

Change Summary

Incremental Difference

--- HtmlDrawApp/src/UI_thread.js (revision 2)
+++ HtmlDrawApp/src/UI_thread.js (revision 3)
@@ -34,6 +34,9 @@
3434 for( let cnt=0; cnt < palButtonlist.length; cnt++ ){
3535 palButtonlist[cnt].addEventListener( 'click', onClickPalButton, false );
3636 }
37+
38+ let savelink = document.getElementById('save');
39+ savelink.addEventListener('click', onClickSaveLink, false);
3740
3841
3942
@@ -142,8 +145,24 @@
142145
143146
144147
148+ // DisplayField 領域の innerHTMLを Blobとして保存
149+ function onClickSaveLink (evt) {
150+ debuglog('onClickSaveLink');
151+ let displayInfo = window.displayField.DOMobject.innerHTML;
152+
153+ let blob = new Blob([displayInfo], {type: "text/plain"});
154+ let a = document.createElement('a');
155+ a.href = URL.createObjectURL(blob);
156+ a.target = '_blank';
157+ a.download = 'filename.txt'; // Edgeは無効……
158+ a.click();
159+
160+ // URL.revokeObjectURL();
161+ };
145162
163+ function onClickPalButton (evt) {
164+ debuglog('onClickPalButton');
165+ };
146166
147167
148-
149168 })();
--- HtmlDrawApp/src/index.html (revision 2)
+++ HtmlDrawApp/src/index.html (revision 3)
@@ -83,6 +83,7 @@
8383 <button type=button class="pal" data-objid="pal" data-palid="2" data-value="0000ff01">button3</button>
8484 <button type=button class="pal" data-objid="pal" data-palid="3" data-value="ffffff01">button4</button>
8585 <button type=button class="pal" data-objid="pal" data-palid="4" data-value="00000000">button5</button>
86+ <a href="#" id="save">Save</a>
8687
8788
8889 <script type="text/javascript" src="Common.js"></script>