How to use settings.read method in Cypress

Best JavaScript code snippet using cypress

app-settings.js

Source:app-settings.js Github

copy

Full Screen

1/*2File: app-settings.js3Description: Handling of settings for an app.4File evothings.json in the app folder contains settings.5Author: Mikael Kindborg6License:7Copyright (c) 2015 Evothings AB8Licensed under the Apache License, Version 2.0 (the "License");9you may not use this file except in compliance with the License.10You may obtain a copy of the License at11	http://www.apache.org/licenses/LICENSE-2.012Unless required by applicable law or agreed to in writing, software13distributed under the License is distributed on an "AS IS" BASIS,14WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.15See the License for the specific language governing permissions and16limitations under the License.17*/18/*********************************/19/***	 Imported modules	   ***/20/*********************************/21var FS = require('fs')22var PATH = require('path')23var FILEUTIL = require('./file-util.js')24var UUID = require('./uuid.js')25/*********************************/26/***	   App settings		   ***/27/*********************************/28/**29 * Get the app ID. Create ID if it does not exist.30 * This ID is used to identify apps.31 */32exports.getOrCreateAppID = function(appPath) {33	var settings = readAppSettings(appPath) || {}34	if (!(settings['uuid'])) {35		settings['uuid'] = UUID.generateUUID()36		writeAppSettings(settings, appPath)37	}38	return settings['uuid']39}40/**41 * Get the app ID, return null if it does not exist.42 */43exports.getAppID = function(appPath) {44	var settings = readAppSettings(appPath)45	if (settings && settings['uuid']) {46		return settings['uuid']47	}48	return null49}50/**51 * Return short name for app, or null if not set.52 */53exports.getName = function(appPath) {54	var settings = readAppSettings(appPath)55	if (settings && settings['name']) {56		return settings['name']57	}58	return null59}60exports.setName = function(appPath, name) {61	var settings = readAppSettings(appPath)62	if (settings) {63		settings['name'] = name64		writeAppSettings(settings, appPath)65	}66	return null67}68/**69 * Return title for app, or null if not set.70 */71exports.getTitle = function(appPath) {72	var settings = readAppSettings(appPath)73	if (settings && settings['title']) {74		return settings['title']75	}76	// Otherwise we try to extract it from title tag77	return getTitleFromFile(appPath)78}79exports.setTitle = function(appPath, title) {80	var settings = readAppSettings(appPath)81	if (settings) {82		settings['title'] = title83		writeAppSettings(settings, appPath)84		// Here we ought to set it in the index file too85	}86	return null87}88function getTitleFromFile(path) {89	// Is it an HTML file?90	if (FILEUTIL.fileIsHTML(path)) {91			var indexPath = path92	}	else if (FILEUTIL.directoryHasEvothingsJson(path)) {93		// Is it a directory with evothings.json in it?94		// Read index file from evothings.json95		var indexPath = exports.getIndexFileFullPath(path)96	}	else 	{97		// Return null on unknown file type.98		return null99	}100	// Read app main file.101	var data = FILEUTIL.readFileSync(indexPath)102	if (!data) {103		// Return null on error (file does not exist).104		return null105	}106	var title = getTagContent(data, 'title')107	if (!title) {108		// If title tag is missing, use short form of path as title.109		title = getNameFromPath(indexPath)110	}111	return title112}113function getTagContent(data, tag)114{115	var tagStart = '<' + tag + '>'116	var tagEnd = '</' + tag + '>'117	var pos1 = data.indexOf(tagStart)118	if (-1 === pos1) { return null }119	var pos2 = data.indexOf(tagEnd)120	if (-1 === pos2) { return null }121	return data.substring(pos1 + tagStart.length, pos2)122}123// Use last part of path as name.124// E.g. '/home/apps/HelloWorld/index.html' -> 'HelloWorld/index.html'125// Use full path as fallback.126function getNameFromPath(path)127{128	path = path.replace(new RegExp('\\' + PATH.sep, 'g'), '/')129	var pos = path.lastIndexOf('/')130	if (-1 === pos) { return path }131	pos = path.lastIndexOf('/', pos - 1)132	if (-1 === pos) { return path }133	return path.substring(pos + 1)134}135/**136 * Return oneline description for app, or null if not set.137 */138exports.getDescription = function(appPath)139{140	var settings = readAppSettings(appPath)141	if (settings && settings['description'])142	{143		return settings['description']144	}145	else146	{147		return null148	}149}150exports.setDescription = function(appPath, description)151{152	var settings = readAppSettings(appPath)153	if (settings)154	{155		settings['description'] = description156		writeAppSettings(settings, appPath)157	}158	else159	{160		return null161	}162}163/**164 * Return long description for app, or null if not set.165 */166exports.getLongDescription = function(appPath)167{168	var settings = readAppSettings(appPath)169	if (settings && settings['long-description'])170	{171		return settings['long-description']172	}173	else174	{175		return null176	}177}178exports.setLongDescription = function(appPath, description)179{180	var settings = readAppSettings(appPath)181	if (settings)182	{183		settings['long-description'] = description184		writeAppSettings(settings, appPath)185	}186	else187	{188		return null189	}190}191/**192 * Return version string for app, or null if not set.193 */194exports.getVersion = function(appPath)195{196	var settings = readAppSettings(appPath)197	if (settings && settings['version'])198	{199		return settings['version']200	}201	else202	{203		return null204	}205}206exports.setVersion = function(appPath, version)207{208	var settings = readAppSettings(appPath)209	if (settings)210	{211		settings['version'] = version212		writeAppSettings(settings, appPath)213	}214	else215	{216		return null217	}218}219/**220 * Return Cordova ID (reverse domain style) for app, or null if not set.221 */222exports.getCordovaID = function(appPath)223{224	var settings = readAppSettings(appPath)225	if (settings && settings['cordova-id'])226	{227		return settings['cordova-id']228	}229	else230	{231		return null232	}233}234exports.setCordovaID = function(appPath, version)235{236	var settings = readAppSettings(appPath)237	if (settings)238	{239		settings['cordova-id'] = version240		writeAppSettings(settings, appPath)241	}242	else243	{244		return null245	}246}247/**248 * Return Author name for app, or null if not set.249 */250exports.getAuthorName = function(appPath)251{252	var settings = readAppSettings(appPath)253	if (settings && settings['author-name'])254	{255		return settings['author-name']256	}257	else258	{259		return null260	}261}262exports.setAuthorName = function(appPath, version)263{264	var settings = readAppSettings(appPath)265	if (settings)266	{267		settings['author-name'] = version268		writeAppSettings(settings, appPath)269	}270	else271	{272		return null273	}274}275/**276 * Return Author email for app, or null if not set.277 */278exports.getAuthorEmail = function(appPath)279{280	var settings = readAppSettings(appPath)281	if (settings && settings['author-email'])282	{283		return settings['author-email']284	}285	else286	{287		return null288	}289}290exports.setAuthorEmail = function(appPath, version)291{292	var settings = readAppSettings(appPath)293	if (settings)294	{295		settings['author-email'] = version296		writeAppSettings(settings, appPath)297	}298	else299	{300		return null301	}302}303/**304 * Return Author URL for app, or null if not set.305 */306exports.getAuthorURL = function(appPath)307{308	var settings = readAppSettings(appPath)309	if (settings && settings['author-url'])310	{311		return settings['author-url']312	}313	else314	{315		return null316	}317}318exports.setAuthorURL = function(appPath, version)319{320	var settings = readAppSettings(appPath)321	if (settings)322	{323		settings['author-url'] = version324		writeAppSettings(settings, appPath)325	}326	else327	{328		return null329	}330}331/**332 * Return path to app image icon, or null if not set.333 */334exports.getAppImage = function(appPath)335{336	var settings = readAppSettings(appPath)337	if (settings && settings['icon']) {338		return settings['icon']339	} else {340		return null341	}342}343/**344 * Return URL to app documentation online, or null if not set.345 */346exports.getDocURL = function(appPath)347{348	var settings = readAppSettings(appPath)349	if (settings && settings['doc-url']) {350		return settings['doc-url']351	} else {352		return null353	}354}355/**356 * Return tags, or null if not set.357 */358exports.getTags = function(appPath)359{360	var settings = readAppSettings(appPath)361	if (settings && settings['tags']) {362		return settings['tags']363	} else {364		return null365	}366}367exports.setTags = function(appPath, tags)368{369	var settings = readAppSettings(appPath)370	if (settings) {371		settings['tags'] = tags372		writeAppSettings(settings, appPath)373	} else {374		return null375	}376}377/**378 * Return libraries, or null if not set.379 */380exports.getLibraries = function(appPath)381{382	var settings = readAppSettings(appPath)383	if (settings && settings['libraries'])384	{385		return settings['libraries']386	}387	else388	{389		return null390	}391}392exports.setLibraries = function(appPath, libraries)393{394	var settings = readAppSettings(appPath)395	if (settings)396	{397		settings['libraries'] = libraries398		writeAppSettings(settings, appPath)399	}400	else401	{402		return null403	}404}405/**406 * Return plugins.407 */408exports.getPlugins = function(appPath)409{410	var settings = readAppSettings(appPath)411	if (settings && settings['plugins'])412	{413		return settings['plugins']414	}415	else416	{417		return []418	}419}420exports.setPlugins = function(appPath, plugins)421{422	var settings = readAppSettings(appPath)423	if (settings)424	{425		settings['plugins'] = plugins426		writeAppSettings(settings, appPath)427	}428	else429	{430		return null431	}432}433/**434 * Generate and save a new App UUID.435 */436exports.generateNewAppUUID = function(appPath)437{438	var settings = readAppSettings(appPath)439	if (settings)440	{441		settings['uuid'] = UUID.generateUUID()442		writeAppSettings(settings, appPath)443	}444	else445	{446		return null447	}448}449/**450 * Set the app HTML file path.451 */452exports.setIndexFile = function(appPath, indexPath)453{454	var settings = readAppSettings(appPath)455	if (settings)456	{457		settings['index-file'] = indexPath458		writeAppSettings(settings, appPath)459	}460	else461	{462		return null463	}464}465/**466 * Get the app HTML file name.467 */468exports.getIndexFile = function(appPath)469{470	var settings = readAppSettings(appPath)471	if (settings)472	{473		return settings['index-file']474	}475	else476	{477		return null478	}479}480/**481 * Directory for app source files.482 */483exports.getAppDir = function(appPath)484{485	var settings = readAppSettings(appPath)486	if (settings)487	{488		return settings['app-dir']489	}490	else491	{492		return null493	}494}495/**496 * Directory for app libraries.497 */498exports.getLibDir = function(appPath)499{500	var appDir = exports.getAppDir(appPath)501	if (appDir) {502	  return PATH.join(appDir, 'libs')503	} else {504	  return 'libs'505	}506}507exports.getLibDirFullPath = function(appPath)508{509	return PATH.join(appPath, exports.getLibDir(appPath))510}511/**512 * Directory for built files.513 */514exports.getWwwDir = function(appPath)515{516	var settings = readAppSettings(appPath)517	if (settings)518	{519		return settings['www-dir']520	}521	else522	{523		return null524	}525}526/**527 * Directories that should not be processed when building.528 */529exports.getAppDontBuildDirs = function(appPath)530{531	var settings = readAppSettings(appPath)532	if (settings)533	{534		return settings['dont-build']535	}536	else537	{538		return null539	}540}541/**542 * Get the app HTML file short path (relative to project root).543 */544exports.getIndexFileShortPath = function(appPath)545{546	var appDirPath = exports.getAppDir(appPath)547	var indexPath = exports.getIndexFile(appPath)548	if (appDirPath && indexPath)549	{550		return PATH.join(appDirPath, indexPath)551	}552	else if (indexPath)553	{554		return indexPath555	}556	else557	{558		return null559	}560}561/**562 * Get the full HTML file path for the app.563 */564exports.getIndexFileFullPath = function(appPath) {565	var indexShortPath = exports.getIndexFileShortPath(appPath)566	if (indexShortPath)567	{568		return PATH.join(appPath, indexShortPath)569	}570	else571	{572		return null573	}574}575/**576 * Read settings file and return data object, or null if settings file is missing.577 */578function readAppSettings(appPath) {579	var path = PATH.join(appPath, 'evothings.json')580	if (FS.existsSync(path)) {581		var json = FILEUTIL.readFileSync(path)582		try {583  		var settings = JSON.parse(json)584  	} catch(error) {585  	  window.alert(`The file "${path}" does not parse correctly, check it with a JSON linter: ${error}`)586  	  return null587  	}588		migrateSettings(settings, appPath)589		return settings590	} else {591		return null592	}593}594function migrateSettings(settings, appPath) {595  // Migrate to new names596  if (settings['app-uuid']) {597  	settings['uuid'] = settings['app-uuid']598  	delete settings['app-uuid']599		writeAppSettings(settings, appPath)600  }	601  if (settings['app-icon']) {602  	settings['icon'] = settings['app-icon']603  	delete settings['app-icon']604		writeAppSettings(settings, appPath)605  }606  if (settings['app-doc-url']) {607  	settings['doc-url'] = settings['app-doc-url']608  	delete settings['app-doc-url']609		writeAppSettings(settings, appPath)610  }611}612/**613 * Write settings file in JSON format.614 */615function writeAppSettings(settings, appPath) {616	var path = PATH.join(appPath, 'evothings.json')617	var data = JSON.stringify(settings, null, 2)618	FS.writeFileSync(path, data, {encoding: 'utf8'})...

Full Screen

Full Screen

main.js

Source:main.js Github

copy

Full Screen

1var URL_COUNT = 5;23var imageUrl = new Array();4for (var i = 0; i < URL_COUNT; i++)5{6  imageUrl.push(new Array());7}89var tumblrUrl = new Array();10for (var i = 0; i < URL_COUNT; i++)11{12  tumblrUrl.push("http://note.quellencode.org/");13}1415var index = -1;16var tumblrIndex = 0;17var timer;18var retryTimer;19var fadeInterval = 1200;20var isUseFade = true;21var isLoadedXml = false;22var interval = 10;23var mouseState = false;24var showStatus = false;2526System.Gadget.settingsUI = "setting.html";2728function view_onOpen()29{30  System.Debug.outputString(tumblrUrl[0]);31  System.Debug.outputString("view_onOpen()");32  document.imgBox.src = "images/connection_error.png";33  HideControls();3435  ReadSettings();3637  System.Debug.outputString("Init variables");38  clearTimeout(retryTimer);39  clearInterval(timer);40  isLoadedXml = false;41  showStatus = false;42  index = -1;4344  System.Debug.outputString("Begin Main Loop");45  for (var l = 0; l < URL_COUNT; l++)46  {47    var imageCache = new Array();48    System.Debug.outputString("peropero");4950    try51    {52      httpClient = new XMLHttpRequest();53      httpClient.open("GET", tumblrUrl[l] + "api/read?type=photo&num=50", false);54      httpClient.setRequestHeader("If-Modified-Since", "Thu, 01 Jun 1970 00:00:00 GMT");55      httpClient.send(null);5657      if (httpClient.status == 200)58      {59        var domRoot = httpClient.responseXML;60        for (var i = 0; domRoot.childNodes[1].childNodes[i] != null; i++)61        {62          var element = domRoot.childNodes[1].childNodes[i];63          if (element.nodeName == "posts")64          {65            for (var j = 0; element.childNodes[j] != null; j++)66            {67              var element2 = element.childNodes[j];68              for (var k = 0; element2.childNodes[k] != null; k++)69              {70                var element3 = element2.childNodes[k];71                if (element3.nodeName == "photo-url")72                {73                  var attribute = element3.getAttribute('max-width');74                  if (attribute == "400")75                  {76                    imageUrl[l].push("" + element3.firstChild.nodeValue);77                    //System.Debug.outputString(imageUrl[l]);78                  }79                }80              }81            }82          }83        }8485        showStatus = true;86        timer = setInterval(RefreshImage, parseInt(interval) * 1000);87        isLoadedXml = true;88        RefreshImage();89      }90      else91      {92        document.imgBox.src = "images/connection_error.gif";93        retryTimer = setTimeout(view_onOpen, 5000);94      }95    }96    catch (e)97    {98      document.imgBox.src = "images/connection_error.gif";99      retryTimer = setTimeout(view_onOpen, 5000);100    }101  }102}103104function ReadSettings()105{106  System.Debug.outputString("ReadSettings()");107  if (System.Gadget.Settings.readString("interval") != "")108  {109    System.Debug.outputString("ReadSettings(): Datas exist");110    tumblrUrl[0] = System.Gadget.Settings.readString("url1");111    tumblrUrl[1] = System.Gadget.Settings.readString("url2");112    tumblrUrl[2] = System.Gadget.Settings.readString("url3");113    tumblrUrl[3] = System.Gadget.Settings.readString("url4");114    tumblrUrl[4] = System.Gadget.Settings.readString("url5");115    interval = parseInt(System.Gadget.Settings.readString("interval"));116    isUseFade = System.Gadget.Settings.read("isUseFade");117  }118  else119  {120    System.Debug.outputString("ReadSettings(): Datas not exist");121    System.Gadget.Settings.writeString("url1", tumblrUrl[0]);122    System.Gadget.Settings.writeString("url2", tumblrUrl[1]);123    System.Gadget.Settings.writeString("url3", tumblrUrl[2]);124    System.Gadget.Settings.writeString("url4", tumblrUrl[3]);125    System.Gadget.Settings.writeString("url5", tumblrUrl[4]);126    System.Gadget.Settings.writeString("interval", interval);127    System.Gadget.Settings.write("isUseFade", isUseFade);128  }129130  _debug_showUrl();131}132133function _debug_showUrl()134{135  System.Debug.outputString("URL");136  System.Debug.outputString(System.Gadget.Settings.readString("url1"));137  System.Debug.outputString(System.Gadget.Settings.readString("url2"));138  System.Debug.outputString(System.Gadget.Settings.readString("url3"));139  System.Debug.outputString(System.Gadget.Settings.readString("url4"));140  System.Debug.outputString(System.Gadget.Settings.readString("url5"));141}142143function HideControls()144{145  $(".previousButton").hide();146  $(".centerButton").hide();147  $(".nextButton").hide();148}149150function ShowControls()151{152  $(".previousButton").show();153  $(".centerButton").show();154  $(".nextButton").show();155}156157function SetTimer()158{159  if (timer != null)160  {161    timer = setInterval(RefreshImage, parseInt(interval) * 1000);162  }163}164165function RefreshImage()166{167  imgBox.onload = AppearImage;168  index++;169  ChangeImage();170}171172function ChangeImage()173{174  if (index > 49)175  {176    index = 0;177  }178  else if (index < 0)179  {180    index = 49;181  }182183  clearInterval(timer);184  $(".imgBox").hide();185  document.imgBox.src = imageUrl[index];186}187188function AppearImage()189{190  imgBox.onload = null;191192  if (isUseFade)193  {194    $(".imgBox").fadeIn(fadeInterval);195  }196  else197  {198   $(".imgBox").show();199  }200201  if (showStatus)202  {203    SetTimer();204    imgBox.onload = null;205  }206}207208209function ToggleViewState()210{211  if (showStatus)212  {213    showStatus = false;214    clearInterval(timer);215    document.centerButtonImage.src = "images/play_white.png";216  }217  else218  {219    showStatus = true;220    SetTimer();221    document.centerButtonImage.src = "images/stop_white.png";222  }223}224225function ShowPreviousImage()226{227  index--;228229  temp = isUseFade;230  isUseFade = false;231  ChangeImage();232  isUseFade = temp;233}234235function ShowNextImage()236{237  index++;238239  temp = isUseFade;240  isUseFade = false;241  ChangeImage();242  isUseFade = temp;243}244245function StopSlideShow()246{247  if (showStatus)248  {249    showStatus = false;250    clearInterval(timer);251    document.centerButtonImage.src = "images/play_gray.png";252  }253}254255function view_onOptionChanged()256{257  tumblrUrl = options("TumblrURL");258  interval = options("interval");259260  clearInterval(timer);261  view_onOpen();262}263264function view_onMouseOver()265{266  if (isLoadedXml)267  {268    ShowControls();269  }270}271272function view_onMouseOut()273{274  if (isLoadedXml)275  {276   HideControls();277  }278}279280function previous_onMouseOver()281{282  document.previousButtonImage.src = "images/previous_white.png";283  document.previousButtonImage.style.cursor = "hand";284}285286function previous_onMouseOut()287{288  document.previousButtonImage.src = "images/previous_gray.png";289  document.previousButtonImage.style.cursor = "default";290}291292function previous_onMouseDown()293{294  document.previousButtonImage.style.zoom = "105%";295}296297function previous_onMouseUp()298{299  document.previousButtonImage.style.zoom = "100%";300301  StopSlideShow();302  imgBox.onload = AppearImage;303  ShowPreviousImage();304}305306function center_onMouseOver()307{308  if (showStatus)309  {310    document.centerButtonImage.src = "images/stop_white.png";311  }312  else313  {314    document.centerButtonImage.src = "images/play_white.png";315  }316  document.centerButtonImage.style.cursor = "hand";317}318319function center_onMouseOut()320{321  if (showStatus)322  {323    document.centerButtonImage.src = "images/stop_gray.png";324  }325  else326  {327    document.centerButtonImage.src = "images/play_gray.png";328  }329  document.centerButtonImage.style.cursor = "default";330}331332function center_onMouseDown()333{334  document.centerButtonImage.style.zoom = "105%";335  ToggleViewState();336}337338function center_onMouseUp()339{340  document.centerButtonImage.style.zoom = "100%";341}342343function next_onMouseOver()344{345  document.nextButtonImage.src = "images/next_white.png";346  document.nextButtonImage.style.cursor = "hand";347}348349function next_onMouseOut()350{351  document.nextButtonImage.src = "images/next_gray.png";352  document.nextButtonImage.style.cursor = "default";353}354355function next_onMouseDown()356{357  document.nextButtonImage.style.zoom = "105%";358}359360function next_onMouseUp()361{362  document.nextButtonImage.style.zoom = "100%";363364  StopSlideShow();365  imgBox.onload = AppearImage;366  ShowNextImage();367}368369System.Gadget.onSettingsClosed = onSettingsClosed;370function onSettingsClosed(e)371{372  if (e.closeAction == e.Action.commit)373  {374    tumblrUrl[0] = System.Gadget.Settings.readString("url1");375    tumblrUrl[1] = System.Gadget.Settings.readString("url2");376    tumblrUrl[2] = System.Gadget.Settings.readString("url3");377    tumblrUrl[3] = System.Gadget.Settings.readString("url4");378    tumblrUrl[4] = System.Gadget.Settings.readString("url5");379    interval = parseInt(System.Gadget.Settings.readString("interval"));380    isUseFade = System.Gadget.Settings.read("isUseFade");381382    /* Debug */383    System.Debug.outputString("設定画面が閉じられました");384    System.Debug.outputString(System.Gadget.Settings.readString("url1");385    System.Debug.outputString(System.Gadget.Settings.readString("url2");386    System.Debug.outputString(System.Gadget.Settings.readString("url3");387    System.Debug.outputString(System.Gadget.Settings.readString("url4");388    System.Debug.outputString(System.Gadget.Settings.readString("url5");389  }390391  StopSlideShow();392  view_onOpen();393}394395System.Gadget.onShowSettings = onShow;396function onShow()397{398  StopSlideShow();
...

Full Screen

Full Screen

NB4.js

Source:NB4.js Github

copy

Full Screen

1//////////////////////////////////////////////////////////////////////////////////////////////////2/////////////////////////////////////////js pour NB4.html/////////////////////////////////////////3//////////////////////////////////////////////////////////////////////////////////////////////////4function Clic()5 {6	if (System.Gadget.Flyout.show==false)7	 {8		System.Gadget.Flyout.file="Flyout.html";9		location.reload();10		System.Gadget.Flyout.show=true;11	 }12 	else13	 {14		System.Gadget.Flyout.show=false;15	 }16 }17function taille()18 {19    document.body.style.width =130;20    document.body.style.height=67;21    document.body.style.margin=0;22 }23///////////////////////////////////////////////////////////////////////////////////////////////////24////////////////////////////////////////js pour Flyout.html////////////////////////////////////////25///////////////////////////////////////////////////////////////////////////////////////////////////26function Change_ip()27 {28		if ((System.Gadget.Settings.readString("WEBLOGIN") == "")||(System.Gadget.Settings.readString("WEBPASS") == ""))29		{30			System.Shell.execute("erreur.vbs", "", System.Gadget.path);31			return;32		}33		else34		{35			var WEBLOGIN = System.Gadget.Settings.readString("WEBLOGIN");36			var WEBPASS = System.Gadget.Settings.readString("WEBPASS");37			var IP = System.Gadget.Settings.readString("IP");38			var random = Math.floor(Math.random() * 99999)+1;39		}40	41	if (System.Gadget.Settings.readString("theme") == "nb6.png")42	{43		var Fonction="-q http://" + IP + "/login --referer=\"http://" + IP + "/login?page_ref=/network/wan\"  http://" + IP + "/network/wan --post-data=\"method=passwd&zsid=&login=" + WEBLOGIN + "&password=" + WEBPASS + "&submit_button&ppp_login=&ppp_password=" + random + "\" -O NUL:";44		System.Shell.execute("wget.exe", Fonction, System.Gadget.path);45	}46	else47	{48		var Fonction="-q http://" + IP + "/login --referer=\"http://" + IP + "/login?page_ref=/network/wan\"  http://" + IP + "/network/wan --post-data=\"method=passwd&zsid=&login=" + WEBLOGIN + "&password=" + WEBPASS + "&submit_button&ppp_login=&ppp_password=" + random + "\" -O NUL:";49		System.Shell.execute("wget.exe", Fonction, System.Gadget.path);50		var Fonction="-q http://" + IP + "/0_2 --referer=\"http://" + IP + "/0_2?page_ref=/2_1\"  http://" + IP + "/2_1 --post-data=\"method=passwd&web_challenge=&web_login=" + WEBLOGIN + "&web_password=" + WEBPASS + "&submit_button&net_infra=adsl&net_mode=router&ppp_login=&ppp_password=" + random + "\" -O NUL:";51		System.Shell.execute("wget.exe", Fonction, System.Gadget.path);52	}53	54	masquer()55 }56function IP() {57	TD = document.getElementById('ip_externe');58	TXT=document.createTextNode("Chargement...");59	TD.appendChild(TXT);60	document.getElementById('ip_externe').appendChild(TD);61	var IP = System.Gadget.Settings.readString("IP");62	var doc ="http://"+IP+"/api/?method=ppp.getInfo";63	var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");64	xmlDoc.async = false;65	if (xmlDoc.load(doc))66	 {67		var Results = xmlDoc.selectSingleNode("/rsp/ppp/@ip_addr").text;68		if (Results == "")69		 {70			var element = document.getElementById('ip_externe');71			while (element.firstChild) {element.removeChild(element.firstChild);}72			TD = document.getElementById('ip_externe');73			TXT=document.createTextNode("Pas de connexion");74			TD.appendChild(TXT);75			document.getElementById('ip_externe').appendChild(TD);76		 }77		else78		 {79			var element = document.getElementById('ip_externe');80			while (element.firstChild) {element.removeChild(element.firstChild);}81			TD = document.getElementById('ip_externe');82			TXT=document.createTextNode(Results);83			TD.appendChild(TXT);84			document.getElementById('ip_externe').appendChild(TD);85			CheckForUpdate()86		 }87	 }88	else89	 {90		var element = document.getElementById('ip_externe');91		while (element.firstChild) {element.removeChild(element.firstChild);}92		TD = document.getElementById('ip_externe');93		TXT=document.createTextNode("Pas de connexion");94		TD.appendChild(TXT);95		document.getElementById('ip_externe').appendChild(TD);96	 }97	xmlDoc=null;98}99function CheckForUpdate()100{101if (System.Gadget.Settings.readString("update")!= "False")102	{103		var doc ="http://nbreboot.sylvainmenu.com/version.php";104		var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");105		xmlDoc.async = false;106		xmlDoc.onreadystatechange = function() {107		if(xmlDoc.readyState == 4 && xmlDoc.status==200){}};108			if(xmlDoc.load(doc))109			 {110				var Results = xmlDoc.selectSingleNode("/gadget/@version").text;111				xmlDoc=null;112				if(Results > System.Gadget.version)113					 {114						var element = document.getElementById('ip_externe');115						while (element.firstChild) {element.removeChild(element.firstChild);}116						TD = document.getElementById('ip_externe');117						TXT=document.createTextNode("Mise à jour disponible");118						TD.appendChild(TXT);119						document.getElementById('ip_externe').replaceChild(TD);120					 }121			 }122	}123}124function CheckForUpdate2(){125	var xhr = getXhr()126	xhr.onreadystatechange = function(){127		if(xhr.readyState == 4 && xhr.status == 200){128			var xmlDoc = xhr.responseXML;129			var Results = xmlDoc.selectSingleNode("/gadget/@version").text;130				if(Results > System.Gadget.version)131					 {132						var element = document.getElementById('ip_externe');133						while (element.firstChild) {element.removeChild(element.firstChild);}134						TD = document.getElementById('ip_externe');135						TXT=document.createTextNode("Mise à jour disponible");136						TD.appendChild(TXT);137						document.getElementById('ip_externe').replaceChild(TD);138					 }139		}140	}141	xhr.open("GET","http://nbreboot.sylvainmenu.com/version.php" ,true);142	//xhr.open("GET","gadget.xml" ,true);143	xhr.send(null);144}145function site()146 {147	if(ip_externe.innerText == "Mise à jour disponible")148	 {149		System.Shell.execute("http://nbreboot.sylvainmenu.com/");150	 }151	else152	 {153		if (System.Gadget.Settings.readString("IP") == "")154		 {155			var IP="192.168.1.1";156		 }157		else158		 {159			var IP = System.Gadget.Settings.readString("IP");160		 }	161		System.Shell.execute("http://" + IP);162	 }163 }164///////////////////////////////////////////////////////////////////////////////////////////////////165///////////////////////////////////////js pour settings.html///////////////////////////////////////166///////////////////////////////////////////////////////////////////////////////////////////////////167function init()168 {169	var temp = System.Gadget.Settings.readString("WEBLOGIN");170	if (temp  != "") {Weblogin.innerText = temp ;}171	else Weblogin.innerText = "admin"172	var temp = System.Gadget.Settings.readString("WEBPASS");173	if (temp  != "") {Webpass.innerText = temp ;}174	var temp = System.Gadget.Settings.readString("IP");175	if (temp  != "") {Ip.innerText = temp ;}176	else Ip.innerText = "192.168.1.1"177	Themes.value = System.Gadget.Settings.read("theme");178	displayTheme2()179	180	var up = System.Gadget.Settings.readString("update");181	if ((up  != "True")&&(up  != "False")) {autoupdate.checked = true}182	if (up  == "True") {autoupdate.checked = true}183	if (up  == "False") {autoupdate.checked = false}184 }185function Save() 186 {187	System.Gadget.Settings.writeString("WEBLOGIN", Weblogin.value);188	System.Gadget.Settings.writeString("WEBPASS", Webpass.value);189	System.Gadget.Settings.writeString("IP", Ip.value);190	System.Gadget.Settings.writeString("theme", Themes.value);191	System.Gadget.Settings.writeString("update", autoupdate.checked);192 }193System.Gadget.onSettingsClosing = SettingsClosing;194function SettingsClosing(event)195{196	if (event.closeAction == event.Action.commit) {Save();}197	event.cancel = false;198}199 function change_onglet(name)200{201	document.getElementById('onglet_'+anc_onglet).className = 'onglet_0 onglet';202	document.getElementById('onglet_'+name).className = 'onglet_1 onglet';203	document.getElementById('contenu_onglet_'+anc_onglet).style.display = 'none';204	document.getElementById('contenu_onglet_'+name).style.display = 'block';205	anc_onglet = name;206}207function displayTheme()208{209 		if(System.Gadget.Settings.readString("theme") == "")210		{211			System.Gadget.Settings.writeString("theme", "sfr.png");212		}213	imgBackground.src = "images/" + System.Gadget.Settings.readString("theme");214}215function displayTheme2()216{217	imgBackground.src = "images/" + Themes.value;...

Full Screen

Full Screen

settings.js

Source:settings.js Github

copy

Full Screen

1function onShow()2{3  System.Debug.outputString("onShow()");4  System.Debug.outputString(System.Gadget.Settings.readString("url1"));5  System.Debug.outputString(System.Gadget.Settings.readString("url2"));6  System.Debug.outputString(System.Gadget.Settings.readString("url3"));7  System.Debug.outputString(System.Gadget.Settings.readString("url4"));8  System.Debug.outputString(System.Gadget.Settings.readString("url5"));910  document.settingForm.baseUrl1.value = System.Gadget.Settings.readString("url1");11  document.settingForm.baseUrl2.value = System.Gadget.Settings.readString("url2");12  document.settingForm.baseUrl3.value = System.Gadget.Settings.readString("url3");13  document.settingForm.baseUrl4.value = System.Gadget.Settings.readString("url4");14  document.settingForm.baseUrl5.value = System.Gadget.Settings.readString("url5");15  document.settingForm.intervalBox.value = parseInt(System.Gadget.Settings.readString("interval"));16  document.settingForm.isFade.checked = System.Gadget.Settings.read("isUseFade");17}1819System.Gadget.onSettingsClosing = onSettingsClosing;20function onSettingsClosing(e)21{22  if (e.closeAction == e.Action.commit)23  {24    var isVailed = true;25    var HTTP = "http://"    /* CONST!!! */2627    if (parseInt(document.settingForm.intervalBox.value) < 10 ||28        !isFinite(parseInt(document.settingForm.intervalBox.value)))29    {30      document.settingForm.intervalBox.value = "10";31      AbortCloseWindow(new Array(e), new Array(isVailed));32    }33    if (document.settingForm.baseUrl1.value != "" &&34      document.settingForm.baseUrl1.value.indexOf(HTTP) == -1)35    {36      SetMessageCorrectUrl(document.settingForm.baseUrl1);37      AbortCloseWindow(new Array(e), new Array(isVailed));38    }39    if (document.settingForm.baseUrl2.value != "" &&40      document.settingForm.baseUrl2.value.indexOf(HTTP) == -1)41    {42      SetMessageCorrectUrl(document.settingForm.baseUrl2);43      AbortCloseWindow(new Array(e), new Array(isVailed));44    }45    if (document.settingForm.baseUrl3.value != "" &&46      document.settingForm.baseUrl3.value.indexOf(HTTP) == -1)47    {48      SetMessageCorrectUrl(document.settingForm.baseUrl3);49      AbortCloseWindow(new Array(e), new Array(isVailed));50    }51    if (document.settingForm.baseUrl4.value != "" &&52      document.settingForm.baseUrl4.value.indexOf(HTTP) == -1)53    {54      SetMessageCorrectUrl(document.settingForm.baseUrl4);55      AbortCloseWindow(new Array(e), new Array(isVailed));56    }57    if (document.settingForm.baseUrl5.value != "" && 58      document.settingForm.baseUrl5.value.indexOf(HTTP) == -1)59    {60      SetMessageCorrectUrl(document.settingForm.baseUrl5);61      AbortCloseWindow(new Array(e), new Array(isVailed));62    }6364    if (isVailed)65    {66      WriteSettings();67    }68  }69}7071function WriteSettings()72{73  System.Gadget.Settings.writeString("interval", document.settingForm.intervalBox.value);74  System.Gadget.Settings.write("isUseFade", document.settingForm.isFade.checked);75  System.Gadget.Settings.writeString("url1", document.settingForm.baseUrl1.value);76  System.Gadget.Settings.writeString("url2", document.settingForm.baseUrl2.value);77  System.Gadget.Settings.writeString("url3", document.settingForm.baseUrl3.value);78  System.Gadget.Settings.writeString("url4", document.settingForm.baseUrl4.value);79  System.Gadget.Settings.writeString("url5", document.settingForm.baseUrl5.value);80}8182function SetMessageCorrectUrl(input)83{84  input.value = "ここに正しいURLをいれてください";85}8687function AbortCloseWindow(e, isVailed)88{89  e[0].cancel = true;90  isVailed[0] = false;
...

Full Screen

Full Screen

bridgeNewsService.js

Source:bridgeNewsService.js Github

copy

Full Screen

1angular.module('bridge.service').service('bridge.service.bridgeNews', ['$http', 'bridgeDataService', 'bridgeInstance', function ($http, bridgeDataService, bridgeInstance) {2    var that = this;3    this.news = {};4    this.isInitialized = false;5    this.selectedNews = null;6    this.modalInstance = null;7    this.initialize = function(){8        var loadNewsPromise = $http({ method: 'GET', url: 'https://ifp.wdf.sap.corp/sap/bc/bridge/GET_NOTIFICATIONS?instance=' + bridgeInstance.getCurrentInstance()});9        loadNewsPromise.then(function(response) {10            that.news.data = response.data.NOTIFICATIONS.map(11                function(item) {12                    // yyyy-mm-dd13                    var time = item.TIMESTAMP.toString();14                    var dateString = time.substring(0, 4) + '-' + time.substring(4, 6) + '-' + time.substring(6, 8);15                    return {16                        id: item.ID,17                        header: item.HEADER,18                        date: dateString,19                        snapURL: item.SNAPURL,20                        preview: item.PREVIEW,21                        content: item.CONTENT,22                        instance: item.INSTANCE23                    };24                });25            that.isInitialized = true;26        });27        return loadNewsPromise;28    };29    this.existUnreadNews = function(){30        var readNews = bridgeDataService.getBridgeSettings().readNews;31        if (that.isInitialized === false){32            return false;33        }34        for (var i = 0; i < that.news.data.length; i++){35            if (!_.contains(readNews, that.news.data[i].id)){36                return true;37            }38        }39        return false;40    };41    this.getUnreadNews = function(){42        var readNews = bridgeDataService.getBridgeSettings().readNews;43        var unreadNews = [];44        for (var i = 0; i < that.news.data.length; i++){45            if (!_.contains(readNews, that.news.data[i].id)){46                unreadNews.push(that.news.data[i]);47            }48        }49        return unreadNews;50    };51    this.markAllNewsAsRead = function() {52        var bridgeSettings = bridgeDataService.getBridgeSettings();53        if (bridgeSettings.readNews === undefined){54            bridgeSettings.readNews = [];55        } else {56            bridgeSettings.readNews.length = 0;57        }58        for (var i = 0; i < this.news.data.length; i++){59            bridgeSettings.readNews.push(this.news.data[i].id);60        }61    };62    this.markItemAsRead = function(newsItem) {63        var bridgeSettings = bridgeDataService.getBridgeSettings();64        if (bridgeSettings.readNews === undefined) {65            bridgeSettings.readNews = [];66        }67        bridgeSettings.readNews.push(newsItem.id);68    };...

Full Screen

Full Screen

gadget.js

Source:gadget.js Github

copy

Full Screen

1// ------------------------------------------------------2// Copyright (C) 2007 Oekosoft3// ------------------------------------------------------4// ------------------------------------------------------5// Gadget6// ------------------------------------------------------7function pageLoad() {8    System.Gadget.settingsUI = 'settings.html';9    System.Gadget.onSettingsClosed = settingsClosed; 10         11    var myurl = System.Gadget.Settings.readString("webCamUrl");12    if (myurl == "") {13          myurl = 'http://meteoinfo.by/radar/UMMN/UMMN_latest.png';14          System.Gadget.Settings.writeString("webCamUrl", myurl);15    }16    myurl = myurl+"?"+new Date().getTime();17    var mydiv = document.getElementById('gadget');18    mydiv.innerHTML = "<a href='"+myurl+"'><img id='photo' src='"+myurl+"' class='layer' border=0></a>";19    startTimeout();20 }21function settingsClosed(p_event) {22    pageLoad();23}24function eraseTimeout() {25    clearTimeout (isTiming);26    isTiming = false;27}28function startTimeout() {29    var myrefresh = System.Gadget.Settings.readString("refreshTime");30    if (myrefresh == "") {31          myrefresh = '300';32          System.Gadget.Settings.writeString("refreshTime", myrefresh);33    }34    isTiming = setTimeout("refresh()", myrefresh*1000);35}36function refresh() {37    eraseTimeout();38    pageLoad();39}40// ------------------------------------------------------41// Settings42// ------------------------------------------------------43function loadSettings()44{45    System.Gadget.onSettingsClosing = settingsClosing; 46    var currentSetting = System.Gadget.Settings.readString("webCamUrl");47    if (currentSetting != "") {48        webUrl.innerText = currentSetting;49    }50    currentSetting = System.Gadget.Settings.readString("refreshTime");51    if (currentSetting != "") {52        refreshTime.innerText = currentSetting;53    }54}55function settingsClosing(event)56{57    if (event.closeAction == event.Action.commit) {58        System.Gadget.Settings.writeString("webCamUrl", webUrl.value);59        System.Gadget.Settings.writeString("refreshTime", refreshTime.value);60    }...

Full Screen

Full Screen

theme.js

Source:theme.js Github

copy

Full Screen

...13// tries to access the config() object before it is created.14function update(settings, configUrl) {15    // TODO: Pass the context into this method instead of hard coding internal: true?16    return when.all([17        settings.read('title'),18        settings.read('description'),19        settings.read('logo'),20        settings.read('cover')21    ]).then(function (globals) {22        // normalise the URL by removing any trailing slash23        themeConfig.url = configUrl.replace(/\/$/, '');24        themeConfig.title = globals[0].settings[0].value;25        themeConfig.description = globals[1].settings[0].value;26        themeConfig.logo = globals[2].settings[0] ? globals[2].settings[0].value : '';27        themeConfig.cover = globals[3].settings[0] ? globals[3].settings[0].value : '';28        return;29    });30}31module.exports = theme;...

Full Screen

Full Screen

settingsReader.js

Source:settingsReader.js Github

copy

Full Screen

1define(['models/templateSettings'], function (TemplateSettings) {2    var ticks = new Date().getTime();3    function readTemplateSettings() {4        return read('settings.js?_=' + ticks)5            .then(function (result) {6                return new TemplateSettings(result);7        });8    }9    function readPublishSettings() {10        return read('publishSettings.js?_=' + ticks);11    }12    function read(filename) {13        var defer = Q.defer();14        $.getJSON(filename).then(function (json) {15            defer.resolve(json);16        }).fail(function () {17            defer.resolve({});18        });19        return defer.promise;20    }21    return {22        readTemplateSettings: readTemplateSettings,23        readPublishSettings: readPublishSettings24    };...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const settings = require('cypress-failed-log/src/settings');2const settings = require('cypress-failed-log/src/settings');3const settings = require('cypress-failed-log/src/settings');4const settings = require('cypress-failed-log/src/settings');5const settings = require('cypress-failed-log/src/settings');6const settings = require('cypress-failed-log/src/settings');7const settings = require('cypress-failed-log/src/settings');8const settings = require('cypress-failed-log/src/settings');9const settings = require('cypress-failed-log/src/settings');10const settings = require('cypress-failed-log/src/settings');11const settings = require('cypress-failed-log/src/settings');12const settings = require('cypress-failed-log/src/settings');13const settings = require('cypress-failed-log/src/settings');14const settings = require('cypress-failed-log/src/settings');15const settings = require('cypress-failed-log/src/settings');16const settings = require('cypress-failed-log/src/settings');17const settings = require('cypress-failed-log/src/settings');18const settings = require('cypress-failed-log/src/settings');19const settings = require('cypress-failed-log/src/settings');20const settings = require('cypress-failed-log/src/settings');21const settings = require('cypress-failed-log/src/settings');22const settings = require('cypress-failed-log/src/settings');

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('test', () => {2  it('test', () => {3    const path = require('path');4    const settings = require('electron-settings');5    const configPath = path.join('cypress', 'fixtures', 'config.json');6    settings.setPath(configPath);7    const value = settings.read('api.url');8    cy.log(value);9  });10});11{12  "api": {13  }14}

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('Test', function() {2  it('should work', function() {3    cy.settings().then(settings => {4      const { width, height } = settings.viewportSize;5      cy.viewport(width, height);6    });7  });8});9Cypress.Commands.add('settings', () => {10  return cy.readFile('cypress.json');11});12{13  "viewportSize": {14  }15}

Full Screen

Using AI Code Generation

copy

Full Screen

1const settings = require('../fixtures/settings.json')2describe('Test', () => {3    it('Test', () => {4        cy.visit(settings.url)5        cy.get('input').type(settings.username)6    })7})

Full Screen

Using AI Code Generation

copy

Full Screen

1describe("Read settings file", function() {2  it("Reads the settings file", function() {3    cy.readFile("cypress/fixtures/settings.json").then((settings) => {4      cy.log(settings);5      cy.log(settings.test);6      cy.log(settings.test1);7      cy.log(settings.test2);8      cy.log(settings.test3);9      cy.log(settings.test4);10    });11  });12});

Full Screen

Cypress Tutorial

Cypress is a renowned Javascript-based open-source, easy-to-use end-to-end testing framework primarily used for testing web applications. Cypress is a relatively new player in the automation testing space and has been gaining much traction lately, as evidenced by the number of Forks (2.7K) and Stars (42.1K) for the project. LambdaTest’s Cypress Tutorial covers step-by-step guides that will help you learn from the basics till you run automation tests on LambdaTest.

Chapters:

  1. What is Cypress? -
  2. Why Cypress? - Learn why Cypress might be a good choice for testing your web applications.
  3. Features of Cypress Testing - Learn about features that make Cypress a powerful and flexible tool for testing web applications.
  4. Cypress Drawbacks - Although Cypress has many strengths, it has a few limitations that you should be aware of.
  5. Cypress Architecture - Learn more about Cypress architecture and how it is designed to be run directly in the browser, i.e., it does not have any additional servers.
  6. Browsers Supported by Cypress - Cypress is built on top of the Electron browser, supporting all modern web browsers. Learn browsers that support Cypress.
  7. Selenium vs Cypress: A Detailed Comparison - Compare and explore some key differences in terms of their design and features.
  8. Cypress Learning: Best Practices - Take a deep dive into some of the best practices you should use to avoid anti-patterns in your automation tests.
  9. How To Run Cypress Tests on LambdaTest? - Set up a LambdaTest account, and now you are all set to learn how to run Cypress tests.

Certification

You can elevate your expertise with end-to-end testing using the Cypress automation framework and stay one step ahead in your career by earning a Cypress certification. Check out our Cypress 101 Certification.

YouTube

Watch this 3 hours of complete tutorial to learn the basics of Cypress and various Cypress commands with the Cypress testing at LambdaTest.

Run Cypress automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful