Changeset 964 for js/human_3d_alignment/src/widgets/fitviewer.jsx
- Timestamp:
- 06/27/20 17:57:53 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
js/human_3d_alignment/src/widgets/fitviewer.jsx
r912 r964 8 8 header: { 9 9 textAlign: 'center', 10 lineHeight: '0.1', 10 11 letterSpacing: '5px', 12 fontFamily: "'Fira Mono', Monaco, 'Andale Mono', 'Lucida Console', 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace", 13 webkitUserSelect : 'none', 14 mozUserSelect: 'none', 15 msUserSelect: 'none', 16 userSelect: 'none' 17 }, 18 info: { 19 textAlign: 'center', 20 lineHeight: '0.1', 21 fontSize: '10px', 11 22 fontFamily: "'Fira Mono', Monaco, 'Andale Mono', 'Lucida Console', 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace", 12 23 webkitUserSelect : 'none', … … 116 127 this.createThirdRow = this.createThirdRow.bind(this); 117 128 this.createFourthRow = this.createFourthRow.bind(this); 118 this.selectLetter = this.selectLetter.bind(this); 119 this.selectNumber = this.selectNumber.bind(this); 120 } 121 122 selectNumber(e) { 129 this.select = this.select.bind(this); 130 } 131 132 select(e) { 123 133 let item = null; 124 134 let index; 125 135 126 let type = 0;127 128 136 for (let i = 0; i < this.props.parts1; i++) { 129 137 let index2 = (i+1).toString(); 130 let itemRow1 = document.querySelector('#rowField1');131 138 let itemD = document.querySelector('#creature' + index2); 132 139 let itemP = document.querySelector('#p' + index2); 133 if ((e.target === itemD && e.target.parentNode.parentNode.parentNode === itemRow1) || (e.target === itemP && e.target.parentNode.parentNode.parentNode.parentNode == itemRow1)) { 134 type = 1; 140 if (e.target === itemD || e.target === itemP) { 135 141 item = null; 136 142 index = index2; … … 138 144 } 139 145 } 140 141 if (this.state.choosed != ' ') {142 if (type == 0) {143 this.setState({ choosed: ' ' }, function() {144 console.log(this.state.choosed);145 });146 } else {147 if (!isNaN(this.state.choosed)) {148 let index1 = this.props.selected1.indexOf(index.toString());149 let index2 = this.props.selected1.indexOf(this.state.choosed);150 151 this.props.handleChangeSelected(1, index1, this.state.choosed);152 this.props.handleChangeSelected(1, index2, index.toString());153 154 this.setState({ choosed: ' ' }, function() {155 console.log(this.state.choosed);156 });157 } else {158 this.setState({ choosed: index }, function() {159 console.log(this.state.choosed);160 });161 }162 163 164 }165 } else {166 if (item != null) {167 this.setState({ choosed: index }, function() {168 console.log(this.state.choosed);169 });170 }171 }172 }173 174 selectLetter(e) {175 let index;176 let indexL;177 178 let type = 0;179 146 180 147 for (let i = 0; i < this.props.parts2; i++) { … … 184 151 } else { 185 152 index2 = String.fromCharCode(i + 1 + 64); 186 } 187 let itemRow2 = document.querySelector('#rowCreature2'); 153 } 188 154 let itemD = document.querySelector('#creature' + index2); 189 155 let itemP = document.querySelector('#p' + index2); 190 191 if ((e.target === itemD && e.target.parentNode.parentNode.parentNode === itemRow2) || (e.target === itemP && e.target.parentNode.parentNode.parentNode.parentNode == itemRow2) || 192 (e.target === itemD && e.target.parentNode.parentNode.parentNode.parentNode === itemRow2) || (e.target === itemP && e.target.parentNode.parentNode.parentNode.parentNode.parentNode == itemRow2)) { 193 type = 1; 156 if (e.target === itemD || e.target === itemP) { 157 item = null; 194 158 index = index2; 195 indexL = index2; 196 if (indexL.charCodeAt(0) > 90) { 197 indexL = String.fromCharCode(indexL.charCodeAt(0) - 6); 198 } 159 item = document.querySelector('#creature' + index); 199 160 } 200 161 } 201 162 202 163 if (this.state.choosed != ' ') { 203 if (type == 0) { 204 for (let i = 0; i < Math.min(this.props.parts1, this.props.parts2); i++) { 205 let index2 = (i+1).toString(); 206 let itemD = document.querySelector('#field2-' + index2); 207 208 if (e.target === itemD) { 209 let temp = this.state.choosed; 210 if (this.state.choosed.charCodeAt(0) > 90) { 211 temp = String.fromCharCode(temp.charCodeAt(0) - 6); 164 if (!item) { 165 if (!isNaN(this.state.choosed)) { 166 for (let i = 0; i < Math.min(this.props.parts1, this.props.parts2); i++) { 167 let index2 = (i+1).toString(); 168 let itemD = document.querySelector('#field1-' + index2); 169 170 171 if (e.target === itemD) { 172 let index3 = this.props.selected1.indexOf(this.state.choosed); 173 174 if (index3 > -1) { 175 this.props.handleChangeSelected(1, index3, ' '); 176 } 177 this.props.handleChangeSelected(1, i, this.state.choosed); 212 178 } 213 214 let index3 = this.props.selected2.indexOf(temp); 215 216 if (index3 > -1) { 217 this.props.handleChangeSelected(2, index3, ' '); 179 } 180 } else { 181 for (let i = 0; i < Math.min(this.props.parts1, this.props.parts2); i++) { 182 let index2 = (i+1).toString(); 183 let itemD = document.querySelector('#field2-' + index2); 184 185 186 if (e.target === itemD) { 187 188 let temp = this.state.choosed; 189 if (this.state.choosed.charCodeAt(0) > 90) { 190 temp = String.fromCharCode(temp.charCodeAt(0) - 6); 191 } 192 193 let index3 = this.props.selected2.indexOf(temp); 194 195 if (index3 > -1) { 196 this.props.handleChangeSelected(2, index3, ' '); 197 } 198 this.props.handleChangeSelected(2, i, this.state.choosed); 218 199 } 219 this.props.handleChangeSelected(2, i, this.state.choosed);220 200 } 221 222 } 223 201 } 224 202 this.setState({ choosed: ' ' }, function() { 225 203 console.log(this.state.choosed); 226 204 }); 205 227 206 } else { 228 if (isNaN(this.state.choosed)) { 229 207 let item2 = document.querySelector('#creature' + this.state.choosed); 208 if ((item.parentNode.parentNode.parentNode.className == 'rowField' || item.parentNode.parentNode.parentNode.className == 'rowBench') && 209 (item2.parentNode.parentNode.parentNode.className == 'rowField' || item2.parentNode.parentNode.parentNode.className == 'rowBench')) { 210 let nr = 0; 211 let index1 = 0; 212 let index2 = 0; 230 213 let temp = this.state.choosed; 231 if (t emp.charCodeAt(0) > 90) {214 if (this.state.choosed.charCodeAt(0) > 90) { 232 215 temp = String.fromCharCode(temp.charCodeAt(0) - 6); 233 216 } 234 235 if (indexL == temp) { 217 if (!isNaN(this.state.choosed)) { 218 nr = 1; 219 index1 = this.props.selected1.indexOf(this.state.choosed); 220 index2 = this.props.selected1.indexOf(index); 221 } else { 222 nr = 2; 223 let temp1 = this.state.choosed; 224 let temp2 = index; 225 if (this.state.choosed.charCodeAt(0) > 90) { 226 temp1 = String.fromCharCode(temp1.charCodeAt(0) - 6); 227 } 228 if (index.charCodeAt(0) > 90) { 229 temp2 = String.fromCharCode(temp2.charCodeAt(0) - 6); 230 } 231 232 index1 = this.props.selected2.indexOf(temp); 233 index2 = this.props.selected2.indexOf(temp2); 234 } 235 this.props.handleChangeSelected(nr, index1, index); 236 this.props.handleChangeSelected(nr, index2, this.state.choosed); 237 238 this.setState({ choosed: ' ' }, function() { 239 console.log(this.state.choosed); 240 }); 241 } else { 242 if (item.parentNode.parentNode.parentNode.parentNode === item2.parentNode.parentNode.parentNode || 243 item.parentNode.parentNode.parentNode === item2.parentNode.parentNode.parentNode.parentNode) { 244 let nr = 0; 245 let index1 = 0; 246 let index2 = 0; 247 if (!isNaN(this.state.choosed)) { 248 nr = 1; 249 index1 = this.props.selected1.indexOf(this.state.choosed); 250 index2 = this.props.selected1.indexOf(index); 251 } else { 252 nr = 2; 253 let temp = this.state.choosed; 254 let temp2 = index; 255 if (this.state.choosed.charCodeAt(0) > 90) { 256 temp = String.fromCharCode(temp.charCodeAt(0) - 6); 257 } 258 if (index.charCodeAt(0) > 90) { 259 temp2 = String.fromCharCode(temp2.charCodeAt(0) - 6); 260 } 261 index1 = this.props.selected2.indexOf(temp); 262 index2 = this.props.selected2.indexOf(temp2); 263 } 264 this.props.handleChangeSelected(nr, index1, index); 265 this.props.handleChangeSelected(nr, index2, this.state.choosed); 236 266 this.setState({ choosed: ' ' }, function() { 237 267 console.log(this.state.choosed); 238 268 }); 239 269 } else { 240 let index1 = this.props.selected2.indexOf(indexL); 241 let index2 = this.props.selected2.indexOf(temp); 242 243 if (index1 > -1 && index2 > -1) { 244 this.props.handleChangeSelected(2, index1, this.state.choosed); 245 this.props.handleChangeSelected(2, index2, index); 246 this.setState({ choosed: ' ' }, function() { 247 console.log(this.state.choosed); 248 }); 249 } else if (index1 > -1 && index2 <= -1) { 250 this.props.handleChangeSelected(2, index1, this.state.choosed); 251 this.setState({ choosed: ' ' }, function() { 252 console.log(this.state.choosed); 253 }); 254 } else if (index1 <= -1 && index2 > -1) { 255 this.props.handleChangeSelected(2, index2, indexL); 256 this.setState({ choosed: ' ' }, function() { 257 console.log(this.state.choosed); 258 }); 259 } else { 260 this.setState({ choosed: index }, function() { 261 console.log(this.state.choosed); 262 }); 263 } 270 this.setState({ choosed: index }, function() { 271 console.log(this.state.choosed); 272 }); 264 273 } 265 } else { 266 this.setState({ choosed: index }, function() { 267 console.log(this.state.choosed); 268 }); 269 } 270 } 271 274 } 275 } 272 276 } else { 273 this.setState({ choosed: index }, function() { 274 console.log(this.state.choosed); 275 }); 277 if (item != null) { 278 this.setState({ choosed: index }, function() { 279 console.log(this.state.choosed); 280 }); 281 } 276 282 } 277 283 } … … 290 296 <div id={'creature' + this.props.selected1[i]} 291 297 className='creature1' 292 onMouseDown={this.select Number}298 onMouseDown={this.select} 293 299 style={styles.creatureBench1}> 294 300 <p id={'p' + this.props.selected1[i]} style={styles.creatureText}> … … 307 313 <div id={'creature' + this.props.selected1[i]} 308 314 className='creature1' 309 onMouseDown={this.select Number}315 onMouseDown={this.select} 310 316 style={styles.creatureBench}> 311 317 <p id={'p' + this.props.selected1[i]} style={styles.creatureText}> … … 321 327 <div id='cellnull' className='cell' style={styles.cell}> 322 328 <div id={'field1-'+(i+1).toString()} 323 onMouseDown = {this.select Number}329 onMouseDown = {this.select} 324 330 className='field' 325 331 style={styles.middleField}> … … 357 363 <div id={'creature' + value} 358 364 className='creature2' 359 onMouseDown={this.select Letter}365 onMouseDown={this.select} 360 366 style={styles.creatureBench2}> 361 367 <p id={'p' + value} style={styles.creatureText}> … … 374 380 <div id={'creature' + value} 375 381 className='creature2' 376 onMouseDown={this.select Letter}382 onMouseDown={this.select} 377 383 style={styles.creatureBench}> 378 384 <p id={'p' + value} style={styles.creatureText}> … … 388 394 <div id='cellnull' className='cell' style={styles.cell}> 389 395 <div id={'field2-'+(i+1).toString()} 390 onMouseDown = {this.select Letter}396 onMouseDown = {this.select} 391 397 className='field' 392 398 style={styles.middleField}> … … 421 427 <div id={'creature' + idtext} 422 428 className='creature2' 423 onMouseDown={this.select Letter}429 onMouseDown={this.select} 424 430 style={styles.creatureBench2}> 425 431 <p id={'p' + idtext} style={styles.creatureText}> … … 434 440 <div id={'creature' + idtext} 435 441 className='creature2' 436 onMouseDown={this.select Letter}442 onMouseDown={this.select} 437 443 style={styles.creatureBench}> 438 444 <p id={'p' + idtext} style={styles.creatureText}> … … 460 466 461 467 return ( 462 <div id='fit' className='fit' onMouseDown={ev => {if (ev) ev.stopPropagation();}} onTouchStart={ev => {if (ev) ev.stopPropagation();}} style={{position: 'relative', width: w, height: h, whiteSpace: 'no-wrap', overflow: 'auto'}}>468 <div id='fit' className='fit' onMouseDown={ev => {if (ev) ev.stopPropagation();}} onTouchStart={ev => {if (ev) ev.stopPropagation();}}>{/* style={{position: 'relative', width: w, height: h, whiteSpace: 'no-wrap', overflow: 'auto'}}>*/} 463 469 <h2 className='title' style={styles.header}> 464 470 DOPASOWANIE 465 471 </h2> 466 467 <div key='rowsFields' className="rows" style={{display: 'table', borderCollapse: 'separate', borderSpacing: '15px'}}> 468 <div id='rowCreature1' onMouseDown = {this.selectNumber}> 469 <div id='rowField1' className='rowField' onMouseDown = {this.selectNumber} style={styles.row}> 472 <div key='rowsFields' onMouseDown = {this.select} className="rows" style={{display: 'table', borderCollapse: 'separate', borderSpacing: '15px'}}> 473 <div id='rowCreature1' onMouseDown = {this.select}> 474 <div id='rowField1' className='rowField' onMouseDown = {this.select} style={styles.row}> 470 475 {this.createSecondRow()} 471 476 </div> 472 477 </div> 473 <div id='rowCreature2' onMouseDown = {this.selectLetter}> 474 <div id='rowField2' className='rowField' onMouseDown = {this.selectLetter} style={styles.row}> 478 <div className='text' style={styles.info}> 479 w najwyższy rząd cyferek nie klikamy 480 </div> 481 <div id='rowCreature2'> 482 <div id='rowField2' className='rowField' onMouseDown = {this.select} style={styles.row}> 475 483 {this.createThirdRow()} 476 484 </div> 477 <div id='rowBench2' className='rowBench' onMouseDown = {this.select Letter} style={styles.row}>485 <div id='rowBench2' className='rowBench' onMouseDown = {this.select} style={styles.row}> 478 486 {this.createFourthRow()} 479 487 </div>
Note: See TracChangeset
for help on using the changeset viewer.