[title] Set cookie about infomation of user action (login ID, selected Distribution ID)
authorSungmin kim <dev.sungmin.kim@samsung.com>
Wed, 24 Apr 2013 06:57:13 +0000 (15:57 +0900)
committerSungmin kim <dev.sungmin.kim@samsung.com>
Wed, 24 Apr 2013 06:57:13 +0000 (15:57 +0900)
dibs-web/public/index.html
dibs-web/public/javascripts/build.js
dibs-web/public/javascripts/main.js
dibs-web/public/javascripts/projects.js
dibs-web/public/javascripts/session.js

index 447d53e50773be5c30db88bc3a0774153c8afd35..18bf04b34bd1672993871194b6d48357739489cc 100644 (file)
@@ -100,11 +100,21 @@ Contributors:
                <div data-role="content">
                        <form id="login-form">
                                <label for="login-form-email" >Email</label>
-                               <input id="login-form-email" type="email" name="email" autocomplete="on"/>
-                               <label for="login-form-password">Password</label>
-                               <input id="login-form-password" type="password" name="password"/>
+                               <span style="float: left; width: 80%;">
+                                       <input id="login-form-email" type="email" name="email" autocomplete="on"/>
+                               </span>
+                               <span style="float: right;">
+                                       <input id="login-form-save" type="checkbox" name="save" class="custom" data-mini="true" checked/>
+                                       <label for="login-form-save">Save</label>
+                               </span>
+                               <span style="clear: both; float: left;">
+                                       <label for="login-form-password">Password</label>
+                               </span>
+                               <span style="clear: both;">
+                                       <input id="login-form-password" type="password" name="password"/>
+                               </span>
                                <br/>
-                               <div data-role="controlgroup" data-type="horizontal">   
+                               <div data-role="controlgroup" data-type="horizontal" style="float: left;">   
                                        <a href="#" data-rel="back" data-role="button" data-mini="true" >Cancel</a>
                                        <a href="#" onClick="sessionLogin()" data-role="button" data-mini="true" >Log in</a>
                                </div>
index a71ce34819f41afa4f2abf37a232f0e46bb4d0f6..e491e5a8a55df5cfeabdcd4ac510a3d85745a185 100644 (file)
@@ -37,7 +37,8 @@ function buildInit() {
                        });
                
                        /* default distribution selection */
-                       $("#build-distribution-select option:eq(0)").attr("selected", "selected");
+                       defualt_dist_id = buildGetCookieDistribution();
+                       $("#build-distribution-select").val(defualt_dist_id);
                        $("#build-distribution-select").selectmenu('refresh');
                
                        // query Project list
@@ -58,6 +59,8 @@ function buildInit() {
 function buildQueryProjectList() {
        var distId = $("#build-distribution-select option:selected").val();
 
+       buildSetCookieDistribution(distId);
+
        queryProjectsInDistribution( distId, function(xml) {
                $("#build-git-table").empty();
                $("#build-binary-table").empty();
@@ -327,3 +330,17 @@ function buildClear() {
        $("#build-git-table").empty();
        $("#build-binary-table").empty();
 }
+
+function buildSetCookieDistribution(id)
+{
+       saveCookie("build_distribution", id, 7);
+}
+
+function buildGetCookieDistribution()
+{
+       id = getCookie("build_distribution");
+       if(id == "") {
+               id = 0;
+       }
+       return id;
+}
index 828c9681123700b6ce6bdd5da381823600d7bf52..b5d997d8ef864dc35e4e57b426abd02dd9d13901 100644 (file)
@@ -69,7 +69,8 @@ $( document ).bind( "pagechange", function( event, data ){
                        clearFormData('signup-form');
                        break;
                case "login":
-                       clearFormData('login-form');
+                       clearLoginData();
+                       getUserId();
                        break;
                case "projects":
                        generateNavigationBar(id);
@@ -320,3 +321,26 @@ function dibsWebClear(){
        buildClear();
        jobsClear();
 }
+
+function getCookie(key)
+{
+       var cook = document.cookie + ";";
+       var idx = cook.indexOf(key, 0);
+       var val = "";
+
+       if (idx != -1) {
+                       cook = cook.substring(idx, cook.length);
+                       begin = cook.indexOf("=", 0) + 1;
+                       end = cook.indexOf(";", begin);
+                       val = unescape(cook.substring(begin, end));
+       }
+
+       return val;
+}
+
+function saveCookie(key, value, expire_days)
+{
+       var today = new Date();
+       today.setDate(today.getDate() + expire_days);
+       document.cookie = key + "=" + escape(value) + "; path=/; expires=" + today.toGMTString() + ";";
+}
index 74d56b98b3b2b2538ad525d25eb105761f560360..1aa86c62d5eaef3ee19f7800678536850b4d223b 100644 (file)
@@ -37,7 +37,8 @@ function projectsInit() {
                        });
                
                        /* default distribution selection */
-                       $("#projects-distribution-select option:eq(0)").attr("selected", "selected");
+                       defualt_dist_id = projectsGetCookieDistribution();
+                       $("#projects-distribution-select").val(defualt_dist_id);
                        $("#projects-distribution-select").selectmenu('refresh');
                
                        $('#projects-type-select input[type="radio"]').attr("checked",false).checkboxradio("refresh");
@@ -52,6 +53,8 @@ function projectsInit() {
 function projectsQueryProjectListType() {
        var dist_id = $("#projects-distribution-select option:selected").val();
 
+       projectsSetCookieDistribution(dist_id);
+
        queryProjectsInfoInDistribution( dist_id, function(xml) {
                $("#projects-project-list").empty();
 
@@ -164,3 +167,16 @@ function projectsClear() {
        $("#projects-project-list").empty();
 }
 
+function projectsSetCookieDistribution(id)
+{
+       saveCookie("projects_distribution", id, 7);
+}
+
+function projectsGetCookieDistribution()
+{
+       id = getCookie("projects_distribution");
+       if(id == "") {
+               id = 0;
+       }
+       return id;
+}
index 89c1e2bb497e4f355baca903671edd9aa79efb89..244107f948de71756d5e2ac337a7bb009a4fdffc 100644 (file)
@@ -119,11 +119,41 @@ function sessionLogin() {
                        sessionStorage.sessionInfoName = name;
                        sessionStorage.sessionInfoGroup = group;
                        sessionStorage.sessionInfoAdmin = admin;
+
+                       saveUserId(email);
+
                        $.mobile.changePage("#index"); 
                } 
                else
                {
                        alert(message);
-                       }
+               }
        });
 } 
+
+function clearLoginData()
+{
+       $("#login-form-email").val("");
+       $("#login-form-password").val("");
+}
+function getUserId()
+{
+       id = getCookie("user_email");
+       if(id != "") {
+               $("#login-form-email").val(id);
+       }
+}
+
+function saveUserId(id)
+{
+       if($("#login-form-save").attr("checked") ==  "checked") {
+               if (id != "") {
+                               saveCookie("user_email", id, 7);
+               } else {
+                               saveCookie("user_email", id, -1);
+               }
+       }
+       else {
+               saveCookie("user_email", id, -1);
+       }
+}