
07.09.2009, 14:29
|
|
Новичок
Регистрация: 08.10.2007
Сообщений: 22
Провел на форуме: 251502
Репутация:
3
|
|
Нужна помощь в вопросе опять на тему КС..
Нужно получить из SteamID ссылку на профиль в стиме.
Формула расчета такая:
стимид вида:
STEAM_X:Y:Z
ссылка на профиль равна:
http://steamcommunity.com/profiles/ +
76561197960265728 + Y + Z*2
Нашёл вот такой скрипт:
Код HTML:
<script type="text/javascript">
function steamIDToProfile(steamID)
\{
var parts = steamID.split(":");
var iServer = Number(parts[1]);
var iAuthID = Number(parts[2]);
var converted = "76561197960265728"
lastIndex = converted.length - 1
var toAdd = iAuthID * 2 + iServer;
var toAddString = new String(toAdd)
var addLastIndex = toAddString.length - 1;
for(var i=0;i<=addLastIndex;i++)
\{
var num = Number(toAddString.charAt(addLastIndex - i));
var j=lastIndex - i;
do
\{
var num2 = Number(converted.charAt(j));
var sum = num + num2;
converted = converted.substr(0,j) + (sum % 10).toString() + converted.substr(j+1);
num = Math.floor(sum / 10);
j--;
}
while(num);
}
return converted;
}
function makeLink(profile)
\{
return "<a href='http://steamcommunity.com/profiles/" + profile + "'>" + profile + "</a>"
}
</script>
<input id="input" type="text" value="SteamID here" onclick="this.onclick='';this.value=''">
<input type="submit" value="Convert" onclick ="document.getElementById('result').innerHTML = makeLink(steamIDToProfile(document.getElementById('input').value))" >
<div id="result">
</div>
Помогите переделать (по возможности оптимизировать) скрипт, чтобы SteamID вводился внутри скрипта (не через input), а на выходе (при <div id="result"> </div>) получать ссылку вида:
Код:
<a href="http://steamcommunity.com/profiles/Тут_результат_расчетной_формулы(76561197960265728 + Y + Z*2)>SteamID_который_ввожу_в_скрипте</a>
Последний раз редактировалось Ser_UFL; 08.09.2009 в 18:01..
|
|
|