Показать сообщение отдельно
  #3 (permalink)  
Старый 23.11.2015, 11:59
Новичок на форуме
Отправить личное сообщение для hostoptus Посмотреть профиль Найти все сообщения от hostoptus
 
Регистрация: 22.11.2015
Сообщений: 4

Спасибо. Как загрузить, преобразовать в массив и считать разобрался.

function file_get_contents( url ) { // Reads entire file into a string
 // 
 // + original by: Legaev Andrey
 // % note 1: This function uses XmlHttpRequest and cannot retrieve resource from different domain.

 var req = null;
 try { req = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {
 try { req = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {
 try { req = new XMLHttpRequest(); } catch(e) {}
 }
 }
 if (req == null) throw new Error('XMLHttpRequest not supported');

 req.open("GET", url, false);
 req.send(null);

 return req.responseText;
}
var mydata = file_get_contents('http://api.worldoftanks.ru/wgn/clans/info/?application_id=demo&clan_id=195497');
mydata = JSON.parse (mydata);
document.write (mydata['data']['195497']['motto']);



А как замутить на js такую же таблицу:


<table class="tablesorter" cellspacing="1" style="width: 100%;">             
                <thead>
                    <tr>
                        <th style="color: #cc9900; font-family: Arial; font-size: 12px; font-weight: bold; text-align: center;">&#1048;&#1084;&#1103;</th>
			<th style="color: #cc9900; font-family: Arial; font-size: 12px; font-weight: bold; text-align: center;">Проведено боёв</th>
			<th style="color: #cc9900; font-family: Arial; font-size: 12px; font-weight: bold; text-align: center;">Личный рейтинг</th>
                        <th style="color: #cc9900; font-family: Arial; font-size: 12px; font-weight: bold; text-align: center;">&#1057;&#1086;&#1089;&#1090;&#1086;&#1080;&#1090; &#1074; &#1082;&#1083;&#1072;&#1085;&#1077;</th>
                        <th style="color: #cc9900; font-family: Arial; font-size: 12px; font-weight: bold; text-align: center;">&#1044;&#1085;&#1077;&#1081; &#1074; &#1082;&#1083;&#1072;&#1085;&#1077;</th>
                        <th style="color: #cc9900; font-family: Arial; font-size: 12px; font-weight: bold; text-align: center;">&#1047;&#1074;&#1072;&#1085;&#1080;&#1077;</th>
                    </tr> 
                </thead>
                <tbody>
                    <?php foreach($new['data'][$clan_id]['members'] as $val){
                        $new_time = date('Y.m.d',$val['joined_at']);
                        ?> 
                        <tr>
                            <td style="font-family: Arial; font-size: 12px; font-weight: bold; text-align: center;"><a style="color: #185100; text-decoration: none;" href="http://worldoftanks.ru/community/accounts/<?php echo $val['account_id'] ?>-<?php echo $val['account_name'] ?>"
                                target="_blank"><?php echo $val['account_name']; ?></a></td>
			    <td style="color: #565354; font-family: Arial; font-size: 12px; font-weight: bold; text-align: center;">
			    <?php $account_id = $val['account_id'];
			    $new3 = file_get_contents("http://api.worldoftanks.ru/wot/account/info/?application_id=54b29552a32dd5f3ade861259e38a368&language=ru&account_id=".$account_id);
			    $new3 = json_decode($new3,TRUE);
			    echo $new3['data'][$account_id]['statistics']['all']['battles']; ?>
			    </td>
			    <td style="color: #7F3606; font-family: Arial; font-size: 12px; font-weight: bold; text-align: center;"><?php echo $new3['data'][$account_id]['global_rating']; ?>
			    </td>
                            <td style="color: #000; font-family: Arial; font-size: 12px; font-weight: bold; text-align: center;"><?php echo $new_time; ?></td>
                            <td style="color: #5B4C00; font-family: Arial; font-size: 12px; font-weight: bold; text-align: center;"><?php echo round((strtotime(date("Y-m-d H:i:s")) - $val['joined_at'])/(3600*24)); ?></td>
                            <td style="color: #00137F; font-family: Arial; font-size: 12px; font-weight: bold; text-align: center;"><?php echo $val['role_i18n']; ?></td>
                        </tr>
                        <?php } ?>
                </tbody> 
            </table>
Ответить с цитированием