Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpenBoard
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lifo
Nicolas Ollinger
OpenBoard
Commits
98128717
Commit
98128717
authored
Jun 28, 2012
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed 'ordre letters' widget
parent
5cb41fcd
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
181 additions
and
56 deletions
+181
-56
basic.css
...ces/nonDistributedWidgets/Ordre lettres.wgt/css/basic.css
+8
-2
script.js
...rces/nonDistributedWidgets/Ordre lettres.wgt/js/script.js
+58
-18
script.js
...tributedWidgets/Ordre lettres.wgt/locales/fr/js/script.js
+57
-18
script.js
...tributedWidgets/Ordre lettres.wgt/locales/ru/js/script.js
+58
-18
No files found.
resources/nonDistributedWidgets/Ordre lettres.wgt/css/basic.css
View file @
98128717
...
@@ -102,7 +102,6 @@ body{
...
@@ -102,7 +102,6 @@ body{
background-color
:
#999
;
background-color
:
#999
;
border-top-left-radius
:
20px
;
border-top-left-radius
:
20px
;
border-bottom-left-radius
:
20px
;
border-bottom-left-radius
:
20px
;
padding-left
:
10px
;
}
}
.close_cont
{
.close_cont
{
...
@@ -155,8 +154,15 @@ body{
...
@@ -155,8 +154,15 @@ body{
.audio_block
{
.audio_block
{
width
:
120px
;
width
:
120px
;
height
:
30px
;
height
:
30px
;
margin
:
5px
0
;
padding
:
5px
0
5px
10px
;
float
:
left
;
float
:
left
;
border-right
:
3px
solid
white
;
}
.audio_gray
{
border-top-left-radius
:
15px
;
border-bottom-left-radius
:
15px
;
background-color
:
white
;
}
}
.audio_desc
{
.audio_desc
{
...
...
resources/nonDistributedWidgets/Ordre lettres.wgt/js/script.js
View file @
98128717
...
@@ -45,9 +45,18 @@ function start(){
...
@@ -45,9 +45,18 @@ function start(){
}
}
$
(
"#wgt_reload"
).
click
(
function
(){
$
(
"#wgt_reload"
).
click
(
function
(){
window
.
location
.
reload
();
if
(
$
(
"#wgt_display"
).
hasClass
(
"selected"
)){
$
(
"#wgt_edit"
).
trigger
(
"click"
);
$
(
"#wgt_display"
).
trigger
(
"click"
);
}
else
{
$
(
"#wgt_display"
).
trigger
(
"click"
);
}
});
});
$
(
"#wgt_reload, #wgt_display, #wgt_edit"
).
mouseover
(
function
(){
exportData
();
});
$
(
".style_select"
).
change
(
function
(
event
){
$
(
".style_select"
).
change
(
function
(
event
){
changeStyle
(
$
(
this
).
find
(
"option:selected"
).
val
());
changeStyle
(
$
(
this
).
find
(
"option:selected"
).
val
());
})
})
...
@@ -67,7 +76,7 @@ function start(){
...
@@ -67,7 +76,7 @@ function start(){
var
imgs_container
=
container
.
find
(
".imgs_cont"
);
var
imgs_container
=
container
.
find
(
".imgs_cont"
);
container
.
find
(
".text_cont .audio_desc"
).
removeAttr
(
"contenteditable"
);
container
.
find
(
".text_cont .audio_desc"
).
removeAttr
(
"contenteditable"
);
container
.
find
(
".
text_cont
"
).
removeAttr
(
"ondragenter"
)
container
.
find
(
".
audio_block
"
).
removeAttr
(
"ondragenter"
)
.
removeAttr
(
"ondragleave"
)
.
removeAttr
(
"ondragleave"
)
.
removeAttr
(
"ondragover"
)
.
removeAttr
(
"ondragover"
)
.
removeAttr
(
"ondrop"
)
.
removeAttr
(
"ondrop"
)
...
@@ -105,10 +114,10 @@ function start(){
...
@@ -105,10 +114,10 @@ function start(){
.
addClass
(
"imgs_answers_gray"
)
.
addClass
(
"imgs_answers_gray"
)
.
sortable
(
"destroy"
);
.
sortable
(
"destroy"
);
container
.
find
(
".text_cont .audio_desc"
).
attr
(
"contenteditable"
,
"true"
);
container
.
find
(
".text_cont .audio_desc"
).
attr
(
"contenteditable"
,
"true"
);
container
.
find
(
".
text_cont
"
).
attr
(
"ondragenter"
,
"return false;"
)
container
.
find
(
".
audio_block
"
).
attr
(
"ondragenter"
,
"return false;"
)
.
attr
(
"ondragleave"
,
"$(this).removeClass('gray'); return false;"
)
.
attr
(
"ondragleave"
,
"$(this).removeClass('
audio_
gray'); return false;"
)
.
attr
(
"ondragover"
,
"$(this).addClass('gray'); return false;"
)
.
attr
(
"ondragover"
,
"$(this).addClass('
audio_
gray'); return false;"
)
.
attr
(
"ondrop"
,
"$(this).removeClass('gray'); return onDropAudio(this,event);"
);
.
attr
(
"ondrop"
,
"$(this).removeClass('
audio_
gray'); return onDropAudio(this,event);"
);
container
.
find
(
".img_block"
).
remove
();
container
.
find
(
".img_block"
).
remove
();
$
(
"<div class='audio_answer' contenteditable>"
+
container
.
find
(
".imgs_cont input"
).
val
()
+
"</div>"
).
appendTo
(
container
.
find
(
".imgs_cont"
));
$
(
"<div class='audio_answer' contenteditable>"
+
container
.
find
(
".imgs_cont input"
).
val
()
+
"</div>"
).
appendTo
(
container
.
find
(
".imgs_cont"
));
});
});
...
@@ -217,7 +226,8 @@ function exportData(){
...
@@ -217,7 +226,8 @@ function exportData(){
var
cont_obj
=
new
Object
();
var
cont_obj
=
new
Object
();
cont_obj
.
text
=
$
(
this
).
find
(
".audio_desc"
).
text
();
cont_obj
.
text
=
$
(
this
).
find
(
".audio_desc"
).
text
();
cont_obj
.
audio
=
$
(
this
).
find
(
"source"
).
attr
(
"src"
);
cont_obj
.
audio
=
$
(
this
).
find
(
"source"
).
attr
(
"src"
);
cont_obj
.
answer
=
$
(
this
).
find
(
".audio_answer"
).
text
();
cont_obj
.
answer
=
$
(
this
).
find
(
".audio_answer"
).
text
();
cont_obj
.
cur_answer
=
""
;
array_to_export
.
push
(
cont_obj
);
array_to_export
.
push
(
cont_obj
);
});
});
}
else
{
}
else
{
...
@@ -226,10 +236,15 @@ function exportData(){
...
@@ -226,10 +236,15 @@ function exportData(){
cont_obj
.
text
=
$
(
this
).
find
(
".audio_desc"
).
text
();
cont_obj
.
text
=
$
(
this
).
find
(
".audio_desc"
).
text
();
cont_obj
.
audio
=
$
(
this
).
find
(
"source"
).
attr
(
"src"
);
cont_obj
.
audio
=
$
(
this
).
find
(
"source"
).
attr
(
"src"
);
cont_obj
.
answer
=
$
(
this
).
find
(
".imgs_cont input"
).
val
();
cont_obj
.
answer
=
$
(
this
).
find
(
".imgs_cont input"
).
val
();
cont_obj
.
cur_answer
=
getAnswer
(
$
(
this
).
find
(
".imgs_cont"
));
array_to_export
.
push
(
cont_obj
);
array_to_export
.
push
(
cont_obj
);
});
});
}
}
sankore
.
setPreference
(
"associer_sound"
,
JSON
.
stringify
(
array_to_export
));
sankore
.
setPreference
(
"associer_sound"
,
JSON
.
stringify
(
array_to_export
));
if
(
$
(
"#wgt_display"
).
hasClass
(
"selected"
))
sankore
.
setPreference
(
"associer_sound_state"
,
"display"
);
else
sankore
.
setPreference
(
"associer_sound_state"
,
"edit"
);
}
}
//import
//import
...
@@ -253,16 +268,32 @@ function importData(data){
...
@@ -253,16 +268,32 @@ function importData(data){
$
(
"<input type='hidden'/>"
).
appendTo
(
audio_block
);
$
(
"<input type='hidden'/>"
).
appendTo
(
audio_block
);
$
(
"<div class='audio_desc'>"
+
data
[
i
].
text
+
"</div>"
).
appendTo
(
text
);
$
(
"<div class='audio_desc'>"
+
data
[
i
].
text
+
"</div>"
).
appendTo
(
text
);
$
(
"<input type='hidden' value='"
+
data
[
i
].
answer
+
"'/>"
).
appendTo
(
imgs_container
);
$
(
"<input type='hidden' value='"
+
data
[
i
].
answer
+
"'/>"
).
appendTo
(
imgs_container
);
for
(
var
j
in
data
[
i
].
answer
){
var
tmp_letter
=
$
(
"<div class='img_block' style='text-align: center;'>"
+
data
[
i
].
answer
[
j
]
+
"</div>"
);
if
(
data
[
i
].
cur_answer
)
tmp_array
.
push
(
tmp_letter
);
for
(
var
j
in
data
[
i
].
cur_answer
){
}
var
tmp_letter
=
$
(
"<div class='img_block' style='text-align: center;'>"
+
data
[
i
].
cur_answer
[
j
]
+
"</div>"
);
tmp_array
=
shuffle
(
tmp_array
);
tmp_array
.
push
(
tmp_letter
);
}
else
for
(
j
in
data
[
i
].
answer
){
tmp_letter
=
$
(
"<div class='img_block' style='text-align: center;'>"
+
data
[
i
].
answer
[
j
]
+
"</div>"
);
tmp_array
.
push
(
tmp_letter
);
}
if
(
sankore
.
preference
(
"associer_sound_state"
,
""
)){
if
(
sankore
.
preference
(
"associer_sound_state"
,
""
)
==
"edit"
)
tmp_array
=
shuffle
(
tmp_array
);
}
else
tmp_array
=
shuffle
(
tmp_array
);
for
(
j
=
0
;
j
<
tmp_array
.
length
;
j
++
)
for
(
j
=
0
;
j
<
tmp_array
.
length
;
j
++
)
tmp_array
[
j
].
appendTo
(
imgs_container
);
tmp_array
[
j
].
appendTo
(
imgs_container
);
imgs_container
.
sortable
(
{
update
:
checkResult
imgs_container
.
sortable
().
bind
(
'sortupdate'
,
function
(
event
,
ui
)
{
}
);
checkResult
(
event
);
});
if
(
data
[
i
].
cur_answer
)
imgs_container
.
trigger
(
"sortupdate"
)
}
}
}
}
...
@@ -296,9 +327,9 @@ function showExample(){
...
@@ -296,9 +327,9 @@ function showExample(){
tmp_array
=
shuffle
(
tmp_array
);
tmp_array
=
shuffle
(
tmp_array
);
for
(
var
i
=
0
;
i
<
tmp_array
.
length
;
i
++
)
for
(
var
i
=
0
;
i
<
tmp_array
.
length
;
i
++
)
tmp_array
[
i
].
appendTo
(
imgs_container
);
tmp_array
[
i
].
appendTo
(
imgs_container
);
imgs_container
.
sortable
(
{
imgs_container
.
sortable
(
).
bind
(
'sortupdate'
,
function
(
event
,
ui
)
{
update
:
checkResult
checkResult
(
event
);
}
);
});
}
}
//check result
//check result
...
@@ -458,6 +489,15 @@ function onDropAudio(obj, event) {
...
@@ -458,6 +489,15 @@ function onDropAudio(obj, event) {
return
false
;
return
false
;
}
}
//get text
function
getAnswer
(
obj
){
var
answer
=
""
;
obj
.
find
(
".img_block"
).
each
(
function
(){
answer
+=
$
(
this
).
text
();
});
return
answer
;
}
if
(
window
.
widget
)
{
if
(
window
.
widget
)
{
window
.
widget
.
onremove
=
function
(){
window
.
widget
.
onremove
=
function
(){
$
(
"audio"
).
each
(
function
(){
$
(
"audio"
).
each
(
function
(){
...
...
resources/nonDistributedWidgets/Ordre lettres.wgt/locales/fr/js/script.js
View file @
98128717
...
@@ -45,7 +45,16 @@ function start(){
...
@@ -45,7 +45,16 @@ function start(){
}
}
$
(
"#wgt_reload"
).
click
(
function
(){
$
(
"#wgt_reload"
).
click
(
function
(){
window
.
location
.
reload
();
if
(
$
(
"#wgt_display"
).
hasClass
(
"selected"
)){
$
(
"#wgt_edit"
).
trigger
(
"click"
);
$
(
"#wgt_display"
).
trigger
(
"click"
);
}
else
{
$
(
"#wgt_display"
).
trigger
(
"click"
);
}
});
$
(
"#wgt_reload, #wgt_display, #wgt_edit"
).
mouseover
(
function
(){
exportData
();
});
});
$
(
".style_select"
).
change
(
function
(
event
){
$
(
".style_select"
).
change
(
function
(
event
){
...
@@ -67,7 +76,7 @@ function start(){
...
@@ -67,7 +76,7 @@ function start(){
var
imgs_container
=
container
.
find
(
".imgs_cont"
);
var
imgs_container
=
container
.
find
(
".imgs_cont"
);
container
.
find
(
".text_cont .audio_desc"
).
removeAttr
(
"contenteditable"
);
container
.
find
(
".text_cont .audio_desc"
).
removeAttr
(
"contenteditable"
);
container
.
find
(
".
text_cont
"
).
removeAttr
(
"ondragenter"
)
container
.
find
(
".
audio_block
"
).
removeAttr
(
"ondragenter"
)
.
removeAttr
(
"ondragleave"
)
.
removeAttr
(
"ondragleave"
)
.
removeAttr
(
"ondragover"
)
.
removeAttr
(
"ondragover"
)
.
removeAttr
(
"ondrop"
)
.
removeAttr
(
"ondrop"
)
...
@@ -105,10 +114,10 @@ function start(){
...
@@ -105,10 +114,10 @@ function start(){
.
addClass
(
"imgs_answers_gray"
)
.
addClass
(
"imgs_answers_gray"
)
.
sortable
(
"destroy"
);
.
sortable
(
"destroy"
);
container
.
find
(
".text_cont .audio_desc"
).
attr
(
"contenteditable"
,
"true"
);
container
.
find
(
".text_cont .audio_desc"
).
attr
(
"contenteditable"
,
"true"
);
container
.
find
(
".
text_cont
"
).
attr
(
"ondragenter"
,
"return false;"
)
container
.
find
(
".
audio_block
"
).
attr
(
"ondragenter"
,
"return false;"
)
.
attr
(
"ondragleave"
,
"$(this).removeClass('gray'); return false;"
)
.
attr
(
"ondragleave"
,
"$(this).removeClass('
audio_
gray'); return false;"
)
.
attr
(
"ondragover"
,
"$(this).addClass('gray'); return false;"
)
.
attr
(
"ondragover"
,
"$(this).addClass('
audio_
gray'); return false;"
)
.
attr
(
"ondrop"
,
"$(this).removeClass('gray'); return onDropAudio(this,event);"
);
.
attr
(
"ondrop"
,
"$(this).removeClass('
audio_
gray'); return onDropAudio(this,event);"
);
container
.
find
(
".img_block"
).
remove
();
container
.
find
(
".img_block"
).
remove
();
$
(
"<div class='audio_answer' contenteditable>"
+
container
.
find
(
".imgs_cont input"
).
val
()
+
"</div>"
).
appendTo
(
container
.
find
(
".imgs_cont"
));
$
(
"<div class='audio_answer' contenteditable>"
+
container
.
find
(
".imgs_cont input"
).
val
()
+
"</div>"
).
appendTo
(
container
.
find
(
".imgs_cont"
));
});
});
...
@@ -217,7 +226,8 @@ function exportData(){
...
@@ -217,7 +226,8 @@ function exportData(){
var
cont_obj
=
new
Object
();
var
cont_obj
=
new
Object
();
cont_obj
.
text
=
$
(
this
).
find
(
".audio_desc"
).
text
();
cont_obj
.
text
=
$
(
this
).
find
(
".audio_desc"
).
text
();
cont_obj
.
audio
=
$
(
this
).
find
(
"source"
).
attr
(
"src"
).
replace
(
"../../"
,
""
);
cont_obj
.
audio
=
$
(
this
).
find
(
"source"
).
attr
(
"src"
).
replace
(
"../../"
,
""
);
cont_obj
.
answer
=
$
(
this
).
find
(
".audio_answer"
).
text
();
cont_obj
.
answer
=
$
(
this
).
find
(
".audio_answer"
).
text
();
cont_obj
.
cur_answer
=
""
;
array_to_export
.
push
(
cont_obj
);
array_to_export
.
push
(
cont_obj
);
});
});
}
else
{
}
else
{
...
@@ -226,10 +236,15 @@ function exportData(){
...
@@ -226,10 +236,15 @@ function exportData(){
cont_obj
.
text
=
$
(
this
).
find
(
".audio_desc"
).
text
();
cont_obj
.
text
=
$
(
this
).
find
(
".audio_desc"
).
text
();
cont_obj
.
audio
=
$
(
this
).
find
(
"source"
).
attr
(
"src"
).
replace
(
"../../"
,
""
);
cont_obj
.
audio
=
$
(
this
).
find
(
"source"
).
attr
(
"src"
).
replace
(
"../../"
,
""
);
cont_obj
.
answer
=
$
(
this
).
find
(
".imgs_cont input"
).
val
();
cont_obj
.
answer
=
$
(
this
).
find
(
".imgs_cont input"
).
val
();
cont_obj
.
cur_answer
=
getAnswer
(
$
(
this
).
find
(
".imgs_cont"
));
array_to_export
.
push
(
cont_obj
);
array_to_export
.
push
(
cont_obj
);
});
});
}
}
sankore
.
setPreference
(
"associer_sound"
,
JSON
.
stringify
(
array_to_export
));
sankore
.
setPreference
(
"associer_sound"
,
JSON
.
stringify
(
array_to_export
));
if
(
$
(
"#wgt_display"
).
hasClass
(
"selected"
))
sankore
.
setPreference
(
"associer_sound_state"
,
"display"
);
else
sankore
.
setPreference
(
"associer_sound_state"
,
"edit"
);
}
}
//import
//import
...
@@ -253,16 +268,31 @@ function importData(data){
...
@@ -253,16 +268,31 @@ function importData(data){
$
(
"<input type='hidden'/>"
).
appendTo
(
audio_block
);
$
(
"<input type='hidden'/>"
).
appendTo
(
audio_block
);
$
(
"<div class='audio_desc'>"
+
data
[
i
].
text
+
"</div>"
).
appendTo
(
text
);
$
(
"<div class='audio_desc'>"
+
data
[
i
].
text
+
"</div>"
).
appendTo
(
text
);
$
(
"<input type='hidden' value='"
+
data
[
i
].
answer
+
"'/>"
).
appendTo
(
imgs_container
);
$
(
"<input type='hidden' value='"
+
data
[
i
].
answer
+
"'/>"
).
appendTo
(
imgs_container
);
for
(
var
j
in
data
[
i
].
answer
){
if
(
data
[
i
].
cur_answer
)
var
tmp_letter
=
$
(
"<div class='img_block' style='text-align: center;'>"
+
data
[
i
].
answer
[
j
]
+
"</div>"
);
for
(
var
j
in
data
[
i
].
cur_answer
){
tmp_array
.
push
(
tmp_letter
);
var
tmp_letter
=
$
(
"<div class='img_block' style='text-align: center;'>"
+
data
[
i
].
cur_answer
[
j
]
+
"</div>"
);
}
tmp_array
.
push
(
tmp_letter
);
tmp_array
=
shuffle
(
tmp_array
);
}
else
for
(
j
in
data
[
i
].
answer
){
tmp_letter
=
$
(
"<div class='img_block' style='text-align: center;'>"
+
data
[
i
].
answer
[
j
]
+
"</div>"
);
tmp_array
.
push
(
tmp_letter
);
}
if
(
sankore
.
preference
(
"associer_sound_state"
,
""
)){
if
(
sankore
.
preference
(
"associer_sound_state"
,
""
)
==
"edit"
)
tmp_array
=
shuffle
(
tmp_array
);
}
else
tmp_array
=
shuffle
(
tmp_array
);
for
(
j
=
0
;
j
<
tmp_array
.
length
;
j
++
)
for
(
j
=
0
;
j
<
tmp_array
.
length
;
j
++
)
tmp_array
[
j
].
appendTo
(
imgs_container
);
tmp_array
[
j
].
appendTo
(
imgs_container
);
imgs_container
.
sortable
(
{
update
:
checkResult
imgs_container
.
sortable
().
bind
(
'sortupdate'
,
function
(
event
,
ui
)
{
}
);
checkResult
(
event
);
});
if
(
data
[
i
].
cur_answer
)
imgs_container
.
trigger
(
"sortupdate"
)
}
}
}
}
...
@@ -296,9 +326,9 @@ function showExample(){
...
@@ -296,9 +326,9 @@ function showExample(){
tmp_array
=
shuffle
(
tmp_array
);
tmp_array
=
shuffle
(
tmp_array
);
for
(
var
i
=
0
;
i
<
tmp_array
.
length
;
i
++
)
for
(
var
i
=
0
;
i
<
tmp_array
.
length
;
i
++
)
tmp_array
[
i
].
appendTo
(
imgs_container
);
tmp_array
[
i
].
appendTo
(
imgs_container
);
imgs_container
.
sortable
(
{
imgs_container
.
sortable
(
).
bind
(
'sortupdate'
,
function
(
event
,
ui
)
{
update
:
checkResult
checkResult
(
event
);
}
);
});
}
}
//check result
//check result
...
@@ -457,6 +487,15 @@ function onDropAudio(obj, event) {
...
@@ -457,6 +487,15 @@ function onDropAudio(obj, event) {
return
false
;
return
false
;
}
}
//get text
function
getAnswer
(
obj
){
var
answer
=
""
;
obj
.
find
(
".img_block"
).
each
(
function
(){
answer
+=
$
(
this
).
text
();
});
return
answer
;
}
if
(
window
.
widget
)
{
if
(
window
.
widget
)
{
window
.
widget
.
onremove
=
function
(){
window
.
widget
.
onremove
=
function
(){
$
(
"audio"
).
each
(
function
(){
$
(
"audio"
).
each
(
function
(){
...
...
resources/nonDistributedWidgets/Ordre lettres.wgt/locales/ru/js/script.js
View file @
98128717
...
@@ -11,6 +11,7 @@ var sankoreLang = {
...
@@ -11,6 +11,7 @@ var sankoreLang = {
pad
:
"Планшет"
pad
:
"Планшет"
};
};
//main function
//main function
function
start
(){
function
start
(){
...
@@ -45,7 +46,16 @@ function start(){
...
@@ -45,7 +46,16 @@ function start(){
}
}
$
(
"#wgt_reload"
).
click
(
function
(){
$
(
"#wgt_reload"
).
click
(
function
(){
window
.
location
.
reload
();
if
(
$
(
"#wgt_display"
).
hasClass
(
"selected"
)){
$
(
"#wgt_edit"
).
trigger
(
"click"
);
$
(
"#wgt_display"
).
trigger
(
"click"
);
}
else
{
$
(
"#wgt_display"
).
trigger
(
"click"
);
}
});
$
(
"#wgt_reload, #wgt_display, #wgt_edit"
).
mouseover
(
function
(){
exportData
();
});
});
$
(
".style_select"
).
change
(
function
(
event
){
$
(
".style_select"
).
change
(
function
(
event
){
...
@@ -67,7 +77,7 @@ function start(){
...
@@ -67,7 +77,7 @@ function start(){
var
imgs_container
=
container
.
find
(
".imgs_cont"
);
var
imgs_container
=
container
.
find
(
".imgs_cont"
);
container
.
find
(
".text_cont .audio_desc"
).
removeAttr
(
"contenteditable"
);
container
.
find
(
".text_cont .audio_desc"
).
removeAttr
(
"contenteditable"
);
container
.
find
(
".
text_cont
"
).
removeAttr
(
"ondragenter"
)
container
.
find
(
".
audio_block
"
).
removeAttr
(
"ondragenter"
)
.
removeAttr
(
"ondragleave"
)
.
removeAttr
(
"ondragleave"
)
.
removeAttr
(
"ondragover"
)
.
removeAttr
(
"ondragover"
)
.
removeAttr
(
"ondrop"
)
.
removeAttr
(
"ondrop"
)
...
@@ -105,10 +115,10 @@ function start(){
...
@@ -105,10 +115,10 @@ function start(){
.
addClass
(
"imgs_answers_gray"
)
.
addClass
(
"imgs_answers_gray"
)
.
sortable
(
"destroy"
);
.
sortable
(
"destroy"
);
container
.
find
(
".text_cont .audio_desc"
).
attr
(
"contenteditable"
,
"true"
);
container
.
find
(
".text_cont .audio_desc"
).
attr
(
"contenteditable"
,
"true"
);
container
.
find
(
".
text_cont
"
).
attr
(
"ondragenter"
,
"return false;"
)
container
.
find
(
".
audio_block
"
).
attr
(
"ondragenter"
,
"return false;"
)
.
attr
(
"ondragleave"
,
"$(this).removeClass('gray'); return false;"
)
.
attr
(
"ondragleave"
,
"$(this).removeClass('
audio_
gray'); return false;"
)
.
attr
(
"ondragover"
,
"$(this).addClass('gray'); return false;"
)
.
attr
(
"ondragover"
,
"$(this).addClass('
audio_
gray'); return false;"
)
.
attr
(
"ondrop"
,
"$(this).removeClass('gray'); return onDropAudio(this,event);"
);
.
attr
(
"ondrop"
,
"$(this).removeClass('
audio_
gray'); return onDropAudio(this,event);"
);
container
.
find
(
".img_block"
).
remove
();
container
.
find
(
".img_block"
).
remove
();
$
(
"<div class='audio_answer' contenteditable>"
+
container
.
find
(
".imgs_cont input"
).
val
()
+
"</div>"
).
appendTo
(
container
.
find
(
".imgs_cont"
));
$
(
"<div class='audio_answer' contenteditable>"
+
container
.
find
(
".imgs_cont input"
).
val
()
+
"</div>"
).
appendTo
(
container
.
find
(
".imgs_cont"
));
});
});
...
@@ -217,7 +227,8 @@ function exportData(){
...
@@ -217,7 +227,8 @@ function exportData(){
var
cont_obj
=
new
Object
();
var
cont_obj
=
new
Object
();
cont_obj
.
text
=
$
(
this
).
find
(
".audio_desc"
).
text
();
cont_obj
.
text
=
$
(
this
).
find
(
".audio_desc"
).
text
();
cont_obj
.
audio
=
$
(
this
).
find
(
"source"
).
attr
(
"src"
).
replace
(
"../../"
,
""
);
cont_obj
.
audio
=
$
(
this
).
find
(
"source"
).
attr
(
"src"
).
replace
(
"../../"
,
""
);
cont_obj
.
answer
=
$
(
this
).
find
(
".audio_answer"
).
text
();
cont_obj
.
answer
=
$
(
this
).
find
(
".audio_answer"
).
text
();
cont_obj
.
cur_answer
=
""
;
array_to_export
.
push
(
cont_obj
);
array_to_export
.
push
(
cont_obj
);
});
});
}
else
{
}
else
{
...
@@ -226,10 +237,15 @@ function exportData(){
...
@@ -226,10 +237,15 @@ function exportData(){
cont_obj
.
text
=
$
(
this
).
find
(
".audio_desc"
).
text
();
cont_obj
.
text
=
$
(
this
).
find
(
".audio_desc"
).
text
();
cont_obj
.
audio
=
$
(
this
).
find
(
"source"
).
attr
(
"src"
).
replace
(
"../../"
,
""
);
cont_obj
.
audio
=
$
(
this
).
find
(
"source"
).
attr
(
"src"
).
replace
(
"../../"
,
""
);
cont_obj
.
answer
=
$
(
this
).
find
(
".imgs_cont input"
).
val
();
cont_obj
.
answer
=
$
(
this
).
find
(
".imgs_cont input"
).
val
();
cont_obj
.
cur_answer
=
getAnswer
(
$
(
this
).
find
(
".imgs_cont"
));
array_to_export
.
push
(
cont_obj
);
array_to_export
.
push
(
cont_obj
);
});
});
}
}
sankore
.
setPreference
(
"associer_sound"
,
JSON
.
stringify
(
array_to_export
));
sankore
.
setPreference
(
"associer_sound"
,
JSON
.
stringify
(
array_to_export
));
if
(
$
(
"#wgt_display"
).
hasClass
(
"selected"
))
sankore
.
setPreference
(
"associer_sound_state"
,
"display"
);
else
sankore
.
setPreference
(
"associer_sound_state"
,
"edit"
);
}
}
//import
//import
...
@@ -253,16 +269,31 @@ function importData(data){
...
@@ -253,16 +269,31 @@ function importData(data){
$
(
"<input type='hidden'/>"
).
appendTo
(
audio_block
);
$
(
"<input type='hidden'/>"
).
appendTo
(
audio_block
);
$
(
"<div class='audio_desc'>"
+
data
[
i
].
text
+
"</div>"
).
appendTo
(
text
);
$
(
"<div class='audio_desc'>"
+
data
[
i
].
text
+
"</div>"
).
appendTo
(
text
);
$
(
"<input type='hidden' value='"
+
data
[
i
].
answer
+
"'/>"
).
appendTo
(
imgs_container
);
$
(
"<input type='hidden' value='"
+
data
[
i
].
answer
+
"'/>"
).
appendTo
(
imgs_container
);
for
(
var
j
in
data
[
i
].
answer
){
if
(
data
[
i
].
cur_answer
)
var
tmp_letter
=
$
(
"<div class='img_block' style='text-align: center;'>"
+
data
[
i
].
answer
[
j
]
+
"</div>"
);
for
(
var
j
in
data
[
i
].
cur_answer
){
tmp_array
.
push
(
tmp_letter
);
var
tmp_letter
=
$
(
"<div class='img_block' style='text-align: center;'>"
+
data
[
i
].
cur_answer
[
j
]
+
"</div>"
);
}
tmp_array
.
push
(
tmp_letter
);
tmp_array
=
shuffle
(
tmp_array
);
}
else
for
(
j
in
data
[
i
].
answer
){
tmp_letter
=
$
(
"<div class='img_block' style='text-align: center;'>"
+
data
[
i
].
answer
[
j
]
+
"</div>"
);
tmp_array
.
push
(
tmp_letter
);
}
if
(
sankore
.
preference
(
"associer_sound_state"
,
""
)){
if
(
sankore
.
preference
(
"associer_sound_state"
,
""
)
==
"edit"
)
tmp_array
=
shuffle
(
tmp_array
);
}
else
tmp_array
=
shuffle
(
tmp_array
);
for
(
j
=
0
;
j
<
tmp_array
.
length
;
j
++
)
for
(
j
=
0
;
j
<
tmp_array
.
length
;
j
++
)
tmp_array
[
j
].
appendTo
(
imgs_container
);
tmp_array
[
j
].
appendTo
(
imgs_container
);
imgs_container
.
sortable
(
{
update
:
checkResult
imgs_container
.
sortable
().
bind
(
'sortupdate'
,
function
(
event
,
ui
)
{
}
);
checkResult
(
event
);
});
if
(
data
[
i
].
cur_answer
)
imgs_container
.
trigger
(
"sortupdate"
)
}
}
}
}
...
@@ -296,9 +327,9 @@ function showExample(){
...
@@ -296,9 +327,9 @@ function showExample(){
tmp_array
=
shuffle
(
tmp_array
);
tmp_array
=
shuffle
(
tmp_array
);
for
(
var
i
=
0
;
i
<
tmp_array
.
length
;
i
++
)
for
(
var
i
=
0
;
i
<
tmp_array
.
length
;
i
++
)
tmp_array
[
i
].
appendTo
(
imgs_container
);
tmp_array
[
i
].
appendTo
(
imgs_container
);
imgs_container
.
sortable
(
{
imgs_container
.
sortable
(
).
bind
(
'sortupdate'
,
function
(
event
,
ui
)
{
update
:
checkResult
checkResult
(
event
);
}
);
});
}
}
//check result
//check result
...
@@ -457,6 +488,15 @@ function onDropAudio(obj, event) {
...
@@ -457,6 +488,15 @@ function onDropAudio(obj, event) {
return
false
;
return
false
;
}
}
//get text
function
getAnswer
(
obj
){
var
answer
=
""
;
obj
.
find
(
".img_block"
).
each
(
function
(){
answer
+=
$
(
this
).
text
();
});
return
answer
;
}
if
(
window
.
widget
)
{
if
(
window
.
widget
)
{
window
.
widget
.
onremove
=
function
(){
window
.
widget
.
onremove
=
function
(){
$
(
"audio"
).
each
(
function
(){
$
(
"audio"
).
each
(
function
(){
...
...
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