Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
officejs
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
officejs
Commits
4003ab14
Commit
4003ab14
authored
Jun 07, 2012
by
Sebastien Robin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add skeleton of a more object oriented javascript (By Nicolas Petton)
parent
3f0be792
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
249 additions
and
0 deletions
+249
-0
OfficeJS/src/jio/announcement.js
OfficeJS/src/jio/announcement.js
+65
-0
OfficeJS/src/jio/commands/command.js
OfficeJS/src/jio/commands/command.js
+51
-0
OfficeJS/src/jio/commands/removeCommand.js
OfficeJS/src/jio/commands/removeCommand.js
+15
-0
OfficeJS/src/jio/commands/saveCommand.js
OfficeJS/src/jio/commands/saveCommand.js
+15
-0
OfficeJS/src/jio/documents/document.js
OfficeJS/src/jio/documents/document.js
+16
-0
OfficeJS/src/jio/exceptions.js
OfficeJS/src/jio/exceptions.js
+10
-0
OfficeJS/src/jio/idHandler.js
OfficeJS/src/jio/idHandler.js
+12
-0
OfficeJS/src/jio/jobs/job.js
OfficeJS/src/jio/jobs/job.js
+17
-0
OfficeJS/src/jio/jobs/jobManager.js
OfficeJS/src/jio/jobs/jobManager.js
+10
-0
OfficeJS/src/jio/storages/storage.js
OfficeJS/src/jio/storages/storage.js
+14
-0
OfficeJS/src/jio/storages/storageHandler.js
OfficeJS/src/jio/storages/storageHandler.js
+24
-0
No files found.
OfficeJS/src/jio/announcement.js
0 → 100644
View file @
4003ab14
var
announcement
=
function
(
spec
)
{
var
spec
=
spec
||
{};
var
that
=
{};
var
callbacks
=
[];
that
.
name
=
spec
.
name
;
that
.
add
=
function
(
callback
)
{
callbacks
.
push
(
callback
);
};
that
.
remove
=
function
(
callback
)
{
//TODO;
};
that
.
register
=
function
()
{
announcer
.
register
(
that
);
};
that
.
unregister
=
function
()
{
announcer
.
unregister
(
that
);
};
that
.
trigger
=
function
(
args
)
{
for
(
var
i
=
0
;
i
<
callbacks
.
length
;
i
++
)
{
callbacks
[
i
].
apply
(
null
,
args
);
};
};
return
that
;
};
var
announcer
=
(
function
()
{
var
that
=
{};
var
announcements
=
{};
that
.
register
(
name
)
{
if
(
!
announcements
[
name
])
{
announcements
[
name
]
=
announcement
();
}
};
that
.
unregister
=
function
(
name
)
{
//TODO
};
that
.
at
=
function
(
name
)
{
return
announcements
[
name
];
};
that
.
on
=
function
(
name
,
callback
)
{
that
.
register
(
name
);
that
.
at
(
name
).
add
(
callback
);
};
that
.
trigger
(
name
,
args
)
{
that
.
at
(
name
).
trigger
(
args
);
}
return
that
;
}());
OfficeJS/src/jio/commands/command.js
0 → 100644
View file @
4003ab14
var
command
=
function
(
spec
)
{
var
spec
=
spec
||
{};
var
that
=
{};
var
id
=
idHandler
.
nextId
();
var
date
=
new
Date
();
that
.
document
=
spec
.
document
;
that
.
getDate
=
function
()
{
return
date
;
};
that
.
getId
=
function
()
{
return
id
;
};
that
.
label
=
function
()
{
return
'
command
'
;
};
/*
* Specialized commands that override this should also call `super`
*/
that
.
validate
=
function
(
handler
)
{
that
.
validateState
();
};
/*
* Delegate actual excecution the the handler object
*/
that
.
execute
=
function
(
handler
)
{
handler
.
execute
(
that
);
};
that
.
executeOn
=
function
(
storage
)
{
};
/*
* Do not override.
* Override `validate()` instead
*/
that
.
validateState
=
function
()
{
if
(
!
that
.
document
)
{
throw
invalidCommandState
(
that
);
};
};
return
that
;
};
OfficeJS/src/jio/commands/removeCommand.js
0 → 100644
View file @
4003ab14
var
removeCommand
=
function
(
spec
)
{
var
spec
=
spec
||
{};
var
that
=
command
(
spec
);
that
.
label
=
function
()
{
return
'
removeCommand
'
;
};
that
.
executeOn
=
function
(
storage
)
{
storage
.
executeRemove
(
that
);
};
return
that
;
};
OfficeJS/src/jio/commands/saveCommand.js
0 → 100644
View file @
4003ab14
var
saveCommand
=
function
(
spec
)
{
var
spec
=
spec
||
{};
var
that
=
command
(
spec
);
that
.
label
=
function
()
{
return
'
saveCommand
'
;
};
that
.
executeOn
=
function
(
storage
)
{
storage
.
executeSave
(
that
);
};
return
that
;
};
OfficeJS/src/jio/documents/document.js
0 → 100644
View file @
4003ab14
var
document
=
function
(
spec
)
{
var
spec
=
spec
||
{};
var
that
=
{};
var
name
=
spec
.
name
;
var
content
=
spec
.
content
;
that
.
getName
=
function
()
{
return
name
;
};
that
.
getContent
=
function
()
{
return
content
;
};
}
OfficeJS/src/jio/exceptions.js
0 → 100644
View file @
4003ab14
var
jioException
=
function
()
{
return
{};
};
var
invalidCommandState
=
function
(
command
)
{
var
that
=
jioException
();
that
.
command
=
command
;
return
that
;
};
OfficeJS/src/jio/idHandler.js
0 → 100644
View file @
4003ab14
var
idHandler
=
(
function
()
{
var
that
=
{};
var
id
=
0
;
that
.
nextId
=
function
()
{
id
=
id
+
1
;
return
id
;
};
return
that
;
}());
OfficeJS/src/jio/jobs/job.js
0 → 100644
View file @
4003ab14
var
job
=
function
(
spec
)
{
var
spec
=
spec
||
{};
var
that
=
{};
var
command
=
spec
.
command
;
that
.
getCommand
=
function
()
{
return
command
;
};
that
.
serialized
=
function
()
{
return
command
.
serialized
();
};
return
that
;
};
OfficeJS/src/jio/jobs/jobManager.js
0 → 100644
View file @
4003ab14
var
jobManager
=
(
function
(
spec
)
{
var
spec
=
spec
||
{};
var
that
=
{};
var
jobs
=
[];
}());
OfficeJS/src/jio/storages/storage.js
0 → 100644
View file @
4003ab14
var
storage
=
function
(
spec
)
{
var
spec
=
spec
||
{};
var
that
=
{};
that
.
execute
=
function
(
command
)
{
command
.
executeOn
(
that
);
};
that
.
executeSave
=
function
(
command
)
{};
that
.
executeRemove
=
function
(
command
)
{};
return
that
;
}
OfficeJS/src/jio/storages/storageHandler.js
0 → 100644
View file @
4003ab14
var
storageHandler
=
function
(
spec
)
{
var
spec
=
spec
||
{};
var
that
=
{};
var
storages
=
spec
.
storages
||
[];
that
.
execute
=
function
(
command
)
{
that
.
validate
(
command
);
that
.
doExecute
(
command
);
};
that
.
doExecute
=
function
(
command
)
{
for
(
var
i
=
0
;
i
<
storages
.
length
;
i
++
)
{
storages
[
i
].
execute
(
command
);
}
};
that
.
validate
=
function
(
command
)
{
command
.
validate
(
that
);
};
return
that
;
};
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