| 1 |
jQuery( document ).ready( |
| 2 |
function ($) { |
| 3 |
'use strict'; |
| 4 |
|
| 5 |
var log_refresh_interval; |
| 6 |
var log_refresh_interval_per_item; |
| 7 |
var timer = 2000; |
| 8 |
var timer_per_item = 4000; |
| 9 |
|
| 10 |
if (jQuery( '#nav-tab-import' ).hasClass( 'nav-tab-active' )) { |
| 11 |
log_refresh_interval = setInterval( mlsimport_log_interval, timer ); |
| 12 |
} |
| 13 |
|
| 14 |
if (jQuery( '#mlsimport-start_item' ).length > 0) { |
| 15 |
log_refresh_interval_per_item = setInterval( mlsimport_log_interval_per_item, timer_per_item ); |
| 16 |
} |
| 17 |
|
| 18 |
//mlsimport_autocomplte_mls_selection(); |
| 19 |
/** |
| 20 |
* Show / hide extra input field - cities and counties |
| 21 |
*/ |
| 22 |
|
| 23 |
mslimport_show_extra_options(); |
| 24 |
|
| 25 |
/** |
| 26 |
* Show / hide input tokens on load |
| 27 |
*/ |
| 28 |
mlsimport_token_on_load(); |
| 29 |
|
| 30 |
/** |
| 31 |
* Show / hide input tokens on change |
| 32 |
*/ |
| 33 |
|
| 34 |
jQuery( '#mlsimport_mls_name' ).on( |
| 35 |
'change', |
| 36 |
function (event) { |
| 37 |
|
| 38 |
var selected_value = jQuery( '#mlsimport_mls_name' ).val(); |
| 39 |
selected_value = parseInt( selected_value ); |
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
if (selected_value >= 7000) { |
| 44 |
|
| 45 |
jQuery( '.fieldset_mlsimport_mls_token' ).hide(); |
| 46 |
jQuery( '.fieldset_mlsimport_tresle_client_id, .fieldset_mlsimport_tresle_client_secret' ).hide(); |
| 47 |
jQuery( '.fieldset_mlsimport_rapattoni_client_id,.fieldset_mlsimport_rapattoni_client_secret,.fieldset_mlsimport_rapattoni_username,.fieldset_mlsimport_rapattoni_password ' ).hide(); |
| 48 |
jQuery( '.fieldset_mlsimport_paragon_client_id, .fieldset_mlsimport_paragon_client_secret' ).hide(); |
| 49 |
jQuery( '.fieldset_mlsimport_realtorca_client_id, .fieldset_mlsimport_realtorca_client_secret' ).show(); |
| 50 |
}else if (selected_value >= 6000) { |
| 51 |
|
| 52 |
jQuery( '.fieldset_mlsimport_mls_token' ).hide(); |
| 53 |
jQuery( '.fieldset_mlsimport_tresle_client_id, .fieldset_mlsimport_tresle_client_secret' ).hide(); |
| 54 |
jQuery( '.fieldset_mlsimport_rapattoni_client_id,.fieldset_mlsimport_rapattoni_client_secret,.fieldset_mlsimport_rapattoni_username,.fieldset_mlsimport_rapattoni_password ' ).hide(); |
| 55 |
jQuery( '.fieldset_mlsimport_paragon_client_id, .fieldset_mlsimport_paragon_client_secret' ).show(); |
| 56 |
jQuery( '.fieldset_mlsimport_realtorca_client_id, .fieldset_mlsimport_realtorca_client_secret' ).hide(); |
| 57 |
} else if ( selected_value > 5000) { |
| 58 |
|
| 59 |
jQuery( '.fieldset_mlsimport_mls_token' ).hide(); |
| 60 |
jQuery( '.fieldset_mlsimport_tresle_client_id,.fieldset_mlsimport_tresle_client_secret' ).hide(); |
| 61 |
jQuery( '.fieldset_mlsimport_rapattoni_client_id,.fieldset_mlsimport_rapattoni_client_secret,.fieldset_mlsimport_rapattoni_username,.fieldset_mlsimport_rapattoni_password ' ).show(); |
| 62 |
jQuery( '.fieldset_mlsimport_paragon_client_id, .fieldset_mlsimport_paragon_client_secret' ).hide(); |
| 63 |
jQuery( '.fieldset_mlsimport_realtorca_client_id, .fieldset_mlsimport_realtorca_client_secret' ).hide(); |
| 64 |
} else if ( selected_value > 900 && selected_value < 3000) { |
| 65 |
|
| 66 |
jQuery( '.fieldset_mlsimport_mls_token' ).hide(); |
| 67 |
jQuery( '.fieldset_mlsimport_rapattoni_client_id,.fieldset_mlsimport_rapattoni_client_secret,.fieldset_mlsimport_rapattoni_username,.fieldset_mlsimport_rapattoni_password ' ).hide(); |
| 68 |
jQuery( '.fieldset_mlsimport_paragon_client_id, .fieldset_mlsimport_paragon_client_secret' ).hide(); |
| 69 |
jQuery( '.fieldset_mlsimport_realtorca_client_id, .fieldset_mlsimport_realtorca_client_secret' ).hide(); |
| 70 |
|
| 71 |
jQuery( '.fieldset_mlsimport_tresle_client_id' ).show(); |
| 72 |
jQuery( '.fieldset_mlsimport_tresle_client_secret' ).show(); |
| 73 |
} else { |
| 74 |
|
| 75 |
jQuery( '.fieldset_mlsimport_mls_token' ).show(); |
| 76 |
jQuery( '.fieldset_mlsimport_rapattoni_client_id,.fieldset_mlsimport_rapattoni_client_secret,.fieldset_mlsimport_rapattoni_username,.fieldset_mlsimport_rapattoni_password ' ).hide(); |
| 77 |
jQuery( '.fieldset_mlsimport_paragon_client_id, .fieldset_mlsimport_paragon_client_secret' ).hide(); |
| 78 |
jQuery( '.fieldset_mlsimport_realtorca_client_id, .fieldset_mlsimport_realtorca_client_secret' ).hide(); |
| 79 |
|
| 80 |
jQuery( '.fieldset_mlsimport_tresle_client_id' ).hide(); |
| 81 |
jQuery( '.fieldset_mlsimport_tresle_client_secret' ).hide(); |
| 82 |
} |
| 83 |
|
| 84 |
} |
| 85 |
); |
| 86 |
|
| 87 |
/** |
| 88 |
* Stop Import per item |
| 89 |
*/ |
| 90 |
|
| 91 |
jQuery( '#mlsimport_stop_item' ).on( |
| 92 |
'click', |
| 93 |
function () { |
| 94 |
console.log( 'mlsimport-stop' ); |
| 95 |
var post_id = jQuery( this ).attr( 'data-post_id' ); |
| 96 |
var nonce = jQuery('#mlsimport_item_actions').val(); |
| 97 |
// stop refreshing logs immediately on the client side |
| 98 |
if (typeof log_refresh_interval_per_item !== 'undefined') { |
| 99 |
clearInterval( log_refresh_interval_per_item ); |
| 100 |
} |
| 101 |
jQuery.ajax( |
| 102 |
{ |
| 103 |
type: 'POST', |
| 104 |
url: ajaxurl, |
| 105 |
data: { |
| 106 |
'action' : 'mlsimport_stop_import_per_item', |
| 107 |
'post_id' : post_id, |
| 108 |
'security' : nonce |
| 109 |
|
| 110 |
}, |
| 111 |
success: function (data) { |
| 112 |
console.log( data ); |
| 113 |
jQuery( '#mlsimport_item_status' ).empty().append( 'Stopping import...' ); |
| 114 |
}, |
| 115 |
error: function (errorThrown) { |
| 116 |
console.log( errorThrown ); |
| 117 |
} |
| 118 |
} |
| 119 |
);// end ajax |
| 120 |
} |
| 121 |
); |
| 122 |
|
| 123 |
/** |
| 124 |
* Start Import per item |
| 125 |
*/ |
| 126 |
|
| 127 |
jQuery( '#mlsimport-start_item,#mlsimport-run-test' ).on( |
| 128 |
'click', |
| 129 |
function (event) { |
| 130 |
console.log( 'mlsimport-start' ); |
| 131 |
var ajaxurl = mlsimport_vars.ajax_url; |
| 132 |
var post_id = jQuery( this ).attr( 'data-post_id' ); |
| 133 |
var post_number = jQuery( this ).attr( 'data-post-number' ); |
| 134 |
var how_many = jQuery( '#mlsimport_item_how_many' ).val(); |
| 135 |
var is_onboard = 0; |
| 136 |
var nonce = jQuery('#mlsimport_item_actions').val(); |
| 137 |
jQuery( '#mlsimport_item_status' ).empty(); |
| 138 |
jQuery( '#mlsimport_item_status' ).append( "Starting the import. Please stand by!" ); |
| 139 |
|
| 140 |
|
| 141 |
if (event.target.id === 'mlsimport-run-test') { |
| 142 |
// Do something only when #mlsimport-run-test is clicked |
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
jQuery(this).prop('disabled', true); |
| 147 |
jQuery('#mlsimport-test-spinner').show(); |
| 148 |
jQuery('.mlsimport-status-message') |
| 149 |
.removeClass('pending') |
| 150 |
.addClass('progress') |
| 151 |
.html('<p><?php _e("Starting import... Please wait.", "mlsimport"); ?></p>' + |
| 152 |
'<div class="mlsimport-progress-bar"><div class="mlsimport-progress-bar-inner" style="width: 20%"></div></div>'); |
| 153 |
|
| 154 |
how_many=5; |
| 155 |
is_onboard=1; |
| 156 |
|
| 157 |
|
| 158 |
} else { |
| 159 |
// Handle #mlsimport-start_item click |
| 160 |
console.log('Start item clicked'); |
| 161 |
} |
| 162 |
|
| 163 |
|
| 164 |
|
| 165 |
|
| 166 |
clearInterval( log_refresh_interval_per_item ); |
| 167 |
log_refresh_interval_per_item = setInterval( mlsimport_log_interval_per_item, timer_per_item ); |
| 168 |
|
| 169 |
|
| 170 |
jQuery.ajax( |
| 171 |
{ |
| 172 |
type: 'POST', |
| 173 |
url: ajaxurl, |
| 174 |
data: { |
| 175 |
'action' : 'mlsimport_move_files_per_item', |
| 176 |
'post_id' : post_id, |
| 177 |
'how_many' : how_many, |
| 178 |
'post_number' : post_number, |
| 179 |
'is_onboard' : is_onboard, |
| 180 |
'security' : nonce, |
| 181 |
}, |
| 182 |
success: function (data) { |
| 183 |
console.log( data ); |
| 184 |
|
| 185 |
}, |
| 186 |
error: function (errorThrown) { |
| 187 |
console.log( errorThrown ); |
| 188 |
} |
| 189 |
} |
| 190 |
);// end ajax |
| 191 |
|
| 192 |
} |
| 193 |
); |
| 194 |
|
| 195 |
/** |
| 196 |
* delete cache |
| 197 |
*/ |
| 198 |
|
| 199 |
jQuery( '#mlsimport-clear-cache' ).on( |
| 200 |
'click', |
| 201 |
function () { |
| 202 |
var ajaxurl = mlsimport_vars.ajax_url; |
| 203 |
var nonce = jQuery('#mlsimport_tool_actions').val(); |
| 204 |
|
| 205 |
jQuery( '#mlsimport-clear-cache' ).val( 'Deleting...' ); |
| 206 |
|
| 207 |
jQuery.ajax( |
| 208 |
{ |
| 209 |
type: 'POST', |
| 210 |
url: ajaxurl, |
| 211 |
data: { |
| 212 |
'action' : 'mlsimport_delete_cache', |
| 213 |
'security' : nonce |
| 214 |
}, |
| 215 |
success: function (data) { |
| 216 |
console.log( data ); |
| 217 |
jQuery( '#mlsimport-clear-cache' ).val( 'Deleted!' ); |
| 218 |
|
| 219 |
}, |
| 220 |
error: function (errorThrown) { |
| 221 |
console.log( errorThrown ); |
| 222 |
} |
| 223 |
} |
| 224 |
);// end ajax |
| 225 |
} |
| 226 |
); |
| 227 |
|
| 228 |
jQuery( '#mlsimport-clear-fields-data' ).on( |
| 229 |
'click', |
| 230 |
function () { |
| 231 |
var ajaxurl = mlsimport_vars.ajax_url; |
| 232 |
var nonce = jQuery('#mlsimport_tool_actions').val(); |
| 233 |
|
| 234 |
jQuery( '#mlsimport-clear-fields-data' ).val( 'Deleting...' ); |
| 235 |
|
| 236 |
jQuery.ajax( |
| 237 |
{ |
| 238 |
type: 'POST', |
| 239 |
url: ajaxurl, |
| 240 |
data: { |
| 241 |
'action' : 'mlsimport_clear_fields_data', |
| 242 |
'security' : nonce |
| 243 |
}, |
| 244 |
success: function (data) { |
| 245 |
console.log( data ); |
| 246 |
jQuery( '#mlsimport-clear-fields-data' ).val( 'Deleted!' ); |
| 247 |
|
| 248 |
}, |
| 249 |
error: function (errorThrown) { |
| 250 |
console.log( errorThrown ); |
| 251 |
} |
| 252 |
} |
| 253 |
);// end ajax |
| 254 |
} |
| 255 |
); |
| 256 |
|
| 257 |
/** |
| 258 |
* delete properties |
| 259 |
*/ |
| 260 |
|
| 261 |
jQuery( '#mlsimport-delete-prop' ).on( |
| 262 |
'click', |
| 263 |
function () { |
| 264 |
var ajaxurl = mlsimport_vars.ajax_url; |
| 265 |
|
| 266 |
var mlsimport_delete_category = jQuery( '#mlsimport_delete_category' ).val(); |
| 267 |
var mlsimport_delete_category_term = jQuery( '#mlsimport_delete_category_term' ).val(); |
| 268 |
var mlsimport_delete_timeout = jQuery( '#mlsimport_delete_timeout' ).val(); |
| 269 |
var nonce = jQuery('#mlsimport_tool_actions').val(); |
| 270 |
|
| 271 |
if (mlsimport_delete_category === '') { |
| 272 |
jQuery( '#mlsimport-delete-notification' ).text( 'Please add the category ' ); |
| 273 |
return; |
| 274 |
} |
| 275 |
if (mlsimport_delete_category_term === '' ) { |
| 276 |
jQuery( '#mlsimport-delete-notification' ).text( 'Please add the category term ' ); |
| 277 |
return; |
| 278 |
} |
| 279 |
|
| 280 |
jQuery( '#mlsimport-delete-notification' ).text( 'Deleting...If you have many properties this may take a while' ); |
| 281 |
jQuery.ajax( |
| 282 |
{ |
| 283 |
type: 'POST', |
| 284 |
url: ajaxurl, |
| 285 |
dataType:'json', |
| 286 |
data: { |
| 287 |
'action' : 'mlsimport_delete_properties', |
| 288 |
'mlsimport_delete_category' : mlsimport_delete_category, |
| 289 |
'mlsimport_delete_category_term' : mlsimport_delete_category_term, |
| 290 |
'mlsimport_delete_timeout' : mlsimport_delete_timeout, |
| 291 |
'security' : nonce |
| 292 |
}, |
| 293 |
success: function (data) { |
| 294 |
console.log( data ); |
| 295 |
jQuery( '#mlsimport-delete-notification' ).text( data.message ); |
| 296 |
|
| 297 |
}, |
| 298 |
error: function (errorThrown) { |
| 299 |
console.log( errorThrown ); |
| 300 |
} |
| 301 |
} |
| 302 |
);// end ajax |
| 303 |
} |
| 304 |
); |
| 305 |
|
| 306 |
/** |
| 307 |
* Stop import |
| 308 |
*/ |
| 309 |
|
| 310 |
jQuery( '#mlsimport_stop' ).on( |
| 311 |
'click', |
| 312 |
function () { |
| 313 |
var ajaxurl = mlsimport_vars.ajax_url; |
| 314 |
|
| 315 |
console.log( 'stop files' ); |
| 316 |
jQuery.ajax( |
| 317 |
{ |
| 318 |
type: 'POST', |
| 319 |
url: ajaxurl, |
| 320 |
data: { |
| 321 |
'action' : 'mlsimport_stop_moving_files', |
| 322 |
}, |
| 323 |
success: function (data) { |
| 324 |
console.log( data ); |
| 325 |
jQuery( '#aws-move-start' ).show(); |
| 326 |
clearInterval( log_refresh_interval ); |
| 327 |
|
| 328 |
}, |
| 329 |
error: function (errorThrown) { |
| 330 |
console.log( errorThrown ); |
| 331 |
} |
| 332 |
} |
| 333 |
);// end ajax |
| 334 |
} |
| 335 |
); |
| 336 |
|
| 337 |
/** |
| 338 |
* Start Import |
| 339 |
*/ |
| 340 |
|
| 341 |
jQuery( '#mlsimport-start' ).on( |
| 342 |
'click', |
| 343 |
function () { |
| 344 |
console.log( 'mlsimport-start' ); |
| 345 |
var ajaxurl = mlsimport_vars.ajax_url; |
| 346 |
aws_show_progress(); |
| 347 |
|
| 348 |
jQuery.ajax( |
| 349 |
{ |
| 350 |
type: 'POST', |
| 351 |
url: ajaxurl, |
| 352 |
data: { |
| 353 |
'action' : 'mlsimport_move_files' |
| 354 |
}, |
| 355 |
success: function (data) { |
| 356 |
console.log( data ); |
| 357 |
console.log( 'starting loggers' ); |
| 358 |
clearInterval( log_refresh_interval ); |
| 359 |
log_refresh_interval = setInterval( mlsimport_log_interval, timer ); |
| 360 |
|
| 361 |
}, |
| 362 |
error: function (errorThrown) { |
| 363 |
console.log( errorThrown ); |
| 364 |
} |
| 365 |
} |
| 366 |
);// end ajax |
| 367 |
|
| 368 |
} |
| 369 |
); |
| 370 |
|
| 371 |
/** |
| 372 |
* Log import |
| 373 |
*/ |
| 374 |
|
| 375 |
function mlsimport_log_interval() |
| 376 |
{ |
| 377 |
|
| 378 |
var progress_total = jQuery( '#mlsimport_monster_myProgress' ).attr( 'data-total' ); |
| 379 |
progress_total = parseInt( progress_total ); |
| 380 |
var remain_images = progress_total; |
| 381 |
var done_images = 0; |
| 382 |
var bar_width = 0; |
| 383 |
jQuery.ajax( |
| 384 |
{ |
| 385 |
type: 'POST', |
| 386 |
url: ajaxurl, |
| 387 |
dataType: 'json', |
| 388 |
data: { |
| 389 |
'action' : 'mlsimport_move_files_to_aws_logger', |
| 390 |
}, |
| 391 |
success: function (data) { |
| 392 |
|
| 393 |
if (data.is_done === 'done' && data.logs === '' ) { |
| 394 |
jQuery( '#log_container' ).prepend( 'COMPLETED' ); |
| 395 |
jQuery( '#log_container' ).append( 'COMPLETED' ); |
| 396 |
clearInterval( log_refresh_interval ); |
| 397 |
} else if (data.logs !== '') { |
| 398 |
jQuery( '#log_container' ).empty().prepend( data.logs ); |
| 399 |
jQuery( '#aws_more_files' ).empty().text( data.current_files_no ); |
| 400 |
|
| 401 |
remain_images = parseInt( data.current_files_no ); |
| 402 |
done_images = progress_total - remain_images; |
| 403 |
|
| 404 |
bar_width = done_images * 100 / progress_total; |
| 405 |
bar_width = parseFloat( bar_width ); |
| 406 |
|
| 407 |
jQuery( '#mlsimport_myBar' ).css( 'width',bar_width + '%' ); |
| 408 |
} |
| 409 |
}, |
| 410 |
error: function (errorThrown) { |
| 411 |
console.log( errorThrown ); |
| 412 |
} |
| 413 |
} |
| 414 |
);// end ajax |
| 415 |
} |
| 416 |
|
| 417 |
/** |
| 418 |
* Log import per item |
| 419 |
*/ |
| 420 |
|
| 421 |
function mlsimport_log_interval_per_item() |
| 422 |
{ |
| 423 |
console.log( 'mlsimport_log_interval_per_item' ); |
| 424 |
var item_id = jQuery( '#mlsimport-start_item' ).attr( 'data-post_id' ); |
| 425 |
var nonce = jQuery('#mlsimport_item_actions').val(); |
| 426 |
jQuery.ajax( |
| 427 |
{ |
| 428 |
type: 'POST', |
| 429 |
url: ajaxurl, |
| 430 |
dataType: 'json', |
| 431 |
data: { |
| 432 |
'action' : 'mlsimport_logger_per_item', |
| 433 |
'post_id' : item_id, |
| 434 |
'security' : nonce |
| 435 |
}, |
| 436 |
success: function (data) { |
| 437 |
console.log( data ); |
| 438 |
var progress = parseInt( data.mlsimport_progress_properties ); |
| 439 |
var total = parseInt( data.mlsimport_task_to_import ); |
| 440 |
if ( ! isNaN( progress ) && ! isNaN( total ) && total > 0 ) { |
| 441 |
var width = progress * 100 / total; |
| 442 |
jQuery( '#mlsimport_item_progress .mlsimport-progress-bar-inner' ).css( 'width', width + '%' ); |
| 443 |
} |
| 444 |
if (data.is_done === 'done' || data.logs === '' ) { |
| 445 |
console.log( 'kill interval' ); |
| 446 |
|
| 447 |
clearInterval( log_refresh_interval_per_item ); |
| 448 |
jQuery( '#mlsimport_item_status' ).empty().append( "Import stopped or completed!" ); |
| 449 |
jQuery( '#mlsimport_item_progress .mlsimport-progress-bar-inner' ).css( 'width', '100%' ); |
| 450 |
|
| 451 |
}else if(data.is_done==='wip'){ |
| 452 |
console.log('we do wip'); |
| 453 |
jQuery( '#mlsimport_item_status' ).empty().append( 'Importing property: '+data.mlsimport_progress_properties+' of '+data.mlsimport_task_to_import+'. Memory used: '+data.memory+' MB.' ); |
| 454 |
|
| 455 |
} else if (data.logs !== '') { |
| 456 |
console.log('we do logs'); |
| 457 |
jQuery( '#mlsimport_item_status' ).empty().append( data.logs ); |
| 458 |
|
| 459 |
|
| 460 |
jQuery('.mlsimport-import-summary').append( |
| 461 |
'<p><strong><?php _e("Status:", "mlsimport"); ?></strong> ' + |
| 462 |
'<span class="mlsimport-status-success">'+data.logs+'/span></p>' |
| 463 |
); |
| 464 |
|
| 465 |
} |
| 466 |
}, |
| 467 |
error: function (errorThrown) { |
| 468 |
console.log( errorThrown ); |
| 469 |
} |
| 470 |
} |
| 471 |
);// end ajax |
| 472 |
} |
| 473 |
|
| 474 |
/** |
| 475 |
* SHow progress bar - |
| 476 |
*/ |
| 477 |
|
| 478 |
function aws_show_progress() |
| 479 |
{ |
| 480 |
|
| 481 |
jQuery( '#log_container' ).empty(); |
| 482 |
|
| 483 |
var files_to_move = jQuery( '#aws_move' ).text(); |
| 484 |
files_to_move = parseInt( files_to_move ); |
| 485 |
|
| 486 |
console.log( 'files_to_move ' + files_to_move ); |
| 487 |
|
| 488 |
if ( isNaN( parseFloat( files_to_move ) ) ) { |
| 489 |
files_to_move = jQuery( '#aws_more_files' ).text(); |
| 490 |
} |
| 491 |
console.log( 'files_to_move2 ' + files_to_move ); |
| 492 |
files_to_move = parseInt( files_to_move ); |
| 493 |
|
| 494 |
jQuery( '#mlsimport_myProgress_wrapper' ).show(); |
| 495 |
jQuery( '.aws_to_move' ).empty().html( '<strong>We start importing. Please wait.</strong>' ); |
| 496 |
jQuery( '#aws-move-start' ).hide(); |
| 497 |
} |
| 498 |
|
| 499 |
/** |
| 500 |
* Check / unchechek fields |
| 501 |
*/ |
| 502 |
|
| 503 |
jQuery( '.mls_import_selec_all_class' ).on( |
| 504 |
'click', |
| 505 |
function () { |
| 506 |
var trigger_type = jQuery( this ).attr( 'data-import' ); |
| 507 |
console.log( 'trigger type ' + trigger_type ); |
| 508 |
|
| 509 |
if (trigger_type === 'import_select') { |
| 510 |
|
| 511 |
jQuery( '.mlsimport_select_import_all' ).prop( 'checked', true ); |
| 512 |
} else if (trigger_type === 'import_select_none') { |
| 513 |
|
| 514 |
jQuery( '.mlsimport_select_import_all' ).prop( 'checked', false ); |
| 515 |
} else if (trigger_type === 'import_admin') { |
| 516 |
jQuery( '.mlsimport_select_import_admin_all' ).prop( 'checked', true ); |
| 517 |
} else if (trigger_type === 'import_admin_none') { |
| 518 |
jQuery( '.mlsimport_select_import_admin_all' ).prop( 'checked', false ); |
| 519 |
} |
| 520 |
} |
| 521 |
); |
| 522 |
|
| 523 |
} |
| 524 |
); |
| 525 |
|
| 526 |
|
| 527 |
|
| 528 |
function mslimport_show_extra_options() |
| 529 |
{ |
| 530 |
jQuery( '.mlsimport_hidden_field_button' ).on( |
| 531 |
'click', |
| 532 |
function () { |
| 533 |
var parent = jQuery( this ).closest( '.mlsimport-fieldset' ); |
| 534 |
console.log( parent ) |
| 535 |
parent.find( '.mlsimport-input-wrapper' ).toggle(); |
| 536 |
} |
| 537 |
); |
| 538 |
} |
| 539 |
|
| 540 |
|
| 541 |
|
| 542 |
|
| 543 |
function mlsimport_saas_get_metadata() |
| 544 |
{ |
| 545 |
|
| 546 |
console.log( 'mlsimport_saas_get_metadata' ); |
| 547 |
var nonce = jQuery('#mlsimport_saas_get_metadata').val(); |
| 548 |
var ajaxurl = mlsimport_vars.ajax_url; |
| 549 |
jQuery.ajax( |
| 550 |
{ |
| 551 |
type: 'POST', |
| 552 |
url: ajaxurl, |
| 553 |
data: { |
| 554 |
'action' : 'mlsimport_saas_get_metadata_function', |
| 555 |
'security' : nonce |
| 556 |
}, |
| 557 |
success: function (data) { |
| 558 |
console.log( data ); |
| 559 |
jQuery( '.mlsimport_populate_warning' ).remove(); |
| 560 |
location.reload( true ); |
| 561 |
}, |
| 562 |
error: function (errorThrown) { |
| 563 |
console.log( errorThrown ); |
| 564 |
} |
| 565 |
} |
| 566 |
);// end ajax |
| 567 |
|
| 568 |
} |
| 569 |
|
| 570 |
|
| 571 |
function mlsimport_token_on_load() |
| 572 |
{ |
| 573 |
var selected_value = jQuery( '#mlsimport_mls_name' ).val(); |
| 574 |
selected_value = parseInt( selected_value ); |
| 575 |
|
| 576 |
console.log("on load "+selected_value); |
| 577 |
if (selected_value >= 7000) { |
| 578 |
|
| 579 |
jQuery( '.fieldset_mlsimport_mls_token' ).hide(); |
| 580 |
jQuery( '.fieldset_mlsimport_tresle_client_id, .fieldset_mlsimport_tresle_client_secret' ).hide(); |
| 581 |
jQuery( '.fieldset_mlsimport_rapattoni_client_id,.fieldset_mlsimport_rapattoni_client_secret,.fieldset_mlsimport_rapattoni_username,.fieldset_mlsimport_rapattoni_password ' ).hide(); |
| 582 |
jQuery( '.fieldset_mlsimport_paragon_client_id, .fieldset_mlsimport_paragon_client_secret' ).hide(); |
| 583 |
jQuery( '.fieldset_mlsimport_realtorca_client_id, .fieldset_mlsimport_realtorca_client_secret' ).show(); |
| 584 |
}else if (selected_value > 6000) { |
| 585 |
|
| 586 |
jQuery( '.fieldset_mlsimport_paragon_client_id, .fieldset_mlsimport_paragon_client_secret' ).show(); |
| 587 |
jQuery( '.fieldset_mlsimport_rapattoni_client_id,.fieldset_mlsimport_rapattoni_client_secret,.fieldset_mlsimport_rapattoni_username,.fieldset_mlsimport_rapattoni_password ' ).hide(); |
| 588 |
jQuery( '.fieldset_mlsimport_mls_token' ).hide(); |
| 589 |
jQuery( '.fieldset_mlsimport_tresle_client_id' ).hide(); |
| 590 |
jQuery( '.fieldset_mlsimport_tresle_client_secret' ).hide(); |
| 591 |
jQuery( '.fieldset_mlsimport_realtorca_client_id, .fieldset_mlsimport_realtorca_client_secret' ).hide(); |
| 592 |
} else if ( selected_value > 5000 && selected_value < 6000) { |
| 593 |
|
| 594 |
jQuery( '.fieldset_mlsimport_rapattoni_client_id,.fieldset_mlsimport_rapattoni_client_secret,.fieldset_mlsimport_rapattoni_username,.fieldset_mlsimport_rapattoni_password ' ).show(); |
| 595 |
jQuery( '.fieldset_mlsimport_mls_token' ).hide(); |
| 596 |
jQuery( '.fieldset_mlsimport_tresle_client_id' ).hide(); |
| 597 |
jQuery( '.fieldset_mlsimport_tresle_client_secret' ).hide(); |
| 598 |
jQuery( '.fieldset_mlsimport_paragon_client_id, .fieldset_mlsimport_paragon_client_secret' ).hide(); |
| 599 |
jQuery( '.fieldset_mlsimport_realtorca_client_id, .fieldset_mlsimport_realtorca_client_secret' ).hide(); |
| 600 |
} else if ( selected_value > 900 && selected_value < 3000) { |
| 601 |
|
| 602 |
jQuery( '.fieldset_mlsimport_mls_token' ).hide(); |
| 603 |
jQuery( '.fieldset_mlsimport_tresle_client_id' ).show(); |
| 604 |
jQuery( '.fieldset_mlsimport_tresle_client_secret' ).show(); |
| 605 |
jQuery( '.fieldset_mlsimport_rapattoni_client_id,.fieldset_mlsimport_rapattoni_client_secret,.fieldset_mlsimport_rapattoni_username,.fieldset_mlsimport_rapattoni_password ' ).hide(); |
| 606 |
jQuery( '.fieldset_mlsimport_paragon_client_id, .fieldset_mlsimport_paragon_client_secret' ).hide(); |
| 607 |
jQuery( '.fieldset_mlsimport_realtorca_client_id, .fieldset_mlsimport_realtorca_client_secret' ).hide(); |
| 608 |
} else { |
| 609 |
|
| 610 |
jQuery( '.fieldset_mlsimport_mls_token' ).show(); |
| 611 |
jQuery( '.fieldset_mlsimport_tresle_client_id' ).hide(); |
| 612 |
jQuery( '.fieldset_mlsimport_tresle_client_secret' ).hide(); |
| 613 |
jQuery( '.fieldset_mlsimport_rapattoni_client_id,.fieldset_mlsimport_rapattoni_client_secret,.fieldset_mlsimport_rapattoni_username,.fieldset_mlsimport_rapattoni_password ' ).hide(); |
| 614 |
jQuery( '.fieldset_mlsimport_paragon_client_id, .fieldset_mlsimport_paragon_client_secret' ).hide(); |
| 615 |
jQuery( '.fieldset_mlsimport_realtorca_client_id, .fieldset_mlsimport_realtorca_client_secret' ).hide(); |
| 616 |
|
| 617 |
} |
| 618 |
} |
| 619 |
|
| 620 |
|
| 621 |
|
| 622 |
function mlsimport_autocomplte_mls_selection(autofill){ |
| 623 |
|
| 624 |
console.log('mlsimport_autocomplte_mls_selection'); |
| 625 |
console.log(typeof jQuery.ui.autocomplete); // should be "function" |
| 626 |
console.log(autofill); |
| 627 |
|
| 628 |
|
| 629 |
jQuery( "#mlsimport_mls_name_front" ).autocomplete({ |
| 630 |
source: autofill, |
| 631 |
minLength: 3, |
| 632 |
open: function(event, ui) { |
| 633 |
jQuery(this).autocomplete("widget").addClass("mlsimport-autocomplete-menu"); |
| 634 |
}, |
| 635 |
change( event, ui ){ |
| 636 |
console.log(ui); |
| 637 |
jQuery("#mlsimport_mls_name_front").val(ui.item.label); |
| 638 |
jQuery("#mlsimport_mls_name").val(ui.item.value); |
| 639 |
mlsimport_token_on_load(); |
| 640 |
}, |
| 641 |
focus: function(event, ui) { |
| 642 |
jQuery("#mlsimport_mls_name_front").val(ui.item.label); |
| 643 |
jQuery("#mlsimport_mls_name").val(ui.item.value); mlsimport_token_on_load(); |
| 644 |
return false; |
| 645 |
}, |
| 646 |
select: function(event, ui) { |
| 647 |
jQuery("#mlsimport_mls_name_front").val(ui.item.label); |
| 648 |
jQuery("#mlsimport_mls_name").val(ui.item.value); mlsimport_token_on_load(); |
| 649 |
return false; |
| 650 |
}, |
| 651 |
response: function(event, ui) { |
| 652 |
if (!ui.content.length) { |
| 653 |
var noResult = { value:"",label:"No results found" }; |
| 654 |
ui.content.push(noResult); |
| 655 |
//$("#message").text("No results found"); |
| 656 |
} else { |
| 657 |
// $("#message").empty(); |
| 658 |
} |
| 659 |
} |
| 660 |
}); |
| 661 |
} |