| 376 | | |
| 377 | | //From prototype.js |
| 378 | | function ctlExtend(destination,source) { |
| 379 | | |
| 380 | | for(var property in source.prototype) { |
| 381 | | destination.prototype[property] = source.prototype[property]; |
| 382 | | } |
| 383 | | return destination; |
| 384 | | } |
| 385 | | |
| 386 | | function ctlTable(containername) |
| 387 | | { |
| 388 | | this.init(); |
| 389 | | |
| 390 | | this.name = "Textcube Control Panel Blog Table Object"; |
| 391 | | this.copyright = "Tatter Network Foundation"; |
| 392 | | |
| 393 | | this.container = document.getElementById(containername); |
| 394 | | } |
| 395 | | |
| 396 | | ctlTable.prototype.init = function() { |
| 397 | | this.instance = this; |
| 398 | | this.enablecheckbox = true; |
| 399 | | this.enableaction = true; |
| 400 | | this.enableinfo = true; |
| 401 | | |
| 402 | | this.table = document.createElement("TABLE"); |
| 403 | | this.rows = 20; |
| 404 | | |
| 405 | | this.url=""; |
| 406 | | this.colitem = new Array(); |
| 407 | | this.collink = new Array(); |
| 408 | | |
| 409 | | } |
| 410 | | |
| 411 | | ctlTable.prototype.setsource = function(url,page,rows) { |
| 412 | | this.url = url; |
| 413 | | } |
| 414 | | |
| 415 | | ctlTable.prototype.setColumns = function(columns) { |
| 416 | | this.columns = columns.length; |
| 417 | | this.colitem = columns; |
| 418 | | } |
| 419 | | |
| 420 | | ctlTable.prototype.refreshTable = function() |
| 421 | | { |
| 422 | | this.showTable(); |
| 423 | | } |
| 424 | | ctlTable.prototype.showTable = function() |
| 425 | | { |
| 426 | | this.requesturl = blogURL + this.url + "?page="+this.page+"&rows="+this.rows; |
| 427 | | var request = new HTTPRequest(this.requesturl); |
| 428 | | request.instance=this.instance; |
| 429 | | request.onSuccess = function () { |
| 430 | | var Line_id,resultResponse,resultRow; |
| 431 | | var instance=this.instance; |
| 432 | | |
| 433 | | resultResponse = this.getText("/response/result"); |
| 434 | | resultRow = instance.resultRow = resultResponse.split('*'); |
| 435 | | instance.container.innerHTML=''; |
| 436 | | instance.table.innerHTML = ''; |
| 437 | | |
| 438 | | if (resultRow.length == 1) |
| 439 | | instance.table = ''; |
| 440 | | else { |
| 441 | | if(instance.enableinfo) { |
| 442 | | tempInfo = instance.printInfo(); |
| 443 | | } |
| 444 | | var containerThead, containerTr, tempTh, tempCheckBox,containerTbody; |
| 445 | | |
| 446 | | containerThead = document.createElement("THEAD"); |
| 447 | | containerTr = document.createElement("TR"); |
| 448 | | |
| 449 | | if(instance.enablecheckbox) { |
| 450 | | tempTh = document.createElement("TH"); |
| 451 | | tempCheckBox = document.createElement("input"); |
| 452 | | tempCheckBox.type = "checkbox"; |
| 453 | | tempCheckBox.onclick = function() { instance.selectCheckBoxAll(this.checked); }; |
| 454 | | tempTh.appendChild(tempCheckBox); |
| 455 | | containerTr.appendChild(tempTh); |
| 456 | | } |
| 457 | | for(var i=0;i<instance.columns;i++) { |
| 458 | | tempTh = document.createElement("TH"); |
| 459 | | tempTh.innerHTML = instance.colitem[i]; |
| 460 | | containerTr.appendChild(tempTh); |
| 461 | | } |
| 462 | | tempTh = document.createElement("TH"); |
| 463 | | tempTh.innerHTML = _t('Actions'); |
| 464 | | containerTr.appendChild(tempTh); |
| 465 | | |
| 466 | | containerThead.appendChild(containerTr); |
| 467 | | instance.table.appendChild(containerThead); |
| 468 | | |
| 469 | | containerTbody = document.createElement("TBODY"); |
| 470 | | |
| 471 | | for (var i=0; i<instance.rows && resultRow.length > 0; i++) { |
| 472 | | tempRow = resultRow.shift(); |
| 473 | | field = tempRow.split(','); |
| 474 | | containerTr = document.createElement("TR"); |
| 475 | | |
| 476 | | var Line_id = field[0]; |
| 477 | | containerTr.id = instance.table.id + "_" + Line_id; |
| 478 | | Td_id = document.createElement("td"); |
| 479 | | |
| 480 | | if(instance.enablecheckbox) { |
| 481 | | tempCheckBox = document.createElement("input"); |
| 482 | | Td_checkbox = document.createElement("td"); |
| 483 | | tempCheckBox.id = containerTr.id+"_check"; |
| 484 | | tempCheckBox.type = "checkbox"; |
| 485 | | Td_checkbox.appendChild(tempCheckBox); |
| 486 | | containerTr.appendChild(Td_checkbox); |
| 487 | | } |
| 488 | | for (var j=0;j<4;j++) { |
| 489 | | Td_id = document.createElement("TD"); |
| 490 | | if (instance.collink[j]!='') { |
| 491 | | var tempLink = document.createElement("A"); |
| 492 | | tempLink.innerHTML = field[j]; |
| 493 | | tempLink.setAttribute("href",instance.collink[j] + Line_id); |
| 494 | | Td_id.appendChild(tempLink); |
| 495 | | } |
| 496 | | else { |
| 497 | | Td_id.innerHTML = field[j]; |
| 498 | | } |
| 499 | | containerTr.appendChild(Td_id); |
| 500 | | } |
| 501 | | |
| 502 | | if(instance.enableaction) { |
| 503 | | Td_action = document.createElement("TD"); |
| 504 | | instance.printAction(Td_action); |
| 505 | | containerTr.appendChild(Td_action); |
| 506 | | } |
| 507 | | |
| 508 | | containerTbody.appendChild(containerTr); |
| 509 | | } |
| 510 | | this.instance.table.appendChild(containerTbody); |
| 511 | | } |
| 512 | | if (this.instance.table != '' ) { |
| 513 | | this.instance.container.appendChild(this.instance.table); |
| 514 | | if(instance.enablecheckbox) { |
| 515 | | tempTable = instance.printActionChecked(); |
| 516 | | this.instance.container.appendChild(tempTable); |
| 517 | | } |
| 518 | | if(instance.enableinfo) { |
| 519 | | this.instance.container.appendChild(tempInfo); |
| 520 | | } |
| 521 | | } |
| 522 | | return true; |
| 523 | | } |
| 524 | | request.onError = function() { |
| 525 | | error = this.getText("/response/error"); |
| 526 | | if (error == -2 ) { |
| 527 | | window.location = "?page="+ this.getText("/response/result"); |
| 528 | | } |
| 529 | | } |
| 530 | | request.send(); |
| 531 | | } |
| 532 | | |
| 533 | | ctlTable.prototype.getChecked = function() { |
| 534 | | var tbody = this.table.childNodes[1]; |
| 535 | | var returnText = new Array(); |
| 536 | | for(var i=0; i<tbody.childNodes.length; i++) { |
| 537 | | var checkbox = document.getElementById(tbody.childNodes[i].id+"_check"); |
| 538 | | if (checkbox.checked) |
| 539 | | { |
| 540 | | returnText.push(tbody.childNodes[i].id.substr(this.table.id.length+1)); |
| 541 | | } |
| 542 | | } |
| 543 | | return returnText.join(","); |
| 544 | | } |
| 545 | | |
| 546 | | ctlTable.prototype.selectCheckBoxAll = function(checked) { |
| 547 | | var tbody = this.table.childNodes[1]; |
| 548 | | for(var i=0; i<tbody.childNodes.length; i++) { |
| 549 | | var checkbox = document.getElementById(tbody.childNodes[i].id+"_check"); |
| 550 | | checkbox.checked = checked; |
| 551 | | } |
| 552 | | } |
| 553 | | |
| 554 | | ctlTable.prototype.reverseCheckBoxAll = function(checked) { |
| 555 | | var tbody = this.table.childNodes[1]; |
| 556 | | for(var i=0; i<tbody.childNodes.length; i++) { |
| 557 | | var checkbox = document.getElementById(tbody.childNodes[i].id+"_check"); |
| 558 | | //checkbox.checked = checked; |
| 559 | | checkbox.checked = !checkbox.checked; |
| 560 | | } |
| 561 | | } |
| 562 | | |
| 563 | | |
| 564 | | //ctlBlog.. |
| 565 | | |
| 566 | | ctlBlog = ctlExtend(ctlBlog, ctlTable); |
| 567 | | |
| 568 | | function ctlBlog(containername) { |
| 569 | | this.name = "Textcube Control Panel Blog Table Object"; |
| 570 | | this.copyright = "Tatter Network Foundation"; |
| 571 | | |
| 572 | | this.init(); |
| 573 | | |
| 574 | | this.container = document.getElementById(containername); |
| 575 | | |
| 576 | | this.table.id = "table-blog-list"; |
| 577 | | this.table.className = "data-inbox"; |
| 578 | | this.table.setAttribute("cellpadding", 0); |
| 579 | | this.table.setAttribute("cellspacing", 0); |
| 580 | | |
| 581 | | this.colitem.push(_t('블로그 ID')); |
| 582 | | this.collink.push(''); |
| 583 | | this.colitem.push(_t('블로그 구분자')); |
| 584 | | this.collink.push(blogURL + "/owner/control/blog/"); |
| 585 | | this.colitem.push(_t('블로그 제목')); |
| 586 | | this.collink.push(''); |
| 587 | | this.colitem.push(_t('블로그 소유자')); |
| 588 | | this.collink.push(''); |
| 589 | | |
| 590 | | this.url="/owner/control/action/blog/index/"; |
| 591 | | this.rows = (typeof(rows) == "undefined") ? 20 : rows; |
| 592 | | this.columns = this.colitem.length; |
| 593 | | } |
| 594 | | |
| 595 | | ctlBlog.prototype.setPage = function(page) { |
| 596 | | this.page = page; |
| 597 | | this.requesturl = blogURL + this.url + "?page="+this.page+"&rows="+this.rows; |
| 598 | | } |
| 599 | | |
| 600 | | ctlBlog.prototype.printInfo = function() { |
| 601 | | var pagelist = this.resultRow.shift(); |
| 602 | | var tempInfo = document.createElement("div"); |
| 603 | | tempInfo.id = "page-navigation"; |
| 604 | | var tempSpan = document.createElement("span"); |
| 605 | | tempSpan.id = "page-list"; |
| 606 | | tempSpan.innerHTML = pagelist |
| 607 | | tempInfo.appendChild(tempSpan); |
| 608 | | var blogs = this.resultRow.shift(); |
| 609 | | tempSpan = document.createElement("span"); |
| 610 | | tempSpan.id = "total-count"; |
| 611 | | tempSpan.innerHTML = "총 " + blogs + "개의 블로그"; |
| 612 | | tempInfo.appendChild(tempSpan); |
| 613 | | return tempInfo; |
| 614 | | } |
| 615 | | |
| 616 | | ctlBlog.prototype.printAction = function(Td) { |
| 617 | | var tempInfo = document.createElement("div"); |
| 618 | | var tempLink = document.createElement("A"); |
| 619 | | tempLink.className = "remove-button button"; |
| 620 | | tempLink.id = "rb_" + field[0]; |
| 621 | | tempLink.setAttribute("href", "#void"); |
| 622 | | tempLink.onclick = function() { deleteBlog(this.id.substr(3)); showTable(page);return false; }; |
| 623 | | tempLink.setAttribute("title", _t('이 블로그를 삭제합니다.')); |
| 624 | | |
| 625 | | var tempSpan = document.createElement("SPAN"); |
| 626 | | tempSpan.className = "text"; |
| 627 | | tempSpan.innerHTML = _t('삭제'); |
| 628 | | |
| 629 | | tempLink.appendChild(tempSpan); |
| 630 | | Td.appendChild(tempLink); |
| 631 | | } |
| 632 | | |
| 633 | | ctlBlog.prototype.printActionChecked = function() { |
| 634 | | var instance = this.instance; |
| 635 | | var tempInfo = document.createElement("div"); |
| 636 | | var tempLink = document.createElement("A"); |
| 637 | | tempLink.className = "remove-button button"; |
| 638 | | tempLink.id = "rb_" + field[0]; |
| 639 | | tempLink.setAttribute("href", "#void"); |
| 640 | | tempLink.onclick = function() { instance.deleteBlogChecked();return false; }; |
| 641 | | tempLink.setAttribute("title", _t('선택된 블로그를 삭제합니다.')); |
| 642 | | |
| 643 | | var tempSpan = document.createElement("SPAN"); |
| 644 | | tempSpan.className = "text"; |
| 645 | | tempSpan.innerHTML = _t('선택된 블로그 삭제'); |
| 646 | | |
| 647 | | tempLink.appendChild(tempSpan); |
| 648 | | tempInfo.appendChild(tempLink); |
| 649 | | return tempInfo; |
| 650 | | } |
| 651 | | |
| 652 | | ctlBlog.prototype.deleteBlogChecked = function() { |
| 653 | | var tbody = this.table.childNodes[1]; |
| 654 | | var itemString = this.getChecked(); |
| 655 | | |
| 656 | | if (!confirm(_t('되돌릴 수 없습니다.\t\n\n계속 진행하시겠습니까?'))) return false; |
| 657 | | var request = new HTTPRequest(blogURL + "/owner/control/action/blog/delete/?item=" +itemString); |
| 658 | | request.instance=this.instance; |
| 659 | | request.onSuccess = function() { |
| 660 | | PM.showMessage(_t('선택된 블로그가 삭제되었습니다.'), "center", "top"); |
| 661 | | this.instance.showTable(); |
| 662 | | } |
| 663 | | request.onError = function() { |
| 664 | | PM.showMessage(_t('삭제 도중 오류가 발생하였습니다.'), "center", "top"); |
| 665 | | } |
| 666 | | request.send(); |
| 667 | | } |
| 668 | | |
| 669 | | |
| 670 | | //ctlUser |
| 671 | | ctlUser = ctlExtend(ctlUser, ctlTable); |
| 672 | | |
| 673 | | function ctlUser(containername) { |
| 674 | | this.name = "Textcube Control Panel User Table Object"; |
| 675 | | this.copyright = "Tatter Network Foundation"; |
| 676 | | |
| 677 | | this.init(); |
| 678 | | |
| 679 | | this.container = document.getElementById(containername); |
| 680 | | |
| 681 | | this.table.id = "table-user-list"; |
| 682 | | this.table.className = "data-inbox"; |
| 683 | | this.table.setAttribute("cellpadding", 0); |
| 684 | | this.table.setAttribute("cellspacing", 0); |
| 685 | | |
| 686 | | this.colitem.push(_t('ID')); |
| 687 | | this.collink.push(''); |
| 688 | | this.colitem.push(_t('로그인 ID')); |
| 689 | | this.collink.push(blogURL + "/owner/control/user/"); |
| 690 | | this.colitem.push(_t('필명')); |
| 691 | | this.collink.push(''); |
| 692 | | this.colitem.push(_t('최종 접속일')); |
| 693 | | this.collink.push(''); |
| 694 | | |
| 695 | | this.url="/owner/control/action/user/index/"; |
| 696 | | this.rows = (typeof(rows) == "undefined") ? 20 : rows; |
| 697 | | this.columns = this.colitem.length; |
| 698 | | } |
| 699 | | |
| 700 | | ctlUser.prototype.setPage = function(page) { |
| 701 | | this.page = page; |
| 702 | | this.requesturl = blogURL + this.url + "?page="+this.page+"&rows="+this.rows; |
| 703 | | } |
| 704 | | |
| 705 | | ctlUser.prototype.printInfo = function() { |
| 706 | | var pagelist = this.resultRow.shift(); |
| 707 | | var tempInfo = document.createElement("div"); |
| 708 | | tempInfo.id = "page-navigation"; |
| 709 | | var tempSpan = document.createElement("span"); |
| 710 | | tempSpan.id = "page-list"; |
| 711 | | tempSpan.innerHTML = pagelist |
| 712 | | tempInfo.appendChild(tempSpan); |
| 713 | | var blogs = this.resultRow.shift(); |
| 714 | | tempSpan = document.createElement("span"); |
| 715 | | tempSpan.id = "total-count"; |
| 716 | | tempSpan.innerHTML = "총 " + blogs + "명의 사용자"; |
| 717 | | tempInfo.appendChild(tempSpan); |
| 718 | | return tempInfo; |
| 719 | | } |
| 720 | | |
| 721 | | ctlUser.prototype.printAction = function(Td) { |
| 722 | | var tempInfo = document.createElement("div"); |
| 723 | | var tempLink = document.createElement("A"); |
| 724 | | tempLink.className = "remove-button button"; |
| 725 | | tempLink.id = "rb_" + field[0]; |
| 726 | | tempLink.setAttribute("href", "#void"); |
| 727 | | tempLink.onclick = function() { return false; }; //TODO:미구현 |
| 728 | | tempLink.setAttribute("title", _t('이 사용자를 삭제합니다.')); |
| 729 | | |
| 730 | | var tempSpan = document.createElement("SPAN"); |
| 731 | | tempSpan.className = "text"; |
| 732 | | tempSpan.innerHTML = _t('삭제'); |
| 733 | | |
| 734 | | tempLink.appendChild(tempSpan); |
| 735 | | Td.appendChild(tempLink); |
| 736 | | } |
| 737 | | |
| 738 | | ctlUser.prototype.printActionChecked = function() { |
| 739 | | var instance = this.instance; |
| 740 | | var tempInfo = document.createElement("div"); |
| 741 | | var tempLink = document.createElement("A"); |
| 742 | | tempLink.className = "remove-button button"; |
| 743 | | tempLink.id = "rb_" + field[0]; |
| 744 | | tempLink.setAttribute("href", "#void"); |
| 745 | | tempLink.onclick = function() { return false; }; //TODO:미구현 |
| 746 | | tempLink.setAttribute("title", _t('선택된 사용자를 삭제합니다.')); |
| 747 | | |
| 748 | | var tempSpan = document.createElement("SPAN"); |
| 749 | | tempSpan.className = "text"; |
| 750 | | tempSpan.innerHTML = _t('선택된 사용자 삭제'); |
| 751 | | |
| 752 | | tempLink.appendChild(tempSpan); |
| 753 | | tempInfo.appendChild(tempLink); |
| 754 | | return tempInfo; |
| 755 | | } |
| 756 | | |
| | 375 | function ctlRefresh() { |
| | 376 | window.location.reload(); |
| | 377 | } |
| | 378 | |