Sunday, September 28, 2014

Hear Web Days-speakers in pod – Internet World

‘; // This element ifogas in the body
  was target_element_selector = ‘# smart-in text-target’; // Id for the same element
  was article_body = jQuery (‘[class = "saplo: body"]‘); // Article Text Column
 
  // Selector video container in the body text or article image container
  was video_container_selector = ”
  + ‘#articleImageBlock Iframe [src * = "http://ljsp.lwcdn.com'], ‘
  + ‘#articleImageBlock Iframe [src * = "youtube.com"],’
  + ‘#articleImageBlock Iframe [src * = "vimeo.com"],’
  + ‘[Class = "saplo: body"] iframe [src * = "http://ljsp.lwcdn.com'], ‘
  + ‘[Class = "saplo: body"] iframe [src * = "youtube.com"],’
  + ‘[Class = "saplo: body"] iframe [src * = "vimeo.com"]‘;
 
  // Loading the video container
  was video_container = jQuery (video_container_selector);
 
  // Called to move the ad from the right column to the body text and display it
  injectAdToText function () {
  jQuery (target_element_selector) .append (smart_in_text_container);
  smart_in_text_container.show ();
  }
 
  // Function that makes it possible to search for the index with regex
  regexIndexOf function (string, regex, startpos) {
  was indexOf = string.substring (startpos || 0) .search (regex);
  return (indexOf & gt; = 0)? (IndexOf + (startpos || 0)): indexOf;
  }
 
 
  // Hides ad
  smart_in_text_container.hide ();
 
  // Run only if there is an article column without any existing video
  if (article_body.length === 1 & amp; & amp; video_container.length === 0) {
  
  // Gets into all the “sections” in the text (or rather, elements with the class “paragraphIntro”)
  was paragraph_array = article_body.find (‘FF + FF + .paragraphIntro’);
  
  // If paragraphs are more than 1
  if (paragraph_array.length & gt; 1) {
  
  was middle_p_nr = (Math.round ((paragraph_array.length / 2)) – 1);
 
  // Prints ad container in the middle of the article
  jQuery (paragraph_array [middle_p_nr]). before (target_element);
  
  // Paste the ad in annonsbeållaren
  injectAdToText ();
  }
 
  // If there are no sections are made to check NR2
  // Look with double line breaks between them
  else {
  
  // Retrieves the body of a string
  was article_text = article_body.html ();
 
 
  // Match all br tags with & amp; nbsp between themselves.
  was search_str = / (
) ( s?) * ( s?) * (
) / g; was current_index = regexIndexOf (article_text, search_str); was brbr_count = []; // Loops through the body and are looking for double line breaks while (current_index! == -1) {Brbr_count.push (current_index); current_index = regexIndexOf (article_text, search_str, (current_index + 1)); //} If there are multiple line breaks in the article if (brbr_count.length & gt; 0) {// Pick out a double line break in the middle, and save the index for this was middle_br_nr = (Math.round ((brbr_count.length / 2 )) – 1); was middle_index = brbr_count [middle_br_nr]; // Creates a new body of the ad container was new_text article_text.substr = (0, middle_index); new_text + = target_element; new_text + = article_text.substr (middle_index, article_text.length); // Replaces the old body text with the new article_body.html (new_text); // Inject the ad in the ad container injectAdToText (); Else {} // If no paragraphs or double br found in the body of the ad is placed at the bottom of the body text. console.log (‘SMART CLIP: Found no clauses inserted at the end of the body text’); article_body.append (target_element); injectAdToText (); //}}} If you already have a video if (video_container.length & gt; 0) {console.log (‘SMART CLIP: Döjs due to conflict with existing video’); }} ());

LikeTweet

No comments:

Post a Comment