From ae75f9317434661e29cb9026a5213991981bcaa1 Mon Sep 17 00:00:00 2001 From: Azgaar Date: Thu, 2 Sep 2021 20:52:03 +0300 Subject: [PATCH 01/12] load dropins from local folder --- index.html | 2 +- libs/dropins.min.js | 2 ++ modules/fonts.js | 25 +++++++++++++------------ modules/save.js | 2 +- 4 files changed, 17 insertions(+), 14 deletions(-) create mode 100644 libs/dropins.min.js diff --git a/index.html b/index.html index 1773ba6c..44869737 100644 --- a/index.html +++ b/index.html @@ -4295,6 +4295,6 @@ - + diff --git a/libs/dropins.min.js b/libs/dropins.min.js new file mode 100644 index 00000000..0745ea4f --- /dev/null +++ b/libs/dropins.min.js @@ -0,0 +1,2 @@ +/*! For license information please see dropins_sdk_v2.js.LICENSE */ +!function(e,o){for(var t in o)e[t]=o[t]}(window,function(e){var o={};function t(n){if(o[n])return o[n].exports;var i=o[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,t),i.l=!0,i.exports}return t.m=e,t.c=o,t.d=function(e,o,n){t.o(e,o)||Object.defineProperty(e,o,{enumerable:!0,get:n})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,o){if(1&o&&(e=t(e)),8&o)return e;if(4&o&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&o&&"string"!=typeof e)for(var i in e)t.d(n,i,function(o){return e[o]}.bind(null,i));return n},t.n=function(e){var o=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(o,"a",o),o},t.o=function(e,o){return Object.prototype.hasOwnProperty.call(e,o)},t.p="",t(t.s=3)}([function(e,o,t){"use strict";t.d(o,"i",function(){return n}),t.d(o,"g",function(){return i}),t.d(o,"e",function(){return r}),t.d(o,"j",function(){return a}),t.d(o,"b",function(){return p}),t.d(o,"d",function(){return u}),t.d(o,"c",function(){return d}),t.d(o,"f",function(){return f}),t.d(o,"k",function(){return h}),t.d(o,"a",function(){return b}),t.d(o,"h",function(){return m});var n,i,r,s=t(1);function a(e,o){return"width="+e+",height="+o+",left="+(window.screenX+((window.outerWidth||document.documentElement.offsetWidth)-e)/2)+",top="+(window.screenY+((window.outerHeight||document.documentElement.offsetHeight)-o)/2)}function c(e,o,t){return""+e+(-1===e.indexOf("?")?"?":"&")+o+"="+t}function l(e){return c(e,"version",encodeURIComponent(Dropbox.VERSION))}function p(e,o){var t,n,i=encodeURIComponent(window.location.protocol+"//"+window.location.host),r=encodeURIComponent(Dropbox.appKey),s=Dropbox.productKey?encodeURIComponent(Dropbox.productKey):null,a=encodeURIComponent(e.linkType||""),p=encodeURIComponent(e._trigger||"js"),u=Boolean(e.multiselect),d=encodeURIComponent(b(e.extensions,"join",function(e){return e.join(" ")})||""),f=Boolean(e.folderselect);o=Boolean(o);var h=Dropbox.baseUrl+"/chooser?origin="+i+"&app_key="+r+"&link_type="+a+"&trigger="+p+"&multiselect="+u+"&extensions="+d+"&folderselect="+f+"&iframe="+o;return void 0!==e.fileselect&&(h=c(h,"fileselect",Boolean(e.fileselect))),void 0!==e.sizeLimit&&(h=c(h,"size_limit",e.sizeLimit)),null!=e.initialNavigation&&(null!=e.initialNavigation.mode&&(h=c(h,"initial_navigation_mode",encodeURIComponent(e.initialNavigation.mode))),null!=e.initialNavigation.role&&(h=c(h,"initial_navigation_role",encodeURIComponent(e.initialNavigation.role))),e.initialNavigation.cursor&&(h=c(h,"initial_navigation_cursor",encodeURIComponent(e.initialNavigation.cursor)))),null!=e.initialViewType&&(h=c(h,"initial_view_type",encodeURIComponent(e.initialViewType))),null!=e.fields&&(h=c(h,"fields",encodeURIComponent("function"==typeof e.fields.join?e.fields.join(" "):void 0))),!1===e.showSignOut&&(h=c(h,"show_sign_out","false")),e.initialNavigationPath&&(h=c(h,"initial_navigation_path",encodeURIComponent(e.initialNavigationPath))),e.requiredPermissions&&(h=c(h,"required_permissions",encodeURIComponent(b(e.requiredPermissions,"join",function(e){return e.join(" ")})||""))),s&&(h=c(h,"product_key",s)),(null===(t=e.suggestions)||void 0===t?void 0:t.experimentGroup)&&(h=c(h,"suggestions_experiment_group",encodeURIComponent(null===(n=e.suggestions)||void 0===n?void 0:n.experimentGroup))),l(h)}function u(){/\bTrident\b/.test(navigator.userAgent)&&null!=document.body&&null==i&&((i=document.createElement("iframe")).setAttribute("id","dropbox_xcomm"),i.setAttribute("src",Dropbox.baseUrl+"/static/api/1/xcomm.html"),i.style.display="none",document.body.appendChild(i))}function d(e){var o={options:Object(s.a)(Object(s.a)({},e),{success:function(t,n){"function"==typeof e.success&&e.success(t,n),r===o&&(r=null)},cancel:function(t){"function"==typeof e.cancel&&e.cancel(t),r===o&&(r=null)}})};return r=o,o}function f(e,o,t){var r,s=JSON.parse(e.data);switch(r=null!=i&&t._popup?i.contentWindow:e.source,void 0!==s.sequence_number&&r.postMessage(JSON.stringify({method:"ack",sequence_number:s.sequence_number}),Dropbox.baseUrl),s.method){case"origin_request":e.source.postMessage(JSON.stringify({method:"origin"}),Dropbox.baseUrl);break;case"ready":if(null!=t.files){var a=void 0;if(t._fetch_url_on_save){for(var c=[],l=0;l0))throw new Error("Old style url as callback is only supported for single files.");r.filename||(r.filename=l(r.url))}}return t};Dropbox.save=function(){for(var e=[],i=0;i=0||i.className.indexOf("dropbox-dropin-default")>=0||i.className.indexOf("dropbox-dropin-disabled")>=0){var o=("function"==typeof n.files?n.files():void 0)||n.files;if(!(null!=o?o.length:void 0))return i.className="dropbox-dropin-btn dropbox-dropin-error",void("function"==typeof n.error&&n.error("Missing files"));Dropbox.save({files:o,success:function(){i.className="dropbox-dropin-btn dropbox-dropin-success","function"==typeof n.success&&n.success()},progress:function(e){i.className="dropbox-dropin-btn dropbox-dropin-progress","function"==typeof n.progress&&n.progress(e)},cancel:function(){"function"==typeof n.cancel&&n.cancel()},error:function(e){i.className="dropbox-dropin-btn dropbox-dropin-error","function"==typeof n.error&&n.error(e)}})}}),i};var u=function(e,o){return" background: "+e+";\n background: -moz-linear-gradient(top, "+e+" 0%, "+o+" 100%);\n background: -webkit-linear-gradient(top, "+e+" 0%, "+o+" 100%);\n background: linear-gradient(to bottom, "+e+" 0%, "+o+" 100%);\n filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='"+e+"', endColorstr='"+o+"',GradientType=0); "},d=document.createElement("style");d.type="text/css";var f=' @-webkit-keyframes rotate {\n from { -webkit-transform: rotate(0deg); }\n to { -webkit-transform: rotate(360deg); }\n }\n\n @keyframes rotate {\n from { transform: rotate(0deg); }\n to { transform: rotate(360deg); }\n }\n\n .dropbox-dropin-btn, .dropbox-dropin-btn:link, .dropbox-dropin-btn:hover {\n display: inline-block;\n height: 14px;\n font-family: "Lucida Grande", "Segoe UI", "Tahoma", "Helvetica Neue", "Helvetica", sans-serif;\n font-size: 11px;\n font-weight: 600;\n color: #636363;\n text-decoration: none;\n padding: 1px 7px 5px 3px;\n border: 1px solid #ebebeb;\n border-radius: 2px;\n border-bottom-color: #d4d4d4;\n '+u("#fcfcfc","#f5f5f5")+"\n }\n\n .dropbox-dropin-default:hover, .dropbox-dropin-error:hover {\n border-color: #dedede;\n border-bottom-color: #cacaca;\n "+u("#fdfdfd","#f5f5f5")+"\n }\n\n .dropbox-dropin-default:active, .dropbox-dropin-error:active {\n border-color: #d1d1d1;\n box-shadow: inset 0 1px 1px rgba(0,0,0,0.1);\n }\n\n .dropbox-dropin-btn .dropin-btn-status {\n display: inline-block;\n width: 15px;\n height: 14px;\n vertical-align: bottom;\n margin: 0 5px 0 2px;\n background: transparent url('"+Dropbox.baseUrl+"/static/images/widgets/dbx-saver-status.png') no-repeat;\n position: relative;\n top: 2px;\n }\n\n .dropbox-dropin-default .dropin-btn-status {\n background-position: 0px 0px;\n }\n\n .dropbox-dropin-progress .dropin-btn-status {\n width: 18px;\n margin: 0 4px 0 0;\n background: url('"+Dropbox.baseUrl+"/static/images/widgets/dbx-progress.png') no-repeat center center;\n -webkit-animation-name: rotate;\n -webkit-animation-duration: 1.7s;\n -webkit-animation-iteration-count: infinite;\n -webkit-animation-timing-function: linear;\n animation-name: rotate;\n animation-duration: 1.7s;\n animation-iteration-count: infinite;\n animation-timing-function: linear;\n }\n\n .dropbox-dropin-success .dropin-btn-status {\n background-position: -15px 0px;\n }\n\n .dropbox-dropin-disabled {\n background: #e0e0e0;\n border: 1px #dadada solid;\n border-bottom: 1px solid #ccc;\n box-shadow: none;\n }\n\n .dropbox-dropin-disabled .dropin-btn-status {\n background-position: -30px 0px;\n }\n\n .dropbox-dropin-error .dropin-btn-status {\n background-position: -45px 0px;\n }\n\n @media only screen and (-webkit-min-device-pixel-ratio: 1.4) {\n .dropbox-dropin-btn .dropin-btn-status {\n background-image: url('"+Dropbox.baseUrl+"/static/images/widgets/dbx-saver-status-2x.png');\n background-size: 60px 14px;\n -webkit-background-size: 60px 14px;\n }\n\n .dropbox-dropin-progress .dropin-btn-status {\n background: url('"+Dropbox.baseUrl+"/static/images/widgets/dbx-progress-2x.png') no-repeat center center;\n background-size: 20px 20px;\n -webkit-background-size: 20px 20px;\n }\n }\n\n .dropbox-saver:hover, .dropbox-chooser:hover {\n text-decoration: none;\n cursor: pointer;\n }\n\n .dropbox-chooser, .dropbox-dropin-btn {\n line-height: 11px !important;\n text-decoration: none !important;\n box-sizing: content-box !important;\n -webkit-box-sizing: content-box !important;\n -moz-box-sizing: content-box !important;\n }\n ";d.styleSheet?d.styleSheet.cssText=f:d.textContent=f,document.getElementsByTagName("head")[0].appendChild(d),setTimeout(n.d,0);var h=function(){document.removeEventListener?document.removeEventListener("DOMContentLoaded",h,!1):document.detachEvent&&document.detachEvent("onreadystatechange",h),Object(n.d)(),s.init()};"interactive"===document.readyState||"complete"===document.readyState?setTimeout(h,0):document.addEventListener?document.addEventListener("DOMContentLoaded",h,!1):document.attachEvent("onreadystatechange",h)}},function(e,o,t){"use strict";t.r(o);var n=t(1),i=t(0),r=function(){function e(e,o){var t=this;this.popupWindow=e,this.onClose=o,this.stopInterval=function(){clearInterval(t.intervalId)},this.isWindowClosedByUser=function(){try{return t.popupWindow.closed}catch(e){}return!1},this.messagingWindow=function(){return void 0!==i.g&&null!==i.g?i.g.contentWindow:t.popupWindow},this.handleInterval=function(){t.isWindowClosedByUser()&&(t.onClose(),t.stopInterval())},this.intervalId=setInterval(this.handleInterval,100)}return e.open=function(o,t,n){var r=Object(i.j)(t.width,t.height)+",resizable,scrollbars",s=window.open(o,"_blank",r);if(null===s)throw new Error("Failed to open the window. Dropbox popups may only be attached to a user-triggered event handler such as a tap or click event.");return s.focus(),new e(s,n)},e}();function s(e){return function(){for(var o=0,t=e;o=0;o--){var t=e[o],n=(t.getAttribute("class")||"").split(" ");n.indexOf("dropbox-saver")>=0?function(e){Dropbox.createSaveButton({files:function(){return[{url:e.getAttribute("data-url")||e.href,filename:e.getAttribute("data-filename")||Object(p.b)(e.pathname)}]}},e)}(t):n.indexOf("dropbox-embed")>=0&&function(e){var o=e.getAttribute("data-url")||e.href;if(o&&e.parentElement){var t=e.getAttribute("data-file-zoom")||void 0,n=e.getAttribute("data-folder-view")||void 0,i=e.getAttribute("data-folder-header-size")||void 0,r=document.createElement("div");r.classList.add("dropbox-embed-container"),r.style.height=e.getAttribute("data-height")||"100%",r.style.width=e.getAttribute("data-width")||"100%",e.parentElement.replaceChild(r,e),Dropbox.embed({link:o,file:{zoom:t},folder:{view:n,headerSize:i}},r)}}(t)}}}();var x=function(){},_=window.Dropbox}])); \ No newline at end of file diff --git a/modules/fonts.js b/modules/fonts.js index fedcbd85..f8d73351 100644 --- a/modules/fonts.js +++ b/modules/fonts.js @@ -52,16 +52,16 @@ function getFontsList(svg) { return [...new Set(fontsInUse)]; } -// code from Kaiido's answer https://stackoverflow.com/questions/42402584/how-to-use-google-fonts-in-canvas-when-drawing-dom-objects-in-svg -function GFontToDataURI(url) { +function convertFontToDataURI(url) { if (!url) return Promise.resolve(); - return fetch(url) // first fecth the embed stylesheet page - .then(resp => resp.text()) // we only need the text of it + return fetch(url) + .then(resp => resp.text()) .then(text => { - let s = document.createElement("style"); - s.innerHTML = text; - document.head.appendChild(s); - const styleSheet = Array.prototype.filter.call(document.styleSheets, sS => sS.ownerNode === s)[0]; + const style = document.createElement("style"); + style.innerHTML = text; + document.head.appendChild(style); + + const styleSheet = document.styleSheets.find(sheet => sheet.ownerNode === style); const FontRule = rule => { const src = rule.style.getPropertyValue("src"); @@ -70,12 +70,12 @@ function GFontToDataURI(url) { }; const fontProms = []; - for (const r of styleSheet.cssRules) { - let fR = FontRule(r); + for (const rule of styleSheet.cssRules) { + let fR = FontRule(rule); if (!fR.url) continue; fontProms.push( - fetch(fR.url) // fetch the actual font-file (.woff) + fetch(fR.url) .then(resp => resp.blob()) .then(blob => { return new Promise(resolve => { @@ -87,7 +87,8 @@ function GFontToDataURI(url) { .then(dataURL => fR.rule.cssText.replace(fR.url, dataURL)) ); } - document.head.removeChild(s); // clean up + + document.head.removeChild(style); // clean up return Promise.all(fontProms); // wait for all this has been done }); } diff --git a/modules/save.js b/modules/save.js index 52f13fef..6754181e 100644 --- a/modules/save.js +++ b/modules/save.js @@ -281,7 +281,7 @@ async function getMapURL(type, options = {}) { const fontsToLoad = usedFonts.filter(font => !webSafe.includes(font)); if (fontsToLoad.length) { const url = "https://fonts.googleapis.com/css?family=" + fontsToLoad.join("|"); - const fontStyle = await GFontToDataURI(url); + const fontStyle = await convertFontToDataURI(url); if (fontStyle) clone.select("defs").append("style").text(fontStyle.join("\n")); } From 2d3f465d689a81d953aafc1823d8c7c4c200405f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gergely=20M=C3=A9sz=C3=A1ros=2C=20Ph=2ED?= Date: Tue, 7 Sep 2021 22:36:09 +0200 Subject: [PATCH 02/12] Cloud support / Dropbox OAuth reference client (#659) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * bioms shouldn't be masked or the style selection box is useless * fix: misleading comment * Fix: calculating absolute flux from precipitation normal-value. * Fix: River automatic rerender on regeneration. * Dropbox OAuth implementation and Cloud framework * add some space * removing unnecessary logs, defer script load Created by: Mészáros Gergely --- dropbox.html | 46 ++++++++++++++ index.html | 32 +++++----- modules/cloud.js | 141 ++++++++++++++++++++++++++++++++++++++++++ modules/load.js | 38 +++++++++--- modules/save.js | 41 +++--------- modules/ui/options.js | 15 ++++- 6 files changed, 256 insertions(+), 57 deletions(-) create mode 100644 dropbox.html create mode 100644 modules/cloud.js diff --git a/dropbox.html b/dropbox.html new file mode 100644 index 00000000..64d578e7 --- /dev/null +++ b/dropbox.html @@ -0,0 +1,46 @@ + + + + + + FMG Dropbox Auth + + + + + diff --git a/index.html b/index.html index 1773ba6c..43eb39d7 100644 --- a/index.html +++ b/index.html @@ -1995,7 +1995,7 @@
Temperature:
- , like in + , like in
@@ -3490,26 +3490,29 @@

Maps are saved in .map format, that can be loaded back via 'Load' in menu. Please keep noted that we do not keep any data on our side. There is no way to restore the progress if .map file is lost. Please keep old .map files on your machine or cloud storage as backups.

-

Saving to Dropbox may not be allowed for big files. In this case open Dropbox, download the .map file and upload it manually.

- -
- Create sharable link - - -
-

GeoJSON format is used in GIS tools such as QGIS. Check out wiki-page for guidance

- -

Generator uses pop-up window to download files. Please ensure your browser does not block popups.

- -

It's also possible to export map to Foundry VTT, see the module.

+

GeoJSON format is used in GIS tools such as QGIS. Check out wiki-page for guidance.

+

Generator uses pop-up window to download files. Please ensure your browser does not block popups.

+

It's also possible to export map to Foundry VTT, see the module.

-

Maps are saved in .map format, that can be loaded back via 'Load' in menu. Please keep noted that we do not keep any data on our side. There is no way to restore the progress if .map file is lost. Please keep old .map files on your machine or cloud storage as backups.

+

Maps are saved in .map format, that can be loaded back via the Load in menu. There is no way to restore the progress if file is lost. Please keep old .map files on your machine or cloud storage as backups.

-
-

From your Dropbox account:

- +
+ From your Dropbox account + - +