Advertisement
buraktokak01

Untitled

Jan 11th, 2017
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.10 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.  
  132. $scope.detay = function(takipNo) {
  133. readTeslimatByTakipNumarasi(takipNo);
  134. openDetail();
  135. }
  136.  
  137. $scope.tamamla = function(teslimatNo, teslimatDurum) {
  138. console.log("Teslimat No: " + teslimatNo);
  139. $http.get('/api/teslimatDurumGuncelle?teslimatNo=' + teslimatNo + '&durum=' + teslimatDurum).then(function(resp) {
  140. console.log("TeslimatDurum: " + teslimatDurum);
  141. alert("Güncellendi");
  142. }, function(err) {
  143. console.log(err);
  144. });
  145. }
  146.  
  147. // Page switch handler function for admin page.
  148. $scope.changeAdmin = function(str) {
  149. $scope.adminPage = str;
  150. console.log($scope.adminPage);
  151. if (str == "personel") {
  152. readPersoneller();
  153. } else if (str == "teslimat") {
  154. readTeslimatlar();
  155. }
  156. }
  157.  
  158.  
  159. // Submits A new personel
  160. // Should be tested.
  161. $scope.submitPersonel = function(ad, soyad, yetkili) {
  162. var obj = {};
  163. obj.ad = ad;
  164. obj.soyad = soyad;
  165. obj.yetkili = yetkili;
  166. $http.post('/api/personelKayit', obj).then(function(resp) {
  167. console.log(resp);
  168. }, function(err) {
  169. console.log(err);
  170. });
  171. alert("Yeni personel eklendi");
  172. $scope.changeAdmin("personel");
  173. $scope.ad = "";
  174. $scope.soyad = "";
  175. $scope.yetkili = "";
  176. }
  177.  
  178. // Submits A new teslimat
  179. // Should be tested.
  180. $scope.submitTeslimat = function(personelNumarasi, gonderen, alan, durum, ulke, il, ilce, postaKodu, acikAdres) {
  181. var obj = {};
  182. obj.kargoElemaniNumarasi = personelNumarasi;
  183. obj.gonderen = gonderen;
  184. obj.alici = alan;
  185. obj.durum = durum;
  186. obj.ulke = ulke;
  187. obj.il = il;
  188. obj.ilce = ilce;
  189. obj.postaKodu = parseInt(postaKodu);
  190. obj.acikAdres = acikAdres;
  191. $http.post('/api/teslimatKayit', obj).then(function(resp) {
  192. console.log(resp);
  193. }, function(err) {
  194. console.log(err);
  195. });
  196. alert("Yeni teslimat eklendi");
  197. $scope.changeAdmin("teslimat");
  198. $scope.personelNumarasi = "";
  199. $scope.gonderen = "";
  200. $scope.alan = "";
  201. $scope.durum = "";
  202. $scope.ulke = "";
  203. $scope.il = "";
  204. $scope.ilce = "";
  205. $scope.postaKodu = "";
  206. $scope.acikAdres = "";
  207. }
  208.  
  209.  
  210. });
  211.  
  212.  
  213. // Page routing configuration
  214. // Also handles HTML5 links.
  215. uygulama.config(function($routeProvider, $locationProvider) {
  216. $routeProvider
  217. .when('/', {
  218. templateUrl: "template/anasayfa.html"
  219. })
  220. .when('/hakkimizda', {
  221. templateUrl: "template/hakkimizda.html"
  222. })
  223. .when('/sorgula', {
  224. templateUrl: "template/sorgula.html"
  225. })
  226. .when('/teslimatKayit', {
  227. templateUrl: "template/teslimatKayit.html"
  228. })
  229. .when('/admin', {
  230. templateUrl: "template/admin.html"
  231. })
  232. .when('/adminlist', {
  233. templateUrl: "template/adminlist.html"
  234. })
  235. .otherwise({
  236. redirectTo: '/'
  237. });
  238. $locationProvider.html5Mode({
  239. enabled: true,
  240. requireBase: false
  241. });
  242. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement