Who to Outlook adin code error for the same [closed] - outlook

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 days ago.
Improve this question
How can one rename a specific column in a pandas DataFrame when the colum name is not unique? Calling df.rename(columns={'old_name':'new_name'} will rename all the columns with the name "old_name". Same question for dropping a column when there are duplicate column names.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
<title>Metadata Extractor</title>
</head>
<body>
<div id="metadataContainer">
<p id="fileName"></p>
<p id="fileSize"></p>
<p id="creationDate"></p>
<p id="fileType"></p>
</div>
<script src="https://appsforoffice.microsoft.com/lib/1/hosted/office.js" type="text/javascript"></script>
<script src="metadata.js" type="text/javascript"></script>
</body>
</html>
Office.initialize = function () {
// Get the metadata of the first attachment in the email
Office.context.mailbox.item.attachments.getItemAt(0).getMetadataAsync(function (result) {
if (result.status === Office.AsyncResultStatus.Succeeded) {
// Extract the metadata
var fileName = result.value.Name;
var fileSize = result.value.Size;
var creationDate = result.value.LastModifiedTime;
var fileType = result.value.ContentType;
// Display the metadata in the custom UI
document.getElementById("fileName").innerText = "File name: " + fileName;
document.getElementById("fileSize").innerText = "File size: " + fileSize + " bytes";
document.getElementById("creationDate").innerText = "Creation date: " + creationDate;
document.getElementById("fileType").innerText = "File type: " + fileType;
} else {
// Handle errors
console.error(result.error.message);
}
});
};
Try to developer a outlook addin

Related

Dynamic section name in EvoHtmlToPdf header

Is there a way in EvoHtmlToPdf to display the section/subsection of a page in the header/footer (i.e. the text of the "current" h1/h2 tag)?
With wkhtmltopdf and other tools, it is possible to replace special tags via JavaScript and the HTML header template (as described here for example Dynamic section name in wicked_pdf header).
Unfortunately, such a solution does not seem to work with EvoHtmlToPdf.
Here's the HTML code of my header template:
<html id="headerFooterHtml">
<head>
<script>
function substHeaderFooter(){
var vars={};
var searchString = document.location.search;
var debugMessage = document.getElementById("showJavaScriptWasExecuted");
if (debugMessage)
debugMessage.textContent = "Search string: ["+ searchString + "]";
var search_list = searchString.substring(1).split('&');
for(var i in search_list){
var content=search_list[i].split('=',2);
vars[content[0]] = decodeQueryParam(content[1]);
}
var tags=['section','subsection'];
for(var i in tags){
var name = tags[i],
classElements = document.getElementsByClassName(name);
for(var j=0; j<classElements.length; ++j){
classElements[j].textContent = vars[name];
}
}
}
</script>
</head>
<body id="headerFooterBody" onload="substHeaderFooter()">
<div id="showJavaScriptWasExecuted"></div>
<div id="sections">{section} / {subsection}</div>
</body>
Resulting header in PDF
I already added the EvoHtmlToPdf PrepareRenderPdfPageDelegate event handler to my code (if that's the way I have to go) but I don't know how to access the section of the current page there...
Thanks in advance for your help!

How to replace an image with another on button click

Hi I have a problem that I can't quite solve. I'm a total noob with HTML/Javascript, so I'm not sure how to proceed. The instructions are in the code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Q2</title>
<script type="text/javascript" src="342.js"></script>
<script type="text/javascript">
function swap() {
if (Math.random()>.5){
document.getElementById("c").style.display = 'none';
document.getElementById("f").src = "images/f.jpg";
} else {
document.getElementById("d").style.display = 'none';
document.getElementById("f").src = "images/f.jpg";
}
}
</script>
</head>
<body>
<p>Add code so that clicking the button changes either the src "c.jpg" or "d.jpg" to "f.jpg" The choice of which should be replaced
should be determined randomly.</p>
<img src="images/c.jpg" id="c"><br>
<img src="images/d.jpg" id="d">
<br><br>
<button type="button" onclick="swap()">OK</button>
</body>
</html>
The original problem had everything but the scripts. When I try this, I'm able to get the image c or d to disappear, but image f doesn't appear. I don't know how to get the image to show. getELementById won't work because I haven't made an id, but how do I do that without having image f showing? Any help is appreciated.
Seems you're missing html
Try add f html element for work:
<img src="images/f.jpg" id="f">
The p tag in the html is talking about c.jpg, d.jpg and e.jpg.
Its not talking about f.jpg, you may want to check that
with the assumption that it is e.jpg and not "f.jpb". And also assuming that you have e.jpg in your images folder. Below code will work fine (small modification in the script)
function swap() {
if (Math.random()>.5){
// document.getElementById("c").style.display = 'none';
document.getElementById("c").src = "images/e.jpg";
} else {
// document.getElementById("d").style.display = 'none';
document.getElementById("d").src = "images/e.jpg";
}
}

Xamarin.Forms UWP - Setting WebView.Source as HtmlWebViewSource Processes Scripts Twice

In Xamarin.Forms UWP, if I have a WebView whose Source property is set to type UrlWebViewSource, it works as expected. BUT, if the Source property is set to type HtmlWebViewSource where the Html property is set as a string, then any <script>s in the HTML are processed twice.
I've set up a brand new Xamarin.Forms project, where the Content of the MainPage is set to a WebView in the code-behind. I've set it up so that I can easily switch out between setting the WebView.Source to UrlWebViewSource or HtmlWebViewSource:
public MainPage()
{
InitializeComponent();
var urlSource = new UrlWebViewSource { Url = "https://htmlpreview.github.io/?https://github.com/joelbyrd/external-resources/blob/master/storefulfillment/Printing/Packing/GNC-Pick.htm" };
var htmlStringSource = new HtmlWebViewSource
{
Html = #"<!doctype html><html lang='en'><head><meta charset='utf-8'><meta http-equiv='x-ua-compatible' content='ie=edge'><meta name='viewport' content='width=device-width, initial-scale=1'><title>Test</title></head><body><div id='log'></div><p>some text</p><script>document.getElementById('log').innerHTML += `<p>Testing</p>`;</script></body></html>"
};
var webView = new WebView
{
Margin = new Thickness(0, 20, 0, 0),
Source = urlSource, // displays as expected
//Source = htmlStringSource // <script>'s are processed twice, appending "Testing" to the body twice
};
Content = webView;
}
It's a problem that the scripts are executed twice, probably for several reasons, but for one, if I'm appending content to the body with JavaScript, then it will be appended twice - not what I want. Here's the test HTML code I'm using:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Test</title>
</head>
<body>
<div id="log"></div>
<p>some text</p>
<script>
document.getElementById('log').innerHTML += `<p>Testing</p>`;
</script>
</body>
</html>
When I set the WebView.Source to type UrlWebViewSource, and set the Url property to "https://htmlpreview.github.io/?https://github.com/joelbyrd/external-resources/blob/master/storefulfillment/Printing/Packing/GNC-Pick.htm", I get the following expected output:
BUT When I set the WebView.Source to type HtmlWebViewSource, with the Html property set to the string above (spaces taken out and properly escaped), I get the following:
You can see that "Testing" has been added to the body twice. This only happens in UWP, so I suspect it's a bug. Can anyone tell me what's going on here, and if there's a workaround?

Flickr.photos.search() Error (GAE+JSF)

my problem is the folling one, I am trying to display a couple of images from flickr by using a tag. When I deploy the app I get a blank page. But by checking the browser's console I have found this:
(index):13
Uncaught SyntaxError: Invalid or unexpected token?method=flickr.photos.search&api_key=88f1c84…&tags=football&per_page=5&page…:1
And
Uncaught ReferenceError: jsonFlickrApi is not defined at ?method=flickr.photos.search&api_key=88f1c84…&tags=football&per_page=5&page…:1
I don't really know what this means at all...
<!DOCTYPE html >
<html>
<head>
<TITLE>Flickr</TITLE>
</head>
<body>
<script>
function jsonFlickrApi(rsp){
window.rsp = rsp;
var s = "";
s = "total number is: "+rsp.photos.photo.length+"<br/>";
for(var i=0;i<rsp.photos.photo.length;i++){
photo = rsp.photos.photo[i];
t_url = "http://farm"+photo.farm+".static.flickr.com/"+photo.server+"/"+photo.id+"_"+photo.secret+"_"+"t.jpg";
p_url = "http://www.flickr.com/photos/"+photo.owner+"/"+photo.id;
s += '' + 'img alt="'+photo.title+ '"src="'+t_url+'"/>'+'';
}
document.writeln(s);
}
</script>
<script src="https://api.flickr.com/services/rest/?method=flickr.photos.search&api_key=88f1c841c5e9acb6cccd8f1f81cf6950&tags=football&per_page=5&page=1&format=json&api_sig=70c1245d615fa1dc6b254724dcbabfad"></script>
</body>
</html>
Your error is in this line:
for(var i=0;i<rsp.photos.photo.length;i++){
< is a string character, when you want it to be the less than sign <. So, change to:
for(var i=0;i<rsp.photos.photo.length;i++){

modify html file in .net windows app

I have a map.html file that contains a script for google maps api v3, i've been trying previously trying to run this script using the webbrowser1.DocumentText and Webbrower1.Document.InvokeScript been unsuccessful.
This time i have the map.html hosted on a website, My objective is been able to modify this html file and then run it on my windows application in order to display a desired address.
below is the code of the map.html which is hosted ex: http://url.com/map.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<script type="text/javascript" src="http://maps.google.com.mx/maps/api/js?sensor=true&language=es"></script>
<script type="text/javascript">
var geocoder;
var map;
function initialize() {
geocoder = new google.maps.Geocoder();
//var latlng = new google.maps.LatLng(-34.397, 150.644);
var myOptions = {
zoom: 16,
//center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
//var address = document.getElementById("address").value;
var address = "Miami Beach, Flordia" //Address to modify in order to display
geocoder.geocode({ 'address': address }, function (results, status) {
if (status == google.maps.GeocoderStatus.OK) {
map.setCenter(results[0].geometry.location);
var marker = new google.maps.Marker({
map: map,
position: results[0].geometry.location
});
} else {
alert("Geocode was not successful for the following reason: " + status);
}
});
map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
}
</script>
</head>
<body onload="initialize()">
<div id="map_canvas" style="width:100%; height:100%"></div>
</body>
</html>
if you copy and paste this code in a html it should display Miami Beach, FL
now on my windows application i want to edit this html that is hosted on a website i want to change Miami Beach, Florida to Naples,Florida as an example.
then use a webbrowser on my windows application and display it as Webbrowser1.Navigate("http://url.com/map.html")
your help is very appreciated it.
I did found how to modify an html when it is saved locally on my computer but for what i exactly need this is not a viable way.
thank you,
Leo P.
I would not try to modify the html code. Since the Google Maps code is all JS, I would write a JS function to move the map to the new location.
You can call that function from your application (or even insert it from there).
using mshtml;
//First, navigate to your page:
Webbrowser1.Navigate("http://url.com/map.html")
void Webbrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
//Then call your move function with the new target:
mshtml.IHTMLDocument2 doc = (mshtml.IHTMLDocument2)Webbrowser1.Document.DomDocument;
mshtml.IHTMLWindow2 window = (mshtml.IHTMLWindow2)doc.parentWindow;
window.execScript("yourMapMoveFunction('Naples,Florida');");
}
BTW, your link does not show a map...

Resources