Skip to content

Commit

Permalink
Adding code to generate system to figure out the threshold
Browse files Browse the repository at this point in the history
  • Loading branch information
gg64du02 committed May 24, 2018
1 parent be3d528 commit 1357354
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 2 deletions.
5 changes: 4 additions & 1 deletion TODO.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@

# TODO: See the memory threshold when it happens.
use: https://stackoverflow.com/questions/4009756/how-to-count-string-occurrence-in-string


# TODO: add a score number to notify the user that his script is to long,
therefore not be able to run on the DigiSpark!!!
w/ proper stylesheet ?
# TODO: See the memory threshold when it happens.

# TODO: Make it deployment friendly for a website (I don't know if it currently works)

Expand Down
41 changes: 40 additions & 1 deletion duckSpark.js_files/duckSpark.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ var keyMap = { // Normal keys
z:'KEY_Z'
};



//gg64du02
//debugger purpose
var numbers_of_character = 0;

class Dckuinojs {
constructor() {
this.keyMap = keyMap;
Expand All @@ -108,7 +114,33 @@ class Dckuinojs {
{
return false;
} // Returning the total uploadable script


//parsedDucky;
//gg64du02
//use: https://stackoverflow.com/questions/4009756/how-to-count-string-occurrence-in-string
//How to count string occurrence in string?
var temp = "This is a string.";
var count = (temp.match(/is/g) || []).length;
console.log("count:"+count);


console.log("DigiKeyboard.h:"+"1");
console.log("setup:"+"1");
console.log("pinmode:"+"2");

var count = (parsedDucky.match(/DigiKeyboard.delay/g) || []).length;
console.log("delay:"+count);

var count = (parsedDucky.match(/DigiKeyboard.sendKeyStroke/g) || []).length;
console.log("sendKeyStroke:"+count);

var count = (parsedDucky.match(/DigiKeyboard.println/g) || []).length;
console.log("println:"+count);


console.log("numbers_of_character (println):"+numbers_of_character);


return '/*\n'
+ ' * Generated with <3 by Dckuino.js, an open source project ! Please check the Nurrl github, and style sheet from Seytonic`s website Modified by gg64du02\n'
+ ' */\n\n'
Expand Down Expand Up @@ -147,6 +179,10 @@ class Dckuinojs {

// Cuting the input in lines
var lineArray = toParse.split('\n');

//gg64du02
//debugger purpose
numbers_of_character = 0;

// Loop every line
for (var i = 0; i < lineArray.length; i++)
Expand Down Expand Up @@ -189,6 +225,9 @@ class Dckuinojs {
{
parsedOut += ' DigiKeyboard.println("' + textString + '");\n';
commandKnown = true;
//gg64du02
//debugger purpose
numbers_of_character = numbers_of_character + textString.length;
} else {
console.error('Error: at line: ' + (i + 1) + ', STRING needs a text');
return;
Expand Down

0 comments on commit 1357354

Please sign in to comment.