Пример #1
0
function search(e) {
  if(e.keyCode != 13) return true;
  var commandStr = $("#search>input").val();
  console.log(commandStr);
  command(commandStr);
  $("#search>input").val("");
  return false;
}
Пример #2
0
 handleOutcome(outcome) {
   if (outcome === "win") {
     this.currentLevel++;
     $('#winGameModal').show();
   } else {
     $('#loseGameModal').show();
     this.playAgain();
   }
 }
Пример #3
0
 UI.CARD_GROUPS.forEach(function(tabName){
   var itemsLeft = $("#" + tabName + ">.item");
   var tab = $("#" + tabName);
   if(itemsLeft.length == 0) {
     tab.empty();
     var placeholder = $("#" + tabName + "Placeholder");
     placeholder.removeClass("closed");
   }
 });
Пример #4
0
			$(win.document).on("click", "a[href]:not([data-bypass])", function(evt) {
				var href = { prop: $(this).prop("href"), attr: $(this).attr("href") };
				var root = win.location.protocol + "//" + win.location.host;

				if (href.prop.slice(0, root.length) === root) {
					evt.preventDefault();
					Backbone.history.navigate(href.attr, true);
				}
			});
Пример #5
0
 addItem: function (area, subreddit, status) {
   var items = $("#" + area);
   var placeholder = $("#" + area + "Placeholder");
   if(!placeholder.hasClass("closed")) {
     items.append(UI.DIVIDER);
     placeholder.addClass("closed");
   }
   items.append(UI.ITEM_TEMPLATE.replace(/\{\{Name\}\}/g, subreddit).replace(/\{\{Status\}\}/g, status));
   items.append(UI.DIVIDER.replace(/\{\{Name\}\}/g, subreddit));
 },
Пример #6
0
 function CatList(opts){
     //用来判断是否需要重新请求
     this.cacheFlag = {};
     //用来存储数据
     this.cache = {};
     this.$tabBdWrap = $(opts.bd);
     this.$tabHdWrap = $(opts.hd);
     this.tpl = $(opts.tpl).html();
     this.inited = false;
     getCats.get().then($.proxy(this.getData,this) );
 };
Пример #7
0
    function main () {
        if ($(".resourceworkaround").length > 0) {
            window.location.href = $(".resourceworkaround")
                                   .find("a")
                                   .prop("href");
        }

        if ($(".urlworkaround").length > 0) {
            window.location.href = $(".urlworkaround").find("a").prop("href");
        }
    }
Пример #8
0
 function UICharacter(controller, character, parent, wrapper){
     this.character = character;
     this.controller = controller;
     this.template = tmpl;
     this.parent = parent || document.body;
     this.wrapper = wrapper || document.createElement('div');
     this.parent.appendChild(this.wrapper);
     this.$parent = $(this.parent);
     this.$wrapper = $(this.wrapper);
     this.$wrapper.html(tmpl(this.templateData));
     this.createUiData();
 }
	_onAlways: function (jqXHRorResult, textStatus, jqXHRorError, options) {
		$.blueimpUI.fileupload.prototype._onAlways.call(this, jqXHRorResult, textStatus, jqXHRorError, options);

		if(typeof(jqXHRorError) === 'string') {
			$('.fileOverview .uploadStatus .state').text(i18n._t('AssetUploadField.UploadField.UPLOADFAIL', 'Sorry your upload failed'));
			$('.fileOverview .uploadStatus').addClass("bad").removeClass("good").removeClass("notice");
		} else if (jqXHRorError.status === 200) {
			$('.fileOverview .uploadStatus .state').text(i18n._t('AssetUploadField.FILEUPLOADCOMPLETED', 'File upload completed!'));//.hide();
			$('.ss-uploadfield-item-edit-all').show();
			$('.fileOverview .uploadStatus').addClass("good").removeClass("notice").removeClass("bad");
		}
	},
Пример #10
0
$(document).ready(function() {
  var menuToggle;
  menuToggle = $('#js-centered-navigation-mobile-menu').unbind();
  $('#js-centered-navigation-menu').removeClass('show');
  menuToggle.on('click', function(e) {
    e.preventDefault();
    $('#js-centered-navigation-menu').slideToggle(function() {
      if ($('#js-centered-navigation-menu').is(':hidden')) {
        $('#js-centered-navigation-menu').removeAttr('style');
      }
    });
  });
});
Пример #11
0
			titles.each(function(){
				var href= base_url($(this).attr("href"));
				var found_word = $(this).text();
				fs.appendFile("parse_log.txt", word+"::"+found_word+"\n", 'UTF-8');
				word_def = $.get(href,function(html){
					try{
						fs.mkdirSync("words");
					}catch(ex){	}

					//如果抓過就跳過
					// if(fs.existsSync("words/"+found_word)){
					// 	return true;
					// }
					try{
						fs.mkdirSync("words/"+found_word);
					}catch(ex){}
					$(html).find(".leftm a").each(function(ind){
						var item = "";

						if($(this).attr("href") == "#XX"){
							return true;
						}
						var defered = null;
						switch(ind){
							case 0:
							 	defered = handle_pronounce_maining(found_word,base_url($(this).attr("href")));
							 	break;
							case 1:
								defered = handle_source(found_word,base_url($(this).attr("href")));
								break;
							case 2:
								defered = handle_source_description(found_word,base_url($(this).attr("href")));
								break;
							case 3:
								defered = handle_reference(found_word,base_url($(this).attr("href")));
								break;
							case 4:
								defered = handle_usage(found_word,base_url($(this).attr("href")));
								break;
							case 5:
								defered = handle_recognize(found_word,base_url($(this).attr("href")));
								break;
							case 6:
								defered = handle_related_word(found_word,base_url($(this).attr("href")));
								break;
						}
						content_deferes.push(defered);
					});
				});
				word_defs.push(word_def);
			});
Пример #12
0
					$(html).find(".leftm a").each(function(ind){
						var item = "";

						if($(this).attr("href") == "#XX"){
							return true;
						}
						var defered = null;
						switch(ind){
							case 0:
							 	defered = handle_pronounce_maining(found_word,base_url($(this).attr("href")));
							 	break;
							case 1:
								defered = handle_source(found_word,base_url($(this).attr("href")));
								break;
							case 2:
								defered = handle_source_description(found_word,base_url($(this).attr("href")));
								break;
							case 3:
								defered = handle_reference(found_word,base_url($(this).attr("href")));
								break;
							case 4:
								defered = handle_usage(found_word,base_url($(this).attr("href")));
								break;
							case 5:
								defered = handle_recognize(found_word,base_url($(this).attr("href")));
								break;
							case 6:
								defered = handle_related_word(found_word,base_url($(this).attr("href")));
								break;
						}
						content_deferes.push(defered);
					});
Пример #13
0
        build: function () {
            var $modalContainer = $('<div />', {
                                    class: ['modal', this.opts.effectType].join(' ')
                                  })
                                  .attr({
                                    'role': 'dialog',
                                    'data-backdrop': this.opts.closeOnBgClick === false ? 'static' : this.opts.openAsModal,
                                    'aria-labelledby': this.opts.title
                                  })

            ,   $modalDialog = $('<div />', { class: ['modal-dialog', this.opts.size].join(' ') })
            ,   $modalContent = $('<div />', { class: 'modal-content' })
            ,   $modalHeader = $('<div />', { class: 'modal-header' })
            ,   $modalBody = $('<div />', { class: 'modal-body' })
            ,   $modalFooter = $('<div />', { class: 'modal-footer' })
            ,   $closeBtn = $('<button />', {
                            class: 'close'
                            })
                            .attr({
                                'aria-hidden': true,
                                'type': 'button'
                            })
                            .html('&times;')
                            .on('click', function (e) {
                                this.close(false);
                            }.bind(this));

            $modalHeader.append($closeBtn);

            if (this.opts.title != null) {
                var $modalTitle = $('<h4 />', { class: 'modal-title', text: this.opts.title });
                $modalHeader.append($modalTitle);
            }

            //Load Content		
            $modalBody.append(this.opts.content);

            //Load Buttons
            if (this.opts.buttons == null) {
                if (!this.opts.hideCancelButton) {
                    $modalFooter.append(this.buttonFactory(defaultButtons.Cancel, 'Cancel'));
                }
                $modalFooter.append(this.buttonFactory(defaultButtons.Ok, 'Ok'));
            } else {
                if (typeof this.opts.buttons != 'object') {
                    throw Error('Buttons must be passed in a an object');
                }

                for (var btn in this.opts.buttons) {
                    $modalFooter.prepend(this.buttonFactory(this.opts.buttons[btn], btn));
                }
            }

            $modalContent.append($modalHeader, $modalBody, $modalFooter);
            $modalDialog.append($modalContent);
            $modalContainer.append($modalDialog);

            return $modalContainer;
        },
Пример #14
0
function(views, models, Core, tmpl){
    var $ = require('jQuery');
    var Backbone = require('Backbone');
    var _ = require('Underscore');

    function log(){
        console.log(arguments);
    }
    var albums = new models.AlbumCollection();
    albums.bind('all', log);

    var albums_view = new views.AlbumCollectionView({
        collection: albums
    });
    albums_view.setElement($('[data-ui=albums]'));
    albums_view.render();
    albums.fetch();

    var files_view;

    $(document).bind('item_selected', function(event, album){
        console.log("Following item was selected:", arguments);
        //var photos = album.fileCollection();
        //photos.fetch();
        if(files_view)
            files_view.remove();
        var collection = album.fileCollection();
        files_view = new views.FilesLayout({
            'album': album,
            collection: collection,
            el: $('[data-ui=files_layout]')
        });
        files_view.render();
        files_view.getView('file_list').collection.fetch();
/*
        upload_view = new Core.views.UploadFileView({
            item_template: tmpl['upload_file.html'],
            template: tmpl['upload_form.html'],
            el:$('[data-ui=upload_form]'),
            formData: [{
                'name': 'album',
                'value': album.id
            }]
        });
        upload_view.render();
        */
    })

});
Пример #15
0
module.exports = function (config) {
    $('body, html').attr('style', 'height:100%;min-height:100%;margin:0');
    var frame = Frame(config);
    var screen = Screen(config.max);
    var heartbeat;

    return {
        run: function () {
            heartbeat = window.setInterval(function () {
                screen.window({
                    width: $(window).width(),
                    height: $(window).height()
                });

                var frameCount = frame.count(screen.upright());
                var tall = screen.window().height / frameCount.height;
                var wide = screen.window().width / frameCount.width;
                var tile = Math.min(tall, wide);

                frame.size({
                    upright: screen.upright(),
                    window: screen.window(),
                    tile: tile,
                    count: frameCount
                });
            }, 500);
        },
        wait: function () {
            window.clearInterval(heartbeat);
        }
    };
};
Пример #16
0
    it('should render start when paused', () => {
      var controls = TestUtils.renderIntoDocument(<Controls countdownStatus='paused'/>);
      var $el = $(ReactDOM.findDOMNode(controls));
      var $startButton = $el.find('button:contains(Start)');

      expect($startButton.length).toBe(1);
    });
Пример #17
0
    }, function(err, window) {
      //Use jQuery just as in a regular HTML page
      var $ = window.jQuery;
      var newsList = new Array();

      $("#smuImageRotator .smuImageList li").each(function(index, value) {
        // console.log(index, value);
        newsList[index] = {
          articleId: GlobalID,
          title: $(value).find(".smuImageTitleText").text(),
          imgsrc: $(value).find('div img').attr('src'),
          desktopLink: $(value).find('a').attr('href')
        };
        var pat = /^https?:\/\//i;
        if (pat.test(newsList[index].desktopLink))
          ;
        else
          newsList[index].desktopLink = 'http://www.smu.ca/' + newsList[index].desktopLink;

        //var tempArticle = new Article(newsList[index]);
        //tempArticle.save(function(){console.log('Article Saved');});
        //console.log(newsList[index]);

        Article.create(newsList[index], function(err) {
          if (err)
            console.log(err);
          //console.log("Article Saved");
        });
        GlobalID++;
      });
      //socket.emit('News Feed List',newsList);
      //console.log(newsList);
      //console.log('news article');
    });
Пример #18
0
 }, function(err, window) {
   //Use jQuery just as in a regular HTML page
   var $ = window.jQuery;
   news.html = $(".templateBodyRightcol").html();
   socket.emit('News Article', news);
   //console.log( JSON.stringify(newsArticle,null,'\t') );
 });
Пример #19
0
 control.catNavListen = function() {
	$('.menu').on('click', '.menu--nav--cats', function(event) {
		$('.panel').remove();
		let menu = model.getMenu();
		view.renderCategory(event.target.id, menu);
	});
};
        parseFunction: function (paraTag) {
            var $header,
                header,
                $code,
                code,
                desc,
                $this = $(paraTag);

            $header = $this.find("b.header");
            header = $header.html();
            $code = $this.find("code");
            code = $code.html();
            $header.remove();
            $code.remove();
            desc = $this.text();

            var descSplit = desc.split("\n");
            var newDesc = "";
            for (var i = 0; i < descSplit.length; i++) {
                var thisDessLine = descSplit[i].replace(/^\s+/, "");
                if (thisDessLine) {
                    newDesc += thisDessLine + " ";
                }
            }

            return util.format(functionFormat, header, newDesc.replace(/[\n\r]/g, ""), parser.parseFunctionParams(header, code));
        }
Пример #21
0
 control.panelListen = function() {
	$('.interface').on('click', '.ingred', function(event) {
		let name = $(event.currentTarget).children('.ingred--name').text();
		let price = $(event.currentTarget).children('.ingred--price').text();
		model.addToOrder(name, price);
	});
};
Пример #22
0
    $(document).bind('item_selected', function(event, album){
        console.log("Following item was selected:", arguments);
        //var photos = album.fileCollection();
        //photos.fetch();
        if(files_view)
            files_view.remove();
        var collection = album.fileCollection();
        files_view = new views.FilesLayout({
            'album': album,
            collection: collection,
            el: $('[data-ui=files_layout]')
        });
        files_view.render();
        files_view.getView('file_list').collection.fetch();
/*
        upload_view = new Core.views.UploadFileView({
            item_template: tmpl['upload_file.html'],
            template: tmpl['upload_form.html'],
            el:$('[data-ui=upload_form]'),
            formData: [{
                'name': 'album',
                'value': album.id
            }]
        });
        upload_view.render();
        */
    })
Пример #23
0
 return function() {
   var number = Math.floor((Math.random() * self.colorsArray.length));
   var cell = self.grid.cellArray[Math.floor(Math.random() * self.grid.cellArray.length)];
   var id = cell.id;
   var colors = self.colorsArray[number];
   $("td" +"#" + id).attr('class', colors);
 };
Пример #24
0
 unfocus: function () {
     $(this.$dialog).css({
         'zIndex': 1030
     }).find('.modal-body').css({
         'zIndex': 1030
     });
 },
Пример #25
0
	return $.get(href,function(res){
		var $res = $(res);

		var obj = {
			recognized : $res.find(".std2").html()
		};
		fs.writeFileSync("words/"+word+"/recognize",JSON.stringify(obj) , "UTF-8");
	});
Пример #26
0
	return $.get(href,function(res){
		var $res = $(res);

		var obj = {
			sourceDescripton:$res.find(".std2:eq(0)").html()
		};
		fs.writeFileSync("words/"+word+"/sourceDescripton",JSON.stringify(obj) , "UTF-8");
	});
Пример #27
0
 menuToggle.on('click', function(e) {
   e.preventDefault();
   $('#js-centered-navigation-menu').slideToggle(function() {
     if ($('#js-centered-navigation-menu').is(':hidden')) {
       $('#js-centered-navigation-menu').removeAttr('style');
     }
   });
 });
Пример #28
0
  index: function(){
    var postList = new views.PostListView({
      collection: this.collection
    });
    $('.app').append(postList.render().el);

    this.collection.fetch();
  },
Пример #29
0
	_onAdd: function(e, data) {
		// use _onAdd instead of add since we only want it called once for a file set, not for each file
		var result = $.blueimpUI.fileupload.prototype._onAdd.call(this, e, data);
		var firstNewFile = this._files.find('.ss-uploadfield-item').slice(data.files.length*-1).first();
		var top = '+=' + (firstNewFile.position().top - parseInt(firstNewFile.css('marginTop'), 10) || 0 - parseInt(firstNewFile.css('borderTopWidth'), 10) || 0);
		firstNewFile.offsetParent().animate({scrollTop: top}, 1000);

		/* Compute total size of files */
		var fSize = 0;
		for(var i = 0; i < data.files.length; i++){
			if(typeof data.files[i].size === 'number'){
				fSize = fSize + data.files[i].size;
			}
		}

		$('.fileOverview .uploadStatus .details .total').text(data.files.length);
		if(typeof fSize === 'number' && fSize > 0){
			fSize = this._formatFileSize(fSize);
			$('.fileOverview .uploadStatus .details .fileSize').text(fSize);
		}

		//Fixes case where someone uploads a single erroring file
		if(data.files.length == 1 && data.files[0].error !== null){
			$('.fileOverview .uploadStatus .state').text(i18n._t('AssetUploadField.UploadField.UPLOADFAIL', 'Sorry your upload failed'));
			$('.fileOverview .uploadStatus').addClass("bad").removeClass("good").removeClass("notice");
		}else{
			$('.fileOverview .uploadStatus .state').text(i18n._t('AssetUploadField.UPLOADINPROGRESS', 'Please wait… upload in progress'));//.show();
			$('.ss-uploadfield-item-edit-all').hide();
			$('.fileOverview .uploadStatus').addClass("notice").removeClass("good").removeClass("bad");
		}

		return result;
	},
Пример #30
0
            heartbeat = window.setInterval(function () {
                screen.window({
                    width: $(window).width(),
                    height: $(window).height()
                });

                var frameCount = frame.count(screen.upright());
                var tall = screen.window().height / frameCount.height;
                var wide = screen.window().width / frameCount.width;
                var tile = Math.min(tall, wide);

                frame.size({
                    upright: screen.upright(),
                    window: screen.window(),
                    tile: tile,
                    count: frameCount
                });
            }, 500);