How do I get metadata for a link? - javascript

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><$BlogPageTitle$></title>
<meta property="og:title" content="" />
<meta property="og:description" content="" />
<meta property="og:image" content="" />
<meta property="og:image:width" content="300" />
<meta property="og:image:height" content="300" />
</head>
<body>
<div trbidi="on">
<div style="padding: 0;">
<div id="makingdifferenttimer" style="display: none;">
<div id="notes_url" style="font-family: Electrolize,lolblogger,Tahoma; font-size: 16px; margin-top: 16px;">
<div id="url_qu">
.</div>
</div>
</div>
<div id="mdtimer">
<div style="font-family: Electrolize,lolblogger,Tahoma; text-align: center;">
<b>Please wait...</b>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<script type="text/javascript">
//<![CDATA[
!function(a,b,c,d){function g(b,c){this.element=b,this.settings=a.extend({},f,c),this.settings.fontSize||(this.settings.fontSize=this.settings.radius/1.2),this.settings.strokeWidth||(this.settings.strokeWidth=this.settings.radius/4),this._defaults=f,this._name=e,this._init()}var e="countdown360",f={radius:15.5,strokeStyle:"#2E64FE",strokeWidth:d,fillStyle:"#8ac575",fontColor:"#2E64FE",fontFamily:"Electrolize,lolblogger,Tahoma",fontSize:d,fontWeight:700,autostart:!0,seconds:20,label:["second","Seconds"],startOverAfterAdding:!0,onComplete:function(){}};g.prototype={getTimeRemaining:function(){var a=this._secondsLeft(this.getElapsedTime());return a},getElapsedTime:function(){return Math.round(((new Date).getTime()-this.startedAt.getTime())/1e3)},extendTimer:function(a){var b=parseInt(a),c=Math.round(((new Date).getTime()-this.startedAt.getTime())/1e3);this._secondsLeft(c)+b<=this.settings.seconds&&this.startedAt.setSeconds(this.startedAt.getSeconds()+parseInt(a))},addSeconds:function(a){var b=Math.round(((new Date).getTime()-this.startedAt.getTime())/1e3);this.settings.startOverAfterAdding?(this.settings.seconds=this._secondsLeft(b)+parseInt(a),this.start()):this.settings.seconds+=parseInt(a)},start:function(){this.startedAt=new Date,this._drawCountdownShape(3.5*Math.PI,!0),this._drawCountdownLabel(0),this.interval=setInterval(jQuery.proxy(this._draw,this),1e3)},stop:function(a){clearInterval(this.interval),a&&a()},_init:function(){this.settings.width=2*this.settings.radius+2*this.settings.strokeWidth,this.settings.height=this.settings.width,this.settings.arcX=this.settings.radius+this.settings.strokeWidth,this.settings.arcY=this.settings.arcX,this._initPen(this._getCanvas()),this.settings.autostart&&this.start()},_getCanvas:function(){var b=a('<canvas id="countdown360_'+a(this.element).attr("id")+'" width="'+this.settings.width+'" height="'+this.settings.height+'"><span id="countdown-text" role="status" aria-live="assertive"></span></canvas>');return a(this.element).prepend(b[0]),b[0]},_initPen:function(b){this.pen=b.getContext("2d"),this.pen.lineWidth=this.settings.strokeWidth,this.pen.strokeStyle=this.settings.strokeStyle,this.pen.fillStyle=this.settings.fillStyle,this.pen.textAlign="center",this.pen.textBaseline="middle",this.ariaText=a(b).children("#countdown-text"),this._clearRect()},_clearRect:function(){this.pen.clearRect(0,0,this.settings.width,this.settings.height)},_secondsLeft:function(a){return this.settings.seconds-a},_drawCountdownLabel:function(a){this.ariaText.text(b),this.pen.font=this.settings.fontWeight+" "+this.settings.fontSize+"px "+this.settings.fontFamily;var b=this._secondsLeft(a),c=1===b?this.settings.label[0]:this.settings.label[1],d=this.settings.label&&2===this.settings.label.length,e=this.settings.width/2;d?y=this.settings.height/2-this.settings.fontSize/6.2:y=this.settings.height/2,this.pen.fillStyle=this.settings.fillStyle,this.pen.fillText(b+1,e,y),this.pen.fillStyle=this.settings.fontColor,this.pen.fillText(b,e,y),d&&(this.pen.font="normal small-caps "+this.settings.fontSize/3+"px "+this.settings.fontFamily,this.pen.fillText(c,this.settings.width/2,this.settings.height/2+this.settings.fontSize/2.2))},_drawCountdownShape:function(a,b){this.pen.fillStyle=this.settings.fillStyle,this.pen.beginPath(),this.pen.arc(this.settings.arcX,this.settings.arcY,this.settings.radius,1.5*Math.PI,a,!1),this.pen.fill(),b&&this.pen.stroke()},_draw:function(){var a=Math.round(((new Date).getTime()-this.startedAt.getTime())/1e3),b=3.5*Math.PI-2*Math.PI/this.settings.seconds*a;this._clearRect(),this._drawCountdownShape(3.5*Math.PI,!1),a<this.settings.seconds?(this._drawCountdownShape(b,!0),this._drawCountdownLabel(a)):(this._drawCountdownLabel(this.settings.seconds),this.stop(),this.settings.onComplete())}},a.fn[e]=function(b){var c;return this.each(function(){c=a.data(this,"plugin_"+e),c||(c=new g(this,b),a.data(this,"plugin_"+e,c))}),c}}(jQuery,window,document);
//]]>
</script>
<br />
<div class="time_dir" style="text-align: center;">
<div id="container">
<div id="countdown">
</div>
<script charset="utf-8" type="text/javascript">var countdown=$("#countdown").countdown360({radius:90,seconds:3,fontColor:"#ffffff",strokeStyle:"#ff8000",fillStyle:"#ff4000",autostart:!1,onComplete:function(){console.log("done"),$(".download_faster").show(),$(".dowen_bum").show(),$("#container").remove()}});countdown.start();</script>
</div>
</div>
<script type="text/javascript">
jQuery(document).ready(function(){var a=2;setInterval(function(){$("#mdtimer span").text(a--),0==a&&($("#makingdifferenttimer").delay(1e3).fadeIn(1e3),$("#mdtimer").hide(1e3).fadeOut(fast))},1e3)});
$(document).ready(function(){$(window).load(function(){var a=window.location.hash.substr(1);$("#url_qu").html("<center><b>👇 Product link ready 👇🏻</b><br><br></center><i class="fa fa-arrow-down" aria-hidden="true"/>Click Here')}),setTimeout(function(){window.location.hash.substr(1)},11010)});
</script>
<div>
<br /></div>
</div>
</div>
<div style="text-align: center;">
<center>
</div>
</div>
</div>
</body>
</html>
How do I get link metadata when shared on social media?
This is a waiting page to redirect visitors to another site link when I type the page link
Then # the link that I want the visitor to go to, waiting for the counter, then clicking on the button, it will go to the other site after the # sign
When I share the link on any social networking site, it shows metadata for the waiting page
How do I get the metadata of the link that the visitor will go to?

They make a request to the link that you provide. You can see that when you use grabify (here you will see the request). Then you can parse the html to get the metadata. You should make the request from the bakend and store the result, so that you dont have to reuqest the information multiple times. Also it is unlikely that the request will be allowed cross domain. You can test it by using fetch for example to get the google homepage like this fetch("https://google.com/") however this will return a CORS policy: No 'Access-Control-Allow-Origin' error.

Related

Why am i getting undefined in the console log instead of the input value?

I am trying to get the input value as my result but after clicking on the button I am getting 'undefined' as the console result. Please help to understand the reason. Sharing the HTML and js code
<!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.0">
<link rel="stylesheet" href="movie-search-engine.css">
<script src="scripts/movie-search-engine.js" defer></script>
<title>Movie Search Engine</title>
</head>
<body>
<div class="searchBox">
<input type="text" class="searchBox" placeholder="Movie Name">
<button onclick="moviesearchEngine()" class="searchBoxID" >Search</button>
</div>
<div class="movieDetails">
<h2 class="movieTitle">Movie Title</h2>
<div class="movieData">
<p class="yearofRelease">Year of Release</p>
<p class="movieTitle">Movie Title</p>
<p class="genre">Genre</p>
<p class="director">Director</p>
<p class="plot">Plot</p>
</div>
</body>
</html>
const moviesearchEngine=()=>{
let searchBox = document.querySelector('.searchBox');
console.log(searchBox.value)
}
You are using a class for multiple elements which is why undefined is shown. Among many ways, I will discuss two here, you have to either use indices with classes if using queryselector to get the correct element or use an ID to select the input element. Here I have used ID to get the input searchbox. See the following code:
const moviesearchEngine = () => {
let searchBox = document.querySelector('#searchBoxInput');
console.log(searchBox.value)
}
<!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.0">
<link rel="stylesheet" href="movie-search-engine.css">
<script src="scripts/movie-search-engine.js" defer></script>
<title>Movie Search Engine</title>
</head>
<body>
<div class="searchBox">
<input type="text" id="searchBoxInput" placeholder="Movie Name">
<button onclick="moviesearchEngine()" class="searchBoxID">Search</button>
</div>
<div class="movieDetails">
<h2 class="movieTitle">Movie Title</h2>
<div class="movieData">
<p class="yearofRelease">Year of Release</p>
<p class="movieTitle">Movie Title</p>
<p class="genre">Genre</p>
<p class="director">Director</p>
<p class="plot">Plot</p>
</div>
</body>
</html>
Your div <div class="searchBox"> also contain a class "searchBox" so it selected that.
Fixed: Add an input selector after class selector.
const moviesearchEngine=()=>{
let searchBox = document.querySelector('.searchBox input');
console.log(searchBox.value)
}
<!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.0">
<link rel="stylesheet" href="movie-search-engine.css">
<script src="scripts/movie-search-engine.js" defer></script>
<title>Movie Search Engine</title>
</head>
<body>
<div class="searchBox">
<input type="text" class="searchBox" placeholder="Movie Name">
<button onclick="moviesearchEngine()" class="searchBoxID" >Search</button>
</div>
<div class="movieDetails">
<h2 class="movieTitle">Movie Title</h2>
<div class="movieData">
<p class="yearofRelease">Year of Release</p>
<p class="movieTitle">Movie Title</p>
<p class="genre">Genre</p>
<p class="director">Director</p>
<p class="plot">Plot</p>
</div>
</body>
</html>

How to get piece of information from url given

Hi i have this html code:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link type="text/css" rel="stylesheet" href="/style.css"/>
<link rel="icon" href="">
<title>Submit</title>
</head>
<body>
<script>
function show_alert() {
alert("Animes score is: ");
}
</script>
<div class=střed>
<form>
<div id="one"><input style="width: 500px" type="text" name="url" value="Enter myanimelist URL" onfocus="if (this.value=='Enter myanimelist URL') this.value='';"/></div>
<div id="two"><input type="image" onclick="show_alert();" name="submit" src="/Button1.png" border="0" alt="Submit" />
</div>
</form>
</div>
</body>
</html>
Now i want to get from user's url (for example: https://myanimelist.net/anime/5114/Fullmetal_Alchemist__Brotherhood) the anime's score from page's html (this part: <span itemprop="ratingValue">9.26</span> - so in this case it would be 9.26) and show it in alert box (doesn't need to be alert box thought, just somehow show it to user). Thanks for any help.

Javascript - How to transform index chat into a chat window

Actually I have some chat and I want to put it inside a window, I found an example but Not loading the chat inside window.
My chat works perfectly with just the index. Check the images.
Old index.ejs code (just chat):
<html>
<head>
<script src="jquery-3.1.1.js"></script>
<script src="app.js"></script>
<base href="/">
<title>XXXXXXXXXXXXXXXX</title>
<meta ------ />
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
<link rel="stylesheet" href="css/app.css">
</head>
<body>
<div id="view-change-button" class="button" onclick="Payloadxxxxxxx.togglePanel(event, this)">
<img class="option full" src="../img/Chat Button.png">
<img class="option not-full" src="../img/Code Button.png">
</div>
<div id="contentParent" class="responsive-columns-wrapper">
<div id="chat-column-holder" class="responsive-column content-column">
<div class="chat-column">
<div id="scrollingChat"></div>
<label for="textInput" class="inputOutline">
<input id="textInput" class="input responsive-column"
placeholder="Type something" type="text"
onkeydown="xxxxxxxxxxxxxxxxPanel.inputKeyDown(event, this)">
</label>
</div>
</div>
<div id="payload-column" class="fixed-column content-column">
<div id="payload-initial-message">
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxOtherDescription.
</div>
<div id="payload-request" class="payload"></div>
<div id="payload-response" class="payload"></div>
</div>
</div>
<script src="js/xxxxx.js"></script>
<script src="js/xxxxxxxx.js"></script>
<script src="js/xxxxxxxxxx.js"></script>
<script src="js/xxxxxxxxxx.js"></script>
<script src="js/xxxxxxxxx.js"></script>
</body>
</html>
Image old (I'm use bootstrap for responsive page):
Web maximize
If I decrease or increase the browser window
And new Index with the button click for open the chat, the all code of chat i put inside chat.ejs:
<!DOCTYPE html>
<html>
<head>
<base href="/">
<title>Web Chat - ITSM</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta property="og:image" content="conversation.svg" />
<meta property="og:title" content="Conversation Chat Simple" />
<meta property="og:description" content="Sample application that shows how to use the Conversation API to identify user intents" />
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
<link rel="stylesheet" href="css/app.css">
<meta charset="UTF-8">
<title>Title of the document</title>
<script
src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js">
</script>
<script type="text/javascript">
function open_chatbox() {
$('#chat').fadeOut(500);
$('#chatBox').fadeIn(1000);
}
function closeChat() {
$('#chatBox').fadeOut(500);
$('#chat').fadeIn(1000);
}
</script>
<style>
#chat
{
position:absolute;
width:200px;
height:auto;
padding:10px;
background:#088A68;
color:#EDEDED;
text-align:center;
font-family:Cambria;
font-size:20px;
bottom:0px;
right:15px;
cursor:pointer;
}
#chatBox
{
display:none;
position:absolute;
width:200px;
height:300px;
padding:10px;
background:#EDEDED;
color:#FF7700;
text-align:center;
font-family:Cambria;
font-size:20px;
bottom:0px;
right:15px;
cursor:pointer;
}
#close
{
position:absolute;
width:15px;
height:15px;
padding:6px 5px 10px 5px;
text-align:center;
background:rgba(0,0,0,0.8);
color:#FF7700;
font-family:Cambria;
right:0px;top:0px;
} </style>
</head>
<body>
<div id="chat" onClick="open_chatbox();"> Chat Now </div>
<div id="chatBox"><div onclick="closeChat()" id="close">X</div> <br><br><div id="view-change-button" class="button" onclick="PayloadPanel.togglePanel(event, this)">
<img class="option full" src="../img/Chat Button.png">
<img class="option not-full" src="../img/Code Button.png">
</div>
<div id="contentParent" class="responsive-columns-wrapper">
<div id="chat-column-holder" class="responsive-column content-column">
<div class="chat-column">
<div id="scrollingChat"></div>
<label for="textInput" class="inputOutline">
<input id="textInput" class="input responsive-column"
placeholder="Type something" type="text"
onkeydown="ConversationPanel.inputKeyDown(event, this)">
</label>
</div>
</div>
</div>
</div>
<script src="js/common.js"></script>
<script src="js/api.js"></script>
<script src="js/conversation.js"></script>
<script src="js/global.js"></script>
</body>
</html>
I see that example for it.
And the error is:
Synchronous XMLHttpRequest on the main thread is deprecated because of
its detrimental effects to the end user's experience. For more help,
check https://xhr.spec.whatwg.org/.
Uncaught TypeError: Cannot read property 'classList' of null
at displayPayload (eval at (jquery.min.js:2), :80:23)
at Object.Api.setRequestPayload (eval at (jquery.min.js:2), :52:7)
at Object.sendRequest (eval at (jquery.min.js:2), :55:11)
at geoSuccess (eval at (jquery.min.js:2), :47:9) displayPayload # VM901:80 Api.setRequestPayload #
VM901:52 sendRequest # VM899:55 geoSuccess # VM900:47 VM901:80
Uncaught TypeError: Cannot read property 'classList' of null
at displayPayload (eval at (jquery.min.js:2), :80:23)
Obs.: The old file index.ejs is the new chat.ejs to load the chat inside window if click the button.
I try see other post with same example but None of them are trying the same as me
In the case I put all .css style inside my css repository, and I added the scripts src inside the index. After it, works fine. I did not need chat.ejs and I inserted all the code in the index just with the .css inside my repository public/css/app.css
Check code:
<!DOCTYPE html>
<html>
<head>
<base href="/">
<title>Web Chat - ITSM</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta property="og:image" content="conversation.svg" />
<meta property="og:title" content="Conversation Chat Simple" />
<meta property="og:description" content="Sample application that shows how to use the Conversation API to identify user intents" />
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
<link rel="stylesheet" href="css/app.css">
<meta charset="UTF-8">
<title>Title of the document</title>
<script
src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js">
</script>
<script type="text/javascript">
function open_chatbox() {
$('#chat').fadeOut(500);
$('#chatBox').fadeIn(1000);
}
function closeChat() {
$('#chatBox').fadeOut(500);
$('#chat').fadeIn(1000);
}
</script>
</head>
<body>
<div id="chat" onClick="open_chatbox();"> Chat Now </div>
<div id="chatBox"><div onclick="closeChat()" id="close">X</div> <br><br><div id="view-change-button" class="button" onclick="PayloadPanel.togglePanel(event, this)">
<img class="option full" src="../img/Chat Button.png">
<img class="option not-full" src="../img/Code Button.png">
</div>
<div id="contentParent" class="responsive-columns-wrapper">
<div id="chat-column-holder" class="responsive-column content-column">
<div class="chat-column">
<div id="scrollingChat"></div>
<label for="textInput" class="inputOutline">
<input id="textInput" class="input responsive-column"
placeholder="Digite algo" type="text"
onkeydown="ConversationPanel.inputKeyDown(event, this)">
</label>
</div>
</div>
</div>
</div>
<script src="js/common.js"></script>
<script src="js/api.js"></script>
<script src="js/conversation.js"></script>
<script src="js/global.js"></script>
</body>
</html>

Facebook doesn't scraped html correctly

I am just trying to load my html using link on facebook,but it is not going to render my html correctly. It is rendering only meta graph tags, which is mentionted by facebook below
<meta property="og:title" content="HyperArts SEO Services" />
<meta property="og:type" content="website" />
<meta property="og:image" content="http://www.hyperarts.com/_img-fb/Image-SRC_HyperArts.png" />
<meta property="og:image" content="http://www.hyperarts.com/_img-fb/Image-SRC_HyperArts_blue.png" />
<meta property="og:url" content="http://www.hyperarts.com/seo-services/search-engine-optimization-services-san-francisco.html" />
<meta property="og:site_name" content="HyperArts Web Design & Social Media" /><!--formatted---
My html is
<!doctype html>
<html ng-app="myapp" xmlns="http://www.w3.org/1999/xhtml">
<head>
<link href="css/style.css" rel="stylesheet" type="text/css" />
<link href="css/din-Regular.css" rel="stylesheet" type="text/css" />
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="author" content="" />
<meta property="og:title" content="myapp" />
<title>myapp</title>
</head>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular-route.min.js"></script>
<script src="app.js"></script>
<script src="profileController.js"></script>
<body>
<div class="wraper"></div>
<div class="box">
<div class="profile-box-row clearfix">
<div class="user-profile left">
<div class="imgb">
<div class="imgb-in">
<img src="images/img_man.jpg" alt="img">
</div>
</div>
<span class="user-name">Akshay</span>
</div>
<div class="txtb">
<span class="percent">80%</span>
<p>common interests in myapp</p>
</div>
<div class="user-profile right">
<div class="imgb">
<div class="imgb-in">
<img src="images/img_girl.jpg" alt="img">
</div>
</div>
<span class="user-name">Pratiksha</span>
</div>
</div>
<div class="botom-text">
<p>See who tops to match your preferences among friends. Download Samepinchh http: //www.myapp.com
</p>
</div>
</div>
</body>
</html>
It is not going to render anything inside body tag,only showing title and image in head tag.
Below is a my controller which i am using for share html link.
My controller
public void shareMatchingOnFb(final User user, final Long friendId, final String fbAccessToken) {
FacebookClient facebookClient = new DefaultFacebookClient(fbAccessToken);
InputStream is;
FacebookType publishPhotoResponse = facebookClient.publish("me/feed", FacebookType.class, Parameter.with("message",
"Testing"),Parameter.with("link",
"http://example.com/122222/1222212"));
}
Please help me what i am doing wrong there,i have already spend one day on it.
Thanks
Add the meta-tags to the head on your HTML
<meta property="og:url" content="http://www.nytimes.com/2015/02/19/arts/international/when-great-minds-dont-think-alike.html" />
<meta property="og:type" content="article" />
<meta property="og:title" content="When Great Minds Don’t Think Alike" />
<meta property="og:description" content="How much does culture influence creative thinking?" />
<meta property="og:image" content="http://static01.nyt.com/images/2015/02/19/arts/international/19iht-btnumbers19A/19iht-btnumbers19A-facebookJumbo-v2.jpg" />
The most important ones are title, description and image
Note: after you make changes, you have to tell Facebook to scrape the updated content: https://developers.facebook.com/tools/debug/og/object/

Angular JS "pageslide-directive"

i am fresher to angular Js. i want to use pageslide-Directive. Below i have shared the sample template. How to load that content dynamically in that panel.. Please suggest.
<head>
<meta charset='utf-8' />
<meta http-equiv="X-UA-Compatible" content="chrome=1" />
<meta name="description" content="Ng-pageslide : AngularJS sliding panel for serving additional content" />
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.1.5/angular.min.js"></script>
<script src="angular-pageslide-directive.js"></script>
<link rel="stylesheet" type="text/css" href="http://cdn.jsdelivr.net/foundation/5.0.0/css/foundation.min.css">
<title>AngularJS Pageslide directive demo</title>
<style>
.ng-pageslide {
background: #eee;
}
</style>
<script>
var app = angular.module("app", ["pageslide-directive"]);
</script>
</head>
<body >
<!-- MAIN CONTENT -->
<div ng-app="app" ng-controller="test" id="" class="outer" style="padding:20px">
<a class="large button" pageslide ps-side="right" ps-speed="0.5" ng-click="profile_action('')" href="#demo-right">Open Demo</a> <div style="padding:20px" id="demo-right">
{{ NAME}}
<a id="demo-right-close"i class="button" >Close</a>
</div>
</div>
</body>
You have to add an controller to the panel and use it to load your content to the panel's items

Categories