From d48c3ccb5e273730d2643366ecd6aa0dcb22e6f4 Mon Sep 17 00:00:00 2001 From: Andrew Date: Mon, 8 Jul 2019 13:29:53 +0400 Subject: =?UTF-8?q?=D0=A0=D0=B5=D1=84=D0=B0=D0=BA=D1=82=D0=BE=D1=80=D0=B8?= =?UTF-8?q?=D0=BD=D0=B3=20javascript=20=D1=84=D0=B0=D0=B9=D0=BB=D0=B0.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- day9/task5/static/js/constants.js | 135 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 135 insertions(+) create mode 100644 day9/task5/static/js/constants.js (limited to 'day9/task5/static/js/constants.js') diff --git a/day9/task5/static/js/constants.js b/day9/task5/static/js/constants.js new file mode 100644 index 0000000..7078fb4 --- /dev/null +++ b/day9/task5/static/js/constants.js @@ -0,0 +1,135 @@ +const request = { + get: function (url, callback) { + let xmlHttp = new XMLHttpRequest(); + xmlHttp.onreadystatechange = function() { + if (xmlHttp.readyState === 4 && xmlHttp.status === 200) + callback(xmlHttp.responseText); + }; + xmlHttp.open("GET", url, true); + xmlHttp.send(); + }, + + post: function (url, callback, data) { + let xmlHttp = new XMLHttpRequest(); + xmlHttp.onreadystatechange = function() { + if (xmlHttp.readyState === 4 && xmlHttp.status === 200) + callback(xmlHttp.responseText); + }; + xmlHttp.open("POST", url, true); + xmlHttp.send(this.formatParams(data)); + }, + + formatParams: function (params) { + return Object.keys(params).map((key) => { + return key+"="+encodeURIComponent(params[key]) + }).join("&") + } + }; + +const defaultColumnInputs = { + 'service_id': ``, + 'servtype': ``, + 'subtype': ``, + 'user_id': ``, + 'referrer_user_id': ``, + 'state': ``, + + 'creation_date': ``, + 'creation_time': ``, + 'creation_request_sent_date': ``, + 'notified_about_expiration': `` +}; + +const baseFormFields = `
+
+
service_id
+
+
+ +
+
servtype
+
+ +
+
+ +
+
subtype
+
+ +
+
+ +
+
user_id
+
+ +
+
+ +
+
referrer_user_id
+
+ +
+
+ +
+
state
+
+ +
+
+ +
+
creation_date
+
+ +
+
+
+
creation_time
+
+ +
+
+ +
+
creation_request_sent_date
+
+ + +
+
+ +
+
notified_about_expiration
+
+ +
+
+
`; + +const formCreateButtons = `
+ + +
`; + +const formEditButtons = `
+ + +
`; + +const uploadFileHtml = ''; -- cgit v1.2.3