Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
typo3
qfq
Commits
8e9e75ce
Commit
8e9e75ce
authored
Jan 30, 2019
by
bbaer
Browse files
Added initialization
parent
c58a80bd
Changes
3
Hide whitespace changes
Inline
Side-by-side
javascript/src/CodeCorrection.js
View file @
8e9e75ce
...
...
@@ -31,24 +31,30 @@ var QfqNS = QfqNS || {};
* @param $target Reference to the HTML Element where the output (comment JSON)
* should be stored.
*/
n
.
CodeCorrection
=
function
(
form
,
data
,
$container
,
$target
,
currentUser
,
language
)
{
this
.
form
=
form
;
this
.
data
=
data
;
n
.
CodeCorrection
=
function
()
{
this
.
page
=
{}
;
this
.
data
=
{}
;
this
.
eventEmitter
=
new
EventEmitter
();
this
.
$parent
=
$container
;
this
.
$target
=
$target
;
this
.
$parent
=
{}
;
this
.
$target
=
{}
;
this
.
$rows
=
[];
this
.
annotations
=
[];
this
.
users
=
[];
this
.
currentUser
=
currentUser
;
this
.
language
=
language
;
this
.
currentUser
=
{}
;
this
.
language
=
""
;
this
.
syntaxHighlight
=
{};
};
/**
* Initializes the Code Correction object, fetches data from URL or API if needed
*/
n
.
CodeCorrection
.
prototype
.
initialize
=
function
()
{
n
.
CodeCorrection
.
prototype
.
initialize
=
function
(
$container
,
page
)
{
this
.
$parent
=
$container
;
this
.
$target
=
$
(
"
#
"
+
$container
.
data
(
"
target
"
));
this
.
data
=
{
url
:
$container
.
data
(
"
file
"
)
};
this
.
currentUser
=
$container
.
data
(
"
uid
"
);
var
that
=
this
;
if
(
this
.
$target
.
val
())
{
var
jImport
=
$
.
parseJSON
(
this
.
$target
.
val
());
...
...
@@ -132,11 +138,19 @@ var QfqNS = QfqNS || {};
var
$hook
=
this
.
$rows
[
annotation
.
lineNumber
];
var
commentController
=
this
.
_buildCommentContainer
(
$hook
);
commentController
.
importComments
(
annotation
.
comments
,
this
.
users
);
this
.
_setListeners
(
commentController
);
this
.
_setCommentController
(
annotation
.
lineNumber
,
commentController
);
}
};
n
.
CodeCorrection
.
prototype
.
_setCommentMarker
=
function
(
$hook
,
numberOfComments
)
{
var
container
=
$
(
'
<span/>
'
,
{
class
:
"
badge
"
,
text
:
numberOfComments
});
};
/**
* Builds a Line as a combination of HTML Elements. Binds the necessary Events.
*
...
...
@@ -158,7 +172,13 @@ var QfqNS = QfqNS || {};
});
var
cLine
=
line
.
replace
(
/
\s
/g
,
'
'
)
.
replace
(
'
<
'
,
'
<
'
)
.
replace
(
'
>
'
,
'
>
'
);
.
replace
(
'
>
'
,
'
>
'
)
.
replace
(
'
&
'
,
'
&
'
)
.
replace
(
'
;
'
,
'
;
'
)
.
replace
(
'
"
'
,
'
"
'
)
.
replace
(
'
\'
'
,
'
'
'
)
.
replace
(
'
\\
'
,
'
\
'
)
.
replace
(
'
/
'
,
'
/
'
);
cLine
=
this
.
syntaxHighlight
.
highlightLine
(
cLine
);
var
htmlCodeLine
=
$
(
'
<div/>
'
,
{
class
:
'
pull-right qfqCode
'
...
...
javascript/src/QfqPage.js
View file @
8e9e75ce
...
...
@@ -100,6 +100,15 @@ var QfqNS = QfqNS || {};
n
.
Log
.
error
(
e
.
message
);
}
try
{
$
(
"
.annotate-text
"
).
each
(
function
()
{
var
codeCorrection
=
new
QfqNS
.
CodeCorrection
();
codeCorrection
.
initialize
(
$
(
this
),
page
);
});
}
catch
(
e
)
{
n
.
Log
.
error
(
e
.
message
);
}
QfqNS
.
TypeAhead
.
install
(
this
.
settings
.
typeAheadUrl
);
QfqNS
.
CharacterCount
.
initialize
();
};
...
...
mockup/codeCorrection.html
View file @
8e9e75ce
...
...
@@ -43,9 +43,9 @@
<div
class=
"col-md-8"
>
<div
class=
"annotate-text"
data-uid=
'{uid: 5, name: "Definitely not an AI", avatar: "mockData/avatar1.png"}'
<!
--
logged
in
user
--
>
data-file="../javascript/src/CodeCorrection.js"
<!-- File to correct -->
data-target="codeCorrection-output1"
<!-- input field -->
data-uid=
'{uid: 5, name: "Definitely not an AI", avatar: "mockData/avatar1.png"}'
data-file=
"../javascript/src/CodeCorrection.js"
data-target=
"codeCorrection-output1"
data-highlight=
"javascript"
>
</div>
...
...
@@ -98,15 +98,14 @@
QfqNS
.
Log
.
level
=
0
;
var
codeCorrection
=
new
QfqNS
.
CodeCorrection
(
qfqPage
,
{
url
:
'
../javascript/src/CodeCorrection.js
'
},
$
(
'
.annotate-text
'
),
$
(
'
#codeCorrection-output1
'
),
{
uid
:
5
,
name
:
"
Definitely not an AI
"
,
avatar
:
"
mockData/avatar1.png
"
},
'
http://localhost:63342/qfq/mockup/mockData/javascript.json
'
);
codeCorrection
.
initialize
();
//var codeCorrection = new QfqNS.CodeCorrection(qfqPage, {
// url: '../javascript/src/CodeCorrection.js'
//}, $('.annotate-text'), $('#codeCorrection-output1'), {
// uid: 5,
// name: "Definitely not an AI",
// avatar: "mockData/avatar1.png"
//}, 'http://localhost:63342/qfq/mockup/mockData/javascript.json');
//codeCorrection.initialize();
});
</script>
</body>
...
...
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