<commit_before>define(["Tone/core/Tone", "Tone/core/Transport", "Tone/core/Master",
	"Tone/core/Types", "Tone/core/TimelineState", "Tone/signal/Signal"],
function(Tone){

	"use strict";

	/**
	 *  @class  Base class for sources. Sources have start/stop methods
	 *          and the ability to be synced to the
	 *          start/stop of Tone.Transport.
	 *
	 *  @constructor
	 *  @extends {Tone}
	 */
	Tone.Source = function(options){
		//Sources only have an output and no input
		Tone.call(this, 0, 1);

		options = this.defaultArg(options, Tone.Source.defaults);

		/**
		 * The volume of the output in decibels.
		 * @type {Decibels}
		 * @signal
		 * @example
		 * source.volume.value = -6;
		 */
		this.volume = new Tone.Signal({
			"param" : this.output.gain,
			"value" : options.volume,
			"units" : Tone.Type.Decibels
		});
		this._readOnly("volume");

		/**
		 * 	Keep track of the scheduled state.
		 *  @type {Tone.TimelineState}
		 *  @private
		 */
		this._state = new Tone.TimelineState(Tone.State.Stopped);

		//make the output explicitly stereo
		this.output.channelCount = 2;
		this.output.channelCountMode = "explicit";
	};

	Tone.extend(Tone.Source);

	/**
	 *  The default parameters
	 *  @static
	 *  @const
	 *  @type {Object}
	 */
	Tone.Source.defaults = {
		"volume" : 0,
	};

	/**
	 *  Returns the playback state of the source, either "started" or "stopped".
	 *  @type {Tone.State}
	 *  @readOnly
	 *  @memberOf Tone.Source#
	 *  @name state
	 */
	Object.defineProperty(Tone.Source.prototype, "state", {
		get : function(){
			return this._state.getStateAtTime(this.now());
		}
	});

	/**
	 *  Start the source at the specified time. If no time is given,
	 *  start the source now.
	 *  @param  {Time} [time=now] When the source should be started.
	 *  @returns {Tone.Source} this
	 *  @example
	 * source.start("+0.5"); //starts the source 0.5 seconds from now
	 */
	Tone.Source.prototype.start = function(time){
		time = this.toSeconds(time);
		if (this._state.getStateAtTime(time) !== Tone.State.Started || this.retrigger){
			this._state.setStateAtTime(Tone.State.Started, time);
			if (this._start){
				this._start.apply(this, arguments);
			}
		}
		return this;
	};

	/**
	 *  Stop the source at the specified time. If no time is given,
	 *  stop the source now.
	 *  @param  {Time} [time=now] When the source should be stopped.
	 *  @returns {Tone.Source} this
	 *  @example
	 * source.stop(); // stops the source immediately
	 */
	Tone.Source.prototype.stop = function(time){
		time = this.toSeconds(time);
		if (this._state.getStateAtTime(time) === Tone.State.Started){
			this._state.setStateAtTime(Tone.State.Stopped, time);
			if (this._stop){
				this._stop.apply(this, arguments);
			}
		}
		return this;
	};

	/**
	 *  Sync the source to the Transport so that when the transport
	 *  is started, this source is started and when the transport is stopped
	 *  or paused, so is the source.
	 *
	 *  @param {Time} [delay=0] Delay time before starting the source after the
	 *                               Transport has started.
	 *  @returns {Tone.Source} this
	 *  @example
	 * //sync the source to start 1 measure after the transport starts
	 * source.sync("1m");
	 * //start the transport. the source will start 1 measure later.
	 * Tone.Transport.start();
	 */
	Tone.Source.prototype.sync = function(delay){
		/*Tone.Transport.syncSource(this, delay);
		Tone.Transport.on("start", this.start.bind(this));
		Tone.Transport.on("stop", this.start.bind(this));*/
		return this;
	};

	/**
	 *  Unsync the source to the Transport. See Tone.Source.sync
	 *  @returns {Tone.Source} this
	 */
	Tone.Source.prototype.unsync = function(){
		// Tone.Transport.unsyncSource(this);
		return this;
	};

	/**
	 *	Clean up.
	 *  @return {Tone.Source} this
	 */
	Tone.Source.prototype.dispose = function(){
		this.stop();
		Tone.TimelineState.prototype.dispose.call(this);
		this._writable("volume");
		this.volume.dispose();
		this.volume = null;
		this._state.dispose();
		this._state = null;
	};

	return Tone.Source;
});<commit_msg>syncing to the Transport through events<commit_after>define(["Tone/core/Tone", "Tone/core/Transport", "Tone/core/Master",
	"Tone/core/Types", "Tone/core/TimelineState", "Tone/signal/Signal"],
function(Tone){

	"use strict";

	/**
	 *  @class  Base class for sources. Sources have start/stop methods
	 *          and the ability to be synced to the
	 *          start/stop of Tone.Transport.
	 *
	 *  @constructor
	 *  @extends {Tone}
	 */
	Tone.Source = function(options){
		//Sources only have an output and no input
		Tone.call(this, 0, 1);

		options = this.defaultArg(options, Tone.Source.defaults);

		/**
		 * The volume of the output in decibels.
		 * @type {Decibels}
		 * @signal
		 * @example
		 * source.volume.value = -6;
		 */
		this.volume = new Tone.Signal({
			"param" : this.output.gain,
			"value" : options.volume,
			"units" : Tone.Type.Decibels
		});
		this._readOnly("volume");

		/**
		 * 	Keep track of the scheduled state.
		 *  @type {Tone.TimelineState}
		 *  @private
		 */
		this._state = new Tone.TimelineState(Tone.State.Stopped);

		/**
		 *  The synced `start` callback function from the transport
		 *  @type {Function}
		 *  @private
		 */
		this._bindedStart = this.start.bind(this);

		/**
		 *  The synced `stop` callback function from the transport
		 *  @type {Function}
		 *  @private
		 */
		this._bindedStop = this.stop.bind(this);

		/**
		 *  If the source is synced to the transport or not
		 *  @type {Boolean}
		 *  @private
		 */
		this._isSynced = false;

		/**
		 *  The offset from the start of the Transport `start`
		 *  @type {Time}
		 *  @private
		 */
		this._startDelay = 0;

		//make the output explicitly stereo
		this.output.channelCount = 2;
		this.output.channelCountMode = "explicit";
	};

	Tone.extend(Tone.Source);

	/**
	 *  The default parameters
	 *  @static
	 *  @const
	 *  @type {Object}
	 */
	Tone.Source.defaults = {
		"volume" : 0,
	};

	/**
	 *  Returns the playback state of the source, either "started" or "stopped".
	 *  @type {Tone.State}
	 *  @readOnly
	 *  @memberOf Tone.Source#
	 *  @name state
	 */
	Object.defineProperty(Tone.Source.prototype, "state", {
		get : function(){
			return this._state.getStateAtTime(this.now());
		}
	});

	/**
	 *  Start the source at the specified time. If no time is given,
	 *  start the source now.
	 *  @param  {Time} [time=now] When the source should be started.
	 *  @returns {Tone.Source} this
	 *  @example
	 * source.start("+0.5"); //starts the source 0.5 seconds from now
	 */
	Tone.Source.prototype.start = function(time){
		time = this.toSeconds(time);
		if (this._isSynced){
			time += this.toSeconds(this._startDelay);
		}
		if (this._state.getStateAtTime(time) !== Tone.State.Started || this.retrigger){
			this._state.setStateAtTime(Tone.State.Started, time);
			if (this._start){
				this._start.apply(this, arguments);
			}
		}
		return this;
	};

	/**
	 *  Stop the source at the specified time. If no time is given,
	 *  stop the source now.
	 *  @param  {Time} [time=now] When the source should be stopped.
	 *  @returns {Tone.Source} this
	 *  @example
	 * source.stop(); // stops the source immediately
	 */
	Tone.Source.prototype.stop = function(time){
		time = this.toSeconds(time);
		if (this._state.getStateAtTime(time) === Tone.State.Started){
			this._state.setStateAtTime(Tone.State.Stopped, time);
			if (this._stop){
				this._stop.apply(this, arguments);
			}
		}
		return this;
	};

	/**
	 *  Sync the source to the Transport so that when the transport
	 *  is started, this source is started and when the transport is stopped
	 *  or paused, so is the source.
	 *
	 *  @param {Time} [delay=0] Delay time before starting the source after the
	 *                               Transport has started.
	 *  @returns {Tone.Source} this
	 *  @example
	 * //sync the source to start 1 measure after the transport starts
	 * source.sync("1m");
	 * //start the transport. the source will start 1 measure later.
	 * Tone.Transport.start();
	 */
	Tone.Source.prototype.sync = function(delay){
		this._isSynced = true;
		this._startDelay = this.defaultArg(delay, 0);
		Tone.Transport.on("start", this._bindedStart);
		Tone.Transport.on("stop pause", this._bindedStop);
		return this;
	};

	/**
	 *  Unsync the source to the Transport. See Tone.Source.sync
	 *  @returns {Tone.Source} this
	 */
	Tone.Source.prototype.unsync = function(){
		this._startDelay = 0;
		this._isSynced = false;
		Tone.Transport.off("start", this._bindedStart);
		Tone.Transport.off("stop pause", this._bindedStop);
		return this;
	};

	/**
	 *	Clean up.
	 *  @return {Tone.Source} this
	 */
	Tone.Source.prototype.dispose = function(){
		this.stop();
		Tone.prototype.dispose.call(this);
		this.unsync();
		this._writable("volume");
		this.volume.dispose();
		this.volume = null;
		this._state.dispose();
		this._state = null;
	};

	return Tone.Source;
});<|endoftext|>


<commit_before>/*jshint boss: true, evil: true */

// usage:
//   jsc ${envHome}/jsc.js -- ${lineCount} {option1:true,option2:false} ${envHome}
var envHome = '';

if (arguments.length > 2) {
    envHome = arguments[2].toString().replace(/\/env$/, '/');
}

load(envHome + "jshint.js");

if (typeof(JSHINT) === 'undefined') {
    print('jshint: Could not load jshint.js, tried "' + envHome + 'jshint.js".');
    quit();
}

var process = function(args) {
    var lineCount = parseInt(args[0], 10),
        opts  = (function(arg){
            switch (arg) {
            case undefined:
            case '':
                return {};
            default:
                return eval('(' + arg + ')');
            }
        })(args[1]);

    if (isNaN(lineCount)) {
        print('jshint: Must provide number of lines to read from stdin.');
        quit();
    }

    var input = readline();

    for (var i = 0; i < lineCount; ++i) {
        input += '\n' + readline();
    }

    // Now read the last line without appending \n
    input += readline();

    var results = [];

    if (!JSHINT(input, opts)) {
        var err;

        for (i = 0; err = JSHINT.errors[i]; i++) {
            results.push(err);
        }
    }

    print(JSON.stringify(results));
    quit();
};

process(arguments);
<commit_msg>Removed extra readline() that I accidentally left behind...<commit_after>/*jshint boss: true, evil: true */

// usage:
//   jsc ${envHome}/jsc.js -- ${lineCount} {option1:true,option2:false} ${envHome}
var envHome = '';

if (arguments.length > 2) {
    envHome = arguments[2].toString().replace(/\/env$/, '/');
}

load(envHome + "jshint.js");

if (typeof(JSHINT) === 'undefined') {
    print('jshint: Could not load jshint.js, tried "' + envHome + 'jshint.js".');
    quit();
}

var process = function(args) {
    var lineCount = parseInt(args[0], 10),
        opts  = (function(arg){
            switch (arg) {
            case undefined:
            case '':
                return {};
            default:
                return eval('(' + arg + ')');
            }
        })(args[1]);

    if (isNaN(lineCount)) {
        print('jshint: Must provide number of lines to read from stdin.');
        quit();
    }

    var input = readline();

    for (var i = 0; i < lineCount; ++i) {
        input += '\n' + readline();
    }

    var results = [];

    if (!JSHINT(input, opts)) {
        var err;

        for (i = 0; err = JSHINT.errors[i]; i++) {
            results.push(err);
        }
    }

    print(JSON.stringify(results));
    quit();
};

process(arguments);
<|endoftext|>


<commit_before>import { handleActions } from 'redux-actions'
// import createReducer from 'utils/createReducer'
import Firebase from 'firebase'
import constants from 'utils/constants'

let quote = {}

// ------------------------------------
// Constants
// ------------------------------------
const GET_QUOTE = 'GET_QUOTES'
const FETCH_STARTED = 'FETCH_STARTED'

// ------------------------------------
// Actions
// ------------------------------------
export const fetch = (id) => {
  const ref = new Firebase(constants.FIREBASE + '/quotes/' + id)
  return (dispatch) => {
    ref.on('value', snapshot => dispatch({
      type: GET_QUOTE,
      payload: dataFromSnapshot(snapshot)
    }))
  }
}

export const getQuote = (id) => {
  return (dispatch) => {
    dispatch({ type: FETCH_STARTED })
    dispatch(fetch(id))
  }
}

export const clearQuote = () => {
  return {}
}

function dataFromSnapshot (snapshot) {
  let data = snapshot.val()
  return data
}

export const actions = {
  fetch,
  getQuote,
  clearQuote
}

// ------------------------------------
// Reducer
// ------------------------------------
export default handleActions({
  [GET_QUOTE]: (state, { payload }) => payload
}, quote)
<commit_msg>chore (clear action)<commit_after>import { handleActions } from 'redux-actions'
// import createReducer from 'utils/createReducer'
import Firebase from 'firebase'
import constants from 'utils/constants'

let quote = {}

// ------------------------------------
// Constants
// ------------------------------------
const GET_QUOTE = 'GET_QUOTES'
const CLEAR_QUOTE = 'CLEAR_QUOTE'
const FETCH_STARTED = 'FETCH_STARTED'

// ------------------------------------
// Actions
// ------------------------------------
export const fetch = (id) => {
  const ref = new Firebase(constants.FIREBASE + '/quotes/' + id)
  return (dispatch) => {
    ref.on('value', snapshot => dispatch({
      type: GET_QUOTE,
      payload: dataFromSnapshot(snapshot)
    }))
  }
}

export const getQuote = (id) => {
  return (dispatch) => {
    dispatch({ type: FETCH_STARTED })
    dispatch(fetch(id))
  }
}

export const clearQuote = () => {
  return (dispatch) => {
    dispatch({
      type: CLEAR_QUOTE,
      payload: {}
    })
  }
}

function dataFromSnapshot (snapshot) {
  let data = snapshot.val()
  return data
}

export const actions = {
  fetch,
  getQuote,
  clearQuote
}

// ------------------------------------
// Reducer
// ------------------------------------
export default handleActions({
  [GET_QUOTE]: (state, { payload }) => payload,
  [CLEAR_QUOTE]: (state, { payload }) => payload
}, quote)
<|endoftext|>


<commit_before>/**
 * mSupply Mobile
 * Sustainable Solutions (NZ) Ltd. 2019
 */

/**
 * Method using a factory pattern variant to get a reducer
 * for a particular page or page style.
 *
 * For a new page - create a constant object with the
 * methods from reducerMethods which are composed to create
 * a reducer. Add to PAGE_REDUCERS.
 *
 * Each key value pair in a reducer object should be in the form
 * action type: reducer function, returning a new state object
 *
 */

import {
  filterData,
  focusNextCell,
  selectRow,
  deselectRow,
  deselectAll,
  focusCell,
  sortData,
  openBasicModal,
  closeBasicModal,
  addMasterListItems,
  addItem,
  editTheirRef,
  editComment,
  deleteRecordsById,
  refreshData,
  createAutomaticOrder,
  hideOverStocked,
  showOverStocked,
  editField,
  selectAll,
  hideStockOut,
  showStockOut,
  selectItems,
  editName,
} from './reducerMethods';

/**
 * Used for actions that should be in all pages using a data table.
 */
const BASE_TABLE_PAGE_REDUCER = {
  focusNextCell,
  focusCell,
  sortData,
};

const customerInvoice = {
  ...BASE_TABLE_PAGE_REDUCER,
  filterData,
  editField,
  selectRow,
  deselectRow,
  deselectAll,
  openBasicModal,
  closeBasicModal,
  addMasterListItems,
  addItem,
  editTheirRef,
  editComment,
  deleteRecordsById,
  refreshData,
};

const customerInvoices = {
  ...BASE_TABLE_PAGE_REDUCER,
  filterData,
  selectRow,
  deselectRow,
  deselectAll,
  openBasicModal,
  closeBasicModal,
  deleteRecordsById,
};

const supplierInvoice = {
  ...BASE_TABLE_PAGE_REDUCER,
  filterData,
  selectRow,
  deselectRow,
  deselectAll,
  closeBasicModal,
  openBasicModal,
  editTheirRef,
  editComment,
  refreshData,
  addItem,
  editField,
  deleteRecordsById,
};

const supplierRequisition = {
  ...BASE_TABLE_PAGE_REDUCER,
  filterData,
  selectRow,
  deselectRow,
  deselectAll,
  openBasicModal,
  closeBasicModal,
  editTheirRef,
  editComment,
  refreshData,
  addMasterListItems,
  addItem,
  createAutomaticOrder,
  hideOverStocked,
  showOverStocked,
  editField,
  deleteRecordsById,
};

const programSupplierRequisition = {
  ...BASE_TABLE_PAGE_REDUCER,
  filterData,
  selectRow,
  deselectRow,
  deselectAll,
  openBasicModal,
  closeBasicModal,
  editTheirRef,
  editComment,
  refreshData,
  addMasterListItems,
  addItem,
  createAutomaticOrder,
  hideOverStocked,
  showOverStocked,
  editField,
};

const supplierRequisitions = {
  sortData,
  filterData,
  selectRow,
  deselectRow,
  openBasicModal,
  closeBasicModal,
  refreshData,
};

const stocktakes = {
  openBasicModal,
  closeBasicModal,
  filterData,
  selectRow,
  deselectAll,
  deselectRow,
  sortData,
};

const stocktakeManager = {
  selectRow,
  deselectAll,
  deselectRow,
  sortData,
  filterData,
  selectAll,
  hideStockOut,
  showStockOut,
  selectItems,
  editName,
};

const PAGE_REDUCERS = {
  customerInvoice,
  customerInvoices,
  supplierInvoice,
  supplierRequisitions,
  supplierRequisition,
  programSupplierRequisition,
  stocktakes,
  stocktakeManager,
};

const getReducer = page => {
  const reducer = PAGE_REDUCERS[page];
  return (state, action) => {
    const { type } = action;
    if (!reducer[type]) return state;
    return reducer[type](state, action);
  };
};

export default getReducer;
<commit_msg>Add stocktake editor initial reducer<commit_after>/**
 * mSupply Mobile
 * Sustainable Solutions (NZ) Ltd. 2019
 */

/**
 * Method using a factory pattern variant to get a reducer
 * for a particular page or page style.
 *
 * For a new page - create a constant object with the
 * methods from reducerMethods which are composed to create
 * a reducer. Add to PAGE_REDUCERS.
 *
 * Each key value pair in a reducer object should be in the form
 * action type: reducer function, returning a new state object
 *
 */

import {
  filterData,
  focusNextCell,
  selectRow,
  deselectRow,
  deselectAll,
  focusCell,
  sortData,
  openBasicModal,
  closeBasicModal,
  addMasterListItems,
  addItem,
  editTheirRef,
  editComment,
  deleteRecordsById,
  refreshData,
  createAutomaticOrder,
  hideOverStocked,
  showOverStocked,
  editField,
  selectAll,
  hideStockOut,
  showStockOut,
  selectItems,
  editName,
} from './reducerMethods';

/**
 * Used for actions that should be in all pages using a data table.
 */
const BASE_TABLE_PAGE_REDUCER = {
  focusNextCell,
  focusCell,
  sortData,
};

const customerInvoice = {
  ...BASE_TABLE_PAGE_REDUCER,
  filterData,
  editField,
  selectRow,
  deselectRow,
  deselectAll,
  openBasicModal,
  closeBasicModal,
  addMasterListItems,
  addItem,
  editTheirRef,
  editComment,
  deleteRecordsById,
  refreshData,
};

const customerInvoices = {
  ...BASE_TABLE_PAGE_REDUCER,
  filterData,
  selectRow,
  deselectRow,
  deselectAll,
  openBasicModal,
  closeBasicModal,
  deleteRecordsById,
};

const supplierInvoice = {
  ...BASE_TABLE_PAGE_REDUCER,
  filterData,
  selectRow,
  deselectRow,
  deselectAll,
  closeBasicModal,
  openBasicModal,
  editTheirRef,
  editComment,
  refreshData,
  addItem,
  editField,
  deleteRecordsById,
};

const supplierRequisition = {
  ...BASE_TABLE_PAGE_REDUCER,
  filterData,
  selectRow,
  deselectRow,
  deselectAll,
  openBasicModal,
  closeBasicModal,
  editTheirRef,
  editComment,
  refreshData,
  addMasterListItems,
  addItem,
  createAutomaticOrder,
  hideOverStocked,
  showOverStocked,
  editField,
  deleteRecordsById,
};

const programSupplierRequisition = {
  ...BASE_TABLE_PAGE_REDUCER,
  filterData,
  selectRow,
  deselectRow,
  deselectAll,
  openBasicModal,
  closeBasicModal,
  editTheirRef,
  editComment,
  refreshData,
  addMasterListItems,
  addItem,
  createAutomaticOrder,
  hideOverStocked,
  showOverStocked,
  editField,
};

const supplierRequisitions = {
  sortData,
  filterData,
  selectRow,
  deselectRow,
  openBasicModal,
  closeBasicModal,
  refreshData,
};

const stocktakes = {
  openBasicModal,
  closeBasicModal,
  filterData,
  selectRow,
  deselectAll,
  deselectRow,
  sortData,
};

const stocktakeManager = {
  selectRow,
  deselectAll,
  deselectRow,
  sortData,
  filterData,
  selectAll,
  hideStockOut,
  showStockOut,
  selectItems,
  editName,
};

const stocktakeEditor = {
  ...BASE_TABLE_PAGE_REDUCER,
  sortData,
  filterData,
  editComment,
};

const PAGE_REDUCERS = {
  customerInvoice,
  customerInvoices,
  supplierInvoice,
  supplierRequisitions,
  supplierRequisition,
  programSupplierRequisition,
  stocktakes,
  stocktakeManager,
  stocktakeEditor,
};

const getReducer = page => {
  const reducer = PAGE_REDUCERS[page];
  return (state, action) => {
    const { type } = action;
    if (!reducer[type]) return state;
    return reducer[type](state, action);
  };
};

export default getReducer;
<|endoftext|>


<commit_before>/*global define*/
define([
       '../Core/Color',
       '../Core/defined',
       '../Core/defineProperties',
       '../ThirdParty/jsep'
    ], function(
        Color,
        defined,
        defineProperties,
        jsep) {
    "use strict";

    /**
     * DOC_TBA
     */
    function Expression(styleEngine, expression) {
        this._styleEngine = styleEngine;

        var ast = jsep(expression);
        console.log(ast);

        this._runtimeAst = createRuntimeAst(this, ast);
        console.log(this._runtimeAst);
    }

    defineProperties(Expression.prototype, {
    });

    Expression.prototype.evaluate = function(feature) {
        return this._runtimeAst.evaluate(feature);
    };

    function Node(value, left, right) {
        this._value = value;
        this._left = left;
        this._right = right;
        this.evaluate = undefined;

        setEvaluateFunction(this);
    }

    function createRuntimeAst(expression, ast) {
        var node;
        var op, val;

        if (ast.type === 'Literal') {
            node = new Node(ast.value);
        } else if (ast.type === 'CallExpression') {
            var call = ast.callee.name;
            var args = ast.arguments;
            if (call === 'color') {
                val = Color.fromCssColorString(args[0].value);
                if (defined(val)) {
                    node = new Node(val);
                }
            } else if (call === 'rgb') {
                val = Color.fromBytes(args[0].value, args[1].value, args[2].value);
                if (defined(val)) {
                    node = new Node(val);
                }
            } else if (call === 'hsl') {
                val = Color.fromHsl(args[0].value, args[1].value, args[2].value);
                if (defined(val)) {
                    node = new Node(val);
                }
            }
        } else if (ast.type === 'UnaryExpression') {
            op = ast.operator;
            var child = createRuntimeAst(expression, ast.argument);
            if (op === '!' || op === '-') {
                node = new Node(op, child);
            }
        } else if (ast.type === 'BinaryExpression') {
            op = ast.operator;
            var left = createRuntimeAst(expression, ast.left);
            var right = createRuntimeAst(expression, ast.right);
            if (op === '+' || op === '-' || op === '*' ||
                op === '/' || op === '%' || op === '===' ||
                op === '!==') {
                node = new Node(op, left, right);
            }
        }

        return node;
    }

    function setEvaluateFunction(node) {
        if (defined(node._right)){
            if (node._value === '+') {
                node.evaluate = node._evaluatePlus;
            } else if (node._value === '-') {
                node.evaluate = node._evaluateMinus;
            } else if (node._value === '*') {
                node.evaluate = node._evaluateTimes;
            } else if (node._value === '/') {
                node.evaluate = node._evaluateDivide;
            } else if (node._value === '%') {
                node.evaluate = node._evaluateMod;
            } else if (node._value === '===') {
                node.evaluate = node._evaluateEquals;
            } else if (node._value === '!==') {
                node.evaluate = node._evaluateNotEquals;
            }
        } else if (defined(node._left)) {
            if (node._value === '!') {
                node.evaluate = node._evaluateNot;
            } else if (node._value === '-') {
                node.evaluate = node._evaluateNegative;
            }
        } else {
            node.evaluate = node._evaluateLiteral;
        }
    }

    Node.prototype._evaluateLiteral = function(feature) {
        return this._value;
    };

    Node.prototype._evaluateNot = function(feature) {
        return !(this._left.evaluate(feature));
    };

    Node.prototype._evaluateNegative = function(feature) {
        return -(this._left.evaluate(feature));
    };

    Node.prototype._evaluatePlus = function(feature) {
        return this._left.evaluate(feature) + this._right.evaluate(feature);
    };

    Node.prototype._evaluateMinus = function(feature) {
        return this._left.evaluate(feature) - this._right.evaluate(feature);
    };

    Node.prototype._evaluateTimes = function(feature) {
        return this._left.evaluate(feature) * this._right.evaluate(feature);
    };

    Node.prototype._evaluateDivide = function(feature) {
        return this._left.evaluate(feature) / this._right.evaluate(feature);
    };

    Node.prototype._evaluateMod = function(feature) {
        return this._left.evaluate(feature) % this._right.evaluate(feature);
    };

    Node.prototype._evaluateEquals = function(feature) {
        return this._left.evaluate(feature) === this._right.evaluate(feature);
    };

    Node.prototype._evaluateNotEquals = function(feature) {
        return this._left.evaluate(feature) !== this._right.evaluate(feature);
    };

    return Expression;
});
<commit_msg>Style fixes<commit_after>/*global define*/
define([
       '../Core/Color',
       '../Core/defined',
       '../Core/defineProperties',
       '../ThirdParty/jsep'
    ], function(
        Color,
        defined,
        defineProperties,
        jsep) {
    "use strict";

    /**
     * DOC_TBA
     */
    function Expression(styleEngine, expression) {
        this._styleEngine = styleEngine;

        var ast = jsep(expression);
        console.log(ast);

        this._runtimeAst = createRuntimeAst(this, ast);
        console.log(this._runtimeAst);
    }

    defineProperties(Expression.prototype, {
    });

    Expression.prototype.evaluate = function(feature) {
        return this._runtimeAst.evaluate(feature);
    };

    function Node(value, left, right) {
        this._value = value;
        this._left = left;
        this._right = right;
        this.evaluate = undefined;

        setEvaluateFunction(this);
    }

    function createRuntimeAst(expression, ast) {
        var node;
        var op;
        var val;

        if (ast.type === 'Literal') {
            node = new Node(ast.value);
        } else if (ast.type === 'CallExpression') {
            var call = ast.callee.name;
            var args = ast.arguments;
            if (call === 'color') {
                val = Color.fromCssColorString(args[0].value);
                if (defined(val)) {
                    node = new Node(val);
                }
            } else if (call === 'rgb') {
                val = Color.fromBytes(args[0].value, args[1].value, args[2].value);
                if (defined(val)) {
                    node = new Node(val);
                }
            } else if (call === 'hsl') {
                val = Color.fromHsl(args[0].value, args[1].value, args[2].value);
                if (defined(val)) {
                    node = new Node(val);
                }
            }
        } else if (ast.type === 'UnaryExpression') {
            op = ast.operator;
            var child = createRuntimeAst(expression, ast.argument);
            if (op === '!' || op === '-') {
                node = new Node(op, child);
            }
        } else if (ast.type === 'BinaryExpression') {
            op = ast.operator;
            var left = createRuntimeAst(expression, ast.left);
            var right = createRuntimeAst(expression, ast.right);
            if (op === '+' || op === '-' || op === '*' ||
                op === '/' || op === '%' || op === '===' ||
                op === '!==') {
                node = new Node(op, left, right);
            }
        }

        return node;
    }

    function setEvaluateFunction(node) {
        if (defined(node._right)) {
            if (node._value === '+') {
                node.evaluate = node._evaluatePlus;
            } else if (node._value === '-') {
                node.evaluate = node._evaluateMinus;
            } else if (node._value === '*') {
                node.evaluate = node._evaluateTimes;
            } else if (node._value === '/') {
                node.evaluate = node._evaluateDivide;
            } else if (node._value === '%') {
                node.evaluate = node._evaluateMod;
            } else if (node._value === '===') {
                node.evaluate = node._evaluateEquals;
            } else if (node._value === '!==') {
                node.evaluate = node._evaluateNotEquals;
            }
        } else if (defined(node._left)) {
            if (node._value === '!') {
                node.evaluate = node._evaluateNot;
            } else if (node._value === '-') {
                node.evaluate = node._evaluateNegative;
            }
        } else {
            node.evaluate = node._evaluateLiteral;
        }
    }

    Node.prototype._evaluateLiteral = function(feature) {
        return this._value;
    };

    Node.prototype._evaluateNot = function(feature) {
        return !(this._left.evaluate(feature));
    };

    Node.prototype._evaluateNegative = function(feature) {
        return -(this._left.evaluate(feature));
    };

    Node.prototype._evaluatePlus = function(feature) {
        return this._left.evaluate(feature) + this._right.evaluate(feature);
    };

    Node.prototype._evaluateMinus = function(feature) {
        return this._left.evaluate(feature) - this._right.evaluate(feature);
    };

    Node.prototype._evaluateTimes = function(feature) {
        return this._left.evaluate(feature) * this._right.evaluate(feature);
    };

    Node.prototype._evaluateDivide = function(feature) {
        return this._left.evaluate(feature) / this._right.evaluate(feature);
    };

    Node.prototype._evaluateMod = function(feature) {
        return this._left.evaluate(feature) % this._right.evaluate(feature);
    };

    Node.prototype._evaluateEquals = function(feature) {
        return this._left.evaluate(feature) === this._right.evaluate(feature);
    };

    Node.prototype._evaluateNotEquals = function(feature) {
        return this._left.evaluate(feature) !== this._right.evaluate(feature);
    };

    return Expression;
});
<|endoftext|>


<commit_before><commit_msg>fix disable header<commit_after><|endoftext|>


<commit_before>import * as ko from 'knockout';
import { Todo } from './todo.model.js';

const DISPLAY_MODES = {
    get all() {
        return 'all';
    },

    get active() {
        return 'active';
    },

    get completed() {
        return 'completed';
    }
}

export class ViewModel {
    constructor() {
        this.todoList = ko.observableArray();
        this.inputText = ko.observable('');
        this.itemsLeftCount = ko.computed(() => this.todoList().filter((element) => !element.checked()).length);
        this.itemsLeftText = ko.computed(this.getItemsLeftText, this);
        this.currentDisplayMode = ko.observable(DISPLAY_MODES.all);
        this.displayedListOfTodos = ko.computed(this.getDisplayedTodos, this);
    }

    toggleChecking(todo) {
        todo.checked(!todo.checked());
    }

    handleKeyUp(todo, event) {
        const ENTER_KEY_CODE = 13;
        const ESCAPE_KEY_CODE = 27;

        if (event.keyCode === ENTER_KEY_CODE && this.inputText()) {
            const text = this.inputText();
            const todo = new Todo(text);
            this.todoList.unshift(todo);
            this.inputText('');
        }

        if (event.keyCode === ESCAPE_KEY_CODE) {
            this.inputText('');
        }
    }

    getItemsLeftText() {
        let count = this.itemsLeftCount();
        const ext = count === 1 ? '' : 's';

        return `${count} item${ext} left`;
    }

    getDisplayedTodos() {
        const current = this.currentDisplayMode();

        switch (current) {
            case DISPLAY_MODES.all:
                return this.todoList();
            case DISPLAY_MODES.active:
                return this.todoList().filter((todo) => !todo.checked());
            case DISPLAY_MODES.completed:
                return this.todoList().filter((todo) => todo.checked());
            default:
                return this.todoList();
        }
    }

    switchModeToAll() {
        this.currentDisplayMode(DISPLAY_MODES.all);
    }

    switchModeToActive() {
        this.currentDisplayMode(DISPLAY_MODES.active);
    }

    switchModeToCompleted() {
        this.currentDisplayMode(DISPLAY_MODES.completed);
    }
}
<commit_msg>Added fall-through solution to prevent duplicating of case statements<commit_after>import * as ko from 'knockout';
import { Todo } from './todo.model.js';

const DISPLAY_MODES = {
    get all() {
        return 'all';
    },

    get active() {
        return 'active';
    },

    get completed() {
        return 'completed';
    }
}

export class ViewModel {
    constructor() {
        this.todoList = ko.observableArray();
        this.inputText = ko.observable('');
        this.itemsLeftCount = ko.computed(() => this.todoList().filter((element) => !element.checked()).length);
        this.itemsLeftText = ko.computed(this.getItemsLeftText, this);
        this.currentDisplayMode = ko.observable(DISPLAY_MODES.all);
        this.displayedListOfTodos = ko.computed(this.getDisplayedTodos, this);
    }

    toggleChecking(todo) {
        todo.checked(!todo.checked());
    }

    handleKeyUp(todo, event) {
        const ENTER_KEY_CODE = 13;
        const ESCAPE_KEY_CODE = 27;

        if (event.keyCode === ENTER_KEY_CODE && this.inputText()) {
            const text = this.inputText();
            const todo = new Todo(text);
            this.todoList.unshift(todo);
            this.inputText('');
        }

        if (event.keyCode === ESCAPE_KEY_CODE) {
            this.inputText('');
        }
    }

    getItemsLeftText() {
        let count = this.itemsLeftCount();
        const ext = count === 1 ? '' : 's';

        return `${count} item${ext} left`;
    }

    getDisplayedTodos() {
        const current = this.currentDisplayMode();
        const todoItems = this.todoList();

        switch (current) {
            case DISPLAY_MODES.active:
                return todoItems.filter((todo) => !todo.checked());
            case DISPLAY_MODES.completed:
                return todoItems.filter((todo) => todo.checked());
            case DISPLAY_MODES.all:
            default:
                return todoItems;
        }
    }

    switchModeToAll() {
        this.currentDisplayMode(DISPLAY_MODES.all);
    }

    switchModeToActive() {
        this.currentDisplayMode(DISPLAY_MODES.active);
    }

    switchModeToCompleted() {
        this.currentDisplayMode(DISPLAY_MODES.completed);
    }
}
<|endoftext|>


<commit_before>MLS.contentFilter = (function () {

    var $cf = $jQ('#content-filter'),
        hashLoaded = false,
        options = {
            endpoint: null,
            callback: function () {},
            container: null
        },

        pub = {

            /*============================
            =            Init            =
            ============================*/

            init: function (o) {
                options = $jQ.extend(options, o);

                // endpoint = endpoint ? endpoint : (ep || MLS.ajax.endpoints.PRODUCT_LISTING);
                // callback = c || contentGrid.reInit;

                $cf = $jQ('#content-filter');
                var $collapsible = $cf.find('.collapsible'),
                    $facets = $cf.find('.facet');

                // collapse all but first dimension
                $collapsible.find('.facet-list').slideToggle('slow');

                // load content on load (if hash)
                !hashLoaded && pub.loadFromHash();
                hashLoaded = true;

                /*==========  bind click events  ==========*/

                // dimension (expansion/collapse)
                $collapsible.find('.dimension-header').on('click', pub.dimensionClick);

                $facets.on('click', pub.facetClick);
                $jQ('.filter-panels li').on('click', pub.sort); /* mobile option */

                // remove filter
                $jQ('#filter-selections').find('a').on('click', pub.removeFilter);

                // compability services
                $jQ('.compatibility-filter').children('select').on('change', pub.compabilitySelect);

                // type ahead (searc)
                $jQ('.compatibility-filter').children('input.type-ahead').on('keyup', pub.compabilitySearch);

                // sort links
                $jQ('#sort-options').find('li').on('click', pub.sort);
                $jQ('#mobile-sort-filter li.sort-option').on('click', pub.sort);
            },
            /*-----  End of Init  ------*/

            /*================================================
            =            Finalize (unbind events)            =
            =================================================*/

            finalize: function () {
                $cf = $jQ('#content-filter');
                var $collapsible = $cf.find('.collapsible'),
                    $facets = $cf.find('.facet');

                 /*==========  bind click events  ==========*/

                // dimension (expansion/collapse)
                $collapsible.find('.dimension-header').unbind('click', pub.dimensionClick);

                $facets.unbind('click', pub.facetClick);
                $jQ('.filter-panels li').unbind('click', pub.sort); /* mobile option */

                // remove filter
                $jQ('#clear-selections').find('li').find('a').unbind('click', pub.removeFilter);

                // compability services
                $jQ('.compatibility-filter').children('select').unbind('change', pub.compabilitySelect);

                // type ahead (searc)
                $jQ('.compatibility-filter').children('input.type-ahead').unbind('keyup', pub.compabilitySearch);

                 // sort links
                $jQ('#sort-options').find('li').on('click', pub.sort);
                $jQ('#mobile-sort-filter li.sort-option').on('click', pub.sort);

            },

            /*-----  End of Finalize (unbind events)  ------*/

            /*============================================
            =            Reinit: on ajax load            =
            ============================================*/

            reInit: function () {
                MLS.contentFilter.finalize();
                MLS.contentFilter.init();

            },

            /*-----  End of Reinit: on ajax load  ------*/

            /*======================================
            =            Load from Hash            =
            ======================================*/
            // If the url contains paramaters in the hash when it
            // is first loaded then request content

            loadFromHash: function () {

                var hash = window.location.hash,
                params = {};

                if (hash !== '') { // we have a hash
                    params = MLS.util.getParamsFromUrl(hash);

                    if (!$jQ.isEmptyObject(params)) {
                        pub.processRequest(params);
                    }

                }

            },

            /*-----  End of Load from Hash  ------*/

            /*=======================================
            =            Listing sorting            =
            =======================================*/

            sort: function (e) {
                e.preventDefault();
                var $elem = $jQ(this),
                    href = $elem.find('a').attr('href'),
                    params = MLS.util.getParamsFromUrl(href);

                pub.processRequest(params);
            },

            /*-----  End of Listing sorting  ------*/

            /*=======================================
            =            dimension click            =
            =======================================*/

            dimensionClick: function (e) {
                e.preventDefault();
                $jQ(this).toggleClass('active').promise().done(function () {
                    $jQ(this).next().slideToggle('slow');
                });
            },

            /*-----  End of dimension click  ------*/

            /*==========================================
            =            Compability search            =
            ==========================================*/

            compabilitySearch: function (e) {
                var $elem = $jQ(this),
                    params = {search: $elem.val()};
                if (e.keyCode === 13) {
                    pub.processRequest(params);
                }
            },

            compabilitySelect: function () {
                var $elem = $jQ(this),
                    href = $elem.find('option:selected').attr('value'),
                    params;

                // update hash
                window.location.hash = MLS.util.setHash(href);

                params = MLS.util.getParamsFromUrl(href);
                pub.processRequest(params);
            },

            facetClick: function (e) {
                e.preventDefault();

                var $elem = $jQ(this),//e.currentTarget,
                    href = $elem.find('a').attr('href'),
                    params;

                // update hash
                window.location.hash = MLS.util.setHash(href);

                params = MLS.util.getParamsFromUrl(href);
                pub.processRequest(params);
            },

            /*-----  End of Compability search  ------*/

            /*=============================================
            =            Remove selected facet            =
            =============================================*/

            removeFilter: function (e) {
                e.preventDefault();
                var $elem = $jQ(this),
                    href = $elem.attr('href'),
                    params = MLS.util.getParamsFromUrl(href);
                window.location.hash = MLS.util.setHash(href);
                pub.processRequest(params);
            },

            /*-----  End of remove facet  ------*/

            /*=======================================
            =            process request            =
            =======================================*/

            processRequest: function (params) {

                // make request
                MLS.ajax.sendRequest(
                    options.endpoint,
                    params,
                    pub.updateResults
                );
            },

            /*-----  End of process request  ------*/

            /*===================================
            =            update grid            =
            ===================================*/

            updateResults : function (data) {
                if (data.hasOwnProperty('success')) {

                    // update results...
                    options.container.html(data.success.responseHTML);

                    // ... and result count ...
                    $jQ('#content-filter-count').find('strong').text(data.success.count);

                    // ... and filters
                    $cf.replaceWith(data.success.filtersHTML);

                    // ... and even the sort by
                    $jQ('#sort-options').find('ul').replaceWith(data.success.sortByHTML);

                    options.callback();
                    pub.reInit();

                } else {
                    options.container.html(data.error.responseHTML);
                }

            },

            /*-----  End of update grid  ------*/

        };

    return pub;
}());

<commit_msg>set hash when sorting list<commit_after>MLS.contentFilter = (function () {

    var $cf = $jQ('#content-filter'),
        hashLoaded = false,
        options = {
            endpoint: null,
            callback: function () {},
            container: null
        },

        pub = {

            /*============================
            =            Init            =
            ============================*/

            init: function (o) {
                options = $jQ.extend(options, o);

                // endpoint = endpoint ? endpoint : (ep || MLS.ajax.endpoints.PRODUCT_LISTING);
                // callback = c || contentGrid.reInit;

                $cf = $jQ('#content-filter');
                var $collapsible = $cf.find('.collapsible'),
                    $facets = $cf.find('.facet');

                // collapse all but first dimension
                $collapsible.find('.facet-list').slideToggle('slow');

                // load content on load (if hash)
                !hashLoaded && pub.loadFromHash();
                hashLoaded = true;

                /*==========  bind click events  ==========*/

                // dimension (expansion/collapse)
                $collapsible.find('.dimension-header').on('click', pub.dimensionClick);

                $facets.on('click', pub.facetClick);
                $jQ('.filter-panels li').on('click', pub.sort); /* mobile option */

                // remove filter
                $jQ('#filter-selections').find('a').on('click', pub.removeFilter);

                // compability services
                $jQ('.compatibility-filter').children('select').on('change', pub.compabilitySelect);

                // type ahead (searc)
                $jQ('.compatibility-filter').children('input.type-ahead').on('keyup', pub.compabilitySearch);

                // sort links
                $jQ('#sort-options').find('li').on('click', pub.sort);
                $jQ('#mobile-sort-filter li.sort-option').on('click', pub.sort);
            },
            /*-----  End of Init  ------*/

            /*================================================
            =            Finalize (unbind events)            =
            =================================================*/

            finalize: function () {
                $cf = $jQ('#content-filter');
                var $collapsible = $cf.find('.collapsible'),
                    $facets = $cf.find('.facet');

                 /*==========  bind click events  ==========*/

                // dimension (expansion/collapse)
                $collapsible.find('.dimension-header').unbind('click', pub.dimensionClick);

                $facets.unbind('click', pub.facetClick);
                $jQ('.filter-panels li').unbind('click', pub.sort); /* mobile option */

                // remove filter
                $jQ('#clear-selections').find('li').find('a').unbind('click', pub.removeFilter);

                // compability services
                $jQ('.compatibility-filter').children('select').unbind('change', pub.compabilitySelect);

                // type ahead (searc)
                $jQ('.compatibility-filter').children('input.type-ahead').unbind('keyup', pub.compabilitySearch);

                 // sort links
                $jQ('#sort-options').find('li').on('click', pub.sort);
                $jQ('#mobile-sort-filter li.sort-option').on('click', pub.sort);

            },

            /*-----  End of Finalize (unbind events)  ------*/

            /*============================================
            =            Reinit: on ajax load            =
            ============================================*/

            reInit: function () {
                MLS.contentFilter.finalize();
                MLS.contentFilter.init();

            },

            /*-----  End of Reinit: on ajax load  ------*/

            /*======================================
            =            Load from Hash            =
            ======================================*/
            // If the url contains paramaters in the hash when it
            // is first loaded then request content

            loadFromHash: function () {

                var hash = window.location.hash,
                params = {};

                if (hash !== '') { // we have a hash
                    params = MLS.util.getParamsFromUrl(hash);

                    if (!$jQ.isEmptyObject(params)) {
                        pub.processRequest(params);
                    }

                }

            },

            /*-----  End of Load from Hash  ------*/

            /*=======================================
            =            Listing sorting            =
            =======================================*/

            sort: function (e) {
                e.preventDefault();
                var $elem = $jQ(this),
                    href = $elem.find('a').attr('href'),
                    params = MLS.util.getParamsFromUrl(href);

                window.location.hash = MLS.util.setHash(href);
                pub.processRequest(params);
            },

            /*-----  End of Listing sorting  ------*/

            /*=======================================
            =            dimension click            =
            =======================================*/

            dimensionClick: function (e) {
                e.preventDefault();
                $jQ(this).toggleClass('active').promise().done(function () {
                    $jQ(this).next().slideToggle('slow');
                });
            },

            /*-----  End of dimension click  ------*/

            /*==========================================
            =            Compability search            =
            ==========================================*/

            compabilitySearch: function (e) {
                var $elem = $jQ(this),
                    params = {search: $elem.val()};
                if (e.keyCode === 13) {
                    pub.processRequest(params);
                }
            },

            compabilitySelect: function () {
                var $elem = $jQ(this),
                    href = $elem.find('option:selected').attr('value'),
                    params;

                // update hash
                window.location.hash = MLS.util.setHash(href);

                params = MLS.util.getParamsFromUrl(href);
                pub.processRequest(params);
            },

            facetClick: function (e) {
                e.preventDefault();

                var $elem = $jQ(this),//e.currentTarget,
                    href = $elem.find('a').attr('href'),
                    params;

                // update hash
                window.location.hash = MLS.util.setHash(href);

                params = MLS.util.getParamsFromUrl(href);
                pub.processRequest(params);
            },

            /*-----  End of Compability search  ------*/

            /*=============================================
            =            Remove selected facet            =
            =============================================*/

            removeFilter: function (e) {
                e.preventDefault();
                var $elem = $jQ(this),
                    href = $elem.attr('href'),
                    params = MLS.util.getParamsFromUrl(href);
                window.location.hash = MLS.util.setHash(href);
                pub.processRequest(params);
            },

            /*-----  End of remove facet  ------*/

            /*=======================================
            =            process request            =
            =======================================*/

            processRequest: function (params) {

                // make request
                MLS.ajax.sendRequest(
                    options.endpoint,
                    params,
                    pub.updateResults
                );
            },

            /*-----  End of process request  ------*/

            /*===================================
            =            update grid            =
            ===================================*/

            updateResults : function (data) {
                if (data.hasOwnProperty('success')) {

                    // update results...
                    options.container.html(data.success.responseHTML);

                    // ... and result count ...
                    $jQ('#content-filter-count').find('strong').text(data.success.count);

                    // ... and filters
                    $cf.replaceWith(data.success.filtersHTML);

                    // ... and even the sort by
                    $jQ('#sort-options').find('ul').replaceWith(data.success.sortByHTML);

                    options.callback();
                    pub.reInit();

                } else {
                    options.container.html(data.error.responseHTML);
                }

            },

            /*-----  End of update grid  ------*/

        };

    return pub;
}());

<|endoftext|>


<commit_before>// Copyright 2015, University of Colorado Boulder

/**
 * Tandem is used to assign unique identifiers to instances in PhET simulations and register/unregister them in a
 * registry. It is used to support PhET-iO.
 *
 * @author Sam Reid (PhET Interactive Simulations)
 */
define( function( require ) {
  'use strict';

  // modules
  var inherit = require( 'PHET_CORE/inherit' );
  var tandemNamespace = require( 'TANDEM/tandemNamespace' );
  var toCamelCase = require( 'PHET_CORE/toCamelCase' );

  // text
  var packageString = require( 'text!REPOSITORY/package.json' );

  // constants
  var packageJSON = JSON.parse( packageString ); // Tandem can't depend on joist, so requiring packageJSON doesn't work
  var PHET_IO_ENABLED = !!( window.phet && window.phet.phetio );

  // Listeners that will be notified when items are registered/deregistered
  var instanceListeners = [];

  // variables
  // Before listeners are wired up, tandems are buffered.  When listeners are wired up, Tandem.launch() is called
  // and buffered tandems are flushed, then subsequent tandems are delivered to listeners directly
  var launched = false;
  var bufferedInstances = [];

  // increment names of uninstrumented common code tandems to avoid collisions for uninstrumented sims with
  // phetioValidateTandems=false
  var uninstrumentedCodeIndex = 0;

  /**
   * Typically, sims will create tandems using `tandem.createTandem`.  This constructor is used internally or when
   * a tandem must be created from scratch.
   *
   * @param {string} id - id as a string (or '' for a root id)
   * @param {Object} [options]
   * @constructor
   */
  function Tandem( id, options ) {

    // @private - options (even subtype options) must be stored on the instance so they can be passed through the super
    // type inheritance chain. Note: Make sure that added options here are also added to options for inheritance and/or
    // for composition (createTandem) as they make sense.
    this.options = _.extend( {

      // Enabled tandems notify listeners when they are added. Disabled tandems do not notify listeners,
      // but children of a disabled tandem may be enabled.
      enabled: true,

      // if the tandem is not supplied and required, an error will be thrown.
      supplied: true,

      // required === false means it is an optional tandem
      required: true
    }, options );

    // @public (read-only)
    this.id = ( id !== undefined ) ? id : '';

    // @private
    this.required = this.options.required;

    // @private
    this.supplied = this.options.supplied;

    // @private
    this.enabled = this.options.enabled;
  }

  tandemNamespace.register( 'Tandem', Tandem );

  inherit( Object, Tandem, {

    /**
     * Adds an instance of any type.  For example, it could be an axon Property, scenery Node or Sun button.  Each
     * item should only be added to the registry once, but that is not enforced here in Tandem.  For PhET-iO, phetio.js
     * enforces one entry per ID in phetio.addInstance
     *
     * This is used to register instances with PhET-iO.
     * @param {Object} instance - the instance to add
     * @param {Object} options - tandem flags, see phetio.js, must include the phetioType (so technically is not optional)
     * @public
     */
    addInstance: function( instance, options ) {

      if ( PHET_IO_ENABLED && this.enabled ) {

        var type = options.phetioType;

        // Throw an error if the tandem is required but not supplied
        if ( phet.phetio.queryParameters.phetioValidateTandems ) {
          assert && assert( !( this.required && !this.supplied ), 'Tandem was required but not supplied' );
        }

        // ValidateTandems is false and printMissingTandems flag is present for a tandem that is required but not supplied.
        if ( phet.phetio.queryParameters.printMissingTandems && ( this.required && !this.supplied ) ) {
          console.log( 'Required Tandem not supplied.\n' +
                       'this.id = ' + this.id + '\n' +
                       'Stack trace: ' + new Error().stack );
        }

        // ifphetio returns a no-op function, so to test whether a valid "T" wrapper type was passed, we search for the typeName
        if ( this.supplied ) {
          assert && assert( type && type.typeName, 'type must be specified and have a typeName for ' + this.id );
        }

        // If tandem is optional, then don't add the instance
        if ( !this.required && !this.supplied ) {
          if ( phet.phetio.queryParameters.printMissingTandems ) {
            var stackTrace = new Error().stack;

            // Generally Font is not desired because there are so many untandemized instances.
            if ( stackTrace.indexOf( 'PhetFont' ) === -1 ) {
              console.log( 'Optional Tandem not supplied.\n' +
                           'this.id = ' + this.id + '\n' +
                           'Stack trace: ' + stackTrace );
            }
          }

          // For optionally instrumented types that are not provided tandems, the instance isn't really "added"
          // but likewise, it in not an error
          return;
        }

        if ( !launched ) {
          bufferedInstances.push( { tandem: this, instance: instance, options: options } );
        }
        else {
          for ( var i = 0; i < instanceListeners.length; i++ ) {
            instanceListeners[ i ].addInstance( this.id, instance, type, options );
          }
        }
      }
    },

    /**
     * Removes an instance from the registry
     * @param {Object} instance - the instance to remove
     * @public
     */
    removeInstance: function( instance ) {
      if ( !this.required && !this.supplied ) {
        return;
      }

      // Only active when running as phet-io
      if ( PHET_IO_ENABLED && this.enabled ) {
        for ( var i = 0; i < instanceListeners.length; i++ ) {
          instanceListeners[ i ].removeInstance( this.id, instance );
        }
      }
    },

    /**
     * Create a new Tandem by appending the given id
     * @param {string} id
     * @param {Object} [options]
     * @returns {Tandem}
     * @public
     */
    createTandem: function( id, options ) {

      // Make sure the id was provided
      assert && assert( typeof id === 'string' && id.length > 0, 'id must be defined' );

      var string = ( this.id.length > 0 ) ? ( this.id + '.' + id ) : id;

      // Any child of something should be passed these inherited options.
      options = _.extend( {
        enabled: this.enabled,
        supplied: this.supplied,
        required: this.required
      }, options );

      return new Tandem( string, options );
    },

    /**
     * Creates a group tandem for creating multiple indexed child tandems, such as:
     * sim.screen.model.electron_0
     * sim.screen.model.electron_1
     *
     * In this case, 'sim.screen.model.electron' is the group tandem id.
     *
     * Used for arrays, observable arrays, or when many elements of the same type are created and they do not otherwise
     * have unique identifiers.
     * @param id
     * @returns {GroupTandem}
     * @public
     */
    createGroupTandem: function( id ) {

      // Unfortunately we must resort to globals here since loading through the namespace would create a cycle
      return new GroupTandem( this.id + '.' + id );
    },

    /**
     * Get the last part of the tandem (after the last .), used in Joist for creating button names dynamically based
     * on screen names
     * @returns {string} the tail of the tandem
     * @public
     */
    get tail() {
      assert && assert( this.id.indexOf( '.' ) >= 0, 'tandem ID does not have a tail' );

      var lastIndexOfDot = this.id.lastIndexOf( '.' );
      var tail = this.id.substring( lastIndexOfDot + 1 );
      assert && assert( tail.length > 0, 'tandem ID did not have a tail' );
      return tail;
    },

    /**
     * Returns a Tandem for everything except the tail.
     * @returns {Tandem}
     * @public
     */
    get parentTandem() {
      assert && assert( this.id.indexOf( '.' ) >= 0, 'tandem ID does not have a tail' );

      var lastIndexOfDot = this.id.lastIndexOf( '.' );
      var headID = this.id.substring( 0, lastIndexOfDot );

      return new Tandem( headID, {
        required: this.required,
        supplied: this.supplied,
        enabled: this.enabled
      } );
    },

    /**
     * Return true if this tandem is legal and can be used by the phet-io system.
     * @returns {boolean}
     * @public
     */
    isLegalAndUsable: function() {

      // If we are not in phet-io mode, then the tandem is not legal and usable.
      if ( !PHET_IO_ENABLED ) {
        return false;
      }

      // A tandem is legal if it has been supplied or, if it hasn't been supplied, if it is optional.
      return this.supplied || ( this.optional && !this.supplied );
    }
  }, {

    /**
     * Adds a listener that will be notified when items are registered/deregistered
     * Listeners have the form
     * {
     *   addInstance(id,instance),
     *   removeInstance(id,instance)
     * }
     * where id is of type {string} and instance is of type {Object}
     *
     * @param {Object} instanceListener - described above
     * @public
     * @static
     */
    addInstanceListener: function( instanceListener ) {
      instanceListeners.push( instanceListener );
    },

    /**
     * When all listeners are listening, all buffered instances are registered.
     * @public
     * @static
     */
    launch: function() {
      assert && assert( !launched, 'Tandem was launched twice' );
      launched = true;
      while ( bufferedInstances.length > 0 ) {
        var tandem = bufferedInstances.shift();
        tandem.tandem.addInstance( tandem.instance, tandem.options );
      }
    },

    /**
     * Catch cases where tandem is being supplied to a class that doesn't support tandem.
     * @param {Object} [options]
     * @public
     * @static
     */
    disallowTandem: function( options ) {

      if ( Tandem.validationEnabled() ) {
        assert && assert( !options.tandem, 'tandem is not allowed' );
      }
    },

    /**
     * When running in PhET-iO brand, some code (such as user interface components) must be instrumented for PhET-iO.
     * Uninstrumented files should call this function to indicate they still need to be instrumented, so they aren't
     * missed.  See https://github.com/phetsims/phet-io/issues/668
     * @public
     * @static
     */
    indicateUninstrumentedCode: function() {

      // Guard against undefined errors
      if ( PHET_IO_ENABLED ) {

        // Assert if validating tandems
        if ( phet.phetio.queryParameters.phetioValidateTandems ) {
          assert && assert( false, 'Uninstrumented code detected' );
        }

        // Print stack trace if query parameter supplied
        if ( phet.phetio.queryParameters.printMissingTandems ) {
          var stackTrace = new Error().stack;
          console.log( 'Uninstrumented Code! Tandem not supplied: ' + ( uninstrumentedCodeIndex++ ) + '.\n' +
                       'Stack trace: ' + stackTrace );
        }

      }
    },

    /**
     * Determine whether or not tandem validation is turned on for the sim.
     * @returns {Boolean} If tandems are being validated or not.
     * @public
     * @static
     */
    validationEnabled: function() {
      return PHET_IO_ENABLED && phet.phetio.queryParameters.phetioValidateTandems;
    }
  } );

  // The next few statics are created outside the static block because they instantiate Tandem instances.

  /**
   * The root tandem for a simulation
   * @public
   * @static
   * @type {Tandem}
   */
  Tandem.rootTandem = new Tandem( toCamelCase( packageJSON.name ) );

  /**
   * Used to indicate a common code component that supports tandem, but doesn't not require it.
   * If a tandem is not passed through to this instance, then it will not be instrumented.
   * @public
   * @static
   * @type {Tandem}
   */
  Tandem.optional = Tandem.rootTandem.createTandem( 'optionalTandem', {
    required: false,
    supplied: false
  } );

  /**
   * Some common code (such as CheckBox or RadioButton) must always be instrumented and hence requires a tandem to be
   * passed in.
   * @public
   * @static
   * @type {Tandem}
   */
  Tandem.required = Tandem.rootTandem.createTandem( 'requiredTandem', {
    required: true,
    supplied: false
  } );

  /**
   * Group Tandem -- Declared in the same file to avoid circular reference errors in module loading.
   * @param {string} id - id as a string (or '' for a root id)
   * @constructor
   * @private create with Tandem.createGroupTandem
   */
  function GroupTandem( id ) {

    Tandem.call( this, id );

    // @private for generating indices from a pool
    this.groupElementIndex = 0;
  }

  tandemNamespace.register( 'Tandem.GroupTandem', GroupTandem );

  inherit( Tandem, GroupTandem, {

    /**
     * Creates the next tandem in the group.
     * @returns {Tandem}
     * @public
     */
    createNextTandem: function() {
      return new Tandem( this.id + '_' + ( this.groupElementIndex++ ) );
    }
  } );

  return Tandem;
} );<commit_msg>remove this.options as instance var, https://github.com/phetsims/tandem/issues/38<commit_after>// Copyright 2015, University of Colorado Boulder

/**
 * Tandem is used to assign unique identifiers to instances in PhET simulations and register/unregister them in a
 * registry. It is used to support PhET-iO.
 *
 * @author Sam Reid (PhET Interactive Simulations)
 */
define( function( require ) {
  'use strict';

  // modules
  var inherit = require( 'PHET_CORE/inherit' );
  var tandemNamespace = require( 'TANDEM/tandemNamespace' );
  var toCamelCase = require( 'PHET_CORE/toCamelCase' );

  // text
  var packageString = require( 'text!REPOSITORY/package.json' );

  // constants
  var packageJSON = JSON.parse( packageString ); // Tandem can't depend on joist, so requiring packageJSON doesn't work
  var PHET_IO_ENABLED = !!( window.phet && window.phet.phetio );

  // Listeners that will be notified when items are registered/deregistered
  var instanceListeners = [];

  // variables
  // Before listeners are wired up, tandems are buffered.  When listeners are wired up, Tandem.launch() is called
  // and buffered tandems are flushed, then subsequent tandems are delivered to listeners directly
  var launched = false;
  var bufferedInstances = [];

  // increment names of uninstrumented common code tandems to avoid collisions for uninstrumented sims with
  // phetioValidateTandems=false
  var uninstrumentedCodeIndex = 0;

  /**
   * Typically, sims will create tandems using `tandem.createTandem`.  This constructor is used internally or when
   * a tandem must be created from scratch.
   *
   * @param {string} id - id as a string (or '' for a root id)
   * @param {Object} [options]
   * @constructor
   */
  function Tandem( id, options ) {

    // options (even subtype options) must be stored on the instance so they can be passed through to children
    // Note: Make sure that added options here are also added to options for inheritance and/or
    // for composition (createTandem/parentTandem) as they make sense.
    options = _.extend( {

      // Enabled tandems notify listeners when they are added. Disabled tandems do not notify listeners,
      // but children of a disabled tandem may be enabled.
      enabled: true,

      // if the tandem is not supplied and required, an error will be thrown.
      supplied: true,

      // required === false means it is an optional tandem
      required: true
    }, options );

    // @public (read-only)
    this.id = ( id !== undefined ) ? id : '';

    // @private
    this.required = options.required;

    // @private
    this.supplied = options.supplied;

    // @private
    this.enabled = options.enabled;
  }

  tandemNamespace.register( 'Tandem', Tandem );

  inherit( Object, Tandem, {

    /**
     * Adds an instance of any type.  For example, it could be an axon Property, scenery Node or Sun button.  Each
     * item should only be added to the registry once, but that is not enforced here in Tandem.  For PhET-iO, phetio.js
     * enforces one entry per ID in phetio.addInstance
     *
     * This is used to register instances with PhET-iO.
     * @param {Object} instance - the instance to add
     * @param {Object} options - tandem flags, see phetio.js, must include the phetioType (so technically is not optional)
     * @public
     */
    addInstance: function( instance, options ) {

      if ( PHET_IO_ENABLED && this.enabled ) {

        var type = options.phetioType;

        // Throw an error if the tandem is required but not supplied
        if ( phet.phetio.queryParameters.phetioValidateTandems ) {
          assert && assert( !( this.required && !this.supplied ), 'Tandem was required but not supplied' );
        }

        // ValidateTandems is false and printMissingTandems flag is present for a tandem that is required but not supplied.
        if ( phet.phetio.queryParameters.printMissingTandems && ( this.required && !this.supplied ) ) {
          console.log( 'Required Tandem not supplied.\n' +
                       'this.id = ' + this.id + '\n' +
                       'Stack trace: ' + new Error().stack );
        }

        // ifphetio returns a no-op function, so to test whether a valid "T" wrapper type was passed, we search for the typeName
        if ( this.supplied ) {
          assert && assert( type && type.typeName, 'type must be specified and have a typeName for ' + this.id );
        }

        // If tandem is optional, then don't add the instance
        if ( !this.required && !this.supplied ) {
          if ( phet.phetio.queryParameters.printMissingTandems ) {
            var stackTrace = new Error().stack;

            // Generally Font is not desired because there are so many untandemized instances.
            if ( stackTrace.indexOf( 'PhetFont' ) === -1 ) {
              console.log( 'Optional Tandem not supplied.\n' +
                           'this.id = ' + this.id + '\n' +
                           'Stack trace: ' + stackTrace );
            }
          }

          // For optionally instrumented types that are not provided tandems, the instance isn't really "added"
          // but likewise, it in not an error
          return;
        }

        if ( !launched ) {
          bufferedInstances.push( { tandem: this, instance: instance, options: options } );
        }
        else {
          for ( var i = 0; i < instanceListeners.length; i++ ) {
            instanceListeners[ i ].addInstance( this.id, instance, type, options );
          }
        }
      }
    },

    /**
     * Removes an instance from the registry
     * @param {Object} instance - the instance to remove
     * @public
     */
    removeInstance: function( instance ) {
      if ( !this.required && !this.supplied ) {
        return;
      }

      // Only active when running as phet-io
      if ( PHET_IO_ENABLED && this.enabled ) {
        for ( var i = 0; i < instanceListeners.length; i++ ) {
          instanceListeners[ i ].removeInstance( this.id, instance );
        }
      }
    },

    /**
     * Create a new Tandem by appending the given id
     * @param {string} id
     * @param {Object} [options]
     * @returns {Tandem}
     * @public
     */
    createTandem: function( id, options ) {

      // Make sure the id was provided
      assert && assert( typeof id === 'string' && id.length > 0, 'id must be defined' );

      var string = ( this.id.length > 0 ) ? ( this.id + '.' + id ) : id;

      // Any child of something should be passed all inherited options. Make sure that this extend call includes all
      // that make sense from the constructor's extend call.
      options = _.extend( {
        enabled: this.enabled,
        supplied: this.supplied,
        required: this.required
      }, options );

      return new Tandem( string, options );
    },

    /**
     * Creates a group tandem for creating multiple indexed child tandems, such as:
     * sim.screen.model.electron_0
     * sim.screen.model.electron_1
     *
     * In this case, 'sim.screen.model.electron' is the group tandem id.
     *
     * Used for arrays, observable arrays, or when many elements of the same type are created and they do not otherwise
     * have unique identifiers.
     * @param id
     * @returns {GroupTandem}
     * @public
     */
    createGroupTandem: function( id ) {

      // Unfortunately we must resort to globals here since loading through the namespace would create a cycle
      return new GroupTandem( this.id + '.' + id );
    },

    /**
     * Get the last part of the tandem (after the last .), used in Joist for creating button names dynamically based
     * on screen names
     * @returns {string} the tail of the tandem
     * @public
     */
    get tail() {
      assert && assert( this.id.indexOf( '.' ) >= 0, 'tandem ID does not have a tail' );

      var lastIndexOfDot = this.id.lastIndexOf( '.' );
      var tail = this.id.substring( lastIndexOfDot + 1 );
      assert && assert( tail.length > 0, 'tandem ID did not have a tail' );
      return tail;
    },

    /**
     * Returns a Tandem for everything except the tail.
     * @returns {Tandem}
     * @public
     */
    get parentTandem() {
      assert && assert( this.id.indexOf( '.' ) >= 0, 'tandem ID does not have a tail' );

      var lastIndexOfDot = this.id.lastIndexOf( '.' );
      var headID = this.id.substring( 0, lastIndexOfDot );

      return new Tandem( headID, {
        required: this.required,
        supplied: this.supplied,
        enabled: this.enabled
      } );
    },

    /**
     * Return true if this tandem is legal and can be used by the phet-io system.
     * @returns {boolean}
     * @public
     */
    isLegalAndUsable: function() {

      // If we are not in phet-io mode, then the tandem is not legal and usable.
      if ( !PHET_IO_ENABLED ) {
        return false;
      }

      // A tandem is legal if it has been supplied or, if it hasn't been supplied, if it is optional.
      return this.supplied || ( this.optional && !this.supplied );
    }
  }, {

    /**
     * Adds a listener that will be notified when items are registered/deregistered
     * Listeners have the form
     * {
     *   addInstance(id,instance),
     *   removeInstance(id,instance)
     * }
     * where id is of type {string} and instance is of type {Object}
     *
     * @param {Object} instanceListener - described above
     * @public
     * @static
     */
    addInstanceListener: function( instanceListener ) {
      instanceListeners.push( instanceListener );
    },

    /**
     * When all listeners are listening, all buffered instances are registered.
     * @public
     * @static
     */
    launch: function() {
      assert && assert( !launched, 'Tandem was launched twice' );
      launched = true;
      while ( bufferedInstances.length > 0 ) {
        var tandem = bufferedInstances.shift();
        tandem.tandem.addInstance( tandem.instance, tandem.options );
      }
    },

    /**
     * Catch cases where tandem is being supplied to a class that doesn't support tandem.
     * @param {Object} [options]
     * @public
     * @static
     */
    disallowTandem: function( options ) {

      if ( Tandem.validationEnabled() ) {
        assert && assert( !options.tandem, 'tandem is not allowed' );
      }
    },

    /**
     * When running in PhET-iO brand, some code (such as user interface components) must be instrumented for PhET-iO.
     * Uninstrumented files should call this function to indicate they still need to be instrumented, so they aren't
     * missed.  See https://github.com/phetsims/phet-io/issues/668
     * @public
     * @static
     */
    indicateUninstrumentedCode: function() {

      // Guard against undefined errors
      if ( PHET_IO_ENABLED ) {

        // Assert if validating tandems
        if ( phet.phetio.queryParameters.phetioValidateTandems ) {
          assert && assert( false, 'Uninstrumented code detected' );
        }

        // Print stack trace if query parameter supplied
        if ( phet.phetio.queryParameters.printMissingTandems ) {
          var stackTrace = new Error().stack;
          console.log( 'Uninstrumented Code! Tandem not supplied: ' + ( uninstrumentedCodeIndex++ ) + '.\n' +
                       'Stack trace: ' + stackTrace );
        }

      }
    },

    /**
     * Determine whether or not tandem validation is turned on for the sim.
     * @returns {Boolean} If tandems are being validated or not.
     * @public
     * @static
     */
    validationEnabled: function() {
      return PHET_IO_ENABLED && phet.phetio.queryParameters.phetioValidateTandems;
    }
  } );

  // The next few statics are created outside the static block because they instantiate Tandem instances.

  /**
   * The root tandem for a simulation
   * @public
   * @static
   * @type {Tandem}
   */
  Tandem.rootTandem = new Tandem( toCamelCase( packageJSON.name ) );

  /**
   * Used to indicate a common code component that supports tandem, but doesn't not require it.
   * If a tandem is not passed through to this instance, then it will not be instrumented.
   * @public
   * @static
   * @type {Tandem}
   */
  Tandem.optional = Tandem.rootTandem.createTandem( 'optionalTandem', {
    required: false,
    supplied: false
  } );

  /**
   * Some common code (such as CheckBox or RadioButton) must always be instrumented and hence requires a tandem to be
   * passed in.
   * @public
   * @static
   * @type {Tandem}
   */
  Tandem.required = Tandem.rootTandem.createTandem( 'requiredTandem', {
    required: true,
    supplied: false
  } );

  /**
   * Group Tandem -- Declared in the same file to avoid circular reference errors in module loading.
   * @param {string} id - id as a string (or '' for a root id)
   * @constructor
   * @private create with Tandem.createGroupTandem
   */
  function GroupTandem( id ) {

    Tandem.call( this, id );

    // @private for generating indices from a pool
    this.groupElementIndex = 0;
  }

  tandemNamespace.register( 'Tandem.GroupTandem', GroupTandem );

  inherit( Tandem, GroupTandem, {

    /**
     * Creates the next tandem in the group.
     * @returns {Tandem}
     * @public
     */
    createNextTandem: function() {
      return new Tandem( this.id + '_' + ( this.groupElementIndex++ ) );
    }
  } );

  return Tandem;
} );<|endoftext|>


<commit_before>var sssheet = (function () {
  var style = document.createElement('style')
  style.appendChild(document.createTextNode(''))
  document.head.appendChild(style)
  return style.sheet
})()

if (window.location.href.indexOf('ifoodie.tw') == -1) {
  // Remove floating ad
  sssheet.insertRule('.adsbygoogle:last-child { display: none !important; }', 0)
  sssheet.insertRule('.anchor-ad-container { display: none !important; }', 0)
  sssheet.insertRule(
    ".adsbygoogle[data-anchor-shown='true'] { display: none !important; }",
    0
  )
  sssheet.insertRule('#blogimoveSLIDE { display: none !important; }', 0)
  sssheet.insertRule('.friends-links { display: none !important; }', 0)
  sssheet.insertRule('#hellobar-bar { display: none !important; }', 0)
  sssheet.insertRule('#gtx-trans { display: none !important; }', 0)
  sssheet.insertRule('#banner-wrapper { display: none !important; }', 0)
  sssheet.insertRule('.nc_wrapper.bottom { display: none !important; }', 0)
  sssheet.insertRule('.mystickyelements-fixed { display: none !important; }', 0)
  // Remove sticky anything
  sssheet.insertRule('.GoTop.show { display: none !important; }', 0)
  sssheet.insertRule('.sticky { display: none !important; }', 0)
  sssheet.insertRule('.anchor-ad { display: none !important; }', 0)
  sssheet.insertRule('.addiv { display: none !important; }', 0)
  sssheet.insertRule(
    '.wow-gemini-ad-bottom-wrapper { display: none !important; }',
    0
  )

  setTimeout(function () {
    for (i = 0; i < 100; i++) {
      window.clearInterval(i)
    }
  }, 5000)
}

if (window.location.href.indexOf('mirrormedia.mg') != -1) {
  sssheet.insertRule(
    '.header.scrolled .header__section-layer { position: relative !important; }',
    0
  )
  sssheet.insertRule(
    '.header.scrolled .header__logo-layer { position: relative !important; }',
    0
  )
  sssheet.insertRule('.relateds-over-content { display: none !important; }', 0)
  sssheet.insertRule('.dfp-st { display: none !important; }', 0)
}

if (window.location.href.indexOf('ifoodie.tw/post') != -1) {
  sssheet.insertRule('#header { display: none !important; }', 0)
} else if (window.location.href.indexOf('maruko.tw') != -1) {
  sssheet.insertRule('#header-inner { display: none !important; }', 0)
} else if (window.location.href.indexOf('leafyeh.com') != -1) {
  sssheet.insertRule('.left-side-menu { display: none !important; }', 0)
  sssheet.insertRule('.scrollup { display: none !important; }', 0)
} else if (window.location.href.indexOf('mecocute.com') != -1) {
  sssheet.insertRule('#header { display: none !important; }', 0)
} else if (window.location.href.indexOf('yukiblog.tw') != -1) {
  $('.adsbygoogle').remove()
  $('.postad').remove()
  $('iframe').remove()
} else if (window.location.href.indexOf('wiselyview.cc') != -1) {
  sssheet.insertRule('#top-btn { display: none !important; }', 0)
  sssheet.insertRule('iframe { display: none !important; }', 0)
} else if (window.location.href.indexOf('mshw.info') != -1) {
  sssheet.insertRule('#page { overflow: hidden; }', 0)
  sssheet.insertRule('.adsbygoogle { display: none !important; }', 0)
  sssheet.insertRule('.shr_ss { display: none !important; }', 0)
} else if (window.location.href.indexOf('meishijournal.com') != -1) {
  sssheet.insertRule('.adsbygoogle { display: none !important; }', 0)
} else if (window.location.href.indexOf('wiselyview.cc') != -1) {
  jQuery('iframe').remove()
  jQuery('#aswift_0_expand').remove()
  jQuery('#aswift_3_expand').remove()
} else if (window.location.href.indexOf('lanlan-life.com') != -1) {
  sssheet.insertRule('#header { display: none !important; }', 0)
  sssheet.insertRule('#sharebar { display: none !important; }', 0)
  sssheet.insertRule('#sharebar-block { display: none !important; }', 0)
} else if (window.location.href.indexOf('fengtaiwanway') != -1) {
  sssheet.insertRule('.left-side-menu { display: none !important; }', 0)
  sssheet.insertRule('.Ba_Ad { display: none !important; }', 0)
} else if (window.location.href.indexOf('candicecity.com') != -1) {
  jQuery('.adsbygoogle, .sharedaddy').remove()
  sssheet.insertRule('.pi-Ad-mb-stick { display: none !important; }', 0)
} else if (window.location.href.indexOf('starwing.cc') != -1) {
  sssheet.insertRule('.adsbygoogle { display: none !important; }', 0)
} else if (window.location.href.indexOf('yuann.tw') != -1) {
  jQuery("a[href='http://radarurl.com/monitor']").remove()
} else if (window.location.href.indexOf('ladymoko.com') != -1) {
  jQuery('.adsbygoogle').remove()
} else if (window.location.href.indexOf('xuite.net') != -1) {
  jQuery('#rmiad').remove()
  sssheet.insertRule('#rmiad { display: none !important; }', 0)
}

if (window.location.href.indexOf('ifoodie.tw') == -1) {
  sssheet.insertRule(
    '.subscribe-bar-container { display: none !important; }',
    0
  )
  sssheet.insertRule(
    '.article-author__subscribe { display: none !important; }',
    0
  )
  sssheet.insertRule(
    '.pixnavbar__top-bar__list { display: none !important; }',
    0
  )

  sssheet.insertRule('.pi-ad-mobile-tag-outer { display: none !important; }', 0)
  sssheet.insertRule('.pi-Ad-mb-stick { display: none !important; }', 0)
  sssheet.insertRule('.pi-Ad-mb-stick { visibility: hidden !important; }', 0)
  // sssheet.insertRule(".adsbygoogle ins { display: none !important; }", 0);
  // sssheet.insertRule(".article-body iframe { display: none !important; }", 0);
  // sssheet.insertRule(".article-body .adsbygoogle { display: none !important; }", 0);
  // sssheet.insertRule(".article-header .adsbygoogle { display: none !important; }", 0);
  sssheet.insertRule(
    '.nc_wrapper .floatBottom { display: none !important; }',
    0
  )
  sssheet.insertRule('.header-advertise { display: none !important; }', 0)
  sssheet.insertRule('.drag-wrapper { display: none !important; }', 0)
  sssheet.insertRule('.fixed-top { display: none !important; }', 0)
  sssheet.insertRule('.addiv { display: none !important; }', 0)
  sssheet.insertRule(
    '.wow-gemini-ad-bottom-wrapper { display: none !important; }',
    0
  )
  sssheet.insertRule(
    '.right-nav-stream-button { display: none !important; }',
    0
  )
  sssheet.insertRule('.right-nav-share-button { display: none !important; }', 0)
  sssheet.insertRule('.sticky-box { display: none !important; }', 0)
  sssheet.insertRule('#pilot { display: none !important; }', 0)
  sssheet.insertRule('.fb_iframe_widget { display: none !important; }', 0)

  if (Math.random() > 0.2) {
    sssheet.insertRule('.pop-ad-cover { display: none !important; }', 0)
    sssheet.insertRule(
      '#scupio_interstitialad { display: none !important; }',
      0
    )
    sssheet.insertRule('#scupio_interstitial { display: none !important; }', 0)
    sssheet.insertRule('#incover-layout0 { display: none !important; }', 0)
  }

  sssheet.insertRule('.sticky-box { display: none !important; }', 0)
  sssheet.insertRule('#pixad1101d { overflow: hidden !important; }', 0)
  sssheet.insertRule('#main { overflow: hidden !important; }', 0)
  sssheet.insertRule('.header-ad { height: 120px !important; }', 0)
  sssheet.insertRule('#main .relative-article { display: none !important; }', 0)
  sssheet.insertRule('.article-body { overflow-x: hidden !important; }', 0)
  sssheet.insertRule('#recommend-tools { display: none !important; }', 0)
  sssheet.insertRule('#main .comment-form { display: none !important; }', 0)
  sssheet.insertRule('#comment-block { display: none !important; }', 0)
  sssheet.insertRule('#main .article-comments { display: none !important; }', 0)
  sssheet.insertRule(
    '#header-bar__share-tools { display: none !important; }',
    0
  )
  sssheet.insertRule(
    '#header .bar--reading span { display: none !important; }',
    0
  )
  sssheet.insertRule('#sb-site #logo { display: none !important; }', 0)
  sssheet.insertRule('#wrapper #toggleMenu { display: none !important; }', 0)
  sssheet.insertRule('#float_fb_plugin { display: none !important; }', 0)

  if (jQuery) {
    jQuery('.article-body').removeClass('show-summary')
    jQuery('a img').parent().css('pointer-events', 'none')
    jQuery("iframe[src*='maps.google.com']").remove()
    jQuery("iframe[src*='www.google.com/maps']").remove()
    jQuery("iframe[src*='facebook.com']").remove()

    if (window.location.href.indexOf('bluehero.pixnet') != -1) {
      jQuery('table,embed').width('100%')
    }
  }
}

// Yuki
// jQuery('.article-header .adsbygoogle').css({height: '120px', overflow: 'hidden'});
<commit_msg>update script<commit_after>var sssheet = (function () {
  var style = document.createElement('style')
  style.appendChild(document.createTextNode(''))
  document.head.appendChild(style)
  return style.sheet
})()

if (window.location.href.indexOf('ifoodie.tw') == -1) {
  // Remove floating ad
  sssheet.insertRule('.adsbygoogle:last-child { display: none !important; }', 0)
  sssheet.insertRule('.anchor-ad-container { display: none !important; }', 0)
  sssheet.insertRule(
    ".adsbygoogle[data-anchor-shown='true'] { display: none !important; }",
    0
  )
  sssheet.insertRule('#blogimoveSLIDE { display: none !important; }', 0)
  sssheet.insertRule('.friends-links { display: none !important; }', 0)
  sssheet.insertRule('#hellobar-bar { display: none !important; }', 0)
  sssheet.insertRule('#gtx-trans { display: none !important; }', 0)
  sssheet.insertRule('#banner-wrapper { display: none !important; }', 0)
  sssheet.insertRule('.nc_wrapper.bottom { display: none !important; }', 0)
  sssheet.insertRule('.mystickyelements-fixed { display: none !important; }', 0)
  // Remove sticky anything
  sssheet.insertRule('.GoTop { display: none !important; }', 0)
  sssheet.insertRule('.sticky { display: none !important; }', 0)
  sssheet.insertRule('.anchor-ad { display: none !important; }', 0)
  sssheet.insertRule('.addiv { display: none !important; }', 0)
  sssheet.insertRule(
    '.wow-gemini-ad-bottom-wrapper { display: none !important; }',
    0
  )

  setTimeout(function () {
    for (i = 0; i < 100; i++) {
      window.clearInterval(i)
    }
  }, 5000)
}

if (window.location.href.indexOf('mirrormedia.mg') != -1) {
  sssheet.insertRule(
    '.header.scrolled .header__section-layer { position: relative !important; }',
    0
  )
  sssheet.insertRule(
    '.header.scrolled .header__logo-layer { position: relative !important; }',
    0
  )
  sssheet.insertRule('.relateds-over-content { display: none !important; }', 0)
  sssheet.insertRule('.dfp-st { display: none !important; }', 0)
}

if (window.location.href.indexOf('ifoodie.tw/post') != -1) {
  sssheet.insertRule('#header { display: none !important; }', 0)
} else if (window.location.href.indexOf('maruko.tw') != -1) {
  sssheet.insertRule('#header-inner { display: none !important; }', 0)
} else if (window.location.href.indexOf('leafyeh.com') != -1) {
  sssheet.insertRule('.left-side-menu { display: none !important; }', 0)
  sssheet.insertRule('.scrollup { display: none !important; }', 0)
} else if (window.location.href.indexOf('mecocute.com') != -1) {
  sssheet.insertRule('#header { display: none !important; }', 0)
} else if (window.location.href.indexOf('yukiblog.tw') != -1) {
  $('.adsbygoogle').remove()
  $('.postad').remove()
  $('iframe').remove()
} else if (window.location.href.indexOf('wiselyview.cc') != -1) {
  sssheet.insertRule('#top-btn { display: none !important; }', 0)
  sssheet.insertRule('iframe { display: none !important; }', 0)
} else if (window.location.href.indexOf('mshw.info') != -1) {
  sssheet.insertRule('#page { overflow: hidden; }', 0)
  sssheet.insertRule('.adsbygoogle { display: none !important; }', 0)
  sssheet.insertRule('.shr_ss { display: none !important; }', 0)
} else if (window.location.href.indexOf('meishijournal.com') != -1) {
  sssheet.insertRule('.adsbygoogle { display: none !important; }', 0)
} else if (window.location.href.indexOf('wiselyview.cc') != -1) {
  jQuery('iframe').remove()
  jQuery('#aswift_0_expand').remove()
  jQuery('#aswift_3_expand').remove()
} else if (window.location.href.indexOf('lanlan-life.com') != -1) {
  sssheet.insertRule('#header { display: none !important; }', 0)
  sssheet.insertRule('#sharebar { display: none !important; }', 0)
  sssheet.insertRule('#sharebar-block { display: none !important; }', 0)
} else if (window.location.href.indexOf('fengtaiwanway') != -1) {
  sssheet.insertRule('.left-side-menu { display: none !important; }', 0)
  sssheet.insertRule('.Ba_Ad { display: none !important; }', 0)
} else if (window.location.href.indexOf('candicecity.com') != -1) {
  jQuery('.adsbygoogle, .sharedaddy').remove()
  sssheet.insertRule('.pi-Ad-mb-stick { display: none !important; }', 0)
} else if (window.location.href.indexOf('starwing.cc') != -1) {
  sssheet.insertRule('.adsbygoogle { display: none !important; }', 0)
} else if (window.location.href.indexOf('yuann.tw') != -1) {
  jQuery("a[href='http://radarurl.com/monitor']").remove()
} else if (window.location.href.indexOf('ladymoko.com') != -1) {
  jQuery('.adsbygoogle').remove()
} else if (window.location.href.indexOf('xuite.net') != -1) {
  jQuery('#rmiad').remove()
  sssheet.insertRule('#rmiad { display: none !important; }', 0)
}

if (window.location.href.indexOf('ifoodie.tw') == -1) {
  sssheet.insertRule(
    '.subscribe-bar-container { display: none !important; }',
    0
  )
  sssheet.insertRule(
    '.article-author__subscribe { display: none !important; }',
    0
  )
  sssheet.insertRule(
    '.pixnavbar__top-bar__list { display: none !important; }',
    0
  )

  sssheet.insertRule('.pi-ad-mobile-tag-outer { display: none !important; }', 0)
  sssheet.insertRule('.pi-Ad-mb-stick { display: none !important; }', 0)
  sssheet.insertRule('.pi-Ad-mb-stick { visibility: hidden !important; }', 0)
  // sssheet.insertRule(".adsbygoogle ins { display: none !important; }", 0);
  // sssheet.insertRule(".article-body iframe { display: none !important; }", 0);
  // sssheet.insertRule(".article-body .adsbygoogle { display: none !important; }", 0);
  // sssheet.insertRule(".article-header .adsbygoogle { display: none !important; }", 0);
  sssheet.insertRule(
    '.nc_wrapper .floatBottom { display: none !important; }',
    0
  )
  sssheet.insertRule('.header-advertise { display: none !important; }', 0)
  sssheet.insertRule('.drag-wrapper { display: none !important; }', 0)
  sssheet.insertRule('.fixed-top { display: none !important; }', 0)
  sssheet.insertRule('.addiv { display: none !important; }', 0)
  sssheet.insertRule(
    '.wow-gemini-ad-bottom-wrapper { display: none !important; }',
    0
  )
  sssheet.insertRule(
    '.right-nav-stream-button { display: none !important; }',
    0
  )
  sssheet.insertRule('.right-nav-share-button { display: none !important; }', 0)
  sssheet.insertRule('.sticky-box { display: none !important; }', 0)
  sssheet.insertRule('#pilot { display: none !important; }', 0)
  sssheet.insertRule('.fb_iframe_widget { display: none !important; }', 0)

  if (Math.random() > 0.2) {
    sssheet.insertRule('.pop-ad-cover { display: none !important; }', 0)
    sssheet.insertRule(
      '#scupio_interstitialad { display: none !important; }',
      0
    )
    sssheet.insertRule('#scupio_interstitial { display: none !important; }', 0)
    sssheet.insertRule('#incover-layout0 { display: none !important; }', 0)
  }

  sssheet.insertRule('.sticky-box { display: none !important; }', 0)
  sssheet.insertRule('#pixad1101d { overflow: hidden !important; }', 0)
  sssheet.insertRule('#main { overflow: hidden !important; }', 0)
  sssheet.insertRule('.header-ad { height: 120px !important; }', 0)
  sssheet.insertRule('#main .relative-article { display: none !important; }', 0)
  sssheet.insertRule('.article-body { overflow-x: hidden !important; }', 0)
  sssheet.insertRule('#recommend-tools { display: none !important; }', 0)
  sssheet.insertRule('#main .comment-form { display: none !important; }', 0)
  sssheet.insertRule('#comment-block { display: none !important; }', 0)
  sssheet.insertRule('#main .article-comments { display: none !important; }', 0)
  sssheet.insertRule(
    '#header-bar__share-tools { display: none !important; }',
    0
  )
  sssheet.insertRule(
    '#header .bar--reading span { display: none !important; }',
    0
  )
  sssheet.insertRule('#sb-site #logo { display: none !important; }', 0)
  sssheet.insertRule('#wrapper #toggleMenu { display: none !important; }', 0)
  sssheet.insertRule('#float_fb_plugin { display: none !important; }', 0)

  if (jQuery) {
    jQuery('.article-body').removeClass('show-summary')
    jQuery('a img').parent().css('pointer-events', 'none')
    jQuery("iframe[src*='maps.google.com']").remove()
    jQuery("iframe[src*='www.google.com/maps']").remove()
    jQuery("iframe[src*='facebook.com']").remove()

    if (window.location.href.indexOf('bluehero.pixnet') != -1) {
      jQuery('table,embed').width('100%')
    }
  }
}

// Yuki
// jQuery('.article-header .adsbygoogle').css({height: '120px', overflow: 'hidden'});
<|endoftext|>