I'm trying to create a custom function calling method from Excel.js API. I have followed the Excel custom function tutorial.
But I always obtained the error value #VALUE! on the worksheet, and this error on the debug:
Verbose Runtime [Console] [Log] Unexpected CustomFunctions [Execution] [End] [Failure] [ExceptionThrown] Function=EXTRACTFORM ReferenceError: 'Excel' is not defined {}
Unexpected CustomFunctions [Execution] [Async] [End] [Failure] Function=EXTRACTFORM, Workbook=Book1.xlsx
I'm using the following code:
For the description file:
{
"functions": [
{
"id": "EXTRACTFORM",
"name": "EXTRACTFORM",
"description": "Extract formData from relaunch button",
"result": {
"type": "string",
"dimensionality": "scalar"
},
"parameters": [
{
"name": "address",
"description": "",
"type": "string",
"dimensionality": "scalar"
}
]
}
]
}
js source:
function run(address) {
var context = new Excel.RequestContext();
var range = context.workbook.worksheets.getActiveWorksheet().getRange(address);
range.load();
return context.sync()
.then(function() {
return range.values[0][0];
});
}
CustomFunctions.associate("EXTRACTFORM", run);
And html:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
<meta http-equiv="Expires" content="0" />
<title>"Custom Functions Upgrade Test"</title>
<script src="https://appsforoffice.microsoft.com/lib/1.1/hosted/custom-functions-runtime.js" type="text/javascript"></script>
<script src="./extractForm.js" type="text/javascript"></script>
</head>
<body>
<h1>"Custom function"</h1>
</body>
</html>
Thank you for your help !
In order to make custom function to call Excel.js API method, you need to configure your add-in to use shared runtime. And please note there are some limitations to call Office.js through a custom function.
Related
I´m trying to use leaftlet search but it doesnt find the markers.
The markers are populated on the map as it should be, but the search wont work.
I have a freg.js file where I have the information to create markers, and I want to search using propertie "maclora" for example:
var freg_palmela = {
"type": "FeatureCollection",
"name": "freg_palmela",
"crs": { "type": "name", "properties": { "name":
"urn:ogc:def:crs:OGC:1.3:CRS84" } },
"features": [
{ "type": "Feature", "properties": { "maclora":
"0004A30B00FB82F0", "serial_num": "2,02103E+14", "freguesias":
"Freguesia de PALMELA", "model": "OCTANS 40", "latitude":
"38.569244417", "longitude": "-8.88123655", "pt":
"PT1508D2052900", "instalation_date": "11/04/2022", "last_ul":
"21/06/2022 05:55", "last_jr": "20/06/2022 21:13", "last_ja":
"20/06/2022 21:13", "last_rssi": "-109", "last_snr": "5,8",
"jr_rssi": "-111,52", "jr_snr": "0,09", "Issue": "Ok" },
"geometry": { "type": "Point", "coordinates": [ -8.88123655,
38.569244417 ] } },
On the .html file the code I have there is
var fregData = L.geoJSON(freg_palmela, {
style: function (feature) {
return feature.properties.style;
},
onEachFeature: function (feature, layer) {
layer.bindPopup('<b>MacloRa: ' +
feature.properties.maclora +
'<br>Serial Number: ' +
'<small>' +
feature.properties.serial_num +
'<br>Model: ' +
feature.properties.model +
'<br>Last UL: ' +
+feature.properties.last_ul +
'<br>Last JR: ' +
feature.properties.last_jr +
'<br>Last JA ' +
feature.properties.last_ja
);
layer.on('mouseover',function(ev) {
ev.target.openPopup();
});
layer.on('mouseout',function(ev) {
ev.target.closePopup();
});
}
}).addTo(map);
var overlays = {
"Palmela":fregData
};
L.control.search({
layer: fregData,
initial: false,
propertyName: 'maclora',
buildTip: function(text, val) {
var type = val.layer.feature.properties.maclora;
return '<a href="#" class="'+type+'">'+text+'<b>'+type+'</b>
</a>';
}
})
.addTo(map);
I assumed you're using leaflet-search.
The problem is in the referenced layer option. It should point to the geojson variable. In short, layer: overlays, should be layer: fregData,.
For a working example - based on the provided code -, please see this fiddle.
Update: example with data in separate js file
What I did:
I put the two files below (data.js and index.html) in a folder (my-map).
Navigated to the folder on my commandline (cd my-map)
Ran a local webserver (e.g php -S localhost:3456).
What I see:
When I visit localhost:3456 in my browser, the page loads without errors. If I type '00' in the search widget, the feature with number '0004A30B00FB82F0' is found. On click the marker is highlighted with a red circle (as demonstrated in the fiddle above).
data.js file:
var freg_palmela = {
"type": "FeatureCollection",
"name": "freg_palmela",
"crs": {
"type": "name", "properties": {
"name":
"urn:ogc:def:crs:OGC:1.3:CRS84"
}
},
"features": [
{
"type": "Feature", "properties": {
"maclora": "0004A30B00FB82F0", "serial_num": "2,02103E+14",
"freguesias": "Freguesia de PALMELA", "model": "OCTANS 40",
"latitude": "38.569244417", "longitude": "-8.88123655",
"pt": "PT1508D2052900", "instalation_date": "11/04/2022",
"last_ul": "21/06/2022 05:55", "last_jr": "20/06/2022 21:13",
"last_ja": "20/06/2022 21:13", "last_rssi": "-109",
"last_snr": "5,8", "jr_rssi": "-111,52",
"jr_snr": "0,09", "Issue": "Ok"
},
"geometry": {
"type": "Point", "coordinates": [-8.88123655, 38.569244417]
}
},
]
}
index.html file:
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Map</title>
<link rel="stylesheet" type="text/css" href="https://unpkg.com/leaflet#1.8.0/dist/leaflet.css">
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/leaflet-search#3.0.2/dist/leaflet-search.min.css">
<style>
#map {
height: 280px;
}
</style>
</head>
<body>
<div id="map"></div>
</body>
<script type="text/javascript" src="https://unpkg.com/leaflet#1.8.0/dist/leaflet.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/leaflet-search#3.0.2/dist/leaflet-search.src.min.js"></script>
<script type="text/javascript" src="data.js"></script>
<script>
var map = L.map('map').setView([38.6, -8.9], 10);
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: 19,
attribution: '© OpenStreetMap'
}).addTo(map);
var fregData = L.geoJSON(freg_palmela, {
onEachFeature: function (feature, layer) {
layer.bindPopup('<b>MacloRa: ' +
feature.properties.maclora +
'<br>Serial Number: ' +
'<small>' +
feature.properties.serial_num +
'<br>Model: ' +
feature.properties.model +
'<br>Last UL: ' +
+feature.properties.last_ul +
'<br>Last JR: ' +
feature.properties.last_jr +
'<br>Last JA ' +
feature.properties.last_ja
);
layer.on('mouseover',function(ev) {
ev.target.openPopup();
});
layer.on('mouseout',function(ev) {
ev.target.closePopup();
});
}
}).addTo(map);
L.control.search({
layer: fregData,
initial: false,
propertyName: 'maclora',
buildTip: function(text, val) {
var type = val.layer.feature.properties.maclora;
return '' + text + '<b>' + type + '</b>';
}
}).addTo(map);
</script>
</html>
I am making a Chrome Extension in which I need to display some videos from YouTube.
The Chrome Extension works as follows. The action button starts a timer. When the timer completes, a new tab appears showing a random video from a list of YouTube videos.
To have control over these videos, and to be able to use the video player controls, I need to include the iFrame player API, but after trying several options I keep getting the same error:
Refused to load the script 'https://www.youtube.com/iframe_api'
because it violates the following Content Security Policy directive:
"script-src 'self'". Note that 'script-src-elem' was not explicitly
set, so 'script-src' is used as a fallback.
The relevant code is as follows:
event.js:
function openNCprojectVideo() {
chrome.tabs.create({url: "ncproject.html"});
}
This code activates when the timer ends.
ncproject.html:
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>NC Project Video</title>
<link rel="stylesheet" href="assets/templates/css/ncproject.css">
</head>
<body class="bg-gradient">
<!-- VIDEO PLAYER -->
<div id="player"></div>
<script src="assets/templates/js/ncproject.js"></script>
</body>
</html>
ncproject.js:
var tag = document.createElement('script');
tag.src = "https://www.youtube.com/iframe_api";
var firstScriptTag = document.getElementsByTagName('script')[0];
firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
var player;
function onYouTubeIframeAPIReady() {
player = new YT.Player('player', {
height: '390',
width: '640',
videoId: 'FfwtA2nS2ik',
playerVars: {
'playsinline': 1
},
events: {
'onReady': onPlayerReady,
'onStateChange': onPlayerStateChange
}
});
}
function onPlayerReady(event) {
event.target.playVideo();
}
var done = false;
function onPlayerStateChange(event) {
if (event.data == YT.PlayerState.PLAYING && !done) {
setTimeout(stopVideo, 6000);
done = true;
}
}
function stopVideo() {
player.stopVideo();
}
Manifest:
{
"name": "NC Project",
"description": "A chair yoga google chrome extension for everyone",
"version": "1.0",
"manifest_version": 3,
"background": {
"service_worker": "event.js"
},
"action": {
"default_title": "NC Project",
"default_icon": "images/icon32.png"
},
"icons": {
"16": "images/icon16.png",
"48": "images/icon48.png",
"128": "images/icon128.png"
},
"permissions": [
"alarms",
"idle",
"notifications",
"tabs",
"storage"
],
"host_permissions": [
"<all_urls>"
],
"options_ui": {
"page": "options.html",
"open_in_tab": true
}
}
I have reviewed several posts related to this same issue, but in none of them I have found a satisfactory solution. Thanks in advance for your help.
I have an angular app running on angular 7 and i'm trying to turn it on PWA, i installed pwa 0.6.8 and everything is working (in localhost) except the add to home screen who doesn't show up when i am running it on galaxy S5 from the google dev tolls
When i run the audit it says that it is installable for the user :
Result of the audit
here is my index.html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>BSJP</title>
<base href="/">
<meta name="viewport" content="width=device-width, initial-
scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500" rel="stylesheet">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link rel="stylesheet" href="https://unpkg.com/leaflet#1.4.0/dist/leaflet.css"
integrity="sha512-puBpdR0798OZvTTbP4A8Ix/l+A4dHDD0DGqYW6RQ+9jxkRFclaxxQb/SJAWZfWAkuyeQUytO7+7N4QKrDh+drA=="
crossorigin=""/>
<link rel="manifest" href="manifest.json">
<link rel="icon" type="image/png" sizes="144x144" href="assets/icons/icon-144x144.png">
<meta name="theme-color" content="#1976d2">
</head>
<body>
<app-root></app-root>
<script src="https://unpkg.com/leaflet#1.4.0/dist/leaflet.js"
integrity="sha512-QVftwZFqvtRNi0ZyCtsznlKSWOStnDORoefr1enyq5mVL4tmKB3S/EnC3rRJcxCPavG10IcrVGSmPh6Qw5lwrg=="
crossorigin=""></script>
</body>
</html>
my manifest :
{
"name": "mvp-front",
"short_name": "BouffeSqueJtePrepare",
"theme_color": "#1976d2",
"background_color": "#fafafa",
"display": "standalone",
"scope": "/",
"start_url": "/index.html",
"icons": [
{
"src": "assets/icons/icon-72x72.png",
"sizes": "72x72",
"type": "image/png"
},
{
"src": "assets/icons/icon-96x96.png",
"sizes": "96x96",
"type": "image/png"
},
{
"src": "assets/icons/icon-128x128.png",
"sizes": "128x128",
"type": "image/png"
},
{
"src": "assets/icons/icon-144x144.png",
"sizes": "144x144",
"type": "image/png"
},
{
"src": "assets/icons/icon-152x152.png",
"sizes": "152x152",
"type": "image/png"
},
{
"src": "assets/icons/icon-192x192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "assets/icons/icon-384x384.png",
"sizes": "384x384",
"type": "image/png"
},
{
"src": "assets/icons/icon-512x512.png",
"sizes": "512x512",
"type": "image/png"
}
]
}
and ngsw.config.json
{
"index": "/index.html",
"assetGroups": [
{
"name": "app",
"installMode": "prefetch",
"resources": {
"files": [
"/favicon.ico",
"/index.html",
"/*.css",
"/*.js"
]
}
}, {
"name": "assets",
"installMode": "lazy",
"updateMode": "prefetch",
"resources": {
"files": [
"/assets/**",
"/*.(eot|svg|cur|jpg|png|webp|gif|otf|ttf|woff|woff2|ani)"
]
}
}
]
}
what am i missing ?
Thank you
A web app can only be added to a homescreen when the site is visited at least twice, with at least five minutes between visits.
This guide tells you how you can simulate those events for development: https://developers.google.com/web/tools/chrome-devtools/progressive-web-apps
Add to home screen will appear if your application fullfills following criteria
manifest.json
app hosted over https server : eg: you can use netlify
service worker with atleast one fetch event.
You can find the entire code for it at
https://github.com/rohan12patil/pwa/tree/A2HS
demo at
https://newpwa.netlify.com
The code is basic & you can easily understand & integrate in your angular app
I would suggest you to try to host the project in Firebase (you can also choose another provider).
It is free and it gives already HTTPS out of the box. You can create a project in Firebase and deploy the solution in less than 10 minutes. Then you can test for real with any mobile device whether you app prompts for a A2HS.
I started writing a series of articles about PWAs, if you are interested to learn more about it you can have a look. The second post covers exactly the A2HS topic: How to install a PWA on a user's device.
I am getting error "resource view/View1.view.xml could not be loaded from resources/view/View1.view.xml" when I try to load a view from folder "view".
Folder structure in WebIDE is as in below picture.
index.html
<!DOCTYPE HTML>
<html>
<head>
<script id="sap-ui-bootstrap"
src="resources/sap-ui-core.js"
data-sap-ui-libs="sap.m"
data-sap-ui-theme="sap_bluecrystal" >
</script>
<script>
sap.ui.localResources("webapp");
var app = new sap.m.App("idApp");
var view1 = sap.ui.view({id:"idView1",
viewName:"view.View1",type:sap.ui.core.mvc.ViewType.XML});
</script>
</head>
<body class="sapUiBody" role="application">
<div id="content" ></div>
</body>
</html>
View1.xml
<mvc:View
xmlns="sap.m"
xmlns:mvc="sap.ui.core.mvc">
<Text id="idbtn" text="Text from" />
</mvc:View>
View1.controller
sap.ui.define([
"sap/ui/core/mvc/Controller"
], function(Controller) {
"use strict";
return Controller.extend("View1");
});
neo-app.json
{
"routes": [
{
"path": "/webapp/resources",
"target": {
"type": "service",
"name": "sapui5",
"entryPath": "/resources"
},
"description": "SAPUI5 Resources"
}
]
}
error in browser
I tried several ways and could not find a way to point to View1.xml
Thanks in Advance,
Srini.
Please use data-sap-ui-resourceroots'{"webapp": "./" }' inside the script tag and the view name should be webapp.view.View1 in index.html.
sap.ui.localResources("webapp"); registers the webapp folder for the webapp namespace. You can see that in the console too.
So it should be viewName: "webapp.view.View1".
Please also note that your controller is then known as webapp.controller.View1:
return Controller.extend("webapp.controller.View1", {
...
I'm working on building a Chrome extension for a forum, but the problem is the JavaScript for my popup.html won't do anything. I added alert("popup.js running...") at the top and it does come up but then my popup doesn't display at all. This is a problem because JavaScript is going to be required for the popup page. I'm kind of lost, so I'm assuming I'm just missing something that is preventing my JavaScript from running. I heard the AdBlock extension would prevent it from running but I removed that and it still didn't work. Anyone see a problem?
manifest.json
{
"name": "Riggy",
"short_name": "Riggy",
"description": "Create your own Roblox Forum signature with Riggy!",
"version": "0.0.1",
"manifest_version": 2,
"browser_action": {
"default_popup": "popup/popup.html"
},
"permissions": [
"storage"
],
"content_scripts": [
{
"matches": ["http://www.roblox.com/*"],
"js": ["scripts/jquery.js", "scripts/content.js"]
}
]
}
popup.html
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="popup.css" />
<script type="text/javascript" src="scripts/jquery.js"></script>
</head>
<body>
<span class="title">Riggy</span><br />
<span>Signature: </span><input name="siggy" id="siggy" value="Riggy is greatness!" />
<span id="output">[output]</span>
<script type="text/javascript" src="popup.js"></script>
</body>
</html>
popup.js
alert("popup.js running");
$(document).on("ready", function() {
var siggy = $("#siggy");
var output = $("#output");
function message(text) {
output.html(text);
}
siggy.change(function() {
chrome.storage.sync.set({"siggy": siggy.val()}, function() {
message("Saved signature.");
});
});
message("Riggy is ready!");
});
I had the same exact problem with an extension of mine, I believe it was fixed after I added this to the manifest file.
manifest.json
"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'"
More info here: http://developer.chrome.com/extensions/contentSecurityPolicy.html.