1let showNotyMessage = true; 2 3$(document).ready(function() { 4 $('body').on('submit', '.form--cv', function(e) { 5 e.preventDefault(); 6 7 if (!saving) { 8 $(this).ajaxSubmit({ 9 url: templateDir + "/services/actors/services/save_cv.php", 10 dataType: 'JSON', 11 beforeSubmit: function(formData, formObject, formOptions) { 12 $(".form--cv :input").prop("disabled", true); 13 $(".form--cv button[type=submit]").addClass('button--withIcon').prepend('<i class="fas fa-spinner fa-spin"></i>'); 14 saving = true; 15 }, 16 success: function(res) { 17 $(".form--cv :input").prop("disabled", false); 18 $(".form--cv button[type=submit]").removeClass('button--withIcon').find('i').remove(); 19 saving = false; 20 21 if (res.errors) { 22 let errors = "<ul>"; 23 res.errors.map((error) => { errors += "<li>" + error + "</li>"; }); 24 errors += "</ul>"; 25 26 noty = new Noty({ 27 text: errors, 28 theme: "nest", 29 type: "error", 30 closeWith: ['click', 'button'], 31 killer: true 32 }).show(); 33 } else { 34 if (noty !== '') noty.close(); 35 36 $('.popup_list table tbody').html(''); 37 res.items.map((item, index)=>{ 38 $('.popup_list table tbody').append("<tr data-id='" + index + "'><td class='maxwidth'>" + item.cv_title + "</td><td class='hide-xs hide-sm'>" + item.cv_category + "</td><td class='hide-xs hide-sm'>" + item.cv_start + "</td><td width='25'><a href='#' class='edit_element'><i class='fal fa-edit'></i></a></td><td width='25'><a href='#' class='remove_element'><i class='far fa-trash-alt'></i></a></td></tr>"); 39 }); 40 41 $('.popup_tabs a[data-type=cv]').click(); 42 43 resetActorForm(); 44 updateActorPage(); 45 } 46 }, 47 error: function() { 48 $(".form--cv :input").prop("disabled", false); 49 $(".form--cv button[type=submit]").removeClass('button--withIcon').find('i').remove(); 50 saving = false; 51 52 noty = new Noty({ 53 text: "Er is iets fout gegaan.", 54 theme: "nest", 55 type: "error", 56 closeWith: ['click', 'button'], 57 killer: true 58 }).show(); 59 } 60 }); 61 } 62 }); 63 64 $('body').on('submit', '.form--update_cv', function(e) { 65 e.preventDefault(); 66 67 if (!saving) { 68 $(this).ajaxSubmit({ 69 url: templateDir + "/services/actors/services/save_cv.php", 70 dataType: 'JSON', 71 beforeSubmit: function(formData, formObject, formOptions) { 72 $(".form--update_cv :input").prop("disabled", true); 73 $(".form--update_cv button[type=submit]").addClass('button--withIcon').prepend('<i class="fas fa-spinner fa-spin"></i>'); 74 saving = true; 75 }, 76 success: function(res) { 77 $(".form--update_cv :input").prop("disabled", false); 78 $(".form--update_cv button[type=submit]").removeClass('button--withIcon').find('i').remove(); 79 saving = false; 80 81 if (res.errors) { 82 let errors = "<ul>"; 83 res.errors.map((error) => { errors += "<li>" + error + "</li>"; }); 84 errors += "</ul>"; 85 86 noty = new Noty({ 87 text: errors, 88 theme: "nest", 89 type: "error", 90 closeWith: ['click', 'button'], 91 killer: true 92 }).show(); 93 } else { 94 if (noty !== '') noty.close(); 95 96 $('.popup_list table tbody').html(''); 97 res.items.map((item, index)=>{ 98 $('.popup_list table tbody').append("<tr data-id='" + index + "'><td class='maxwidth'>" + item.cv_title + "</td><td class='hide-xs hide-sm'>" + item.cv_category + "</td><td class='hide-xs hide-sm'>" + item.cv_start + "</td><td width='25'><a href='#' class='edit_element'><i class='fal fa-edit'></i></a></td><td width='25'><a href='#' class='remove_element'><i class='far fa-trash-alt'></i></a></td></tr>"); 99 }); 100 101 $('.popup_tabs a[data-type=cv]').click(); 102 resetActorForm(); 103 updateActorPage(); 104 } 105 }, 106 error: function() { 107 $(".form--cv :input").prop("disabled", false); 108 $(".form--cv button[type=submit]").removeClass('button--withIcon').find('i').remove(); 109 saving = false;
110 111 noty = new Noty({ 112 text: "Er is iets fout gegaan.", 113 theme: "nest", 114 type: "error", 115 closeWith: ['click', 'button'], 116 killer: true 117 }).show(); 118 } 119 }); 120 } 121 }); 122 123 $('body').on('submit', '.form--main_cv', function(e) { 124 e.preventDefault(); 125 126 if (!saving) { 127 $(this).ajaxSubmit({ 128 url: templateDir + "/services/actors/services/save_cv_main.php", 129 dataType: 'JSON', 130 beforeSubmit: function(formData, formObject, formOptions) { 131 $(".form--main_cv :input").prop("disabled", true); 132 $(".form--main_cv button[type=submit]").addClass('button--withIcon').prepend('<i class="fas fa-spinner fa-spin"></i>'); 133 saving = true; 134 }, 135 success: function(res) { 136 $(".form--main_cv :input").prop("disabled", false); 137 $(".form--main_cv button[type=submit]").removeClass('button--withIcon').find('i').remove(); 138 saving = false; 139 140 if (res.errors) { 141 let errors = "<ul>"; 142 res.errors.map((error) => { errors += "<li>" + error + "</li>"; }); 143 errors += "</ul>"; 144 145 noty = new Noty({ 146 text: errors, 147 theme: "nest", 148 type: "error", 149 closeWith: ['click', 'button'], 150 killer: true 151 }).show(); 152 } else { 153 if (noty !== '') noty.close(); 154 noty = new Noty({ 155 text: "Je gegevens zijn aangepast.", 156 theme: "nest", 157 type: "success", 158 closeWith: ['click', 'button'], 159 killer: true 160 }).show(); 161 162 updateActorPage(); 163 } 164 }, 165 error: function() { 166 $(".form--main_cv :input").prop("disabled", false); 167 $(".form--main_cv button[type=submit]").removeClass('button--withIcon').find('i').remove(); 168 saving = false; 169 170 noty = new Noty({ 171 text: "Er is iets fout gegaan.", 172 theme: "nest", 173 type: "error", 174 closeWith: ['click', 'button'], 175 killer: true 176 }).show(); 177 } 178 }); 179 } 180 181 }); 182 183 $('body').on('submit', '.form--sizes_cv', function(e) { 184 e.preventDefault(); 185 186 if (!saving) { 187 $(this).ajaxSubmit({ 188 url: templateDir + "/services/actors/services/save_cv_sizes.php", 189 dataType: 'JSON', 190 beforeSubmit: function(formData, formObject, formOptions) { 191 $(".form--sizes_cv :input").prop("disabled", true); 192 $(".form--sizes_cv button[type=submit]").addClass('button--withIcon').prepend('<i class="fas fa-spinner fa-spin"></i>'); 193 saving = true; 194 }, 195 success: function(res) { 196 $(".form--sizes_cv :input").prop("disabled", false); 197 $(".form--sizes_cv button[type=submit]").removeClass('button--withIcon').find('i').remove(); 198 saving = false; 199 200 if (res.errors) { 201 let errors = "<ul>"; 202 res.errors.map((error) => { errors += "<li>" + error + "</li>"; }); 203 errors += "</ul>"; 204 205 noty = new Noty({ 206 text: errors, 207 theme: "nest", 208 type: "error", 209 closeWith: ['click', 'button'], 210 killer: true 211 }).show(); 212 } else { 213 if (noty !== '') noty.close(); 214 noty = new Noty({ 215 text: "Je maten zijn aangepast.", 216 theme: "nest", 217 type: "success", 218 closeWith: ['click', 'button'], 219 killer: true 220 }).show(); 221 222 updateActorPage(); 223 } 224 }, 225 error: function() { 226 $(".form--sizes_cv :input").prop("disabled", false); 227 $(".form--sizes_cv button[type=submit]").removeClass('button--withIcon').find('i').remove(); 228 saving = false; 229 230 noty = new Noty({ 231 text: "Er is iets fout gegaan.", 232 theme: "nest", 233 type: "error", 234 closeWith: ['click', 'button'], 235 killer: true 236 }).show(); 237 } 238 }); 239 } 240 241 }); 242 243 $('body').on('submit', '.form--specifications_cv', function(e) { 244 e.preventDefault(); 245 246 if (!saving) { 247 $(this).ajaxSubmit({ 248 url: templateDir + "/services/actors/services/save_cv_specifications.php", 249 dataType: 'JSON', 250 beforeSubmit: function(formData, formObject, formOptions) { 251 $(".form--specifications_cv :input").prop("disabled", true); 252 $(".form--specifications_cv button[type=submit]").addClass('button--withIcon').prepend('<i class="fas fa-spinner fa-spin"></i>'); 253 saving = true; 254 }, 255 success: function(res) { 256 $(".form--specifications_cv :input").prop("disabled", false); 257 $(".form--specifications_cv button[type=submit]").removeClass('button--withIcon').find('i').remove(); 258 saving = false;
259 260 if (res.errors) { 261 let errors = "<ul>"; 262 res.errors.map((error) => { errors += "<li>" + error + "</li>"; }); 263 errors += "</ul>"; 264 265 noty = new Noty({ 266 text: errors, 267 theme: "nest", 268 type: "error", 269 closeWith: ['click', 'button'], 270 killer: true 271 }).show(); 272 } else { 273 if (noty !== '') noty.close(); 274 console.log(showNotyMessage); 275 276 if (showNotyMessage) { 277 noty = new Noty({ 278 text: "Je specificaties zijn aangepast.", 279 theme: "nest", 280 type: "success", 281 closeWith: ['click', 'button'], 282 killer: true 283 }).show(); 284 } 285 286 showNotyMessage = true; 287 updateActorPage(); 288 } 289 }, 290 error: function() { 291 $(".form--specifications_cv :input").prop("disabled", false); 292 $(".form--specifications_cv button[type=submit]").removeClass('button--withIcon').find('i').remove(); 293 saving = false; 294 295 noty = new Noty({ 296 text: "Er is iets fout gegaan.", 297 theme: "nest", 298 type: "error", 299 closeWith: ['click', 'button'], 300 killer: true 301 }).show(); 302 } 303 }); 304 } 305 306 }); 307 308 $('body').on('submit', '.form--other_cv', function(e) { 309 e.preventDefault(); 310 311 if (!saving) { 312 $(this).ajaxSubmit({ 313 url: templateDir + "/services/actors/services/save_cv_other.php", 314 dataType: 'JSON', 315 beforeSubmit: function(formData, formObject, formOptions) { 316 $(".form--other_cv :input").prop("disabled", true); 317 $(".form--other_cv button[type=submit]").addClass('button--withIcon').prepend('<i class="fas fa-spinner fa-spin"></i>'); 318 saving = true; 319 }, 320 success: function(res) { 321 $(".form--other_cv :input").prop("disabled", false); 322 $(".form--other_cv button[type=submit]").removeClass('button--withIcon').find('i').remove(); 323 saving = false; 324 325 if (res.errors) { 326 let errors = "<ul>"; 327 res.errors.map((error) => { errors += "<li>" + error + "</li>"; }); 328 errors += "</ul>"; 329 330 noty = new Noty({ 331 text: errors, 332 theme: "nest", 333 type: "error", 334 closeWith: ['click', 'button'], 335 killer: true 336 }).show(); 337 } else { 338 if (noty !== '') noty.close(); 339 showPopup($(".form--other_cv input[name=actorid]").val(), 'other_cv'); 340 updateActorPage(); 341 } 342 }, 343 error: function() { 344 $(".form--other_cv :input").prop("disabled", false); 345 $(".form--other_cv button[type=submit]").removeClass('button--withIcon').find('i').remove(); 346 saving = false; 347 348 noty = new Noty({ 349 text: "Er is iets fout gegaan.", 350 theme: "nest", 351 type: "error", 352 closeWith: ['click', 'button'], 353 killer: true 354 }).show(); 355 } 356 }); 357 } 358 359 }); 360 361 $('body').on('submit', '.form--profile_description', function(e) { 362 e.preventDefault(); 363 364 if (!saving) { 365 $(this).ajaxSubmit({ 366 url: templateDir + "/services/actors/services/save_description.php", 367 dataType: 'JSON', 368 beforeSubmit: function(formData, formObject, formOptions) { 369 $(".form--profile_description :input").prop("disabled", true); 370 $(".form--profile_description button[type=submit]").addClass('button--withIcon').prepend('<i class="fas fa-spinner fa-spin"></i>'); 371 saving = true; 372 }, 373 success: function(res) { 374 $(".form--profile_description :input").prop("disabled", false); 375 $(".form--profile_description button[type=submit]").removeClass('button--withIcon').find('i').remove(); 376 saving = false; 377 378 if (res.errors) { 379 let errors = "<ul>"; 380 res.errors.map((error) => { errors += "<li>" + error + "</li>"; }); 381 errors += "</ul>"; 382 383 noty = new Noty({ 384 text: errors, 385 theme: "nest", 386 type: "error", 387 closeWith: ['click', 'button'], 388 killer: true 389 }).show(); 390 } else { 391 if (noty !== "") noty.close(); 392 393 noty = new Noty({ 394 text: "De omschrijving is opgeslagen.", 395 theme: "nest", 396 type: "success", 397 closeWith: ['click', 'button'], 398 killer: true, 399 timeout: 3000 400 }).show(); 401 402 updateActorPage(); 403 } 404 }, 405 error: function() { 406 $(".form--profile_description :input").prop("disabled", false); 407 $(".form--profile_description button[type=submit]").removeClass('button--withIcon').find('i').remove(); 408 saving = false;
409 410 noty = new Noty({ 411 text: "Er is iets fout gegaan.", 412 theme: "nest", 413 type: "error", 414 closeWith: ['click', 'button'], 415 killer: true 416 }).show(); 417 } 418 }); 419 } 420 }); 421}); 422 423function cvActions() { 424 if ($('.tab.cv').length === 1) { 425 $('.custom_fields button').on('click', function(e) { 426 e.preventDefault(); 427 if (noty !== '') noty.close(); 428 const fieldDescription = $(this).closest('.custom_fields').find('.cv_desc').val(); 429 const fieldContent = $(this).closest('.custom_fields').find('.cv_cnt').val(); 430 431 if (fieldDescription !== '' && fieldContent !== '') { 432 let fields = $(this).closest('.custom_fields').find('input[name=cv_custom]').val() === '' ? [] : JSON.parse($(this).closest('.custom_fields').find('input[name=cv_custom]').val()); 433 fields.push({ desc: fieldDescription, cnt: fieldContent }); 434 $(this).closest('.custom_fields').find('input[name=cv_custom]').val(JSON.stringify(fields)); 435 436 $(this).closest('.custom_fields').find('.cv_desc').val(''); 437 $(this).closest('.custom_fields').find('.cv_cnt').val(''); 438 439 $(this).closest('.custom_fields').find('.custom_field_rows').html(''); 440 fields.map((field, index) => { 441 $(this).closest('.custom_fields').find('.custom_field_rows').append("<div class='row' data-id='" + index + "'><span>" + field.desc + "</span><span>" + field.cnt + " <a href='#' class='remove_custom'>x</a></span></div>"); 442 }); 443 444 } else { 445 noty = new Noty({ 446 text: "Voer een omschrijving en de inhoud van het eigen veld in.", 447 theme: "nest", 448 type: "error", 449 closeWith: ['click', 'button'], 450 killer: true, 451 timeout: 3500 452 }).show(); 453 } 454 }); 455 456 $('.custom_fields').on('click', '.row .remove_custom', function(e) { 457 e.preventDefault(); 458 const index = $(this).closest('.row').attr('data-id'); 459 const customFieldsObj = $(this).closest('.custom_fields') 460 let fields = customFieldsObj.find('input[name=cv_custom]').val() === '' ? [] : JSON.parse(customFieldsObj.find('input[name=cv_custom]').val()); 461 $(this).closest('.row').remove(); 462 463 fields.splice(index, 1); 464 465 customFieldsObj.find('.custom_field_rows').html(''); 466 fields.map((field, index) => { 467 customFieldsObj.find('.custom_field_rows').append("<div class='row' data-id='" + index + "'><span>" + field.desc + "</span><span>" + field.cnt + " <a href='#' class='remove_custom'>x</a></span></div>"); 468 }); 469 470 customFieldsObj.find('input[name=cv_custom]').val(fields.length > 0 ? JSON.stringify(fields) : ''); 471 }); 472 473 $('.tab.cv').on('click', 'a.remove_element', function(e) { 474 e.preventDefault(); 475 const index = $(this).closest('tr').attr('data-id'); 476 477 noty = new Noty({ 478 text: "Weet je zeker dat je dit cv-item wil verwijderen?", 479 theme: "nest", 480 type: "error", 481 closeWith: ['click', 'button'], 482 killer: true, 483 buttons: [ 484 Noty.button('OK', 'button button--small button--autowidth', function () { 485 removeCv(index); 486 noty.close(); 487 }, {id: 'button1', 'data-status': 'ok'}), 488 489 Noty.button('Annuleren', 'button button--small button--text button--autowidth', function () { 490 noty.close(); 491 }) 492 ] 493 }).show(); 494 }); 495 496 $('.tab.cv').on('click', 'a.edit_element', function(e) { 497 e.preventDefault(); 498 const index = $(this).closest('tr').attr('data-id'); 499 const actorid = $('.popup input[name=actorid]').val(); 500 501 $.ajax({ 502 url: templateDir + "/services/actors/services/mutate_cv.php", 503 method: 'POST', 504 dataType: "JSON", 505 data: { 506 type: 'load', 507 actorid: actorid, 508 cv_index: index 509 }, 510 success: function(res) { 511 if (res.cv) { 512 $('.popup_tabs a[data-type=edit_cv]').click(); 513 $('.tab.edit_cv input[name=cv_title]').val(res.cv.cv_title); 514 $('.tab.edit_cv select[name=cv_category]').val(res.cv.cv_category); 515 $('.tab.edit_cv select[name=cv_start]').val(res.cv.cv_start); 516 $('.tab.edit_cv select[name=cv_end]').val(res.cv.cv_end); 517 $('.tab.edit_cv input[name=cv_custom]').val(res.cv.cv_custom); 518 $('.tab.edit_cv input[name=cvid]').val(index); 519 520 if (res.cv.cv_custom !== '') { 521 let fields = JSON.parse(res.cv.cv_custom); 522 $('.tab.edit_cv .custom_field_rows').html(''); 523 fields.map((field, index) => { 524 $('.tab.edit_cv .custom_field_rows').append("<div class='row' data-id='" + index + "'><span>" + field.desc + "</span><span>" + field.cnt + " <a href='#' class='remove_custom'>x</a></span></div>"); 525 }); 526 } 527 } 528 } 529 }); 530 }); 531 532 $('.tab.specifications_cv').on('change', '.select2', function(e) { 533 showNotyMessage = false;
534 $(this).closest('form').submit(); 535 }); 536 537 $('.tab.specifications_cv').on('blur', 'input[name=user_hair_color], input[name=user_eyes_color]', function(e) { 538 showNotyMessage = false; 539 $(this).closest('form').submit(); 540 }); 541 542 $('.tab.specifications_cv').on('change', '.form_checkboxes input[type=checkbox]', function(e) { 543 showNotyMessage = false; 544 $(this).closest('form').submit(); 545 const custForm = $(this).closest('.form_row').find('.form--other_cv'); 546 const select = custForm.find('select'); 547 select.html('<option value="">Maak een keuze</option>'); 548 549 if ($(this).closest('.form_row').find('input[type=checkbox]:checked').length > 0) { 550 $(this).closest('.form_row').find('input[type=checkbox]:checked').each(function() { 551 select.append("<option value='" + $(this).attr('value') + "'>" + $(this).attr('value') + "</option>"); 552 }) 553 custForm.removeClass('hide'); 554 } else { 555 custForm.addClass('hide'); 556 } 557 558 if (!$(this).prop('checked')) { 559 const actorid = $('.popup input[name=actorid]').val(); 560 const field = custForm.closest('.form_row'); 561 const sublevel = $(this).val(); 562 563 $.ajax({ 564 url: templateDir + "/services/actors/services/remove_custom_cv_specifications.php", 565 method: 'POST', 566 dataType: "JSON", 567 data: { 568 value: sublevel, 569 actorid: actorid, 570 field: field.data('key') 571 }, 572 success: function(res) { 573 if (res) { 574 const table = field.find('.popup_list table'); 575 576 table.find('tbody tr').each(function() { 577 if ($(this).data('sub_level') === sublevel) { 578 $(this).remove(); 579 } 580 }); 581 582 if (table.find('tbody tr').length === 0) { 583 table.closest('.popup_list').addClass('hide'); 584 }; 585 } 586 } 587 }); 588 } 589 }); 590 591 $('.tab.specifications_cv').on('click', '.form--other_cv .button--save', function(e) { 592 e.preventDefault(); 593 const form = $(this).closest('.form--other_cv') 594 const formfield = form.find('input'); 595 const value = formfield.val(); 596 const sublevel = form.find('select').length === 1 ? form.find('select').val() : ''; 597 const actorid = $('.popup input[name=actorid]').val(); 598 const field = form.closest('.form_row').data('key'); 599 600 if (value !== '') { 601 $.ajax({ 602 url: templateDir + "/services/actors/services/add_custom_cv_specification.php", 603 method: 'POST', 604 dataType: "JSON", 605 data: { 606 value: value, 607 sub_level: sublevel, 608 actorid: actorid, 609 field: field 610 }, 611 success: function(res) { 612 if (res) { 613 formfield.val(''); 614 if (form.find('select').length === 1) form.find('select').val(''); 615 616 const table = form.closest('.form_row').find('.popup_list table'); 617 if (table.length === 1) { 618 table.closest('.popup_list').removeClass('hide'); 619 if (sublevel !== '') { 620 table.find('tbody').append('<tr data-id="' + table.find('tbody tr').length + '" data-field="' + field + '" data-sub_level="' + sublevel + '" data-value="' + value +'"><td class="maxwidth"><span style="height:auto">' + value + '</span></td><td>' + sublevel + '</td><td width="25"><a href="#" class="remove_custom_spec"><i class="far fa-trash-alt"></i></a></td></tr>'); 621 } else { 622 table.find('tbody').append('<tr data-id="' + table.find('tbody tr').length + '" data-field="' + field + '" data-sub_level="" data-value="' + value +'"><td class="maxwidth"><span style="height:auto">' + value + '</span></td><td width="25"><a href="#" class="remove_custom_spec"><i class="far fa-trash-alt"></i></a></td></tr>'); 623 } 624 } 625 } 626 } 627 }); 628 } 629 }); 630 631 $('.tab.specifications_cv').on('click', '.remove_custom_spec', function(e) { 632 e.preventDefault(); 633 const row = $(this).closest('tr'); 634 const id = row.data('id'); 635 const field = row.data('field'); 636 const sublevel = row.data('sub_level'); 637 const value = row.data('value');
638 const actorid = $('.popup input[name=actorid]').val(); 639 640 $.ajax({ 641 url: templateDir + "/services/actors/services/remove_custom_cv_specification.php", 642 method: 'POST', 643 dataType: "JSON", 644 data: { 645 id: id, 646 field: field, 647 sublevel: sublevel, 648 value: value, 649 actorid: actorid 650 }, 651 success: function(res) { 652 if (res) { 653 if (row.closest('tbody').find('tr').length <= 1) row.closest('.popup_list').addClass('hide'); 654 row.remove(); 655 } 656 } 657 }); 658 }); 659 660 function removeCv(index) { 661 const actorid = $('.popup input[name=actorid]').val(); 662 663 $.ajax({ 664 url: templateDir + "/services/actors/services/mutate_cv.php", 665 method: 'POST', 666 dataType: "JSON", 667 data: { 668 type: 'delete', 669 actorid: actorid, 670 cv_index: index 671 }, 672 success: function(res) { 673 674 if (res.errors) { 675 676 } else if (res.items.length == 0) { 677 $('.popup_list table tbody').html("<tr><td colspan='4' class='empty_row'>Er zijn nog geen cv-items toegevoegd.</td></tr>"); 678 } else { 679 $('.popup_list table tbody').html(''); 680 res.items.map((item, index)=>{ 681 $('.popup_list table tbody').append("<tr data-id='" + index + "'><td>" + item.cv_title + "</td><td>" + item.cv_category + "</td><td>" + item.cv_start + "</td><td width='25'><a href='#' class='edit_element'><i class='fal fa-edit'></i></a></td><td width='25'><a href='#' class='remove_element'><i class='far fa-trash-alt'></i></a></td></tr>"); 682 }); 683 } 684 685 updateActorPage(); 686 } 687 }); 688 } 689 } 690 691 if ($('.tab.other_cv').length === 1) { 692 $('.tab.other_cv').on('click', 'a.remove_other_cv', function(e) { 693 e.preventDefault(); 694 const index = $(this).closest('tr').index(); 695 696 noty = new Noty({ 697 text: "Weet je zeker dat je dit cv-item wil verwijderen?", 698 theme: "nest", 699 type: "error", 700 closeWith: ['click', 'button'], 701 killer: true, 702 buttons: [ 703 Noty.button('OK', 'button button--small button--autowidth', function () { 704 removeCvOther(index); 705 noty.close(); 706 }, {id: 'button1', 'data-status': 'ok'}), 707 708 Noty.button('Annuleren', 'button button--small button--text button--autowidth', function () { 709 noty.close(); 710 }) 711 ] 712 }).show(); 713 }); 714 715 function removeCvOther(index) { 716 const actorid = $('.popup input[name=actorid]').val(); 717 718 $.ajax({ 719 url: templateDir + "/services/actors/services/mutate_cv_other.php", 720 method: 'POST', 721 dataType: "JSON", 722 data: { 723 type : 'delete', 724 actorid : actorid, 725 cv_other_index : index 726 }, 727 success: function(res) { 728 if (res.errors) { 729 730 } else { 731 showPopup($(".form--other_cv input[name=actorid]").val(), 'other_cv'); 732 } 733 734 updateActorPage(); 735 } 736 }); 737 } 738 } 739 740 if ($('.form--download_cv').length === 1) { 741 $('.form--download_cv input[type=checkbox]').on('change', function(e) { 742 // console.log('change'); 743 if ($(this).attr('name') === 'cv_categories[]') { 744 if ($(this).prop('checked')) { 745 $(this).closest('li').find('ul input[type=checkbox]').prop('checked', true); 746 } else { 747 $(this).closest('li').find('ul input[type=checkbox]').prop('checked', false); 748 } 749 } else { 750 if ($(this).prop('checked')) { 751 $(this).closest('ul').closest('li').find('> label input[type=checkbox]').prop('checked', true); 752 } else { 753 const numChecked = $(this).closest('ul').find('input[type=checkbox]:checked').length; 754 755 if (numChecked === 0) { 756 $(this).closest('ul').closest('li').find('> label input[type=checkbox]').prop('checked', false); 757 } else if (numChecked > 0) { 758 $(this).closest('ul').closest('li').find('> label input[type=checkbox]').prop('checked', true); 759 } 760 } 761 } 762 }); 763 764 $('.form--download_cv').on('submit', function(e) { 765 e.preventDefault(); 766 const actorid = $(this).find('input[name=actorid]').val(); 767 let categories = []; 768 let items = []; 769 $(this).find('input[type=checkbox]').each(function() { 770 if ($(this).prop('checked') && $(this).attr('name') == 'cv_categories[]') { 771 categories.push($(this).val()); 772 } else if ($(this).prop('checked') && $(this).attr('name') == 'cv_items[]') { 773 items.push($(this).val()); 774 } 775 }); 776 777 const that = $(this); 778 779 if (!saving) { 780 $.ajax({ 781 url: templateDir + '/services/actors/downloadCV.php', 782 dataType: "JSON", 783 method: "POST", 784 beforeSend: function() { 785 that.find('button[type=submit] i').remove(); 786 that.find('button[type=submit]').addClass('button--withIcon').prepend('<i class="fas fa-spinner fa-spin"></i>'); 787 saving = true; 788 }, 789 data: { 790 actorid: actorid, 791 categories: categories, 792 items: items 793 } 794 }).done(function(res) { 795 pdfMake.fonts = { 796 Poppins: { 797 normal: 'Poppins-Regular.ttf', 798 bold: 'Poppins-Medium.ttf', 799 italics: 'Poppins-Italic.ttf', 800 bolditalics: 'Poppins-MediumItalic.ttf' 801 } 802 } 803 804 let docDefinition = { 805 pageMargins: [ 25, 50, 25, 100 ], 806 defaultStyle: { 807 font: 'Poppins', 808 fontSize: 12, 809 color:"#000", 810 lineGap: 21, 811 paragraphGap: 5 812 }, 813 header: function(currentPage, pageCount, pageSize) { 814 return { canvas: [{ type: 'line', x1: 0, y1: 0, x2: 595.28, y2: 0, lineWidth: 10, lineColor: '#236FA8' }] } 815 }, 816 footer: function(currentPage, pageCount) { 817 const url = res.actor_url.replace('https://','').replace('http://',''); 818 819 return { stack: [ 820 { text: 'Kijk voor meer informatie over ' + res.actor + ' op', fontSize:10, alignment:'center',margin:[0,45,0,0] }, 821 { text: url.substring(0, url.length - 1), fontSize:10, alignment:'center' }, 822 { canvas: [{ type: 'line', x1: 0, y1: 25, x2: 595.28, y2:25, lineWidth: 5, lineColor: '#236FA8' }] } 823 ]}; 824 }, 825 content: res.content, 826 styles: { 827 h1: { fontSize: 22, alignment: 'center', color: '#236FA8', margin: [ 0, -30, 0, 10 ], font: 'Poppins', bold: true }, 828 h2: { fontSize: 16, color: '#000000', font: 'Poppins', bold: true }, 829 h3: { fontSize: 14, color: '#236FA8', font: 'Poppins', bold: true }, 830 grey_txt: { color: '#999999' } 831 } 832 }; 833
834 const pdfDocGenerator = pdfMake.createPdf(docDefinition); 835 pdfDocGenerator.download(res.filename); 836 saving = false; 837 removePopup(); 838 }); 839 } 840 }); 841 } 842}
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.