Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //NativeJS
- window.onload = function() {
- document.getElementById("menu").addEventListener("click", menuClick);
- document.getElementById("menuBar").addEventListener("click", coverClick);
- document.getElementById("cover").addEventListener("click", coverClick);
- }
- // Creates random string with 5 figures.
- function makeid() {
- var text = "";
- var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
- for (var i = 0; i < 5; i++)
- text += possible.charAt(Math.floor(Math.random() * possible.length));
- return text;
- }
- // Action and animation handler for
- // menu bar icon.
- function menuClick() {
- document.getElementById("menuBar").style.left = "0px";
- var cover = document.getElementById("cover");
- cover.style.display = "block";
- setTimeout(function() {
- cover.style.background = "rgba(0,0,0,0.7)";
- }, 10);
- }
- // Action and animation handler for
- // Cover or menu listing page click.
- function coverClick() {
- document.getElementById("menuBar").style.left = "-290px";
- var cover = document.getElementById("cover");
- document.getElementById("detail").style.display = "none";
- cover.style.background = "rgba(0,0,0,0)";
- setTimeout(function() {
- cover.style.display = "none";
- }, 400);
- }
- function openDetail() {
- document.getElementById("detail").style.display = "block";
- var cover = document.getElementById("cover");
- cover.style.display = "block";
- setTimeout(function() {
- cover.style.background = "rgba(0,0,0,0.7)";
- }, 10);
- }
- function closeDetail() {
- document.getElementById("detail").style.display = "none";
- var cover = document.getElementById("cover");
- cover.style.background = "rgba(0,0,0,0)";
- setTimeout(function() {
- cover.style.display = "none";
- }, 400);
- }
- // AngularJS Initilization
- // Starts after vanillaJS is done.
- var uygulama = angular.module("ngUygulamam", ["ngRoute"]);
- uygulama.controller("ngKontrol", function($scope, $http, $location) {
- // Create a captcha after angular initilized.
- $scope.captcha = makeid();
- // Tracking function submit handler.
- $scope.submitSorgula = function(takipNo, captcha) {
- if (captcha != $scope.captcha) {
- $scope.sorgulaContent = "Yanlış bir güvenlik kodu girdiniz.";
- } else {
- if (takipNo) {
- $scope.sorgulaContent = "";
- readTeslimatByTakipNumarasi(takipNo);
- openDetail();
- } else {
- $scope.sorgulaContent = "Takip numaranızı boş bırakmayınız!";
- }
- }
- }
- /* ** Admin Actions** */
- /* ------------------ */
- // Admin login handler, should be used with an Auth service
- // Later on.
- $scope.login = function(userName, password) {
- var obj = {};
- obj.userName = userName;
- obj.password = password;
- if (userName == "admin" && password == "123456") {
- $location.path("adminlist");
- } else {
- alert("Yanlış bir giriş yapıldı!");
- }
- }
- function readTeslimatByTakipNumarasi(takipNo) {
- $http.get('/api/teslimatListesi?teslimatNo=' + takipNo).then(function(resp) {
- $scope.detailData = resp.data[0];
- }, function(err) {
- console.log(err);
- });
- }
- function readPersoneller() {
- $http.get('/api/personelListesi?personelNo=').then(function(resp) {
- $scope.personeller = resp.data;
- }, function(err) {
- console.log(err);
- });
- }
- function readTeslimatlar() {
- $http.get('/api/teslimatListesi?teslimatNo=').then(function(resp) {
- $scope.teslimatlar = resp.data;
- }, function(err) {
- console.log(err);
- });
- }
- $scope.detay = function(takipNo) {
- readTeslimatByTakipNumarasi(takipNo);
- openDetail();
- }
- $scope.tamamla = function(teslimatNo, teslimatDurum) {
- console.log("Teslimat No: " + teslimatNo);
- $http.get('/api/teslimatDurumGuncelle?teslimatNo=' + teslimatNo + '&durum=' + teslimatDurum).then(function(resp) {
- console.log("TeslimatDurum: " + teslimatDurum);
- alert("Güncellendi");
- }, function(err) {
- console.log(err);
- });
- }
- // Page switch handler function for admin page.
- $scope.changeAdmin = function(str) {
- $scope.adminPage = str;
- console.log($scope.adminPage);
- if (str == "personel") {
- readPersoneller();
- } else if (str == "teslimat") {
- readTeslimatlar();
- }
- }
- // Submits A new personel
- // Should be tested.
- $scope.submitPersonel = function(ad, soyad, yetkili) {
- var obj = {};
- obj.ad = ad;
- obj.soyad = soyad;
- obj.yetkili = yetkili;
- $http.post('/api/personelKayit', obj).then(function(resp) {
- console.log(resp);
- }, function(err) {
- console.log(err);
- });
- alert("Yeni personel eklendi");
- $scope.changeAdmin("personel");
- $scope.ad = "";
- $scope.soyad = "";
- $scope.yetkili = "";
- }
- // Submits A new teslimat
- // Should be tested.
- $scope.submitTeslimat = function(personelNumarasi, gonderen, alan, durum, ulke, il, ilce, postaKodu, acikAdres) {
- var obj = {};
- obj.kargoElemaniNumarasi = personelNumarasi;
- obj.gonderen = gonderen;
- obj.alici = alan;
- obj.durum = durum;
- obj.ulke = ulke;
- obj.il = il;
- obj.ilce = ilce;
- obj.postaKodu = parseInt(postaKodu);
- obj.acikAdres = acikAdres;
- $http.post('/api/teslimatKayit', obj).then(function(resp) {
- console.log(resp);
- }, function(err) {
- console.log(err);
- });
- alert("Yeni teslimat eklendi");
- $scope.changeAdmin("teslimat");
- $scope.personelNumarasi = "";
- $scope.gonderen = "";
- $scope.alan = "";
- $scope.durum = "";
- $scope.ulke = "";
- $scope.il = "";
- $scope.ilce = "";
- $scope.postaKodu = "";
- $scope.acikAdres = "";
- }
- });
- // Page routing configuration
- // Also handles HTML5 links.
- uygulama.config(function($routeProvider, $locationProvider) {
- $routeProvider
- .when('/', {
- templateUrl: "template/anasayfa.html"
- })
- .when('/hakkimizda', {
- templateUrl: "template/hakkimizda.html"
- })
- .when('/sorgula', {
- templateUrl: "template/sorgula.html"
- })
- .when('/teslimatKayit', {
- templateUrl: "template/teslimatKayit.html"
- })
- .when('/admin', {
- templateUrl: "template/admin.html"
- })
- .when('/adminlist', {
- templateUrl: "template/adminlist.html"
- })
- .otherwise({
- redirectTo: '/'
- });
- $locationProvider.html5Mode({
- enabled: true,
- requireBase: false
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement