Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kityminder-core
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
吴志俊
kityminder-core
Commits
4d023087
Commit
4d023087
authored
Jul 07, 2014
by
techird
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加GBK导入的选项
parent
ad8d2e16
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
14 deletions
+22
-14
social.js
social/social.js
+13
-5
dropfile.js
src/module/dropfile.js
+9
-9
No files found.
social/social.js
View file @
4d023087
...
@@ -124,16 +124,24 @@ $(function() {
...
@@ -124,16 +124,24 @@ $(function() {
acceptFiles
.
push
(
p
.
fileExtension
);
acceptFiles
.
push
(
p
.
fileExtension
);
}
}
});
});
menus
=
menus
.
concat
([{
label
:
'导入本地文件'
,
function
importUseEncoding
(
encoding
)
{
click
:
function
()
{
return
function
()
{
$
(
'<input type="file" />'
)
$
(
'<input type="file" />'
)
.
attr
(
'accept'
,
acceptFiles
.
join
(
','
))
.
attr
(
'accept'
,
acceptFiles
.
join
(
','
))
.
on
(
'change'
,
function
(
e
)
{
.
on
(
'change'
,
function
(
e
)
{
e
=
e
.
originalEvent
;
e
=
e
.
originalEvent
;
minder
.
importFile
(
e
.
target
.
files
[
0
]);
minder
.
importFile
(
e
.
target
.
files
[
0
]
,
encoding
);
}).
click
();
}).
click
();
}
};
}
menus
=
menus
.
concat
([{
label
:
'导入...'
,
click
:
importUseEncoding
(
'utf8'
)
},
{
label
:
'以 GBK 编码导入...'
,
click
:
importUseEncoding
(
'gbk'
)
},
{
},
{
divider
:
true
divider
:
true
}]);
}]);
...
...
src/module/dropfile.js
View file @
4d023087
...
@@ -34,7 +34,7 @@ KityMinder.registerModule('DropFile', function() {
...
@@ -34,7 +34,7 @@ KityMinder.registerModule('DropFile', function() {
}
}
}
}
function
importMinderFile
(
minder
,
file
)
{
function
importMinderFile
(
minder
,
file
,
encoding
)
{
if
(
!
file
)
return
;
if
(
!
file
)
return
;
var
ext
=
/
(
.
)\w
+$/
.
exec
(
file
.
name
);
var
ext
=
/
(
.
)\w
+$/
.
exec
(
file
.
name
);
...
@@ -48,11 +48,11 @@ KityMinder.registerModule('DropFile', function() {
...
@@ -48,11 +48,11 @@ KityMinder.registerModule('DropFile', function() {
}
else
if
((
/mmap/g
).
test
(
ext
))
{
// mindmanager zip
}
else
if
((
/mmap/g
).
test
(
ext
))
{
// mindmanager zip
importSync
(
minder
,
file
,
'mindmanager'
);
importSync
(
minder
,
file
,
'mindmanager'
);
}
else
if
((
/mm/g
).
test
(
ext
))
{
//freemind xml
}
else
if
((
/mm/g
).
test
(
ext
))
{
//freemind xml
importAsync
(
minder
,
file
,
'freemind'
);
importAsync
(
minder
,
file
,
'freemind'
,
encoding
);
}
else
if
(
/km/
.
test
(
ext
))
{
// txt json
}
else
if
(
/km/
.
test
(
ext
))
{
// txt json
importAsync
(
minder
,
file
,
'json'
);
importAsync
(
minder
,
file
,
'json'
,
encoding
);
}
else
if
(
/txt/
.
test
(
ext
))
{
}
else
if
(
/txt/
.
test
(
ext
))
{
importAsync
(
minder
,
file
,
'plain'
);
importAsync
(
minder
,
file
,
'plain'
,
encoding
);
}
else
{
}
else
{
alert
(
'不支持导入此类文件!'
);
alert
(
'不支持导入此类文件!'
);
}
}
...
@@ -78,12 +78,12 @@ KityMinder.registerModule('DropFile', function() {
...
@@ -78,12 +78,12 @@ KityMinder.registerModule('DropFile', function() {
}
}
// 异步加载文件
// 异步加载文件
function
importAsync
(
minder
,
file
,
protocal
)
{
function
importAsync
(
minder
,
file
,
protocal
,
encoding
)
{
var
reader
=
new
FileReader
();
var
reader
=
new
FileReader
();
reader
.
onload
=
function
(
e
)
{
reader
.
onload
=
function
(
e
)
{
importSync
(
minder
,
e
.
target
.
result
,
protocal
);
importSync
(
minder
,
e
.
target
.
result
,
protocal
);
};
};
reader
.
readAsText
(
file
);
reader
.
readAsText
(
file
,
encoding
||
'utf8'
);
}
}
function
createDraft
(
minder
)
{
function
createDraft
(
minder
)
{
...
@@ -92,8 +92,8 @@ KityMinder.registerModule('DropFile', function() {
...
@@ -92,8 +92,8 @@ KityMinder.registerModule('DropFile', function() {
}
}
kity
.
extendClass
(
Minder
,
{
kity
.
extendClass
(
Minder
,
{
importFile
:
function
(
file
)
{
importFile
:
function
(
file
,
encoding
)
{
importMinderFile
(
this
,
file
);
importMinderFile
(
this
,
file
,
encoding
);
return
this
;
return
this
;
}
}
});
});
...
...
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