summaryrefslogtreecommitdiff
path: root/static/fork-awesome/src/doc/assets/js/share.min.js
blob: d3588e96a6ceea07b04f69fc5a70aa895651216f (plain)
1
"use strict";document.addEventListener("DOMContentLoaded",function(){function e(e){if(e.match(/^https:\/\//i))return e;var t=e.split("/").filter(function(e){return e.indexOf(".")>-1});return"https://"+encodeURIComponent(t)}for(var t=document.querySelector("h1"),n=document.querySelector("head").querySelector("title"),o=document.querySelector('meta[property="og:title"]'),r=null===n?"":n.textContent,i=null===o?"":o.content,l=null===t?"":t.textContent,u=r||i||l,a=encodeURIComponent(window.location.href),c=document.querySelectorAll(".share-btn"),d=[],s=0;s<c.length;s++)d.push(c[s]);for(var p=document.querySelectorAll(".popup input"),f=[],h=0;h<p.length;h++)f.push(p[h]);var m=function(t){var n="podurl"!==t.target.name,o=n?t.target.value:t.target.nextSibling.value,r=n?t.target.previousSibling.value:t.target.value,i=encodeURI(u).replace(/%20/g,"+"),l=e(r);if("diaspora"===o||"friendica"===o||"socialhome"===o)window.open(l+"/bookmarklet?url="+a+"&title="+i);else if("gnusocial"===o)window.open(l+"/notice/new?status_textarea="+i+"&"+a);else if("mastodon"===o)window.open(l+"/share?text="+i+" "+a);else{if("hubzilla"!==o)return;window.open(l+"/rpost?f=&url="+a+"&title="+i)}};d.forEach(function(e){return e.addEventListener("click",m,!1)}),f.forEach(function(e){return e.addEventListener("keypress",function(e){13===e.keyCode&&m(e)})})});