Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

cpan.js: un-break Shift+Enter -> IFL feature

I broke the Shift+Enter IFL feature while solving a bug in
140605c.

Now we can:

 * Shift+Enter to do IFL
 * Click the IFL button

*Without* implicitly adding a "1" to search queries and thus throwing
them off.

I've only tested this in Chrome but it's using some pretty basic W3C
core API to append the element, so it probably shouldn't break
anywhere.
  • Loading branch information...
commit bcfec8c9d2cb6e9d9c874f0d9b325689453327d7 1 parent 140605c
@avar avar authored
Showing with 11 additions and 2 deletions.
  1. +11 −2 root/static/js/cpan.js
View
13 root/static/js/cpan.js
@@ -88,7 +88,16 @@ $(document).ready(function() {
$('#search-input').keydown(function(event) {
if (event.keyCode == '13' && event.shiftKey) {
event.preventDefault();
- document.forms[0].q.name = 'lucky';
+
+ /* To make this a lucky search we have to create a new
+ * <input> element to pass along lucky=1.
+ */
+ var luckyField = document.createElement("input");
+ luckyField.type = 'hidden';
+ luckyField.name = 'lucky';
+ luckyField.value = '1';
+ document.forms[0].appendChild(luckyField);
+
document.forms[0].submit();
}
});
@@ -222,4 +231,4 @@ function favDistribution(form) {
}
});
return false;
-}
+}
Please sign in to comment.
Something went wrong with that request. Please try again.