p.subscribe('/settings/updateFromModel', model => {
	p.publish('/settings/patternImg', model.patternImg);
	p.publish('/settings/ui/colours/a', model.colours.a);
	p.publish('/settings/ui/colours/b', model.colours.b);
	p.publish('/settings/ui/increment', model.increment);
	p.publish('/settings/ui/stitchMarkers', model.stitchMarkers);
});
Example #2
0
p.subscribe('/save-settings', settingsModel => {

	model.pattern = new Pattern(settingsModel.patternImg);

	if(model.patternDisplay) {
		model.patternDisplay.tearDown();
	}
	model.patternDisplay = new PatternDisplay(model.pattern);

	model.stitchMarkers = new StitchMarkers(model.pattern.height, model.pattern.width);

	model.colours = {
		notDone: deepCopyObject(settingsModel.colours),
		done: {
			a: tweakColourLuminance(settingsModel.colours.a, -0.4),
			b: tweakColourLuminance(settingsModel.colours.b, -0.4)
		}
	};

	model.increment = settingsModel.increment;
	p.publish('/increment', model.increment);

	model.stitchMarkers = settingsModel.stitchMarkers;
	p.publish('/stitchMarkers', model.stitchMarkers);

	p.publish('/stitch', model.stitch);

	localStorage.patternUrl = settingsModel.patternImg.src;
	localStorage.colours = JSON.stringify(settingsModel.colours);
	localStorage.increment = settingsModel.increment;
	localStorage.stitchMarkers = JSON.stringify(settingsModel.stitchMarkers);
});
Example #3
0
	stitchCountInputEl.addEventListener('input', () => {
		let intVal = parseInt(stitchCountInputEl.value);

		if(!isNaN(intVal) && intVal >= 0 && intVal <= model.getTotalStitches() && intVal !== model.stitch) {
			p.publish('/stitch', parseInt(stitchCountInputEl.value));
		}
	});
function handleUiColourUpdate (aOrB, newColour) {
	if(hexColourPattern.test(newColour)) {
		if(newColour.lastIndexOf('#', 0) !== 0) {
			newColour = '#' + newColour;
		}

		settingsModel.colours[aOrB] = newColour;
		p.publish('/settings/colours/' + aOrB, newColour);
	}
}
Example #5
0
p.subscribe('/settings/open', () => {
	if(model.pattern) {
		p.publish('/settings/updateFromModel', {
			patternImg: model.pattern.img,
			colours: deepCopyObject(model.colours.notDone),
			increment: model.increment,
			stitchMarkers: model.stitchMarkers
		});
	}
});
Example #6
0
	function periodicResizeCheck() {
		var width = $(window).width(),
			height = $(window).height();

		if (width !== periodic_resize_check_width || height !== periodic_resize_check_height) {
			periodic_resize_check_width = width;
			periodic_resize_check_height = height;
			pubsub.publish(enums.PubSub.Client_Resize, width, height);
		}

		setTimeout(periodicResizeCheck, 500);
	}
Example #7
0
/**
 * This method publishes the received notification to the device's notification channel
 * @method handle
 * @param {Object} notification
 * @return  {Object} the result of the exectution of the native sendMail function.
 */
function handle(notification) {
  console.log("Notification " + JSON.stringify(notification));
  if (notification) {
    
    if (notification.subscription && notification.subscription.appData ) {
      
      var appData = JSON.parse(notification.subscription.appData);
      if (appData.vin) {
        
        var channelName = notifications._getChannelName(appData.vin);
      	pubsub.publish(channelName, {msg:notification}); 
      }
    }  	
  }else {
    return "Unhandled";
  }
}			
Example #8
0
	function showPage(page) {
		if (page !== current_page) {
			$('.page').hide();
			$('#page-' + page).show();

			if (page === 'login') {
				$('#login-form-username').focus();
			}

			if (page === 'lobby' || page === 'game') {
				$('body').addClass('hide-overflow');
			} else {
				$('body').removeClass('hide-overflow');
			}

			current_page = page;

			updateColorScheme();

			pubsub.publish(enums.PubSub.Client_SetPage, page);
		}
	}
Example #9
0
p.subscribe('/stitch/unpick', () => p.publish('/stitch', Math.max(model.stitch - model.increment, 0)));
Example #10
0
p.subscribe('/stitch/do', () => p.publish('/stitch', Math.min(model.stitch + model.increment, getTotalStitches())));
Example #11
0
	ready_state_check_interval = setInterval(function() {
		if (document.readyState === 'complete') {
			pubsub.publish(enums.PubSub.Client_InitializationComplete);
			clearInterval(ready_state_check_interval);
		}
	}, 10);
Example #12
0
	doUnpickEl.addEventListener('click', () => p.publish('/stitch/unpick'));
Example #13
0
	doStitchEl.addEventListener('click', () => p.publish('/stitch/do'));
Example #14
0
 $(this).on('click', function(e) {
     pubsub.publish('SHARE');
 });