MediaWiki:Gadget-highlightTable-core.js: Difference between revisions

mNo edit summary
mNo edit summary
 
Line 1: Line 1:
/*
/** <pre>
  * highlightTable.js
  * highlightTable.js
  *
  *
Line 5: Line 5:
  * Adds highlighting to tables
  * Adds highlighting to tables
  *
  *
* History:
* - 1.0: Row highlighting                        - Quarenon
* - 1.1: Update from pengLocations.js v1.0      - Quarenon
* - 2.0: pengLocations v2.1, Granular cookie    - Saftzie
* - 2.1: Made compatible with jquery.tablesorter - Cqm
* - 2.2: Switch to localStorage                  - Cqm
* - 3.0: Allow cell highlighting                - mejrs
*
* @todo Allow the stored data to be coupled to the table in question. Currently the data is stored
*      on the page itself, so if any tables are shuffled, the highlighting doesn't follow. For
*      the same reason tables hosted on other pages are not synchronized.
  */
  */


Line 110: Line 99:
             * Perform initial checks on the page and browser.
             * Perform initial checks on the page and browser.
             */
             */
             init: function() {
             init: function(sorted) {
                 var $tables = $('table.' + TABLE_CLASS),
                 var $tables = $('table.' + TABLE_CLASS),
                     hashedPageName = self.hashString(mw.config.get('wgPageName'));
                     hashedPageName = self.hashString(mw.config.get('wgPageName'));
Line 121: Line 110:
                 if (!gs.hasLocalStorage()) {
                 if (!gs.hasLocalStorage()) {
                     return;
                     return;
                }
                // check if any of the tables are autosort tables
                // and, if so, ensure the autosort gadget runs first
                if (!sorted && $tables.filter('[class*="autosort="]').length) {
                mw.hook('gadget.autosort.sorted').add(function delayInit() {
                self.init(true);
               
                // only run once
                mw.hook('gadget.autosort.sorted').remove(delayInit);
                });
               
                return;
                 }
                 }


Line 437: Line 438:


                 // guarantee 8-bit chars
                 // guarantee 8-bit chars
                 input = window.eministation(window.encodeURI(input));
                 input = window.unescape(window.encodeURI(input));


                 // calculate the crc (cyclic redundancy check) for all 8-bit data
                 // calculate the crc (cyclic redundancy check) for all 8-bit data