Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
OERu
register-enrol
Commits
718d533e
Commit
718d533e
authored
Nov 27, 2020
by
Dave Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
just before removing now-redundant replacement functions
parent
3dc738fe
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
22 deletions
+23
-22
js/ore_script.js
js/ore_script.js
+23
-22
No files found.
js/ore_script.js
View file @
718d533e
...
...
@@ -394,29 +394,29 @@ jQuery(document).ready(function() {
LOG
(
"
we've got a user!
"
);
form_markup
=
replace_dialog_tokens
(
form_markup
,
ore_data
.
user
);
title
=
replace_dialog_tokens
(
title
,
ore_data
.
user
);
LOG
(
'
Replacing user tokens with contents of
'
,
ore_data
.
user
);
/*
LOG('Replacing user tokens with contents of ', ore_data.user);
// replace values in forms based on the user values
form_markup = replace_user_tokens(form_markup, ore_data.user);
title
=
replace_user_tokens
(
title
,
ore_data
.
user
);
title = replace_user_tokens(title, ore_data.user);
*/
}
else
{
user
=
null
;
LOG
(
'
no user object!
'
);
}
// if there're some arguments provided, substitute those!
if
(
current_hash_args
!=
null
)
{
/*
if (current_hash_args != null) {
//LOG('replacing tokens with args - ', current_hash_args);
form_markup = replace_args_tokens(form_markup, current_hash_args);
title = replace_args_tokens(title, current_hash_args);
//LOG('after replace_args_tokens - '+form_markup);
}
}
*/
//LOG('after replace_user_tokens - '+form_markup);
if
(
id
==
'
edit_profile
'
||
id
==
'
register
'
)
{
/*
if (id == 'edit_profile' || id == 'register') {
LOG('adding countries');
form_markup = add_countries(form_markup, ore_data.country_select);
}
}
*/
// tidy up any residual tokens
form_markup
=
replace_unused_tokens
(
form_markup
);
title
=
replace_unused_tokens
(
title
);
//
form_markup = replace_unused_tokens(form_markup);
//
title = replace_unused_tokens(title);
LOG
(
'
appending form to parent
'
);
// at this point, the form should appear!
// here form is a DOM node...
...
...
@@ -722,10 +722,10 @@ jQuery(document).ready(function() {
}
// replace country selector tag with country selector
function
add_countries
(
markup
,
select
)
{
/*
function add_countries(markup, select) {
//LOG('adding country selector', form);
return markup.replace('{country_selector}', select);
}
}
*/
// set the country of the current user
function
set_country
(
form
,
country
)
{
...
...
@@ -744,7 +744,6 @@ jQuery(document).ready(function() {
var
re
=
/
\{\{(
.+
?)\}\}
/g
;
second
=
string
.
replace
(
re
,
function
(
match
,
$1
)
{
//LOG('$1: ', $1);
replacement
=
null
;
// split the match into its parts joined by "."
parts
=
$1
.
split
(
'
.
'
);
// find the variable
...
...
@@ -753,7 +752,9 @@ jQuery(document).ready(function() {
value
=
null
;
length
=
parts
.
length
;
//LOG('length: ', length);
if
(
length
==
4
)
{
if
(
length
==
5
)
{
value
=
obj
[
parts
[
1
]][
parts
[
2
]][
parts
[
3
]][
parts
[
4
]];
}
else
if
(
length
==
4
)
{
value
=
obj
[
parts
[
1
]][
parts
[
2
]][
parts
[
3
]];
}
else
if
(
length
==
3
)
{
value
=
obj
[
parts
[
1
]][
parts
[
2
]];
...
...
@@ -763,15 +764,15 @@ jQuery(document).ready(function() {
value
=
obj
;
}
//LOG('value: ', value)
//
LOG('
discovered val:
', value);
LOG
(
'
REPLACE: match
'
+
match
+
'
=>
'
,
value
);
return
value
;
});
//LOG('returning: ', second);
//LOG('
REPLACE: string '+string+' -
returning: ', second);
return
second
;
}
// replace user tokens
function
replace_user_tokens
(
string
,
user
)
{
/*
function replace_user_tokens(string, user) {
for (var key in user) {
if (key === 'course') {
for (var course_key in user['course']) {
...
...
@@ -790,26 +791,26 @@ jQuery(document).ready(function() {
}
}
return string;
}
}
*/
function
replace_args_tokens
(
string
,
args
)
{
//
LOG('in replace_args_tokens');
/*
function replace_args_tokens(string, args) {
LOG('in replace_args_tokens');
for (var key in args) {
replacement = args[key];
if (replacement != null && replacement != "") {
//
LOG('replac
ement (args)
'+replacement);
LOG('replac
ing '+key+' with
'+replacement);
string = string.replace('{'+key+'}', replacement);
}
}
return string;
}
}
*/
function
replace_unused_tokens
(
string
)
{
/*
function replace_unused_tokens(string) {
//LOG('in replace_unused_tokens');
pattern = /{.+}/gm;
string = string.replace(pattern, "");
return string;
}
}
*/
function
value_in_object
(
obj
,
needle
)
{
match
=
false
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment