Created
June 3, 2017 06:38
-
-
Save des1roer/2f670631f9a60bbb3ada02a7adfe3742 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
c = function () { | |
return console.log.apply(console, arguments); | |
}; | |
Object.size = function (obj) { | |
var size = 0, key; | |
for (key in obj) { | |
if (obj.hasOwnProperty(key)) | |
size++; | |
} | |
return size; | |
}; | |
Vue.component('modal', { | |
template: '#modal-template' | |
}) | |
var vm = new Vue({ | |
el: '.wrapper', | |
data: { | |
cols: {}, | |
id: window.location.href.split('#')[1] || 0, | |
loader: true, | |
showModal: false, | |
add_row: {}, | |
rows: {}, | |
}, | |
mounted: function () { | |
// next(self.videos, self.id) | |
}, | |
methods: { | |
refresh: function () { | |
var self = this; | |
$.ajax({ | |
url: "php/data.php", | |
type: 'POST', | |
data: {act: 'load', user: self.user_id}, | |
success: function (data) { | |
c(data) | |
var data = $.parseJSON(data); | |
c(data) | |
self.loader = false; | |
self.cols = data; | |
}, | |
error: function (jqXHR, textStatus, errorThrown) { | |
alert(errorThrown); | |
} | |
}); | |
}, | |
pass: function (data) { | |
handleAuthClick(); | |
}, | |
add: function (data) { | |
var self = this; | |
if (typeof self.add_row.name == 'undefined' || self.add_row.name.trim() == '') | |
return false; | |
self.loader = true; | |
$.ajax({ | |
url: "php/data.php", | |
type: 'POST', | |
data: {act: 'add', data: self.add_row, user: self.user_id}, | |
success: function (data) { | |
var data = JSON.parse(data); | |
if (typeof data.error == 'undefined') { | |
self.add_row = {}; | |
vm.refresh(); | |
} else { | |
alert(data.error.errorInfo); | |
} | |
}, | |
error: function (jqXHR, textStatus, errorThrown) { | |
alert(errorThrown); | |
} | |
}); | |
}, | |
edit: function (data) { | |
console.log(data) | |
this.loader = true; | |
$.ajax({ | |
url: "php/data.php", | |
type: 'POST', | |
data: {act: 'edit', data: data}, | |
success: function (data) { | |
var data = JSON.parse(data); | |
if (typeof data.error == 'undefined') { | |
vm.refresh(); | |
} else { | |
alert(data.error.errorInfo); | |
} | |
}, | |
error: function (jqXHR, textStatus, errorThrown) { | |
alert(errorThrown); | |
} | |
}); | |
}, | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment