1function baseList_selectorChoseAddItem(baseListId, itemId, itemName) 2{ 3 if (window.opener.baseListArray[baseListId] == undefined) { 4 window.opener.baseListArray[baseListId] = new Array(); 5 } 6 7 if (window.opener.baseListArray[baseListId][itemId] == undefined) { 8 item = 9 '<div id ="div-' + baseListId + '-' + itemId + '">' 10 + itemName + ' <input type="button" class="baseList-selector-removeItem" id="a-div-' + baseListId + '-' + itemId + '" value="(X)" />' + 11 '</div>'; 12 13 window.opener.jQuery('#div-' + baseListId).append(item); 14 if (window.opener.jQuery('.div-' + baseListId + '-hideOnAdd').length > 0) { 15 window.opener.jQuery('.div-' + baseListId + '-hideOnAdd').hide(); 16 } 17 18 window.opener.baseListArray[baseListId][itemId] = 1; 19 } 20 21 window.opener.jQuery('input[name="' + baseListId + '"]').attr('value', ''); 22 23 if (window.opener.jQuery('.' + baseListId + 'Reload').length > 0) { 24 window.opener.jQuery('.' + baseListId + 'Reload').valid(); 25 } 26} 27 28function baseList_wipeOpenerItems(baseListId) 29{ 30 for (var index in window.opener.baseListArray[baseListId]) { 31 window.opener.jQuery('#div-' + baseListId + '-' + index).remove(); 32 delete window.opener.baseListArray[baseListId][index]; 33 34 if (window.opener.jQuery('.div-' + baseListId + '-showOnDelete').length > 0) { 35 window.opener.jQuery('.div-' + baseListId + '-showOnDelete').show(); 36 } 37 38 if (window.opener.jQuery('.' + baseListId + 'Reload').length > 0) { 39 window.opener.jQuery('.' + baseListId + 'Reload').valid(); 40 } 41 } 42} 43 44$(document).ready(function(){ 45 46 if (window.baseListArray == undefined) { 47 window.baseListArray = new Array(); 48 } 49 50 $('.baseList-selectorChoose').click(function() { 51 id = $(this).attr('id'); 52 id = id.substr(5); 53 name = $('#item-' + id + '-name').html(); 54 baseListId = $('#baseListId').html(); 55 56 baseList_selectorChoseAddItem(baseListId, id, name); 57 58 self.close(); 59 }); 60 61 $('.baseList-selector-removeItem').live('click', function() { 62 itemId = '#' + $(this).attr('id').substr(2); 63 $(itemId).remove(); 64 65 myString = $(this).attr('id').substr(6); 66 myArray = myString.split('-'); 67 baseListId = myArray[0]; 68 id = myArray[1]; 69 70 if ($('.div-' + baseListId + '-showOnDelete').length > 0) { 71 $('.div-' + baseListId + '-showOnDelete').show(); 72 } 73 74 delete window.baseListArray[baseListId][id]; 75 76 if ($('.' + baseListId + 'Reload').length > 0) { 77 $('.' + baseListId + 'Reload').valid(); 78 } 79 }); 80 81 $('.baseList-selectorShow').click(function() { 82 baseListHandle = '#' + $(this).attr('name'); 83 baseListId = $(baseListHandle).attr('name'); 84 baseListSearch = $(baseListHandle).attr('value'); 85 86 urlPlus = ''; 87 if ($(this).hasClass('new-form')) { 88 urlPlus += '&new-form=1'; 89 } 90 91 window.open( 92 CLE_nonRootPrefix + 'admin/books/' + baseListId + '/selector/?s=' + baseListSearch + urlPlus, 93 "_blank", 94 "width=800,height=500,toolbar=0,status=0,scrollbars=yes" 95 ); 96 }); 97 98 baseListfieldKeyPrevent = false; 99 $('.baseList-selector-searchField').keypress(function(e) { 100 if (e.keyCode == 40 101 || e.keyCode == 38 102 || e.keyCode == 34 103 || e.keyCode == 33 104 ) { 105 baseListfieldKeyPrevent = true; 106 } else { 107 if (e.keyCode == 13 && !baseListfieldKeyPrevent) { 108 baseListfieldKeyPrevent = false; 109 110 baseListId = $(this).attr('name'); 111 baseListSearch = $(this).attr('value'); 112 113 urlPlus = ''; 114 if ($(this).hasClass('new-form')) { 115 urlPlus += '&new-form=1'; 116 } 117 118 window.open( 119 CLE_nonRootPrefix + 'admin/books/' + baseListId + '/selector/?s=' + baseListSearch + urlPlus, 120 "_blank", 121 "width=800,height=500,toolbar=0,status=0,scrollbars=yes" 122 ); 123 124 return false;
125 } else { 126 baseListfieldKeyPrevent = false; 127 if (e.keyCode == 13) { 128 return false; 129 } 130 } 131 } 132 }); 133 134 $("#baseList-selector-new-item").submit(function() { 135 baseListId = $('input[name="baseListId"]').attr('value'); 136 name = $('#add').attr('value'); 137 138 $.getJSON( 139 CLE_nonRootPrefix + 'json/baseList/', 140 { 141 "a" : 'tokenGet' 142 }, 143 function(data) { 144 $.getJSON( 145 CLE_nonRootPrefix + 'json/baseList/', 146 { 147 "a": 'getId', 148 "json_token" : data['json_token'], 149 150 "baseListId" : baseListId, 151 "name" : name 152 }, 153 function(data2) { 154 id = data2['item-id']; 155 156 baseList_selectorChoseAddItem(baseListId, id, name); 157 158 self.close(); 159 }); 160 }); 161 162 return false; 163 }); 164 165});
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.