Skip to content

Instantly share code, notes, and snippets.

@daserge
daserge / splashscreen.js
Created December 13, 2016 11:56
splashscreen titlebar colorize with fading
/*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
// file: F:/coho/cordova-windows/cordova-js-src/confighelper.js
define("cordova/confighelper", function(require, exports, module) {
// config.xml wrapper (non-node ConfigParser analogue)
var config, doc;
var utils = require("cordova/utils");
var isPhone = (cordova.platformId == 'windows') && WinJS.Utilities.isPhone;
var isWin10UWP = navigator.appVersion.indexOf('MSAppHost/3.0') !== -1;
var manifestFilePath = isWin10UWP ? "/package.windows10.appxmanifest" : (isPhone ? "/package.phone.appxmanifest" : "/package.windows.appxmanifest");
(get-content config.xml) | foreach-object {
$wordToFind='windows-target-version'
$containsWord=$_ -match $wordToFind
If($containsWord -contains $true) {
$_ -replace '(<preference name=\"windows-target-version\" value=\")([^\"]+)(\" \/><\/widget>)', '${1}10.0${3}'
} Else {
$_ -replace '<\/widget>', '<preference name="windows-target-version" value="10.0" /></widget>'
}
} | set-content config.xml
@daserge
daserge / cordova-docs-gen.md
Last active September 3, 2015 16:46
Cordova docs-gen proposal

Cordova docs-gen proposal

  • Use JSDoc for code documentation for following reasons:
    • JSDoc parses code-tree, which means smart code analysis, internal linking and less comments verbosity in code,
    • JSDoc is extensible via JS plugins,
    • JSDoc presentation is customizable via templates,
    • Existing code uses JSDoc format mostly;
  • Use either JSDoc or jsdoc-to-markdown to generate documentation HTML/md,
    • In case of jsdoc-to-markdown we will need to set up code linking (it is included by JSDoc by default but not by jsdoc-to-markdown);
  • Create JSDoc plugin for handling Cordova-specific tags like supported-platforms, quirks (or windows-quirks, android-quirks, ...), etc.,
  • Investigate possibility: Link to quirks/examples (similar to tutorial tag) instead of inlining to reduce noise in
@daserge
daserge / logcat.ps1
Last active May 4, 2016 09:38
adb logcat filter by package id
adb logcat | Select-String (adb shell ps | findstr io.cordova.hellocordova).Split("", [System.StringSplitOptions]::RemoveEmptyEntries)[1]
@daserge
daserge / HostedWebAppPluginProxy.js
Last active August 29, 2015 14:23
Cordova hosted app for Windows 10 (based on ManifoldJS template)
webView.addEventListener("MSWebViewScriptNotify", scriptNotify);
...
function scriptNotify(e) {
console.log('scriptNotify e: ' + e.value);
var opts = JSON.parse(e.value);
var callbackId = opts.callbackId;
var exec = cordova.require('cordova/exec');
function success(result, callbackOptions) {
@daserge
daserge / commands.bat
Created November 22, 2014 09:57
Create cordova project from a template
Create project, add platforms and plugin, copy www contents from template, run different platforms:
cdv create test
cd test
cdv platform add windows
cdv platform add wp8
cdv plugin add "..\cordova-plugin-globalization"
rmdir /s /q www
echo d | xcopy /e /v ..\template\www www
cdv run windows
cdv run wp8
@daserge
daserge / create-mobile-spec-windows.md
Last active November 10, 2015 17:53
Create mobile-spec from scratch on Windows

To create mobilespec from scratch use these commands (as Administrator):
Note: There should not be any spaces in the root path!

git clone https://github.com/apache/cordova-mobile-spec
cd cordova-mobile-spec\createmobilespec\
npm install
cd ..\..
git clone https://git-wip-us.apache.org/repos/asf/cordova-coho.git
cd cordova-coho\
@daserge
daserge / BatteryProxy.js
Created November 13, 2014 12:15
Cordova Windows plugin: Winmd + event subscription in JS
cordova.define("org.apache.cordova.battery-status.Battery", function(require, exports, module) { /*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
@daserge
daserge / BatteryProxy.js
Created November 13, 2014 11:51
Cordova Windows plugin: Winmd + callback from JS
cordova.define("org.apache.cordova.battery-status.Battery", function (require, exports, module) { /*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*