Advertisement
buraktokak01

Untitled

Jan 11th, 2017
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.42 KB | None | 0 0
  1. //NativeJS
  2.  
  3. window.onload = function() {
  4. document.getElementById("menu").addEventListener("click", menuClick);
  5. document.getElementById("menuBar").addEventListener("click", coverClick);
  6. document.getElementById("cover").addEventListener("click", coverClick);
  7. }
  8.  
  9. // Creates random string with 5 figures.
  10. function makeid() {
  11. var text = "";
  12. var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
  13.  
  14. for (var i = 0; i < 5; i++)
  15. text += possible.charAt(Math.floor(Math.random() * possible.length));
  16.  
  17. return text;
  18. }
  19.  
  20. // Action and animation handler for
  21. // menu bar icon.
  22. function menuClick() {
  23. document.getElementById("menuBar").style.left = "0px";
  24. var cover = document.getElementById("cover");
  25. cover.style.display = "block";
  26. setTimeout(function() {
  27. cover.style.background = "rgba(0,0,0,0.7)";
  28. }, 10);
  29. }
  30.  
  31. // Action and animation handler for
  32. // Cover or menu listing page click.
  33. function coverClick() {
  34. document.getElementById("menuBar").style.left = "-290px";
  35. var cover = document.getElementById("cover");
  36. cover.style.background = "rgba(0,0,0,0)";
  37. setTimeout(function() {
  38. cover.style.display = "none";
  39. }, 400);
  40. }
  41.  
  42.  
  43.  
  44. // AngularJS Initilization
  45. // Starts after vanillaJS is done.
  46.  
  47. var uygulama = angular.module("ngUygulamam", ["ngRoute"]);
  48.  
  49. uygulama.controller("ngKontrol", function($scope, $http, $location) {
  50. // Create a captcha after angular initilized.
  51. $scope.captcha = makeid();
  52.  
  53.  
  54.  
  55.  
  56. // Tracking function submit handler.
  57. $scope.submitSorgula = function(takipNo, captcha) {
  58. if (captcha != $scope.captcha) {
  59. $scope.sorgulaContent = "Yanlış bir güvenlik kodu girdiniz.";
  60. } else {
  61. if (takipNo) {
  62. $scope.sorgulaContent = "Kargo Bilgileri: ";
  63. readTeslimatByTakipNumarasi(takipNo);
  64.  
  65. } else {
  66. $scope.sorgulaContent = "Takip numaranızı boş bırakmayınız!";
  67. }
  68. }
  69. }
  70.  
  71. /* ** Admin Actions** */
  72. /* ------------------ */
  73.  
  74.  
  75. // Admin login handler, should be used with an Auth service
  76. // Later on.
  77. $scope.login = function(userName, password) {
  78. var obj = {};
  79. obj.userName = userName;
  80. obj.password = password;
  81. if (userName == "admin" && password == "123456") {
  82. $location.path("adminlist");
  83. } else {
  84. alert("Yanlış bir giriş yapıldı!");
  85. }
  86. }
  87.  
  88. function readTeslimatByTakipNumarasi(takipNo) {
  89. $http.get('/api/teslimatListesi?teslimatNo=' + takipNo).then(function(resp) {
  90. $scope.teslimatByNo = resp.data;
  91. console.log($scope.teslimatByNo);
  92. }, function(err) {
  93. console.log(err);
  94. });
  95. }
  96.  
  97. function readPersoneller() {
  98. $http.get('/api/personelListesi?personelNo=').then(function(resp) {
  99. $scope.personeller = resp.data;
  100. }, function(err) {
  101. console.log(err);
  102. });
  103. }
  104.  
  105. function readTeslimatlar() {
  106. $http.get('/api/teslimatListesi?teslimatNo=').then(function(resp) {
  107. $scope.teslimatlar = resp.data;
  108. }, function(err) {
  109. console.log(err);
  110. });
  111. }
  112.  
  113. $scope.tamamla = function(teslimatNo, teslimatDurum) {
  114. console.log("Teslimat No: " + teslimatNo);
  115. $http.get('/api/teslimatDurumGuncelle?teslimatNo=' + teslimatNo + '&durum=' + teslimatDurum).then(function(resp) {
  116. console.log("TeslimatDurum: " + teslimatDurum);
  117. alert("Güncellendi");
  118. }, function(err) {
  119. console.log(err);
  120. });
  121. }
  122.  
  123. // Page switch handler function for admin page.
  124. $scope.changeAdmin = function(str) {
  125. $scope.adminPage = str;
  126. console.log($scope.adminPage);
  127. if (str == "personel") {
  128. readPersoneller();
  129. } else if (str == "teslimat") {
  130. readTeslimatlar();
  131. }
  132. }
  133.  
  134.  
  135. // Submits A new personel
  136. // Should be tested.
  137. $scope.submitPersonel = function(ad, soyad, yetkili) {
  138. var obj = {};
  139. obj.ad = ad;
  140. obj.soyad = soyad;
  141. obj.yetkili = yetkili;
  142. $http.post('/api/personelKayit', obj).then(function(resp) {
  143. console.log(resp);
  144. }, function(err) {
  145. console.log(err);
  146. });
  147. alert("Yeni personel eklendi");
  148. $scope.changeAdmin("personel");
  149. $scope.ad = "";
  150. $scope.soyad = "";
  151. $scope.yetkili = "";
  152. }
  153.  
  154. // Submits A new teslimat
  155. // Should be tested.
  156. $scope.submitTeslimat = function(personelNumarasi, gonderen, alan, durum, ulke, il, ilce, postaKodu, acikAdres) {
  157. var obj = {};
  158. obj.kargoElemaniNumarasi = personelNumarasi;
  159. obj.gonderen = gonderen;
  160. obj.alici = alan;
  161. obj.durum = durum;
  162. obj.ulke = ulke;
  163. obj.il = il;
  164. obj.ilce = ilce;
  165. obj.postaKodu = parseInt(postaKodu);
  166. obj.acikAdres = acikAdres;
  167. $http.post('/api/teslimatKayit', obj).then(function(resp) {
  168. console.log(resp);
  169. }, function(err) {
  170. console.log(err);
  171. });
  172. alert("Yeni teslimat eklendi");
  173. $scope.changeAdmin("teslimat");
  174. $scope.personelNumarasi = "";
  175. $scope.gonderen = "";
  176. $scope.alan = "";
  177. $scope.durum = "";
  178. $scope.ulke = "";
  179. $scope.il = "";
  180. $scope.ilce = "";
  181. $scope.postaKodu = "";
  182. $scope.acikAdres = "";
  183. }
  184.  
  185.  
  186. });
  187.  
  188.  
  189. // Page routing configuration
  190. // Also handles HTML5 links.
  191. uygulama.config(function($routeProvider, $locationProvider) {
  192. $routeProvider
  193. .when('/', {
  194. templateUrl: "template/anasayfa.html"
  195. })
  196. .when('/hakkimizda', {
  197. templateUrl: "template/hakkimizda.html"
  198. })
  199. .when('/sorgula', {
  200. templateUrl: "template/sorgula.html"
  201. })
  202. .when('/teslimatKayit', {
  203. templateUrl: "template/teslimatKayit.html"
  204. })
  205. .when('/admin', {
  206. templateUrl: "template/admin.html"
  207. })
  208. .when('/adminlist', {
  209. templateUrl: "template/adminlist.html"
  210. })
  211. .otherwise({
  212. redirectTo: '/'
  213. });
  214. $locationProvider.html5Mode({
  215. enabled: true,
  216. requireBase: false
  217. });
  218. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement