Is it possible to import an external library (in this case Tabulator) into GAS? I've tried using the eval() function and it simply says Syntax Error whenever I attempt to use it. Many thanks
Managed to figure it out, since GAS only allows HTML and GS files in the project I had to reference and include the library from a server repository in the html file
Related
So I'm trying to use two different libraries. The first one is #pancakeswap-libs/sdk which requires node to function. The second is lightweight charts which can't run on node (reference https://github.com/tradingview/lightweight-charts/issues/557).
My idea was to import the tradingview library through script in an HTML file and create the chart from an external js file while on node I read the HTML doc and print the result while parsing data using the same HTML file but making the data invisible.
I am kinda lost because I don't understand how should I use the tradingview sdks, what server should I use if it doesn't work with node?
Also, do I need to use typescript to use a typescript library?
I have a JavaScript file that's a generated parser (let's call it MyParser), which I am using in an add-on for Google Forms.
It needs to be used in the client side's Sidebar.html where I'm including it with HtmlService.createHtmlOutputFromFile('MyParser.js').getContent();, which means it must be an .html file as far as I understand. Then it must be used on the server side where I have it in a file MyParser.js.gs.
With my current solution, it's duplicated in my file structure:
Code.gs
MyParser.js.gs
MyParser.js.html
Sidebar.html
Is there a way I can make this work without having two files? Edit: As I understand it, libraries are only for the server side.
If not, any hints to making the updating of the two files more robust (currently it's manual copy/paste)?
Edit: According to the best practices, one must wrap the JavaScript inside a <script> tag inside the .html file:
Notice that the included files contain <style> and <script> tags because they're HTML snippets and not pure .css or .js files.
So it seems it's not easy to have just one file.
As far as I could tell, there's no way to reuse a single file and respect Google's best practices.
My solution, following #tehhowch's advice, was with #google/clasp and doing local development.
To build the parser (in another GitHub project), I use npm-run-script. So, I just appended a && bash makeHTML.sh to the build script.
Inside makeHTML.sh I wrapped the built MyParser.js file in a <script> tag with:
#!/usr/bin/env bash
{ echo "<script>"; cat MyParser.js; echo "</script>"; } > MyParser.js.html
Since I'm using bash it's not a true node.js solution (won't run unless there's bash installed). If someone knows of a better way to pull off the wrapping that's 100% node and doesn't require installing a whole bunch of other modules, feel free to edit the answer.
As your add-on has just few files you might use ScriptApp.getResource(filename).getDataAsString() to get the content of a .gs file and add it to the sidebar HttpOutput object enclosed in <script> tags.
Code.gs
function showSidebar(){
const htmlOutput = HtmlService.createHtmlOutput('<h1>My Sidebar content</h1>');
.append(`<script>${ScriptApp.getResource('JavaScript').getDataAsString()}</script>`);
SpreadsheetApp.showSidebar(htmlOutput,'My Sidebar');
}
JavaScript.gs
To keep things simple, this file should contain only reusable (server-side + cliente-side) JavaScript
function myFunction(){
console.log('My function ran successfully');
}
The above over simplistic code example might be applied to a bit more complex projects and will keep you away from having to use CLASP.
Contrary as happens with .gs and .html files, so far I was unable to make ScriptApp.getResource(filename).getDataAsString() to work to pull reusable JavaScript from .gs files hosted on a Google Apps Script library. Anyway, it's still possible to stay away of CLASP, one option might be to use Advanced Service Google Apps Script API, another might be to host the shared JavaScript and imported from Google Drive or from another host by using Url Fetch service.
Related
Is it possible to read the contents of a Google Apps Script from another Script
HTML and JavaScript from another server?
Server side HTML Form validation?
I improving site performance and for that, I try to Bundle or combine ScriptResource.axd and Webresource.axd but before combine to I need to know javascript file reference name which is used by ajax control toolkit in asp.net web form
like this https://lancezhang.wordpress.com/2008/11/15/aspnet-ajax-performance/
I need ScriptReferenceProfiler.DLL to get a reference of the javascript file which is used in ajax toolkit on the web page.
do you have any idea to get this dll file
I go through this tutorial
https://channel9.msdn.com/Blogs/ASP-NET-Site-Videos/using-script-combining-to-improve-ajax-performance
Or if you have any alternate solution please let me know
The file you looking and reference from the link you add was here : http://aspnet.codeplex.com/releases/view/13356
I can not find it now so I uploaded for you here, both source code and binaries.
http://planethost.gr/so/ScriptReferenceProfiler.zip
http://planethost.gr/so/ScriptReferenceProfilerBinaries.zip
I have a meteor project where I want to include the conversational form framework.
There is a npm package, however it is not properly imported (probably due to some kind of bug). According to the github issue, this:
import cf from 'conversational-form'
does not work, because the export function exports cf.ConversationalForm, not cf (but cf is needed for existing declarations). The form is created and styled, but cannot be addressed in the js.
I was already able to use the framework in a normal html/js/css project, so now I wanted to just include the external script as a workaround.
However, downloading + importing in client/main.js did not work for me.
I've tried:
import '/imports/api/conversational-form.min.js
as well as:
$.getScript
in Meteor.startup.
Do I need to write specific exports in the external .js? I'm far from a professional, so I'm a little hesitant to dissect the external .js.
Any tips on how to simply mimic the html-script-inclusion? Or other ideas on how to get the framework running?
Sincerely, desperate.
Well Meteor allows you many ways to do that, the first ideas that come to my mind are:
Depending on your project structure you can create your own meteor package as a wrapper and internally load the library.
Hardcoding the script tag in you entry point.(Im not sure if this would work to be honest but you can try).
I ended up downloading the script, modifying it to set my options and including it via \imports.
VERY hacky solution, but well, it works...
Meteor allow you to load external library and scope them in all the client
via the /compatibility folder.
Just put the file in there, and it will be scoped automaticaly.
I am trying to use the wonderful Daff library by Paul Fitz in a script designed to bring some version control to a google sheet Im working on. However I can't seem to include the javascript file in the script. I've tried importing it as an html file with tags, and with an eval() call on an external source but both have produced either syntax errors or Undefined Exports errors. Any idea what this means? with a little research I see that this means node.js isn't included? Anyway around this or way to include library in the script? Here is external source.
The Answer Provide by Mr. Fritz himself involved deleting the first line of the file "#!/usr/bin/env node" and then wrapping the entire code in an init function to then call from outside!