1angular 2 .module("wcdWebAppFront", [ 3 "wcdWebAppFront.routes", 4 "angularUtils.directives.dirPagination", 5 "angularjs-dropdown-multiselect" 6 ]) 7 .config(function(paginationTemplateProvider) { 8 paginationTemplateProvider.setPath( 9 site_url + 10 "/wp-content/plugins/entity-closing-lite/template/dirPagination.tpl.html" 11 ); 12 }) 13 .controller("shortcodeCtrl", [ 14 "$scope", 15 "$http", 16 function($scope, $http) { 17 $scope.progressMessage = "Loading..."; 18 $scope.progressStatus = true; 19 $scope.alphabetFilter = "All"; 20 $scope.pageSize = 10; 21 $scope.pagination = { 22 current: 1 23 }; 24 $scope.oldPage = 0; 25 $scope.templateUrl = 26 site_url + 27 "/wp-content/plugins/entity-closing-lite/template/dirPagination.tpl.html"; 28 $scope.alphabets = [ 29 "All", 30 "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", 31 "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", 32 "~", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "-", "_", "+", "/", ".", ":", "\\", "<", ">" 33 ]; 34 35 $scope.checkListType = [ 36 { label: "School", id: "school" }, 37 { label: "Business", id: "business" }, 38 { label: "Civic Groups", id: "civic-groups" }, 39 { label: "College/University", id: "college-university" }, 40 { label: "Day Care", id: "day-care" }, 41 { label: "Government", id: "government" }, 42 { label: "Medical", id: "medical" }, 43 { label: "Other", id: "other" }, 44 { label: "Sporting Event", id: "sporting-event" } 45 ]; 46 47 //WPB-2705 48 $scope.checkListStatus = [ 49 { label: "Hide", id: "hide" }, 50 { label: "Delayed", id: "delay" }, 51 { label: "Open", id: "open" }, 52 { label: "Closed", id: "close" }, 53 { label: "Canceled", id: "canceled" }, 54 { label: "Postponed", id: "postponed" }, 55 { label: "Closing Early", id: "cl_early" } 56 ]; 57 58 $scope.checkedFilter = { 59 type: [] 60 }; 61 62 if (custom_type_str) { 63 var option_arr = custom_type_str.split("^@^"); 64 for (x in option_arr) { 65 var option_str = option_arr[x]; 66 var option_arr_1 = option_str.split("^*^"); 67 $scope.checkListType.push({ 68 label: option_arr_1[1], 69 id: option_arr_1[0] 70 }); 71 //$scope.checkedFilter1.type.push({label: option_arr_1[1], id: option_arr_1[0]}); 72 } 73 } 74 //WPB-2705 75 if (custom_status_str) { 76 var option_arr = custom_status_str.split("^@^"); 77 for (x in option_arr) { 78 var option_str = option_arr[x]; 79 var option_arr_1 = option_str.split("^*^"); 80 $scope.checkListStatus.push({ 81 label: option_arr_1[1], //text 82 id: option_arr_1[0] //value 83 }); 84 } 85 } 86 87 if ($scope.wcdShortcodeType != "none") { 88 $scope.checkListType.forEach(function(element) { 89 if (element.id == $scope.wcdShortcodeType) { 90 $scope.checkedFilter.type.push(element); 91 return; 92 } 93 }); 94 } else { 95 $scope.checkListType.forEach(function(element) { 96 $scope.checkedFilter.type.push(element); 97 }); 98 } 99 100 $scope.example6settings = { 101 scrollableHeight: "500px", 102 scrollable: true, 103 checkBoxes: true, 104 styleActive: true, 105 enableSearch: true 106 }; 107 if (closing_per_page == 0) { 108 $scope.pageSize = 1000; 109 } else if (!closing_per_page) { 110 $scope.pageSize = 10; 111 } else { 112 $scope.pageSize = closing_per_page; 113 } 114 $scope.location=closing_location; 115 116 //https://makitweb.com/sort-the-table-on-header-click-using-angularjs/ 117 // column to sort 118 $scope.column = 'name'; 119 // sort ordering (Ascending or Descending). Set true for desending 120 $scope.reverse = false; 121 122 // called on header click 123 $scope.sortColumn = function(col){ 124 $scope.column = col; 125 if($scope.reverse){ 126 $scope.reverse = false;
127 $scope.reverseclass = 'arrow-up'; 128 }else{ 129 $scope.reverse = true; 130 $scope.reverseclass = 'arrow-down'; 131 } 132 }; 133 134 $scope.sortClass = function(col){ 135 if($scope.column == col ){ 136 if($scope.reverse){ 137 return 'arrow-down'; 138 }else{ 139 return 'arrow-up'; 140 } 141 }else{ 142 return ''; 143 } 144 }; 145 146 $scope.onSelect = function() { 147 $scope.progressMessage = "Loading..."; 148 $scope.progressStatus = true; 149 getListClosings(1); 150 }; 151 152 $scope.onSearch = function() { 153 $scope.progressMessage = "Loading..."; 154 $scope.progressStatus = true; 155 getListClosings(1); 156 }; 157 getListClosings($scope.pagination.current); 158 $scope.pageChangeHandler = function(newPage, oldPage) { 159 if ($scope.oldPage != newPage) { 160 $scope.progressMessage = "Loading..."; 161 $scope.progressStatus = true; 162 getListClosings(newPage); 163 window.scrollTo(0, 0); 164 } 165 }; 166 /*$scope.$watch('pagination.current', function(newPage) { 167 if($scope.oldPage != newPage){ 168 $scope.oldPage=newPage; 169 $scope.pagination.current=newPage; 170 getListClosings(newPage); 171 } 172 });*/ 173 function getListClosings(pageNumber) { 174 $scope.oldPage = pageNumber; 175 $scope.checkedCategory = []; 176 $scope.checkedFilter.type.forEach(function(element) { 177 $scope.checkedCategory.push(element.id); 178 }); 179 $http({ 180 url: "/wp-content/plugins/entity-closing-lite/post/list-front.php", 181 method: "POST", 182 data: { 183 chkClo : cl_wpb_key, 184 wpbCheck: "1", 185 wcdAlphabet: $scope.alphabetFilter, 186 wcdPageSize: $scope.pageSize, 187 wcdPagenumber: pageNumber, 188 wcdType: $scope.wcdShortcodeType, 189 wcdClosingType: $scope.checkedCategory, 190 wcdLocation: $scope.location 191 } 192 }).then( 193 function(data, status, headers, config) { 194 $scope.searchData = data.data.list; 195 $scope.searchData.forEach(function(element) { 196 if (element.status.length === 0) { 197 element.status = "Hide"; 198 } else if (element.status == "close") { 199 element.status = "Closed"; 200 } else if (element.status == "delay") { 201 element.status = "Delayed"; 202 } else if (element.status == "open") { 203 element.status = "Open"; 204 } else if (element.status == "canceled") { 205 element.status = "Canceled"; 206 } else if (element.status == "postponed") { 207 element.status = "Postponed"; 208 } else if (element.status == "cl_early") { 209 element.status = "Closing Early"; 210 } 211 else { //WPB-2705 -- custom stats. 212 for (x in $scope.checkListStatus) { 213 if ($scope.checkListStatus[x].id == element.status) { 214 element.status = $scope.checkListStatus[x].label; 215 } 216 } 217 } 218 219 if (element.type == "school") { 220 element.labelType = "School"; 221 } else if (element.type == "business") { 222 element.labelType = "Business"; 223 } else if (element.type == "civic-groups") { 224 element.labelType = "Civic Groups"; 225 } else if (element.type == "college-university") { 226 element.labelType = "College/University"; 227 } else if (element.type == "day-care") { 228 element.labelType = "Day Care"; 229 } else if (element.type == "government") { 230 element.labelType = "Government"; 231 } else if (element.type == "medical") { 232 element.labelType = "Medical"; 233 } else if (element.type == "other") { 234 element.labelType = "Other"; 235 } else if (element.type == "sporting-event") { 236 element.labelType = "Sporting Event"; 237 } else { 238 element.labelType = element.type; 239 //WD-1896 240 if (custom_type_str) { 241 var option_arr = custom_type_str.split("^@^"); 242 for (x in option_arr) { 243 var option_str = option_arr[x]; 244 var option_arr_1 = option_str.split("^*^"); 245 if (element.type == option_arr_1[0]) { 246 element.labelType = option_arr_1[1]; 247 } 248 } 249 } //End of if (custom_type_str) 250 } 251 }); 252 $scope.filterDataCount = data.data.count; 253 $scope.progressStatus = false;
254 }, 255 function errorCallback(response) { 256 //console.log(response); 257 } 258 ); 259 } 260 } 261 ]) 262 263 .filter("capitalize", function() { 264 return function(input) { 265 return !!input 266 ? input.charAt(0).toUpperCase() + input.substr(1).toLowerCase() 267 : ""; 268 }; 269 }); 270 271//***************************************************************** 272function myFunction() { 273 if (document.getElementById("myDropdown").style.display == 'none') 274 document.getElementById("myDropdown").style.display = 'block'; 275 else if (document.getElementById("myDropdown").style.display == 'block') 276 document.getElementById("myDropdown").style.display = 'none'; 277} 278 279function filterFunction() { 280 var input, filter, ul, li, a, i; 281 input = document.getElementById("myInput"); 282 filter = input.value.toUpperCase(); 283 div = document.getElementById("myDropdown"); 284 a = div.getElementsByTagName("a"); 285 for (i = 0; i < a.length; i++) { 286 txtValue = a[i].textContent || a[i].innerText; 287 if (txtValue.toUpperCase().indexOf(filter) > -1) { 288 a[i].style.display = ""; 289 } else { 290 a[i].style.display = "none"; 291 } 292 } 293} 294 295function capitalizeFirstLetter(string) { 296 return string.charAt(0).toUpperCase() + string.slice(1); 297} 298 299function chkCategoryCheckbox(chkObj) { 300 var totalCheckboxChecked = 0; 301 jQuery("input:checkbox[class=checkboxInput]:checked").each(function(){ 302 totalCheckboxChecked++; 303 }); 304 jQuery('#numberChecked').html(totalCheckboxChecked); 305} 306 307function selectAll() { 308 jQuery("input:checkbox[class=checkboxInput]").each(function(){ 309 this.checked = true; 310 }); 311} 312 313function deselectAll() { 314 jQuery("input:checkbox[class=checkboxInput]").each(function(){ 315 this.checked = false; 316 }); 317} 318 319jQuery(document).click(function(event) { 320 if ( jQuery(event.target).hasClass('dropbtn') || jQuery(event.target).hasClass('dropbtn_count') || jQuery(event.target).hasClass('checkboxInput') || jQuery(event.target).hasClass('chkLink') || jQuery(event.target).hasClass('chkLabel') || jQuery(event.target).hasClass('categorySearch') || jQuery(event.target).hasClass('ng-binding') || jQuery(event.target).hasClass('dashicons dashicons-yes') || jQuery(event.target).hasClass('dashicons dashicons-no') ) { 321 322 } 323 else { 324 jQuery("#myDropdown").hide(); 325 } 326}); 327 328function sortTable(n, thObj) { 329 var table, rows, switching, i, x, y, shouldSwitch, dir, switchcount = 0; 330 table = document.getElementById("myTableClosing"); 331 switching = true; 332 // Set the sorting direction to ascending: 333 dir = "asc"; 334 /* Make a loop that will continue until 335 no switching has been done: */ 336 while (switching) { 337 // Start by saying: no switching is done: 338 switching = false; 339 rows = table.rows; 340 /* Loop through all table rows (except the 341 first, which contains table headers): */ 342 for (i = 1; i < (rows.length - 1); i++) { 343 // Start by saying there should be no switching: 344 shouldSwitch = false; 345 /* Get the two elements you want to compare, 346 one from current row and one from the next: */ 347 x = rows[i].getElementsByTagName("TD")[n]; 348 y = rows[i + 1].getElementsByTagName("TD")[n]; 349 /* Check if the two rows should switch place, 350 based on the direction, asc or desc: */ 351 if (dir == "asc") { 352 if (x.innerHTML.toLowerCase() > y.innerHTML.toLowerCase()) { 353 // If so, mark as a switch and break the loop: 354 shouldSwitch = true; 355 break; 356 } 357 } else if (dir == "desc") { 358 if (x.innerHTML.toLowerCase() < y.innerHTML.toLowerCase()) { 359 // If so, mark as a switch and break the loop: 360 shouldSwitch = true; 361 break; 362 } 363 } 364 } 365 if (shouldSwitch) { 366 /* If a switch has been marked, make the switch 367 and mark that a switch has been done: */ 368 rows[i].parentNode.insertBefore(rows[i + 1], rows[i]); 369 switching = true; 370 // Each time a switch is done, increase this count by 1: 371 switchcount ++; 372 } else { 373 /* If no switching has been done AND the direction is "asc", 374 set the direction to "desc" and run the while loop again. */ 375 if (switchcount == 0 && dir == "asc") { 376 dir = "desc"; 377 switching = true; 378 } 379 } 380 } 381 382 if (dir == "asc") { 383 thObj.classList.remove("arrow-down"); 384 thObj.classList.add("arrow-up"); 385 } 386 else if (dir == "desc") { 387 thObj.classList.remove("arrow-up"); 388 thObj.classList.add("arrow-down"); 389 } 390} 391 392function removeIcons() { 393 jQuery('#myTableClosing > thead > tr > th').each(function(){ 394 this.classList.remove("arrow-up"); 395 this.classList.remove("arrow-down"); 396 }) 397} 398 399var $scope = {}; 400$scope.oldPage = 0; 401 402function sendClosingData(typeVal, location, pageNumber, flagBtn) { 403 $scope.alphabetFilter = "All"; //default 404 var alphabetFilter_value = jQuery('#start_from_drp').val();
405 if (alphabetFilter_value && alphabetFilter_value != 'undefined') { 406 //var tempArr = alphabetFilter_value.split(':'); 407 //$scope.alphabetFilter = tempArr[1]; 408 $scope.alphabetFilter = alphabetFilter_value.replace('string:',''); 409 } 410 411 if (closing_per_page == 0) { 412 $scope.pageSize = 1000; 413 } else if (!closing_per_page) { 414 $scope.pageSize = 10; 415 } else { 416 $scope.pageSize = closing_per_page; 417 } 418 if(location!='') 419 $scope.location = location; 420 //$scope.pageSize = 1; //temp check for 2 records , 1 per pages. 421 422 $scope.oldPage = pageNumber; 423 $scope.wcdShortcodeType = typeVal; 424 425 $scope.checkedCategory = []; 426 jQuery("input:checkbox[class=checkboxInput]:checked").each(function(){ 427 $scope.checkedCategory.push(jQuery(this).val()); 428 }); 429 430 // WPB-6212 -- added closing date to frontend. 431 jQuery('#searchData_closing').html('<div class="loading_front_closing" style="padding-top:20px;font-size:20px;">Loading closing list, please wait.....</div>'); 432 jQuery.ajax({ 433 type: 'POST', 434 //url: '/wp-content/plugins/entity-closing-lite/closing-ajax.php', 435 url: '/wp-content/plugins/entity-closing-lite/post/list-front.php', 436 data: { 437 chkClo : cl_wpb_key, 438 wpbCheck: "2", 439 closingFlag: 'ajax', // or angular if not pass. 440 //type: typeVal, 441 wcdAlphabet: $scope.alphabetFilter, 442 wcdPageSize: $scope.pageSize, 443 wcdPagenumber: pageNumber, 444 wcdType: $scope.wcdShortcodeType, 445 wcdClosingType: $scope.checkedCategory, 446 wcdLocation: $scope.location 447 } 448 }).done(function(data) { 449 //jQuery('#searchData_closing').html(dataHTML); //closing-ajax.php 450 var jsonData = jQuery.parseJSON(data); 451 var htmlTable = '<table id="myTableClosing" class="wcd-table-front-display table table-responsive table-bordered table-hover table-striped" style="margin-bottom:0px!important; margin-top: 10px;"><thead><tr class="info"><th class="col-xs-4 col-sm-4" style="cursor:pointer;" onclick="removeIcons(); sortTable(0, this);" id="thClosingName">Name</th> <th class="col-xs-2 col-sm-2" style="cursor:pointer;" onclick="removeIcons(); sortTable(1, this);">Type</th> <th class="col-xs-2 col-sm-2" style="cursor:pointer;" onclick="">Status</th> <th class="col-xs-2 col-sm-2" style="cursor:pointer;display:none;" onclick="">Location</th><th class="col-xs-4 col-sm-4">Comments</th> </tr> </thead> <tbody id="wcd-front-tbody"> '; 452 453 $scope.searchData = jsonData.list; 454 $scope.searchData.forEach(function(element) { 455 if(element.status=='cl_early') 456 element.status='Closing Early'; 457 458 if(element.status=='delay') 459 element.status='Delayed'; 460 461 if(element.status=='close') 462 element.status='Closed'; 463 464 htmlTable += '<tr><td>'+element.name+'</td><td>'+capitalizeFirstLetter(element.type)+'</td><td>'+capitalizeFirstLetter(element.status)+'</td><td style="display:none">'+capitalizeFirstLetter(element.location)+'</td><td>'+element.comments+'</td></tr>'; 465 }); 466 467 htmlTable += '</tbody> </table>'; 468 469 $scope.filterDataCount = jsonData.count; 470 if ($scope.filterDataCount > 0) { 471 if (closing_per_page > 0) { 472 var totalPages = Math.ceil( $scope.filterDataCount/ $scope.pageSize ); 473 var page_first = 1; 474 var page_prev = pageNumber > 1 ? pageNumber-1 : 1; 475 var page_next = pageNumber < totalPages ? pageNumber + 1 : ''; 476 var page_last = pageNumber < totalPages ? totalPages : ''; 477 478 var htmlPagination = '<div> </div> <div class="closingPaginationDiv">'; 479 480 if (pageNumber == 1) { 481 //donot show page numbers if only 1 page. 482 } 483 else { 484 htmlPagination += '<a href="javascript:void(0);" onclick="pageLink('+page_first+');">« First</a> '; 485 htmlPagination += '<a href="javascript:void(0);" onclick="pageLink('+page_prev+');">Prev</a> '; 486 } 487 488 if (totalPages <= 1) { 489 490 } 491 else { 492 for (i = 1; i <= totalPages; i++) { 493 var classSelected = ''; 494 if (i == pageNumber) { 495 classSelected = 'font-weight:bold;'; 496 } 497 htmlPagination += '<a style="'+classSelected+'" href="javascript:void(0);" onclick="pageLink('+i+');">'+i+'</a> '; 498 } 499 } 500 501 if (pageNumber == totalPages) { 502 503 } 504 else { 505 htmlPagination += '<a href="javascript:void(0);" onclick="pageLink('+page_next+');">Next</a> '; 506 htmlPagination += '<a href="javascript:void(0);" onclick="pageLink('+page_last+');">Last »</a> '; 507 } 508 509 htmlPagination += '</div>'; 510 } 511 else { 512 var htmlPagination = ''; 513 } 514
515 jQuery('#searchData_closing').html(htmlTable + htmlPagination); 516 sortTable(0, document.getElementById('thClosingName')); 517 } 518 else { 519 if (flagBtn == 'search_click') { 520 jQuery('#searchData_closing').html('<div class="alert alert-info" id="progress-msg-div-wcd-nodata"> <i class="fa fa-info-circle"></i> <span id="progress-msg-span-wcd-nodata">No closings found !</span> </div>'); 521 } 522 else { 523 jQuery('#searchData_closing').html('<div class="alert alert-info" id="progress-msg-div-wcd-nodata"> <i class="fa fa-info-circle"></i> <span id="progress-msg-span-wcd-nodata">No closings reported yet...</span> </div>'); 524 } 525 } 526 }); 527}//End of function sendClosingData 528//*****************************************************************
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.