~muffinresearch/ubuntu-start-page/add-rtl-script

« back to all changes in this revision

Viewing changes to www/12.10/Baidu/index.html.id

  • Committer: Stuart Colville
  • Date: 2012-10-03 22:39:17 UTC
  • Revision ID: stuart.colville@canonical.com-20121003223917-3jvqvcrskveo9tyg
re-generate

Show diffs side-by-side

added added

removed removed

Lines of Context:
171
171
    </div><!-- close search-box -->
172
172
<script type="text/javascript">
173
173
//<![CDATA[
174
 
(function focus_search() {
 
174
(function(){
 
175
    "use strict";
 
176
    var ltrChars = 'A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02B8\u0300-\u0590\u0800-\u1FFF\u2C00-\uFB1C\uFDFE-\uFE6F\uFEFD-\uFFFF',
 
177
        rtlChars = '\u0591-\u07FF\uFB1D-\uFDFD\uFE70-\uFEFC',
 
178
        ltrRx = new RegExp('^[^'+rtlChars+']*['+ltrChars+']'),
 
179
        rtlRx = new RegExp('^[^'+ltrChars+']*['+rtlChars+']'),
 
180
        formElm = document.getElementById("kw"),
 
181
        checkDir = function(formElm){
 
182
            var val = formElm.value;
 
183
            if (ltrRx.test(val)) {
 
184
                formElm.dir = "ltr";
 
185
            } else if (rtlRx.test(val)) {
 
186
                formElm.dir = "rtl";
 
187
            } else {
 
188
                formElm.dir = "";
 
189
            }
 
190
        };
 
191
    formElm.onkeyup = function(){
 
192
        checkDir(this);
 
193
    };
 
194
    formElm.onkeydown = function(){
 
195
        checkDir(this);
 
196
    };
 
197
    formElm.onclick = function(){
 
198
        checkDir(this);
 
199
    };
175
200
    function search_select(e) {
176
201
        if(e.value.length > 0) {
177
202
            e.select();
178
203
        }
179
204
        e.select();
180
205
    }
181
 
    sbi = document.getElementById('kw');
182
 
    sbi.focus();
183
 
    search_select(sbi);
184
 
})();
 
206
    formElm.focus();
 
207
    search_select(formElm);
 
208
    checkDir(formElm);
 
209
}());
185
210
//]]>
186
211
</script>
187
212
</body>