Commit e075ab68 authored by Lingnan Wu's avatar Lingnan Wu

Add the dinamic function to build the list in the List page . Change the...

Add the dinamic function to build the list in the List page . Change the officeJS to OfficeJS-Mobile to suit the site
parent 9e6a4d29
...@@ -14,10 +14,10 @@ ...@@ -14,10 +14,10 @@
<script type="text/javascript" src="lib/sjcl/sjcl.min.js"></script> <script type="text/javascript" src="lib/sjcl/sjcl.min.js"></script>
<script type="text/javascript" src="src/jio.storage.js"></script> <script type="text/javascript" src="src/jio.storage.js"></script>
<script type="text/javascript" src="js/officejs.js"></script> <script type="text/javascript" src="js/officejs-mobile.js"></script>
</head> </head>
<body> <body>
<!-- Home --> <!---------------------------------------------------------- Home --------------------------------------------------------------->
<div data-role="page" id="home"> <div data-role="page" id="home">
<div data-role="header"> <div data-role="header">
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
<div data-role="content" style="padding: 15px"> <div data-role="content" style="padding: 15px">
<div data-role="fieldcontain"> <div data-role="fieldcontain">
<fieldset data-role="controlgroup"> <fieldset data-role="controlgroup">
<label class="control-label" for="input_json_storage"> <label class="control-label ui-input-text" for="input_json_storage">
JSON Storage JSON Storage
</label> </label>
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
<div data-role="fieldcontain"> <div data-role="fieldcontain">
<fieldset data-role="controlgroup"> <fieldset data-role="controlgroup">
<label class="control-label" for="JSONapplicantID"> <label class="control-label ui-input-text" for="JSONapplicantID">
JSON Application JSON Application
</label> </label>
...@@ -51,13 +51,13 @@ ...@@ -51,13 +51,13 @@
</fieldset> </fieldset>
</div> </div>
<a href="#tools" data-role="button" data-transition="slideup" data-theme="b" onclick="console.log('asdf');OfficeJS.setJio( <a href="#tools" data-role="button" data-transition="slideup" data-theme="b" onclick="OfficeJS.setJio(
$('#input_json_storage').attr('value'), $('#input_json_storage').attr('value'),
$('#input_json_applicant').attr('value'));">Create New JIO</a> $('#input_json_applicant').attr('value'));">Create New JIO</a>
</div> </div>
</div> </div>
<!--Tools Page--> <!-----------------------------------------------------Tools Page-------------------------------------------------------------->
<div data-role="page" id="tools"> <div data-role="page" id="tools">
<div data-role="header"> <div data-role="header">
...@@ -81,7 +81,7 @@ ...@@ -81,7 +81,7 @@
</a> </a>
</li> </li>
<li data-theme="c"> <li data-theme="c">
<a href="#text" data-transition="slide"> <a href="#text" data-transition="slide" onclick=" OfficeJS.open({app:'text_editor'}); return false;">
New Text Document New Text Document
</a> </a>
</li> </li>
...@@ -105,7 +105,7 @@ ...@@ -105,7 +105,7 @@
</div> </div>
<!--List Page--> <!-------------------------------------------------------List Page------------------------------------------------------------->
<div data-role="page" id="list"> <div data-role="page" id="list">
<div data-role="header"> <div data-role="header">
...@@ -119,11 +119,11 @@ ...@@ -119,11 +119,11 @@
</div> </div>
<div data-role="content" style="padding: 15px"> <div data-role="content" style="padding: 15px">
<ul class="ui-listview" data-role="listview"> <ul class="ui-listview" data-role="listview" id="textlist">
<li class="ui-btn ui-btn-icon-right ui-li-has-arrow ui-li ui-btn-up-c" data-corners="false" data-shadow="false" data-iconshadow="true" data-wrapperels="div" data-icon="arrow-r" data-iconpos="right" data-theme="c"> <li class="ui-btn ui-btn-icon-right ui-li-has-arrow ui-li ui-btn-up-c" data-corners="false" data-shadow="false" data-iconshadow="true" data-wrapperels="div" data-icon="arrow-r" data-iconpos="right" data-theme="c">
<div class="ui-btn-inner ui-li"> <div class="ui-btn-inner ui-li">
<div class="ui-btn-text"> <div class="ui-btn-text">
<a class="ui-link-inherit" href="#text"> <a class="ui-link-inherit" href="#text" onclick="console.log('name is '+OfficeJS.list[0].title+' text is '+OfficeJS.list[0].text)">
<h3 class="ui-li-heading">name</h3> <h3 class="ui-li-heading">name</h3>
<p class="ui-li-desc">Text Editor</p> <p class="ui-li-desc">Text Editor</p>
</a> </a>
...@@ -132,12 +132,64 @@ ...@@ -132,12 +132,64 @@
</div> </div>
</li> </li>
</ul> </ul>
</div> <script type="text/javascript">
NewList = function (listname,listtype){
</div> //get the main list
var mainList = document.getElementById("textlist");
//set the new element
<!--Text Page--> newElement = document.createElement("li");
newElement.setAttribute("class","ui-btn ui-btn-icon-right ui-li-has-arrow ui-li ui-btn-up-c");
newElement.setAttribute("data-theme","c");
newElement.setAttribute("data-iconpos","right");
newElement.setAttribute("data-icon","arrow-r");
newElement.setAttribute("data-wrapperels","div");
newElement.setAttribute("data-iconshadow","true");
newElement.setAttribute("data-shadow","false");
newElement.setAttribute("data-corners","false");
mainList.appendChild(newElement);
//set firstdiv
newFirstdiv = document.createElement("div");
newFirstdiv.setAttribute("class","ui-btn-inner ui-li");
newElement.appendChild(newFirstdiv);
//set seconddiv
newSeconddiv = document.createElement("div");
newSeconddiv.setAttribute("class","ui-btn-text");
newFirstdiv.appendChild(newSeconddiv);
//set a tag
newa = document.createElement("a");
newa.setAttribute("class","ui-link-inherit");
newa.setAttribute("href","#text");
newa.setAttribute("onclick","console.log('name is '+OfficeJS.list[0].title+' text is '+OfficeJS.list[0].text)");
newSeconddiv.appendChild(newa);
//set head
newhead = document.createElement("h3");
newhead.setAttribute("class","ui-li-heading");
newa.appendChild(newhead);
newHeadtext = document.createTextNode(listname);
newhead.appendChild(newHeadtext);
//set type
newtype = document.createElement("p");
newtype.setAttribute("class","ui-li-desc");
newa.appendChild(newtype);
newTypetext = document.createTextNode(listtype);
newtype.appendChild(newTypetext);
//set shadow
newshadow = document.createElement("span");
newshadow.setAttribute("class","ui-icon ui-icon-arrow-r ui-icon-shadow");
newFirstdiv.appendChild(newshadow);
}
NewList("name","Text Editor");
</script>
</div>
</div>
<!---------------------------------------------------------Text Page------------------------------------------------------------->
<div data-role="page" id="text"> <div data-role="page" id="text">
<div data-role="header"> <div data-role="header">
...@@ -154,22 +206,22 @@ ...@@ -154,22 +206,22 @@
<div data-role="content" style="padding: 15px"> <div data-role="content" style="padding: 15px">
<div data-role="fieldcontain"> <div data-role="fieldcontain">
<fieldset data-role="controlgroup"> <fieldset data-role="controlgroup">
<label for="textinput6"> <label for="input_file_name">
Name Name
</label> </label>
<input id="textinput6" placeholder="" value="" type="text"> <input id="input_file_name" placeholder="" value="" type="text">
</fieldset> </fieldset>
</div> </div>
<div data-role="fieldcontain"> <div data-role="fieldcontain">
<fieldset data-role="controlgroup"> <fieldset data-role="controlgroup">
<label for="textarea2"> <label for="input_file_content">
Content Content
</label> </label>
<textarea id="textarea2" placeholder=""> <textarea id="input_file_content" placeholder="">
</textarea> </textarea>
</fieldset> </fieldset>
</div> </div>
<a data-role="button" data-transition="fade" data-theme="b" href="#page1"> <a data-role="button" data-transition="fade" data-theme="b" class="btn btn-primary" onclick="OfficeJS.save($('#input_file_name').attr('value'),$('#input_file_content').attr('value'));" type="submit">
Save Save
</a> </a>
</div> </div>
......
...@@ -9,13 +9,19 @@ ...@@ -9,13 +9,19 @@
return file_name; return file_name;
} }
}; };
/** /**
* OfficeJS Object * OfficeJS Object
*/ */
;
window.OfficeJS = (function () { window.OfficeJS = (function () {
var that = {}, priv = {}; var that = {}, priv = {};
// Attributes // // Attributes //
that.list=new Array();//数组
priv.preference_object = { priv.preference_object = {
document_lister:'slickgrid', document_lister:'slickgrid',
edit_preferences:'simplepreferenceeditor', edit_preferences:'simplepreferenceeditor',
...@@ -432,7 +438,7 @@ ...@@ -432,7 +438,7 @@
that.setJio = function (storage,applicant) { that.setJio = function (storage,applicant) {
var leftnavbar; var leftnavbar;
if (priv.isJioSet()) { if (priv.isJioSet()) {
alert ('Jio already set.'); // alert ('Jio already set.');
return; return;
} }
// if there is not any jio created // if there is not any jio created
...@@ -442,7 +448,8 @@ ...@@ -442,7 +448,8 @@
if (typeof leftnavbar.update !== 'undefined') { if (typeof leftnavbar.update !== 'undefined') {
leftnavbar.update(); leftnavbar.update();
}*/ }*/
that.getList(); //Forbid the list to avoid error
// that.getList();
}; };
/** /**
...@@ -488,8 +495,8 @@ ...@@ -488,8 +495,8 @@
* @method save * @method save
* @param {string} basename The document name without ext. * @param {string} basename The document name without ext.
*/ */
that.save = function (basename) { that.save = function (basename,content) {
var current_editor = priv.data_object.currentEditor; /* var current_editor = priv.data_object.currentEditor;
if (!priv.isJioSet()) { if (!priv.isJioSet()) {
console.error ('No Jio set yet.'); console.error ('No Jio set yet.');
return; return;
...@@ -505,7 +512,16 @@ ...@@ -505,7 +512,16 @@
priv.loading_object.end_save(); priv.loading_object.end_save();
that.getList(); that.getList();
} }
}); });*/
var obj=new Object();//new object
obj.title=basename;//object title and text
obj.text=content;
that.list.push(obj);//save in the list
}; };
/** /**
...@@ -590,8 +606,4 @@ ...@@ -590,8 +606,4 @@
return that; return that;
}()); // end OfficeJS }()); // end OfficeJS
// show gadgets
OfficeJS.open({app:'topnavbar'});
OfficeJS.open({app:'leftnavbar'});
OfficeJS.open({app:'login'});
}()); }());
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment