Advertisement
buraktokak01

Untitled

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