<commit_before>// ***********************************************************
// ***********************************************************
// This is the code to add SQL Support to GunDB
// ***********************************************************
// ***********************************************************
var localgun;
var localgunclass;
var sqlParseFn;
var changed               =     false;
var staticSqlResultSets   = new Object();
var realtimeSqlResultSets = new Object();

(function(exports){

    function objectToArray(data) {
        var list2 = [];
        for (var itemkey in Object.keys(data)) {
            var obj = data[itemkey];
            //console.log(itemkey);
          if(data[itemkey] != undefined) {
            list2.push(obj);
            }
        };
        return list2;
    }

    // ---------------------------------------------
    //                  in_where
    //
    // This defines the where claus for the SQL
    // ---------------------------------------------
    function in_where( o, where ) {
        if (!where) {
            return true;
        }
        switch(where.operator) {
            case '='  : // fall through
            case 'IS' : return o[where.left.column] == where.right.value; break;
            case '>'  : return o[where.left.column] > where.right.value; break;
            case '<'  : return o[where.left.column] < where.right.value;break;
            case '&'  : // fall through
            case 'AND': return in_where(o, where.left) && in_where(o, where.right); break;
            case '||' : // fall through
            case 'OR' : return in_where(o, where.left) || in_where(o, where.right);break;
            default: return false;
        }
    };

    // ---------------------------------------------
    //                  g_insert
    //
    // This creates a new record
    // ---------------------------------------------
    function g_insert( newAst, gun, schema){
        var newRecord = {};
        var fields    = newAst.values[0].value;

        for(i = 0; i < fields.length; i ++) {
            newRecord[newAst.columns[i]] = fields[i].value;
        };
        gun.get(schema).get(newAst.table).set(newRecord);
    }

    // ---------------------------------------------
    //                  g_select
    //
    // This uses SQL to get records
    // ---------------------------------------------
    function g_select( sql, newAst, gun, cb, schema ) {
        staticSqlResultSets[sql] = [];
        var i = 0
        var count = 0;
        //console.log('*cb: '  + cb)

        function each(a){
            var b = localgunclass.obj.copy(a);
            if(in_where(b, newAst.where)) {
                count++;
                delete b['_'];
         	    //console.log('select from each',a);
                staticSqlResultSets[sql].push(b)
            };
        }

        function end(coll){
            //console.log('coll: '  + JSON.stringify(coll , null, 2))
            //staticSqlResultSets[sql] = objectToArray(temp);
            //console.log('**Get: '  + JSON.stringify(staticSqlResultSets[sql] , null, 2))
            console.log('**Finished Get: '  + count)
            //console.log('**cb: '  + cb)
            if (cb) {
                cb( staticSqlResultSets[sql] );
            };

        }

        gun.get(schema).get(newAst.from[0].table).valMapEnd(each,end);
        gun.get(schema).get(newAst.from[0].table).not(end);

      return true;//staticSqlResultSets[sql];
   };

    // ---------------------------------------------
    //                  g_update
    //
    // This uses SQL to update records
    // ---------------------------------------------
    function g_update( newAst, gun, schema ){
        //console.log('Update table name: ' + newAst.table);
        //console.log('Update schema name: ' + schema);

        var i = 0;

        function each(a, newId){
            //console.log("ID: " + newId);
            if (in_where( a, newAst.where )) {
                i ++;

                for (column of newAst.set) {
                    a[ column.column ] = column.value.value;
                    //console.log( column.column + ' = ' + column.value.value);
                }
                //console.log("ID: " + newId);
                gun.get(schema).get(newAst.table).get(newId).put(
                    a,
                    function(ack) {
                        //console.log('Updated')
                    });
            }
        }

        function end(coll){
            //console.log('Finished Get')
        }

        gun.get(schema).get(newAst.table).valMapEnd(each,end);
    };

    // ---------------------------------------------
    //                  setGunDB
    //
    // This sets the instance of GunDB
    // ---------------------------------------------
    exports.setGunDB  = function(lg) {
        localgun = lg;
    };

    // ---------------------------------------------
    //                  setGunDBClass
    //
    // This sets the Class GunDB
    // ---------------------------------------------
    exports.setGunDBClass  = function(lg) {
        localgunclass = lg;
        localgunclass.chain.sql = function( sql, cb, schema ){
            var newAst = sqlParseFn(sql);
            if (!schema) {
                schema = 'default'
            }

            var chain  = this.chain();
            switch(newAst.type ) {
                case 'insert' : g_insert(newAst,      this,     schema);break;
                case 'select' : g_select(sql, newAst, this, cb, schema);break;
                case 'update' : g_update(newAst,      this,     schema);break;
            }
            //return this
        }

        localgunclass.chain.valMapEnd = function (cb, end) {
            var n   = function () {},
            count   = 0,
            souls   = [],
            gun     = this;
            cb      = cb || n;
            end     = end || n;

            gun.val( function (list) {
                var args = Array.prototype.slice.call(arguments);
                localgunclass.node.is(list, function (n, soul) {
                    count += 1;
                    souls.push(soul);
                });

                souls.forEach(function (soul) {
                    gun.back(-1).get(soul).val(function (val, key) {
                        count -= 1;
                        cb.apply(this, arguments);
                        if (!count) {
                            end.apply(this, args);
                        }
                    });
                });
            });
            return gun;
        };
    };

    exports.sql = function( sql, cb, schema ){
        localgun.sql( sql, cb, schema );
    }

    // ---------------------------------------------
    //                  setSqlParseFn
    //
    // This sets the parse function to use
    // ---------------------------------------------
    exports.setSqlParseFn = function(lg) {
        sqlParseFn = lg;
    };

    exports.realtimeSql = function(sql3, callbackFn, schema) {
        try {
            if (!schema) {
                schema = 'default'
            }
            newAst = sqlParseFn(sql3);
            //console.log('RTable: ' + newAst.from[0].table);
            if (newAst.type == 'select') {
                localgun.get( schema ).get( newAst.from[0].table ).on(
                  function(a) {
                       //localgun.sql(sql3);
                    changed = true;
                    //console.log('(REAL:): ' + sql3)
                    },false);
            }
        }
        catch(err) {
            console.log(err);
            return false;
        }
        return true;
      };

      setInterval(function(){
        //console.log('Changed: ' + changed);
        if (changed) {
          localgun.sql("SELECT * FROM Customers ");
          }
        changed = false;

                            }, 1000)

}(typeof exports === 'undefined' ? this.share = {} : exports));
<commit_msg>Disabled real time SQL as hardcoded to customers table<commit_after>// ***********************************************************
// ***********************************************************
// This is the code to add SQL Support to GunDB
// ***********************************************************
// ***********************************************************
var localgun;
var localgunclass;
var sqlParseFn;
var changed               =     false;
var staticSqlResultSets   = new Object();
var realtimeSqlResultSets = new Object();

(function(exports){

    function objectToArray(data) {
        var list2 = [];
        for (var itemkey in Object.keys(data)) {
            var obj = data[itemkey];
            //console.log(itemkey);
          if(data[itemkey] != undefined) {
            list2.push(obj);
            }
        };
        return list2;
    }

    // ---------------------------------------------
    //                  in_where
    //
    // This defines the where claus for the SQL
    // ---------------------------------------------
    function in_where( o, where ) {
        if (!where) {
            return true;
        }
        switch(where.operator) {
            case '='  : // fall through
            case 'IS' : return o[where.left.column] == where.right.value; break;
            case '>'  : return o[where.left.column] > where.right.value; break;
            case '<'  : return o[where.left.column] < where.right.value;break;
            case '&'  : // fall through
            case 'AND': return in_where(o, where.left) && in_where(o, where.right); break;
            case '||' : // fall through
            case 'OR' : return in_where(o, where.left) || in_where(o, where.right);break;
            default: return false;
        }
    };

    // ---------------------------------------------
    //                  g_insert
    //
    // This creates a new record
    // ---------------------------------------------
    function g_insert( newAst, gun, schema){
        var newRecord = {};
        var fields    = newAst.values[0].value;

        for(i = 0; i < fields.length; i ++) {
            newRecord[newAst.columns[i]] = fields[i].value;
        };
        gun.get(schema).get(newAst.table).set(newRecord);
    }

    // ---------------------------------------------
    //                  g_select
    //
    // This uses SQL to get records
    // ---------------------------------------------
    function g_select( sql, newAst, gun, cb, schema ) {
        staticSqlResultSets[sql] = [];
        var i = 0
        var count = 0;
        //console.log('*cb: '  + cb)

        function each(a){
            var b = localgunclass.obj.copy(a);
            if(in_where( b, newAst.where )) {
                count ++;
                delete b['_'];
         	    //console.log('select from each',a);
                staticSqlResultSets[sql].push(b)
            };
        }

        function end(coll){
            //console.log('coll: '  + JSON.stringify(coll , null, 2))
            //staticSqlResultSets[sql] = objectToArray(temp);
            //console.log('**Get: '  + JSON.stringify(staticSqlResultSets[sql] , null, 2))
            //console.log('**cb: '  + cb)
            if (cb) {
                cb( staticSqlResultSets[sql] );
            };
            console.log('**Finished Get: '  + count)

        }

        gun.get(schema).get(newAst.from[0].table).valMapEnd(each,end);
        gun.get(schema).get(newAst.from[0].table).not(end);

      return true;//staticSqlResultSets[sql];
   };

    // ---------------------------------------------
    //                  g_update
    //
    // This uses SQL to update records
    // ---------------------------------------------
    function g_update( newAst, gun, schema ){
        //console.log('Update table name: ' + newAst.table);
        //console.log('Update schema name: ' + schema);

        var i = 0;

        function each(a, newId){
            //console.log("ID: " + newId);
            if (in_where( a, newAst.where )) {
                i ++;

                for (column of newAst.set) {
                    a[ column.column ] = column.value.value;
                    //console.log( column.column + ' = ' + column.value.value);
                }
                //console.log("ID: " + newId);
                gun.get(schema).get(newAst.table).get(newId).put(
                    a,
                    function(ack) {
                        //console.log('Updated')
                    });
            }
        }

        function end(coll){
            //console.log('Finished Get')
        }

        gun.get(schema).get(newAst.table).valMapEnd(each,end);
    };

    // ---------------------------------------------
    //                  setGunDB
    //
    // This sets the instance of GunDB
    // ---------------------------------------------
    exports.setGunDB  = function(lg) {
        localgun = lg;
    };

    // ---------------------------------------------
    //                  setGunDBClass
    //
    // This sets the Class GunDB
    // ---------------------------------------------
    exports.setGunDBClass  = function(lg) {
        localgunclass = lg;
        localgunclass.chain.sql = function( sql, cb, schema ){
            var newAst = sqlParseFn(sql);
            if (!schema) {
                schema = 'default'
            }

            var chain  = this.chain();
            switch(newAst.type ) {
                case 'insert' : g_insert(newAst,      this,     schema);break;
                case 'select' : g_select(sql, newAst, this, cb, schema);break;
                case 'update' : g_update(newAst,      this,     schema);break;
            }
            //return this
        }

        localgunclass.chain.valMapEnd = function (cb, end) {
            var n   = function () {},
            count   = 0,
            souls   = [],
            gun     = this;
            cb      = cb || n;
            end     = end || n;

            gun.val( function (list) {
                var args = Array.prototype.slice.call(arguments);
                localgunclass.node.is(list, function (n, soul) {
                    count += 1;
                    souls.push(soul);
                });

                souls.forEach(function (soul) {
                    gun.back(-1).get(soul).val(function (val, key) {
                        count -= 1;
                        cb.apply(this, arguments);
                        if (!count) {
                            end.apply(this, args);
                        }
                    });
                });
            });
            return gun;
        };
    };

    exports.sql = function( sql, cb, schema ){
        localgun.sql( sql, cb, schema );
    }

    // ---------------------------------------------
    //                  setSqlParseFn
    //
    // This sets the parse function to use
    // ---------------------------------------------
    exports.setSqlParseFn = function(lg) {
        sqlParseFn = lg;
    };

    exports.realtimeSql = function(sql3, callbackFn, schema) {
        try {
            if (!schema) {
                schema = 'default'
            }
            newAst = sqlParseFn(sql3);
            //console.log('RTable: ' + newAst.from[0].table);
            if (newAst.type == 'select') {
                localgun.get( schema ).get( newAst.from[0].table ).on(
                  function(a) {
                       //localgun.sql(sql3);
                    changed = true;
                    //console.log('(REAL:): ' + sql3)
                    },false);
            }
        }
        catch(err) {
            console.log(err);
            return false;
        }
        return true;
      };

      setInterval( function () {
          //console.log('Changed: ' + changed);
          if (changed) {
              //localgun.sql("SELECT * FROM Customers ");
          }
          changed = false;
      }, 1000)

}(typeof exports === 'undefined' ? this.share = {} : exports));
<|endoftext|>


<commit_before>/* jshint evil:true, camelcase:false */
(function () {
    var head = document.getElementsByTagName('head').item(0);

    function loadCss(href) {
        // summary:
        //      Adds a css link element to the document head with the
        //      passed in href
        // console.log(this.declaredClass + "::loadCss", arguments);

        var link = document.createElement('link');
        link.rel = 'stylesheet';
        link.type = 'text/css';
        link.href = href;
        head.appendChild(link);
    }

    loadCss('/app/resources/App.css');
    loadCss('/bootstrap/dist/css/bootstrap.css'); // dev
    loadCss('/bootstrap/css/bootstrap.css'); // built

    document.write('<script type="text/javascript" src="/dojo/dojo.js" data-dojo-config="isDebug: 1"></script>');
    document.write('<script type="text/javascript" src="/app/run.js"></script>');
}());
<commit_msg>feat: add google analytics<commit_after>/* jshint evil:true, camelcase:false */
(function () {
    var head = document.getElementsByTagName('head').item(0);

    function loadCss(href) {
        // summary:
        //      Adds a css link element to the document head with the
        //      passed in href
        // console.log(this.declaredClass + "::loadCss", arguments);

        var link = document.createElement('link');
        link.rel = 'stylesheet';
        link.type = 'text/css';
        link.href = href;
        head.appendChild(link);
    }

    loadCss('/app/resources/App.css');
    loadCss('/bootstrap/dist/css/bootstrap.css'); // dev
    loadCss('/bootstrap/css/bootstrap.css'); // built

    document.write('<script type="text/javascript" src="/dojo/dojo.js" data-dojo-config="isDebug: 1"></script>');
    document.write('<script type="text/javascript" src="/app/run.js"></script>');

    // google analytics
    document.write('<script async src="https://www.googletagmanager.com/gtag/js?id=G-PECSFZVT9S"></script>');

    window.dataLayer = window.dataLayer || [];
    function gtag() {
        window.dataLayer.push(arguments);
    }
    gtag('js', new Date());

    gtag('config', 'G-PECSFZVT9S');
}());
<|endoftext|>


<commit_before>"use strict";
(function() {
	var r = this,
		lzwCompress = function(r, e, n) {
			var t = {},
				o = !1,
				i = function(r) {
					try {
						console.log("lzwCompress: " + (new Date).toISOString() + " : " + ("object" == typeof r ? e.stringify(r) : r))
					} catch (n) {}
				};
			! function(r, e, n) {
				var t = [],
					u = function(r) {
						return function(e) {
							return e === r
						}
					},
					f = function(r, e) {
						for (var n = 0; n < r.length; n++)
							if (e(r[n])) return !0;
						return !1
					},
					a = function(r, e, n) {
						f(r, n) || r.push(e)
					},
					c = function(r) {
						if ("object" == typeof r)
							for (var n in r) e.isArray(r) || a(t, n, u(n)), c(r[n])
					},
					s = function(r) {
						if ("object" != typeof r) return r;
						for (var n in r) e.isArray(r) ? r[n] = s(r[n]) : r.hasOwnProperty(n) && (r[t.indexOf(n)] = s(r[n]), delete r[n]);
						return r
					},
					p = function(r) {
						if ("object" != typeof r) return r;
						for (var n in r) e.isArray(r) ? r[n] = p(r[n]) : r.hasOwnProperty(n) && (r[t[n]] = p(r[n]), delete r[n]);
						return r
					},
					y = function(r) {
						t = [];
						var e = n.parse(r);
						return c(e), o && i("keys length : " + t.length), o && i("keys        : " + t), n.stringify({
							__k: t,
							__v: s(e)
						})
					},
					l = function(r) {
						var e = r;
						return "object" != typeof e ? r : e.hasOwnProperty("__k") ? (t = e.__k, p(e.__v)) : n.stringify(e)
					};
				r.KeyOptimize = {
					pack: y,
					unpack: l
				}
			}(t, r, e),
			function(r, e) {
				var t = function(r) {
						if ("string" != typeof r) return r;
						var e, t, o, i = {},
							u = "",
							f = [],
							a = 256;
						for (e = 0; 256 > e; e += 1) i[String.fromCharCode(e)] = e;
						for (e = 0; e < r.length; e += 1)
							if (t = r.charAt(e), o = u + t, i[o]) u = o;
							else {
								if (i[u] === n) return r;
								f.push(i[u]), i[o] = a++, u = String(t)
							}
						return "" !== u && f.push(i[u]), f
					},
					o = function(r) {
						if (!e.isArray(r)) return r;
						var n, t, o, i, u = [],
							f = "",
							a = 256;
						for (n = 0; 256 > n; n += 1) u[n] = String.fromCharCode(n);
						for (t = String.fromCharCode(r[0]), o = t, n = 1; n < r.length; n += 1) {
							if (i = r[n], u[i]) f = u[i];
							else {
								if (i !== a) return null;
								f = t + t.charAt(0)
							}
							o += f, u[a++] = t + f.charAt(0), t = f
						}
						return o
					};
				r.LZWCompress = {
					pack: t,
					unpack: o
				}
			}(t, r);
			var u = function(r) {
					if (o && i("original (uncompressed) : " + r), !r || r === !0 || r instanceof Date) return r;
					var n = r;
					"object" == typeof r && (n = t.KeyOptimize.pack(e.stringify(r)), o && i("key optimized: " + n));
					var u = t.LZWCompress.pack(n);
					return o && i("packed   (compressed)   : " + u), u
				},
				f = function(r) {
					if (o && i("original (compressed)   : " + r), !r || r === !0 || r instanceof Date) return r;
					var n, u = t.LZWCompress.unpack(r);
					try {
						n = e.parse(u)
					} catch (f) {
						return o && i("unpacked (uncompressed) : " + u), u
					}
					return "object" == typeof n && (u = t.KeyOptimize.unpack(n)), o && i("unpacked (uncompressed) : " + u), u
				},
				a = function(r) {
					o = r
				};
			return {
				pack: u,
				unpack: f,
				enableLogging: a
			}
		}(Array, JSON);
	"undefined" != typeof module && module.exports ? module.exports = lzwCompress : r.lzwCompress = lzwCompress
}).call(this);<commit_msg>Better for Usage<commit_after>"use strict";(function() {var r = this,lzwCompress = function(r, e, n) {var t = {},o = !1,i = function(r) {try {console.log("lzwCompress: " + (new Date).toISOString() + " : " + ("object" == typeof r ? e.stringify(r) : r))} catch (n) {}};! function(r, e, n) {var t = [],u = function(r) {return function(e) {return e === r}},f = function(r, e) {for (var n = 0; n < r.length; n++)if (e(r[n])) return !0;return !1},a = function(r, e, n) {f(r, n) || r.push(e)},c = function(r) {if ("object" == typeof r)for (var n in r) e.isArray(r) || a(t, n, u(n)), c(r[n])},s = function(r) {if ("object" != typeof r) return r;for (var n in r) e.isArray(r) ? r[n] = s(r[n]) : r.hasOwnProperty(n) && (r[t.indexOf(n)] = s(r[n]), delete r[n]);return r},p = function(r) {if ("object" != typeof r) return r;for (var n in r) e.isArray(r) ? r[n] = p(r[n]) : r.hasOwnProperty(n) && (r[t[n]] = p(r[n]), delete r[n]);return r},y = function(r) {t = [];var e = n.parse(r);return c(e), o && i("keys length : " + t.length), o && i("keys        : " + t), n.stringify({__k: t,__v: s(e)})},l = function(r) {var e = r;return "object" != typeof e ? r : e.hasOwnProperty("__k") ? (t = e.__k, p(e.__v)) : n.stringify(e)};r.KeyOptimize = {pack: y,unpack: l}}(t, r, e),function(r, e) {var t = function(r) {if ("string" != typeof r) return r;var e, t, o, i = {},u = "",f = [],a = 256;for (e = 0; 256 > e; e += 1) i[String.fromCharCode(e)] = e;for (e = 0; e < r.length; e += 1)if (t = r.charAt(e), o = u + t, i[o]) u = o;else {if (i[u] === n) return r;f.push(i[u]), i[o] = a++, u = String(t)}return "" !== u && f.push(i[u]), f},o = function(r) {if (!e.isArray(r)) return r;var n, t, o, i, u = [],f = "",a = 256;for (n = 0; 256 > n; n += 1) u[n] = String.fromCharCode(n);for (t = String.fromCharCode(r[0]), o = t, n = 1; n < r.length; n += 1) {if (i = r[n], u[i]) f = u[i];else {if (i !== a) return null;f = t + t.charAt(0)}o += f, u[a++] = t + f.charAt(0), t = f}return o};r.LZWCompress = {pack: t,unpack: o}}(t, r);var u = function(r) {if (o && i("original (uncompressed) : " + r), !r || r === !0 || r instanceof Date) return r;var n = r;"object" == typeof r && (n = t.KeyOptimize.pack(e.stringify(r)), o && i("key optimized: " + n));var u = t.LZWCompress.pack(n);return o && i("packed   (compressed)   : " + u), u},f = function(r) {if (o && i("original (compressed)   : " + r), !r || r === !0 || r instanceof Date) return r;var n, u = t.LZWCompress.unpack(r);try {n = e.parse(u)} catch (f) {return o && i("unpacked (uncompressed) : " + u), u}return "object" == typeof n && (u = t.KeyOptimize.unpack(n)), o && i("unpacked (uncompressed) : " + u), u},a = function(r) {o = r};return {pack: u,unpack: f,enableLogging: a}}(Array, JSON);"undefined" != typeof module && module.exports ? module.exports = lzwCompress : r.lzwCompress = lzwCompress}).call(this);<|endoftext|>


<commit_before>frappe.provide("frappe.ui");
frappe.provide("frappe.web_form");
import EventEmitterMixin from '../../frappe/event_emitter';

export default class WebForm extends frappe.ui.FieldGroup {
	constructor(opts) {
		super();
		Object.assign(this, opts);
		frappe.web_form = this;
		frappe.web_form.events = {};
		Object.assign(frappe.web_form.events, EventEmitterMixin);
	}

	prepare(web_form_doc, doc) {
		Object.assign(this, web_form_doc);
		this.fields = web_form_doc.web_form_fields;
		this.doc = doc;
	}

	make() {
		super.make();
		this.set_field_values();
		if (this.introduction_text) this.set_form_description(this.introduction_text);
		if (this.allow_print && !this.is_new) this.setup_print_button();
		if (this.allow_delete && !this.is_new) this.setup_delete_button();
		if (this.is_new) this.setup_cancel_button();
		this.setup_primary_action();
		$(".link-btn").remove();

		// webform client script
		frappe.init_client_script && frappe.init_client_script();
		frappe.web_form.events.trigger('after_load');
		this.after_load && this.after_load();
	}

	on(fieldname, handler) {
		let field = this.fields_dict[fieldname];
		field.df.change = () => {
			handler(field, field.value);
		};
	}

	set_field_values() {
		if (this.doc.name) this.set_values(this.doc);
		else return;
	}

	set_default_values() {
		let values = frappe.utils.get_query_params();
		delete values.new;
		this.set_values(values);
	}

	set_form_description(intro) {
		let intro_wrapper = document.getElementById('introduction');
		intro_wrapper.innerHTML = intro;
	}

	add_button(name, type, action, wrapper_class=".web-form-actions") {
		const button = document.createElement("button");
		button.classList.add("btn", "btn-" + type, "btn-sm", "ml-2");
		button.innerHTML = name;
		button.onclick = action;
		document.querySelector(wrapper_class).appendChild(button);
	}

	add_button_to_footer(name, type, action) {
		this.add_button(name, type, action, '.web-form-footer');
	}

	add_button_to_header(name, type, action) {
		this.add_button(name, type, action, '.web-form-actions');
	}

	setup_primary_action() {
		this.add_button_to_header(this.button_label || "Save", "primary", () =>
			this.save()
		);

		this.add_button_to_footer(this.button_label || "Save", "primary", () =>
			this.save()
		);
	}

	setup_cancel_button() {
		this.add_button_to_header(__("Cancel"), "light", () => this.cancel());
	}

	setup_delete_button() {
		this.add_button_to_header(
			'',
			"light",
			() => this.delete()
		);
	}

	setup_print_button() {
		this.add_button_to_header(
			'',
			"light",
			() => this.print()
		);
	}

	save() {
		if (this.validate && !this.validate()) {
			frappe.throw(__("Couldn't save, please check the data you have entered"), __("Validation Error"));
		}

		// validation hack: get_values will check for missing data
		let doc_values = super.get_values(this.allow_incomplete);

		if (!doc_values) return;

		if (window.saving) return;
		let for_payment = Boolean(this.accept_payment && !this.doc.paid);

		Object.assign(this.doc, doc_values);
		this.doc.doctype = this.doc_type;
		this.doc.web_form_name = this.name;

		// Save
		window.saving = true;
		frappe.form_dirty = false;

		frappe.call({
			type: "POST",
			method: "frappe.website.doctype.web_form.web_form.accept",
			args: {
				data: this.doc,
				web_form: this.name,
				docname: this.doc.name,
				for_payment
			},
			callback: response => {
				// Check for any exception in response
				if (!response.exc) {
					// Success
					this.handle_success(response.message);
					frappe.web_form.events.trigger('after_save');
					this.after_save && this.after_save();
					// args doctype and docname added to link doctype in file manager
					frappe.call({
						type: 'POST',
						method: "frappe.handler.upload_file",
						args: {
							file_url: response.message.attachment,
							doctype: response.message.doctype,
							docname: response.message.name
						}
					});
				}
			},
			always: function() {
				window.saving = false;
			}
		});
		return true;
	}

	delete() {
		frappe.call({
			type: "POST",
			method: "frappe.website.doctype.web_form.web_form.delete",
			args: {
				web_form_name: this.name,
				docname: this.doc.name
			}
		});
	}

	print() {
		window.open(`/printview?
			doctype=${this.doc_type}
			&name=${this.doc.name}
			&format=${this.print_format || "Standard"}`, '_blank');
	}

	cancel() {
		window.location.href = window.location.pathname;
	}

	handle_success(data) {
		if (this.accept_payment && !this.doc.paid) {
			window.location.href = data;
		}

		const success_dialog = new frappe.ui.Dialog({
			title: __("Saved Successfully"),
			secondary_action: () => {
				if (this.success_url) {
					window.location.href = this.success_url;
				} else if(this.login_required) {
					window.location.href =
						window.location.pathname + "?name=" + data.name;
				}
			}
		});

		success_dialog.show();
		const success_message =
			this.success_message || __("Your information has been submitted");
		success_dialog.set_message(success_message);
	}
}
<commit_msg>Removed buggy code<commit_after>frappe.provide("frappe.ui");
frappe.provide("frappe.web_form");
import EventEmitterMixin from '../../frappe/event_emitter';

export default class WebForm extends frappe.ui.FieldGroup {
	constructor(opts) {
		super();
		Object.assign(this, opts);
		frappe.web_form = this;
		frappe.web_form.events = {};
		Object.assign(frappe.web_form.events, EventEmitterMixin);
	}

	prepare(web_form_doc, doc) {
		Object.assign(this, web_form_doc);
		this.fields = web_form_doc.web_form_fields;
		this.doc = doc;
	}

	make() {
		super.make();
		this.set_field_values();
		if (this.introduction_text) this.set_form_description(this.introduction_text);
		if (this.allow_print && !this.is_new) this.setup_print_button();
		if (this.allow_delete && !this.is_new) this.setup_delete_button();
		if (this.is_new) this.setup_cancel_button();
		this.setup_primary_action();
		$(".link-btn").remove();

		// webform client script
		frappe.init_client_script && frappe.init_client_script();
		frappe.web_form.events.trigger('after_load');
		this.after_load && this.after_load();
	}

	on(fieldname, handler) {
		let field = this.fields_dict[fieldname];
		field.df.change = () => {
			handler(field, field.value);
		};
	}

	set_field_values() {
		if (this.doc.name) this.set_values(this.doc);
		else return;
	}

	set_default_values() {
		let values = frappe.utils.get_query_params();
		delete values.new;
		this.set_values(values);
	}

	set_form_description(intro) {
		let intro_wrapper = document.getElementById('introduction');
		intro_wrapper.innerHTML = intro;
	}

	add_button(name, type, action, wrapper_class=".web-form-actions") {
		const button = document.createElement("button");
		button.classList.add("btn", "btn-" + type, "btn-sm", "ml-2");
		button.innerHTML = name;
		button.onclick = action;
		document.querySelector(wrapper_class).appendChild(button);
	}

	add_button_to_footer(name, type, action) {
		this.add_button(name, type, action, '.web-form-footer');
	}

	add_button_to_header(name, type, action) {
		this.add_button(name, type, action, '.web-form-actions');
	}

	setup_primary_action() {
		this.add_button_to_header(this.button_label || "Save", "primary", () =>
			this.save()
		);

		this.add_button_to_footer(this.button_label || "Save", "primary", () =>
			this.save()
		);
	}

	setup_cancel_button() {
		this.add_button_to_header(__("Cancel"), "light", () => this.cancel());
	}

	setup_delete_button() {
		this.add_button_to_header(
			'',
			"light",
			() => this.delete()
		);
	}

	setup_print_button() {
		this.add_button_to_header(
			'',
			"light",
			() => this.print()
		);
	}

	save() {
		if (this.validate && !this.validate()) {
			frappe.throw(__("Couldn't save, please check the data you have entered"), __("Validation Error"));
		}

		// validation hack: get_values will check for missing data
		let doc_values = super.get_values(this.allow_incomplete);

		if (!doc_values) return;

		if (window.saving) return;
		let for_payment = Boolean(this.accept_payment && !this.doc.paid);

		Object.assign(this.doc, doc_values);
		this.doc.doctype = this.doc_type;
		this.doc.web_form_name = this.name;

		// Save
		window.saving = true;
		frappe.form_dirty = false;

		frappe.call({
			type: "POST",
			method: "frappe.website.doctype.web_form.web_form.accept",
			args: {
				data: this.doc,
				web_form: this.name,
				docname: this.doc.name,
				for_payment
			},
			callback: response => {
				// Check for any exception in response
				if (!response.exc) {
					// Success
					this.handle_success(response.message);
					frappe.web_form.events.trigger('after_save');
					this.after_save && this.after_save();
				}
			},
			always: function() {
				window.saving = false;
			}
		});
		return true;
	}

	delete() {
		frappe.call({
			type: "POST",
			method: "frappe.website.doctype.web_form.web_form.delete",
			args: {
				web_form_name: this.name,
				docname: this.doc.name
			}
		});
	}

	print() {
		window.open(`/printview?
			doctype=${this.doc_type}
			&name=${this.doc.name}
			&format=${this.print_format || "Standard"}`, '_blank');
	}

	cancel() {
		window.location.href = window.location.pathname;
	}

	handle_success(data) {
		if (this.accept_payment && !this.doc.paid) {
			window.location.href = data;
		}

		const success_dialog = new frappe.ui.Dialog({
			title: __("Saved Successfully"),
			secondary_action: () => {
				if (this.success_url) {
					window.location.href = this.success_url;
				} else if(this.login_required) {
					window.location.href =
						window.location.pathname + "?name=" + data.name;
				}
			}
		});

		success_dialog.show();
		const success_message =
			this.success_message || __("Your information has been submitted");
		success_dialog.set_message(success_message);
	}
}
<|endoftext|>


<commit_before>/*global $, d3, techan, moment*/
import Ember from 'ember';

export default
Ember.Component.extend({
  tagName: 'div',
  attributeBindings: ['style'],
  style: '',

  selectedItem: null,
  onChange: function () {
    var self = this;
    var selectedItem = self.get('selectedItem');

    if (selectedItem) {
      d3.select(".selected-chart").html("");

      var symbol = selectedItem.symbol;
      var startDate = moment().subtract(30, 'days').format('YYYY-MM-DD');
      var endDate = moment().format('YYYY-MM-DD');

      var yqlURL = "http://query.yahooapis.com/v1/public/yql?q=";
      var dataFormat = "&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys";
      var historicalQ = yqlURL + "select%20*%20from%20yahoo.finance.historicaldata%20where%20symbol%20%3D%20%22" + symbol + "%22%20and%20startDate%20%3D%20%22" + startDate + "%22%20and%20endDate%20%3D%20%22" + endDate + "%22" + dataFormat;

      $.ajax({
        url: historicalQ,
        dataType: 'json',
        method: 'GET'
      }).done(function (data) {
        console.log(symbol);
        self.renderChart(data);
      }).fail(function () {
      });
    }

  }.observes('selectedItem').on('init'),

  renderChart: function (result) {
    var data = result.query.results.quote;

    var margin = {top: 20, right: 20, bottom: 30, left: 50},
      width = 960 - margin.left - margin.right,
      height = 500 - margin.top - margin.bottom;

    var parseDate = d3.time.format("%d-%b-%y").parse,
      timeFormat = d3.time.format('%Y-%m-%d'),
      valueFormat = d3.format(',.2fs');

    var x = techan.scale.financetime()
      .range([0, width]);

    var y = d3.scale.linear()
      .range([height, 0]);

    var candlestick = techan.plot.candlestick()
      .xScale(x)
      .yScale(y);

    var xAxis = d3.svg.axis()
      .scale(x)
      .orient("bottom");

    var yAxis = d3.svg.axis()
      .scale(y)
      .orient("left");

    var svg = d3.select(".selected-chart").append("svg")
      .attr("width", width + margin.left + margin.right)
      .attr("height", height + margin.top + margin.bottom)
      .append("g")
      .attr("transform", "translate(" + margin.left + "," + margin.top + ")");

    var valueText = svg.append('text')
      .style("text-anchor", "end")
      .attr("class", "coords")
      .attr("x", width - 5)
      .attr("y", 15);

    var accessor = candlestick.accessor();

    data = data.slice(0).map(function (d) {
      return {
        date: new Date(d.Date),
        open: +d.Open,
        high: +d.High,
        low: +d.Low,
        close: +d.Close,
        volume: +d.Volume
      };
    }).sort(function (a, b) {
      return d3.ascending(accessor.d(a), accessor.d(b));
    });

    x.domain(data.map(accessor.d));
    y.domain(techan.scale.plot.ohlc(data, accessor).domain());

    svg.append("g")
      .datum(data)
      .attr("class", "candlestick")
      .call(candlestick);

    svg.append("g")
      .attr("class", "x axis")
      .attr("transform", "translate(0," + height + ")")
      .call(xAxis);

    svg.append("g")
      .attr("class", "y axis")
      .call(yAxis)
      .append("text")
      .attr("transform", "rotate(-90)")
      .attr("y", 6)
      .attr("dy", ".71em")
      .style("text-anchor", "end")
      .text("Price ($)");
  }
});
<commit_msg>clean up<commit_after>/*global $, d3, techan, moment*/
import Ember from 'ember';

export default
Ember.Component.extend({
    tagName: 'div',
    attributeBindings: ['style'],
    style: '',

    selectedItem: null,
    onChange: function () {
        var self = this;
        var selectedItem = self.get('selectedItem');

        if (selectedItem) {
            d3.select(".selected-chart").html("");

            var symbol = selectedItem.symbol;
            var startDate = moment().subtract(30, 'days').format('YYYY-MM-DD');
            var endDate = moment().format('YYYY-MM-DD');

            var yqlURL = "http://query.yahooapis.com/v1/public/yql?q=";
            var dataFormat = "&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys";
            var historicalQ = yqlURL + "select%20*%20from%20yahoo.finance.historicaldata%20where%20symbol%20%3D%20%22" + symbol + "%22%20and%20startDate%20%3D%20%22" + startDate + "%22%20and%20endDate%20%3D%20%22" + endDate + "%22" + dataFormat;

            $.ajax({
                url: historicalQ,
                dataType: 'json',
                method: 'GET'
            }).done(function (data) {
                console.log(symbol);
                self.renderChart(data);
            }).fail(function () {
            });
        }

    }.observes('selectedItem').on('init'),

    renderChart: function (result) {
        var data = result.query.results.quote;

        var margin = {top: 20, right: 20, bottom: 30, left: 50},
            width = 960 - margin.left - margin.right,
            height = 500 - margin.top - margin.bottom;

        var x = techan.scale.financetime()
            .range([0, width]);

        var y = d3.scale.linear()
            .range([height, 0]);

        var candlestick = techan.plot.candlestick()
            .xScale(x)
            .yScale(y);

        var xAxis = d3.svg.axis()
            .scale(x)
            .orient("bottom");

        var yAxis = d3.svg.axis()
            .scale(y)
            .orient("left");

        var svg = d3.select(".selected-chart").append("svg")
            .attr("width", width + margin.left + margin.right)
            .attr("height", height + margin.top + margin.bottom)
            .append("g")
            .attr("transform", "translate(" + margin.left + "," + margin.top + ")");

        svg.append('text')
            .style("text-anchor", "end")
            .attr("class", "coords")
            .attr("x", width - 5)
            .attr("y", 15);

        var accessor = candlestick.accessor();

        data = data.slice(0).map(function (d) {
            return {
                date: new Date(d.Date),
                open: +d.Open,
                high: +d.High,
                low: +d.Low,
                close: +d.Close,
                volume: +d.Volume
            };
        }).sort(function (a, b) {
            return d3.ascending(accessor.d(a), accessor.d(b));
        });

        x.domain(data.map(accessor.d));
        y.domain(techan.scale.plot.ohlc(data, accessor).domain());

        svg.append("g")
            .datum(data)
            .attr("class", "candlestick")
            .call(candlestick);

        svg.append("g")
            .attr("class", "x axis")
            .attr("transform", "translate(0," + height + ")")
            .call(xAxis);

        svg.append("g")
            .attr("class", "y axis")
            .call(yAxis)
            .append("text")
            .attr("transform", "rotate(-90)")
            .attr("y", 6)
            .attr("dy", ".71em")
            .style("text-anchor", "end")
            .text("Price ($)");
    }
});
<|endoftext|>


<commit_before>/*
  react学习(一)
  个人理解,React组件分为两部分,即编写组件和使用组件
  编写组件
  var TestPlugin(组件名,首字母需要大写)=React.createClass({
    render:function(){
      return (

                Hello World!

      );//一些html标签
    }
  });
  传入一个对象,属性render返回组件的UI界面组成(html部分)

  使用组件
  ReactDOM.render(<TestPlugin />,document.getElementById("id"));
  第一个参数为编写的组件,第二个为组件要放在页面上的位置

  jsx遇到(,会解析HTML
     遇到{,会解析成JavaScript
*/
  var TestPlugin=React.createClass({
    render:function(){
      return (

                Hello World!

      );
    }
  });
  ReactDOM.render(<TestPlugin />,document.getElementById("container"));

/*
  react学习(二)
  组件的PropTypes属性
  编写组件时保证组件被正确使用变得非常有用,React的PropTypes属性可以对组件的属性值进行限定
  propTypes的常用值
  React.PropTypes.array|React.PropTypes.array.isRequired
  React.PropTypes.bool|React.PropTypes.bool.isRequired
  React.PropTypes.func|React.PropTypes.func.isRequired
  React.PropTypes.number|React.PropTypes.number.isRequired
  React.PropTypes.object|React.PropTypes.object.isRequired
  React.PropTypes.string|React.PropTypes.string.isRequired
  this.props代表组件的属性
*/
  var MyTitle=React.createClass({
    propTypes:{//此处propTypes为小写小写小写!!!
      title:React.PropTypes.string.isRequired,
    },
    render:function(){
      return (

Hello,{this.props.title}!

      );
    }
  });
  ReactDOM.render(<MyTitle title="NBA" />,document.body);
/*
  react学习(三)
  getDefaultProps来设置组件属性的默认值
*/
  var SearchPlugin=React.createClass({
    getDefaultProps:function(){
      return {
        value:"iphone 7"
      };
    },
    render:function(){
      return (

            <input type="text" value={this.props.value} />
            <button>搜索</button>

        );
    }
  });
  ReactDOM.render(<SearchPlugin />,document.getElementById("container"));
/*
  react学习(四)
  获取真实的DOM节点
  组件不是真实的DOM节点，而是存在于内存之中的一种数据结构，叫做虚拟DOM(virtual DOM).
  只有把它插入文档以后才会变成真实的DOM.所有的DOM变得都是先在虚拟DOM上发生,然后通过DOM diff算法反应到真实的DOM上
  但是若果需要获取真实的DOM节点,需要用到ref属性.
  有关于props和state的关系,可以看看这篇blog:
  http://blog.csdn.net/code_for_free/article/details/50762171

  getInitialState用于定义初始状态(是一个对象),可以通过this.state获取这个对象,this.setState方法用于修改状态值
  每次修改后自动调用this.render方法,再次渲染组件
  this.props和this.state都用于描述组件的特性,较为粗浅的区分方法是this.props表示那些一旦定义就不再改变的特性
  this.state是会随着用户互动而产生变化的特性
*/
  var SearchInput=React.createClass({
    getInitialState:function(){
      return {
        val:"iphone 7"
      };
    },
    handleFocus:function(){
      var inputnode=ReactDOM.findDOMNode(this.refs.sin);//网上说this.refs.sin就可以取到DOM节点，我试了不行，后来发现可能是版本的原因
      inputnode.style.borderColor="#2E8B57";
      this.setState({
        val:""
      });
    },
    handleBlur:function(){
      var inputnode=ReactDOM.findDOMNode(this.refs.sin);
      inputnode.style.borderColor="#DCDCDC";
      this.setState({
        val:"iphone 7"
      });
    },
    render:function(){
      return (

            <input type="text" ref="sin" value={this.state.val} onFocus={this.handleFocus} onBlur={this.handleBlur} />
            <button>搜索</button>

        );
    }
  });
  ReactDOM.render(<SearchInput />,document.getElementById("container"));
/*
  react学习(五)
  React组件之表单元素的组件
  约束性组件和非约束性组件的区分(使用value之分)
  非约束性组件:其value值由原生的DOM管理.用户输入A -> 显示A
  约束性组件:其value值由React管理.用户输入A -> 触发onChange事件 -> 事件处理函数中设置state.name=A -> 渲染标签并显示A

  不设置value(或者设置value=null)的组件是非约束性组件,此时如果想设置默认值可以使用defaultValue="sth"实现
  类型为radio,checkbox的<input />可以使用defaultChecked,<textarea />,<select />可以使用defaultValue.

  onChange事件中通过event.target.value来读取用户输入的值
*/
  var LimitPlugin=React.createClass({
    getInitialState:function(){
      return {
        value:"Hello World!"
      };
    },
    handleChange:function(event){
      this.setState({
        value:event.target.value
      });
      //如果把上面一段代码注释掉,不做任何处理,则组件为不可编辑状态
    },
    render:function(){
      return (

          <input type="text" value={this.state.value} onChange={this.handleChange} />

      );
    }
  });
  ReactDOM.render(<LimitPlugin />,document.getElementById("container"));

  var UnLimitPlugin=React.createClass({
    render:function(){
      return (

          <input type="text" defaultValue="Hello NBA!" />

      );
    }
  });
  ReactDOM.render(<UnLimitPlugin />,document.getElementById("container"));
/*
  react学习(六)
  css样式
  在React中,style行内样式不再是一个简单的字符串.它是一个{}的对象,这个对象里边的key是样式名称的驼峰命名显示,
  而value则是你想要的样式值(通常是字符串).
  1.使用{{}}来添加css样式
  var CssPlugin=React.createClass({
    render:function(){
      return (

Hello World!

      );
    }
  });
  2.使用变量单独定义
  var divStyle={color:"red"};
  var CssPlugin=React.createClass({
    render:function(){
      return (

Hello World!

      );
    }
  });
*/
/*
  react学习(七)
  组件的生命周期
  React组件的生命周期分为三个状态:
  Mount,英文有安装,嵌入,准备成立的意思
  Update,这个大家都知道,更新
  Unmount,英文意思就是卸载
  然后React为每个状态都提供了两种处理函数:will,在进入状态之前调用和did,在进入状态之后调用
  三种状态共计五个函数:
  componentWillMount(),componentDidMount(),componentWillUnmount(),
  componentWillUpdate(object nextProps,object nextState),componentDidUpdate(object prevProps,object prevState)
  组件第一次被实例化经历以下几个阶段:
  getDefaultProps->getInitialState->componentWillMount->render->componentDidMount
  以后组件的state变化时:
  shouldComponentUpdate(object nextProps,object nextState)(组件判断是否重新渲染时调用,如果没有变化则不会重新渲染)->
  componentWillUpdate->render->componentDidUpdate
  以后组件的props变化时:

*/
<commit_msg>Update exam.js<commit_after>/*
  react学习(一)
  个人理解,React组件分为两部分,即编写组件和使用组件
  编写组件
  var TestPlugin(组件名,首字母需要大写)=React.createClass({
    render:function(){
      return (

                Hello World!

      );//一些html标签
    }
  });
  传入一个对象,属性render返回组件的UI界面组成(html部分)

  使用组件
  ReactDOM.render(<TestPlugin />,document.getElementById("id"));
  第一个参数为编写的组件,第二个为组件要放在页面上的位置

  jsx遇到(,会解析HTML
     遇到{,会解析成JavaScript
*/
  var TestPlugin=React.createClass({
    render:function(){
      return (

                Hello World!

      );
    }
  });
  ReactDOM.render(<TestPlugin />,document.getElementById("container"));

/*
  react学习(二)
  组件的PropTypes属性
  编写组件时保证组件被正确使用变得非常有用,React的PropTypes属性可以对组件的属性值进行限定
  propTypes的常用值
  React.PropTypes.array|React.PropTypes.array.isRequired
  React.PropTypes.bool|React.PropTypes.bool.isRequired
  React.PropTypes.func|React.PropTypes.func.isRequired
  React.PropTypes.number|React.PropTypes.number.isRequired
  React.PropTypes.object|React.PropTypes.object.isRequired
  React.PropTypes.string|React.PropTypes.string.isRequired
  this.props代表组件的属性
*/
  var MyTitle=React.createClass({
    propTypes:{//此处propTypes为小写小写小写!!!
      title:React.PropTypes.string.isRequired,
    },
    render:function(){
      return (

Hello,{this.props.title}!

      );
    }
  });
  ReactDOM.render(<MyTitle title="NBA" />,document.body);
/*
  react学习(三)
  getDefaultProps来设置组件属性的默认值
*/
  var SearchPlugin=React.createClass({
    getDefaultProps:function(){
      return {
        value:"iphone 7"
      };
    },
    render:function(){
      return (

            <input type="text" value={this.props.value} />
            <button>搜索</button>

        );
    }
  });
  ReactDOM.render(<SearchPlugin />,document.getElementById("container"));
/*
  react学习(四)
  获取真实的DOM节点
  组件不是真实的DOM节点，而是存在于内存之中的一种数据结构，叫做虚拟DOM(virtual DOM).
  只有把它插入文档以后才会变成真实的DOM.所有的DOM变得都是先在虚拟DOM上发生,然后通过DOM diff算法反应到真实的DOM上
  但是若果需要获取真实的DOM节点,需要用到ref属性.
  有关于props和state的关系,可以看看这篇blog:
  http://blog.csdn.net/code_for_free/article/details/50762171

  getInitialState用于定义初始状态(是一个对象),可以通过this.state获取这个对象,this.setState方法用于修改状态值
  每次修改后自动调用this.render方法,再次渲染组件
  this.props和this.state都用于描述组件的特性,较为粗浅的区分方法是this.props表示那些一旦定义就不再改变的特性
  this.state是会随着用户互动而产生变化的特性
*/
  var SearchInput=React.createClass({
    getInitialState:function(){
      return {
        val:"iphone 7"
      };
    },
    handleFocus:function(){
      var inputnode=ReactDOM.findDOMNode(this.refs.sin);//网上说this.refs.sin就可以取到DOM节点，我试了不行，后来发现可能是版本的原因
      inputnode.style.borderColor="#2E8B57";
      this.setState({
        val:""
      });
    },
    handleBlur:function(){
      var inputnode=ReactDOM.findDOMNode(this.refs.sin);
      inputnode.style.borderColor="#DCDCDC";
      this.setState({
        val:"iphone 7"
      });
    },
    render:function(){
      return (

            <input type="text" ref="sin" value={this.state.val} onFocus={this.handleFocus} onBlur={this.handleBlur} />
            <button>搜索</button>

        );
    }
  });
  ReactDOM.render(<SearchInput />,document.getElementById("container"));
/*
  react学习(五)
  React组件之表单元素的组件
  约束性组件和非约束性组件的区分(使用value之分)
  非约束性组件:其value值由原生的DOM管理.用户输入A -> 显示A
  约束性组件:其value值由React管理.用户输入A -> 触发onChange事件 -> 事件处理函数中设置state.name=A -> 渲染标签并显示A

  不设置value(或者设置value=null)的组件是非约束性组件,此时如果想设置默认值可以使用defaultValue="sth"实现
  类型为radio,checkbox的<input />可以使用defaultChecked,<textarea />,<select />可以使用defaultValue.

  onChange事件中通过event.target.value来读取用户输入的值
*/
  var LimitPlugin=React.createClass({
    getInitialState:function(){
      return {
        value:"Hello World!"
      };
    },
    handleChange:function(event){
      this.setState({
        value:event.target.value
      });
      //如果把上面一段代码注释掉,不做任何处理,则组件为不可编辑状态
    },
    render:function(){
      return (

          <input type="text" value={this.state.value} onChange={this.handleChange} />

      );
    }
  });
  ReactDOM.render(<LimitPlugin />,document.getElementById("container"));

  var UnLimitPlugin=React.createClass({
    render:function(){
      return (

          <input type="text" defaultValue="Hello NBA!" />

      );
    }
  });
  ReactDOM.render(<UnLimitPlugin />,document.getElementById("container"));
/*
  react学习(六)
  css样式
  在React中,style行内样式不再是一个简单的字符串.它是一个{}的对象,这个对象里边的key是样式名称的驼峰命名显示,
  而value则是你想要的样式值(通常是字符串).
  1.使用{{}}来添加css样式
  var CssPlugin=React.createClass({
    render:function(){
      return (

Hello World!

      );
    }
  });
  2.使用变量单独定义
  var divStyle={color:"red"};
  var CssPlugin=React.createClass({
    render:function(){
      return (

Hello World!

      );
    }
  });
*/
/*
  react学习(七)
  组件的生命周期
  React组件的生命周期分为三个状态:
  Mount,英文有安装,嵌入,准备成立的意思
  Update,这个大家都知道,更新
  Unmount,英文意思就是卸载
  然后React为每个状态都提供了两种处理函数:will,在进入状态之前调用和did,在进入状态之后调用
  三种状态共计五个函数:
  componentWillMount(),componentDidMount(),componentWillUnmount(),
  componentWillUpdate(object nextProps,object nextState),componentDidUpdate(object prevProps,object prevState)
  组件第一次被实例化经历以下几个阶段:
  getDefaultProps->getInitialState->componentWillMount->render->componentDidMount
  以后组件的state变化时:
  shouldComponentUpdate(object nextProps,object nextState)(组件判断是否重新渲染时调用,如果没有变化则不会重新渲染)->
  componentWillUpdate->render->componentDidUpdate
  以后组件的props变化时:
  componentWillReceiveProps(object nextProps)->shouldComponentUpdate->componentWillUpdate->render->componentDidUpdate
*/
<|endoftext|>


<commit_before>/**
 * @class ChosenSelectpicker
 * @memberof module:plugins
 * @descriptioon Applies chosen-js Select on filters and operators combo-boxes.
 * @param {object} [options] Supports all the options for chosen
 * @throws MissingLibraryError
 */
QueryBuilder.define('chosen-selectpicker', function(options) {

    if (!$.fn.chosen) {
        Utils.error('MissingLibrary', 'chosen is required to use "chosen-selectpicker" plugin. Get it here: https://github.com/harvesthq/chosen');
    }

    if (this.settings.plugins['bt-selectpicker']) {
        Utils.error('Conflict', 'bt-selectpicker is already selected as the dropdown plugin. Please remove chosen-selectpicker from the plugin list');
    }

    var Selectors = QueryBuilder.selectors;

    // init selectpicker
    this.on('afterCreateRuleFilters', function(e, rule) {
        rule.$el.find(Selectors.rule_filter).removeClass('form-control').chosen(options);
    });

    this.on('afterCreateRuleOperators', function(e, rule) {
        rule.$el.find(Selectors.rule_operator).removeClass('form-control').chosen(options);
    });

    // update selectpicker on change
    this.on('afterUpdateRuleFilter', function(e, rule) {
        rule.$el.find(Selectors.rule_filter).trigger('chosen:updated');
    });

    this.on('afterUpdateRuleOperator', function(e, rule) {
        rule.$el.find(Selectors.rule_operator).trigger('chosen:updated');
    });

    this.on('beforeDeleteRule', function(e, rule) {
        rule.$el.find(Selectors.rule_filter).chosen('destroy');
        rule.$el.find(Selectors.rule_operator).chosen('destroy');
    });
});
<commit_msg>chg: [plugin:chosen] avoid creating useless chosen widget (#743)<commit_after>/**
 * @class ChosenSelectpicker
 * @memberof module:plugins
 * @descriptioon Applies chosen-js Select on filters and operators combo-boxes.
 * @param {object} [options] Supports all the options for chosen
 * @throws MissingLibraryError
 */
QueryBuilder.define('chosen-selectpicker', function(options) {

    if (!$.fn.chosen) {
        Utils.error('MissingLibrary', 'chosen is required to use "chosen-selectpicker" plugin. Get it here: https://github.com/harvesthq/chosen');
    }

    if (this.settings.plugins['bt-selectpicker']) {
        Utils.error('Conflict', 'bt-selectpicker is already selected as the dropdown plugin. Please remove chosen-selectpicker from the plugin list');
    }

    var Selectors = QueryBuilder.selectors;

    // init selectpicker
    this.on('afterCreateRuleFilters', function(e, rule) {
        rule.$el.find(Selectors.rule_filter).removeClass('form-control').chosen(options);
    });

    this.on('afterCreateRuleOperators', function(e, rule) {
        if (e.builder.getOperators(rule.filter).length > 1) {
            rule.$el.find(Selectors.rule_operator).removeClass('form-control').chosen(options);
        }
    });

    // update selectpicker on change
    this.on('afterUpdateRuleFilter', function(e, rule) {
        rule.$el.find(Selectors.rule_filter).trigger('chosen:updated');
    });

    this.on('afterUpdateRuleOperator', function(e, rule) {
        rule.$el.find(Selectors.rule_operator).trigger('chosen:updated');
    });

    this.on('beforeDeleteRule', function(e, rule) {
        rule.$el.find(Selectors.rule_filter).chosen('destroy');
        rule.$el.find(Selectors.rule_operator).chosen('destroy');
    });
});
<|endoftext|>


<commit_before>{
    "configurationSettings":[
        {
            "category":"Content Options",
            "fields":[
                {
                    "type":"group",
                    "label":"Select a group"
                },
                {
                    "type":"string",
                    "fieldName":"siteTitle",
                    "label":"Website banner title:",
                    "tooltip":"The title of this template's website.",
                    "placeHolder":"My Maps"
                },
                {
                    "type":"paragraph",
                    "value":"The text above will be displayed in the top banner if no banner image is set. Uses group title by default."
                },
                {
                    "type":"string",
                    "fieldName":"siteBannerImage",
                    "tooltip":"URL for the navigation header logo image. If empty, Site Title text is used.",
                    "placeHolder":"http://www.mysite.com/logo.png",
                    "label":"Banner logo:"
                },
                {
                    "type":"paragraph",
                    "value":"Image to display in the top banner. Recommended height of 75 pixels."
                },
                {
                    "type":"string",
                    "fieldName":"addThisProfileId",
                    "label":"AddThis.com profile ID:",
                    "tooltip":"Account ID for AddThis.com.",
                    "placeHolder":"xa-4f3bf72958320e9e"
                },
                {
                    "type":"paragraph",
                    "value":"Register an AddThis.com<\/a> account for social media button analytics."
                },
                {
                    "type":"string",
                    "fieldName":"sourceCountry",
                    "label":"Locator Source Country",
                    "tooltip":"Locator Source Country",
                    "placeHolder":""
                },
                {
                    "type":"paragraph",
                    "value":"A value representing the country. Providing this value increases geocoding speed."
                }
            ]
        },
        {
            "category":"Home page Settings",
            "fields":[
                {
                    "type":"string",
                    "fieldName":"homeHeading",
                    "label":"Homepage heading:",
                    "tooltip":"Heading displayed within the main panel on the index page.",
                    "placeHolder":""
                },
                {
                    "type":"string",
                    "fieldName":"homeSideHeading",
                    "label":"Homepage side heading:",
                    "tooltip":"Heading displayed within the side panel on the index page.",
                    "placeHolder":""
                },
                {
                    "type":"string",
                    "fieldName":"homeSnippet",
                    "label":"Homepage snippet:",
                    "tooltip":"Brief text displayed on the index page.",
                    "placeHolder":""
                },
                {
                    "type":"string",
                    "fieldName":"homeSideContent",
                    "label":"Homepage side content:",
                    "tooltip":"Content displayed within the side panel on the index page.",
                    "placeHolder":""
                }
            ]
        },
        {
            "category":"Footer Settings",
            "fields":[
                {
                    "type":"string",
                    "fieldName":"footerHeading",
                    "label":"Footer heading:",
                    "tooltip":"Heading displayed in the footer.",
                    "placeHolder":""
                },
                {
                    "type":"string",
                    "fieldName":"footerDescription",
                    "label":"Footer content:",
                    "tooltip":"Content description displayed in the footer.",
                    "stringFieldOption":"textarea",
                    "placeHolder":"Footer Content"
                },
                {
                    "type":"string",
                    "fieldName":"footerLogo",
                    "tooltip":"Image to display in the footer. If empty, the group's thumbnail image is used.",
                    "placeHolder":"http://www.mysite.com/logo.png",
                    "label":"Footer logo:"
                },
                {
                    "type":"paragraph",
                    "value":"Image to display in the footer. If empty, the group's thumbnail image is used."
                },
                {
                    "type":"string",
                    "fieldName":"footerLogoUrl",
                    "tooltip":"Link for the image in the footer. If empty, link to the group on ArcGIS Online is used.",
                    "placeHolder":"http://www.mysite.com/",
                    "label":"Footer logo link:"
                },
                {
                    "type":"paragraph",
                    "value":"Link for the image in the footer. If empty, link to the group on ArcGIS Online is used."
                }
            ]
        },
        {
            "category":"General Settings",
            "fields":[
                {
                    "type":"string",
                    "fieldName":"theme",
                    "tooltip":"Color theme to use.",
                    "label":"Color theme:",
                    "options":[
                        {
                            "label":"Blue",
                            "value":"blueTheme"
                        },
                        {
                            "label":"Red",
                            "value":"redTheme"
                        },
                        {
                            "label":"Green",
                            "value":"greenTheme"
                        }
                    ]
                },
                {
                    "type":"string",
                    "fieldName":"defaultLayout",
                    "tooltip":"Whether to use grid view or list view as the default layout.",
                    "label":"Default layout:",
                    "options":[
                        {
                            "label":"Grid",
                            "value":"grid"
                        },
                        {
                            "label":"List",
                            "value":"list"
                        }
                    ]
                },
                {
                    "type":"string",
                    "fieldName":"sortField",
                    "tooltip":"Field to sort the group items by.",
                    "label":"Group sort field:",
                    "options":[
                        {
                            "label":"Modified Date",
                            "value":"modified"
                        },
                        {
                            "label":"Title",
                            "value":"title"
                        },
                        {
                            "label":"Type",
                            "value":"type"
                        },
                        {
                            "label":"Owner",
                            "value":"owner"
                        },
                        {
                            "label":"Average rating",
                            "value":"avgRating"
                        },
                        {
                            "label":"Number of ratings",
                            "value":"numRatings"
                        },
                        {
                            "label":"Number of comments",
                            "value":"numComments"
                        },
                        {
                            "label":"Number of views",
                            "value":"numViews"
                        }
                    ]
                },
                {
                    "type":"string",
                    "fieldName":"sortOrder",
                    "tooltip":"Order to sort the group field.",
                    "label":"Group sort order:",
                    "options":[
                        {
                            "label":"Descending",
                            "value":"desc"
                        },
                        {
                            "label":"Ascending",
                            "value":"asc"
                        }
                    ]
                },
                {
                    "type":"string",
                    "fieldName":"mapViewer",
                    "tooltip":"Open maps with this viewer.",
                    "label":"Open maps with:",
                    "options":[
                        {
                            "label":"Simple Viewer",
                            "value":"simple"
                        },
                        {
                            "label":"Map Viewer",
                            "value":"arcgis"
                        },
                        {
                            "label":"ArcGIS Item Page",
                            "value":"item_page"
                        }
                    ]
                },
                {
                    "type":"string",
                    "fieldName":"galleryItemsPerPage",
                    "tooltip":"Gallery items to show per page.",
                    "label":"Items per page:",
                    "options":[
                        {
                            "label":"3",
                            "value":"3"
                        },
                        {
                            "label":"6",
                            "value":"6"
                        },
                        {
                            "label":"9",
                            "value":"9"
                        },
                        {
                            "label":"12",
                            "value":"12"
                        },
                        {
                            "label":"15",
                            "value":"15"
                        }
                    ]
                },
                {
                    "type":"string",
                    "fieldName":"searchString",
                    "tooltip":"Default search string for group query.",
                    "placeHolder":"",
                    "label":"Search string:"
                },
                {
                    "type":"paragraph",
                    "value":"Default search string for group query."
                }
            ]
        },
        {
            "category":"Options",
            "fields":[
                {
                    "type":"boolean",
                    "fieldName":"openGalleryItemsNewWindow",
                    "label":"Open items in new window.",
                    "tooltip":"Open group items in a new window."
                },
                {
                    "type":"paragraph",
                    "value":"Open group items in a new window."
                },
                {
                    "type":"boolean",
                    "fieldName":"showProfileUrl",
                    "label":"Show profile link.",
                    "tooltip":"Links usernames to ArcGIS Online profiles."
                },
                {
                    "type":"paragraph",
                    "value":"Links usernames to ArcGIS Online profiles."
                },
                {
                    "type":"boolean",
                    "fieldName":"showSocialButtons",
                    "label":"Show social media buttons.",
                    "tooltip":""
                },
                {
                    "type":"paragraph",
                    "value":"Show social media buttons."
                },
                {
                    "type":"boolean",
                    "fieldName":"showFooter",
                    "label":"Show footer.",
                    "tooltip":"Show footer on all pages."
                },
                {
                    "type":"paragraph",
                    "value":"Show footer on all pages."
                },
                {
                    "type":"boolean",
                    "fieldName":"showArcGISOnlineButton",
                    "label":"Show Map Viewer button.",
                    "tooltip":"Displays the button to open the webmap in ArcGIS Online Map Viewer."
                },
                {
                    "type":"paragraph",
                    "value":"Displays the button to open the webmap in ArcGIS Online Map Viewer."
                },
                {
                    "type":"boolean",
                    "fieldName":"showMobileButtons",
                    "label":"Show mobile buttons.",
                    "tooltip":"Displays a mobile button to open the webmap in ArcGIS mobile app and a button to download the app."
                },
                {
                    "type":"paragraph",
                    "value":"Displays a mobile button to open the webmap in ArcGIS mobile app and a button to download the app."
                },
                {
                    "type":"boolean",
                    "fieldName":"showAttribution",
                    "label":"Show attribution.",
                    "tooltip":"Displays credits on the map page."
                },
                {
                    "type":"paragraph",
                    "value":"Displays credits on the map page."
                },
                {
                    "type":"boolean",
                    "fieldName":"showLicenseInfo",
                    "label":"Show constraints.",
                    "tooltip":"Displays constraints on the map page."
                },
                {
                    "type":"paragraph",
                    "value":"Displays constraints on the map page."
                },
                {
                    "type":"boolean",
                    "fieldName":"showMoreInfo",
                    "label":"Show more info links.",
                    "tooltip":"Displays More information links to the ArcGIS Online item page."
                },
                {
                    "type":"paragraph",
                    "value":"Displays More information links to the ArcGIS Online item page."
                },
                {
                    "type":"boolean",
                    "fieldName":"showGroupSort",
                    "label":"Show group sort bar",
                    "tooltip":"Displays group sort bar on the home page."
                },
                {
                    "type":"paragraph",
                    "value":"Displays group sort bar on the home page."
                },
                {
                    "type":"boolean",
                    "fieldName":"showViews",
                    "label":"Show Views",
                    "tooltip":"Displays view counts for maps"
                },
                {
                    "type":"paragraph",
                    "value":"Displays view counts for maps."
                },
                {
                    "type":"boolean",
                    "fieldName":"showComments",
                    "label":"Show comments",
                    "tooltip":"Shows comments for items and allows items to be commented on"
                },
                {
                    "type":"paragraph",
                    "value":"Shows comments for items and allows items to be commented on."
                },
                {
                    "type":"boolean",
                    "fieldName":"showRatings",
                    "label":"Show ratings",
                    "tooltip":"Shows ratings for items and allows items to be rated"
                },
                {
                    "type":"paragraph",
                    "value":"Shows ratings for items and allows items to be rated."
                },
                {
                    "type":"boolean",
                    "fieldName":"showFilterType",
                    "label":"Show Filter By Type",
                    "tooltip":"Shows a list allowing users to filter items by type."
                },
                {
                    "type":"paragraph",
                    "value":"Shows a list allowing users to filter items by type."
                },
                {
                    "type":"boolean",
                    "fieldName":"openLayersInViewer",
                    "label":"Open Layers in ArcGIS Map Viewer",
                    "tooltip":"Opens layers in the map viewer instead of the layer's REST URL"
                },
                {
                    "type":"paragraph",
                    "value":"Opens layers in the map viewer instead of the layer's REST URL"
                }
            ]
        }
    ],
    "values":{
        "theme":"blueTheme",
        "siteTitle":"",
        "searchString":"",
        "homeHeading":"",
        "homeSideHeading":"",
        "homeSideContent":"",
        "homeSnippet":"",
        "addThisProfileId":"xa-4f3bf72958320e9e",
        "defaultLayout":"grid",
        "sortField":"modified",
        "sortOrder":"desc",
        "mapViewer":"simple",
        "footerHeading":"",
        "footerDescription":"",
        "footerLogo":"",
        "footerLogoUrl":"",
        "openLayersInViewer":true,
        "showProfileUrl":true,
        "showSocialButtons":true,
        "showFooter":true,
        "showMoreInfo":false,
        "showComments":false,
        "showRatings":false,
        "showViews":false,
        "showArcGISOnlineButton":false,
        "showMobileButtons":false,
        "openGalleryItemsNewWindow":false,
        "showAttribution":true,
        "showLicenseInfo":true,
        "showGroupSort":false,
        "showFilterType":false,
        "galleryItemsPerPage":"9",
        "sourceCountry":"USA"
    }
}<commit_msg>config update<commit_after>{
  "configurationSettings":[
    {
      "category":"Content Options",
      "fields":[
        {
          "type":"group",
          "label":"Select a group"
        },
        {
          "type":"string",
          "fieldName":"siteTitle",
          "label":"Website banner title:",
          "tooltip":"The title of this template's website.",
          "placeHolder":"My Maps"
        },
        {
          "type":"paragraph",
          "value":"The text above will be displayed in the top banner if no banner image is set. Uses group title by default."
        },
        {
          "type":"string",
          "fieldName":"siteBannerImage",
          "tooltip":"URL for the navigation header logo image. If empty, Site Title text is used.",
          "placeHolder":"http://www.mysite.com/logo.png",
          "label":"Banner logo:"
        },
        {
          "type":"paragraph",
          "value":"Image to display in the top banner. Recommended height of 75 pixels."
        },
        {
          "type":"string",
          "fieldName":"addThisProfileId",
          "label":"AddThis.com profile ID:",
          "tooltip":"Account ID for AddThis.com.",
          "placeHolder":"xa-4f3bf72958320e9e"
        },
        {
          "type":"paragraph",
          "value":"Register an AddThis.com<\/a> account for social media button analytics."
        },
        {
          "type":"string",
          "fieldName":"sourceCountry",
          "label":"Locator Source Country",
          "tooltip":"Locator Source Country",
          "placeHolder":""
        },
        {
          "type":"paragraph",
          "value":"A value representing the country. Providing this value increases geocoding speed."
        }
      ]
    },
    {
      "category":"Home page Settings",
      "fields":[
        {
          "type":"string",
          "fieldName":"homeHeading",
          "label":"Homepage heading:",
          "tooltip":"Heading displayed within the main panel on the index page.",
          "placeHolder":""
        },
        {
          "type":"string",
          "fieldName":"homeSideHeading",
          "label":"Homepage side heading:",
          "tooltip":"Heading displayed within the side panel on the index page.",
          "placeHolder":""
        },
        {
          "type":"string",
          "fieldName":"homeSnippet",
          "label":"Homepage snippet:",
          "tooltip":"Brief text displayed on the index page.",
          "placeHolder":""
        },
        {
          "type":"string",
          "fieldName":"homeSideContent",
          "label":"Homepage side content:",
          "tooltip":"Content displayed within the side panel on the index page.",
          "placeHolder":""
        }
      ]
    },
    {
      "category":"Footer Settings",
      "fields":[
        {
          "type":"string",
          "fieldName":"footerHeading",
          "label":"Footer heading:",
          "tooltip":"Heading displayed in the footer.",
          "placeHolder":""
        },
        {
          "type":"string",
          "fieldName":"footerDescription",
          "label":"Footer content:",
          "tooltip":"Content description displayed in the footer.",
          "stringFieldOption":"textarea",
          "placeHolder":"Footer Content"
        },
        {
          "type":"string",
          "fieldName":"footerLogo",
          "tooltip":"Image to display in the footer. If empty, the group's thumbnail image is used.",
          "placeHolder":"http://www.mysite.com/logo.png",
          "label":"Footer logo:"
        },
        {
          "type":"paragraph",
          "value":"Image to display in the footer. If empty, the group's thumbnail image is used."
        },
        {
          "type":"string",
          "fieldName":"footerLogoUrl",
          "tooltip":"Link for the image in the footer. If empty, link to the group on ArcGIS Online is used.",
          "placeHolder":"http://www.mysite.com/",
          "label":"Footer logo link:"
        },
        {
          "type":"paragraph",
          "value":"Link for the image in the footer. If empty, link to the group on ArcGIS Online is used."
        }
      ]
    },
    {
      "category":"General Settings",
      "fields":[
        {
          "type":"string",
          "fieldName":"theme",
          "tooltip":"Color theme to use.",
          "label":"Color theme:",
          "options":[
            {
              "label":"Blue",
              "value":"blueTheme"
            },
            {
              "label":"Red",
              "value":"redTheme"
            },
            {
              "label":"Green",
              "value":"greenTheme"
            }
          ]
        },
        {
          "type":"string",
          "fieldName":"defaultLayout",
          "tooltip":"Whether to use grid view or list view as the default layout.",
          "label":"Default layout:",
          "options":[
            {
              "label":"Grid",
              "value":"grid"
            },
            {
              "label":"List",
              "value":"list"
            }
          ]
        },
        {
          "type":"string",
          "fieldName":"sortField",
          "tooltip":"Field to sort the group items by.",
          "label":"Group sort field:",
          "options":[
            {
              "label":"Modified Date",
              "value":"modified"
            },
            {
              "label":"Title",
              "value":"title"
            },
            {
              "label":"Type",
              "value":"type"
            },
            {
              "label":"Owner",
              "value":"owner"
            },
            {
              "label":"Average rating",
              "value":"avgRating"
            },
            {
              "label":"Number of ratings",
              "value":"numRatings"
            },
            {
              "label":"Number of comments",
              "value":"numComments"
            },
            {
              "label":"Number of views",
              "value":"numViews"
            }
          ]
        },
        {
          "type":"string",
          "fieldName":"sortOrder",
          "tooltip":"Order to sort the group field.",
          "label":"Group sort order:",
          "options":[
            {
              "label":"Descending",
              "value":"desc"
            },
            {
              "label":"Ascending",
              "value":"asc"
            }
          ]
        },
        {
          "type":"string",
          "fieldName":"filterType",
          "tooltip":"Only display this type of items",
          "label":"Only display this type of items:",
          "options":[
            {
              "label":"All",
              "value":""
            },
            {
              "label":"Maps",
              "value":"Maps"
            },
            {
              "label":"Layers",
              "value":"Layers"
            },
            {
              "label":"Applications",
              "value":"Applications"
            },
            {
              "label":"Tools",
              "value":"Tools"
            },
            {
              "label":"Datafiles",
              "value":"Datafiles"
            }
          ]
        },
        {
          "type":"string",
          "fieldName":"mapViewer",
          "tooltip":"Open maps with this viewer.",
          "label":"Open maps with:",
          "options":[
            {
              "label":"Simple Viewer",
              "value":"simple"
            },
            {
              "label":"Map Viewer",
              "value":"arcgis"
            },
            {
              "label":"ArcGIS Item Page",
              "value":"item_page"
            }
          ]
        },
        {
          "type":"string",
          "fieldName":"galleryItemsPerPage",
          "tooltip":"Gallery items to show per page.",
          "label":"Items per page:",
          "options":[
            {
              "label":"3",
              "value":"3"
            },
            {
              "label":"6",
              "value":"6"
            },
            {
              "label":"9",
              "value":"9"
            },
            {
              "label":"12",
              "value":"12"
            },
            {
              "label":"15",
              "value":"15"
            }
          ]
        },
        {
          "type":"string",
          "fieldName":"searchString",
          "tooltip":"Default search string for group query.",
          "placeHolder":"",
          "label":"Search string:"
        },
        {
          "type":"paragraph",
          "value":"Default search string for group query."
        }
      ]
    },
    {
      "category":"Options",
      "fields":[
        {
          "type":"boolean",
          "fieldName":"openGalleryItemsNewWindow",
          "label":"Open items in new window.",
          "tooltip":"Open group items in a new window."
        },
        {
          "type":"paragraph",
          "value":"Open group items in a new window."
        },
        {
          "type":"boolean",
          "fieldName":"showProfileUrl",
          "label":"Show profile link.",
          "tooltip":"Links usernames to ArcGIS Online profiles."
        },
        {
          "type":"paragraph",
          "value":"Links usernames to ArcGIS Online profiles."
        },
        {
          "type":"boolean",
          "fieldName":"showSocialButtons",
          "label":"Show social media buttons.",
          "tooltip":""
        },
        {
          "type":"paragraph",
          "value":"Show social media buttons."
        },
        {
          "type":"boolean",
          "fieldName":"showFooter",
          "label":"Show footer.",
          "tooltip":"Show footer on all pages."
        },
        {
          "type":"paragraph",
          "value":"Show footer on all pages."
        },
        {
          "type":"boolean",
          "fieldName":"showArcGISOnlineButton",
          "label":"Show Map Viewer button.",
          "tooltip":"Displays the button to open the webmap in ArcGIS Online Map Viewer."
        },
        {
          "type":"paragraph",
          "value":"Displays the button to open the webmap in ArcGIS Online Map Viewer."
        },
        {
          "type":"boolean",
          "fieldName":"showMobileButtons",
          "label":"Show mobile buttons.",
          "tooltip":"Displays a mobile button to open the webmap in ArcGIS mobile app and a button to download the app."
        },
        {
          "type":"paragraph",
          "value":"Displays a mobile button to open the webmap in ArcGIS mobile app and a button to download the app."
        },
        {
          "type":"boolean",
          "fieldName":"showAttribution",
          "label":"Show attribution.",
          "tooltip":"Displays credits on the map page."
        },
        {
          "type":"paragraph",
          "value":"Displays credits on the map page."
        },
        {
          "type":"boolean",
          "fieldName":"showLicenseInfo",
          "label":"Show constraints.",
          "tooltip":"Displays constraints on the map page."
        },
        {
          "type":"paragraph",
          "value":"Displays constraints on the map page."
        },
        {
          "type":"boolean",
          "fieldName":"showMoreInfo",
          "label":"Show more info links.",
          "tooltip":"Displays More information links to the ArcGIS Online item page."
        },
        {
          "type":"paragraph",
          "value":"Displays More information links to the ArcGIS Online item page."
        },
        {
          "type":"boolean",
          "fieldName":"showGroupSort",
          "label":"Show group sort bar",
          "tooltip":"Displays group sort bar on the home page."
        },
        {
          "type":"paragraph",
          "value":"Displays group sort bar on the home page."
        },
        {
          "type":"boolean",
          "fieldName":"showViews",
          "label":"Show Views",
          "tooltip":"Displays view counts for maps"
        },
        {
          "type":"paragraph",
          "value":"Displays view counts for maps."
        },
        {
          "type":"boolean",
          "fieldName":"showComments",
          "label":"Show comments",
          "tooltip":"Shows comments for items and allows items to be commented on"
        },
        {
          "type":"paragraph",
          "value":"Shows comments for items and allows items to be commented on."
        },
        {
          "type":"boolean",
          "fieldName":"showRatings",
          "label":"Show ratings",
          "tooltip":"Shows ratings for items and allows items to be rated"
        },
        {
          "type":"paragraph",
          "value":"Shows ratings for items and allows items to be rated."
        },
        {
          "type":"boolean",
          "fieldName":"showFilterType",
          "label":"Show Filter By Type",
          "tooltip":"Shows a list allowing users to filter items by type."
        },
        {
          "type":"paragraph",
          "value":"Shows a list allowing users to filter items by type."
        },
        {
          "type":"boolean",
          "fieldName":"openLayersInViewer",
          "label":"Open Layers in ArcGIS Map Viewer",
          "tooltip":"Opens layers in the map viewer instead of the layer's REST URL"
        },
        {
          "type":"paragraph",
          "value":"Opens layers in the map viewer instead of the layer's REST URL"
        }
      ]
    }
  ],
  "values":{
    "theme":"blueTheme",
    "siteTitle":"",
    "searchString":"",
    "homeHeading":"",
    "homeSideHeading":"",
    "homeSideContent":"",
    "homeSnippet":"",
    "addThisProfileId":"xa-4f3bf72958320e9e",
    "defaultLayout":"grid",
    "sortField":"modified",
    "sortOrder":"desc",
    "filterType":"",
    "mapViewer":"simple",
    "footerHeading":"",
    "footerDescription":"",
    "footerLogo":"",
    "footerLogoUrl":"",
    "openLayersInViewer":true,
    "showProfileUrl":true,
    "showSocialButtons":true,
    "showFooter":true,
    "showMoreInfo":false,
    "showComments":false,
    "showRatings":false,
    "showViews":false,
    "showArcGISOnlineButton":false,
    "showMobileButtons":false,
    "openGalleryItemsNewWindow":false,
    "showAttribution":true,
    "showLicenseInfo":true,
    "showGroupSort":false,
    "showFilterType":false,
    "galleryItemsPerPage":"9",
    "sourceCountry":"USA"
  }
}<|endoftext|>


<commit_before>// geo location of festival
Ti.App.location_maribor = {latitude:46.55964925,longitude:15.646033,latitudeDelta:0.013, longitudeDelta:0.013};

Ti.App.days = ["Ned","Pon","Tor","Sre","Čet","Pet","Sob","Ned"];

// stages used in multiple views
// data from:
// http://lent10.slovenija.net/index.php?eID=tx_mnmysql2json_Table&tx_mnmysql2json[action]=getTable&tx_mnmysql2json[tableName]=tx_cal_location&tx_mnmysql2json[fields]=uid,name,street,zip,city,longitude,latitude&tx_mnmysql2json[where]=deleted=0%20AND%20hidden=0%20AND%20sys_language_uid=0

stages = Array();
stages[1] = {"uid":"1","name":"SNG Maribor ","street":"SNG Maribor ","zip":"2000","city":"Maribor","longitude":"15.643866","latitude":"46.5597013"};
stages[2] = {"uid":"2","name":"Oder Rotovž","street":"Oder Rotovž","zip":"2000","city":"Maribor","longitude":"15.6454968","latitude":"46.5581373"};
stages[4] = {"uid":"4","name":"Jazzlent","street":"Jazzlent","zip":"2000","city":"Maribor","longitude":"15.6532024","latitude":"46.536221"};
stages[5] = {"uid":"5","name":"Večerov oder","street":"Večerov oder","zip":"2000","city":"Maribor","longitude":"15.6435441","latitude":"46.5566618"};
stages[6] = {"uid":"6","name":"Jurčkov oder","street":"Jurčkov oder","zip":"2000","city":"Maribor","longitude":"15.6532024","latitude":"46.536221"};
stages[7] = {"uid":"7","name":"Sodni stolp","street":"Sodni stolp","zip":"2000","city":"Maribor","longitude":"15.6410336","latitude":"46.5568684"};
stages[10] = {"uid":"10","name":"Naskov dvorec","street":"Zlati Lev","zip":"2000","city":"Maribor","longitude":"15.6363344","latitude":"46.558698"};
stages[11] = {"uid":"11","name":"Mladinin oder","street":"Mladinin oder","zip":"2000","city":"Maribor","longitude":"15.6415486","latitude":"46.5572815"};
stages[15] = {"uid":"15","name":"Glavni trg ","street":"Glavni trg ","zip":"2000","city":"Maribor","longitude":"15.6459971","latitude":"46.557332"};
stages[16] = {"uid":"16","name":"Grajski trg ","street":"Grajski trg ","zip":"2000","city":"Maribor","longitude":"15.6478955","latitude":"46.5599862"};
stages[17] = {"uid":"17","name":"Kavarna Kavajo ","street":"Kavarna Kavajo ","zip":"2000","city":"Maribor","longitude":"15.6456685","latitude":"46.5535631"};
stages[18] = {"uid":"18","name":"Klub KGB ","street":"Klub KGB ","zip":"2000","city":"Maribor","longitude":"15.641849","latitude":"46.5577537"};
stages[19] = {"uid":"19","name":"KMŠ oder","street":"KMŠ oder","zip":"2000","city":"Maribor","longitude":"15.6361842","latitude":"46.5580488"};
stages[20] = {"uid":"20","name":" Glavni oder na Dravi","street":"Glavni oder na Dravi","zip":"2000","city":"Maribor","longitude":"15.6532024","latitude":"46.536221"};
stages[23] = {"uid":"23","name":"Sinagoga","street":"Sinagoga","zip":"2000","city":"Maribor","longitude":"15.6477284","latitude":"46.5567356"};
stages[26] = {"uid":"26","name":"Mestni park","street":"Mestni park","zip":"2000","city":"Maribor","longitude":"15.6471276","latitude":"46.5657354"};
stages[27] = {"uid":"27","name":"Trg generala Maistra ","street":"Trg generala Maistra ","zip":"2000","city":"Maribor","longitude":"15.6490588","latitude":"46.561575"};
stages[28] = {"uid":"28","name":"Trg Svobode ","street":"Trg Svobode","zip":"2000","city":"Maribor","longitude":"15.6491661","latitude":"46.560557"};
stages[29] = {"uid":"29","name":"Dvorana Union","street":"Dvorana Union","zip":"2000","city":"Maribor","longitude":"15.6532024","latitude":"46.536221"};

// categories used in multipel views
// data from:
// http://lent10.slovenija.net/index.php?eID=tx_mnmysql2json_Table&tx_mnmysql2json[action]=getTable&tx_mnmysql2json[tableName]=tx_cal_category&tx_mnmysql2json[fields]=uid,title&tx_mnmysql2json[where]=deleted=0%20AND%20hidden=0%20AND%20sys_language_uid=0
categories = Array();
categories[1] = {"uid":"1","title":"Delavnice"};
categories[2] = {"uid":"2","title":"Razstava"};
categories[3] = {"uid":"3","title":"Koncert"};
categories[4] = {"uid":"4","title":"Stand-up"};
categories[5] = {"uid":"5","title":"Komedija"};
categories[6] = {"uid":"6","title":"Šport"};
categories[7] = {"uid":"7","title":"Ples"};
categories[8] = {"uid":"8","title":"Lutkovna predstava"};
categories[9] = {"uid":"9","title":"Gledališče"};
categories[10] = {"uid":"10","title":"Film"};
categories[11] = {"uid":"11","title":"Folklorni festival FOLKART"};
categories[12] = {"uid":"12","title":"Glasbeno-plesni projekt"};
categories[13] = {"uid":"13","title":"Literarni dan"};
categories[14] = {"uid":"14","title":"Muzikal"};
categories[15] = {"uid":"15","title":"Ulično gledališče"};
categories[16] = {"uid":"16","title":"Otroška in mladinska prireditev"};
categories[17] = {"uid":"17","title":"Ognjemet"};
categories[18] = {"uid":"18","title":"Ostalo"};
categories[19] = {"uid":"19","title":"Priporočamo"};
categories[39] = {"uid":"39","title":"Razprodano"};
<commit_msg>Fixed geo locations of stages.<commit_after>// geo location of festival
Ti.App.location_maribor = {latitude:46.55964925,longitude:15.646033,latitudeDelta:0.007, longitudeDelta:0.007};

Ti.App.days = ["Ned","Pon","Tor","Sre","Čet","Pet","Sob","Ned"];

// stages used in multiple views
// data from:
// http://lent11.slovenija.net/index.php?eID=tx_mnmysql2json_Table&tx_mnmysql2json[action]=getTable&tx_mnmysql2json[tableName]=tx_cal_location&tx_mnmysql2json[fields]=uid,name,street,zip,city,longitude,latitude&tx_mnmysql2json[where]=deleted=0%20AND%20hidden=0%20AND%20sys_language_uid=0

stages = Array();
stages[1] = {"uid":"1","name":"SNG Maribor","street":"SNG Maribor","zip":"2000","city":"Maribor","longitude":"15.643866","latitude":"46.5597013"};
stages[2] = {"uid":"2","name":"Oder Rotovž","street":"Oder Rotovž","zip":"2000","city":"Maribor","longitude":"15.6454968","latitude":"46.5581373"};
stages[4] = {"uid":"4","name":"Jazzlent","street":"Jazzlent","zip":"2000","city":"Maribor","longitude":"15.641999","latitude":"46.55754"};
stages[5] = {"uid":"5","name":"Večerov oder","street":"Večerov oder","zip":"2000","city":"Maribor","longitude":"15.6435441","latitude":"46.5566618"};
stages[6] = {"uid":"6","name":"Jurčkov oder","street":"Jurčkov oder","zip":"2000","city":"Maribor","longitude":"15.6453895","latitude":"46.5568831"};
stages[7] = {"uid":"7","name":"Sodni stolp","street":"Sodni stolp","zip":"2000","city":"Maribor","longitude":"15.6410336","latitude":"46.5568684"};
stages[10] = {"uid":"10","name":"Vetrinjski dvor","street":"Vetrinjski dvor","zip":"2000","city":"Maribor","longitude":"15.648286","latitude":"46.559734"};
stages[11] = {"uid":"11","name":"Mladinin oder","street":"Mladinin oder","zip":"2000","city":"Maribor","longitude":"15.6415486","latitude":"46.5572815"};
stages[15] = {"uid":"15","name":"Glavni trg ","street":"Glavni trg","zip":"2000","city":"Maribor","longitude":"15.645293","latitude":"46.55765"};
stages[16] = {"uid":"16","name":"Grajski trg ","street":"Grajski trg","zip":"2000","city":"Maribor","longitude":"15.6478955","latitude":"46.5599862"};
stages[17] = {"uid":"17","name":"Kavarna Kavajo ","street":"Kavarna Kavajo","zip":"2000","city":"Maribor","longitude":"15.6456685","latitude":"46.5535631"};
stages[18] = {"uid":"18","name":"Klub KGB","street":"Klub KGB","zip":"2000","city":"Maribor","longitude":"15.642686","latitude":"46.557532"};

// not correct geo location!
stages[19] = {"uid":"19","name":"KMŠ oder","street":"KMŠ oder","zip":"2000","city":"Maribor","longitude":"15.6361842","latitude":"46.5580488"};

stages[20] = {"uid":"20","name":"Glavni oder na Dravi","street":"Glavni oder na Dravi","zip":"2000","city":"Maribor","longitude":"15.6486511","latitude":"46.5563224"};
stages[23] = {"uid":"23","name":"Sinagoga","street":"Sinagoga","zip":"2000","city":"Maribor","longitude":"15.6477284","latitude":"46.5567356"};
stages[26] = {"uid":"26","name":"Mestni park","street":"Mestni park","zip":"2000","city":"Maribor","longitude":"15.6471276","latitude":"46.5657354"};
stages[27] = {"uid":"27","name":"Trg generala Maistra","street":"Trg generala Maistra","zip":"2000","city":"Maribor","longitude":"15.6492029","latitude":"46.5612573"};
stages[30] = {"uid":"30","name":"Ostala prizorišča","street":"","zip":"2000","city":"Maribor","longitude":"0","latitude":"0"};
stages[28] = {"uid":"28","name":"Trg Svobode","street":"Trg Svobode","zip":"2000","city":"Maribor","longitude":"15.6489726","latitude":"46.5608156"};
stages[29] = {"uid":"29","name":"Dvorana Union","street":"Dvorana Union","zip":"2000","city":"Maribor","longitude":"15.651183","latitude":"46.561088"};

// categories used in multipel views
// data from:
// http://lent11.slovenija.net/index.php?eID=tx_mnmysql2json_Table&tx_mnmysql2json[action]=getTable&tx_mnmysql2json[tableName]=tx_cal_category&tx_mnmysql2json[fields]=uid,title&tx_mnmysql2json[where]=deleted=0%20AND%20hidden=0%20AND%20sys_language_uid=0
categories = Array();
categories[1] = {"uid":"1","title":"Delavnice"};
categories[2] = {"uid":"2","title":"Razstava"};
categories[3] = {"uid":"3","title":"Koncert"};
categories[4] = {"uid":"4","title":"Stand-up"};
categories[5] = {"uid":"5","title":"Komedija"};
categories[6] = {"uid":"6","title":"Šport"};
categories[7] = {"uid":"7","title":"Ples"};
categories[8] = {"uid":"8","title":"Lutkovna predstava"};
categories[9] = {"uid":"9","title":"Gledališče"};
categories[10] = {"uid":"10","title":"Film"};
categories[11] = {"uid":"11","title":"Folklorni festival FOLKART"};
categories[12] = {"uid":"12","title":"Glasbeno-plesni projekt"};
categories[13] = {"uid":"13","title":"Literarni dan"};
categories[14] = {"uid":"14","title":"Muzikal"};
categories[15] = {"uid":"15","title":"Ulično gledališče"};
categories[16] = {"uid":"16","title":"Otroška in mladinska prireditev"};
categories[17] = {"uid":"17","title":"Ognjemet"};
categories[18] = {"uid":"18","title":"Ostalo"};
categories[19] = {"uid":"19","title":"Priporočamo"};
<|endoftext|>