Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
{
"props": false
}
]
],
// allow destructuring and declarations of simple objects on one line.
"object-curly-newline": 0
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ protected function getActions(
if (!$disabled) {
$button = $button->withOnLoadCode(
fn($id) => "$('#$id').on('click', (e)=> {
let promptId = e.target.closest('.il-prompt').id;
il.UI.prompt.get(promptId).show('$link');
let promptId = e.target.closest('.c-prompt').id;
il.UI.Prompt.get(promptId).loadState('$link');
});"
);
}
Expand Down Expand Up @@ -176,8 +176,8 @@ public function getConfirmationShowState(
$button = $this->ui_factory->button()->standard($this->presentation_utilities->txt('confirm'), '#');
$button = $button->withOnLoadCode(
fn($id) => "$('#$id').on('click', (e)=> {
let promptId = e.target.closest('.il-prompt').id;
il.UI.prompt.get(promptId).show('$action');
let promptId = e.target.closest('.c-prompt').id;
il.UI.Prompt.get(promptId).loadState('$action');
});"
);
return $this->ui_factory->prompt()->state()->show(
Expand Down
21 changes: 21 additions & 0 deletions components/ILIAS/UI/UI.php
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,7 @@ public function init(
$internal[UI\Implementation\Component\Prompt\Factory::class] = static fn() =>
new UI\Implementation\Component\Prompt\Factory(
$internal[UI\Implementation\Component\SignalGeneratorInterface::class],
$internal[UI\Implementation\Component\Prompt\State\Factory::class],
);
$internal[UI\Implementation\Component\Prompt\State\Factory::class] = static fn() =>
new UI\Implementation\Component\Prompt\State\Factory();
Expand All @@ -492,6 +493,7 @@ public function init(
$internal[UI\Implementation\Render\ResourceRegistry::class],
new UI\Implementation\Render\FSLoader(
new UI\Implementation\Render\DefaultRendererFactory(
$internal[UI\Implementation\Render\ContextMatcher::class],
$use[UI\Implementation\FactoryInternal::class],
$internal[UI\Implementation\Render\TemplateFactory::class],
$use[Language\Language::class],
Expand All @@ -502,6 +504,7 @@ public function init(
$internal[UI\Implementation\Component\Input\UploadLimitResolver::class],
),
new UI\Implementation\Component\Button\ButtonRendererFactory(
$internal[UI\Implementation\Render\ContextMatcher::class],
$use[UI\Implementation\FactoryInternal::class],
$internal[UI\Implementation\Render\TemplateFactory::class],
$use[Language\Language::class],
Expand All @@ -512,6 +515,7 @@ public function init(
$internal[UI\Implementation\Component\Input\UploadLimitResolver::class],
),
new UI\Implementation\Component\Input\Field\FieldRendererFactory(
$internal[UI\Implementation\Render\ContextMatcher::class],
$use[UI\Implementation\FactoryInternal::class],
$internal[UI\Implementation\Render\TemplateFactory::class],
$use[Language\Language::class],
Expand All @@ -522,6 +526,7 @@ public function init(
$internal[UI\Implementation\Component\Input\UploadLimitResolver::class],
),
new UI\Implementation\Component\MessageBox\MessageBoxRendererFactory(
$internal[UI\Implementation\Render\ContextMatcher::class],
$use[UI\Implementation\FactoryInternal::class],
$internal[UI\Implementation\Render\TemplateFactory::class],
$use[Language\Language::class],
Expand All @@ -532,6 +537,7 @@ public function init(
$internal[UI\Implementation\Component\Input\UploadLimitResolver::class],
),
new UI\Implementation\Component\Input\Container\Form\FormRendererFactory(
$internal[UI\Implementation\Render\ContextMatcher::class],
$use[UI\Implementation\FactoryInternal::class],
$internal[UI\Implementation\Render\TemplateFactory::class],
$use[Language\Language::class],
Expand All @@ -542,6 +548,18 @@ public function init(
$internal[UI\Implementation\Component\Input\UploadLimitResolver::class],
),
new UI\Implementation\Component\Menu\MenuRendererFactory(
$internal[UI\Implementation\Render\ContextMatcher::class],
$use[UI\Implementation\FactoryInternal::class],
$internal[UI\Implementation\Render\TemplateFactory::class],
$use[Language\Language::class],
$internal[UI\Implementation\Render\JavaScriptBinding::class],
$use[UI\Implementation\Render\ImagePathResolver::class],
$pull[Data\Factory::class],
$use[UI\HelpTextRetriever::class],
$internal[UI\Implementation\Component\Input\UploadLimitResolver::class],
),
new UI\Implementation\Component\Entity\EntityRendererFactory(
$internal[UI\Implementation\Render\ContextMatcher::class],
$use[UI\Implementation\FactoryInternal::class],
$internal[UI\Implementation\Render\TemplateFactory::class],
$use[Language\Language::class],
Expand All @@ -552,6 +570,7 @@ public function init(
$internal[UI\Implementation\Component\Input\UploadLimitResolver::class],
),
new UI\Implementation\Component\Listing\ListingRendererFactory(
$internal[UI\Implementation\Render\ContextMatcher::class],
$use[UI\Implementation\FactoryInternal::class],
$internal[UI\Implementation\Render\TemplateFactory::class],
$use[Language\Language::class],
Expand All @@ -564,6 +583,8 @@ public function init(
)
)
);
$internal[UI\Implementation\Render\ContextMatcher::class] = static fn() =>
new UI\Implementation\Render\ContextMatcher();
$internal[UI\Implementation\Render\JavaScriptBinding::class] = static fn() =>
new UI\Implementation\Render\ilJavaScriptBinding(
$use[UICore\GlobalTemplate::class],
Expand Down
1 change: 1 addition & 0 deletions components/ILIAS/UI/resources/js/Core/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export default {
],
input: './src/core.js',
output: {
// file: '../../../../../../public/assets/js/core.js',
file: './dist/core.js',
format: 'iife',
banner: copyright,
Expand Down
5 changes: 3 additions & 2 deletions components/ILIAS/UI/resources/js/Core/src/AsyncRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,12 @@ export default class AsyncRenderer {
* root element.
*
* @param {URL|string} url
* @param {RequestInit} [request={}]
* @returns {Promise<DocumentFragment>}
* @throws {Error} if the request with fetch() failed.
*/
loadContent(url) {
return fetch(url.toString())
loadContent(url, request = {}) {
return fetch(url.toString(), request)
.then((response) => response.text())
.then((html) => this.#createElements(html))
.then((elements) => createDocumentFragment(this.#document, elements))
Expand Down
90 changes: 90 additions & 0 deletions components/ILIAS/UI/resources/js/Core/src/createHashCode.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/**
* This file is part of ILIAS, a powerful learning management system
* published by ILIAS open source e-Learning e.V.
*
* ILIAS is licensed with the GPL-3.0,
* see https://www.gnu.org/licenses/gpl-3.0.en.html
* You should have received a copy of said license along with the
* source code, too.
*
* If this is not the case or you just want to try ILIAS, you'll find
* us at:
* https://www.ilias.de
* https://github.com/ILIAS-eLearning
*/

/**
* Returns a hash code which is NOT cryptographically secure.
* This can be used in contexts where Window.crypto is not available.
*
* The current algorithm is based on Paul Hsieh's SuperFastHash which
* has been translated to JavaScript. Unlike the original algorithm,
* this function returns a fixed-width string instead of an unsigned
* integer.
*
* @see http://www.azillionmonkeys.com/qed/hash.html
*
* @param {string} string
* @returns {string}
*/
export default function createHashCode(string) {
/* eslint-disable no-bitwise */

const bytes = new TextEncoder().encode(string);

let len = bytes.length;
if (len <= 0) return 0;

let hash = len >>> 0;
let tmp;
let i = 0;

const get16bits = (p) => bytes[p] | (bytes[p + 1] << 8);

const rem = len & 3;
len >>>= 2;

// main loop
for (; len > 0; len -= 1) {
hash = (hash + get16bits(i)) >>> 0;
tmp = ((get16bits(i + 2) << 11) ^ hash) >>> 0;
hash = ((hash << 16) ^ tmp) >>> 0;
i += 4;
hash = (hash + (hash >>> 11)) >>> 0;
}

// handle end cases
switch (rem) {
case 3:
hash = (hash + get16bits(i)) >>> 0;
hash = (hash ^ (hash << 16)) >>> 0;
// (signed char) cast: sign-extend the byte
hash = (hash ^ (((bytes[i + 2] << 24) >> 24) << 18)) >>> 0;
hash = (hash + (hash >>> 11)) >>> 0;
break;
case 2:
hash = (hash + get16bits(i)) >>> 0;
hash = (hash ^ (hash << 11)) >>> 0;
hash = (hash + (hash >>> 17)) >>> 0;
break;
case 1:
hash = (hash + ((bytes[i] << 24) >> 24)) >>> 0;
hash = (hash ^ (hash << 10)) >>> 0;
hash = (hash + (hash >>> 1)) >>> 0;
break;
default:
// end case valid
break;
}

// force "avalanching" of final 127 bits
hash = (hash ^ (hash << 3)) >>> 0;
hash = (hash + (hash >>> 5)) >>> 0;
hash = (hash ^ (hash << 4)) >>> 0;
hash = (hash + (hash >>> 17)) >>> 0;
hash = (hash ^ (hash << 25)) >>> 0;
hash = (hash + (hash >>> 6)) >>> 0;

// return fixed-width 8 character hex string
return hash.toString(16).padStart(8, '0');
}
Loading
Loading