Yammer embed action (follow and like) - embed

Has anybody got the Yammer embed API for Follow and Like to work in a SharePoint site? I can get the buttons to appear and when I click on them they change to Liked and Followed but nothing is posted to Yammer and nothing appears in the activity feed. Several folks have tried this and given up and doing something via the Java SDK instead but this is long-winded with the embed API should work. Any ideas?
Code is as follows:
<script type="text/javascript" src="https://assets.yammer.com/assets/platform_embed.js"></script>
<div id="embedded-like" style="width:400px;"></div>
<script>
yam.connect.actionButton({
container: "#embedded-like",
network: "mynetwork.com",
action: "like"
});
</script>
<p>
<div id="embedded-follow" style="width:400px;"></div>
<script>
yam.connect.actionButton({
container: "#embedded-follow",
network: "mynetwork.com",
action: "follow"
});
</script>

don't know if you got there already - but was able to expand the object properties on the embed like to push details in the recent activity feed in yammer from a sp2010 page. Its totally hard coded for just one page - but I'm exploring the elements the like button can pick up - saw some on this page - but could be pre-API change
http://sp2013.blogspot.co.nz/2013/10/sharepoint-and-yammer-yammer-feed-like.html
my code:
<div id="embedded-like"></div>
<script src="https://assets.yammer.com/assets/platform_embed.js"></script>
<script>
yam.connect.actionButton({
container: "#embedded-like",
network: "[mynetwork]",
objectProperties: {
url: "URL To my sp2010 page",
type: "page",
title: "Some Title to show in the feed"
},
action: "like"
});
</script>

Related

How can i load an API call for this weather API to display inside a div in my html page

I have this weather API plugin and my api key and i would like to show the data it displays inside a div. RIght now if i enter this link into my browser it shows me the correct weather info. My question is how do i get this data to display in a div in my web page.
API call (link): http://api.openweathermap.org/data/2.5/weather?q=Montreal&mode=html&appid=4a5344b7f84ba5c5c620525315413734
If you enter this link above in any browser it will work.
I haven't tried anything because its just a link, so obviously adding it anywhere on my page doesn't make sense. I think this has something to do with a GET request perhaps...?
Here is a basic example from your post.
$(function() {
$(".weatherbug > div:eq(1)").load("https://api.openweathermap.org/data/2.5/weather?q=Montreal&mode=html&appid=4a5344b7f84ba5c5c620525315413734");
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="weatherbug">
<div>My Weather</div>
<div></div>
</div>

Using typeahead with Bootstrap 3

I am trying to use typeahead.js to create a 'live search' - basically I want to search a json file and return back the results to the screen.
I have generated a json file with all of the devices I am trying to search, the structure is as follows:
{"short_name":"3555","long_name":"Nokia 3555"}
So whatever the user enters then it is searched for in the long_name, the only reason I have the 'short_name' is because I require it to generate the URL that the user will be redirected to eg. site.com/device/3555
I've uploaded the full json file here -
https://docs.google.com/file/d/0B6O0C30w5kQgR08xZ0xMWnV5TW8/edit?usp=sharing
<script type="text/javascript">
$('.typeahead').typeahead({
name: 'devices',
prefect: '/data/devices.json',
limit: 10
});
</script>
The following code doesn't seem to do anything - can anyone indicate where I am going wrong?
You have a spelling mistake prefect should be prefetch, try it but you will want to check the path is correct in your own code too:
<script type="text/javascript">
$('.typeahead').typeahead({
name: 'devices',
prefetch: '/data/devices.json',
limit: 10
});
</script>

assistance with html code for popup window

I will be using shopify's system so i am restricted to how and which pages i can edit.
I have one page that is an app but i want that page, on loading, to show a popup disclaimer before they can see the page.
I am told that i can't edit the app page itself but i can add javascript code in the common site footer to check current url and if it equals this certain page, then create a popup.
I have created a page that holds the disclaimer information so i would like the popup window to load this pages' content.
I believe i can load the content using this div tag
div id="popupinfo" pages.disclaimer.content div
I do not know how to add the if statement to check if current url = site.com app.html then div id="popupinfo" pages.disclamier.content div
This site uses their own language called Liquid, hence the double brackets..but any code to pull the content of an html page would work i am sure.
Can i please have some assistance in how i am to
check current page
if page = xxx
best way to create a popup window where the user has to click as yes or ok button
then display the regular page
Thanks in advance!
Brocour
It's only possible to open a pop-up window upon a user-action, for example a 'click' action.
if( document.URL === "myPage.html" ){
// Disclaimer alert
if (confirm('Do you agree to this Disclaimer?')){
// Redirect
window.location = "myNewPage.html";
} else {
// Do nothing
}
}
Try something like this:
<html>
<head>
</head>
<script type="text/javascript">
function poponload()
{
popupwindow=window.open("","mywindow","location=1,status=1,scrollbars=1,width=100,height=100");
popupwindow.moveTo(0, 0);
}
</script>
<body onload="javascript: poponload()">
This is the page
</body>
</html>
You could use the code in this example i made.
$(document).ready(function(){
$('#open_popup').click(function(){
popupwindow=window.open("http://google.com","mywindow","location=1,status=1,scrollbars=1,width=600,height=500");
})
})

How to tell google bot to skip part of HTML?

There is much info about opposite situation, when people try to have stuff in HTML, that is visible to Google bots, but not visible to users, in my case, I need opposite thing - to hide some of the html from google bot. The question would be how?
Flash is not an answer,
Would prefer not to use fancy ajax things also (mainly because I need it right away, not on document ready),
Also robots.txt is not an answer, because it works on urls, not parts of the page.
Would any special css/simple javascript work, is any special html tag for this?
Maybe a base64 encoding server side and then decoding on the client side could work?
Code:
<!-- visible to Google -->
<p> Hi, Google Bot! </p>
<!-- not visible from here on -->
<script type="text/javascript">
document.write ("<?php echo base64_encode('<b>hey there, user</b>'); ?>");
</script>
How it looks to the bot:
<!-- visible to Google -->
<p> Hi, Google Bot! </p>
<!-- not visible from here on -->
<script type="text/javascript">
document.write (base64_decode("B9A985350099BC8913=="));
</script>
Create a Div,
Load the content of the Div (ajax) from an html file which resides in a directory protected by robots.
Example.
/index.html
Somewhere on the header. (check http://api.jquery.com/jQuery.ajax/ )
$.ajax({
url: '/hiddendirfrombots/test.html',
success: function(data) {
$('#hiddenfrombots').html(data);
}
});
...
somewhere in the body
<div id="hiddenfrombots"></div>
create a directory "hiddenfrombots" and put the followin in the roots .htaccess
User-agent: *
Disallow: /hiddenfrombots/
This should do the Trick:
<!--googleoff: index-->
<p>hide me!</p>
<!--googleon: index-->
For more information check out the link to Googles page that describes it in more depth.
Excluding Unwanted Text from the Index
If you can use PHP, just output your content if not Googlebot:
// if not google
if(!strstr(strtolower($_SERVER['HTTP_USER_AGENT']), "googlebot")) {
echo $div;
}
That's how I could solve this issue.
Load your content via an Ajax call
But create a JS file (e.g.: noGoogleBot.js) that contains the function that implements the ajax call:
$.ajax({
url: 'anything.html',
success: function(data) {
$('#anywhere').html(data);
}
});
Then in your robots.txt
User-agent: *
Disallow: /noGoogleBot.js
So all the divs that are loaded using the function in noGoogleBot will be blocked.
Googlebot (or any other crawler) will ignore the content of noGoogleBot.js.
Per Google docs
<p>This text can be shown in a snippet
<span data-nosnippet>and this part would not be shown</span>.</p>
Adding data-nosnippet to div, span, or section prevents the content from being shown in the search result.
simple, create an image with the text you don't want Google to see

Grabbing Google Directions gadget from Ajax call

I am trying to throw together a website using Ajax for the first time, to finally get with the times and figure it out. So far it is nothing but HTML pages and a bit of JS. Using some basic AJAX script I found online, I have the main index.htm which has a title, navigation, and content divs. The Ajax calls grab other content includes (which are just files with text content for the most part) to throw into the content div. For the most part it works, except for when I am trying to add the Google Directions gadget. When I add the script code it gives me to a file and call that file, there is no noticeable output.
Any suggestions on what I am doing wrong or what I'm missing?
If I am understanding you correctly this is an unnecessary use of AJAX. From what it seems like you want to do is load JavaScript via a JavaScript call. This can be accomplished using either method described here. Example:
<script type="text/javascript">
function dhtmlLoadScript(url)
{
var e = document.createElement("script");
e.src = url;
e.type="text/javascript";
document.getElementsByTagName("head")[0].appendChild(e);
}
onload = function()
{
dhtmlLoadScript("dhtml_way.js");
}
</script>
If the above link does not help or I am misunderstanding your question please provide further clarification or some sort of code example.
Following up on your comment
Here is a work around for your gadget, the below code would be on your main page (the one that is initially loaded). Here is my test HTML page:
<html>
<head>
<script type="text/javascript">
var gadget;
function getGadgetAndMove(node)
{
gadget = document.getElementsByTagName("table")[0];
node.appendChild(gadget);
gadget.style.visibility = "visible";
gadget.style.display = "inline-block";
}
</script>
<style>
.ig_reset, .ig_tbl_line { visibility:hidden;}
</style>
</head>
<body>
<div onclick="getGadgetAndMove(this);">Test</div>
</body>
<script src="http://www.gmodules.com/ig/ifr?url=http://hosting.gmodules.com/ig/gadgets/file/114281111391296844949/driving-directions.xml&up_fromLocation=&up_myLocations=1600%20Amphitheatre%20Pkway%2C%20Mountain%20View%2C%20CA&synd=open&w=320&h=55&title=Directions+by+Google+Maps&brand=light&lang=en&country=US&border=%23ffffff%7C3px%2C1px+solid+%23999999&output=js"></script>
</html>
If you need further explanation please let me know.
I believe I know what you want to accomplish, because I ran into the same problem. And I found a solution. So I would say that no it is not an improper use of ajax, because you could run into this in some circumstances.
Put the directions gadget not directly in the page content that is being loaded via ajax, but in a separate file such as "directionsgadget.html" (insert the script tag for the gadget in this file).
Then use an iframe with src="/path/to/directionsgadget.html" in your ajax loaded content.
The gadget should get loaded this way.
If you want the gadget centered within the iframe, you can wrap the script tag in directionsgadget.html in a div with a set width and style="margin:0px auto". That will center the gadget.
Here is an example:
Your main page is "index.html", and contains a div that will contain ajax loaded content:
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
$(document).ready(function(){
$.ajax({
url: 'ajaxcontent.html',
success: function(returndata){ $('#ajaxcontent').html(returndata); }
});
});
</script>
</head>
<body>
<div id="ajaxcontent"></div>
</body>
</html>
Then you have a file with the content that is to be loaded via ajax, and this has among other things a google gadget. Were not going to put the gadget directly here, but were going to put it in a separate file and point to it with an iframe. Let's call this first file ajaxcontent.html, as indicated in the ajax call in the head section of the first file:
<span>Here is some content that will be loaded onto the main page via ajax.</span><br />
<span>Among other things, there is a google directions gadget that will be loaded.</span>
<div id="getdirections" style="margin:0px auto;">
<iframe style="width:365px;height:216px;" src="directions.html"></iframe>
</div>
Now we will put the script for the google gadget itself in a separate file "directions.html" (as indicated in the src of the iframe above), and in order for the rendered gadget to be centered we are going to wrap the script tag within a div just so:
<div style="width:336px;height:116px;margin:0px auto;">
<script type="text/javascript" src="http://www.gmodules.com/ig/ifr?url=http://hosting.gmodules.com/ig/gadgets/file/114281111391296844949/driving-directions.xml&up_fromLocation=&up_myLocations=_a_bunch_of_information_with_personal_list_of_locations_&synd=open&w=320&h=55&title=Street+directions+by+Google+Maps&brand=light&lang=it&country=ALL&border=http%3A%2F%2Fwww.gmodules.com%2Fig%2Fimages%2F&output=js"></script>
</div>
I hope this example was clear enough!