Pull to refresh

Comments 15

По столбцу s захватывает часть стобца r
Точно. Есть мнение, что картинка не дискретная (с) pepelsbey
Поэтому, я поставил быстренький костыль «pos_1 = pos_1 * 1.0645;»
И еще, уж как-то очень много кода вы написали :)
samples.ozoned.biz/code/

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
  <head>
    <title>Country Codes</title>
    <script type="text/javascript">
      function getCountryXY(code) {
        char1 = code.substring(0,1);
        char2 = code.substring(1,2);
        char1 = char1.toUpperCase();
        char2 = char2.toUpperCase();
        code1 = char1.charCodeAt(0);
        code2 = char2.charCodeAt(0);
        bgX = -16 * (code1 - 64) + 'px';
        bgY = -11 * (code2 - 64) + 'px';
        document.getElementById('cur').style.backgroundPosition = bgX + ' ' + bgY;
      }
    </script>
    <style type="text/css">
      #cur {
        width: 16px;
        height: 11px;
        background: url(flags.png);
      }
    </style>
  </head>
  <body>
    <img src="flags.png" alt="all"/><br/>
    <input type="text" size="2" maxlength="2" name="code" id="code" />
    <input type="button" onclick="getCountryXY(document.getElementById('code').value);" value="Get"/>
    <div id="cur"> </div>
  </body>
</html>


* This source code was highlighted with Source Code Highlighter.
тогда уж
code = code.toUpperCase();
code1 = code.charCodeAt(0);
code2 = code.charCodeAt(1);


:)
Кто короче? :)

Можно и так (но зачем? – специально разделил по операциям до этого):

function getCountryXY(code) {
document.getElementById('cur').style.backgroundPosition =
(-16 * (code.toUpperCase().charCodeAt(0) - 64)) + 'px ' +
(-11 * (code.toUpperCase().charCodeAt(1) - 64)) + 'px';
}
я именно фрагмент разделения и написал. вместо шести трочек три.
Залинковать? Что ты под этим подразумеваешь?
Ну рановато еще показывать-то :)
стоит код
var word_array = new Array(26);
word_array[0] = '_';
word_array[1] = 'a';

word_array[25] = 'y';
word_array[26] = 'z';

преобразовать к виду
var word_array = ['_', 'a', ..., 'y', 'z'];


UFO just landed and posted this here
точно, просто в глаза сразу бросилась «пулеметная лента», вот и отписал, а варианты не заметил :)
Если приходится часто использовать карты будет проще добиратся к коду страны через класс:
<div class="ru" id="map"></div>


Ну и позиционирование:
function posmap() {
  document.getElementById("map").style.backgroundPosition = ((document.getElementById("map").className.toUpperCase().charCodeAt(0)-64) * -16 + 'px ') + ((document.getElementById("map").className.toUpperCase().charCodeAt(1)-64) * -11 + 'px');
}
Подразумевается, что в стилях уже указано вышеуказанное изображение с картой флагов:
div#map {
width: 16px;height: 11px;
background: url("skypeflags.png") no-repeat;
}
Sign up to leave a comment.

Articles