// 전역 변수
//var URL_NATIVE_BUILD = "https://gpbuild.gonggames.com/builds/bis/bis_builds_qa.json"; // 초기값 : bis
var URL_NATIVE_BUILD = "https://gpbuild.gonggames.com/builds/gapps/gapps_builds_qa.json";
var URL_UNITY_BUILD = "https://gpbuild.gonggames.com/builds/sdksamples/unity_builds.json";
var URL_VERSION_QA = "https://gpbuild.gonggames.com/builds/sdksamples/version_builds.json";
var pageIndex = 0;
var maxLines = 40;
var maxSize;
var showCount = 0;
var oldBuildTypeValue;
var bottomDiv, buttonFirst, buttonPrev, buttonNext, buttonLast;
var textCurrenctIndex, textMaxIndex;
var newArrayJson;
$(function(){
// 앱 리스트 마우스 오버 효과
$(".appLstCon ul li").each(function(){
$(this).hover(function(){
$(this).css("color","#7fbe25");
},function(){
$(this).css("color","#fff");
})
})
// 확인 버튼 마우스 오버 효과
$(".btn_refresh").hover(function(){
$(this).css("background","#262f7a");
},function(){
$(this).css("background","#20212a");
});
// 페이지 넘버링 마우스 오버 효과
$(".pageNum .pageBtn").each(function(){
$(this).hover(function(){
$(this).siblings(".pageBtn").css("opacity","0.3");
},function(){
$(this).siblings(".pageBtn").css("opacity","1");
})
});
tblType();
});
// 탭 클릭 스크립트
function tabLink(type){
if(type == "bis"){
// 테이블 로딩 정보 변경
URL_NATIVE_BUILD = "https://gpbuild.gonggames.com/builds/bis/bis_builds_qa.json";
// 타이틀명 변경
$(".title").find("span").text('GBIS');
}else if(type == "sdk"){
// 테이블 로딩 정보 변경
URL_NATIVE_BUILD = "https://gpbuild.gonggames.com/builds/sdksamples/native_builds.json";
// 타이틀명 변경
$(".title").find("span").text('Field SDK');
}else if(type == "uts"){
// 테이블 로딩 정보 변경
URL_NATIVE_BUILD = "https://gpbuild.gonggames.com/builds/uts/uts_kbo2_builds.json";
// 타이틀명 변경
$(".title").find("span").text('Field UTS');
}else if(type == "kbo2"){
// 테이블 로딩 정보 변경
URL_NATIVE_BUILD = "https://gpbuild.gonggames.com/builds/games/kbo_builds.json";
// 타이틀명 변경
$(".title").find("span").text('이사만루2');
}
else if(type == "kbo3"){
// alert("준비중입니다");
// 테이블 로딩 정보 변경
URL_NATIVE_BUILD = "https://gpbuild.gonggames.com/builds/kbo3/kbo_builds.json";
// 타이틀명 변경
$(".title").find("span").text('이사만루3');
}
else if(type == "gapps"){
// alert("준비중입니다");
// 테이블 로딩 정보 변경
URL_NATIVE_BUILD = "https://gpbuild.gonggames.com/builds/gapps/gapps_builds_qa.json";
// 타이틀명 변경
$(".title").find("span").text('GAPPS');
}
else if(type == "projectM"){
// alert("준비중입니다");
// 테이블 로딩 정보 변경
URL_NATIVE_BUILD = "https://gpbuild.gonggames.com/builds/projectm/builds.json";
// 타이틀명 변경
$(".title").find("span").text('Project M');
}
/*if(type == "kbo3"){
$(".title").css("display","none");
$(".buildType").css("display","none");
$("#table").css("display","none");
$("#btmArea").css("display","none");
$(".kbo3Txt").css("display","block");
}else{
$(".title").css("display","block");
$(".buildType").css("display","inline-block");
$("#table").css("display","block");
$("#btmArea").css("display","block");
$(".kbo3Txt").css("display","none");
}*/
// 각 페이지에 해당하는 select box 노출
$("." + type + "Select").siblings("#buildType").css("display","none");
$("." + type + "Select").css("display","block");
pageIndex = 0;
tblType();
}
// 모바일 os 체크
function getMobileOS(){
var userAgent = navigator.userAgent || navigator.vendor || window.opera;
if( userAgent.match( /iPad/i ) || userAgent.match( /iPhone/i ) || userAgent.match( /iPod/i) || (userAgent.toLowerCase().indexOf('macintosh') > -1 && navigator.maxTouchPoints && navigator.maxTouchPoints > 2)){
return 'iOS';
}else if( userAgent.match( /Android/i ) ){
return 'Android';
}
else{
return 'unknown';
}
}
// 페이지 이동
function setPage(page){
var currentURL = URL_NATIVE_BUILD;
var maxPage = parseInt(maxSize / maxLines) + 1;
if(page == "0") pageIndex = 0;
else if(page == "1") pageIndex--;
else if(page == "2") pageIndex++;
else if(page == "3") pageIndex = maxPage-2;
if(pageIndex < 0) pageIndex = 0;
else if(pageIndex > maxPage-2){
pageIndex = maxPage-2;
return;
}
requestJSONData2(currentURL, maxLines);
// $("html,body").animate({scrollTop: $(document).height()}, 0)
}
function requestJSONData2(url){
var xmlhttp = new XMLHttpRequest();
currentURL = url;
xmlhttp.onreadystatechange=function(){
if(xmlhttp.readyState == 4 && xmlhttp.status == 200){
pageIndex = 0;
makeTables(xmlhttp.responseText);
}
}
xmlhttp.open("GET", url, true);
xmlhttp.setRequestHeader('Cache-Control', 'no-cache');
xmlhttp.send();
}
function requestJSONData2(url, lines){
$(document).ready(function(){
$.ajax({
type: "get",
data: "",
dataType: "text",
url: url,
cache : false,
success: function(text){
makeTables(text);
},
error: function (msg) {
// alert(msg);
}
});
});
}
// 페이지 이동 버튼
function initControls(){
if(bottomDiv == null){
bottomDiv = document.createElement("ul");
bottomDiv.setAttribute("class","pageNum clear");
}
if(buttonFirst == null){
buttonFirst = document.createElement("li");
buttonFirst.setAttribute("onclick","setPage(0)");
buttonFirst.setAttribute("class","btn_first pageBtn");
buttonImg = document.createElement("img");
buttonImg.setAttribute("src","images/btn_pageFirst.jpg");
buttonImg.setAttribute("alt","맨 앞으로");
buttonFirst.appendChild(buttonImg);
bottomDiv.appendChild(buttonFirst);
}
if(buttonPrev == null){
buttonPrev = document.createElement("li");
buttonPrev.setAttribute("onclick","setPage(1)");
buttonPrev.setAttribute("class","btn_prev pageBtn");
buttonImg = document.createElement("img");
buttonImg.setAttribute("src","images/btn_pagePrev.jpg");
buttonImg.setAttribute("alt","이전 페이지");
buttonPrev.appendChild(buttonImg);
bottomDiv.appendChild(buttonPrev);
}
updatePageIndex();
if(buttonNext == null){
buttonNext = document.createElement("li");
buttonNext.setAttribute("onclick","setPage(2)");
buttonNext.setAttribute("class","btn_next pageBtn");
buttonImg = document.createElement("img");
buttonImg.setAttribute("src","images/btn_pageNext.jpg");
buttonImg.setAttribute("alt","다음 페이지");
buttonNext.appendChild(buttonImg);
bottomDiv.appendChild(buttonNext);
}
if(buttonLast == null){
buttonLast = document.createElement("li");
buttonLast.setAttribute("onclick","setPage(3)");
buttonLast.setAttribute("class","btn_last pageBtn");
buttonImg = document.createElement("img");
buttonImg.setAttribute("src","images/btn_pageLast.jpg");
buttonImg.setAttribute("alt","맨 뒤로");
buttonLast.appendChild(buttonImg);
bottomDiv.appendChild(buttonLast);
div = document.getElementById("btmArea");
div.appendChild(bottomDiv);
}
}
// 페이지 표시
function updatePageIndex(){
var i = 0;
var platformCount = 0;
var osType = getMobileOS();
for(i = 0; i < maxSize; i++){
if(osType == "iOS"){
if(arrayJson[i].Platform == 'iOS'){
continue;
}
}else if(osType == "Android"){
if(arrayJson[i].Platform == 'Android'){
continue;
}
}
platformCount++;
}
var maxPage = parseInt(platformCount / maxLines + 1);
var current = pageIndex+1;
// 현재 페이지
if(textCurrenctIndex == null){
textCurrenctIndex = document.createElement("li");
textCurrenctIndex.setAttribute("class","now");
idxTxt = document.createTextNode(current);
textCurrenctIndex.appendChild(idxTxt);
bottomDiv.appendChild(textCurrenctIndex);
}else{
idxTxt.nodeValue = current;
textCurrenctIndex.appendChild(idxTxt);
}
// 전체 페이지
if(textMaxIndex == null){
textMaxIndex = document.createElement("li");
textMaxIndex.setAttribute("class","total");
maxTxt = document.createTextNode(maxPage);
textMaxIndex.appendChild(maxTxt);
bottomDiv.appendChild(textMaxIndex);
}else{
maxTxt.nodeValue = maxPage;
textMaxIndex.appendChild(maxTxt);
}
}
// 테이블 생성
function makeTables(response){
arrayJson = JSON.parse(response);
var i;
var out = "
";
maxSize = arrayJson.length;
var osType = getMobileOS();
out += "Bundle Version | Version | Dates | Build Type | Description | Link |
";
count = 0;
newArrayJson = [];
for(i = 0; i < arrayJson.length; i++){
if(osType == "iOS"){
if(arrayJson[i].Platform != "iOS"){
continue;
}
}else if(osType == "Android"){
if(arrayJson[i].Platform != 'Android'){
continue;
}
}
newArrayJson[count++] = arrayJson[i];
}
var startIndex = pageIndex * maxLines;
var endIndex = startIndex + maxLines;
if(endIndex >= newArrayJson.length) endIndex = newArrayJson.length;
for(i = startIndex; i < endIndex; i++){
if(osType == "iOS"){
if(newArrayJson[i].Platform != "iOS") {
continue;
}
}else if(osType == "Android"){
if(newArrayJson[i].Platform != 'Android'){
continue;
}
}
var buildType = "Gradle";
if(newArrayJson[i].BuildType)
buildType = newArrayJson[i].BuildType;
if(osType == "Android"){
out += "" +
newArrayJson[i].Bundle +
" | " +
newArrayJson[i].Version +
" | " +
newArrayJson[i].Dates +
" | " +
buildType +
" | " +
newArrayJson[i].Description +
" | Download"
" |
";
}else{
out += "" +
newArrayJson[i].Bundle +
" | " +
newArrayJson[i].Version +
" | " +
newArrayJson[i].Dates +
" | " +
buildType +
" | " +
newArrayJson[i].Description +
" | Download"
" |
";
}
}
out += "
";
document.getElementById("table").innerHTML = out;
initControls();
}
// 빌드 타입 선택 스크립트
function selectBuildType(selectObj){
var currentURL = URL_NATIVE_BUILD;
var osType = getMobileOS();
var select = document.getElementById("buildType");
if(selectObj.value == "0") {
currentURL = URL_NATIVE_BUILD;
requestJSONData2(URL_NATIVE_BUILD, maxLines);
}else if(selectObj.value == "1"){
currentURL = URL_UNITY_BUILD;
requestJSONData2(URL_UNITY_BUILD, maxLines);
}else if(selectObj.value == "2"){
currentURL = URL_VERSION_QA;
requestJSONData2(URL_VERSION_QA, maxLines);
}
pageIndex = 0;
oldBuildTypeValue = selectObj.value;
};
// 타입별 테이블 생성 스크립트
function tblType(){
var currentURL = URL_NATIVE_BUILD;
requestJSONData(currentURL, maxLines);
function requestJSONData(url){
var xmlhttp = new XMLHttpRequest();
currentURL = url;
xmlhttp.onreadystatechange=function(){
if(xmlhttp.readyState == 4 && xmlhttp.status == 200){
pageIndex = 0;
makeTables(xmlhttp.responseText);
}
}
xmlhttp.open("GET", url, true);
xmlhttp.setRequestHeader('Cache-Control', 'no-cache');
xmlhttp.send();
}
function requestJSONData(url, lines){
$(document).ready(function(){
$.ajax({
type: "get",
data: "",
dataType: "text",
url: url,
cache : false,
success: function(text){
makeTables(text);
},
error: function (msg) {
// alert(msg);
}
});
});
}
// 테이블 생성
function makeTables(response){
arrayJson = JSON.parse(response);
var i;
var out = "";
maxSize = arrayJson.length;
var osType = getMobileOS();
out += "Bundle Version | Version | Dates | Build Type | Description | Link |
";
count = 0;
newArrayJson = [];
for(i = 0; i < arrayJson.length; i++){
if(osType == "iOS"){
if(arrayJson[i].Platform != "iOS"){
continue;
}
}else if(osType == "Android"){
if(arrayJson[i].Platform != 'Android'){
continue;
}
}
newArrayJson[count++] = arrayJson[i];
}
var startIndex = pageIndex * maxLines;
var endIndex = startIndex + maxLines;
if(endIndex >= newArrayJson.length) endIndex = newArrayJson.length;
for(i = startIndex; i < endIndex; i++){
if(osType == "iOS"){
if(newArrayJson[i].Platform != "iOS") {
continue;
}
}else if(osType == "Android"){
if(newArrayJson[i].Platform != 'Android'){
continue;
}
}
var buildType = "Gradle";
if(newArrayJson[i].BuildType)
buildType = newArrayJson[i].BuildType;
if(osType == "Android"){
out += "" +
newArrayJson[i].Bundle +
" | " +
newArrayJson[i].Version +
" | " +
newArrayJson[i].Dates +
" | " +
buildType +
" | " +
newArrayJson[i].Description +
" | Download"
" |
";
}else{
out += "" +
newArrayJson[i].Bundle +
" | " +
newArrayJson[i].Version +
" | " +
newArrayJson[i].Dates +
" | " +
buildType +
" | " +
newArrayJson[i].Description +
" | Download"
" |
";
}
}
out += "
";
document.getElementById("table").innerHTML = out;
initControls();
}
}