2013-12-31 12:33:45 +00:00
|
|
|
(function (w, d) {
|
|
|
|
'use strict';
|
|
|
|
function addListener(el, type, fn) {
|
|
|
|
if (el.addEventListener) {
|
|
|
|
el.addEventListener(type, fn, false);
|
|
|
|
} else {
|
|
|
|
el.attachEvent('on' + type, fn);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function placeCursorAtEnd() {
|
|
|
|
if (this.setSelectionRange) {
|
|
|
|
var len = this.value.length * 2;
|
|
|
|
this.setSelectionRange(len, len);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
addListener(w, 'load', function () {
|
|
|
|
var qinput = d.getElementById('q');
|
2014-01-02 22:02:38 +00:00
|
|
|
if (qinput !== null && qinput.value === "") {
|
2013-12-31 12:33:45 +00:00
|
|
|
addListener(qinput, 'focus', placeCursorAtEnd);
|
|
|
|
qinput.focus();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
})(window, document);
|
|
|
|
|