{"id":219,"date":"2009-07-27T22:33:49","date_gmt":"2009-07-27T21:33:49","guid":{"rendered":"http:\/\/www.codingfriends.com\/?p=219"},"modified":"2009-07-27T22:33:49","modified_gmt":"2009-07-27T21:33:49","slug":"how-to-convert-the-output-format-in-javascript","status":"publish","type":"post","link":"https:\/\/www.codingfriends.com\/index.php\/2009\/07\/27\/how-to-convert-the-output-format-in-javascript\/","title":{"rendered":"How to convert the output format in Javascript"},"content":{"rendered":"<p>How to convert the output format in Javascript<\/p>\n<p>If you want to format the output in Javascript, you must realize your codes by yourself because there are no related functions in Javascrip. These days, I got a set of functions written in Javascript to realize the data formatting coded by AJAX WebShop (You can dowonload AJAX WebShop in theire official site:<a title=\"link\"  href=\"http:\/\/ http:\/\/www.joyistar.com\" target=\"_blank\">link<\/a>. Version 3 is recommended). They are very helpful.<\/p>\n<p>Find &#8216;system.js&#8217; in the directory of AJAX WebShop and you will get these functions below:<\/p>\n<pre lang=\"javascript\">\r\nfunction FormatFloat(value,mask)\r\n{\r\n       return BasicFormat(value,mask,'FormatNumber')\r\n}\r\nfunction FormatDate(varDate, bstrFormat, varDestLocale)\r\n{\r\n       return BasicFormat(varDate,bstrFormat,'FormatDate',varDestLocale);\r\n}\r\nfunction FormatTime(varTime, bstrFormat, varDestLocale)\r\n{\r\n       return BasicFormat(varTime,bstrFormat,'FormatTime',varDestLocale);\r\n}\r\nfunction BasicFormat(value,mask,action,param)\r\n{\r\n       var xmlDoc;\r\n       var xslDoc;\r\n       var v='<formats><format><value>'+value+'<\/value><mask>'+mask+'<\/mask><\/format><\/formats>';\r\n       xmlDoc=parseXML(v);\r\n\r\n       var x; \r\n       if(isIE)\r\n              x='<xsl:stylesheet xmlns:xsl=\"uri:xsl\">'\r\n       else\r\n              x='<xsl:stylesheet version=\"1.0\" xmlns:xsl=\"http:\/\/www.w3.org\/1999\/XSL\/Transform\">';\r\n       x+='<xsl:template match=\"\/\">';\r\n       if(isIE) {\r\n              x+='<xsl:eval>'+action+'('+value+',\"'+mask+'\"';\r\n              if(param)x+=','+param;\r\n              x+=')<\/xsl:eval>';\r\n       }\r\n       else\r\n              x+='<xsl:value-of select=\"format-number('+value+',\\''+mask+'\\')\" \/>';\r\n\r\n       x+='<\/xsl:template><\/xsl:stylesheet>';\r\n       xslDoc=parseXML(x);\r\n       var s;\r\n       if(isIE)\r\n        s= xmlDoc.transformNode(xslDoc)\r\n       else{\r\n              \/\/for mozilla\/netscape \r\n        var processor = new XSLTProcessor(); \r\n              processor.importStylesheet(xslDoc);\r\n              var result = processor.transformToFragment(xmlDoc, xmlDoc);\r\n        var xmls = new XMLSerializer(); \r\n        s = xmls.serializeToString(result);\r\n       }\r\n       return s;\r\n}\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>How to convert the output format in Javascript If you want to format the output in Javascript, you must realize your codes by yourself because there are no related functions in Javascrip. These days, I got a set of functions written in Javascript to realize the data formatting coded by AJAX WebShop (You can dowonload &hellip; <a href=\"https:\/\/www.codingfriends.com\/index.php\/2009\/07\/27\/how-to-convert-the-output-format-in-javascript\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">How to convert the output format in Javascript<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[402,398,400],"class_list":["post-219","post","type-post","status-publish","format-standard","hentry","category-javascript","tag-javascript","tag-linux","tag-windows"],"_links":{"self":[{"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/posts\/219","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/comments?post=219"}],"version-history":[{"count":1,"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/posts\/219\/revisions"}],"predecessor-version":[{"id":220,"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/posts\/219\/revisions\/220"}],"wp:attachment":[{"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/media?parent=219"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/categories?post=219"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.codingfriends.com\/index.php\/wp-json\/wp\/v2\/tags?post=219"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}