Commits

Anonymous committed b3a1a8e Merge

merge

Comments (0)

Files changed (10)

File contents unchanged.

smtuning/content/about.xul

File contents unchanged.

smtuning/content/options.xul

       <preference id="pref_extra_mark_read" name="extensions.smtuning.extra_mark_read" type="bool"/>
       <preference id="pref_hide_non_english" name="extensions.smtuning.hide_non_english" type="bool"/>
       <preference id="pref_no_avatars" name="extensions.smtuning.no_avatars" type="bool"/>
-      <preference id="pref_sort_games_drop" name="extensions.smtuning.sort_games_drop" type="bool"/>
       <preference id="pref_signal_games_clock" name="extensions.smtuning.signal_games_clock" type="bool"/>
       <preference id="pref_patch_window_title" name="extensions.smtuning.patch_window_title" type="bool"/>
       <preference id="pref_patch_window_background" name="extensions.smtuning.patch_window_background" type="bool"/>
     <groupbox>
       <caption label="&section.game_list;"/>
 
-      <checkbox id="pref_sort_games_drop" preference="pref_sort_games_drop" label="&pref_sort_games_drop.label;" accesskey="S"/>
-      <label class="comment">&pref_sort_games_drop.comment;</label>
-
       <checkbox id="pref_signal_games_clock" preference="pref_signal_games_clock" label="&pref_signal_games_clock.label;" accesskey="C"/>
       <label class="comment">&pref_signal_games_clock.comment;</label>
 

smtuning/content/overlay.js

         title.parentNode.insertBefore(toolbar, title);
     },
 
-    addSortDropDown : function(doc, view) {
-        var title = smtdoc.xpathFirst(doc, "//h1");
-        if (! title) return;
-        var dropdown = doc.createElement("select");
-        dropdown.setAttribute("id", "SmGameSortSelect");
-        dropdown.setAttribute("onChange", "smtdoc.resortGames(this.options[selectedIndex].value)");
-        //dropdown.setAttribute("style", "float: right");
-        title.parentNode.insertBefore(dropdown, title);
-        dropdown.options[dropdown.options.length] = new Option("-- Change ordering --", "0");
-        dropdown.options[dropdown.options.length] = new Option("Default", "9");
-        dropdown.options[dropdown.options.length] = new Option("By variant", "1");
-        dropdown.options[dropdown.options.length] = new Option("By variant (rev)", "2");
-        dropdown.options[dropdown.options.length] = new Option("By start date (up)", "5");
-        dropdown.options[dropdown.options.length] = new Option("By start date (down)", "6");
-        dropdown.options[dropdown.options.length] = new Option("By opponent name", "11");
-        dropdown.options[dropdown.options.length] = new Option("By opponent clock", "13");
-    },
+    // Zdezaktualizowane, austin zrobił swój dropdown. Kod
+    // zostawiam jkao przykład robienia dropdowna
+    //
+    // addSortDropDown : function(doc, view) {
+    //     var title = smtdoc.xpathFirst(doc, "//h1");
+    //     if (! title) return;
+    //     var dropdown = doc.createElement("select");
+    //     dropdown.setAttribute("id", "SmGameSortSelect");
+    //     dropdown.setAttribute("onChange", "smtdoc.resortGames(this.options[selectedIndex].value)");
+    //     title.parentNode.insertBefore(dropdown, title);
+    //     dropdown.options[dropdown.options.length] = new Option("-- Change ordering --", "0");
+    //     dropdown.options[dropdown.options.length] = new Option("Default", "9");
+    //     dropdown.options[dropdown.options.length] = new Option("By variant", "1");
+    //     dropdown.options[dropdown.options.length] = new Option("By variant (rev)", "2");
+    //     dropdown.options[dropdown.options.length] = new Option("By start date (up)", "5");
+    //     dropdown.options[dropdown.options.length] = new Option("By start date (down)", "6");
+    //     dropdown.options[dropdown.options.length] = new Option("By opponent name", "11");
+    //     dropdown.options[dropdown.options.length] = new Option("By opponent clock", "13");
+    // },
 
     addDarkPreviewDropDown : function(doc, view) {
         var title = smtdoc.xpathFirst(doc, "//h1");
     // Funkcja pomocnicza. W podanym bloku wyszukuje wszystkie ikony
     // zegarka i podmienia na zadane. block należy podać tylko gdy nie jest null
     replaceClockIcons : function(doc, block, clockType) {
-        var pfx = "";
         if( block ) {
-            pfx = "td";
+            // pass
         } else {
             block = doc;
         }
+
+        // Obsługujemy dwa warianty. Stary - gdzie są po prosu
+        // obrazki src clock.gif i clocka.gif - oraz nowy - gdzie
+        // mamy spany klasy clock i clock_running.
+        // 
+        smtext.dump("Trying to replace clock to " + clockType + " in " + block.innerHTML);
+
         var nodes = smtdoc.xpathRelative(
             doc, block,
-            pfx + "//img[contains(@src,'/clock.gif')]");
+            ".//img[contains(@src,'/clock.gif')]");
+        for (var i = 0; i < nodes.snapshotLength; i++) {
+            smtext.dump("Old style clock.gif");
+            var thisImg = nodes.snapshotItem(i);
+            thisImg.setAttribute("src","chrome://smtuning/skin/clock/clock_" + clockType + ".gif");
+        }
+
+        var nodes = smtdoc.xpathRelative(
+            doc, block,
+            ".//img[contains(@src,'/clocka.gif')]");
+        for (var i = 0; i < nodes.snapshotLength; i++) {
+            smtext.dump("Old style clocka.gif");
+            var thisImg = nodes.snapshotItem(i);
+            thisImg.setAttribute("src","chrome://smtuning/skin/clock/clocka_" + clockType + ".gif");
+        }
+
+        var nodes = smtdoc.xpathRelative(
+            doc, block,
+            ".//span[contains(@class,'clock')]");
         for (var i = 0; i < nodes.snapshotLength; i++) {
             var thisImg = nodes.snapshotItem(i);
-            //smtext.dump("Patching " + thisImg.getAttribute("src") + " to " + clockType);
-            thisImg.setAttribute("src","chrome://smtuning/skin/clock/clock_" + clockType + ".gif");
-        }
-        var nodes = smtdoc.xpathRelative(
-            doc, block,
-            pfx + "//img[contains(@src,'/clocka.gif')]");
-        for (var i = 0; i < nodes.snapshotLength; i++) {
-            var thisImg = nodes.snapshotItem(i);
-            //smtext.dump("Patching " + thisImg.getAttribute("src") + " to " + clockType);
-            thisImg.setAttribute("src","chrome://smtuning/skin/clock/clocka_" + clockType + ".gif");
+            var thisClass = thisImg.getAttribute("class");
+            smtext.dump("new style elem of class " + thisClass);
+            thisClass = thisClass.replace(/\b(clock_running|clock)\b/, "$1_" + clockType);
+            thisImg.setAttribute("class", thisClass);
+            smtext.dump("class set to " + thisClass);
         }
     },
 
         var rows = smtdoc.xpath(
             doc,
             "//div[contains(@class,'itemgame')]");
-        alert(rows.snapshotLength);
-        // smtext.dump("Games found: " + rows.snapshotLength);
+        smtext.dump("Games found: " + rows.snapshotLength);
         for (var i = 0; i < rows.snapshotLength; i++) {
             var row = rows.snapshotItem(i);
             var linkHref = smtdoc.xpathFirstRelative(
-                doc, row, "//a[contains(@href,'game.aspx')]");
+                doc, row, ".//a[contains(@href,'game.aspx')]");
             if(linkHref) {
                 var link = linkHref.getAttribute("href");
-                if (link.match(/game_id=([0-9]+)/)) {
+                smtext.dump("Found link " + link);
+                if (link.match(/game_id=([0-9][0-9]*)/)) {
                     var gameId = RegExp.$1;
+                    smtext.dump("Matched game id: " + gameId);
                     if (colorizeClock) {
                         var clockType = smtdoc.readSavedGameClockInfo(gameId);
+                        smtext.dump("Clock type: " + clockType);
                         if (clockType) {
                             //smtext.dump("row " + i + " clock " + clockType);
                             smtuning.replaceClockIcons(doc, row, clockType);
                         }
                     }
+                } else {
+                    smtext.dump("Can not find game id in link " + link);
                 }
+            } else {
+                smtext.dump("linkHref not found in row " + int2string(i));
             }
         }
     },
             // Current Games
             if (href.match(/schemingmind\.com\/currentgames.aspx/i)
                 || href.match(/testpages\/currentgames\.html/) ) {
-                var drop = smtext.prefman.getValue("sort_games_drop");
-                if (drop) {
-                    smtuning.addSortDropDown(doc, view);
-                }
                 if (signalClock) {
                     smtuning.patchGameList(doc, view, signalClock);
                 }

smtuning/content/smt_docutil.js

         return document.evaluate(query, document, null,
                                  XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
     },
-    // Szukanie w bloku under a nie całym dokumencie
+    // Szukanie w bloku under a nie całym dokumencie. Uwaga, by
+    // to działało z sensem trzeba dawać query zaczynające się
+    // od           .//
     xpathRelative : function(document, under, query) {
         return document.evaluate(query, under, null,
                                  XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
         }
 
         var cmtBox = document.getElementById("ContentPlaceHolder1_txtComment");
-        var privRadio = smtdoc.xpathFirst(document, "//input[@type='radio' and @value='private_comment']");
+        var privRadio = smtdoc.xpathFirst(document, "//input[@type='radio' and @value='notetoself']");
         if (privRadio) {
             privRadio.checked = 1;
             privRadio.click();
         //var clockPref = 'data.clock.' + gameId;
         //smtext.prefman.setValue(clockPref, clockType);
         //console.log("Saving clock for " + gameId + ": " + clockType);
-        localStorage.setItem("smtuning.clock." + gameId, clockType);
+    
+        //storage = localStorage;
+        var storage = globalStorage["schemingmind.com"];
+
+        storage.setItem("smtuning.clock." + gameId, clockType);
     },
 
     // Odczytuje zegar albo null
         //var clockPref = 'data.clock.' + gameId;
         //var clockType = smtext.prefman.getValue(clockPref, null);
         //dump("Loading");
-        var clockType = localStorage.getItem("smtuning.clock." + gameId, null);
+        // storage = localStorage;
+        var storage = globalStorage["schemingmind.com"];
+
+        var clockType = storage.getItem("smtuning.clock." + gameId, null);
         return clockType;
     }
 

smtuning/defaults/preferences/defaults.js

 pref("extensions.smtuning.extra_mark_read", true);
 pref("extensions.smtuning.hide_non_english", false);
 pref("extensions.smtuning.no_avatars", false);
-pref("extensions.smtuning.sort_games_drop", true);
 pref("extensions.smtuning.signal_games_clock", true);
 pref("extensions.smtuning.save_analysis", true);
 pref("extensions.smtuning.flip_analysis", true);

smtuning/install.rdf

File contents unchanged.

smtuning/locale/en-US/options.dtd

File contents unchanged.

smtuning/skin/smtuning_document.css

 .highlighted_check_black {
   border: 2px ridge black;  
   background-color: #777;
+}
+
+/*
+.clock {
+  background-image:url(images/clock.gif);
+  padding-left:16px;
+}
+.clock_running {
+  background-image:url(images/clocka.gif);
+}
+*/
+.clock_blitz {
+  background-image:url(chrome://smtuning/skin/clock/clock_blitz.gif);
+  padding-left:16px;
+}
+.clock_running_blitz {
+  background-image:url(chrome://smtuning/skin/clock/clocka_blitz.gif);
+  padding-left:16px;
+}
+.clock_standard {
+  background-image:url(chrome://smtuning/skin/clock/clock_standard.gif);
+  padding-left:16px;
+}
+.clock_running_standard {
+  background-image:url(chrome://smtuning/skin/clock/clocka_standard.gif);
+  padding-left:16px;
+}
+.clock_fast {
+  background-image:url(chrome://smtuning/skin/clock/clock_fast.gif);
+  padding-left:16px;
+}
+.clock_running_fast {
+  background-image:url(chrome://smtuning/skin/clock/clocka_fast.gif);
+  padding-left:16px;
+}
+.clock_leisure {
+  background-image:url(chrome://smtuning/skin/clock/clock_leisure.gif);
+  padding-left:16px;
+}
+.clock_running_leisure {
+  background-image:url(chrome://smtuning/skin/clock/clocka_leisure.gif);
+  padding-left:16px;
 }

smtuning/update.rdf

File contents unchanged.