r57865 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r57864‎ | r57865 | r57866 >
Date:13:31, 18 October 2009
Author:ashley
Status:ok
Tags:
Comment:
ClickTracking:
*coding style cleanup
*marked SpecialPage's constructor and execute func as public
*fixed some message names in SpecialClickTracking.php
*capitalized SQL keywords
Modified paths:
  • /trunk/extensions/UsabilityInitiative/ClickTracking/ApiClickTracking.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/ClickTracking/ApiSpecialClickTracking.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/ClickTracking/ClickTracking.hooks.php (modified) (history)
  • /trunk/extensions/UsabilityInitiative/ClickTracking/ClickTracking.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/ClickTracking/SpecialClickTracking.js (modified) (history)
  • /trunk/extensions/UsabilityInitiative/ClickTracking/SpecialClickTracking.php (modified) (history)

Diff [purge]

Index: trunk/extensions/UsabilityInitiative/ClickTracking/ApiClickTracking.php
@@ -27,10 +27,10 @@
2828 $now = time();
2929 $granularity1 = $is_logged_in ?
3030 ClickTrackingHooks::getEditCountSince( $now - $wgClickTrackContribGranularity1 ) : 0;
31 -
 31+
3232 $granularity2 = $is_logged_in ?
3333 ClickTrackingHooks::getEditCountSince( $now - $wgClickTrackContribGranularity2 ) : 0;
34 -
 34+
3535 $granularity3 = $is_logged_in ?
3636 ClickTrackingHooks::getEditCountSince( $now - $wgClickTrackContribGranularity3 ) : 0;
3737
Index: trunk/extensions/UsabilityInitiative/ClickTracking/ApiSpecialClickTracking.php
@@ -21,22 +21,19 @@
2222 $enddate = $params['enddate'];
2323 $increment = $params['increment'];
2424 $userDefString = $params['userdefs'];
25 -
26 - //this is if it's asking for tableData
27 - if(isset($params['tabledata'])){
28 - $tableData = SpecialClickTracking::buildRowArray($startdate, $enddate, $userDefString);
29 - $this->getResult()->addValue(array('tablevals'), 'vals', $tableData);
30 -
31 - }
32 - else{ //chart data
 25+
 26+ // this is if it's asking for tableData
 27+ if( isset( $params['tabledata'] ) ) {
 28+ $tableData = SpecialClickTracking::buildRowArray( $startdate, $enddate, $userDefString );
 29+ $this->getResult()->addValue( array( 'tablevals' ), 'vals', $tableData );
 30+ } else{ //chart data
3331 $click_data = array();
34 - try{
35 - $click_data = SpecialClickTracking::getChartData($event_id, $startdate, $enddate, $increment, $userDefString);
36 - $this->getResult()->addValue(array('datapoints'), 'expert', $click_data['expert']);
37 - $this->getResult()->addValue(array('datapoints'), 'basic', $click_data['basic']);
38 - $this->getResult()->addValue(array('datapoints'), 'intermediate', $click_data['intermediate']);
39 - }
40 - catch(Exception $e){ /* no result */ }
 32+ try {
 33+ $click_data = SpecialClickTracking::getChartData( $event_id, $startdate, $enddate, $increment, $userDefString );
 34+ $this->getResult()->addValue( array( 'datapoints' ), 'expert', $click_data['expert'] );
 35+ $this->getResult()->addValue( array( 'datapoints' ), 'basic', $click_data['basic'] );
 36+ $this->getResult()->addValue( array( 'datapoints' ), 'intermediate', $click_data['intermediate'] );
 37+ } catch( Exception $e ) { /* no result */ }
4138 }
4239 }
4340
@@ -51,39 +48,39 @@
5249 $this->dieUsageMsg( array( 'missingparam', $arg ) );
5350 }
5451 }
55 -
56 - //check if event id parses to an int greater than zero
57 - if( (int) $params['eventid'] < 0){
58 - $this->dieUsage("Invalid event ID", "badeventid");
 52+
 53+ // check if event id parses to an int greater than zero
 54+ if( (int) $params['eventid'] < 0 ) {
 55+ $this->dieUsage( 'Invalid event ID', 'badeventid' );
5956 }
60 -
61 - //check start and end date are of proper format
62 - if($params['startdate'] != 0 && strptime( $this->space_out_date($params['startdate']), "%Y %m %d") === false){
63 - $this->dieUsage("startdate not in YYYYMMDD format: <<{$params['startdate']}>>", "badstartdate");
 57+
 58+ // check start and end date are of proper format
 59+ if( $params['startdate'] != 0 && strptime( $this->space_out_date( $params['startdate'] ), "%Y %m %d" ) === false ) {
 60+ $this->dieUsage( "startdate not in YYYYMMDD format: <<{$params['startdate']}>>", 'badstartdate' );
6461 }
65 - if($params['enddate'] != 0 && strptime( $this->space_out_date($params['enddate']), "%Y %m %d") === false){
66 - $this->dieUsage("enddate not in YYYYMMDD format:<<{$params['enddate']}>>", "badenddate");
 62+ if( $params['enddate'] != 0 && strptime( $this->space_out_date( $params['enddate'] ), "%Y %m %d" ) === false ) {
 63+ $this->dieUsage( "enddate not in YYYYMMDD format:<<{$params['enddate']}>>", 'badenddate' );
6764 }
68 -
69 - //check if increment is a positive int
70 - if( (int) $params['increment'] <= 0){
71 - $this->dieUsage("Invalid increment", "badincrement");
 65+
 66+ // check if increment is a positive int
 67+ if( (int) $params['increment'] <= 0 ) {
 68+ $this->dieUsage( 'Invalid increment', 'badincrement' );
7269 }
73 -
74 - if(json_decode($params['userdefs']) == null){
75 - $this->dieUsage("Invalid JSON encoding <<{$params['userdefs']}>>", "badjson");
 70+
 71+ if( json_decode( $params['userdefs'] ) == null ) {
 72+ $this->dieUsage( "Invalid JSON encoding <<{$params['userdefs']}>>", 'badjson' );
7673 }
7774 }
7875
7976 /**
80 - * Space out the dates,
 77+ * Space out the dates
8178 * @param $datewithnospaces date with no spaces
8279 * @return date with spaces
8380 */
84 - public function space_out_date($datewithnospaces){
85 - return (substr($datewithnospaces, 0, 4) . " " .substr($datewithnospaces, 4, 2) . " " . substr($datewithnospaces, 6, 2));
 81+ public function space_out_date( $datewithnospaces ) {
 82+ return ( substr( $datewithnospaces, 0, 4 ) . ' ' .substr( $datewithnospaces, 4, 2 ) . ' ' . substr( $datewithnospaces, 6, 2 ) );
8683 }
87 -
 84+
8885 public function getParamDescription() {
8986 return array(
9087 'eventid' => 'event ID (number)',
@@ -97,7 +94,7 @@
9895
9996 public function getDescription() {
10097 return array(
101 - 'Returns data to the special:clicktracking visualization page'
 98+ 'Returns data to the Special:ClickTracking visualization page'
10299 );
103100 }
104101
@@ -118,10 +115,12 @@
119116 ApiBase::PARAM_MIN => 1,
120117 ApiBase::PARAM_MAX => 365 //1 year
121118 ),
122 - 'userdefs' => array (
123 - ApiBase::PARAM_TYPE => 'string'),
124 - 'tabledata' => array (
125 - ApiBase::PARAM_TYPE => 'integer'),
 119+ 'userdefs' => array(
 120+ ApiBase::PARAM_TYPE => 'string'
 121+ ),
 122+ 'tabledata' => array(
 123+ ApiBase::PARAM_TYPE => 'integer'
 124+ ),
126125 );
127126 }
128127
Index: trunk/extensions/UsabilityInitiative/ClickTracking/SpecialClickTracking.php
@@ -7,549 +7,579 @@
88 */
99
1010 class SpecialClickTracking extends SpecialPage {
11 -
12 - //set to zero for 'all'
 11+
 12+ // set to zero for 'all'
1313 private $top_results = 10;
1414 private $normalize_top_results = false;
1515 private $normalize_results = false;
1616 private $end_timeframe = '20090902';
17 - private static $minimum_date = '20091009'; //YYYYMMDD (+1 for today)
18 -
19 - private static $userTypes = array("basic" => 0, "intermediate" => 1, "expert" => 2);
 17+ private static $minimum_date = '20091009'; // YYYYMMDD (+1 for today)
 18+
 19+ private static $userTypes = array( 'basic' => 0, 'intermediate' => 1, 'expert' => 2 );
2020 private $user_defs = array();
21 -
22 - //array of event_id => event_name
 21+
 22+ // array of event_id => event_name
2323 public static $expert_user_conds = "user_total_contribs > 10 ";
2424 public static $intermediate_user_conds = "user_total_contribs < 10 AND user_total_contribs > 1 ";
2525 public static $basic_user_conds = "user_total_contribs <= 1";
26 -
27 - /*
 26+
 27+ /**
2828 * " DISTINCT session_id "
29 - *
 29+ *
3030 * " select count(*), event_id from click_tracking group by event_id order by count(*) desc limit 10;"
31 - *
 31+ *
3232 */
33 -
3433 private $event_id_to_name = array();
3534 private $name_to_event_id = array();
36 - private $time_constraint_sql = "";
37 -
38 -
39 -
40 - function __construct() {
41 - parent::__construct( 'ClickTracking' , 'clicktrack');
 35+ private $time_constraint_sql = '';
 36+
 37+ /**
 38+ * Constructor -- set up the new special page
 39+ */
 40+ public function __construct() {
 41+ parent::__construct( 'ClickTracking' , 'clicktrack' );
4242 wfLoadExtensionMessages( 'ClickTracking' );
4343 UsabilityInitiativeHooks::initialize();
4444 UsabilityInitiativeHooks::addStyle( 'ClickTracking/SpecialClickTracking.css' );
4545 UsabilityInitiativeHooks::addScript( 'ClickTracking/SpecialClickTracking.js' );
4646 }
47 -
48 -
49 -
50 -
51 - function setDefaults(){
52 - $this->user_defs["basic"] = array(
53 - "anonymous" => "1",
54 - "total_contribs" => array(
55 - array("operation" => "<=", "value" => "1"),
 47+
 48+ function setDefaults() {
 49+ $this->user_defs['basic'] = array(
 50+ 'anonymous' => '1',
 51+ 'total_contribs' => array(
 52+ array( 'operation' => '<=', 'value' => '1' ),
5653 ),
5754 );
58 -
59 - $this->user_defs["intermediate"] = array(
60 - "anonymous" => "0",
61 - "total_contribs" => array(
62 - array("operation" => "<", "value" => "10"),
63 - array("operation" => ">", "value" => "1"),
 55+
 56+ $this->user_defs['intermediate'] = array(
 57+ 'anonymous' => '0',
 58+ 'total_contribs' => array(
 59+ array( 'operation' => '<', 'value' => '10' ),
 60+ array( 'operation' => '>', 'value' => '1' ),
6461 ),
6562 );
66 -
67 - $this->user_defs["expert"] = array(
68 - "anonymous" => "0",
69 - "total_contribs" => array(
70 - array("operation" => ">=", "value" => "10"),
 63+
 64+ $this->user_defs['expert'] = array(
 65+ 'anonymous' => '0',
 66+ 'total_contribs' => array(
 67+ array( 'operation' => '>=', 'value' => '10' ),
7168 ),
7269 );
73 -
74 -
 70+
7571 }
76 -
77 -
78 -
79 - function execute( $par ) {
 72+
 73+ /**
 74+ * Show the special page
 75+ *
 76+ * @param $par Mixed: parameter passed to the page or null
 77+ */
 78+ public function execute( $par ) {
8079 global $wgOut, $wgUser;
81 -
 80+
8281 // Check permissions
8382 if ( !$this->userCanExecute( $wgUser ) ) {
8483 $this->displayRestrictionError();
8584 return;
8685 }
87 -
88 -
 86+
8987 $this->setHeaders();
9088 $this->setDefaults();
91 -
92 - $wgOut->addScript('<script type="text/javascript">'. "var wgClickTrackUserDefs = ".json_encode($this->user_defs). '</script>');
93 -
 89+
 90+ $wgOut->addScript( '<script type="text/javascript">' . "var wgClickTrackUserDefs = " . json_encode( $this->user_defs ) . '</script>' );
 91+
9492 $wgOut->setPageTitle( wfMsg( 'ct-title' ) );
95 -
96 - $outputTable ="";
97 -
98 -
99 - //grab top N
 93+
 94+ $outputTable = '';
 95+
 96+ // grab top N
10097 $events = $this->getTopEvents();
101 -
102 - //open table
103 - $outputTable .= Xml::openElement( "table", array( "class" =>"sortable click-data", "id" => "clicktrack_data_table" ) );
104 -
105 - //create a row for every event
 98+
 99+ // open table
 100+ $outputTable .= Xml::openElement( 'table', array( 'class' => 'sortable click-data', 'id' => 'clicktrack_data_table' ) );
 101+
 102+ // create a row for every event
106103 $i = 0;
107104 $db_result;
108 -
109 - //build row headers
 105+
 106+ // build row headers
110107 $header_row = array();
111 -
112 - $header_row["event_header"] = wfMsg( 'ct-event-name' );
113 - $header_row["expert_header"] = wfMsg( 'ct-expert-header' );
114 - $header_row["intermediate_header"] = wfMsg( 'ct-intermediate-header' );
115 - $header_row["basic_header"] = wfMsg( 'ct-beginner-header' );
116 - $header_row["total_header"] = wfMsg( 'ct-total-header' );
117 - $outputTable .= Xml::buildTableRow( array( "class"=>"table_headers" ), $header_row );
118 -
119 - //foreach event, build a row
120 - while(($db_result = $events->fetchRow()) != null){
 108+
 109+ $header_row['event_header'] = wfMsg( 'ct-event-name' );
 110+ $header_row['expert_header'] = wfMsg( 'ct-expert-header' );
 111+ $header_row['intermediate_header'] = wfMsg( 'ct-intermediate-header' );
 112+ $header_row['basic_header'] = wfMsg( 'ct-beginner-header' );
 113+ $header_row['total_header'] = wfMsg( 'ct-total-header' );
 114+ $outputTable .= Xml::buildTableRow( array( 'class' => 'table_headers' ), $header_row );
 115+
 116+ // foreach event, build a row
 117+ while( ( $db_result = $events->fetchRow() ) != null ) {
121118 ++$i;
122 - $outputTable .= $this->buildRow( $db_result, $i, $this->user_defs);
 119+ $outputTable .= $this->buildRow( $db_result, $i, $this->user_defs );
123120 }
124 -
125 -
126 - //close table
127 - $outputTable .= Xml::closeElement("table");
128 -
 121+
 122+ // close table
 123+ $outputTable .= Xml::closeElement( 'table' );
 124+
129125 $wgOut->addHTML( $outputTable );
130126
131 - $wgOut->addHTML($this->buildDateRange());
132 -
133 - //build chart
134 - $wgOut->addHTML($this->buildChart("advanced.hide",10, "20090815", "20090902", 1));
135 -
136 - //$wgOut->addHTML($this->buildControlBox());
137 -
138 - $wgOut->addHTML($this->buildChartDialog());
139 - $wgOut->addHTML($this->buildUserDefBlankDialog());
140 -
 127+ $wgOut->addHTML( $this->buildDateRange() );
 128+
 129+ // build chart
 130+ $wgOut->addHTML( $this->buildChart( 'advanced.hide', 10, '20090815', '20090902', 1 ) );
 131+
 132+ //$wgOut->addHTML( $this->buildControlBox() );
 133+
 134+ $wgOut->addHTML( $this->buildChartDialog() );
 135+ $wgOut->addHTML( $this->buildUserDefBlankDialog() );
141136 }
142 -
143137
144138 /**
145139 * Gets the data to build a chart for PHP or JS purposes
146 - * @param $event_id event id this chart is for
 140+ * @param $event_id event id this chart is for
147141 * @param $minTime minimum day
148142 * @param $maxTime maximum day
149143 * @param $increment number of day(s) to increment in units
150 - * @param $userDefs user defintions
151 - * @param $isUserDefsJSON true if userDefs is JSON
 144+ * @param $userDefs user defintions
 145+ * @param $isUserDefsJSON Boolean: true if userDefs is JSON
152146 * @return array with chart info
153147 */
154 - static function getChartData($event_id, $minTime, $maxTime, $increment, $userDefs, $isUserDefsJSON=true){
155 - //get data
156 - date_default_timezone_set('UTC');
157 -
158 - if($maxTime == 0){
159 - $maxTime = gmdate("Ymd",time()); //today
 148+ static function getChartData( $event_id, $minTime, $maxTime, $increment, $userDefs, $isUserDefsJSON = true ) {
 149+ // get data
 150+ date_default_timezone_set( 'UTC' );
 151+
 152+ if( $maxTime == 0 ) {
 153+ $maxTime = gmdate( 'Ymd', time() ); // today
160154 }
161 - if($minTime == 0){
 155+ if( $minTime == 0 ) {
162156 $minTime = self::$minimum_date;
163157 }
164 -
165 -
166 - //FIXME: On PHP 5.3+, this will be MUCH cleaner
 158+
 159+ // FIXME: On PHP 5.3+, this will be MUCH cleaner
167160 $currBeginDate = new DateTime( $minTime );
168161 $currEndDate = new DateTime( $minTime );
169162 $endDate = new DateTime( $maxTime );
170 -
171 -
172 - //get user definitions
173 - if($isUserDefsJSON){
174 - $userDefs = json_decode($userDefs, true);
 163+
 164+ // get user definitions
 165+ if( $isUserDefsJSON ) {
 166+ $userDefs = json_decode( $userDefs, true );
175167 }
176 -
 168+
177169 $basicUserData = array();
178170 $intermediateUserData = array();
179171 $expertUserData = array();
180 -
 172+
181173 // PHP 5.3...hurry!
182 - $plural = ( $increment == 1 ? "" : "s" );
183 -
184 - while( $currEndDate->format( "U" ) < $endDate->format( "U" ) ){
 174+ $plural = ( $increment == 1 ? '' : 's' );
 175+
 176+ while( $currEndDate->format( 'U' ) < $endDate->format( 'U' ) ) {
185177 $currEndDate->modify( "+$increment day$plural" );
186 -
187 - $minDate = $currBeginDate->format("Ymd");
188 - $maxDate = $currEndDate->format("Ymd");
189 -
 178+
 179+ $minDate = $currBeginDate->format( 'Ymd' );
 180+ $maxDate = $currEndDate->format( 'Ymd' );
 181+
190182 $basicUserData[] = self::getTableValue( $event_id, $userDefs['basic'], $minDate, $maxDate );
191183 $intermediateUserData[] = self::getTableValue( $event_id, $userDefs['intermediate'], $minDate, $maxDate );
192184 $expertUserData[] = self::getTableValue( $event_id, $userDefs['expert'], $minDate, $maxDate );
193185 $currBeginDate->modify( "+$increment day$plural" );
194186 }
195 - return array("expert" => $expertUserData, "basic" => $basicUserData, "intermediate" => $intermediateUserData);
196 - }
 187+ return array( 'expert' => $expertUserData, 'basic' => $basicUserData, 'intermediate' => $intermediateUserData );
 188+ }
197189
198 - function buildChart($event_name, $event_id, $minTime, $maxTime, $increment){
199 - $chartData = self::getChartData($event_id, $minTime, $maxTime, $increment, $this->user_defs, false);
200 - $chartSrc = $this->getGoogleChartParams( $event_id, $event_name, $minTime, $maxTime, $chartData["basic"], $chartData["intermediate"], $chartData["expert"]);
 190+ function buildChart( $event_name, $event_id, $minTime, $maxTime, $increment ) {
 191+ $chartData = self::getChartData( $event_id, $minTime, $maxTime, $increment, $this->user_defs, false );
 192+ $chartSrc = $this->getGoogleChartParams(
 193+ $event_id, $event_name, $minTime, $maxTime, $chartData['basic'],
 194+ $chartData['intermediate'], $chartData['expert']
 195+ );
201196 return Xml::element( 'img', array( 'src' => $chartSrc , 'id' => 'chart_img' ) );
202197 }
203 -
204 -
 198+
205199 function getGoogleChartParams( $event_id, $event_name, $minDate, $maxDate, $basicUserData, $intermediateUserData, $expertUserData ) {
206 - $max = max( max($basicUserData), max($intermediateUserData), max($expertUserData));
207 - return "http://chart.apis.google.com/chart?" . wfArrayToCGI(
208 - array(
209 - 'chs' => '400x400',
210 - 'cht' => 'lc',
211 - 'chco' => 'FF0000,0000FF,00FF00',
212 - 'chtt' => "$event_name from $minDate to $maxDate",
213 - 'chdl' => 'Expert|Intermediate|Beginner',
214 - 'chxt' => 'x,y',
215 - 'chd' => 't:' . implode( "," , $expertUserData ) . "|" .
 200+ $max = max( max( $basicUserData ), max( $intermediateUserData ), max( $expertUserData ) );
 201+ return 'http://chart.apis.google.com/chart?' . wfArrayToCGI(
 202+ array(
 203+ 'chs' => '400x400',
 204+ 'cht' => 'lc',
 205+ 'chco' => 'FF0000,0000FF,00FF00',
 206+ 'chtt' => "$event_name from $minDate to $maxDate",
 207+ 'chdl' => 'Expert|Intermediate|Beginner',
 208+ 'chxt' => 'x,y',
 209+ 'chd' => 't:' . implode( "," , $expertUserData ) . "|" .
216210 implode( "," , $intermediateUserData ) . "|" . implode( "," , $basicUserData ),
217 - 'chds' => "0,$max,0,$max,0,$max"
218 - ));
 211+ 'chds' => "0,$max,0,$max,0,$max"
 212+ )
 213+ );
219214 }
220 -
221 -
 215+
222216 function buildUserDefBlankDialog(){
223 - $control = "";
224 - $control .= Xml::openElement("div", array("id" => "user_def_dialog", "class" => "dialog"));
225 -
 217+ $control = '';
 218+ $control .= Xml::openElement( 'div', array( 'id' => 'user_def_dialog', 'class' => 'dialog' ) );
 219+
226220 //currently editing...----|
227 - $control .= Xml::openElement("form", array("id" => "user_definition_form", "class" => "user_def_form"));
228 - $control .= Xml::openElement("fieldset", array("id" => "user_def_alter_fieldset"));
229 - $control .= Xml::openElement("legend", array("id" => "user_def_alter_legend"));
230 - $control .= wfMsg( "editing" );
231 - $control .= Xml::closeElement("legend");
232 -
 221+ $control .= Xml::openElement( 'form', array( 'id' => 'user_definition_form', 'class' => 'user_def_form' ) );
 222+ $control .= Xml::openElement( 'fieldset', array( 'id' => 'user_def_alter_fieldset' ) );
 223+ $control .= Xml::openElement( 'legend', array( 'id' => 'user_def_alter_legend' ) );
 224+ $control .= wfMsg( 'editing' );
 225+ $control .= Xml::closeElement( 'legend' );
 226+
233227 //[] anonymous users?
234 - $control .= Xml::openElement("div", array("id" => "anon_users_div", "class" => "checkbox_div control_div"));
235 - $control .= Xml::openElement("input", array("type" => "checkbox", "id" => "anon_users_checkbox", "class" => "user_def_checkbox"));
236 - $control .= Xml::closeElement("input");
237 - $control .= wfMsg("anon-users");
238 - $control .= Xml::closeElement("div");
239 -
 228+ $control .= Xml::openElement( 'div', array( 'id' => 'anon_users_div', 'class' => 'checkbox_div control_div' ) );
 229+ $control .= Xml::openElement( 'input', array( 'type' => 'checkbox', 'id' => 'anon_users_checkbox', 'class' => 'user_def_checkbox' ) );
 230+ $control .= Xml::closeElement( 'input' );
 231+ $control .= wfMsg( 'anon-users' );
 232+ $control .= Xml::closeElement( 'div' );
 233+
240234 // ----------------
241 - $control .= Xml::openElement("hr");
242 - $control .= Xml::closeElement("hr");
243 - $control .= Xml::openElement("div", array("id" => "contrib_opts_container"));
244 -
 235+ $control .= Xml::openElement( 'hr' );
 236+ $control .= Xml::closeElement( 'hr' );
 237+ $control .= Xml::openElement( 'div', array( 'id' => 'contrib_opts_container' ) );
 238+
245239 // [] users with contributions [>=V] [n ]
246 - $control .= Xml::openElement("div", array("id" => "total_users_contrib_div", "class" => "checkbox_div control_div"));
247 - $control .= Xml::openElement("input", array("type" => "checkbox", "id" => "contrib_checkbox", "class" => "user_def_checkbox"));
248 - $control .= Xml::closeElement("input");
249 - $control .= wfMsg("user-contribs");
250 -
251 -
252 - $control .= Xml::closeElement("div");
253 -
 240+ $control .= Xml::openElement( 'div', array( 'id' => 'total_users_contrib_div', 'class' => 'checkbox_div control_div' ) );
 241+ $control .= Xml::openElement( 'input', array( 'type' => 'checkbox', 'id' => 'contrib_checkbox', 'class' => 'user_def_checkbox' ) );
 242+ $control .= Xml::closeElement( 'input' );
 243+ $control .= wfMsg( 'ct-user-contribs' );
 244+
 245+ $control .= Xml::closeElement( 'div' );
 246+
254247 // [] contributions in timespan 1
255 - $control .= Xml::openElement("div", array("id" => "contrib_span_1_div", "class" => "checkbox_div control_div"));
256 -
257 - $control .= Xml::openElement("div", array("id" => "contrib_span_1_text_div", "class" => "checkbox_div"));
258 - $control .= Xml::openElement("input", array("type" => "checkbox", "id" => "contrib_span_1_checkbox", "class" => "user_def_checkbox"));
259 - $control .= Xml::closeElement("input");
260 - $control .= wfMsg("user-span") . " 1";
261 - $control .= Xml::closeElement("div");
262 - $control .= Xml::closeElement("div");
263 -
 248+ $control .= Xml::openElement( 'div', array( 'id' => 'contrib_span_1_div', 'class' => 'checkbox_div control_div' ) );
 249+
 250+ $control .= Xml::openElement( 'div', array( 'id' => 'contrib_span_1_text_div', 'class' => 'checkbox_div' ) );
 251+ $control .= Xml::openElement( 'input',
 252+ array(
 253+ 'type' => 'checkbox',
 254+ 'id' => 'contrib_span_1_checkbox',
 255+ 'class' => 'user_def_checkbox'
 256+ )
 257+ );
 258+ $control .= Xml::closeElement( 'input' );
 259+ $control .= wfMsg( 'ct-user-span' ) . ' 1';
 260+ $control .= Xml::closeElement( 'div' );
 261+ $control .= Xml::closeElement( 'div' );
 262+
264263 // [] contributions in timespan 2
265 - $control .= Xml::openElement("div", array("id" => "contrib_span_2_div", "class" => "checkbox_div control_div"));
266 -
267 - $control .= Xml::openElement("div", array("id" => "contrib_span_2_text_div", "class" => "checkbox_div"));
268 - $control .= Xml::openElement("input", array("type" => "checkbox", "id" => "contrib_span_2_checkbox", "class" => "user_def_checkbox"));
269 - $control .= Xml::closeElement("input");
270 - $control .= wfMsg("user-span") . " 2";
271 - $control .= Xml::closeElement("div");
272 - $control .= Xml::closeElement("div");
273 -
 264+ $control .= Xml::openElement( 'div', array( 'id' => 'contrib_span_2_div', 'class' => 'checkbox_div control_div' ) );
 265+
 266+ $control .= Xml::openElement( 'div', array( 'id' => 'contrib_span_2_text_div', 'class' => 'checkbox_div' ) );
 267+ $control .= Xml::openElement( 'input', array( 'type' => 'checkbox', 'id' => 'contrib_span_2_checkbox', 'class' => 'user_def_checkbox' ) );
 268+ $control .= Xml::closeElement( 'input' );
 269+ $control .= wfMsg( 'ct-user-span' ) . ' 2';
 270+ $control .= Xml::closeElement( 'div' );
 271+ $control .= Xml::closeElement( 'div' );
 272+
274273 // [] contributions in timespan 3
275 - $control .= Xml::openElement("div", array("id" => "contrib_span_3_div", "class" => "checkbox_div control_div"));
276 -
277 - $control .= Xml::openElement("div", array("id" => "contrib_span_3_text_div", "class" => "checkbox_div"));
278 - $control .= Xml::openElement("input", array("type" => "checkbox", "id" => "contrib_span_3_checkbox", "class" => "user_def_checkbox"));
279 - $control .= Xml::closeElement("input");
280 - $control .= wfMsg("user-span") . " 3";
281 - $control .= Xml::closeElement("div");
282 - $control .= Xml::closeElement("div");
283 -
284 -
285 -
286 -
287 - $control .= Xml::closeElement("div");//close contrib opts
288 -
289 - $control .= Xml::closeElement("fieldset");
290 - $control .= Xml::closeElement("form");
291 - $control .= Xml::closeElement("div");
 274+ $control .= Xml::openElement( 'div', array( 'id' => 'contrib_span_3_div', 'class' => 'checkbox_div control_div' ) );
 275+
 276+ $control .= Xml::openElement( 'div', array( 'id' => 'contrib_span_3_text_div', 'class' => 'checkbox_div' ) );
 277+ $control .= Xml::openElement( 'input', array( 'type' => 'checkbox', 'id' => 'contrib_span_3_checkbox', 'class' => 'user_def_checkbox' ) );
 278+ $control .= Xml::closeElement( 'input' );
 279+ $control .= wfMsg( 'ct-user-span' ) . ' 3';
 280+ $control .= Xml::closeElement( 'div' );
 281+ $control .= Xml::closeElement( 'div' );
 282+
 283+ $control .= Xml::closeElement( 'div' ); // close contrib opts
 284+
 285+ $control .= Xml::closeElement( 'fieldset' );
 286+ $control .= Xml::closeElement( 'form' );
 287+ $control .= Xml::closeElement( 'div' );
292288 return $control;
293289 }
294 -
295 -
296 -
297 - function buildUserDefNumberSelect($include_checkbox, $include_and, $ids){
298 - $control = "";
299 - if($include_checkbox){
300 - $control .= Xml::openElement("input", array("type" => "checkbox", "id" => "{$ids}_checkbox", "class" => "number_select_checkbox"));
301 - $control .= Xml::closeElement("input");
 290+
 291+ function buildUserDefNumberSelect( $include_checkbox, $include_and, $ids ) {
 292+ $control = '';
 293+ if( $include_checkbox ) {
 294+ $control .= Xml::openElement( 'input', array( 'type' => 'checkbox', 'id' => "{$ids}_checkbox", 'class' => 'number_select_checkbox' ) );
 295+ $control .= Xml::closeElement( 'input' );
302296 }
303 -
304 - if($include_and){
305 - $control .= wfMsg("ct-and");
 297+
 298+ if( $include_and ) {
 299+ $control .= wfMsg( 'ct-and' );
306300 }
307 -
308 - $control .= Xml::openElement("select", array("id" => "{$ids}_ltgt", "class" => "number_select_ltgt"));
309 - $control .= Xml::openElement("option", array("id" => "{$ids}_lt", "class" => "number_select_ltgt_opt", "value" => "lt"));
 301+
 302+ $control .= Xml::openElement( 'select', array( 'id' => "{$ids}_ltgt", 'class' => 'number_select_ltgt' ) );
 303+ $control .= Xml::openElement( 'option', array( 'id' => "{$ids}_lt", 'class' => 'number_select_ltgt_opt', 'value' => 'lt' ) );
310304 $control .= "&lt;=";
311 - $control .= Xml::closeElement("option");
312 - $control .= Xml::openElement("option", array("id" => "{$ids}_gt", "class" => "number_select_ltgt_opt", "value" => "gt"));
 305+ $control .= Xml::closeElement( 'option' );
 306+ $control .= Xml::openElement( 'option', array( 'id' => "{$ids}_gt", 'class' => 'number_select_ltgt_opt', 'value' => 'gt' ) );
313307 $control .= "&gt;=";
314 - $control .= Xml::closeElement("option");
315 - $control .= Xml::closeElement("select");
316 - $control .= Xml::openElement("input", array("type" => "text", "id" => "{$ids}_text", "class" => "number_select_text"));
317 - $control .= Xml::closeElement("input");
 308+ $control .= Xml::closeElement( 'option' );
 309+ $control .= Xml::closeElement( 'select' );
 310+ $control .= Xml::openElement( 'input', array( 'type' => 'text', 'id' => "{$ids}_text", 'class' => 'number_select_text' ) );
 311+ $control .= Xml::closeElement( 'input' );
318312 return $control;
319313 }
320 -
321 -
322 - function buildChartDialog(){
323 - $control = "";
324 - $control .= Xml::openElement("div", array("id" => "chart_dialog", "class" => "dialog"));
325 -
326 - $control .= Xml::openElement("form", array("id" => "chart_dialog_form", "class" => "chart_form"));
327 - $control .= Xml::openElement("fieldset", array("id" => "chart_dialog_alter_fieldset"));
328 - $control .= Xml::openElement("legend", array("id" => "chart_dialog_alter_legend"));
329 - $control .= wfMsg( "ct-increment-by" );
330 - $control .= Xml::closeElement("legend");
331 -
332 - $control .= Xml::openElement("table", array("id" => "chart_dialog_increment_table"));
333 - $control .= Xml::openElement("tbody", array("id" => "chart_dialog_increment_tbody"));
334 -
335 - $control .= Xml::openElement("tr", array("id" => "chart_dialog_increment_row"));
336 -
337 - $control .= Xml::openElement("td", array("id" => "chart_dialog_increment_cell"));
338 - $control .= Xml::openElement("input", array("type" => "text", "id" => "chart_increment", "class" => "chart_dialog_area", "value" => '1'));
339 - $control .= Xml::closeElement("input");
340 - $control .= Xml::closeElement("td");
341 -
342 - $control .= Xml::openElement("td", array("id" => "chart_dialog_button_cell"));
343 - $control .= Xml::openElement("input", array("type" => "button", "id" => "change_graph", "value" => wfMsg( "ct-change-graph" ) ) );
344 - $control .= Xml::closeElement("input");
345 - $control .= Xml::closeElement("td");
346 -
347 - $control .= Xml::closeElement("tr");
348 -
349 - $control .= Xml::closeElement("tbody");
350 - $control .= Xml::closeElement("table");
351 - $control .= Xml::closeElement("fieldset");
352 - $control .= Xml::closeElement("form");
353 - $control .= Xml::closeElement("div");
 314+
 315+ function buildChartDialog() {
 316+ $control = '';
 317+ $control .= Xml::openElement( 'div', array( 'id' => 'chart_dialog', 'class' => 'dialog' ) );
 318+
 319+ $control .= Xml::openElement( 'form', array( 'id' => 'chart_dialog_form', 'class' => 'chart_form' ) );
 320+ $control .= Xml::openElement( 'fieldset', array( 'id' => 'chart_dialog_alter_fieldset' ) );
 321+ $control .= Xml::openElement( 'legend', array( 'id' => 'chart_dialog_alter_legend' ) );
 322+ $control .= wfMsg( 'ct-increment-by' );
 323+ $control .= Xml::closeElement( 'legend' );
 324+
 325+ $control .= Xml::openElement( 'table', array( 'id' => 'chart_dialog_increment_table' ) );
 326+ $control .= Xml::openElement( 'tbody', array( 'id' => 'chart_dialog_increment_tbody' ) );
 327+
 328+ $control .= Xml::openElement( 'tr', array( 'id' => 'chart_dialog_increment_row' ) );
 329+
 330+ $control .= Xml::openElement( 'td', array( 'id' => 'chart_dialog_increment_cell' ) );
 331+ $control .= Xml::openElement( 'input',
 332+ array(
 333+ 'type' => 'text',
 334+ 'id' => 'chart_increment',
 335+ 'class' => 'chart_dialog_area',
 336+ 'value' => '1'
 337+ )
 338+ );
 339+ $control .= Xml::closeElement( 'input' );
 340+ $control .= Xml::closeElement( 'td' );
 341+
 342+ $control .= Xml::openElement( 'td', array( 'id' => 'chart_dialog_button_cell' ) );
 343+ $control .= Xml::openElement( 'input',
 344+ array(
 345+ 'type' => 'button',
 346+ 'id' => 'change_graph',
 347+ 'value' => wfMsg( 'ct-change-graph' )
 348+ )
 349+ );
 350+ $control .= Xml::closeElement( 'input' );
 351+ $control .= Xml::closeElement( 'td' );
 352+
 353+ $control .= Xml::closeElement( 'tr' );
 354+
 355+ $control .= Xml::closeElement( 'tbody' );
 356+ $control .= Xml::closeElement( 'table' );
 357+ $control .= Xml::closeElement( 'fieldset' );
 358+ $control .= Xml::closeElement( 'form' );
 359+ $control .= Xml::closeElement( 'div' );
354360 return $control;
355361 }
356 -
357 -
358 - function buildDateRange(){
359 - $control = Xml::openElement("form", array("id" => "date_range"));
360 -
361 - $control .= Xml::openElement("fieldset", array("id" => "date_range_fieldset"));
362 - $control .= Xml::openElement("legend", array("id" => "date_range_legend"));
363 - $control .= wfMsg('ct-date-range');
364 - $control .= Xml::closeElement("legend");
365 -
366362
367 -
368 - $control .= Xml::openElement("table", array("id" => "date_range_table"));
369 - $control .= Xml::openElement("tbody", array("id" => "date_range_tbody"));
370 -
371 -
372 - $control .= Xml::openElement("tr", array("id" => "start_date_row"));
373 -
374 - $control .= Xml::openElement("td", array("id" => "start_date_label", "class" => "date_range_label"));
375 - $control .= Xml::openElement("input", array("type" => "checkbox", "id" => "start_date_checkbox", "class" => "date_range_checkbox", "checked" => ""));
376 - $control .= Xml::closeElement("input");
377 - $control .= wfMsg( "ct-start-date" );
378 - $control .= Xml::closeElement("td");
379 -
380 - $control .= Xml::openElement("td", array("id" => "start_date_textarea"));
381 - $control .= Xml::openElement("input", array("type" => "text", "id" => "start_date", "class" => "date_range_input"));
382 - $control .= Xml::closeElement("input");
383 - $control .= Xml::closeElement("td");
384 -
385 - $control .= Xml::closeElement("tr");
386 -
387 - $control .= Xml::openElement("tr", array("id" => "end_date_row"));
388 -
389 - $control .= Xml::openElement("td", array("id" => "end_date_label", "class" => "date_range_label"));
390 - $control .= Xml::openElement("input", array("type" => "checkbox", "id" => "end_date_checkbox", "class" => "date_range_checkbox", "checked" => ""));
391 - $control .= Xml::closeElement("input");
392 - $control .= wfMsg( "ct-end-date" );
393 - $control .= Xml::closeElement("td");
394 -
395 - $control .= Xml::openElement("td", array("id" => "end_date_textarea"));
396 - $control .= Xml::openElement("input", array("type" => "text", "id" => "end_date", "class" => "date_range_input"));
397 - $control .= Xml::closeElement("input");
398 - $control .= Xml::closeElement("td");
399 -
400 - $control .= Xml::closeElement("tr");
401 -
 363+ function buildDateRange() {
 364+ $control = Xml::openElement( 'form', array( 'id' => 'date_range' ) );
402365
403 - $control .= Xml::openElement("tr", array("id" => "update_row"));
404 -
405 - $control .= Xml::openElement("td");
406 - $control .= Xml::closeElement("td");
407 -
408 - $control .= Xml::openElement("td", array("id" => "update_table_button_td"));
409 - $control .= Xml::openElement("input", array("type" => "button", "id" => "update_table_button", "class" => "update_button", "value" =>wfMsg("ct-update-table")));
410 - $control .= Xml::closeElement("input");
411 - $control .= Xml::closeElement("td");
412 -
413 - $control .= Xml::closeElement("tr");
414 -
415 - $control .= Xml::closeElement("tbody");
416 - $control .= Xml::closeElement("table");
417 - $control .= Xml::closeElement("fieldset");
418 -
419 - $control .= Xml::closeElement("form");
420 -
 366+ $control .= Xml::openElement( 'fieldset', array( 'id' => 'date_range_fieldset' ) );
 367+ $control .= Xml::openElement( 'legend', array( 'id' => 'date_range_legend' ) );
 368+ $control .= wfMsg( 'ct-date-range' );
 369+ $control .= Xml::closeElement( 'legend' );
 370+
 371+ $control .= Xml::openElement( 'table', array( 'id' => 'date_range_table' ) );
 372+ $control .= Xml::openElement( 'tbody', array( 'id' => 'date_range_tbody' ) );
 373+
 374+ $control .= Xml::openElement( 'tr', array( 'id' => 'start_date_row' ) );
 375+
 376+ $control .= Xml::openElement( 'td', array( 'id' => 'start_date_label', 'class' => 'date_range_label' ) );
 377+ $control .= Xml::openElement( 'input',
 378+ array(
 379+ 'type' => 'checkbox',
 380+ 'id' => 'start_date_checkbox',
 381+ 'class' => 'date_range_checkbox',
 382+ 'checked' => ''
 383+ )
 384+ );
 385+ $control .= Xml::closeElement( 'input' );
 386+ $control .= wfMsg( 'ct-start-date' );
 387+ $control .= Xml::closeElement( 'td' );
 388+
 389+ $control .= Xml::openElement( 'td', array( 'id' => 'start_date_textarea' ) );
 390+ $control .= Xml::openElement( 'input', array( 'type' => 'text', 'id' => 'start_date', 'class' => 'date_range_input' ) );
 391+ $control .= Xml::closeElement( 'input' );
 392+ $control .= Xml::closeElement( 'td' );
 393+
 394+ $control .= Xml::closeElement( 'tr' );
 395+
 396+ $control .= Xml::openElement( 'tr', array( 'id' => 'end_date_row' ) );
 397+
 398+ $control .= Xml::openElement( 'td', array( 'id' => 'end_date_label', 'class' => 'date_range_label' ) );
 399+ $control .= Xml::openElement( 'input',
 400+ array(
 401+ 'type' => 'checkbox',
 402+ 'id' => 'end_date_checkbox',
 403+ 'class' => 'date_range_checkbox',
 404+ 'checked' => ''
 405+ )
 406+ );
 407+ $control .= Xml::closeElement( 'input' );
 408+ $control .= wfMsg( 'ct-end-date' );
 409+ $control .= Xml::closeElement( 'td' );
 410+
 411+ $control .= Xml::openElement( 'td', array( 'id' => 'end_date_textarea' ) );
 412+ $control .= Xml::openElement( 'input', array( 'type' => 'text', 'id' => 'end_date', 'class' => 'date_range_input' ) );
 413+ $control .= Xml::closeElement( 'input' );
 414+ $control .= Xml::closeElement( 'td' );
 415+
 416+ $control .= Xml::closeElement( 'tr' );
 417+
 418+ $control .= Xml::openElement( 'tr', array( 'id' => 'update_row' ) );
 419+
 420+ $control .= Xml::openElement( 'td' );
 421+ $control .= Xml::closeElement( 'td' );
 422+
 423+ $control .= Xml::openElement( 'td', array( 'id' => 'update_table_button_td' ) );
 424+ $control .= Xml::openElement( 'input',
 425+ array(
 426+ 'type' => 'button',
 427+ 'id' => 'update_table_button',
 428+ 'class' => 'update_button',
 429+ 'value' => wfMsg( 'ct-update-table' )
 430+ )
 431+ );
 432+ $control .= Xml::closeElement( 'input' );
 433+ $control .= Xml::closeElement( 'td' );
 434+
 435+ $control .= Xml::closeElement( 'tr' );
 436+
 437+ $control .= Xml::closeElement( 'tbody' );
 438+ $control .= Xml::closeElement( 'table' );
 439+ $control .= Xml::closeElement( 'fieldset' );
 440+
 441+ $control .= Xml::closeElement( 'form' );
 442+
421443 return $control;
422444 }
423 -
424 -
425445
426 - public static function buildRowArray($minTime, $maxTime, $userDefs, $is_JSON= true){
427 -
428 -
429 - if($minTime == 0){
 446+ public static function buildRowArray( $minTime, $maxTime, $userDefs, $is_JSON = true) {
 447+ if( $minTime == 0 ) {
430448 $minTime = self::$minimum_date;
431449 }
432 - if($maxTime == 0){
433 - $maxTime = gmdate("Ymd",time()); //today
 450+
 451+ if( $maxTime == 0 ) {
 452+ $maxTime = gmdate( 'Ymd', time() ); // today
434453 }
435 -
436 - if($is_JSON){
437 - $userDefs = json_decode($userDefs, true);
 454+
 455+ if( $is_JSON ) {
 456+ $userDefs = json_decode( $userDefs, true );
438457 }
439 -
440 -
441 - $events = self::getTopEvents($minTime, $maxTime);
442 -
 458+
 459+ $events = self::getTopEvents( $minTime, $maxTime );
 460+
443461 $returnArray = array();
444 -
445 - while(($data_result = $events->fetchRow()) != null){
 462+
 463+ while( ( $data_result = $events->fetchRow() ) != null ) {
446464 $outputArray = array();
447465 $outputArray['event_name'] = $data_result['event_name'];
448466 $outputArray['event_id'] = $data_result['event_id'];
449 - $outputArray['expert'] = self::getTableValue($data_result['event_id'], $userDefs["expert"]);
450 - $outputArray['intermediate'] = self::getTableValue($data_result['event_id'], $userDefs["intermediate"]);
451 - $outputArray['basic'] = self::getTableValue($data_result['event_id'], $userDefs["basic"]);
452 - $outputArray['total'] = $data_result["totalevtid"];
 467+ $outputArray['expert'] = self::getTableValue( $data_result['event_id'], $userDefs['expert'] );
 468+ $outputArray['intermediate'] = self::getTableValue( $data_result['event_id'], $userDefs['intermediate'] );
 469+ $outputArray['basic'] = self::getTableValue( $data_result['event_id'], $userDefs['basic']);
 470+ $outputArray['total'] = $data_result['totalevtid'];
453471 $returnArray[] = $outputArray;
454472 }
455 -
 473+
456474 return $returnArray;
457 -
458475 }
459 -
460 - function buildRow($data_result, $row_count, $userDefs){
461 -
462 - $outputRow = Xml::openElement("tr", array("class" => "table_data_row"));
463 -
464 - //event name
465 - $outputRow .=Xml::openElement("td",
466 - array("class" => "event_name", "id" => "event_name_$row_count", "value" =>$data_result['event_id']));
467 - $outputRow .= $data_result['event_name'];
468 - $outputRow .=Xml::closeElement("td");
469 -
470 - //advanced users
471 - $cellValue = self::getTableValue($data_result['event_id'], $userDefs["expert"]);
472 - $outputRow .=Xml::openElement("td",
473 - array("class" => "event_data expert_data", "id" => "event_expert_$row_count",
474 - "value" => $cellValue));
475 - $outputRow .= $cellValue;
476 - $outputRow .=Xml::closeElement("td");
477 -
478 - //intermediate users
479 - $cellValue = self::getTableValue($data_result['event_id'], $userDefs["intermediate"]);
480 - $outputRow .=Xml::openElement("td",
481 - array("class" => "event_data intermediate_data", "id" => "event_intermediate_$row_count",
482 - "value" => $cellValue));
483 - $outputRow .= $cellValue;
484 - $outputRow .=Xml::closeElement("td");
485 -
486 - //basic users
487 - $cellValue = self::getTableValue($data_result['event_id'], $userDefs["basic"]);
488 - $outputRow .=Xml::openElement("td",
489 - array("class" => "event_data basic_data", "id" => "event_basic_$row_count",
490 - "value" => $cellValue));
491 - $outputRow .= $cellValue;
492 - $outputRow .=Xml::closeElement("td");
493 -
494 - //totals
495 - $cellValue = $data_result["totalevtid"];
496 - $outputRow .=Xml::openElement("td",
497 - array("class" => "event_data total_data", "id" => "total_$row_count",
498 - "value" => $cellValue));
499 - $outputRow .= $cellValue;
500 - $outputRow .=Xml::closeElement("td");
501 -
502 -
503 - $outputRow .= Xml::closeElement("tr");
504 -
505 - return $outputRow;
506 -
 476+
 477+ function buildRow( $data_result, $row_count, $userDefs ) {
 478+ $outputRow = Xml::openElement( 'tr', array( 'class' => 'table_data_row' ) );
 479+
 480+ // event name
 481+ $outputRow .= Xml::openElement( 'td',
 482+ array(
 483+ 'class' => 'event_name',
 484+ 'id' => "event_name_$row_count",
 485+ 'value' => $data_result['event_id']
 486+ )
 487+ );
 488+ $outputRow .= $data_result['event_name'];
 489+ $outputRow .= Xml::closeElement( 'td' );
 490+
 491+ // advanced users
 492+ $cellValue = self::getTableValue( $data_result['event_id'], $userDefs['expert'] );
 493+ $outputRow .=Xml::openElement( 'td',
 494+ array(
 495+ 'class' => 'event_data expert_data',
 496+ 'id' => "event_expert_$row_count",
 497+ 'value' => $cellValue
 498+ )
 499+ );
 500+ $outputRow .= $cellValue;
 501+ $outputRow .= Xml::closeElement( 'td' );
 502+
 503+ // intermediate users
 504+ $cellValue = self::getTableValue( $data_result['event_id'], $userDefs['intermediate'] );
 505+ $outputRow .= Xml::openElement( 'td',
 506+ array(
 507+ 'class' => 'event_data intermediate_data',
 508+ 'id' => "event_intermediate_$row_count",
 509+ 'value' => $cellValue
 510+ )
 511+ );
 512+ $outputRow .= $cellValue;
 513+ $outputRow .= Xml::closeElement( 'td' );
 514+
 515+ // basic users
 516+ $cellValue = self::getTableValue( $data_result['event_id'], $userDefs['basic'] );
 517+ $outputRow .= Xml::openElement( 'td',
 518+ array(
 519+ 'class' => 'event_data basic_data',
 520+ 'id' => "event_basic_$row_count",
 521+ 'value' => $cellValue
 522+ )
 523+ );
 524+ $outputRow .= $cellValue;
 525+ $outputRow .= Xml::closeElement( 'td' );
 526+
 527+ // totals
 528+ $cellValue = $data_result['totalevtid'];
 529+ $outputRow .=Xml::openElement( 'td',
 530+ array(
 531+ 'class' => 'event_data total_data',
 532+ 'id' => "total_$row_count",
 533+ 'value' => $cellValue
 534+ )
 535+ );
 536+ $outputRow .= $cellValue;
 537+ $outputRow .= Xml::closeElement( 'td' );
 538+ $outputRow .= Xml::closeElement( 'tr' );
 539+
 540+ return $outputRow;
507541 }
508542
509 - /*
510 - * get time constraints
 543+ /**
 544+ * Get time constraints
511545 * @param minTime minimum day (YYYYMMDD)
512546 * @param maxTime max day (YYYYMMDD)
513547 * NOTE: once some of the constraints have been finalized, this will use more of the Database functions and not raw SQL
514548 */
515 - static function getTimeConstraintsStatement( $minTime, $maxTime ){
516 - if($minTime == 0 || $maxTime == 0){
517 - return '';
 549+ static function getTimeConstraintsStatement( $minTime, $maxTime ) {
 550+ if( $minTime == 0 || $maxTime == 0 ) {
 551+ return '';
 552+ } else {
 553+ return "WHERE `action_time` >= '$minTime' AND `action_time` <= '$maxTime'";
518554 }
519 - else {
520 -
521 - return "WHERE `action_time` >= '$minTime' AND `action_time` <= '$maxTime'";
522 - }
523 -
524555 }
525 -
526 -
 556+
527557 /**
528558 * Gets the top N events as set in the page pref
529559 * @param $time_constraint_statement
530560 * @return unknown_type
531561 * NOTE: once some of the constraints have been finalized, this will use more of the Database functions and not raw SQL
532562 */
533 - public static function getTopEvents($minTime = "", $maxTime = "", $normalize_top_results = false){
534 -
535 - $normalize = "click_tracking";
536 - //escaped
537 -
538 - $time_constraint_statement = self::getTimeConstraintsStatement($minTime,$maxTime);
 563+ public static function getTopEvents( $minTime = '', $maxTime = '', $normalize_top_results = false ) {
 564+ $normalize = 'click_tracking';
 565+ // escaped
 566+
 567+ $time_constraint_statement = self::getTimeConstraintsStatement( $minTime, $maxTime );
539568 $time_constraint = $time_constraint_statement;
540 -
541 - if($normalize_top_results){
542 - $normalize = "(select distinct session_id, event_id from click_tracking $time_constraint_statement) as t1";
543 - $time_constraint = "";
 569+
 570+ if( $normalize_top_results ) {
 571+ $normalize = "(SELECT DISTINCT session_id, event_id FROM click_tracking $time_constraint_statement) AS t1";
 572+ $time_constraint = '';
544573 }
545 - $join = " ";
546 - $sql = "select count(event_id) as totalevtid, event_id,event_name from $normalize" .
 574+
 575+ $join = ' ';
 576+ $sql = "SELECT COUNT(event_id) AS totalevtid, event_id,event_name FROM $normalize" .
547577 " LEFT JOIN click_tracking_events ON event_id=click_tracking_events.id".
548 - " $time_constraint group by event_id order by totalevtid desc";
549 -
550 - //returns count(event_id),event_id, event_name, top one first
 578+ " $time_constraint GROUP BY event_id ORDER BY totalevtid DESC";
 579+
 580+ // returns count(event_id),event_id, event_name, top one first
551581 $dbr = wfGetDB( DB_SLAVE );
552 - $dbresult = $dbr->query($sql);
553 -
 582+ $dbresult = $dbr->query( $sql, __METHOD__ );
 583+
554584 return $dbresult;
555585 }
556586
@@ -557,31 +587,30 @@
558588 * Gets a table value for a given User ID
559589 * NOTE: once some of the constraints have been finalized, this will use more of the Database functions and not raw SQL
560590 */
561 - static function getTableValue($event_id, $userDef, $minTime = '', $maxTime = '', $normalize_results = false){
562 -
563 - $normalize = "click_tracking";
564 - //escaped
565 - $time_constraint_statement = self::getTimeConstraintsStatement($minTime,$maxTime);
 591+ static function getTableValue( $event_id, $userDef, $minTime = '', $maxTime = '', $normalize_results = false ) {
 592+ $normalize = 'click_tracking';
 593+ // escaped
 594+ $time_constraint_statement = self::getTimeConstraintsStatement( $minTime, $maxTime );
566595 $time_constraint = $time_constraint_statement;
567 - if($normalize_results){
568 - $normalize = "(select distinct session_id, event_id, user_total_contribs, user_contribs_span1, user_contribs_span2, user_contribs_span3, is_logged_in from click_tracking $time_constraint_statement) as t1";
569 - $time_constraint = "";
 596+ if( $normalize_results ) {
 597+ $normalize = "(SELECT DISTINCT session_id, event_id, user_total_contribs, user_contribs_span1, user_contribs_span2, user_contribs_span3, is_logged_in FROM click_tracking $time_constraint_statement) AS t1";
 598+ $time_constraint = '';
570599 }
571 -
572 - $user_conditions = SpecialClickTracking::buildUserDefQuery($userDef);
573 -
574 - $where = ($time_constraint == "" ? "where" : "");
575 -
576 - $and = ($time_constraint == "" ? "": "and");
577 -
578 - $sql ="select count(*) as totalcount from $normalize $where $time_constraint $and ($user_conditions) and event_id=$event_id";
579 -
 600+
 601+ $user_conditions = SpecialClickTracking::buildUserDefQuery( $userDef );
 602+
 603+ $where = ( $time_constraint == '' ? 'WHERE' : '' );
 604+
 605+ $and = ( $time_constraint == '' ? '' : 'AND' );
 606+
 607+ $sql = "SELECT COUNT(*) AS totalcount FROM $normalize $where $time_constraint $and ($user_conditions) AND event_id=$event_id";
 608+
580609 $dbr = wfGetDB( DB_SLAVE );
581 - $result = $dbr->query($sql);
 610+ $result = $dbr->query( $sql, __METHOD__ );
582611 $resRow = $result->fetchRow();
583 - return $resRow["totalcount"];
 612+ return $resRow['totalcount'];
584613 }
585 -
 614+
586615 /**
587616 * Generates a query for a user type definition
588617 * @param $include_anon_users boolean, include anon users or not
@@ -591,74 +620,90 @@
592621 * @param $contrib_3 array, nonempty AND conditions for user_contribs_1
593622 * @return unknown_type query
594623 */
595 - public static function buildUserDefQuery($def){
596 -
597 - $include_anon_users = (empty($def['anonymous'])?array():$def['anonymous']);
598 - $total_contribs = (empty($def['total_contribs'])?array():$def['total_contribs']);
599 - $contrib_1 = (empty($def['contrib_1'])?array():$def['contrib_1']);
600 - $contrib_2 = (empty($def['contrib_2'])?array():$def['contrib_2']);
601 - $contrib_3 = (empty($def['contrib_3'])?array():$def['contrib_3']);
602 -
 624+ public static function buildUserDefQuery( $def ) {
 625+ $include_anon_users = ( empty( $def['anonymous'] ) ? array() : $def['anonymous'] );
 626+ $total_contribs = ( empty( $def['total_contribs'] ) ? array() : $def['total_contribs'] );
 627+ $contrib_1 = ( empty( $def['contrib_1'] ) ? array() : $def['contrib_1'] );
 628+ $contrib_2 = ( empty( $def['contrib_2'] ) ? array() : $def['contrib_2'] );
 629+ $contrib_3 = ( empty( $def['contrib_3'] ) ? array() : $def['contrib_3'] );
 630+
603631 $or_conds = array();
604632 $and_conds = array();
605 - $sql = "";
606 -
607 -
608 - if( (boolean)$include_anon_users ){
609 - $or_conds[] = array("field" => "is_logged_in", "operation" => "=", "value" =>"0");
 633+ $sql = '';
 634+
 635+ if( (boolean)$include_anon_users ) {
 636+ $or_conds[] = array( 'field' => 'is_logged_in', 'operation' => '=', 'value' => '0' );
610637 }
611 -
612 - if(!empty($total_contribs)){
613 - foreach($total_contribs as $contribs){
614 - $and_conds[] = array("field" => "user_total_contribs", "operation" => SpecialClickTracking::validate_oper($contribs["operation"]), "value" => intval($contribs["value"]));
 638+
 639+ if( !empty( $total_contribs ) ) {
 640+ foreach( $total_contribs as $contribs ) {
 641+ $and_conds[] = array(
 642+ 'field' => 'user_total_contribs',
 643+ 'operation' => SpecialClickTracking::validate_oper( $contribs['operation'] ),
 644+ 'value' => intval( $contribs['value'] )
 645+ );
615646 }
616647 }
617 -
618 - if(!empty($contrib_1)){
619 - foreach($contrib_1 as $contribs){
620 - $and_conds[] = array("field" => "user_contribs_span1", "operation" => SpecialClickTracking::validate_oper($contribs["operation"]), "value" => intval($contribs["value"]));
 648+
 649+ if( !empty( $contrib_1 ) ) {
 650+ foreach( $contrib_1 as $contribs ) {
 651+ $and_conds[] = array(
 652+ 'field' => 'user_contribs_span1',
 653+ 'operation' => SpecialClickTracking::validate_oper( $contribs['operation'] ),
 654+ 'value' => intval( $contribs['value'] )
 655+ );
621656 }
622657 }
623 - if(!empty($contrib_2)){
624 - foreach($contrib_2 as $contribs){
625 - $and_conds[] = array("field" => "user_contribs_span2", "operation" => SpecialClickTracking::validate_oper($contribs["operation"]), "value" => intval($contribs["value"]));
 658+
 659+ if( !empty( $contrib_2 ) ) {
 660+ foreach( $contrib_2 as $contribs ) {
 661+ $and_conds[] = array(
 662+ 'field' => 'user_contribs_span2',
 663+ 'operation' => SpecialClickTracking::validate_oper( $contribs['operation'] ),
 664+ 'value' => intval( $contribs['value'] )
 665+ );
626666 }
627667 }
628 - if(!empty($contrib_3)){
629 - foreach($contrib_3 as $contribs){
630 - $and_conds[] = array("field" => "user_contribs_span3", "operation" => SpecialClickTracking::validate_oper($contribs["operation"]), "value" => intval($contribs["value"]));
 668+
 669+ if( !empty( $contrib_3 ) ) {
 670+ foreach( $contrib_3 as $contribs ) {
 671+ $and_conds[] = array(
 672+ 'field' => 'user_contribs_span3',
 673+ 'operation' => SpecialClickTracking::validate_oper( $contribs['operation'] ),
 674+ 'value' => intval( $contribs['value'] )
 675+ );
631676 }
632677 }
633 -
634 - foreach($and_conds as $cond){
635 - if(!empty($sql)){
636 - $sql .= " AND ";
 678+
 679+ foreach( $and_conds as $cond ) {
 680+ if( !empty( $sql ) ) {
 681+ $sql .= ' AND ';
637682 }
638 - $sql .= $cond["field"] . " " . $cond["operation"] . " " . $cond["value"];
 683+ $sql .= $cond['field'] . ' ' . $cond['operation'] . ' ' . $cond['value'];
639684 }
640 - foreach($or_conds as $cond){
641 - if(!empty($sql)){
642 - $sql .= " OR ";
 685+
 686+ foreach( $or_conds as $cond ) {
 687+ if( !empty( $sql ) ) {
 688+ $sql .= ' OR ';
643689 }
644 - $sql .= $cond["field"] . " " . $cond["operation"] . " " . $cond["value"];
 690+ $sql .= $cond['field'] . ' ' . $cond['operation'] . ' ' . $cond['value'];
645691 }
646 -
 692+
647693 return $sql;
648694 }
649 -
650 - public static function validate_oper($operation){
651 - $o_trim = trim($operation);
652 - switch($o_trim){ //valid operations
653 - case ">":
654 - case "<":
655 - case "<=":
656 - case ">=":
657 - case "=":
 695+
 696+ public static function validate_oper( $operation ) {
 697+ $o_trim = trim( $operation );
 698+ switch( $o_trim ) { // valid operations
 699+ case '>':
 700+ case '<':
 701+ case '<=':
 702+ case '>=':
 703+ case '=':
658704 return $o_trim;
659705 default:
660 - return "=";
 706+ return '=';
661707 }
662708 }
663 -
664 -
 709+
665710 }
\ No newline at end of file
Index: trunk/extensions/UsabilityInitiative/ClickTracking/ClickTracking.hooks.php
@@ -40,22 +40,21 @@
4141 $tables[] = 'click_tracking_events';
4242 return true;
4343 }
44 -
45 - /*
46 - * check to see if user is throttled
 44+
 45+ /**
 46+ * Check to see if user is throttled
4747 */
4848 public static function isUserThrottled() {
4949 global $wgClickTrackThrottle;
5050 return !( $wgClickTrackThrottle >= 0 && rand() % $wgClickTrackThrottle == 0 );
5151 }
52 -
53 -
 52+
5453 /**
5554 * Adds JavaScript
5655 */
5756 public static function addJS() {
5857 global $wgOut;
59 -
 58+
6059 UsabilityInitiativeHooks::initialize();
6160 UsabilityInitiativeHooks::addScript( 'ClickTracking/ClickTracking.js' );
6261 UsabilityInitiativeHooks::addVariables(
@@ -64,8 +63,8 @@
6564 'wgClickTrackingIsThrottled' => ClickTrackingHooks::isUserThrottled()
6665 )
6766 );
 67+
6868 return true;
69 -
7069 }
7170
7271 /**
@@ -108,14 +107,13 @@
109108 return $edits;
110109 }
111110
112 -
113111 /**
114112 * Get event ID from name
115113 * @param $event_name String: name of the event to get
116114 * @return integer
117115 */
118116 public static function getEventIDFromName( $event_name ) {
119 - $dbw = wfGetDB( DB_MASTER ); //replication lag means sometimes a new event will not exist in the table yet
 117+ $dbw = wfGetDB( DB_MASTER ); // replication lag means sometimes a new event will not exist in the table yet
120118
121119 $id_num = $dbw->selectField(
122120 'click_tracking_events',
Index: trunk/extensions/UsabilityInitiative/ClickTracking/ClickTracking.js
@@ -1,6 +1,6 @@
22 (function($) {
33
4 - if(!wgClickTrackingIsThrottled){
 4+ if( !wgClickTrackingIsThrottled ) {
55 // creates 'track action' function to call the clicktracking API and send the ID
66 $.trackAction = function ( id ) {
77 $j.post( wgScriptPath + '/api.php', { 'action': 'clicktracking', 'eventid': id, 'token': wgTrackingToken } );
Index: trunk/extensions/UsabilityInitiative/ClickTracking/SpecialClickTracking.js
@@ -1,531 +1,509 @@
22 (function($) {
33 /* Very limited JSON encoder */
4 - $.json_encode = function (js_obj){
 4+ $.json_encode = function( js_obj ) {
55 var returnstr = "{ ";
6 -
7 - //trailing commas and json don't mix
 6+
 7+ // trailing commas and json don't mix
88 var propertynum = 0;
9 - for(property in js_obj){
10 - if(propertynum > 0){
 9+ for( property in js_obj ) {
 10+ if( propertynum > 0 ) {
1111 returnstr +=", ";
1212 }
1313 returnstr += "\"" + property + "\"" + " : ";
14 - if(typeof js_obj[property] == 'object'){
15 - returnstr += $.json_encode(js_obj[property]);
16 - }
17 - else{
 14+ if( typeof js_obj[property] == 'object' ) {
 15+ returnstr += $.json_encode( js_obj[property] );
 16+ } else {
1817 returnstr += "\"" + js_obj[property] + "\" ";
1918 }
2019 propertynum++;
2120 }
22 -
23 - returnstr+= " }";
 21+
 22+ returnstr += " }";
2423 return returnstr;
2524 };
26 -
27 -
28 -
29 - $.getUserDefsFromDialog = function(){
 25+
 26+ $.getUserDefsFromDialog = function() {
3027 var currUserDefs = new Array();
31 - if($("#anon_users_checkbox").is(":checked")){
32 - currUserDefs["anonymous"] = 1;
 28+ if( $("#anon_users_checkbox").is( ":checked" ) ) {
 29+ currUserDefs['anonymous'] = 1;
 30+ } else {
 31+ currUserDefs['anonymous'] = 0;
3332 }
34 - else{
35 - currUserDefs["anonymous"] = 0;
36 - }
37 -
38 - var getCheckBoxData = function(contribName){
39 - if($("#"+ contribName +"_checkbox").is(":checked")){
 33+
 34+ var getCheckBoxData = function( contribName ) {
 35+ if( $("#"+ contribName + "_checkbox").is( ":checked" ) ) {
4036 currUserDefs[contribName] = new Array();
 37+ } else {
 38+ return;
4139 }
42 - else{ return;}
43 - var totalConds = $("#" + contribName +"_div").data("totalConditions");
 40+ var totalConds = $("#" + contribName + "_div").data("totalConditions");
4441 var i;
45 -
46 - for(i = 1; i <= totalConds; i++){
47 - if($("#"+contribName+"_"+i+"_checkbox").is(":checked")){
48 - $("#"+contribName+"_"+i+"_ltgt").children().each(function(){
49 - if($(this).is(":selected")){
 42+
 43+ for( i = 1; i <= totalConds; i++ ) {
 44+ if( $("#" + contribName + "_" + i + "_checkbox").is( ":checked" ) ) {
 45+ $("#" + contribName + "_" + i + "_ltgt").children().each(function() {
 46+ if( $(this).is( ":selected" ) ) {
5047 var currentCond = new Array();
51 - switch($(this).attr("value")){
52 - case 'lt': currentCond["operation"] = "<"; break;
53 - case 'lteq': currentCond["operation"] = "<="; break;
54 - case 'gt': currentCond["operation"] = ">"; break;
55 - case 'gteq' : currentCond["operation"] = ">="; break;
56 - default: currentCond["operation"] = "<"; break;
 48+ switch( $(this).attr("value") ) {
 49+ case 'lt':
 50+ currentCond['operation'] = '<';
 51+ break;
 52+ case 'lteq':
 53+ currentCond['operation'] = '<=';
 54+ break;
 55+ case 'gt':
 56+ currentCond['operation'] = '>';
 57+ break;
 58+ case 'gteq':
 59+ currentCond['operation'] = '>=';
 60+ break;
 61+ default:
 62+ currentCond['operation'] = '<';
 63+ break;
5764 }
58 - currentCond["value"] = $("#"+contribName+"_"+i+"_text").val();
 65+ currentCond['value'] = $("#" + contribName + "_" + i + "_text").val();
5966 currUserDefs[contribName].push(currentCond);
6067 }
6168 });
62 - } //ifchecked
63 - }//forloop
 69+ } // ifchecked
 70+ } // forloop
6471 };
65 -
66 -
 72+
6773 getCheckBoxData("total_contribs");
6874 getCheckBoxData("contribs_span_1");
6975 getCheckBoxData("contribs_span_2");
7076 getCheckBoxData("contribs_span_3");
7177 wgClickTrackUserDefs[$("#user_def_alter_legend").data("currentlyEditing")] = currUserDefs;
7278 };
73 -
74 - $.renderUserDefDialogWith = function (userDef, defName){
75 - //change name
 79+
 80+ $.renderUserDefDialogWith = function( userDef, defName ) {
 81+ // change name
7682 $("#user_def_alter_legend").text($("#user_def_alter_legend").data("defaultChangeText") + " " + defName);
7783 $("#user_def_alter_legend").data("currentlyEditing", defName);
78 -
79 -
80 - var setContribs = function(conditionArray, contribName){
81 -
82 - initialDiv = $("<div></div>").attr("id", contribName +"_div");
83 - initialDiv.addClass("checkbox_div");
84 - initialDiv.addClass("control_div");
85 -
86 - textDiv = $("<div></div>").attr("id", contribName +"_text_div");
87 - mainCheckbox = $("<input>").attr("id", contribName +"_checkbox");
88 - mainCheckbox.attr("type", "checkbox");
89 - mainCheckbox.addClass("user_def_checkbox");
90 -
91 - if(conditionArray.length > 0){
92 - mainCheckbox.attr("checked", true);
 84+
 85+ var setContribs = function( conditionArray, contribName ) {
 86+ initialDiv = $("<div></div>").attr('id', contribName + '_div');
 87+ initialDiv.addClass('checkbox_div');
 88+ initialDiv.addClass('control_div');
 89+
 90+ textDiv = $("<div></div>").attr('id', contribName + '_text_div');
 91+ mainCheckbox = $("<input>").attr('id', contribName + '_checkbox');
 92+ mainCheckbox.attr('type', 'checkbox');
 93+ mainCheckbox.addClass('user_def_checkbox');
 94+
 95+ if( conditionArray.length > 0 ) {
 96+ mainCheckbox.attr( 'checked', true );
9397 }
94 -
95 - textDiv.append(mainCheckbox);
96 - textDiv.text(contribName); //i18n txt here
97 - textDiv.css('display', 'inline');
98 - initialDiv.append(mainCheckbox);
99 - initialDiv.append(textDiv);
100 -
101 -
102 -
103 - var buildConditionDiv = function (condition, counter, isChecked){
104 - conditionDiv = $("<div></div>").attr("id", contribName + "_range_" + counter + "_div");
105 - conditionDiv.addClass("checkbox_div");
106 - conditionDiv.addClass("sub_option_div");
10798
 99+ textDiv.append( mainCheckbox );
 100+ textDiv.text( contribName ); // i18n txt here
 101+ textDiv.css( 'display', 'inline' );
 102+ initialDiv.append( mainCheckbox );
 103+ initialDiv.append( textDiv );
 104+
 105+ var buildConditionDiv = function( condition, counter, isChecked ) {
 106+ conditionDiv = $("<div></div>").attr('id', contribName + '_range_' + counter + '_div');
 107+ conditionDiv.addClass( 'checkbox_div' );
 108+ conditionDiv.addClass( 'sub_option_div' );
 109+
108110 //initialDiv.append(conditionDiv);
109 - cCheckbox = $("<input></input>").attr("id", contribName+"_"+counter+"_checkbox");
110 - cCheckbox.attr("type", "checkbox");
111 - if(isChecked){
112 - cCheckbox.attr("checked", true);
 111+ cCheckbox = $("<input></input>").attr('id', contribName + '_' + counter + '_checkbox');
 112+ cCheckbox.attr('type', 'checkbox');
 113+ if( isChecked ) {
 114+ cCheckbox.attr( 'checked', true );
113115 }
114 - cCheckbox.addClass("number_select_checkbox");
115 - conditionDiv.append(cCheckbox);
116 -
117 - cSelect = $("<select></select>").attr("id", contribName+"_"+counter+"_ltgt");
118 - cSelect.addClass("number_select_ltgt");
119 -
120 - cOpt1 = $("<option></option>").attr("id", contribName+"_"+counter+"_lt");
121 - cOpt1.addClass("number_select_ltgt_opt");
122 - cOpt1.attr("value", "lt");
123 - cOpt1.text("<");
124 - if(condition["operation"] == "<"){
125 - cOpt1.attr("selected", true);
 116+ cCheckbox.addClass( 'number_select_checkbox' );
 117+ conditionDiv.append( cCheckbox );
 118+
 119+ cSelect = $("<select></select>").attr('id', contribName + '_' + counter + '_ltgt');
 120+ cSelect.addClass( 'number_select_ltgt' );
 121+
 122+ cOpt1 = $("<option></option>").attr('id', contribName + '_' + counter + '_lt');
 123+ cOpt1.addClass( 'number_select_ltgt_opt' );
 124+ cOpt1.attr( 'value', 'lt' );
 125+ cOpt1.text( '<' );
 126+ if( condition['operation'] == '<' ) {
 127+ cOpt1.attr( 'selected', true );
126128 }
127 -
128 -
129 - cOpt2 = $("<option></option>").attr("id", contribName+"_"+counter+"_gt");
130 - cOpt2.addClass("number_select_ltgt_opt");
131 - cOpt2.attr("value", "gt");
132 - cOpt2.text(">");
133 - if(condition["operation"] == ">"){
134 - cOpt2.attr("selected", true);
 129+
 130+ cOpt2 = $("<option></option>").attr('id', contribName + '_' + counter + '_gt');
 131+ cOpt2.addClass( 'number_select_ltgt_opt' );
 132+ cOpt2.attr( 'value', 'gt' );
 133+ cOpt2.text( '>' );
 134+ if( condition['operation'] == '>' ) {
 135+ cOpt2.attr( 'selected', true );
135136 }
136 -
137 - cOpt3 = $("<option></option>").attr("id", contribName+"_"+counter+"_lteq");
138 - cOpt3.addClass("number_select_ltgt_opt");
139 - cOpt3.attr("value", "lteq");
140 - cOpt3.text("<=");
141 - if(condition["operation"] == "<="){
142 - cOpt3.attr("selected", true);
 137+
 138+ cOpt3 = $("<option></option>").attr('id', contribName + '_' + counter + '_lteq');
 139+ cOpt3.addClass( 'number_select_ltgt_opt' );
 140+ cOpt3.attr( 'value', 'lteq' );
 141+ cOpt3.text( '<=' );
 142+ if( condition['operation'] == '<=' ) {
 143+ cOpt3.attr( 'selected', true );
143144 }
144 -
145 - cOpt4 = $("<option></option>").attr("id", contribName+"_"+counter+"_gteq");
146 - cOpt4.addClass("number_select_ltgt_opt");
147 - cOpt4.attr("value", "gteq");
148 - cOpt4.text(">=");
149 - if(condition["operation"] == ">="){
150 - cOpt4.attr("selected", true);
 145+
 146+ cOpt4 = $("<option></option>").attr('id', contribName + '_' + counter + '_gteq');
 147+ cOpt4.addClass( 'number_select_ltgt_opt' );
 148+ cOpt4.attr( 'value', 'gteq' );
 149+ cOpt4.text( '>=' );
 150+ if( condition['operation'] == '>=' ) {
 151+ cOpt4.attr( 'selected', true );
151152 }
152 -
153 - cSelect.append(cOpt1);
154 - cSelect.append(cOpt2);
155 - cSelect.append(cOpt3);
156 - cSelect.append(cOpt4);
157 - conditionDiv.append(cSelect);
158 -
159 - cTextInput = $("<input></input>").attr("id", contribName+"_"+counter+"_text");
160 - cTextInput.addClass("number_select_text");
161 - cTextInput.attr('value', condition["value"]);
162 - conditionDiv.append(cTextInput);
 153+
 154+ cSelect.append( cOpt1 );
 155+ cSelect.append( cOpt2 );
 156+ cSelect.append( cOpt3 );
 157+ cSelect.append( cOpt4 );
 158+ conditionDiv.append( cSelect );
 159+
 160+ cTextInput = $("<input></input>").attr('id', contribName + '_' + counter + '_text');
 161+ cTextInput.addClass( 'number_select_text' );
 162+ cTextInput.attr( 'value', condition['value'] );
 163+ conditionDiv.append( cTextInput );
163164 return conditionDiv;
164165 };
165 -
166 -
167 - var i=0;
168 - for( var condition in conditionArray){
 166+
 167+ var i = 0;
 168+ for( var condition in conditionArray ) {
169169 i++;
170 - var conditionDiv = buildConditionDiv(conditionArray[condition], i, true);
171 - initialDiv.append(conditionDiv);
172 - } //forloop
173 - initialDiv.data("totalConditions", i);
174 - addConditions = $("<div></div>").attr("id", contribName+"_addbutton");
175 - addConditions.data("contribName", contribName);
176 - addConditions.addClass("add_condition_button");
177 - addConditions.text("+");
178 - initialDiv.append(addConditions);
179 - addConditions.click( function(){
180 - var initDiv = $("#" + $(this).data('contribName') +"_div");
181 - var totalConds = initDiv.data('totalConditions');
 170+ var conditionDiv = buildConditionDiv( conditionArray[condition], i, true );
 171+ initialDiv.append( conditionDiv );
 172+ } // forloop
 173+ initialDiv.data( 'totalConditions', i );
 174+ addConditions = $("<div></div>").attr('id', contribName + '_addbutton');
 175+ addConditions.data( 'contribName', contribName );
 176+ addConditions.addClass( 'add_condition_button' );
 177+ addConditions.text( '+' );
 178+ initialDiv.append( addConditions );
 179+ addConditions.click( function() {
 180+ var initDiv = $("#" + $(this).data('contribName') + '_div');
 181+ var totalConds = initDiv.data( 'totalConditions' );
182182 totalConds++;
183 - initDiv.data('totalConditions', totalConds);
 183+ initDiv.data( 'totalConditions', totalConds );
184184 var tmpCond = new Array();
185 - tmpCond["operation"] = " ";
186 - tmpCond["value"] = " ";
 185+ tmpCond['operation'] = ' ';
 186+ tmpCond['value'] = ' ';
187187
188188 buildConditionDiv(tmpCond, totalConds).insertBefore($(this));
189 - initDiv.data("totalConditions", totalConds, false);
190 -
191 -
 189+ initDiv.data( 'totalConditions', totalConds, false );
192190 });
193 -
 191+
194192 return initialDiv;
195 - }; //setcontribs
196 -
197 -
198 - //check anonymous
 193+ }; // setcontribs
 194+
 195+ // check anonymous
199196 var anon = false;
200 - if(parseInt(userDef["anonymous"]) == 1){
 197+ if( parseInt( userDef['anonymous'] ) == 1 ) {
201198 anon = true;
202199 }
203200 $("#anon_users_checkbox").attr('checked', anon);
204 -
205 - //clear out old contents
 201+
 202+ // clear out old contents
206203 $("#contrib_opts_container").empty();
207 -
208 - var setup_set_contribs = function(contribName){
 204+
 205+ var setup_set_contribs = function( contribName ) {
209206 var current_contribs = userDef[contribName];
210 - if(current_contribs == undefined){
 207+ if( current_contribs == undefined ) {
211208 current_contribs = new Array();
212209 }
213 - $("#contrib_opts_container").append(setContribs(current_contribs, contribName));
 210+ $("#contrib_opts_container").append( setContribs( current_contribs, contribName ) );
214211 };
215 -
216 -
217 - //total contribs
218 - setup_set_contribs("total_contribs");
219 - setup_set_contribs("contribs_span_1");
220 - setup_set_contribs("contribs_span_2");
221 - setup_set_contribs("contribs_span_3");
222 -
223 - //OK button
224 - var okButton = $("<input>").attr("id", "ok_button");
225 - okButton.attr("type", "button");
226 - okButton.attr("value", "ok");
227 - okButton.click(function(){
 212+
 213+ // total contribs
 214+ setup_set_contribs( 'total_contribs' );
 215+ setup_set_contribs( 'contribs_span_1' );
 216+ setup_set_contribs( 'contribs_span_2' );
 217+ setup_set_contribs( 'contribs_span_3' );
 218+
 219+ // OK button
 220+ var okButton = $("<input>").attr('id', 'ok_button');
 221+ okButton.attr( 'type', 'button' );
 222+ okButton.attr( 'value', 'ok' );
 223+ okButton.click(function() {
228224 $.getUserDefsFromDialog();
229225 $("#user_def_dialog").dialog('close');
230 -
231226 });
232227 $("#contrib_opts_container").append(okButton);
233 -
234 - }; //renderUserDefDialogWith
235 -
236 -
 228+ }; // renderUserDefDialogWith
237229
238 -
239 - //functions
240 - $.updateChart = function(){
241 -
242 - event_name = $("#chart_img").data("event_name");
243 -
244 - var processChartJSON = function(data, status){
245 -
246 - var getMax = function(findMax){
 230+ // functions
 231+ $.updateChart = function() {
 232+ event_name = $("#chart_img").data('event_name');
 233+
 234+ var processChartJSON = function( data, status ) {
 235+
 236+ var getMax = function( findMax ) {
247237 var retval = Number.MIN_VALUE;
248 - for(var i in findMax){
249 - if(findMax[i] > retval) {
 238+ for( var i in findMax ) {
 239+ if( findMax[i] > retval ) {
250240 retval = findMax[i];
251241 }
252242 }
253243 return retval;
254244 };
255 -
256 - max1 = getMax(data['datapoints']['expert']);
257 - max2 = getMax(data['datapoints']['intermediate']);
258 - max3 = getMax(data['datapoints']['basic']);
259 - max = Math.max(max3, Math.max(max1,max2));
 245+
 246+ max1 = getMax( data['datapoints']['expert'] );
 247+ max2 = getMax( data['datapoints']['intermediate'] );
 248+ max3 = getMax( data['datapoints']['basic'] );
 249+ max = Math.max( max3, Math.max( max1, max2 ) );
260250 chartURL = 'http://chart.apis.google.com/chart?' +
261251 'chs=400x400&' +
262252 'cht=lc&' +
263253 'chco=FF0000,0000FF,00FF00&' +
264254 'chtt=' + event_name + ' from ' + $("#start_date").val() +' to ' +$("#end_date").val() + "&" +
265 - 'chdl=' + 'Expert|Intermediate|Beginner' + "&"+
 255+ 'chdl=' + 'Expert|Intermediate|Beginner' + "&" +
266256 'chxt=x,y&' +
267 - 'chd=t:' + data['datapoints']['expert'].join(',') + "|" +
 257+ 'chd=t:' + data['datapoints']['expert'].join(',') + "|" +
268258 data['datapoints']['intermediate'].join(',') + "|" + data['datapoints']['basic'].join(',') + "&" +
269259 'chds=0,'+ max +',0,'+ max +',0,'+ max
270260 ;
271 - $("#chart_img").attr( "src",chartURL);
 261+ $("#chart_img").attr( 'src', chartURL );
272262 };
273 -
274 -
 263+
275264 start_date = $("#start_date").val();
276 - if($("#start_date").hasClass("hidden")){
 265+ if( $("#start_date").hasClass( 'hidden' ) ) {
277266 start_date = '0';
278267 }
279 -
 268+
280269 end_date = $("#end_date").val();
281 - if($("#end_date").hasClass("hidden")){
 270+ if( $("#end_date").hasClass( 'hidden' ) ) {
282271 end_date = '0';
283272 }
284 -
285 - //post relevant info
286 - $j.post( wgScriptPath + '/api.php',
287 - { 'action': 'specialclicktracking', 'format': 'json',
288 - 'eventid': $("#chart_img").data( "eventid" ), 'increment': $("#chart_increment").val(),
289 - 'startdate': start_date, 'enddate':end_date, 'userdefs': $.json_encode(wgClickTrackUserDefs) } , processChartJSON, "json");
 273+
 274+ // post relevant info
 275+ $j.post( wgScriptPath + '/api.php',
 276+ { 'action': 'specialclicktracking', 'format': 'json',
 277+ 'eventid': $("#chart_img").data( 'eventid' ), 'increment': $("#chart_increment").val(),
 278+ 'startdate': start_date, 'enddate': end_date, 'userdefs': $.json_encode( wgClickTrackUserDefs ) },
 279+ processChartJSON, 'json'
 280+ );
290281 };
291 -
292 -
293 - //pretty colors for the table
294 - $.colorizeTable = function (){
295 - //expert
296 -
297 -
298 - //get totals
 282+
 283+ // pretty colors for the table
 284+ $.colorizeTable = function() {
 285+ // expert
 286+
 287+ // get totals
299288 var expert_total = 0;
300 -
301 - $(".expert_data").each(function(){
302 - expert_total += parseInt($(this).attr( "value"));
 289+
 290+ $(".expert_data").each(function() {
 291+ expert_total += parseInt( $(this).attr( 'value' ) );
303292 });
304 -
305 - //set proper red shade
306 - $(".expert_data").each(function(){
 293+
 294+ // set proper red shade
 295+ $(".expert_data").each(function() {
307296 var rval = 255;
308 - var gval = (expert_total == 0 ? 255 : 255 - (255 * $(this).attr("value") / expert_total));
 297+ var gval = ( expert_total == 0 ? 255 : 255 - ( 255 * $(this).attr( 'value' ) / expert_total ) );
309298 var bval = gval;
310 - rgbString = "rgb(" + parseInt(rval) + "," + parseInt(gval) + "," + parseInt(bval) + ")";
311 - $(this).data("rgb", rgbString);
312 - $(this).css("color", rgbString);
313 - $(this).css("background-color", rgbString);
 299+ rgbString = "rgb(" + parseInt( rval ) + "," + parseInt( gval ) + "," + parseInt( bval ) + ")";
 300+ $(this).data('rgb', rgbString);
 301+ $(this).css('color', rgbString);
 302+ $(this).css('background-color', rgbString);
314303 });
315 -
316304
317 - //intermediate
318 -
319 - //total
 305+ // intermediate
 306+
 307+ // total
320308 var intermediate_total = 0;
321 - $(".intermediate_data").each(function(){
322 - intermediate_total += parseInt($(this).attr( "value"));
 309+ $(".intermediate_data").each(function() {
 310+ intermediate_total += parseInt( $(this).attr( 'value' ) );
323311 });
324 -
325 -
326 - //blue shade
327 - $(".intermediate_data").each(function(){
328 - var rval = (intermediate_total == 0 ? 255 : 255 - (255 * $(this).attr("value") / intermediate_total));
 312+
 313+ // blue shade
 314+ $(".intermediate_data").each(function() {
 315+ var rval = ( intermediate_total == 0 ? 255 : 255 - ( 255 * $(this).attr( 'value' ) / intermediate_total ) );
329316 var gval = rval;
330317 var bval = 255;
331 - rgbString = "rgb(" + parseInt(rval) + "," + parseInt(gval) + "," + parseInt(bval) + ")";
332 - $(this).data("rgb", rgbString);
333 - $(this).css("color", rgbString);
334 - $(this).css("background-color", rgbString);
 318+ rgbString = "rgb(" + parseInt( rval ) + "," + parseInt( gval ) + "," + parseInt( bval ) + ")";
 319+ $(this).data('rgb', rgbString);
 320+ $(this).css('color', rgbString);
 321+ $(this).css('background-color', rgbString);
335322 });
336 -
337 - //total
 323+
 324+ // total
338325 var basic_total = 0;
339 - $(".basic_data").each(function(){
340 - basic_total += parseInt($(this).attr( "value"));
 326+ $(".basic_data").each(function() {
 327+ basic_total += parseInt( $(this).attr( 'value' ) );
341328 });
342 -
343 - //green shade
344 - $(".basic_data").each(function(){
345 - var rval = (basic_total == 0 ? 255 : 255 - (255 * $(this).attr("value") / basic_total));
 329+
 330+ // green shade
 331+ $(".basic_data").each(function() {
 332+ var rval = ( basic_total == 0 ? 255 : 255 - ( 255 * $(this).attr( 'value' ) / basic_total ) );
346333 var gval = 255;
347334 var bval = rval;
348 - rgbString = "rgb(" + parseInt(rval) + "," + parseInt(gval) + "," + parseInt(bval) + ")";
349 - $(this).data("rgb", rgbString);
350 - $(this).css("color", rgbString);
351 - $(this).css("background-color", rgbString);
 335+ rgbString = "rgb(" + parseInt( rval ) + "," + parseInt( gval ) + "," + parseInt( bval ) + ")";
 336+ $(this).data('rgb', rgbString);
 337+ $(this).css('color', rgbString);
 338+ $(this).css('background-color', rgbString);
352339 });
353 -
 340+
354341 // I wanted to do this with classes, but the element's style rule wins over class rule
355342 // and each element has its own alternative color
356 - $(".event_data").mouseover(function(){
357 - $(this).css("color", "#000000");
358 - $(this).css("background-color", "#FFFFFF");
 343+ $(".event_data").mouseover(function() {
 344+ $(this).css('color', '#000000');
 345+ $(this).css('background-color', '#FFFFFF');
359346 });
360 -
361 - $(".event_data").mouseout(function(){
 347+
 348+ $(".event_data").mouseout(function() {
362349 rgbString = $(this).data("rgb");
363 - $(this).css("color", rgbString);
364 - $(this).css("background-color", rgbString);
 350+ $(this).css('color', rgbString);
 351+ $(this).css('background-color', rgbString);
365352 });
366 -
367 - };//colorize
368 -
369 - $.updateTable = function(){
370 -
371 - var processTableJSON = function(data, status){
372 -
373 - //clear
374 - $(".table_data_row").each(function(){ $(this).remove();});
375 -
 353+
 354+ }; // colorize
 355+
 356+ $.updateTable = function() {
 357+ var processTableJSON = function( data, status ) {
 358+ // clear
 359+ $(".table_data_row").each( function() { $(this).remove(); } );
 360+
376361 var row_count = 0;
377 - for( var row_iter in data['tablevals']['vals']){
378 - var row = data['tablevals']['vals'][row_iter]; //really, JS?
 362+ for( var row_iter in data['tablevals']['vals'] ) {
 363+ var row = data['tablevals']['vals'][row_iter]; // really, JS?
379364 row_count++;
380 -
 365+
381366 var outputRow = $("<tr></tr>");
382 - outputRow.addClass("table_data_row");
383 -
384 - var cell =$("<td></td>").attr("id", "event_name_" + row_count);
385 - cell.addClass("event_name");
386 - cell.attr("value", row['event_id']);
387 - cell.text(row['event_name']);
388 - outputRow.append(cell);
389 -
390 - var createClassCell = function(userclass){
391 - var newcell = $("<td></td>").attr("id", "event_"+userclass+"_" + row_count);
392 - newcell.addClass("event_data");
393 - newcell.addClass(userclass+"_data");
394 - newcell.text(row[userclass]);
395 - newcell.attr("value", row[userclass]);
396 - outputRow.append(newcell);
397 -
 367+ outputRow.addClass( 'table_data_row' );
 368+
 369+ var cell =$("<td></td>").attr('id', 'event_name_' + row_count);
 370+ cell.addClass( 'event_name' );
 371+ cell.attr( 'value', row['event_id'] );
 372+ cell.text( row['event_name']);
 373+ outputRow.append( cell );
 374+
 375+ var createClassCell = function( userclass ) {
 376+ var newcell = $("<td></td>").attr('id', 'event_' + userclass + '_' + row_count);
 377+ newcell.addClass( 'event_data' );
 378+ newcell.addClass( userclass + '_data' );
 379+ newcell.text( row[userclass] );
 380+ newcell.attr( 'value', row[userclass] );
 381+ outputRow.append( newcell );
398382 };
399 -
400 - createClassCell("expert");
401 - createClassCell("intermediate");
402 - createClassCell("basic");
403 - createClassCell("total");
404 - $("#clicktrack_data_table").append(outputRow);
 383+
 384+ createClassCell( 'expert' );
 385+ createClassCell( 'intermediate' );
 386+ createClassCell( 'basic' );
 387+ createClassCell( 'total' );
 388+ $("#clicktrack_data_table").append( outputRow );
405389 }
406 -
 390+
407391 $.colorizeTable();
408392 };
409 -
410 -
 393+
411394 start_date = $("#start_date").val();
412 - if($("#start_date").hasClass("hidden")){
 395+ if( $("#start_date").hasClass( 'hidden' ) ) {
413396 start_date = '0';
414397 }
415 -
 398+
416399 end_date = $("#end_date").val();
417 - if($("#end_date").hasClass("hidden")){
 400+ if( $("#end_date").hasClass( 'hidden' ) ) {
418401 end_date = '0';
419402 }
420 -
421 - //post relevant info
422 - $j.post( wgScriptPath + '/api.php',
423 - { 'action': 'specialclicktracking', 'format': 'json',
424 - 'eventid': 1, 'increment': $("#chart_increment").val(),
425 - 'startdate': start_date, 'enddate':end_date, 'userdefs': $.json_encode(wgClickTrackUserDefs), 'tabledata': 1 } , processTableJSON, "json");
426 -
427 - };//updateTable
428 -
429 - $.setUIControls = function(){
430 -
431 - //SET UP DATE RANGES
432 -
433 -
434 - //date-pickers for start and end dates
435 - $('.date_range_input').each(function(){
 403+
 404+ // post relevant info
 405+ $j.post( wgScriptPath + '/api.php',
 406+ { 'action': 'specialclicktracking', 'format': 'json',
 407+ 'eventid': 1, 'increment': $("#chart_increment").val(),
 408+ 'startdate': start_date, 'enddate': end_date, 'userdefs': $.json_encode( wgClickTrackUserDefs ), 'tabledata': 1 },
 409+ processTableJSON, 'json'
 410+ );
 411+
 412+ }; // updateTable
 413+
 414+ $.setUIControls = function() {
 415+ // SET UP DATE RANGES
 416+
 417+ // date-pickers for start and end dates
 418+ $('.date_range_input').each(function() {
436419 $(this).datepicker();
437 - $(this).datepicker('option', 'dateFormat', 'yymmdd');
 420+ $(this).datepicker( 'option', 'dateFormat', 'yymmdd' );
438421 });
439422 var startDate = new Date();
440 - $('#start_date').val("20091009"); //click_tracking start date as default
441 -
442 - var toggleDateInput = function(tableRow){
443 - var checked= false;
444 - tableRow.children().each(function(){
445 - if(checked == false){
446 - checked = $(this).children("input:checkbox").eq(0).is(":checked");}
 423+ $('#start_date').val("20091009"); // click_tracking start date as default
 424+
 425+ var toggleDateInput = function( tableRow ) {
 426+ var checked = false;
 427+ tableRow.children().each( function() {
 428+ if( checked == false ) {
 429+ checked = $(this).children("input:checkbox").eq(0).is(":checked");
 430+ }
447431 });
448 -
449 - if(checked){
450 - tableRow.removeClass("disabled_option");
451 - tableRow.children("td").each(function(){
452 - $(this).children(".date_range_input").removeClass("hidden");
 432+
 433+ if( checked ) {
 434+ tableRow.removeClass( 'disabled_option' );
 435+ tableRow.children("td").each(function() {
 436+ $(this).children(".date_range_input").removeClass( 'hidden' );
453437 });
454 - }
455 - else{
456 - tableRow.children("td").each(function(){
457 - $(this).children(".date_range_input").addClass("hidden");
 438+ } else {
 439+ tableRow.children("td").each(function() {
 440+ $(this).children(".date_range_input").addClass( 'hidden' );
458441 });
459 - tableRow.addClass("disabled_option");
 442+ tableRow.addClass( 'disabled_option' );
460443 }
461444 };
462 -
463 - $('.date_range_checkbox').click(function(){
464 - toggleDateInput($(this).closest("tr"));
 445+
 446+ $('.date_range_checkbox').click(function() {
 447+ toggleDateInput( $(this).closest( 'tr' ) );
465448 });
466 -
467 - //update table
 449+
 450+ // update table
468451 $('#update_table_button').click($.updateTable);
469 -
470 - //CHART DIALOG
 452+
 453+ // CHART DIALOG
471454 $("#chart_dialog").dialog({ autoOpen: false, width: 400 });
472 - $("#chart_img").css("cursor","pointer");
473 - $("#chart_img").click(function(){
 455+ $("#chart_img").css('cursor', 'pointer');
 456+ $("#chart_img").click(function() {
474457 $("#chart_dialog").dialog('open');
475458 });
 459+
 460+ $("#chart_increment").data( 'value', $("#chart_increment").val() );
476461
477 - $("#chart_increment").data("value", $("#chart_increment").val());
478 -
479 - $("#change_graph").click(function(){
 462+ $("#change_graph").click(function() {
480463 $("#chart_dialog").dialog('close');
481464
482 - //check if the value actually changed, if so, update and increment things accordingly
483 - if( $("#chart_increment").data("value") != $("#chart_increment").val() ){
484 - $("#chart_increment").data("value", $("#chart_increment").val());
 465+ // check if the value actually changed, if so, update and increment things accordingly
 466+ if( $("#chart_increment").data( 'value' ) != $("#chart_increment").val() ) {
 467+ $("#chart_increment").data( 'value', $("#chart_increment").val() );
485468 $.updateChart();
486469 }
487 -
 470+
488471 });
489 -
490 - //CHANGE USER INFO DIALOG
 472+
 473+ // CHANGE USER INFO DIALOG
491474 $("#user_def_dialog").dialog({ autoOpen: false, width: 400 });
492 - $("#user_def_alter_legend").data("defaultChangeText", $("#user_def_alter_legend").text());
493 -
494 -
495 - //CHANGE USER/INTERMEDIATE/EXPERT DIALOGS
496 - var loadHeaderInfo = function(headerName){
497 - $("#" + headerName + "_header").css("cursor", "pointer");
498 - $("#" + headerName + "_header").click(function(){
499 - $.renderUserDefDialogWith (wgClickTrackUserDefs[headerName], headerName);
 475+ $("#user_def_alter_legend").data( 'defaultChangeText', $("#user_def_alter_legend").text() );
 476+
 477+ // CHANGE USER/INTERMEDIATE/EXPERT DIALOGS
 478+ var loadHeaderInfo = function( headerName ) {
 479+ $("#" + headerName + "_header").css('cursor', 'pointer');
 480+ $("#" + headerName + "_header").click(function() {
 481+ $.renderUserDefDialogWith( wgClickTrackUserDefs[headerName], headerName );
500482 $("#user_def_dialog").dialog('open');
501483 });
502 - }; //headername
503 -
504 -
505 - loadHeaderInfo("basic");
506 - loadHeaderInfo("intermediate");
507 - loadHeaderInfo("expert");
508 -
 484+ }; // headername
 485+
 486+ loadHeaderInfo( 'basic' );
 487+ loadHeaderInfo( 'intermediate' );
 488+ loadHeaderInfo( 'expert' );
 489+
509490 };
510 -
511 -
512 - $.changeDataLinks = function (){
513 -
514 - $(".event_name").each(function(){
515 - $(this).css("cursor", "pointer");
516 -
517 - $(this).click(function(){
518 - $("#chart_img").data("eventid", $(this).attr( "value" ));
519 - $("#chart_img").data("event_name", $(this).text());
 491+
 492+ $.changeDataLinks = function() {
 493+ $(".event_name").each(function() {
 494+ $(this).css('cursor', 'pointer');
 495+
 496+ $(this).click(function() {
 497+ $("#chart_img").data( 'eventid', $(this).attr( 'value' ) );
 498+ $("#chart_img").data( 'event_name', $(this).text() );
520499 $.updateChart();
521 - });//click
522 - });//each
523 - };//addlink
524 -
 500+ }); // click
 501+ }); // each
 502+ }; // addlink
 503+
525504 return $(this);
526505 })(jQuery);
527506
528 -//colorize the table on document.ready
529 -js2AddOnloadHook($j.colorizeTable);
530 -js2AddOnloadHook($j.changeDataLinks);
531 -js2AddOnloadHook($j.setUIControls);
532 -
 507+// colorize the table on document.ready
 508+js2AddOnloadHook( $j.colorizeTable );
 509+js2AddOnloadHook( $j.changeDataLinks );
 510+js2AddOnloadHook( $j.setUIControls );
\ No newline at end of file

Status & tagging log