﻿
MyFilter = function()
{
   MyFilter.initializeBase(this);
   this.set_isDom(false);
   this.set_enabled(true);
   this.set_name("RadEditor filter");
   this.set_description("RadEditor filter description");
}

MyFilter.prototype =
{
   SiteUrl : "",

   getHtmlContent : function(content)
   {
     var newContent = content;
     
     //Make changes to the content and return it

     if (this.SiteUrl.length > 0)
     {
         // replace all the absolute paths for links
         //newContent = newContent.replace("href=\"" + this.SiteUrl + "/", "href=\"/");

         // replace all the absolute paths for links         
         var myRegExp = new RegExp('href="' + this.SiteUrl, 'gi');
         newContent = newContent.replace(myRegExp, 'href="');

         // replace all the absolute paths for img src
         //newContent = newContent.replace("src=\"" + this.SiteUrl + "/", "src=\"/");
         
         // replace all the absolute paths for img src
         myRegExp = new RegExp('src="' + this.SiteUrl, 'gi');
         newContent = newContent.replace(myRegExp, 'src="');
     }

     return newContent;
   },
   
   getDesignContent : function(content)
   {
     var newContent = content;

     //Make changes to the content and return it

     if (this.SiteUrl.length > 0)
     {
         // replace all the absolute paths for links
         //newContent = newContent.replace("href=\"" + this.SiteUrl + "/", "href=\"/");

         // replace all the absolute paths for links         
         var myRegExp = new RegExp('href="' + this.SiteUrl, 'gi');
         newContent = newContent.replace(myRegExp, 'href="');

         // replace all the absolute paths for img src
         //newContent = newContent.replace("src=\"" + this.SiteUrl + "/", "src=\"/");
         
         // replace all the absolute paths for img src
         myRegExp = new RegExp('src="' + this.SiteUrl, 'gi');
         newContent = newContent.replace(myRegExp, 'src="');        
     }

     return newContent;
   }
}


