function updateHREFs()

in assets/download/legacy/download.js [341:424]


function updateHREFs() {
  var qabuildsul = document.getElementById("qabuilds");
  var anchorsToMirror = document.getElementsByTagName("a");

  if (document.downloadSettings.cbIncludeJRE.checked == false) {
	for (var i = 0; i < anchorsToMirror.length; i++) {
	   	if ( anchorsToMirror[i].href.indexOf( "os=linuxinteldeb" ) == -1
			&& anchorsToMirror[i].href.indexOf( "os=macosx" ) == -1
		) {
			if ( anchorsToMirror[i].href.indexOf( "?" ) > 0 && anchorsToMirror[i].href.indexOf( MIRROR_BOUNCER_URL ) > -1 ) {
	   			anchorsToMirror[i].href = anchorsToMirror[i].href.replace("wjre&amp;lang=","&amp;lang=");
	   			anchorsToMirror[i].href = anchorsToMirror[i].href.replace("wjre&lang=","&lang=");
			} else if ( anchorsToMirror[i].href.indexOf( MIRROR_MIRRORBRAIN_URL + "files/" ) > -1 ) {
				if ( anchorsToMirror[i].href.indexOf( "_install-" ) > -1 ||
					( anchorsToMirror[i].href.indexOf( "_install_" ) > -1 &&
						( anchorsToMirror[i].href.indexOf( "_Linux_" ) > -1 || anchorsToMirror[i].href.indexOf( "_MacOS_" ) > -1 ||
						  anchorsToMirror[i].href.indexOf( "_Win_" ) > -1 ) ) ) {
					// new schema
	   				anchorsToMirror[i].href = anchorsToMirror[i].href.replace("-wJRE_","_");
				} else {
					// old schema
	   				anchorsToMirror[i].href = anchorsToMirror[i].href.replace("install_wJRE_","install_");
				}
			} else {
	   			anchorsToMirror[i].href = anchorsToMirror[i].href.replace("wjre&amp;lang=","&amp;lang=");
	   			anchorsToMirror[i].href = anchorsToMirror[i].href.replace("wjre&lang=","&lang=");
			}
		}
		if ( anchorsToMirror[i].href.indexOf( "_Linux_x86-64_install-rpm_" ) > -1 || anchorsToMirror[i].href.indexOf( "_Solaris_" ) > -1) {
			// do not include Linux x86-64 RPM, Solaris in the JRE switching as only wJRE builds are available
			anchorsToMirror[i].href = anchorsToMirror[i].href.replace("_install-rpm_","_install-rpm-wJRE_");
			anchorsToMirror[i].href = anchorsToMirror[i].href.replace("_install_","_install-wJRE_");
		}
		if ( anchorsToMirror[i].href.indexOf( "OOo-SDK_" ) > -1 ) {
			// do not include SDK in the JRE switching as only non-JRE builds are available
			anchorsToMirror[i].href = anchorsToMirror[i].href.replace("_install-wJRE_","_install_");
			anchorsToMirror[i].href = anchorsToMirror[i].href.replace("_install-rpm-wJRE_","_install-rpm_");
		}
	}
  } else {
	for (var i = 0; i < anchorsToMirror.length; i++) {
		if ( anchorsToMirror[i].href.indexOf( "os=linuxinteldeb" ) == -1
			&& anchorsToMirror[i].href.indexOf( "os=macosx" ) == -1
		) {
			if ( anchorsToMirror[i].href.indexOf( "?" ) > 0 && anchorsToMirror[i].href.indexOf( MIRROR_BOUNCER_URL ) > -1 ) {
	   			// we cannot assume that it is always right, and in order to prevent wjrewjrewjre&... this (should) solve(s) it...
	   			anchorsToMirror[i].href = anchorsToMirror[i].href.replace("wjre&amp;lang=","&amp;lang=");
	   			anchorsToMirror[i].href = anchorsToMirror[i].href.replace("wjre&lang=","&lang=");
	   			// and now we add them :)
	   			anchorsToMirror[i].href = anchorsToMirror[i].href.replace("&amp;lang=","wjre&amp;lang=");
	   			anchorsToMirror[i].href = anchorsToMirror[i].href.replace("&lang=","wjre&lang=");
			} else if ( anchorsToMirror[i].href.indexOf( MIRROR_MIRRORBRAIN_URL + "files/" ) > -1 ) {
				if ( anchorsToMirror[i].href.indexOf( "_install" ) > -1 &&
					( anchorsToMirror[i].href.indexOf( "_MacOS" ) > -1 || anchorsToMirror[i].href.indexOf( "_deb" ) > -1 ||
					  anchorsToMirror[i].href.indexOf( "_HPPA" ) > -1 || anchorsToMirror[i].href.indexOf( "_IA64" ) > -1 ||
					  anchorsToMirror[i].href.indexOf( "_PPC" ) > -1 || anchorsToMirror[i].href.indexOf( "_S390X" ) > -1 ||
					  anchorsToMirror[i].href.indexOf( "OOo-SDK_" ) > -1 ) ) {
					// do nothing for MAC, _deb, Linux HPPA, IA64, PPC, S390X and OOo-SDK
				} else if ( anchorsToMirror[i].href.indexOf( "_install-" ) > -1 || (
					anchorsToMirror[i].href.indexOf( "_install_" ) > -1 && (
					anchorsToMirror[i].href.indexOf( "_Linux_" ) > -1 || anchorsToMirror[i].href.indexOf( "_Win_" ) > -1 ||
					anchorsToMirror[i].href.indexOf( "_Solaris_" ) > -1
					)
        		) ) {
					// new schema
	   				anchorsToMirror[i].href = anchorsToMirror[i].href.replace("_install_","_install-wJRE_");
					anchorsToMirror[i].href = anchorsToMirror[i].href.replace("_install-rpm_","_install-rpm-wJRE_");
				} else {
					// old schema
	   				anchorsToMirror[i].href = anchorsToMirror[i].href.replace("install_wJRE_","install_");
					anchorsToMirror[i].href = anchorsToMirror[i].href.replace("install_","install_wJRE_");
				}
			} else {
				// we cannot assume that it is always right, and in order to prevent wjrewjrewjre&... this (should) solve(s) it...
	   			anchorsToMirror[i].href = anchorsToMirror[i].href.replace("wjre&amp;lang=","&amp;lang=");
	   			anchorsToMirror[i].href = anchorsToMirror[i].href.replace("wjre&lang=","&lang=");
	   			// and now we add them :)
	   			anchorsToMirror[i].href = anchorsToMirror[i].href.replace("&amp;lang=","wjre&amp;lang=");
	   			anchorsToMirror[i].href = anchorsToMirror[i].href.replace("&lang=","wjre&lang=");
			}
		}
	}
  }
}