1$(document).ready(function() { 2 var $con = $('<div id="title_con" />').insertAfter('table.product.detail').hide(); 3 var $editor = $('<div id="title_editor" />').appendTo($con); 4 var $preview = $('<div id="title_preview" class="alt1"></div>').appendTo($con); 5 6 var show_title_editor = function() { 7 //$('table.titlechange.detail').hide(); 8 $con.show(); 9 $('div.buttons').show(); 10 /* 11 $('table.titlechange.detail').hide('blind', {}, 10, 12 function() { 13 $con.show('drop', {}, 2000, function() { 14 $('div.buttons').show(); 15 }); 16 } 17 ); 18 */ 19 }; 20 21 var fx_flash = function(el, n) { $(el).effect('pulsate', { times:n }, 400) } 22 23 var stash = { 24 user_in_cart: false, 25 targetid: 0, 26 username: "", 27 title_text: "", 28 title_imageid: 0, 29 title_centered: 0, 30 title_for: 'SELF' 31 }; 32 33 var $input_username = $('input#username'); 34 var $input_password = $('input#password'); 35 var $input_targets = $('.target_option input'); 36 37 $('div.buttons').hide(); 38 $('tr.nojs').hide(); 39 $('tr.account_password').hide(); 40 41 var $diag_add_wait = $('<div id="title_add_wait">').dialog({ 42 modal: true, 43 title: 'Adding to cart...', 44 autoOpen: false, 45 closeOnEscape: false, 46 width: 400, 47 dialogClass: 'add_wait', 48 buttons: {} 49 }); 50 51 $('div.buttons input').click(function(e) { 52 var $self = $(this); 53 if($self.data('busy') === true) return; 54 $self.addClass('spin').data('busy', true); 55 $diag_add_wait.html('Please hold while we add this item to your shopping cart!<br><div class="pb1"/>').dialog('open'); 56 57 stash.title_text = $('textarea#title_text').val(); 58 59 setTimeout(function() { 60 $.ajax({ 61 data: stash, 62 url: '/xhr/title_add.php', 63 type: 'POST', 64 success: function(data) { 65 if(data.success) { 66 window.location = '/cart/index.php'; 67 } else { 68 alert('Could not add title to cart! ' + data.error); 69 $self.removeClass('spin').data('busy', false); 70 $diag_add_wait.dialog('close'); 71 } 72 }, 73 error: function() { 74 alert('Could not add title to cart!'); 75 $self.removeClass('spin').data('busy', false); 76 $diag_add_wait.dialog('close'); 77 } 78 }); 79 }, 700); 80 81 return false; 82 }); 83 84 var $btn_get_pass = $('<button/>').insertAfter($input_password).text('GO').button().click(function() { 85 var $self = $(this); 86 var password = $input_password.val(); 87 if($self.data('busy') === true) return; 88 $self.data('busy', true); 89 $input_password.prop('disabled', true); 90 $.ajax({ 91 type: 'POST', 92 url: '/xhr/check_auth.php', 93 data: { 94 username: $input_username.val(), 95 userid: stash.targetid, 96 password: $input_password.val(), 97 title_for: stash.title_for 98 }, 99 success: function(data) { 100 if(data.success && data.authenticated) { 101 stash['password'] = $input_password.val(); 102 //$('tr.account_password').hide(); 103 $btn_get_pass.hide(); 104 show_title_editor(); 105 } else { 106 alert('Authentication failed! Check your password'); 107 $input_password.prop('disabled', false).focus().select(); 108 } 109 $self.data('busy', false); 110 }, 111 error: function() { 112 alert('Could not authenticate user!'); 113 $input_password.prop('disabled', false).focus().select(); 114 $self.data('busy', false); 115 } 116 }); 117 return false; 118 }); 119 120 $input_password.keydown(function(e) { 121 if(e.which == 13) { 122 $btn_get_pass.click(); 123 e.preventDefault(); 124 return false; 125 } 126 }); 127 128 var $btn_get_user = $('<button/>').insertAfter($input_username).text('GO').button().click(function(e) { 129 var $self = $(this); 130 if($self.data('busy') === true) return; 131 $self.data('busy', true); 132 $input_username.prop('disabled', true); 133 $.ajax({ 134 type: 'POST', 135 url: '/xhr/check_user.php', 136 data: { username: $input_username.val(), title_for: stash.title_for }, 137 success: function(data) { 138 $('.messagebox').hide('fade'); 139 var targetid; 140 if(data.success) { 141 if(data.user_in_cart) { 142 targetid = data.requestid; 143 show_title_editor(); 144 } else { 145 targetid = data.userid; 146 if(stash.title_for == 'SELF') { 147 $('tr.account_password') 148 .focus().show() 149 .find('td.password').append('<i>Enter password for this user to continue</i>'); 150 $input_password.focus(); 151 $('.target_option.other').hide(); 152 fx_flash($input_password, 3); 153 } else { 154 show_title_editor(); 155 $('.target_option.self').hide(); 156 } 157 } 158 159 $input_targets.prop('disabled', true); 160 $('.target_option').addClass('disable'); 161 162 stash['user_in_cart'] = data.user_in_cart ? 1 : 0; 163 stash['targetid'] = targetid; 164 stash['username'] = $input_username.val(); 165 166 $preview.find('.author').text(stash['username']); 167 168 $btn_get_user.hide(); 169 } else { 170 $input_username.prop('disabled', false).focus().select();
171 alert('Could not find username in forums or shopping cart!'); 172 } 173 $self.data('busy', false); 174 }, 175 error: function() { 176 $self.data('busy', false); 177 $input_username.prop('disabled', false).focus().select(); 178 alert('Could not lookup username!'); 179 } 180 }); 181 return false; 182 }); 183 184 $input_targets.change(function() { 185 //$(this).find('~ label').each(function(i,e) { fx_flash(e, 1) }); 186 stash.username = ''; 187 stash.password = ''; 188 stash.targetid = 0; 189 stash.title_for = $(this).val(); 190 $input_password.val('').prop('disabled', false); 191 $input_username.val('').prop('disabled', false).focus().select(); 192 $btn_get_user.show(); 193 fx_flash($input_username, 3); 194 $('tr.account_password').hide(); 195 196 var newprice; 197 if(stash.title_for == 'SELF') { 198 $('tr.account_username .username i').text('Existing user or a new user in your cart'); 199 newprice = price.self; 200 } else { 201 $('tr.account_username .username i').text('Enter username of any existing user'); 202 newprice = price.other; 203 } 204 $('span.total_price').text(newprice); 205 }); 206 207 $('form input').keypress(function(e) { 208 if(e.which == 13) { 209 e.stopPropagation(); 210 e.preventDefault(); 211 return false; 212 } 213 }); 214 215 $input_username.keypress(function(e) { 216 if(e.which == 13) { 217 $btn_get_user.click(); 218 e.stopPropagation(); 219 e.preventDefault(); 220 return false; 221 } 222 }); 223 224 /*****************************************************/ 225 /*****************************************************/ 226 227 var max_title_chars = 300; 228 var $input_ta = $('textarea#title_text'); 229 $input_ta.attr('maxlength', max_title_chars); 230 231 var counter_timer = function() { 232 setTimeout(function() { 233 var len = $input_ta.val().length; 234 if(len >= 300) len = '<b>' + len + '</b>'; 235 $('#charcount').html(len); 236 counter_timer(); 237 }, 700); 238 }; 239 counter_timer(); 240 241 $editor.html( 242 '<div class="inner editarea">' + 243 '<h3>Custom Title Editor</h3>' + 244 'User account accepted! Specify the custom title below:<br>' + 245 '<br>' + 246 '<h5>Title Image</h5>' + 247 '<i>Must be smaller than 180x180 pixels and no larger than 250kB. Only GIF, PNG, ' + 248 'and JPG images are allowed. Images should be "work-safe".</i><br>' + 249 '<div class="buttons-image"></div>' + 250 '' + 251 '<h5>Title Text</h5>' + 252 '<i>You have used <span id="charcount">0</span> of ' + max_title_chars + ' characters allowed.</i>' + 253 '' + 254 '</div>' 255 ); 256 257 $editor.find('.inner').append($input_ta); 258 259 $preview.html( 260 '<div class="inner preview">' + 261 '<h3>Preview</h3><br>' + 262 '<table><tr class="row alt1"><td class="user">' + 263 '<dl class="userinfo">' + 264 '<dt class="author">Your Username</dt>' + 265 '<dt class="registered">May 04, 2006</dt>' + 266 '<dt class="title">' + 267 '<div class="title_image"></div><div class="title_text"></div>' + 268 '</dt>' + 269 '</dl></td><td class="fakepost">' + 270 '<div>' + 271 'This is some text that is fake<br>' + 272 'and furthermore I would like to<br>' + 273 'drive my bike up your ass today.<br><br>' + 274 'Touching myself is lots of fun<br>' + 275 'although I am not very good at it.<br>' + 276 '</div>' + 277 '</td></tr>' + 278 '<tr class="row alt1"><td class="postdate">May 09, 2009 05:40</td><td></td></tr>' + 279 '</table>' + 280 '</div>' 281 ); 282 283 /*****************************************************/ 284 /*****************************************************/ 285 286 var $upload_progress = $('<div>Please wait while your image is uploaded...<br></div>').appendTo('body'); 287 $upload_progress.dialog({ 288 modal: true, 289 title: 'Upload in progress...', 290 autoOpen: false, 291 closeOnEscape: false, 292 width: 400, 293 dialogClass: 'uploader', 294 buttons: {} 295 }); 296 297 var $btn_img_select = $('<div class="title-ui-button">Upload Image</div>').addClass('upload').button().appendTo('.buttons-image'); 298 var $btn_img_remove = $('<a class="title-ui-button">Remove Image</a>').addClass('remove').button().addClass('disabled').appendTo('.buttons-image'); 299 300 var uploader; 301 uploader = new qq.FineUploaderBasic({ 302 request: { 303 endpoint: '/image_upload/store.php' 304 }, 305 callbacks: { 306 onSubmit: function(id, filename) { $(uploader).trigger('uploadBegin') }, 307 onComplete: function(id, filename, response) { 308 $upload_progress.dialog('close'); 309 if(response.success) { 310 $(uploader).trigger('uploadSuccess', [ response.imageid ]); 311 } else { 312 $(uploader).trigger('uploadFail', [ response.error ]); 313 } 314 }, 315 onError: function(id, filename, errorReason, xhr) { 316 $upload_progress.dialog('close'); 317 // alert("failed"); 318 } 319 }, 320 321 button: $btn_img_select[0], 322 allowedExtensions: ['jpg','png','gif','jpeg'], 323 sizeLimit: (250 * 1024), 324 image: { 325 maxHeight: 180, 326 maxWidth: 180, 327 }, 328 multiple: false, 329 itemLimit: 1, 330 debug: false, 331 }); 332 333 $btn_img_select.find('.qq-upload-button').addClass('ui-button-text'); 334 335 /*****************************************************/ 336 /*****************************************************/ 337 338 var previewer = {}; 339 340 var $btn_text_preview = $('<div class="title-ui-button update-preview">Update Preview</div>'); 341 $btn_text_preview.insertAfter($input_ta).wrap('<div class="buttons-text"/>'); 342 $btn_text_preview.button().click(function() { 343 if($(this).hasClass('disabled')) return; 344 $btn_text_preview.addClass('disabled'); 345 $.ajax({ 346 url: '/xhr/render_title.php', 347 type: "POST", 348 data: { title_text: $input_ta.val() }, 349 success: function(data) { 350 $btn_text_preview.removeClass('disabled'); 351 $(previewer).trigger('titlePreviewReady', [ data.title_parsed ]); 352 }, 353 error: function() { 354 $btn_text_preview.removeClass('disabled'); 355 $(previewer).trigger('titlePreviewFail'); 356 } 357 }); 358 }); 359 360 $('<div class="title-options"/>') 361 .insertBefore('.buttons-text') 362 .append('<input type="checkbox" name="cb_bbcode_center" id="cb_bbcode_center"> <label for="cb_bbcode_center">Center title horizontally</label>') 363 .find('input') 364 .change(function() { 365 stash['title_centered'] = ($(this).prop('checked') === true) ? 1 : 0; 366 $('#title_preview .userinfo .title').css({ 'text-align': (stash['title_centered'] ? 'center' : 'left') }); 367 }) 368 ; 369 370 /*****************************************************/ 371 /*****************************************************/ 372 373 $(uploader).bind('uploadBegin', function(e) { 374 $upload_progress.dialog('open'); 375 }); 376 377 $(uploader).bind('uploadSuccess', function(e, imageid) { 378 stash.title_imageid = imageid; 379 var img_src = '/image_upload/show.php?imageid=' + imageid; 380 $('dt.title .title_image').html('<img src="' + img_src + '">'); 381 382 $btn_img_remove.removeClass('disabled').one('click', function() { 383 stash.title_imageid = 0; 384 $(this).addClass('disabled'); 385 $('dt.title .title_image').html(''); 386 }); 387 }); 388 389 $(uploader).bind('uploadFail', function(e, error) { 390 alert(error); 391 }); 392 393 $(previewer).bind('titlePreviewReady', function(e, title) { 394 title = decodeURIComponent(escape(title)); 395 $('dt.title .title_text').html(title); 396 }); 397 398 $(previewer).bind('titlePreviewFail', function(e) { 399 alert("Title preview failed to load"); 400 }); 401 402 /*****************************************************/ 403 /*****************************************************/ 404 405}); 406
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.