1var likebtn_donate_systems = [ 2 { 3 system: "PayPal", 4 options: ["account", "amount_integer", "amount_fractional", "currency"], 5 // https://cms.paypal.com/mx/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_nvp_currency_codes 6 currencies: ["USD", "AUD", "BRL", "CAD", "CZK", "DKK", "EUR", "HKD", "HUF", "ILS", "JPY", "MYR", "MXN", "NOK", "NZD", "PHP", "PLN", "GBP", "SGD", "SEK", "CHF", "TWD", "THB", "TRY"] 7 }, 8 { 9 system: "Bitcoin", 10 options: ["account"] 11 }, 12 { 13 system: "Google Wallet", 14 options: ["account"] 15 }, 16 { 17 system: "Yandex.Money", 18 options: ["account", "amount_integer", "amount_fractional"] 19 }, 20 { 21 system: "WebMoney", 22 options: ["account"] 23 }, 24 { 25 system: "Qiwi", 26 options: ["account", "amount_integer", "amount_fractional"] 27 }, 28 { 29 system: "SmsCoin", 30 options: ["account", "language"], 31 languages: ["en", "ru"] 32 }, 33 { 34 system: "Zaypay", 35 options: ["account"] 36 //languages: ["", "en", "ru", "id", "bs", "da", "de", "es", "ls", "fr", "hr", "it", "nl", "pl", "pt", "ro", "sr", "fi", "sv", "cs", "bg", "he"] 37 } 38]; 39 40//var likebtn_donate_pattern = { 41// purpose: "", 42// payment_systems: [] 43//}; 44 45var likebtn_system_pattern = { 46 system: "", 47 account: "", 48 amount_fractional: "", 49 amount_integer: "", 50 currency: "", 51 language: "" 52}; 53 54var likebtn_decimal_separator = '.'; 55 56var likebtn_donate_row_counter = 0; 57var likebtn_donate_target_el = null; 58 59var likebtn_donate_config = {}; 60 61// Show donate generator 62function likebtnDG(target, ok_link, css, config) 63{ 64 var html = ''; 65 var donate_obj = null; 66 var purpose = ''; 67 likebtn_donate_config = config || {}; 68 69 if (typeof(target) == "string") { 70 if (target.indexOf('#') == -1 && target.indexOf('.') == -1) { 71 likebtn_donate_target_el = jQuery("#"+target); 72 } else { 73 likebtn_donate_target_el = jQuery(target); 74 } 75 } else { 76 likebtn_donate_target_el = jQuery(target); 77 } 78 if (!likebtn_donate_target_el) { 79 return; 80 } 81 if (likebtn_donate_target_el.attr("disabled")) { 82 return; 83 } 84 85 if (typeof(LikeBtn) != "undefined") { 86 donate_obj = LikeBtn.unserializeDonateStr( likebtn_donate_target_el.val() ); 87 } 88 89 if (typeof(donate_obj) != "undefined" && donate_obj && typeof(donate_obj.purpose) != "undefined") { 90 purpose = donate_obj.purpose; 91 } 92 93 html += '<style>'; 94 html += likebtnDGStyle(); 95 html += '</style>'; 96 html += '<script type="text/javascript" src="//w.likebtn.com/js/w/widget.js" async="async"></script>'; 97 html += '<div id="likebtn-dg-background"></div><div id="likebtn-dg-container"><div id="likebtn-dg-content">'; 98 html += '<a href="javascript:likebtnDGClose();void(0);" id="likebtn-dg-close" title="Cancel"><strong>X</strong></a>'; 99 100 html += '<div id="likebtn-dg-header">Donation Settings</div><br/>'; 101 102 html += '<table id="likebtn-dg-fields-container">'; 103 html += '<tr><td><strong>Purpose</strong> <input value="' + purpose + '" class="likebtn-donate-purpose" size="50" onkeyup="likebtnDGOptionChange(-1)"/></td><td> <small>(optional)</small></td></tr>'; 104 html += '<tr><td class="likebtn-dg-donate-systems_container">'; 105 html += '<strong>Add a payment method</strong> '; 106 html += '<select id="likebtn-dg-donate-systems"> '; 107 for (i=0; i<likebtn_donate_systems.length; i++) { 108 html += '<option value="'+likebtn_donate_systems[i].system+'" '; 109 html += '>'+likebtn_donate_systems[i].system+'</option>'; 110 } 111 html += '</select> '; 112 html += '</td>'; 113 html += '<td> <a href="javascript:likebtnDGAddSystem();void(0);" id="likebtn-dg-add-trigger" class="likebtn-dg-trigger" title="Add">add</a></td>'; 114 html += '</tr>'; 115 html += '</table><br/>'; 116 117 html += '<table width="100%" id="likebtn-systems-container">'; 118 html += '<tr><th> </th><th>Payment System</th><th title="email or account number">Account</th><th>
118Amount</th><th>Currency</th><th>Lang</th><th>Demo</th></tr>'; 119 120 html += '<tr class="likebtn-dg-empty-msg-container"><td colspan="7" class="likebtn-dg-empty-msg">You have not defined a payment method yet</td></tr>'; 121 html += '</table>'; 122 123 html += '<br/>'; 124 125 if (typeof(likebtn_donate_config.button_ok_html) !== "undefined" && likebtn_donate_config.button_ok_html) { 126 html += likebtn_donate_config.button_ok_html; 127 } else if (typeof(ok_link) == "undefined" || !ok_link) { 128 html += '<button onclick="likebtnDGOk()" id="likebtn-dg-ok">OK</button>'; 129 } else { 130 html += '<a href="javascript:likebtnDGOk();void(0);" id="likebtn-dg-ok"><strong>OK</strong></a>'; 131 } 132 if (typeof(likebtn_donate_config.button_cancel_html) !== "undefined" && likebtn_donate_config.button_cancel_html) { 133 html += likebtn_donate_config.button_cancel_html; 134 } else { 135 html += '<a href="javascript:likebtnDGClose();void(0);">Cancel</a>'; 136 } 137 138 html += '</div>'; 139 html += '</div>'; 140 141 /*if (typeof(likebtn_donate_config.append_container) !== "undefined") { 142 jQuery(likebtn_donate_config.append_container).after(html); 143 } else {*/ 144 likebtn_donate_target_el.after(html); 145 146 // Apply css 147 if (typeof(css) != "undefined" && css) { 148 jQuery("#likebtn-dg-content").css(css); 149 } 150 151 // Populate payment systems 152 if (typeof(donate_obj) != "undefined" && donate_obj && typeof(donate_obj.payment_systems) != "undefined") { 153 for (var system in donate_obj.payment_systems) { 154 if (isNaN(parseInt(system))) { 155 continue; 156 } 157 likebtnDGAddSystem(donate_obj.payment_systems[system]); 158 } 159 } 160 161 jQuery("#likebtn-dg-content").css('top', likebtn_donate_target_el); 162} 163 164// Close the generator and populate the field 165function likebtnDGOk() 166{ 167 var donate_obj = likebtnGetDonateObject(); 168 var donate_str = ''; 169 if (donate_obj) { 170 var donate_str = likebtnSerializeDonate(donate_obj); 171 } 172 if (likebtn_donate_target_el) { 173 likebtn_donate_target_el.val(donate_str).trigger("keyup"); 174 } 175 176 // Display preview 177 if (typeof(likebtn_donate_config.preview_container) !== "undefined") { 178 jQuery(likebtn_donate_config.preview_container).html(likebtnDGGetPreview()); 179 } 180 181 likebtnDGClose(); 182} 183 184// Prepare donate object 185function likebtnGetDonateObject() 186{ 187 var donate = { 188 purpose: "", 189 payment_systems: [] 190 }; 191 192 donate.purpose = jQuery(".likebtn-donate-purpose:first").val()+""; 193 194 jQuery("#likebtn-systems-container .likebtn_donate_row").each(function() { 195 system = { 196 system: jQuery(this).find(".likebtn_donate_system:first").text() || "", 197 account: jQuery(this).find(".likebtn_donate_account:first").val() || "" 198 }; 199 200 var amount_fractional = ''; 201 var amount_integer = ''; 202 203 var amount = jQuery(this).find(".likebtn_donate_amount:first").val(); 204 205 if (typeof(amount) != "undefined") { 206 var amount_parts = amount.split(/[.,]/); 207 if (typeof(amount_parts[0]) != "undfined") { 208 amount_integer = parseInt(amount_parts[0]); 209 if (!isNaN(amount_integer)) { 210 system.amount_integer = amount_integer; 211 } 212 } 213 if (typeof(amount_parts[1]) != "undfined") { 214 amount_fractional = parseInt(amount_parts[1]); 215 if (!isNaN(amount_fractional)) { 216 system.amount_fractional = amount_fractional; 217 } 218 } 219 } 220 221 var currency = jQuery(this).find(".likebtn_donate_currency:first").val(); 222 if (typeof(currency) != "undefined") { 223 system.currency = currency; 224 } 225 var language = jQuery(this).find(".likebtn_donate_language:first").val(); 226 if (typeof(language) != "undefined") { 227 system.language = language; 228 } 229 if (system.system && system.account) { 230 donate.payment_systems.push(system); 231 } 232 }); 233 /*if (!donate.payment_systems.length) { 234 donate = null; 235 }*/ 236 237 return donate; 238} 239 240// Serizalize donate object into string 241function likebtnSerializeDonate(donate_obj) 242{ 243 donate_str = ''; 244 245 if (donate_obj) { 246 if (typeof(LikeBtn) != "undefined") { 247 donate_obj = LikeBtn.escapeDonateObj(donate_obj, true); 248 donate_str = LikeBtn.JSON.encode(donate_obj); 249 } 250 } 251 252 return donate_str; 253} 254 255// Close the generator 256function likebtnDGClose() 257{ 258 likebtn_donate_row_counter = 0; 259 likebtn_donate_target_el = null; 260 261 jQuery("#likebtn-dg-container").remove(); 262 jQuery("#likebtn-dg-background").remove(); 263} 264 265// Add system row 266function likebtnDGAddSystem(row) 267{ 268 var html = ''; 269 var system = null; 270 var amount = ''; 271 272 // Remove empty message 273 jQuery(".likebtn-dg-empty-msg-container").hide(); 274 275 if (typeof(row) == "undefined" || !row.system) { 276 row = likebtn_system_pattern; 277 // Get selected system 278 if (jQuery("#likebtn-dg-donate-systems").val()) { 279 row.system = jQuery("#likebtn-dg-donate-systems").val(); 280 } else { 281 // Show default 282 row.system = "PayPal"; 283 } 284 } 285 system = likebtnGetSystem(row.system); 286 if (!system) { 287 row = likebtn_default_donate_system; 288 system = likebtnGetSystem(row.system); 289 } 290 291 // Amount 292 if (jQuery.inArray("amount_integer", system.options) != -1) { 293 amount = row.amount_integer; 294 } 295 if (jQuery.inArray("amount_fractional", system.options) != -1) { 296 amount += likebtn_decimal_separator+row.amount_fractional; 297 } 298 299 html += '<tr class="likebtn_donate_row" id="likebtn_donate_row_'+likebtn_donate_row_counter+'">'; 300 html += '<td><a href="javascript:likebtnDGRemoveSystem('+likebtn_donate_row_counter+');void(0);
300" id="likebtn-dg-remove-trigger" class="likebtn-dg-trigger" title="Remove">â</a></td>'; 301 html += '<td><small class="likebtn_donate_system" >'+row.system+'</small></td>'; 302 html += '<td><input value="'+row.account+'" class="likebtn_donate_account" size="18" onkeyup="likebtnDGOptionChange('+likebtn_donate_row_counter+')" /></td>'; 303 html += '<td>'; 304 if (amount) { 305 html += '<input value="'+row.amount_integer+'" class="likebtn_donate_amount" size="6" onkeyup="likebtnDGOptionChange('+likebtn_donate_row_counter+')" />'; 306 } else { 307 html += '-'; 308 } 309 html += '</td>'; 310 311 html += '<td>'; 312 if (jQuery.inArray("currency", system.options) != -1) { 313 html += '<select class="likebtn_donate_currency" onchange="likebtnDGOptionChange('+likebtn_donate_row_counter+')"> '; 314 for (i=0; i<system.currencies.length; i++) { 315 html += '<option value="'+system.currencies[i]+'" '; 316 if (system.currencies[i] == row.currency) { 317 html += 'selected="selected"'; 318 } 319 html += '>'+system.currencies[i]+'</option>'; 320 } 321 html += '</select> '; 322 } else { 323 html += '-'; 324 } 325 html += '</td>'; 326 327 html += '<td>'; 328 if (jQuery.inArray("language", system.options) != -1) { 329 html += '<select class="likebtn_donate_language" onchange="likebtnDGOptionChange('+likebtn_donate_row_counter+')"> '; 330 for (i=0; i<system.languages.length; i++) { 331 html += '<option value="'+system.languages[i]+'" '; 332 if (system.languages[i] == row.language) { 333 html += 'selected="selected"'; 334 } 335 html += '>'+system.languages[i]+'</option>'; 336 } 337 html += '</select> '; 338 } else { 339 html += '-'; 340 } 341 html += '</td>'; 342 343 html += '<td class="likebtn_donate_demo"> </td>'; 344 html += '</tr>'; 345 346 likebtn_donate_row_counter++; 347 348 jQuery("#likebtn-systems-container tr:last").after(html); 349 350 likebtnDGOptionChange(-1); 351} 352 353// Remove system row 354function likebtnDGRemoveSystem(index) 355{ 356 jQuery('#likebtn_donate_row_'+index).remove(); 357 358 // Remove empty message 359 if (jQuery("#likebtn-systems-container .likebtn_donate_row").size() == 0) { 360 jQuery(".likebtn-dg-empty-msg-container").show(); 361 } 362} 363 364// Get system by name 365function likebtnGetSystem(system) 366{ 367 for (i=0; i<likebtn_donate_systems.length; i++) { 368 if (likebtn_donate_systems[i].system == system) { 369 return likebtn_donate_systems[i]; 370 break; 371 } 372 } 373 return null; 374} 375 376// Show demo 377function likebtnDGOptionChange(index) 378{ 379 var html = ''; 380 var total_rows = jQuery("#likebtn-systems-container .likebtn_donate_row").size(); 381 var donate_obj = likebtnGetDonateObject(); 382 383 /*if (typeof(donate_obj) == "undefined" 384 || typeof(donate_obj.payment_systems) == "undefined" 385 || typeof(donate_obj.payment_systems[index]) == "undefined")*/ 386 if (index == -1) { 387 // Show demos for all rows 388 for (system_index in donate_obj.payment_systems) { 389 if (isNaN(parseInt(system_index))) { 390 continue; 391 } 392 if (typeof(LikeBtn) != "undefined") { 393 html = LikeBtn.getPaymentSystemHtml(donate_obj.payment_systems[system_index], donate_obj.purpose); 394 } 395 396 jQuery("#likebtn_donate_row_"+system_index+" .likebtn_donate_demo:first").html(html); 397 } 398 } else { 399 // Show demo for the changed line 400 // determine system index in onject 401 var system_index = -1; 402 var not_empty_account_counter = 0; 403 404 jQuery("#likebtn-systems-container .likebtn_donate_account").each(function() { 405 if (jQuery(this).val()) { 406 not_empty_account_counter++; 407 } 408 if (jQuery(this).parents("tr:first").attr('id') == 'likebtn_donate_row_'+index) { 409 system_index = not_empty_account_counter-1; 410 return false; 411 } 412 }); 413 414 if (typeof(LikeBtn) != "undefined" && system_index >= 0) { 415 html = LikeBtn.getPaymentSystemHtml(donate_obj.payment_systems[system_index], donate_obj.purpose); 416 jQuery("#likebtn_donate_row_"+index+" .likebtn_donate_demo:first").html(html); 417 } 418 } 419} 420 421// Get css 422function likebtnDGStyle() 423{ 424 css = ''; 425 426 css += '#likebtn-dg-background {'; 427 css += ' position: fixed;'; 428 css += ' top: 0;'; 429 css += ' left: 0;'; 430 css += ' width: 100%;'; 431 css += ' height: 100%;'; 432 css += ' background-color: white;'; 433 css += ' opacity: .50;'; 434 css += ' -webkit-opacity: .5;'; 435 css += ' -moz-opacity: .5;'; 436 css += ' filter: alpha(opacity=50);'; 437 css += ' z-index: 1000;'; 438 css += '}'; 439 440 441 css += '#likebtn-dg-content {'; 442 css += ' background-color: white;'; 443 css += ' border-radius: 10px;'; 444 css += ' box-shadow: 0 0 20px 0 #222;'; 445 css += ' display: inline-block;'; 446 css += ' margin: 36px 10px 16px;'; 447 css += ' padding: 10px;'; 448 css += ' position: relative;';
449 css += ' text-align: left;'; 450 css += '}'; 451 452 css += '#likebtn-dg-container {'; 453 css += ' height: 100%;'; 454 css += ' left: 0;'; 455 css += ' position: fixed;'; 456 css += ' text-align: center;'; 457 css += ' top: 0;'; 458 css += ' width: 100%;'; 459 css += ' z-index: 2147483647;'; 460 css += '}'; 461 462 css += '#likebtn-dg-container .likebtn-donate-purpose {'; 463 css += ' margin: 0;'; 464 css += '}'; 465 466 css += '#likebtn-dg-ok {'; 467 css += ' float: right;'; 468 css += '}'; 469 470 css += '#likebtn-dg-close {'; 471 css += ' float: right;'; 472 css += '}'; 473 474 css += '#likebtn-dg-header {'; 475 css += ' font-weight: bold;'; 476 css += ' font-size: 20px;'; 477 css += ' text-align: center;'; 478 css += '}'; 479 480 css += '#likebtn-systems-container .likebtn-dg-empty-msg {'; 481 css += ' color: #b1b1b1;'; 482 css += ' padding: 20px 0;'; 483 css += ' text-align: center;'; 484 css += '}'; 485 486 css += '#likebtn-systems-container .likebtn_donate_demo {'; 487 css += ' min-width: 62px;'; 488 css += '}'; 489 490 491 css += '#likebtn-dg-fields-container .likebtn-dg-donate-systems_container {'; 492 css += ' text-align: right;'; 493 css += ' margin-top: 10px;'; 494 css += '}'; 495 496 css += '#likebtn-dg-fields-container .likebtn-dg-donate-systems_container strong {'; 497 css += ' float: left;'; 498 css += '}'; 499 500 css += '#likebtn-systems-container td {'; 501 css += ' text-align: left;'; 502 css += '}'; 503 504 css += '#likebtn-systems-container th small {'; 505 css += ' font-weight: normal;'; 506 css += '}'; 507 508 css += '#likebtn-dg-fields-container td {'; 509 css += ' border: 0;'; 510 css += ' padding: 5px 0 3px;'; 511 css += ' margin: 0;'; 512 css += ' background-image: none;'; 513 css += ' background-color: transparent;'; 514 css += ' vertical-align: bottom;'; 515 css += '}'; 516 517 css += '#likebtn-dg-content a.likebtn-dg-trigger:link,'; 518 css += '#likebtn-dg-content a.likebtn-dg-trigger:visited {'; 519 css += ' text-decoration: none;'; 520 css += '}'; 521 522 css += '#likebtn-dg-content input,'; 523 css += '#likebtn-dg-content select {'; 524 css += ' border: 1px solid #CCCCCC;'; 525 css += '}'; 526 527 return css; 528} 529 530// Get html of donate buttons 531function likebtnDGGetPreview(target_field) 532{ 533 var html = ''; 534 var donate_obj; 535 536 if (typeof(LikeBtn) === "undefined") { 537 return html; 538 } 539 540 if (typeof(target_field) !== "undefined") { 541 donate_obj = LikeBtn.unserializeDonateStr( jQuery(target_field).val() ); 542 } else { 543 donate_obj = likebtnGetDonateObject(); 544 } 545 546 if (!donate_obj) { 547 return html; 548 } 549 550 // Get html for each button 551 for (system_index in donate_obj.payment_systems) { 552 if (isNaN(parseInt(system_index))) { 553 continue; 554 } 555 556 html += LikeBtn.getPaymentSystemHtml(donate_obj.payment_systems[system_index], donate_obj.purpose) + ' '; 557 } 558 559 return html; 560}
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.