{include file='header'}
-<script data-relocate="true" src="//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
-<script data-relocate="true">
- //<![CDATA[
- if (window.jQuery) {
- $(function() {
- $('#wcfUrlContainer').show();
-
- // data
- var $domainName = '{@$domainName|encodeJS}';
- var $installScriptDir = '{@$installScriptDir|encodeJS}';
- var $installScriptUrl = '{@$installScriptUrl|encodeJS}';
- var $invalidErrorMessage = '{lang}wcf.global.wcfDir.error.invalid{/lang}';
- var $wcfDir = $('#wcfDir');
- var $wcfUrl = $('#wcfUrl');
-
- function updateWcfUrl() {
- // split paths and remove empty parts
- var $installScriptDirs = removeEmptyDirParts($installScriptDir.split('/'));
- var $wcfDirs = removeEmptyDirParts($wcfDir.val().split('/'));
- var $installScriptUrlDirs = removeEmptyDirParts($installScriptUrl.split('/'));
-
- // get relative path
- var $relativePathDirs = [];
- var $max = ($wcfDirs.length > $installScriptDirs.length) ? $wcfDirs.length : $installScriptDirs.length;
- for (var $i = 0; $i < $max; $i++) {
- if ($i < $installScriptDirs.length && $i < $wcfDirs.length) {
- if ($installScriptDirs[$i] != $wcfDirs[$i]) {
- $wcfDirs.splice(0, i);
- for (var $j = 0, $length = $installScriptDirs.length - $i; $j < $length; $j++) $relativePathDirs.push('..');
- $relativePathDirs = $relativePathDirs.concat($wcfDirs);
- break;
- }
- }
- // go up one level
- else if ($i < $installScriptDirs.length && $i >= $wcfDirs.length) {
- $relativePathDirs.push('..');
- }
- else {
- $relativePathDirs.push($wcfDirs[$i]);
- }
- }
-
- // loop dirs
- for (var $i = 0; $i < $relativePathDirs.length; $i++) {
- if ($relativePathDirs[$i] == '..') {
- if ($installScriptUrlDirs.length < 1) {
- $wcfUrl.html($invalidErrorMessage);
- return;
- }
-
- $installScriptUrlDirs.pop();
- }
- else {
- $installScriptUrlDirs.push($relativePathDirs[$i]);
- }
- }
-
- // implode and show result
- var $result = $domainName;
- for (var $i = 0; $i < $installScriptUrlDirs.length; $i++) $result += '/' + $installScriptUrlDirs[$i];
- $wcfUrl.html($result);
- }
-
- function removeEmptyDirParts(dir) {
- for (var $i = dir.length; $i >= 0; $i--) {
- if (dir[$i] == '' || dir[$i] == '.') {
- dir.splice($i, 1);
- }
- }
-
- return dir;
- }
-
- $wcfDir.keyup(updateWcfUrl).blur(updateWcfUrl);
- updateWcfUrl();
- });
- }
- //]]>
-</script>
-
<header class="boxHeadline boxSubHeadline">
<h2>{lang}wcf.global.wcfDir{/lang}</h2>
<p>{lang}wcf.global.wcfDir.description{/lang}</p>
</div>
</form>
+<script data-relocate="true">
+ document.getElementById('wcfUrlContainer').style.removeProperty('display');
+
+ // data
+ var DOMAIN_NAME = '{@$domainName|encodeJS}';
+ var INSTALL_SCRIPT_DIR = '{@$installScriptDir|encodeJS}';
+ var INSTALL_SCRIPT_URL = '{@$installScriptUrl|encodeJS}';
+ var INVALID_ERROR_MESSAGE = '{lang}wcf.global.wcfDir.error.invalid{/lang}';
+ var wcfDir = document.getElementById('wcfDir');
+ var wcfUrl = document.getElementById('wcfUrl');
+
+ function removeEmptyDirParts(dir) {
+ for (var i = dir.length; i >= 0; i--) {
+ if (dir[i] == '' || dir[i] == '.') {
+ dir.splice(i, 1);
+ }
+ }
+
+ return dir;
+ }
+
+ function updateWcfUrl() {
+ // split paths and remove empty parts
+ var installScriptDirs = removeEmptyDirParts(INSTALL_SCRIPT_DIR.split('/'));
+ var wcfDirs = removeEmptyDirParts(wcfDir.value.split('/'));
+ var installScriptUrlDirs = removeEmptyDirParts(INSTALL_SCRIPT_URL.split('/'));
+
+ // get relative path
+ var relativePathDirs = [];
+ var max = (wcfDirs.length > installScriptDirs.length) ? wcfDirs.length : installScriptDirs.length;
+ for (var i = 0; i < max; i++) {
+ if (i < installScriptDirs.length && i < wcfDirs.length) {
+ if (installScriptDirs[i] !== wcfDirs[i]) {
+ wcfDirs.splice(0, i);
+
+ for (var j = 0, length = installScriptDirs.length - i; j < length; j++) {
+ $relativePathDirs.push('..');
+ }
+
+ relativePathDirs = relativePathDirs.concat(wcfDirs);
+ break;
+ }
+ }
+ // go up one level
+ else if (i < installScriptDirs.length && i >= wcfDirs.length) {
+ relativePathDirs.push('..');
+ }
+ else {
+ relativePathDirs.push(wcfDirs[i]);
+ }
+ }
+
+ // loop dirs
+ for (var i = 0; i < relativePathDirs.length; i++) {
+ if (relativePathDirs[i] == '..') {
+ if (installScriptUrlDirs.length < 1) {
+ wcfUrl.textContent = INVALID_ERROR_MESSAGE;
+ return;
+ }
+
+ installScriptUrlDirs.pop();
+ }
+ else {
+ installScriptUrlDirs.push(relativePathDirs[i]);
+ }
+ }
+
+ wcfUrl.textContent = DOMAIN_NAME + (installScriptUrlDirs.length ? '/' : '') + installScriptUrlDirs.join('/');
+ }
+
+ wcfDir.addEventListener('keyup', updateWcfUrl);
+ wcfDir.addEventListener('blur', updateWcfUrl);
+
+ updateWcfUrl();
+</script>
+
{include file='footer'}