Advertisement
Guest User

Untitled

a guest
Jan 11th, 2017
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.45 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. // TODO: takip numarası ile kargo bilgilerini çekip yazdır.
  64.  
  65.  
  66. } else {
  67. $scope.sorgulaContent = "Takip numaranızı boş bırakmayınız!";
  68. }
  69. }
  70. }
  71.  
  72. /* ** Admin Actions** */
  73. /* ------------------ */
  74.  
  75.  
  76. // Admin login handler, should be used with an Auth service
  77. // Later on.
  78. $scope.login = function(userName, password) {
  79. var obj = {};
  80. obj.userName = userName;
  81. obj.password = password;
  82. if (userName == "admin" && password == "123456") {
  83. $location.path("adminlist");
  84. } else {
  85. alert("Yanlış bir giriş yapıldı!");
  86. }
  87. }
  88.  
  89. function readTeslimatByTakipNumarasi(takipNo) {
  90. $http.get('/api/teslimatListesi?teslimatNo=' + takipNo).then(function(resp) {
  91. $scope.teslimatByNo = resp.data;
  92. console.log($scope.teslimatByNo);
  93. }, function(err) {
  94. console.log(err);
  95. });
  96. }
  97.  
  98. function readPersoneller() {
  99. $http.get('/api/personelListesi?personelNo=').then(function(resp) {
  100. $scope.personeller = resp.data;
  101. }, function(err) {
  102. console.log(err);
  103. });
  104. }
  105.  
  106. function readTeslimatlar() {
  107. $http.get('/api/teslimatListesi?teslimatNo=').then(function(resp) {
  108. $scope.teslimatlar = resp.data;
  109. }, function(err) {
  110. console.log(err);
  111. });
  112. }
  113.  
  114. $scope.tamamla = function(teslimatNo, teslimatDurum) {
  115. console.log("Teslimat No: " + teslimatNo);
  116. $http.get('/api/teslimatDurumGuncelle?teslimatNo=' + tesimatNo + '&durum=' + teslimatDurum).then(function(resp) {
  117. console.log("TeslimatDurum: " + teslimatDurum);
  118. alert("Güncellendi");
  119. }, function(err) {
  120. console.log(err);
  121. });
  122. }
  123.  
  124. // Page switch handler function for admin page.
  125. $scope.changeAdmin = function(str) {
  126. $scope.adminPage = str;
  127. console.log($scope.adminPage);
  128. if (str == "personel") {
  129. readPersoneller();
  130. } else if (str == "teslimat") {
  131. readTeslimatlar();
  132. }
  133. }
  134.  
  135.  
  136. // Submits A new personel
  137. // Should be tested.
  138. $scope.submitPersonel = function(ad, soyad, yetkili) {
  139. var obj = {};
  140. obj.ad = ad;
  141. obj.soyad = soyad;
  142. obj.yetkili = yetkili;
  143. $http.post('/api/personelKayit', obj).then(function(resp) {
  144. console.log(resp);
  145. }, function(err) {
  146. console.log(err);
  147. });
  148. alert("Yeni personel eklendi");
  149. $scope.changeAdmin("personel");
  150. $scope.ad = "";
  151. $scope.soyad = "";
  152. $scope.yetkili = "";
  153. }
  154.  
  155. // Submits A new teslimat
  156. // Should be tested.
  157. $scope.submitTeslimat = function(personelNumarasi, gonderen, alan, durum, ulke, il, ilce, postaKodu, acikAdres) {
  158. var obj = {};
  159. obj.kargoElemaniNumarasi = personelNumarasi;
  160. obj.gonderen = gonderen;
  161. obj.alici = alan;
  162. obj.durum = durum;
  163. obj.ulke = ulke;
  164. obj.il = il;
  165. obj.ilce = ilce;
  166. obj.postaKodu = parseInt(postaKodu);
  167. obj.acikAdres = acikAdres;
  168. $http.post('/api/teslimatKayit', obj).then(function(resp) {
  169. console.log(resp);
  170. }, function(err) {
  171. console.log(err);
  172. });
  173. alert("Yeni teslimat eklendi");
  174. $scope.changeAdmin("teslimat");
  175. $scope.personelNumarasi = "";
  176. $scope.gonderen = "";
  177. $scope.alan = "";
  178. $scope.durum = "";
  179. $scope.ulke = "";
  180. $scope.il = "";
  181. $scope.ilce = "";
  182. $scope.postaKodu = "";
  183. $scope.acikAdres = "";
  184. }
  185.  
  186.  
  187. });
  188.  
  189.  
  190. // Page routing configuration
  191. // Also handles HTML5 links.
  192. uygulama.config(function($routeProvider, $locationProvider) {
  193. $routeProvider
  194. .when('/', {
  195. templateUrl: "template/anasayfa.html"
  196. })
  197. .when('/hakkimizda', {
  198. templateUrl: "template/hakkimizda.html"
  199. })
  200. .when('/sorgula', {
  201. templateUrl: "template/sorgula.html"
  202. })
  203. .when('/teslimatKayit', {
  204. templateUrl: "template/teslimatKayit.html"
  205. })
  206. .when('/admin', {
  207. templateUrl: "template/admin.html"
  208. })
  209. .when('/adminlist', {
  210. templateUrl: "template/adminlist.html"
  211. })
  212. .otherwise({
  213. redirectTo: '/'
  214. });
  215. $locationProvider.html5Mode({
  216. enabled: true,
  217. requireBase: false
  218. });
  219. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement