From ad944024006ae63f6b7da49d663bd1ba8dacfac4 Mon Sep 17 00:00:00 2001 From: Rick Companje Date: Thu, 25 Jan 2018 16:40:10 +0100 Subject: [PATCH] custom html, favicon and btnExport --- favicon.ico | Bin 0 -> 4286 bytes index.js | 31 ++++++++++++++++++++++- package-lock.json | 62 +++++++++++++++++++++++----------------------- src/index.html | 11 ++++++++ webpack.config.js | 7 +++--- 5 files changed, 75 insertions(+), 36 deletions(-) create mode 100644 favicon.ico create mode 100644 src/index.html diff --git a/favicon.ico b/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..921abddd2c44ae7f4c0bfb994e33291bf2d82c0a GIT binary patch literal 4286 zcma)930Rd?8oo{Sn3yOcAUj-^L{vsmz_bBz6y#n&Ru>j|LJ){uwm=ZsH(7<;Vo4}X zAw+N`AQZz5B3znW63eC35f{iCq&^%LL$cf(xOL&`PKyq!H{0(_UULJky*7A)b&<*h(lO zq!1zq&IDt^8^ZcOYiWKZ;UeKxR85mU!hY(j6WU(2;ib9l^gKh@FSInqcynrMYC=*{ z5~NZaIJ-C?BQp&RhZ=D6=1pMY{+>mW`R4C8p_FzS+qP!!Y+iCF*?6qL~1+|2f)p`ig& zrpRH2o;qBuO@V740UbHN!PH0> zIG2sb%}JwpGScsBNhUe6FhsKWxh{f|k`k_5xgy9wLIVQ>1JKqMbKOsxG>PlW)YKFj z8XAz1nSeOY8q|;s#UU4OZiI4oJR z1c8Bpi1o1oE)}Aozz^?;)$pkKg`TU@Js~SAi>XtmLSI`A3rH4AGeg{ON(R#nI<`P+ zJ`@V z=q^Chjt`)&qJUqHCvqRC*zCrAgxOeEtc|iHcdU2)2UaaNA$w%=H8~+tI61qHu!k4x z_&-`@fMi(qtxQMTzKT;&HZ{I%1%ga+7 zs6kUxlS5ryo$FF|q8zgPzCyU`ZtgpAadD7X%mTj6#pV66&{9`H*B(l@q+7;+#*7)G z{$*xnhRyyGs8Am0-1}lpQRE8P**OUOnf-6E2j-JwF*G!Ur%#{4+S;0Ok_$eGxec+l zE`oxBV7=8CEoo2%A;;k{OKYjBm_&$3`pNwaQEmYXsRlr zWe4#meN-fQKu%5$D_5?BmX;RAj~`DuRmEp%UKnntm^_yQi+TEF@BC3V#l^+k_7ljz zSRR};YZjQ^m>w0Ts3Odz9ChUX1%aJp7j5L^LEc>$q*N*KLHm z#0&;vW%7SzSeQ&l8Tll$JBz>T2RA~V;_u9vGo$=HJv}*pC-X4m1+*i?u@u2hrPx6B zE{*&N^~pnMNEwE+c@(!l%fVs|Mf}=EG2NDd8TuO78cY66^7IoA#%thI2Kw8mBvW1j zz4xOpH}iPe;9<%08q0YC`TP5G{%%V*;>4C=98G@#mUBOk??c+UMwrdC<+-r6wG|gG zT!4ILKJ|Ag{XZ9d0rT2)oW_p#X4R8z*S`UGBYj19GrA4yji%C!PN zp&cL{;hS9SN_58r85!*|T!B@1WX^!0q8ws6k9ji+dWX6*ou@lfRUemGK(N z?uM*(UcP)8XU?AGceJZluYuiZUZOAQ*_rTPcWJh!va%A&q@!ed_qC-v@WIcw;CB2l z>_6TC>9%4x?cWRcQ>_T;dx+r2|Azm~>+tS64~NgHV3V2xX;2_M3Ay?C=<4diwQJYF za`*qBUugV8uKW@GS5#CWIwl5QRPX%@@)0u7hlpoS5joh8pu0a|E%A1&tblb^I_!6D zgJabv@N8{DFv&>~fH*=7hOzG34%lulfh0Ev%fmxqANT>>Nv?$CWW><lQ3 zYxW`V&X0&BJu;c2NDhYs)i`p5J{_pWt|wm1<|D*A?5?n8%^Fx*S;1~Y7;H(`PPNro zM>_Dm`W@D`pM*>8e%O)zC53rhKKJJ1@VU@Qe4c{6b7=29_c? zJCGmP6y@W+h;S^YaX*qXhHS l7EL1F;|Q;f;IBmavw30f>om#EVqpD0P$G>C5pY8!`VR}!!)X8j literal 0 HcmV?d00001 diff --git a/index.js b/index.js index 84f82ae..23019f4 100644 --- a/index.js +++ b/index.js @@ -11,6 +11,7 @@ import thunkMiddleware from 'redux-thunk'; import promiseMiddleware from 'redux-promise-middleware'; import { createLogger } from 'redux-logger'; import sketcherReducer from './src/reducer/index.js'; + const reducer = combineReducers({ sketcher: sketcherReducer }); const enhancer = compose(applyMiddleware(thunkMiddleware, promiseMiddleware(), createLogger({ collapsed: true }))); const store = createStore(reducer, enhancer); @@ -23,6 +24,12 @@ import { saveAs as saveAsLib } from 'file-saver'; // download file import { createFile } from './src/utils/exportUtils.js'; +import sketchDataToJSON from './src/shape/sketchDataToJSON.js'; +import { JSONToBlob } from './src/utils/binaryUtils.js'; + +import keycode from 'keycode'; +import btnExportURL from './img/corner/btnExport.png'; + window.downloadStl = () => { store.dispatch(async (dispatch, getState) => { const state = getState(); @@ -31,6 +38,23 @@ window.downloadStl = () => { }); }; +window.downloadSketch = () => { + store.dispatch( (dispatch, getState) => { + const state = getState(); + const json = sketchDataToJSON(state.sketcher.present); + const blob = JSONToBlob(json); + saveAsLib(blob, 'doodle.d3sketch'); + }); +}; + +window.addEventListener('keydown',(event) => { + // downloadSketch + const key = keycode(event); + if (key=='s') downloadSketch(); + console.log(event.shiftKey, key); +}); + + // add model to store import modelData from './models/circle_error.d3sketch'; import JSONToSketchData from './src/shape/JSONToSketchData.js'; @@ -64,9 +88,14 @@ async function init() { await new Promise(resolve => document.addEventListener('deviceready', resolve, false)); } + console.log(btnExportURL); + render(( - + + +
+
), document.getElementById('app')); } diff --git a/package-lock.json b/package-lock.json index 9d2f26e..3db3187 100644 --- a/package-lock.json +++ b/package-lock.json @@ -62,6 +62,16 @@ "pepjs": "0.4.3" } }, + "JSONStream": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.1.tgz", + "integrity": "sha1-cH92HgHa6eFvG8+TcDt4xwlmV5o=", + "dev": true, + "requires": { + "jsonparse": "1.3.1", + "through": "2.3.8" + } + }, "abbrev": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", @@ -1703,9 +1713,9 @@ "integrity": "sha1-+GzWzvT1MAyOY+B6TVEvZfv/RTE=", "dev": true, "requires": { + "JSONStream": "1.3.1", "combine-source-map": "0.7.2", "defined": "1.0.0", - "JSONStream": "1.3.1", "through2": "2.0.3", "umd": "3.0.1" } @@ -1733,6 +1743,7 @@ "integrity": "sha1-CJo0Y69Y0OSNjNQHCz90ZU1avKk=", "dev": true, "requires": { + "JSONStream": "1.3.1", "assert": "1.4.1", "browser-pack": "6.0.2", "browser-resolve": "1.11.2", @@ -1754,7 +1765,6 @@ "https-browserify": "1.0.0", "inherits": "2.0.3", "insert-module-globals": "7.0.1", - "JSONStream": "1.3.1", "labeled-stream-splicer": "2.0.0", "module-deps": "4.1.1", "os-browserify": "0.1.2", @@ -5365,15 +5375,6 @@ } } }, - "string_decoder": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.1.tgz", - "integrity": "sha1-YuIA8DmVWmgQ2N8KM//A8BNmLZg=", - "dev": true, - "requires": { - "safe-buffer": "5.0.1" - } - }, "string-width": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", @@ -5385,6 +5386,15 @@ "strip-ansi": "3.0.1" } }, + "string_decoder": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.1.tgz", + "integrity": "sha1-YuIA8DmVWmgQ2N8KM//A8BNmLZg=", + "dev": true, + "requires": { + "safe-buffer": "5.0.1" + } + }, "stringstream": { "version": "0.0.5", "resolved": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.5.tgz", @@ -6420,10 +6430,10 @@ "integrity": "sha1-wDv04BywhtW15azorQr+eInWOMM=", "dev": true, "requires": { + "JSONStream": "1.3.1", "combine-source-map": "0.7.2", "concat-stream": "1.5.2", "is-buffer": "1.1.5", - "JSONStream": "1.3.1", "lexical-scope": "1.2.0", "process": "0.11.10", "through2": "2.0.3", @@ -7035,16 +7045,6 @@ "integrity": "sha1-T9kss04OnbPInIYi7PUfm5eMbLk=", "dev": true }, - "JSONStream": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.1.tgz", - "integrity": "sha1-cH92HgHa6eFvG8+TcDt4xwlmV5o=", - "dev": true, - "requires": { - "jsonparse": "1.3.1", - "through": "2.3.8" - } - }, "jsprim": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", @@ -8139,6 +8139,7 @@ "integrity": "sha1-IyFYM/HaE/1gbMuAh7RIUty4If0=", "dev": true, "requires": { + "JSONStream": "1.3.1", "browser-resolve": "1.11.2", "cached-path-relative": "1.0.1", "concat-stream": "1.5.2", @@ -8146,7 +8147,6 @@ "detective": "4.7.0", "duplexer2": "0.1.4", "inherits": "2.0.3", - "JSONStream": "1.3.1", "parents": "1.0.1", "readable-stream": "2.3.3", "resolve": "1.5.0", @@ -12912,14 +12912,6 @@ "integrity": "sha1-J5siXfHVgrH1TmWt3UNS4Y+qBxM=", "dev": true }, - "string_decoder": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", - "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", - "requires": { - "safe-buffer": "5.1.1" - } - }, "string-length": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/string-length/-/string-length-1.0.1.tgz", @@ -12968,6 +12960,14 @@ "integrity": "sha1-aybpvTr8qnvjtCabUm3huCAArHg=", "dev": true }, + "string_decoder": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.0.3.tgz", + "integrity": "sha512-4AH6Z5fzNNBcH+6XDMfA/BTt87skxqJlO0lAh3Dker5zThcAxG6mKz+iGu308UKoPPQ8Dcqx/4JhujzltRa+hQ==", + "requires": { + "safe-buffer": "5.1.1" + } + }, "stringstream": { "version": "0.0.5", "resolved": "https://registry.npmjs.org/stringstream/-/stringstream-0.0.5.tgz", diff --git a/src/index.html b/src/index.html new file mode 100644 index 0000000..e217ba7 --- /dev/null +++ b/src/index.html @@ -0,0 +1,11 @@ + + + + + + Doodle3D Transform + + +
+ + diff --git a/webpack.config.js b/webpack.config.js index 22b7fc5..051cd28 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -80,10 +80,9 @@ module.exports = { }), new HTMLWebpackPlugin({ title: 'Doodle3D Core - Simple example', - template: require('html-webpack-template'), - inject: false, - scripts: appMode ? ['cordova.js'] : null, - appMountId: 'app' + template: 'src/index.html', + favicon: 'favicon.ico', + inject: true, }), new GoogleFontsPlugin({ fonts: [