PageSourceSearch

https://www.research.news/Javascripts/SBA-WP-13.js

js research.news collected 2026-10-04 00:06:51 UTC 10,343 bytes, 313 lines download raw bytes

1//UPDATED ON 4/5/2017 @ 1:06PM
2
3jQuery(document).ready(function() {
4
5// ---------------------------------------------------------
6
7var d = new Date();
8var month = new Array();
9month[0] = "Jan";
10month[1] = "Feb";
11month[2] = "Mar";
12month[3] = "Apr";
13month[4] = "May";
14month[5] = "Jun";
15month[6] = "Jul";
16month[7] = "Aug";
17month[8] = "Sep";
18month[9] = "Oct";
19month[10] = "Nov";
20month[11] = "Dec";
21var y = month[d.getMonth()];
22
23// ---------------------------------------------------------
24
25SingleSBA('LB-1.xml','SBAMasthead');
26SingleSBA('MR-1-' + y + '.xml','SBAArticle');
27SingleSBA('MR-2-' + y + '.xml','SBARightTop');
28SingleSBA('MR-3-' + y + '.xml','SBARightBottom');
29
30// ---------------------------------------------------------
31
32});
33
34////////////////////////////////////////////////////////////////////////////////////////////////////////
35
36function shuffle(o){
37for(var j, x, i = o.length; i; j = parseInt(Math.random() * i), x = o[--i], o[i] = o[j], o[j] = x);
38return o;
39};
40
41////////////////////////////////////////////////////////////////////////////////////////////////////////
42
43//Check to see if it should be removed from article
44function KeywordCheck(vKeywords) {
45var vRemove = false;
46var vMetaKeywords = jQuery("meta[name='keywords']").attr("content");
47vMetaKeywords = vMetaKeywords.toLowerCase();
48var a = vKeywords.split(",");
49for (var x = 0, y = a.length; x < y; x++) {
50var vKey = a[x];
51vKey = vKey.trim();
52vKey = vKey.toLowerCase();
53if (vMetaKeywords.indexOf(vKey) >= 0) { // keyword found in metakeywords
54vRemove = true;	
55};
56};
57return vRemove;
58};
59
60////////////////////////////////////////////////////////////////////////////////////////////////////////
61
62//Check to see if it should be removed from article
63function ExpireCheck(vExpire) {
64var vRemove = false;
65var a = vExpire.split("/");
66var vMonth = (a[0] - 1); // Jan is 0, Dec is 11
67var vDay = a[1];
68var vYear = a[2];
69var vToday = new Date();
70var vExpireDate = new Date();
71vExpireDate.setFullYear(vYear, vMonth, vDay);
72if (vToday > vExpireDate) {
73vRemove = true;
74};
75return vRemove;
76};
77
78////////////////////////////////////////////////////////////////////////////////////////////////////////
79
80//shuffle items in xml, file, find divs with class name and insert image and link
81function SingleSBA(vFile,vDiv) {
82var vXMLPath = "xml/";
83var vImagePath = "images/";
84var vCount = 0;
85var vSelectorCount = 1;
86jQuery.get(vXMLPath + vFile,{},function(xml){
87var jQueryitems = shuffle(jQuery("item", xml));
88jQueryitems.each(function() {
89var x = jQueryitems[vCount];
90var vReserve = jQuery(x).attr('reserve');
91if (vReserve == null) {
92var vExpire = jQuery(x).attr('expire');
93var vNoFollow = jQuery(x).attr('nofollow');
94var vImage = jQuery(x).find('image').text();
95var vURL = jQuery(x).find('url').text();
96var vKeywords = jQuery(x).find('keywords').text();
97var vAlt = jQuery(x).find('alt').text(); 
98if (vAlt !='') {
99vAlt =	' alt="' + vAlt + '"';
100} else {
101vAlt = '';
102};
103vNoFollow = ' rel="nofollow"';
104var vRemove = false;
105if (vKeywords !="") {
106vRemove = KeywordCheck(vKeywords); // Keywords exist, check to see if it should be removed from article
107};
108if (vExpire !="") {
109vRemove = ExpireCheck(vExpire); // Expire date exists, check to see if it should be removed from article
110};
111if (vRemove == false) {
112//var vBlock = '<a href="' + vURL + '"' + vNoFollow + ' target="_blank"><img src="' + vImagePath + vImage + '" border="0"' + vAlt + '></a>';
113
114if (vDiv == 'SBAMasthead') {
115var vBlock = '<a href="' + vURL + '"' + vNoFollow + ' target="_blank"><img style="width:728px;height:auto" src="' + vImagePath + vImage + '" border="0"' + vAlt + '></a>';	
116} else {
117var vBlock = '<a href="' + vURL + '"' + vNoFollow + ' target="_blank"><img style="width:300px;height:auto" src="' + vImagePath + vImage + '" border="0"' + vAlt + '></a>';
118};
119
120
121
122jQuery('.' + vDiv + ':nth-child(' + vSelectorCount + ')').html(vBlock);
123vSelectorCount++;
124};
125};
126vCount++;
127});
128});
129
130};
131
132////////////////////////////////////////////////////////////////////////////////////////////////////////
133
134//shuffle items in xml, file, find div with class name and insert multiple images and links
135function MultiSBA(vFile,vDiv,vTotal) {
136var vXMLPath = "xml/";
137var vImagePath = "images/";
138var vBlock = "";
139var vCount = 0;
140jQuery.get(vXMLPath + vFile,{},function(xml){						   
141var jQueryitems = shuffle(jQuery("item", xml));
142jQueryitems.each(function(index, x) {
143var vReserve = jQuery(x).attr('reserve');
144if (vReserve == null) {
145var vExpire = jQuery(x).attr('expire');
146var vNoFollow = jQuery(x).attr('nofollow');
147var vImage = jQuery(x).find('image').text();
148var vURL = jQuery(x).find('url').text();
149var vKeywords = jQuery(x).find('keywords').text();
150var vAlt = jQuery(x).find('alt').text();
151if (vAlt !='') {
152vAlt =	' alt="' + vAlt + '"';
153} else {
154vAlt = '';
155};
156vNoFollow = ' rel="nofollow"';
157var vRemove = false;
158if (vKeywords !="") {
159vRemove = KeywordCheck(vKeywords);
160};
161if (vExpire !="") {
162vRemove = ExpireCheck(vExpire); // Expire date exists, check to see if it should be removed from article
163};
164if (vRemove == false) {
165vBlock += '<div><a href="' + vURL + '"' + vNoFollow + ' target="_blank"><img src="' + vImagePath + vImage + '" border="0"' + vAlt + '></a></div>';
166vCount++;
167};
168};
169jQuery('.' + vDiv).html(vBlock);
170});
171if (vCount < vTotal) {
172ReserveSBA(vFile,vDiv,vTotal,vCount,'M'); //Fill in removed spots with reserves
173};
174});
175};
176
177////////////////////////////////////////////////////////////////////////////////////////////////////////
178
179//shuffle items in xml, file, find divs with class name and insert image and link, then rotate each div every x seconds (vSpeed)
180function RotateSBA(vFile,vDiv,vSpeed) {
181var vXMLPath = "xml/";
182var vImagePath = "images/";
183var vBlock = "";
184var vCount = 100; // starting z-index
185jQuery.get(vXMLPath + vFile,{},function(xml){
186var jQueryitems = shuffle(jQuery("item", xml)); //Shuffle
187jQueryitems.each(function(index, x) {		 
188var vExpire = jQuery(x).attr('expire');
189var vNoFollow = jQuery(x).attr('nofollow');				 
190var vImage = jQuery(x).find('image').text();
191var vURL = jQuery(x).find('url').text();
192var vKeywords = jQuery(x).find('keywords').text();
193var vAlt = jQuery(x).find('alt').text();
194if (vAlt !='') {
195vAlt =	' alt="' + vAlt + '"';
196} else {
197vAlt = '';
198};
199vNoFollow = ' rel="nofollow"';
200var vRemove = false;
201if (vKeywords !="") {
202vRemove = KeywordCheck(vKeywords); // Keywords exist, check to see if it should be removed from article
203};
204if (vExpire !="") {
205vRemove = ExpireCheck(vExpire); // Expire date exists, check to see if it should be removed from article
206};
207if(vRemove == false) {
208vBlock += '<div style="position: absolute; top: 0px; left: 0px; z-index: ' + vCount + '; opacity: 100; display: block; visibility: visible;"><a href="' + vURL + '"' + vNoFollow + ' target="_blank"><img src="'  + vImagePath + vImage + '"' + vAlt + ' data-pin-no-hover="true"></a></div>';
209vCount = vCount - 1;
210};
211jQuery('.' + vDiv).html(vBlock);
212});
213});
214jQuery('.' + vDiv + ' > div:gt(0)').hide();
215setInterval(function() {
216if ( jQuery('.' + vDiv + ' div').length >1) { // If more than one image		
217jQuery('.' + vDiv + ' > div:first')
218.fadeOut(500)
219.next()
220.fadeIn(500)
221.end()
222.appendTo('.' + vDiv);
223} //
224},  vSpeed);
225jQuery('.' + vDiv).css("display","block");
226};
227
228////////////////////////////////////////////////////////////////////////////////////////////////////////
229
230//Generate random number, if percentage of image matches random number, show image
231function PercentageSBA(vFile,vDiv) {
232var vXMLPath = "xml/";
233var vImagePath = "images/";
234var vTotal = 1;
235var vCount = 0;
236var vCount2 = 0;
237var vNumber = Math.floor((Math.random() * 10000) + 1);
238jQuery.get(vXMLPath + vFile,{},function(xml){
239var vBlock;
240var jQueryitems = jQuery("item", xml);
241jQueryitems.each(function(index, x) {
242var vPercent = jQuery(x).attr('percent');
243vPercent = (vPercent * 100) + vCount;
244if (vNumber > vCount && vNumber <= vPercent) {
245var vExpire = jQuery(x).attr('expire');
246var vNoFollow = jQuery(x).attr('nofollow');		
247var vImage = jQuery(x).find('image').text();
248var vURL = jQuery(x).find('url').text();
249var vKeywords = jQuery(x).find('keywords').text();
250var vAlt = jQuery(x).find('alt').text();
251if (vAlt !='') {
252vAlt =	' alt="' + vAlt + '"';
253} else {
254vAlt = '';
255};
256vNoFollow = ' rel="nofollow"';
257var vRemove = false;
258if (vKeywords !="") {
259vRemove = KeywordCheck(vKeywords); // Keywords exist, check to see if it should be removed from article
260};
261if (vExpire !="") {
262vRemove = ExpireCheck(vExpire); // Expire date exists, check to see if it should be removed from article
263};
264if(vRemove == false) {
265vBlock = '<a href="' + vURL + '"' + vNoFollow + ' target="_blank"><img src="' + vImagePath + vImage + '" border="0"' + vAlt + '></a>';
266jQuery('.' + vDiv).html(vBlock);
267vCount2++;	
268};
269};
270vCount = vPercent;
271});
272if (vCount2 < vTotal) {
273ReserveSBA(vFile,vDiv,vTotal,vCount2,'S'); //Fill in removed spots with reserves
274};
275});
276};
277
278////////////////////////////////////////////////////////////////////////////////////////////////////////
279
280function ReserveSBA(vFile,vDiv,vTotal,vCount,vType) {
281var vXMLPath = "xml/";
282var vImagePath = "images/";
283var vBlock = jQuery('.' + vDiv).html();
284jQuery.get(vXMLPath + vFile,{},function(xml){
285var jQueryitems = shuffle(jQuery("item", xml));
286jQueryitems.each(function(index, x) {
287if (vCount < vTotal) {
288var vReserve = jQuery(x).attr('reserve');
289if (vReserve == "true") {
290var vExpire = jQuery(x).attr('expire');
291var vNoFollow = jQuery(x).attr('nofollow');	
292var vImage = jQuery(x).find('image').text();
293var vURL = jQuery(x).find('url').text();
294var vKeywords = jQuery(x).find('keywords').text();
295var vAlt = jQuery(x).find('alt').text();
296if (vAlt !='') {
297vAlt =	' alt="' + vAlt + '"';
298} else {
299vAlt = '';
300};
301vNoFollow = ' rel="nofollow"';
302if (vType =='M') {
303vBlock += '<div><a href="' + vURL + '"' + vNoFollow + ' target="_blank"><img src="' + vImagePath + vImage + '" border="0"' + vAlt + '></a></div>';
304} else {
305vBlock += '<a href="' + vURL + '"' + vNoFollow + ' target="_blank"><img src="' + vImagePath + vImage + '" border="0"' + vAlt + '></a>';
306};
307jQuery('.' + vDiv).html(vBlock);
308vCount++;
309};
310};
311});
312});
313};

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.