Commit 49c4fd1a authored by Lingnan Wu's avatar Lingnan Wu

add all the ajax with cash :true for using the cash ,and add a ung-theme.js in...

add all the ajax with cash :true for using the cash ,and add a ung-theme.js in js file to control the show and hide of the ung and theme gadgets
parent f31af4f1
This diff is collapsed.
......@@ -2215,6 +2215,7 @@ Ext.lib.Ajax = function(){
jQuery.ajax({
type: Ext.getDom(form).method ||'POST',
url: uri,
cache: true,
data: jQuery(form).serialize()+(data?'&'+data:''),
timeout: cb.timeout,
complete: createComplete(cb)
......@@ -2447,4 +2448,4 @@ if(Ext.isIE) {
}
window.attachEvent("onunload", fnCleanUp);
}
})();
\ No newline at end of file
})();
......@@ -779,6 +779,7 @@ function evalScript( i, elem ) {
jQuery.ajax({
url: elem.src,
async: false,
cache: true,
dataType: "script"
});
} else {
......@@ -4822,6 +4823,7 @@ jQuery.fn.extend({
url: url,
type: type,
dataType: "html",
cache: true,
data: params,
complete: function( res, status ) {
// If successful, inject the HTML into all the matched elements
......@@ -4896,6 +4898,7 @@ jQuery.extend({
return jQuery.ajax({
type: "GET",
url: url,
cache:true ,
data: data,
success: callback,
dataType: type
......@@ -4922,6 +4925,7 @@ jQuery.extend({
type: "POST",
url: url,
data: data,
cache: true,
success: callback,
dataType: type
});
......
This diff is collapsed.
......@@ -5726,7 +5726,8 @@ function evalScript( i, elem ) {
jQuery.ajax({
url: elem.src,
async: false,
dataType: "script"
dataType: "script",
cache: true
});
} else {
jQuery.globalEval( elem.text || elem.textContent || elem.innerHTML || "" );
......@@ -6281,6 +6282,7 @@ jQuery.fn.extend({
type: type,
dataType: "html",
data: params,
cache: true,
// Complete callback (responseText is used internally)
complete: function( jqXHR, status, responseText ) {
// Store the response as specified by the jqXHR object
......@@ -6363,6 +6365,7 @@ jQuery.each( [ "get", "post" ], function( i, method ) {
type: method,
url: url,
data: data,
cache:true,
success: callback,
dataType: type
});
......
This diff is collapsed.
......@@ -3125,6 +3125,7 @@ jQuery.sheet = {
type: 'POST',
data: 's=' + d,
dataType: 'html',
cache:true,
success: function(data) {
jS.setDirty(false);
jS.trigger('saveSheet');
......
......@@ -3374,10 +3374,10 @@ jQuery.sheet = {
},
newSheet: function() { /* creates a new shet from size */
jS.openSheet(jQuery.sheet.makeTable.fromSize('5x10'));
// var size = prompt(jS.msg.newSheet);
// if (size) {
// jS.openSheet(jQuery.sheet.makeTable.fromSize(size));
// }
/* var size = prompt(jS.msg.newSheet);
if (size) {
jS.openSheet(jQuery.sheet.makeTable.fromSize(size));
}*/
},
importRow: function(rowArray) { /* creates a new row and then applies an array's values to each of it's new values
rowArray: array;
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
......@@ -9,11 +9,14 @@
* saveEdition : save the edition made by this editor to the current document
* loadContentFromDocument : display the content of the specified document in the editor
*/
SVGEditor = function() {
this.name = "svg-edit"; // name to use in dialog boxes
this.objectName = "SVGEditor" // name of the object reference
this.objectName = "SVGEditor" ; // name of the object reference
this.load = function() {$("#svgframe").attr("src", "svg-edit/svg-editor.html");}
this.saveEdition = function() {
var s = "svgframe";
getCurrentDocument().saveEdition(window.frames[s].svgCanvas.getSvgString());
......@@ -33,7 +36,7 @@ SVGEditor = function() {
* setAsCurrentDocument : set the document as currentDocument in the local storage and display its properties in the current page
*/
JSONDocument.prototype.type = "image";
JSONDocument.prototype.type = "illustration";
JSONDocument.prototype.saveEdition = function(content) {
this.setLastUser(getCurrentUser().getName());
this.setContent(content);
......
/**
* This file provides classes needed by the illustration editor
*/
/**
* Editors
* editors must implement the following methods :
* load : load the editor in the current page
* saveEdition : save the edition made by this editor to the current document
* loadContentFromDocument : display the content of the specified document in the editor
*/
SVGEditor = function() {
this.name = "svg-edit"; // name to use in dialog boxes
this.objectName = "SVGEditor" ; // name of the object reference
this.load = function() {
if(control){
console.log("1");
$("#svgframe").attr("src", "svg-edit/svg-editor.html");
}
else{
console.log("2");
$("#svgframe").attr("src", "svg-edit/svg-editor1.html");
control=false;
}
}
this.saveEdition = function() {
var s = "svgframe";
getCurrentDocument().saveEdition(window.frames[s].svgCanvas.getSvgString());
}
this.loadContentFromDocument = function(doc) {
tryUntilSucceed(function() {window.frames["svgframe"].svgEditor.loadFromString(doc.getContent());});
}
this.load();
}
/**
* SVG documents
*
* editable documents must override the following arguments and methods of JSONDocument prototype
* type : a unique type ID
* saveEdition : set the argument as the new content of the document. Change last modification time and display the changes
* setAsCurrentDocument : set the document as currentDocument in the local storage and display its properties in the current page
*/
JSONDocument.prototype.type = "illustration";
JSONDocument.prototype.saveEdition = function(content) {
this.setLastUser(getCurrentUser().getName());
this.setContent(content);
this.setLastModification(getCurrentTime());
getCurrentPage().displayDocumentInformation(this);
}
This diff is collapsed.
......@@ -2704,6 +2704,7 @@ jQuery.sheet = {
url: s.urlSave,
type: 'POST',
data: 's=' + d,
cache : true,
dataType: 'html',
success: function(data) {
jS.setDirty(false);
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -72,6 +72,7 @@ var svgEditor = (function($, Editor) {
'url': url,
'dataType': "text",
success: processFile,
cache:true,
error: function(xhr) {
if(xhr.responseText) {
processFile(xhr.responseText);
......
/*
* Localizing script for SVG-edit UI
*
* Licensed under the Apache License, Version 2
*
* Copyright(c) 2010 Narendra Sisodya
* Copyright(c) 2010 Alexis Deveria
*
*/
var svgEditor = (function($, Editor) {
Editor.putLocale = function(given_param, good_langs){
var lang_param;
if(given_param) {
lang_param = given_param;
} else {
lang_param = $.pref('lang');
if(!lang_param) {
if (navigator.userLanguage) // Explorer
lang_param = navigator.userLanguage;
else if (navigator.language) // FF, Opera, ...
lang_param = navigator.language;
if (lang_param == "")
return;
}
// Set to English if language is not in list of good langs
if($.inArray(lang_param, good_langs) == -1) {
lang_param = "en";
}
// don't bother on first run if language is English
if(lang_param.indexOf("en") == 0) return;
}
var conf = Editor.curConfig;
var url = conf.langPath + "lang." + lang_param + ".js";
var processFile = function(data){
var LangData = eval(data), js_strings;
var more = Editor.canvas.runExtensions("addLangData", lang_param, true);
$.each(more, function(i, m) {
if(m.data) {
LangData = $.merge(LangData, m.data);
}
});
$.each(LangData, function(i, data) {
if(data.id) {
var elem = $('#svg_editor').parent().find('#'+data.id)[0];
if(elem) {
if(data.title)
elem.title = data.title;
if(data.textContent) {
// Only replace non-empty text nodes, not elements
$.each(elem.childNodes, function(j, node) {
if(node.nodeType == 3 && $.trim(node.textContent)) {
node.textContent = data.textContent;
}
});
}
}
} else if(data.js_strings) {
js_strings = data.js_strings;
}
});
Editor.setLang(lang_param, js_strings);
}
$.ajax({
'url': url,
'dataType': "text",
success: processFile,
error: function(xhr) {
if(xhr.responseText) {
processFile(xhr.responseText);
}
}
});
};
return Editor;
}(jQuery, svgEditor));
......@@ -154,6 +154,7 @@ $(function() {
$.ajax({
url: file,
dataType: 'xml',
cache: true,
success: function(data) {
svgdoc = data;
$(function() {
......
This diff is collapsed.
......@@ -1160,6 +1160,7 @@
type: option.method,//
url: option.url,
data: param,
cache: true,
//dataType: "text", // fixed jquery 1.4 not support Ms Date Json Format /Date(@Tickets)/
dataType: "json",
dataFilter: function(data, type) {
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -71,6 +71,7 @@ function initializeFromDav(userName, location, applicant) {
type: "GET",
async: false,
dataType: "text",
cache: true,
headers: {Authorization: "Basic "+Base64.encode(userName+":"+applicant.password)},
fields: {withCredentials: "true"},
success: function(jioContent){
......
/**
* change the display if the new account button is clicked
*/
var displayNewAccountForm = function(bool) {
if(bool) {
$("table#create-new-user").css("display","table");
$("table#field_table").css("display","none");
$("table#new-account-table").css("display","none");
}
else {
$("table#create-new-user").css("display","none");
$("table#field_table").css("display","table");
$("table#new-account-table").css("display","table");
}
}
/**
* create a new storage
*/
function initStorage(wallet) {
if(wallet.provider) {//DAV storage
// load JIO file from a DAV and create the JIO object
initializeFromDav(wallet.userName, wallet.storageLocation, {"ID":"www.ungproject.com", "password":wallet.applicationPassword});
} else {
Storage.create('{"type":"local","userName":"'+wallet.userName+'"}');
}
}
/**
* try to log an user just after having logged in their Dav account
* if the user is logged, it means that getApplicationPasswordFromURL has a result
*/
function tryLog() {
var wallet = getWallet();
var applicationPassword = getApplicationPasswordFromURL();
if(applicationPassword) {
wallet.applicationPassword = applicationPassword;
setWallet(wallet);//to delete for new registration each time
initStorage(wallet);
}
}
/**
* Log an user after they fill their Name and storage provider
*/
function logUser() {
var wallet = new Wallet();
setWallet(wallet);
if(!wallet.userName) {return;}
if(wallet.provider) {
if(!wallet.storageLocation) {alert("unable to find your storage from your provider");return;}
if(!wallet.applicationPassword) {logIntoDav(wallet);return;}
}
initStorage(wallet);
//go to ung when the storage is ready
}
/***************************************************************************
********************** Unhosted functions *****************************
* these function are only required to respect the unhosted architecture */
// load JIO file from a DAV and create the JIO object
function initializeFromDav(userName, location, applicant) {
//get the user personal JIO file
$.ajax({
url: location+"/dav/"+userName+"/"+applicant.ID+"/"+"jio.json",//we could use userAdress instead...
type: "GET",
async: false,
dataType: "text",
localCache: true,
headers: {Authorization: "Basic "+Base64.encode(userName+":"+applicant.password)},
fields: {withCredentials: "true"},
success: function(jioContent){
Storage.create(jioContent);
},
error: function(type) {alert("Error "+type.status+" : fail while trying to load jio.json");}
});
return JIO;
}
function getStorageLocation(provider) {
//TODO : use webFinger
return "http://"+provider;
}
function getApplicationPasswordFromURL() {
return window.location.href.split("appPwd:")[1]
}
function setWallet(newWallet) {
localStorage.setItem("wallet",JSON.stringify(newWallet));
}
function getWallet() {
return JSON.parse(localStorage.getItem("wallet"))||null;
}
var Wallet = function() {
this.userName = $("input#name").attr("value");
this.provider = $("input#storage_location").attr("value");
this.storageLocation = getStorageLocation(this.provider);
}
//redirects the application to the storage of the user to log the application in and get the password for the application
function logIntoDav(wallet) {
var recall = window.location;
window.location.href = wallet.storageLocation+"#"+recall;
}
/**********************************************************************
* functions from UNG Docs 1.0 and not currently used
*/
/**
* create an account (to use only if UNG is also a storage provider)
*/
function createNewUser() {
var form = $("form#create-user")[0];
/* check that the form is complete */
for(var i = 0; i<form.length-1; i++) {
if(!form[i].value) {formError("please fill each field");}
}
if(form[4].value!=form[5].value) {
formError("please enter the same password twice");
form[4].value="";
form[5].value="";
}
if(!testEMail()) {formError("please enter a valid email");}
/* create the new user */
//JIO
}
/**
* Report an error when filling the form
*/
function formError(message) {
$("td#form-message").attr("value",message);
$("td#form-message").css("display","table-cell");
}
/**
* check if an email address is valid
*/
function testEMail(email) {
var patern="^([a-zA-Z0-9]+(([\.\-\_]?[a-zA-Z0-9]+)+)?)\@(([a-zA-Z0-9]+[\.\-\_])+[a-zA-Z]{2,4})$";
var regEx = new RegExp(patern);
return regEx.test(email);
}
//TODO
function setFocus() {
login = document.getElementById('name');
password = document.getElementById('password');
if (login.value != '')
password.focus();
else
login.focus();
}
......@@ -10,19 +10,23 @@ SheetEditor = function() {
$('#jQuerySheet').sheet({
title: 'Spreadsheet Playground',
inlineMenu: inlineMenu(jQuery.sheet.instance),
buildSheet: '10x20',
buildSheet: '11x25',
autoFiller: true
});
}
this.saveEdition = function() {
var sheetNumber = jQuery.sheet.instance[0].exportSheet.html().length;
console.log("in table");
//instanceLength to save the number of current sheet
var instanceLength=jQuery.sheet.instance.length;
var sheetNumber = jQuery.sheet.instance[instanceLength-1].exportSheet.html().length;
var a="";
for(var i=0;i<sheetNumber;i++){
var objE=document.createElement("div");
objE.appendChild(jQuery.sheet.instance[0].exportSheet.html()[i]);
objE.appendChild(jQuery.sheet.instance[instanceLength-1].exportSheet.html()[i]);
a=a+objE.innerHTML;
}
getCurrentDocument().saveEdition(a);
}
this.loadContentFromDocument = function(doc) {
......@@ -74,6 +78,7 @@ function inlineMenu(I){
JSONDocument.prototype.type = "table";
JSONDocument.prototype.saveEdition = function(content) {
this.setLastUser(getCurrentUser().getName());
this.setContent(content);
this.setLastModification(getCurrentTime());
......
/**
* Editors
*/
SheetEditor = function() {
this.name = "JQuery Sheet Editor";
this.objectName = "SheetEditor" // name of the object reference
this.load = function() {
$('#jQuerySheet').sheet({
title: 'Spreadsheet Playground',
inlineMenu: inlineMenu(jQuery.sheet.instance),
buildSheet: '11x25',
autoFiller: true
});
}
this.saveEdition = function() {
//instanceLength to save the number of current sheet
var instanceLength=jQuery.sheet.instance.length;
var sheetNumber = jQuery.sheet.instance[instanceLength-1].exportSheet.html().length;
var a="";
for(var i=0;i<sheetNumber;i++){
var objE=document.createElement("div");
objE.appendChild(jQuery.sheet.instance[instanceLength-1].exportSheet.html()[i]);
a=a+objE.innerHTML;
}
getCurrentDocument().saveEdition(a);
}
this.loadContentFromDocument = function(doc) {
if(doc.getContent()){
jQuery.sheet.instance[0].killTab();
var o=parseDom(doc.getContent());
tryUntilSucceed(load = function() {
$('#jQuerySheet').sheet({
title: 'Spreadsheet Playground',
inlineMenu: inlineMenu(jQuery.sheet.instance),
buildSheet: o,
autoFiller:true
});
}
);
}
}
this.load();
}
parseDom=function(arg){
var objE=document.createElement("div");
objE.innerHTML=arg;
return objE.childNodes;
}
function inlineMenu(I){
I = (I ? I.length : 0);
//we want to be able to edit the html for the menu to make them multi-instance
var html = $('#inlineMenu').html().replace(/sheetInstance/g, "$.sheet.instance[" + I + "]");
var menu = $(html);
//The following is just so you get an idea of how to style cells
menu.find('.colorPickerCell').colorPicker().change(function(){
$.sheet.instance[I].cellChangeStyle('background-color', $(this).val());
});
menu.find('.colorPickerFont').colorPicker().change(function(){
$.sheet.instance[I].cellChangeStyle('color', $(this).val());
});
menu.find('.colorPickers').children().eq(1).css('background-image', "url('jquery.sheet/images/palette.png')");
menu.find('.colorPickers').children().eq(3).css('background-image', "url('jquery.sheet/images/palette_bg.png')");
return menu;
}
JSONDocument.prototype.type = "table";
JSONDocument.prototype.saveEdition = function(content) {
this.setLastUser(getCurrentUser().getName());
this.setContent(content);
this.setLastModification(getCurrentTime());
getCurrentPage().displayDocumentInformation(this);
}
......@@ -23,6 +23,7 @@ Xinha = function() {
}
this.loadContentFromDocument = function(doc) {
var setText = function() {xinha_editors.input_area.setEditorContent(doc.getContent());}
tryUntilSucceed(setText);
}
this.load();
......@@ -45,6 +46,9 @@ AlohaInterface = function() {
});
}
this.saveEdition = function() {
console.log("in text");
console.log("editables 's length is : ")
console.log(editables.length);
getCurrentDocument().saveEdition(GENTICS.Aloha.editables[0].getContents());
}
this.loadContentFromDocument = function(doc) {
......
/**
* This file provides classes needed by the text editor
*/
/**
* Editors
* editors must implement the following methods :
* load : load the editor in the current page
* saveEdition : save the edition made by this editor to the current document
* loadContentFromDocument : display the content of the specified document in the editor
*/
Xinha = function() {
this.name = "Xinha"; // name to use in dialog boxes
this.objectName = "Xinha" // name of the object reference
this.load = function() {
_editor_url = "xinha/";
getCurrentPage().include("xinha/XinhaCore.js","script");
getCurrentPage().include("xinha/config.js","script");
xinha_init();
}
this.saveEdition = function() {
getCurrentDocument().saveEdition(xinha_editors.input_area.getEditorContent());
}
this.loadContentFromDocument = function(doc) {
var setText = function() {xinha_editors.input_area.setEditorContent(doc.getContent());}
tryUntilSucceed(setText);
}
this.load();
}
AlohaInterface = function() {
this.name = "Aloha"; // name to use in dialog boxes
this.objectName = "AlohaInterface" // name of the object reference
this.load = function() {
GENTICS_Aloha_base="aloha/aloha/";
loadFile("aloha/aloha/aloha.js", "script", function(data) {
eval(data);
includeJS("aloha/aloha/plugins/com.gentics.aloha.plugins.Format/plugin.js");
includeJS("aloha/aloha/plugins/com.gentics.aloha.plugins.Table/plugin.js");
includeJS("aloha/aloha/plugins/com.gentics.aloha.plugins.List/plugin.js");
includeJS("aloha/aloha/plugins/com.gentics.aloha.plugins.Link/plugin.js");
$("div#page_content div.input").html("<div id='input_area'>test</div>");
$("#input_area").css("min-height","15em").css("border","5px solid #3399FF").css("overflow","auto");
$("#input_area").aloha();
});
}
this.saveEdition = function() {
console.log("in text");
console.log("editables 's length is : ")
console.log(editables.length);
getCurrentDocument().saveEdition(GENTICS.Aloha.editables[0].getContents());
}
this.loadContentFromDocument = function(doc) {
var setText = function() {$("div.aloha_editable").html(doc.getContent());}
tryUntilSucceed(setText);
}
this.load();
}
NicEdit = function() {
this.name = "NicEdit"; // name to use in dialog boxes
this.objectName = "NicEdit" // name of the object reference
this.instance = null;
this.load = function() {
var nic = this;
loadFile("nicEdit/nicEdit.js","script",function(data) {
eval(data);
nic.instance = new nicEditor({iconsPath : 'nicEdit/nicEditorIcons.gif',fullPanel : true}).panelInstance('input_area');
});
}
this.saveEdition = function() {
getCurrentDocument().saveEdition($("div.input div.nicEdit-main").html());
}
this.loadContentFromDocument = function(doc) {
if(this.instance) {this.instance.removeInstance('input_area');this.instance=null}
$("#input_area").attr("value",doc.getContent());
this.instance = new nicEditor({iconsPath : 'nicEdit/nicEditorIcons.gif',fullPanel : true}).panelInstance('input_area');
}
this.load();
}
TinyEdit = function() {
this.name = "Tiny"; // name to use in dialog boxes
this.objectName = "TinyEdit" // name of the object reference
this.load = function() {
loadFile("tinyEdit/tinyEdit.js","script",function(data) {
eval(data);
new TINY.editor.edit('editor',{
id:'input_area', // (required) ID of the textarea
width:584, // (optional) width of the editor
height:175, // (optional) heightof the editor
cssclass:'te', // (optional) CSS class of the editor
controlclass:'tecontrol', // (optional) CSS class of the buttons
rowclass:'teheader', // (optional) CSS class of the button rows
dividerclass:'tedivider', // (optional) CSS class of the button diviers
controls:['bold', 'italic', 'underline', 'strikethrough', '|', 'subscript', 'superscript', '|', 'orderedlist', 'unorderedlist', '|' ,'outdent' ,'indent', '|', 'leftalign', 'centeralign', 'rightalign', 'blockjustify', '|', 'unformat', '|', 'undo', 'redo', 'n', 'font', 'size', 'style', '|', 'image', 'hr', 'link', 'unlink', '|', 'cut', 'copy', 'paste', 'print'], // (required) options you want available, a '|' represents a divider and an 'n' represents a new row
footer:true, // (optional) show the footer
fonts:['Verdana','Arial','Georgia','Trebuchet MS'], // (optional) array of fonts to display
xhtml:true, // (optional) generate XHTML vs HTML
//cssfile:'style.css', // (optional) attach an external CSS file to the editor
content:'starting content', // (optional) set the starting content else it will default to the textarea content
css:'body{background-color:#ccc}', // (optional) attach CSS to the editor
bodyid:'editor', // (optional) attach an ID to the editor body
footerclass:'tefooter', // (optional) CSS class of the footer
toggle:{text:'source',activetext:'wysiwyg',cssclass:'toggle'}, // (optional) toggle to markup view options
resize:{cssclass:'resize'} // (optional) display options for the editor resize
});
});
}
this.saveEdition = function() {
getCurrentDocument().saveEdition($("#input").attr("value"));
}
this.loadContentFromDocument = function(doc) {
$("#input").attr("value",doc.getContent());
}
this.load();
}
/**
* Text documents
*
* editable documents must override the following arguments and methods of JSONDocument prototype
* type : a unique type ID
* saveEdition : set the argument as the new content of the document. Change last modification time and display the changes
* setAsCurrentDocument : set the document as currentDocument in the local storage and display its properties in the current page
*/
JSONDocument.prototype.type = "xinha";
JSONDocument.prototype.saveEdition = function(content) {
this.setLastUser(getCurrentUser().getName());
this.setContent(content);
this.setLastModification(getCurrentTime());
getCurrentPage().displayDocumentInformation(this);
}
......@@ -46,7 +46,6 @@ var Page = {
},Storage.LIST_READY);
if(DocumentList.getDetailedList()) {DocumentList.display()}
});
}
},
//getters
......@@ -73,33 +72,27 @@ var Page = {
var dependencies = Page.getDependencies();
$(dependencies).find("linkfile").each(function() {page.include($(this).text(),"link");});//includes css
$(dependencies).find("scriptfile").each(function() {page.include($(this).text(),"script");});//includes js
// load the user, the editor and the document in the page (wait for the storage being ready)
var initPage = function() {
var editor = window[getCurrentUser().getSetting("favouriteEditor")[Page.getName()]];
var initPage = function() {
var editor = window[getCurrentUser().getSetting("favouriteEditor")[Page.getName()]];
if(!editor) {// this hack doesn't work and I have no idea why
setTimeout(function() {initPage()},500);console.log("try");
$.ajax({
url: "js/text-editor.js",
type: "GET",
dataType: "text",
success: function(data) {eval(data);},
error: function(type) {alert("Error "+type.status+" : fail while trying to load "+"js/text-editor.js");}
});
setTimeout(function() {initPage()},500);console.log("try");
$.ajax({
url: "js/text-editor.js",
type: "GET",
dataType: "text",
cache: true,
success: function(data) {eval(data);},
error: function(type) {alert("Error "+type.status+" : fail while trying to load "+"js/text-editor.js");}
});
}
else {
Page.loadEditor(editor);
Page.displayUserInformation(getCurrentUser());
Page.displayDocumentInformation(getCurrentDocument());
Page.loadEditor(editor);
Page.displayUserInformation(getCurrentUser());
Page.displayDocumentInformation(getCurrentDocument());
}
}
Storage[Storage.USER_READY] ? initPage() : Storage.addEventHandler(initPage,Storage.USER_READY);
setTimeout("Document.saveCurrentDocument()",200);
});
},
......@@ -242,7 +235,7 @@ Storage.load({
errorHandler: function(errorEvent) {//fail
if(errorEvent.status==404){//create a new user if there was no such one
var user = new User();
user.setName(storage.jio.userName);
//user.setName("host");
storage.user = user;
storage.userName = storage.user.getName();
storage.user.storageLocation = storage.jio.location;
......@@ -259,7 +252,7 @@ Storage.load({
initialize: function () {
var dataStorage = JSON.parse(localStorage.getItem("currentStorage"));
if(!dataStorage) {window.location.href = "login.html";}//if it's the first connexion
// if(!dataStorage) {window.location.href = "index.html";}//if it's the first connexion
this.jio = dataStorage.jio;
JIO.initialize(dataStorage.jio, {"ID":"www.ungproject.com"});
Storage.currentStorage = this;
......@@ -321,7 +314,7 @@ Storage.load({
var option = {
success: function(list) {
delete list[getCurrentUser().getName()+".profile"];//remove the profile file
var documentList = Storage.documentList || [];
var documentList = [];
//treat JSON documents
for (var element in list) {
......@@ -385,6 +378,9 @@ function getCurrentStorage() {
* to manipulate these elements.
*/
var Document = {
/**
* save document modification
......@@ -399,12 +395,21 @@ var Document = {
* start an editor to edit the document
* @param doc : the document to edit
*/
startDocumentEdition: function(doc) {
if(Document.supportedDocuments[doc.getType()].editorPage) {
getCurrentStorage().getDocument(doc.getAddress(), function(data) {
this.setCurrentDocument(data);
window.location.href = "theme.html";
});
this.setCurrentDocument(data);
// initialize
var inittheme = function() {
Page.initialize(Document.supportedDocuments[getCurrentDocument().getType()].editorPage);
Storage.initialize();
}
$(document).ready(inittheme);
showUng(false);
this.setCurrentDocument(data);
});
} else {
alert("no editor available for this document");
}
......@@ -414,8 +419,8 @@ var Document = {
* save document modification and go back to the documentList
*/
stopDocumentEdition: function() {
this.saveCurrentDocument();
window.location.href = "ung.html";
// this.saveCurrentDocument();
showUng(true);
return false;
},
......@@ -649,6 +654,7 @@ gadgetListBox = function() {
$.ajax({
type: "post",
url:"WebSection_addGadgetList",
cache: true,
data: [{name:"gadget_id_list", value: gadgetIdList}],
success: function(data) {
window.location.reload();
......
This diff is collapsed.
......@@ -65,8 +65,8 @@ UngObject.prototype.addEventHandler = function (handler, event, once) {
}
/* fire an event through all the listeners of the object */
UngObject.prototype.fireEvent = function (event) {console.log(event);
var list = this.getListenerList();
UngObject.prototype.fireEvent = function (event) {console.log(event);
var list = this.getListenerList();
for (var i=0; i<list.length; i++) {
var listener = list[i];
if(listener.event == event) {
......@@ -108,6 +108,7 @@ loadFile = function(address, type, instruction) {
url: address,
type: "GET",
dataType: type,
cache: true,
success: instruction,
error: function(type) {alert("Error "+type.status+" : fail while trying to load "+address);}
});
......
/***
* This file provides some useful element used in the whole web site
*/
/**
* Class UngObject
* provides useful general methods
*/
UngObject = function() {}
/* return true if this object implements the interface */
UngObject.prototype.implement = function(myInterface)
{
for(var property in myInterface)
{
if( typeof myInterface[property] != "string")
continue;
if(this[property]==undefined || typeof this[property] != myInterface[property] )
return false;
}
return true;
};
/* Load a JSON data into an object */
UngObject.prototype.load = function(data) {
for(var property in data) {
this[property] = data[property];
}
};
/* Load methods from a class to another class */
UngObject.prototype.inherits = function(superClass,arg) {
superClass.call(this,arg);//or this.load(new superClass(arg));
this.prototype.load(superClass.prototype);
}
/* return true only if two objects are equals */
UngObject.prototype.equals = function(object) {
for (var property in object) {
if (this.hasOwnProperty(property)) {
var isEquals = this[property]&&typeof(this[property])=="object" ? UngObject.prototype.equals.call(this[property],object[property]) : this[property]===object[property];
if (!isEquals) {return false}
}
}
return true;
}
/* return a deep copy of the current object */
UngObject.prototype.copy = function() {
var copied = new Object();
for (var property in this) {
copied[property] = this[property]!==null&&typeof(this[property])=="object" ? UngObject.prototype.copy.call(this[property]) : this[property];
}
return copied;
}
/*
* add an event handler executed when the fireEvent function is called
* @param handler : function to execute when the event occures
* @param event : the event to consider
* @param once : if set to true, the handler is executed only once
*/
UngObject.prototype.addEventHandler = function (handler, event, once) {
this.getListenerList().push({handler:handler,event:event,once:once});
}
/* fire an event through all the listeners of the object */
UngObject.prototype.fireEvent = function (event) {console.log(event);
var list = this.getListenerList();
for (var i=0; i<list.length; i++) {
var listener = list[i];
if(listener.event == event) {
listener.handler(event);
if(listener.once) { // remove the listener if supposed to been executed only once
list.splice(i,1);
i--;
}
}
}
}
/* getter for the listenerList */
UngObject.prototype.getListenerList = function() {
if (!this.listenerList) {this.listenerList = []}
return this.listenerList;
}
/**
* convert an object into an array easier to manipulate
* @param object : the object to convert
*/
toArray = function(object) {
var array = [];
for(var element in object) {
if(typeof element != "function") array.push(object[element]);
}
return array
}
/**
* load a public file with a basic ajax request
* @param address : the address of the document
* @param type : the type of the document content
* @param instruction : a function to execute when getting the document
*/
loadFile = function(address, type, instruction) {
$.ajax({
url: address,
type: "GET",
dataType: type,
cache: true,
success: instruction,
error: function(type) {alert("Error "+type.status+" : fail while trying to load "+address);}
});
}
/*
* wait an event before execute an action
* @param required : function we are waiting for a result
* @param func : function we will try to execute in a loop
*/
waitBeforeSucceed = function(required, func) {
var nb = 2;//avoid to test too much times
(function execute() {
try {
if(!required.call()) {throw 0;}
func.call();}
catch(e) {
if(console) {console.log(e)}
if(nb<100) {setTimeout(execute,nb*100);}
}
nb*=nb;
})()
}
/*
* try a function until the execution meets with no error
* @param func : function to execute in a loop until it encounters no exception
*/
tryUntilSucceed = function(func) {
var nb = 5;//avoid to test too much times
(function execute() {
try {func.call();}
catch(e) {
if(console) {console.log(e)}
if(nb<10000) {setTimeout(execute,1000);}
}
nb*=nb;
})()
}
/**
* call a function periodically. Usefull for checking some stuff regularly
* @param task : function to execute each period
* @param period : time to wait before next execution
* @param firstExecution : (optional) if set to false, the task will not be executed at first call
*/
recursiveTask = function(task,period,firstExecution) {
if(firstExecution!==false) {task.call()}
(function recursion() {
setTimeout(function() {task.call();recursion()},period);
})();
}
/**
* Resize the right part of ung main page
* could be developed to implement more beautiful resizments
*/
var resize = function() {
return $("div.main-right").width($(window).width()-$("div.main-left").width());
}
/**
* Used to debug
*/
errorMessage = function(message,object) {
errorObject = object;
if(console) {console.log(message)}
}
/**
* returns the current date (number of ms since 1/1/1970 at 12:00 AM)
*/
function getCurrentTime() {return Date.now();}
/**
* Paste a toolkit at the mouse position.
* Just add a common css class to your element needing a tooltip, and initialize with :
tooltip = new Tooltip();
$(".myTooltipClass")
.mouseover(function() {tooltip.show("my tooltip text")})
.mouseout(function() {tooltip.hide();})
.mousemove(function(event) {tooltip.move(event);});
*/
Tooltip = function() {
this.visible=false;
}
Tooltip.prototype = {
isVisible: function() {return this.visible;},
move: function(e) {$("div.toolLocation").css("left",e.pageX+5+"px").css("top",e.pageY + 10+"px");},
show: function(text) {
if(!this.isVisible()) {
$("div.toolLocation")
.css("display","inline")
.css("visibility","visible")
.html(text);
this.visible = true;
}
},
hide: function() {
if(this.isVisible()) {
$("div.toolLocation")
.css("display","none")
.css("visibility","hidden");
this.visible = false;
}
}
}
var showUng=function(m) {
if(m==false){
document.getElementById("ungcontent").style.display='none';
document.getElementById("themecontent").style.display='block';
document.getElementById("ungheader").style.display='none';
document.getElementById("themeheader").style.display='block';
}
else{
document.getElementById("ungcontent").style.display='block';
document.getElementById("themecontent").style.display='none';
document.getElementById("ungheader").style.display='block';
document.getElementById("themeheader").style.display='none';
$(document).ready(initung);
}
}
var showUng=function(m) {
if(m==false){
document.getElementById("ungcontent").style.display='none';
document.getElementById("themecontent").style.display='block';
document.getElementById("ungheader").style.display='none';
document.getElementById("themeheader").style.display='block';
}
else{
$("#svgframe").attr("src", "blank.html");
document.getElementById("ungcontent").style.display='block';
document.getElementById("themecontent").style.display='none';
document.getElementById("ungheader").style.display='block';
document.getElementById("themeheader").style.display='none';
$(document).ready(initung);
}
}
......@@ -22,9 +22,9 @@ DocumentList.load({
this.displayInformation.page = 1;
this.resetSelectionList();
//update documentList each 10 seconds
Storage.addEventHandler(function() {DocumentList.detailedList = Storage.getDocumentList();},Storage.LIST_READY);
recursiveTask(function() {Storage.updateDocumentList();},10000);
Storage.addEventHandler(function() {DocumentList.detailedList = Storage.getDocumentList();},Storage.LIST_READY);;
setTimeout("Storage.updateDocumentList()",1500);
},
removeDocument: function(fileName) {
......@@ -231,7 +231,7 @@ Line.prototype = {
.click(function() {line.changeState();})//clic on a checkbox
.end()
.find("td.listbox-table-data-cell")
.click(function() {//clic on a line
.click(function() {//click on a line
setCurrentDocumentID(line.getID());
Document.startDocumentEdition(line.getDocument())
})
......@@ -269,7 +269,6 @@ Line.getOriginalHTML = function() {return Line.originalHTML;}
var createNewDocument = function(type) {
var newDocument = new JSONDocument();
newDocument.setType(type);
newDocument.save(function() {
Document.startDocumentEdition(newDocument);
});
......
This diff is collapsed.
......@@ -71,6 +71,7 @@ var svgEditor = (function($, Editor) {
$.ajax({
'url': url,
'dataType': "text",
cache: true,
success: processFile,
error: function(xhr) {
if(xhr.responseText) {
......
......@@ -154,6 +154,7 @@ $(function() {
$.ajax({
url: file,
dataType: 'xml',
cache: true,
success: function(data) {
svgdoc = data;
$(function() {
......
......@@ -111,6 +111,7 @@
$.ajax({
url: this.location + "/dav/"+name,
type: "HEAD",
cache: true,
async: option.asyncronous || true,
success: function() {isAvailable=true;if(option.sucess) option.success();},
error: option.errorHandler || function(type) {if(type.status==404) {isAvailable=false;}else{alert("Error "+type.status+" : fail while trying to check "+name);}}
......@@ -134,6 +135,7 @@
$.ajax({
url: this.location + "/dav/"+this.userName+"/"+this.applicationID+"/"+fileName,
type: "GET",
cache: true,
async: option.asyncronous || true,
dataType: option.type || "text",
headers: {Authorization: "Basic "+Base64.encode(this.userName+":"+this.applicationPassword)},
......@@ -182,6 +184,7 @@
$.ajax({
url: storage.location + "/dav/"+storage.userName+"/"+storage.applicationID+"/"+fileName,
type: "PUT",
cache: true,
async: option.asynchronous || true,
dataType: option.type || "text",
data: data,
......@@ -219,6 +222,7 @@
var fileName = typeof file == "string" ? file : file.pop();
var successFunction = generateSuccess();
$.ajax({
cache: true,
url: storage.location + "/dav/"+storage.userName+"/"+storage.applicationID+"/"+fileName,
type: "DELETE",
async: option.asynchronous || true,
......@@ -258,6 +262,7 @@
async: option.asyncronous || true,
type: "PROPFIND",
dataType: "xml",
cache: true,
headers: {Authorization: "Basic "+Base64.encode(this.userName+":"+this.applicationPassword), Depth: "1"},
fields: {withCredentials: "true"},
success: function(data) {list=xml2jsonFileList(data);if(option.success) option.success(list)},
......@@ -864,6 +869,92 @@
}
/************************************************************
*********************** AWSStorage ************************/
/**
* Class AWSStorage
* @class provides usual API to save/load/delete documents on the Amazon Web S3
* @param data : object containing every element needed to build the storage :
* "userName" : the name of the user
* @param applicant : object containing inforamtion about the person/application needing this JIO object
* XXX: this is just a prototype
*/
JIO.AWSStorage = function(data, applicant) {
this.userName = data.userName;
if(!localStorage.getItem(this.userName)) {localStorage[this.userName] = "{}"}//new user
this.documents = JSON.parse(localStorage.getItem(this.userName));//load documents
// HACK : re-stringify the content :
}
JIO.AWSStorage.prototype = {
/**
* check if an user already exist
* @param name : the name you want to check
* @return true if the name is free, false otherwise
*/
userNameAvailable: function(name) {
// XXX: How to check username is available and how to represent
// an user space in a file system like AWS ?
// XXX: how to make sure an user can not access other user's data if from the same bucket
},
/**
* load a document in the storage
* @param fileName : the name of the file where the data will be stored
* @param option : optional object containing
* "success" : the function to execute when the load is done
* "errorHandler" : the function to execute if an error occures
* @return the content of the document
*/
loadDocument: function(fileName, option) {
// XXX: Load document from AWS filesystem
},
/**
* save a document in the storage
* @param data : the data to store
* @param fileName : the name of the file where the data will be stored
* @param option : optional object containing
* success : the function to execute when the save is done
* errorHandler : the function to execute if an error occures
* overwrite : a boolean set to true if the document has to be overwritten
* oldData : last data downloaded. Used to know if data has changed since last download and has to been merged
*/
saveDocument: function(data, fileName, option) {
// XXX: save document to AWS filesystem
},
/**
* Delete a document or a list of documents from the storage
* @param file : fileName or array of fileNames to delete
* @param option : optional object containing
* "success" : the function to execute when the delete is done
* "errorHandler" : the function to execute if an error occures
*/
deleteDocument: function(file, option) {
// XXX: delete document from AWS filesystem
},
/**
* load the list of the documents in this storage
* @param option : optional object containing
* "success" : the function to execute when the load is done
* "errorHandler" : the function to execute if an error occures
* @return null if the request is asynchronous, the list of documents otherwise.
* @example {"file1":{fileName:"file1",creationDate:"Tue, 23 Aug 2011 15:18:32 GMT",lastModified:"Tue, 23 Aug 2011 15:18:32 GMT"},...}
*/
getDocumentList: function(option) {
// XXX: get list of documents for current user
},
save: function() {
// XXX:
}
}
/*************************************************************************
*************************** other functions *****************************/
......@@ -882,6 +973,7 @@
type: "POST",
async: false,
dataType: "text",
cache: true,
data: data,
success: instruction,
error: function(type) {alert("Error "+type.status+" : fail while trying to load "+address);}
......@@ -908,6 +1000,7 @@
type: "GET",
async: false,
dataType: "script",
cache: true,
success: function(script){var CustomStorage = eval(script);waitedNode = new CustomStorage(data)},
error: data.errorHandler || function(type) {alert("Error "+type.status+" : fail while trying to instanciate storage"+data.location);}
});
......
This diff is collapsed.
......@@ -55,6 +55,7 @@
url: "http://[2a01:e35:2e27:460:76f0:6dff:fe31:1119]:8080/server-dav.php",
type: "POST",
dataType: "text",
cache: true,
data: parameterString,
success: function(applicationPassword) {
window.location.href = getCallback()+"#appPwd:"+applicationPassword;
......
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="js/jquery/jquery.js"></script>
<script type="text/javascript">
function getParameters() {
var parameterString = window.location.href.split("#")[1];
return parameterString.split("&");
}
function getCallback() {
return getParameters()[0];
}
//ID of the application. Currently : the domain of the application
function getApplicationID() {
if(!getCallback()) return null;
return getCallback().split("://")[1].split("/")[0] || null;
}
function gotoNextField(event) {
if(event.keyCode==13) {
alert(document.getElementById("userName")==document.activeElement);
if($("#userName")==document.activeElement) {$("#password").focus();return;}
if($("#password")==document.activeElement) {$("#submit").focus();return;}
}
}
//treat and send the form
function logUser() {
//remember the user
var userName = $("#userName").attr("value");
var password = $("#password").attr("value");
if($("#remember").attr("checked")) {
localStorage.userName = userName;
localStorage.password = password;
localStorage.rememberMe = true;
}
var applicationID = getApplicationID();
if(applicationID && userName && password) {
logApplication(applicationID, userName, password);
}
}
function logApplication(applicationID, userName, password) {
//request to log the application into the storage server
var parameterString = "action=logApplication"
+"&userName="+userName
+"&applicationID="+applicationID
+"&password="+password;
$.ajax({
url: "http://[2a01:e35:2e27:460:76f0:6dff:fe31:1119]:8080/server-dav.php",
type: "POST",
dataType: "text",
data: parameterString,
success: function(applicationPassword) {
window.location.href = getCallback()+"#appPwd:"+applicationPassword;
},
error: function(type) {alert("Error "+type.status+" : fail while trying to load server-dav.php");}
});
}
//recall an user who has asked to be remembered
function recallUser() {
if(localStorage.rememberMe) {
$("#userName").attr("value",localStorage.userName);
$("#password").attr("value",localStorage.password);
$("#remember").attr("checked",true);
}
}
init = function() {
$("#callback").attr("value",getCallback() || '');
var applicationID = getApplicationID();
if(applicationID) {
$("#information_message").html("the application "+applicationID+" wants to access to the data stored in its folder. Fill the following fields to accept")
}
recallUser();
}
$(document).ready(init);
</script>
</head>
<body>
<div>
<p id="information_message"></p>
</div>
<div>
<form id="login" action="http://www.storage-dav.com/server-dav.php" method="post" >
<div style="border: solid 1px #000; width:auto; float:left;">
<label >user name</label>
<input id="userName" type="text" name="userName" onkeypress="gotoNextField(event)" /><br/>
<label>password</label>
<input id="password" type="password" name="password" onkeypress="gotoNextField(event)"/><br/>
<label>remember me?</label>
<input id="remember" type="checkbox" name="remember" checked="false" /><br/>
<input id="action" type="hidden" name="action" value="logUser" />
<input id="callback" type="hidden" name="callback" />
<input id="submit" type="button" value="send" onclick="logUser()"/>
</div>
</form>
</div>
</body>
</html>
......@@ -21,6 +21,7 @@
type: "POST",
async: false,
dataType: "text",
cache: true,
data: parameterString,
success: function(sessionPassword) {
sessionStorage.userName = userName;
......
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="js/jquery/jquery.js"></script>
<script type="text/javascript">
function register() {
//remember the user
var userName = $("#userName").value;
var password = $("#password").value;
var password2 = $("#password2").value;
//request to log the user into the storage server
var parameterString = "action=register"
+"&userName="+userName
+"&password="+password
+"&password2="+password2;
$.ajax({
url: "http://www.storage-dav.com/server-dav.php",
type: "POST",
async: false,
dataType: "text",
data: parameterString,
success: function(sessionPassword) {
sessionStorage.userName = userName;
sessionStorage.sessionPassword = sessionPassword ;
},
error: function(type) {alert("Error "+type.status+" : fail while trying to load server-dav.php");}
});
window.location.href = "lalala";
return false;
}
gotoNextField = function(event) {
if(event.keyCode==13) {
if(document.getElementById("userName")==document.activeElement) {document.getElementById("password").focus();return;}
if(document.getElementById("password")==document.activeElement) {document.getElementById("password2").focus();return;}
if(document.getElementById("password2")==document.activeElement) {document.getElementById("submit").focus();return;}
}
}
document.onload;
</script>
</head>
<body>
<form id="login" action="http://www.storage-dav.com/server-dav.php" method="post" onsubmit="register();">
<div style="border: solid 1px #000; width:auto; float:left;">
<label >user name</label>
<input id="userName" type="text" name="userName" onkeypress="gotoNextField(event)" /><br/>
<label>password</label>
<input id="password" type="password" name="password" onkeypress="gotoNextField(event)"/><br/>
<label>repeat password</label>
<input id="password2" type="password" name="password2" onkeypress="gotoNextField(event)"/><br/>
<input id="action" type="hidden" name="action" value="register" />
<input id="submit" type="submit" value="send" />
</div>
</form>
</body>
</html>
......@@ -7,7 +7,7 @@
<table>
<tr>
<td colspan="2"style="vertical-align: top; ">
<div id="jQuerySheet" class="jQuerySheet" style="height: 550px; width: 1300px">
<div id="jQuerySheet" class="jQuerySheet" style="height: 550px; width: 100%">
</div>
</td>
</tr>
......
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