Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // app.js
- var slide = $("header > img");
- var sno = 0;
- var eno = slide.length - 1;
- if( eno ) {
- for( var i=0; i<=eno; i++ ){
- var pointer = "<span>●</span>";
- $(".pointer").append(pointer);
- }
- }
- var pointers = $(".pointer span");
- $( pointers[sno] ).addClass("active");
- $("header").on("click",function(){
- $( slide[sno] ).animate({
- left:"940px",
- opacity: 0
- },1000,function(){
- $(this).css({left:"-940px"});
- });
- sno++;
- if( sno > eno ) sno = 0;
- $( slide[sno] ).animate({
- left:"0",
- opacity: 1
- },1000,function(){
- $(".pointer span").removeClass("active");
- $( pointers[sno] ).addClass("active");
- });
- });
- var timer = setInterval(function(){
- $("header").click();
- },2000);
- $("nav > ul > li").hover(
- function(){
- $(this).children("ul").slideDown();
- },
- function(){
- $(this).children("ul").slideUp("fast");
- }
- );
- var page = 1;
- function list(){
- $.getJSON("list.php?start="+page,function(d){
- if( ! d ) return;
- for(var i=0; i<d.length; i++){
- var tr = "<tr>";
- tr += "<td class='name'>" + d[i].name + "</td>";
- tr += "<td class='phone'>" + d[i].phone + "</td>";
- tr += "<td class='birth'>" + d[i].birth + "</td>";
- tr += "<td class='email'>" + d[i].email + "</td>";
- tr += "<td data-id='" + d[i].id + "'><button class='edit btn btn-info btn-sm'><span class='glyphicon glyphicon-pencil'></span>수정</button> <button class='remove btn btn-danger btn-sm'><span class='glyphicon glyphicon-trash'></span>삭제</button></td>";
- tr += "</tr>";
- $("#list tr:last").after(tr);
- }
- });
- }
- list();
- $(window).scroll(function(){
- var dh = $(document).height();
- var wh = $(window).height();
- var st = $(window).scrollTop();
- var sp = wh + st;
- if( (dh-sp)/dh === 0 ){
- page++;
- list();
- }
- });
- $("#list").on("click",".remove",function(){
- var id = $(this).parent("td").attr("data-id");
- var del = confirm("정말 지울까요?");
- if( ! del ) return;
- var data = {"act":"delete","id":id};
- $.post("action.php",data,function(r){
- if( r == "1" ) {
- location.reload();
- } else {
- alert("삭제 실패");
- }
- });
- });
- $("#list").on("click",".edit",function(){
- var id = $(this).parent("td").attr("data-id");
- if( ! id ) return;
- var tr = $(this).parent("td").parent("tr");
- var name = $(tr).children(".name").text();
- var phone = $(tr).children(".phone").text();
- var birth = $(tr).children(".birth").text();
- var email = $(tr).children(".email").text();
- if( ! name || ! phone || ! birth || ! email ) return;
- $("#name").val(name);
- $("#phone").val(phone);
- $("#birth").val(birth);
- $("#email").val(email);
- $("#pop").dialog();
- });
- /*
- var app = angular.module("myApp",[]);
- app.controller("myPeople",function($scope,$http){
- $http.get("list.php").then(
- function(p){
- $scope.people = p.data;
- }
- );
- });
- */
- $("#pop").hide();
- $(".add").on("click",function(){
- $("#pop").dialog({
- width: 500,
- height: 450,
- title: "친구추가",
- modal: true,
- buttons: {
- "등록": function(){
- var data = {};
- data.name = $("#name").val();
- data.phone = $("#phone").val();
- data.birth = $("#birth").val();
- data.email = $("#email").val();
- if( ! data.name || ! data.phone || ! data.birth || ! data.email ) return;
- data.act = "insert";
- $.post("action.php",data,function(r){
- if( r == "1" ) {
- location.reload();
- } else {
- alert("등록 실패" + r);
- }
- });
- },
- "닫기": function(){
- $(this).dialog("close");
- }
- }
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment