Advertisement
Guest User

Untitled

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