This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository scmwebeditor. See http://git.nuiton.org/scmwebeditor.git commit 5cb44e48191351cd22d5d1ca52ee5ef88f3d64a2 Author: Hugo PIGEON <hpigeon@codelutin.com> Date: Mon Jun 1 11:04:02 2015 +0200 Add an automatic save of the edited file every 5 minutes --- .../i18n/scmwebeditor-ui-web_en_GB.properties | 2 + .../i18n/scmwebeditor-ui-web_fr_FR.properties | 2 + .../src/main/resources/scmwebeditor.properties | 2 +- .../webapp/WEB-INF/content/modificationViewer.jsp | 52 +++++++++++++++++++--- swe-ui-web/src/main/webapp/css/main.css | 11 ++++- swe-ui-web/src/main/webapp/js/editor.js | 27 +++++++++-- 6 files changed, 83 insertions(+), 13 deletions(-) diff --git a/swe-ui-web/src/main/resources/i18n/scmwebeditor-ui-web_en_GB.properties b/swe-ui-web/src/main/resources/i18n/scmwebeditor-ui-web_en_GB.properties index 704d9a5..384ebf8 100644 --- a/swe-ui-web/src/main/resources/i18n/scmwebeditor-ui-web_en_GB.properties +++ b/swe-ui-web/src/main/resources/i18n/scmwebeditor-ui-web_en_GB.properties @@ -34,6 +34,7 @@ scm.info.rstWebsite=RST documentation website scm.language=Language scm.lastChangeSave=Last change save scm.logAs=You are log as \: +scm.loginAutoSaveFile=Login for the automatic save scm.loginButton=Login scm.logoutWait=Logout... scm.modificationViewer.betterUseJavascript=For a better use of SCMWebEditor please activate JavaScript. @@ -44,6 +45,7 @@ scm.modificationViewer.previewPosition=Preview's position\: scm.modificationViewer.previewPosition.below=Below scm.modificationViewer.previewPosition.none=No preview scm.modificationViewer.previewPosition.side=On the side +scm.modificationViewer.save=Save scm.moveFile=Move a file scm.moveFileSuccess=File moved successfully scm.moveFileTitle=Move a file on the repository diff --git a/swe-ui-web/src/main/resources/i18n/scmwebeditor-ui-web_fr_FR.properties b/swe-ui-web/src/main/resources/i18n/scmwebeditor-ui-web_fr_FR.properties index 469e56d..59bf203 100644 --- a/swe-ui-web/src/main/resources/i18n/scmwebeditor-ui-web_fr_FR.properties +++ b/swe-ui-web/src/main/resources/i18n/scmwebeditor-ui-web_fr_FR.properties @@ -34,6 +34,7 @@ scm.info.rstWebsite=site de la documentation RST scm.language=Langage scm.lastChangeSave=Dernière sauvegarde effectuée scm.logAs=Connecté en tant que \: +scm.loginAutoSaveFile=Connexion pour la sauvegarde automatique scm.loginButton=Connexion scm.logoutWait=Déconnexion... scm.modificationViewer.betterUseJavascript=Activer Javascript pour accéder à toutes les fonctionnalités. @@ -44,6 +45,7 @@ scm.modificationViewer.previewPosition=Position de l'aperçu \: scm.modificationViewer.previewPosition.below=En dessous scm.modificationViewer.previewPosition.none=Pas d'aperçu scm.modificationViewer.previewPosition.side=Sur le côté +scm.modificationViewer.save=Enregistrer scm.moveFile=Déplacer un fichier scm.moveFileSuccess=Fichier déplacé avec succès scm.moveFileTitle=Déplacer un fichier au sein du dépôt diff --git a/swe-scm-api/src/main/resources/scmwebeditor.properties b/swe-ui-web/src/main/resources/scmwebeditor.properties similarity index 90% rename from swe-scm-api/src/main/resources/scmwebeditor.properties rename to swe-ui-web/src/main/resources/scmwebeditor.properties index ac2ef8b..0deeb80 100644 --- a/swe-scm-api/src/main/resources/scmwebeditor.properties +++ b/swe-ui-web/src/main/resources/scmwebeditor.properties @@ -2,7 +2,7 @@ # #%L # ScmWebEditor # %% -# Copyright (C) 2009 - 2011 CodeLutin +# Copyright (C) 2009 - 2015 CodeLutin # %% # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as diff --git a/swe-ui-web/src/main/webapp/WEB-INF/content/modificationViewer.jsp b/swe-ui-web/src/main/webapp/WEB-INF/content/modificationViewer.jsp index 65c39ef..68b17f5 100644 --- a/swe-ui-web/src/main/webapp/WEB-INF/content/modificationViewer.jsp +++ b/swe-ui-web/src/main/webapp/WEB-INF/content/modificationViewer.jsp @@ -363,7 +363,7 @@ <p> - <s:text name="scm.FileInEditor"/><s:property value="address"/> + <s:text name="scm.FileInEditor"/> <s:property value="address"/> <s:text name="scm.atRevision"/> <span id="numrevisionDiv"><s:property value="numRevision"/></span> @@ -479,7 +479,7 @@ <s:if test="username==null || pw==null"> <label for="username"><s:text name="scm.username"/> :</label> <input type="text" name="username" id="username"/><br/> <label for="pw"><s:text name="scm.password"/> :</label> <input type="password" id="pw" name="pw"/><br/> - <input type="checkbox" name="saveCookie" value="true"><s:text name="scm.stayLogin"/> + <input type="checkbox" name="saveCookie" value="true" id="saveCookie"><s:text name="scm.stayLogin"/> </s:if> <s:else> @@ -554,12 +554,50 @@ </div> -<div id="popinBackground"></div> +<!-- popin to login for auto save --> +<div class="popin" id="autoSavePopin"> + <span class="closePopin" onclick="closePopin('autoSavePopin')"> + X + </span> + + <h1><s:text name="scm.loginAutoSaveFile"/></h1> + + <form id="autoSaveLoginForm"> + + <input type="hidden" name="commitMessage" value="auto save"/> + <input type="hidden" name="newText" id="newTextIdAutoSave" value=""/> + <s:hidden key="scmType" label=''/> + <s:hidden key="address" label=''/> + <s:hidden key="origText" label=''/> + <s:hidden key="format" label=''/> + + <label for="username"><s:text name="scm.username"/> :</label> <input type="text" name="username" id="usernameAutoSave"/><br/> + <label for="pw"><s:text name="scm.password"/> :</label> <input type="password" id="pwAutoSave" name="pw"/><br/> + <input type="checkbox" name="saveCookie" value="true" id="saveCookieAutoSave"><s:text name="scm.stayLogin"/> + + <s:set id="modificationViewer.save"> + <s:text name="scm.modificationViewer.save"/> + </s:set> + + <s:url id="ajaxAutoSave" value="save.action"/> -<script type="text/javascript"> - closePopin("commitPopin"); - closePopin("openFilePopin"); -</script> + </form> + + <sj:a + id="ajaxAutoSaveButton" + formIds="autoSaveLoginForm" + href="%{ajaxAutoSave}" + targets="autoSaveMessage" + > + <s:submit onclick="loadChange(); closePopin('autoSavePopin');" value="%{modificationViewer.save}"/> + </sj:a> + + <input type="hidden" id="autoSaveMessage" value=""/> + +</div> + + +<div id="popinBackground"></div> </body> </html> diff --git a/swe-ui-web/src/main/webapp/css/main.css b/swe-ui-web/src/main/webapp/css/main.css index 8898d09..3497678 100644 --- a/swe-ui-web/src/main/webapp/css/main.css +++ b/swe-ui-web/src/main/webapp/css/main.css @@ -401,6 +401,7 @@ ul.flags li { border: 1px solid black; z-index: 11; padding: 10px; + display: none; } #commitPopin { @@ -416,6 +417,13 @@ ul.flags li { overflow: scroll; } +#autoSavePopin { + height: 75%; + top: 12%; + left: 25%; + overflow: scroll; +} + #popinBackground { position: fixed; width: 100%; @@ -424,6 +432,7 @@ ul.flags li { background-color: rgba(100, 100, 100, 0.5); top: 0; left: 0; + display: none; } .closePopin { @@ -435,7 +444,7 @@ ul.flags li { color: red; } -#ajaxSaveButton { +#ajaxSaveButton, #ajaxAutoSaveButton { text-decoration: none; } diff --git a/swe-ui-web/src/main/webapp/js/editor.js b/swe-ui-web/src/main/webapp/js/editor.js index 113ee6b..d803e76 100644 --- a/swe-ui-web/src/main/webapp/js/editor.js +++ b/swe-ui-web/src/main/webapp/js/editor.js @@ -3,6 +3,7 @@ var exitAfterCommit = false; /* Changes the value of the new text */ function loadChange() { document.getElementById('newTextId').value = editor.getValue(); + document.getElementById('newTextIdAutoSave').value = editor.getValue(); } /* Opens the popin */ @@ -40,11 +41,29 @@ $.subscribe('treeChanged', function(event, data) { } }); -//function autoSave() { -// alert("auto save"); -//} +function autoSave() { + loadChange(); + + $.post("save.action", { + username: document.getElementById("username").value, + pw: document.getElementById("pw").value, + saveCookie: document.getElementById("saveCookie").value, + commitMessage: "auto save", + newText: document.getElementById("newTextId").value, + origText: document.getElementById("origText").value, + format: document.getElementById("format").value, + scmType: document.getElementById("scmType").value, + address: document.getElementById("address").value + }).done(function(data) { + + // if there is an error, we ask the user to login + if (data.contains('<font color="red">')) { + openPopin('autoSavePopin'); + } + }); +} // Every 5 minutes, the file is automatically saved -//setInterval(autoSave, 300000); +setInterval(autoSave, 300000); window.onbeforeunload = confirmExitOnUnload; \ No newline at end of file -- To stop receiving notification emails like this one, please contact nuiton.org SCM administrator <admin+scm@nuiton.org>.