PageSourceSearch

https://research.news/wp-content/themes/NTTheme/js/Social.js

js research.news collected 2026-10-04 00:06:26 UTC 10,854 bytes, 304 lines download raw bytes

1//UPDATED ON 9/09/2020 @ 12:26PM
2
3///////////////////////////////////////////////////////////////
4
5$(document).ready(function() {
6AddIcons();
7GetViews();
8
9if($('meta[property="og:url"]').length) {
10var vURL = $('meta[property="og:url"]').attr('content');
11} else {
12var vURL = document.URL;
13};
14
15var vTitle = document.title
16vTitle = vTitle.replace("'","\\'"); //Escape the apostrophe with  backslashes
17vTitle = encodeURIComponent(vTitle);
18vURL = encodeURIComponent(vURL);
19
20//===================================
21
22$('.SocialButtons .Facebook').click(function() { ShareWindow('Facebook',vTitle,vURL); });
23$('.SocialButtons .BrighteonIO').click(function() { ShareWindow('BrighteonIO',vTitle,vURL); });
24$('.SocialButtons .Twitter').click(function() { ShareWindow('Twitter',vTitle,vURL); });
25$('.SocialButtons .Google').click(function() { ShareWindow('Google',vTitle,vURL); });
26$('.SocialButtons .Add2Any').click(function() { ShareWindow('Add2Any',vTitle,vURL); });
27$('.SocialButtons .Email').click(function() { EmailWindow(vURL); });
28$('.SocialButtons .Print').click(function() { PrintWindow(); });
29$('.SocialButtons .Comments').click(function() { scrollToComments(); });
30
31//===================================
32
33$('.SocialButtons .Facebook').hover(function(){
34$(this).addClass('Facebook-Hover');
35}, function(){
36$(this).removeClass('Facebook-Hover');
37});
38
39$('.SocialButtons .Twitter').hover(function(){
40$(this).addClass('Twitter-Hover');
41}, function(){
42$(this).removeClass('Twitter-Hover');
43});
44
45$('.SocialButtons .Add2Any').hover(function(){
46$(this).addClass('Add2Any-Hover');
47}, function(){
48$(this).removeClass('Add2Any-Hover');
49});
50
51$('.SocialButtons .Email').hover(function(){
52$(this).addClass('Email-Hover');
53}, function(){
54$(this).removeClass('Email-Hover');
55});
56
57$('.SocialButtons .Print').hover(function(){
58$(this).addClass('Print-Hover');
59}, function(){
60$(this).removeClass('Print-Hover');
61});
62
63$('.SocialButtons .Comments').hover(function(){
64$(this).addClass('Comments-Hover');
65}, function(){
66$(this).removeClass('Comments-Hover');
67});
68
69});
70
71//////////////////////////////////////////////////////////////////////////////////////////////
72
73$(window).load(function() {
74
75});
76
77//////////////////////////////////////////////////////////////////////////////////////////////
78//////////////////////////////////////////////////////////////////////////////////////////////
79//////////////////////////////////////////////////////////////////////////////////////////////
80//////////////////////////////////////////////////////////////////////////////////////////////
81//////////////////////////////////////////////////////////////////////////////////////////////
82
83function AddIcons() {
84$('.Social').each(function( index ) {
85var vURL = $(this).parent().parent().find(".Title").find("a").attr('href');
86var vTitle = $(this).parent().parent().find(".Title").text();
87var vHTTP = vURL.indexOf('http://');
88var vHTTPS = vURL.indexOf('https://');
89var vDoubleSlash = vURL.indexOf('//');
90if ( vDoubleSlash < 0 && (vHTTP < 0 || vHTTPS < 0)) { //link must be relative (no http, https, or //)
91vURL = document.location.href + vURL;
92};
93vTitle = vTitle.replace("'","\\'"); //Escape the apostrophe with  backslashes
94vURL = encodeURIComponent(vURL);
95vTitle = encodeURIComponent(vTitle);
96
97//var vFB = "Javascript: ShareWindow('Facebook','" + vTitle + "','" + vURL + "')";
98//var vGP = "Javascript: ShareWindow('Google','" + vTitle + "','" + vURL + "')";
99var vMD = "Javascript: ShareWindow('Mastodon','" + vTitle + "','" + vURL + "')";
100var vGAB = "Javascript: ShareWindow('GAB','" + vTitle + "','" + vURL + "')";
101var vTW = "Javascript: ShareWindow('Twitter','" + vTitle + "','" + vURL + "')";
102
103var vBlock = '<div class="Table">';
104vBlock += '<div class="Col"><a href="' + vGAB + '"><img src="/wp-content/themes/NTTheme/images/GAB-16x16.svg" title="Share on GAB"></a></div>';
105vBlock += '<div class="Col"><a href="' + vTW + '"><img src="/wp-content/themes/NTTheme/images/Twitter-16x16.svg" title="Share on Twitter"></a></div>';
106vBlock += '</div>';
107
108$(this).html(vBlock);
109
110});
111};
112
113//////////////////////////////////////////////////////////////////////////////////////////////
114
115function ShareBrighteonIO() {
116if ($('.ActivePost').length == 0) { //share from home/index page
117var vHeadline = $('title').text();
118var vURL = window.location.href;
119} else {
120var vHeadline = GetActiveHeadline();
121var vURL = GetActiveURL();
122};
123
124vHeadline = specialCharactersHandler(vHeadline)
125
126var k = $("meta[name='keywords']").attr("content");
127pos = k.indexOf(",");
128pos = k.indexOf(",",pos+1);
129pos = k.indexOf(",",pos+1);
130k = k.substring(0,pos);
131tags = k.split(",");
132
133const share = window.bastyonLib.share({
134share: {
135description: vHeadline,
136url: vURL,
137tags: tags
138}
139})
140const brighteonIOShareURL = share.makeURL()
141const win = window.open(
142brighteonIOShareURL,
143'_blank',
144'scrollbars=0, resizable=1, menubar=0, left=100, top=100, width=550, height=440, toolbar=0, status=0'
145)
146win?.focus()
147};
148
149function specialCharactersHandler(vText) {
150
151vText = vText.replaceAll('   ', ' '); //triple space
152vText = vText.replaceAll('  ', ' '); //double space
153
154vText = vText.replaceAll('&#8211;', ' -- '); //endash
155vText = vText.replaceAll('&#8212;', ' -- '); //emdash
156vText = vText.replaceAll("&#8216;", "'"); //left curly apostrophe
157vText = vText.replaceAll("&#8217;", "'"); //right curly apostrophe
158vText = vText.replaceAll("&rsquo;", "'"); //right curly apostrophe
159
160vText = vText.replaceAll('—', ' -- '); //emdash
161vText = vText.replaceAll('–', ' -- '); //endash
162vText = vText.replaceAll('…', '...'); //ellipsis
163vText = vText.replaceAll('“', '"'); //left quote
164vText = vText.replaceAll('”', '"'); //right quote
165vText = vText.replaceAll("‘", "’"); // left curly apostrophe
166vText = vText.replaceAll("’", "'"); // right curly apostrophe
167
168vText = vText.replaceAll('&', 'and'); //ampersand
169
170//console.log(vText);
171
172return vText
173};
174
175function ShareWindow(vType, vTitle, vURL) {
176
177
178if (vType == 'Add2Any') {
179vURL = 'https://www.addtoany.com/share_save#url=' + vURL;
180};
181
182if (vType == 'GAB') {
183vURL = 'https://gab.com/';
184};
185
186if (vType == 'Twitter') {
187vURL = 'https://twitter.com/intent/tweet?text=' + vTitle + '&url=' + vURL;
188};
189
190if (vType == 'BrighteonIO') {
191console.log("click BrighteonIO");
192ShareBrighteonIO();
193return;
194};
195
196//if (vType == 'Facebook') {
197//vURL = 'http://www.facebook.com/sharer/sharer.php?u=' + vURL;
198//};
199
200//if (vType == 'Google') {
201//vURL = 'https://plus.google.com/share?url=' + vURL;
202//};
203
204var iMyWidth = ( window.screen.width / 2 ) - ( 300 + 10 );
205var iMyHeight = ( window.screen.height / 2 ) - ( 400 + 50 );
206shareWindow = window.open( vURL, 'shareWin', 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=700,height=450,left=' + iMyWidth + ',top=200' );
207shareWindow.focus();
208};
209
210//////////////////////////////////////////////////////////////////////////////////////////////
211
212function EmailWindow(url) {
213var vTitle = document.title;
214window.location.href = "mailto:?subject=Check out this interesting article&body=" + url + "%0A%0A";
215};
216
217//////////////////////////////////////////////////////////////////////////////////////////////
218
219function PrintWindow() {
220var vURL = document.URL;
221var vDomain = vURL.substring(0, vURL.lastIndexOf("/") + 1); //assumes the file is kept in the root, not subfolders
222var vHeadline = $('.PostTitle').text();
223var vAuthor = $('.PostInfo').text();
224var vArticle = $('.PostArticle').html();
225var iMyWidth = ( window.screen.width / 2 ) - ( 300 + 10 );
226newWindow = window.open('', 'PrintFriendly', 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width=700,height=450,left=' + iMyWidth + ',top=200' );
227newWindow.focus();
228var text = '<html><head><title>' + vHeadline + '</title>';
229text += '</head><body>';
230text += '<div style="font-family: arial, helvetica, san-serif;">';
231text += '<p><button style="float: right;" onclick="window.print();">Print</button></p><h1>' + vHeadline + '</h1>' + '<p>' + vAuthor + '</p><p>This article was printed from: '+ vURL + '</p><p>' + vArticle + '</p><p>See more articles like this at: ' + vDomain + '</p>';
232text += '</div></body></html>';
233newWindow.document.write(text);
234newWindow.print();
235};
236
237//////////////////////////////////////////////////////////////////////////////////////////////
238
239function formatNumber(vCount) {
240if (vCount >999999) {
241vCount = Math.floor(vCount/1000000);
242vCount = vCount.toString();
243var vFinalCount = vCount + "M" //Million
244} else if (vCount >9999) {
245vCount = Math.floor(vCount/1000);
246vCount = vCount.toString();
247var vFinalCount = vCount + "k" //Thousand
248} else {
249var vFinalCount  = vCount .toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); //add comma(s) to final number
250};
251return vFinalCount;
252};
253
254//////////////////////////////////////////////////////////////////////////////////////////////
255
256function GetViews() {
257var vDomain = document.URL;
258var vDomain = vDomain.substring(0, vDomain.lastIndexOf("/") + 1); //assumes the file is kept in the root, not subfolders
259var vFilename = vDomain.substring(vDomain.lastIndexOf("/") + 1, vDomain.length);
260$('.Views').each(function() {				 
261var vElement = $(this);
262var vURL = $(this).html();
263if (vURL ==''){
264vURL = $('meta[property="og:url"]').attr('content');
265};				 
266if (vURL === null || vURL === undefined){
267vURL = document.URL;
268};
269var vViewPage = 'GetViews.asp?url=';
270var vPage = vDomain + vViewPage + vURL;
271var request = $.get(vPage);
272request.success(function(data) { //Get views successful
273var vCount = formatNumber(data);
274vElement.html(vCount + ' Views');
275});
276});	
277};
278
279//////////////////////////////////////////////////////////////////////////////////////////////
280
281function WriteSocialBlock() {	
282var SocialBlock = "";
283SocialBlock += '<div class="SocialButtons">';
284//SocialBlock += '<div class="Facebook" title="Share on Facebook"></div>';
285SocialBlock += '<div class="BrighteonIO" title="Share on Brighteon IO"></div>';
286SocialBlock += '<div class="Twitter" title="Share on Twitter"></div>';
287SocialBlock += '<div class="Add2Any a2a_dd"></div>';
288SocialBlock += '<div class="Comments" title="Read Comments"></div>';
289SocialBlock += '<div class="Email" title="Email This"></div>';
290SocialBlock += '<div class="Print" title="Print This"></div>';
291SocialBlock += '</div>';
292document.write(SocialBlock);
293};
294
295//////////////////////////////////////////////////////////////////////////////////////////////
296
297function scrollToComments() {
298var aTag = $('.PostComments');
299$('html,body').animate({
300scrollTop: aTag.offset().top
301}, 'slow');
302};
303
304//////////////////////////////////////////////////////////////////////////////////////////////

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.