示例#1
0
module.exports = function(opts) {

  var setScore = function(stage, score) {
    xhr.setScore(stage.key, score).then(function(data) {
      opts.data = data;
    });
  };

  var stage = makeStage(stages.get(m.route.param("id")), {
    level: m.route.param('level') || 1,
    setScore: setScore
  });

  opts.route = 'run';
  opts.stageId = stage.blueprint.id;

  var getNext = function() {
    return stages.get(stage.blueprint.id + 1);
  };

  return {
    stage: function() {
      return stage;
    },
    getNext: getNext
  };
};
示例#2
0
export function handleBackPress(): boolean {
	if (window.tutao.modal.components.length > 0) { // first check if any modal dialog is visible
		let activeComponent = window.tutao.modal.components[window.tutao.modal.components.length - 1]
		activeComponent.component.onClose()
		return true
	} else if (tutao.currentView instanceof LoginView && tutao.currentView.onBackPress()) {
		return true
	} else { // otherwise try to navigate back in the current view
		const viewSlider = window.tutao.header._getViewSlider()
		const currentRoute = m.route.get()
		if (viewSlider && viewSlider.isFocusPreviousPossible()) { // current view can navigate back
			viewSlider.focusPreviousColumn()
			return true
		} else if (currentRoute.startsWith("/contact") || currentRoute.startsWith("/settings")
			|| currentRoute.startsWith("/search")) {
			m.route.set(window.tutao.header.mailNavButton._getUrl())
			return true
		} else if (m.route.get().startsWith("/mail/")) {
			const parts = m.route.get().split("/").filter(part => part !== "")
			if (parts.length > 1) {
				const selectedMailListId = parts[1]
				const inboxMailListId = getInboxFolder(mailModel.mailboxDetails()[0].folders).mails
				if (inboxMailListId !== selectedMailListId) {
					m.route.set("/mail/" + inboxMailListId)
					return true
				}
			}
			return false
		} else {
			return false
		}
	}
}
示例#3
0
文件: index.js 项目: makiwiki/maki
app.oninit = function (vnode) {
  if (m.route.get() === "/") {
    location.href = "/?/HomePage"
  }
  var doArg = m.route.param("do")
  if (doArg === "auth") {
    m.mount(document.body, auth)
    return false
  }
  else if (doArg === "logout") {
    if (app.config) {
      app.condig.dbx.authTokenRevoke()
    }
    removeToken()
    app.config = null
    location.href = "/?/HomePage"
  }
  else if (doArg === "index") {
    app.config = app.config || new app.Config({ 'token': getToken() })
    app.vm.init()
    app.vm.page.name("Index")
    document.title = "Index"
    app.listPages("/")
  }
  else {
    app.config = app.config || new app.Config({ 'token': getToken() })
    app.vm.init()
    var name = m.route.get().substr(1).replace(/\?.*$/, '')
    app.vm.page.name(name)
    document.title = name
    app.renderPage(name)
  }
}
示例#4
0
文件: Header.js 项目: tutao/tutanota
 .setClickHandler(() => {
     const route = m.route.get()
     let url
     if (route.startsWith(this.contactsUrl) || route.startsWith("/search/contact")) {
         url = "/search/contact"
     } else {
         url = "/search/mail"
     }
     m.route.set(url)
 })
示例#5
0
  controller: function (bottleid) {
    bottleid = bottleid || m.route.param("bottle");

    this.bottle = m.prop({});
    this.amount = m.prop(m.route.param("amount") || 40);

    this.submit = function () {
      Drink.create(this.bottle(), this.amount()).then(m.route.bind(null, "/"));
    }.bind(this);

    Bottle.getById(bottleid).then(this.bottle);
  },
示例#6
0
	elementSelected(entries: SearchResultListEntry[], elementClicked: boolean, selectionChanged: boolean, multiSelectOperation: boolean): void {
		this._viewer.elementSelected(entries, elementClicked, selectionChanged, multiSelectOperation)
		if (entries.length === 1 && !multiSelectOperation && (selectionChanged || !this._viewer._viewer)) {
			// do not set the search url if an element is removed from this list by another view
			if (m.route.get().startsWith("/search")) {
				setSearchUrl(getSearchUrl(locator.search.lastQuery(), getRestriction(m.route.get()), entries[0]._id[1]))
			}
		}
		if (!multiSelectOperation && elementClicked) {
			this._searchList.loading().then(() => {
				this.viewSlider.focus(this.resultDetailsColumn)
			})
		}
	}
示例#7
0
文件: Header.js 项目: tutao/tutanota
 _getCenterContent(): Vnode<mixed> | null {
     const viewSlider = this._getViewSlider()
     const header = (title: string) => m(".flex-center.header-middle.items-center.text-ellipsis.b", title)
     if (this._searchBarVisible()) {
         return this._searchBar()
     } else if (viewSlider) {
         return header(viewSlider.focusedColumn.getTitle())
     } else if (m.route.get().startsWith('/login')) {
         return header(lang.get("login_label"))
     } else if (m.route.get().startsWith('/signup')) {
         return header(lang.get("registrationHeadline_msg"))
     } else {
         return null
     }
 }
示例#8
0
文件: app.js 项目: lopalo/dc
 view: function () {
     var sectionName = m.route.param("section");
     var pageName = m.route.param("page");
     var component;
     pages.forEach(function (section) {
         if (section.section === sectionName) {
             section.pages.forEach(function (page) {
                 if (page.id === pageName) {
                     component = page.component;
                 }
             });
         }
     });
     return component;
 }
示例#9
0
文件: app.js 项目: tutao/tutanota
					promise.then(view => {
						view.updateUrl(args, requestedPath)
						const currentPath = m.route.get()
						routeChange({args, requestedPath, currentPath})
						header.updateCurrentView(view)
						tutao.currentView = view
					})
示例#10
0
  submit: ({ username, password }) => {
    login.user = username === 'test' && password === 'test' && username
    login.error = !login.user && 'Wrong login - Try test/test'

    if (login.user)
      m.route.set(login.redirect)
  }
示例#11
0
 controller: function() {
   this.thread = new thread.thread();
   gapi.client.gmail.users.threads.get({ 'userId': 'me', 'id': m.route.param('id') }).execute(function(resp) {
     this.thread.messages(resp.messages);
     m.redraw();
   }.bind(this));
 },
示例#12
0
 var init = function () {
   var uInfo = auth.userInfo();
   var current = [];
   if (!c.addView()) {
     c.key = m.route.param('key');
     c.userlist = uInfo.userlists[c.key];
     current = ld.pluck(c.userlist.users, 'login');
     c.data.name(c.userlist.name);
   }
   var tags = ld.reduce(uInfo.userlists, function (memo, ul) {
     ld.each(ul.users, function (user) {
       if (!ld.includes(memo, user.login)) {
         memo.push(user.login);
         memo.push(user.email);
       }
     });
     return memo;
   }, []);
   c.tag = new tag.controller({
     name: 'users',
     label: conf.LANG.GROUP.INVITE_USER.USERS_SELECTION,
     current: current,
     placeholder: conf.LANG.GROUP.INVITE_USER.PLACEHOLDER,
     tags: tags
   });
   document.title = (c.addView() ? conf.LANG.USERLIST.ADD :
     conf.LANG.USERLIST.EDIT);
   document.title += ' - ' + conf.SERVER.title;
 };
示例#13
0
function oninit(vnode){
  var state = this
  var slug = m.route.param('article')

  state.rendered = Stream('')
  state.article = Stream()

  m.request({ method: 'GET', url: config.serverUrl + '/article/'+slug })
    .then(function(result){
      state.rendered(result.rendered)
      title.set(result.title)
      state.article(result)
    })

  function markedRenderer(){
    var renderer = new marked.Renderer();

    renderer.heading = function (text, level) {
      return [
        '<h', level, ' id="', makeID(text), '">',
          text,
        '</h', level, '>'
      ].join('')
    }

    return renderer
  }


}
示例#14
0
 var init = function () {
   var key = m.route.param('key');
   c.group = model.data()[key];
   c.pads = ld.map(c.group.pads, function (p) {
     return model.pads()[p];
   });
 };
示例#15
0
asset.controller = function () {
  var asset = assets.get(m.route.param('assetId'))
  return {
    asset: asset,
    back: function (id) { m.route('/assets') }
  }
}
示例#16
0
文件: index.js 项目: makiwiki/maki
app.view = function() {
  var cur = m.route.get()
  if (cur.indexOf("?") !== -1) {
    cur = "/?" + cur.substr(0, cur.indexOf("?"))
  }
  else {
    cur = "/?" + cur
  }
  if (app.vm.page === undefined) {
    return []
  }
  return [
    m('div', { 'id': "main", 'class': "container grid-960" }, [
      m('header', { 'class': "navbar" }, [
        m('section', { 'class': "navbar-section" }, [
          m('a', { 'href': "#", 'class': "navbar-brand", 'id': "page-name" }, app.vm.page.name())
        ]),
        m('section', { 'class': "navbar-section" }, [
          m('input', { 'type': "text", 'class': "form-input input-inline", 'placeholder': "Search" }, ''),
          m('a.btn', { 'href': "/?/HomePage" }, 'Home'),
          m('a.btn', { 'href': cur + "?do=index" }, 'Index'),
          m('a.btn', { 'href': "#" }, 'Share'), // cur + "?do=share"
          m('a.btn.btn-primary', { 'href': cur + "?do=logout" }, 'Logout')
        ])
      ]),
      app.vm.page.content()
    ])
  ]
}
示例#17
0
文件: ItemsManager.js 项目: gebv/gong
    view: function(c, args) {
        var classifer_id = m.route.param("classifer_id");

        var filter = m.component(SearchFilter, { resource_name: args.resource_name, classifer_id: classifer_id })
        var result = m.component(SearchResult, { resource_name: args.resource_name, classifer_id: classifer_id })

        return m("div.uk-margin-top", [filter, result]);
    }
示例#18
0
 onclick: function(e) {
     if (itemlink) {
         const link = itemlink.replace(/:([0-9a-zA-Z_]+)/g, function(match, p1) {
             return record[p1];
         });
         m.route.set(link);
     }
 },
示例#19
0
 add.controller = function () {
   if (!auth.isAuthenticated()) { return m.route('/login'); }
   var key = m.route.param('pad');
   var gkey = m.route.param('group');
   var opts;
   if (key) {
     opts = {
       pad: model.pads()[key],
       method: 'PUT',
       url: conf.URLS.PAD + '/' + key,
       promptMsg: GROUP.PAD.ADD_PROMPT,
       successMsg: GROUP.INFO.PAD_EDIT_SUCCESS
     };
   } else {
     opts = {
       pad: { name: '' },
       method: 'POST',
       url: conf.URLS.PAD,
       promptMsg: GROUP.PAD.EDIT_PROMPT,
       successMsg: GROUP.INFO.PAD_ADD_SUCCESS
     };
   }
   opts.pad.group = gkey;
   var name = window.prompt(opts.promptMsg, opts.pad.name);
   if (name) {
     opts.pad.name = name;
     m.request({
       method: opts.method,
       url: opts.url,
       data: opts.pad
     }).then(function (resp) {
       var pads = model.pads();
       pads[resp.key] = resp.value;
       model.pads(pads);
       if (!key) {
         var groups = model.data();
         groups[gkey].pads.push(resp.key);
         model.data(groups);
       }
       notif.success({ body: opts.successMsg });
       m.route('/mypads/group/' + gkey + '/view');
     }, function (err) { notif.error({ body: err.error }); });
   } else {
     m.route('/mypads/group/' + gkey + '/view');
   }
 };
示例#20
0
const mvCursor = ({ x, y }) => {
  const cali = calibrations[m.route.param('case')];
  const mx = window.innerWidth - ((x - cali.x) / cali.dx * window.innerWidth);
  const my = (y - cali.y) / cali.dy * window.innerHeight;

  document.querySelector('#cursor').style.top = `${my}px`;
  document.querySelector('#cursor').style.left = `${mx}px`;
};
示例#21
0
 .then(function(result){
   if(result.error){
     console.log(result.error)
   } else {
     window.onbeforeunload = null
     m.route.set('/article/'+state.article().slug)
   }
 }, function(error){
示例#22
0
			oncreate: (vnode: VirtualElement) => {
				this._domButton = vnode.dom
				// route.link adds the appropriate prefix to the href attribute and sets the domButton.onclick handler
				if (!this._isExternalUrl(a.href)) {
					m.route.link(vnode)
				}
				this._domButton.onclick = (event: MouseEvent) => this.click(event, a)
				addFlash(vnode.dom)
			},
示例#23
0
文件: Items.js 项目: gebv/gong
    controller: function(c) {
        var bucket_id = m.route.param("bucket_id");

        var api = {
            bucket_id: bucket_id,
        }

        return api;
    },
示例#24
0
文件: app.js 项目: tutao/tutanota
function forceLogin(args: {[string]: string}, requestedPath: string) {
	if (requestedPath.indexOf('#mail') !== -1) {
		m.route.set(`/ext${location.hash}`)
	} else if (requestedPath.startsWith("/#")) {
		// we do not allow any other hashes except "#mail". this prevents login loops.
		m.route.set("/login")
	} else {
		let pathWithoutParameter = requestedPath.indexOf("?") > 0
			? requestedPath.substring(0, requestedPath.indexOf("?"))
			: requestedPath
		if (pathWithoutParameter.trim() === '/') {
			let newQueryString = m.buildQueryString(args)
			m.route.set(`/login` + (newQueryString.length > 0 ? "?" + newQueryString : ""))
		} else {
			m.route.set(`/login?requestedPath=${encodeURIComponent(requestedPath)}`)
		}
	}
}
示例#25
0
 args.breadcrumbs.map(function(b) {
     if(b.link) {
         return m('h3.subheader-page', {class: b.css || ''},  m('a', {
             onclick: m.route.bind(null, b.link, b.params || {})
         }, b.label));
     }
     else {
         return m('h3.subheader-page', b.label);
     }
 }),
示例#26
0
文件: Header.js 项目: tutao/tutanota
 _searchBarVisible(): boolean {
     let route = m.route.get()
     let locator: ?MainLocatorType = window.tutao.locator
     return this.searchBar != null
         && locator != null
         && !locator.search.indexState().initializing
         && !styles.isDesktopLayout()
         && logins.isInternalUserLoggedIn()
         && (route.startsWith("/search"))
 }
示例#27
0
  init: () => {
    const pageArtist = artists[m.route.param('case')];

    vm.bandName = prop(pageArtist.name);
    vm.primaryGenre = prop(pageArtist.genre);
    vm.subGenres = prop(pageArtist.subGenres);
    vm.origin = prop(pageArtist.origin);
    vm.inducted = prop(pageArtist.inducted);
    vm.heyday = prop(pageArtist.heyday);
    vm.page = prop('ONE');
  },
示例#28
0
const touchScreen = ({ x, y }) => {
  const cali = calibrations[m.route.param('case')];

  const clickSpot = document.elementFromPoint(
    window.innerWidth - ((x - cali.x) / cali.dx * window.innerWidth),
    (y - cali.y) / cali.dy * window.innerHeight);
    console.log(clickSpot);
    mvCursor({ x, y });
    // console.log('click', `x: ${x}, y: ${y}`);
  return clickSpot && clickSpot.click();
};
示例#29
0
 .then(function(result){
   console.log(result)
   if(result.error){
     console.log(result.error)
   } else {
     window.onbeforeunload = null
     let url = `/snippet/${state.snippet().slug}`
     console.log('url', url)
     m.route.set(url)
   }
 })
示例#30
0
const view = () =>
  <html>
    <Head />
    <body>
      <div className="fullscreen-bg">
        <video loop muted autoplay className="fullscreen-bg__video">
            <source src={artists[m.route.param('case')].video} type="video/mp4" />
        </video>
      </div>
        {(vm.page() !== 'FIVE') ? eh() : <div config={trans.FIVE}></div>}
    </body>
  </html>;