{{> header }}
{{> nav }}

<div class="main_color container_wrap_first container_wrap fullsize">
	<div class="container">
		<main role="main" itemprop="mainContentOfPage" class="template-page content av-content-full alpha units">
			<div class="post-entry post-entry-type-page post-entry-18">
				<div class="entry-content-wrapper clearfix">
					<div class="flex_column av_one_full flex_column_div av-zero-column-padding first avia-builder-el-0 el_before_av_one_fifth avia-builder-el-first"
						style="border-radius:0px;">
						<section class="av_textblock_section" itemscope="itemscope" itemtype="https://schema.org/CreativeWork">
							<div class="avia_textblock" itemprop="text">
								<h2>活动历史</h2>
							</div>
						</section>
						<div class="hr hr-short hr-left avia-builder-el-2 el_after_av_textblock el_before_av_textblock">
							<span class="hr-inner"><span class="hr-inner-style"></span></span>
						</div>
						<section class="av_textblock_section" itemscope="itemscope" itemtype="https://schema.org/CreativeWork">
							<div class="tabn">
                                <button class="tabnlinks" onclick="tabSwitch(event, 'lucky')">幸运2021</button>
                                <button class="tabnlinks" onclick="tabSwitch(event, 'lucky_a')">番外A</button>
                                <button class="tabnlinks" onclick="tabSwitch(event, 'lucky_b')">番外B</button>
                            </div>

                            <div id="lucky" class="tabncontent">
                                <table>
                                    <tr>
                                        <th>时间</th>
                                        <th>结果</th>
                                    </tr>
                                </table>
                            </div>

                            <div id="lucky_a" class="tabncontent">
                                <table>
                                    <tr>
                                        <th>时间</th>
                                        <th>结果</th>
                                    </tr>
                                </table>
                            </div>

                            <div id="lucky_b" class="tabncontent">
                                <table>
                                    <tr>
                                        <th>时间</th>
                                        <th>结果</th>
                                    </tr>
                                </table>
                            </div>
						</section>
					</div>
				</div>
			</div>
		</main><!-- close content main element -->
		<!-- section close by builder template -->
	</div>
	<!--end builder template-->
</div><!-- close default .container_wrap element -->

<script type="text/javascript">
    jQuery.ajax({
        url: 'https://twong.shotshock.shop/api/activities?callback=?',
        type: 'GET',
        jsonp: 'callback',
        dataType: 'jsonp',
        data: {

        },
        success: function(resp) {
            insertTableRow('lucky', resp);
            insertTableRow('lucky_a', resp);
            insertTableRow('lucky_b', resp);
        },
        error: function(jqXHR, textStatus, error) {
            console.log(error);
        }
   });

   function insertTableRow(divId, arr)
   {
       var div = document.getElementById(divId);
       var table = div.getElementsByTagName('table')[0];
       var i = 1;
       arr.forEach(function (item, index) {
           if (item.activity === divId) {
                table.insertRow(i);
                table.rows[i].insertCell(0).innerHTML = item.ts;
                table.rows[i].insertCell(1).innerHTML = item.result;
                i += 1;
           }
       });
   }

</script>

{{> footer }}
