History
   Show Presentation
 
 
 dsn.min.inc.ORIGINAL
Home • Plugins • RWD-Plugins_Old • RWDConfig • RWDDigitalSign • js • OLD • GARBAGE 001 • dsn.min.inc.ORIGINAL
 




/*
*       Digital Signage 2.1A  LCORE VER.
*       --------------------------      
*       JQ vertical scroller script: http://buildinternet.com/project/totem/  (Totem Ticker) -MIT Lisc.
*       JSON Controller // XHR System : rob@firstclassdepot.com
*       
*       Grabs JSON file and uses it to set up Digital Signage.
*       Check JSON file, as of now, everything EXCEPT Ticker{} will be reloaded after all the content has scrolled.
*       
*/


(function( $ ){
        
        if(!$.omr){
                $.omr = {};
        }

        //Master Data Structures
        var tParams     = {};           //Ticker Params
        var iParams     = {};           //Ticker Item Params
        var pParams     = {};           //Page Params
        var hContent    = {};           //Header Content
        var fContent    = {};           //Footer Content
        var wContent    = {};           //Widget Content
        var lContent    = {};           //Logo Content
        var tElements   = {};           //Ticker Elements
        
        
        //12HR -> 24Hr CONVERSION LOOKUP
        var ac = {"12":  "00", "01":  "01", "02":  "02", "03":  "03", "04":  "04", "05":  "05", "06": "06", "07": "07", "08": "08", "09": "09", "10": "10", "11": "11"};
        var pc = {"12": "12", "01": "13", "02": "14", "03": "15", "04": "16", "05": "17", "06": "18", "07": "19", "08": "20", "09": "21", "10": "22", "11": "23"};
        var cv12 = {"AM": ac, "PM": pc};
        
        //24HR -> 12Hr CONVERSION LOOKUP
        var cv24 = {"00": "12", "01": "01", "02": "02", "03": "03", "04": "04", "05": "05", "06": "06", "07": "07", "08": "08", "09": "09", "10": "10", "11": "11", "12": "12", "13": "01", "14": "02", "15": "03", "16": "04", "17": "05", "18": "06", "19": "07", "20": "08", "21": "09", "22": "10", "23": "11"};


        $.omr.ds = function(el, options ) {
                var base = this;
                var counter =0;
                var full =0;
                
                //Define the DOM elements
                base.el = el;
                base.$el = $(el);
                
                // Add a reverse reference to the DOM object
                       base.$el.data("omr.ds", base);
                
                base.init = function(){
                       base.options = $.extend({},$.omr.ds.defaultOptions, options);
           
            //Define the ticker object
               base.ticker;

                        //Disable Caching
                        base.setAJAX();
                        
                        //Adjust the height of ticker if specified
                        base.format_ticker();
                        
                        //Setup navigation links (if specified)
                        base.setup_nav();
                        
                        //Start Data Poll Intreval
                        base.start_dataPollIntreval();
                                
                        //Start the ticker
                        base.start_ticker();

                        //Debugging info in console
                        //base.debug_info();
       };
                


                base.setAJAX = function(){
                $.ajaxSetup ({
                        // Disable caching of AJAX responses
                        cache: false,
                        timeout: 20000
                });
                };


                function sortElements(dsElements){
                                /**********************************************
                                //SORT AREA. AD | AM | PM  BY START TIME
                                ***********************************************/
                                
                                var adEvents = [];
                                var amTop = [];
                                var amEvents = [];
                                var pmEvents = [];
                                var pmTop = [];
                                var sorted = [];
                                
                                for (k in dsElements)
                                {
                                        var current = dsElements[k];
                                                
                                        if(current.alldayevent === true)
                                        {adEvents.push(current);}
                                        else
                                        {
                                                //WORKS WITH LPAD OR NO LPAD.
                                                var start = ''+current.start+'';
                                                var ampm = start.substring(start.length-2,start.length);

                                                if(parseFloat(start.substring(0,2)).toFixed(0) == 12 && ampm == "AM")
                                                        {amTop.push(current);}
                                                else if (parseFloat(start.substring(0,2)).toFixed(0) == 12 && ampm=="PM")
                                                        {pmTop.push(current);}
                                                else if(ampm == "AM")
                                                        {amEvents.push(current);}
                                                else
                                                        {pmEvents.push(current);}       
                                        }       
                                }

                                
                                // SORT COMPARATOR
                                function compare(a,b)
                                {               
                                  /* DEBUG ALERT */
                                  //alert(" .. ST:" + a.start.substring(0,2).toString().replace(":",'') + "AS : "+ parseInt(parseFloat(a.start.substring(0,2)).toFixed(0).toString().replace(":",''),10) + "    ||  ST:"  + b.start.substring(0,2).toString().replace(":",'') + "AS : " +   parseInt(parseFloat(b.start.substring(0,2)).toFixed(0).toString().replace(":",''),10));

                                  if (parseInt(parseFloat(a.start.substring(0,2)).toFixed(0).toString().replace(":",''),10) <  parseInt(parseFloat(b.start.substring(0,2)).toFixed(0).toString().replace(":",''),10))
                                        { return -1;}
                                  if (parseInt(parseFloat(a.start.substring(0,2)).toFixed(0).toString().replace(":",''),10) > parseInt(parseFloat(b.start.substring(0,2)).toFixed(0).toString().replace(":",''),10))
                                        { return 1;}
                                  return 0;             
                                }

                                amTop.sort(compare);
                                amEvents.sort(compare);
                                pmEvents.sort(compare);
                                pmTop.sort(compare);
                                sorted = adEvents.concat(amTop).concat(amEvents).concat(pmTop).concat(pmEvents);

                                return sorted;  
                        }
                        
        
        //.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.
        //     LOAD
        //.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.
                        
        base.loadParameters = function() {

                /**********************************************
                // GET TICKER ITEM PARAMETERS
                ***********************************************/
                $.get('<!--#echo var="config_parameter" -->',
                function(data){
                        iParams.src =data.Ticker.item['src'];
                        iParams.backgroundcolor =data.Ticker.item['background-color'];
                        iParams.backgroundopacity =data.Ticker.item['background-opacity'] -1;
                        iParams.timecolor =data.Ticker.item['time-color'];
                }, "json")
                .error(function(jqXHR, textStatus, errorThrown){
                        //alert(textStatus);
                        //alert(jqXHR.responseText);
                        //console.log("error " + textStatus);
                        //console.log("incoming Text " + jqXHR.responseText);
                });


                /**********************************************
                // GET TICKER PARAMETERS
                ***********************************************/
                $.get('<!--#echo var="config_parameter" -->',
                function(data){

                        tParams.show = data.Ticker['items-to-show'];
                        tParams.polltime = data.Ticker['polltime'];
                        tParams.speed = data.Ticker['speed'];
                        tParams.interval = data.Ticker['intreval'];
                        tParams.rowheight =data.Ticker['rowheight'];
                        tParams.direction = data.Ticker['scroll-direction'];
                        tParams.scrollOff = data.Ticker['scroll-off'];  
                        tParams.calendar_select = data.Ticker['calendar-select'];       
                        tParams.calendar_link = data.Ticker['calendar-link'];   
                        tParams.show_past = data.Ticker['show-past'];
                        tParams.time_diff=data.Ticker['time-diff'];
                        tParams.full_screen=data.Ticker['full-screen'];
                }, "json")
                .error(function(jqXHR, textStatus, errorThrown){
                        //alert(textStatus);
                        //alert(jqXHR.responseText);
                        //console.log("error " + textStatus);
                        //console.log("incoming Text " + jqXHR.responseText);
                });


                /**********************************************
                // GET PAGE PARAMETERS
                ***********************************************/
                $.get('<!--#echo var="config_parameter" -->',
                function(data){
                        pParams.width = data.Page['width'];
                        pParams.height = data.Page['height'];
                        pParams.title = data.Page['title'];
                        pParams.backgroundposition = data.Page['background-position'];
                        pParams.backgroundcolor = data.Page['background-color'];
                        pParams.backgroundimage = data.Page['background-image'];
                        pParams.fullscreenbg = data.Page['fullscreen-background'];
                        pParams.margin =data.Page['margin'];
                        pParams.padding = data.Page['padding'];

                }, "json")
                .error(function(jqXHR, textStatus, errorThrown){
                        //alert(textStatus);
                        //alert(jqXHR.responseText);
                        //console.log("error " + textStatus);
                        //console.log("incoming Text " + jqXHR.responseText);
                });     
        };
        

        base.loadContent = function() {
                /**********************************************
                // GET WIDGET CONTENT
                ***********************************************/
                $.get('<!--#echo var="config_parameter" -->',
                function(data){
                        wContent.src =data.Page.widget['src'];
                        wContent.width = data.Page.widget['width'];
                        wContent.height = data.Page.widget['height'];
                        wContent.displaylist = data.Page.widget['display-list'];
                        wContent.displaywidget = data.Page.widget['display-widget'];
                }, "json")
                .error(function(jqXHR, textStatus, errorThrown){
                        //alert(textStatus);
                        //alert(jqXHR.responseText);
                        //console.log("error " + textStatus);
                        //console.log("incoming Text " + jqXHR.responseText);
                });


                /**********************************************
                // GET HEADER CONTENT
                ***********************************************/
                $.get('<!--#echo var="config_parameter" -->',
                function(data){
                        hContent.text = data.Page.header['text'];
                        hContent.color = data.Page.header['color'];
                        hContent.fontsize = data.Page.header['font-size'];
                        hContent.fontfamily = data.Page.header['font-family'];  
                        hContent.textdecoration = data.Page.header['text-decoration'];
                        hContent.src =data.Page.header['src'];
                        hContent.position = data.Page.header['position'];
                        hContent.width = data.Page.header['width'];
                        hContent.height = data.Page.header['height'];
                        hContent.displaytime = data.Page.header['display-time'];
                }, "json")
                .error(function(jqXHR, textStatus, errorThrown){
                        //alert(textStatus);
                        //alert(jqXHR.responseText);
                        //console.log("error " + textStatus);
                        //console.log("incoming Text " + jqXHR.responseText);
                });


                /**********************************************
                // GET FOOTER CONTENT
                ***********************************************/
                $.get('<!--#echo var="config_parameter" -->',
                function(data){
                        fContent.text = data.Page.footer['text'];
                        fContent.height = data.Page.footer['height'];
                        fContent.displayfooter = data.Page.footer['display-footer'];
                }, "json")
                .error(function(jqXHR, textStatus, errorThrown){
                        //alert(textStatus);
                        //alert(jqXHR.responseText);
                        //console.log("error " + textStatus);
                        //console.log("incoming Text " + jqXHR.responseText);
                });


                /**********************************************
                // GET LOGO CONTENT
                ***********************************************/
                $.get('<!--#echo var="config_parameter" -->',
                function(data){
                        lContent.src = data.Page.logo['src'];
                        lContent.position = data.Page.logo['position'];
                        lContent.width = data.Page.logo['width'];
                        lContent.height = data.Page.logo['height'];

                }, "json")
                .error(function(jqXHR, textStatus, errorThrown){
                        //alert(textStatus);
                        //alert(jqXHR.responseText);
                        //console.log("error " + textStatus);
                        //console.log("incoming Text " + jqXHR.responseText);
                });
        
        };
                
                
                base.loadElements = function()
                {
        
                     if(typeof(base.options.calendar_link)!='undefined')
                      {

                        //Sel=0 :: FC
                        //Sel=1 :: GCAL
                        //Sel=2 :: CONFIG
                        var sel = (base.options.calendar_link.indexOf("google")<0)?0:1;


                        //CURRENT DATE-TIME VARS
                        var now = new Date();
                        var ch = now.getHours();
                        var cm = now.getMinutes();
                        var mm = (((now.getMonth()+1)).length==2)?(now.getMonth()+1):('0'+(now.getMonth()+1));
                        var dd = (((now.getDate()+2)).length==2)?(now.getDate()):('0'+(now.getDate()));
                        dd = dd.substring(dd.length-2,dd.length);


                        //CAL URL PARAMS INIT (XHR ENTRY)
                        //Note: If params is null, then eparams starts with '?'
                        var calURL = "";
                        var params = "";        
                        var eparams = "";
                        var url = "";


                        /**********************************************
                        //MASTER SWITCH
                        ***********************************************/        
                        switch(sel)
                        {
                                case 0:
                                /**********************************************
                                // [FC] First Class Calendar Elements
                                ***********************************************/        
                                 calURL = 'http://'+location.hostname + base.options.calendar_link;
                                 params = "";
                                 eparams = "";                                          
                                 url = calURL + params + eparams;                       
                        
                                $.get(url,function(data)
                                {

                                        /**********************************************
                                        // FC Pull
                                        ***********************************************/
                                        //DS ELEMENTS INTO ARRAY STRUCT
                                        var dsElements = [];

                                        for( k in data.Elements)
                                         {

                                                //WE WANT PROPER ELEMENTS ONLY
                                                if(typeof data.Elements[k]['no'] !== 'undefined')
                                                {
                                                        var msg = new Object();
                                                        var current = data.Elements[k];
        
                                                        msg.no = current['no'];
                                                                
                                                        //PARSE VARS FOR TIME
                                                        var tmin = "All Day";
                                                        var st = current['start_time'];
                                                        var p = st.indexOf(":");
                                                        var now = false;
                                                        
                                                        if(p<0)
                                                        {
                                                                        msg.alldayevent=true;
                                                                        msg.start = "";
                                                                        msg.end = "";
                                                                        msg.duration = "All Day";
                                                        }
                                                        else
                                                {               
                                                                        /**********************************************
                                                                        //PARSE THE TIME (12H)
                                                                        ***********************************************/        
                
                                                                        //START TIME EXPLODED (0L PADDED) LEN:8
                                                                        st = current['start_time'];
                                                                        p = st.indexOf(":");
                                                                        var s0 = (st.substring(0,p).length==1)?'0'+st.substring(0,p):st.substring(0,p);
                                                                        var s1 = st.substring(st.length-5,st.length-3);
                                                                        var s2 = st.substring(st.length-2,st.length);

                                                                        //END TIME EXPLODED (0L PADDED) LEN:8
                                                                        var en = current['end_time'];
                                                                        var d = en.indexOf(":");
                                                                        var e0 = (en.substring(0,d).length==1)?'0'+en.substring(0,d):en.substring(0,d);
                                                                        var e1 = en.substring(en.length-5,en.length-3);
                                                                        var e2 = en.substring(en.length-2,en.length);
                                                                                

                                                                        /**********************************************
                                                                        //CURRENT EVENT INDICATORS (BOOL1 && BOOL2)=OUT
                                                                        ***********************************************/
                                                                        var bool1 = (ch==parseInt(cv12[s2][s0],10))? ((cm>=parseInt(s1,10))?true:false):((ch>parseInt(cv12[s2][s0],10))?true:false);
                                                                        var bool2 = (ch==parseInt(cv12[e2][e0],10))? ((cm<=parseInt(e1,10))?true:false):((ch<parseInt(cv12[e2][e0],10))?true:false);
                                                                        msg.indicator = (bool1 && bool2);
                                                                                
                                                                                
                                                                        /**********************************************
                                                                        //CONVERT THE TIME TO 24Hr (For Duration)
                                                                        ***********************************************/
                                                                        //alert(s0 + ":" + s1 + s2 + " to " + e0 + ":" + e1 + e2);
                                                                        var s0i = parseInt(parseFloat(cv12[s2][s0],10).toFixed(0),10);
                                                                        var e0i = parseInt(parseFloat(cv12[e2][e0],10).toFixed(0),10);
                                                                                

                                                                        var hrs = 0;
                                                                        if(s0i >=13 && e0i <=11)
                                                                                {hrs = parseInt(24-s0i,10) + parseInt(e0i,10);}
                                                                        else
                                                                                {hrs = parseInt(e0i,10) - parseInt(s0i,10);}
                                                                                
                                                                        tmin = ((60*hrs) + (parseInt(e1,10) - parseInt(s1,10)));
                                                                        msg.alldayevent = false;
                                                                        msg.duration = Math.floor(tmin/60) + "Hr " +  (tmin%60) + "Min";
                                
                                                                        msg.start = (s0) + ":" + s1 + ((parseInt(s0i,10)<12)?" AM":" PM");                                                                  
                                                                        msg.end = (e0) + ":" + e1 + ((parseInt(e0i,10)<12)?" AM":" PM");                
                                                        }
                                                                
                                                                        
                                                                //msg.backgroundcolor = current['background-color'];
                                                                msg.title =  "<!--<img src= \"img/fc.png\"  style=\"width:30px;   height:30px; padding-top:4px; padding-right:4px; \"/>--> " + current['title'];
                                                                msg.subject = current['subject'];
                                                                msg.href = current['href'];
                                                                        
                                                                /**********************************************
                                                                //PAST EVENT CHECK
                                                                ***********************************************/
                                                                var past = (typeof(base.options.show_past) == "undefined")? true : base.options.show_past;
                                                                var bool3 = (ch==e0i)?((cm>parseInt(e1,10))?false:true):((ch>e0i)?false:true);
                                                                if((!past && bool3) || past || msg.alldayevent)
                                                                                {dsElements.push(msg);}
                                                }
                                        }

                                        tElements = sortElements(dsElements);
                                        
                                },'json');
                                break;

                                case 1:
                                /**********************************************
                                // [GCAL] Google Calendar Elements [CROSS DOMAIN/CROSS SITE SCRIPTING; TRANSPORT: JSONP (ALT)]
                                ***********************************************/        
                                
//TimeZone Issue (Non Persistent)

var o = base.options.time_diff;
o = parseInt(o,10)>0?('+'+o):(''+o);
o = o.length>2?o: o.substring(0,1) +'0' + o.substring(1,2);
o = o + ":00";
o = o.replace('+', '%2B');
//o = "%2D00:00";


                                //GCAL XHR PARAMS
                                var startmin = now.getFullYear() +"-" +mm+"-"+dd+"T00:01:00"+o;
                                var startmax = now.getFullYear() +"-" +mm+"-"+dd+"T23:59:59"+o;
                                //alert(startmin + "\n" + startmax);

                                var singleevents = "true";
                                var sortorder = "ascending";
                                var alt = "json";

                                //BUILD XHR URL
                                 //params = "?alt="+alt+"&start-min="+startmin+"&start-max="+startmax+"&sortorder="+sortorder;
                                params = "?alt="+alt+"&start-min="+startmin+"&start-max="+startmax;
                                 eparams = "";
                                 calURL = base.options.calendar_link;
                                 url = calURL + params + eparams;
        

                                $.get(url,function(data)
                                {               


                                        /* Note: No JSON Data Type, Responce is Text(?) And we use eval to get the JSON inside the callback function.
                                        (This is only relevant if using callback function (2.eparams) */        

                        //var data = eval(data);



                                        /* Note :: If there exists a event the night before at (XX:XX -> 00:00), it will display for one cycle and then get deleted. */
                                        //WE WANT PROPER ELEMENTS ONLY


                                        if(typeof(data.feed.entry) != 'undefined')
                                        {
                                                /**********************************************
                                                //GOOGLE CALENDAR DEV
                                                ***********************************************/        
                                                var dsElements = [];
                                                var calFullTitle = data.feed.title.$t;
                                                var calSubTitle = data.feed.subtitle.$t;
                                                var author = data.feed.author[0].name.$t;

                                                $.each(data.feed.entry,function(i,entry)
                                                {
                                                        var msg = new Object();
                                                        msg.no = entry.id.$t;   
                                                                                
                                                        var startTime;
                                                        var endTime;
var p =-2;
var n =0;

        
                                                        try
                                                        {
                                                        //PARSE VARS FOR TIME
startTime = entry.gd$when[0].startTime;
endTime = entry.gd$when[0].endTime;
p = startTime.indexOf("T");
n = startTime.indexOf(":",p);
}catch(err){}


//GOOGLE CALENDAR BUG FIX (FEED PARAM. BUG (start-min/max) All Day)
                                                        var fail = false;

                                                        if(p==-1)
                                                        {
                                                                if(startTime.substring(startTime.length-2)==dd)
                                                                {
                                                                        msg.alldayevent=true;
                                                                        msg.start = "";
                                                                        msg.end = "";
                                                                        msg.duration = "All Day";
                                                                }
else
{
        fail=true;
}
                                                        }
                                                        else
                                                        {
                                                                /**********************************************
                                                                //PARSE THE TIME (24H)
                                                                ***********************************************/        

                        //INDC 001
                                                                //START TIME EXPLODED (0L PADDED) LEN:5 (s0)
                        var s0 = startTime.substring(p+1,p+3);
                        var s1 = startTime.substring(n+1,n+3);

                        p = endTime.indexOf("T");
                        n = endTime.indexOf(":",p);
                                                                
                                                                //END TIME EXPLODED (0L PADDED) LEN:5  (e0)
                        var e0 = endTime.substring(p+1,p+3);
                        var e1 = endTime.substring(n+1,n+3);

                                                                /**********************************************
                                                                //CURRENT EVENT INDICATORS (BOOL1 && BOOL2)=OUT
                                                                ***********************************************/
                                                                var bool1 = (ch==parseInt(s0,10))? ((cm>=parseInt(s1,10))?true:false):((ch>parseInt(s0,10))?true:false);
                                                                var bool2 = (ch==parseInt(e0,10))? ((cm<=parseInt(e1,10))?true:false):((ch<parseInt(e0,10))?true:false);
                                                                msg.indicator = (bool1 && bool2);
                                                                        
                                                                /**********************************************
                                                                //DURATION COMPUTE
                                                                ***********************************************/
                                                                var s0i = parseInt(parseFloat(s0.substring(0,2)).toFixed(0),10);
                                                                var e0i = parseInt(parseFloat(e0.substring(0,2)).toFixed(0),10);
                                                                        
                                                                var hrs = 0;
                                                                if(s0i >=13 && e0i <=11)
                                                                        {hrs = parseInt(24-s0i,10) + parseInt(e0i,10);}
                                                                else
                                                                        {hrs = parseInt(e0i,10) - parseInt(s0i,10);}
                                                                        
                                                                var tmin = ((60*hrs) + (parseInt(e1,10) - parseInt(s1,10)));
                                                                msg.alldayevent = false;
                                                                msg.duration = Math.floor(tmin/60) + "Hr " +  (tmin%60) + "Min";
                                
                                                                msg.start = (cv24[s0]) + ":" + s1 + ((parseInt(s0i,10)<12)?" AM":" PM");                                                                         
                                                                msg.end = (cv24[e0]) + ":" + e1 + ((parseInt(e0i,10)<12)?" AM":" PM");          
                                                        }                       
                                                                
                                                        //msg.backgroundcolor = "#0064ce";
                                                        msg.title = "<!--<img src=\"img/gcal.jpg\" style=\"width:30px; height:30px; padding-top:4px; padding-right:4px; \"/>--> <a href="+entry.id.$t+">"+ entry.title.$t + "</a>";
                                                        msg.subject = entry.content.$t ;
                                                        msg.href = entry.id.$t;

                                                        /**********************************************
                                                        //PAST EVENT CHECK
                                                        ***********************************************/
                                                        var past = (typeof(base.options.show_past) == "undefined")? true : base.options.show_past;
                                                        var bool3 = (ch==e0i)?((cm>parseInt(e1,10))?false:true):((ch>e0i)?false:true);

                                                        if(((!past && bool3) || past || msg.alldayevent)&& !fail)
                                                        {dsElements.push(msg);}
                                                        
                                        });                     
                                        
                                }
                                tElements = sortElements(dsElements);
                                },'jsonp');
                                break;
                        
        
                                case 2:
                                        alert("iCAL PENDING ...");
                                break;
                        

                                default:
                                        alert("Configuration Error - Bad Calendar Selector");
                                break;
                        
                        }
                      }
                };
                
                
                //.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.
                //      [][][][][][][][][][] APPLY [][][][][][][][][][]
                //.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.
                
                base.applyParameters=function()
                {
                        /**********************************************
                        // APPLY TICKER PARAMETERS
                        ***********************************************/
                        //OTF = ON THE FLY AJAX

                        base.options.row_height          =       tParams.rowheight;                             //OK OTF
                        base.options.speed                       =          tParams.speed;                              //OK OTF
                        base.options.pad                         =       tParams.scrollOff;                             //OK OTF
                        base.options.calendar_link               =       tParams.calendar_link;                 //OK OTF
                        base.options.calendar_select             =       tParams.calendar_select;                       //OK OTF
                        base.options.show_past           =       tParams.show_past;                             //OK OTF
                        //base.options.max_items                 =       tParams.show;                          //NOT OTF       
                        //base.options.interval                  =       tParams.interval;                              //SET IN INTREVAL, CANNOT MODIFY
                        //base.options.direction                 =       tParams.direction;                             //SET IN INTREVAL, CANNOT MODIFY
                        //base.options.polltime                  =       tParams.polltime;                              //SET IN INTREVAL, CANNOT MODIFY
                        base.options.time_diff                  =       tParams.time_diff;
                        base.options.full_screen                =       tParams.full_screen;
                        
                        
                        /**********************************************
                        // APPLY HEIGHT TRANSFORMS
                        ***********************************************/
                        var h = (base.options.full_screen === true)?'auto' : ((base.options.full_screen===false)?(base.options.max_items * base.options.row_height.replace(/px/i, '')):('') );
$('#wrapper').css({"height" :h});
$('#vertical-ticker').css({"height" : h});      
$('#footer').css({"height" :fContent.height});


                        /**********************************************
                        // APPLY PAGE ATTRIBUTES
                        ***********************************************/        
$('#vertical-ticker').css({"background-color" : pParams.backgroundcolor});      
$('#pagewidth').css({"background-color" : pParams.backgroundcolor});    

                       document.title = pParams.title;

$(!pParams.fullscreenbg?'#pagewidth' : '#vertical-ticker').css({
"background-image" : "none",
"background-repeat": "repeat",
"background-position": "",
"margin" : "",
"padding" : ""
});     

$(pParams.fullscreenbg?'#pagewidth' : '#vertical-ticker').css({
"background-image" : "url('"+pParams.backgroundimage+"')",
"background-repeat": "repeat",
"background-position": pParams.backgroundposition,
"margin" : pParams.margin,
"padding" : pParams.padding

});     

                };
                
                
                base.applyContent=function()
                {

                        /**********************************************
                        //APPLY HEADER
                        ***********************************************/
                        var d = hContent.textdecoration=="Italic"?"font-style":( hContent.textdecoration == "bold" ?"font-weight":"text-decoration");
                        var j = (typeof(hContent.text)=="undefined"?"":hContent.text) ;
                        
                        //HF1


var builtHeader = "";

if(hContent.position == "top")
{
builtHeader = "<img src=\""+hContent.src+"\"    style=\"display:"+((hContent.src=="")?'none':'block')+"; width:"+hContent.width+";   height:"+hContent.height+";  \" />";
builtHeader+= "<span class=\"none\" style=\"text-align:left; color:"+hContent.color+"; font-size:"+hContent.fontsize+"; font-family:"+hContent.fontfamily+";"+d+":"+hContent.textdecoration+"; \">"+ j + "</span>";
}
else if (hContent.position == "bottom")
{
builtHeader = "<span style=\"text-align:left; color:"+hContent.color+"; font-size:"+hContent.fontsize+"; font-family:"+hContent.fontfamily+";"+d+":"+hContent.textdecoration+"; \">"+ j + "</span>";
builtHeader += "<img src=\""+hContent.src+"\"    style=\"display:"+((hContent.src=="")?'none':'block')+"; width:"+hContent.width+";   height:"+hContent.height+";  \" />";
}
else if (hContent.position == "left" || hContent.position == "right")
{
builtHeader ="<img src=\""+hContent.src+"\"    style=\"float:"+hContent.position+";  display:"+((hContent.src=="")?'none':'block')+"; width:"+hContent.width+";   height:"+hContent.height+";  \" /><p style=\" padding:0px; margin:0px;  text-align:left; color:"+hContent.color+"; font-size:"+hContent.fontsize+"; font-family:"+hContent.fontfamily+";        "+d+":"+hContent.textdecoration+";  \">"+ j + "</p>";
}


                        (hContent.src == "")?$('#top > img').hide():$('#top > img').show();

                        if(document.getElementById('header').innerHTML != builtHeader)
                                {document.getElementById('header').innerHTML = builtHeader;}


                        /**********************************************
                        //APPLY LOGO
                        ***********************************************/
                        var builtLogo ="<img src=\""+lContent.src+"\"    style=\"width:"+lContent.width+";   height:"+lContent.height+";\" />";
                var sp = "logo_bottom"; 


                if(lContent.position == 'top')
                {
                        $('#logo_top').css({"display" :"block"});
                        $('#logo_bottom').css({"display" :"none"});
                         sp = "logo_top";       
                }
                else
                {
                        $('#logo_top').css({"display" :"none"});
                        $('#logo_bottom').css({"display" :"block"});
                                 sp = "logo_bottom";
                }

                        (lContent.src == "")?$('#'+sp).hide():$('#'+sp).show();

                        if(document.getElementById(sp).innerHTML != builtLogo)
                                {document.getElementById(sp).innerHTML = builtLogo;}
                        



                        /**********************************************
                        //APPLY FOOTER
                        ***********************************************/
                        if(fContent.displayfooter==1)
                        {
                                //$('#footer').show();
        $('#footer').css({"display" :"block"});

                                var builtFooter ="<p>"+fContent.text+"</p>";
                                if(document.getElementById('footer').innerHTML != builtFooter)
                                        {document.getElementById('footer').innerHTML = builtFooter;}
                        }
                        else
                        {
                                //$('#footer').hide();
        $('#footer').css({"display" :"none"});
                        }
                        




                        /**********************************************
                        //APPLY WIDGET
                        ***********************************************/
                        if(wContent.displaywidget ==1)
                        {

                                //Frame Size
                        var h = wContent.height;
                        var w = wContent.width;

                                //Frame Source
                        var x = "/plugins/RWDDigitalSign/PreDefined_Widgets/" +(  (wContent.src=== "")?( "?plugin=RWDDigitalSign&Templates=WidgetLists&panel_height="+h+"&panel_width="+w) :(wContent.src)  );

                        //Strip Google Branding
function stripGoogle()
{
                                            if ($($('#frame')).contents().find('tr:last-child').text() == "Gadgets powered by Google")
                                        {
                                                try
                                                {
                                                        $($('#frame')).contents().find('tr:first-child').remove();
                                                        $($('#frame')).contents().find('tr:last-child').remove();
                                                }
                                catch(err){}
                                        }
}

                        //Frame Sizing Function
                        function sizeFrame(h,w)
                        {

                //Frame Sizing width
                if(w=="auto"){$('#frame').width($($($('#frame'))).contents().width());}
else {$('#frame').width(w);}

                                        //Frame Sizing height
                if(h=="auto") {$('#frame').height($($($('#frame'))).contents().height());}
                                        else{$('#frame').height(h);}

                                        //alert("W: " + wContent.width + ",H: " +wContent.height );
                //alert("CW: " +$($($('#frame'))).contents().width() + ",CH: "+ $($($('#frame'))).contents().height() );

                $('#widget').height($($($('#frame'))).contents().height());
                $('#widget').width($($($('#frame'))).contents().width());
                        }

                        //IE BG-Color Fix, ETC.
function cleanWidget()
{
        $($($('#frame'))).contents().find("body").css({"margin-left":"0px"});
        $($($('#frame'))).contents().find("body").css({"background-color":"transparent"});
        //$($($('#frame'))).contents().find("iframe").attr({"scrolling":"no"});
}



                        //Frame Loader
                        if(x != $($('#frame')).attr('src') && typeof(wContent.src) != "undefined")
                {
                        $($('#frame')).attr('src',x);

                        //When Loaded,
                                        $('iframe#frame').load(function()
                                       Â  {
                stripGoogle();
                                        sizeFrame(h,w);
                cleanWidget();
                                       Â  });

                }
                
                sizeFrame(h,w);
                        //$('#widget').show();
        $('#widget').css({"display" :"block"});



}
else
                {       //$('#widget').hide();  
        $('#widget').css({"display" :"none"});
                }

                };
                



                base.applyElements=function()
                {       
                        //Apply the structure to the HTML doc
                        var tickerHTML = "";
                        for (i in tElements)
                        {
        
tickerHTML+= "<li class=\"content\"><div class=\"tickeritem\"   style=\"height:"+base.options.row_height+";   background-image: url('"+iParams.src+"'); background-color:"+ iParams.backgroundcolor+";   opacity:"+(iParams.backgroundopacity/100)+";   filter: alpha(opacity="+(iParams.backgroundopacity)+");    \"  >";
                                
//tickerHTML += "<li class=\"content\"><div class=\"background\" style=\"z-index:-1; height:"+base.options.row_height+";   background-image: url('"+iParams.src+"'); background-color:"+ iParams.backgroundcolor+";   opacity:"+(iParams.backgroundopacity/100)+";   filter: alpha(opacity="+(iParams.backgroundopacity)+");    \" ></div><div class=\"tickeritem\"   style=\"z-index:5; top:0px; left:0px; height:"+base.options.row_height+";  \"  >";

                                if(tElements[i].alldayevent)
                                {
                                        tickerHTML += "<div class= \"tmsg\"><div class=\"timestamp\" style=\"color:#ff1300;    text-transform: capitalize;\">All Day</div></div>";
                                }
                                else
                                {
                                        if(tElements[i].indicator)
                                                {tickerHTML += "<div class= \"tmsg\"> <img src= \"<!--#echo var="plugin_dir"-->img/bell.png\"   style=\"float:left; width:auto;   height:auto; padding-left:2px;\" />      <div class=\"timestamp\" style=\"color:#aaaadd;\">"+tElements[i].start+"</div></div>";}
                                        else
                                                {tickerHTML += "<div class= \"tmsg\"><div class=\"timestamp\" style=\"   color:#aaaadd;\">"+tElements[i].start+"</div></div>";}                 
                                }
                                
                                tickerHTML+="<div class=\"dmsg\">";
                                tickerHTML += "<div class=\"eventtitle\" style=\" background-color:"+ iParams.timecolor+"\">"+tElements[i].title+"</div><!--<img src= \"img/clock.png\"   style=\"float:left; width:auto;   height:auto; padding-top:3px;\" />-->  ";
                                //tickerHTML += "<div class=\"eventmessage\"  >"+tElements[i].start+" -> "+ tElements[i].end+"</div>";
                                
                                if(tElements[i].alldayevent) {tickerHTML += "<div class=\"eventmessage\" > All Day Event</div>";}
                                else {tickerHTML += "<div class=\"eventmessage\">"+tElements[i].start+" to "+ tElements[i].end+ "  -  ("+tElements[i].duration+")</div>";}
                        
                                //tickerHTML += "<div class=\"eventmessage\">"+tElements[i].subject+"</div>";
                                //tickerHTML += "<div class=\"eventnote\">"+tElements[i].href+"</div>";
                                tickerHTML += "</div><br clear=\"all\"> </div></li>";
                        }

                        
                //Detect Change && Pad Elements
                if(document.getElementById('vertical-ticker').innerHTML != tickerHTML)
                {
                        document.getElementById('vertical-ticker').innerHTML = tickerHTML;              
                        
                        if(base.options.pad)
                        {
                                var mi = (base.options.full_screen===true)?(   Math.floor(  parseInt(((typeof(window.innerHeight)=='undefined'?document.documentElement.clientHeight:window.innerHeight)-$('#header').height()-$('#footer').height()) ,10)    /    parseInt(base.options.row_height.replace(/px/i, '') ,10))):(base.options.max_items);


                                var output = "";
                                for (var i=0; i<mi; i++)
                                {
                                        /**********************************************
                                        //BLANK STYLE, STYLE AS NOTHING
                                        ***********************************************/
                                        
                                        output += "<li class=\"padding\"><div class=\"none\" style=\"height:"+base.options.row_height+"; \">";
                                        output += "<div class=\"dmsg\">";               
                                        output += "<div class=\"none\">  </div>";
                                        output += "<div class=\"none\">  </div>";
                                        output += "<div class=\"none\">  </div>";
                                        output += "<div class=\"none\">  </div>";
                                        output += "</div><br clear=\"all\"> </div></li>";
                                }
                                document.getElementById('vertical-ticker').innerHTML += output;


                        }
                }                       

                if (base.options.direction == 'down')
                {full = $("li").length;}
                else
                {full = 2* $("li").length;}
                        
                };
                                        

                
                //.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.
                //  [][][][][][][][][][] COMBINED FUNC [][][][][][][][][][]
                //.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo. 
                
                base.getData = function()
                {
                        //alert("LOAD");
                        base.loadParameters();
                        base.loadContent();
                        base.loadElements();
                };
                
                
                base.applyData = function()
                {
                        //alert("APPLY");
                        base.applyParameters();
                        base.applyContent();
                        base.applyElements();
                };
                

                                        
                //.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.
                // [][][][][][][][][][] DS CLOCK INTREVAL [][][][][][][][][][]
                //.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.                 
                
                base.updateClock = function(){  
                        if (hContent.displaytime==1)
                        {
                                var mydate=new Date();
                                var year=mydate.getYear();
                                if (year < 1000)
                                {year+=1900;}
                                var day=mydate.getDay();
                                var month=mydate.getMonth();
                                var daym=mydate.getDate();
                                if (daym<10)
                                {daym="0"+daym;}
                
                                var hour = mydate.getHours();
                                var min = mydate.getMinutes();
                                var sec = mydate.getSeconds();
                                var time;
                                
                                if(min<=9){min="0"+min;}
                                if(sec<=9){sec ="0"+sec;}
                                        if(hour>12){hour=hour-12;add=" <span class='ampm'>pm</span>";}
                                        else{add=" <span class='ampm'>am</span>";}
                                        //else{hour=hour;add=" <span class='ampm'>am</span>";}

                                if(hour==12){add="<span class='ampm'>pm</span>";}
                                if(hour==0){hour="12";} time=((hour<=9)?"0"+hour:hour)+":"+min+add;
                                
                                var dayarray=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
                                var montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December");
                                
                                document.getElementById('theTime').innerHTML=time;
                                document.getElementById('theDate').innerHTML="<small><font color='white' face='Arial'><b>"+dayarray[day]+", "+montharray[month]+" "+daym+", "+year+"</b></font></small>";

                        var mc =  ($('#top').css('height').replace(/px/i,'')/2) -  ($('.dateTime').css('height').replace(/px/i,'')/2);


$('.dateTime').css({"top" :   (mc<0)?'0px':mc + 'px'     });

                        }
                        else
                        {
                                document.getElementById('theTime').innerHTML="";
                                document.getElementById('theDate').innerHTML="";
                        }
                };
                                
                base.start_dataPollIntreval = function (){
                        base.getData();
                        base.applyData();
                
                        $('#pagewidth').show();

                        setInterval(base.updateClock, 1000);
                        setInterval(base.getData, base.options.polltime);

                };
                                
                base.start_ticker = function(){
                        
                        //Clear out any existing interval
                        clearInterval(base.ticker);

                        if (base.options.direction == 'down') {
                                //If the direction has been set to up
                                base.ticker = setInterval(function() {
                                
                                        /**********************************************
                                        //COUNTER BASED CONTENT RELOAD CONTENT SCRL UP
                                        ***********************************************/
                                
                                                /* ****** ACTIVE *********  */
                                                //alert(counter + ',' + full);
                                                if (counter == full-1 || (full<=base.options.max_items))
                                                {
                                                        counter=0;      
                                                        base.applyData();
                                                }
                                                else
                                                {
                                                        counter++;      
                                                }                                                                               

                                                
                                        //ok.
                                        if(full>base.options.max_items)
                                        {
                                                base.$el.find('li:last-child').detach().prependTo(base.$el).css('marginTop', '-' + base.options.row_height);
                                                base.$el.find('li:first-child').animate({
                                                        marginTop: '0px'
                                                }, base.options.speed, function () {
                                                        //Callback functions go here
                                                });
                                
                                        }
                                
                                        
                                }, base.options.interval);
                        }else if(base.options.direction=='up'){
                                //Otherwise, run the default of down
                                base.ticker = setInterval(function() {

                                        /**********************************************
                                        //COUNTER BASED CONTENT RELOAD CONTENT SCRL DOWN
                                        ***********************************************/                                                
                                        
                                                /* ****** ACTIVE *********  */
                                                //alert(counter + ',' + full);
                                                if (counter > full-2)
                                                {
                                                        counter=0;      
                                                        //document.getElementById('vertical-ticker').innerHTML = ticker_buffer; 
                                                        
                                                        base.applyData();                                                                       
                                                        //base.applyParameters();
                                                        //base.applyContent();
                                                        //base.applyElements();
                                                }
                                                else
                                                {
                                                        counter++;      
                                                }                                                       

                                        //ok.
                                        if(full >2*base.options.max_items)
                                        {
                                                base.$el.find('li:first-child').animate({
                                                        marginTop: '-' + base.options.row_height
                                                }, base.options.speed, function() {
                                                        $(this).detach().css('marginTop', '0').appendTo(base.$el);                                      
                                                        counter++;                                                                                       
                                                });
                                        }
                                        
                                }, base.options.interval);
                        }
                };
                
                base.reset_interval = function(){                       
                        clearInterval(base.ticker);
                        counter=0;
                        base.start_ticker();
                };
                        
                base.stop_interval = function(){
                        clearInterval(base.ticker);
                        counter=0;
                };
                
                base.format_ticker = function(){
                
                           if(typeof(base.options.max_items) != "undefined" && base.options.max_items !== null)
                        {       
                                var mi = (base.options.full_screen===true)?('auto'): ((base.options.max_items * base.options.row_height.replace(/px/i, ''))  + 'px');
                                base.$el.css({
                                        height          : mi,
                                        overflow        : 'hidden'
                                });
                        }
                        else
                        {
                                //No heights were specified, so just doublecheck overflow = hidden
                                base.$el.css({
                                        overflow        : 'hidden'
                                });
                        }       
                };
        
                base.setup_nav = function(){
                        
                        //Stop Button
                        if (typeof(base.options.stop) != "undefined"  && base.options.stop != null){
                                $(base.options.stop).click(function(){
                                        base.stop_interval();
                                        return false;
                                });
                        }
                        
                        //Start Button
                        if (typeof(base.options.start) != "undefined"  && base.options.start != null){
                                $(base.options.start).click(function(){
                                        base.start_ticker();
                                        return false;
                                });
                        }
                        
                        //Previous Button
                        if (typeof(base.options.previous) != "undefined"  && base.options.previous != null){
                                $(base.options.previous).click(function(){
                                        base.$el.find('li:last-child').detach().prependTo(base.$el).css('marginTop', '-' + base.options.row_height);
                                        base.$el.find('li:first-child').animate({
                                        marginTop: '0px'
                                    }, base.options.speed, function () {
                                        base.reset_interval();
                                    });
                                    return false;
                                });
                        }
                        
                        //Next Button
                        if (typeof(base.options.next) != "undefined" && base.options.next != null){
                                $(base.options.next).click(function(){
                                        base.$el.find('li:first-child').animate({
                                                marginTop: '-' + base.options.row_height
                                }, base.options.speed, function() {
                                    $(this).detach().css('marginTop', '0px').appendTo(base.$el);
                                    base.reset_interval();
                                });
                                return false;
                                });
                        }
                        
                        //Stop on mouse hover
                        if (typeof(base.options.mousestop) != "undefined" && base.options.mousestop === true) {
                                base.$el.mouseenter(function(){
                                        base.stop_interval();
                                }).mouseleave(function(){
                                        base.start_ticker();
                                });
                        }
                        
                        /*
                                TO DO List
                                ----------------
                                Add a continuous scrolling mode
                        */
                        
                };
                
                base.debug_info = function(){
                        //Dump options into console
                        console.log(base.options);
                };
                
                //Make it go!
                base.init();
 };
 
  $.omr.ds.defaultOptions = {
               message         :       'Ticker Loaded',                /* Disregard */
               next                    :       null,                           /* ID of next button or link */
               previous                :       null,                           /* ID of previous button or link */
               stop                    :       null,                           /* ID of stop button or link */
               start                   :       null,                           /* ID of start button or link */
               row_height              :       '100px',                        /* Height of each ticker row in PX. Should be uniform. */
               speed                   :       800,                            /* Speed of transition animation in milliseconds */
               interval                        :       4000,                           /* Time between change in milliseconds */
                max_items               :       null,                           /* Integer for how many items to display at once. Resizes height accordingly (OPTIONAL) */
                mousestop               :       false,                          /* If set to true, the ticker will stop on mouseover */
                direction               :       'down',                         /* Direction that list will scroll */           
                polltime                        :       2000,                           /* TIME OF DATA POLL */         
                pad                     :       true,                           /* Pad Data? */
                calendar_select         :       '',                             /* GCAL || FC || CONFIG */
                calendar_link           :       '',                             /* URL || fcCal || CONFIG */
                show_past               :       false,                          /* Show events in the day that have already passed */
                full_screen             :       false,                          /* Full Screen Mode */
                time_diff               :       '-5'
 };
 
  $.fn.ds = function( options ){
   return this.each(function(){
       (new $.omr.ds(this, options));
       });
 };
 
})( jQuery );