Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var found = [];
- var bait_pos = ["Worm","Maggot","Cricket","Locust","GreenMoth","GreyMoth","Crayfish","Shrimp"];
- var hook_pos = ["Standard","Slim","Large","Double","Bone","Wood"];
- var weight_pos = [1,2,3,4,5,6];
- var inner_reset = "";
- var previous = {'select_bait':[-1],'select_hook':[-1],'select_weight':[-1]};
- var sel1,sel2,sel3;
- valid=true;
- function start() {/*
- a1lib.identifyUrl("appconfig.json");
- if (!window.alt1) { document.getElementById("mainTable").innerHTML = "You need to run Alt1 to for this app."; valid=false;}
- else if (alt1.versionint < 8) { document.getElementById("mainTable").innerHTML = "You need at least Alt1 0.0.8 for this app";valid=false;}
- */inner_reset=document.getElementById("mainTable").innerHTML;
- populateOptions();
- return;
- }
- function clicksolve() {
- /*if(valid){
- var img;
- try { img = a1lib.bindfullrs(); } catch (e) { }
- if (!img) {
- var problem = "Failed to grab image from your screen. There is more information under Alt1 settings > capture.";
- if (alt1.permissionPixel == false) { problem = "Need 'view screen' permission to grab pixels from the screen. The app permissions can be found by clicking the spanner on the top right of this window."; }
- if (alt1.rsLinked == false) { problem = "Can't find the Runescape window. There is more information under Alt1 settings > capture."; }
- document.getElementById("mainTable").innerHTML = problem;
- return;
- }*/
- solve(); //solve(img);
- }
- function solve(img){
- //TODO: IMAGE DETECT TO FIND ROW IN MINIGAME
- //ASSUME FOLLOWING ROW(s) FOUND (IN CATCH HISTORY):
- //
- //Salmon | Docks | 29 | Crayfish | Large | 3 | 100 <--100% fish found
- row={fish:"Salmon",loc:"Docks",bait:"Crayfish",hook:"Large",weight:3,percent:100} //(returned from image detect)
- if(row['percent']==100 && found.indexOf(row['fish'])){ //if not already found
- found.push(row['fish']);
- var str = "<td>"+row['fish']+"</td><td>"+row['loc']+"</td><td>"+row['bait']+"</td><td>"+row['hook']+"</td><td>"+row['weight']+"</td>"
- sel1=document.getElementById(row['fish']).getElementsByClassName("select_bait")[0].selectedIndex;
- sel2=document.getElementById(row['fish']).getElementsByClassName("select_hook")[0].selectedIndex;
- sel3=document.getElementById(row['fish']).getElementsByClassName("select_weight")[0].selectedIndex;
- document.getElementById(row['fish']).innerHTML = str;
- bait_pos.splice( bait_pos.indexOf( row['bait']),1);
- hook_pos.splice( hook_pos.indexOf( row['hook']),1);
- weight_pos.splice(weight_pos.indexOf(row['weight']),1);
- removeOptions(row['bait'],row['hook'],row['weight']);
- //TODO: overlay an X over removed value's to indicate they should not be used again.
- }
- }
- function removeOptions(bait,hook,weight){ //remove options for confirmed 100% fish
- e1=document.getElementsByClassName("select_bait");
- e2=document.getElementsByClassName("select_hook");
- e3=document.getElementsByClassName("select_weight");
- for(i=0; i<e1.length; i++){
- for(j=0; j<e1[i].length; j++){
- if(e1[i][j].value==bait){
- e1[i].remove(j);
- }
- }
- for(j=0; j<e2[i].length; j++){
- if(e2[i][j].value==hook){
- e2[i].remove(j);
- }
- }
- for(j=0; j<e3[i].length; j++){
- if(e3[i][j].value==weight){
- e3[i].remove(j);
- }
- }
- }
- e1=document.getElementsByClassName("select_bait");
- e2=document.getElementsByClassName("select_hook");
- e3=document.getElementsByClassName("select_weight");
- for(i=0; i<e1.length;i++){
- previous = {'select_bait':[-1],'select_hook':[-1],'select_weight':[-1]};
- if(e1[i].selectedIndex!=0){
- previous['select_bait'].push(e1[i].selectedIndex);
- }
- if(e2[i].selectedIndex!=0){
- previous['select_hook'].push(e2[i].selectedIndex);
- }
- if(e3[i].selectedIndex!=0){
- previous['select_weight'].push(e3[i].selectedIndex);
- }
- }
- for(i=0; i<e1.length; i++){
- e1[i][sel1].disabled = false;
- e2[i][sel2].disabled = false;
- e3[i][sel3].disabled = false;
- }
- }
- function cellChanged(){
- e = document.getElementsByClassName(event.target.className);
- var indexes = [-1];
- for(i=0;i<e.length;i++){ //disable
- if(e[i].selectedIndex!=0){
- indexes.push(e[i].selectedIndex);
- }
- if(event.target.selectedIndex!=0&&e[i]!=event.target){
- e[i][event.target.selectedIndex].disabled = true;
- }
- }
- //for values in previous not in current index
- for(i=0;i<previous[event.target.className].length;i++){
- if(indexes.indexOf(previous[event.target.className][i])==-1){
- for(j=0;j<e.length;j++){
- e[j][previous[event.target.className][i]].disabled=false;
- }
- }
- } previous[event.target.className] = indexes;
- }
- function reset(){
- found = [];
- bait_pos = ["Worm","Maggot","Cricket","Locust","Crayfish","Shrimp","Grey Moth","Green Moth"];
- hook_pos = ["Standard","Slim","Large","Double","Bone","Wood"];
- weight_pos = [1,2,3,4,5,6];
- previous = {'select_bait':[-1],'select_hook':[-1],'select_weight':[-1]};
- document.getElementById("mainTable").innerHTML = inner_reset;
- populateOptions();
- }
- function populateOptions(){
- var columns,column,z,output;
- columns = ['location','bait','hook','weight'];
- for(z=0;z<columns.length;z++){
- column = columns[z];
- if(column=="location"){s=["Docks","River","Lake","Beach"];}
- else if(column=="bait"){s=bait_pos;}
- else if(column=="hook"){s=hook_pos;}
- else if(column=="weight"){s=weight_pos;}
- output = "<select class=select_"+column+"><option>-</option>"
- for(i=0; i<s.length;i++){
- output = output+ "<option>" + s[i] + "</option>";
- } output = output + "</select>"
- e = document.getElementsByClassName(column);
- for(i=0; i<e.length;i++){
- e[i].innerHTML = output;
- }
- if(!(column=='location')){
- e = document.getElementsByClassName("select_"+column);
- for(i=0;i<e.length;i++){
- e[i].addEventListener('change',cellChanged);
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment