summaryrefslogtreecommitdiff
path: root/plugins/cordova-plugin-crosswalk-webview/hooks
diff options
context:
space:
mode:
authorArjun Roychowdhury <pliablepixels@gmail.com>2015-10-31 08:21:38 -0400
committerArjun Roychowdhury <pliablepixels@gmail.com>2015-10-31 08:21:38 -0400
commit02811010cf62f1b21a06780d1e470d04bb24c50f (patch)
tree0d933789068aac11c810ed4bb169d14ab16c43c6 /plugins/cordova-plugin-crosswalk-webview/hooks
parentbca561c1b3989d62a1fba829e0380c6fbf36caf5 (diff)
removed unecessary files from git
Diffstat (limited to 'plugins/cordova-plugin-crosswalk-webview/hooks')
-rw-r--r--plugins/cordova-plugin-crosswalk-webview/hooks/after_plugin_install/000-shared_mode_special.js100
-rw-r--r--plugins/cordova-plugin-crosswalk-webview/hooks/before_plugin_uninstall/000-shared_mode_special.js60
2 files changed, 0 insertions, 160 deletions
diff --git a/plugins/cordova-plugin-crosswalk-webview/hooks/after_plugin_install/000-shared_mode_special.js b/plugins/cordova-plugin-crosswalk-webview/hooks/after_plugin_install/000-shared_mode_special.js
deleted file mode 100644
index b0581b02..00000000
--- a/plugins/cordova-plugin-crosswalk-webview/hooks/after_plugin_install/000-shared_mode_special.js
+++ /dev/null
@@ -1,100 +0,0 @@
-#!/usr/bin/env node
-
-module.exports = function(context) {
-
- /** @external */
- var fs = context.requireCordovaModule('fs'),
- path = context.requireCordovaModule('path'),
- deferral = context.requireCordovaModule('q').defer(),
- ConfigParser = context.requireCordovaModule("cordova-lib/src/configparser/ConfigParser"),
- XmlHelpers = context.requireCordovaModule("cordova-lib/src/util/xml-helpers"),
- et = context.requireCordovaModule('elementtree');
-
- /** @defaults */
- var xwalkVariables = {'xwalkVersion':'14+', 'xwalkCommandLine':'--disable-pull-to-refresh-effect',
- 'xwalkMode':'embedded'},
- argumentsString = context.cmdLine,
- androidPlatformDir = path.join(context.opts.projectRoot,
- 'platforms', 'android'),
- projectConfigurationFile = path.join(context.opts.projectRoot,
- 'config.xml'),
- projectManifestFile = path.join(androidPlatformDir,
- 'AndroidManifest.xml'),
- platformJsonFile = path.join(context.opts.projectRoot,
- 'plugins', 'android.json');
-
- /** Init */
- var CordovaConfig = new ConfigParser(projectConfigurationFile);
-
- var addPermission = function() {
- var projectManifestXmlRoot = XmlHelpers.parseElementtreeSync(projectManifestFile);
- var child = et.XML('<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />');
- XmlHelpers.graftXML(projectManifestXmlRoot, [child], '/manifest');
- fs.writeFileSync(projectManifestFile, projectManifestXmlRoot.write({indent: 4}), 'utf-8');
- }
-
- /** Set preference */
- var addPreferences = function() {
- var configXmlRoot = XmlHelpers.parseElementtreeSync(projectConfigurationFile);
- for (name in xwalkVariables) {
- var child = et.XML('<preference name="' + name + '" value="' + xwalkVariables[name] + '" />');
- XmlHelpers.graftXML(configXmlRoot, [child], '/*');
- }
- fs.writeFileSync(projectConfigurationFile, configXmlRoot.write({indent: 4}), 'utf-8');
- }
-
- /** The style of name align with config.xml */
- var setConfigPreference = function(name, value) {
- var localName = null;
- if (name == 'XWALK_VERSION') {
- localName = 'xwalkVersion';
- } else if (name == 'XWALK_COMMANDLINE') {
- localName = 'xwalkCommandLine';
- } else if (name == 'XWALK_MODE') {
- localName = 'xwalkMode';
- }
-
- if (localName) {
- xwalkVariables[localName] = value;
- }
- }
-
- /** Pase the cli command to get the specific preferece*/
- var parseCliPreference = function() {
- var commandlineVariablesList = argumentsString.split('variable');
- if (commandlineVariablesList) {
- commandlineVariablesList.forEach(function(element) {
- var spaceList = element.split(' ');
- if (spaceList) {
- spaceList.forEach(function(element) {
- var preference = element.split('=');
- if (preference && preference.length == 2) {
- setConfigPreference(preference[0].toUpperCase(), preference[1]);
- }
- });
- }
- });
- }
- }
-
- /** Main method */
- var main = function() {
- // Parse cli preference
- parseCliPreference();
-
- // Add xwalk preference to config.xml
- addPreferences();
-
- if (xwalkVariables['xwalkMode'] == 'shared') {
- // Add the permission of write_external_storage in shared mode
- addPermission();
- }
-
- deferral.resolve();
- };
-
- main();
-
- return deferral.promise;
-
-};
diff --git a/plugins/cordova-plugin-crosswalk-webview/hooks/before_plugin_uninstall/000-shared_mode_special.js b/plugins/cordova-plugin-crosswalk-webview/hooks/before_plugin_uninstall/000-shared_mode_special.js
deleted file mode 100644
index 2cc741d3..00000000
--- a/plugins/cordova-plugin-crosswalk-webview/hooks/before_plugin_uninstall/000-shared_mode_special.js
+++ /dev/null
@@ -1,60 +0,0 @@
-#!/usr/bin/env node
-
-module.exports = function(context) {
-
- /** @external */
- var fs = context.requireCordovaModule('fs'),
- path = context.requireCordovaModule('path'),
- deferral = context.requireCordovaModule('q').defer(),
- ConfigParser = context.requireCordovaModule("cordova-lib/src/configparser/ConfigParser"),
- XmlHelpers = context.requireCordovaModule("cordova-lib/src/util/xml-helpers"),
- et = context.requireCordovaModule('elementtree');
-
- /** @defaults */
- var xwalkVariables = ['xwalkVersion', 'xwalkCommandLine', 'xwalkMode'];
- androidPlatformDir = path.join(context.opts.projectRoot,
- 'platforms', 'android'),
- projectConfigurationFile = path.join(context.opts.projectRoot,
- 'config.xml'),
- projectManifestFile = path.join(androidPlatformDir,
- 'AndroidManifest.xml');
-
- /** Init */
- var CordovaConfig = new ConfigParser(projectConfigurationFile);
-
- var removePermission = function() {
- var projectManifestXmlRoot = XmlHelpers.parseElementtreeSync(projectManifestFile);
- var child = et.XML('<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />');
- XmlHelpers.pruneXML(projectManifestXmlRoot, [child], '/manifest');
- fs.writeFileSync(projectManifestFile, projectManifestXmlRoot.write({indent: 4}), 'utf-8');
- }
-
- var removeXWalkVariables = function() {
- var configXmlRoot = XmlHelpers.parseElementtreeSync(projectConfigurationFile);
- for (var index = 0; index < xwalkVariables.length; index++) {
- var child = configXmlRoot.find('./preference[@name="' + xwalkVariables[index] + '"]');
- if (child) {
- XmlHelpers.pruneXML(configXmlRoot, [child], '/*');
- }
- }
- fs.writeFileSync(projectConfigurationFile, configXmlRoot.write({indent: 4}), 'utf-8');
- }
-
- /** Main method */
- var main = function() {
- // Remove the xwalk variables
- removeXWalkVariables();
-
- if (CordovaConfig.getGlobalPreference('xwalkMode') == 'shared') {
- // Add the permission of write_external_storage in shared mode
- removePermission();
- }
-
- deferral.resolve();
- };
-
- main();
-
- return deferral.promise;
-
-};