001 : //------------------------------------------------------------ 002 : // RateMe.js ─ Website Rating System 003 : // 004 : // By M.Miyazaki 005 : // Created : 2012.09.19 006 : // REQUIRED! : Use with the 'jQuery' 007 : //------------------------------------------------------------ 008 : 009 : //========== 010 : // for Ajax 011 : //========== 012 : 013 : /** 014 : * Accessor 015 : */ 016 : function getElement(id) 017 : { 018 : return document.getElementById(id); 019 : } 020 : 021 : /** 022 : * Submit a value for StarRating. 023 : */ 024 : function submitStarRating() 025 : { 026 : var starRatingValue = getElement('StarRating').value; 027 : var url = getElement('PageUrl').value; 028 : 029 : var params = ""; 030 : params += "mode=" + "post" + "&"; 031 : params += "href=" + url + "&"; 032 : params += "type=" + "starRating" + "&"; 033 : params += "value=" + starRatingValue; 034 : 035 : $.ajax({type:"POST", url:"./RateMe.php", data:params, success:receiveStarRating, error:failStarRating}); 036 : 037 : getElement('firstDisplayStarRating').style.display = "none"; 038 : getElement('processingStarRating').style.display = ""; 039 : 040 : return; 041 : } 042 : 043 : /** 044 : * Receive a response of StarRating process. 045 : */ 046 : function receiveStarRating(data, status, xhr){ 047 : //alert(data); // for debug... 048 : getElement('processingStarRating').style.display = "none"; 049 : getElement('secondDisplayStarRating').style.display = ""; 050 : return; 051 : } 052 : 053 : /** 054 : * Submit a comment for StarRating. 055 : */ 056 : function submitStarRatingComment() 057 : { 058 : var comment = getElement('StarRatingComment').value; 059 : var url = getElement('PageUrl').value; 060 : 061 : var params = ""; 062 : params += "mode=" + "post" + "&"; 063 : params += "href=" + url + "&"; 064 : params += "type=" + "comment" + "&"; 065 : params += "value=" + comment; 066 : 067 : $.ajax({type:"POST", url:"./RateMe.php", data:params, success:receiveStarRatingComment, error:failStarRating}); 068 : 069 : getElement('secondDisplayStarRating').style.display = "none"; 070 : getElement('processingStarRating').style.display = ""; 071 : 072 : return; 073 : } 074 : 075 : /** 076 : * Receive a response of StarRating Comment process. 077 : */ 078 : function receiveStarRatingComment(data, status, xhr){ 079 : //alert(data); // for debug... 080 : getElement('processingStarRating').style.display = "none"; 081 : getElement('thirdDisplayStarRating').style.display = ""; 082 : return; 083 : } 084 : 085 : /** 086 : * If the process failed... 087 : */ 088 : function failStarRating() 089 : { 090 : getElement('processingStarRating').style.display = "none"; 091 : getElement('sorryStarRating').style.display = ""; 092 : return; 093 : } 094 : 095 : /** 096 : * Receive a response of StarRating process. 097 : */ 098 : function receiveStarRating(data, status, xhr){ 099 : //alert(data); // for debug... 100 : getElement('processingStarRating').style.display = "none"; 101 : getElement('secondDisplayStarRating').style.display = ""; 102 : return; 103 : } 104 : 105 : /** 106 : * Submit a comment for Yet Button. 107 : */ 108 : function submitYet() 109 : { 110 : var url = getElement('PageUrl').value; 111 : 112 : var params = ""; 113 : params += "mode=" + "post" + "&"; 114 : params += "href=" + url + "&"; 115 : params += "type=" + "yet"; 116 : 117 : $.ajax({type:"POST", url:"./RateMe.php", data:params, success:receiveYet, error:failYet}); 118 : 119 : getElement('firstDisplayYet').style.display = "none"; 120 : getElement('processingStarRating').style.display = ""; 121 : 122 : return; 123 : } 124 : 125 : /** 126 : * Receive a response of Yet process. 127 : */ 128 : function receiveYet(data, status, xhr){ 129 : //alert(data); // for debug... 130 : getElement('processingYet').style.display = "none"; 131 : getElement('secondDisplayYet').style.display = ""; 132 : return; 133 : } 134 : 135 : /** 136 : * If the process failed... 137 : */ 138 : function failYet() 139 : { 140 : getElement('processingYet').style.display = "none"; 141 : getElement('sorryYet').style.display = ""; 142 : return; 143 : } 144 :
This document was generated by NanigashiBiyori on 2012/09/26 at 02:05:14.