Plugin Directory

Changeset 203254

Timestamp:
02/08/2010 02:32:43 PM (15 years ago)
Author:
ShaneF
Message:

first pass at the new code for the flash charts. unsure if it works. Should in theory. :)

Location:
woopra/trunk
Files:
2 added
1 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • woopra/trunk/css/analytics.css

    r200971 r203254  
    123123 */
    124124
    125 .woopra_table {
     125.woopratable {
    126126    width: 100%;
    127127}
    128128
    129129
    130 .woopra_table td, .woopra_table th {
     130.woopratable th {
    131131    height: 20px;
    132132    padding: 5px;
     
    163163}
    164164
    165 .wlinechart {
     165.w {
    166166    text-align: center;
    167167    padding: 5px !important;
  • woopra/trunk/inc/admin.php

    r201117 r203254  
    185185           
    186186            /** jQuery Scripts */
    187             wp_enqueue_script( 'woopra-analytics',  $plugin_url. '/js/jquery.analytics.js',     array('jquery') );
     187            wp_enqueue_script( 'woopra-analytics',  $plugin_url. '/js/jquery.analytics.js',     array('jquery') );
    188188            wp_localize_script( 'woopra-analytics',
    189189                'woopraL10n',
     
    234234                    )
    235235            );
    236            
    237             // ** jQuery UI Datepicker **/
    238             wp_enqueue_script( 'woopra-datepicker', $plugin_url . '/js/ui.datepicker.js',       array('jquery') );
    239                        
    240             // @todo Update with Flash Version
    241             wp_enqueue_script( 'woopra-swfobject',  $plugin_url . '/js/swfobject.js'                            );
     236            // ** jQuery Plugins Needed **/
     237            wp_enqueue_script( 'woopra-md5',        $plugin_url . '/js/jquery.md5.js',          array('jquery', 'woopra-analytics') );
     238            wp_enqueue_script( 'woopra-flash',      $plugin_url . '/js/jquery.flash.js',        array('jquery', 'woopra-analytics') );
     239            wp_enqueue_script( 'woopra-datepicker', $plugin_url . '/js/ui.datepicker.js',       array('jquery', 'woopra-analytics') );
     240           
    242241            //  *** SYTLE SHEETS ***/
    243242            wp_enqueue_style( 'woopra-analytics',   $plugin_url . '/css/analytics.css'                          );
  • woopra/trunk/inc/render.php

    r201708 r203254  
    226226        arsort($entries);   // force arsort.
    227227    ?>
    228         <table class="woopra_table" width="100%" cellpadding="0" cellspacing="0">
     228        <table class="woopratable" width="100%" cellpadding="0" cellspacing="0">
    229229            <tr>
    230230                <th class="text-header"><?php _e("Day", 'woopra') ?></th>
     
    241241               
    242242                //  Time Code
     243
    243244                //$timespentstring = $this->woopra_ms_to_string((int) $entry['totalTimeSpent']);
    244                 //  Vistor Code
     245               
     246                //  Visitors Code
    245247                $newvisitors = (int) $entry['totalNewVisitors'];
    246248                $visitors = (int) $entry['totalVisitors'];
    247249               
     250
    248251                $visitorsstring = "-";
    249252                if ($newvisitors <= $visitors && $visitors != 0) {
     
    253256                //  Page Views Code
    254257                $pageviews = (int) $entry['totalPageviews'];
     258
    255259                //  Percent Code
    256260                $percent = round($pageviews*100/$max);
    257261               
    258                 $hashid = $this->woopra_friendly_hash('GLOBALS');
     262                //  Hash ID
     263                $hashid = $this->woopra_friendly_hash($this->api_page);
    259264               
    260265                ?>
     
    264269                    <td class="text-item"><?php echo $visitorsstring; ?></td>
    265270                    <td class="text-item"><?php echo number_format($visitors); ?></td>
    266                     <td class="text-item highlight"><a href="#" onclick="return expandByDay('GLOBALS', '<?php echo $hashid; ?>', <?php echo $counter; ?>, <?php echo $entry['index']; ?>)"><?php echo number_format($pageviews); ?></a></td>
     271                    <td class="text-item highlight"><a href="#" onclick="return expand; ?>)"><?php echo number_format($pageviews); ?></a></td>
    267272                    <td class="bar"><?php echo $this->woopra_bar($percent); ?></td>
    268273                </tr>
    269                 <tr id="wlc-<?php echo $hashid; ?>-<?php echo $counter; ?>" style=" height: 120px; display: none;">
    270                     <td class="wlinechart" id="linecharttd-<?php echo $hashid; ?>-<?php echo $counter ?>" colspan="6"></td>
     274                <tr id="w-<?php echo $hashid; ?>-<?php echo $counter; ?>" style=" height: 120px; display: none;">
     275                    <td class="wtd-<?php echo $hashid; ?>-<?php echo $counter ?>" colspan="6"></td>
    271276                </tr>
    272277            <?php
     
    327332        <?php
    328333    }
    329    
    330     /**
    331      * Render Referrers Section
    332      * @return
    333      * @param object $entries
    334      * @param object $key
    335      */
    336     function render_referrers($entries, $key) {
    337        
    338         ?>
    339         <table class="woopra_table" width="100%" cellpadding="0" cellspacing="0">
    340         <tr>
    341             <th>&nbsp;</th>
    342             <th class="text-header"><?php _e('Referrer', 'woopra'); ?></th>
    343             <th class="text-header" width="100"><?php _e('Hits', 'woopra'); ?></th>
    344             <th width="400">&nbsp;</th>
    345         </tr>
    346         <?php
    347        
    348         $counter = 0;
    349         $sum = $this->woopra_sum($entries, 'vts');
    350        
    351         foreach($entries as $index => $entry) {
    352             $name = urldecode($entry['name']);
    353             $hits = (int) $entry['vts'];
    354             $meta = urldecode($entry['meta']);
    355            
    356             $percent = 0;
    357             if ($sum != 0)
    358                 $percent = round($hits*100/$sum);
    359            
    360             $hashid = $this->woopra_friendly_hash($key);
    361             ?>
    362             <tr<?php echo (($counter++%2==0) ? " class=\"even_row\"" : "" ); ?>>
    363                 <td class="index"><?php echo $counter; ?></td>
    364                 <td><span class="ellipsis"><a href="<?php echo $name; ?>" target="_blank"><?php echo $this->woopra_render_name($key, $name, $meta); ?></a></span></td>
    365                 <td width="100" class="text-item highlight"><a href="#" onclick="return expandByDay('<?php echo $key; ?>', '<?php echo $hashid; ?>', <?php echo $counter; ?>, <?php echo $entry['index']; ?>)"><?php echo $hits; ?></a></td>
    366                 <td class="bar"><?php echo $this->woopra_bar($percent) ?></td>
    367             </tr>
    368             <tr id="wlc-<?php echo $hashid; ?>-<?php echo $counter ?>" style=" height: 120px; display: none;"><td class="wlinechart" id="linecharttd-<?php echo $hashid ?>-<?php echo $counter; ?>" colspan="4"></td></tr>
    369             <tr id="refexp-<?php echo $hashid; ?>-<?php echo $counter; ?>" style="display: none;"><td colspan="4" style="padding: 0;"><div id="refexptd-<?php echo $hashid; ?>-<?php echo $counter; ?>"></div></td></tr>
    370             <?php
    371         }
    372         ?>
    373         </table>
    374         <?php
    375     }
    376    
     334       
    377335    /**
    378336     * Render the chart data format. Using Open-Flash-2 PHP Librarys
  • woopra/trunk/js/jquery.analytics.js

    r201084 r203254  
    3030   
    3131    var pageKeys = new Array();
     32
    3233   
    3334    var defaultSubTab = new Array();
     
    8889        //  Create API Key Array
    8990        pageKeys[superid + '-' + id] = keys;
     91
     92
     93
     94
    9095       
    9196        //  If the 'defaultSubTab' tab is null for this super id, set it to the id.
     
    221226            },
    222227            function(returned_data) {
    223                 if (returned_data != null)
     228                if (returned_data != null) {
     229                    //  Return the data..
    224230                    jQuery('#woopra-data-' + area).html(returned_data);
    225                 else
     231               
    226232                    jQuery('#woopra-data-' + area).html(woopraL10n.error);
     233
    227234            }
    228235        );
     
    231238   
    232239    /**
    233      * Debug Function!
     240     * Expand Line Chart for Rendering the Flash Chart
     241     * @param {Object} key
     242     * @param {Object} hashid
     243     * @param {Object} id
     244     */
     245    function expandLineChart(key, hashid, id) {
     246       
     247        if ( jQuery('#woopra-chart-line-tr-' + hashid + '-' + id).attr('class') == 'loaded' )
     248        {
     249            // Hide the 'tr'
     250            jQuery('#woopra-chart-line-tr-' + hashid + '-' + id).attr("style", "display: none;").removeAttr("class");
     251            // Clear the flash element. So it can be reloaded at a future time.
     252            jQuery('#woopra-chart-line-td-' + hashid + '-' + id).html();
     253            // Return False
     254            return false;
     255        }
     256       
     257        //  Show Chart Line 'tr'
     258        jQuery('#woopra-chart-line-tr-' + hashid + '-' + id).attr("style", "display: table-row;").addClass("loaded");
     259       
     260        var phpfile = woopraL10n.siteurl + '/wp-admin/admin-ajax.php?action=woopra&datatype=flash&apikey=' + woopradefaultL10n.apikey + '&id=' + index + '&wkey=' + key + '&date_format=' + date_format + '&from=' + date_from + '&to=' + date_to;
     261       
     262        //  Flash jQuery Code
     263        jQuery('#woopra-chart-line-td-' + hashid + '-' + id).flash({
     264            src: woopraL10n.siteurl + '/flash/open-flash-chart.swf',
     265            data-file: escape(phpfile),
     266            width: 968,
     267            height: 110,
     268            quality: 'best',
     269            bgcolor: '#FFFFFF',
     270            allowFullScreen: 'false',
     271            menu: 'false',
     272            allowScriptAccess: 'sameDomain',
     273            wmode: 'transparent',
     274            expressInstall: true
     275        }, {
     276            version: 10
     277        },
     278        function(htmlOptions){
     279            jQuery(this).html(jQuery.fn.flash.transform(htmlOptions));
     280        });
     281               
     282        return false;
     283    }
     284   
     285    /**
     286     * Debug
    234287     * @param {Object} message
    235288     */
    236289    function debug(message) {
    237         if (typeof console != 'undefined' && typeof console.debug != 'undefined' && $.fn.trackEvent.defaults.debug) {
     290        if (typeof console != 'undefined' && typeof console.debug != 'undefined') {
    238291            console.debug(message);
    239292        }
    240     };
     293    }
    241294   
    242295    /** Non "Global" Functions **/
     
    340393   
    341394});
    342 
    343 /************************
    344  *
    345  * I am changing this code to jQuery Syle.
    346  *
    347  ************************/
    348 
    349 function expandByDay(key, hashid, id, index) {
    350     var row = document.getElementById('wlc-' + hashid + '-' + id);
    351     if (row.style.display == 'table-row') {
    352         row.style.display = 'none';
    353     }
    354     else {
    355         row.style.display = 'table-row';
    356     }
    357    
    358     if (row.className == 'loaded') {
    359         return false;
    360     }
    361     row.className = 'loaded';
    362    
    363     var phpfile = woopraL10n.siteurl + '/wp-admin/admin-ajax.php?action=woopra&datatype=flash&apikey=' + woopradefaultL10n.apikey + '&id=' + index + '&wkey=' + key + '&date_format=' + date_format + '&from=' + date_from + '&to=' + date_to;
    364     var so = new SWFObject(woopraL10n.baseurl + "/flash/open-flash-chart.swf", hashid, "968", "110", "9");
    365     so.addVariable("data-file", escape(phpfile));
    366     so.addParam("allowScriptAccess", "sameDomain");
    367     so.addParam("wmode", "transparent");
    368     so.addParam("bgcolor", "#FFFFFF");
    369 
    370     so.write('linecharttd-' + hashid + '-' + id);
    371     return false;
    372 }
    373 
    374 function expandReferrer(key, hashid) {
    375     trref = document.getElementById('refexp-'+hashid);
    376     if (trref.style.display == 'none') {
    377         trref.style.display = 'table-row';
    378     }
    379     else {
    380         trref.style.display = 'none';
    381     }
    382     if (trref.className == 'loaded') { return false; }
    383    
    384     trref.className = 'loaded';
    385    
    386     tdref = document.getElementById('refexptd-' + hashid);
    387     setPageLoading('refexptd-' + hashid);
    388     requestData('refexptd-' + hashid, key);
    389     return false;
    390 }
Note: See TracChangeset for help on using the changeset viewer.