Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
jio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Aurélien Vermylen
jio
Commits
c1a8aff1
Commit
c1a8aff1
authored
Dec 05, 2013
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
html5.js not used by Firefox and Chrome anymore
parent
f544ed16
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
228 additions
and
223 deletions
+228
-223
test/html5.js
test/html5.js
+228
-223
No files found.
test/html5.js
View file @
c1a8aff1
/*jslint indent: 2, nomen: true, sloppy: true */
/*jslint indent: 2, nomen: true, sloppy: true */
/*global setTimeout */
/*global setTimeout
, window, navigator
*/
////////////////////////////////////////////////////////////
(
function
()
{
// https://github.com/TristanCavelier/notesntools/blob/\
////////////////////////////////////////////////////////////
// master/javascript/stringToUtf8Bytes.js
// https://github.com/TristanCavelier/notesntools/blob/\
/**
// master/javascript/stringToUtf8Bytes.js
/**
* Converts a string into a Utf8 raw string (0 <= char <= 255)
* Converts a string into a Utf8 raw string (0 <= char <= 255)
*
*
* @param {String} input String to convert
* @param {String} input String to convert
* @return {String} Utf8 byte string
* @return {String} Utf8 byte string
*/
*/
function
stringToUtf8ByteString
(
input
)
{
function
stringToUtf8ByteString
(
input
)
{
/*jslint bitwise: true */
/*jslint bitwise: true */
var
output
=
""
,
i
,
x
,
y
,
l
=
input
.
length
;
var
output
=
""
,
i
,
x
,
y
,
l
=
input
.
length
;
...
@@ -47,15 +48,15 @@ function stringToUtf8ByteString(input) {
...
@@ -47,15 +48,15 @@ function stringToUtf8ByteString(input) {
}
}
}
}
return
output
;
return
output
;
}
}
/**
/**
* Converts a Utf8 raw string (0 <= char <= 255) into a real string
* Converts a Utf8 raw string (0 <= char <= 255) into a real string
*
*
* @param {String} input Utf8 encoded Bytes to convert
* @param {String} input Utf8 encoded Bytes to convert
* @return {String} Real string
* @return {String} Real string
*/
*/
function
utf8ByteStringToString
(
input
)
{
function
utf8ByteStringToString
(
input
)
{
/*jslint bitwise: true */
/*jslint bitwise: true */
var
output
=
""
,
i
,
x
,
l
=
input
.
length
;
var
output
=
""
,
i
,
x
,
l
=
input
.
length
;
...
@@ -101,15 +102,11 @@ function utf8ByteStringToString(input) {
...
@@ -101,15 +102,11 @@ function utf8ByteStringToString(input) {
}
}
}
}
return
output
;
return
output
;
}
}
////////////////////////////////////////////////////////////
function
ord
(
chr
)
{
////////////////////////////////////////////////////////////
return
chr
.
charCodeAt
(
0
);
}
function
Blob
(
parts
,
properties
)
{
function
Blob
(
parts
,
properties
)
{
var
i
,
part
,
raw
=
''
,
type
;
var
i
,
part
,
raw
=
''
,
type
;
type
=
(
properties
&&
properties
.
type
&&
properties
.
type
.
toString
())
||
""
;
type
=
(
properties
&&
properties
.
type
&&
properties
.
type
.
toString
())
||
""
;
if
(
!
Array
.
isArray
(
parts
))
{
if
(
!
Array
.
isArray
(
parts
))
{
...
@@ -148,10 +145,10 @@ function Blob(parts, properties) {
...
@@ -148,10 +145,10 @@ function Blob(parts, properties) {
"
writable
"
:
false
,
"
writable
"
:
false
,
"
value
"
:
type
"
value
"
:
type
});
});
}
}
Blob
.
prototype
.
type
=
""
;
Blob
.
prototype
.
type
=
""
;
Blob
.
prototype
.
size
=
0
;
Blob
.
prototype
.
size
=
0
;
Blob
.
prototype
.
slice
=
function
(
start
,
end
,
contentType
)
{
Blob
.
prototype
.
slice
=
function
(
start
,
end
,
contentType
)
{
var
data
,
blob
,
i
,
fake_data
=
''
;
var
data
,
blob
,
i
,
fake_data
=
''
;
data
=
this
.
_data
.
slice
(
start
,
end
);
data
=
this
.
_data
.
slice
(
start
,
end
);
for
(
i
=
0
;
i
<
data
.
length
;
i
+=
1
)
{
for
(
i
=
0
;
i
<
data
.
length
;
i
+=
1
)
{
...
@@ -160,16 +157,16 @@ Blob.prototype.slice = function (start, end, contentType) {
...
@@ -160,16 +157,16 @@ Blob.prototype.slice = function (start, end, contentType) {
blob
=
new
Blob
([
fake_data
],
{
"
type
"
:
contentType
});
blob
=
new
Blob
([
fake_data
],
{
"
type
"
:
contentType
});
blob
.
_data
=
data
;
blob
.
_data
=
data
;
return
blob
;
return
blob
;
};
};
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
// https://github.com/TristanCavelier/notesntools/blob/\
// https://github.com/TristanCavelier/notesntools/blob/\
// master/javascript/emitter.js
// master/javascript/emitter.js
function
FileReader
()
{
function
FileReader
()
{
return
;
return
;
}
}
FileReader
.
prototype
.
addEventListener
=
function
(
eventName
,
callback
)
{
FileReader
.
prototype
.
addEventListener
=
function
(
eventName
,
callback
)
{
// Check parameters
// Check parameters
if
(
typeof
callback
!==
"
function
"
)
{
if
(
typeof
callback
!==
"
function
"
)
{
return
;
return
;
...
@@ -179,9 +176,9 @@ FileReader.prototype.addEventListener = function (eventName, callback) {
...
@@ -179,9 +176,9 @@ FileReader.prototype.addEventListener = function (eventName, callback) {
this
.
_events
=
this
.
_events
||
{};
this
.
_events
=
this
.
_events
||
{};
this
.
_events
[
eventName
]
=
this
.
_events
[
eventName
]
||
[];
this
.
_events
[
eventName
]
=
this
.
_events
[
eventName
]
||
[];
this
.
_events
[
eventName
].
push
(
callback
);
this
.
_events
[
eventName
].
push
(
callback
);
};
};
function
dispatchEvent
(
fr
,
eventName
)
{
function
dispatchEvent
(
fr
,
eventName
)
{
var
args
,
i
,
funs
=
fr
.
_events
&&
fr
.
_events
[
eventName
]
&&
var
args
,
i
,
funs
=
fr
.
_events
&&
fr
.
_events
[
eventName
]
&&
fr
.
_events
[
eventName
].
slice
();
fr
.
_events
[
eventName
].
slice
();
...
@@ -206,9 +203,9 @@ function dispatchEvent(fr, eventName) {
...
@@ -206,9 +203,9 @@ function dispatchEvent(fr, eventName) {
funs
[
i
].
apply
(
fr
,
args
);
funs
[
i
].
apply
(
fr
,
args
);
}
}
}
}
}
}
FileReader
.
prototype
.
removeEventListener
=
function
(
eventName
,
callback
)
{
FileReader
.
prototype
.
removeEventListener
=
function
(
eventName
,
callback
)
{
var
i
,
funs
=
this
.
_events
&&
this
.
_events
[
eventName
];
var
i
,
funs
=
this
.
_events
&&
this
.
_events
[
eventName
];
if
(
funs
)
{
if
(
funs
)
{
...
@@ -219,14 +216,14 @@ FileReader.prototype.removeEventListener = function (eventName, callback) {
...
@@ -219,14 +216,14 @@ FileReader.prototype.removeEventListener = function (eventName, callback) {
}
}
}
}
}
}
};
};
FileReader
.
prototype
.
abort
=
function
()
{
FileReader
.
prototype
.
abort
=
function
()
{
this
.
dispatchEvent
(
"
abort
"
,
{
"
target
"
:
this
});
this
.
dispatchEvent
(
"
abort
"
,
{
"
target
"
:
this
});
delete
this
.
_events
;
delete
this
.
_events
;
};
};
FileReader
.
prototype
.
readAsBinaryString
=
function
(
blob
)
{
FileReader
.
prototype
.
readAsBinaryString
=
function
(
blob
)
{
var
that
=
this
;
var
that
=
this
;
setTimeout
(
function
()
{
setTimeout
(
function
()
{
dispatchEvent
(
that
,
"
progress
"
,
{
dispatchEvent
(
that
,
"
progress
"
,
{
...
@@ -241,9 +238,9 @@ FileReader.prototype.readAsBinaryString = function (blob) {
...
@@ -241,9 +238,9 @@ FileReader.prototype.readAsBinaryString = function (blob) {
"
target
"
:
that
"
target
"
:
that
});
});
});
});
};
};
FileReader
.
prototype
.
readAsText
=
function
(
blob
)
{
FileReader
.
prototype
.
readAsText
=
function
(
blob
)
{
var
that
=
this
;
var
that
=
this
;
setTimeout
(
function
()
{
setTimeout
(
function
()
{
dispatchEvent
(
that
,
"
progress
"
,
{
dispatchEvent
(
that
,
"
progress
"
,
{
...
@@ -258,6 +255,14 @@ FileReader.prototype.readAsText = function (blob) {
...
@@ -258,6 +255,14 @@ FileReader.prototype.readAsText = function (blob) {
"
target
"
:
that
"
target
"
:
that
});
});
});
});
};
};
////////////////////////////////////////////////////////////
if
(
typeof
Blob
!==
'
function
'
||
typeof
FileReader
!==
'
function
'
||
(
/
\b
PhantomJS
\b
/i
).
test
(
navigator
.
userAgent
))
{
window
.
Blob
=
Blob
;
window
.
FileReader
=
FileReader
;
}
////////////////////////////////////////////////////////////
}());
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