Advertisement
buraktokak01

Untitled

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