我正在编写一些代码来识别Google表格中的学校。除非我减少If..else语句的数量,否则该函数不会运行。目前大约有204个。当我删除一大块这些函数时,会运行导致我相信它,因为if..else结构太大了。
如何简化以下代码才能运行。非常感谢任何帮助:)
if (school == "Abernethy Primary") {group ="/Primary/Abernethy Primary/"; domain ="GrantownGrammar.org.uk"; schoolType ="Primary";}
else if (school == "Acharacle Primary") {group ="/Primary/Acharacle Primary/"; domain ="ArdnamurchanHigh.org.uk"; schoolType ="Primary";}
else if (school == "Achiltibuie Primary") {group ="/Primary/Achiltibuie Primary/"; domain ="UllapoolHigh.org.uk"; schoolType ="Primary";}
else if (school == "Aldourie Primary") {group ="/Primary/Aldourie Primary/"; domain ="InvernessRoyalAcademy.org.uk"; schoolType ="Primary";}
else if (school == "Alness Academy") {group ="/Secondary/Alness Academy/"; domain ="AlnessAcademy.org.uk"; schoolType ="Secondary";}
else if (school == "Altnaharra Primary") {group ="/Primary/Altnaharra Primary/"; domain ="FarrHigh.org.uk"; schoolType ="Primary";}
else if (school == "Alvie Primary") {group ="/Primary/Alvie Primary/"; domain ="KingussieHigh.org.uk"; schoolType ="Primary";}
else if (school == "Applecross Primary") {group ="/Primary/Applecross Primary/"; domain ="PlocktonHigh.org.uk"; schoolType ="Primary";}
else if (school == "Ardersier Primary") {group ="/Primary/Ardersier Primary/"; domain ="CullodenAcademy.org.uk"; schoolType ="Primary";}
else if (school == "Ardgour Primary") {group ="/Primary/Ardgour Primary/"; domain ="ArdnamurchanHigh.org.uk"; schoolType ="Primary";}
else if (school == "Ardnamurchan High School") {group ="/Secondary/Ardnamurchan High School/"; domain ="ArdnamurchanHigh.org.uk"; schoolType ="Secondary";}
else if (school == "Ardross Primary") {group ="/Primary/Ardross Primary/"; domain ="AlnessAcademy.org.uk"; schoolType ="Primary";}
else if (school == "Arisaig Primary") {group ="/Primary/Arisaig Primary/"; domain ="MallaigHigh.org.uk"; schoolType ="Primary";}
else if (school == "Auchtertyre Primary") {group ="/Primary/Auchtertyre Primary/"; domain ="PlocktonHigh.org.uk"; schoolType ="Primary";}
else if (school == "Auldearn Primary") {group ="/Primary/Auldearn Primary/"; domain ="NairnAcademy.net"; schoolType ="Primary";}
else if (school == "Aviemore Primary") {group ="/Primary/Aviemore Primary/"; domain ="KingussieHigh.org.uk"; schoolType ="Primary";}
else if (school == "Avoch Primary") {group ="/Primary/Avoch Primary/"; domain ="FortroseAcademy.org.uk"; schoolType ="Primary";}
else if (school == "Badcaul Primary") {group ="/Primary/Badcaul Primary/"; domain ="UllapoolHigh.org.uk"; schoolType ="Primary";}
else if (school == "Ballachulish Primary") {group ="/Primary/Ballachulish Primary/"; domain ="KinlochlevenHigh.org.uk"; schoolType ="Primary";}
else if (school == "Balloch Primary") {group ="/Primary/Balloch Primary/"; domain ="CullodenAcademy.org.uk"; schoolType ="Primary";}
else if (school == "Balnain Primary") {group ="/Primary/Balnain Primary/"; domain ="GlenurquhartHigh.org.uk"; schoolType ="Primary";}
else if (school == "Banavie Primary") {group ="/Primary/Banavie Primary/"; domain ="LochaberHigh.org.uk"; schoolType ="Primary";}
else if (school == "Beauly Primary") {group ="/Primary/Beauly Primary/"; domain ="CharlestonAcademy.org.uk"; schoolType ="Primary";}
else if (school == "Ben Wyvis Primary") {group ="/Primary/Ben Wyvis Primary/"; domain ="DingwallAcademy.org.uk"; schoolType ="Primary";}
else if (school == "Bishop Eden Primary") {group ="/Primary/Bishop Eden Primary/"; domain ="InvernessHigh.org.uk"; schoolType ="Primary";}
else if (school == "Black Isle Education Centre") {group ="/Special/Black Isle Education Centre/"; domain ="Highlandschools.net"; schoolType ="Special";}
else if (school == "Bonar Bridge Primary") {group ="/Primary/Bonar Bridge Primary/"; domain ="DornochAcademy.org.uk"; schoolType ="Primary";}
else if (school == "Bower Primary") {group ="/Primary/Bower Primary/"; domain ="WickHigh.org.uk"; schoolType ="Primary";}
else if (school == "Bridgend Primary") {group ="/Primary/Bridgend Primary/"; domain ="AlnessAcademy.org.uk"; schoolType ="Primary";}
else if (school == "Broadford Primary") {group ="/Primary/Broadford Primary/"; domain ="PortreeHigh.org.uk"; schoolType ="Primary";}
else if (school == "Brora Primary") {group ="/Primary/Brora Primary/"; domain ="GolspieHigh.org.uk"; schoolType ="Primary";}
else if (school == "Bualnaluib Primary") {group ="/Primary/Bualnaluib Primary/"; domain ="GairlochHigh.org.uk"; schoolType ="Primary";}
else if (school == "Bun-sgoil Ghaidhlig Inbhir Nis") {group ="/Primary/Bun-sgoil Ghaidhlig Inbhir Nis/"; domain ="InvernessRoyalAcademy.org.uk"; schoolType ="Primary";}
else if (school == "Bun-sgoil Ghaidhlig Loch Abar") {group ="/Primary/Bun-sgoil Ghaidhlig Loch Abar/"; domain ="LochaberHigh.org.uk"; schoolType ="Primary";}
else if (school == "Bun-sgoil Shll-ite") {group ="/Primary/Bun-sgoil Shll-ite/"; domain ="PortreeHigh.org.uk"; schoolType ="Primary";}
else if (school == "Canisbay Primary") {group ="/Primary/Canisbay Primary/"; domain ="WickHigh.org.uk"; schoolType ="Primary";}
else if (school == "Canna Primary") {group ="/Primary/Canna Primary/"; domain ="MallaigHigh.org.uk"; schoolType ="Primary";}
else if (school == "Cannich Bridge Primary") {group ="/Primary/Cannich Bridge Primary/"; domain ="GlenurquhartHigh.org.uk"; schoolType ="Primary";}
else if (school == "Caol Primary") {group ="/Primary/Caol Primary/"; domain ="LochaberHigh.org.uk"; schoolType ="Primary";}
else if (school == "Carbost Primary") {group ="/Primary/Carbost Primary/"; domain ="PortreeHigh.org.uk"; schoolType ="Primary";}
else if (school == "Carrbridge Primary") {group ="/Primary/Carrbridge Primary/"; domain ="GrantownGrammar.org.uk"; schoolType ="Primary";}
else if (school == "Castletown Primary") {group ="/Primary/Castletown Primary/"; domain ="ThursoHigh.org.uk"; schoolType ="Primary";}
else if (school == "Cauldeen Primary") {group ="/Primary/Cauldeen Primary/"; domain ="InvernessRoyalAcademy.org.uk"; schoolType ="Primary";}
else if (school == "Cawdor Primary") {group ="/Primary/Cawdor Primary/"; domain ="NairnAcademy.net"; schoolType ="Primary";}
else if (school == "Central Primary") {group ="/Primary/Central Primary/"; domain ="InvernessHigh.org.uk"; schoolType ="Primary";}
else if (school == "Charleston Academy") {group ="/Secondary/Charleston Academy/"; domain ="CharlestonAcademy.org.uk"; schoolType ="Secondary";}
else if (school == "Coulhill Primary") {group ="/Primary/Coulhill Primary/"; domain ="AlnessAcademy.org.uk"; schoolType ="Primary";}
else if (school == "Cradlehall Primary") {group ="/Primary/Cradlehall Primary/"; domain ="CullodenAcademy.org.uk"; schoolType ="Primary";}
else if (school == "Craighill Primary") {group ="/Primary/Craighill Primary/"; domain ="TainRoyalAcademy.net"; schoolType ="Primary";}
else if (school == "Cromarty Primary") {group ="/Primary/Cromarty Primary/"; domain ="FortroseAcademy.org.uk"; schoolType ="Primary";}
else if (school == "Crossroads Primary") {group ="/Primary/Crossroads Primary/"; domain ="ThursoHigh.org.uk"; schoolType ="Primary";}
else if (school == "Crown Primary") {group ="/Primary/Crown Primary/"; domain ="MillburnAcademy.org.uk"; schoolType ="Primary";}
else if (school == "Croy Primary") {group ="/Primary/Croy Primary/"; domain ="CullodenAcademy.org.uk"; schoolType ="Primary";}
else if (school == "Culbokie Primary") {group ="/Primary/Culbokie Primary/"; domain ="FortroseAcademy.org.uk"; schoolType ="Primary";}
else if (school == "Culloden Academy") {group ="/Secondary/Culloden Academy/"; domain ="CullodenAcademy.org.uk"; schoolType ="Secondary";}
else if (school == "Dalneigh Primary") {group ="/Primary/Dalneigh Primary/"; domain ="InvernessHigh.org.uk"; schoolType ="Primary";}
else if (school == "Daviot Primary") {group ="/Primary/Daviot Primary/"; domain ="MillburnAcademy.org.uk"; schoolType ="Primary";}
else if (school == "Deshar Primary") {group ="/Primary/Deshar Primary/"; domain ="GrantownGrammar.org.uk"; schoolType ="Primary";}
else if (school == "Dingwall Academy") {group ="/Secondary/Dingwall Academy/"; domain ="DingwallAcademy.org.uk"; schoolType ="Secondary";}
else if (school == "Dingwall Primary") {group ="/Primary/Dingwall Primary/"; domain ="DingwallAcademy.org.uk"; schoolType ="Primary";}
else if (school == "Dochgarroch Primary") {group ="/Primary/Dochgarroch Primary/"; domain ="CharlestonAcademy.org.uk"; schoolType ="Primary";}
else if (school == "Dornoch Academy") {group ="/Secondary/Dornoch Academy/"; domain ="DornochAcademy.org.uk"; schoolType ="Secondary";}
else if (school == "Dornoch Primary") {group ="/Primary/Dornoch Primary/"; domain ="DornochAcademy.org.uk"; schoolType ="Primary";}
else if (school == "Drakies Primary") {group ="/Primary/Drakies Primary/"; domain ="MillburnAcademy.org.uk"; schoolType ="Primary";}
else if (school == "Drummond School") {group ="/Special/Drummond School/"; domain ="Highlandschools.net"; schoolType ="Special";}
else if (school == "Dunbeath Primary") {group ="/Primary/Dunbeath Primary/"; domain ="WickHigh.org.uk"; schoolType ="Primary";}
else if (school == "Duncan Forbes Primary") {group ="/Primary/Duncan Forbes Primary/"; domain ="CullodenAcademy.org.uk"; schoolType ="Primary";}
else if (school == "Dunvegan Primary") {group ="/Primary/Dunvegan Primary/"; domain ="PortreeHigh.org.uk"; schoolType ="Primary";}
else if (school == "Durness Primary") {group ="/Primary/Durness Primary/"; domain ="KinlochbervieHigh.org.uk"; schoolType ="Primary";}
else if (school == "Duror Primary") {group ="/Primary/Duror Primary/"; domain ="KinlochlevenHigh.org.uk"; schoolType ="Primary";}
else if (school == "Edderton Primary") {group ="/Primary/Edderton Primary/"; domain ="TainRoyalAcademy.net"; schoolType ="Primary";}
else if (school == "Edinbane Primary") {group ="/Primary/Edinbane Primary/"; domain ="PortreeHigh.org.uk"; schoolType ="Primary";}
else if (school == "Eigg Primary") {group ="/Primary/Eigg Primary/"; domain ="MallaigHigh.org.uk"; schoolType ="Primary";}
else if (school == "Elgol Primary") {group ="/Primary/Elgol Primary/"; domain ="PortreeHigh.org.uk"; schoolType ="Primary";}
else if (school == "Farr High School") {group ="/Secondary/Farr High School/"; domain ="FarrHigh.org.uk"; schoolType ="Secondary";}
else if (school == "Farr Primary (Inv)") {group ="/Primary/Farr Primary (Inv)/"; domain ="InvernessRoyalAcademy.org.uk"; schoolType ="Primary";}
else if (school == "Farr Primary (Suth)") {group ="/Primary/Farr Primary (Suth)/"; domain ="FarrHigh.org.uk"; schoolType ="Primary";}
else if (school == "Ferintosh Primary") {group ="/Primary/Ferintosh Primary/"; domain ="DingwallAcademy.org.uk"; schoolType ="Primary";}
else if (school == "Fortrose Academy") {group ="/Secondary/Fortrose Academy/"; domain ="FortroseAcademy.org.uk"; schoolType ="Secondary";}
else if (school == "Foyers Primary") {group ="/Primary/Foyers Primary/"; domain ="InvernessRoyalAcademy.org.uk"; schoolType ="Primary";}
else if (school == "Gairloch High School") {group ="/Secondary/Gairloch High School/"; domain ="GairlochHigh.org.uk"; schoolType ="Secondary";}
else if (school == "Gairloch Primary") {group ="/Primary/Gairloch Primary/"; domain ="GairlochHigh.org.uk"; schoolType ="Primary";}
else if (school == "Gergask Primary") {group ="/Primary/Gergask Primary/"; domain ="KingussieHigh.org.uk"; schoolType ="Primary";}
else if (school == "Gledfield Primary") {group ="/Primary/Gledfield Primary/"; domain ="TainRoyalAcademy.net"; schoolType ="Primary";}
else if (school == "Glen Urquhart High School") {group ="/Secondary/Glen Urquhart High School/"; domain ="GlenurquhartHigh.org.uk"; schoolType ="Secondary";}
else if (school == "Glencoe Primary") {group ="/Primary/Glencoe Primary/"; domain ="KinlochlevenHigh.org.uk"; schoolType ="Primary";}
else if (school == "Glenelg Primary") {group ="/Primary/Glenelg Primary/"; domain ="PlocktonHigh.org.uk"; schoolType ="Primary";}
else if (school == "Glenurquhart Primary") {group ="/Primary/Glenurquhart Primary/"; domain ="GlenurquhartHigh.org.uk"; schoolType ="Primary";}
else if (school == "Golspie High School") {group ="/Secondary/Golspie High School/"; domain ="GolspieHigh.org.uk"; schoolType ="Secondary";}
else if (school == "Golspie Primary") {group ="/Primary/Golspie Primary/"; domain ="GolspieHigh.org.uk"; schoolType ="Primary";}
else if (school == "Grantown Grammar School") {group ="/Secondary/Grantown Grammar School/"; domain ="GrantownGrammar.org.uk"; schoolType ="Secondary";}
else if (school == "Grantown Primary") {group ="/Primary/Grantown Primary/"; domain ="GrantownGrammar.org.uk"; schoolType ="Primary";}
else if (school == "Halkirk Primary") {group ="/Primary/Halkirk Primary/"; domain ="ThursoHigh.org.uk"; schoolType ="Primary";}
else if (school == "Helmsdale Primary") {group ="/Primary/Helmsdale Primary/"; domain ="GolspieHigh.org.uk"; schoolType ="Primary";}
else if (school == "Hill of Fearn Primary") {group ="/Primary/Hill of Fearn Primary/"; domain ="TainRoyalAcademy.net"; schoolType ="Primary";}
else if (school == "Hilton of Cadboll Primary") {group ="/Primary/Hilton of Cadboll Primary/"; domain ="TainRoyalAcademy.net"; schoolType ="Primary";}
else if (school == "Hilton Primary") {group ="/Primary/Hilton Primary/"; domain ="InvernessRoyalAcademy.org.uk"; schoolType ="Primary";}
else if (school == "Holm Primary") {group ="/Primary/Holm Primary/"; domain ="InvernessRoyalAcademy.org.uk"; schoolType ="Primary";}
else if (school == "Inshes Primary") {group ="/Primary/Inshes Primary/"; domain ="MillburnAcademy.org.uk"; schoolType ="Primary";}
else if (school == "Inver Primary") {group ="/Primary/Inver Primary/"; domain ="TainRoyalAcademy.net"; schoolType ="Primary";}
else if (school == "Invergarry Primary") {group ="/Primary/Invergarry Primary/"; domain ="LochaberHigh.org.uk"; schoolType ="Primary";}
else if (school == "Invergordon Academy") {group ="/Secondary/Invergordon Academy/"; domain ="InvergordonAcademy.org.uk"; schoolType ="Secondary";}
else if (school == "Inverie Primary") {group ="/Primary/Inverie Primary/"; domain ="MallaigHigh.org.uk"; schoolType ="Primary";}
else if (school == "Inverlochy Primary") {group ="/Primary/Inverlochy Primary/"; domain ="LochaberHigh.org.uk"; schoolType ="Primary";}
else if (school == "Inverness High School") {group ="/Secondary/Inverness High School/"; domain ="InvernessHigh.org.uk"; schoolType ="Secondary";}
else if (school == "Inverness Royal Academy") {group ="/Secondary/Inverness Royal Academy/"; domain ="InvernessRoyalAcademy.org.uk"; schoolType ="Secondary";}
else if (school == "Keiss Primary") {group ="/Primary/Keiss Primary/"; domain ="WickHigh.org.uk"; schoolType ="Primary";}
else if (school == "Kilchoan Primary") {group ="/Primary/Kilchoan Primary/"; domain ="ArdnamurchanHigh.org.uk"; schoolType ="Primary";}
else if (school == "Kilchuimen Academy") {group ="/Secondary/Kilchuimen Academy/"; domain ="KilchuimenAcademy.org.uk"; schoolType ="Secondary";}
else if (school == "Kilchuimen Primary") {group ="/Primary/Kilchuimen Primary/"; domain ="KilchuimenAcademy.org.uk"; schoolType ="Primary";}
else if (school == "Kilmuir Primary") {group ="/Primary/Kilmuir Primary/"; domain ="PortreeHigh.org.uk"; schoolType ="Primary";}
else if (school == "Kiltearn Primary") {group ="/Primary/Kiltearn Primary/"; domain ="AlnessAcademy.org.uk"; schoolType ="Primary";}
else if (school == "Kingussie High School") {group ="/Secondary/Kingussie High School/"; domain ="KingussieHigh.org.uk"; schoolType ="Secondary";}
else if (school == "Kingussie Primary") {group ="/Primary/Kingussie Primary/"; domain ="KingussieHigh.org.uk"; schoolType ="Primary";}
else if (school == "Kinlochbervie High School") {group ="/Secondary/Kinlochbervie High School/"; domain ="KinlochbervieHigh.org.uk"; schoolType ="Secondary";}
else if (school == "Kinlochbervie Primary") {group ="/Primary/Kinlochbervie Primary/"; domain ="KinlochbervieHigh.org.uk"; schoolType ="Primary";}
else if (school == "Kinlochewe Primary") {group ="/Primary/Kinlochewe Primary/"; domain ="GairlochHigh.org.uk"; schoolType ="Primary";}
else if (school == "Kinlochleven High School") {group ="/Secondary/Kinlochleven High School/"; domain ="KinlochlevenHigh.org.uk"; schoolType ="Secondary";}
else if (school == "Kinlochleven Primary") {group ="/Primary/Kinlochleven Primary/"; domain ="KinlochlevenHigh.org.uk"; schoolType ="Primary";}
else if (school == "Kinmylies Primary") {group ="/Primary/Kinmylies Primary/"; domain ="CharlestonAcademy.org.uk"; schoolType ="Primary";}
else if (school == "Kirkhill Primary") {group ="/Primary/Kirkhill Primary/"; domain ="CharlestonAcademy.org.uk"; schoolType ="Primary";}
else if (school == "Knockbreck Primary (Dunvegan)") {group ="/Primary/Knockbreck Primary (Dunvegan)/"; domain ="PortreeHigh.org.uk"; schoolType ="Primary";}
else if (school == "Knockbreck Primary (Tain)") {group ="/Primary/Knockbreck Primary (Tain)/"; domain ="TainRoyalAcademy.net"; schoolType ="Primary";}
else if (school == "Kyle Primary") {group ="/Primary/Kyle Primary/"; domain ="PlocktonHigh.org.uk"; schoolType ="Primary";}
else if (school == "Kyleakin Primary") {group ="/Primary/Kyleakin Primary/"; domain ="PlocktonHigh.org.uk"; schoolType ="Primary";}
else if (school == "Lady Lovat Primary") {group ="/Primary/Lady Lovat Primary/"; domain ="MallaigHigh.org.uk"; schoolType ="Primary";}
else if (school == "Lairg Primary") {group ="/Primary/Lairg Primary/"; domain ="GolspieHigh.org.uk"; schoolType ="Primary";}
else if (school == "Loch Duich Primary") {group ="/Primary/Loch Duich Primary/"; domain ="PlocktonHigh.org.uk"; schoolType ="Primary";}
else if (school == "Lochaber High School") {group ="/Secondary/Lochaber High School/"; domain ="LochaberHigh.org.uk"; schoolType ="Secondary";}
else if (school == "Lochaline Primary") {group ="/Primary/Lochaline Primary/"; domain ="ArdnamurchanHigh.org.uk"; schoolType ="Primary";}
else if (school == "Lochardil Primary") {group ="/Primary/Lochardil Primary/"; domain ="InvernessRoyalAcademy.org.uk"; schoolType ="Primary";}
else if (school == "Lochcarron Primary") {group ="/Primary/Lochcarron Primary/"; domain ="PlocktonHigh.org.uk"; schoolType ="Primary";}
else if (school == "Lochinver Primary") {group ="/Primary/Lochinver Primary/"; domain ="UllapoolHigh.org.uk"; schoolType ="Primary";}
else if (school == "Lundavra Primary") {group ="/Primary/Lundavra Primary/"; domain ="LochaberHigh.org.uk"; schoolType ="Primary";}
else if (school == "Lybster Primary") {group ="/Primary/Lybster Primary/"; domain ="WickHigh.org.uk"; schoolType ="Primary";}
else if (school == "Macdiarmid Primary") {group ="/Primary/Macdiarmid Primary/"; domain ="PortreeHigh.org.uk"; schoolType ="Primary";}
else if (school == "Mallaig High School") {group ="/Secondary/Mallaig High School/"; domain ="MallaigHigh.org.uk"; schoolType ="Secondary";}
else if (school == "Mallaig Primary") {group ="/Primary/Mallaig Primary/"; domain ="MallaigHigh.org.uk"; schoolType ="Primary";}
else if (school == "Marybank Primary") {group ="/Primary/Marybank Primary/"; domain ="DingwallAcademy.org.uk"; schoolType ="Primary";}
else if (school == "Melvich Primary") {group ="/Primary/Melvich Primary/"; domain ="FarrHigh.org.uk"; schoolType ="Primary";}
else if (school == "Merkinch Primary") {group ="/Primary/Merkinch Primary/"; domain ="InvernessHigh.org.uk"; schoolType ="Primary";}
else if (school == "Millbank Primary") {group ="/Primary/Millbank Primary/"; domain ="NairnAcademy.net"; schoolType ="Primary";}
else if (school == "Millburn Academy") {group ="/Secondary/Millburn Academy/"; domain ="MillburnAcademy.org.uk"; schoolType ="Secondary";}
else if (school == "Miller Academy Primary") {group ="/Primary/Miller Academy Primary/"; domain ="ThursoHigh.org.uk"; schoolType ="Primary";}
else if (school == "Milton of Leys Primary") {group ="/Primary/Milton of Leys Primary/"; domain ="MillburnAcademy.org.uk"; schoolType ="Primary";}
else if (school == "Milton Primary") {group ="/Primary/Milton Primary/"; domain ="InvergordonAcademy.org.uk"; schoolType ="Primary";}
else if (school == "Mount Pleasant Primary") {group ="/Primary/Mount Pleasant Primary/"; domain ="ThursoHigh.org.uk"; schoolType ="Primary";}
else if (school == "Muck Primary") {group ="/Primary/Muck Primary/"; domain ="MallaigHigh.org.uk"; schoolType ="Primary";}
else if (school == "Muirtown Primary") {group ="/Primary/Muirtown Primary/"; domain ="CharlestonAcademy.org.uk"; schoolType ="Primary";}
else if (school == "Mulbuie Primary") {group ="/Primary/Mulbuie Primary/"; domain ="DingwallAcademy.org.uk"; schoolType ="Primary";}
else if (school == "Munlochy Primary") {group ="/Primary/Munlochy Primary/"; domain ="FortroseAcademy.org.uk"; schoolType ="Primary";}
else if (school == "Nairn Academy") {group ="/Secondary/Nairn Academy/"; domain ="NairnAcademy.net"; schoolType ="Secondary";}
else if (school == "Newmore Primary") {group ="/Primary/Newmore Primary/"; domain ="InvergordonAcademy.org.uk"; schoolType ="Primary";}
else if (school == "Newton Park Primary") {group ="/Primary/Newton Park Primary/"; domain ="WickHigh.org.uk"; schoolType ="Primary";}
else if (school == "Newtonmore Primary") {group ="/Primary/Newtonmore Primary/"; domain ="KingussieHigh.org.uk"; schoolType ="Primary";}
else if (school == "North Kessock Primary") {group ="/Primary/North Kessock Primary/"; domain ="FortroseAcademy.org.uk"; schoolType ="Primary";}
else if (school == "Noss Primary") {group ="/Primary/Noss Primary/"; domain ="WickHigh.org.uk"; schoolType ="Primary";}
else if (school == "Obsdale Primary") {group ="/Primary/Obsdale Primary/"; domain ="AlnessAcademy.org.uk"; schoolType ="Primary";}
else if (school == "Park Primary School") {group ="/Primary/Park Primary School/"; domain ="InvergordonAcademy.org.uk"; schoolType ="Primary";}
else if (school == "Pennyland Primary") {group ="/Primary/Pennyland Primary/"; domain ="ThursoHigh.org.uk"; schoolType ="Primary";}
else if (school == "Plockton High School") {group ="/Secondary/Plockton High School/"; domain ="PlocktonHigh.org.uk"; schoolType ="Secondary";}
else if (school == "Plockton Primary") {group ="/Primary/Plockton Primary/"; domain ="PlocktonHigh.org.uk"; schoolType ="Primary";}
else if (school == "Poolewe Primary") {group ="/Primary/Poolewe Primary/"; domain ="GairlochHigh.org.uk"; schoolType ="Primary";}
else if (school == "Portree High School") {group ="/Secondary/Portree High School/"; domain ="PortreeHigh.org.uk"; schoolType ="Secondary";}
else if (school == "Portree Primary") {group ="/Primary/Portree Primary/"; domain ="PortreeHigh.org.uk"; schoolType ="Primary";}
else if (school == "Raasay Primary") {group ="/Primary/Raasay Primary/"; domain ="PortreeHigh.org.uk"; schoolType ="Primary";}
else if (school == "Raigmore Primary") {group ="/Primary/Raigmore Primary/"; domain ="MillburnAcademy.org.uk"; schoolType ="Primary";}
else if (school == "Reay Primary") {group ="/Primary/Reay Primary/"; domain ="ThursoHigh.org.uk"; schoolType ="Primary";}
else if (school == "Resolis Primary") {group ="/Primary/Resolis Primary/"; domain ="FortroseAcademy.org.uk"; schoolType ="Primary";}
else if (school == "Rogart Primary") {group ="/Primary/Rogart Primary/"; domain ="GolspieHigh.org.uk"; schoolType ="Primary";}
else if (school == "Rosebank Primary") {group ="/Primary/Rosebank Primary/"; domain ="NairnAcademy.net"; schoolType ="Primary";}
else if (school == "Rosehall Primary") {group ="/Primary/Rosehall Primary/"; domain ="GolspieHigh.org.uk"; schoolType ="Primary";}
else if (school == "Roybridge Primary") {group ="/Primary/Roybridge Primary/"; domain ="LochaberHigh.org.uk"; schoolType ="Primary";}
else if (school == "Rum Primary") {group ="/Primary/Rum Primary/"; domain ="MallaigHigh.org.uk"; schoolType ="Primary";}
else if (school == "Scoraig School") {group ="/Primary/Scoraig School/"; domain ="UllapoolHigh.org.uk"; schoolType ="Primary";}
else if (school == "Scourie Primary") {group ="/Primary/Scourie Primary/"; domain ="KinlochbervieHigh.org.uk"; schoolType ="Primary";}
else if (school == "Shieldaig Primary") {group ="/Primary/Shieldaig Primary/"; domain ="GairlochHigh.org.uk"; schoolType ="Primary";}
else if (school == "Smithton Primary") {group ="/Primary/Smithton Primary/"; domain ="CullodenAcademy.org.uk"; schoolType ="Primary";}
else if (school == "South Lodge Primary") {group ="/Primary/South Lodge Primary/"; domain ="InvergordonAcademy.org.uk"; schoolType ="Primary";}
else if (school == "Spean Bridge Primary") {group ="/Primary/Spean Bridge Primary/"; domain ="LochaberHigh.org.uk"; schoolType ="Primary";}
else if (school == "St Bride's Primary") {group ="/Primary/St Bride's Primary/"; domain ="KinlochlevenHigh.org.uk"; schoolType ="Primary";}
else if (school == "St Clement's School") {group ="/Special/St Clement's School/"; domain ="Highlandschools.net"; schoolType ="Special";}
else if (school == "St Columba's RC Primary") {group ="/Primary/St Columba's RC Primary/"; domain ="LochaberHigh.org.uk"; schoolType ="Primary";}
else if (school == "St Duthus School") {group ="/Special/St Duthus School/"; domain ="Highlandschools.net"; schoolType ="Special";}
else if (school == "St Joseph's RC Primary") {group ="/Primary/St Joseph's RC Primary/"; domain ="InvernessHigh.org.uk"; schoolType ="Primary";}
else if (school == "Staffin Primary") {group ="/Primary/Staffin Primary/"; domain ="PortreeHigh.org.uk"; schoolType ="Primary";}
else if (school == "Strathconon Primary") {group ="/Primary/Strathconon Primary/"; domain ="DingwallAcademy.org.uk"; schoolType ="Primary";}
else if (school == "Strathdearn Primary") {group ="/Primary/Strathdearn Primary/"; domain ="MillburnAcademy.org.uk"; schoolType ="Primary";}
else if (school == "Stratherrick Primary") {group ="/Primary/Stratherrick Primary/"; domain ="InvernessRoyalAcademy.org.uk"; schoolType ="Primary";}
else if (school == "Strathgarve Primary") {group ="/Primary/Strathgarve Primary/"; domain ="DingwallAcademy.org.uk"; schoolType ="Primary";}
else if (school == "Strathpeffer Primary") {group ="/Primary/Strathpeffer Primary/"; domain ="DingwallAcademy.org.uk"; schoolType ="Primary";}
else if (school == "Strontian Primary") {group ="/Primary/Strontian Primary/"; domain ="ArdnamurchanHigh.org.uk"; schoolType ="Primary";}
else if (school == "Struan Primary") {group ="/Primary/Struan Primary/"; domain ="PortreeHigh.org.uk"; schoolType ="Primary";}
else if (school == "Tain Royal Academy") {group ="/Secondary/Tain Royal Academy/"; domain ="TainRoyalAcademy.net"; schoolType ="Secondary";}
else if (school == "Tarbat Old Primary") {group ="/Primary/Tarbat Old Primary/"; domain ="TainRoyalAcademy.net"; schoolType ="Primary";}
else if (school == "Tarradale Primary") {group ="/Primary/Tarradale Primary/"; domain ="DingwallAcademy.org.uk"; schoolType ="Primary";}
else if (school == "Teanassie Primary") {group ="/Primary/Teanassie Primary/"; domain ="CharlestonAcademy.org.uk"; schoolType ="Primary";}
else if (school == "The Bridge") {group ="/Special/The Bridge/"; domain ="Highlandschools.net"; schoolType ="Special";}
else if (school == "Thrumster Primary") {group ="/Primary/Thrumster Primary/"; domain ="WickHigh.org.uk"; schoolType ="Primary";}
else if (school == "Thurso High School") {group ="/Secondary/Thurso High School/"; domain ="ThursoHigh.org.uk"; schoolType ="Secondary";}
else if (school == "Tomnacross Primary") {group ="/Primary/Tomnacross Primary/"; domain ="CharlestonAcademy.org.uk"; schoolType ="Primary";}
else if (school == "Tongue Primary") {group ="/Primary/Tongue Primary/"; domain ="FarrHigh.org.uk"; schoolType ="Primary";}
else if (school == "Tore Primary") {group ="/Primary/Tore Primary/"; domain ="FortroseAcademy.org.uk"; schoolType ="Primary";}
else if (school == "Ullapool High School") {group ="/Secondary/Ullapool High School/"; domain ="UllapoolHigh.org.uk"; schoolType ="Secondary";}
else if (school == "Ullapool Primary") {group ="/Primary/Ullapool Primary/"; domain ="UllapoolHigh.org.uk"; schoolType ="Primary";}
else if (school == "Watten Primary") {group ="/Primary/Watten Primary/"; domain ="WickHigh.org.uk"; schoolType ="Primary";}
else if (school == "Wick High School") {group ="/Secondary/Wick High School/"; domain ="WickHigh.org.uk"; schoolType ="Secondary";}
答案 0 :(得分:1)
将数据放入对象
var schools = {
"Abernethy Primary": {
"group":"/Primary/Abernethy Primary/",
"domain":"GrantownGrammar.org.uk",
"schoolType":"Primary"
},
...
};
通过
获得所需的变量var group = schools[school].group;
var domain = schools[school].domain;
var schoolType = schools[school].schoolType;
将这些数据放入单独文件的更好方法。
答案 1 :(得分:0)
如果您无法将这些值存储在数据库或外部文件中,那么您就不走运了。您可以通过将值存储在数组中来缩短和组织它。
然后你可以通过循环数据来进行查找
var schools = {
Primary: [
["Abernethy Primary", "GrantownGrammar.org.uk"],
["Acharacle Primary", "ArdnamurchanHigh.org.uk"],
// etc
],
Secondary: [
["Ullapool High School", "UllapoolHigh.org.uk"],
["Wick High School", "WickHigh.org.uk"],
// etc
]
};
function findData(schoolName) {
for (var t in schools) {
if (schools.hasOwnProperty(t)) {
for (var i = 0; i < schools[t].length; i++) {
if (schoolName == schools[t][i][0]) {
return {
group: "/" + t + "/" + schools[t][i][0] + "/",
domain: schools[t][i][1],
schoolType: t
}
}
}
}
}
}
console.log(findData("Abernethy Primary"));
console.log(findData("Wick High School"));
&#13;